messagingfw/msgsrvnstore/server/inc/MSVENTRY.H
changeset 0 8e480a14352b
child 58 6c34d0baa0b1
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     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 //
       
    15 
       
    16 #ifndef __MSVENTRY_H__
       
    17 #define __MSVENTRY_H__
       
    18 
       
    19 
       
    20 
       
    21 #if !defined(__E32BASE_H__)
       
    22 #include <e32base.h>
       
    23 #endif
       
    24 
       
    25 #if !defined(__MSVSTORE_H__)
       
    26 #include <msvstore.h>
       
    27 #endif
       
    28 
       
    29 //
       
    30 // Forward declarations
       
    31 class CMsvStore;
       
    32 class CMsvCopyMoveEntriesBase;
       
    33 class CMsvServer;
       
    34 
       
    35 //**********************************
       
    36 // CMsvServerEntry
       
    37 //**********************************
       
    38 //
       
    39 //
       
    40 //
       
    41 
       
    42 class CMsvServerEntry : public CActive, public MMsvStoreObserver
       
    43 /** Accesses and acts upon a particular Message Server entry. 
       
    44 
       
    45 It provides similar 
       
    46 functionality to that which CMsvEntry gives to client-side programs. The current 
       
    47 entry that a CMsvServerEntry object relates is similarly referred to as its 
       
    48 context. 
       
    49 
       
    50 A difference to note is that CMsvEntry functions, when used on a remote context, 
       
    51 can result in requests to Server-side MTMs to change data on a remote server, 
       
    52 as well as the local Message Server index. Naturally, as CMsvServerEntry is 
       
    53 designed to be used by Server-side MTMs themselves, its comparable functions 
       
    54 only alter the Message Server index.
       
    55 
       
    56 A CBaseServerMTM-derived object gets an initial CMsvServerEntry on construction. 
       
    57 It can get further CMsvServerEntry objects by calling NewEntryL(). The context 
       
    58 can be changed by SetEntry().
       
    59 
       
    60 The context is locked, preventing it being accessed by other MTMs. The lock 
       
    61 is released when the object is deleted, or the context changes.
       
    62 
       
    63 As with CMsvEntry, CBaseServerMTM functions can be divided into two broad 
       
    64 groups. The first provides means to access the various types of storage associated 
       
    65 with an entry. The second provides a means to discover and access other entries 
       
    66 that the entry owns (its children).  
       
    67 @publishedAll
       
    68 @released
       
    69 */
       
    70 	{
       
    71 public:
       
    72 	IMPORT_C static CMsvServerEntry* NewL(CMsvServer& aServer, TMsvId aId);
       
    73 	~CMsvServerEntry();
       
    74 	//
       
    75 	// Set and get the current context
       
    76 	IMPORT_C TInt SetEntry(TMsvId aId);
       
    77 	inline const TMsvEntry& Entry() const;
       
    78 	IMPORT_C TMsvId OwningService() const;
       
    79 	//
       
    80 	// current entry only functions
       
    81 	IMPORT_C TInt ChangeEntry(const TMsvEntry& aEntry, TSecureId aOwnerId);
       
    82 	IMPORT_C TInt ChangeEntry(const TMsvEntry& aEntry);
       
    83 	
       
    84 
       
    85 	//
       
    86 	// child entry only functions
       
    87 	IMPORT_C TInt CreateEntry(TMsvEntry& aEntry);
       
    88 	IMPORT_C TInt CreateEntry(TMsvEntry& aEntry, TSecureId aOwnerId);
       
    89 	IMPORT_C TInt CreateEntry(TMsvEntry& aEntry, TSecureId aOwnerId, TBool aBulk);
       
    90 	IMPORT_C TInt DeleteEntry(TMsvId aId);
       
    91 	IMPORT_C TInt DeleteEntries(CMsvEntrySelection& aSelection);
       
    92 	IMPORT_C TInt MoveEntryWithinService(TMsvId aId, TMsvId aDestination);
       
    93 	IMPORT_C TInt MoveEntriesWithinService(CMsvEntrySelection& aSelection, TMsvId aDestination);
       
    94 	IMPORT_C TInt ChangeAttributes(const CMsvEntrySelection& aSelection, TUint aSetAttributes, TUint aClearAttributes);
       
    95 	IMPORT_C void MoveEntryL(TMsvId aId, TMsvId aDestination, TRequestStatus& aObserverStatus);
       
    96 	IMPORT_C void MoveEntriesL(const CMsvEntrySelection& aSelection, TMsvId aDestination, TRequestStatus& aObserverStatus);
       
    97 	IMPORT_C void CopyEntryL(TMsvId aId, TMsvId aDestination, TRequestStatus& aObserverStatus);
       
    98 	IMPORT_C void CopyEntryL(TMsvId aId, TMsvId aDestination, TMsvId& aCompletedEntry, TRequestStatus& aObserverStatus);
       
    99 	IMPORT_C void CopyEntriesL(const CMsvEntrySelection& aSelection, TMsvId aDestination, TRequestStatus& aObserverStatus);
       
   100 	IMPORT_C void CopyEntriesL(const CMsvEntrySelection& aSelection, TMsvId aDestination, CMsvEntrySelection& aCompletedSelection, TRequestStatus& aObserverStatus);
       
   101 	IMPORT_C TInt GetEntryFromId(TMsvId aId,TMsvEntry*& aEntry);
       
   102 	//
       
   103 	// read and write the store associated with the context
       
   104 	IMPORT_C CMsvStore* ReadStoreL();
       
   105 	IMPORT_C CMsvStore* EditStoreL();
       
   106 	//
       
   107 	// List the children of the context 
       
   108 	inline const TMsvSelectionOrdering& Sort();
       
   109 	inline void SetSort(TMsvSelectionOrdering& aOrdering);
       
   110 	inline void SetMtm(TUid aMtm);
       
   111 	IMPORT_C TInt GetChildren(CMsvEntrySelection& aSelection);
       
   112 	//
       
   113 	IMPORT_C TInt GetChildrenWithService(TMsvId aServiceId, CMsvEntrySelection& aSelection);
       
   114 	IMPORT_C TInt GetChildrenWithMtm(TUid aMtm, CMsvEntrySelection& aSelection);
       
   115 	IMPORT_C TInt GetChildrenWithType(TUid aType, CMsvEntrySelection& aSelection);
       
   116 	//
       
   117 	// Spawns a new CMsvServerEntry object
       
   118 	IMPORT_C CMsvServerEntry* NewEntryL(TMsvId aId);
       
   119 	// 
       
   120 	// from MMsvStoreObserver
       
   121 	void HandleStoreEvent(MMsvStoreObserver::TMsvStoreEvent aEvent, TMsvId aId);
       
   122 	//
       
   123 	//
       
   124 
       
   125 	IMPORT_C TBool HasStoreL() const;
       
   126 	//
       
   127 	IMPORT_C RFs& FileSession();
       
   128 	//
       
   129 	// Methods for creating and changing entries in bulk
       
   130 	// (e.g. during email header downloading)
       
   131 	IMPORT_C TInt CreateEntryBulk(TMsvEntry& aEntry, TSecureId aOwnerId);
       
   132 
       
   133 	IMPORT_C TInt CreateEntryBulk(TMsvEntry& aEntry);
       
   134 
       
   135 	IMPORT_C TInt ChangeEntryBulk(const TMsvEntry& aEntry, TSecureId aOwnerId);
       
   136 	IMPORT_C TInt ChangeEntryBulk(const TMsvEntry& aEntry);
       
   137 	
       
   138 	IMPORT_C void CompleteBulk();
       
   139 
       
   140 protected:
       
   141 	CMsvServerEntry(CMsvServer& aIndex);
       
   142 	void ConstructL(TMsvId aId);
       
   143 	//
       
   144 	void RunL();
       
   145 	void DoCancel();
       
   146 	//
       
   147 private:
       
   148 	TInt IncreaseBufferSizes(TInt aNewDescriptionSize, TInt aNewDetailsSize);
       
   149 	TBool AreChildren(const CMsvEntrySelection& aSelection) const;
       
   150 	TBool IsAChild(TMsvId aId) const;
       
   151 	void DoMoveEntryL(TMsvId aId, TMsvId aDestination);
       
   152 	void DoDeleteEntryL(TMsvId aId, CMsvEntrySelection*& aDeleted, CMsvEntrySelection*& aMoved);
       
   153 	void DoDeleteEntriesL(CMsvEntrySelection& aSelection, CMsvEntrySelection*& aDeleted, CMsvEntrySelection*& aMoved);
       
   154 	void DoMoveEntriesL(CMsvEntrySelection& aSelection, TMsvId aDestination, CMsvEntrySelection*& aMoved);
       
   155 	TInt DoGetChildren(TMsvId aServiceId, TUid aMtm, TUid aType, CMsvEntrySelection& aSelection);
       
   156 	void DoGetChildrenL(TMsvId aServiceId, TUid aMtm, TUid aType, CMsvEntrySelection& aSelection);
       
   157 	void DoCopyEntriesL(const CMsvEntrySelection& aSelection, TMsvId aDestination, TRequestStatus& aObserverStatus);
       
   158 	TInt DoChangeEntry(const TMsvEntry& aEntry, TSecureId aOwnerId, TBool aForcedUpdate, TBool aBulk);
       
   159 
       
   160 	//
       
   161 private:
       
   162 	TBool iLockedStore;
       
   163 	TMsvSelectionOrdering iOrdering;
       
   164 	TMsvEntry iEntry;
       
   165 	HBufC* iDescription;
       
   166 	HBufC* iDetails;
       
   167 	CMsvServer& iServer;
       
   168 	CMsvStore* iStore;
       
   169 	TUid iMtm;
       
   170 	CMsvCopyMoveEntriesBase* iCopyMove;
       
   171 	TMsvId iSource;
       
   172 	enum { EMsvIdle, EMsvMoving, EMsvCopying } iEntryState;
       
   173 	TRequestStatus* iObserverStatus;
       
   174 	CMsvEntrySelection* iCompletedSelection;
       
   175 	TMsvId* iCompletedEntryId;
       
   176 	TSecureId	iContextOwnerId;
       
   177 	};
       
   178 
       
   179 
       
   180 #include <msventry.inl>
       
   181 
       
   182 #endif // __MSVENTRY_H__