62
|
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 |
// MTCLBASE.CPP
|
|
15 |
//
|
|
16 |
#include <e32std.h>
|
|
17 |
#include <txtrich.h>
|
|
18 |
#include <txtfmlyr.h>
|
|
19 |
#include <mtmuids.h>
|
|
20 |
|
|
21 |
#include "MSVIDS.H"
|
|
22 |
#include "MSVAPI.H"
|
|
23 |
#include "MTCLBASE.H"
|
|
24 |
#include "MTCLREG.H"
|
|
25 |
#include "MSVPANIC.H"
|
|
26 |
#include "MSVUIDS.H"
|
|
27 |
|
|
28 |
#include <mmsvattachmentmanager.h>
|
|
29 |
#include "CMsvAttachmentWaiter.h"
|
|
30 |
#include <cmsvmimeheaders.h>
|
|
31 |
|
|
32 |
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
|
|
33 |
#include "msvconsts.h"
|
|
34 |
#endif
|
|
35 |
|
|
36 |
#if defined(_DEBUG)
|
|
37 |
_LIT(KMtclPanicString, "MSGS");
|
|
38 |
#endif
|
|
39 |
|
|
40 |
|
|
41 |
EXPORT_C CBaseMtm::CBaseMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aSession)
|
|
42 |
: iRegisteredMtmDll(aRegisteredMtmDll), iSession(aSession)
|
|
43 |
//
|
|
44 |
//
|
|
45 |
//
|
|
46 |
/** Creates a CBaseMtm with member variables initialised from the passed arguments.
|
|
47 |
|
|
48 |
|
|
49 |
Client applications do not use this function. It is relevant only to implementers
|
|
50 |
of derived classes.
|
|
51 |
|
|
52 |
The value of aSession can be accessed through Session().
|
|
53 |
|
|
54 |
Derived classes can implement a constructor to perform any additional MTM-specific
|
|
55 |
setup that can be safely carried out in a constructor. Such constructors must
|
|
56 |
call the base class constructor function.
|
|
57 |
|
|
58 |
Derived classes also implement two-phase construction functions (NewL(), ConstructL())
|
|
59 |
to create a new instance of the object, in which any dynamic allocation should
|
|
60 |
be performed. Client-side MTMs also implement a factory function by which
|
|
61 |
a MTM registry can request an instance of the class.
|
|
62 |
|
|
63 |
@param aRegisteredMtmDll Registration data for the MTM DLL.
|
|
64 |
@param aSession The CMsvSession of the client requesting the object */
|
|
65 |
{}
|
|
66 |
|
|
67 |
|
|
68 |
EXPORT_C CBaseMtm::~CBaseMtm()
|
|
69 |
//
|
|
70 |
//
|
|
71 |
//
|
|
72 |
/** Cleans up the base class.
|
|
73 |
|
|
74 |
CBaseMtm -derived objects must be deleted by client applications when they
|
|
75 |
are no longer required.
|
|
76 |
|
|
77 |
Derived classes can implement a destructor to do any additional clean up tasks
|
|
78 |
that they require. */
|
|
79 |
{
|
|
80 |
DeleteEntry();
|
|
81 |
delete iAddresseeList;
|
|
82 |
delete iRichTextBody;
|
|
83 |
delete iCharFormatLayer;
|
|
84 |
delete iParaFormatLayer;
|
|
85 |
iRegisteredMtmDll.ReleaseLibrary();
|
|
86 |
delete iAttachmentWaiter;
|
|
87 |
delete iExtensionData;
|
|
88 |
}
|
|
89 |
|
|
90 |
|
|
91 |
EXPORT_C TUid CBaseMtm::Type() const
|
|
92 |
/** Gets the Type UID of the message type associated with the Client-side MTM.
|
|
93 |
|
|
94 |
@return UID of the message type associated with the MTM */
|
|
95 |
{
|
|
96 |
return iRegisteredMtmDll.MtmTypeUid();
|
|
97 |
}
|
|
98 |
|
|
99 |
|
|
100 |
EXPORT_C TInt CBaseMtm::QueryCapability(TUid /*aCapability*/, TInt& /*aResponse*/)
|
|
101 |
//
|
|
102 |
//
|
|
103 |
//
|
|
104 |
/** Queries if the MTM supports a particular capability, specified by a UID.
|
|
105 |
|
|
106 |
For MTM-specific UIDs, see the documentation for the relevant MTM.
|
|
107 |
|
|
108 |
Requirements:
|
|
109 |
|
|
110 |
Implementations should check aCapability for the standard capability values,
|
|
111 |
plus any MTM-specific capabilities, and if recognised, return a suitable response
|
|
112 |
in aResponse. If aCapability is unknown, return KErrNotSupported.
|
|
113 |
|
|
114 |
The default implementation returns KErrNotSupported.
|
|
115 |
|
|
116 |
@param aCapability UID of capability to be queried
|
|
117 |
@param aResponse Response value. The format of the response varies according
|
|
118 |
to the capability.
|
|
119 |
@return KErrNone: aCapability is a recognised value and a response is returned
|
|
120 |
KErrNotSupported: aCapability is not a recognised value */
|
|
121 |
{
|
|
122 |
return KErrNotSupported;
|
|
123 |
}
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
EXPORT_C void CBaseMtm::SwitchCurrentEntryL(TMsvId aId)
|
|
128 |
//
|
|
129 |
//
|
|
130 |
//
|
|
131 |
/** Changes the entry on which later actions are performed to the entry with the
|
|
132 |
specified TMsvId.
|
|
133 |
|
|
134 |
@param aId The ID of the entry upon which all following actions will be performed
|
|
135 |
|
|
136 |
@leave KErrNoMemory Insufficient memory
|
|
137 |
@leave KErrNotFound The requested entry does not exist */
|
|
138 |
{
|
|
139 |
// create the new CMsvEntry
|
|
140 |
CMsvEntry* newEntry = Session().GetEntryL(aId);
|
|
141 |
SetCurrentEntryL(newEntry);
|
|
142 |
}
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
EXPORT_C void CBaseMtm::SetCurrentEntryL(CMsvEntry* aEntry)
|
|
147 |
//
|
|
148 |
//
|
|
149 |
//
|
|
150 |
/** Sets the entry on which later actions are performed to the specified CMsvEntry.
|
|
151 |
|
|
152 |
|
|
153 |
@param aEntry The entry on which all following actions will be performed
|
|
154 |
@leave KErrNoMemory Insufficient memory */
|
|
155 |
{
|
|
156 |
CleanupStack::PushL(aEntry);
|
|
157 |
|
|
158 |
if (iAddresseeList==NULL)
|
|
159 |
iAddresseeList = CMsvRecipientList::NewL();
|
|
160 |
if (iParaFormatLayer==NULL)
|
|
161 |
iParaFormatLayer = CParaFormatLayer::NewL();
|
|
162 |
if (iCharFormatLayer==NULL)
|
|
163 |
iCharFormatLayer = CCharFormatLayer::NewL();
|
|
164 |
if (iRichTextBody==NULL)
|
|
165 |
iRichTextBody = CRichText::NewL(iParaFormatLayer, iCharFormatLayer);
|
|
166 |
else
|
|
167 |
iRichTextBody->Reset();
|
|
168 |
|
|
169 |
aEntry->AddObserverL(*this);
|
|
170 |
|
|
171 |
CleanupStack::Pop(); // aEntry
|
|
172 |
|
|
173 |
// swap the old and new context
|
|
174 |
DeleteEntry();
|
|
175 |
iMsvEntry = aEntry;
|
|
176 |
iEntryId = iMsvEntry->EntryId();
|
|
177 |
|
|
178 |
// If waiting for attachment additons to be commited, delete without commiting
|
|
179 |
// the changed
|
|
180 |
delete iAttachmentWaiter;
|
|
181 |
iAttachmentWaiter = NULL;
|
|
182 |
|
|
183 |
// inform concrete implementation that the context has switched (or set in the first case)
|
|
184 |
ContextEntrySwitched();
|
|
185 |
}
|
|
186 |
|
|
187 |
|
|
188 |
EXPORT_C CMsvEntry& CBaseMtm::Entry() const
|
|
189 |
/** Gets a CMsvEntry for the current context. The message client application can
|
|
190 |
then use this to manipulate the entry.
|
|
191 |
|
|
192 |
Implementers should note that this function returns the value of the protected
|
|
193 |
data member iMsvEntry.
|
|
194 |
|
|
195 |
@return CMsvEntry for the current context */
|
|
196 |
{
|
|
197 |
__ASSERT_DEBUG(iMsvEntry!=NULL, User::Panic(KMtclPanicString, 275));
|
|
198 |
return *iMsvEntry;
|
|
199 |
};
|
|
200 |
|
|
201 |
|
|
202 |
EXPORT_C TBool CBaseMtm::HasContext() const
|
|
203 |
/** Tests if an MTM context has been set.
|
|
204 |
|
|
205 |
A Client-side MTM has no context until one is set through SwitchCurrentEntryL()
|
|
206 |
or SetCurrentEntryL() .
|
|
207 |
|
|
208 |
@return ETrue: context has been set EFalse: context has not been set */
|
|
209 |
{
|
|
210 |
return (iMsvEntry!=NULL);
|
|
211 |
}
|
|
212 |
|
|
213 |
|
|
214 |
void CBaseMtm::DeleteEntry()
|
|
215 |
//
|
|
216 |
//
|
|
217 |
//
|
|
218 |
{
|
|
219 |
if (iMsvEntry!=NULL)
|
|
220 |
{
|
|
221 |
iMsvEntry->RemoveObserver(*this);
|
|
222 |
delete iMsvEntry;
|
|
223 |
iMsvEntry=NULL;
|
|
224 |
}
|
|
225 |
}
|
|
226 |
|
|
227 |
EXPORT_C void CBaseMtm::StoreBodyL(CMsvStore& aStore)
|
|
228 |
//
|
|
229 |
//
|
|
230 |
//
|
|
231 |
/** Stores and commits the current cached CRichText body text to the appropriate
|
|
232 |
stream in the specified message store. Client applications do not use this
|
|
233 |
function. It is relevant only to implementers of derived classes.
|
|
234 |
|
|
235 |
The function overwrites any existing data in that stream. The implementation
|
|
236 |
must have write access to aStore.
|
|
237 |
|
|
238 |
A typical use of this function is from SaveMessageL().
|
|
239 |
|
|
240 |
@param aStore Message store in which to store the body text
|
|
241 |
@leave KErrAccessDenied The store was opened for read only
|
|
242 |
@leave Other Standard stream-related leave codes */
|
|
243 |
{
|
|
244 |
__ASSERT_ALWAYS(iMsvEntry!=NULL, PanicServer(EMtclMsvEntryNotSet));
|
|
245 |
__ASSERT_ALWAYS(iMsvEntry->EntryId()==iEntryId, PanicServer(EMtclContextChangedByOwner));
|
|
246 |
|
|
247 |
aStore.StoreBodyTextL(*iRichTextBody);
|
|
248 |
}
|
|
249 |
|
|
250 |
EXPORT_C void CBaseMtm::RestoreBodyL(CMsvStore& aStore)
|
|
251 |
//
|
|
252 |
//
|
|
253 |
//
|
|
254 |
/** Gets the current cached CRichText from the appropriate stream in the specified
|
|
255 |
message store. Client applications do not use this function. It is relevant
|
|
256 |
only to implementers of derived classes.
|
|
257 |
|
|
258 |
A typical use of this function is from LoadMessageL().
|
|
259 |
|
|
260 |
@param aStore Message store from which to read the body text */
|
|
261 |
{
|
|
262 |
__ASSERT_ALWAYS(iMsvEntry!=NULL, PanicServer(EMtclMsvEntryNotSet));
|
|
263 |
__ASSERT_ALWAYS(iMsvEntry->EntryId()==iEntryId, PanicServer(EMtclContextChangedByOwner));
|
|
264 |
|
|
265 |
aStore.RestoreBodyTextL(*iRichTextBody);
|
|
266 |
}
|
|
267 |
|
|
268 |
|
|
269 |
EXPORT_C CRichText& CBaseMtm::Body()
|
|
270 |
/** Gets the body text of the context, that must be a message. For non-message
|
|
271 |
contexts, an empty CRichText is returned.
|
|
272 |
|
|
273 |
@return Body text of the context
|
|
274 |
@see StoreBodyL()
|
|
275 |
@see RestoreBodyL() */
|
|
276 |
{
|
|
277 |
__ASSERT_DEBUG(iMsvEntry!=NULL, User::Panic(KMtclPanicString, 275));
|
|
278 |
return *iRichTextBody;
|
|
279 |
}
|
|
280 |
|
|
281 |
|
|
282 |
EXPORT_C const CRichText& CBaseMtm::Body() const
|
|
283 |
/** Gets the read-only body text of the context, that must be a message. For non-message
|
|
284 |
contexts, an empty CRichText is returned.
|
|
285 |
|
|
286 |
@return Read-only body text of the context
|
|
287 |
@see StoreBodyL()
|
|
288 |
@see RestoreBodyL() */
|
|
289 |
{
|
|
290 |
__ASSERT_DEBUG(iMsvEntry!=NULL, User::Panic(KMtclPanicString, 275));
|
|
291 |
return *iRichTextBody;
|
|
292 |
}
|
|
293 |
|
|
294 |
|
|
295 |
EXPORT_C void CBaseMtm::SetSubjectL(const TDesC& /*aSubject*/)
|
|
296 |
//
|
|
297 |
//
|
|
298 |
//
|
|
299 |
/** Sets the subject text of the context, which must be a message.
|
|
300 |
|
|
301 |
Some Client-side MTMs may not support subject text, in which case the function
|
|
302 |
leaves with KErrNotSupported.
|
|
303 |
|
|
304 |
Requirements:
|
|
305 |
|
|
306 |
If the message protocol supports subject text, implementations should maintain
|
|
307 |
a private buffer to store this information, settable through this function.
|
|
308 |
|
|
309 |
Implementations should save the subject text to the appropriate place in the
|
|
310 |
message store when the message is stored.
|
|
311 |
|
|
312 |
The default implementation leaves with KErrNotSupported.
|
|
313 |
|
|
314 |
@param aSubject Message subject text
|
|
315 |
@leave KErrNotSupported The Client-side MTMs does not support subject text
|
|
316 |
@see StoreBodyL()
|
|
317 |
@see RestoreBodyL() */
|
|
318 |
{
|
|
319 |
User::Leave(KErrNotSupported);
|
|
320 |
}
|
|
321 |
|
|
322 |
|
|
323 |
/** Gets the list of intended recipients for the current context, which must be
|
|
324 |
a message.
|
|
325 |
|
|
326 |
In the case of protocols that allow different classes of recipient (such as
|
|
327 |
To, Cc and Bcc), the list returned is whatever the protocol defines as the
|
|
328 |
default recipient list.
|
|
329 |
|
|
330 |
Requirements:
|
|
331 |
|
|
332 |
The default implementation simply returns the value of the protected data
|
|
333 |
member iAddresseeList. As a consequence, Client-side MTM implementations should
|
|
334 |
update this member whenever the address list is modified.
|
|
335 |
|
|
336 |
@return Array of recipients
|
|
337 |
*/
|
|
338 |
EXPORT_C const CMsvRecipientList& CBaseMtm::AddresseeList() const
|
|
339 |
{
|
|
340 |
__ASSERT_DEBUG(iMsvEntry!=NULL, User::Panic(KMtclPanicString, 275));
|
|
341 |
return *iAddresseeList;
|
|
342 |
}
|
|
343 |
|
|
344 |
|
|
345 |
/** Adds addressee to list.
|
|
346 |
|
|
347 |
The default implementation treats To: and Cc: type addressees as if the addressee
|
|
348 |
had no type.
|
|
349 |
|
|
350 |
The default implementation does not support Bcc type addressees.
|
|
351 |
|
|
352 |
@param aType
|
|
353 |
The addressee type.
|
|
354 |
|
|
355 |
@param aRealAddress
|
|
356 |
The addressee address.
|
|
357 |
|
|
358 |
@leave KErrNotSupprted
|
|
359 |
The addressee type was Bcc which is not supported in the default implementation.
|
|
360 |
*/
|
|
361 |
EXPORT_C void CBaseMtm::AddAddresseeL(TMsvRecipientType aType, const TDesC& aRealAddress)
|
|
362 |
{
|
|
363 |
if (aType == EMsvRecipientBcc)
|
|
364 |
{
|
|
365 |
User::Leave(KErrNotSupported);
|
|
366 |
}
|
|
367 |
AddAddresseeL(aRealAddress);
|
|
368 |
}
|
|
369 |
|
|
370 |
|
|
371 |
/** Adds addressee to list.
|
|
372 |
|
|
373 |
The default implementation treats To: and Cc: type addressees as if the addressee
|
|
374 |
had no type.
|
|
375 |
|
|
376 |
The default implementation does not support Bcc type addressees.
|
|
377 |
|
|
378 |
@param aType
|
|
379 |
The addressee type.
|
|
380 |
|
|
381 |
@param aRealAddress
|
|
382 |
The addressee address.
|
|
383 |
|
|
384 |
@param aAlias
|
|
385 |
The alias for the addressee.
|
|
386 |
|
|
387 |
@leave KErrNotSupprted
|
|
388 |
The addressee type was Bcc which is not supported in the default implementation.
|
|
389 |
*/
|
|
390 |
EXPORT_C void CBaseMtm::AddAddresseeL(TMsvRecipientType aType, const TDesC& aRealAddress, const TDesC& aAlias)
|
|
391 |
{
|
|
392 |
if (aType == EMsvRecipientBcc)
|
|
393 |
{
|
|
394 |
User::Leave(KErrNotSupported);
|
|
395 |
}
|
|
396 |
AddAddresseeL(aRealAddress, aAlias);
|
|
397 |
}
|
|
398 |
|
|
399 |
|
|
400 |
EXPORT_C const TPtrC CBaseMtm::SubjectL() const
|
|
401 |
//
|
|
402 |
//
|
|
403 |
//
|
|
404 |
/** Gets the subject text of the context, which must be a message.
|
|
405 |
|
|
406 |
Some Client-side MTMs may not support subject text, in which case the function
|
|
407 |
leaves with KErrNotSupported.
|
|
408 |
|
|
409 |
Requirements:
|
|
410 |
|
|
411 |
If the message protocol supports subject text, implementations should maintain
|
|
412 |
a private buffer to store this information, gettable through this function.
|
|
413 |
|
|
414 |
The default implementation leaves with KErrNotSupported.
|
|
415 |
|
|
416 |
@leave KErrNotSupported The Client-side MTMs does not support subject text
|
|
417 |
@return Message subject text */
|
|
418 |
{
|
|
419 |
User::Leave(KErrNotSupported);
|
|
420 |
return TPtrC();
|
|
421 |
}
|
|
422 |
|
|
423 |
|
|
424 |
EXPORT_C void CBaseMtm::HandleEntryEventL(TMsvEntryEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/)
|
|
425 |
/** Indicates that an event has occurred.
|
|
426 |
|
|
427 |
Client applications do not use this function. It is relevant only to implementers of derived classes.
|
|
428 |
|
|
429 |
The Client-side MTM object is automatically set as an observer, through CMsvEntry::AddObserverL(),
|
|
430 |
for the context whenever the context changes (by SetCurrentEntryL() or SwitchCurrentEntryL()).
|
|
431 |
|
|
432 |
The default implementation is defined to do nothing.
|
|
433 |
|
|
434 |
Requirements:
|
|
435 |
|
|
436 |
Implementations can override this function to handle events concerning the current context.
|
|
437 |
|
|
438 |
@param aEvent Indicates the event type
|
|
439 |
@param aArg1 Event specific argument value
|
|
440 |
@param aArg2 Event specific argument value
|
|
441 |
@param aArg3 Event specific argument value
|
|
442 |
*/
|
|
443 |
{
|
|
444 |
}
|
|
445 |
|
|
446 |
|
|
447 |
EXPORT_C CMsvSession& CBaseMtm::Session()
|
|
448 |
/** Gets a reference to the session object passed by the creator of the Client-side
|
|
449 |
MTM.
|
|
450 |
|
|
451 |
@return Session object used by the Client-side MTM */
|
|
452 |
{
|
|
453 |
return iSession;
|
|
454 |
}
|
|
455 |
|
|
456 |
|
|
457 |
/**
|
|
458 |
Adds a file attachment to the current message entry.
|
|
459 |
|
|
460 |
The attachment is referenced by its file path and is copied into the message store.
|
|
461 |
Only one asynchronous operation can be run at any one time.
|
|
462 |
|
|
463 |
@param aFilePath The full path specification of the attachment file.
|
|
464 |
@param aMimeType The mime type of the attachment file.
|
|
465 |
@param aCharset The mime charset. The value is a standard IANA value. The value 0 indicates
|
|
466 |
that no charset is provided.
|
|
467 |
@param aStatus The request status to complete when request has completed.
|
|
468 |
@leave System-wide error codes.
|
|
469 |
*/
|
|
470 |
EXPORT_C void CBaseMtm::AddAttachmentL(const TDesC& aFilePath, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus)
|
|
471 |
{
|
|
472 |
AddFilePathAttachmentL(aFilePath, aMimeType, aCharset, CMsvAttachment::EMsvFile, aStatus);
|
|
473 |
}
|
|
474 |
|
|
475 |
/**
|
|
476 |
Adds a file attachment to the current message entry.
|
|
477 |
|
|
478 |
The attachment is referenced by an open file handle and is copied into the message store.
|
|
479 |
Only one asynchronous operation can be run at any one time.
|
|
480 |
|
|
481 |
@param aFile An open file handle for the file attachment.
|
|
482 |
@param aMimeType The mime type of the attachment file.
|
|
483 |
@param aCharset The mime charset. The value is a standard IANA value. The value 0 indicates
|
|
484 |
that no charset is provided.
|
|
485 |
@param aStatus The request status to complete when request has completed.
|
|
486 |
@leave System-wide error codes.
|
|
487 |
*/
|
|
488 |
EXPORT_C void CBaseMtm::AddAttachmentL(RFile& aFile, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus)
|
|
489 |
{
|
|
490 |
if( iAttachmentWaiter == NULL )
|
|
491 |
iAttachmentWaiter = CMsvAttachmentWaiter::NewL();
|
|
492 |
|
|
493 |
CMsvStore* store = iMsvEntry->EditStoreL();
|
|
494 |
CleanupStack::PushL(store);
|
|
495 |
|
|
496 |
CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
|
|
497 |
CleanupStack::PushL(attachment);
|
|
498 |
|
|
499 |
// set the size
|
|
500 |
TInt size = 0;
|
|
501 |
User::LeaveIfError(aFile.Size(size));
|
|
502 |
attachment->SetSize(size);
|
|
503 |
|
|
504 |
// set the mime-type if provided
|
|
505 |
if( aMimeType.Length() > 0 )
|
|
506 |
{
|
|
507 |
attachment->SetMimeTypeL(aMimeType);
|
|
508 |
}
|
|
509 |
|
|
510 |
TFileName fileName;
|
|
511 |
User::LeaveIfError(aFile.Name(fileName));
|
|
512 |
attachment->SetAttachmentNameL(fileName);
|
|
513 |
|
|
514 |
if( aCharset!=0 )
|
|
515 |
{
|
|
516 |
CMsvMimeHeaders* headers = CMsvMimeHeaders::NewLC();
|
|
517 |
headers->SetMimeCharset(aCharset);
|
|
518 |
headers->StoreL(*attachment);
|
|
519 |
CleanupStack::PopAndDestroy(headers);
|
|
520 |
}
|
|
521 |
|
|
522 |
// attachment is initialised, pass to the attachment manager
|
|
523 |
MMsvAttachmentManager& manager = store->AttachmentManagerL();
|
|
524 |
manager.AddAttachmentL(aFile, attachment, iAttachmentWaiter->iStatus);
|
|
525 |
CleanupStack::Pop(attachment); // ownership passed to manager
|
|
526 |
iAttachmentWaiter->StartWaitingL(aStatus, store, &manager);
|
|
527 |
CleanupStack::Pop(store); // ownership passed
|
|
528 |
}
|
|
529 |
|
|
530 |
/**
|
|
531 |
Adds a file attachment to the current message entry as a linked file.
|
|
532 |
|
|
533 |
The attachment is referenced by its file path and is not copied into the message store. The attachment file is always used from
|
|
534 |
its original location on disk indicated by the aFilePath parameter. Only one asynchronous operation can be run at any one time.
|
|
535 |
|
|
536 |
@param aFilePath The full path specification of the attachment file.
|
|
537 |
@param aMimeType The mime type of the attachment file.
|
|
538 |
@param aCharset The mime charset. The value is a standard IANA value. The value 0 indicates
|
|
539 |
that no charset is provided.
|
|
540 |
@param aStatus The request status to complete when request has completed.
|
|
541 |
@leave System-wide error codes.
|
|
542 |
*/
|
|
543 |
EXPORT_C void CBaseMtm::AddLinkedAttachmentL(const TDesC& aFilePath, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus)
|
|
544 |
{
|
|
545 |
AddFilePathAttachmentL(aFilePath, aMimeType, aCharset, CMsvAttachment::EMsvLinkedFile, aStatus);
|
|
546 |
}
|
|
547 |
|
|
548 |
/**
|
|
549 |
Creates a new empty file attachment to the current message entry.
|
|
550 |
|
|
551 |
An empty file attachment is created with the suggested given name and if
|
|
552 |
completed successfully, the aAttachmentFile will be open on the new file.
|
|
553 |
Only one asynchronous operation can be run at any one time.
|
|
554 |
|
|
555 |
@param aFileName The suggested file name for the new attachment file.
|
|
556 |
@param aAttachmentFile If successful, this will be set to the open new file.
|
|
557 |
@param aMimeType The mime type of the attachment file.
|
|
558 |
@param aCharset The mime charset. The value is a standard IANA value. The value 0 indicates
|
|
559 |
that no charset is provided.
|
|
560 |
@param aStatus The request status to complete when request has completed.
|
|
561 |
@leave System-wide error codes.
|
|
562 |
*/
|
|
563 |
EXPORT_C void CBaseMtm::CreateAttachmentL(const TDesC& aFileName, RFile& aAttachmentFile, const TDesC8& aMimeType, TUint aCharset, TRequestStatus& aStatus)
|
|
564 |
{
|
|
565 |
if( iAttachmentWaiter == NULL )
|
|
566 |
iAttachmentWaiter = CMsvAttachmentWaiter::NewL();
|
|
567 |
|
|
568 |
CMsvStore* store = iMsvEntry->EditStoreL();
|
|
569 |
CleanupStack::PushL(store);
|
|
570 |
|
|
571 |
CMsvAttachment* attachmentInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
|
|
572 |
CleanupStack::PushL(attachmentInfo);
|
|
573 |
attachmentInfo->SetAttachmentNameL(aFileName);
|
|
574 |
attachmentInfo->SetMimeTypeL(aMimeType);
|
|
575 |
|
|
576 |
if( aCharset!=0 )
|
|
577 |
{
|
|
578 |
CMsvMimeHeaders* headers = CMsvMimeHeaders::NewLC();
|
|
579 |
headers->SetMimeCharset(aCharset);
|
|
580 |
headers->StoreL(*attachmentInfo);
|
|
581 |
CleanupStack::PopAndDestroy(headers);
|
|
582 |
}
|
|
583 |
|
|
584 |
MMsvAttachmentManager& manager = store->AttachmentManagerL();
|
|
585 |
manager.CreateAttachmentL(aFileName, aAttachmentFile, attachmentInfo, iAttachmentWaiter->iStatus);
|
|
586 |
CleanupStack::Pop(attachmentInfo); // ownership passed to manager
|
|
587 |
iAttachmentWaiter->StartWaitingL(aStatus, store, &manager);
|
|
588 |
CleanupStack::Pop(store); // ownership passed
|
|
589 |
}
|
|
590 |
|
|
591 |
/**
|
|
592 |
Adds a message entry as an attachment to the current message entry.
|
|
593 |
|
|
594 |
This method simply registers an existing message entry as an attachment to the current entry. Only one asynchronous
|
|
595 |
operation can be run at any one time.
|
|
596 |
|
|
597 |
@param aAttachmentId The message Id of the message entry to add as an attachment.
|
|
598 |
@param aStatus The request status to complete when request has completed.
|
|
599 |
@leave System-wide error codes.
|
|
600 |
*/
|
|
601 |
EXPORT_C void CBaseMtm::AddEntryAsAttachmentL(TMsvId aAttachmentId, TRequestStatus& aStatus)
|
|
602 |
{
|
|
603 |
// Get the size of the message entry
|
|
604 |
CMsvEntry* attachEntry = iSession.GetEntryL(aAttachmentId);
|
|
605 |
TInt attachSize = attachEntry->Entry().iSize;
|
|
606 |
delete attachEntry;
|
|
607 |
attachEntry = NULL;
|
|
608 |
|
|
609 |
if( iAttachmentWaiter == NULL )
|
|
610 |
iAttachmentWaiter = CMsvAttachmentWaiter::NewL();
|
|
611 |
|
|
612 |
CMsvStore* store = iMsvEntry->EditStoreL();
|
|
613 |
CleanupStack::PushL(store);
|
|
614 |
|
|
615 |
CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvMessageEntry);
|
|
616 |
CleanupStack::PushL(attachment);
|
|
617 |
attachment->SetSize(attachSize);
|
|
618 |
|
|
619 |
// Register entry as attachment
|
|
620 |
MMsvAttachmentManager& manager = store->AttachmentManagerL();
|
|
621 |
manager.AddEntryAsAttachmentL(aAttachmentId, attachment, iAttachmentWaiter->iStatus);
|
|
622 |
CleanupStack::Pop(attachment); // ownership passed to manager
|
|
623 |
iAttachmentWaiter->StartWaitingL(aStatus, store, &manager);
|
|
624 |
CleanupStack::Pop(store); // ownership passed
|
|
625 |
}
|
|
626 |
|
|
627 |
void CBaseMtm::AddFilePathAttachmentL(const TDesC& aFilePath, const TDesC8& aMimeType, TUint aCharset, CMsvAttachment::TMsvAttachmentType aType, TRequestStatus& aStatus)
|
|
628 |
{
|
|
629 |
__ASSERT_DEBUG(aType != CMsvAttachment::EMsvMessageEntry, User::Invariant());
|
|
630 |
|
|
631 |
if( iAttachmentWaiter == NULL )
|
|
632 |
iAttachmentWaiter = CMsvAttachmentWaiter::NewL();
|
|
633 |
|
|
634 |
CMsvStore* store = iMsvEntry->EditStoreL();
|
|
635 |
CleanupStack::PushL(store);
|
|
636 |
|
|
637 |
CMsvAttachment* attachment = CMsvAttachment::NewL(aType);
|
|
638 |
CleanupStack::PushL(attachment);
|
|
639 |
|
|
640 |
// set the size
|
|
641 |
TEntry fileEntry;
|
|
642 |
RFs& fs = iSession.FileSession();
|
|
643 |
User::LeaveIfError(fs.Entry(aFilePath, fileEntry));
|
|
644 |
attachment->SetSize(fileEntry.iSize);
|
|
645 |
|
|
646 |
// set the mime-type, if provided
|
|
647 |
if( aMimeType.Length() > 0 )
|
|
648 |
{
|
|
649 |
attachment->SetMimeTypeL(aMimeType);
|
|
650 |
}
|
|
651 |
|
|
652 |
// set attachment name
|
|
653 |
TParse fileNameParser;
|
|
654 |
User::LeaveIfError(fileNameParser.Set(aFilePath, NULL, NULL));
|
|
655 |
attachment->SetAttachmentNameL(fileNameParser.NameAndExt());
|
|
656 |
|
|
657 |
if( aCharset!=0 )
|
|
658 |
{
|
|
659 |
CMsvMimeHeaders* headers = CMsvMimeHeaders::NewLC();
|
|
660 |
headers->SetMimeCharset(aCharset);
|
|
661 |
headers->StoreL(*attachment);
|
|
662 |
CleanupStack::PopAndDestroy(headers);
|
|
663 |
}
|
|
664 |
|
|
665 |
// attachment is initialised, pass to the attachment manager
|
|
666 |
MMsvAttachmentManager& manager = store->AttachmentManagerL();
|
|
667 |
switch(aType)
|
|
668 |
{
|
|
669 |
case CMsvAttachment::EMsvFile:
|
|
670 |
manager.AddAttachmentL(aFilePath, attachment, iAttachmentWaiter->iStatus);
|
|
671 |
break;
|
|
672 |
case CMsvAttachment::EMsvLinkedFile:
|
|
673 |
manager.AddLinkedAttachmentL(aFilePath, attachment, iAttachmentWaiter->iStatus);
|
|
674 |
break;
|
|
675 |
default:
|
|
676 |
break;
|
|
677 |
}
|
|
678 |
|
|
679 |
CleanupStack::Pop(attachment); // ownership passed to manager
|
|
680 |
|
|
681 |
iAttachmentWaiter->StartWaitingL(aStatus, store, &manager);
|
|
682 |
CleanupStack::Pop(store); // ownership passed
|
|
683 |
}
|
|
684 |
|
|
685 |
/**
|
|
686 |
Cancels the current attachment operation.
|
|
687 |
*/
|
|
688 |
EXPORT_C void CBaseMtm::CancelAttachmentOperation()
|
|
689 |
{
|
|
690 |
if(iAttachmentWaiter)
|
|
691 |
{
|
|
692 |
iAttachmentWaiter->Cancel();
|
|
693 |
delete iAttachmentWaiter;
|
|
694 |
iAttachmentWaiter = NULL;
|
|
695 |
}
|
|
696 |
}
|
|
697 |
|
|
698 |
|
|
699 |
// virtual
|
|
700 |
EXPORT_C void CBaseMtm::CreateMessageL(TMsvId aServiceId)
|
|
701 |
/** Creates a new message entry as a child of the current context.
|
|
702 |
|
|
703 |
The default implementation creates an empty entry with its visible flag set
|
|
704 |
to false and its in-preparation flag set to true.
|
|
705 |
|
|
706 |
@param aServiceId ID of the service to own the entry. */
|
|
707 |
{
|
|
708 |
// create an invisible blank entry
|
|
709 |
TMsvEntry entry;
|
|
710 |
entry.iType = KUidMsvMessageEntry;
|
|
711 |
entry.iServiceId = aServiceId;
|
|
712 |
entry.iMtm = Type();
|
|
713 |
entry.SetVisible(EFalse);
|
|
714 |
entry.SetInPreparation(ETrue);
|
|
715 |
|
|
716 |
// store entry in folder
|
|
717 |
iMsvEntry->CreateL(entry);
|
|
718 |
iMsvEntry->SetEntryL(entry.Id());
|
|
719 |
iEntryId = entry.Id();
|
|
720 |
}
|
|
721 |
|
|
722 |
EXPORT_C void CBaseMtm::BioTypeChangedL(TUid /*aBioTypeUid*/)
|
|
723 |
/** Informs client-side MTM that the context's BIO field is being changed as a
|
|
724 |
result of a call to CSendAs::SetBioTypeL().
|
|
725 |
|
|
726 |
CSendAs::SetBioTypeL() calls this function before setting the BIO field in
|
|
727 |
the context's index entry. This allows a client-side MTM to perform MTM specific
|
|
728 |
actions when the BIO type changes.
|
|
729 |
|
|
730 |
CSendAs will not change the BIO type if this function leaves.
|
|
731 |
|
|
732 |
The default implementation is to do nothing.
|
|
733 |
|
|
734 |
@param aBioTypeUid New value for the BIO field
|
|
735 |
@see CSendAs::SetBioTypeL() */
|
|
736 |
{
|
|
737 |
//The default implementation is to do nothing.
|
|
738 |
}
|
|
739 |
|
|
740 |
/**
|
|
741 |
Gets the default MTM service.
|
|
742 |
|
|
743 |
The default implementation is to assume the MTM only supports one service so finds the
|
|
744 |
first service associated with this MTM and returns that.
|
|
745 |
|
|
746 |
@return
|
|
747 |
The default service
|
|
748 |
|
|
749 |
@leave
|
|
750 |
KErrNotFound If no service has been created.
|
|
751 |
*/
|
|
752 |
EXPORT_C TMsvId CBaseMtm::DefaultServiceL() const
|
|
753 |
{
|
|
754 |
// Create a new entry, showing invisible entries (because the service entry may be invisible)
|
|
755 |
TMsvSelectionOrdering ordering(KMsvNoGrouping, EMsvSortByNone, ETrue);
|
|
756 |
CMsvEntry* entry = CMsvEntry::NewL(iSession, KMsvRootIndexEntryId, ordering);
|
|
757 |
CleanupStack::PushL(entry);
|
|
758 |
|
|
759 |
CMsvEntrySelection *sel=entry->ChildrenWithMtmL(iRegisteredMtmDll.MtmTypeUid());
|
|
760 |
CleanupStack::PushL(sel);
|
|
761 |
if(sel->Count() == 0)
|
|
762 |
{
|
|
763 |
User::Leave(KErrNotFound);
|
|
764 |
}
|
|
765 |
TMsvId service=sel->At(0);
|
|
766 |
CleanupStack::PopAndDestroy(2,entry);
|
|
767 |
return service;
|
|
768 |
}
|
|
769 |
|
|
770 |
/**
|
|
771 |
Removes the default service setting. The default implementation of this function assumes
|
|
772 |
that the MTM only supports one service and therefore this does nothing.
|
|
773 |
*/
|
|
774 |
EXPORT_C void CBaseMtm::RemoveDefaultServiceL()
|
|
775 |
{
|
|
776 |
}
|
|
777 |
|
|
778 |
/**
|
|
779 |
Sets the default MTM service. The default implementation of this function assumes that
|
|
780 |
the MTM only supports one service and therefore this does nothing.
|
|
781 |
|
|
782 |
@param aService
|
|
783 |
The default service
|
|
784 |
*/
|
|
785 |
EXPORT_C void CBaseMtm::ChangeDefaultServiceL(const TMsvId& /*aService*/)
|
|
786 |
{
|
|
787 |
}
|
|
788 |
|
|
789 |
|
|
790 |
/**
|
|
791 |
Returns a pointer to the interface with the specified Uid.
|
|
792 |
|
|
793 |
This method is the first part of an extension pattern to allow for
|
|
794 |
more functionality to be supported without adding virtual methods
|
|
795 |
to this base class.
|
|
796 |
|
|
797 |
The default implementation returns a NULL pointer.
|
|
798 |
|
|
799 |
@param aUid
|
|
800 |
Uid of the extension interface
|
|
801 |
@return
|
|
802 |
Pointer to the extension interface
|
|
803 |
*/
|
|
804 |
EXPORT_C TAny* CBaseMtm::GetInterface(TUid /*aUid*/)
|
|
805 |
{
|
|
806 |
return NULL;
|
|
807 |
}
|
|
808 |
|
|
809 |
/**
|
|
810 |
Sets the character encoding value. The character encoding value options are 7-bit,
|
|
811 |
8-bit and 16-Bit Unicode. By default the character set encoding is 7 bit encoding.
|
|
812 |
@param aCharSet Character encoding value may be 7-bit/8-bit/16-bit Unicode.
|
|
813 |
@return KErrNone If charset is changed successfully in SMS settings.
|
|
814 |
*/
|
|
815 |
|
|
816 |
EXPORT_C TInt CBaseMtm::SetMessageCharacterSet(TUint aCharSet)
|
|
817 |
{
|
|
818 |
TAny* ptrNull=NULL;
|
|
819 |
return Extension_(KUIDCharacterSet,ptrNull,&aCharSet);
|
|
820 |
}
|
|
821 |
|
|
822 |
/**
|
|
823 |
The default Extension service. The default implementation of this function assumes that
|
|
824 |
the new service for setting the charset encoding value for a SMS message is not
|
|
825 |
supported. TAny* is equivalent to void*.
|
|
826 |
@param a0 The collective parameters of TAny*
|
|
827 |
@param a1 The collective parameters of TAny*,Charset encoding value is actually extracted from a1.
|
|
828 |
@param aExtensionId Uid of the extension interface
|
|
829 |
@return KErrExtensionNotSupported If the message is other than SMS.
|
|
830 |
@return Other Standard system-wide error codes.
|
|
831 |
*/
|
|
832 |
|
|
833 |
EXPORT_C TInt CBaseMtm::Extension_(TUint aExtensionId, TAny *&a0, TAny *a1)
|
|
834 |
{
|
|
835 |
TInt ret = KErrNone;
|
|
836 |
switch(aExtensionId)
|
|
837 |
{
|
|
838 |
case KUIDCharacterSet:
|
|
839 |
{
|
|
840 |
ret = KErrExtensionNotSupported;
|
|
841 |
}
|
|
842 |
break;
|
|
843 |
default:
|
|
844 |
{
|
|
845 |
// Chain to base class
|
|
846 |
ret = CBase::Extension_(aExtensionId,a0,a1);
|
|
847 |
}
|
|
848 |
break;
|
|
849 |
}
|
|
850 |
return ret;
|
|
851 |
}
|
|
852 |
|
|
853 |
//if passed value is NULL, its as good as reset extention data
|
|
854 |
EXPORT_C void CBaseMtm::SetExtensionData(TAny* aSortData)
|
|
855 |
{
|
|
856 |
iExtensionData=aSortData;
|
|
857 |
}
|
|
858 |
|
|
859 |
EXPORT_C TAny* CBaseMtm::GetExtensionData()
|
|
860 |
{
|
|
861 |
return iExtensionData;
|
|
862 |
}
|
|
863 |
|