phonebookui/Phonebook2/ServerApplication/inc/CPbk2CommAddressSelectPhase.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 server app address select phase.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CPBK2COMMADDRESSSELECTPHASE_H
       
    20 #define CPBK2COMMADDRESSSELECTPHASE_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <badesca.h>
       
    24 #include <e32base.h>
       
    25 #include <MVPbkSingleContactOperationObserver.h>
       
    26 #include <MPbk2KeyEventHandler.h>
       
    27 #include "MPbk2ServicePhase.h"
       
    28 #include <VPbkFieldTypeSelectorFactory.h>
       
    29 #include <MVPbkOperationObserver.h>
       
    30 #include <mcontactpresenceobs.h>
       
    31 #include <MVPbkContactStoreObserver.h>
       
    32 
       
    33 // FORWARD DECLARATIONS
       
    34 class MVPbkContactLink;
       
    35 class CVPbkContactLinkArray;
       
    36 class MPbk2DialogEliminator;
       
    37 class MPbk2ServicePhaseObserver;
       
    38 class MVPbkContactOperationBase;
       
    39 class RVPbkContactFieldDefaultPriorities;
       
    40 class MVPbkStoreContact;
       
    41 class MVPbkStoreContactField;
       
    42 class CPbk2KeyEventDealer;
       
    43 class CEikonEnv;
       
    44 class CVPbkxSPContacts;
       
    45 class MContactPresence;
       
    46 class CPbk2PresenceIconInfo;
       
    47 
       
    48 // CLASS DECLARATION
       
    49 
       
    50 /**
       
    51  * Phonebook 2 server app address select phase.
       
    52  * Responsible for performing address select.
       
    53  */
       
    54 class CPbk2CommAddressSelectPhase : public CBase,
       
    55                     public MPbk2ServicePhase,
       
    56                     private MVPbkSingleContactOperationObserver,
       
    57                     private MPbk2KeyEventHandler,
       
    58                     public MVPbkOperationErrorObserver,
       
    59                     public MVPbkOperationResultObserver<MVPbkContactLinkArray*>,
       
    60                     public MContactPresenceObs,
       
    61                     public MVPbkContactStoreObserver
       
    62     {
       
    63     private:
       
    64         
       
    65         enum TState
       
    66             {
       
    67             // EInitialState -> EMainContactRetrieved
       
    68             EInitialState,
       
    69             // EMainContactRetrieved -> ExSPLinksRetrieved
       
    70             // EMainContactRetrieved -> EAddressSelectDone
       
    71             EMainContactRetrieved,
       
    72             // ExSPLinksRetrieved -> ExSPContactRetrieved 
       
    73             // ExSPLinksRetrieved -> EPresenceIconInfoRetrieved
       
    74             // ExSPLinksRetrieved -> EAddressSelectDone
       
    75             ExSPLinksRetrieved, 
       
    76             // ExSPContactRetrieved -> ExSPContactRetrieved
       
    77             // ExSPContactRetrieved -> ExSPContactsRetrieved
       
    78             // ExSPContactRetrieved -> EAddressSelectDone
       
    79             ExSPContactRetrieved,
       
    80             // ExSPContactsRetrieved -> EPresenceIconInfoRetrieved
       
    81             // ExSPContactsRetrieved -> EAddressSelectDone
       
    82             ExSPContactsRetrieved,
       
    83             // EPresenceIconInfoRetrieved -> EPresenceIconRetrieved
       
    84             // EPresenceIconInfoRetrieved -> EAddressSelectDone
       
    85             EPresenceIconInfoRetrieved,
       
    86             // EPresenceIconRetrieved -> EPresenceIconsRetrieved
       
    87             // EPresenceIconRetrieved -> EAddressSelectDone
       
    88             EPresenceIconRetrieved,
       
    89             // EPresenceIconsRetrieved -> EAddressSelectDone
       
    90             EPresenceIconsRetrieved,
       
    91             // EAddressSelectDone -> EAddressSelectError
       
    92             EAddressSelectDone,
       
    93             EAddressSelectError
       
    94             };
       
    95      
       
    96     public: // Construction
       
    97 
       
    98         /**
       
    99          * Creates a new instance of this class.
       
   100          *
       
   101          * @param aObserver          Observer.
       
   102          * @param aContactLink       Contact link.
       
   103          * @param aPriorities        Address select default priorities.
       
   104          * @param aFieldTypeSelector Field type selector.
       
   105          * @param aCommSelector      Enum value for field type selector.
       
   106          * @param aRskBack           Indicates whether the RSK should be Back.
       
   107          * @return  A new instance of this class.
       
   108          */
       
   109         static CPbk2CommAddressSelectPhase* NewL(
       
   110                 MPbk2ServicePhaseObserver& aObserver,
       
   111                 const MVPbkContactLink& aContactLink,
       
   112                 RVPbkContactFieldDefaultPriorities& aPriorities,
       
   113                 CVPbkFieldTypeSelector& aFieldTypeSelector,
       
   114                 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector
       
   115                     aCommSelector,
       
   116                 TBool aRskBack );
       
   117 
       
   118         /**
       
   119          * Destructor.
       
   120          */
       
   121         ~CPbk2CommAddressSelectPhase();
       
   122 
       
   123     public: // From MPbk2ServicePhase
       
   124         void LaunchServicePhaseL();
       
   125         void CancelServicePhase();
       
   126         void RequestCancelL(
       
   127                 TInt aExitCommandId );
       
   128         void AcceptDelayedL(
       
   129                 const TDesC8& aContactLinkBuffer );
       
   130         void DenyDelayedL(
       
   131                 const TDesC8& aContactLinkBuffer );
       
   132         MVPbkContactLinkArray* Results() const;
       
   133         TInt ExtraResultData() const;
       
   134         MVPbkStoreContact* TakeStoreContact();
       
   135         HBufC* FieldContent() const;
       
   136 
       
   137     public: // From MVPbkSingleContactOperationObserver
       
   138         void VPbkSingleContactOperationComplete(
       
   139                 MVPbkContactOperationBase& aOperation,
       
   140                 MVPbkStoreContact* aContact );
       
   141         void VPbkSingleContactOperationFailed(
       
   142                 MVPbkContactOperationBase& aOperation,
       
   143                 TInt aError );
       
   144 
       
   145     private: // From MPbk2KeyEventHandler
       
   146         TBool Pbk2ProcessKeyEventL(
       
   147                 const TKeyEvent& aKeyEvent,
       
   148                 TEventCode aType );
       
   149                 
       
   150     public: // From MVPbkOperationErrorObserver
       
   151         void VPbkOperationFailed( MVPbkContactOperationBase* aOperation,
       
   152             TInt aError );
       
   153     
       
   154     public: // From MVPbkOperationResultObserver
       
   155         void VPbkOperationResultCompleted(
       
   156             MVPbkContactOperationBase* aOperation,
       
   157             MVPbkContactLinkArray* aArray );
       
   158     
       
   159     public: //From MContactPresenceObs
       
   160     
       
   161         void ReceiveIconInfoL(
       
   162             const TDesC8& aPackedLink,
       
   163             const TDesC8& aBrandId,
       
   164             const TDesC8& aElementId );
       
   165 
       
   166         void ReceiveIconFileL(
       
   167             const TDesC8& aBrandId,
       
   168             const TDesC8& aElementId,
       
   169             CFbsBitmap* aBrandedBitmap,
       
   170             CFbsBitmap* aMask );
       
   171               
       
   172         void PresenceSubscribeError(
       
   173             const TDesC8& aPackedLink,
       
   174             TInt aStatus );
       
   175 
       
   176         void ErrorOccured(
       
   177             TInt aOpId,
       
   178             TInt aStatus );
       
   179         
       
   180         void ReceiveIconInfosL(
       
   181             const TDesC8& aPackedLink,
       
   182             RPointerArray <MContactPresenceInfo>& aInfoArray,
       
   183             TInt aOpId ); 
       
   184         
       
   185     private: // From MVPbkContactStoreObserver 
       
   186         void StoreReady(
       
   187                 MVPbkContactStore& aContactStore );
       
   188         void StoreUnavailable(
       
   189                 MVPbkContactStore& aContactStore,
       
   190                 TInt aReason );
       
   191         void HandleStoreEventL(
       
   192                 MVPbkContactStore& aContactStore,
       
   193                 TVPbkContactStoreEvent aEvent );
       
   194         
       
   195     private: // Implementation
       
   196         CPbk2CommAddressSelectPhase(
       
   197                 MPbk2ServicePhaseObserver& aObserver,
       
   198                 RVPbkContactFieldDefaultPriorities& aPriorities,                
       
   199                 TBool aRskBack,
       
   200                 CVPbkFieldTypeSelector& aFieldTypeSelector,
       
   201                 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector
       
   202                     aCommSelector );
       
   203         void ConstructL(
       
   204                 const MVPbkContactLink& aContactLink );
       
   205         void HandleReceiveIconInfosL(
       
   206                 const TDesC8& aPackedLink,
       
   207                 RPointerArray <MContactPresenceInfo>& aInfoArray,
       
   208                 TInt aOpId );
       
   209         void RetrieveContact();
       
   210         void RetrieveContactL();
       
   211         void DoSelectAddresses();
       
   212         void DoSelectAddressesL();
       
   213         TInt CorrectRSK(
       
   214                 TInt aAddressSelectResourceId );
       
   215         void AppendResultL(
       
   216                 const MVPbkStoreContactField* aField );
       
   217         void GetImppFieldDataL(CDesC16ArrayFlat & aXspIdArray, 
       
   218                 MVPbkStoreContact& aContact );
       
   219         void FilterXspContactsL();
       
   220         TBool IsMatchL( MVPbkStoreContact& aXspContact, 
       
   221                 MVPbkStoreContact& aStoreContact );
       
   222         void StartLoadingxSPContactLinks();
       
   223         void StartLoadingxSPContactLinksL();
       
   224         void StartLoadingxSPContacts( MVPbkContactLinkArray& aArray );
       
   225         void StartLoadingxSPContactsL( MVPbkContactLinkArray& aArray );
       
   226         void StartLoadingPresenceIconInfo();
       
   227         void StartLoadingPresenceIconInfoL();
       
   228         TInt NumOfAddressesL( MVPbkStoreContact& aStoreContact );
       
   229         TInt NumOfAddressesL();
       
   230         void GetPresenceInfoL();
       
   231     
       
   232     private: // Data
       
   233         /// Ref: Observer
       
   234         MPbk2ServicePhaseObserver& iObserver;
       
   235         /// Own: Contact links
       
   236         MVPbkContactLink* iContactLink;
       
   237         /// Own: Results array
       
   238         CVPbkContactLinkArray* iResults;
       
   239         /// Ref: Address select default priorities
       
   240         RVPbkContactFieldDefaultPriorities& iPriorities;
       
   241         /// Own: Address select resource id
       
   242         TInt iResourceId;
       
   243         /// Own: Indicates whether the RSK should be Back
       
   244         TBool iRskBack;
       
   245         /// Ref: For address select dialog's exit handling
       
   246         MPbk2DialogEliminator* iAddressSelectEliminator;
       
   247         /// Own: Contact retrieve operation
       
   248         MVPbkContactOperationBase* iRetrieveOperation;
       
   249         /// Own: Store contact
       
   250         MVPbkStoreContact* iStoreContact;
       
   251         /// Own: Key event dealer
       
   252         CPbk2KeyEventDealer* iDealer;
       
   253         /// Own: Title resource id
       
   254         TInt iTitleResId;
       
   255         /// Ref: Eikon enviroment
       
   256         CEikonEnv* iEikenv;
       
   257         /// Ref: Field type selector
       
   258         CVPbkFieldTypeSelector& iFieldTypeSelector;
       
   259         /// Own: xSP stores interface
       
   260         CVPbkxSPContacts* ixSPManager;
       
   261         /// Own: xSP contact retrieve operation
       
   262         MVPbkContactOperationBase* ixSPContactOperation;
       
   263         /// Own: xSP contacts array
       
   264         CVPbkContactLinkArray* ixSPContactsArray;
       
   265         /// Own: xSP store contacts array
       
   266         RPointerArray<MVPbkStoreContact> ixSPStoreContactsArray;
       
   267         /// Own: state
       
   268         TState iState;
       
   269         /// Own: content of the selected field
       
   270         HBufC* iFieldContent;
       
   271         /// Own: contact presence manager
       
   272         MContactPresence* iContactPresence;
       
   273         /// Own: array of presence icons
       
   274         RPointerArray<CPbk2PresenceIconInfo> iPresenceIconArray;
       
   275         /// Own: Communication method
       
   276         VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector iCommMethod;
       
   277     };
       
   278 
       
   279 #endif // CPBK2COMMADDRESSSELECTPHASE_H
       
   280 
       
   281 // End of File