1 // Copyright (c) 1998-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
26 Specifies an entry in the Message Server index.
29 @see #KMsvNullIndexEntryId
30 @see #KMsvTempIndexEntryId
31 @see #KMsvRootIndexEntryId
32 @see #KMsvLocalServiceIndexEntryId
33 @see #KMsvGlobalInBoxIndexEntryId
34 @see #KMsvGlobalOutBoxIndexEntryId
35 @see #KMsvDraftEntryId
37 @see #KMsvDeletedEntryFolderEntryId
38 @see #KMsvUnknownServiceIndexEntryId
40 typedef TInt32 TMsvId;
42 /** Identifies an asynchronous messaging operation.
44 This ID is unique within a
45 Message Server session. The ID of an operation can be obtained from CMsvOperation::Id(). */
46 typedef TInt32 TMsvOp;
48 /** Supplies the standard values for the message priority index entry field.
53 /** High message priority */
55 /** Medium message priority */
57 /** Low message priority */
65 class CMsvServerEntry;
67 _LIT(KMsvDefaultFolder, "\\Private\\1000484b\\Mail\\");
68 _LIT(KMsvDefaultIndexFile, "\\Private\\1000484b\\Mail\\Index");
69 _LIT(KMsvDefaultFolder2, "\\Private\\1000484b\\Mail2\\");
70 _LIT(KMsvDefaultIndexFile2, "\\Private\\1000484b\\Mail2\\Index");
71 _LIT(KMsvDirectoryExt, "_S\\");
72 _LIT(KMsvBinaryFolderExt, "_F\\");
74 const TInt KFileNameFixedWidth=8;
75 const TInt KMaxSubjectSkipStringLength=8; // For subject based email thread sorting
76 _LIT(KSendAsRenderedImage, "Image");
78 // Server name and moving semaphore
79 _LIT(KMsvServerName, "!MsvServer");
80 _LIT(KMsvMovingSemaphore, "MsvMovingSemaphore");
82 _LIT_SECURE_ID(KMsvServerId, 0x1000484B);
85 /** Represents an entry in the Message Server index.
87 MTM implementations and message client applications use it to access and manipulate
88 index entry values. Note that a TMsvEntry is effectively a local cache of
89 the index entry, and changes to it are not automatically written into the
90 index. To commit changes to the Message Server, you need to call CMsvEntry::ChangeL()
91 (or CMsvServerEntry::ChangeEntry()).
93 To avoid repetition, the functions and data members are simply listed here,
94 without detailed explanation of the fields. The public data members can be
95 used to get and set the values of some index entry fields.
102 IMPORT_C TMsvEntry();
103 IMPORT_C TMsvEntry(const TMsvEntry& aEntry);
104 IMPORT_C TMsvEntry& operator=(const TMsvEntry& aEntry);
105 IMPORT_C TBool operator==(const TMsvEntry& aEntry) const;
106 IMPORT_C TBool PermanentDataUnchanged(const TMsvEntry& aEntry) const;
108 IMPORT_C TMsvPriority Priority() const;
109 IMPORT_C void SetPriority(TMsvPriority aPriority);
111 IMPORT_C void InternalizeL(RReadStream& aStream);
112 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
113 // Read only for clients
114 inline TMsvId Id() const;
115 inline TMsvId Parent() const;
116 inline TBool Owner() const;
117 inline TBool Deleted() const;
118 // Read & write for clients
119 inline TBool Complete() const;
120 inline void SetComplete(TBool aComplete);
121 inline TBool New() const;
122 inline void SetNew(TBool aNew);
123 inline TBool Unread() const;
124 inline void SetUnread(TBool aUnread);
125 inline TBool Failed() const;
126 inline void SetFailed(TBool aFailed);
127 inline TBool Operation() const;
128 inline void SetOperation(TBool aOperation);
129 inline TBool Visible() const;
130 inline void SetVisible(TBool aVisble);
131 inline TBool MultipleRecipients() const;
132 inline void SetMultipleRecipients(TBool aMultipleRecipient);
133 inline TBool ReadOnly() const;
134 inline void SetReadOnly(TBool aReadOnly);
135 inline TBool StandardFolder() const;
136 inline void SetStandardFolder(TBool aStanardFolder);
137 inline TBool Attachment() const;
138 inline void SetAttachment(TBool aAttachmentFlag);
139 inline TBool Connected() const;
140 inline void SetConnected(TBool aConnected);
141 inline TBool InPreparation() const;
142 inline void SetInPreparation(TBool aInPreparation);
144 inline TInt PcSyncCount() const;
145 inline void DecPcSyncCount();
146 inline void IncPcSyncCount();
148 inline TBool OffPeak() const;
149 inline void SetOffPeak(TBool aOffPeak);
150 inline TBool Scheduled() const;
151 inline void SetScheduled(TBool aScheduled);
152 inline TUint SendingState() const;
153 inline void SetSendingState(TUint aSendingState);
154 inline TBool PendingDelete() const;
155 inline void SetPendingDelete(TBool aPendingDelete);
157 /** This method sets bit 24 of iMtmData1, if you are using this bit elsewhere don't call this method.*/
158 inline void SetDeleteProtected(TBool aDeleteProtected);
159 inline TBool DeleteProtected() const;
160 /** This method sets bit 31 of iMtmData1, if you are using this bit elsewhere don't call this method.*/
161 inline void SetForwarded(TBool aForwarded);
162 inline TBool Forwarded() const;
163 /** This method sets bit 32 of iMtmData1, if you are using this bit elsewhere don't call this method.*/
164 inline void SetLocallyDeleted(TBool aLocallyDeleted);
165 inline TBool LocallyDeleted() const;
167 IMPORT_C TBool PendingConditions() const;
168 IMPORT_C void SetPendingConditions(TBool aPendingConditions);
170 IMPORT_C TInt32 MtmData1() const;
171 IMPORT_C TInt32 MtmData2() const;
172 IMPORT_C TInt32 MtmData3() const;
177 IMPORT_C void SetMtmData1(TInt32 aMtmData);
181 IMPORT_C void SetMtmData2(TInt32 aMtmData);
185 IMPORT_C void SetMtmData3(TInt32 aMtmData);
188 // only the server will be able to set the following
189 inline void SetId(TMsvId aId);
190 inline void SetParent(TMsvId aId);
191 inline void SetOwner(TBool aAttachment);
192 inline void SetDeleted(TBool aDeletedFlag);
194 inline TUint PersistedFlags() const;
195 inline TUint TemporaryFlags() const;
198 void Copy(const TMsvEntry& aEntry);
205 TInt32 iReserved; // reserved for future proofing
209 /** Related folder ID. */
221 /** BIO message type */
223 // following three can be used by MTM
224 /** MTM data 1: this can be used for any purpose by an MTM. This member must
225 only be accessed through the predefined set and get functions. If you must
226 write data to a bit that has no meaning in the predefined derived classes
227 then you must derive your own class from TMsvEntry.
230 /** MTM data 2: this can be used for any purpose by an MTM. This member must
231 only be accessed through the predefined set and get functions. If you must
232 write data to a bit that has no meaning in the predefined derived classes
233 then you must derive your own class from TMsvEntry.
236 /** MTM data 3: this can be used for any purpose by an MTM. This member must
237 only be accessed through the predefined set and get functions. If you must
238 write data to a bit that has no meaning in the predefined derived classes
239 then you must derive your own class from TMsvEntry.
243 // The TPtrC must be kept at end of class to simplify comparisons and initialisation
252 friend class CMsvEntry;
253 friend class CMsvServer;
254 friend class CMsvServerEntry;
255 friend class CMsvClientEntry;
256 friend class CMsvServerSession;
257 friend class TMsvServerEntry;
258 friend class CMsvServerIndex;
259 friend class RMsvServerSession;
260 friend class CMsvLocalCopyOperation;
261 friend class CMsvMove;
262 friend class CMsvIndexRebuild;
263 friend class CMsvCopyEntry;
264 friend class CMsvDelete;
265 friend class CMsvIndexContext;
266 friend class CMsvEntryArray;
270 enum { KMsvEntryPriorityMask= 0x00000003,
271 KMsvEntryHighPriority= 0x00000002,
272 KMsvEntryMediumPriority= 0x00000001,
273 KMsvEntryLowPriority= 0x00000000,
274 KMsvEntryClearFlag= 0x00000000,
275 KMsvOffPeakFlag= 0x00000004,
276 KMsvEntryNotCompleteFlag= 0x00000008,
277 KMsvEntryNewFlag= 0x00000010,
278 KMsvEntryUnreadFlag= 0x00000020,
279 KMsvEntryFailedFlag= 0x00000040,
280 KMsvEntryOperationFlag= 0x00000080,
281 KMsvEntryOwnerFlag= 0x00000100,
282 KMsvEntryInvisibleFlag= 0x00000200,
283 KMsvEntryMultipleRecipientFlag= 0x00000400,
284 KMsvScheduledFlag= 0x00000800,
285 KMsvEntryReadOnlyFlag= 0x00001000,
286 KMsvEntryDeletedFlag= 0x00002000,
287 KMsvEntryStandardFolderFlag= 0x00004000,
288 KMsvEntryAttachmentFlag= 0x00008000,
289 KMsvEntryInPreparationFlag= 0x00010000,
290 KMsvSendingStateFlags= 0x001E0000, // Note: Sending state is shifted KMsvSendingStateShift places left
291 KMsvEntryPersistedFlags= 0x00FFFFFF,
292 KMsvEntryPendingConditionsFlag= 0x00800000,
293 KMsvEntryTemporaryFlags= 0xFF000000,
294 KMsvEntryConnectedFlag= 0x01000000,
295 KMsvEntryPendingDeleteFlag= 0x02000000};
299 KMsvEntryDeleteProtected= 0x800000,
300 KMsvEntryForwarded= 0x40000000,
301 KMsvEntryLocallyDeleted= 0x80000000
304 const TUint KMsvSendingStateShift=0x11; // Places to shift sending state
306 /** Defines sending state flags.
312 /** State unknown. */
313 KMsvSendStateUnknown = 0x0,
314 /** Message will be sent on request. */
315 KMsvSendStateUponRequest = 0x1,
316 /** Waiting to be sent.
318 Messages in the outbox with this state can be sent automatically by the relevant
319 MTM once an appropriate connection is established. */
320 KMsvSendStateWaiting = 0x2,
321 /** Sending in progress. */
322 KMsvSendStateSending = 0x3,
323 /** Sending scheduled. */
324 KMsvSendStateScheduled = 0x4,
326 KMsvSendStateResend = 0x5,
327 /** Sending suspended. */
328 KMsvSendStateSuspended = 0x6,
329 /** Sending failed. */
330 KMsvSendStateFailed = 0x7,
331 /** Sending complete. */
332 KMsvSendStateSent = 0x8,
333 /** Not applicable. */
334 KMsvSendStateNotApplicable = 0x9
337 const TUint KMsvSendStateLast = KMsvSendStateNotApplicable;
338 const TUint KMsvSendStateMax = 0x0F;
340 /** Supplies values for bitmasks that allows the rapid setting or clearing of a
341 number of TMsvEntry fields.
343 The fields that can be manipulated are:
345 1. PC synchronisation
351 4. In-preparation flag
355 6. Pending deletion flag.
360 @see CMsvSession::ChangeAttributesL()
361 @see CMsvServerEntry::ChangeAttributes()
366 /** PC synchronisation field. */
367 KMsvPcSyncCountAttribute =0x00000001,
368 /** Visibility flag field. */
369 KMsvVisibilityAttribute =0x00000200,
370 /** Read flag field. */
371 KMsvUnreadAttribute =0x00000020,
372 /** In-preparation field. */
373 KMsvInPreparationAttribute =0x00010000,
374 /** Connected flag field. */
375 KMsvConnectedAttribute =0x01000000,
376 /** Pending deletion flag. */
377 KMsvPendingDeleteAttribute =0x02000000,
378 /** New flag field. */
379 KMsvNewAttribute =0x00000010};
381 /** Defines the sort order options for a TMsvSelectionOrdering object. Options
382 are set through TMsvSelectionOrdering::SetSorting().
384 @see TMsvSelectionOrdering
391 EMsvSortByNone=0, // Don't sort
392 /** Date (earliest-latest) */
393 EMsvSortByDate, // Date (earliest-latest)
394 /** Date (latest-earliest) */
395 EMsvSortByDateReverse, // Date (latest-earliest)
396 /** Size (smallest-largest) */
397 EMsvSortBySize, // Size (smallest-largest)
398 /** Size (largest-smallest) */
399 EMsvSortBySizeReverse, // Size (largest-smallest)
400 /** To/From (A-Z folded) */
401 EMsvSortByDetails, // ToFrom (A-Z collated)
402 /** To/From (Z-A folded) */
403 EMsvSortByDetailsReverse, // ToFrom (Z-A collated)
404 /** Description (A-Z folded) */
405 EMsvSortByDescription, // Description (A-Z collated)
406 /** Description (Z-A folded) */
407 EMsvSortByDescriptionReverse, // Description (Z-A collated)
408 /** Sort by message ID. */
409 EMsvSortById, // Id (lowest-highest)
410 /** Sort in reverse order by message ID. */
411 EMsvSortByIdReverse // Id (highest-lowest)
414 /** Defines grouping order options for a TMsvEntrySelection object. Grouping options
415 can be combined in a bitmask and set through the TMsvEntrySelection constructor
422 KMsvNoGrouping=0, // No grouping
423 /** Group by entry type, in order, services, folders, messages, attachments */
424 KMsvGroupByType=0x2, // Folder, Message, Attachment
425 /** Place standard folders first, in the order they were created */
426 KMsvGroupByStandardFolders=0x6, // Standrad folders first (must have sorting by type set aswell)
427 /** Group by message priority, in order, high, medium, then low */
428 KMsvGroupByPriority=0x8, // High, Mediem, Low
429 /** Group by MTM, either in the order set by CMsvEntry::SetMtmListL() or by MTM
431 KMsvGroupByMtm=0x10, // By increasing uid value
434 /** Defines the sorting and grouping rules used to prepare a selection of entries.
436 It is used in the interfaces of CMsvEntry and CMsvServerEntry to set the ordering
437 of an entry's children.
439 Firstly, the entries will be grouped, if the appropriate grouping option is
442 1. Standard folders: any entries marked as standard folders are placed first,
443 in the order they were created.
445 2. Entry type: in the order services, folders, messages, attachments, unknown
447 3. Priority: in the order high, medium, then low
449 4. MTM: either in the MTM order set by CMsvEntry::SetMtmListL() or just in MTM
452 Grouping options are simply Boolean flags that can be set on or off by functions
455 Secondly, the order of entries within these groups is defined by a sorting
463 class TMsvSelectionOrdering
466 IMPORT_C TMsvSelectionOrdering();
467 IMPORT_C TMsvSelectionOrdering(TInt aGroupingKey, TMsvSorting aSorting, TBool aShowInvisible=EFalse);
468 IMPORT_C void InternalizeL(RReadStream& aStream);
469 IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
470 IMPORT_C TBool operator==(const TMsvSelectionOrdering& aOrdering) const;
471 IMPORT_C void SetSubjectSkipString(const TDesC& aSubjectSkipString);
472 IMPORT_C const TDesC& SubjectSkipString() const;
475 inline TMsvSorting Sorting() const;
476 inline TBool GroupByType() const;
477 inline TBool GroupStandardFolders() const;
478 inline TBool GroupByPriority() const;
479 inline TBool GroupByMtm() const;
480 inline TBool ShowInvisibleEntries() const;
481 inline TBool GroupingOn() const;
483 inline void SetGroupByType(TBool aFlag);
484 inline void SetGroupStandardFolders(TBool aFlag);
485 inline void SetGroupByPriority(TBool aFlag);
486 inline void SetGroupByMtm(TBool aFlag);
487 inline void SetShowInvisibleEntries(TBool aFlag);
488 inline void SetSorting(TMsvSorting aSortType);
494 enum TMsvGroupingPrivate
496 KMsvInvisibleFlag=0x1,
497 KMsvStandardFolders=0x4,
498 KMsvAllGroupingFlags=0x1e
501 TMsvSorting iSortType;
502 TBuf<KMaxSubjectSkipStringLength> iSubjectSkipString;
505 const TInt KMsvInvisibleFlag=1;
507 /** Encapsulates an array of entry IDs.
509 An object of this type is commonly passed to a function to indicate the set
510 of entries on which the function should operate. The array base class (CArrayFixFlat<TMsvId>)
511 provide methods to access, sort, and manipulate members of the array.
516 class CMsvEntrySelection : public CArrayFixFlat<TMsvId>
519 IMPORT_C CMsvEntrySelection();
520 IMPORT_C CMsvEntrySelection* CopyL() const;
521 IMPORT_C CMsvEntrySelection* CopyLC() const;
522 IMPORT_C TInt Find(TMsvId aId) const;
525 /** Specifies a default service for a MTM.
530 class TMsvDefaultService
533 /** MTM for which the default service is specified. */
535 /** ID of the default service. */
541 /** Used to query the Message Server for entries that match the specification defined
544 It allows a query to be performed on service, MTM, type and last change date.
545 The filter also enables the specification of the order in which the entries
548 @see CMsvSession::GetChildIdsL()
552 class CMsvEntryFilter : public CBase
555 IMPORT_C static CMsvEntryFilter* NewLC();
556 IMPORT_C static CMsvEntryFilter* NewL();
559 inline TMsvId Service() const;
560 inline void SetService(TMsvId aServiceId);
562 inline TUid Mtm() const;
563 inline void SetMtm(TUid aMtm);
565 inline TUid Type() const;
566 inline void SetType(TUid aType);
568 inline const TTime& LastChangeDate() const;
569 inline void SetLastChangeDate(const TTime& aLastChange);
571 inline const TMsvSelectionOrdering& Order() const;
572 inline void SetOrder(const TMsvSelectionOrdering& aOrder);
574 inline TUid SortMtm() const;
575 inline void SetSortMtm(TUid aSortMtm);
585 TMsvSelectionOrdering iOrdering;
589 // Error resolver leave codes -7000 to -7127
590 /** Defines error codes that relate to the Message Server.
592 @see MMsvEntryObserver::EMsvContextInvalid
596 enum TMsvResolverLeave
598 /** There is no disk in the drive containing the Message Server index. */
599 KMsvMediaUnavailable = -7000,
600 /** There is a disk in the drive containing the Message Server index, but it is
602 KMsvMediaIncorrect = -7001,
603 /** A CMsvEntry context is no longer valid because the location of the Message Server's
606 Such contexts will need refreshing by the client.
608 @see MMsvEntryObserver::EMsvContextInvalid */
609 KMsvMediaChanged = -7002,
610 KMsvIndexBackup = -7003,
611 KMsvIndexRestore = -7004
614 #include <msvstd.inl>