|
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 responsible for writting to the ICC. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalComponent |
|
21 */ |
|
22 |
|
23 #ifndef __WRITECONTACTTOICC_H__ |
|
24 #define __WRITECONTACTTOICC_H__ |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <mpbutil.h> |
|
28 #include <etelmm.h> |
|
29 #include <etelsat.h> |
|
30 #include <satcs.h> |
|
31 |
|
32 #include "phbksyncsvr.h" |
|
33 #include "SyncEngineServer.h" |
|
34 |
|
35 |
|
36 /** |
|
37 * This class is responsible for implementing the state machine required to write |
|
38 * phonebook entries to ICC. |
|
39 */ |
|
40 class CWriteContactToICC : public CActive |
|
41 { |
|
42 private: |
|
43 enum TPBSyncIccWrite |
|
44 { |
|
45 EPBSyncIccWriteIdle, |
|
46 EPBSyncIccWriteWaitForIccWrite, |
|
47 EPBSyncIccWriteWaitForCancel, |
|
48 EPBSyncIccWriteDeleteOldSlot |
|
49 }; |
|
50 |
|
51 enum TTypeOfWrite |
|
52 { |
|
53 EWriteAddNew, |
|
54 EWriteEdit, |
|
55 EWriteEditSlotNumber |
|
56 }; |
|
57 |
|
58 public: |
|
59 static CWriteContactToICC* NewL(CSyncEngineSession& aSession, |
|
60 TInt aBufferSize, |
|
61 CPhoneBookManager& aPhonebookManager, |
|
62 RMobilePhone& aPhone, |
|
63 TUid aPhonebookUid, |
|
64 const RMessage2& aClientMessage); |
|
65 ~CWriteContactToICC(); |
|
66 |
|
67 void DoIccWriteL(); |
|
68 |
|
69 inline TUid PhonebookUid() const; |
|
70 inline const RMessage2& ClientMessage() const; |
|
71 inline TInt SlotNum() const; |
|
72 |
|
73 void DoCancel(); |
|
74 |
|
75 protected: |
|
76 void RunL(); |
|
77 TInt RunError(TInt aError); |
|
78 |
|
79 private: |
|
80 CWriteContactToICC(CSyncEngineSession& aSession, |
|
81 CPhoneBookManager& aPhonebookManager, |
|
82 RMobilePhone& aPhone, |
|
83 TUid aPhonebookUid, |
|
84 const RMessage2& aClientMessage); |
|
85 void ConstructL(TInt aBufferSize); |
|
86 |
|
87 TUint8 ConvertTonNpiByte(RMobilePhone::TMobileTON aTon); |
|
88 void EncodeICCEntryL(); |
|
89 |
|
90 |
|
91 CSyncEngineSession& iSession; |
|
92 CPhoneBookManager& iPhonebookManager; |
|
93 RMobilePhone& iPhone; |
|
94 TUid iPhonebookUid; |
|
95 RMessage2 iClientMessage; |
|
96 |
|
97 CBufBase* iIccEntryBuf; |
|
98 TPtr8 iIccEntryPtr; |
|
99 CSyncContactICCEntry* iIccEntry; |
|
100 |
|
101 HBufC8* iPhonebookData; |
|
102 TPtr8 iPhonebookDataPtr; |
|
103 TInt iOldSlot; |
|
104 |
|
105 TTypeOfWrite iTypeOfWrite; |
|
106 TPBSyncIccWrite iIccWriteState; |
|
107 RMobilePhoneBookStore iPhonebookStore; |
|
108 RMobilePhoneBookStore::TMobilePhoneBookInfoV5 iPhBkInfoV5; |
|
109 CPhoneBookBuffer* iPhonebookBuffer; |
|
110 TBool iIsUsedSlot; |
|
111 }; |
|
112 |
|
113 |
|
114 /** |
|
115 * Return the ICC phonebook UID. |
|
116 * |
|
117 * @return The UID of the phonebook being used by this Active Object. |
|
118 */ |
|
119 inline TUid CWriteContactToICC::PhonebookUid() const |
|
120 { |
|
121 return iPhonebookUid; |
|
122 } // CWriteContactToICC::PhonebookUid |
|
123 |
|
124 |
|
125 /** |
|
126 * Return the client message handle. |
|
127 * |
|
128 * @return A reference to the client message request being used by this |
|
129 * Active Object. |
|
130 */ |
|
131 inline const RMessage2& CWriteContactToICC::ClientMessage() const |
|
132 { |
|
133 return iClientMessage; |
|
134 } // CWriteContactToICC::ClientMessage |
|
135 |
|
136 |
|
137 /** |
|
138 * Return the slot number of the newly written entry. |
|
139 * |
|
140 * @return The slot number. |
|
141 */ |
|
142 inline TInt CWriteContactToICC::SlotNum() const |
|
143 { |
|
144 return iIccEntry->iSlotNum; |
|
145 } // CWriteContactToICC::SlotNum |
|
146 |
|
147 |
|
148 #endif // __WRITECONTACTTOICC_H__ |