|
1 /* |
|
2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: HPosLmDatabaseInfo class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef HPOSLMDATABASEINFO_H |
|
21 #define HPOSLMDATABASEINFO_H |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <f32file.h> |
|
25 #include "EPos_TPosLmDatabaseSettings.h" |
|
26 |
|
27 /** |
|
28 * @ref HPosLmDatabaseInfo encapsulates information about a landmark database. |
|
29 * |
|
30 * @lib eposlmdbmanlib.lib |
|
31 * @since S60 3.0 |
|
32 */ |
|
33 class HPosLmDatabaseInfo |
|
34 { |
|
35 public: |
|
36 |
|
37 /** |
|
38 * Two-phased constructor. |
|
39 * |
|
40 * @param[in] aDatabaseUri The URI of the landmark database. |
|
41 * @return A new instance of this class. |
|
42 */ |
|
43 IMPORT_C static HPosLmDatabaseInfo* NewLC( const TDesC& aDatabaseUri ); |
|
44 |
|
45 /** |
|
46 * Two-phased constructor. |
|
47 * |
|
48 * @param[in] aDatabaseUri The URI of the landmark database. |
|
49 * @return A new instance of this class. |
|
50 */ |
|
51 IMPORT_C static HPosLmDatabaseInfo* NewL( const TDesC& aDatabaseUri ); |
|
52 |
|
53 /** |
|
54 * Two-phased copy constructor. |
|
55 * |
|
56 * @param[in] aDatabaseInfo The information instance to copy. |
|
57 * @return A new instance of this class. |
|
58 */ |
|
59 IMPORT_C static HPosLmDatabaseInfo* NewLC( |
|
60 const HPosLmDatabaseInfo& aDatabaseInfo |
|
61 ); |
|
62 |
|
63 /** |
|
64 * Two-phased copy constructor. |
|
65 * |
|
66 * @param[in] aDatabaseInfo The information instance to copy. |
|
67 * @return A new instance of this class. |
|
68 */ |
|
69 IMPORT_C static HPosLmDatabaseInfo* NewL( |
|
70 const HPosLmDatabaseInfo& aDatabaseInfo |
|
71 ); |
|
72 |
|
73 |
|
74 public: |
|
75 |
|
76 /** |
|
77 * Retrieves the database URI. |
|
78 * |
|
79 * @return A pointer to the URI descriptor. This pointer is valid until |
|
80 * the @ref HPosLmDatabaseInfo object is destroyed. |
|
81 */ |
|
82 IMPORT_C TPtrC DatabaseUri() const; |
|
83 |
|
84 /** |
|
85 * Returns the protocol part from the URI which is set. |
|
86 * |
|
87 * Example: If the URI is "file://c:landmarks.ldb" then the protocol is |
|
88 * "file". |
|
89 * |
|
90 * If no protocol is specified, an empty descriptor is returned. This |
|
91 * implies "file" protocol. |
|
92 * |
|
93 * @return A pointer to the protocol descriptor. This pointer is valid |
|
94 * until the @ref HPosLmDatabaseInfo object is destroyed. |
|
95 */ |
|
96 IMPORT_C TPtrC Protocol() const; |
|
97 |
|
98 /** |
|
99 * Returns whether the database is the default database. |
|
100 * |
|
101 * Note: that this attribute is only set if the @ref HPosLmDatabaseInfo |
|
102 * instance has been returned from a @ref CPosLmDatabaseManager |
|
103 * function, e.g. @ref CPosLmDatabaseManager::ListDatabasesL, |
|
104 * @ref CPosLmDatabaseManager::GetDatabaseInfoL, |
|
105 * @ref CPosLmDatabaseManager::RegisterDatabaseL, |
|
106 * @ref CPosLmDatabaseManager::CreateDatabaseL or |
|
107 * @ref CPosLmDatabaseManager::ModifyDatabaseSettingsL. If not, this |
|
108 * function returns @p EFalse. |
|
109 * |
|
110 * @return @p ETrue if the database is the default one, otherwise @p EFalse. |
|
111 */ |
|
112 IMPORT_C TBool IsDefault() const; |
|
113 |
|
114 /** |
|
115 * Returns which storage media the database resides in. |
|
116 * |
|
117 * Note: this attribute is only set if the @ref HPosLmDatabaseInfo |
|
118 * instance has been returned from a @ref CPosLmDatabaseManager |
|
119 * function, e.g. @ref CPosLmDatabaseManager::ListDatabasesL, |
|
120 * @ref CPosLmDatabaseManager::GetDatabaseInfoL, |
|
121 * @ref CPosLmDatabaseManager::RegisterDatabaseL, |
|
122 * @ref CPosLmDatabaseManager::CreateDatabaseL or |
|
123 * @ref CPosLmDatabaseManager::ModifyDatabaseSettingsL. If not, this |
|
124 * function returns @p EMediaUnknown. |
|
125 * |
|
126 * @return The storage media the database resides in. |
|
127 */ |
|
128 IMPORT_C TMediaType DatabaseMedia() const; |
|
129 |
|
130 /** |
|
131 * Returns which database drive the database resides in. |
|
132 * |
|
133 * Note: that this attribute is only set if the @ref HPosLmDatabaseInfo |
|
134 * instance has been returned from a @ref CPosLmDatabaseManager |
|
135 * function, e.g. @ref CPosLmDatabaseManager::ListDatabasesL, |
|
136 * @ref CPosLmDatabaseManager::GetDatabaseInfoL, |
|
137 * @ref CPosLmDatabaseManager::RegisterDatabaseL, |
|
138 * @ref CPosLmDatabaseManager::CreateDatabaseL or |
|
139 * @ref CPosLmDatabaseManager::ModifyDatabaseSettingsL. If not, this |
|
140 * function returns 0. |
|
141 * |
|
142 * If database drive is not applicable for the database, e.g. the |
|
143 * database is remote, this function returns 0. |
|
144 * |
|
145 * @return The drive letter for the drive where the database resides, or |
|
146 * 0 if the letter is not set. |
|
147 */ |
|
148 IMPORT_C TChar DatabaseDrive() const; |
|
149 |
|
150 /** |
|
151 * Retrieve a const reference to the database settings. |
|
152 * |
|
153 * The const reference can be used to read the database settings. |
|
154 * |
|
155 * @returns Const reference to the database settings |
|
156 */ |
|
157 IMPORT_C const TPosLmDatabaseSettings& Settings() const; |
|
158 |
|
159 /** |
|
160 * Retrieve a reference to the database settings. |
|
161 * |
|
162 * The reference can be used to read and write to the database settings. |
|
163 * |
|
164 * @returns Reference to the database settings |
|
165 */ |
|
166 IMPORT_C TPosLmDatabaseSettings& Settings(); |
|
167 |
|
168 /** |
|
169 * Returns the size in bytes of this object. |
|
170 * |
|
171 * @returns The size of this object. |
|
172 */ |
|
173 IMPORT_C TInt Size() const; |
|
174 |
|
175 /** |
|
176 * @internal */ |
|
177 /* |
|
178 * Sets the default database indicator flag. |
|
179 * This flag is used to indicate if the database described by the |
|
180 * object is the default database. |
|
181 * |
|
182 * @param[in] aIsDefault @p ETrue if the database is the default database, |
|
183 * otherwise @p ETrue. |
|
184 */ |
|
185 void SetDefault( TBool aIsDefault ); |
|
186 |
|
187 /** |
|
188 * @internal */ |
|
189 /* |
|
190 * Sets the database media type. |
|
191 * |
|
192 * @param[in] aMediaType The media type. |
|
193 */ |
|
194 void SetMediaType( TMediaType aMediaType ); |
|
195 |
|
196 /** |
|
197 * @internal */ |
|
198 /* |
|
199 * Sets the database drive. |
|
200 * |
|
201 * @param[in] aDatabaseDrive The database drive letter. |
|
202 */ |
|
203 void SetDatabaseDrive( TChar aDatabaseDrive ); |
|
204 |
|
205 private: |
|
206 |
|
207 // C++ constructor. |
|
208 HPosLmDatabaseInfo(const TDesC& aDatabaseUri); |
|
209 |
|
210 // C++ copy constructor. |
|
211 HPosLmDatabaseInfo(const HPosLmDatabaseInfo& aDatabaseInfo); |
|
212 |
|
213 // Allocates memory for URI descriptor during construction. |
|
214 static TAny* AllocateL(const TDesC& aDatabaseUri); |
|
215 |
|
216 // Sets URI descriptor during construction. |
|
217 void SetDatabaseUri(const TDesC& aDatabaseUri); |
|
218 |
|
219 // Calculates buffer offset so that buffer is 4-byte aligned |
|
220 static TInt BufferOffset(); |
|
221 |
|
222 // Prohibit assigment operator |
|
223 HPosLmDatabaseInfo& operator= ( const HPosLmDatabaseInfo& ); |
|
224 |
|
225 private: |
|
226 |
|
227 TPosLmDatabaseSettings iSettings; |
|
228 TMediaType iDatabaseMedia; |
|
229 TChar iDatabaseDrive; |
|
230 TBool iIsDefault; |
|
231 TUint8 iBuffer[1]; // Must be at end of class |
|
232 |
|
233 }; |
|
234 |
|
235 #endif // HPOSLMDATABASEINFO_H |
|
236 |
|
237 |