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