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