locationdataharvester/maptileservice/src/maptileservice.cpp
changeset 31 8db05346071b
parent 30 96df3ab41000
child 35 59575560d1e6
--- a/locationdataharvester/maptileservice/src/maptileservice.cpp	Wed Jun 23 18:07:15 2010 +0300
+++ b/locationdataharvester/maptileservice/src/maptileservice.cpp	Tue Jul 06 14:10:28 2010 +0300
@@ -21,6 +21,7 @@
 #include <locationservicedefines.h>
 #include <qvaluespacepublisher.h>
 #include <qvaluespacesubscriber.h>
+#include <qfile.h>
 #include "mylocationlogger.h"
 
 #include "maptileservice.h"
@@ -123,7 +124,8 @@
 // Gets the maptile image path associated with a contact.
 // -----------------------------------------------------------------------------
 //
-int MapTileService::getMapTileImage( int id, AddressType sourceType, QString& imagePath )    
+int MapTileService::getMapTileImage( int id, AddressType sourceType, 
+             QString& imagePath, Qt::Orientations orientation )    
 {
     __TRACE_CALLSTACK;
     
@@ -138,15 +140,42 @@
     if ( KErrNone == error  )
     {
      
-        //Get the image path
-        QString imageFile((QChar*)lookupItem.iFilePath.Ptr(),
-                    lookupItem.iFilePath.Length());
-        imagePath = imageFile;
-            
         maptileStatus = lookupItem.iFetchingStatus;
         MYLOCLOGSTRING1("getMapTileImage maptileStatus  - %d ", maptileStatus );
-
-        if( maptileStatus == MapTileFetchingNetworkError ||
+        
+        if( maptileStatus == MapTileFetchingCompleted )
+        {
+            //Get the image path
+	          QString imageFile((QChar*)lookupItem.iFilePath.Ptr(),
+	                    lookupItem.iFilePath.Length());
+	          imagePath = imageFile;
+	        
+	          if( orientation == Qt::Vertical )
+	          {
+	              imagePath.append( MAPTILE_IMAGE_PORTRAIT ); 
+	          }
+	          else
+	          {
+	              if( sourceType == AddressPlain )
+	              {
+	                  imagePath.append( MAPTILE_IMAGE_CALENDAR );
+	              }
+	              else if ( sourceType == AddressHome || 
+	                   sourceType == AddressPreference || sourceType == AddressWork )
+	              {
+	                  imagePath.append( MAPTILE_IMAGE_CONTACT );
+	              }
+	              imagePath.append( MAPTILE_IMAGE_LANDSCAPE );
+	          }
+	          
+	          //Check if file exist
+	          if( !QFile::exists( imagePath ) )
+	          {
+	              imagePath.clear();
+	           		maptileStatus = MapTileFetchingUnknownError;
+	          }
+	      }
+        else if( maptileStatus == MapTileFetchingNetworkError ||
                     maptileStatus == MapTileFetchingInProgress )
         {
             switch(sourceType)