|
1 /* |
|
2 * Copyright (c) 2007 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: Encapsulates saving and removing email accounts |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef IPSSETDATAMANAGER_H |
|
19 #define IPSSETDATAMANAGER_H |
|
20 |
|
21 |
|
22 typedef RArray<TImapAccount> RIpsSetDataImap4IdArray; |
|
23 typedef RArray<TPopAccount> RIpsSetDataPop3IdArray; |
|
24 typedef RArray<TSmtpAccount> RIpsSetDataSmtpIdArray; |
|
25 |
|
26 class CIpsSetData; |
|
27 class CIpsSetDataStorer; |
|
28 class CEmailAccounts; |
|
29 class CMsvSession; |
|
30 class CIMAMailboxDoctor; |
|
31 |
|
32 // Maximum length of IMEI code |
|
33 const TInt KIMAMaxPhoneIdLength = 50; |
|
34 |
|
35 /** |
|
36 * This class encapsulates saving and removing email accounts. |
|
37 * |
|
38 * @since FS v1.0 |
|
39 * @lib IpsSosSettings.lib |
|
40 */ |
|
41 class CIpsSetDataManager : public CBase |
|
42 { |
|
43 public: |
|
44 |
|
45 /** |
|
46 * 2 phase construction. |
|
47 * |
|
48 * @param aSession Message server session. |
|
49 * @return self pointer |
|
50 */ |
|
51 static CIpsSetDataManager* NewL( |
|
52 CMsvSession& aSession ); |
|
53 |
|
54 /** |
|
55 * 2 phase construction with stack push. |
|
56 * |
|
57 * @param CMsvSession Message server session. |
|
58 * @return self pointer |
|
59 */ |
|
60 static CIpsSetDataManager* NewLC( |
|
61 CMsvSession& aSession ); |
|
62 |
|
63 /** |
|
64 * Destructor |
|
65 */ |
|
66 virtual ~CIpsSetDataManager(); |
|
67 |
|
68 public: |
|
69 |
|
70 /** |
|
71 * Creates email service and account. |
|
72 * |
|
73 * @param aSettings Settings data object. |
|
74 * @param aPopulateDefaults Sets default data. |
|
75 */ |
|
76 TInt CreateEmailAccount( |
|
77 CIpsSetData& aSettings, |
|
78 const TBool aPopulateDefaults = EFalse ); |
|
79 |
|
80 /** |
|
81 * Saves email settings |
|
82 * |
|
83 * @param aSettings Settings data object. |
|
84 * @return KErrNone, when savng is ok. |
|
85 */ |
|
86 TInt SaveEmailSettingsL( |
|
87 CIpsSetData& aSettings ); |
|
88 |
|
89 /** |
|
90 * Loads email settings. |
|
91 * |
|
92 * @param aEntry Mailbox entry. |
|
93 * @param aSettings Settings data object. |
|
94 */ |
|
95 void LoadEmailSettingsL( |
|
96 const TMsvEntry& aEntry, |
|
97 CIpsSetData& aSettings ); |
|
98 |
|
99 /** |
|
100 * Removes whole mailbox account. |
|
101 * |
|
102 * @param aRelatedAccountId Receiving account ID. |
|
103 * @param aMtmId Service protocol. |
|
104 */ |
|
105 void RemoveAccountL( |
|
106 const TMsvEntry& aMailbox ); |
|
107 |
|
108 /** |
|
109 * Removes settings from the account. |
|
110 * |
|
111 * @param aAccountId Account ID. |
|
112 * @param aMtmId Service protocol. |
|
113 */ |
|
114 /*TInt DeleteAccountSettings( |
|
115 const TUint32 aAccountId, |
|
116 const TUid& aMtmId );*/ |
|
117 |
|
118 private: |
|
119 |
|
120 /** |
|
121 * C++ constructor |
|
122 * |
|
123 * @param aSession Message server session. |
|
124 */ |
|
125 CIpsSetDataManager( CMsvSession& aSession ); |
|
126 |
|
127 /** |
|
128 * 2nd phase of construction. |
|
129 */ |
|
130 void ConstructL(); |
|
131 |
|
132 private: |
|
133 |
|
134 /** |
|
135 * Creates mailbox service and account. |
|
136 * |
|
137 * @param aSettings Settings data object. |
|
138 * @param aPopulateDefaults Populates default settings. |
|
139 */ |
|
140 void DoCreateEmailAccountL( |
|
141 CIpsSetData& aSettings, |
|
142 const TBool aPopulateDefaults ); |
|
143 |
|
144 |
|
145 /** |
|
146 * Stores signature to stream. |
|
147 * |
|
148 * @param aSettings Settings data object. |
|
149 */ |
|
150 void StoreSignatureL( const CIpsSetData& aSettings ); |
|
151 |
|
152 /** |
|
153 * Retrieves signature from stream. |
|
154 * |
|
155 * @param aSettings Settings data object. |
|
156 */ |
|
157 void RestoreSignatureL( CIpsSetData& aSettings ); |
|
158 |
|
159 /** |
|
160 * Create Imap4 service and account. |
|
161 * |
|
162 * @param aSettings Settings data object. |
|
163 * @param aPopulateDefaults Populates default settings. |
|
164 * @param aReadOnly The service is created as read only. |
|
165 */ |
|
166 TUint32 CreateImap4AccountL( |
|
167 CIpsSetData& aSettings, |
|
168 const TBool aPopulateDefaults, |
|
169 const TBool aReadOnly = EFalse ); |
|
170 |
|
171 /** |
|
172 * Create Pop3 service and account. |
|
173 * |
|
174 * @param aSettings Settings data object. |
|
175 * @param aPopulateDefaults Populates default settings. |
|
176 * @param aReadOnly The service is created as read only. |
|
177 */ |
|
178 TUint32 CreatePop3AccountL( |
|
179 CIpsSetData& aSettings, |
|
180 const TBool aPopulateDefaults, |
|
181 const TBool aReadOnly = EFalse ); |
|
182 |
|
183 /** |
|
184 * Create extended settings. |
|
185 * |
|
186 * @param aMailboxId Mailbox's service Id. |
|
187 * @param aAccountId Account Id. |
|
188 * @param aProtocol Service protocol. |
|
189 * @param aSettings Settings data object. |
|
190 * @param aPopulateDefaults Populates default settings. |
|
191 */ |
|
192 void CreateExtendedSettingsL( |
|
193 const TMsvId aMailboxId, |
|
194 const TUint32 aAccountId, |
|
195 const TUid& aProtocol, |
|
196 CIpsSetData& aSettings, |
|
197 const TBool aPopulateDefaults = EFalse ); |
|
198 |
|
199 /** |
|
200 * imei code saving function |
|
201 * |
|
202 */ |
|
203 TInt StoreIMEIToMailbox( |
|
204 const TMsvId aMailboxId ) const; |
|
205 |
|
206 /** |
|
207 * imei code saving function |
|
208 * |
|
209 */ |
|
210 TInt StoreIMEIToEntry( const TMsvId aMailboxId ) const; |
|
211 |
|
212 /** |
|
213 * imei code saving function |
|
214 * |
|
215 */ |
|
216 void GetAndStoreIMEIToEntryL( const TMsvId aMailboxId ) const; |
|
217 |
|
218 /** |
|
219 * Loads Pop3 settings. |
|
220 * |
|
221 * @param aSettings Settings data object. |
|
222 */ |
|
223 void LoadPop3SettingsL( CIpsSetData& aSettings ); |
|
224 |
|
225 /** |
|
226 * Loads Imap4 settings. |
|
227 * |
|
228 * @param aSettings Settings data object. |
|
229 */ |
|
230 void LoadImap4SettingsL( CIpsSetData& aSettings ); |
|
231 |
|
232 /** |
|
233 * Saves Pop3 settings. |
|
234 * |
|
235 * @param aSettings Settings data object. |
|
236 */ |
|
237 void SavePop3SettingsL( CIpsSetData& aSettings ); |
|
238 |
|
239 /** |
|
240 * Saves Imap4 settings. |
|
241 * |
|
242 * @param aSettings Settings data object. |
|
243 */ |
|
244 void SaveImap4SettingsL( CIpsSetData& aSettings ); |
|
245 |
|
246 /** |
|
247 * Used to send event to email plugin |
|
248 * that settings have been changed |
|
249 */ |
|
250 TInt SendPropertyEventL( TInt aMailbox, TBool aIsImap ); |
|
251 |
|
252 /** |
|
253 * Cleans all global folders (drafts, outbox, sent) out of entries that |
|
254 * belong to the given mailbox |
|
255 * @param aMailbox mailbox that is being deleted |
|
256 */ |
|
257 void CleanGlobalFoldersL( const TMsvEntry& aMailbox ); |
|
258 |
|
259 /** |
|
260 * Cleans one folder (drafts, outbox, sent) out of entries that |
|
261 * belong to the given mailbox |
|
262 * @param aFolderId standard/global folder id |
|
263 * @param aMailbox mailbox that is being deleted |
|
264 */ |
|
265 void CleanGlobalFolderL( const TMsvId& aFolderId, const TMsvEntry& aMailbox ); |
|
266 |
|
267 TBool VerifyMailboxCreation( const CIpsSetData& aSettings ); |
|
268 |
|
269 void CleanInvalidMailbox( const CIpsSetData& aSettings ); |
|
270 |
|
271 void SetRelatedIdL( TMsvId aEntryId, TMsvId aRelatedId ); |
|
272 |
|
273 private: |
|
274 |
|
275 /** |
|
276 * Message Server Session |
|
277 */ |
|
278 CMsvSession& iSession; |
|
279 |
|
280 /** |
|
281 * An object to handle the storing of the settings |
|
282 * Owned. |
|
283 */ |
|
284 CIpsSetDataStorer* iStorer; |
|
285 |
|
286 /** |
|
287 * An object to handle account creation |
|
288 * Owned. |
|
289 */ |
|
290 CEmailAccounts* iAccounts; |
|
291 }; |
|
292 |
|
293 #endif // IPSSETDATAMANAGER_H |
|
294 |
|
295 // End of File |