40
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef OBEXUTILSMESSAGEHANDLER_H
|
|
20 |
#define OBEXUTILSMESSAGEHANDLER_H
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
#include <e32base.h>
|
|
24 |
#include <e32cmn.h>
|
|
25 |
#include <obex.h>
|
|
26 |
#include <msvapi.h>
|
|
27 |
|
|
28 |
#include <cmsvattachment.h>
|
|
29 |
#include <biodb.h>
|
|
30 |
|
|
31 |
// CLASS DECLARATION
|
|
32 |
|
|
33 |
/**
|
|
34 |
* Utility methods for message handling.
|
|
35 |
*/
|
|
36 |
class TObexUtilsMessageHandler
|
|
37 |
{
|
|
38 |
public:
|
|
39 |
|
|
40 |
/**
|
|
41 |
* Get status of file system. (in C drive)
|
|
42 |
* @return Symbian OS errorcode
|
|
43 |
*/
|
|
44 |
IMPORT_C static TInt GetFileSystemStatus();
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Get status of file system in MMC.
|
|
48 |
* @return Symbian OS errorcode
|
|
49 |
*/
|
|
50 |
IMPORT_C static TInt GetMmcFileSystemStatus();
|
|
51 |
|
|
52 |
/**
|
|
53 |
* Get current message centre drive
|
|
54 |
* @return Drive unit of the message centre drive
|
|
55 |
*/
|
|
56 |
IMPORT_C static TInt GetMessageCentreDriveL();
|
|
57 |
|
|
58 |
/**
|
|
59 |
* Creates default Mtm service
|
|
60 |
* @param aMtm Mtm
|
|
61 |
*/
|
|
62 |
IMPORT_C static void CreateDefaultMtmServiceL(TUid aMtm);
|
|
63 |
|
|
64 |
/**
|
|
65 |
* Saves received object to Inbox.
|
|
66 |
* @param aReceivedObject The object to be saved.
|
|
67 |
* @param aDrive The current messaging drive.
|
|
68 |
* @param aMtmID The message type module id.
|
|
69 |
* @return None.
|
|
70 |
*/
|
|
71 |
IMPORT_C static void SaveObjToInboxL( CObexBufObject* aReceivedObject,
|
|
72 |
const TDesC16& aPath,
|
|
73 |
const TUid aMtmID );
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Creates an Outbox entry
|
|
77 |
* @param aMTm Message type id
|
|
78 |
* @param aResourceID Resource id for the message entry text
|
|
79 |
* @return Message server entry.
|
|
80 |
*/
|
|
81 |
IMPORT_C static TMsvId CreateOutboxEntryL( const TUid& aMtm, const TInt& aResourceID );
|
|
82 |
|
|
83 |
/**
|
|
84 |
* Deletes an Outbox entry
|
|
85 |
* @param aMessageServerIndex Message server entry
|
|
86 |
* @return None.
|
|
87 |
*/
|
|
88 |
IMPORT_C static void DeleteOutboxEntryL( const TMsvId& aMessageServerIndex );
|
|
89 |
|
|
90 |
/**
|
|
91 |
* Create inbox attachment and entries.
|
|
92 |
* @param aBufObject The object to be saved
|
|
93 |
* @param aMtmId MTM Id
|
|
94 |
* @param aMsvIdParent Parent message entry (returned)
|
|
95 |
* @param aFile File to the attachment (returned)
|
|
96 |
* @return None.
|
|
97 |
*/
|
|
98 |
IMPORT_C static void CreateInboxAttachmentL(
|
|
99 |
CObexBufObject* &aBufObject,
|
|
100 |
const TUid aMtmId,
|
|
101 |
TMsvId &aMsvIdParent,
|
|
102 |
RFile &aFile);
|
|
103 |
|
|
104 |
/**
|
|
105 |
* Create inbox attachment and entries.
|
|
106 |
* @param aBufObject The object to be saved
|
|
107 |
* @param aMtmId MTM Id
|
|
108 |
* @param aMsvIdParent Parent message entry (returned)
|
|
109 |
* @param aFile File to the attachment (returned)
|
|
110 |
* @param aRemoteBluetoothName sender's bluetooth name.
|
|
111 |
* @return None.
|
|
112 |
*/
|
|
113 |
IMPORT_C static void CreateInboxAttachmentL(
|
|
114 |
CObexBufObject* &aBufObject,
|
|
115 |
const TUid aMtmId,
|
|
116 |
TMsvId &aMsvIdParent,
|
|
117 |
RFile &aFile,
|
|
118 |
const TDesC& aRemoteBluetoothName);
|
|
119 |
|
|
120 |
/**
|
|
121 |
* Saves received object to Inbox.
|
|
122 |
* @param aReceivedObject The object to be saved (set to null after remove).
|
|
123 |
* @param aFile File to the attachment
|
|
124 |
* @param aMsvIdParent Parent message entry
|
|
125 |
* @return None.
|
|
126 |
*/
|
|
127 |
IMPORT_C static void SaveObjToInboxL(
|
|
128 |
CObexBufObject* &aReceivedObject,
|
|
129 |
RFile &aFile,
|
|
130 |
TMsvId aMsvIdParent);
|
|
131 |
|
|
132 |
/**
|
|
133 |
* Remove unfinished work from inbox
|
|
134 |
* @param aBufObject The object to be saved (set to null after remove)
|
|
135 |
* @param aMsvIdParent Parent message entry
|
|
136 |
* @return None.
|
|
137 |
*/
|
|
138 |
IMPORT_C static void RemoveInboxEntriesL(CObexBufObject* &aBufObject, TMsvId aMsvIdParent);
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Gets central repository key's integer value
|
|
142 |
* @param aRepositoryUid Central repository's UID value
|
|
143 |
* @param aId Central repository's ID value
|
|
144 |
* @param aVal Returned integer value
|
|
145 |
* @return Symbian OS errorcode
|
|
146 |
*/
|
|
147 |
IMPORT_C static TInt GetCenRepKeyIntValueL(TUid aRepositoryUid, TUint32 aId, TInt& aVal);
|
|
148 |
|
|
149 |
/**
|
|
150 |
* Gets central repository key's string value
|
|
151 |
* @param aRepositoryUid Central repository's UID value
|
|
152 |
* @param aId Central repository's ID value
|
|
153 |
* @param aVal Returned string value
|
|
154 |
* @return Symbian OS errorcode
|
|
155 |
*/
|
|
156 |
|
|
157 |
IMPORT_C static TInt GetCenRepKeyStringValueL(TUid aRepositoryUid, TUint32 aId, TDes& aVal);
|
|
158 |
|
|
159 |
/**
|
|
160 |
* Gets Publish & Subscribe key's integer value
|
|
161 |
* @param aCategory Category of the key
|
|
162 |
* @param aKey PUBSUB Key
|
|
163 |
* @param value Returned value
|
|
164 |
* @return Symbian OS errorcode
|
|
165 |
*/
|
|
166 |
IMPORT_C static TInt GetPubSubKeyIntValue(TUid aCategory, TUint aKey, TInt& value);
|
|
167 |
|
|
168 |
/**
|
|
169 |
* Create receive buffer and RFile object.
|
|
170 |
* @Since S60 v5.0
|
|
171 |
* @param aFile File to temp file
|
|
172 |
* @param aPath Path The directory in which the file is created
|
|
173 |
* @param aFullName Contains the full path and file name of the file (returned)
|
|
174 |
* @param aReceiveObject Obex object for receive buffer ( returned )
|
|
175 |
* @param aBufSize Size of receive buffer
|
|
176 |
* @return Symbian error code.
|
|
177 |
*/
|
|
178 |
IMPORT_C static TInt CreateReceiveBufferAndRFileL ( RFile& aFile,
|
|
179 |
const TDesC& aPath,
|
|
180 |
TFileName& aFullName,
|
|
181 |
CBufFlat* &aReceiveObject,
|
|
182 |
const TInt aBufSize );
|
|
183 |
|
|
184 |
/**
|
|
185 |
* Remove temporary RFile object.
|
|
186 |
* @Since S60 v5.0
|
|
187 |
* @param aFullName Contains the full path and file name of the file
|
|
188 |
* @return Symbian error code.
|
|
189 |
*/
|
|
190 |
IMPORT_C static void RemoveTemporaryRFileL ( const TFileName& aFullName );
|
|
191 |
|
|
192 |
/**
|
|
193 |
* Create inbox entries and saves received object to file system
|
|
194 |
* @Since S60 v5.0
|
|
195 |
* @param aReceiveObject Obex object for receive buffer
|
|
196 |
* @param aMtmId MTM Id
|
|
197 |
* @param aMsvIdParent Parent message entry (returned)
|
|
198 |
* @param aFullName The directory and file name in which the file is saved (returned)
|
|
199 |
* @param aFile File handler identical with the one in CreateReceiveBufferAndRFileL()
|
|
200 |
* it must be opened before use.
|
|
201 |
* @return None
|
|
202 |
*/
|
|
203 |
IMPORT_C static void SaveFileToFileSystemL(CObexBufObject* &aReceiveObject,
|
|
204 |
const TUid aMtmId,
|
|
205 |
TMsvId& aMsvIdParent,
|
|
206 |
TFileName& aFullName,
|
|
207 |
RFile& aFile,
|
|
208 |
const TDesC& aSenderBluetoothName);
|
|
209 |
|
|
210 |
/**
|
|
211 |
* Add an entry to Inbox
|
|
212 |
* @Since S60 v5.0
|
|
213 |
* @param aMsvIdParent Parent message entry
|
|
214 |
* @param aFullName Contains the full path and file name of the file
|
|
215 |
* @return None
|
|
216 |
*/
|
|
217 |
IMPORT_C static void AddEntryToInboxL( TMsvId& aMsvIdParent,
|
|
218 |
TFileName& aFullName);
|
|
219 |
|
|
220 |
/**
|
|
221 |
* Add an entry to Inbox
|
|
222 |
* @Since S60 v5.0
|
|
223 |
* @param aMsvIdParent Parent message entry
|
|
224 |
* @param aFullName Contains the full path and file name of the file
|
|
225 |
* @param aMsvIdArray an array contains a list of TMsvId ( returned )
|
|
226 |
* @return None
|
|
227 |
*/
|
|
228 |
IMPORT_C static void AddEntryToInboxL( TMsvId& aMsvIdParent,
|
|
229 |
TFileName& aFullName,
|
|
230 |
RArray<TMsvId>* aMsvIdArray);
|
|
231 |
|
|
232 |
/**
|
|
233 |
* Update entry attachmeent in Inbox
|
|
234 |
* @Since S60 v5.0
|
|
235 |
* @param aFullName Contains the full path and file name of the file
|
|
236 |
* @param aMsvIdParent Parent message entry
|
|
237 |
* @return None
|
|
238 |
*/
|
|
239 |
IMPORT_C static void UpdateEntryAttachmentL ( TFileName& aFullName,CMsvEntry* aParentEntry );
|
|
240 |
|
|
241 |
|
|
242 |
|
|
243 |
private:
|
|
244 |
|
|
245 |
class CDummySessionObserver;
|
|
246 |
class TReceivedData;
|
|
247 |
|
|
248 |
/**
|
|
249 |
* Create inbox attachment and entries.
|
|
250 |
* @param aMtmId Mtm ID of the message
|
|
251 |
* @param aMsvIdParent Parent message entry (returned)
|
|
252 |
* @param aFile File to the attachment (returned)
|
|
253 |
* @param aRemoteBluetoothName sender's bluetooth name.
|
|
254 |
*/
|
|
255 |
static void DoCreateInboxAttachmentL(
|
|
256 |
const TUid aMtmId,
|
|
257 |
TMsvId &aMsvIdParent,
|
|
258 |
RFile &aFile,
|
|
259 |
const TDesC& aRemoteBluetoothName = KNullDesC);
|
|
260 |
|
|
261 |
/**
|
|
262 |
* Deletes Obex Buf Object buffer
|
|
263 |
* @param aBufObject The buffer object
|
|
264 |
* @return None.
|
|
265 |
*/
|
|
266 |
static void RemoveObexBuffer(CObexBufObject* &aBufObject);
|
|
267 |
|
|
268 |
/*
|
|
269 |
* Creates Msv session
|
|
270 |
* @param aSessionObs Session observer
|
|
271 |
* @param aMsvSession Session
|
|
272 |
*/
|
|
273 |
static void CreateMsvSessionLC(
|
|
274 |
CDummySessionObserver* &aSessionObs,
|
|
275 |
CMsvSession* &aMsvSession);
|
|
276 |
|
|
277 |
/*
|
|
278 |
* Creates Msv session to selected destination
|
|
279 |
* @param aSessionObs Session observer
|
|
280 |
* @param aMsvSession Session
|
|
281 |
* @param aDestination Destination
|
|
282 |
* @param aMsvId Destination type
|
|
283 |
*/
|
|
284 |
static void CreateMsvSessionLC(
|
|
285 |
CDummySessionObserver* &aSessionObs,
|
|
286 |
CMsvSession* &aMsvSession,
|
|
287 |
CMsvEntry* &aDestination,
|
|
288 |
TMsvId aMsvId);
|
|
289 |
|
|
290 |
/**
|
|
291 |
* Gets current time
|
|
292 |
* @return None.
|
|
293 |
*/
|
|
294 |
static TTime GetCurrentTime();
|
|
295 |
|
|
296 |
/**
|
|
297 |
* Stores message as rich text
|
|
298 |
* @param aParentEntry Parent entry
|
|
299 |
* @param aFile File to store to the message entry's store
|
|
300 |
* @return None.
|
|
301 |
*/
|
|
302 |
static void StoreAsRichTextL(CMsvEntry* aParentEntry, RFile& aFile);
|
|
303 |
|
|
304 |
/**
|
|
305 |
* Updates attachment's information
|
|
306 |
* @param aRecData Received obex data
|
|
307 |
* @param aAttachEntry Attachment entry
|
|
308 |
* @param aAttachInfo Attachment information
|
|
309 |
* @param aStore Message store (attachment)
|
|
310 |
* @return None.
|
|
311 |
*/
|
|
312 |
static void UpdateAttachmentInformationL(
|
|
313 |
TReceivedData& aRecData,
|
|
314 |
CMsvEntry* aAttachEntry,
|
|
315 |
CMsvAttachment* aAttachInfo,
|
|
316 |
CMsvStore* aStore);
|
|
317 |
|
|
318 |
/**
|
|
319 |
* Finalises the parent entry to contain correct data
|
|
320 |
* @param aParentEntry Parent entry
|
|
321 |
* @param aReceivedData Received obex data
|
|
322 |
* @param aStore Attachment's store
|
|
323 |
* @param aIsBioMsg Is BIO message?
|
|
324 |
* @return None.
|
|
325 |
*/
|
|
326 |
static void FinaliseMessageL(
|
|
327 |
CMsvEntry* aParentEntry,
|
|
328 |
TReceivedData& aRecData,
|
|
329 |
CMsvStore* aStore,
|
|
330 |
TBool aIsBioMsg);
|
|
331 |
|
|
332 |
/**
|
|
333 |
* Finalises the parent entry to contain correct data
|
|
334 |
* @Since v5.0
|
|
335 |
* @param aParentEntry Parent entry
|
|
336 |
* @param aStore Attachment's store
|
|
337 |
* @param aFileEntry a file entry
|
|
338 |
* @param aFileNameParser a file name parser
|
|
339 |
* @return None.
|
|
340 |
*/
|
|
341 |
static void FinaliseMessageL(
|
|
342 |
CMsvEntry* aParentEntry,
|
|
343 |
CMsvStore* aStore,
|
|
344 |
TEntry& aFileEntry,
|
|
345 |
TParse& aFileNameParser);
|
|
346 |
|
|
347 |
/**
|
|
348 |
* Stores BIO message to parent entry's body and updates information
|
|
349 |
* @param aBioDB BIO database for a BIO message
|
|
350 |
* @param parentEntry Parent entry
|
|
351 |
* @param aFile File to save to parent entry's body
|
|
352 |
* @return None.
|
|
353 |
*/
|
|
354 |
static void StoreAndUpdateBioMessageL(
|
|
355 |
CBIODatabase* aBioDB,
|
|
356 |
TUid aBioMsgId,
|
|
357 |
CMsvEntry* parentEntry,
|
|
358 |
RFile& aFile);
|
|
359 |
|
|
360 |
/**
|
|
361 |
* Recognises MIME type of a file
|
|
362 |
* @param aFile File to recognise
|
|
363 |
* @param aAttachInfo Attachment information
|
|
364 |
* @return None.
|
|
365 |
*/
|
|
366 |
static void RecogniseObjectsL(
|
|
367 |
TFileName& aFileName,
|
|
368 |
CMsvAttachment* aAttachInfo);
|
|
369 |
|
|
370 |
/**
|
|
371 |
* Saves MIME type and gets BIO for that MIME type
|
|
372 |
* @param aFile File to be recognised
|
|
373 |
* @param aFsSess File session to use for BIO database
|
|
374 |
* @param aAttachInfo Attachment information
|
|
375 |
* @param aBioMsgId Returned BIO message's ID
|
|
376 |
* @return BIO database for a MIME type (null if not BIO)
|
|
377 |
*/
|
|
378 |
static CBIODatabase* SaveMimeAndGetBioLC(
|
|
379 |
TFileName& aFileName,
|
|
380 |
RFs& aFsSess,
|
|
381 |
CMsvAttachment* aAttachInfo,
|
|
382 |
TUid &aBioMsgId);
|
|
383 |
|
|
384 |
/**
|
|
385 |
* Constructs rich text
|
|
386 |
* @return Text in rich text.
|
|
387 |
*/
|
|
388 |
static CRichText* ConstructRichTextLC();
|
|
389 |
|
|
390 |
/**
|
|
391 |
* Makes a valid OS filesystem filename by removing illegal characters
|
|
392 |
* @param aFileSession File server filesession
|
|
393 |
* @param aFileName File name to check and modify
|
|
394 |
* @return None.
|
|
395 |
*/
|
|
396 |
static void MakeValidFileName(RFs& aFileSession, TDes& aFileName);
|
|
397 |
|
|
398 |
/**
|
|
399 |
* Converts text from UTF-8 to two-byte Unicode
|
|
400 |
* @param aText destination where to store the converted text
|
|
401 |
* @param aType source of conversion in UTF-8
|
|
402 |
* @return None.
|
|
403 |
*/
|
|
404 |
static void SetBioDataTextL(TBioMsgIdText& aText, const TDesC8& aType);
|
|
405 |
|
|
406 |
/**
|
|
407 |
* Converts text from UTF-8 to two-byte Unicode
|
|
408 |
* @param aDetails destination where to store the converted text
|
|
409 |
* @param aType source of conversion in UTF-8
|
|
410 |
* @return None.
|
|
411 |
*/
|
|
412 |
static void SetDetailsLC(
|
|
413 |
TPtrC& aDetails,
|
|
414 |
const TDesC8& aType);
|
|
415 |
|
|
416 |
|
|
417 |
/**
|
|
418 |
* Rename file and move file if needed.
|
|
419 |
* @Since S60 v5.0
|
|
420 |
* @param anOldFileName a file name with absolute path ( returned )
|
|
421 |
* @param aNewFileName new path where file will be moved to
|
|
422 |
* @param aFileSession a file session
|
|
423 |
* @return None
|
|
424 |
*/
|
|
425 |
static TInt RenameFileL(TFileName& aFileName,
|
|
426 |
TFileName& aNewFileName,
|
|
427 |
const TDesC& aNewPath,
|
|
428 |
RFs& aFileSession);
|
|
429 |
|
|
430 |
/**
|
|
431 |
* Rename filename with a segement number.
|
|
432 |
* @Since S60 v5.0
|
|
433 |
* @param aFilename name of the file ( returned )
|
|
434 |
* @param aSegmentNum number used to modifed the file name
|
|
435 |
* @param aSegmentString string will be added to filename to solve the duplicate filenames
|
|
436 |
* @return None.
|
|
437 |
*/
|
|
438 |
static TInt RenameFileWithSegmentNumL(
|
|
439 |
TDes& aFileName,
|
|
440 |
TInt aSegmentNum,
|
|
441 |
TDes& aSegementString);
|
|
442 |
|
|
443 |
/**
|
|
444 |
* FixExtremeLongFileName
|
|
445 |
* @param aFileName extreme long file name (returned)
|
|
446 |
* @param aDriveAndPath file drive and path
|
|
447 |
* @return None
|
|
448 |
*/
|
|
449 |
static void FixExtremeLongFileName(TFileName& aExtremeLongFileName, const TDesC& aDriveAndPath);
|
|
450 |
|
|
451 |
|
|
452 |
/**
|
|
453 |
* A dummy class for opening CMsvSession.
|
|
454 |
*/
|
|
455 |
class CDummySessionObserver : public CBase , public MMsvSessionObserver
|
|
456 |
{
|
|
457 |
public:
|
|
458 |
void HandleSessionEventL( TMsvSessionEvent/*aEvent*/,
|
|
459 |
TAny* /*aArg1*/,
|
|
460 |
TAny* /*aArg2*/,
|
|
461 |
TAny* /*aArg3*/ ) {};
|
|
462 |
};
|
|
463 |
|
|
464 |
/**
|
|
465 |
* Class for obex received data
|
|
466 |
*/
|
|
467 |
class TReceivedData
|
|
468 |
{
|
|
469 |
public:
|
|
470 |
TInt bytesReceived;
|
|
471 |
TTime recTime;
|
|
472 |
TFileName msgName;
|
|
473 |
};
|
|
474 |
|
|
475 |
};
|
|
476 |
|
|
477 |
#endif // OBEXUTILSMESSAGEHANDLER_H
|
|
478 |
|
|
479 |
// End of File
|