messagingappbase/obexmtms/obexmtm/obexclient/include/obexClientMtm.h
changeset 31 ebfee66fde93
child 47 5b14749788d7
equal deleted inserted replaced
30:6a20128ce557 31:ebfee66fde93
       
     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 "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 // obexClientMtm.h
       
    15 //
       
    16 
       
    17 #ifndef __OBEXCLIENTMTM_H__
       
    18 #define __OBEXCLIENTMTM_H__
       
    19 
       
    20 #include <mtclbase.h> //CBaseMtm
       
    21 
       
    22 // temporary forward declaration for now...
       
    23 class CObexHeaderList;
       
    24 
       
    25 class CMsvEntry;
       
    26 class CMtmDllRegistry;
       
    27 class CRichText;
       
    28 class TMsvEntry;
       
    29 class CRegisteredMtmDll;
       
    30 class CMsvSession;
       
    31 class CObexMtmHeader;
       
    32 
       
    33 //extern const TInt KMaxObexPasswordLength;
       
    34 
       
    35 class TObexMtmProgress
       
    36 /**
       
    37 Used to determine the progress for the current obex send operation.
       
    38 
       
    39 @publishedPartner
       
    40 @released
       
    41 */
       
    42 	{
       
    43 public:
       
    44 
       
    45 	//The current state the send operation is in
       
    46 	enum TSendState
       
    47 		{
       
    48 		ENullOp = 0, //< Undefined state
       
    49 		EInitialise, //< Initialise Obex client object
       
    50 		EConnect, //< Trying to connect
       
    51 		EConnectAttemptComplete, //< Connection complete
       
    52 		ESendObject, //< Send Obex object
       
    53 		ESendNextObject, //< Send next Obex object
       
    54 		ESendComplete, //< Send complete
       
    55 		EDisconnected, //< Disconnected
       
    56 		EUserCancelled,  //< User has cancelled the send, the current operation is unimportant
       
    57 		ESendError, //< Problem with the send
       
    58 		EInitialised, //< Initialisation complete
       
    59 		EMovedToSent //< Move sent message to outbox (not supported from v7.0s)
       
    60 		};
       
    61 	TSendState iSendState; //< Current state of send operation
       
    62 	TInt iTotalEntryCount; //< Total number of objects to send
       
    63 	TInt iEntriesDone; 		//< Number of entries sent
       
    64 	TInt iCurrentEntrySize; //< Length attribute of the current object (bytes)
       
    65 	TInt iCurrentBytesTrans;//< Number of bytes sent of the current object
       
    66 	TInt iError;			//< Operation error code
       
    67 	};
       
    68 
       
    69 
       
    70 
       
    71 class CObexClientMtm : public CBaseMtm
       
    72 /**
       
    73 CObexClientMtm 
       
    74 
       
    75 Abstract base class for Client Mtms that send obex objects
       
    76 
       
    77 The functionality missing is an implementation of InvokeAsyncFunctionL()
       
    78 which should return a messaging operation for a specific transport, InitialiseHeaderL() which is used
       
    79 to create a CObexMtmHeader derived object of the appropriate type, and TestInvariant() which is used to
       
    80 perform invariant testing of the derived types (in debug only).
       
    81 These pure-virtual functions are the transport specific aspects of the MTM.
       
    82 
       
    83 @publishedPartner
       
    84 @released
       
    85 */
       
    86 	{
       
    87 public:
       
    88 
       
    89 	// Contains the connect the timeout values for connect and put operations
       
    90 	struct STimeouts
       
    91 		{
       
    92 		TInt iConnectTimeout;
       
    93 		TInt iPutTimeout;
       
    94 		};
       
    95 
       
    96 	//CBaseMtm Implementation
       
    97 	
       
    98 	/**
       
    99 	 * Commits cached changes to the message store, by calling CommitChangesL. 
       
   100 	 *
       
   101 	 * @leave KErrXxx System-wide error codes if message cannot be saved.
       
   102 	 */
       
   103 	
       
   104 	IMPORT_C virtual void SaveMessageL();
       
   105 	
       
   106 	/**
       
   107 	 * This function loads the header from the message store
       
   108 	 *
       
   109 	 * @leave KErrXXX system-wide error codes
       
   110 	 */
       
   111 	
       
   112 	IMPORT_C virtual void LoadMessageL();
       
   113 
       
   114 	/**
       
   115 	 * Ensure that the current message context part indicated is valid. Currently only works on KMsvMessagePartRecipient--all other parts
       
   116 	 * are assumed to be valid
       
   117 	 *
       
   118 	 * @param aPartList Bitmask indicating parts of message to be validated
       
   119 	 * @return Bitmask of any invalid parts--KErrNone otherwise
       
   120 	 */
       
   121 	
       
   122 	IMPORT_C virtual TUint ValidateMessage(TMsvPartList aPartList);
       
   123 	
       
   124 	/**
       
   125   	 * Finds the given text within the specified parts of the current message context. NOT IMPLEMENTED!
       
   126 	 * 
       
   127 	 * @param aTextToFind Reference to the text to search for in the specified message parts
       
   128 	 * @param aPartList Bitmask indicating parts of message to be searched for the text
       
   129 	 * @return Bitmask of any parts containing the message text
       
   130 	 */
       
   131 	
       
   132 	IMPORT_C virtual TMsvPartList Find(const TDesC& aTextToFind, TMsvPartList aPartList);
       
   133 	
       
   134 	/**
       
   135 	 * Unsupported
       
   136 	 *
       
   137 	 * @leave Leaves always with KErrNotSupported
       
   138 	 */
       
   139 	
       
   140 	IMPORT_C virtual CMsvOperation* ReplyL  (TMsvId aReplyEntryId, TMsvPartList aPartlist, TRequestStatus& aCompletionStatus);
       
   141 	
       
   142 	/**
       
   143 	 * Unsupported
       
   144 	 *
       
   145 	 *  @leave Leaves always with KErrNotSupported
       
   146 	 */
       
   147 		
       
   148 	IMPORT_C virtual CMsvOperation* ForwardL(TMsvId aForwardEntryId, TMsvPartList aPartList, TRequestStatus& aCompletionStatus);
       
   149 	// addresssee list (used by objects with no MTM knowledge)
       
   150 	
       
   151 	/**
       
   152 	 * Adds addressee to the addressee "list". Note that this MUST be a TDesC containing binary data representing
       
   153 	 * the TSockAddress of the addressee, usually as a TDesC16. This function will then package the data directly into 
       
   154 	 * 8 bit data.
       
   155  	 * NB: Only ONE addressee is supported
       
   156 	 *
       
   157 	 * @param aRealAddress Reference to the address of the recipient
       
   158  	 * @leave KErrXXX if address cannot be appended
       
   159 	 * @leave KErrAlreadyExists if the Addressee "list" already contains an entry
       
   160 	 */
       
   161 
       
   162 	IMPORT_C virtual void AddAddresseeL(const TDesC& aRealAddress);
       
   163 	
       
   164 	/**
       
   165 	 * Adds addressee to the addressee "list". Note that this MUST be a TDesC containing binary data representing
       
   166 	 * the TSockAddress of the addressee, usually as a TDesC16. This function will then package the data directly into 
       
   167 	 * 8 bit data.
       
   168 	 * NB: Only ONE addressee is supported
       
   169 	 *
       
   170 	 * @param aRealAddress Reference to the address of the recipient
       
   171 	 * @param aAlias Reference to the alias of the recipient--ignored in this implementation
       
   172 	 * @leave KErrXXX if address cannot be appended
       
   173 	 * @leave KErrAlreadyExists if the Addressee "list" already contains an entry
       
   174 	 */
       
   175 
       
   176 	IMPORT_C virtual void AddAddresseeL(const TDesC& aRealAddress, const TDesC& aAlias);
       
   177 	
       
   178 	/**
       
   179 	 * Removes addressee at index aIndex from the addressee "list".
       
   180 	 *
       
   181 	 * @param aIndex zero-based index of the addressee (ignored since "there can be only one").
       
   182 	 */
       
   183 
       
   184 	IMPORT_C virtual void RemoveAddressee(TInt aIndex);
       
   185 	
       
   186 	/**
       
   187 	 * Sets the subject of the current message context
       
   188 	 *
       
   189 	 * @param aSubject Reference to the new message subject text
       
   190 	 * @leave Leaves if creation of new HBufC fails
       
   191 	 */	
       
   192 	
       
   193 	IMPORT_C void SetSubjectL(const TDesC& aSubject);
       
   194 
       
   195 	/**
       
   196 	 * Returns the subject of the current message context. Will not leave.
       
   197 	 *
       
   198 	 * @return const TPtrC representation of the Subject, or an empty TPtrC if the subject hasn't been set
       
   199 	 * @leave Never
       
   200 	 */
       
   201 	
       
   202 	IMPORT_C const TPtrC SubjectL() const;
       
   203 	
       
   204 	IMPORT_C void CreateMessageAttachmentL(TMsvId aAttachmentId); 
       
   205 
       
   206 	
       
   207 	// --- RTTI functions ---
       
   208 
       
   209 	/**
       
   210 	 * Gives the capability of the MTM. 
       
   211 	 *
       
   212 	 * @param aCapability capability to be queried
       
   213 	 * @param aResponse capability dependent return value.
       
   214 	 * @return KErrNone if the capability is supported, or KErrNotSupported if not.
       
   215 	 */
       
   216 
       
   217 	IMPORT_C virtual TInt QueryCapability(TUid aCapability, TInt& aResponse);
       
   218 
       
   219 	IMPORT_C virtual void InvokeSyncFunctionL(TInt aFunctionId,const CMsvEntrySelection& aSelection, TDes8& aParameter);
       
   220 	
       
   221 	/**
       
   222 	 * Create a new message for this MTM. This creates a new messaging entry, then
       
   223 	 * re-initialises the MTM's CObexMtmHeader object.
       
   224 	 *
       
   225 	 * @param aServiceId The ID of the service for which the message is to be created
       
   226 	 * @leave KErrXxx Standard EPOC error codes if construction of new objects fails
       
   227 	 */
       
   228 
       
   229 	IMPORT_C virtual void CreateMessageL(TMsvId /*aServiceId*/);
       
   230 	
       
   231 	/**
       
   232 	 * Destructor deletes FileNameExternaliser and Header
       
   233 	 */
       
   234 
       
   235 	IMPORT_C ~CObexClientMtm();
       
   236 
       
   237 	/**
       
   238 	 * Commits cached changes to the message store. 
       
   239 	 *
       
   240 	 * @leave KErrXxx System-wide error codes if changes cannot be committed.
       
   241 	 */
       
   242 
       
   243 	IMPORT_C void CommitChangesL();
       
   244 	
       
   245 	/**
       
   246 	 * This function calculates the size of all attachments to the message by either:
       
   247 	 *
       
   248 	 *  @li summing the sizes of each of the children or;
       
   249 	 *  @li reading in all of the filenames from the store, and summing their sizes.*
       
   250 	 *
       
   251 	 *  @return total size of the attachments.
       
   252 	 *  @leave KErrXXX system-wide error codes
       
   253 	 */
       
   254 	
       
   255 	IMPORT_C TInt32 GetAttachmentSizeL();
       
   256 
       
   257 
       
   258 protected:
       
   259 	
       
   260 	/**
       
   261 	 * Constructor. Initialises iMsgTypeUid with Uid provided by the derived class.
       
   262 	 *
       
   263 	 * @param aRegisteredMtmDll Registration data for MTM DLL.
       
   264 	 * @param aMsvSession CMsvSession of the client requesting the object.
       
   265 	 * @param aMsgTypeUid Uid of the message
       
   266 	 */
       
   267 
       
   268 	IMPORT_C CObexClientMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession, TUid aMsgTypeUid);
       
   269 	
       
   270 	/**
       
   271 	 * Empty implementation provided for future-proofing.
       
   272 	 */
       
   273 	
       
   274 	IMPORT_C void ConstructL();
       
   275 	
       
   276 	
       
   277 	// Initialises header information (must be overridden in derived class)
       
   278 	virtual void InitialiseHeaderL() = 0;
       
   279 	
       
   280 	/**
       
   281 	 * Resets the MTM when the context is switched.
       
   282 	 * Must be called by the derived class's ContextEntrySwitched prior to constructing a new header.
       
   283 	 */
       
   284 
       
   285 	IMPORT_C void ContextEntrySwitched(); // called after the context of this instance has been changed to another entry
       
   286 
       
   287 protected:
       
   288 	CObexMtmHeader* iHeader;	//<Header information that must be initialised by InitialiseHeaderL in the derived classes!
       
   289 
       
   290 private:
       
   291 	const TUid iMsgTypeUid;	//<Message type UID, set by the derived class's constructor as appropriate for each derived MTM
       
   292 	};
       
   293 
       
   294 //Custom invariant test macro--allows TestInvariant() function to be virtual
       
   295 
       
   296 #ifdef _DEBUG
       
   297 #define __TEST_INVARIANT_VIRTUAL TestInvariant();
       
   298 #else
       
   299 #define __TEST_INVARIANT_VIRTUAL
       
   300 #endif //__DEBUG__
       
   301 
       
   302 #endif // __OBEXCLIENTMTM_H__