1 /* |
|
2 * Copyright (c) 2005-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: CSmsAdapterMsvApi header |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef SMSADAPTERMSVAPI_H |
|
21 #define SMSADAPTERMSVAPI_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> // CActive |
|
25 #include <msvstd.h> // TMsvId |
|
26 #include <msvapi.h> // CMsvOperation |
|
27 #include <mtclreg.h> //CClientMtmRegistry |
|
28 #include <msvids.h> |
|
29 #include <mtclbase.h> |
|
30 #include <msvuids.h> |
|
31 #include <smut.h> |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 class CSmsClientMtm; |
|
35 class CVMessageParser; |
|
36 class CContactDatabase; |
|
37 |
|
38 // CONSTANTS |
|
39 const TInt KMsvMyFoldersEntryIdValue = 0x1008; |
|
40 const TInt KMsvMyFoldersTemplatesFolderId = 0x1009; |
|
41 |
|
42 // CLASS DECLARATION |
|
43 |
|
44 /** |
|
45 * Class CSmsAdapterMsvApi |
|
46 * Internal class that provides access to SMS message store. |
|
47 */ |
|
48 class CSmsAdapterMsvApi : public CBase, public MMsvSessionObserver |
|
49 { |
|
50 public: // Constructors and destructor |
|
51 |
|
52 /** |
|
53 * Two-phased constructor. |
|
54 */ |
|
55 static CSmsAdapterMsvApi* NewL(); |
|
56 |
|
57 /** |
|
58 * Destructor. |
|
59 */ |
|
60 virtual ~CSmsAdapterMsvApi(); |
|
61 |
|
62 private: // Private constructor functions |
|
63 |
|
64 /** |
|
65 * C++ default constructor. |
|
66 * C++ default constructor can NOT contain any code, that |
|
67 * might leave. |
|
68 */ |
|
69 CSmsAdapterMsvApi(); |
|
70 |
|
71 /** |
|
72 * By default Symbian 2nd phase constructor is private. |
|
73 */ |
|
74 void ConstructL(); |
|
75 |
|
76 public: // New functions |
|
77 |
|
78 /** |
|
79 * Add a SMS message. The given SMS message is stored to the target folder. |
|
80 * |
|
81 * @param aSm IN: Contains SMS message in decoded format |
|
82 * @param aFolder IN: The folder in which the SM will be stored |
|
83 * @param aSmId OUT: The index created for the added SM. |
|
84 */ |
|
85 void AddSML( |
|
86 CVMessageParser& aSm, |
|
87 TMsvId aFolder, |
|
88 TMsvId& aSmId ); |
|
89 |
|
90 /** |
|
91 * Replace existing SMS message |
|
92 * |
|
93 * @param aSmId IN: the index to the replaceable SM |
|
94 * @param aSm IN: Contains data of the new SM |
|
95 */ |
|
96 void ReplaceSML ( |
|
97 TMsvId aSmId, |
|
98 CVMessageParser& aSm ); |
|
99 |
|
100 /** |
|
101 * Delete a SMS message. |
|
102 * |
|
103 * @param aSmId IN: the index to the SM, which will be deleted |
|
104 */ |
|
105 void DeleteSML( TMsvId aSmId ); |
|
106 |
|
107 /** |
|
108 * Delete a SMS message. |
|
109 * |
|
110 * @param aUid IN: the index to the SM, which will be deleted |
|
111 * |
|
112 * @return KErrNone in success. KErrInUse if folder was not deleted because it was not empty. |
|
113 */ |
|
114 TInt CSmsAdapterMsvApi::DeleteUserFolderL( TMsvId aUid ); |
|
115 |
|
116 /** |
|
117 * Retriveve SMS message from the message store. |
|
118 * |
|
119 * @param aSmId IN: Index to the SM, which will be retrieved |
|
120 * @param aParent OUT: Index of parent folder |
|
121 * @param aSm OUT: The SM data is stored into this object. |
|
122 * @param aUnread OUT: Whether the SM is unread or not |
|
123 */ |
|
124 void RetrieveSML( |
|
125 TMsvId aSmId, |
|
126 TMsvId& aParent, |
|
127 CVMessageParser& aSM, |
|
128 TBool& aUnread ); |
|
129 |
|
130 /** |
|
131 * Sends the specified SM. |
|
132 * |
|
133 * @param aSmId IN: Index to the SM, which will be sent. |
|
134 */ |
|
135 void SendSML( TMsvId aSmId ); |
|
136 |
|
137 /** |
|
138 * This function can be used when client needs direct access to CMsvSession. |
|
139 * @return ponter to opened message server session. |
|
140 */ |
|
141 CMsvSession* MsvSessionL(); |
|
142 |
|
143 /** |
|
144 * Empties folder from SMS messages. |
|
145 * |
|
146 * @param aFolderId IN: TMsvId of the folder |
|
147 */ |
|
148 void CleanFolderL( TMsvId aFolderId); |
|
149 |
|
150 /** |
|
151 * Empties user folders under My Folders from SMS messages |
|
152 */ |
|
153 void CSmsAdapterMsvApi::CleanUserFoldersL(); |
|
154 |
|
155 /** |
|
156 * Empties folder from SMS messages and returns list of deleted messages |
|
157 * Caller is responsible of deleting returned list. |
|
158 * |
|
159 * @param aFolderId IN: TMsvId of the folder |
|
160 * |
|
161 * @return List of identifiers of deleted messages |
|
162 */ |
|
163 CMsvEntrySelection* CleanFolderGetMsvIdsL(TMsvId aFolderId); |
|
164 |
|
165 /** |
|
166 * Checks whether disk space is below critical level. |
|
167 * |
|
168 * @param aDataSize Size of data to be added to disk. |
|
169 */ |
|
170 TBool DiskSpaceBelowCriticalLevelL( TInt aDataSize ); |
|
171 |
|
172 /** |
|
173 * Updates SM status in inbox |
|
174 * |
|
175 * @param aSmId IN: the index to the SM |
|
176 * @param aSm IN: Contains status of the new SM |
|
177 */ |
|
178 void UpdateSMStatusL( TMsvId aSmId, CVMessageParser& aSm ); |
|
179 |
|
180 /** |
|
181 * Moves SM to another folder |
|
182 * |
|
183 * @param aSmId IN: the index to the SM |
|
184 * @param aParentId IN: Contains the target folder |
|
185 */ |
|
186 void MoveSML( TMsvId aSmId, TMsvId aParentId ); |
|
187 |
|
188 /** |
|
189 * Valid folder checks if the folder is valid. |
|
190 * The caller of the function can set, if Outbox folder is valid or not. |
|
191 * |
|
192 * @param aFolder folder |
|
193 * @param aOutboxValid if the MM is outbox is valid folder or not |
|
194 * |
|
195 * @return ETrue when the folder is valid. |
|
196 * @return EFalse when the folder is not valid. |
|
197 */ |
|
198 TBool ValidFolderL( TMsvId aFolder , TBool aOutboxValid = ETrue ); |
|
199 |
|
200 /** |
|
201 * Creates new user defined folder |
|
202 * |
|
203 * @param aFolder OUT: index of the new folder |
|
204 * @param aName IN: name of the new folder |
|
205 * |
|
206 * @return KErrNone or error |
|
207 */ |
|
208 TInt AddUserFolderL( TMsvId& aFolder, const TDesC& aName ); |
|
209 |
|
210 /** |
|
211 * Updates name of user defined folder |
|
212 * |
|
213 * @param aFolder IN: index of the folder |
|
214 * @param aName IN: new name of the folder |
|
215 * |
|
216 * @return KErrNone or error |
|
217 */ |
|
218 TInt UpdateUserFolderL( TMsvId aFolder, const TDesC& aName ); |
|
219 |
|
220 /** |
|
221 * Searches user folder with given UID |
|
222 * |
|
223 * @param aFolder IN: Folder UID |
|
224 * @param aFound OUT: name of found user folder |
|
225 * @param aDate OUT: time stamp of found user folder |
|
226 * |
|
227 * @return Return value indicates whether folder was found or not |
|
228 */ |
|
229 TBool FindUserFolderL(TMsvId aFolder, TPtrC& aName, TTime& aDate); |
|
230 |
|
231 /** |
|
232 * Searches user folder with given UID |
|
233 * |
|
234 * @param aFolder IN: Folder UID |
|
235 * |
|
236 * @return Return value indicates whether folder was found or not |
|
237 */ |
|
238 TBool FindUserFolderL(TMsvId aFolder); |
|
239 |
|
240 protected: // Functions from base classes |
|
241 |
|
242 /** |
|
243 * From MMsvSessionObserver. Message server event handler function. |
|
244 * |
|
245 * @param aEvent the caller of the method sets the value. |
|
246 * @param aArg1 depends on the aEvent value |
|
247 * @param aArg2 depends on the aEvent value |
|
248 * @param aArg3 depends on the aEvent value |
|
249 * |
|
250 */ |
|
251 virtual void HandleSessionEventL( TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3 ); |
|
252 |
|
253 private: // Internal functions |
|
254 |
|
255 /** |
|
256 * Updates existing SMS message with given values. |
|
257 * Used internally by AddSML and ReplaceSML |
|
258 * |
|
259 * @param aSmId IN: the index to the SM |
|
260 * @param aSm IN: contains data of the SM |
|
261 * @param aNewSm IN: indicates whether this SM is a new one |
|
262 */ |
|
263 void DoUpdateSML( TMsvId aSmId, CVMessageParser& aSm, TBool aNewSm ); |
|
264 |
|
265 /** |
|
266 * Check whether folder with given name exists |
|
267 * |
|
268 * @param aName IN: Folder name |
|
269 * @parem aFolder OUT: Folder UID if matching folder was found. |
|
270 * |
|
271 * @return ETrue or EFalse |
|
272 */ |
|
273 TBool FindUserFolderL(const TDesC& aName, TMsvId& aFolder); |
|
274 |
|
275 /** |
|
276 * Test whether given character needs unicode coding when constructing |
|
277 * a SMS message. |
|
278 * 7-bit coding is used if there are no unicoder characters in the message. |
|
279 * |
|
280 * @param aValue IN: Given character value |
|
281 * |
|
282 * @return ETrue if unicode coding is needed, EFalse otherwise |
|
283 */ |
|
284 TBool IsUnicode( const TUint16 aValue ); |
|
285 |
|
286 /** |
|
287 * Convert given home time to universal time. |
|
288 * |
|
289 * @param aTime IN: Home time |
|
290 * |
|
291 * @return Universal time |
|
292 */ |
|
293 TTime UniversalTimeFromHomeTime( TTime aTime ); |
|
294 |
|
295 /** |
|
296 * Convert given universal time to home time. |
|
297 * |
|
298 * @param aTime IN: Universal time |
|
299 * |
|
300 * @return Home time |
|
301 */ |
|
302 TTime HomeTimeFromUniversalTime( TTime aTime ); |
|
303 |
|
304 /** |
|
305 * Find contact name from address book for given number |
|
306 * |
|
307 * @param aTime IN: Phone number |
|
308 * @param aName OUT: Contact name, empty if suitable contact not found |
|
309 */ |
|
310 void FetchNameFromContactsL(const TDesC& aNumber, TDes& aName); |
|
311 |
|
312 |
|
313 private: // Data |
|
314 |
|
315 CMsvSession* iSession; |
|
316 CClientMtmRegistry* iMtmReg; |
|
317 CSmsClientMtm* iMtm; |
|
318 |
|
319 RFs iFs; |
|
320 TInt iMessageDrive; |
|
321 |
|
322 CContactDatabase* iContactsDb; |
|
323 |
|
324 }; |
|
325 |
|
326 #endif //SMSADAPTERMSVAPI_H |
|