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