phonebookui/Phonebook2/CommandsExtension/src/CPbk2RemoveImageCmd.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 14 Sep 2010 20:54:53 +0300
branchRCL_3
changeset 68 9da50d567e3c
parent 0 e686773b3f54
child 85 38bb213f60ba
permissions -rw-r--r--
Revision: 201033 Kit: 201035

/*
* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*           Remove image command event handling class.
*
*/


// INCLUDE FILES
#include "CPbk2RemoveImageCmd.h"
#include "CPbk2ImageManager.h"
#include <pbk2commands.rsg>

#include <AknQueryDialog.h>
#include <MVPbkStoreContact.h>
#include <MVPbkFieldType.h>

#include <Pbk2Debug.h>


// ================= MEMBER FUNCTIONS =======================

CPbk2RemoveImageCmd::CPbk2RemoveImageCmd
        (MPbk2ContactUiControl& aUiControl) :
    CPbk2ImageCmdBase(aUiControl)
    {
    }

void CPbk2RemoveImageCmd::ConstructL()
    {
    CPbk2ImageCmdBase::BaseConstructL();
    }

CPbk2RemoveImageCmd* CPbk2RemoveImageCmd::NewL
        (MPbk2ContactUiControl& aUiControl)
    {
    CPbk2RemoveImageCmd* self = new (ELeave)
        CPbk2RemoveImageCmd(aUiControl);
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop(self);
    return self;
    }

CPbk2RemoveImageCmd::~CPbk2RemoveImageCmd()
    {
    }

TBool CPbk2RemoveImageCmd::ExecuteCommandL()
    {
    if( CAknQueryDialog::NewL()->ExecuteLD(
            R_PHONEBOOK2_REMOVE_IMAGE_CONFIRMATION_DIALOG ) )
        {
        // User has confirmed image removal
        TInt imageIndex = FindFieldIndex( *iImageFieldType );
        if ( imageIndex != KErrNotFound )
            {
            iStoreContact->RemoveField( imageIndex );
            }
        iImageManager->RemoveImage( *iStoreContact, *iThumbnailFieldType );
        }
    iStoreContact->CommitL( *this );
    return ETrue;
    }


//  End of File