31 |
31 |
32 // string 'And' |
32 // string 'And' |
33 _LIT( KStringAnd, " AND " ); |
33 _LIT( KStringAnd, " AND " ); |
34 |
34 |
35 |
35 |
|
36 _LIT(KQueryByMaptileState,"SELECT * FROM cntmaptilelookuptable WHERE cntuid = %d AND ( fetchingstatus = %d OR fetchingstatus = %d )"); |
36 // ----------------------------------------------------------------------------- |
37 // ----------------------------------------------------------------------------- |
37 // CLookupMapTileDatabase::CLookupMapTileDatabase() |
38 // CLookupMapTileDatabase::CLookupMapTileDatabase() |
38 // Default constructor. |
39 // Default constructor. |
39 // ----------------------------------------------------------------------------- |
40 // ----------------------------------------------------------------------------- |
40 // |
41 // |
102 // database exists |
103 // database exists |
103 iDatabaseExists = ETrue; |
104 iDatabaseExists = ETrue; |
104 } |
105 } |
105 } |
106 } |
106 |
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CLookupMapTileDatabase::FindNumberOfAddressL() |
|
110 // Finds the number of address associated with an contact. |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 int CLookupMapTileDatabase::FindNumberOfAddressL( int& aId ) |
|
114 { |
|
115 int count = 0; |
|
116 |
|
117 // Create a query to find the item. |
|
118 TFileName queryBuffer; |
|
119 queryBuffer.Format( KQueryByMaptileState,aId, |
|
120 CntMapTileService::MapTileFetchingInProgress, |
|
121 CntMapTileService::MapTileFetchingNetworkError ); |
|
122 |
|
123 TInt ret = iItemsDatabase.Open( iFsSession, iDbFileName ); |
|
124 |
|
125 if( ret != KErrNone ) |
|
126 { |
|
127 //if already opened , close and open again |
|
128 iItemsDatabase.Close(); |
|
129 User::LeaveIfError( iItemsDatabase.Open( iFsSession, iDbFileName ) ); |
|
130 } |
|
131 |
|
132 User::LeaveIfError( iItemsDatabase.Begin() ); |
|
133 // Create a view of the table with the above query. |
|
134 RDbView myView; |
|
135 myView.Prepare( iItemsDatabase, TDbQuery( queryBuffer ) ); |
|
136 CleanupClosePushL( myView ); |
|
137 myView.EvaluateAll(); |
|
138 myView.FirstL(); |
|
139 |
|
140 |
|
141 while (myView.AtRow()) |
|
142 { |
|
143 count++; |
|
144 myView.NextL(); |
|
145 } |
|
146 |
|
147 CleanupStack::PopAndDestroy( &myView ); // myView |
|
148 |
|
149 //Close the database |
|
150 iItemsDatabase.Close(); |
|
151 |
|
152 return count; |
|
153 } |
107 |
154 |
108 // ----------------------------------------------------------------------------- |
155 // ----------------------------------------------------------------------------- |
109 // CLookupMapTileDatabase::FindEntryL() |
156 // CLookupMapTileDatabase::FindEntryL() |
110 // Finds an entry in the lookup table. |
157 // Finds an entry in the lookup table. |
111 // ----------------------------------------------------------------------------- |
158 // ----------------------------------------------------------------------------- |
123 queryBuffer.Copy( KSelectAllFrom ); |
170 queryBuffer.Copy( KSelectAllFrom ); |
124 queryBuffer.Append( KMapTileLookupTable ); |
171 queryBuffer.Append( KMapTileLookupTable ); |
125 queryBuffer.Append( KStringWhere ); |
172 queryBuffer.Append( KStringWhere ); |
126 queryBuffer.Append( NCntColUid ); |
173 queryBuffer.Append( NCntColUid ); |
127 queryBuffer.Append( KStringEqual ); |
174 queryBuffer.Append( KStringEqual ); |
128 queryBuffer.AppendNum( aLookupItem.icntUid ); |
175 queryBuffer.AppendNum( aLookupItem.iUid ); |
129 queryBuffer.Append( KStringAnd ); |
176 queryBuffer.Append( KStringAnd ); |
130 queryBuffer.Append( NColSource ); |
177 queryBuffer.Append( NColSource ); |
131 queryBuffer.Append( KStringEqual ); |
178 queryBuffer.Append( KStringEqual ); |
132 queryBuffer.AppendNum( aLookupItem.iSource ); |
179 queryBuffer.AppendNum( aLookupItem.iSource ); |
133 |
180 |
150 |
197 |
151 if( myView.AtRow() ) |
198 if( myView.AtRow() ) |
152 { |
199 { |
153 // Item found. get the details. |
200 // Item found. get the details. |
154 myView.GetL(); |
201 myView.GetL(); |
155 if( aLookupItem.icntUid == myView.ColUint( KColumncntUid ) ) |
202 if( aLookupItem.iUid == myView.ColUint( KColumncntUid ) ) |
156 { |
203 { |
157 aLookupItem.iFilePath.Copy( myView.ColDes16( KColumnFilePath ) ); |
204 aLookupItem.iFilePath.Copy( myView.ColDes16( KColumnFilePath ) ); |
|
205 aLookupItem.iFetchingStatus = myView.ColUint( KColumnMapTileFetchingStatus ); |
158 entryAvailable = ETrue; |
206 entryAvailable = ETrue; |
159 } |
207 } |
160 } |
208 } |
161 |
209 |
162 CleanupStack::PopAndDestroy( &myView ); // myView |
210 CleanupStack::PopAndDestroy( &myView ); // myView |