epoc32/include/mw/msvstore.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 // Copyright (c) 1998-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 // MSVSTORE.H
    15 //
    16 /**
    17  * @file 
    18  * @publishedAll
    19  * @released
    20  */
    21 #if !defined(__MSVSTORE_H__)
    22 #define __MSVSTORE_H__
    23 
    24 #include <e32base.h>
    25 #include <s32file.h>
    26 #include <msvstd.h>
    27 
    28 class CMsvCachedStore;
    29 class CMsvBodyText;
    30 class CMsvAttachment;
    31 
    32 //**********************************
    33 // MMsvStoreObserver
    34 //**********************************
    35 //
    36 // 
    37 //
    38 
    39 class MMsvStoreObserver
    40 /** Observer interface to get events relating to a message store.
    41 
    42 This is used in the derivation of CMsvServerEntry and CMsvEntry.
    43 
    44 @publishedAll
    45 @released
    46 */
    47 	{
    48 public:
    49 /**
    50 Defines message store event types.
    51 
    52 @publishedAll
    53 @released
    54 */
    55 	enum TMsvStoreEvent {	/** A read-only message store was closed. */
    56 							EMsvReadStoreClosed,	// read only CMsvStore closed
    57 							/** An editable message store was closed. */
    58 							EMsvEditStoreClosed		// edit only CMsvStore closed
    59 							};	
    60 public:
    61 	/** Receives a message store event.
    62 
    63 	@param aEvent Event type
    64 	@param aId ID of the message to which the event relates
    65 	*/
    66 	virtual void HandleStoreEvent(TMsvStoreEvent aEvent, TMsvId aId)=0;
    67 	};
    68 
    69 
    70 //**********************************
    71 // CMsvStore
    72 //**********************************
    73 //
    74 // The entry structure that the client uses
    75 //
    76 
    77 /*
    78 Uid which are not needed to be known outside CMsvStore
    79 @publishedAll
    80 @released
    81 */
    82 const TUid KMsvEntryRichTextBody={0x10000F70};
    83 
    84 class MMsvAttachmentManager;
    85 class MMsvAttachmentManagerSync;
    86 class CMsvAttachmentManager;
    87 class MMsvStoreManager;
    88 class CMsvPlainBodyText;
    89 
    90 
    91 class CMsvStore : public CBase
    92 /** Provides an interface over the message store that is associated with a message 
    93 entry. It is similar to the dictionary store in supporting the concept of 
    94 streams referenced by UID. 
    95 
    96 This class is intended for use by MTM implementations. Message client applications 
    97 access the store through the higher-level functions provided by Client-side 
    98 and User Interface MTMs.
    99 
   100 A CMsvStore object is created by a CMsvEntry object and passed to a client 
   101 process. The client process then becomes responsible for deleting the CMsvStore 
   102 object. The store can be opened in two modes, read or edit, and only one CMsvStore 
   103 object can have edit access to a store. 
   104 
   105 CMsvStore provides functions for general manipulation of the store, and for 
   106 accessing the standard body text stream. RMsvReadStream and RMsvWriteStream 
   107 must be used to access other streams. 
   108 @publishedAll
   109 @released
   110 */
   111 	{
   112 public:
   113 	IMPORT_C ~CMsvStore();
   114 	//
   115 	IMPORT_C void StoreBodyTextL(const CRichText& aRichTextBody);
   116 	
   117 	IMPORT_C void RestoreBodyTextL(CRichText& aRichTextBody);
   118 	IMPORT_C void RestoreBodyTextL(CRichText& aRichTextBody, TUint aCharsetOverride);
   119 	
   120 	IMPORT_C void DeleteBodyTextL();
   121 	IMPORT_C TBool HasBodyTextL() const;
   122 	//
   123 	IMPORT_C void DeleteL(); // deletes the message store
   124 	IMPORT_C TInt SizeL(); // the size of the store
   125 	//
   126 	// The following give the Dictionary store interface
   127 	IMPORT_C TBool IsNullL() const;
   128 	IMPORT_C TBool IsPresentL(TUid aUid) const;
   129 	IMPORT_C void Remove(TUid aUid);
   130 	IMPORT_C void RemoveL(TUid aUid);
   131 	IMPORT_C void Revert();
   132 	IMPORT_C void RevertL();
   133 	IMPORT_C TInt Commit(); 
   134 	IMPORT_C void CommitL();
   135 
   136 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
   137 	IMPORT_C TBool IsDbStore();
   138 	void CommitHeaderL();
   139 #endif
   140 
   141 	// Attachment Management
   142 	IMPORT_C MMsvAttachmentManager& AttachmentManagerL();
   143 	IMPORT_C MMsvAttachmentManagerSync& AttachmentManagerExtensionsL();
   144 	
   145 	// APIs to get the CMsvPlainBodyText interface.
   146 	IMPORT_C CMsvPlainBodyText* InitialisePlainBodyTextForWriteL(TBool aIs8Bit, TUint aCharsetId, TUint aDefaultCharsetId);
   147 	IMPORT_C CMsvPlainBodyText* InitialisePlainBodyTextForReadL(TInt aChunkLength);
   148 
   149 	IMPORT_C void CreateShareProtectedAttachmentL(const TDesC& aFileName, RFile& aAttachmentFile, CMsvAttachment* aAttachmentInfo);
   150 	void Restore8BitBodyTextL(RFileReadStream& aInputStream);
   151 protected:
   152 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
   153 	IMPORT_C static CMsvStore* OpenForReadL(MMsvStoreObserver& aObserver, RFs& aFs, MMsvStoreManager& aStoreManager, TMsvId aId, TUid aMtmId);
   154 	IMPORT_C static CMsvStore* OpenForWriteL(MMsvStoreObserver& aObserver, RFs& aFs, MMsvStoreManager& aStoreManager, TMsvId aId, TUid aMtmId);
   155 #endif
   156 	IMPORT_C CMsvStore(MMsvStoreObserver& aObserver, RFs& aFs, TMsvId aId, MMsvStoreManager& aStoreManager);
   157 	IMPORT_C static CMsvStore* OpenForReadL(MMsvStoreObserver& aObserver, RFs& aFs, MMsvStoreManager& aStoreManager, TMsvId aId);
   158 	IMPORT_C static CMsvStore* OpenForWriteL(MMsvStoreObserver& aObserver, RFs& aFs, MMsvStoreManager& aStoreManager, TMsvId aId);
   159 	
   160 private:
   161 	
   162 	void ConstructL(TBool aReadOnly);
   163 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
   164 	void ConstructDbL(TUid aMtmId,TBool aReadOnly);
   165 	void RestoreL();
   166 	void LoadHeaderEntryL(const TUid aMtmId, TBool aUid);
   167 #endif
   168 
   169 	//Methods to handle plain bodytext.
   170 	void RestorePlainBodyTextL(CRichText& aRichText, TUint aCharsetOverride);
   171 	void GetRichTextFrom8BitL(RFile& aBodyTextFile, CRichText& aRichText, TUint aCharSet, TUint aDefaultCharSet);
   172 	void GetRichTextFrom16BitL(RFile& aBodyTextFile, CRichText& aRichText);
   173 	void Convert8BitToRichTextL(RFile& aBodyTextFile, CRichText& aRichText, TUint aCharSet, TUint aDefaultCharSet);
   174 
   175 	void Lock();
   176 	inline const CMsvCachedStore& Store() const;
   177 	inline CMsvCachedStore& Store();
   178 private:
   179 	enum {EMsvStoreUnlocked, EMsvStoreLocked} iLockStatus;
   180 
   181 	RFs& iFs;
   182 	MMsvStoreObserver& iObserver;
   183 	
   184 
   185 	const TMsvId iId;
   186 	CMsvCachedStore* iStore;
   187 	TBool iConstructed;
   188 	CMsvBodyText* iBodyText;
   189 	
   190 	MMsvStoreManager& iStoreManager;
   191 	CMsvAttachmentManager* iAttachmentManager;
   192 
   193 friend class CMsvEntry;
   194 friend class CMsvServerEntry;
   195 friend class RMsvReadStream;
   196 friend class RMsvWriteStream;
   197 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
   198 friend class TMsvWriteStore;
   199 friend class TMsvReadStore;
   200 #endif
   201 	};
   202 
   203 
   204 class RMsvReadStream : public RReadStream
   205 /** Accesses the streams in a message store with read access. 
   206 
   207 Before it is used, 
   208 a CMsvStore must have been opened on the message store with read or read/write 
   209 access.
   210 
   211 This class is intended for use by MTM implementations to store MTM-specific 
   212 information. Message client applications access the store through the higher-level 
   213 functions provided by Client-side and User Interface MTMs.
   214 
   215 Most of its functionality is provided by the base class RReadStream. 
   216 @publishedAll
   217 @released
   218 */
   219 	{
   220 public:
   221 	IMPORT_C void OpenL(const CMsvStore& aMsvStore, TUid aUid);
   222 	IMPORT_C void OpenLC(const CMsvStore& aMsvStore,TUid aUid);
   223 	void OpenLC(CMsvCachedStore& aStore,TUid aUid);
   224 	};
   225 
   226 
   227 class RMsvWriteStream : public RWriteStream
   228 /** Accesses the streams in a message store with write access, or creates new streams. 
   229 Before it is used, a CMsvStore must have been opened on the message store 
   230 with write access.
   231 
   232 This class is intended for use by MTM implementations to store MTM-specific 
   233 information. Message client applications access the store through the higher-level 
   234 functions provided by Client-side and User Interface MTMs.
   235 
   236 Most of its functionality is provided by the base class RWriteStream. 
   237 @publishedAll
   238 @released
   239 */
   240 	{
   241 public:
   242 	IMPORT_C void AssignLC(CMsvStore &aMsvStore, TUid aUid);
   243 	IMPORT_C void AssignL(CMsvStore &aMsvStore, TUid aUid);
   244 	void AssignLC(CMsvCachedStore &aStore, TUid aUid);
   245 	};
   246 
   247 
   248 
   249 #if (defined SYMBIAN_MESSAGESTORE_HEADER_BODY_USING_SQLDB)
   250 
   251 /** Accesses the message store with write access, or creates new header entry. 
   252 Before it is used, a CMsvStore must have been opened on the message store 
   253 with write access.
   254 
   255 This class is intended for use by MTM implementations to store MTM-specific 
   256 information. Message client applications access the store through the higher-level 
   257 functions provided by Client-side and User Interface MTMs.
   258 
   259 @publishedAll
   260 @released
   261 */
   262 class TMsvWriteStore
   263 	{
   264 public:	
   265 	IMPORT_C TMsvWriteStore(CMsvStore& aMsvStore);
   266 	IMPORT_C void AssignL(CHeaderFields* aHeaderFields);
   267 	IMPORT_C void CommitL();	
   268 public:
   269 	CMsvStore& iMsvStore;
   270 	};
   271 	
   272 /** Accesses the a message store with read access. 
   273 
   274 Before it is used, 
   275 a CMsvStore must have been opened on the message store with read or read/write 
   276 access.
   277 
   278 This class is intended for use by MTM implementations to store MTM-specific 
   279 information. Message client applications access the store through the higher-level 
   280 functions provided by Client-side and User Interface MTMs.
   281 
   282 @publishedAll
   283 @released
   284 */
   285 	
   286 class TMsvReadStore
   287 	{
   288 public:	
   289 	IMPORT_C TMsvReadStore(CMsvStore& aMsvStore, TUid aUid);
   290 	IMPORT_C void LoadL(CHeaderFields*& aHeaderFields);
   291 	IMPORT_C void ReadL(CHeaderFields*& aHeaderFields);
   292 public:
   293 	CMsvStore& iMsvStore;
   294 	TUid iUid;
   295 	};
   296 #endif
   297 
   298 #endif