phonebookui/Phonebook2/USIMExtension/inc/CPsu2CopyToSimCmd.h
changeset 0 e686773b3f54
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:  A command for copying contacts to the (U)SIM store.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPSU2COPYTOSIMCMD_H
       
    20 #define CPSU2COPYTOSIMCMD_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <MPbk2Command.h>
       
    25 #include <MPbk2ProcessDecorator.h>
       
    26 #include <MVPbkSingleContactOperationObserver.h>
       
    27 #include <MVPbkContactObserver.h>
       
    28 #include <MVPbkContactStoreObserver.h>
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class MVPbkContactStore;
       
    32 class MVPbkContactOperationBase;
       
    33 class MVPbkFieldType;
       
    34 class CVPbkContactLinkArray;
       
    35 class CPbk2FieldPropertyArray;
       
    36 class MPbk2FieldProperty;
       
    37 class MPbk2ContactUiControl;
       
    38 class CPsu2CopyToSimFieldInfoArray;
       
    39 class CPsu2SimContactProcessor;
       
    40 class CVPbkFieldTypeRefsList;
       
    41 class CPsu2ContactCopyInspector;
       
    42 class CPbk2ApplicationServices;
       
    43 
       
    44 // CLASS DECLARATION
       
    45 
       
    46 /**
       
    47  *  A command for copying contacts to the (U)SIM store.
       
    48  */
       
    49 class CPsu2CopyToSimCmd :
       
    50         public CActive,
       
    51         public MPbk2Command,
       
    52         public MVPbkContactStoreObserver,
       
    53         private MVPbkSingleContactOperationObserver,
       
    54         private MVPbkContactObserver,
       
    55         private MPbk2ProcessDecoratorObserver
       
    56     {
       
    57     private:
       
    58         enum TSimSpaceStatus
       
    59             {
       
    60             ESimSpaceIsFull,
       
    61             ESimSpaceIsNotFull,
       
    62             ESimSpaceUnknown
       
    63             };
       
    64     public:  // Constructors and destructor
       
    65         /**
       
    66          * Two-phased constructor.
       
    67          *
       
    68          * @param aUiControl    UI control.
       
    69          * @param aTargetStore  The target store for the copied contacts.
       
    70          * @return A new instance of this class.
       
    71          */
       
    72         static CPsu2CopyToSimCmd* NewL(
       
    73                 MPbk2ContactUiControl& aUiControl,
       
    74                 MVPbkContactStore& aTargetStore);
       
    75 
       
    76         /**
       
    77          * Destructor.
       
    78          */
       
    79         ~CPsu2CopyToSimCmd();
       
    80 
       
    81     private: // From CActive
       
    82         void RunL();
       
    83         void DoCancel();
       
    84         TInt RunError( TInt aError );
       
    85 
       
    86     public: // From MPbk2Command
       
    87         void ExecuteLD();
       
    88         void AddObserver(MPbk2CommandObserver& aObserver);
       
    89         void ResetUiControl(MPbk2ContactUiControl& aUiControl);
       
    90     public: // From MVPbkContactStoreObserver
       
    91     	void StoreReady(MVPbkContactStore& aContactStore);
       
    92     	void StoreUnavailable(MVPbkContactStore& aContactStore, 
       
    93     	                TInt aReason);
       
    94     	void HandleStoreEventL(
       
    95     	                MVPbkContactStore& aContactStore, 
       
    96     	                TVPbkContactStoreEvent aStoreEvent);
       
    97             
       
    98     private: // From MVPbkSingleContactOperationObserver
       
    99         void VPbkSingleContactOperationComplete(
       
   100                 MVPbkContactOperationBase& aOperation,
       
   101                 MVPbkStoreContact* aContact);
       
   102         void VPbkSingleContactOperationFailed(
       
   103                 MVPbkContactOperationBase& aOperation,
       
   104                 TInt aError);
       
   105 
       
   106     private: // From MVPbkContactObserver
       
   107         void ContactOperationCompleted(
       
   108                 TContactOpResult aResult);
       
   109         void ContactOperationFailed(
       
   110                 TContactOp aOpCode,
       
   111                 TInt aErrorCode,
       
   112                 TBool aErrorNotified);
       
   113 
       
   114     private: // From MPbk2ProcessDecoratorObserver
       
   115         void ProcessDismissed(TInt aCancelCode);
       
   116 
       
   117     private: // Implementation
       
   118         CPsu2CopyToSimCmd(
       
   119                 MPbk2ContactUiControl& aUiControl,
       
   120                 MVPbkContactStore& aTargetStore);
       
   121         void ConstructL();
       
   122         void IssueRequest();
       
   123         void StartL();
       
   124         void HandleCanceling();
       
   125         void RetrieveSourceContactL();
       
   126         void CreateSimContactsL();
       
   127         void StartCopyL();
       
   128         void CopyCurrentContactL();
       
   129         void ShowResultsNoteL();
       
   130         void CompleteL();
       
   131         MVPbkStoreContact* NextSimContact();
       
   132         void HandleError(TInt aError);
       
   133         void MoveToNextContact();
       
   134         void CopyNextSimContact();
       
   135         void CompleteWithResults();
       
   136         // return current sim space status
       
   137         TSimSpaceStatus GetSimSpaceStatusL();
       
   138         // Show information note about SIM is full
       
   139         void ShowSimIsFullNoteL();
       
   140 
       
   141     private:  // Data
       
   142         /// Ref: UI control which can store or contact control
       
   143         MPbk2ContactUiControl* iUiControl;
       
   144         /// Ref: Parent control of the store list control
       
   145         MPbk2ContactUiControl* iNameListUiControl;
       
   146         /// Ref: The target (U)SIM store
       
   147         MVPbkContactStore& iTargetStore;
       
   148         /// Ref: Command observer
       
   149         MPbk2CommandObserver* iCommandObserver;
       
   150         /// Own: Selected contacts
       
   151         CVPbkContactLinkArray* iLinkArray;
       
   152         /// Own: An array of sim copy infos
       
   153         CPsu2CopyToSimFieldInfoArray* iCopyToSimTypeInfos;
       
   154         /// Own: Processes contacts to correct form
       
   155         CPsu2SimContactProcessor* iSimContactProcessor;
       
   156         /// Own: Decorator for the process
       
   157         MPbk2ProcessDecorator* iDecorator;
       
   158         /// Own: An operation to get a contact from the link
       
   159         MVPbkContactOperationBase* iContactRetriever;
       
   160         /// Own: The task that will be done next
       
   161         TInt iNextTask;
       
   162         /// Own: An index of the contact that is currently copied
       
   163         TInt iCurrentIndex;
       
   164         /// Own: The current source contact to copy
       
   165         MVPbkStoreContact* iCurrentSourceContact;
       
   166         /// Own: The current (U)SIM contact to copy
       
   167         MVPbkStoreContact* iCurrentSimContact;
       
   168         /// Own: An array of 'to be copied' sim contacts
       
   169         RPointerArray<MVPbkStoreContact> iSimContacts;
       
   170         /// Own: The number of copied contacts
       
   171         TInt iCopied;
       
   172         /// Own: The flag indicating if control should be updated after command
       
   173         ///      execution.
       
   174         TBool iUpdateControl;
       
   175         /// Own: The copy inspector
       
   176         CPsu2ContactCopyInspector* iContactInspector;
       
   177         /// Own: Flag indicating if all contacts were copied completely
       
   178         TBool iIsCopiedCompletely;
       
   179         /// Own: Flag indicating if the last contact copy was failed for memory  
       
   180         ///      full, this flag is used for the case we use the sim not 
       
   181         ///      providing its free space When it's full, its copy will fail.
       
   182         TBool iIsLastCopyFailedForSimIsFull;
       
   183         /// Own: The target store status.
       
   184         TInt iTargetStoreStatus;
       
   185 
       
   186         /// Own: Application Services pointer
       
   187         CPbk2ApplicationServices* iAppServices;
       
   188     };
       
   189 
       
   190 #endif // CPSU2COPYTOSIMCMD_H
       
   191 
       
   192 // End of File