phonebookui/Phonebook2/UIControls/inc/CPbk2FetchResults.h
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
child 85 38bb213f60ba
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2005-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 fetch results.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPBK2FETCHRESULTS_H
       
    20 #define CPBK2FETCHRESULTS_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <MVPbkContactLinkArray.h>
       
    25 #include <MVPbkContactStoreObserver.h>
       
    26 #include <MVPbkSingleContactOperationObserver.h>
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class MVPbkContactLink;
       
    30 class MVPbkStreamable;
       
    31 class CVPbkContactLinkArray;
       
    32 class CVPbkContactManager;
       
    33 class MVPbkContactStoreList;
       
    34 class MPbk2FetchDlg;
       
    35 class MPbk2FetchDlgPages;
       
    36 class MPbk2FetchDlgObserver;
       
    37 class MPbk2FetchResultsObserver;
       
    38 class CAknInputBlock;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 
       
    42 /**
       
    43  * Phonebook 2 fetch results.
       
    44  * Responsible for managing fetch results
       
    45  */
       
    46 NONSHARABLE_CLASS(CPbk2FetchResults) : public CBase,
       
    47                                        public MVPbkContactLinkArray,
       
    48                                        private MVPbkSingleContactOperationObserver,
       
    49                                        private MVPbkContactStoreObserver
       
    50     {
       
    51     public: // Constructors and destructor
       
    52 
       
    53         /**
       
    54          * Creates a new instance of this class.
       
    55          *
       
    56          * @param aContactManager   Virtual Phonebook contact manager.
       
    57          * @param aFetchDlg         Fetch dialog.
       
    58          * @param aPages            Fetch dialog pages.
       
    59          * @param aObserver         Fetch dialog observer.
       
    60          * @param aResultsObserver  Results observer.
       
    61          * @return  A new instance of this class.
       
    62          */
       
    63         static CPbk2FetchResults* NewL(
       
    64                 CVPbkContactManager& aContactManager,
       
    65                 MPbk2FetchDlg& aFetchDlg,
       
    66                 MPbk2FetchDlgPages& aPages,
       
    67                 MPbk2FetchDlgObserver& aObserver,
       
    68                 MPbk2FetchResultsObserver& aResultsObserver );
       
    69 
       
    70         /**
       
    71          * Destructor
       
    72          */
       
    73         ~CPbk2FetchResults();
       
    74 
       
    75     public: // Interface
       
    76 
       
    77         /**
       
    78          * Appends a contact link to selection.
       
    79          *
       
    80          * @param aLink     The link to append.
       
    81          */
       
    82         void AppendL(
       
    83                 const MVPbkContactLink& aLink );
       
    84 
       
    85         /**
       
    86          * Appends a delayed contact link to selection.
       
    87          *
       
    88          * @param aLink     The link to append.
       
    89          */
       
    90         void AppendDelayedL(
       
    91                 const MVPbkContactLink& aLink );
       
    92 
       
    93         /**
       
    94          * Deny to Append a delayed contact link to selection.
       
    95          *
       
    96          * @param aLink     The link to deny append.
       
    97          */
       
    98         void DenyAppendDelayedL(
       
    99                 const MVPbkContactLink& aLink );
       
   100 
       
   101         /**
       
   102          * Appends a contact link to fetch results.
       
   103          *
       
   104          * @param aLink     The link to append.
       
   105          */
       
   106         void AppendToResultsL(
       
   107                 const MVPbkContactLink& aLink );
       
   108 
       
   109         /**
       
   110          * Removes a contact link from selection.
       
   111          *
       
   112          * @param aLink     The link to remove.
       
   113          */
       
   114         void RemoveL(
       
   115                 const MVPbkContactLink& aLink );
       
   116 
       
   117         /**
       
   118          * Resets the array and destroys the links.
       
   119          */
       
   120         void ResetAndDestroy();
       
   121 
       
   122         /**
       
   123          * Wait operations to complete
       
   124          */
       
   125         void WaitOperationsCompleteL();
       
   126     public: // From MVPbkContactLinkArray
       
   127         TInt Count() const;
       
   128         const MVPbkContactLink& At(
       
   129                 TInt aIndex ) const;
       
   130         TInt Find(
       
   131                 const MVPbkContactLink& aLink ) const;
       
   132         HBufC8* PackLC() const;
       
   133         const MVPbkStreamable* Streamable() const;
       
   134       
       
   135     private:   
       
   136         /**
       
   137          * Fetch Results Append- and Remove-Contact operation
       
   138          * representation 
       
   139          */
       
   140         class CFRConatactOperation : public CBase
       
   141             {
       
   142             public:
       
   143                 /**
       
   144                  * Contact Operation types
       
   145                  */
       
   146                 enum EOperationType
       
   147                     {
       
   148                     EAppendContact = 0x0,
       
   149                     EAppendContactDelayed,
       
   150                     ERemoveContact
       
   151                     };
       
   152                 
       
   153                 /**
       
   154                  * Creates a new instance of this class.
       
   155                  *
       
   156                  * @param aContactLink   MVPbkContactLink.
       
   157                  * @param aType          Operation type.
       
   158                  * @return  A new instance of this class.
       
   159                  */
       
   160                 static CFRConatactOperation* NewL(
       
   161                                   const MVPbkContactLink& aContactLink,
       
   162                                   const EOperationType aType );
       
   163                 
       
   164                 /**
       
   165                  * Destructor
       
   166                  */
       
   167                 ~CFRConatactOperation();
       
   168                 
       
   169                 // Get Contact Link
       
   170                 MVPbkContactLink* GetContactLink(){ return iContactLink; };
       
   171                 
       
   172                 // Get Operation Type
       
   173                 EOperationType GetOperationType(){ return iType; };
       
   174                   
       
   175             private:
       
   176                 CFRConatactOperation( const EOperationType aType );
       
   177                 void ConstructL( const MVPbkContactLink& aContactLink );
       
   178                 
       
   179             private:
       
   180                 MVPbkContactLink* iContactLink;
       
   181                 const EOperationType iType; 
       
   182             };
       
   183         
       
   184     private: // From MVPbkSingleContactOperationObserver
       
   185         void VPbkSingleContactOperationComplete(
       
   186                 MVPbkContactOperationBase& aOperation,
       
   187                 MVPbkStoreContact* aContact );
       
   188         void VPbkSingleContactOperationFailed(
       
   189                 MVPbkContactOperationBase& aOperation,
       
   190                 TInt aError );
       
   191 
       
   192     private: // From MVPbkContactStoreObserver
       
   193         void StoreReady(
       
   194                 MVPbkContactStore& aContactStore );
       
   195         void StoreUnavailable(
       
   196                 MVPbkContactStore& aContactStore,
       
   197                 TInt aReason );
       
   198         void HandleStoreEventL(
       
   199                 MVPbkContactStore& aContactStore,
       
   200                 TVPbkContactStoreEvent aStoreEvent );
       
   201 
       
   202     private: // Implementation
       
   203         CPbk2FetchResults(
       
   204                 CVPbkContactManager& aContactManager,
       
   205                 MPbk2FetchDlg& aFetchDlg,
       
   206                 MPbk2FetchDlgPages& aPages,
       
   207                 MPbk2FetchDlgObserver& aObserver,
       
   208                 MPbk2FetchResultsObserver& aResultsObserver );
       
   209         void ConstructL(
       
   210                 CVPbkContactManager& aContactManager );
       
   211         void DoAppendContactL(
       
   212                 MVPbkStoreContact& aContact,
       
   213                 TBool aDelayed );
       
   214         void DoRemoveContactL(
       
   215                 MVPbkStoreContact& aContact );
       
   216         void RemoveFromResultsL(
       
   217                 const MVPbkContactLink& aLink );
       
   218         TInt CountContactsL(
       
   219                 MVPbkStoreContact& aContact,
       
   220                 MVPbkContactLink& aLink );
       
   221         void HandleContactOperationCompleteL(
       
   222                 MVPbkContactOperationBase& aOperation,
       
   223                 MVPbkStoreContact* aContact );
       
   224         void ProcessNextContactOperationL();
       
   225         void AppendContactOperationL( CFRConatactOperation* aOperation );
       
   226         CFRConatactOperation* GetCurrentContactOperation( );
       
   227         void RemoveCurrentContactOperation( );
       
   228 
       
   229 
       
   230     private: // Data
       
   231         /// Own: Fetch results
       
   232         CVPbkContactLinkArray* iSelectedContacts;
       
   233         /// Ref: Virtual Phonebook contact manager
       
   234         CVPbkContactManager& iContactManager;
       
   235         /// Ref: Contact stores used
       
   236         MVPbkContactStoreList* iStoreList;
       
   237         /// Ref: Fetch dialog
       
   238         MPbk2FetchDlg& iFetchDlg;
       
   239         /// Ref: Fetch dialog pages
       
   240         MPbk2FetchDlgPages& iPages;
       
   241         /// Ref: Observer
       
   242         MPbk2FetchDlgObserver& iObserver;
       
   243         /// Ref: Results observer
       
   244         MPbk2FetchResultsObserver& iResultsObserver;
       
   245         /// Own: Contact-Operations queue
       
   246         CArrayFixFlat<CFRConatactOperation*>* iOperationQueue;
       
   247         /// Own: Contact retrieve operation
       
   248         MVPbkContactOperationBase* iRetrieveOperation;
       
   249         /// Own: Is it waiting the acceptance, initialized to EFalse
       
   250         TBool iWaitingForDelayedAppend;
       
   251         /// Own: Wait until finish contact store operation
       
   252         CActiveSchedulerWait* iWaitForAllOperationComplete;
       
   253         /// Own: User input blocker
       
   254         CAknInputBlock* iInputBlock;
       
   255     };
       
   256 
       
   257 #endif // CPBK2FETCHRESULTS_H
       
   258 
       
   259 // End of File