phonebookui/Phonebook/View/src/CPbkContactEditorNewContact.cpp
changeset 0 e686773b3f54
child 21 9da50d567e3c
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002 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 *           Phonebook contact editor new contact strategy.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CPbkContactEditorNewContact.h"
       
    22 #include <coemain.h>
       
    23 #include <cntdef.h>
       
    24 #include <coehelp.h>
       
    25 #include <eikmenup.h>
       
    26 #include <bldvariant.hrh>
       
    27 #include <featmgr.h>
       
    28 #include <PbkView.rsg>
       
    29 #include "CPbkContactEngine.h"
       
    30 #include <CPbkFFSCheck.h>
       
    31 #include <avkon.hrh>
       
    32 #include <cshelp/phob.hlp.hrh>
       
    33 
       
    34 
       
    35 /// State flag values 
       
    36 enum TStateFlag
       
    37     {
       
    38     EInitialized,
       
    39     EContactSaved,
       
    40     EModified
       
    41     };
       
    42 
       
    43 // ================= MEMBER FUNCTIONS =======================
       
    44 
       
    45 inline CPbkContactEditorNewContact::CPbkContactEditorNewContact
       
    46         (CPbkContactEngine& aEngine, CPbkContactItem& aContactItem) :
       
    47 		iEngine(aEngine), iContactItem(aContactItem),
       
    48 		iContactId(KNullContactId)
       
    49 	{
       
    50 	}
       
    51 
       
    52 inline void CPbkContactEditorNewContact::ConstructL()
       
    53 	{
       
    54     CCoeEnv* coeEnv = CCoeEnv::Static();
       
    55 	iFFSCheck = CPbkFFSCheck::NewL(coeEnv);
       
    56 	iDefaultTitle = coeEnv->AllocReadResourceL(R_QTN_PHOB_TITLE_NEW_ENTRY);
       
    57 	}
       
    58 
       
    59 CPbkContactEditorNewContact* CPbkContactEditorNewContact::NewL
       
    60         (CPbkContactEngine& aEngine,
       
    61         CPbkContactItem& aContactItem)
       
    62 	{
       
    63 	CPbkContactEditorNewContact* self = new(ELeave) CPbkContactEditorNewContact(aEngine, aContactItem);
       
    64 	CleanupStack::PushL(self);
       
    65 	self->ConstructL();
       
    66 	CleanupStack::Pop(self);
       
    67 	return self;
       
    68 	}
       
    69 
       
    70 CPbkContactEditorNewContact::~CPbkContactEditorNewContact()
       
    71 	{
       
    72 	delete iDefaultTitle;
       
    73     delete iFFSCheck;
       
    74 	}
       
    75 
       
    76 TContactItemId CPbkContactEditorNewContact::SaveContactL()
       
    77 	{
       
    78     // Check that free FFS space is above critical level before saving to
       
    79     // database
       
    80     if (iStateFlags.IsSet(EModified) && !iStateFlags.IsSet(EContactSaved) &&
       
    81         iStateFlags.IsSet(EInitialized) && iFFSCheck->FFSClCheckL())
       
    82         {
       
    83         iContactId = iEngine.AddNewContactL(iContactItem, ETrue);
       
    84 		iStateFlags.Set(EContactSaved);
       
    85 		iStateFlags.Clear(EModified);
       
    86 		}
       
    87     return iContactId;
       
    88 	}
       
    89 
       
    90 void CPbkContactEditorNewContact::GetHelpContext
       
    91         (TCoeHelpContext& aContext) const
       
    92 	{
       
    93     aContext.iContext = KPHOB_HLP_ADD_ENTRY;
       
    94     }
       
    95 
       
    96 void CPbkContactEditorNewContact::SetStateModified()
       
    97     {
       
    98     iStateFlags.Set(EModified);
       
    99     }
       
   100 
       
   101 void CPbkContactEditorNewContact::SetStateInitialized()
       
   102     {
       
   103     iStateFlags.Set(EInitialized);
       
   104     }
       
   105 
       
   106 void CPbkContactEditorNewContact::DeleteContactL()
       
   107 	{
       
   108 	iStateFlags.Set(EContactSaved);
       
   109 	}
       
   110 
       
   111 const TDesC& CPbkContactEditorNewContact::DefaultTitle() const
       
   112 	{
       
   113 	return *iDefaultTitle;
       
   114 	}
       
   115 
       
   116 void CPbkContactEditorNewContact::DynInitMenuPaneL
       
   117         (TInt aResourceId, 
       
   118         CEikMenuPane* aMenuPane)
       
   119     {
       
   120     if (aResourceId == R_CONTACTEDITOR_MENUPANE)
       
   121         {
       
   122         if (!FeatureManager::FeatureSupported(KFeatureIdHelp)) 
       
   123             {
       
   124             // remove non-supported help from menu
       
   125             aMenuPane->SetItemDimmed(EAknCmdHelp, ETrue);
       
   126             }
       
   127         }
       
   128     }
       
   129 
       
   130 //  End of File