|
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 Background Sync Engine server. The engine provides |
|
15 // the ability to perform Phonebook Sync's long running operations (e.g. Sync, |
|
16 // write contact and delete contact). |
|
17 // |
|
18 // |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent |
|
23 */ |
|
24 |
|
25 #ifndef __SYNCENGINESERVER_H__ |
|
26 #define __SYNCENGINESERVER_H__ |
|
27 |
|
28 #include <commsdattypesv1_1.h> |
|
29 #include <e32property.h> |
|
30 #include <etelsat.h> |
|
31 #include <f32file.h> |
|
32 |
|
33 #include "common.h" |
|
34 |
|
35 |
|
36 /** |
|
37 * Name of the engine. The '!' means it is a protected server. |
|
38 */ |
|
39 _LIT(PHBKSYNC_ENGINE_NAME, "!PhBkSyncEngine"); |
|
40 |
|
41 |
|
42 // |
|
43 // Template field lengths... |
|
44 // |
|
45 const TInt KTemplateFieldLength = 16; |
|
46 const TInt KTemplateNumberLength = 8; |
|
47 |
|
48 |
|
49 // |
|
50 // Phonebook data size limits. |
|
51 // |
|
52 const TInt KPBDataClientHeap = 900; |
|
53 const TInt KPBDataClientBuf = 512; |
|
54 |
|
55 |
|
56 /** |
|
57 * Number of retries to open, create or write to the DB. |
|
58 */ |
|
59 const TInt KMaxDbAccessRetryCount = 3; |
|
60 |
|
61 |
|
62 class CSyncEngineSession; |
|
63 class CSyncContactsWithICC; |
|
64 class CWriteContactToICC; |
|
65 class CDeleteContactFromICC; |
|
66 class CPhoneBookSyncEngineStarter; |
|
67 |
|
68 |
|
69 /** |
|
70 * Background Sync Engine server class. |
|
71 */ |
|
72 class CSyncEngineServer : public CPolicyServer |
|
73 { |
|
74 friend class CPhoneBookSyncEngineStarter; |
|
75 |
|
76 public: |
|
77 static CSyncEngineServer* NewL(CPhoneBookManager& aPhoneBookManager); |
|
78 |
|
79 void AddSessionL(CSyncEngineSession* aSession); |
|
80 void DropSession(CSyncEngineSession* aSession); |
|
81 |
|
82 void DoSynchronisationL(const RMessage2& aMessage, |
|
83 TUid aPhonebookUid); |
|
84 void DeleteCntFromICCL(const RMessage2& aMessage, |
|
85 TUid aPhonebookUid, TContactItemId aContactId); |
|
86 void WriteCntToICCL(const RMessage2& aMessage, |
|
87 TContactItemId aTemplateId, TInt aBufferSize); |
|
88 TInt DoSynchronisationCancelL(TUid aPhonebookUid); |
|
89 TInt DeleteCntFromICCCancelL(TUid aPhonebookUid); |
|
90 TInt WriteCntToICCCancelL(TUid aPhonebookUid); |
|
91 |
|
92 TContactItemId WriteICCContactToDBL(CSyncContactICCEntry& aICCEntry); |
|
93 void RollbackIccTransaction(); |
|
94 void CommitIccTransactionL(); |
|
95 |
|
96 void CompleteDoSync(TInt aRetVal); |
|
97 void CompleteWriteContactToICC(TInt aRetVal); |
|
98 void CompleteDoIccDelete(TInt aRetVal); |
|
99 |
|
100 inline TBool IsV2Tsy(); |
|
101 |
|
102 private: |
|
103 CSyncEngineServer(CPhoneBookManager& aPhoneBookManager); |
|
104 ~CSyncEngineServer(); |
|
105 |
|
106 void ConstructL(); |
|
107 CSession2* NewSessionL(const TVersion& aVersion,const RMessage2&/*aMessage*/) const; |
|
108 |
|
109 void ConfigureEngineL(); |
|
110 void UnconfigureEngineL(); |
|
111 void ConnectToEtelL(); |
|
112 |
|
113 TInt RunError(TInt aError); |
|
114 CContactItemField* AddTextFieldToIccContactL(TStorageType aType, TFieldType aFieldType, TUid aMapping, TDesC& aField, CContactICCEntry* aIccEntry, TInt aCount); |
|
115 void CreateTemplateIdL(TUid aPhonebookUid, TUint32 aICCCaps); |
|
116 void CreateGroupIdL(TUid aPhonebookUid); |
|
117 void CreatePhoneBookIdsL(); |
|
118 void AssignAlphaTagsToFieldTypeL(const TDesC16 &aTextTag, CContactItemField *apCurrField); |
|
119 TBool EntriesIdenticalL(CSyncContactICCEntry& aICCEntry, TContactItemId& aId); |
|
120 void RemoveAllContactsForPhoneBookL(TUid aPhonebookUid); |
|
121 |
|
122 RTelServer iEtelServer; |
|
123 TUint32 iICCCaps; |
|
124 RMobilePhone iPhone; |
|
125 CContactDatabase* iDb; |
|
126 |
|
127 CPhoneBookSyncEngineStarter* iPhoneBookSyncEngineStarter; |
|
128 |
|
129 CSyncEngineSession* iConnectedSession; |
|
130 CPhoneBookManager& iPhonebookManager; |
|
131 |
|
132 TBool iIsInTransaction; |
|
133 TBool iIsV2Tsy; |
|
134 |
|
135 // |
|
136 // Pointers to the worker Active Objects... |
|
137 // |
|
138 CSyncContactsWithICC* iSyncContactsWithICC; |
|
139 CWriteContactToICC* iWriteContactToICC; |
|
140 CDeleteContactFromICC* iDeleteContactFromICC; |
|
141 |
|
142 // |
|
143 // Policy Server Tables (naturally the same as CPhoneBookServer)... |
|
144 // |
|
145 static const TInt iRanges[]; |
|
146 static const TUint8 iElementsIndex[]; |
|
147 static const CPolicyServer::TPolicyElement iElements[]; |
|
148 static const CPolicyServer::TPolicy iPolicy; |
|
149 }; |
|
150 |
|
151 |
|
152 /** |
|
153 * Simple Active Object to start the configuration of the engine. |
|
154 * This is used to break any deadlock between CntModel starting |
|
155 * PhoneBookSync and PhoneBookSync starting CntModel. |
|
156 */ |
|
157 class CPhoneBookSyncEngineStarter : public CAsyncOneShot |
|
158 { |
|
159 public: |
|
160 CPhoneBookSyncEngineStarter(CSyncEngineServer& aEngine); |
|
161 |
|
162 private: |
|
163 virtual void RunL(); |
|
164 |
|
165 CSyncEngineServer& iEngine; |
|
166 }; |
|
167 |
|
168 |
|
169 /** |
|
170 * Specialised Active Scheduler to cleanly handle leaves of the Active |
|
171 * Objects. |
|
172 */ |
|
173 class CSyncEngineScheduler : public CActiveScheduler |
|
174 { |
|
175 public: |
|
176 static CSyncEngineScheduler* New(); |
|
177 void Error(TInt aError) const; |
|
178 }; |
|
179 |
|
180 |
|
181 /** |
|
182 * Indicates whether V2 functionality is supported by the TSY. |
|
183 * |
|
184 * @return Boolean indicating whether V2 functionality is supported by the |
|
185 * phone. |
|
186 */ |
|
187 inline TBool CSyncEngineServer::IsV2Tsy() |
|
188 { |
|
189 return iIsV2Tsy; |
|
190 } // CSyncEngineServer::IsV2Tsy |
|
191 |
|
192 |
|
193 #endif // __SYNCENGINESERVER_H__ |
|
194 |