23 #include <qvaluespacesubscriber.h> |
23 #include <qvaluespacesubscriber.h> |
24 #include <qfile.h> |
24 #include <qfile.h> |
25 #include "mylocationlogger.h" |
25 #include "mylocationlogger.h" |
26 |
26 |
27 #include "maptileservice.h" |
27 #include "maptileservice.h" |
|
28 #include "mylocationsdefines.h" |
28 #include "maptiledblookuptable.h" |
29 #include "maptiledblookuptable.h" |
29 #include <QVariant> |
30 #include <QVariant> |
30 // CONSTANTS |
31 // CONSTANTS |
31 // Maptile interface uid |
32 // Maptile interface uid |
32 const TUid KUidMapTileInterface = { 0x2002E6E8 }; |
33 const TUid KUidMapTileInterface = { 0x2002E6E8 }; |
33 |
34 |
34 // Central Repository Key IDs |
35 // Central Repository Key IDs |
35 const TInt KEnableLocationFeature = 0x1; |
36 const TInt KEnableLocationFeature = 0x1; |
|
37 const TInt KMaptileDbSyncState = 0x2; |
36 |
38 |
37 const char *MAPTILE_STATUS_RECEIVER = "/maptilestatuspublisher/name"; |
39 const char *MAPTILE_STATUS_RECEIVER = "/maptilestatuspublisher/name"; |
38 const char *MAPTILE_STATUS_PUBLISHER = "/maptilecontactpublisher"; |
40 const char *MAPTILE_STATUS_PUBLISHER = "/maptilecontactpublisher"; |
39 const char *MAPTILE_STATUS_CALENDAR_PUBLISHER = "/maptilecalpublisher"; |
41 const char *MAPTILE_STATUS_CALENDAR_PUBLISHER = "/maptilecalpublisher"; |
40 |
42 |
127 int MapTileService::getMapTileImage( int id, AddressType sourceType, |
129 int MapTileService::getMapTileImage( int id, AddressType sourceType, |
128 QString& imagePath, Qt::Orientations orientation ) |
130 QString& imagePath, Qt::Orientations orientation ) |
129 { |
131 { |
130 __TRACE_CALLSTACK; |
132 __TRACE_CALLSTACK; |
131 |
133 |
132 TLookupItem lookupItem; |
134 if ( sourceType == AddressPlain ){ |
133 |
135 CRepository* centralRepository = NULL; |
|
136 TRAP_IGNORE( centralRepository = CRepository::NewL( KUidMapTileInterface ) ); |
|
137 int repValue=0; |
|
138 if(centralRepository){ |
|
139 centralRepository->Get( KMaptileDbSyncState , repValue ); |
|
140 delete centralRepository; |
|
141 if(repValue == 1){ |
|
142 publishCalEntry( id ); |
|
143 return MapTileFetchingInProgress; |
|
144 } |
|
145 } |
|
146 } |
|
147 |
|
148 MaptileLookupItem lookupItem; |
134 int addressCount = 0; |
149 int addressCount = 0; |
135 int maptileStatus = MapTileFetchingUnknownError; |
150 int maptileStatus = MapTileFetchingUnknownError; |
136 |
151 int error; |
137 int error = readEntryFromMaptileDataBase( id, sourceType, lookupItem, addressCount ); |
152 error = readEntryFromMaptileDataBase( id, sourceType, lookupItem, addressCount ); |
138 |
153 |
139 //if entry available returns the file path otherwise NULL. |
154 //if entry available returns the file path otherwise NULL. |
140 if ( KErrNone == error ) |
155 if ( KErrNone == error ) |
141 { |
156 { |
142 |
157 |
144 MYLOCLOGSTRING1("getMapTileImage maptileStatus - %d ", maptileStatus ); |
159 MYLOCLOGSTRING1("getMapTileImage maptileStatus - %d ", maptileStatus ); |
145 |
160 |
146 if( maptileStatus == MapTileFetchingCompleted ) |
161 if( maptileStatus == MapTileFetchingCompleted ) |
147 { |
162 { |
148 //Get the image path |
163 //Get the image path |
149 QString imageFile((QChar*)lookupItem.iFilePath.Ptr(), |
164 QString imageFile(lookupItem.iFilePath); |
150 lookupItem.iFilePath.Length()); |
|
151 imagePath = imageFile; |
165 imagePath = imageFile; |
152 |
166 |
153 if( orientation == Qt::Vertical ) |
167 if( orientation == Qt::Vertical ) |
154 { |
168 { |
155 imagePath.append( MAPTILE_IMAGE_PORTRAIT ); |
169 imagePath.append( MAPTILE_IMAGE_PORTRAIT ); |
344 // MapTileService::readEntryFromMaptileDataBase() |
358 // MapTileService::readEntryFromMaptileDataBase() |
345 // Read all entries from database |
359 // Read all entries from database |
346 // ----------------------------------------------------------------------------- |
360 // ----------------------------------------------------------------------------- |
347 // |
361 // |
348 int MapTileService::readEntryFromMaptileDataBase( |
362 int MapTileService::readEntryFromMaptileDataBase( |
349 int id, AddressType sourceType, TLookupItem& aLookupItem, int& aNoOfAddress ) |
363 int id, AddressType sourceType, MaptileLookupItem& aLookupItem, int& aNoOfAddress ) |
350 { |
364 { |
351 |
365 |
|
366 TInt err = KErrUnknown; |
|
367 |
352 //Maptile database instance |
368 //Maptile database instance |
353 CLookupMapTileDatabase* mapTileDatabase = NULL; |
369 LookupMapTileDatabase* mapTileDatabase = new LookupMapTileDatabase(); |
354 |
370 |
355 TRAPD( err, mapTileDatabase = CLookupMapTileDatabase::NewL( |
371 if ( mapTileDatabase ) |
356 KMapTileLookupDatabaseName ) ); |
|
357 |
|
358 if ( KErrNone == err ) |
|
359 { |
372 { |
360 TRAP( err,aNoOfAddress = mapTileDatabase->FindNumberOfAddressL(id) ); |
373 if( mapTileDatabase->open() ) |
361 MYLOCLOGSTRING1("no of address FindNumberOfAddressL returns - %d ", err ); |
|
362 if ( KErrNone == err ) |
|
363 { |
374 { |
364 aLookupItem.iUid = id; |
375 err = KErrNone; |
365 switch (sourceType) |
376 aNoOfAddress = mapTileDatabase->findNumberOfAddress(id); |
366 { |
377 aLookupItem.iUid = id; |
367 case AddressPlain: |
378 switch (sourceType) |
368 aLookupItem.iSource = ESourceCalendar; |
379 { |
369 break; |
380 case AddressPlain: |
370 case AddressPreference: |
381 aLookupItem.iSource = ESourceCalendar; |
371 aLookupItem.iSource = ESourceContactsPref; |
382 break; |
372 break; |
383 case AddressPreference: |
373 case AddressWork: |
384 aLookupItem.iSource = ESourceContactsPref; |
374 aLookupItem.iSource = ESourceContactsWork; |
385 break; |
375 break; |
386 case AddressWork: |
376 case AddressHome: |
387 aLookupItem.iSource = ESourceContactsWork; |
377 aLookupItem.iSource = ESourceContactsHome; |
388 break; |
378 break; |
389 case AddressHome: |
379 default: |
390 aLookupItem.iSource = ESourceContactsHome; |
380 break; |
391 break; |
381 } |
392 default: |
382 |
393 break; |
383 TRAP( err , mapTileDatabase->FindEntryL( aLookupItem ) ); |
394 } |
384 |
395 |
385 MYLOCLOGSTRING1("getMapTileImage FindEntryL returns - %d ", err ); |
396 if( !mapTileDatabase->getEntry( aLookupItem ) ) |
|
397 { |
|
398 err = KErrNotFound; |
|
399 } |
|
400 |
|
401 MYLOCLOGSTRING1("getMapTileImage getEntry returns - %d ", err ); |
386 } |
402 } |
387 //delet the database instance |
403 //delet the database instance |
388 delete mapTileDatabase; |
404 delete mapTileDatabase; |
389 |
405 |
390 } |
406 } |
391 |
407 |
392 return err; |
408 return err; |
393 } |
409 } |
|
410 |
|
411 // ----------------------------------------------------------------------------- |
|
412 // MapTileService::keepExistingLocation() |
|
413 // update the map tile table user setting status according to user setting status |
|
414 // ----------------------------------------------------------------------------- |
|
415 // |
|
416 void MapTileService::keepExistingLocation(int id ,AddressType sourceType, bool value) |
|
417 { |
|
418 //Maptile database instance |
|
419 LookupMapTileDatabase mapTileDatabase ; |
|
420 switch(sourceType) |
|
421 { |
|
422 case AddressPlain: |
|
423 { |
|
424 if( mapTileDatabase.open() ) |
|
425 { |
|
426 MaptileLookupItem lookupItem; |
|
427 lookupItem.iUid=id; |
|
428 lookupItem.iSource=sourceType; |
|
429 mapTileDatabase.getEntry(lookupItem); |
|
430 lookupItem.iUserSetting=value; |
|
431 if(!value) |
|
432 { |
|
433 lookupItem.iFetchingStatus=MapTileFetchingInProgress; |
|
434 } |
|
435 mapTileDatabase.updateUserSetting(lookupItem); |
|
436 } |
|
437 break; |
|
438 } |
|
439 default: |
|
440 break; |
|
441 } |
|
442 |
|
443 } |
394 // End of file |
444 // End of file |