Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
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.
17 #undef _NO_SESSION_LOGGING_
26 #ifdef _MSVAPI_DONT_INCLUDE_FLOGGER_
27 #ifndef _NO_SESSION_LOGGING_
28 #define _NO_SESSION_LOGGING_
40 // Forward declarations
44 class CMsvClientEntry;
47 class CMsvServerEntry;
49 // Remove these to remove client logging
50 //#define _NO_SESSION_LOGGING_
51 #define _NO_SESSION_LOGGING_SERIAL_
53 // Single export used to start the message server
54 IMPORT_C TInt StartMessageServer(TAny*);
56 // Create Message Server and return a server entry owned by caller
57 // This is all that is required to test server Mtm's
58 IMPORT_C CServer2* CreateMessageServerL(CMsvServerEntry*& aServerEntry);
60 //**********************************
62 //**********************************
64 // Abstract base class for operations controlling asynchronous functions
67 class CMsvOperation : public CActive
68 /** Defines an interface for use by objects which control asynchronous commands
69 in the messaging system.
71 Such objects are returned by CMsvEntry and User Interface MTM functions that
72 complete asynchronously. The interface allows clients to:
74 1. get progress information about the operation
76 2. cancel the operation
78 3. be signalled asynchronously when the operation completes; a client passes
79 in a TRequestStatus of a suitable active object for this purpose
81 The client only needs to understand the CMsvOperation interface, not the concrete
84 Writing derived classes:
86 As the base class interface for User Interface MTMs, CBaseUiMtm, defines functions
87 that return CMsvOperation objects for control of asynchronous operations,
88 implementers of these MTM components are required to provide suitable derived
89 classes. For example, if CBaseUiMtm::EditL() is implemented to provide message
90 editing, a CMsvOperation -derived class would be provided that completes when
91 the editing operation is complete.
93 Concrete derived classes must provide implementations of the pure virtual
94 DoCancel() and RunL() functions defined by CActive. DoCancel() should be provided
95 in the normal way to cancel the operation. RunL() should, in addition to any
96 other required functionality, always end by signalling the client that the
97 operation is complete with a suitable completion code.
104 IMPORT_C CMsvOperation(CMsvSession& aMsvSession, TInt aPriority, TRequestStatus& aObserverRequestStatus);
105 IMPORT_C ~CMsvOperation();
106 /** Gets information on the progress of the operation.
108 All operations on local entries share the same progress information format,
109 which defined by TMsvLocalOperationProgress.
111 For MTM-specific operations, progress information can be extracted by calling
112 CBaseUiMtm::GetProgress() or displayed by CBaseUiMtm::DisplayProgressSummary()
113 on the appropriate User Interface MTM.
117 Derived classes should implement this function so that the client can check
118 on the progress of the operation. The function should share an understanding
119 of the format of the buffer with the implementations of CBaseUiMtm::GetProgress()
120 and CBaseUiMtm::DisplayProgressSummary() in the User Interface MTM. The arguments
121 of CBaseUiMtm::GetProgress() show some information that should be included
124 @leave KErrNotReady The operation has not yet been started: it has been queued
125 for execution in the Message Server
126 @return Descriptor holding progress information. The maximum buffer size should
127 be KMsvProgressBufferLength (defined in msvipc.h). */
128 virtual const TDesC8& ProgressL()=0;
129 IMPORT_C virtual const TDesC8& FinalProgress();
130 IMPORT_C TInt SystemProgress(TMsvSystemProgress& aOutSysProg);
131 IMPORT_C virtual TUid Mtm() const;
133 inline TMsvOp Id() const;
134 inline TMsvId Service() const;
137 IMPORT_C TInt Extension_(TUint aExtensionId, TAny *&a0, TAny *a1);
140 /** The ID of the service that is associated with this operation.
142 Usually, the derived class constructor will contain a suitable argument to
143 allow the caller to set this.
147 /** The UID of the MTM associated with the operation.
149 The appropriate value should be set by the derived class constructor.
153 /** Request status of the operation observer.
155 This is the aObserverRequestStatus passed in the constructor. */
156 TRequestStatus& iObserverRequestStatus;
157 /** Message Server session used by object. This is set by the constructor. */
158 CMsvSession& iMsvSession;
165 //**********************************
167 //**********************************
169 // Allows a synchronous wait on a operation
172 class CMsvOperationWait: public CActive
173 /** Utility class used to wait until an asynchronous messaging operation
176 Note that CMsvOperationActiveSchedulerWait is simpler to use, and should be used in
177 preference to this class.
181 1. Create a new CMsvOperationWait object
183 2. Call the messaging function that returns the asynchronous operation.
184 The operation observer parameter should be the iStatus word of the CMsvOperationWait
185 object. This means that the CMsvOperationWait object will be signalled when
186 the operation completes.
188 3. Call the CMsvOperationWait object's Start() function. This sets the object
191 4. Call CActiveScheduler::Start(). This starts a nested active scheduler. The
192 program will then wait until this active scheduler is stopped. The CMsvOperationWait
193 object stops the scheduler when the operation completes, allowing the program to
196 These steps cause the program to wait until the operation completes.
199 CMsvOperationWait* waiter=CMsvOperationWait::NewLC();
200 CMsvOperation* op = function_returning_opLC(waiter->iStatus);
202 CActiveScheduler::Start();
203 CleanupStack::PopAndDestroy(2); // op, waiter
206 @see CActiveScheduler
212 IMPORT_C static CMsvOperationWait* NewLC(TInt aPriority=EPriorityStandard);
213 IMPORT_C ~CMsvOperationWait();
214 IMPORT_C void Start();
216 CMsvOperationWait(TInt aPriority);
222 //**********************************
223 // CMsvOperationActiveSchedulerWait
224 //**********************************
226 // Allows a synchronous wait on a operation using CActiveSchedulerWait class
227 // This class should be used in preference to CMsvOperationWait
228 // DOES NOT require an explicit call to CActiveScheduler::Start()--CMsvOperationActiveSchedulerWait::Start()
229 // effectively encapsulates this functionality
232 class CMsvOperationActiveSchedulerWait: public CActive
233 /** Utility class used to wait until an asynchronous messaging operation
238 1. Create a new CMsvOperationActiveSchedulerWait object
240 2. Call the messaging function that returns the asynchronous operation.
241 The operation observer parameter should be the iStatus word of the CMsvOperationActiveSchedulerWait
242 object. This means that the CMsvOperationActiveSchedulerWait object will be signalled when
243 the operation completes.
245 3. Call the CMsvOperationActiveSchedulerWait object's Start() function. This sets the object
248 These steps cause the program to wait until the operation completes.
251 CMsvOperationActiveSchedulerWait* waiter=CMsvOperationActiveSchedulerWait::NewLC();
252 CMsvOperation* op = function_returning_opLC(waiter->iStatus);
255 CleanupStack::PopAndDestroy(2); // op, waiter
263 IMPORT_C static CMsvOperationActiveSchedulerWait* NewLC(TInt aPriority=EPriorityStandard);
264 IMPORT_C ~CMsvOperationActiveSchedulerWait();
265 IMPORT_C void Start();
267 CMsvOperationActiveSchedulerWait(TInt aPriority);
271 CActiveSchedulerWait iActiveSchedulerWait;
274 //**********************************
275 // CMsvCompletedOperation
276 //**********************************
278 // An operation which is already completed on construction
281 class CMsvCompletedOperation : public CMsvOperation
282 /** Utility to create a messaging operation object for an operation that has already
285 This utility is useful, for example, for writers of MTMs, where the API requires that an
286 asynchronous operation is returned, but where in reality, the operation has performed
287 synchronously. It allows the program to construct an operation object for which
288 the operation is already completed, with the progress information and error code set.
295 IMPORT_C static CMsvCompletedOperation* NewL(CMsvSession& aMsvSession, TUid aMtm, const TDesC8& aProgress, TMsvId aService, TRequestStatus& aObserverRequestStatus, TInt aErr=KErrNone);
296 IMPORT_C ~CMsvCompletedOperation();
298 const TDesC8& ProgressL();
299 const TDesC8& FinalProgress();
301 CMsvCompletedOperation(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus);
302 void ConstructL(TUid aMtm, TInt aError, const TDesC8& aProgress, TMsvId aService);
311 //**********************************
313 //**********************************
315 // A send operation which returns a standard progress (used by SendAs2)
318 /** Utility to create an operation containing a sending operation which may be used
319 to retrieve a standard progress structure.
321 This class is intended to be derived from. The derived class must define the TranslateProgress()
322 member function. This function is responsible for translating the native progress of the given
323 mtm into the standard progress structure, CMsvSendOperation::TSendOperationProgress.
328 class CMsvSendOperation : public CMsvOperation
331 /** Send progress state.
333 @see TSendOperationProgress
335 enum TSendOperationState
337 ESendStateInPreparation,
338 ESendStateWaitingToSend,
339 ESendStateConnecting,
346 Structure holding send progress. For mtms unable to provide detailed progress
347 information, iProgressMax and iProgress must be zeroed. This will then allow
348 the client to check for this case and display a busy status dialog as opposed to
349 a progress dialog. If the mtm is capable of detailed progress, iProgressMax
350 should be set to the total number of units to be sent and iProgress the number
353 @see TSendOperationState
355 class TSendOperationProgress
358 TSendOperationState iState;
365 IMPORT_C virtual ~CMsvSendOperation();
366 // methods from CMsvOperation
367 IMPORT_C virtual const TDesC8& ProgressL();
368 IMPORT_C virtual const TDesC8& FinalProgress();
369 IMPORT_C void Start(CMsvOperation* aOperation);
371 IMPORT_C CMsvSendOperation(CMsvSession& aMsvSession, TRequestStatus& aObserverRequestStatus);
372 private: // methods from CActive
373 IMPORT_C virtual void DoCancel();
374 IMPORT_C virtual void RunL();
376 /** Translates the progress from sending operation's progress into TSendOperationProgress.
378 This member function must be defined by derived classes. Must not leave.
379 @see TSendOperationProgress
380 @return Descriptor holding progress information.
382 virtual const TDesC8& TranslateProgress(const TDesC8& aProgress)=0;
383 void Complete(TInt anError);
385 /** The progress that is associated with this operation.
387 The TranslateProgress defined by derived classes must populate and return
388 this progress structure.
389 @see TranslateProgress()
390 @see TSendOperationProgress */
391 TPckgBuf<TSendOperationProgress> iProgress;
392 /** The sending operation.
394 Assigned when ConstructL is called
396 CMsvOperation* iOperation;
399 /** Package buffer for a TSendOperationProgress
401 typedef TPckgBuf<CMsvSendOperation::TSendOperationProgress> TMsvSendOperationProgress;
404 //**********************************
405 // MMsvSessionObserver
406 //**********************************
411 class MMsvSessionObserver
412 /** Provides the interface for notification of events from a Message Server session.
415 The types of event are given in the enumeration TMsvSessionEvent. Clients
416 must provide an object that implements the interface, and set it to be notified
417 through CMsvSession::OpenSyncL() or CMsvSession::OpenASyncL(). Additional
418 observers can also be added and removed through CMsvSession.
420 @see CMsvSession::AddObserverL()
421 @see CMsvSession::RemoveObserver()
427 /** Session event type.
429 @see EMsvMediaUnavailable
432 enum TMsvSessionEvent
434 /** One or more entries have been created.
436 aArg1 is a CMsvEntrySelection of the new entries. aArg2 is the TMsvId of the
439 /** One or more index entries have been changed.
441 aArg1 is a CMsvEntrySelection of the index entries. aArg2 is the TMsvId of
444 /** One or more entries have been deleted.
446 aArg1 is a CMsvEntrySelection containing the IDs of the deleted entries. aArg2
447 is the TMsvId of the parent entry. */
449 /** One or more entries have been moved.
451 aArg1 is a CMsvEntrySelection containing the IDs of the moved entries. aArg2
452 is the TMsvId of the new parent. aArg3 is the TMsvId of the old parent entry. */
454 /** A new MTM has been installed.
456 aArg2 points to a TUid for the new MTM. */
457 EMsvMtmGroupInstalled,
458 /** A MTM has been uninstalled.
460 aArg2 points to a TUid of the removed MTM. */
461 EMsvMtmGroupDeInstalled,
462 /** Something has happening in the server, but this client was unable to retrieve
465 aArg1 points to the error code. */
467 /** The client should immediately close the session with the Message Server. */
469 /** Received after a client has used CMsvSession::OpenAsyncL() to create a session.
472 The session can now be used. */
474 /** Received after a client has used CMsvSession::OpenAsyncL() to create a session.
477 The server could not be started, and aArg1 points to the error code. */
478 EMsvServerFailedToStart,
479 /** The Message Server index had been corrupted and had to be rebuilt.
481 All local entries are recovered, but all remote entries have been lost. */
482 EMsvCorruptedIndexRebuilt,
483 /** The Message Server has been terminated.
485 All clients must close their sessions immediately. */
486 EMsvServerTerminated,
487 /** The Message Server has automatically changed the index location to use the
490 aArg1 is a TDriveNumber value that identifies the drive used by the Message
491 Server to hold the index prior to the change.
493 aArg2 is also a TDriveNumber value; it identifies the new drive that the Message
496 CMsvEntry contexts either refresh themselves or mark themselves invalid.
498 @see EMsvMediaUnavailable
500 EMsvMediaChanged, // I assume the following four are in sequential order
501 /** The media (disk) containing the Message Server index has been removed.
503 aArg1 is a TDriveNumber value that identifies the drive that is no longer
506 Future requests may fail with KMsvMediaUnavailable. A EMsvMediaChanged event
507 may be received in the future, as the Message Server switches back to the
509 EMsvMediaUnavailable,
510 /** The disk containing the Message Store is available again.
512 aArg1 is a TDriveNumber value that identifies the drive that is being used.
514 The Message Server can now operate as normal. No client action is necessary. */
516 /** An incorrect disk is inserted.
518 aArg1 is a TDriveNumber value that identifies the drive in which the incorrect
519 disk has been inserted.
521 Some requests may fail with KMsvMediaIncorrect. Clients may get an EMsvMediaChanged
522 event in the future telling them that the Message Server has switched back
523 to the internal drive. */
525 /** The Message Server has started to rebuild its index after it has been corrupted.
527 @see EMsvCorruptedIndexRebuilt */
528 EMsvCorruptedIndexRebuilding
531 /** Indicates an event has occurred.
533 The type of event is indicated by the value of aEvent. The interpretation
534 of the TAny arguments depends on this type.
536 For most event types, the action that is taken, for example, updating the
537 display, is client-specific. All clients though should respond to EMsvCloseSession
538 and EMsvServerTerminated events.
540 @param aEvent Indicates the event type.
541 @param aArg1 Event type-specific argument value
542 @param aArg2 Event type-specific argument value
543 @param aArg3 Event type-specific argument value */
544 virtual void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3)=0;
547 //**********************************
549 //**********************************
554 class TCapabilitySet;
556 const TInt KMsvSessionObserverGranularity=4; //???
558 class CMsvSession: public CActive
559 /** Represents a channel of communication between a client thread (Client-side
560 MTM, User Interface MTM, or message client application) and the Message Server
563 The class provides the means by which clients are notified when important
564 Message Server events occur.
566 Note the following significant groups of functions:
568 Creation functions: a message client application must use OpenSyncL() or OpenASyncL()
569 to create a session object, before it can instantiate any MTM or CMsvEntry
570 object. Only a single session should be created within a thread. As Client-side
571 MTM, User Interface MTM, and CMsvEntry objects are created in the client thread,
572 these use the client session, and do not create their own. Note that to close
573 a session, delete all objects relying on that session, and then the session
576 Cleanup functions: CMsvSession provides the ability to handle the cleanup
577 of entries in the event of a leave occurring, in a very similar manner to
578 the standard cleanup stack. The difference is that, on a leave, any entries
579 that are on the entry cleanup stack are removed from the Message Server. The
580 implementation uses the standard cleanup stack, so entry push and pop functions
581 should be used in the same order as all other types of push and pop. The functions
582 can be used both by MTM implementations and message client applications.
588 IMPORT_C static CMsvSession* OpenSyncL(MMsvSessionObserver& aObserver);
589 IMPORT_C static CMsvSession* OpenAsyncL(MMsvSessionObserver& aObserver);
590 IMPORT_C static CMsvSession* OpenAsObserverL(MMsvSessionObserver& aObserver);
592 IMPORT_C static CMsvSession* OpenSyncL(MMsvSessionObserver& aObserver, RFs& aFs);
593 IMPORT_C static CMsvSession* OpenAsyncL(MMsvSessionObserver& aObserver, RFs& aFs);
594 IMPORT_C static CMsvSession* OpenAsObserverL(MMsvSessionObserver& aObserver, RFs& aFs);
596 IMPORT_C static CMsvSession* OpenSyncL(MMsvSessionObserver& aObserver, TInt aPriority);
597 IMPORT_C static CMsvSession* OpenAsyncL(MMsvSessionObserver& aObserver, TInt aPriority);
598 IMPORT_C static CMsvSession* OpenAsObserverL(MMsvSessionObserver& aObserver, TInt aPriority);
600 IMPORT_C static CMsvSession* OpenSyncL(MMsvSessionObserver& aObserver, RFs& aFs, TInt aPriority);
601 IMPORT_C static CMsvSession* OpenAsyncL(MMsvSessionObserver& aObserver, RFs& aFs, TInt aPriority);
602 IMPORT_C static CMsvSession* OpenAsObserverL(MMsvSessionObserver& aObserver, RFs& aFs, TInt aPriority);
605 // --- Observer functions ---
606 IMPORT_C void AddObserverL(MMsvSessionObserver& aObserver);
607 IMPORT_C void RemoveObserver(MMsvSessionObserver& aObserver);
608 IMPORT_C TInt SetReceiveEntryEvents(TBool aReceive);
609 // --- Utility functions ---
610 IMPORT_C CMsvEntry* GetEntryL(TMsvId aEntId);
611 IMPORT_C TInt GetEntry(TMsvId aId, TMsvId& aService, TMsvEntry& aEntry);
613 IMPORT_C CMsvOperation* TransferCommandL(const CMsvEntrySelection& aSelection, TInt aCommandId, const TDesC8& aParameter, TRequestStatus& aStatus);
614 IMPORT_C void TransferCommandL(const CMsvEntrySelection& aSelection, TInt aCommandId, const TDesC8& aParameter, TDes8& aProgress);
615 IMPORT_C void IncPcSyncCountL(const CMsvEntrySelection& aSelection);
616 IMPORT_C void DecPcSyncCountL(const CMsvEntrySelection& aSelection);
617 IMPORT_C void GetChildIdsL(TMsvId aId, const CMsvEntryFilter& aFilter, CMsvEntrySelection& aSelection);
618 IMPORT_C void ChangeAttributesL(const CMsvEntrySelection& aSelection, TUint aSetAttributes, TUint aClearAttributes);
619 IMPORT_C CMsvOperation* ChangeDriveL(TInt aDrive, TRequestStatus& aStatus);
620 IMPORT_C TInt OutstandingOperationsL();
621 IMPORT_C CMsvOperation* CopyStoreL(const TDriveUnit& aDrive, TRequestStatus& aStatus);
622 IMPORT_C CMsvOperation* DeleteStoreL(const TDriveUnit& aDrive, TRequestStatus& aStatus);
623 // --- cleanup functions
624 IMPORT_C static void CleanupEntry(TAny* aPtr);
625 IMPORT_C void CleanupEntryPushL(TMsvId aId);
626 IMPORT_C void CleanupEntryPop(TInt aCount=1);
628 IMPORT_C void RemoveEntry(TMsvId aId);
630 IMPORT_C TInt InstallMtmGroup(const TDesC& aFullName);
631 IMPORT_C TInt DeInstallMtmGroup(const TDesC& aFullName);
633 IMPORT_C TInt StopService(TMsvId aServiceId);
634 IMPORT_C TBool ServiceActive(TMsvId aServiceId);
635 IMPORT_C TInt ServiceProgress(TMsvId aServiceId, TDes8& aProgress);
637 IMPORT_C void CloseMessageServer();
638 IMPORT_C RFs& FileSession();
640 IMPORT_C void GetMtmRequiredCapabilitiesL(TUid aMtmTypeUid, TCapabilitySet& aCapSet) const;
641 MMsvStoreManager& StoreManager();
643 IMPORT_C TBool GetAndClearIndexCorruptFlagL();
644 IMPORT_C TDriveUnit CurrentDriveL();
645 IMPORT_C TBool DriveContainsStoreL(TDriveUnit aDrive);
646 IMPORT_C TBool MessageStoreDrivePresentL();
648 IMPORT_C TInt ServiceAccessPointId(TMsvId aServiceId, TUint32& aAccessPointId);
651 CMsvSession(MMsvSessionObserver& aObserver);
652 CMsvSession(MMsvSessionObserver& aObserver, RFs& aFs);
653 CMsvSession(MMsvSessionObserver& aObserver, TInt aPriority);
654 CMsvSession(MMsvSessionObserver& aObserver, RFs& aFs, TInt aPriority);
656 void ConstructL(TBool aSyncOpening);
657 void ConstructAsObserverL();
659 IMPORT_C TInt OperationId();
660 IMPORT_C RMsvServerSession& Session();
667 TInt RunError(TInt aError);
670 void NotifyAllObserversL(MMsvSessionObserver::TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3);
671 void CleanupEntryDelete();
672 void DoRunL(TMsvNotifBuffer& aBuffer);
673 void HandleNotifyL();
674 void DoHandleNotifyL(TMsvNotifBuffer& aBuffer);
675 void GetMessageFolderL();
680 RMsvServerSession iSession;
681 TMsvNotifBuffer iChange;
682 MMsvSessionObserver& iMainObserver;
683 CArrayPtrFlat<MMsvSessionObserver>* iObservers;
684 CMsvEntrySelection* iCleanupList;
686 HBufC* iMessageFolder;
688 CMsvEntrySelection* iNotifSelection;
689 TPckgBuf<TUint32> iSequenceBuf;
690 TUint32 iNotifySequence;
691 TBool iReceiveEntryEvents;
692 /** Specifies whether to use the shared file server session */
695 #ifndef _NO_SESSION_LOGGING_
696 void CreateSessionLogL();
697 void Log(TRefByValue<const TDesC> aFmt, ...);
699 // must be the last data member in the class to preserve BC.
700 mutable RFileLogger iLog;
703 friend class CSendAs;
704 friend class CMsvEntry;
705 friend class CMsvOperation;
706 friend class CMsvEntryOperation;
707 friend class CObserverRegistry;
714 //**********************************
716 //**********************************
721 class MMsvEntryObserver
722 /** Provides the interface for notification of events associated with an entry.
724 The types of event are given in the enumeration TMsvEntryEvent. Clients can
725 provide an object that implements the interface, and set it to be notified
726 through CMsvEntry::AddObserverL().
732 /** Defines entry event types.
738 /** The entry has been changed, either as a result of a CMsvEntry::ChangeL() or
739 by another client. */
741 /** New children have been created. aArg1 points to a CMsvEntrySelection contain
742 the ID of the new children. */
744 /** Children have been deleted. aArg1 points to a CMsvEntrySelection contain the
745 ID of the deleted children. */
747 /** One or more of the children have been changed. aArg1 points to a CMsvEntrySelection
748 containing the IDs of the changed children. */
750 /** The entry has been deleted by another client. The context is now invalid. */
752 /** The context has become invalid. The entry has been changed, but the CMsvEntry
753 was unable to update the context. The context will only become valid by a
754 successful CMsvEntry::SetEntryL() call. aArg1 points to a TInt containing
755 the error code for the invalid context. */
757 /** Some new children have been created, but CMsvEntry was unable to retrieve the
758 data from the Message Server. The children will be correct only after a successful
759 call to CMsvEntry::SetEntryL(). */
761 /** An error has occurred such that the status of the children is unknown and probably
762 invalid. aArg1 points to a TInt containing the error code for the invalid
765 /** The current entry has been moved by another client. The CMsvEntry has already
766 been updated to reflect the new parent. */
769 /** Indicates when called by a CMsvEntry object that an event has occurred.
771 The type of event is indicated by the value of aEvent. The interpretation of the aArg1-3 values depends on this type.
772 For most event types, the action that is taken, for example, updating the display, is client-specific. Most clients will
773 need to handle events that make the current context invalid: EMsvContextInvalid and EMsvEntryDeleted.
775 An implementation can leave if an error occurs. The leave is not trapped by the framework, so
776 the error code may be displayed to the user.
778 @param aEvent Indicates the event type.
779 @param aArg1 Event-specific argument value
780 @param aArg2 Event-specific argument value
781 @param aArg3 Event-specific argument value
783 virtual void HandleEntryEventL(TMsvEntryEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3)=0;
788 //**********************************
790 //**********************************
795 class CMsvEntry: public CBase, public MMsvSessionObserver, public MMsvStoreObserver
796 /** Accesses and acts upon a particular Message Server entry. The current entry
797 that a CMsvEntry object relates is referred to as its context.
799 It may be helpful to consider CMsvEntry functions in two broad groups. The
800 first provides means to access the various types of storage associated with
801 an entry. The second provides a means to discover and access other entries
802 that the entry owns (its children).
804 Message client applications, Client-side MTMs, and User Interface MTMs all
805 commonly use CMsvEntry objects. CMsvEntry objects though represent a lower
806 level of access to an entry than that provided by a Client-side MTM or User
807 Interface MTM. In particular, any MTM-specific functionality, such as address
808 lists or subject fields, must be accessed by a message client application
809 through an MTM inteface.
811 A CMsvEntry object is relatively expensive in RAM usage, as it caches its
812 children, updating them as necessary when notified of changes. They should
813 therefore be created sparingly.
815 Note that Server-side MTMs do not use this class, but a similar one, CMsvServerEntry.
821 public: // Public member functions
822 IMPORT_C static CMsvEntry* NewL(CMsvSession& aMsvSession, TMsvId aMsvId, const TMsvSelectionOrdering& aOrdering);
823 IMPORT_C ~CMsvEntry();
825 // --- Observer functions ---
826 IMPORT_C void AddObserverL(MMsvEntryObserver& aObserver);
827 IMPORT_C void RemoveObserver(MMsvEntryObserver& aObserver);
829 // --- Accessor for associated session ---
830 inline CMsvSession& Session();
832 // --- Accessors the associated message store ---
833 IMPORT_C CMsvStore* ReadStoreL();
834 IMPORT_C CMsvStore* EditStoreL();
836 // --- Synchronous Current Entry functions ---
837 inline TMsvId EntryId() const;
838 inline const TMsvEntry& Entry() const;
839 inline const TMsvSelectionOrdering& SortType() const;
840 inline TMsvId OwningService() const;
841 IMPORT_C void SetSortTypeL(const TMsvSelectionOrdering& aOrdering);
842 IMPORT_C void SetMtmListL(const CArrayFix<TUid>& aMtmList);
843 IMPORT_C void SetEntryL(TMsvId aId);
844 IMPORT_C void ChangeL(const TMsvEntry& aEntry);
845 IMPORT_C void ChangeL(const TMsvEntry& aEntry, TSecureId aOwnerId);
849 // --- Asynchronous Current Entry functions ---
850 IMPORT_C CMsvOperation* ChangeL(const TMsvEntry& aEntry, TRequestStatus& aStatus);
851 IMPORT_C CMsvOperation* ChangeL(const TMsvEntry& aEntry, TSecureId aOwnerId, TRequestStatus& aStatus);
853 // --- Asynchronous Child Entry functions ---
854 IMPORT_C CMsvOperation* CreateL(const TMsvEntry& aEntry, TRequestStatus& aStatus);
855 IMPORT_C CMsvOperation* CreateL(const TMsvEntry& aEntry, TSecureId aOwnerId, TRequestStatus& aStatus);
856 IMPORT_C CMsvOperation* DeleteL(const CMsvEntrySelection& aSelection, TRequestStatus& aStatus);
857 IMPORT_C CMsvOperation* DeleteL(TMsvId aMsvId, TRequestStatus& aStatus);
858 IMPORT_C CMsvOperation* CopyL(const CMsvEntrySelection& aSelection, TMsvId aTargetId, TRequestStatus& aStatus);
859 IMPORT_C CMsvOperation* CopyL(TMsvId aMsvId, TMsvId aTargetId, TRequestStatus& aStatus);
860 IMPORT_C CMsvOperation* MoveL(const CMsvEntrySelection& aSelection, TMsvId aTargetId, TRequestStatus& aStatus);
861 IMPORT_C CMsvOperation* MoveL(TMsvId aMsvId, TMsvId aTargetId, TRequestStatus& aStatus);
863 // --- Synchronous Child Entry functions ---
864 IMPORT_C CMsvEntrySelection* ChildrenL() const;
865 IMPORT_C CMsvEntrySelection* ChildrenWithServiceL(TMsvId aServiceId) const;
866 IMPORT_C CMsvEntrySelection* ChildrenWithMtmL(TUid aMtm) const;
867 IMPORT_C CMsvEntrySelection* ChildrenWithTypeL(TUid aType) const;
868 inline TInt Count() const;
869 IMPORT_C const TMsvEntry& ChildDataL(TMsvId aId) const;
870 IMPORT_C const TMsvEntry& operator[](TInt aIndex) const;
871 IMPORT_C CMsvEntry* ChildEntryL(TMsvId aId) const;
872 IMPORT_C void MoveL(TMsvId aMsvId, TMsvId aTargetId);
873 IMPORT_C void MoveL(const CMsvEntrySelection& aSelection, TMsvId aTargetId, TMsvLocalOperationProgress& aProgress);
874 IMPORT_C void CopyL(const CMsvEntrySelection& aSelection, TMsvId aTargetId, TMsvLocalOperationProgress& aProgress);
875 IMPORT_C void CopyL(TMsvId aMsvId, TMsvId aTargetId);
878 IMPORT_C void CreateL(TMsvEntry& aEntry);
879 IMPORT_C void CreateL(TMsvEntry& aEntry, TSecureId aOwnerId);
880 IMPORT_C void DeleteL(TMsvId aId);
881 IMPORT_C void DeleteL(const CMsvEntrySelection& aSelection, TMsvLocalOperationProgress& aProgress);
882 IMPORT_C void ChangeAttributesL(const CMsvEntrySelection& aSelection, TUint aSetAttributes, TUint aClearAttributes);
884 // from MMsvSessionObserver
885 void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3);
886 // From MMsvStoreObserver
887 void HandleStoreEvent(TMsvStoreEvent aEvent, TMsvId aId);
890 IMPORT_C TBool HasStoreL() const;
892 /** @internalTechnology */
893 IMPORT_C void SetEntryNoCheckL(TMsvId aId);
895 private: // Private members
896 CMsvEntry(CMsvSession& aMsvSession, const TMsvSelectionOrdering& aOrdering);
897 void ConstructL(TMsvId aMsvId);
899 void NotifyAllObserversL(MMsvEntryObserver::TMsvEntryEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3);
900 void ContextChangedL(MMsvEntryObserver::TMsvEntryEvent aEvent);
901 void NewChildrenL(const CMsvEntrySelection& aSelection);
902 CMsvEntrySelection* DoGetNewChildrenL(const CMsvEntrySelection& aSelection);
903 void DeletedChildrenL(const CMsvEntrySelection& aSelection);
904 void ChildrenChangedL(const CMsvEntrySelection& aSelection);
905 void CheckNewGrandchildrenL(TMsvId aId);
906 void CheckDeletedGrandchildrenL(TMsvId aId);
907 void NotifyChildChangedL(TMsvId aId);
908 CMsvEntrySelection* DoMakeSelectionL(TMsvId aId);
909 void CheckIfContextMovedL(const CMsvEntrySelection& aSelection);
911 TBool IsAChild(TMsvId aId) const;
912 TBool AreChildren(const CMsvEntrySelection& aSelection) const;
914 CMsvOperation* DoDeleteL(const CMsvEntrySelection& aSelection, TRequestStatus& aStatus);
915 CMsvClientEntry* DoGetEntryLC(TMsvId aId, TMsvId& aOwningService);
916 void DoGetChildrenL();
917 CMsvEntryArray* GetNewSortedListL(const TMsvSelectionOrdering& aOrdering, const CArrayFix<TUid>& aMtmList);
918 void DoSortTypeL(CMsvClientEntry* aContext);
919 void ReplaceChildL(TInt pos, const TMsvEntry& aEntry);
920 void DeleteChild(TInt aPosition);
921 void HandleMediaChangeL();
923 TInt MoveOneL(TMsvId aMsvId, TMsvId aTargetId);
924 TInt CopyOneL(TMsvId aMsvId, TMsvId aTargetId);
925 TInt DeleteOneL(TMsvId aMsvId);
928 enum TEntryState { EValid,
929 EInvalidChangingContext,
930 EInvalidDeletedContext,
932 EInvalidMissingChildren};
934 #ifndef _NO_SESSION_LOGGING_
935 void Log(TRefByValue<const TDesC> aFmt, ...);
939 TBool iOberserverAdded;
941 CMsvSession& iMsvSession;
942 TMsvSelectionOrdering iOrdering;
943 const TMsvEntry* iEntryPtr;
944 CArrayPtrFlat<MMsvEntryObserver>* iObservers;
945 CArrayPtrFlat<CMsvClientEntry>* iEntries;
946 CMsvEntryArray* iSortedChildren;
948 CArrayFixFlat<TUid>* iMtmList;
949 TMsvId iOwningService;
950 TUint32 iNotifySequence;
953 //**********************************
955 //**********************************
961 /** Provides various static information functions relating to the Message Server.
969 IMPORT_C static TVersion Version();
970 IMPORT_C static TMsvId NullUidValue();
972 IMPORT_C static TBool DriveContainsStore(RFs& aFs, TInt aDrive);
973 IMPORT_C static TInt CurrentDriveL(RFs& aFs);
974 IMPORT_C static TBool IsMessageStoreDrivePresentL(RFs& aFs);
977 //**********************************
979 //**********************************
985 /** Utility class to simplify getting progress information from a messaging operation object.
987 The functions get and unpack the progress information buffers from an operation object.
994 IMPORT_C static TMsvLocalOperationProgress GetLocalProgressL(CMsvOperation& aOperation);
995 IMPORT_C static TMsvLocalOperationProgress GetFinalLocalProgress(CMsvOperation& aOperation);
996 IMPORT_C static TInt GetProgressErrorL(CMsvOperation& aOperation);
997 IMPORT_C static TMsvId GetProgressIdL(CMsvOperation& aOperation);
1000 #include <msvapi.inl>
1002 #endif // __MSVAPI_H__