|
1 // Copyright (c) 1997-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 // |
|
15 |
|
16 #if !defined(__DATASTOR_H__) |
|
17 #define __DATASTOR_H__ |
|
18 |
|
19 #if !defined(__E32BASE_H__) |
|
20 #include <e32base.h> |
|
21 #endif |
|
22 |
|
23 #if !defined(__S32FILE_H__) |
|
24 #include <s32file.h> |
|
25 #endif |
|
26 #if !defined(__APMSTD_H__) |
|
27 #include <apmstd.h> |
|
28 #endif |
|
29 |
|
30 class RReadStream; |
|
31 class RWriteStream; |
|
32 |
|
33 /** |
|
34 @internalComponent |
|
35 */ |
|
36 const TUid KUidDatastor = {0x1000071E}; |
|
37 |
|
38 /** |
|
39 @internalComponent |
|
40 */ |
|
41 const TUid KUidDatastorSettings = {0x10000790}; |
|
42 |
|
43 /** |
|
44 @internalComponent |
|
45 */ |
|
46 _LIT(KIniFileName,":\\private\\10003a3f\\Dtstor.ini"); |
|
47 |
|
48 /** |
|
49 @internalTechnology |
|
50 @released |
|
51 */ |
|
52 class TMappingDataTypeToApp |
|
53 { |
|
54 public: |
|
55 IMPORT_C TMappingDataTypeToApp(); |
|
56 IMPORT_C TMappingDataTypeToApp(const TDataType& aDataType, |
|
57 TDataTypePriority aPriority, TUid aAppUid); |
|
58 IMPORT_C TMappingDataTypeToApp(const TDataType& aDataType, |
|
59 TDataTypePriority aPriority, TUid aAppUid, TUid aServiceUid); |
|
60 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
61 IMPORT_C void ExternalizeL(RWriteStream& aStream) const; |
|
62 public: |
|
63 TDataType iDataType; |
|
64 TDataTypePriority iPriority; |
|
65 TUid iAppUid; // Uid [2] of the target application |
|
66 TUid iServiceUid; |
|
67 }; |
|
68 |
|
69 /** A store of mappings between data types, the UIDs of applications that |
|
70 can handle them and the priority at which the application handles them. |
|
71 |
|
72 @internalTechnology |
|
73 @released |
|
74 */ |
|
75 class CTypeStoreManager : public CBase |
|
76 { |
|
77 public: |
|
78 IMPORT_C static CTypeStoreManager* NewL(RFs& aFs); |
|
79 IMPORT_C ~CTypeStoreManager(); |
|
80 // Persistence |
|
81 IMPORT_C void StoreL(); |
|
82 IMPORT_C void RestoreL(); |
|
83 IMPORT_C void InternalizeL(RReadStream& aStream); |
|
84 IMPORT_C void ExternalizeL(RWriteStream& aStream) const; |
|
85 // Enquiry |
|
86 IMPORT_C void GetAppByDataType(const TDataType& aDataType, TUid& aUid) const; |
|
87 IMPORT_C void GetAppByDataType(const TDataType& aDataType, |
|
88 TUid aServiceUid, TUid& aUid) const; |
|
89 IMPORT_C void GetDataTypesByAppL(TUid aUid, CArrayFix<TDataType>* aTypeArray) const; |
|
90 IMPORT_C const CArrayFixFlat<TMappingDataTypeToApp>& MappingArray() const; |
|
91 // Management |
|
92 IMPORT_C void InsertDataMappingL(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid); |
|
93 IMPORT_C void InsertDataMappingL(const TDataType& aDataType, |
|
94 TDataTypePriority aPriority, TUid aUid, TUid aServiceUid); |
|
95 IMPORT_C TBool InsertIfHigherL(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid); |
|
96 IMPORT_C TBool InsertIfHigherL(const TDataType& aDataType, |
|
97 TDataTypePriority aPriority, TUid aUid, TUid aServiceUid); |
|
98 IMPORT_C void DeleteDataMapping(const TDataType& aDataType); |
|
99 IMPORT_C void DeleteDataMapping(const TDataType& aDataType, |
|
100 TUid aServiceUid); |
|
101 inline TPtrC IniFileName() const; |
|
102 IMPORT_C void InsertAndStoreDataMappingL(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid, TUid aServiceUid); |
|
103 IMPORT_C void InsertAndStoreDataMappingL(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid); |
|
104 IMPORT_C TBool InsertAndStoreIfHigherL(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid); |
|
105 IMPORT_C TBool InsertAndStoreIfHigherL(const TDataType& aDataType, TDataTypePriority aPriority, TUid aUid, TUid aServiceUid); |
|
106 IMPORT_C void DeleteAndStoreDataMappingL(const TDataType& aDataType); |
|
107 IMPORT_C void DeleteAndStoreDataMappingL(const TDataType& aDataType, TUid aServiceUid); |
|
108 IMPORT_C TBool DeleteApplicationDataMappings(const TUid aAppUid); |
|
109 |
|
110 private: |
|
111 CDictionaryStore* OpenIniFileLC() const; |
|
112 CTypeStoreManager(RFs& aFs); |
|
113 TInt FindDataMapping(const TDataType& aDataType, const TUid& aServiceUid) const; |
|
114 void ConstructL(); |
|
115 private: |
|
116 CArrayFixFlat<TMappingDataTypeToApp> iAppMappings; |
|
117 RFs& iFs; |
|
118 RBuf iIniFileName; |
|
119 }; |
|
120 |
|
121 inline TPtrC CTypeStoreManager::IniFileName() const |
|
122 { |
|
123 return iIniFileName; |
|
124 } |
|
125 |
|
126 #endif |