phonebookui/Phonebook2/xSPExtensionManager/src/CxSPContactManager.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2006 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: 
       
    15 *       Contact manager.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef __CXSPCONTACTMANAGER_H__
       
    21 #define __CXSPCONTACTMANAGER_H__
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include "MxSPContactManager.h"
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class CPbk2ViewState;
       
    29 class MxSPFactory;
       
    30 class MVPbkContactStoreList;
       
    31 class CVPbkContactManager;
       
    32 
       
    33 /**
       
    34  * Contact map. Represents simply the mapping/linking between a single
       
    35  * contact link and a contact id.
       
    36  */
       
    37 class CxSPPbkContactMap : public CBase
       
    38 	{
       
    39 	public:
       
    40 
       
    41 		/**
       
    42          * Constructor.
       
    43          */
       
    44         CxSPPbkContactMap();
       
    45 
       
    46 		/**
       
    47          * Destructor.
       
    48          */
       
    49         ~CxSPPbkContactMap();
       
    50 
       
    51 		/**
       
    52 		 * Internalize the class data
       
    53 		 *
       
    54 		 * @param aStream Stream for internalizing
       
    55 		 * @param aContactStores
       
    56 		 */
       
    57 		void InternalizeL( RReadStream& aStream,
       
    58 							const MVPbkContactStoreList& aContactStores );
       
    59 
       
    60 		/**
       
    61 		 * Externalize the class data
       
    62 		 *
       
    63 		 * @param aStream Stream for externalizing
       
    64 		 */
       
    65 		void ExternalizeL( RWriteStream& aStream ) const;
       
    66 
       
    67 	public: // data
       
    68 		/// Original contact id
       
    69 		TUint32 iId;
       
    70 
       
    71 		/// xSP contact id
       
    72 		TInt32 ixSPContactId;
       
    73 
       
    74 		/// Own: Contact link
       
    75 		MVPbkContactLink* iPbkContactLink;
       
    76 	};
       
    77 
       
    78 
       
    79 /**
       
    80  * Contact manager.
       
    81  */
       
    82 class CxSPContactManager : public CBase,
       
    83                                public MxSPContactManager
       
    84     {
       
    85     public:
       
    86         /**
       
    87 		 * Static factory function that performs the 2-phased construction.
       
    88 		 *
       
    89 		 * @param aFactories Array of xSP factories
       
    90 		 * @param aVPbkContactManager Virtual phonebook contact manager
       
    91 		 *
       
    92          * @return new object of this class
       
    93          */
       
    94         static CxSPContactManager* NewL( CArrayPtrFlat<MxSPFactory>& aFactories,
       
    95         									CVPbkContactManager& aVPbkContactManager );
       
    96 
       
    97         /**
       
    98          * Destructor.
       
    99          */
       
   100         ~CxSPContactManager();
       
   101 
       
   102 	public: // from MxSPContactManager
       
   103 
       
   104 		void MapContactL( TUint32 aId,
       
   105 						  const MVPbkContactLink& aPbkContactLink,
       
   106         				  TInt32 axSPContactId );
       
   107 		void UnmapContactL( TUint32 aId,
       
   108 						    const MVPbkContactLink& aPbkContactLink,
       
   109         					TInt32 axSPContactId );
       
   110 		void GetMappedPbkContactsL( TUint32 aId,
       
   111 									TInt32 axSPContactId,
       
   112         							RPointerArray<MVPbkContactLink>& aPbkContactLinks ) const;
       
   113 		void GetMappedxSPContactsL( TUint32 aId,
       
   114 									const MVPbkContactLink& aPbkContactLink,
       
   115         							RArray<TInt32>& axSPContactIds ) const;
       
   116 		void ViewActivatedL( const TVwsViewId& aPrevViewId,
       
   117                          	 TUid aCustomMessageId,
       
   118                          	const TDesC8& aCustomMessage );
       
   119 		const CPbk2ViewState* NamesListState() const;
       
   120 
       
   121 	public:
       
   122 
       
   123 		/**
       
   124 		 * Converts the given contact link to buffer
       
   125 		 *
       
   126 		 * @param aLink contact link to be converted
       
   127 		 *
       
   128 		 * @return the converted link as buffer
       
   129 		 */
       
   130 		static HBufC8* LinkToBufferL( const MVPbkContactLink* aLink );
       
   131 
       
   132 		/**
       
   133 		 * Converts the given data buffer to contact link
       
   134 		 *
       
   135 		 * @param aBuffer data buffer to be converted
       
   136 		 * @param aContactStores list of contact stores
       
   137 		 *
       
   138 		 * @return the converted data as contact link
       
   139 		 */
       
   140 		static MVPbkContactLink* BufferToLinkL( const TDesC8& aBuffer,
       
   141 									const MVPbkContactStoreList& aContactStores );
       
   142 
       
   143     private: // Implementation
       
   144 
       
   145     	/**
       
   146          * Default constructor.
       
   147          */
       
   148         CxSPContactManager();
       
   149 
       
   150         /**
       
   151          * 2nd phase constructor.
       
   152          *
       
   153 		 * @param aFactories Array of xSP factories
       
   154 		 * @param aVPbkContactManager Virtual phonebook contadct manager
       
   155          */
       
   156         void ConstructL( CArrayPtrFlat<MxSPFactory>& aFactories,
       
   157         					CVPbkContactManager& aVPbkContactManager );
       
   158 
       
   159   	private:
       
   160 
       
   161   		/**
       
   162          * 	Searches for contact mapping
       
   163          *
       
   164          *	@param aId xSP implementation ID
       
   165          *	@param aPbkContactLink Phonebook contact link
       
   166          *	@param axSPContactId xSP contact ID
       
   167          *
       
   168          *	@return index of mapping or KErrNotFound
       
   169          */
       
   170   		TInt FindMap( TUint32 aId,
       
   171   					  const MVPbkContactLink& aPbkContactLink,
       
   172   					  TInt32 axSPContactId ) const;
       
   173 
       
   174   		/**
       
   175   		 * Creates a new folder
       
   176   		 *
       
   177   		 * @param aSession File server session
       
   178   		 * @param aPath path of the folder to be created
       
   179   		 * @param aDrive Drive name to which the folder is to be created
       
   180   		 *
       
   181   		 * @return error code in case of error
       
   182   		 */
       
   183 		TInt CreatePrivateFolder( RFs& aSession, TDes& aPath, TDriveNumber aDrive ) const;
       
   184 
       
   185 		/**
       
   186 		 * Saves the contact map data to a file
       
   187 		 *
       
   188 		 * @param aFileName file name to be used
       
   189 		 */
       
   190 		void SaveArrayL( const TDesC& aFileName );
       
   191 
       
   192 		/**
       
   193 		 * Restores the contact map data from file
       
   194 		 *
       
   195 		 * @param aFileName file name to be used for reading data
       
   196 		 * @param aFactories array of xSP factories available
       
   197 		 * @param aContactStoreList list of contact stores available
       
   198 		 */
       
   199 		void RestoreArrayL( const TDesC& aFileName,
       
   200 							CArrayPtrFlat<MxSPFactory>& aFactories,
       
   201 							MVPbkContactStoreList& aContactStoreList );
       
   202 
       
   203     private: // data
       
   204 		/// Contact map to be used
       
   205         RPointerArray<CxSPPbkContactMap> iContactMap;
       
   206 
       
   207         /// Own: Current view state
       
   208       	CPbk2ViewState* iState;
       
   209     };
       
   210 
       
   211 
       
   212 
       
   213 #endif // __CXSPCONTACTMANAGER_H__
       
   214 
       
   215 // End of File