pimprotocols/phonebooksync/inc/SyncContactsWithICC.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Header file for the Active Object based class which synchronises the
       
    15 // Contacts DB with the ICC.
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22 */
       
    23 
       
    24 #ifndef __SYNCCONTACTWITHICC_H__
       
    25 #define __SYNCCONTACTWITHICC_H__
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <mpbutil.h>
       
    29 #include <etelmm.h>
       
    30 #include <etelsat.h>
       
    31 #include <satcs.h>
       
    32 
       
    33 #include "phbksyncsvr.h"
       
    34 #include "SyncEngineServer.h"
       
    35 
       
    36 
       
    37 /**
       
    38  *  This class is responsible for implementing the state machine required
       
    39  *  to perform the synchronisation of the Contacts DB with the ICC.
       
    40  */
       
    41 class CSyncContactsWithICC : public CActive
       
    42 	{
       
    43 private:
       
    44 	enum TSyncContactsWithICCState
       
    45 		{
       
    46 		ESyncContactsWithICCStateIdle,
       
    47 		ESyncContactsWithICCStateWaitForRead,
       
    48 		ESyncContactsWithICCStateRemoveUnconfirmedEntries,
       
    49 		ESyncContactsWithICCStateWaitForCancel
       
    50 		};
       
    51 
       
    52 public:
       
    53 	static CSyncContactsWithICC* NewL(CSyncEngineSession& aSession, 
       
    54 		                              CPhoneBookManager& aPhonebookManager,
       
    55 		                              CContactDatabase& aDb,
       
    56 		                              RMobilePhone& aPhone,
       
    57 									  TUid aPhonebookType,
       
    58 									  const RMessage2& aClientMessage);
       
    59 	~CSyncContactsWithICC();
       
    60 
       
    61 	void SyncContactsWithICCL();
       
    62 	void DecodeICCAndStoreToDbL(TInt& aIndex, TInt& aReceivedEntries);
       
    63 
       
    64 	inline TUid PhonebookUid() const;
       
    65 	inline const RMessage2& ClientMessage() const;
       
    66 
       
    67 	void DoCancel();
       
    68 
       
    69 protected:
       
    70 	TInt RunError(TInt aError);
       
    71 
       
    72 private:
       
    73 	CSyncContactsWithICC(CSyncEngineSession& aSession,
       
    74 						 CPhoneBookManager& aPhonebookManager,
       
    75 						 CContactDatabase& aDb,
       
    76 						 RMobilePhone& aPhone,
       
    77 						 TUid aPhonebookUid,
       
    78 						 const RMessage2& aClientMessage);
       
    79 	void ConstructL();
       
    80 	void RunL();
       
    81 
       
    82 	void ReadICCEntries();
       
    83 	void YieldToOtherActiveObjects();
       
    84 	RMobilePhone::TMobileTON ConvertTypeOfNumber(TUint8 aValue) const;
       
    85 
       
    86 private:
       
    87 	CSyncEngineSession&  iSession;
       
    88 	CPhoneBookManager&  iPhonebookManager;
       
    89 	CContactDatabase&  iDb;
       
    90 	RMobilePhone&  iPhone;
       
    91 	TUid  iPhonebookUid;
       
    92 	RMessage2  iClientMessage;
       
    93 
       
    94 	TSyncContactsWithICCState  iState;
       
    95 	RMobilePhoneBookStore::TMobilePhoneBookInfoV5  iPhBkInfo;
       
    96 	RMobilePhoneBookStore  iPhonebookStore;
       
    97 	HBufC8*  iPhonebookData;
       
    98 	TPtr8  iPhonebookDataPtr;
       
    99 	TInt  iReceivedEntries;
       
   100 	TInt  iNumOfEntries;
       
   101 	TInt  iSlotNum;
       
   102 	TInt  iDbAccessRetryCount;
       
   103 	TInt  iICCReadRetryCount;
       
   104 	RTimer  iTimer;
       
   105 	RArray<TInt>  iUnconfirmedEntries;
       
   106 	};
       
   107 
       
   108 
       
   109 /**
       
   110  *  Return the ICC phonebook UID. 
       
   111  *
       
   112  *  @return The UID of the phonebook being used by this Active Object.
       
   113  */
       
   114 inline TUid CSyncContactsWithICC::PhonebookUid() const
       
   115 	{
       
   116 	return iPhonebookUid;
       
   117 	} // CSyncContactsWithICC::PhonebookUid
       
   118 
       
   119 
       
   120 /**
       
   121  *  Return the client message handle. 
       
   122  *
       
   123  *  @return  A reference to the client message request being used by this
       
   124  *  Active Object.
       
   125  */
       
   126 inline const RMessage2& CSyncContactsWithICC::ClientMessage() const
       
   127 	{
       
   128 	return iClientMessage;
       
   129 	} // CSyncContactsWithICC::ClientMessage
       
   130 
       
   131 
       
   132 #endif // __SYNCCONTACTWITHICC_H__