messagingfw/msgsrvnstore/server/inc/MSVAPI.H
changeset 62 db3f5fa34ec7
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     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 "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // MSVAPI.H
       
    15 //
       
    16 /**
       
    17  * @file 
       
    18  * @publishedAll
       
    19  * @released
       
    20  */
       
    21 
       
    22 #ifdef _DEBUG
       
    23 #undef _NO_SESSION_LOGGING_
       
    24 #endif
       
    25 
       
    26 #ifndef __MSVAPI_H__
       
    27 #define __MSVAPI_H__
       
    28 
       
    29 #include <e32base.h>
       
    30 #include <s32file.h>
       
    31 
       
    32 #ifdef _MSVAPI_DONT_INCLUDE_FLOGGER_
       
    33 	#ifndef _NO_SESSION_LOGGING_
       
    34 		#define _NO_SESSION_LOGGING_
       
    35 	#endif
       
    36 #else
       
    37 	#include <flogger.h>
       
    38 #endif
       
    39 
       
    40 #include <msvstd.h>
       
    41 #include <msvstore.h>
       
    42 #include <msvipc.h>
       
    43 #include <msvarray.h>
       
    44 #include <mclient.h>
       
    45 #include <tmsvsystemprogress.h>
       
    46 
       
    47 // Forward declarations
       
    48 class CMsvSession;
       
    49 class CMsvEntry;
       
    50 class CBaseMtm;
       
    51 class CMsvClientEntry;
       
    52 class CMsvEntryArray;
       
    53 class CMsvServer;
       
    54 class CMsvServerEntry;
       
    55 class CMsvSearchSortOperation;
       
    56 
       
    57 
       
    58 
       
    59 // Remove these to remove client logging
       
    60 //#define _NO_SESSION_LOGGING_
       
    61 #define _NO_SESSION_LOGGING_SERIAL_
       
    62 
       
    63 // Single export used to start the message server
       
    64 IMPORT_C TInt StartMessageServer(TAny*);
       
    65 
       
    66 // Create Message Server and return a server entry owned by caller
       
    67 // This is all that is required to test server Mtm's
       
    68 IMPORT_C CServer2* CreateMessageServerL(CMsvServerEntry*& aServerEntry);
       
    69 
       
    70 //**********************************
       
    71 // CMsvOperation
       
    72 //**********************************
       
    73 //
       
    74 // Abstract base class for operations controlling asynchronous functions
       
    75 //
       
    76 
       
    77 class CMsvOperation : public CActive
       
    78 /** Defines an interface for use by objects which control asynchronous commands 
       
    79 in the messaging system. 
       
    80 
       
    81 Such objects are returned by CMsvEntry and User Interface MTM functions that 
       
    82 complete asynchronously. The interface allows clients to:
       
    83 
       
    84 1. get progress information about the operation
       
    85 
       
    86 2. cancel the operation
       
    87 
       
    88 3. be signalled asynchronously when the operation completes; a client passes 
       
    89 in a TRequestStatus of a suitable active object for this purpose
       
    90 
       
    91 The client only needs to understand the CMsvOperation interface, not the concrete 
       
    92 implementation used. 
       
    93 
       
    94 Writing derived classes:
       
    95 
       
    96 As the base class interface for User Interface MTMs, CBaseUiMtm, defines functions 
       
    97 that return CMsvOperation objects for control of asynchronous operations, 
       
    98 implementers of these MTM components are required to provide suitable derived 
       
    99 classes. For example, if CBaseUiMtm::EditL() is implemented to provide message 
       
   100 editing, a CMsvOperation -derived class would be provided that completes when 
       
   101 the editing operation is complete.
       
   102 
       
   103 Concrete derived classes must provide implementations of the pure virtual 
       
   104 DoCancel() and RunL() functions defined by CActive. DoCancel() should be provided 
       
   105 in the normal way to cancel the operation. RunL() should, in addition to any 
       
   106 other required functionality, always end by signalling the client that the 
       
   107 operation is complete with a suitable completion code. 
       
   108 
       
   109 @publishedAll
       
   110 @released
       
   111 */
       
   112 	{
       
   113 public:
       
   114 	IMPORT_C CMsvOperation(CMsvSession& aMsvSession, TInt aPriority, TRequestStatus& aObserverRequestStatus);
       
   115 	IMPORT_C ~CMsvOperation();
       
   116 	/** Gets information on the progress of the operation. 
       
   117 	
       
   118 	All operations on local entries share the same progress information format, 
       
   119 	which defined by TMsvLocalOperationProgress. 
       
   120 	
       
   121 	For MTM-specific operations, progress information can be extracted by calling 
       
   122 	CBaseUiMtm::GetProgress() or displayed by CBaseUiMtm::DisplayProgressSummary() 
       
   123 	on the appropriate User Interface MTM.
       
   124 	
       
   125 	Requirements:
       
   126 	
       
   127 	Derived classes should implement this function so that the client can check 
       
   128 	on the progress of the operation. The function should share an understanding 
       
   129 	of the format of the buffer with the implementations of CBaseUiMtm::GetProgress() 
       
   130 	and CBaseUiMtm::DisplayProgressSummary() in the User Interface MTM. The arguments 
       
   131 	of CBaseUiMtm::GetProgress() show some information that should be included 
       
   132 	where appropriate.
       
   133 	
       
   134 	@leave KErrNotReady The operation has not yet been started: it has been queued 
       
   135 	for execution in the Message Server 
       
   136 	@return Descriptor holding progress information. The maximum buffer size should 
       
   137 	be KMsvProgressBufferLength (defined in msvipc.h). */
       
   138 	virtual const TDesC8& ProgressL()=0;
       
   139 	IMPORT_C virtual const TDesC8& FinalProgress();
       
   140 	IMPORT_C TInt SystemProgress(TMsvSystemProgress& aOutSysProg);
       
   141 	IMPORT_C virtual TUid Mtm() const;
       
   142 	//
       
   143 	inline TMsvOp Id() const;
       
   144 	inline TMsvId Service() const;
       
   145 	//
       
   146 protected:
       
   147 	IMPORT_C TInt Extension_(TUint aExtensionId, TAny *&a0, TAny *a1);
       
   148 
       
   149 protected:
       
   150 	/** The ID of the service that is associated with this operation. 
       
   151 	
       
   152 	Usually, the derived class constructor will contain a suitable argument to 
       
   153 	allow the caller to set this.
       
   154 	
       
   155 	@see Service() */
       
   156 	TMsvId iService;
       
   157 	/** The UID of the MTM associated with the operation. 
       
   158 	
       
   159 	The appropriate value should be set by the derived class constructor.
       
   160 	
       
   161 	@see Mtm() */
       
   162 	TUid iMtm;
       
   163 	/** Request status of the operation observer. 
       
   164 	
       
   165 	This is the aObserverRequestStatus passed in the constructor. */
       
   166 	TRequestStatus& iObserverRequestStatus;
       
   167 	/** Message Server session used by object. This is set by the constructor. */
       
   168 	CMsvSession& iMsvSession;
       
   169 	
       
   170 private:
       
   171 	TMsvOp iId;
       
   172 	};
       
   173 
       
   174 
       
   175 //**********************************
       
   176 // CMsvOperationWait
       
   177 //**********************************
       
   178 //
       
   179 // Allows a synchronous wait on a operation
       
   180 //
       
   181 
       
   182 class CMsvOperationWait: public CActive
       
   183 /** Utility class used to wait until an asynchronous messaging operation
       
   184 has completed. 
       
   185 
       
   186 Note that CMsvOperationActiveSchedulerWait is simpler to use, and should be used in 
       
   187 preference to this class.
       
   188 
       
   189 To use the class:
       
   190 
       
   191 1. Create a new CMsvOperationWait object
       
   192 
       
   193 2. Call the messaging function that returns the asynchronous operation. 
       
   194 The operation observer parameter should be the iStatus word of the CMsvOperationWait 
       
   195 object. This means that the CMsvOperationWait object will be signalled when
       
   196 the operation completes.
       
   197 
       
   198 3. Call the CMsvOperationWait object's Start() function. This sets the object
       
   199 to be active.
       
   200 
       
   201 4. Call CActiveScheduler::Start(). This starts a nested active scheduler. The 
       
   202 program will then wait until this active scheduler is stopped. The CMsvOperationWait 
       
   203 object stops the scheduler when the operation completes, allowing the program to 
       
   204 continue. 
       
   205 
       
   206 These steps cause the program to wait until the operation completes.
       
   207 
       
   208 @code
       
   209      CMsvOperationWait* waiter=CMsvOperationWait::NewLC();
       
   210      CMsvOperation* op = function_returning_opLC(waiter->iStatus);
       
   211      waiter->Start();
       
   212      CActiveScheduler::Start();
       
   213      CleanupStack::PopAndDestroy(2); // op, waiter
       
   214 @endcode
       
   215 
       
   216 @see CActiveScheduler
       
   217 @publishedAll
       
   218 @released
       
   219 */
       
   220 	{
       
   221 public:
       
   222 	IMPORT_C static CMsvOperationWait* NewLC(TInt aPriority=EPriorityStandard);
       
   223 	IMPORT_C ~CMsvOperationWait();
       
   224 	IMPORT_C void Start();
       
   225 protected:
       
   226 	CMsvOperationWait(TInt aPriority);
       
   227 	void RunL();
       
   228 	void DoCancel();
       
   229 	};
       
   230 
       
   231 
       
   232 //**********************************
       
   233 // CMsvOperationActiveSchedulerWait
       
   234 //**********************************
       
   235 //
       
   236 // Allows a synchronous wait on a operation using CActiveSchedulerWait class
       
   237 // This class should be used in preference to CMsvOperationWait
       
   238 // DOES NOT require an explicit call to CActiveScheduler::Start()--CMsvOperationActiveSchedulerWait::Start()
       
   239 // effectively encapsulates this functionality
       
   240 //
       
   241 
       
   242 class CMsvOperationActiveSchedulerWait: public CActive
       
   243 /** Utility class used to wait until an asynchronous messaging operation
       
   244 has completed. 
       
   245 
       
   246 To use the class:
       
   247 
       
   248 1. Create a new CMsvOperationActiveSchedulerWait object
       
   249 
       
   250 2. Call the messaging function that returns the asynchronous operation. 
       
   251 The operation observer parameter should be the iStatus word of the CMsvOperationActiveSchedulerWait 
       
   252 object. This means that the CMsvOperationActiveSchedulerWait object will be signalled when
       
   253 the operation completes.
       
   254 
       
   255 3. Call the CMsvOperationActiveSchedulerWait object's Start() function. This sets the object
       
   256 to be active.
       
   257 
       
   258 These steps cause the program to wait until the operation completes.
       
   259 
       
   260 @code
       
   261      CMsvOperationActiveSchedulerWait* waiter=CMsvOperationActiveSchedulerWait::NewLC();
       
   262      CMsvOperation* op = function_returning_opLC(waiter->iStatus);
       
   263      waiter->Start();
       
   264 
       
   265      CleanupStack::PopAndDestroy(2); // op, waiter
       
   266 @endcode
       
   267 
       
   268 @publishedAll
       
   269 @released
       
   270 */
       
   271 	{
       
   272 public:
       
   273 	IMPORT_C static CMsvOperationActiveSchedulerWait* NewLC(TInt aPriority=EPriorityStandard);
       
   274 	IMPORT_C ~CMsvOperationActiveSchedulerWait();
       
   275 	IMPORT_C void Start();
       
   276 private:
       
   277 	CMsvOperationActiveSchedulerWait(TInt aPriority);
       
   278 	void RunL();
       
   279 	void DoCancel();
       
   280 private:
       
   281 	CActiveSchedulerWait iActiveSchedulerWait;
       
   282 	};
       
   283 
       
   284 //**********************************
       
   285 // CMsvCompletedOperation
       
   286 //**********************************
       
   287 //
       
   288 // An operation which is already completed on construction
       
   289 //
       
   290 
       
   291 class CMsvCompletedOperation : public CMsvOperation
       
   292 /** Utility to create a messaging operation object for an operation that has already 
       
   293 completed. 
       
   294 
       
   295 This utility is useful, for example, for writers of MTMs, where the API requires that an 
       
   296 asynchronous operation is returned, but where in reality, the operation has performed
       
   297 synchronously. It allows the program to construct an operation object for which 
       
   298 the operation is already completed, with the progress information and error code set.   
       
   299 
       
   300 @publishedAll
       
   301 @released
       
   302 */
       
   303 	{
       
   304 public:
       
   305 	IMPORT_C static CMsvCompletedOperation* NewL(CMsvSession& aMsvSession, TUid aMtm, const TDesC8& aProgress, TMsvId aService, TRequestStatus& aObserverRequestStatus, TInt aErr=KErrNone);
       
   306 	IMPORT_C ~CMsvCompletedOperation();
       
   307 	//
       
   308 	const TDesC8& ProgressL();
       
   309 	const TDesC8& FinalProgress();
       
   310 private:
       
   311 	CMsvCompletedOperation(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus);
       
   312 	void ConstructL(TUid aMtm, TInt aError, const TDesC8& aProgress, TMsvId aService);
       
   313 	// from CActive
       
   314 	void DoCancel();
       
   315 	void RunL();
       
   316 	//
       
   317 private:
       
   318 	HBufC8* iProgress;
       
   319 	};
       
   320 
       
   321 //**********************************
       
   322 // CMsvSendOperation
       
   323 //**********************************
       
   324 //
       
   325 // A send operation which returns a standard progress (used by SendAs2)
       
   326 //
       
   327 
       
   328 /** Utility to create an operation containing a sending operation which may be used
       
   329 to retrieve a standard progress structure.
       
   330 
       
   331 This class is intended to be derived from. The derived class must define the TranslateProgress()
       
   332 member function. This function is responsible for translating the native progress of the given
       
   333 mtm into the standard progress structure, CMsvSendOperation::TSendOperationProgress.
       
   334 
       
   335 @publishedAll
       
   336 @released
       
   337 */
       
   338 class CMsvSendOperation : public CMsvOperation
       
   339 	{
       
   340 public:
       
   341 	/** Send progress state.
       
   342 
       
   343 	@see TSendOperationProgress
       
   344 	*/
       
   345 	enum TSendOperationState
       
   346 		{
       
   347 		ESendStateInPreparation,
       
   348 		ESendStateWaitingToSend,
       
   349 		ESendStateConnecting,
       
   350 		ESendStateSending,
       
   351 		ESendStateDone,
       
   352 		ESendStateFailed
       
   353 		};
       
   354 	/** Send progress.
       
   355 	
       
   356 	Structure holding send progress. For mtms unable to provide detailed progress 
       
   357 	information, iProgressMax and iProgress must be zeroed. This will then allow
       
   358 	the client to check for this case and display a busy status dialog as opposed to
       
   359 	a progress dialog. If the mtm is capable of detailed progress, iProgressMax 
       
   360 	should be set to the total number of units to be sent and iProgress the number
       
   361 	of units sent.
       
   362 
       
   363 	@see TSendOperationState
       
   364 	*/
       
   365 	class TSendOperationProgress
       
   366 		{
       
   367 	public:
       
   368 		TSendOperationState iState;
       
   369 		TInt 				iError;
       
   370 		TInt 				iProgressMax;
       
   371 		TInt 				iProgress;	
       
   372 		};
       
   373 
       
   374 public:
       
   375 	IMPORT_C virtual ~CMsvSendOperation();
       
   376 	// methods from CMsvOperation
       
   377 	IMPORT_C virtual const TDesC8& ProgressL();
       
   378 	IMPORT_C virtual const TDesC8& FinalProgress();
       
   379 	IMPORT_C void Start(CMsvOperation* aOperation);
       
   380 protected:
       
   381 	IMPORT_C CMsvSendOperation(CMsvSession& aMsvSession, TRequestStatus& aObserverRequestStatus);
       
   382 private:	// methods from CActive
       
   383 	IMPORT_C virtual void DoCancel();
       
   384 	IMPORT_C virtual void RunL();
       
   385 private:
       
   386 	/** Translates the progress from sending operation's progress into TSendOperationProgress. 
       
   387 	
       
   388 	This member function must be defined by derived classes. Must not leave.
       
   389 	@see TSendOperationProgress 
       
   390 	@return Descriptor holding progress information.
       
   391 	*/
       
   392 	virtual const TDesC8& TranslateProgress(const TDesC8& aProgress)=0;
       
   393 	void Complete(TInt anError);
       
   394 protected:
       
   395 	/** The progress that is associated with this operation. 
       
   396 
       
   397 	The TranslateProgress defined by derived classes must populate and return
       
   398 	this progress structure.
       
   399 	@see TranslateProgress() 
       
   400 	@see TSendOperationProgress */
       
   401 	TPckgBuf<TSendOperationProgress> iProgress;
       
   402 	/** The sending operation. 
       
   403 	
       
   404 	Assigned when ConstructL is called
       
   405 	*/
       
   406 	CMsvOperation* iOperation;
       
   407 	};
       
   408 	
       
   409 /** Package buffer for a TSendOperationProgress
       
   410 */
       
   411 typedef TPckgBuf<CMsvSendOperation::TSendOperationProgress> TMsvSendOperationProgress;
       
   412 
       
   413 
       
   414 //**********************************
       
   415 // MMsvSessionObserver
       
   416 //**********************************
       
   417 //
       
   418 // 
       
   419 //
       
   420 
       
   421 class MMsvSessionObserver
       
   422 /** Provides the interface for notification of events from a Message Server session. 
       
   423 
       
   424 
       
   425 The types of event are given in the enumeration TMsvSessionEvent. Clients 
       
   426 must provide an object that implements the interface, and set it to be notified 
       
   427 through CMsvSession::OpenSyncL() or CMsvSession::OpenASyncL(). Additional 
       
   428 observers can also be added and removed through CMsvSession.
       
   429 
       
   430 @see CMsvSession::AddObserverL()
       
   431 @see CMsvSession::RemoveObserver() 
       
   432 @publishedAll
       
   433 @released
       
   434 */
       
   435 	{
       
   436 public:
       
   437 	/** Session event type.
       
   438 
       
   439 	@see EMsvMediaUnavailable
       
   440 	@see TDriveNumber 
       
   441 	*/
       
   442 	enum TMsvSessionEvent 
       
   443 							{ 
       
   444 	/** One or more entries have been created.
       
   445 	
       
   446 	aArg1 is a CMsvEntrySelection of the new entries. aArg2 is the TMsvId of the 
       
   447 	parent entry. */
       
   448 							EMsvEntriesCreated,
       
   449 	/** One or more index entries have been changed. 
       
   450 	
       
   451 	aArg1 is a CMsvEntrySelection of the index entries. aArg2 is the TMsvId of 
       
   452 	the parent entry. */
       
   453 							EMsvEntriesChanged,
       
   454 	/** One or more entries have been deleted.
       
   455 	
       
   456 	aArg1 is a CMsvEntrySelection containing the IDs of the deleted entries. aArg2 
       
   457 	is the TMsvId of the parent entry. */
       
   458 							EMsvEntriesDeleted,
       
   459 	/** One or more entries have been moved.
       
   460 	
       
   461 	aArg1 is a CMsvEntrySelection containing the IDs of the moved entries. aArg2 
       
   462 	is the TMsvId of the new parent. aArg3 is the TMsvId of the old parent entry. */
       
   463 							EMsvEntriesMoved,
       
   464 	/** A new MTM has been installed. 
       
   465 	
       
   466 	aArg2 points to a TUid for the new MTM. */
       
   467 							EMsvMtmGroupInstalled,
       
   468 	/** A MTM has been uninstalled. 
       
   469 	
       
   470 	aArg2 points to a TUid of the removed MTM. */
       
   471 							EMsvMtmGroupDeInstalled,
       
   472 	/** Something has happening in the server, but this client was unable to retrieve 
       
   473 	the information.
       
   474 	
       
   475 	aArg1 points to the error code. */
       
   476 							EMsvGeneralError,
       
   477 	/** The client should immediately close the session with the Message Server. */
       
   478 							EMsvCloseSession,
       
   479 	/** Received after a client has used CMsvSession::OpenAsyncL() to create a session. 
       
   480 	
       
   481 	
       
   482 	The session can now be used. */
       
   483 							EMsvServerReady,
       
   484 	/** Received after a client has used CMsvSession::OpenAsyncL() to create a session. 
       
   485 	
       
   486 	
       
   487 	The server could not be started, and aArg1 points to the error code. */
       
   488 							EMsvServerFailedToStart,
       
   489 	/** The Message Server index had been corrupted and had to be rebuilt. 
       
   490 	
       
   491 	All local entries are recovered, but all remote entries have been lost. */
       
   492 							EMsvCorruptedIndexRebuilt,
       
   493 	/** The Message Server has been terminated. 
       
   494 	
       
   495 	All clients must close their sessions immediately. */
       
   496 							EMsvServerTerminated,
       
   497 	/** This notification is sent whenever Message Server current drive is changed.
       
   498 	Upon receiving this event, the client should delete the current context of operations 
       
   499 	and refresh its view of messaging.
       
   500 	
       
   501 	aArg1 is a TDriveNumber value that identifies the drive used by the Message 
       
   502 	Server to hold the index prior to the change. 
       
   503 	
       
   504 	aArg2 is also a TDriveNumber value; it identifies the new drive that the Message 
       
   505 	Server is using.
       
   506 	
       
   507 	CMsvEntry contexts either refresh themselves or mark themselves invalid.
       
   508 	
       
   509 	@see EMsvMediaUnavailable
       
   510 	@see TDriveNumber */
       
   511 							EMsvMediaChanged, // I assume the following four are in sequential order
       
   512 	/** The media (disk) containing the Message Server index has been removed. 
       
   513 	
       
   514 	aArg1 is a TDriveNumber value that identifies the drive that is no longer 
       
   515 	available.
       
   516 	
       
   517 	Future requests may fail with KMsvMediaUnavailable. A EMsvMediaChanged event 
       
   518 	may be received in the future, as the Message Server switches back to the 
       
   519 	internal drive. */
       
   520 							EMsvMediaUnavailable,
       
   521 	/** The disk containing the Message Store is available again.
       
   522 	
       
   523 	aArg1 is a TDriveNumber value that identifies the drive that is being used.
       
   524 	
       
   525 	The Message Server can now operate as normal. No client action is necessary. */
       
   526 							EMsvMediaAvailable,
       
   527 	/** An incorrect disk is inserted. 
       
   528 	
       
   529 	aArg1 is a TDriveNumber value that identifies the drive in which the incorrect 
       
   530 	disk has been inserted.
       
   531 	
       
   532 	Some requests may fail with KMsvMediaIncorrect. Clients may get an EMsvMediaChanged 
       
   533 	event in the future telling them that the Message Server has switched back 
       
   534 	to the internal drive. */
       
   535 							EMsvMediaIncorrect,
       
   536 	/** The Message Server has started to rebuild its index after it has been corrupted.
       
   537 	
       
   538 	@see EMsvCorruptedIndexRebuilt */
       
   539 							EMsvCorruptedIndexRebuilding
       
   540 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
   541 	/** A media with pre-SQLite message store index has been inserted into a drive in the
       
   542 	priority drive list. */
       
   543 							,EMsvMessageStoreNotSupported,
       
   544 	/** A media with corrupt message store has been inserted into a drive in the priority
       
   545 	drive list and will be deleted. */
       
   546 							EMsvMessageStoreCorrupt,
       
   547 	/** The client needs to refresh its view of messaging either due to a drive with a 
       
   548 	valid message store being added or removed from the priority drive list, or a disk with
       
   549 	a valid message store being inserted or removed from a drive with priority less than
       
   550 	the current drive. */
       
   551 							EMsvRefreshMessageView,
       
   552 	/** Media is not available in the drive that has been added to the priority drive list. */
       
   553 							EMsvDiskNotAvailable,
       
   554 	/** A media insertion/removal event is received by server which it is unable to handle. */
       
   555 							EMsvUnableToProcessDiskNotification
       
   556 #endif
       
   557 							};
       
   558 public: 
       
   559 	/** Indicates an event has occurred. 
       
   560 	
       
   561 	The type of event is indicated by the value of aEvent. The interpretation 
       
   562 	of the TAny arguments depends on this type. 
       
   563 	
       
   564 	For most event types, the action that is taken, for example, updating the 
       
   565 	display, is client-specific. All clients though should respond to EMsvCloseSession 
       
   566 	and EMsvServerTerminated events. 
       
   567 	
       
   568 	@param aEvent Indicates the event type. 
       
   569 	@param aArg1 Event type-specific argument value 
       
   570 	@param aArg2 Event type-specific argument value 
       
   571 	@param aArg3 Event type-specific argument value */
       
   572 	virtual void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3)=0;
       
   573 	};
       
   574 
       
   575 //**********************************
       
   576 // CMsvSession
       
   577 //**********************************
       
   578 //
       
   579 // 
       
   580 //
       
   581 
       
   582 class TCapabilitySet;
       
   583 
       
   584 const TInt KMsvSessionObserverGranularity=4;  //???
       
   585 
       
   586 class CMsvSession: public CActive
       
   587 /** Represents a channel of communication between a client thread (Client-side 
       
   588 MTM, User Interface MTM, or message client application) and the Message Server 
       
   589 thread. 
       
   590 
       
   591 The class provides the means by which clients are notified when important 
       
   592 Message Server events occur.
       
   593 
       
   594 Note the following significant groups of functions:
       
   595 
       
   596 Creation functions: a message client application must use OpenSyncL() or OpenASyncL() 
       
   597 to create a session object, before it can instantiate any MTM or CMsvEntry 
       
   598 object. Only a single session should be created within a thread. As Client-side 
       
   599 MTM, User Interface MTM, and CMsvEntry objects are created in the client thread, 
       
   600 these use the client session, and do not create their own. Note that to close 
       
   601 a session, delete all objects relying on that session, and then the session 
       
   602 object itself.
       
   603 
       
   604 Cleanup functions: CMsvSession provides the ability to handle the cleanup 
       
   605 of entries in the event of a leave occurring, in a very similar manner to 
       
   606 the standard cleanup stack. The difference is that, on a leave, any entries 
       
   607 that are on the entry cleanup stack are removed from the Message Server. The 
       
   608 implementation uses the standard cleanup stack, so entry push and pop functions 
       
   609 should be used in the same order as all other types of push and pop. The functions 
       
   610 can be used both by MTM implementations and message client applications. 
       
   611 @publishedAll
       
   612 @released
       
   613 */
       
   614 	{
       
   615 public: 
       
   616 	IMPORT_C static CMsvSession* OpenSyncL(MMsvSessionObserver& aObserver);
       
   617 	IMPORT_C static CMsvSession* OpenAsyncL(MMsvSessionObserver& aObserver);
       
   618 	IMPORT_C static CMsvSession* OpenAsObserverL(MMsvSessionObserver& aObserver);
       
   619 	
       
   620 	IMPORT_C static CMsvSession* OpenSyncL(MMsvSessionObserver& aObserver, RFs& aFs);
       
   621 	IMPORT_C static CMsvSession* OpenAsyncL(MMsvSessionObserver& aObserver, RFs& aFs);
       
   622 	IMPORT_C static CMsvSession* OpenAsObserverL(MMsvSessionObserver& aObserver, RFs& aFs);
       
   623 	
       
   624 	IMPORT_C static CMsvSession* OpenSyncL(MMsvSessionObserver& aObserver, TInt aPriority);
       
   625 	IMPORT_C static CMsvSession* OpenAsyncL(MMsvSessionObserver& aObserver, TInt aPriority);
       
   626 	IMPORT_C static CMsvSession* OpenAsObserverL(MMsvSessionObserver& aObserver, TInt aPriority);
       
   627 	
       
   628 	IMPORT_C static CMsvSession* OpenSyncL(MMsvSessionObserver& aObserver, RFs& aFs, TInt aPriority);
       
   629 	IMPORT_C static CMsvSession* OpenAsyncL(MMsvSessionObserver& aObserver, RFs& aFs, TInt aPriority);
       
   630 	IMPORT_C static CMsvSession* OpenAsObserverL(MMsvSessionObserver& aObserver, RFs& aFs, TInt aPriority);	
       
   631 	
       
   632 	~CMsvSession();
       
   633 	// --- Observer functions ---
       
   634 	IMPORT_C void AddObserverL(MMsvSessionObserver& aObserver);
       
   635 	IMPORT_C void RemoveObserver(MMsvSessionObserver& aObserver);
       
   636 	IMPORT_C TInt SetReceiveEntryEvents(TBool aReceive);
       
   637 	// --- Utility functions ---
       
   638 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
   639     IMPORT_C CMsvEntry* GetEntryL(TMsvId aEntId, TBool aChildrenOfAvailableDrives);
       
   640 #endif
       
   641 	IMPORT_C CMsvEntry* GetEntryL(TMsvId aEntId);
       
   642 	IMPORT_C TInt GetEntry(TMsvId aId, TMsvId& aService, TMsvEntry& aEntry);
       
   643 	
       
   644 	IMPORT_C CMsvOperation* TransferCommandL(const CMsvEntrySelection& aSelection, TInt aCommandId, const TDesC8& aParameter, TRequestStatus& aStatus);
       
   645 	IMPORT_C void TransferCommandL(const CMsvEntrySelection& aSelection, TInt aCommandId, const TDesC8& aParameter, TDes8& aProgress);
       
   646 	IMPORT_C void IncPcSyncCountL(const CMsvEntrySelection& aSelection);
       
   647 	IMPORT_C void DecPcSyncCountL(const CMsvEntrySelection& aSelection);
       
   648 	IMPORT_C void GetChildIdsL(TMsvId aId, const CMsvEntryFilter& aFilter, CMsvEntrySelection& aSelection);
       
   649 	IMPORT_C void ChangeAttributesL(const CMsvEntrySelection& aSelection, TUint aSetAttributes, TUint aClearAttributes);
       
   650 	IMPORT_C CMsvOperation* ChangeDriveL(TInt aDrive, TRequestStatus& aStatus);
       
   651 	IMPORT_C TInt OutstandingOperationsL();
       
   652 	IMPORT_C CMsvOperation* CopyStoreL(const TDriveUnit& aDrive, TRequestStatus& aStatus);
       
   653 	IMPORT_C CMsvOperation* DeleteStoreL(const TDriveUnit& aDrive, TRequestStatus& aStatus);
       
   654 	// --- cleanup functions
       
   655 	IMPORT_C static void CleanupEntry(TAny* aPtr);
       
   656 	IMPORT_C void CleanupEntryPushL(TMsvId aId);
       
   657 	IMPORT_C void CleanupEntryPop(TInt aCount=1);
       
   658 
       
   659 	IMPORT_C void RemoveEntry(TMsvId aId);
       
   660 	// MTM functions
       
   661 	IMPORT_C TInt InstallMtmGroup(const TDesC& aFullName);
       
   662 	IMPORT_C TInt DeInstallMtmGroup(const TDesC& aFullName); 
       
   663 	
       
   664 	IMPORT_C TInt StopService(TMsvId aServiceId);
       
   665 	IMPORT_C TBool ServiceActive(TMsvId aServiceId);
       
   666 	IMPORT_C TInt ServiceProgress(TMsvId aServiceId, TDes8& aProgress);
       
   667 	
       
   668 	IMPORT_C void CloseMessageServer();
       
   669 	IMPORT_C RFs& FileSession();
       
   670 	
       
   671 	IMPORT_C void GetMtmRequiredCapabilitiesL(TUid aMtmTypeUid, TCapabilitySet& aCapSet) const;
       
   672 	MMsvStoreManager& StoreManager();
       
   673 
       
   674 	IMPORT_C TBool GetAndClearIndexCorruptFlagL();
       
   675 	IMPORT_C TDriveUnit CurrentDriveL();
       
   676 	IMPORT_C TBool DriveContainsStoreL(TDriveUnit aDrive);
       
   677 	IMPORT_C TBool MessageStoreDrivePresentL();
       
   678 
       
   679 	IMPORT_C TInt ServiceAccessPointId(TMsvId aServiceId, TUint32& aAccessPointId);
       
   680 	
       
   681 	// Changed for PREQ 557.
       
   682 	// ---- Preferred list related APIs.
       
   683 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
   684 	IMPORT_C void CurrentDriveInfoL(TDriveNumber& aDriveNumber, TUint& aPriority);
       
   685 	IMPORT_C void DriveListL(RArray<TDriveNumber>& aDriveList);
       
   686 	IMPORT_C void AvailableDriveListL(RArray<TDriveNumber>& aDriveList);
       
   687 	IMPORT_C void AddDriveL(TDriveNumber aDriveNumber, TUint& aPriority);
       
   688 	IMPORT_C void RemoveDriveL(TDriveNumber aDriveNumber);
       
   689 	IMPORT_C void UpdateDrivePriorityL(TDriveNumber aDriveNumber, TUint& aPriority);		
       
   690 	IMPORT_C void GetChildIdsAllL(TMsvId aId, const CMsvEntryFilter& aFilter, CMsvEntrySelection& aSelection);
       
   691 
       
   692 #if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE)
       
   693 	IMPORT_C void ResetRepositoryL();
       
   694 	IMPORT_C void PrintCache();
       
   695 #endif
       
   696 #endif
       
   697 
       
   698     // change for PREQ 2073 Converter
       
   699 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
       
   700 	IMPORT_C void GetConvertibleDriveListL(RArray<TDriveNumber>& aDriveList);
       
   701 	IMPORT_C void ConvertMessageStore(TDriveNumber aDrive,TRequestStatus& aStatus);
       
   702 	IMPORT_C void GetConversionStatusL(TDriveNumber aDrive);
       
   703 	IMPORT_C TInt CancelConversion(TDriveNumber aDrive);
       
   704 #endif			// #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
       
   705 protected:
       
   706 	CMsvSession(MMsvSessionObserver& aObserver);
       
   707 	CMsvSession(MMsvSessionObserver& aObserver, RFs& aFs);
       
   708 	CMsvSession(MMsvSessionObserver& aObserver, TInt aPriority);
       
   709 	CMsvSession(MMsvSessionObserver& aObserver, RFs& aFs, TInt aPriority);
       
   710 	
       
   711 	void ConstructL(TBool aSyncOpening);
       
   712 	void ConstructAsObserverL();
       
   713 	//
       
   714 	IMPORT_C TInt OperationId();
       
   715 	IMPORT_C RMsvServerSession& Session();
       
   716 
       
   717 	void CheckDrive();
       
   718 	//
       
   719 	// from CActive
       
   720 	void RunL();
       
   721 	void DoCancel();
       
   722 	TInt RunError(TInt aError);
       
   723 	//
       
   724 private:
       
   725 	void NotifyAllObserversL(MMsvSessionObserver::TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3);
       
   726 	void CleanupEntryDelete();
       
   727   	void DoRunL(TMsvNotifBuffer& aBuffer);
       
   728  	void HandleNotifyL();
       
   729  	void DoHandleNotifyL(TMsvNotifBuffer& aBuffer);
       
   730 	void GetMessageFolderL();
       
   731 
       
   732 	//	
       
   733 private:
       
   734 	TInt iOperationId;
       
   735 	RFs	iFs;
       
   736 	RMsvServerSession* iSession;
       
   737 	TInt dummy1;
       
   738 	TInt dummy2;
       
   739 	TInt dummy3;
       
   740 	TMsvNotifBuffer iChange;	
       
   741 	MMsvSessionObserver&	iMainObserver;
       
   742 	CArrayPtrFlat<MMsvSessionObserver>* iObservers;
       
   743 	CMsvEntrySelection* iCleanupList;
       
   744 	TInt iSyncStart;
       
   745 	HBufC* iMessageFolder;
       
   746 	TDriveNumber iDrive;
       
   747 	CMsvEntrySelection* iNotifSelection;
       
   748 	TPckgBuf<TUint32> iSequenceBuf;
       
   749 	TUint32 iNotifySequence;
       
   750 	TBool iReceiveEntryEvents;
       
   751 	/** Specifies whether to use the shared file server session */	
       
   752 	TBool iUseSharedFs;
       
   753 	//
       
   754 #ifndef _NO_SESSION_LOGGING_
       
   755 	void CreateSessionLogL();
       
   756 	void Log(TRefByValue<const TDesC> aFmt, ...);
       
   757 
       
   758 	// must be the last data member in the class to preserve BC.
       
   759 	mutable RFileLogger iLog;
       
   760 #endif
       
   761 	//
       
   762 friend class CSendAs;
       
   763 friend class CMsvEntry;
       
   764 friend class CMsvOperation;
       
   765 friend class CMsvEntryOperation;
       
   766 friend class CObserverRegistry;
       
   767 friend class CMsvSearchSortOperation;
       
   768 friend class CMsvSearchsortOpOnHeaderBody;
       
   769 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
       
   770 friend class CMsvHeaderStore;
       
   771 #endif
       
   772 #if (defined SYMBIAN_MESSAGESTORE_UNIT_TESTCODE)
       
   773 	friend class CTestMsvSession;
       
   774 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
       
   775 	friend class CTestHeaderEntry;
       
   776 #endif
       
   777 #endif	
       
   778 	};
       
   779 
       
   780 
       
   781 
       
   782 
       
   783 //**********************************
       
   784 // MMsvEntryObserver
       
   785 //**********************************
       
   786 //
       
   787 // 
       
   788 //
       
   789 
       
   790 class MMsvEntryObserver
       
   791 /** Provides the interface for notification of events associated with an entry. 
       
   792 
       
   793 The types of event are given in the enumeration TMsvEntryEvent. Clients can 
       
   794 provide an object that implements the interface, and set it to be notified 
       
   795 through CMsvEntry::AddObserverL(). 
       
   796 @publishedAll
       
   797 @released
       
   798 */
       
   799 	{
       
   800 public:
       
   801 	/** Defines entry event types. 
       
   802 @publishedAll
       
   803 @released
       
   804 */
       
   805 	enum TMsvEntryEvent 
       
   806 							{	
       
   807 	/** The entry has been changed, either as a result of a CMsvEntry::ChangeL() or 
       
   808 	by another client. */
       
   809 							EMsvEntryChanged,
       
   810 	/** New children have been created. aArg1 points to a CMsvEntrySelection contain 
       
   811 	the ID of the new children. */
       
   812 							EMsvNewChildren,
       
   813 	/** Children have been deleted. aArg1 points to a CMsvEntrySelection contain the 
       
   814 	ID of the deleted children. */
       
   815 							EMsvDeletedChildren,
       
   816 	/** One or more of the children have been changed. aArg1 points to a CMsvEntrySelection 
       
   817 	containing the IDs of the changed children. */
       
   818 							EMsvChildrenChanged,
       
   819 	/** The entry has been deleted by another client. The context is now invalid. */
       
   820 							EMsvEntryDeleted,
       
   821 	/** The context has become invalid. The entry has been changed, but the CMsvEntry 
       
   822 	was unable to update the context. The context will only become valid by a 
       
   823 	successful CMsvEntry::SetEntryL() call. aArg1 points to a TInt containing 
       
   824 	the error code for the invalid context. */
       
   825 							EMsvContextInvalid,
       
   826 	/** Some new children have been created, but CMsvEntry was unable to retrieve the 
       
   827 	data from the Message Server. The children will be correct only after a successful 
       
   828 	call to CMsvEntry::SetEntryL(). */
       
   829 							EMsvChildrenMissing,
       
   830 	/** An error has occurred such that the status of the children is unknown and probably 
       
   831 	invalid. aArg1 points to a TInt containing the error code for the invalid 
       
   832 	context */
       
   833 							EMsvChildrenInvalid,
       
   834 	/** The current entry has been moved by another client. The CMsvEntry has already 
       
   835 	been updated to reflect the new parent. */
       
   836 							EMsvEntryMoved};
       
   837 public: 
       
   838 	/** Indicates when called by a CMsvEntry object that an event has occurred.
       
   839 	
       
   840 	The type of event is indicated by the value of aEvent. The interpretation of the aArg1-3 values depends on this type. 
       
   841 	For most event types, the action that is taken, for example, updating the display, is client-specific. Most clients will 
       
   842 	need to handle events that make the current context invalid: EMsvContextInvalid and EMsvEntryDeleted.
       
   843 
       
   844 	An implementation can leave if an error occurs. The leave is not trapped by the framework, so 
       
   845 	the error code may be displayed to the user.
       
   846 
       
   847 	@param aEvent Indicates the event type.
       
   848 	@param aArg1 Event-specific argument value
       
   849 	@param aArg2 Event-specific argument value
       
   850 	@param aArg3 Event-specific argument value
       
   851 	*/
       
   852 	virtual void HandleEntryEventL(TMsvEntryEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3)=0;
       
   853 	};
       
   854 
       
   855 
       
   856 
       
   857 //**********************************
       
   858 // CMsvEntry
       
   859 //**********************************
       
   860 //
       
   861 // 
       
   862 //
       
   863 
       
   864 class CMsvEntry: public CBase, public MMsvSessionObserver, public MMsvStoreObserver
       
   865 /** Accesses and acts upon a particular Message Server entry. The current entry 
       
   866 that a CMsvEntry object relates is referred to as its context. 
       
   867 
       
   868 It may be helpful to consider CMsvEntry functions in two broad groups. The 
       
   869 first provides means to access the various types of storage associated with 
       
   870 an entry. The second provides a means to discover and access other entries 
       
   871 that the entry owns (its children). 
       
   872 
       
   873 Message client applications, Client-side MTMs, and User Interface MTMs all 
       
   874 commonly use CMsvEntry objects. CMsvEntry objects though represent a lower 
       
   875 level of access to an entry than that provided by a Client-side MTM or User 
       
   876 Interface MTM. In particular, any MTM-specific functionality, such as address 
       
   877 lists or subject fields, must be accessed by a message client application 
       
   878 through an MTM inteface.
       
   879 
       
   880 A CMsvEntry object is relatively expensive in RAM usage, as it caches its 
       
   881 children, updating them as necessary when notified of changes. They should 
       
   882 therefore be created sparingly.
       
   883 
       
   884 Note that Server-side MTMs do not use this class, but a similar one, CMsvServerEntry.
       
   885  
       
   886 @publishedAll
       
   887 @released
       
   888 */
       
   889 	{
       
   890 public: // Public member functions
       
   891 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
   892     IMPORT_C static CMsvEntry* NewL(CMsvSession& aMsvSession, TMsvId aMsvId, const TMsvSelectionOrdering& aOrdering, TBool aChildrenOfAvailableDrives);
       
   893     IMPORT_C void SetStandardFolderEntryL(TMsvId aId);
       
   894     IMPORT_C CMsvEntrySelection* ChildrenOfAvailableDrivesL() const;
       
   895 #endif
       
   896 	IMPORT_C static CMsvEntry* NewL(CMsvSession& aMsvSession, TMsvId aMsvId, const TMsvSelectionOrdering& aOrdering);
       
   897 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
   898 	IMPORT_C void SetEntryNoCheckL(TMsvId aId, TBool aChildrenOfAvailableDrives=EFalse);
       
   899 #else
       
   900 	IMPORT_C void SetEntryNoCheckL(TMsvId aId);
       
   901 #endif
       
   902 	IMPORT_C ~CMsvEntry();
       
   903 	//
       
   904 	// --- Observer functions ---
       
   905 	IMPORT_C void AddObserverL(MMsvEntryObserver& aObserver);
       
   906 	IMPORT_C void RemoveObserver(MMsvEntryObserver& aObserver);
       
   907 	//
       
   908 	// --- Accessor for associated session ---
       
   909 	inline CMsvSession& Session(); 
       
   910 	//
       
   911 	// --- Accessors the associated message store ---
       
   912 	IMPORT_C CMsvStore* ReadStoreL();
       
   913 	IMPORT_C CMsvStore* EditStoreL();
       
   914 	//
       
   915 	// --- Synchronous Current Entry functions ---
       
   916 	inline TMsvId EntryId() const; 
       
   917 	inline const TMsvEntry& Entry() const; 
       
   918 	inline const TMsvSelectionOrdering& SortType() const;
       
   919 	inline TMsvId OwningService() const;
       
   920 	IMPORT_C void SetSortTypeL(const TMsvSelectionOrdering& aOrdering);
       
   921 	IMPORT_C void SetMtmListL(const CArrayFix<TUid>& aMtmList);
       
   922 	IMPORT_C void SetEntryL(TMsvId aId);
       
   923 	IMPORT_C void ChangeL(const TMsvEntry& aEntry);
       
   924 	IMPORT_C void ChangeL(const TMsvEntry& aEntry, TSecureId aOwnerId);
       
   925 	
       
   926 
       
   927 	//
       
   928 	// --- Asynchronous Current Entry functions ---
       
   929 	IMPORT_C CMsvOperation* ChangeL(const TMsvEntry& aEntry, TRequestStatus& aStatus);
       
   930 	IMPORT_C CMsvOperation* ChangeL(const TMsvEntry& aEntry, TSecureId aOwnerId, TRequestStatus& aStatus);
       
   931 	IMPORT_C CMsvOperation* ChangeL(const CMsvEntrySelection& aSelection, TBool aMark,TRequestStatus& aStatus);
       
   932 	//
       
   933 	// --- Asynchronous Child Entry functions ---
       
   934 	IMPORT_C CMsvOperation* CreateL(const TMsvEntry& aEntry, TRequestStatus& aStatus);
       
   935 	IMPORT_C CMsvOperation* CreateL(const TMsvEntry& aEntry, TSecureId aOwnerId, TRequestStatus& aStatus);
       
   936 	IMPORT_C CMsvOperation* DeleteL(const CMsvEntrySelection& aSelection, TRequestStatus& aStatus);
       
   937 	IMPORT_C CMsvOperation* DeleteL(TMsvId aMsvId, TRequestStatus& aStatus);
       
   938 	IMPORT_C CMsvOperation* CopyL(const CMsvEntrySelection& aSelection, TMsvId aTargetId, TRequestStatus& aStatus);
       
   939 	IMPORT_C CMsvOperation* CopyL(TMsvId aMsvId, TMsvId aTargetId, TRequestStatus& aStatus);
       
   940 	IMPORT_C CMsvOperation* MoveL(const CMsvEntrySelection& aSelection, TMsvId aTargetId, TRequestStatus& aStatus);
       
   941 	IMPORT_C CMsvOperation* MoveL(TMsvId aMsvId, TMsvId aTargetId, TRequestStatus& aStatus);
       
   942 	//
       
   943 	// --- Synchronous Child Entry functions ---
       
   944 	IMPORT_C CMsvEntrySelection* ChildrenL() const;
       
   945 	IMPORT_C CMsvEntrySelection* ChildrenWithServiceL(TMsvId aServiceId) const;
       
   946 	IMPORT_C CMsvEntrySelection* ChildrenWithMtmL(TUid aMtm) const;
       
   947 	IMPORT_C CMsvEntrySelection* ChildrenWithTypeL(TUid aType) const;
       
   948 	
       
   949 	inline TInt Count() const;
       
   950 	IMPORT_C const TMsvEntry& ChildDataL(TMsvId aId) const;
       
   951 	IMPORT_C const TMsvEntry& operator[](TInt aIndex) const;
       
   952 	IMPORT_C CMsvEntry* ChildEntryL(TMsvId aId) const;
       
   953 	IMPORT_C void MoveL(TMsvId aMsvId, TMsvId aTargetId);
       
   954 	IMPORT_C void MoveL(const CMsvEntrySelection& aSelection, TMsvId aTargetId, TMsvLocalOperationProgress& aProgress);
       
   955 	IMPORT_C void CopyL(const CMsvEntrySelection& aSelection, TMsvId aTargetId, TMsvLocalOperationProgress& aProgress);
       
   956 	IMPORT_C void CopyL(TMsvId aMsvId, TMsvId aTargetId);
       
   957 
       
   958 
       
   959 	IMPORT_C void CreateL(TMsvEntry& aEntry);
       
   960 	IMPORT_C void CreateL(TMsvEntry& aEntry, TSecureId aOwnerId);
       
   961 	IMPORT_C void DeleteL(TMsvId aId);
       
   962 	IMPORT_C void DeleteL(const CMsvEntrySelection& aSelection, TMsvLocalOperationProgress& aProgress);
       
   963 	IMPORT_C void ChangeAttributesL(const CMsvEntrySelection& aSelection, TUint aSetAttributes, TUint aClearAttributes);
       
   964 	//
       
   965 	// from MMsvSessionObserver
       
   966 	void HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3);
       
   967 	// From MMsvStoreObserver
       
   968 	void HandleStoreEvent(TMsvStoreEvent aEvent, TMsvId aId);
       
   969 
       
   970 
       
   971 	IMPORT_C TBool HasStoreL() const;
       
   972 	
       
   973 	//	
       
   974 private: // Private members
       
   975 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
   976     CMsvEntry(CMsvSession& aMsvSession, const TMsvSelectionOrdering& aOrdering, TBool aChildrenOfAvailableDrives);
       
   977 	inline TUint GetDriveId(TMsvId aMaskedId) const;
       
   978 #endif
       
   979 	CMsvEntry(CMsvSession& aMsvSession, const TMsvSelectionOrdering& aOrdering);
       
   980 
       
   981 	void ConstructL(TMsvId aMsvId);
       
   982 	//
       
   983 	void NotifyAllObserversL(MMsvEntryObserver::TMsvEntryEvent aEvent, TAny* aArg1, TAny* aArg2, TAny* aArg3);
       
   984 	void ContextChangedL(MMsvEntryObserver::TMsvEntryEvent aEvent);
       
   985 	void NewChildrenL(const CMsvEntrySelection& aSelection);
       
   986 	CMsvEntrySelection* DoGetNewChildrenL(const CMsvEntrySelection& aSelection);
       
   987 	void DeletedChildrenL(const CMsvEntrySelection& aSelection);
       
   988 	void ChildrenChangedL(const CMsvEntrySelection& aSelection);
       
   989 	void CheckNewGrandchildrenL(TMsvId aId);
       
   990 	void CheckDeletedGrandchildrenL(TMsvId aId);
       
   991 	void NotifyChildChangedL(TMsvId aId);
       
   992 	CMsvEntrySelection* DoMakeSelectionL(TMsvId aId);
       
   993 	void CheckIfContextMovedL(const CMsvEntrySelection& aSelection);
       
   994 	//
       
   995 	TBool IsAChild(TMsvId aId) const;
       
   996 	TBool AreChildren(const CMsvEntrySelection& aSelection) const;
       
   997 	//
       
   998 	CMsvOperation* DoDeleteL(const CMsvEntrySelection& aSelection, TRequestStatus& aStatus);
       
   999 	CMsvClientEntry* DoGetEntryLC(TMsvId aId, TMsvId& aOwningService);
       
  1000 	void DoGetChildrenL();
       
  1001 	CMsvEntryArray* GetNewSortedListL(const TMsvSelectionOrdering& aOrdering, const CArrayFix<TUid>& aMtmList);
       
  1002 	void DoSortTypeL(CMsvClientEntry* aContext);
       
  1003 	void ReplaceChildL(TInt pos, const TMsvEntry& aEntry);
       
  1004 	void DeleteChild(TInt aPosition);
       
  1005 	void HandleMediaChangeL();
       
  1006 
       
  1007 	TInt MoveOneL(TMsvId aMsvId, TMsvId aTargetId);
       
  1008 	TInt CopyOneL(TMsvId aMsvId, TMsvId aTargetId);
       
  1009 	TInt DeleteOneL(TMsvId aMsvId);
       
  1010 
       
  1011 	//
       
  1012 private:
       
  1013 	enum TEntryState {	EValid,
       
  1014 						EInvalidChangingContext,
       
  1015 						EInvalidDeletedContext,
       
  1016 						EInvalidOldContext,
       
  1017 						EInvalidMissingChildren};
       
  1018 	//
       
  1019 #ifndef _NO_SESSION_LOGGING_
       
  1020 	void Log(TRefByValue<const TDesC> aFmt, ...);
       
  1021 #endif
       
  1022 	//
       
  1023 private:
       
  1024 	TBool iOberserverAdded;
       
  1025 	TEntryState	iState;
       
  1026 	CMsvSession& iMsvSession;
       
  1027 	TMsvSelectionOrdering iOrdering;
       
  1028 	const TMsvEntry* iEntryPtr;
       
  1029 	CArrayPtrFlat<MMsvEntryObserver>* iObservers;
       
  1030 	CArrayPtrFlat<CMsvClientEntry>* iEntries;
       
  1031 	CMsvEntryArray* iSortedChildren;
       
  1032 	CMsvStore* iStore;
       
  1033 	CArrayFixFlat<TUid>* iMtmList;
       
  1034 	TMsvId iOwningService;
       
  1035 	TUint32 iNotifySequence;
       
  1036 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
  1037 	/* If this flag is set, child entries from all available drives
       
  1038 	   in the preferred drive list will be fetched. */
       
  1039 	TBool iChildrenOfAvailableDrives;
       
  1040 #endif
       
  1041 	};
       
  1042 
       
  1043 //**********************************
       
  1044 // MessageServer
       
  1045 //**********************************
       
  1046 //
       
  1047 // 
       
  1048 //
       
  1049 
       
  1050 class MessageServer
       
  1051 /** Provides various static information functions relating to the Message Server.
       
  1052 
       
  1053 @see TDriveNumber 
       
  1054 @publishedAll
       
  1055 @released
       
  1056 */
       
  1057 	{
       
  1058 public:
       
  1059 	IMPORT_C static TVersion Version();
       
  1060 	IMPORT_C static TMsvId NullUidValue();
       
  1061 	//
       
  1062 	IMPORT_C static TBool DriveContainsStore(RFs& aFs, TInt aDrive);
       
  1063 	IMPORT_C static TInt CurrentDriveL(RFs& aFs);
       
  1064 	IMPORT_C static TBool IsMessageStoreDrivePresentL(RFs& aFs);
       
  1065 #if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
       
  1066 	IMPORT_C static TBool IsMessageStoreSupported(TDriveNumber aDrive);
       
  1067 #endif
       
  1068 	};
       
  1069 
       
  1070 //**********************************
       
  1071 // MtmClientUtils
       
  1072 //**********************************
       
  1073 //
       
  1074 // 
       
  1075 //
       
  1076 
       
  1077 class McliUtils
       
  1078 /** Utility class to simplify getting progress information from a messaging operation object.
       
  1079 
       
  1080 The functions get and unpack the progress information buffers from an operation object.
       
  1081 
       
  1082 @publishedAll
       
  1083 @released
       
  1084 */
       
  1085     {
       
  1086 public:
       
  1087     IMPORT_C static TMsvLocalOperationProgress GetLocalProgressL(CMsvOperation& aOperation);
       
  1088     IMPORT_C static TMsvLocalOperationProgress GetFinalLocalProgress(CMsvOperation& aOperation);
       
  1089     IMPORT_C static TInt GetProgressErrorL(CMsvOperation& aOperation);
       
  1090     IMPORT_C static TMsvId GetProgressIdL(CMsvOperation& aOperation);
       
  1091 	};
       
  1092 
       
  1093 
       
  1094 
       
  1095 
       
  1096 
       
  1097 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
       
  1098 
       
  1099 /**
       
  1100  * The class allows  client MTMs  to communicate the  header structure 
       
  1101  * to the message server. It provides API to add various fields to the
       
  1102  * header structure. Finally it provides API to create header store in
       
  1103  * the messaging DB.   The store will always be created in the message
       
  1104  * server current drive. In order to create store in non-current drive
       
  1105  * the user should perform ChangeDrive() operation.
       
  1106 
       
  1107  * The header store should be created immediately after creating the
       
  1108  * mail account. The server will create separate header store for each
       
  1109  * MTM type. The function does not return an error if the header store
       
  1110  * being created already exist.
       
  1111 
       
  1112  @publishedAll
       
  1113  @released
       
  1114  */
       
  1115 class CMsvHeaderStore : public CBase
       
  1116 	{
       
  1117 public:
       
  1118 
       
  1119 	/**
       
  1120 	 * Common Header Fields
       
  1121 	 * @publishedAll
       
  1122 	 * @released
       
  1123 	 */
       
  1124 	enum TCommonHeaderField
       
  1125 		{		
       
  1126 		EFrom    = 0x001,
       
  1127 		ETo      = 0x002,
       
  1128 		ECC      = 0x004,
       
  1129 		EBCC     = 0x008,
       
  1130 		ESubject = 0x010
       
  1131 		};
       
  1132 
       
  1133 
       
  1134 	IMPORT_C static CMsvHeaderStore* NewL(const TUid& aMtmId, CMsvSession& aSession);
       
  1135 	IMPORT_C static CMsvHeaderStore* NewLC(const TUid& aMtmId, CMsvSession& aSession);
       
  1136 	~CMsvHeaderStore();
       
  1137 
       
  1138 	IMPORT_C void AddFieldL(HBufC* aFieldName, EFieldType aFieldType);
       
  1139 	IMPORT_C void AddFieldL(TCommonHeaderField aCommonHeaderFieldName);
       
  1140 	IMPORT_C void CreateStoreL();
       
  1141 	IMPORT_C static TBool DoesStoreExistsL(const TUid& aMtmId, CMsvSession& aSession);
       
  1142 	IMPORT_C TPtrC LastErrorMessageL();
       
  1143 	
       
  1144 private:
       
  1145 	CMsvHeaderStore(TUid aMtmId, CMsvSession& aSession);
       
  1146 	void ConstructL();
       
  1147 
       
  1148 private:
       
  1149 
       
  1150 	TUid iMtmUid;
       
  1151 	CMsvSession& iSessionRef;
       
  1152 	RPointerArray<CFieldPair> iFieldDetails;
       
  1153 	HBufC* iLastErrorMessage;
       
  1154 	};
       
  1155 
       
  1156 
       
  1157 #endif    	// #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
       
  1158 #include <msvapi.inl>
       
  1159 
       
  1160 #endif // __MSVAPI_H__