epoc32/include/obexclientmtm.h
branchSymbian2
changeset 2 2fe1408b6811
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef __OBEXCLIENTMTM_H__
       
    17 #define __OBEXCLIENTMTM_H__
       
    18 
       
    19 
       
    20 
       
    21 #include <mtclbase.h> //CBaseMtm
       
    22 
       
    23 // temporary forward declaration for now...
       
    24 class CObexHeaderList;
       
    25 
       
    26 class CMsvEntry;
       
    27 class CMtmDllRegistry;
       
    28 class CRichText;
       
    29 class TMsvEntry;
       
    30 class CRegisteredMtmDll;
       
    31 class CMsvSession;
       
    32 class CObexMtmHeader;
       
    33 
       
    34 extern const TInt KMaxObexPasswordLength;
       
    35 
       
    36 
       
    37 
       
    38 class TObexMtmProgress
       
    39 /**
       
    40 Used to determine the progress for the current obex send operation.
       
    41 
       
    42 @publishedPartner
       
    43 @released
       
    44 */
       
    45 	{
       
    46 public:
       
    47 
       
    48 	///The current state the send operation is in
       
    49 	enum TSendState
       
    50 		{
       
    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)
       
    63 		};
       
    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
       
    70 	};
       
    71 
       
    72 
       
    73 
       
    74 class CObexClientMtm : public CBaseMtm
       
    75 /**
       
    76 CObexClientMtm 
       
    77 
       
    78 Abstract base class for Client Mtms that send obex objects
       
    79 
       
    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.
       
    85 
       
    86 @internalTechnology
       
    87 @released
       
    88 */
       
    89 	{
       
    90 public:
       
    91 
       
    92 	/// Contains the connect the timeout values for connect and put operations
       
    93 	struct STimeouts
       
    94 		{
       
    95 		TInt iConnectTimeout;
       
    96 		TInt iPutTimeout;
       
    97 		};
       
    98 
       
    99 	//CBaseMtm Implementation
       
   100 	
       
   101 	/**
       
   102 	 * Commits cached changes to the message store, by calling CommitChangesL. 
       
   103 	 *
       
   104 	 * @leave KErrXxx System-wide error codes if message cannot be saved.
       
   105 	 */
       
   106 	
       
   107 	IMPORT_C virtual void SaveMessageL();
       
   108 	
       
   109 	/**
       
   110 	 * This function loads the header from the message store
       
   111 	 *
       
   112 	 * @leave KErrXXX system-wide error codes
       
   113 	 */
       
   114 	
       
   115 	IMPORT_C virtual void LoadMessageL();
       
   116 
       
   117 	/**
       
   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
       
   120 	 *
       
   121 	 * @param aPartList Bitmask indicating parts of message to be validated
       
   122 	 * @return Bitmask of any invalid parts--KErrNone otherwise
       
   123 	 */
       
   124 	
       
   125 	IMPORT_C virtual TUint ValidateMessage(TMsvPartList aPartList);
       
   126 	
       
   127 	/**
       
   128   	 * Finds the given text within the specified parts of the current message context. NOT IMPLEMENTED!
       
   129 	 * 
       
   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
       
   133 	 */
       
   134 	
       
   135 	IMPORT_C virtual TMsvPartList Find(const TDesC& aTextToFind, TMsvPartList aPartList);
       
   136 	
       
   137 	/**
       
   138 	 * Unsupported
       
   139 	 *
       
   140 	 * @leave Leaves always with KErrNotSupported
       
   141 	 */
       
   142 	
       
   143 	IMPORT_C virtual CMsvOperation* ReplyL  (TMsvId aReplyEntryId, TMsvPartList aPartlist, TRequestStatus& aCompletionStatus);
       
   144 	
       
   145 	/**
       
   146 	 * Unsupported
       
   147 	 *
       
   148 	 *  @leave Leaves always with KErrNotSupported
       
   149 	 */
       
   150 		
       
   151 	IMPORT_C virtual CMsvOperation* ForwardL(TMsvId aForwardEntryId, TMsvPartList aPartList, TRequestStatus& aCompletionStatus);
       
   152 	// addresssee list (used by objects with no MTM knowledge)
       
   153 	
       
   154 	/**
       
   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 
       
   157 	 * 8 bit data.
       
   158  	 * NB: Only ONE addressee is supported
       
   159 	 *
       
   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
       
   163 	 */
       
   164 
       
   165 	IMPORT_C virtual void AddAddresseeL(const TDesC& aRealAddress);
       
   166 	
       
   167 	/**
       
   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 
       
   170 	 * 8 bit data.
       
   171 	 * NB: Only ONE addressee is supported
       
   172 	 *
       
   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
       
   177 	 */
       
   178 
       
   179 	IMPORT_C virtual void AddAddresseeL(const TDesC& aRealAddress, const TDesC& aAlias);
       
   180 	
       
   181 	/**
       
   182 	 * Removes addressee at index aIndex from the addressee "list".
       
   183 	 *
       
   184 	 * @param aIndex zero-based index of the addressee (ignored since "there can be only one").
       
   185 	 */
       
   186 
       
   187 	IMPORT_C virtual void RemoveAddressee(TInt aIndex);
       
   188 	
       
   189 	/**
       
   190 	 * Sets the subject of the current message context
       
   191 	 *
       
   192 	 * @param aSubject Reference to the new message subject text
       
   193 	 * @leave Leaves if creation of new HBufC fails
       
   194 	 */	
       
   195 	
       
   196 	IMPORT_C void SetSubjectL(const TDesC& aSubject);
       
   197 
       
   198 	/**
       
   199 	 * Returns the subject of the current message context. Will not leave.
       
   200 	 *
       
   201 	 * @return const TPtrC representation of the Subject, or an empty TPtrC if the subject hasn't been set
       
   202 	 * @leave Never
       
   203 	 */
       
   204 	
       
   205 	IMPORT_C const TPtrC SubjectL() const;
       
   206 	
       
   207 	IMPORT_C void CreateMessageAttachmentL(TMsvId aAttachmentId); 
       
   208 
       
   209 	
       
   210 	// --- RTTI functions ---
       
   211 
       
   212 	/**
       
   213 	 * Gives the capability of the MTM. 
       
   214 	 *
       
   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.
       
   218 	 */
       
   219 
       
   220 	IMPORT_C virtual TInt QueryCapability(TUid aCapability, TInt& aResponse);
       
   221 
       
   222 	IMPORT_C virtual void InvokeSyncFunctionL(TInt aFunctionId,const CMsvEntrySelection& aSelection, TDes8& aParameter);
       
   223 	
       
   224 	/**
       
   225 	 * Create a new message for this MTM. This creates a new messaging entry, then
       
   226 	 * re-initialises the MTM's CObexMtmHeader object.
       
   227 	 *
       
   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
       
   230 	 */
       
   231 
       
   232 	IMPORT_C virtual void CreateMessageL(TMsvId /*aServiceId*/);
       
   233 	
       
   234 	/**
       
   235 	 * Destructor deletes FileNameExternaliser and Header
       
   236 	 */
       
   237 
       
   238 	IMPORT_C ~CObexClientMtm();
       
   239 
       
   240 	/**
       
   241 	 * Commits cached changes to the message store. 
       
   242 	 *
       
   243 	 * @leave KErrXxx System-wide error codes if changes cannot be committed.
       
   244 	 */
       
   245 
       
   246 	IMPORT_C void CommitChangesL();
       
   247 	
       
   248 	/**
       
   249 	 * This function calculates the size of all attachments to the message by either:
       
   250 	 *
       
   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.*
       
   253 	 *
       
   254 	 *  @return total size of the attachments.
       
   255 	 *  @leave KErrXXX system-wide error codes
       
   256 	 */
       
   257 	
       
   258 	IMPORT_C TInt32 GetAttachmentSizeL();
       
   259 
       
   260 
       
   261 protected:
       
   262 	
       
   263 	/**
       
   264 	 * Constructor. Initialises iMsgTypeUid with Uid provided by the derived class.
       
   265 	 *
       
   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
       
   269 	 */
       
   270 
       
   271 	IMPORT_C CObexClientMtm(CRegisteredMtmDll& aRegisteredMtmDll, CMsvSession& aMsvSession, TUid aMsgTypeUid);
       
   272 	
       
   273 	/**
       
   274 	 * Empty implementation provided for future-proofing.
       
   275 	 */
       
   276 	
       
   277 	IMPORT_C void ConstructL();
       
   278 	
       
   279 	
       
   280 	/// Initialises header information (must be overidden in derived class)
       
   281 	virtual void InitialiseHeaderL() = 0;
       
   282 	
       
   283 	/**
       
   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.
       
   286 	 */
       
   287 
       
   288 	IMPORT_C void ContextEntrySwitched(); // called after the context of this instance has been changed to another entry
       
   289 
       
   290 protected:
       
   291 	CObexMtmHeader* iHeader;	///<Header information that must be initialised by InitialiseHeaderL in the derived classes!
       
   292 
       
   293 private:
       
   294 	const TUid iMsgTypeUid;	///<Message type UID, set by the derived class's constructor as appropriate for each derived MTM
       
   295 	};
       
   296 
       
   297 //Custom invariant test macro--allows TestInvariant() function to be virtual
       
   298 
       
   299 #ifdef _DEBUG
       
   300 #define __TEST_INVARIANT_VIRTUAL TestInvariant();
       
   301 #else
       
   302 #define __TEST_INVARIANT_VIRTUAL
       
   303 #endif //__DEBUG__
       
   304 
       
   305 #endif // __OBEXCLIENTMTM_H__