17 */ |
17 */ |
18 |
18 |
19 #ifndef __MAPTILEDBLOOKUPTABLE_H__ |
19 #ifndef __MAPTILEDBLOOKUPTABLE_H__ |
20 #define __MAPTILEDBLOOKUPTABLE_H__ |
20 #define __MAPTILEDBLOOKUPTABLE_H__ |
21 |
21 |
22 //Headers needed |
22 // DLL_EXPORT macro definition |
23 #include <f32file.h> //RFs |
23 #ifdef MAPTILESERVICEDLL |
24 #include <d32dbms.h> //RDbNamedDatabase,RDbView |
24 #define MAPTILESERVICE_EXPORT Q_DECL_EXPORT |
|
25 #else |
|
26 #define MAPTILESERVICE_EXPORT Q_DECL_IMPORT |
|
27 #endif |
25 |
28 |
26 #include "mylocationsdefines.h" |
29 #include <locationservicedefines.h> |
|
30 |
|
31 // forward declarations |
|
32 class QSqlDatabase; |
|
33 |
|
34 |
|
35 |
27 /** |
36 /** |
28 * CLookupMapTileDatabase class. |
37 * LookupMapTileDatabase class. |
29 * This class handles all the operations related to maptile lookup database. |
38 * This class handles all the operations related to maptile lookup database. |
30 * |
39 * |
31 */ |
40 */ |
32 class CLookupMapTileDatabase : public CBase |
41 class MAPTILESERVICE_EXPORT LookupMapTileDatabase : public QObject |
33 { |
42 { |
34 public: |
43 public: |
35 |
44 |
36 /** |
45 /** |
37 * This is a static function, which creates and returns an instance of this class. |
46 * Constructor |
38 */ |
47 */ |
39 static CLookupMapTileDatabase* NewL( const TDesC& aLookupTableName ); |
48 LookupMapTileDatabase( QObject *parent = 0 ); |
40 |
|
41 /** |
|
42 * This is a static function, which creates and returns an instance of this class. |
|
43 * Pushes the created object to the cleanup stack. |
|
44 */ |
|
45 static CLookupMapTileDatabase* NewLC( const TDesC& aLookupTableName ); |
|
46 |
49 |
47 /** |
50 /** |
48 * Destructor |
51 * Destructor |
49 */ |
52 */ |
50 ~CLookupMapTileDatabase(); |
53 ~LookupMapTileDatabase(); |
|
54 |
|
55 /** |
|
56 * Opens the lookup database. |
|
57 */ |
|
58 bool open(); |
|
59 |
|
60 /** |
|
61 * Closes the lookup database. |
|
62 */ |
|
63 void close(); |
|
64 |
51 |
65 |
52 public: |
66 public: |
|
67 |
|
68 |
|
69 /** |
|
70 * Creates an entry in the lookup table. |
|
71 * @param[in] aLookupItem The lookup item to be created in the database. |
|
72 */ |
|
73 void createEntry( const MaptileLookupItem& aLookupItem ); |
|
74 |
|
75 /** |
|
76 * Updates an entry in the lookup table. |
|
77 * @param[in] aLookupItem The lookup item to be updated in the database. |
|
78 */ |
|
79 void updateEntry( const MaptileLookupItem& aLookupItem ); |
|
80 |
|
81 /** |
|
82 * Updates the user setting of an calendar entry in the lookup table. |
|
83 * @param[in] aLookupItem The lookup item to be updated in the database. |
|
84 */ |
|
85 void updateUserSetting( const MaptileLookupItem& aLookupItem ); |
|
86 /** |
|
87 * Deletes an entry from the lookup table. |
|
88 * @param[in] aLookupItem The lookup item to be deleted from the database. |
|
89 */ |
|
90 void deleteEntry( MaptileLookupItem& aLookupItem ); |
|
91 |
|
92 /** |
|
93 * Deletes maptile from the repository if the ref to that maptile in the db reaches one |
|
94 * @param[in] aLookupItem The lookup item containing the path to the maptile |
|
95 */ |
|
96 void deleteMapTile( const MaptileLookupItem& aLookupItem ); |
|
97 |
|
98 |
|
99 /** |
|
100 * Gets an entry from the lookup table. |
|
101 * @param[in/out] aLookupItem The lookup item to be fetched from the database. |
|
102 * The source iUid and type is passed in the lookup item. If the item is found the aLookupItem remaining fields are updated. |
|
103 * @return true if the item is found. |
|
104 */ |
|
105 bool getEntry( MaptileLookupItem& aLookupItem ); |
|
106 |
|
107 /** |
|
108 * Gets the list of calendar ids. |
|
109 * @param[out] aIdArray Calendar id list |
|
110 */ |
|
111 void getAllCalendarIds( QList<quint32>& aIdArray ); |
|
112 |
|
113 /** |
|
114 * ReSet the entry in the lookup table , with null value |
|
115 * @param aLookupItem The lookup item entry to be reseted in the database, |
|
116 * get the used maptile path as part of lookupItem filepath , to free the resource |
|
117 */ |
|
118 void resetEntry( MaptileLookupItem &aLookupItem ); |
53 |
119 |
54 /** |
120 /** |
55 * Finds an entry in the lookup table. |
121 * Finds an entry in the lookup table. |
56 * @param[in/out] aLookupItem The lookup item to be found in the database. |
122 * @param[in] aLookupItem The lookup item to be found in the database. |
57 * The source iUid is passed in the lookup item |
123 * The source iUid and type is passed in the lookup item |
|
124 * @return true if the item is found. |
58 */ |
125 */ |
59 void FindEntryL( TLookupItem& aLookupItem ); |
126 bool findEntry( const MaptileLookupItem& aLookupItem ); |
60 |
127 |
61 /** |
128 /** |
62 * Finds the number of address present in db associated with the aId. |
129 * Finds the number of address present in db associated with the aId. |
63 * @param id, entry (calendar/contact) uid. |
130 * @param id, entry (calendar/contact) uid. |
64 * @return Number of address a contact has. |
131 * @return Number of address a contact has. |
65 */ |
132 */ |
66 int FindNumberOfAddressL( int& aId ); |
133 int findNumberOfAddress( int& aId ); |
67 |
134 |
68 private: |
135 /** |
69 |
136 * Finds an entry in the lookup table for the given maptile name. |
70 // default constructor |
137 * @param[in] aFilePath The lookup item to be found in the database. maptile file path is passed |
71 CLookupMapTileDatabase(); |
138 * @return ETrue if found, else EFalse |
72 |
139 */ |
73 // Second phase constructor |
140 bool findEntryByFilePath(const QString& aFilePath); |
74 void ConstructL( const TDesC& aLookupTableName ); |
141 |
|
142 /** |
|
143 * Get all the entries in the lookup table for a given fetching status. |
|
144 * @param[in] aFetchingState The fetching status to be found in the database. |
|
145 * @param[out] aLookupItemArray List of lookup items having the fetching status as aFetchingState. |
|
146 */ |
|
147 void findEntriesByMapTileFetchingState(const quint32 aFetchingState, |
|
148 QList<MaptileLookupItem>& aLookupItemArray); |
75 |
149 |
76 private: |
150 private: |
77 |
151 |
78 // Handle to the items database |
152 // Handle to the items database |
79 RDbNamedDatabase iItemsDatabase; |
153 QSqlDatabase *mDb; |
80 |
154 |
81 // handle to the file session |
155 |
82 RFs iFsSession; |
156 // Flag to indicate if db is open |
83 |
157 bool mDbOpen; |
84 // holds the database file name |
|
85 TFileName iDbFileName; |
|
86 |
|
87 // holds the info about database existence. |
|
88 TBool iDatabaseExists; |
|
89 |
158 |
90 }; |
159 }; |
91 |
160 |
92 |
161 |
93 #endif // __MAPTILEDBLOOKUPTABLE_H__` |
162 #endif // __MAPTILEDBLOOKUPTABLE_H__` |