phonebookui/Phonebook2/NamesListExtension/inc/cpbk2mycard.h
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
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: MyCard class observes the state of MyCard, whether its created
       
    15 * or not. Also responsible for linking the data to MyCard.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CPBK2MYCARD_H_
       
    21 #define CPBK2MYCARD_H_
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <MVPbkSingleContactLinkOperationObserver.h>
       
    26 #include <MVPbkContactStoreObserver.h>
       
    27 #include <MPbk2ImageOperationObservers.h>
       
    28 #include <MVPbkSingleContactOperationObserver.h>
       
    29 #include "mpbk2mycardobserver.h"
       
    30 #include <TPbk2IconId.h>
       
    31 
       
    32 class MPbk2CmdItemVisibilityObserver;
       
    33 class MVPbkContactOperationBase;
       
    34 class MVPbkContactStore;
       
    35 class MPbk2MyCardObserver;
       
    36 class CPbk2ImageManager;
       
    37 class MPbk2ImageOperation;
       
    38 class CVPbkContactManager;
       
    39 class CPbk2ApplicationServices;
       
    40 class MVPbkBaseContact;
       
    41 class CFbsBitmap;
       
    42 
       
    43 /**
       
    44  *
       
    45  */
       
    46 NONSHARABLE_CLASS( CPbk2MyCard ) : public CBase,
       
    47                                    public MVPbkSingleContactLinkOperationObserver,
       
    48                                    public MVPbkContactStoreObserver,
       
    49                                    public MVPbkSingleContactOperationObserver,
       
    50                                    public MPbk2ImageGetObserver
       
    51     {
       
    52     public: // Construction & destruction
       
    53     	
       
    54         static CPbk2MyCard* NewL( MVPbkContactStore& aPhoneStore );
       
    55         ~CPbk2MyCard();
       
    56 
       
    57         void SetObserverL(MPbk2MyCardObserver& aObserver);
       
    58         void RemoveObserver(MPbk2MyCardObserver& aObserver);
       
    59         
       
    60         enum{ EUnkown = 0x0, 
       
    61 			  EExisting, 
       
    62 			  ENonExisting };
       
    63         inline TInt MyCardState() {return iMyCardState;}
       
    64         
       
    65     public:
       
    66     	/*
       
    67     	 * Returns my card link, NULL if it doesn't exist
       
    68     	 */
       
    69     	MVPbkContactLink* MyCardLink() const;
       
    70     	
       
    71     	/*
       
    72     	 * Returns my card thumbnail bitmap, NULL if it doesn't exist.
       
    73     	 * ownership is transferred to the client
       
    74     	 */
       
    75     	CFbsBitmap* MyCardBitmapL() const;
       
    76     	
       
    77     	/*
       
    78     	 * Returns MyCard icon id if created, otherwise empty TPbk2IconId
       
    79     	 */
       
    80     	const TPbk2IconId& MyCardIconId() const;
       
    81     	    	
       
    82     	/*
       
    83     	 * Returns MVPbkStoreContact if available, NULL otherwise
       
    84     	 */
       
    85     	MVPbkStoreContact* MyCardStoreContact() const;
       
    86     	
       
    87     	/**
       
    88     	 * Contact manager used by mycard
       
    89     	 */
       
    90     	CVPbkContactManager& ContactManager();
       
    91         
       
    92     private: // From MVPbkSingleContactLinkOperationObserver
       
    93         void VPbkSingleContactLinkOperationComplete(
       
    94                 MVPbkContactOperationBase& aOperation,
       
    95                 MVPbkContactLink* aLink );
       
    96 
       
    97         void VPbkSingleContactLinkOperationFailed(
       
    98                 MVPbkContactOperationBase& aOperation,
       
    99                 TInt aError );
       
   100 
       
   101     private: // From MVPbkContactStoreObserver
       
   102         void StoreReady( MVPbkContactStore& aContactStore );
       
   103         void StoreUnavailable(
       
   104                 MVPbkContactStore& aContactStore,
       
   105                 TInt aReason );
       
   106         void HandleStoreEventL(
       
   107                 MVPbkContactStore& aContactStore,
       
   108                 TVPbkContactStoreEvent aStoreEvent );
       
   109 
       
   110     private: // From MVPbkSingleContactOperationObserver
       
   111        void VPbkSingleContactOperationComplete(
       
   112     		   MVPbkContactOperationBase& aOperation,
       
   113     		   MVPbkStoreContact* aContact );
       
   114        
       
   115        void VPbkSingleContactOperationFailed(
       
   116     		   MVPbkContactOperationBase& aOperation,
       
   117     		   TInt aError );
       
   118        
       
   119     private: // From MPbk2ImageGetObserver
       
   120         virtual void Pbk2ImageGetComplete(
       
   121                 MPbk2ImageOperation& aOperation,
       
   122                 CFbsBitmap* aBitmap );
       
   123         virtual void Pbk2ImageGetFailed(
       
   124                 MPbk2ImageOperation& aOperation,
       
   125                 TInt aError );
       
   126         
       
   127     private:
       
   128         CPbk2MyCard( MVPbkContactStore& aPhoneStore );
       
   129         void ConstructL();
       
   130 
       
   131         void NotifyObservers( MPbk2MyCardObserver::TMyCardStatusEvent aEvent );
       
   132         
       
   133         /*
       
   134          * Starts loading thumbnail for the mycard contact if there is one
       
   135          */
       
   136         void LoadThumbnailL( MVPbkBaseContact& aContact );
       
   137         
       
   138     private: // data
       
   139     	TInt iMyCardState;
       
   140     	///  Own
       
   141         MVPbkContactOperationBase* iOperation;
       
   142         /// Ref
       
   143         MVPbkContactStore* iPhoneStore;
       
   144         /// Own
       
   145         MVPbkContactLink* iMyCardLink;
       
   146         /// 
       
   147         RPointerArray<MPbk2MyCardObserver> iObserverArray;
       
   148         /// Own. Phonebook image manager
       
   149 		CPbk2ImageManager*   iImageManager;
       
   150 		/// Own. Image operation
       
   151 		MPbk2ImageOperation* iImageOperation;
       
   152 		/// Own. for the store contact fetching 
       
   153 		MVPbkContactOperationBase* 	iRetrieveOperation;
       
   154 		// Ref. contact manager
       
   155 		CVPbkContactManager* iContactManager;
       
   156 		// Own. instance
       
   157 		CPbk2ApplicationServices* iAppServices;
       
   158 		// Own. MycardStoreContact
       
   159 		MVPbkStoreContact*	iMyCardStoreContact;
       
   160 		/// Ref. Thumbnail bitmap
       
   161 		CFbsBitmap*			iThumbBitmap;
       
   162 		/// default ID for the mycard icon
       
   163 		TPbk2IconId iIconId;
       
   164 		/// Empty id
       
   165 		TPbk2IconId	iEmptyId;
       
   166     };
       
   167 
       
   168 #endif /*CPBK2MYCARD_H_*/