phonebookui/Phonebook2/CommandsExtension/src/CPbk2RemoveImageCmd.cpp
changeset 0 e686773b3f54
child 68 9da50d567e3c
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *           Remove image command event handling class.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CPbk2RemoveImageCmd.h"
       
    22 #include "CPbk2ImageManager.h"
       
    23 #include <Pbk2Commands.rsg>
       
    24 
       
    25 #include <AknQueryDialog.h>
       
    26 #include <MVPbkStoreContact.h>
       
    27 #include <MVPbkFieldType.h>
       
    28 
       
    29 #include <Pbk2Debug.h>
       
    30 
       
    31 
       
    32 // ================= MEMBER FUNCTIONS =======================
       
    33 
       
    34 CPbk2RemoveImageCmd::CPbk2RemoveImageCmd
       
    35         (MPbk2ContactUiControl& aUiControl) :
       
    36     CPbk2ImageCmdBase(aUiControl)
       
    37     {
       
    38     }
       
    39 
       
    40 void CPbk2RemoveImageCmd::ConstructL()
       
    41     {
       
    42     CPbk2ImageCmdBase::BaseConstructL();
       
    43     }
       
    44 
       
    45 CPbk2RemoveImageCmd* CPbk2RemoveImageCmd::NewL
       
    46         (MPbk2ContactUiControl& aUiControl)
       
    47     {
       
    48     CPbk2RemoveImageCmd* self = new (ELeave)
       
    49         CPbk2RemoveImageCmd(aUiControl);
       
    50     CleanupStack::PushL(self);
       
    51     self->ConstructL();
       
    52     CleanupStack::Pop(self);
       
    53     return self;
       
    54     }
       
    55 
       
    56 CPbk2RemoveImageCmd::~CPbk2RemoveImageCmd()
       
    57     {
       
    58     }
       
    59 
       
    60 TBool CPbk2RemoveImageCmd::ExecuteCommandL()
       
    61     {
       
    62     if( CAknQueryDialog::NewL()->ExecuteLD(
       
    63             R_PHONEBOOK2_REMOVE_IMAGE_CONFIRMATION_DIALOG ) )
       
    64         {
       
    65         // User has confirmed image removal
       
    66         TInt imageIndex = FindFieldIndex( *iImageFieldType );
       
    67         if ( imageIndex != KErrNotFound )
       
    68             {
       
    69             iStoreContact->RemoveField( imageIndex );
       
    70             }
       
    71         iImageManager->RemoveImage( *iStoreContact, *iThumbnailFieldType );
       
    72         }
       
    73     iStoreContact->CommitL( *this );
       
    74     return ETrue;
       
    75     }
       
    76 
       
    77 
       
    78 //  End of File