2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: CPosLmDatabaseManager class
20 #ifndef CPOSLMDATABASEMANAGER_H
21 #define CPOSLMDATABASEMANAGER_H
25 #include "EPos_TPosLmDatabaseEvent.h"
26 #include "EPos_TPosLmDatabaseSettings.h"
27 #include "EPos_HPosLmDatabaseInfo.h"
31 * This class is used to manage landmark databases.
33 * @p CPosLmDatabaseManager contains functions for listing registering,
34 * unregistering, creating, deleting, copying landmark databases, etc.
35 * It also has functions for managing the default landmark database. The
36 * client can listen to events related to database management.
38 * A database is local if it resides in the phone or in some device which
39 * is mapped to the phones file system. If a database is not local, it is
42 * The client refers to a database by URI. The URI consists of a protocol
43 * specifier and the database location: "protocol://location". If the
44 * client does not specify a protocol, "file://" is assumed.
46 * For local landmark databases, the URI consists of the drive and the
47 * database file name, e.g. "c:landmarks.ldb". The path cannot be specified
48 * by the client. The extension of the database file name must be "ldb".
49 * If a path is included or if the file name extension is not .ldb",
50 * the client receives the error code @p KErrArgument. For local landmark
51 * databases, the client receives the error code @p KErrBadName if the
52 * file name is invalid and @p KErrNotReady if the drive specified in the URI
55 * If the client specifies a local database URI and does not specify the drive
56 * letter, e.g. "landmarks.ldb", default database drive is assumed.
58 * Local databases are created by calling @ref CreateDatabaseL. "Bookmarks"
59 * to remote databases are created by calling @ref RegisterDatabaseL. After
60 * this they are listed by the database manager.
62 * If @ref CPosLmDatabaseManager is used, the client must call the global
63 * function @ref ReleaseLandmarkResources before terminating, in order to
64 * release all used landmark resources, otherwise the client may receive
67 * @lib eposlmdbmanlib.lib
70 class CPosLmDatabaseManager : public CBase
75 * Two-phased constructor.
77 * This function requires @p ReadUserData capability.
79 IMPORT_C static CPosLmDatabaseManager* NewL();
84 IMPORT_C virtual ~CPosLmDatabaseManager();
89 * Retrieves the URI of the default landmark database.
91 * The default landmark database is the one which is opened when calling
92 * @p CPosLandmarkDatabase::OpenL without any parameters.
94 * Only "file"-protocol databases can be set as default.
96 * This function requires @p ReadUserData capability.
98 * @return The URI of the default landmark database. The client takes
99 * ownership of the descriptor object.
101 virtual HBufC* DefaultDatabaseUriLC() = 0;
104 * Sets a landmark database as default.
106 * This database is opened the next time
107 * @p CPosLandmarkDatabase::OpenL() called without parameters.
109 * To move the current default database to another drive, first use
110 * @ref CopyDatabaseL to copy the database to the new drive, then use
111 * @ref SetDefaultDatabaseUriL to set the new database as default and
112 * finally, use @ref DeleteDatabaseL if the old default database should
115 * Only "file"-protocol databases can be set as default.
117 * This function requires @p WriteDeviceData capability.
119 * @param[in] aDatabaseUri The URI of the database which should be set as
121 * @leave KErrNotSupported The protocol specified something else
122 * than "file://" as protocol in the URI.
123 * @leave KErrArgument The URI is incorrect.
124 * @leave KErrNotFound The landmark database which should be set as default
127 virtual void SetDefaultDatabaseUriL( const TDesC& aDatabaseUri ) = 0;
130 * Listens for database management events.
132 * This function is asynchronous and it completes the request
133 * status when an event occurs. At this time, the client can read
134 * event information from the retrieved event object.
136 * Event listening can be canceled by calling
137 * @ref CancelNotifyDatabaseEvent.
139 * This function requires @p ReadUserData capability.
141 * @param[out] aEvent Contains the event information when an event
142 * occurs (request completes).
143 * @param[out] aStatus Is completed with @p KErrNone if an event
144 * occurs or an error code if some error is encountered.
146 virtual void NotifyDatabaseEvent(
147 TPosLmDatabaseEvent& aEvent,
148 TRequestStatus& aStatus
152 * Cancels a call to @ref NotifyDatabaseEvent.
154 * @return @p KErrNone if the request was successfully cancelled,
155 * otherwise a system wide error code.
157 virtual TInt CancelNotifyDatabaseEvent() = 0;
160 * Retrieves the database URI associated with the last event.
162 * Some events, e.g. @p EPosLmDbDatabaseRegistered and
163 * @p EPosLmDbDatabaseUnregistered, refer to a specific database. The
164 * URI of the database can be retrieved through this function.
166 * If the URI should be retrieved, this function must be called before
167 * @ref NotifyDatabaseEvent is called again to listen for the next
170 * This function requires @p ReadUserData capability.
172 * @return The database URI associated with the event. The client takes
173 * ownership of the descriptor object.
174 * @leave KErrNotFound There is no database URI associated with the event
175 * or, the database URI has been discarded because the client has called
176 * @ref NotifyDatabaseEvent again.
178 virtual HBufC* DatabaseUriFromLastEventLC() = 0;
181 * Lists the URIs to all landmark databases known by the Landmarks
184 * The client can specify a protocol string as input to this function.
185 * The function then only returns a list of the databases which
186 * are accessed through this protocol.
188 * The client takes ownership of the returned array.
190 * If no databases are found, an empty array is returned.
192 * This function requires @p ReadUserData capability.
194 * @param[in] aProtocol The protocol for which database URIs should be
195 * listed. If no protocol is specified, i.e. if an empty string is
196 * specified, all known database URIs are listed.
197 * @return The list of database URIs.
198 * @leave KErrNotSupported The protocol is not supported in the platform.
200 virtual CDesCArray* ListDatabasesLC( const TDesC& aProtocol = KNullDesC ) = 0;
203 * Lists information about each landmark database known by the Landmarks
206 * The client can specify a protocol string as input to this function.
207 * The function then only returns information about the databases
208 * which are accessed through this protocol.
210 * The client specifies an array which is populated by this function.
211 * The client takes ownership of all information objects in the array.
213 * If no databases are found, an empty array is returned.
215 * This function requires @p ReadUserData capability.
217 * @param[out] aDatabaseInfoArray On return, contains information about
218 * the landmark databases. Any objects which are in the array when
219 * it is passed to this function are not removed.
220 * @param[in] aProtocol The protocol for which database URIs should be
221 * listed. If no protocol is specified, i.e. if an empty string is
222 * specified, all known database URIs are listed.
223 * @leave KErrNotSupported The protocol is not supported in the platform.
225 virtual void ListDatabasesL(
226 RPointerArray<HPosLmDatabaseInfo>& aDatabaseInfoArray,
227 const TDesC& aProtocol = KNullDesC
231 * Registers a landmark database.
233 * The landmark database is then returned when listing landmark
236 * For local landmark databases, this function leaves with error code
237 * @p KErrNotSupported. To add a local database, the client must call
238 * @ref CreateDatabaseL.
240 * The client supplies an information object containing the URI of the
241 * database to register. The information object can also contain
242 * database settings, e.g. a display name for the database.
244 * This function requires @p ReadUserData and @p WriteUserData
247 * @param[in,out] aDatabaseInfo Information about the landmark database to
248 * register. The information object will be updated with
249 * media type and drive information.
251 * @leave KErrNotSupported The protocol specified in the URI is not
252 * supported in the platform or the protocol does not allow
253 * registering landmark databases.
254 * @leave KErrArgument The URI is incorrect.
255 * @leave KErrAlreadyExists The database already exists in the registry.
257 virtual void RegisterDatabaseL( HPosLmDatabaseInfo& aDatabaseInfo ) = 0;
260 * Unregisters a landmark database.
262 * After this, the landmark database is not returned when listing
263 * landmark databases.
265 * For local landmark databases, this function leaves with error code
266 * @p KErrNotSupported. To remove a local database, the client must call
267 * @ref DeleteDatabaseL.
269 * This function requires @p ReadUserData and @p WriteUserData
272 * @param[in] aDatabaseUri The URI of the database to register.
274 * @leave KErrNotSupported The protocol specified in the URI is not
275 * supported in the platform or the protocol does not allow
276 * unregistering landmark databases.
277 * @leave KErrArgument The URI is incorrect.
279 virtual void UnregisterDatabaseL( const TDesC& aDatabaseUri ) = 0;
282 * Unregisters all landmark database which are accessed through a
285 * After this, the landmark databases are not be returned when listing
286 * landmark databases.
288 * For local landmark databases, this function leaves with error code
289 * @p KErrNotSupported. To remove a local database, the client must call
290 * @ref DeleteDatabaseL.
292 * This function requires @p ReadUserData and @p WriteUserData
295 * @param[in] aProtocol The protocol to unregister all databases for.
297 * @leave KErrNotSupported The protocol is not supported in the platform
298 * or the protocol does not allow unregistering landmark databases.
299 * @leave KErrArgument The protocol is an empty string.
301 virtual void UnregisterAllDatabasesL( const TDesC& aProtocol ) = 0;
304 * Modifies the settings for a landmark database.
306 * This function requires @p ReadUserData and @p WriteUserData
309 * @param[in] aDatabaseUri The URI of the database to modify settings for.
310 * @param[in] aDatabaseSettings The new settings for the database.
312 * @leave KErrNotSupported The protocol specified in the URI is not
313 * supported in the platform.
314 * @leave KErrNotFound The specified database is not found.
315 * @leave KErrArgument The URI is incorrect.
317 virtual void ModifyDatabaseSettingsL(
318 const TDesC& aDatabaseUri,
319 const TPosLmDatabaseSettings& aDatabaseSettings
323 * Retrieve information about a landmark database.
325 * This function requires @p ReadUserData capability.
327 * @param[in,out] aDatabaseInfo An information object containing the URI of the
328 * landmark database. On return, the object contains information about
329 * the landmark database, including any database settings.
331 * @leave KErrNotSupported The protocol specified in the URI is not
332 * supported in the platform.
333 * @leave KErrNotFound The specified database is not found.
334 * @leave KErrArgument The URI is incorrect.
336 virtual void GetDatabaseInfoL( HPosLmDatabaseInfo& aDatabaseInfo ) = 0;
339 * Checks if the specified landmark database exists.
341 * The database to check is specified by passing a URI to this function.
342 * URI construction is described in the class description for
343 * @ref CPosLmDatabaseManager. The URI must point to a database which is
344 * handled by this database manager, i.e. not a remote location.
346 * This function requires @p ReadUserData capability. If the database is
347 * remote, @p NetworkServices capability is also needed.
349 * @param[in] aDatabaseUri The URI of the database which should be checked
351 * @return @p ETrue if the database exists, otherwise @p EFalse.
353 * @leave KErrNotSupported The protocol specified in the URI is not
355 * @leave KErrArgument The URI is incorrect.
357 virtual TBool DatabaseExistsL( const TDesC& aDatabaseUri ) = 0;
360 * Creates a landmark database.
362 * This function requires @p ReadUserData and @p WriteUserData
363 * capabilities. If the database is remote, @p NetworkServices
364 * capability is also needed.
366 * @param aDatabaseInfo Information about the landmark database to
367 * create. The information object will be updated with
368 * media type and drive information.
370 * @leave KErrNotSupported The protocol specified in the URI is not
372 * @leave KErrArgument The URI is incorrect.
373 * @leave KErrAlreadyExists There is already a database at this URI.
375 virtual void CreateDatabaseL( HPosLmDatabaseInfo& aDatabaseInfo ) = 0;
378 * Deletes a landmark database.
380 * The database to delete is specified by passing a URI to this
381 * function. URI construction is described in the class description for
382 * @ref CPosLmDatabaseManager.
384 * If the specified database does not exist, the call is ignored.
386 * This function requires @p ReadUserData and @p WriteUserData
387 * capabilities. If the database is remote, @p NetworkServices
388 * capability is also needed.
390 * @param aDatabaseUri The URI of the database to delete.
392 * @leave KErrNotSupported The protocol specified in the URI is not
394 * @leave KErrArgument The URI is incorrect.
395 * @leave KErrInUse The database is in use by some client.
396 * @leave KErrAccessDenied The database is read-only.
398 virtual void DeleteDatabaseL( const TDesC& aDatabaseUri ) = 0;
401 * Copies a landmark database to a new location.
403 * Database locations are specified as URIs. URI construction is
404 * described in the class description for @ref CPosLmDatabaseManager.
405 * Target URI protocol must be the same as source URI protocol.
407 * This function requires @p ReadUserData and @p WriteUserData
408 * capabilities. If the databases are remote, @p NetworkServices
409 * capability is also needed.
411 * @param[in] aSourceUri The URI of the database to copy.
412 * @param[in] aTargetUri The URI of the new database location.
414 * @leave KErrNotSupported The protocol specified in the a URI is not
416 * @leave KErrArgument A URI is incorrect.
417 * @leave KErrAlreadyExists There is already a database at the target URI.
418 * @leave KErrInUse There is a write-lock on the database, e.g. some client
419 * is currently modifying the database.
420 * @leave KErrNotFound There is no database at the source URI.
422 virtual void CopyDatabaseL(
423 const TDesC& aSourceUri,
424 const TDesC& aTargetUri
430 IMPORT_C CPosLmDatabaseManager();
434 // Prohibit copy constructor
435 CPosLmDatabaseManager( const CPosLmDatabaseManager& );
436 // Prohibit assigment operator
437 CPosLmDatabaseManager& operator= ( const CPosLmDatabaseManager& );
441 // Implementation Uid
445 #endif // CPOSLMDATABASEMANAGER_H