locationdataharvester/mylocationsdatabasemanager/src/mylocationsdatabasemanager.cpp
changeset 41 b3dd5ec3089d
parent 35 59575560d1e6
equal deleted inserted replaced
38:793f76d9ab0c 41:b3dd5ec3089d
    31 #include "mylocationlogger.h"
    31 #include "mylocationlogger.h"
    32 #include "mylocationsdefines.h"
    32 #include "mylocationsdefines.h"
    33 
    33 
    34 #include <locationdatalookupdb.h>
    34 #include <locationdatalookupdb.h>
    35 #include <QString>
    35 #include <QString>
       
    36 #include <QList>
    36 // separator
    37 // separator
    37 _LIT( KSeparator, ",");
    38 _LIT( KSeparator, ",");
    38 // space
    39 // space
    39 _LIT( KSpace, " ");
    40 _LIT( KSpace, " ");
    40 
    41 
   286     lookupItem.mDestId = 0;
   287     lookupItem.mDestId = 0;
   287     lookupItem.mIconType = QLookupItem::EIconTypeDefault;
   288     lookupItem.mIconType = QLookupItem::EIconTypeDefault;
   288     lookupItem.mIsDuplicate = 0;
   289     lookupItem.mIsDuplicate = 0;
   289     lookupItem.mIconPath = "";
   290     lookupItem.mIconPath = "";
   290     lookupItem.mMapTilePath = "";
   291     lookupItem.mMapTilePath = "";
   291     lookupItem.mSingleLineAddress="";
       
   292     TPtrC16 dataPtr;
       
   293     aLandmark->GetPositionField(EPositionFieldComment ,dataPtr);
       
   294     lookupItem.mSingleLineAddress=QString::fromUtf16(dataPtr.Ptr(),
       
   295             dataPtr.Length());
       
   296     //fill address into lookup item.
   292     //fill address into lookup item.
   297     FillLookupItemAddressDetails( aLandmark, lookupItem );
   293     FillLookupItemAddressDetails( aLandmark, lookupItem );
   298 
   294 
   299     if ( aSourceType == ESourceLandmarks )
   295     if ( aSourceType == ESourceLandmarks )
   300     {
   296     {
   390 
   386 
   391     QLookupItem lookupItem;
   387     QLookupItem lookupItem;
   392     lookupItem.mSourceUid = aUid;
   388     lookupItem.mSourceUid = aUid;
   393     lookupItem.mSourceType = aSourceType;
   389     lookupItem.mSourceType = aSourceType;
   394     lookupItem.mIconType = QLookupItem::EIconTypeDefault;
   390     lookupItem.mIconType = QLookupItem::EIconTypeDefault;
   395     TPtrC16 dataPtr;
       
   396     aLandmark->GetPositionField(EPositionFieldComment ,dataPtr);
       
   397     lookupItem.mSingleLineAddress=QString::fromUtf16(dataPtr.Ptr(),
       
   398             dataPtr.Length());
       
   399 
   391 
   400     // Behavior: If an entry is modified, 
   392     // Behavior: If an entry is modified, 
   401     // If this entry is not present in lookup table. add the entry and update the landmarks db.
   393     // If this entry is not present in lookup table. add the entry and update the landmarks db.
   402     // If this entry is already present in lookup table, check if the location info is modified or not.
   394     // If this entry is already present in lookup table, check if the location info is modified or not.
   403     // If the location info is modified, delete the landmark from db and add the new landmark
   395     // If the location info is modified, delete the landmark from db and add the new landmark
  1144     QString source = QString( (QChar*)aAddress.Ptr(), aAddress.Length());
  1136     QString source = QString( (QChar*)aAddress.Ptr(), aAddress.Length());
  1145     if( source == target )
  1137     if( source == target )
  1146     {
  1138     {
  1147         compareStatus= EFalse;
  1139         compareStatus= EFalse;
  1148     }
  1140     }
       
  1141     else
       
  1142     {
       
  1143         iLocationAppLookupDb->updateCalendarLocationById(aId,source);   
       
  1144     }
  1149     return compareStatus;
  1145     return compareStatus;
  1150 }
  1146 }
  1151 
  1147 
       
  1148 // -----------------------------------------------------------------------------
       
  1149 // CMyLocationsDatabaseManager::UpdateCalendarLocationById()
       
  1150 // -----------------------------------------------------------------------------
       
  1151 //
       
  1152 EXPORT_C void CMyLocationsDatabaseManager::UpdateCalendarLocationById(const TUint32 aUid, const TUint32 aChangeType,const TDesC& aLocation)
       
  1153 {
       
  1154     
       
  1155     
       
  1156     switch (aChangeType)
       
  1157        {
       
  1158            case EEntryAdded:
       
  1159            case EEntryModified:
       
  1160                
       
  1161            {
       
  1162                QString location = QString( (QChar*)aLocation.Ptr(), aLocation.Length());
       
  1163                iLocationAppLookupDb->updateCalendarLocationById(aUid,location);
       
  1164                break;
       
  1165            }          
       
  1166            case EEntryDeleted:
       
  1167            {
       
  1168                iLocationAppLookupDb->deleteCalendarEntry(aUid);
       
  1169                break;
       
  1170            }
       
  1171        }       
       
  1172 }
       
  1173 
       
  1174 // -----------------------------------------------------------------------------
       
  1175 // CMyLocationsDatabaseManager::GetAllCalendarEntry()
       
  1176 // -----------------------------------------------------------------------------
       
  1177 //
       
  1178 EXPORT_C void CMyLocationsDatabaseManager::GetAllCalendarEntry(QList<QCalendarLocationDetails>& aCalEntryArray)
       
  1179 {
       
  1180     iLocationAppLookupDb->getAllCalendarEntry(aCalEntryArray);
       
  1181 }
       
  1182 
  1152 // End of file
  1183 // End of file