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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __MSVENTRY_H__
17 #define __MSVENTRY_H__
21 #if !defined(__E32BASE_H__)
25 #if !defined(__MSVSTORE_H__)
30 // Forward declarations
32 class CMsvCopyMoveEntriesBase;
35 //**********************************
37 //**********************************
42 class CMsvServerEntry : public CActive, public MMsvStoreObserver
43 /** Accesses and acts upon a particular Message Server entry.
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
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.
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().
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.
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).
72 IMPORT_C static CMsvServerEntry* NewL(CMsvServer& aServer, TMsvId aId);
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;
80 // current entry only functions
81 IMPORT_C TInt ChangeEntry(const TMsvEntry& aEntry, TSecureId aOwnerId);
82 IMPORT_C TInt ChangeEntry(const TMsvEntry& aEntry);
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);
103 // read and write the store associated with the context
104 IMPORT_C CMsvStore* ReadStoreL();
105 IMPORT_C CMsvStore* EditStoreL();
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);
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);
117 // Spawns a new CMsvServerEntry object
118 IMPORT_C CMsvServerEntry* NewEntryL(TMsvId aId);
120 // from MMsvStoreObserver
121 void HandleStoreEvent(MMsvStoreObserver::TMsvStoreEvent aEvent, TMsvId aId);
125 IMPORT_C TBool HasStoreL() const;
127 IMPORT_C RFs& FileSession();
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);
133 IMPORT_C TInt CreateEntryBulk(TMsvEntry& aEntry);
135 IMPORT_C TInt ChangeEntryBulk(const TMsvEntry& aEntry, TSecureId aOwnerId);
136 IMPORT_C TInt ChangeEntryBulk(const TMsvEntry& aEntry);
138 IMPORT_C void CompleteBulk();
141 CMsvServerEntry(CMsvServer& aIndex);
142 void ConstructL(TMsvId aId);
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);
163 TMsvSelectionOrdering iOrdering;
170 CMsvCopyMoveEntriesBase* iCopyMove;
172 enum { EMsvIdle, EMsvMoving, EMsvCopying } iEntryState;
173 TRequestStatus* iObserverStatus;
174 CMsvEntrySelection* iCompletedSelection;
175 TMsvId* iCompletedEntryId;
176 TSecureId iContextOwnerId;
180 #include <msventry.inl>
182 #endif // __MSVENTRY_H__