messagingfw/msgsrvnstore/server/inc/MSVREG.H
changeset 0 8e480a14352b
child 58 6c34d0baa0b1
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     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 // MSVREG.H
       
    15 //
       
    16 /**
       
    17  * @file 
       
    18  * @publishedAll
       
    19  * @released
       
    20  */
       
    21 
       
    22 #if !defined(__MSVREG_H__)
       
    23 #define __MSVREG_H__
       
    24 #if !defined(__E32BASE_H__)
       
    25 #include <e32base.h>
       
    26 #endif
       
    27 #if !defined(__F32FILE_H__)
       
    28 #include <f32file.h>
       
    29 #endif
       
    30 
       
    31 const TInt KHumanReadableNameLength=50;
       
    32 typedef TBuf<KHumanReadableNameLength> THumanReadableName;   //  could be used client side
       
    33 
       
    34 #define KMsvDefaultTimeoutMicroSeconds32 30000000
       
    35 
       
    36 // forward declarations
       
    37 class RWriteStream;
       
    38 class RReadStream;
       
    39 class RFs;
       
    40 
       
    41 
       
    42 class CMtmDllInfo : public CBase
       
    43 /** Encapsulates the registration data for a single concrete MTM component. 
       
    44 
       
    45 It is used in the creation of registration data for an MTM group. Typically, 
       
    46 an application gathers a number of CMtmDllInfo objects into an CMtmDllInfoArray. 
       
    47  
       
    48 @publishedAll
       
    49 @released
       
    50 */
       
    51 	{
       
    52 public:
       
    53 	IMPORT_C static CMtmDllInfo* NewL(const TDesC& aHumanReadableName,const TUidType& aUidType,const TDesC& aFilename,TInt aEntryPointOrdinalNumber,const TVersion aVersion);
       
    54 	IMPORT_C static CMtmDllInfo* NewL(const CMtmDllInfo& aMtmDllInfo);
       
    55 	IMPORT_C static CMtmDllInfo* NewL(RReadStream& aStream);
       
    56 	IMPORT_C ~CMtmDllInfo();
       
    57 	IMPORT_C void SetHumanReadableNameL(const TDesC& aHumanReadableName);
       
    58 	inline TPtrC HumanReadableName() const;
       
    59 	IMPORT_C void InternalizeL(RReadStream& aStream);
       
    60 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;  // not used but as it is exported it has been kept
       
    61 	IMPORT_C TBool operator==(const CMtmDllInfo& aMtmDllInfo) const; 
       
    62 	void SetMessagingCapability(TBool aCapability);
       
    63 	void SetSendBodyCapability(TBool aCapability);
       
    64 	void SetCapabilitiesAvailable(TBool aBool);
       
    65 	IMPORT_C TBool MessagingCapability() const;
       
    66 	IMPORT_C TBool SendBodyCapability() const;
       
    67 	IMPORT_C TBool CapabilitiesAvailable() const;
       
    68 	TPtrC FileName() const;
       
    69 private:
       
    70 	CMtmDllInfo();
       
    71 	CMtmDllInfo(const TUidType& aUidType,TInt aEntryPointOrdinalNumber,const TVersion aVersion);
       
    72 	CMtmDllInfo(const CMtmDllInfo& aMtmDllInfo);
       
    73 	void ConstructL(const TDesC& aHumanReadableName, const TDesC& aFilename);
       
    74 private:
       
    75 	HBufC* iHumanReadableName;         //  Should be less than KHumanReadableNameLength
       
    76 public:
       
    77 	/** Group of UIDs for the MTM. See NewL() for details. */
       
    78 	TUidType iUidType;                 //  Three uids
       
    79 	/** Ordinal of factory function for the MTM component */
       
    80 	TInt iEntryPointOrdinalNumber;
       
    81 	/** Version information for the MTM component */
       
    82 	TVersion iVersion;
       
    83 
       
    84 	/** Flag that indicates if the MTM can send messages */
       
    85 	TBool iMessagingCapability;
       
    86 	/** Flag that indicates if the MTM can handle body text */
       
    87 	TBool iSendBodyCapability;
       
    88 	/** Flag that indicates if settings have been made for the 
       
    89 	MessagingCapability() and SendBodyCapability() flags */	
       
    90 	TBool iCapabilitiesAvailable;
       
    91 private:
       
    92 	HBufC* iFilename;
       
    93 	};
       
    94 
       
    95 
       
    96 class CMtmDllInfoArray : public CArrayPtrFlat<CMtmDllInfo>
       
    97 /** Collects the registration data for concrete MTM components, as encapsulated 
       
    98 in CMtmDllInfo objects, into an array.
       
    99 
       
   100 Basic array functionality is provided by the base class CArrayPtrFlat<CMtmDllInfo>.
       
   101 
       
   102 It is used in the creation of registration data for an MTM group: see CMtmGroupData. 
       
   103 
       
   104 @publishedAll
       
   105 @released
       
   106 */
       
   107 	{
       
   108 public:
       
   109 	IMPORT_C CMtmDllInfoArray();
       
   110 	IMPORT_C ~CMtmDllInfoArray();
       
   111 	IMPORT_C void AddMtmDllInfoL(CMtmDllInfo* aMtmDllInfo);
       
   112 	};
       
   113 
       
   114 class TCapabilitySet;
       
   115 
       
   116 class CMtmGroupData : public CBase
       
   117 /** Encapsulates the registration data for an MTM group. 
       
   118 
       
   119 It is used to access and write the registration data file for an MTM group.
       
   120  
       
   121 @publishedAll
       
   122 @released
       
   123 */
       
   124 	{
       
   125 public:
       
   126 	IMPORT_C static CMtmGroupData* NewL(TUid aMtmTypeUid, TUid aTechnologyTypeUid,CMtmDllInfoArray* aMtmDllInfoArray, const TCapabilitySet& aMtmRequiredCaps);
       
   127 	IMPORT_C static CMtmGroupData* NewL(const CMtmGroupData& aMtmGroupData);
       
   128 	IMPORT_C static CMtmGroupData* NewL(RReadStream& aStream);
       
   129 	IMPORT_C ~CMtmGroupData();
       
   130 	IMPORT_C void InternalizeL(RReadStream& aStream);
       
   131 	IMPORT_C void ExternalizeL(RWriteStream& aStream) const;  // not used but as it is exported it has been kept
       
   132 	inline TUid MtmTypeUid() const;
       
   133 	inline TUid TechnologyTypeUid() const;
       
   134 	IMPORT_C const CMtmDllInfoArray& MtmDllInfoArray() const;
       
   135 	IMPORT_C const TCapabilitySet& GetMtmRequiredCapabilities() const;
       
   136 	IMPORT_C TBool operator==(const CMtmGroupData& aMtmGroupData) const;
       
   137 private:
       
   138 	CMtmGroupData(TUid aMtmTypeUid, TUid aTechnologyTypeUid, CMtmDllInfoArray* aMtmDllInfoArray, const TCapabilitySet& aMtmRequiredCaps);
       
   139 	void ConstructL(const CMtmGroupData& aMtmGroupData);
       
   140 	void ConstructL();
       
   141 	void AppendMtmDllInfoArrayL(const CMtmDllInfoArray& aMtmDllInfoArray);
       
   142 	CMtmDllInfoArray& MtmDllInfoArrayPrivate();
       
   143 	CMtmGroupData(TUid aMtmTypeUid=KNullUid,TUid aTechnologyTypeUid=KNullUid);
       
   144 	void AppendMtmDllInfoL(CMtmDllInfo* aMtmDllInfo);  // Leaves if second uid wrong
       
   145 private:
       
   146 	TUid iMtmTypeUid;
       
   147 	TUid iTechnologyTypeUid;
       
   148 	CMtmDllInfoArray* iMtmDllInfoArray;
       
   149 	TCapabilitySet iMtmRequiredCaps;
       
   150 	};
       
   151 
       
   152 
       
   153 class MRegisteredMtmDllObserver
       
   154 /** 
       
   155 @publishedAll
       
   156 @released
       
   157 */
       
   158 	{
       
   159 public:
       
   160 	virtual TInt UseMtmGroup(TUid aMtmTypeUid)=0;
       
   161 	virtual TInt ReleaseMtmGroup(TUid aMtmTypeUid)=0;
       
   162 	};
       
   163 
       
   164 
       
   165 //  Real non-derivable class
       
   166 
       
   167 class CRegisteredMtmDll : public CTimer
       
   168 /** Allows an MTM object to access registry information about itself.
       
   169  
       
   170 @publishedAll
       
   171 @released
       
   172 */
       
   173 	{
       
   174 public:
       
   175 	IMPORT_C static CRegisteredMtmDll* NewL(TUid aMtmTypeUid,TUid aTechnologyTypeUid,const CMtmDllInfo& aMtmDllInfo,const TTimeIntervalMicroSeconds32 aTimeoutMicroSeconds32,MRegisteredMtmDllObserver& aRegisteredMtmDllObserver);
       
   176 	IMPORT_C ~CRegisteredMtmDll();
       
   177 
       
   178 	inline TUid MtmTypeUid() const;
       
   179 	inline TUid TechnologyTypeUid() const;
       
   180 	inline const CMtmDllInfo& MtmDllInfo() const;
       
   181 
       
   182 	inline TInt MtmDllRefCount() const;
       
   183 
       
   184 	IMPORT_C TInt GetLibrary(RFs& aFs,RLibrary& aMtmDllLibrary);   // Increments reference count if successful or returns error 
       
   185 	IMPORT_C void ReleaseLibrary();                       // Decrements access count
       
   186 	                                                      // Should be called from destructor of any objects created from the library 
       
   187 private:
       
   188 	CRegisteredMtmDll(TUid aMtmTypeUid,TUid aTechnologyTypeUid,const TTimeIntervalMicroSeconds32 aTimeoutMicroSeconds32,MRegisteredMtmDllObserver& aRegisteredMtmDllObserver);
       
   189 	void ConstructL(const CMtmDllInfo& aMtmDllInfo);
       
   190 	void LoadLibraryL(RFs& aFs);   
       
   191 
       
   192 	void RunL();
       
   193 
       
   194 private:
       
   195 	TUid iMtmTypeUid;
       
   196 	TUid iTechnologyTypeUid;
       
   197 	CMtmDllInfo* iMtmDllInfo;
       
   198 	RLibrary iMtmDllLibrary;
       
   199 	TInt iMtmDllRefCount;
       
   200 	TTimeIntervalMicroSeconds32 iTimeoutMicroSeconds32;
       
   201 	MRegisteredMtmDllObserver& iRegisteredMtmDllObserver;
       
   202 	};
       
   203 
       
   204 
       
   205 
       
   206 class CRegisteredMtmDllArray : public CArrayPtrFlat<CRegisteredMtmDll>
       
   207 /**
       
   208 @publishedAll
       
   209 @released
       
   210 */
       
   211 	{
       
   212 public:
       
   213 	IMPORT_C CRegisteredMtmDllArray();
       
   214 	IMPORT_C ~CRegisteredMtmDllArray();
       
   215 	IMPORT_C void AddRegisteredMtmDllL(CRegisteredMtmDll* aRegisteredMtmDll);
       
   216 	};
       
   217 
       
   218 //  Base class
       
   219 
       
   220 class CMtmDllRegistry : public CBase
       
   221 /** Accesses the various MTM component registries. 
       
   222 
       
   223 The derived classes used by 
       
   224 clients are CClientMtmRegistry, CMtmUiDataRegistry, and CMtmUiRegistry. It 
       
   225 provides functions to discover the MTMs registered in such a registry. The 
       
   226 registered MTMs can be regarded as existing in a list: you can use NumRegisteredMtmDlls() 
       
   227 to get the number in the list, and MtmTypeUid() to index into it.
       
   228  
       
   229 @publishedAll
       
   230 @released
       
   231 */
       
   232 	{
       
   233 public:
       
   234 	IMPORT_C ~CMtmDllRegistry();
       
   235 
       
   236 	inline TInt NumRegisteredMtmDlls() const;
       
   237 	IMPORT_C TUid MtmTypeUid(TInt anIndex) const;                                
       
   238 
       
   239 	inline TBool IsPresent(TUid aMtmTypeUid) const;
       
   240 	IMPORT_C TUid TechnologyTypeUid(TUid aMtmTypeUid) const;
       
   241 	IMPORT_C const CMtmDllInfo& RegisteredMtmDllInfo(TUid aMtmTypeUid) const;                                
       
   242 	IMPORT_C TBool IsInUse(TUid aMtmTypeUid) const;        // returns true if specified DLL in use 
       
   243 	IMPORT_C TBool IsInUse() const;                        // returns true if any DLL in use 
       
   244 
       
   245 protected:
       
   246 	IMPORT_C CMtmDllRegistry(RFs& aFs,TUid aMtmDllTypeUid,TTimeIntervalMicroSeconds32 aTimeoutMicroSeconds32=KMsvDefaultTimeoutMicroSeconds32); 
       
   247 
       
   248 	IMPORT_C TInt MtmTypeUidToIndex(TUid anMtmTypeUid) const;
       
   249 
       
   250 	IMPORT_C TInt AddRegisteredMtmDll(TUid aMtmTypeUid,TUid aTechnologyTypeUid,const CMtmDllInfo& aMtmDllInfo,MRegisteredMtmDllObserver& aRegisteredMtmDllObserver); // returns error
       
   251 	IMPORT_C void RemoveRegisteredMtmDll(TUid aMtmTypeUid);         
       
   252 	IMPORT_C void RemoveAllRegisteredMtmDlls();                     
       
   253 
       
   254 private:
       
   255 	void DoAddRegisteredMtmDllL(TUid aMtmTypeUid,TUid aTechnologyTypeUid,const CMtmDllInfo& aMtmDllInfo,MRegisteredMtmDllObserver& aRegisteredMtmDllObserver); // returns error
       
   256 
       
   257 protected:
       
   258 	RFs& iFs;
       
   259 	TUid iMtmDllTypeUid;  //  Second Uid in all Dlls
       
   260 	CRegisteredMtmDllArray iRegisteredMtmDllArray;  // Inline CArray, OK because no NewL();
       
   261 	TTimeIntervalMicroSeconds32 iTimeoutMicroSeconds32;
       
   262 	};
       
   263 
       
   264 
       
   265 #include <msvreg.inl>
       
   266 
       
   267 #endif