messagingappbase/obexmtms/obexmtm/obexutil/include/obexMtmUtil.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     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 // $Workfile: obexMtmUtil.h $
       
    15 // $Author: Stevep $
       
    16 // $Revision: 10 $
       
    17 // $Date: 25/03/02 8:49 $
       
    18 // 
       
    19 //
       
    20 
       
    21 
       
    22 #ifndef __OBEXMTMUTIL_H__
       
    23 #define __OBEXMTMUTIL_H__
       
    24 
       
    25 
       
    26 #include <e32std.h>
       
    27 
       
    28 #include <BAUTILS.H>	// NearestLanguageFile
       
    29 #include <basched.h>
       
    30 #include <coeutils.h>	// ConeUtils::FileExists
       
    31 #include <apparc.h>		// CApaApplication::GenerateFileName
       
    32 #include <apgcli.h>		// RApaLsSession   <-- data recognition.
       
    33 
       
    34 #include <txtrich.h>	// Richtext
       
    35 #include <utf.h>		// CharConv
       
    36 #include <baclipb.h>	// Clipboard
       
    37 
       
    38 // Obex
       
    39 #include <obex.h>
       
    40 
       
    41 // MS
       
    42 #include <msvAPI.h>
       
    43 #include <msvIDs.h>
       
    44 #include <msvUIDs.h>
       
    45 #include <msvSTD.hrh>
       
    46 
       
    47 extern const TInt KMaxObexPasswordLength;
       
    48 const TUid KObexFileNameStreamUid = {0x1000AAC5};
       
    49 
       
    50 // temporary IDs to indicate either a filename or a headerlist entry in the stream
       
    51 const TInt32 KObexFileNameStreamFileNameUid		= 0x1000;
       
    52 const TInt32 KObexFileNameStreamHeaderListUid	= 0x1001;
       
    53 
       
    54 class CObexHeaderList;
       
    55 
       
    56 //
       
    57 // Container class for an array with descriptors and header lists associated with it
       
    58 //
       
    59 class CObexMtmFileNameWithHeaders : public CBase
       
    60 /**
       
    61 @internalTechnology
       
    62 @released
       
    63 */
       
    64 	{
       
    65 public:
       
    66 	/**
       
    67 	 * Canonical NewL factory function.
       
    68 	 *
       
    69 	 * @return an empty CObexMtmFileNameWithHeaders class
       
    70 	 * @leave KErrXXX system wide error codes
       
    71 	 */
       
    72 	IMPORT_C static CObexMtmFileNameWithHeaders* NewL();
       
    73 
       
    74 	/**
       
    75 	 * Destructor. Will destroy the data pointed to by the 2 member pointers.
       
    76 	 */
       
    77 	CObexMtmFileNameWithHeaders::~CObexMtmFileNameWithHeaders();
       
    78 
       
    79 private:
       
    80 	/**
       
    81 	 * Constructor.
       
    82 	 */
       
    83 	CObexMtmFileNameWithHeaders();
       
    84 
       
    85 public:
       
    86 	/**
       
    87 	 * iFileName points to a descriptor (owned by this class) which holds the filename
       
    88 	 */
       
    89 	TDesC16			*iFileName;
       
    90 	/**
       
    91 	 * iHeaderList points to a CObexHeaderList class containing the set of headers for this file.
       
    92 	 */
       
    93 	CObexHeaderList *iHeaderList;
       
    94 	};
       
    95 
       
    96 //
       
    97 // Class to allow an arbitrary number of filenames to be saved to a CMsvEntry
       
    98 //
       
    99 // For obex msgs the obex objects to send are stored in files and not in the msg body. 
       
   100 // These files may be copied into messaging and attached to the msg as "proper" 
       
   101 // attachments, OR the msg itself can contain a list of filenames of files that exist
       
   102 // anywhere on the filesystem. This class is used in the latter case to externalise/
       
   103 // internalise filenames to/from the msg entry.
       
   104 //
       
   105 //
       
   106 typedef RPointerArray<CObexMtmFileNameWithHeaders> RObexMtmFileNameWithHeadersArray;
       
   107 
       
   108 class CObexMtmFileNameExternaliser : public CBase
       
   109 /** Allows an arbitrary number of filenames to be saved to a CMsvEntry.
       
   110 
       
   111 @publishedPartner
       
   112 @released
       
   113 */
       
   114 //this class was originally classified as internal technology but was changed to publised partner as one licensee used 
       
   115 //the static function ExternaliseAndCommit1FileNameL() in its code before the API classification work was done
       
   116 	{  
       
   117 public: //static methods
       
   118 	
       
   119 	/**
       
   120 	 * Static function to write one and only one filename to the message store, then finalise and commit it. This function
       
   121 	 * should be called ONCE ONLY. To externalise more than one filename, instantiate this class and use ExternaliseFileNameL()
       
   122 	 * followed by CommitStoreL().
       
   123 	 * @param aEntry the entry whose store is to be written to
       
   124 	 * @param aDes The filename to write to the store
       
   125 	 * @leave KErrXXX system-wide error codes
       
   126 	 */	
       
   127 	
       
   128 	IMPORT_C	static	void ExternaliseAndCommit1FileNameL(CMsvEntry* aEntry, const TDesC16* aDes);
       
   129 
       
   130 	/**
       
   131 	* Static function to read in one filename from the store.
       
   132 	*
       
   133 	* @param aEntry entry to read the filename from
       
   134 	* @param aDes Descriptor to receive the new filename. Any existing data will be overwritten. MUST be long enough to contain the name.
       
   135 	* @leave KErrXXX system wide error codes.
       
   136 	*/
       
   137 	
       
   138 	IMPORT_C	static	void Internalise1FileNameL(CMsvEntry* aEntry, TDes16* aDes);
       
   139 
       
   140 	/**
       
   141 	 * Static function to get the filenames stored within the message entry. The returned array is pushed onto the cleanup
       
   142 	 * stack.
       
   143 	 *
       
   144 	 * @param aMessageStore Store from which the names are to be read
       
   145 	 * @return Array of filenames, pushed onto the cleanup stack.
       
   146 	 * @leave System wide error codes
       
   147 	 */
       
   148 	
       
   149 	IMPORT_C	static   RObexMtmFileNameWithHeadersArray* InternaliseFileNamesLC(CMsvStore& aMessageStore);
       
   150 
       
   151 public: //non-static methods
       
   152 	
       
   153 	/**
       
   154 	 * Canonical NewL factory function.
       
   155 	 *
       
   156 	 * @param aSession A messaging server session
       
   157 	 * @param aId TMsvId of the entry to externalise/internalise to/from. This association is fixed for the lifetime of this instance of the class.
       
   158 	 * @return a newly constucted CObexMtmFileNameExternaliser
       
   159 	 * @leave KErrXXX system wide error codes
       
   160 	 */
       
   161 	
       
   162 	IMPORT_C	static  CObexMtmFileNameExternaliser* NewL(CMsvSession* aSession, TMsvId aId);
       
   163 	
       
   164 	/**
       
   165 	 * Destructor. Will revert the stream to its original state if the store hasn't been comitted.
       
   166 	 */
       
   167 	
       
   168 	CObexMtmFileNameExternaliser::~CObexMtmFileNameExternaliser();
       
   169 
       
   170 	/**
       
   171 	 * Initialises the store of the given entry, ready for reading or writing.
       
   172 	 *
       
   173 	 * @param aId The TMsvId of the entry whose store should be initialised.
       
   174 	 * @leave KErrXXX system wide error codes.
       
   175 	 */
       
   176 	
       
   177 	IMPORT_C	void InitialiseStoreL(TMsvId aId);
       
   178 
       
   179 	/**
       
   180 	 * Externalises a single filename to the associated entry's message store.
       
   181 	 *
       
   182 	 * @param aFileName the filename to externalise.
       
   183 	 * @leave KErrXXX system-wide error codes.
       
   184 	 */
       
   185 
       
   186 	IMPORT_C  	void ExternaliseFileNameL(const TDesC16* aFileName);
       
   187 
       
   188 	/**
       
   189 	 * Externalises a pair consisting of a single filename and an obex header list to the associated entry's message store.
       
   190 	 *
       
   191 	 * @param aFileName the filename to externalise.
       
   192 	 * @param aHeaderList the header list to externalise.
       
   193 	 * @leave KErrXXX system-wide error codes.
       
   194 	 */
       
   195 
       
   196 	IMPORT_C  	void ExternaliseFileNameAndHeadersL(const TDesC16* aFileName, const CObexHeaderList* aHeaderList);
       
   197 
       
   198 	/**
       
   199 	 * Finalises and commits the store. This function MUST be called once all of the filenames have been externalised, and not
       
   200 	 * before. If it is not called, any changes will be lost and the store will revert to its former state.
       
   201 	 *
       
   202 	 * @leave KErrXXX system wide error codes.
       
   203 	 */
       
   204 	
       
   205 	IMPORT_C  	void CommitStoreL();
       
   206 
       
   207 private:
       
   208 	
       
   209 	/**
       
   210 	 * Constructor	
       
   211 	 *
       
   212 	 * @param aSession A messaging server session
       
   213 	 */
       
   214 	
       
   215 	CObexMtmFileNameExternaliser(CMsvSession* aSession);
       
   216 
       
   217 private:
       
   218 	CMsvSession*		iSession; //< Session with the message server
       
   219 	CMsvEntry*			iEntry; //< Message entry
       
   220 	CMsvStore*			iMessageStore; //< Direct interface to the message store associated with a particular entry
       
   221 	RMsvWriteStream		iMessageWriteStream; //< Accesses streams in a message store with write access
       
   222 	TBool				iHaveCommitted; //< Indicates whether the message write stream has committed changes
       
   223 	};
       
   224 
       
   225 #endif // __OBEXMTMUTIL_H__