1 // Copyright (c) 2001-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __OBEXCLIENTMTM_H__
17 #define __OBEXCLIENTMTM_H__
21 #include <mtclbase.h> //CBaseMtm
23 // temporary forward declaration for now...
24 class CObexHeaderList;
27 class CMtmDllRegistry;
30 class CRegisteredMtmDll;
34 extern const TInt KMaxObexPasswordLength;
38 class TObexMtmProgress
40 Used to determine the progress for the current obex send operation.
48 ///The current state the send operation is in
51 ENullOp = 0, ///< Undefined state
52 EInitialise, ///< Initialise Obex client object
53 EConnect, ///< Trying to connect
54 EConnectAttemptComplete, ///< Connection complete
55 ESendObject, ///< Send Obex object
56 ESendNextObject, ///< Send next Obex object
57 ESendComplete, ///< Send complete
58 EDisconnected, ///< Disconnected
59 EUserCancelled, ///< User has cancelled the send, the current operation is unimportant
60 ESendError, ///< Problem with the send
61 EInitialised, ///< Initialisation complete
62 EMovedToSent ///< Move sent message to outbox (not supported from v7.0s)
64 TSendState iSendState; ///< Current state of send operation
65 TInt iTotalEntryCount; ///< Total number of objects to send
66 TInt iEntriesDone; ///< Number of entries sent
67 TInt iCurrentEntrySize; ///< Length attribute of the current object (bytes)
68 TInt iCurrentBytesTrans;///< Number of bytes sent of the current object
69 TInt iError; ///< Operation error code
74 class CObexClientMtm : public CBaseMtm
78 Abstract base class for Client Mtms that send obex objects
80 The functionality missing is an implementation of InvokeAsyncFunctionL()
81 which should return a messaging operation for a specific transport, InitialiseHeaderL() which is used
82 to create a CObexMtmHeader derived object of the appropriate type, and TestInvariant() which is used to
83 perform invariant testing of the derived types (in debug only).
84 These pure-virtual functions are the transport specific aspects of the MTM.
92 /// Contains the connect the timeout values for connect and put operations
99 //CBaseMtm Implementation
102 * Commits cached changes to the message store, by calling CommitChangesL.
104 * @leave KErrXxx System-wide error codes if message cannot be saved.
107 IMPORT_C virtual void SaveMessageL();
110 * This function loads the header from the message store
112 * @leave KErrXXX system-wide error codes
115 IMPORT_C virtual void LoadMessageL();
118 * Ensure that the current message context part indicated is valid. Currently only works on KMsvMessagePartRecipient--all other parts
119 * are assumed to be valid
121 * @param aPartList Bitmask indicating parts of message to be validated
122 * @return Bitmask of any invalid parts--KErrNone otherwise
125 IMPORT_C virtual TUint ValidateMessage(TMsvPartList aPartList);
128 * Finds the given text within the specified parts of the current message context. NOT IMPLEMENTED!
130 * @param aTextToFind Reference to the text to search for in the specified message parts
131 * @param aPartList Bitmask indicating parts of message to be searched for the text
132 * @return Bitmask of any parts containing the message text
135 IMPORT_C virtual TMsvPartList Find(const TDesC& aTextToFind, TMsvPartList aPartList);
140 * @leave Leaves always with KErrNotSupported
143 IMPORT_C virtual CMsvOperation* ReplyL (TMsvId aReplyEntryId, TMsvPartList aPartlist, TRequestStatus& aCompletionStatus);
148 * @leave Leaves always with KErrNotSupported
151 IMPORT_C virtual CMsvOperation* ForwardL(TMsvId aForwardEntryId, TMsvPartList aPartList, TRequestStatus& aCompletionStatus);
152 // addresssee list (used by objects with no MTM knowledge)
155 * Adds addressee to the addressee "list". Note that this MUST be a TDesC containing binary data representing
156 * the TSockAddress of the addressee, usually as a TDesC16. This function will then package the data directly into
158 * NB: Only ONE addressee is supported
160 * @param aRealAddress Reference to the address of the recipient
161 * @leave KErrXXX if address cannot be appended
162 * @leave KErrAlreadyExists if the Addressee "list" already contains an entry
165 IMPORT_C virtual void AddAddresseeL(const TDesC& aRealAddress);
168 * Adds addressee to the addressee "list". Note that this MUST be a TDesC containing binary data representing
169 * the TSockAddress of the addressee, usually as a TDesC16. This function will then package the data directly into
171 * NB: Only ONE addressee is supported
173 * @param aRealAddress Reference to the address of the recipient
174 * @param aAlias Reference to the alias of the recipient--ignored in this implementation
175 * @leave KErrXXX if address cannot be appended
176 * @leave KErrAlreadyExists if the Addressee "list" already contains an entry
179 IMPORT_C virtual void AddAddresseeL(const TDesC& aRealAddress, const TDesC& aAlias);
182 * Removes addressee at index aIndex from the addressee "list".
184 * @param aIndex zero-based index of the addressee (ignored since "there can be only one").
187 IMPORT_C virtual void RemoveAddressee(TInt aIndex);
190 * Sets the subject of the current message context
192 * @param aSubject Reference to the new message subject text
193 * @leave Leaves if creation of new HBufC fails
196 IMPORT_C void SetSubjectL(const TDesC& aSubject);
199 * Returns the subject of the current message context. Will not leave.
201 * @return const TPtrC representation of the Subject, or an empty TPtrC if the subject hasn't been set
205 IMPORT_C const TPtrC SubjectL() const;
207 IMPORT_C void CreateMessageAttachmentL(TMsvId aAttachmentId);
210 // --- RTTI functions ---
213 * Gives the capability of the MTM.
215 * @param aCapability capability to be queried
216 * @param aResponse capability dependent return value.
217 * @return KErrNone if the capability is supported, or KErrNotSupported if not.
220 IMPORT_C virtual TInt QueryCapability(TUid aCapability, TInt& aResponse);
222 IMPORT_C virtual void InvokeSyncFunctionL(TInt aFunctionId,const CMsvEntrySelection& aSelection, TDes8& aParameter);
225 * Create a new message for this MTM. This creates a new messaging entry, then
226 * re-initialises the MTM's CObexMtmHeader object.
228 * @param aServiceId The ID of the service for which the message is to be created
229 * @leave KErrXxx Standard EPOC error codes if construction of new objects fails
232 IMPORT_C virtual void CreateMessageL(TMsvId /*aServiceId*/);
235 * Destructor deletes FileNameExternaliser and Header
238 IMPORT_C ~CObexClientMtm();
241 * Commits cached changes to the message store.
243 * @leave KErrXxx System-wide error codes if changes cannot be committed.
246 IMPORT_C void CommitChangesL();
249 * This function calculates the size of all attachments to the message by either:
251 * @li summing the sizes of each of the children or;
252 * @li reading in all of the filenames from the store, and summing their sizes.*
254 * @return total size of the attachments.
255 * @leave KErrXXX system-wide error codes
258 IMPORT_C TInt32 GetAttachmentSizeL();
264 * Constructor. Initialises iMsgTypeUid with Uid provided by the derived class.
266 * @param aRegisteredMtmDll Registration data for MTM DLL.
267 * @param aMsvSession CMsvSession of the client requesting the object.
268 * @param aMsgTypeUid Uid of the message
271 IMPORT_C CObexClientMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession, TUid aMsgTypeUid);
274 * Empty implementation provided for future-proofing.
277 IMPORT_C void ConstructL();
280 /// Initialises header information (must be overidden in derived class)
281 virtual void InitialiseHeaderL() = 0;
284 * Resets the MTM when the context is switched.
285 * Must be called by the derived class's ContextEntrySwitched prior to constructing a new header.
288 IMPORT_C void ContextEntrySwitched(); // called after the context of this instance has been changed to another entry
291 CObexMtmHeader* iHeader; ///<Header information that must be initialised by InitialiseHeaderL in the derived classes!
294 const TUid iMsgTypeUid; ///<Message type UID, set by the derived class's constructor as appropriate for each derived MTM
297 //Custom invariant test macro--allows TestInvariant() function to be virtual
300 #define __TEST_INVARIANT_VIRTUAL TestInvariant();
302 #define __TEST_INVARIANT_VIRTUAL
305 #endif // __OBEXCLIENTMTM_H__