|
1 /* |
|
2 * Copyright (c) 2002-2007 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: Utility function for landmark database. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef POSLMDATABASEUTILITY_H |
|
21 #define POSLMDATABASEUTILITY_H |
|
22 |
|
23 #include <e32std.h> |
|
24 |
|
25 class CPosLmLocalDbAccess; |
|
26 class RDbNamedDatabase; |
|
27 |
|
28 _LIT(KPosLocalDbFileProtocol, "file://"); |
|
29 _LIT(KPosDbFileExtension, ".ldb"); |
|
30 |
|
31 /** |
|
32 * Utility function for landmark database. |
|
33 */ |
|
34 class PosLmDatabaseUtility |
|
35 { |
|
36 |
|
37 public: // New functions |
|
38 |
|
39 /** |
|
40 * Creates a correct database URI, |
|
41 * using format file://[drive]:[filename].ldb. |
|
42 * |
|
43 * Check that there is at least a [filename].ldb in incoming URI. |
|
44 * Adds file:// if not present in incoming URI. |
|
45 * If [drive]: is not present in incoming URI c: is set in |
|
46 * created URI. |
|
47 * |
|
48 * Leaves with @p KErrArgument if URI has wrong format. |
|
49 * |
|
50 * @param aDbUri A database URI. |
|
51 * @return A correct URI. |
|
52 */ |
|
53 IMPORT_C static HBufC* CreateDatabaseUriL( |
|
54 /* IN */ const TDesC& aDbUri |
|
55 ); |
|
56 |
|
57 /** |
|
58 * Validates a database URI, using format file://drive:filename.ldb. |
|
59 * |
|
60 * Return @p KErrArgument if URI is not valid. |
|
61 * |
|
62 * @param aDbUri A database URI. |
|
63 * @return Error code. |
|
64 */ |
|
65 IMPORT_C static TInt ValidateDatabaseUri( |
|
66 /* IN */ const TDesC& aDbUri |
|
67 ); |
|
68 |
|
69 /** |
|
70 * Removes the protocol (i.e. "file://") from the URI. This function |
|
71 * assumes that the protocol is present first in the specified URI. |
|
72 * |
|
73 * @param aUri A URI. On out it contains the URI without the protocol. |
|
74 */ |
|
75 IMPORT_C static void RemoveProtocolFromUriL( |
|
76 /* IN/OUT */ TPtrC& aDbUri |
|
77 ); |
|
78 |
|
79 /** |
|
80 * Single quote characters (') in the search text will be embedded by |
|
81 * using two single quote characters. |
|
82 * |
|
83 * The caller takes ownership of the returned string. |
|
84 * |
|
85 * @param aSearchText The search text. |
|
86 * @return The search text with embedded single quote characters. |
|
87 */ |
|
88 IMPORT_C static HBufC* EmbedSingleQuoteCharactersLC( |
|
89 /* IN */ const TDesC& aSearchText |
|
90 ); |
|
91 |
|
92 /** Returns number of rows in a table |
|
93 * @param aTableName Name of the table which rowcount is needed */ |
|
94 IMPORT_C static TUint GetTableRowCountL( |
|
95 CPosLmLocalDbAccess& aDbAccess, |
|
96 const TDesC& aTableName ); |
|
97 |
|
98 /** Checks whether given index exists on given table */ |
|
99 IMPORT_C static TBool IndexExistsL( |
|
100 const RDbNamedDatabase& aDatabase, |
|
101 const TDesC& aTable, |
|
102 const TDesC& aIndex ); |
|
103 |
|
104 private: |
|
105 |
|
106 /** |
|
107 * Verifies that a database URI is valid. |
|
108 * |
|
109 * @param aUriWoProtocol The database path set by a client, which |
|
110 * is the same as the URI without the protocol. |
|
111 * @param aDefaultDrive The default drive, or NULL if no drive |
|
112 * default drive should be set. |
|
113 * @param aPath Contains the full path including drive |
|
114 * but without protocol. This path is only set if this function |
|
115 * returns KErrNone. |
|
116 * @return KErrNone if valid, KErrArgument otherwise. |
|
117 */ |
|
118 static TInt VerifyUriIsValid( |
|
119 /* IN */ const TDesC& aUriWoProtocol, |
|
120 /* IN/OUT */ const TDesC* aDefaultDrive, |
|
121 /* OUT */ TFileName* aPath = NULL |
|
122 ); |
|
123 |
|
124 /** |
|
125 * Returns the URI without the protocol. Assumes there is a protocol |
|
126 * available. |
|
127 * |
|
128 * @param aDbUri A database URI. |
|
129 * @return Database URI without protocol. |
|
130 */ |
|
131 static TPtrC UriWithoutProtocol( |
|
132 /* IN */ const TDesC& aDbUri |
|
133 ); |
|
134 |
|
135 /** |
|
136 * Checks if the protocol is present first in the URI. |
|
137 * |
|
138 * @param aDbUri A database URI. |
|
139 * @return ETrue if the protocol is present. EFalse othwerwise. |
|
140 */ |
|
141 static TBool ProtocolPresent( |
|
142 /* IN */ const TDesC& aDbUri |
|
143 ); |
|
144 }; |
|
145 |
|
146 #endif // POSLMDATABASEUTILITY_H |
|
147 |