2 * Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Client Mtm for multimedia messaging.
16 * This is the API for accessing multimedia messaging engine.
26 #include <mtclbase.h> // base client mtm
27 #include <e32std.h> // TTimeInterval & TTime
28 #include "mmsconst.h" // common constants
37 const TUint SymbianCharsetUID;
38 const TUint IANAMIBEnum;
39 }TMmsCharacterSetLookup;
41 // FUNCTION PROTOTYPES
43 // FORWARD DECLARATIONS
46 class CMsvMimeHeaders;
48 class CMmsAttachmentWaiter;
53 * Client Mtm for multimedia messaging subsystem.
55 * This class will be the interface to the UI component and other
56 * messaging component that might want to handle multimedia messages
57 * (For example SendAs interface).
59 * This class provides access to MMS specific headers in the message.
61 * Note: new functions are added as the last virtual functions in order
62 * not to to break the vtable
65 * // Example of getting access to this class:
67 * // Called by an application that implements
68 * // MMsvSessionObserver interface
70 * iSession = CMsvSession::OpenSyncL(*this);
71 * CleanupStack::PushL(iSession);
72 * iClientMtmRegistry = CClientMtmRegistry::NewL(*iSession);
73 * CleanupStack::PushL(iClientMtmRegistry);
74 * iMmsClient = (CMmsClientMtm *) iClientMtmRegistry->
75 * NewMtmL(KUidMsgTypeMultimedia);
76 * CleanupStack::PushL(iMmsClient);
78 * // - do other initialization
80 * CleanupStack::Pop(3); //iSession, iClientMtmRegistry, iMmsClient
82 * // - call any public functions in CMmsClientMtm
84 * // When the application finishes,
85 * // it must delete the objects in reverse order:
87 * delete iClientMtmRegistry;
92 class CMmsClientMtm :public CBaseMtm
94 public: // Constructors and destructor
99 * The only function exported by this polymorphic interface dll.
100 * This function is not directly called by the application that needs
101 * access, it is called by an instance of CClientMtmRegistry class.
103 * @param[in] aRegisteredMtmDll Mtm Dll registry class
104 * @param[in] aSession Message Server session.
105 * @return Pointer to CMmsClientMtm class.
107 IMPORT_C static CMmsClientMtm* NewL(
108 CRegisteredMtmDll& aRegisteredMtmDll,
109 CMsvSession& aSession );
114 virtual ~CMmsClientMtm();
116 public: // New functions
118 // ----------------------------------------------------------
119 // Functions to create and modify message entries
122 * Create a new message entry.
124 * @param[in] aDestination Target folder.
125 * @param[in] aCompletionStatus Reference to the status of an active object.
126 * This status will contain the relevant error code when the operation
128 * @return Pointer to a message server operation (active object).
129 * When the message has been created the progress information of the
130 * operation provides the id of the created message in an 8-bit package
131 * buffer. While the operation is in progress the package will contain a
132 * null id (KMsvNullIndexEntryId). If there is an error while
133 * creating the message the message will be deleted and the
134 * package will contain a null id.
136 * This function is suitable when the caller is an active object or the
137 * caller does not want to immediately change current context to the
140 * If the caller is not an active object and the caller wants the context
141 * of CMmsClientMtm to be immediately set to the new entry, it is simpler
142 * to call CreateMessageL.
143 * @see CMmsClientMtm::CreateMessageL
146 * // This example shows usage with a caller that is not an active object,
147 * // so a separate waiter is needed. If the caller is an active object,
148 * // the caller gives its own status to the function and continues
149 * // execution in RunL function.
151 * CMsvOperation* myOperation = NULL;
152 * CMsvOperationActiveSchedulerWait* wait =
153 * CMsvOperationActiveSchedulerWait::NewLC();
155 * // destinationId specifies the destination folder.
156 * myOperation = iMmsClient->CreateNewEntryL( destinationId, wait->iStatus );
158 * CleanupStack::PushL( myOperation );
162 * if ( wait->iStatus.Int() != KErrNone )
164 * // error handling, e.g. leave
167 * // Get the message id
168 * TPckgBuf<TMsvId> pkg;
169 * pkg.Copy( myOperation->ProgressL() );
170 * TMsvId progress = pkg();
171 * CleanupStack::PopAndDestroy(2); // myOperation, wait;
173 * // Load the new message
174 * iMmsClient->SwitchCurrentEntryL( progress );
176 * // load the default values that were already intialized
177 * // when the message was created
178 * iMmsClient->LoadMessageL();
180 * // continue adding data to the message
184 virtual CMsvOperation* CreateNewEntryL(
186 TRequestStatus& aCompletionStatus);
189 // -------------------------------------------------------------------
190 // FUNCTIONS TO HANDLE MMSC SETTINGS
192 // Only one MMS service entry may be created!
194 // The Client MTM maintains cached MMS service settings, referred to
195 // as current service below. Some of those cached settings are used
196 // as template values when a new multimedia message is created.
198 // Use Base MTM functions to get default service id.
202 * Create new service entry.
204 * Context is set to the new service entry.
205 * Currently a maximum of one service is created, and further requests
206 * do not create a new service entry.
207 * @deprecated Only one MMS service is supported and it is automatically created.
208 * Use DefaultServiceL() to get the id for the default service.
210 virtual void CreateServiceL();
213 // Functions to load, save, and access MMS Settings.
214 // There is no need to change the context when these functions are used.
218 * Get a reference to CMmsSettings class.
220 * This method should be used by MMS UI only. Other applications should
221 * not touch the MMS settings. The methods are needed in MMS Client API
222 * to allow MMS UI to inform MMS Client MTM about changed settings.
224 * The contents of the class are those used by MMS Client MTM
225 * when constructing a message. If the settings must be changed,
226 * a copy must be made, and SetSettingsL function used to deliver
227 * the settings to MMS Client MTM.
229 * @return constant reference to iMmsSettings member of CMmsClientMtm.
234 * CMmsSettings* settings = CMmsSettings::NewL();
235 * CleanupStack::PushL( settings );
236 * iMmsClient->RestoreSettingsL();
237 * settings->CopyL( iMmsClient->MmsSettings() );
239 * // change settings here...
240 * // The settings are changed using CMmsSettings API
242 * iMmsClient->SetSettingsL( *settings );
243 * iMmsClient->StoreSettingsL();
244 * CleanupStack::PopAndDestroy(); // settings
248 virtual const CMmsSettings& MmsSettings();
251 * Copy the values from aSettings to CMmsClientMtm.
253 * This method should be used by MMS UI only. Other applications should
254 * not touch the MMS settings.
256 * Used to provide new settings to MMS Client MTM when settings have
257 * been changed. Will affect only messages created after the settings
260 * Use function StoreSettingsL to save the settings on disk.
262 * @param[in] aSettings New values for CMmsSettings
264 virtual void SetSettingsL( const CMmsSettings& aSettings );
267 * Save settings to disk.
269 * This method should be used by MMS UI only. Other applications should
270 * not touch the MMS settings.
272 virtual void StoreSettingsL();
275 * Load settings from disk.
277 * This method should be used by MMS UI only. Other applications should
278 * not touch the MMS settings.
280 virtual void RestoreSettingsL();
284 * Restore factory settings.
286 * Restore settings from ROM to the default service entry and select it
287 * as the current service entry.
288 * @param aLevel Defines the operations to be done.
289 * @deprecated MMS UI should restore the factory settings directly.
291 virtual void RestoreFactorySettingsL(
292 TMmsFactorySettingsLevel aLevel = EMmsFactorySettingsLevelNormal );
298 * Checks that access point refers to a valid entry in comms database.
300 * @param[in] aServiceId Id of the MMS service
301 * @return Error code.
302 * - KErrNone: The service is OK.
303 * - KErrNotFound: The service id is incorrect.
304 * - KMmsErrorInvalidSettings: The settings contain invalid values.
305 * This error is possible only if the settings file has been corrupted.
306 * - KMmsErrorNoWAPAccessPoint: No access point has been defined.
307 * - KMmsErrorAP1Invalid: MMS access point refers to an invalid entry in comms
309 * - KMmsErrorNoURI1: Home page has not been defined for MMS access point
311 virtual TInt ValidateService( TMsvId aServiceId );
313 // -------------------------------------------------------------------
314 // FUNCTIONS TO HANDLE MMS HEADERS
316 // Accessors and mutators (getters and setters) for header fields.
317 // Some of these header fields have default values that are assigned
318 // from cached service settings when a new header is allocated.
319 // Some header fields are needed by protocol only.
320 // Those headers don't have accessors and mutators here,
321 // as they are used by Server MTM who accesses them directly
322 // through functions offered by CMmsHeaders.
325 * Set the sender of the message.
327 * If the sender of the message is not explicitly defined, the Proxy-Relay
328 * or MMS Service Centre will add the sender's phone number.
330 * @param[in] aAlias The phone number of the sender of the message.
331 * Maximum length 256 characters. This string will be included
332 * as the sender of the message when the message is sent, but
333 * the MMS Service Centre will check the validity of the
334 * value and replace it with the actual phone number of the
335 * sender if it is not correct.
337 virtual void SetSenderL( const TDesC& aAlias );
340 * Get the sender of the message.
342 * @return Address of the sender of the message (for example phone number).
343 * If the sender has not been defined, returns an empty string.
345 virtual const TPtrC Sender() const;
348 * Set the message class.
350 * If message class is not explicitly set, the message will have
351 * class "Personal" by default.
353 * @param [in] aMessageClass Message class code. Possible values:
354 * - EMmsClassPersonal: Message is a normal person-to-person message (default).
355 * - EMmsClassAdvertisement: Message contains an advertisement.
356 * - EMmsClassInformational: Message contains data from an information service.
357 * - EMmsClassAuto: Message has been automatically generated by the phone.
358 * This class is only valid for a message that is a read report to another message.
360 virtual void SetMessageClass( TMmsMessageClass aMessageClass );
363 * Get the message class.
365 * @return Message class. Possible values:
366 * - EMmsClassPersonal: Message is a normal person-to-person message (default).
367 * - EMmsClassAdvertisement: Message contains an advertisement.
368 * - EMmsClassInformational: Message contains data from an information service.
369 * - EMmsClassAuto: Message has been automatically generated by the phone.
370 * This class is only valid for a message that is a read report to another message.
371 * - 0: Message class has not been defined. Handle as EMmsClassPersonal.
373 virtual TInt MessageClass() const;
376 * Set the validity period of the message.
378 * If the validity period is not defined for the message, default
379 * validity period from MMS settings or MMS Service Centre will be used.
381 * @param[in] aInterval The length of time in seconds after which the
382 * message will be discarded by MMS Service Centre.
383 * MMSC may limit the maximum length of the validity period.
385 virtual void SetExpiryInterval( TTimeIntervalSeconds aInterval );
388 * Get the validity period of the message.
390 * @return Storage time of the message in MMS Service Centre (in seconds).
391 * If the message cannot be delivered to the recipient within the
392 * validity period, it will be discarded. If the validity period is 0,
393 * it has not been defined.
395 virtual TTimeIntervalSeconds ExpiryInterval() const;
398 * Set the expiration date of the message.
400 * @param[in] aDate The date and time when the message will expire
401 * (In UTC time). The date must be later than 1970-01-01, 00:00:00 GMT
402 * If the MMS Service Centre cannot deliver the message to the recipient
403 * before the expiration date, the message will be discarded. If expiration
404 * date or validity period have not been defined, default is used.
406 virtual void SetExpiryDate( TTime aDate );
409 * Get the expiration date of the message.
411 * @return The date and time when the message will expire. (in UTC time).
412 * If the expiration date has not been defined, TTime(0) will be
415 virtual TTime ExpiryDate() const;
418 * Set the delivery time interval for the message.
420 * @param[in] aInterval The length of time in seconds after which the message
421 * will be delivered to the recipient by the MMS Service Centre.
422 * If neither delivery time interval or delivery date have been defined,
423 * MMS Service Centre will deliver the message immediately.
425 virtual void SetDeliveryTimeInterval( TTimeIntervalSeconds aInterval );
428 * Get the delivery time interval of the message.
430 * @return The length of time in seconds after which the message will be
431 * delivered to the recipient by MMS Service Centre. If the delivery
432 * time interval is 0, it has not been defined.
434 virtual TTimeIntervalSeconds DeliveryTimeInterval() const;
437 * Set the delivery date for the message.
439 * @param[in] aDate The date and time when the message will be delivered
440 * to the recipient by the MMSC (in UTC time). The date must be
441 * later than 1970-01-01, 00:00:00 GMT. If neither delivery time
442 * interval or delivery date have been defined, MMS Service Centre
443 * will deliver the message immediately.
445 virtual void SetDeliveryDate( TTime aDate );
448 * Get the delivery date of the message.
450 * @return The date and time when the message will be (or was) delivered
451 * to the recipient by the MMSC (in UTC time). If the delivery date
452 * has not been defined, TTime(0) is returned.
454 virtual TTime DeliveryDate() const;
457 * Set the priority of the message.
459 * If the priority of the message is not set, the default priority will be
462 * @param[in] aPriority Message priority, possible values:
463 * - EMmsPriorityLow: Low priority.
464 * - EMmsPriorityNormal: Normal priority.
465 * - EMmsPriorityHigh: High priority.
467 virtual void SetMessagePriority( TMmsMessagePriority aPriority );
470 * Get the priority of the message.
472 * @return Message priority, possible values:
473 * - EMmsPriorityLow: Low priority.
474 * - EMmsPriorityNormal: Normal priority.
475 * - EMmsPriorityHigh: High priority.
476 * - 0: Priority has not been defined, treat as EMmsPriorityNormal
478 virtual TInt MessagePriority() const;
481 * Set the sender visibility setting for the message.
483 * Indicates whether the MMS Service Centre should hide the sender's phone
484 * number from the recipient. If the value is not defined, default is
485 * used. The default is to show the sender's number unless the sender
486 * has a secret number.
488 * @param[in] aVisibility Visibility of the sender's phone number to the
489 * recipient. Possible values:
490 * - EMmsSenderVisibilityDefault: Use default visibility.
491 * - EMmsSenderVisibilityHide: Hide the sender's number.
492 * - EMmsSenderVisibilityShow: Show the sender's number even if it is a
495 virtual void SetSenderVisibility(
496 TMmsMessageSenderVisibility aVisibility );
499 * Get the sender visibility setting of the message.
501 * Indicates whether the MMS Service Centre should hide the sender's phone
502 * number from the recipient. The default is show the sender's number
503 * unless the server has a secret number.
505 * @return visibility setting. Possible values:
506 * - EMmsSenderVisibilityDefault: Default visibility.
507 * - EMmsSenderVisibilityHide: Hide the sender's number.
508 * - EMmsSenderVisibilityShow: Show the sender's number even if it is a
510 * - 0: Sender visibilty has not been defined, use default.
512 virtual TInt SenderVisibility() const;
515 * Set the delivery report request setting value for the message.
517 * If the value is not set, default value from MMS settings will be used.
519 * @param[in] aRequest tells if the user wants a delivery report for this
520 * message. Possible values:
521 * - EMmsYes: The user wants a delivery report.
522 * - EMmsNo: The user does not want a delivery report.
524 virtual void SetDeliveryReport(
525 TMmsYesNo aRequest );
528 * Get the delivery report request setting of the message.
530 * If the value is not defined, default value from MMS settings is used.
532 * @return delivery report request setting. Possible values:
533 * - EMmsYes: The user wants a delivery report.
534 * - EMmsNo: The user does not want a delivery report.
535 * - 0: Setting has not been defined.
537 virtual TInt DeliveryReport() const;
540 * Set the read report request setting value for the message.
542 * Specifies if the user wants a read report for the current message.
543 * If this value is Yes, the recipient phone should send a read report
544 * when the user opens the message for the first time.
546 * @param[in] aRequest read report request setting. Possible values:
547 * - EMmsYes: The user wants a read report.
548 * - EMmsNo: The user does not want a read report.
550 virtual void SetReadReply( TMmsYesNo aRequest );
553 * Get the read report request setting of the message.
555 * Specifies if the sender wants a read report for current message.
556 * If this value is yes and the message has been received by the phone
557 * (has "KMmsMessageMobileTerminated" flag) a read report should be
558 * sent to the sender of this message when the message is opened
559 * for the first time.
561 * @return read report request setting. Possible values:
562 * - EMmsYes: The user wants a read report.
563 * - EMmsNo: The user does not want a read report.
564 * - 0: Setting has not been defined. Do not send a read report.
566 virtual TInt ReadReply() const;
569 * Get the sending date and time of the message.
570 * Valid only for messages received by the phone.
571 * @return the time when MMS Service Centre has received the message
572 * from sender (in UTC time).
573 * If the time has not been defined, returns TTime(0).
575 virtual TTime SendingDate() const;
578 * Get the response text from the message.
580 * Valid only in cases a response text has been obtained from MMS Service
581 * Centre. Possible cases are received messages and messages whose
582 * senging has failed. The text may explain the cause of the failure.
584 * @return Response text string. If text is not defined, returns an empty
588 virtual TPtrC ResponseText() const;
591 * Get the response status value from the message.
593 * This function returns the status MMS Service Centre has sent with a
594 * retrieved message or as a response to a failure to send a message.
595 * The status code may be used in case of permanent failures to retrieve
596 * or failures to send to indicate the reason of the failure.
598 * @return Status code sent by MMS Service Centre. Possible values are
599 * defined in OMA MMS Encapsulations specifications, and depend on
600 * the version of the MMS Service Centre sending the response.
601 * - Error codes 128 - 136 denote legacy errors from MMS encapsulation
603 * - Error codes 192 - 223 denote transient failures.
604 * - Error codes 224 - 255 denote permanent failures.
605 * - 0 means the response status has not been set. Either the operation was
606 * successful or the cause of the failure was not set by MMS Service Centre.
609 virtual TInt ResponseStatus() const;
612 * Get number of times the message has been forwarded.
614 * Returns the number of previous senders in case of a message that
615 * has been forwarded from one terminal to another based on the
616 * MMS notification only without retrieving the actual message to
617 * the terminal first.
619 * @return Number of times the message has been forwarded.
622 virtual TInt NumberOfPreviousSenders() const;
625 * Get the address of a previous sender.
627 * The addresses of the previous senders are defined for messages that
628 * have been forwarded without fetching them to the terminal first.
630 * @param[in] aSequenceNumber Indicates the number of the sender in the
631 * sequence. 1 is the first sender, a higher number indicates a later
633 * @return Address of the specified previous sender. If the sequence number
634 * exceeds the number of senders or is less than 1, an empty string is
638 virtual TPtrC PreviousSender( TInt aSequenceNumber ) const;
641 * Get the time when the message was previously sent (in UTC time).
643 * The function is valid only for messages that have been forwarded
644 * without fetching them to the terminal first.
646 * @param[in] aSequenceNumber Indicates the number of the sender in the
647 * sequence. 1 is the first sender, a higher number indicates a later
649 * @return Time of the previous sending (in UTC time). If the sequence
650 * number exceeds the number of senders or is less than 1, TTime(0)
654 virtual TTime PreviousSendingDate( TInt aSequenceNumber ) const;
657 * Get the time when the message was received in the terminal.
659 * @return Time of the arrival of the message (in UTC time).
660 * If the time has not been defined, TTime(0) is returned.
663 virtual TTime MessageReceiveTime() const;
666 * Get the incoming message size.
668 * This is valid only for a notification.
670 * @return Message size in octets as specified in MMS Notification.
672 virtual TInt MessageTransferSize() const;
675 * Get the Uri from which the message can be fetched.
677 * This is valid only for a nofification.
679 * @return Content location of the actual message, the Uri from which
680 * the message is fetched from MMS Service Centre.
682 virtual TPtrC8 MessageContentLocation() const;
685 * Set id of the root part of the message.
687 * @param[in] aId Attachment Id of the message part which controls the
688 * display of the message. Should point to the SMIL part if present.
690 virtual void SetMessageRootL( const TMsvAttachmentId aId );
693 * Get the id of the root part of the message.
695 * @return Id of the attachment that starts the message display,
696 * KMsvNullIndexEntryId if the root part has not been defined.
698 virtual TMsvAttachmentId MessageRootAttachment() const;
701 * Set the maximum size of the images that can be inserted in the message.
703 * @param[in] aHeight Image height in pixels.
704 * @param[in] aWidth Image width in pixels.
706 virtual void SetMaximumImage( TInt aWidth, TInt aHeight );
709 * Get the maximum size of the images that can be inserted in the message.
711 * The returned values are 0 if the maximum values have not been defined.
712 * @param[out] aHeight image height in pixels
713 * @param[out] aWidth image width in pixels
715 virtual void GetMaximumImage( TInt& aWidth, TInt& aHeight ) const;
717 // -------------------------------------------------------------------
718 // GENERAL MESSAGE INFORMATION METHODS
721 * Get the message size.
723 * SaveMessageL and LoadMessageL updates the value. This function returns
724 * the total amount of disk space the message takes. The actual message
725 * size in transmission is smaller due to binary encoding of the headers.
727 * @return size of all message parts in bytes including both attachments
728 * and internal header structures.
730 virtual TInt32 MessageSize();
733 * Set the message description string.
735 * This provides a method to override the default message description.
736 * The next SaveMessageL saves the description text in the
737 * TMsvEntry::iDescription field. This field is shown in Message Centre
738 * message lists to describe the contents of the message. Normally it is
739 * the message subject, but if there is no subject in the message, the
740 * caller may set some text from a text part of the message as the
743 * Note that this method does not check the text length, so avoid long
744 * descriptions to minimize memory usage.
746 * @param[in] aText Message description
748 virtual void SetMessageDescriptionL( const TDesC& aText );
750 // ---------------------------------------------------------------------
751 // FUNCTIONS TO HANDLE EXTRA MESSAGE ATTRIBUTES (FOR UI USE ONLY)
754 * Add attribute to an attribute array (for the use of MMS UI only).
756 * No duplicates are allowed. If an attribute exists, its value is changed.
757 * The attributes and their values can be arbitrary strings. There are no
758 * restrictions. The purpose is to allow the UI to store some extra
759 * information with the message. The values of the attibutes are not included
760 * when the message is sent.
761 * @param[in] aName Name of the attribute (case sensitive).
762 * @param[in] aValue Value of the attribute.
764 * @leave KErrArgument if length of aName or aValue is 0.
765 * @leave KErrNoMemory if memory runs out while adding the attribute.
767 virtual void AddAttributeL( const TDesC& aName, const TDesC& aValue );
770 * Get value of an attribute (for the use of MMS UI only).
772 * @param[in] aName Name of the attribute (case sensitive).
773 * @return Value of the attribute.
774 * @leave KErrNotFound if attribute not found or the length of aName is 0.
776 virtual TPtrC GetAttributeL( const TDesC& aName );
779 * Check if attribute is present (for the use of MMS UI only).
781 * @param[in] aName Name of the attribute (case sensitive).
782 * @return ETrue if the attribute is found, EFalse otherwise.
784 virtual TBool FindAttribute( const TDesC& aName );
787 * Delete named attribute from list (for the use of MMS UI only).
789 * @param[in] aName Name of the attribute (case sensitive).
791 virtual void DeleteAttribute( const TDesC& aName );
794 * Reset all attributes (for the use of MMS UI only).
796 * Removes all attributes (names and values) from the message.
798 virtual void ResetAttributes();
800 // -------------------------------------------------------------------
801 // FUNCTIONS TO HANDLE MESSAGE ATTACHMENTS
804 * Create attachment entry and copy specified file to message store.
806 * The user should call SaveMessageL after having added all attachments
807 * to update TMsvEntry of the message entry.
809 * @param[in] aStore An open edit store for the message entry.
810 * Caller must commit and close the store when ready. (Several
811 * attachments can be added before committing the store.)
812 * @param[in] aFile Open file handle, source of the attachment.
813 * Caller must close the file afterwards.
814 * @param[in] aMimeType Mime type (content type) of the attachmet
815 * in format type/subtype, for example image/jpeg.
816 * @param[in] aMimeHeaders Mime headers for the attachment. If the content
817 * type is not defined in aMimeHeaders, the function adds the mime type
818 * and subtype from aMimeType. Suggested filename in aMimeHeaders is
819 * used as attachment name.
820 * @param[in] aAttachmentInfo Attachment into structure, must be
821 * initialized to CMsvAttachment::EMsvFile. If mime type is added
822 * into the attachment info, it must be of format type/subtype,
823 * for example image/jpeg. On return AttachmentInfo contains data
824 * about the attachment. Ownership of attachmentinfo is transferred
825 * to attachment manager, it must not be deleted by caller. It must
826 * not be put on cleanup stack either. MMS engine keeps it safe until
827 * the ownership has been transferred.
828 * @param[out] aAttaId Attachment id of the newly created attachment.
830 * @pre A message entry must exist. It may be a new entry or an old entry
832 * @pre CMsvMimeHeaders structure must have been filled in advantage.
833 * The following values should be set:
834 * - Content type, for example image
835 * - Content subtype, for example jpeg
836 * - Character set IANA MIBEnum value, for example 106 (utf-8). Should be
837 * defined only if the content type is text.
838 * - Content-id if the presentation part refers to the attachments by
840 * - Suggested filename (name only, no path), the name that should be
841 * used to store the attachment and used as suggested filename
842 * when sending the message. If the suggested filename is not set, the
843 * name of the attachment file will be used.
844 * - Content-location if the presentation part refers to the attachments by
845 * using content-location. The content-location string must contain only
846 * us-ascii characters.
847 * - X-type parameters (if needed). These are always handled as pairs of a
848 * parameter name and parameter value. A descriptor at an even idex
849 * in the array (0, 2, 4, ...) represents the parameter name and a
850 * descriptor at an odd index (1, 3, 5, ...) represents the parameter
851 * value. If a parameter has no value, it must be indicated by an empty
852 * descriptor. The X-type parameter array must always contain an even
853 * number of elements.
856 * // The following code shows a short example of how the attachement
857 * // creation proceeds.
859 * // Assume that the client entry is set to the message entry.
860 * // Attachments are added to the message entry one by one
861 * CMsvStore* store = iMmsClient->Entry().EditStoreL();
862 * CleanupStack::PushL(store);
864 * CMsvAttachment* attaInfo = NULL;
865 * TMsvAttachmentId attaId = 0;
868 * // Set filename of attachment
869 * TFileName name( _L("C:\\pictures\\picture123.jpg") );
871 * CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewL();
872 * CleanupStack::PushL( mimeHeaders );
874 * // Set values to mime headers
875 * mimeHeaders->SetContentTypeL( _L8( "image") );
876 * mimeHeaders->SetContentSubTypeL( _L8( "jpeg" ) );
878 * _LIT8(KMimeType, "image/jpeg");
879 * // CreateAttachment2L will set the content type to attachment Info
881 * // Open the attachment file for reading
882 * attaFile.Open( iFs, name, EFileShareReadersOnly | EFileRead );
883 * CleanupClosePushL(attaFile);
885 * attaInfo = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
886 * // attaInfo ownerhip will be transferred to Attachment Manager.
887 * // It must not be pushed onto the cleanupStack before calling
888 * // CreateAttachment2L.
890 * TMsvAttachmentId attaId = 0;
892 * iMmsClient->CreateAttachment2L(
893 * *store, // edit store
894 * attaFile, // open file handle
895 * KMimeType, // combination type like image/jpeg
899 * // Now Attachment Manager owns the attaInfo
902 * CleanupStack::PopAndDestroy(); // attaFile.Close()
903 * CleanupStack::PopAndDestroy(); // mimeHeaders
905 * // Several attachments can be added before committing the store
907 * // Store must be committed before it is destroyed
909 * CleanupStack::PopAndDestroy(); // store
912 virtual void CreateAttachment2L(
916 CMsvMimeHeaders& aMimeHeaders,
917 CMsvAttachment* aAttachmentInfo,
918 TMsvAttachmentId& aAttaId);
921 * Create a text/plain attachment.
923 * Creates a text attachment from text in a descriptor.
924 * Has option to convert all unicode paragraph separator marks to
926 * Converts text from unicode (ucs-2) to utf-8 before storing it.
928 * @param[in] aStore An open edit store. Caller must commit and close the
929 * store (several attachments can be added before committing store).
930 * @param[out] aAttachmentId Attachment id of the new attachment entry.
931 * @param[in] aText Unicode text to be added as a text/plain attachment.
932 * @param[in] aFile Suggested filename for the attachment.
933 * @param[in] aConvertParagraphSeparator Flag that tells the function
934 * to search for all 0x2029 characters (Unicode paragraph
935 * separator) and to replace them with 0x000d 0x000a (carriage return,
938 * - ETrue: Convert paragraph separators (default).
939 * - EFalse: Do not convert paragraph separators.
941 * @pre A message entry must exist. It may be a new entry or an old entry
946 * TFileName attachmentFile( _L("story.txt") );
948 * CMsvStore* store = iMmsClient->Entry().EditStoreL();
949 * CleanupStack::PushL(store);
950 * TMsvAttachmentId attaId = 0;
952 * TBufC<12> story = _L( "Hello world!" );
954 * iMmsClient->CreateTextAttachmentL(
961 * // When the call returns the id of the attachment will be strored in attaId
963 * // caller must commit the store as several attachments could be added berore
964 * // committing the store.
966 * CleanupStack::PopAndDestroy(); // store
970 virtual void CreateTextAttachmentL(
972 TMsvAttachmentId& aAttachmentId,
975 TBool aConvertParagraphSeparator = ETrue );
977 // -------------------------------------------------------------------
978 // MESSAGE HANDLING FUNCTIONS
980 // NOTE: these are asynchronous functions
983 * Send current message in the background.
985 * The message is automatically moved to Outbox folder before the
988 * @param[in] aCompletionStatus iStatus member of an active object.
989 * It will be set as completed when the operating system has relayed
990 * the request to the server side of Symbian Messaging System.
991 * @param[in] aSendingTime Time at which the message is to be sent
992 * given as UTC time. If aSending time is zero or in the past, the
993 * message is scheduled to be sent as soon as possible.
994 * @return Pointer to an operation active object.
995 * The operation will complete when the sending has been successfully
996 * scheduled. The actual sending will happen in the background.
997 * If scheduling the send fails, the status of CMsvOperation will
998 * contain the relevant error code. The operation object must not
999 * be deleted before it completes.
1001 * @leave KErrNoMemory or other Symbian error code. If the function leaves
1002 * the owner of aCompletionStatus must not be set active because there
1003 * will be no pending request.
1005 virtual CMsvOperation* SendL( TRequestStatus& aCompletionStatus,
1006 const TTime aSendingTime = TTime( 0 ) );
1009 * Send a selection of messages in the background.
1011 * The messages are moved to Outbox folder before the sending starts.
1012 * All messages must be in the same place originally
1013 * (all in drafts, or all in outbox, for example).
1015 * @param[in] aSelection List of messages to be sent.
1016 * @param[in] aCompletionStatus iStatus member of an active object.
1017 * It will be set as completed when the operating system has relayed
1018 * the request to the server side of Symbian Messaging System.
1019 * @param aSendingTime Time at which the message selection is to be sent
1020 * given as UTC time. If aSending time is zero or in the past, the
1021 * message is scheduled to be sent as soon as possible.
1022 * @return Pointer to an operation active object.
1023 * The operation will complete when the sending has been successfully
1024 * scheduled. The actual sending will happen in the background.
1025 * If scheduling the send fails, the status of CMsvOperation will
1026 * contain the relevant error code. The operation object must not
1027 * be deleted before it completes.
1029 * @leave KErrNotFound if aSelection is empty, or other Symbian error code.
1030 * If the function leaves the owner of aCompletionStatus must not be set
1031 * active because there will be no pending request.
1033 virtual CMsvOperation* SendL(
1034 CMsvEntrySelection& aSelection,
1035 TRequestStatus& aCompletionStatus,
1036 TTime aSendingTime = TTime( 0 ) );
1039 * Fetch pending MMS messages from MMS Service Centre to inbox.
1041 * If there are notifications in postponed state they are all fetched.
1042 * If there are notification in inbox, they are not touched.
1044 * @param[in] aCompletionStatus iStatus member of an active object.
1045 * It will be set as completed when the operating system has relayed
1046 * the request to the server side of Symbian Messaging System.
1047 * @param[in] aForced indicates if the messages should be fetched
1048 * regardless of current mode settings.
1049 * - ETrue: User initiated fetch, use override.
1050 * - EFalse: Event triggered fetch, fetch only if settings allow.
1051 * @return Pointer to an operation active object.
1052 * The operation will complete when the retrieving has been successfully
1053 * scheduled. The actual retrieving will happen in the background.
1054 * If scheduling the fetch fails, the status of CMsvOperation will
1055 * contain the relevant error code. The operation object must not
1056 * be deleted before it completes.
1058 * @leave KErrNoMemory or other Symbian error code. If the function leaves
1059 * the owner of aCompletionStatus must not be set active because there
1060 * will be no pending request.
1062 * @deprecated Postponed fetching mode is no longer supported by UI. In most
1063 * cases this function would not have any effect.
1065 virtual CMsvOperation* FetchAllL( TRequestStatus& aCompletionStatus,
1066 TBool aForced = ETrue );
1069 * Send a read report to the sender of a message.
1071 * This function should be called when a new message is opened and the
1072 * sender of the message has specified that he wants a read report
1073 * for the message in question. This function should not be called
1074 * if the settings indicate that sending read reports is not allowed.
1076 * @param[in] aReadMessageId Id of the message for which a read report
1077 * should be sent. The message must not be locked and the caller
1078 * should not have CMsvStore open for the message as MMS Client Mtm
1079 * must be able to read header fields from the original message.
1080 * @param[in] aCompletionStatus iStatus member of an active object.
1081 * It will be set as completed when the operating system has relayed
1082 * the request to the server side of Symbian Messaging System.
1083 * @param[in] aReadStatus indicates if the message was read
1085 * - EMmsReadStatusRead: The message was read.
1086 * - EMmsReadStatusDeletedWithoutBeingRead: The message was deleted
1087 * without being read.
1088 * @return Pointer to an operation active object.
1089 * The operation will complete when the sending of the read report
1090 * has been successfully scheduled. The actual sending will happen
1091 * in the background. If scheduling the send fails, the status of
1092 * CMsvOperation will contain the relevant error code.
1093 * If the sender of the message has not requested a read report or
1094 * read report sending is not allowed, the operation completes
1095 * with error code KErrGeneral.
1096 * The operation object must not be deleted before it completes.
1098 * @leave KErrLocked if the message entry cannot be accessed.
1100 virtual CMsvOperation* SendReadReportL( TMsvId aReadMessageId,
1101 TRequestStatus& aCompletionStatus,
1102 TMmsReadStatus aReadStatus = EMmsReadStatusRead );
1104 public: // FUNCTIONS FROM BASE CLASSES
1107 * From CBaseMtm: Return type of this Mtm.
1108 * @return Registered Mtm type.
1110 inline TUid Type() const;
1113 // Context specific functions
1116 * From CBaseMtm: Set current context.
1117 * @param[in] aEntry Pointer to entry instance.
1119 inline void SetCurrentEntryL( CMsvEntry* aEntry );
1122 * From CBaseMtm: Switch context to entry defined by aId.
1123 * @param[in] aId Entry id in message store.
1125 inline void SwitchCurrentEntryL( TMsvId aId );
1128 * From CBaseMtm: Get reference to current entry.
1129 * @return Reference to entry instance.
1131 inline CMsvEntry& Entry() const;
1134 * From CBaseMtm: Query if entry context has been set.
1135 * @return Status, possible values:
1136 * - ETrue: Context has been set.
1137 * - EFalse: Context has not been set.
1139 inline TBool HasContext() const;
1141 // Message specific functions
1144 * From CBaseMtm: Store current entry data.
1146 void SaveMessageL();
1149 * From CBaseMtm: Restore current entry data.
1151 void LoadMessageL();
1154 * From CBaseMtm: Checks that selected parts of current message are
1156 * @param[in] aPartList Flags specifying which parts to validate.
1157 * (defined in MTMDEF.H). Possible values:
1158 * - KMsvMessagePartPartBody: Ignored. MMS engine does not support
1159 * separate message body.
1160 * - KMsvMessagePartRecipient: Supported.
1161 * - KMsvMessagePartOriginator Supported.
1162 * - KMsvMessagePartDescription: Ignored. Description is always valid
1163 * - KMsvMessagePartDate: Ignored. Date is always valid
1164 * - KMsvMessagePartAttachments: Supported.
1165 * @return TMsvPartList bitmask identifies each invalid part. If all parts
1166 * are valid, returned value is 0.
1168 TMsvPartList ValidateMessage( TMsvPartList aPartList );
1171 * From CBaseMtm: Searches for specified text in selected parts of
1173 * @param[in] aTextToFind Text to search for.
1174 * @param aPartList Flags specifying which parts to search.
1175 * (defined in MTMDEF.H). Possible values:
1176 * - KMsvMessagePartPartBody: Ignored.
1177 * - KMsvMessagePartRecipient: Supported.
1178 * - KMsvMessagePartOriginator: Supported.
1179 * - KMsvMessagePartDescription: Supported.
1180 * - KMsvMessagePartDate: Ignored.
1181 * - KMsvMessagePartAttachments: Ignored.
1182 * @return TMsvPartList bitmask specifies in which of the specified parts the text
1185 TMsvPartList Find( const TDesC& aTextToFind, TMsvPartList aPartList );
1188 * From CBaseMtm: Send a reply to current message.
1190 * @param[in] aDestination Id of the folder where the reply is generated.
1191 * @param[in] aPartlist Flags specifying which standard message parts
1192 * are to be included in the response (defined in MTMDEF.H). Following
1193 * values are possible:
1194 * - KMsvMessagePartPartBody: Ignored.
1195 * - KMsvMessagePartRecipient: Causes reply-to-all. Otherwise reply-to-sender
1197 * - KMsvMessagePartOriginator: Ignored.
1198 * - KMsvMessagePartDescription: Subject field is copied.
1199 * - KMsvMessagePartDate: Ignored.
1200 * - KMsvMessagePartAttachments: Ignored. Attachments are never copied to a reply.
1201 * @param[in] aCompletionStatus Status of an active object. This status
1202 * will be set as completed when the operation completes.
1203 * @return Pointer to an operation active object. The progress information
1204 * provides the id of the created message when the operation is complete.
1205 * If there was an error while creating the message, then the message
1206 * will be deleted and the result will contain a null id.
1207 * The operation object must not be deleted before it completes.
1209 CMsvOperation* ReplyL(
1210 TMsvId aDestination,
1211 TMsvPartList aPartlist,
1212 TRequestStatus& aCompletionStatus );
1215 * From CBaseMtm: Forward current message to new recipient.
1217 * @param[in] aDestination Id of the folder where the new message
1219 * @param[in] aPartList Flags specifying which standard message parts
1220 * are to be included in the response. Possible values:
1221 * - KMsvMessagePartPartBody: Ignored.
1222 * - KMsvMessagePartRecipient: Ignored.
1223 * - KMsvMessagePartOriginator: Ignored.
1224 * - KMsvMessagePartDescription: Subject field is copied.
1225 * - KMsvMessagePartDate: Ignored.
1226 * - KMsvMessagePartAttachments: Ignored. Attachments are always
1227 * automatically included when forwarding a message.
1228 * @param[in] aCompletionStatus Status of an active object. This status
1229 * will be set as completed when the operation completes.
1230 * @return Pointer to an operation active object. The progress information
1231 * provides the id of the created message when the operation is complete.
1232 * If there was an error while creating the message, then the message
1233 * will be deleted and the result will contain a null id.
1234 * The operation object must not be deleted before it completes.
1236 CMsvOperation* ForwardL(
1237 TMsvId aDestination,
1238 TMsvPartList aPartList,
1239 TRequestStatus& aCompletionStatus );
1242 * New recipient list function is not virtual, and the base MTM
1243 * implementation must always be used.
1244 * The function is shown here for reference only:
1246 * const CMsvRecipientList& AddresseeList() const;
1250 * From CBaseMtm: Adds an addressee, cannot distiguish To, Cc, and Bcc.
1252 * New addresses are handled as To type of addresses.
1253 * @param[in] aRealAddress Recipient address without alias.
1255 void AddAddresseeL( const TDesC& aRealAddress );
1258 * From CBaseMtm: Adds an addressee, cannot distiguish To, Cc, and Bcc.
1260 * New addresses are handled as To type of addresses.
1261 * @param[in] aRealAddress Recipient address.
1262 * @param[in] aAlias Descriptive name for the recipient.
1264 void AddAddresseeL( const TDesC& aRealAddress, const TDesC& aAlias );
1267 * From CBaseMtm: Adds a typed addressee (To, Cc or Bcc).
1269 * @param[in] aType recipient type. Possible values:
1270 * - EMsvRecipientTo: Normal recipient.
1271 * - EMsvRecipientCc: Recipient of a carbon copy.
1272 * - EMsvRecipientBcc: Recipient of a blind carbon copy.
1273 * @param[in] aRealAddress Address string without alias.
1275 virtual void AddAddresseeL(
1276 TMsvRecipientType aType,
1277 const TDesC& aRealAddress);
1280 * From CBaseMtm: Adds a typed addressee (To, Cc or Bcc).
1282 * @param[in] aType recipient type. Possible values:
1283 * - EMsvRecipientTo: Normal recipient.
1284 * - EMsvRecipientCc: Recipient of a carbon copy.
1285 * - EMsvRecipientBcc: Recipient of a blind carbon copy.
1286 * @param[in] aRealAddress Address string without alias.
1287 * @param[in] aAlias Descriptive name for the recipient.
1289 virtual void AddAddresseeL(
1290 TMsvRecipientType aType,
1291 const TDesC& aRealAddress,
1292 const TDesC& aAlias);
1295 * From CBaseMtm: Removes an entry from addressee list.
1297 * Cannot distinguish To, Cc and Bcc.
1298 * @param[in] aIndex Index to the array of addresses from
1299 * AddresseeList() function.
1301 void RemoveAddressee( TInt aIndex );
1303 // Note: rich text body not supported in MMS Message encapsulation.
1306 * From CBaseMtm: Get rich text body of the message.
1308 * MMS does not support separate message body. Body is ignored.
1309 * All MMS message parts are attachments.
1310 * @return Rich text body from CBaseMtm.
1312 inline CRichText& Body();
1315 * From CBaseMtm: Get rich text body.
1317 * MMS does not support separate message body. Body is ignored.
1318 * All MMS message parts are attachments.
1319 * @return Rich text body from CBaseMtm.
1321 inline const CRichText& Body() const;
1324 * From CBaseMtm: Set message subject.
1325 * @param[in] aSubject Message subject.
1327 void SetSubjectL( const TDesC& aSubject );
1330 * From CBaseMtm: Get message subject.
1331 * @return Message subject.
1333 const TPtrC SubjectL() const;
1335 // General MTM-specific functionality
1338 * From CBaseMtm: Query capabilities of MTM.
1340 * @param[in] aCapability UID specifying which capablity is queried.
1341 * For the possible Capability UIDs and types of return values
1343 * @param[out] aResponse The value describing the capability at return.
1344 * @return error code, Possible values:
1345 * - KErrNone: Specified capability is supported and aResponse
1346 * contains the value of the capability if available.
1347 * - KErrNotSupported: Capability is not supported.
1349 TInt QueryCapability( TUid aCapability, TInt& aResponse );
1352 * From CBaseMtm: Pass a request to MMS Server MTM.
1354 * Pass a function code to Server MTM, wait until the
1355 * function returns. This function can be used to
1356 * invoke synchronous protocol-specific operations.
1357 * The supported functions are private and this function should
1358 * be called by MMS UI only.
1359 * @param[in] aFunctionId Enumeration constant defining the operation.
1360 * @param[in] aSelection Array of message entry ids to be operated on.
1361 * @param[in] aParameter A descriptor that contains any parameters
1362 * required by function specified by aFunctionId.
1364 void InvokeSyncFunctionL(
1366 const CMsvEntrySelection& aSelection,
1367 TDes8& aParameter );
1370 * From CBaseMtm: Pass an asychronous request to Server MTM.
1372 * Pass a function code to Server MTM. The operation will
1373 * run in the background. This function can be used to
1374 * invoke asynchronous protocol-specific operations.
1375 * The supported functions are private and this function should
1376 * be called by MMS UI only.
1377 * @param[in] aFunctionId Enumeration constant defining the operation.
1378 * @param[in] aSelection Array of message entry ids to be uperated on.
1379 * @param[in] aParameter A descriptor that contains any parameters
1380 * required by function specified by aFunctionId.
1381 * @param[in] aCompletionStatus Status of an active object.
1382 * This status will be set as completed when the operation completes
1383 * @return Pointer to a message server operation (active object).
1385 CMsvOperation* InvokeAsyncFunctionL(
1387 const CMsvEntrySelection& aSelection,
1389 TRequestStatus& aCompletionStatus );
1392 * From CBaseMtm: Return session that was set at initialization.
1393 * @return Reference to Message Server session object.
1395 inline CMsvSession& Session();
1397 // Functions for SendAs support
1400 * From CBaseMtm: Add a file attachment to the current message entry.
1402 * The attachment is referenced by its file path and is copied into the
1404 * This function needs an edit store for the current entry.
1405 * The caller should not keep the store open.
1406 * The store is committed and closed after each attachment operation.
1407 * Only one asynchronous operation can be running at any one time.
1409 * If the file is a plain text file with ucs-2 character set MMS Engine
1410 * will convert the character set to utf-8 and create a text attachment
1411 * using this character set. The original file is not affected. This
1412 * must be done because MMS text attachments should be sent using
1413 * utf-8 character set.
1415 * @param[in] aFilePath Full path specification of the attachment file.
1416 * @param[in] aMimeType Mime type of the attachment file.
1417 * @param[in] aCharset IANA MIBEnum of the character set of the attachment.
1418 * If character set is not relevant for current attachment type,
1419 * aCharset should be 0.
1420 * @param[in] aStatus The request status to complete.
1421 * @leave System-wide error codes.
1425 * TFileName attachmentFile( _L("c:\\pictures\\picture123.jpg") );
1426 * TBufC8<20> mimeType = _L8( "image/jpeg" );
1427 * TUint charset = 0; // no character set needed for images
1429 * CMsvOperationActiveSchedulerWait* wait =
1430 * CMsvOperationActiveSchedulerWait::NewLC();
1432 * iMmsClient->AddAttachmentL(
1440 * if ( wait->iStatus.Int() != KErrNone )
1442 * // error handling, e.g. leave
1445 * CleanupStack::PopAndDestroy(); // wait
1447 * // The attachment has been added, store has been committed, and attachment data
1448 * // has been copied to the message store.
1449 * // If the original file is now modified, it does not affect the attachment file
1450 * // in the message store any more.
1454 void AddAttachmentL( const TDesC& aFilePath,
1455 const TDesC8& aMimeType,
1457 TRequestStatus& aStatus );
1460 * From CBaseMtm: Add a file attachment to the current message entry.
1462 * The attachment is referenced by an open file handle and is copied
1463 * into the message store.
1464 * This function needs an edit store for the current entry.
1465 * The caller should not keep the store open.
1466 * The store is committed and closed after each attachment operation.
1468 * If the file is a plain text file with ucs-2 character set MMS Engine
1469 * will convert the character set to utf-8 and create a text attachment
1470 * using this character set. The original file is not affected. This
1471 * must be done because MMS text attachments should be sent using
1472 * utf-8 character set.
1474 * Only one asynchronous operation can be running at any one time.
1475 * @param[in] aFile An open file handle for the file attachment. The handle
1476 * is closed when the function completes.
1477 * @param[in] aMimeType Mime type of the attachment file.
1478 * @param[in] aCharset IANA MIBEnum of the character set of the attachment.
1479 * If character set is not relevant for current attachment type,
1480 * aCharset should be 0.
1481 * @param[in] aStatus The request status to complete.
1482 * @leave System-wide error codes.
1484 * The function closes the file handle when done. The caller must not attempt
1485 * to close the file handle afterwards.
1489 * TFileName attachmentFile( _L("c:\\private\\privatedir\\picture123.jpg") );
1491 * TBufC8<20> mimeType = _L8( "image/jpeg" );
1492 * TUint charset = 0; // no character set needed for images
1494 * fileHandle.Open( iFs, attachmentFile, EFileShareReadersOnly | EFileRead );
1495 * CleanupClosePush(fileHandle);
1497 * CMsvOperationActiveSchedulerWait* wait =
1498 * CMsvOperationActiveSchedulerWait::NewLC();
1500 * iMmsClient->AddAttachmentL(
1508 * if ( wait->iStatus.Int() != KErrNone )
1510 * // error handling, e.g. leave
1513 * CleanupStack::PopAndDestroy(); // wait
1514 * CleanupStack::Pop(); // file handle was closed if function did not leave
1518 void AddAttachmentL( RFile& aFile,
1519 const TDesC8& aMimeType,
1521 TRequestStatus& aStatus );
1524 * From CBaseMtm: Add a file attachment to the current message entry
1527 * The attachment is referenced by its file path and is not copied
1528 * into the message store. The attachment file is always used from
1529 * its original location on disk indicated by the aFilePath
1532 * This function needs an edit store for the current entry.
1533 * The caller should not keep the store open.
1534 * The store is committed and closed after each attachment operation.
1535 * Only one asynchronous operation can be running at any one time.
1537 * The file must be in some public directory so that MMS Engine can access
1538 * the file when it is actually sent. If the file is a plain text attachment
1539 * the character set cannot be converted to utf-8 as the original file cannot
1540 * be changed. Text files should not be sent as linked attachmets unless the
1541 * character set of the file is utf-8.
1543 * @param[in] aFilePath Full path specification of the attachment file.
1544 * @param[in] aMimeType Mime type of the attachment file.
1545 * @param[in] aCharset IANA MIBEnum of the character set of the attachment.
1546 * If character set is not relevant for current attachment type,
1547 * aCharset should be 0.
1548 * @param[in] aStatus The request status to complete.
1549 * @leave System-wide error codes.
1551 void AddLinkedAttachmentL( const TDesC& aFilePath,
1552 const TDesC8& aMimeType,
1554 TRequestStatus& aStatus );
1557 * From CBaseMtm: Add a message entry as an attachment to the current
1560 * Not supported. No Message attachments allowed in MMS.
1561 * @leave KErrNotSupported
1563 void AddEntryAsAttachmentL( TMsvId aAttachmentId,
1564 TRequestStatus& aStatus );
1567 * From CBaseMtm: Create an attachment and return an open file handle for it.
1569 * This function needs an edit store for the current entry.
1570 * The caller should not keep the store open.
1571 * The store is committed and closed after each attachment operation.
1572 * Only one asynchronous operation can be running at any one time.
1574 * @param[in] aFileName Suggested filename.
1575 * @param[out] aAttachmentFile An open file handle for read/write
1576 * attachment file. The caller must close the handle.
1577 * @param[in] aMimeType Mime type of the attachment file.
1578 * @param[in] aCharset IANA MIBEnum of the character set of the attachment.
1579 * If character set is not relevant for current attachment type,
1580 * aCharset should be 0.
1581 * @param[in] aStatus The request status to complete.
1582 * @leave System-wide error codes.
1585 * TFileName attachmentFile( _L("picture123.jpg") );
1587 * TBufC8<20> mimeType = _L8( "image/jpeg" );
1588 * TUint charset = 0; // no character set needed for images
1590 * CMsvOperationActiveSchedulerWait* wait =
1591 * CMsvOperationActiveSchedulerWait::NewLC();
1593 * iMmsClient->CreateAttachmentL(
1602 * // When the function returns, the store has been committed
1604 * // The attachment file handle is now open for writing the attachment data
1605 * CleanupClosePush(fileHandle);
1607 * if ( wait->iStatus.Int() != KErrNone )
1609 * // error handling, e.g. leave
1612 * // write file content to open handle
1615 * CleanupStack::PopAndDestroy(); // close file handle
1616 * CleanupStack::PopAndDestroy(); // wait
1620 void CreateAttachmentL( const TDesC& aFileName,
1621 RFile& aAttachmentFile,
1622 const TDesC8& aMimeType,
1624 TRequestStatus& aStatus);
1627 * From CBaseMtm: Cancel the current attachment operation.
1629 void CancelAttachmentOperation();
1631 // End of attachment funtions to support SendAs
1634 * From CBaseMtm: Create an empty entry as the child of the current context.
1636 * Sets the new entry as current context.
1637 * The entry will be invisible and under construction.
1639 * @param[in] aServiceId Service id for the new entry.
1642 * // Context must be set to parent folder for CreateMessageL
1643 * // This example creates the message to drafts folder
1645 * TMsvId serviceId = iMmsClient->DefaultServiceL();
1646 * iMmsClient->SwitchCurrentEntryL( KMsvDraftEntryId );
1647 * iMmsClient->CreateMessageL( serviceId );
1649 * // The message entry is invisible and in "In Preparation" state.
1650 * // The context of CMmsClientMtm has now been switched to the new message entry.
1651 * // The message entry is still completely empty.
1652 * // Continue by adding data to the message
1656 void CreateMessageL( TMsvId aServiceId );
1659 * From CBaseMtm: Inform Client MTM about bio type change.
1661 * This function does nothing.
1663 void BioTypeChangedL( TUid aBioTypeUid );
1666 * From CBaseMtm: Return id of default service for this MTM type.
1668 * Only one MMS service is supported.
1669 * @return default service id.
1671 TMsvId DefaultServiceL() const;
1674 * From CBaseMtm: Remove default service.
1676 * Does nothing. Deletion of service not supported.
1678 void RemoveDefaultServiceL();
1681 * From CBaseMtm: Change default service.
1683 * Does nothing. Changing of default service not supported.
1685 void ChangeDefaultServiceL(const TMsvId& aService);
1687 protected: // New functions
1690 * Lists all visible and free MMS Notifications from inbox.
1691 * @return selection of Notifications in inbox.
1694 CMsvEntrySelection* ListNotificationsInInboxL();
1696 protected: // Functions from base classes
1699 * From CBaseMtm: Called after the context of this instance
1700 * has been changed to another entry.
1702 void ContextEntrySwitched();
1705 * From CBaseMtm: React to changes
1706 * @param[in] aEvent Code that tells which event has occurred.
1707 * Event codes defined in MSVAPI.H
1708 * @param[in] arg1 Depends on Event
1709 * @param[in] arg2 Depends on Event
1710 * @param[in] arg3 Depends on Event
1712 void HandleEntryEventL(
1713 TMsvEntryEvent aEvent,
1719 * By default Symbian OS constructor is private.
1720 * @param[in] aRegisteredMtmDll Reference to Mtm Dll registry class
1721 * @param[in] aSession Reference to a Message Server session.
1724 CRegisteredMtmDll& aRegisteredMtmDll,
1725 CMsvSession& aSession );
1732 * Build the iAddresseeList from the iMmsHeaders data.
1734 void BuildAddresseeListL();
1737 * Add entries from the the specified array to iAddresseeList.
1738 * @param aArray recipient array.
1739 * @param aValue recipient type.
1741 void BuildAddresseeListL(
1742 const CDesCArray& aArray, TMsvRecipientType aValue);
1746 * @return size of all attachments, binary data + mime headers.
1748 TInt32 AttachmentsSizeL();
1751 * List notifications in MMS folder.
1752 * @return selection of notifications
1754 CMsvEntrySelection* ListMmsFolderNotificationsL();
1757 * List notifications in inbox - only for mode switch fetch.
1758 * @return selection of notifications
1760 CMsvEntrySelection* ListInboxNotificationsL();
1763 * Fetch messages corresponding to unhandled notifications in ibox
1764 * This function is needed only when the fetching mode is changed
1765 * @param[in] aCompletionStatus iStatus member of an active object.
1766 * It will be set as completed when the request has finished.
1767 * @aparam[in] aForced indicates if the messages should be fetched
1768 * regardless of current mode settings.
1769 * ETrue = user initiated fetch, use override
1770 * EFalse = event triggered fetch, fetch only if settings allow.
1771 * @return pointer to an operation active object.
1772 * If successful, this is an asynchronously completing operation.
1773 * If failed, this is a completed operation, with status set to
1774 * the relevant error code.
1776 CMsvOperation* FetchAllFromInboxL( TRequestStatus& aCompletionStatus,
1777 TBool aForced = ETrue );
1780 * Convert date time from UTC to local time.
1781 * @param aDate UTC date time
1782 * @return local time
1784 // all times expressed in global time zone - no conversions
1786 TInt64 ConvertUTCDateToLocal( TInt64 aDate ) const;
1790 * Find text from the given recipient list.
1791 * @param[in] aTextToFind a text to be searched
1792 * @param[in] aPartList message part list
1793 * @param[in] aRecipients the recipient list
1794 * @param[in] aFindText CMsvFindText object to help in the find
1795 * @return ETrue if match found.
1797 TBool FindInRecipientL(
1798 const TDesC& aTextToFind,
1799 TMsvPartList aPartlist,
1800 const CDesCArray& aRecipients,
1801 CMsvFindText& aFindText );
1804 * Add an attachment from public location either as copied file or
1806 * @param[in] aFilePath The full path specification of the attachment file.
1807 * @param[in] aMimeType The mime type of the attachment file.
1808 * @param[in] aType CMsvAttachment::EMsvFile or
1809 * CMsvAttachment::EMsvLinkedFile
1810 * @param[in] aStatus The request status to complete when request has
1812 * @param[in] aCharacter set IANA MIBEnum of the character set for the
1813 * attachment if needed.
1815 void AddFilePathAttachmentL(const TDesC& aFilePath,
1816 const TDesC8& aMimeType,
1817 CMsvAttachment::TMsvAttachmentType aType,
1818 TRequestStatus& aStatus,
1819 const TUint aCharacterSet = 0 );
1822 * Store attribures to attribute stream in message entry
1823 * @param[in] aStore message store
1825 void StoreAttributesL( CMsvStore& aStore );
1828 * Restore attribures from attribute stream in message entry
1829 * @param[in] aStore message store
1831 void RestoreAttributesL( CMsvStore& aStore );
1834 * Checks whether given sample is UTF16 text.
1836 * @param[in] aSample text sample
1837 * @return 1015 if the sample starts with unicode BOM
1838 * (unicode with explicit byte mark)
1841 TUint GetUnicodeCharacterSet( TDesC8& aSample );
1844 * Reads bytes from so that sample is full or if file is shorter than
1845 * sample then read whole file.
1847 * @param[in] aFile open file handle to read bytes from
1848 * @param[out] aSample sample buffer filled with data
1850 void ReadBytesFromFileL( const RFile aFile, TDes8& aSample );
1853 * Tries to recognize character set from given sample.
1855 * @param[in] aFile File to be recognized
1856 * @return CharConv UID of the character set
1858 TUint RecognizeCharSetL( RFile& aFile );
1864 CMmsSettings* iMmsSettings; // MMSC settings (access point etc.)
1866 CMmsHeaders* iMmsHeaders; // MMS message headers
1867 TMsvId iServiceId; // last selected service
1868 TBool iFetchAll; // All the messages are fetched when
1869 // settings are saved after certain fetch
1871 TBool iFetchOverride; // force fetching all messages.
1872 TInt iMessageDrive; // messages are on C: drive by default,
1873 // may be moved to other drive
1874 TInt32 iHomeMode; // receiving mode in the home network
1875 TInt32 iRoamingMode; // receiving mode when roaming
1876 TInt iAccessPointCount; // number of access points
1877 CDesCArrayFlat* iAttributes; // zero or more attributes for UI.
1878 // Name, value pairs
1879 CMsvSession& iOwnSession; // copy of session because base class session is private
1883 // active object that commits the store when attachment operation
1885 CMmsAttachmentWaiter* iAttaWaiter;
1887 public: // Friend classes
1889 protected: // Friend classes
1891 private: // Friend classes
1896 GLREF_C void gPanic( TMmsPanic aPanic );
1898 #include "mmsclient.inl"
1900 #endif // MMSCLIENT_H