phonebookui/Phonebook2/CommandsExtension/inc/CPbk2CopyContactsStarterCmd.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:  Phonebook 2 copy contacts starter command.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPBK2COPYCONTACTSSTARTERCMD_H
       
    20 #define CPBK2COPYCONTACTSSTARTERCMD_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <MPbk2Command.h>
       
    25 #include <MPbk2CommandObserver.h>
       
    26 #include <MVPbkContactStoreObserver.h>
       
    27 #include <CPbk2ContactUiControlSubstitute.h>
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class MPbk2ContactUiControl;
       
    31 class CVPbkContactStoreUriArray;
       
    32 class MVPbkContactStoreList;
       
    33 class CPbk2ApplicationServices;
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38  * Phonebook 2 copy contacts starter command.
       
    39  * Responsible for selecting target store and starting the real copy command.
       
    40  */
       
    41 NONSHARABLE_CLASS(CPbk2CopyContactsStarterCmd) : public CActive,
       
    42                                                   public MPbk2Command,
       
    43                                                   public MPbk2CommandObserver,
       
    44                                                   public MVPbkContactStoreObserver
       
    45     {
       
    46     public:  // Constructors and destructor
       
    47         
       
    48         /**
       
    49          * Creates a new instance of this class.
       
    50          *
       
    51          * @param aUiControl    UI control.
       
    52          * @return  A new instance of this class.
       
    53          */
       
    54         static CPbk2CopyContactsStarterCmd* NewL(
       
    55                 MPbk2ContactUiControl& aUiControl );
       
    56         
       
    57         /**
       
    58          * Destructor.
       
    59          */
       
    60         virtual ~CPbk2CopyContactsStarterCmd();
       
    61 
       
    62     public: // From MPbk2Command
       
    63         void ExecuteLD();
       
    64         void AddObserver(
       
    65                 MPbk2CommandObserver& aObserver );
       
    66         void ResetUiControl(
       
    67                 MPbk2ContactUiControl& aUiControl );
       
    68 
       
    69     protected: // From CActive
       
    70         void RunL();
       
    71         void DoCancel();
       
    72         TInt RunError(
       
    73                 TInt aError );
       
    74 
       
    75     private: // From MPbk2CommandObserver
       
    76         void CommandFinished(
       
    77                 const MPbk2Command& aCommand );
       
    78 
       
    79     private: // From MVPbkContactStoreObserver
       
    80         void StoreReady(
       
    81                 MVPbkContactStore& aContactStore );
       
    82         void StoreUnavailable(
       
    83                 MVPbkContactStore& aContactStore,
       
    84                 TInt aReason );
       
    85         void HandleStoreEventL(
       
    86                 MVPbkContactStore& aContactStore,
       
    87                 TVPbkContactStoreEvent aStoreEvent );
       
    88 
       
    89     private: // Implementation
       
    90         CPbk2CopyContactsStarterCmd(
       
    91                 MPbk2ContactUiControl& aUiControl );
       
    92         void ConstructL();
       
    93         static TInt IdleQueryCallbackL(
       
    94                 TAny* aSelf );
       
    95         void QueryL();
       
    96         void ExecuteCopyCommandL();
       
    97         void OpenStoresL();
       
    98         void InitCommandL();
       
    99         void IssueRequest();
       
   100         HBufC* GetQueryTitleLC();
       
   101         void HandleError(
       
   102                 TInt aError );
       
   103 
       
   104     private: // Data structures
       
   105         /// Copy starter states
       
   106         enum TPbk2CopyStarterState
       
   107             {
       
   108             EPbk2CopyOpenStores,
       
   109             EPbk2CopyStarterInit,
       
   110             EPbk2CopyStarterQuery,
       
   111             EPbk2CopyStarterExecuteCopy,
       
   112             EPbk2CopyStarterComplete
       
   113             };
       
   114 
       
   115         /// Number of contacts
       
   116         enum TNumOfContacts
       
   117             {
       
   118             EPbk2NoContacts         = 0,
       
   119             EPbk2OneContact         = 1
       
   120             };
       
   121 
       
   122     private: // Data
       
   123         /// Ref: UI control
       
   124         MPbk2ContactUiControl* iUiControl;
       
   125         /// Ref: The observer for completion of the command
       
   126         MPbk2CommandObserver* iCommandObserver;
       
   127         /// Own: An array of selected contacts
       
   128         MVPbkContactLinkArray* iSelectedContacts;
       
   129         /// Own: The actual command that does the job
       
   130         MPbk2Command* iExecutiveCommand;
       
   131         /// Own: Store control
       
   132         CPbk2ContactUiControlSubstitute* iStoreControl;
       
   133         /// Own: The URIs that are shown in the query
       
   134         CVPbkContactStoreUriArray* iTargetStoreUris;
       
   135         /// Own: The URIs of stores that failed to open
       
   136         CVPbkContactStoreUriArray* iFailedStoreUris;
       
   137         /// Own: Command state
       
   138         TInt iState;
       
   139         /// Ref: The global contact store list
       
   140         MVPbkContactStoreList* iStoreList;
       
   141         /// Own: Number of responded stores
       
   142         TInt iRespondedStores;
       
   143         /// Own: Application Services pointer
       
   144         CPbk2ApplicationServices* iAppServices;
       
   145         /// Own: Idle query launcher
       
   146         CIdle* iIdleQuery;
       
   147     };
       
   148 
       
   149 #endif // CPBK2COPYCONTACTSSTARTERCMD_H
       
   150             
       
   151 // End of File