examples/ForumNokia/S60_3rd_Edition_TextMTM_Example/modules/UiData/inc/txut.h

00001 // TXUT.H
00002 //
00003 // © 2004 Nokia Corporation.  All rights reserved.
00004 //
00005 
00006 #ifndef __TXUT_H__
00007 #define __TXUT_H__
00008 
00009 #include <e32std.h>
00010 #include <msvapi.h>             // TMsvId, CMsvOperation, CMsvSession
00011 
00012 
00013 // TextMTM UIDs
00014 LOCAL_D const TInt KUidMsgTypeTextValue = 0x10005247; 
00015 LOCAL_D const TUid KUidMsgTypeText = { KUidMsgTypeTextValue};
00016 LOCAL_D const TUid KTxtMtmTechnologyTypeUid     = { KUidMsgTypeTextValue};
00017 
00018 LOCAL_D const TUid KUidMsvMtmTextServerDLL      ={0x101FDA9C};
00019 LOCAL_D const TUid KUidMsvMtmTextClientDLL      ={0x101FDA9B};
00020 LOCAL_D const TUid KUidMsvMtmTextUiDLL          ={0x101FDA9D};
00021 LOCAL_D const TUid KUidMsvMtmTextUiDataDLL      ={0x101FDA9E};
00022 LOCAL_D const TUid KUidTextMtmVersion1          ={ KUidMsgTypeTextValue};
00023 
00024 // Constants
00025 LOCAL_D const TInt KUidTxtMTMSettingsValue = 0x1000525A; 
00026 LOCAL_D const TUid KUidTxtMTMSettings={KUidTxtMTMSettingsValue};
00027 LOCAL_D const TInt KMaxTextMessageSize = 0xFFFF;
00028 
00029 
00030 //
00031 //      TTxtProgress: Operation progress information
00032 //
00033 class TTxtProgress 
00034         {
00035 public:
00036         TInt            iTotalMsgs;
00037         TInt            iMsgsProcessed;
00038         TInt            iErrorCode;     // client side needs to be informed of an error
00039         TMsvId          iNewId;         // Used with CreateL, or any copy/move, storing the last moved message id.
00040         };
00041 
00042 //
00043 //  Package buffer of progress structure
00044 //
00045 typedef TPckgBuf<TTxtProgress> TTxtProgressBuf;
00046 
00047 //
00048 // TxtUtils: Generic static utility functions
00049 // 
00050 class TxtUtils
00051         {
00052 public: 
00053         // Build file name for associated entry, given its entry.
00054         IMPORT_C static void GetEntryFileNameL(TFileName& aFileName, TMsvEntry& aEntry);
00055     // Prepends the drive letter to aFileName found in aLocation 
00056     IMPORT_C static void FindFileL(const TDesC& aFileName, const TDesC& aLocation, TFileName& aRetVal);
00057         };
00058 
00059 //
00060 // TMTMTxtSettings: contains the settings for a service. It can be stored in the CMsvStore
00061 // associated with the service entry.
00062 //
00063 class TMTMTxtSettings 
00064         {
00065 public:
00066         IMPORT_C void StoreL(CMsvStore& aMsvStore) const;
00067         IMPORT_C void RestoreL(const CMsvStore& aMessageStore );
00068         IMPORT_C void ExternalizeL( RMsvWriteStream& aWriteStream ) const;
00069         IMPORT_C void InternalizeL( RMsvReadStream& aReadStream );
00070 
00071 public:
00072         TPtrC RootFolder() const;
00073         void SetRootFolder(const TDesC& aRootFolder);
00074 
00075 private:
00076         TFileName iRootFolder;
00077         };
00078 
00079 
00080 //
00081 // CMsvOpWait:
00082 //      Allows a synchronous wait on a operation
00083 //
00084 
00085 class CMsvOpWait: public CActive
00086         {
00087 public:
00088         IMPORT_C static CMsvOpWait* NewLC(TInt aPriority=EPriorityStandard);
00089         IMPORT_C ~CMsvOpWait();
00090         IMPORT_C void Start();
00091 
00092 protected:
00093         CMsvOpWait(TInt aPriority);
00094 
00095 protected:
00096     // from CActive
00097         virtual void RunL();
00098         virtual void DoCancel();
00099         };
00100 
00101 
00102 //
00103 // CMsvCompOperation: 
00104 //      An operation which is already completed on construction
00105 //
00106 class CMsvCompOperation : public CMsvOperation
00107         {
00108 public:
00109         IMPORT_C static CMsvCompOperation* NewL(CMsvSession& aMsvSession, TUid aMtm, const TDesC8& aProgress, TMsvId aService, TRequestStatus& aObserverRequestStatus, TInt aErr=KErrNone);
00110         IMPORT_C ~CMsvCompOperation();
00111 
00112 public:
00113     // from CMsvOperation
00114         virtual const TDesC8& ProgressL();
00115 
00116 private:
00117         CMsvCompOperation(CMsvSession& aSession, TRequestStatus& aObserverRequestStatus);
00118         void ConstructL(TUid aMtm, TInt aError, const TDesC8& aProgress, TMsvId aService);
00119 
00120 private:
00121         // from CActive
00122         virtual void DoCancel();
00123         virtual void RunL();
00124 
00125 private:
00126         HBufC8* iProgress;
00127         };
00128 
00129 
00130 //
00131 // inline implementations
00132 //
00133 inline void TMTMTxtSettings::SetRootFolder(const TDesC& aRootFolder) 
00134         {
00135         iRootFolder = aRootFolder;
00136         }
00137 
00138 inline TPtrC TMTMTxtSettings::RootFolder() const 
00139         { 
00140         return iRootFolder; 
00141         }
00142 
00143 class CRepository;
00144 
00149 class CMTMTxtSettings: public CBase
00150         {
00151 public:
00152         IMPORT_C static CMTMTxtSettings* NewL();
00153         ~CMTMTxtSettings();
00154         // load, save, and delete text mtm settings
00155         IMPORT_C void LoadSettingsL(TMsvId aServiceId, TMTMTxtSettings& aSettings) const;
00156         IMPORT_C void SaveSettingsL(TMsvId aServiceId, const TMTMTxtSettings& aSettings);
00157         IMPORT_C void DeleteSettingsL(TMsvId aServiceId);
00158         // handle a setting that specifies what the default service is
00159         IMPORT_C TMsvId DefaultServiceL() const;
00160         IMPORT_C void SetDefaultServiceL(TMsvId aService);
00161         IMPORT_C void DeleteDefaultServiceSettingL();
00162         
00163 private:
00164         void ConstructL();      
00165         void CreateOrSetL(TUint aKey, const TDesC& aValue);
00166         void CreateOrSetL(TUint aKey, TInt aValue);
00167         TUint32 FindAccountL(TMsvId aService) const;
00168         TUint GetNextAccountSlotL();
00169         void DeleteSettingL(TUint32 settingId);
00170         
00171 private:
00172         CRepository* iRepository;
00173         };
00174 #endif // __TXUT_H__
00175 

Generated by  doxygen 1.6.2