|
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 Phonebook Synchroniser Server server side Session |
|
15 // classes. |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 */ |
|
23 |
|
24 #ifndef __PHBKSYNCSRV_H__ |
|
25 #define __PHBKSYNCSRV_H__ |
|
26 |
|
27 #include <commsdattypesv1_1.h> |
|
28 #include <e32property.h> |
|
29 #include <etelsat.h> |
|
30 #include <f32file.h> |
|
31 |
|
32 #include "common.h" |
|
33 #include "SyncEngineClient.h" |
|
34 |
|
35 |
|
36 /** |
|
37 * Name of the server. The '!' means it is a protected server. |
|
38 */ |
|
39 _LIT(PHBKSYNC_SERVER_NAME, "!PhBkSyncServer"); |
|
40 |
|
41 |
|
42 /** |
|
43 * Only bits 5-7 needed for TON. |
|
44 */ |
|
45 const TInt KEtsiTonPosition = 0x70; |
|
46 |
|
47 |
|
48 /** |
|
49 * Following literals are used for the INI file... |
|
50 */ |
|
51 _LIT8(KPhBkSyncPhonebook, "Phonebook"); |
|
52 _LIT8(KPhBkSyncHiddenName, "**********"); |
|
53 |
|
54 |
|
55 // |
|
56 // Forward declarations... |
|
57 // |
|
58 class CPhoneBookSession; |
|
59 class CGetPhoneStoreInfo; |
|
60 class CNotifySecurityEvent; |
|
61 class CNotifyLockInfoChange; |
|
62 class CNotifySATUpdates; |
|
63 class CNotifyAppInfoChange; |
|
64 class CNotifyBackupAndRestore; |
|
65 class CSyncEngineRequest; |
|
66 class CPhoneBookSyncStarter; |
|
67 |
|
68 |
|
69 /** |
|
70 * Structure to hold information for Sync State Notifications. |
|
71 */ |
|
72 typedef struct |
|
73 { |
|
74 CPhoneBookSession* iSession; |
|
75 RMessage2 iMessage; |
|
76 TUid iPhonebookUid; |
|
77 } TCacheStateNotification; |
|
78 |
|
79 |
|
80 /** |
|
81 * The Phonebook Synchroniser Server class. This class provides the front end |
|
82 * server implementation which handles all basic (and quick) requests and |
|
83 * forwards the longer requests to the Background Sync Engine. |
|
84 * |
|
85 * The class provides all the services required by class CPhoneBookSession. |
|
86 */ |
|
87 class CPhoneBookServer : public CPolicyServer |
|
88 { |
|
89 friend class CPhoneBookSyncStarter; |
|
90 |
|
91 private: |
|
92 /** |
|
93 * Configuration level of the server. |
|
94 */ |
|
95 enum TServerConfiguration |
|
96 { |
|
97 /** Not configured for use */ |
|
98 EServerConfigurationNone = 0, |
|
99 /** Not configured, configuring to Idle configuration */ |
|
100 EServerConfigurationConfiguringToIdle = 1, |
|
101 /** Configured only to support existing session closures */ |
|
102 EServerConfigurationIdle = 2, |
|
103 /** Idle config, configuring to full running configuration */ |
|
104 EServerConfigurationConfiguringToFull = 3, |
|
105 /** Full running configuration */ |
|
106 EServerConfigurationFull = 4 |
|
107 }; |
|
108 |
|
109 public: |
|
110 static CPhoneBookServer* NewL(); |
|
111 |
|
112 void HandleBackupOrRestoreStarting(); |
|
113 void HandleBackupOrRestoreComplete(); |
|
114 |
|
115 void AddSessionL(CPhoneBookSession* aSession); |
|
116 void DropSession(CPhoneBookSession* aSession); |
|
117 |
|
118 void DoSynchronisationL(CPhoneBookSession& aSession, |
|
119 const RMessage2& aMessage, |
|
120 TUid aPhonebookUid); |
|
121 TInt GetContactFormatL(TUid aPhonebookUid, |
|
122 RPhoneBookSession::TContactFieldsV3& aContactFields); |
|
123 TInt GetSyncModeL(TUid aPhonebookUid, |
|
124 RPhoneBookSession::TPhonebookSyncMode& aSyncMode); |
|
125 TInt SetSyncModeL(TUid aPhonebookUid, |
|
126 RPhoneBookSession::TPhonebookSyncMode aSyncMode); |
|
127 void DeleteCntFromICCL(CPhoneBookSession& aSession, |
|
128 const RMessage2& aMessage, |
|
129 TContactItemId aContactId); |
|
130 void WriteCntToICCL(CPhoneBookSession& aSession, |
|
131 const RMessage2& aMessage, |
|
132 TInt aSlotNum, TContactItemId aTemplateId); |
|
133 TInt ValidateContactL(TContactItemId aContactId, |
|
134 MContactSynchroniser::TValidateOperation aValidateOp); |
|
135 TInt UpdateLookupTableL(TUid aPhonebookUid, TContactItemId aContactId, |
|
136 TInt aSlotNum); |
|
137 TInt GetPhoneBookIdL(TUid aPhonebookUid, |
|
138 RPhoneBookSession::TSyncIdType aSyncIdType, |
|
139 TContactItemId& aContactItemId); |
|
140 TInt GetCacheStateL(TUid aPhonebookUid, |
|
141 RPhoneBookSession::TSyncState& aSyncState); |
|
142 TInt DbgMarkHeap() const; |
|
143 TInt DbgCheckHeap(TInt aCount) const; |
|
144 TInt DbgMarkEnd(TInt aCount) const; |
|
145 TInt DbgFailNext(TInt aCount) const; |
|
146 TInt DoSynchronisationCancelL(CPhoneBookSession& aSession, |
|
147 TUid aPhonebookUid); |
|
148 TInt DeleteCntFromICCCancelL(CPhoneBookSession& aSession, |
|
149 TUid aPhonebookUid); |
|
150 TInt WriteCntToICCCancelL(CPhoneBookSession& aSession, TUid aPhonebookUid); |
|
151 void NotifyCacheStateChangeL(CPhoneBookSession& aSession, |
|
152 const RMessage2& aMessage, |
|
153 TUid aPhonebookUid); |
|
154 TInt NotifyCacheStateChangeCancelL(CPhoneBookSession& aSession, |
|
155 TUid aPhonebookUid); |
|
156 TInt GetLastSyncErrorL(TUid aPhonebookUid, TInt& aLastSyncError); |
|
157 TInt GetNumSlotsL(TUid aPhonebookUid, TInt& aNumSlots); |
|
158 TInt GetNumFreeSlotsL(TUid aPhonebookUid, TInt& aNumFreeSlots); |
|
159 TInt GetFreeSlotsL(TUid aPhonebookUid, RArray<TInt>& aFreeSlots); |
|
160 TInt GetSlotIdL(TUid aPhonebookUid, TInt aSlotNum, |
|
161 TContactItemId& aContactItemId); |
|
162 TInt ShutdownServer(TBool aConditional); |
|
163 |
|
164 void CompleteNotifyStateChange(TUid aPhonebookUid); |
|
165 void CompleteGetPhoneStoreInfo(TInt aRetVal, RMobilePhoneBookStore::TMobilePhoneBookInfoV5& aStoreInfo, |
|
166 TUid aPhonebook); |
|
167 void CompleteNotifySecurityEvent(TInt aRetVal, RMobilePhone::TMobilePhoneSecurityEvent aSecurityEvent); |
|
168 void CompleteNotifyLockInfoChange(TInt aRetVal, RMobilePhone::TMobilePhoneLock& aLock, |
|
169 RMobilePhone::TMobilePhoneLockInfoV1& aLockInfo); |
|
170 void CompleteNotifySATUpdates(TInt aRetVal, RSat::TRefreshType aRefreshType, |
|
171 RArray<TUid>& aPhonebookList); |
|
172 void CompleteNotifyAppInfoChange(TInt aRetVal, TBool aInitialValue, |
|
173 RMobilePhone::TAID& aActiveUsimAID); |
|
174 |
|
175 inline TUint32 ICCCaps(); |
|
176 inline TBool IsV2Tsy(); |
|
177 inline TBool IsV5Tsy(); |
|
178 inline TBool IsV2Sat(); |
|
179 inline TBool IsUsimAppTsy(); |
|
180 |
|
181 void QueueEngineRequestL(TPhonebookSyncRequest aPhonebookSyncRequest, |
|
182 TUid aPhonebookUid, |
|
183 TContactItemId aContactId, |
|
184 CPhoneBookSession* aClientSession, |
|
185 const RMessage2& aClientMessage); |
|
186 void StartNextEngineRequest(); |
|
187 void CompleteEngineRequest(CSyncEngineRequest& aEngineRequest); |
|
188 void CancelEngineRequest(TPhonebookSyncRequest aPhonebookSyncRequest, |
|
189 TUid aPhonebookUid, |
|
190 TContactItemId aContactId, |
|
191 CPhoneBookSession* aClientSession); |
|
192 TBool IsEngineRequestQueued(TPhonebookSyncRequest aPhonebookSyncRequest, |
|
193 TUid aPhonebookUid, |
|
194 TBool aIncludeUserRequests, |
|
195 TBool aIncludeActiveRequests); |
|
196 void QueueAutoSyncRequest(TUid aPhonebookUid); |
|
197 |
|
198 private: |
|
199 CPhoneBookServer(); |
|
200 ~CPhoneBookServer(); |
|
201 |
|
202 void ConstructL(); |
|
203 |
|
204 void ConnectToEtelL(); |
|
205 void ConfigureServerL(TServerConfiguration aLevel); |
|
206 void AttemptToConfigureServerL(TServerConfiguration aLevel); |
|
207 CSession2* NewSessionL(const TVersion& aVersion,const RMessage2&/*aMessage*/) const; |
|
208 TInt RunError(TInt aError); |
|
209 |
|
210 |
|
211 TServerConfiguration iServerConfigLevel; |
|
212 |
|
213 RTelServer iEtelServer; |
|
214 TUint32 iICCCaps; |
|
215 RMobilePhone iPhone; |
|
216 RSat iSat; |
|
217 TBool iIsV2Tsy; |
|
218 TBool iIsV5Tsy; |
|
219 TBool iIsV2SAT; |
|
220 TBool iIsUsimAppTsy; |
|
221 |
|
222 TBool iIsSatSupported; |
|
223 |
|
224 CGetPhoneStoreInfo* iGetPhoneStoreInfo; |
|
225 CNotifyLockInfoChange* iNotifyLockInfoChange; |
|
226 CNotifySecurityEvent* iGetSecurityEvent; |
|
227 CNotifySATUpdates* iNotifySatUpdates; |
|
228 CNotifyAppInfoChange* iNotifyAppInfoChange; |
|
229 CNotifyBackupAndRestore* iNotifyBackupAndRestore; |
|
230 CPhoneBookSyncStarter* iPhoneBookSyncStarter; |
|
231 |
|
232 RPointerArray<CPhoneBookSession> iSessionArray; |
|
233 |
|
234 CPhoneBookManager* iPhonebookManager; |
|
235 |
|
236 RMobilePhone::TAID iActiveUsimAID; |
|
237 |
|
238 // |
|
239 // Variables to control shutdown of the server... |
|
240 // |
|
241 TBool iShouldShutdownServer; |
|
242 TBool iShouldShutdownUnconditionally; |
|
243 |
|
244 // |
|
245 // Connection to the Background Sync Engine... |
|
246 // |
|
247 RSyncEngineSession iSyncEngine; |
|
248 RPointerArray<CSyncEngineRequest> iSyncEngineRequestArray; |
|
249 |
|
250 // |
|
251 // List of notification requests and on which phonebook UIDs. |
|
252 // |
|
253 RArray<TCacheStateNotification> iCacheStateNotificationArray; |
|
254 |
|
255 // |
|
256 // Policy server information... |
|
257 // |
|
258 static const TInt iRanges[]; |
|
259 static const TUint8 iElementsIndex[]; |
|
260 static const CPolicyServer::TPolicyElement iElements[]; |
|
261 static const CPolicyServer::TPolicy iPolicy; |
|
262 }; |
|
263 |
|
264 |
|
265 /** |
|
266 * Simple Active Object to start the configuration of the server. |
|
267 * This is used to break any deadlock between CntModel starting |
|
268 * PhoneBookSync and PhoneBookSync starting CntModel. |
|
269 */ |
|
270 class CPhoneBookSyncStarter : public CAsyncOneShot |
|
271 { |
|
272 public: |
|
273 CPhoneBookSyncStarter(CPhoneBookServer& aServer); |
|
274 |
|
275 private: |
|
276 virtual void RunL(); |
|
277 |
|
278 CPhoneBookServer& iServer; |
|
279 }; |
|
280 |
|
281 |
|
282 /** |
|
283 * Specialised Active Scheduler to cleanly handle leaves of the Active |
|
284 * Objects. |
|
285 */ |
|
286 class CPhoneBookSyncScheduler : public CActiveScheduler |
|
287 { |
|
288 public: |
|
289 static CPhoneBookSyncScheduler* NewL(); |
|
290 void Error(TInt aError) const; |
|
291 }; |
|
292 |
|
293 |
|
294 // |
|
295 // Old unsupported PhBkSync server thread. |
|
296 // |
|
297 IMPORT_C TInt PhBkSyncServerThread(TAny* aArg); |
|
298 |
|
299 |
|
300 /** |
|
301 * Indicates whether V2 functionality is supported by the TSY. |
|
302 * |
|
303 * @return Boolean indicating whether V2 functionality is supported by the phone. |
|
304 */ |
|
305 inline TBool CPhoneBookServer::IsV2Tsy() |
|
306 { |
|
307 return iIsV2Tsy; |
|
308 } // CPhoneBookServer::IsV2Tsy |
|
309 |
|
310 |
|
311 /** |
|
312 * Indicates whether V5 functionality is supported by the TSY. |
|
313 * |
|
314 * @return Boolean indicating whether V5 functionality is supported by the phone. |
|
315 */ |
|
316 inline TBool CPhoneBookServer::IsV5Tsy() |
|
317 { |
|
318 return iIsV5Tsy; |
|
319 } // CPhoneBookServer::IsV5Tsy |
|
320 |
|
321 |
|
322 /** |
|
323 * Indicates whether V2 SAT is supported by the TSY. |
|
324 * |
|
325 * @return Boolean indicating whether V2 SAT is supported |
|
326 */ |
|
327 inline TBool CPhoneBookServer::IsV2Sat() |
|
328 { |
|
329 return iIsV2SAT; |
|
330 } // CPhoneBookServer::IsV2Sat |
|
331 |
|
332 |
|
333 /** |
|
334 * Indicates whether USIM App is supported by the TSY. |
|
335 * |
|
336 * @return Boolean indicating whether USIM App is supported |
|
337 */ |
|
338 inline TBool CPhoneBookServer::IsUsimAppTsy() |
|
339 { |
|
340 return iIsUsimAppTsy; |
|
341 } // CPhoneBookServer::IsUsimAppTsy |
|
342 |
|
343 |
|
344 #endif // __PHBKSYNCSRV_H__ |
|
345 |