19 |
19 |
20 #include <centralrepository.h> |
20 #include <centralrepository.h> |
21 #include <locationservicedefines.h> |
21 #include <locationservicedefines.h> |
22 #include <qvaluespacepublisher.h> |
22 #include <qvaluespacepublisher.h> |
23 #include <qvaluespacesubscriber.h> |
23 #include <qvaluespacesubscriber.h> |
|
24 #include <qfile.h> |
24 #include "mylocationlogger.h" |
25 #include "mylocationlogger.h" |
25 |
26 |
26 #include "maptileservice.h" |
27 #include "maptileservice.h" |
27 #include "maptiledblookuptable.h" |
28 #include "maptiledblookuptable.h" |
28 #include <QVariant> |
29 #include <QVariant> |
121 // ----------------------------------------------------------------------------- |
122 // ----------------------------------------------------------------------------- |
122 // MapTileService::getMapTileImage() |
123 // MapTileService::getMapTileImage() |
123 // Gets the maptile image path associated with a contact. |
124 // Gets the maptile image path associated with a contact. |
124 // ----------------------------------------------------------------------------- |
125 // ----------------------------------------------------------------------------- |
125 // |
126 // |
126 int MapTileService::getMapTileImage( int id, AddressType sourceType, QString& imagePath ) |
127 int MapTileService::getMapTileImage( int id, AddressType sourceType, |
|
128 QString& imagePath, Qt::Orientations orientation ) |
127 { |
129 { |
128 __TRACE_CALLSTACK; |
130 __TRACE_CALLSTACK; |
129 |
131 |
130 TLookupItem lookupItem; |
132 TLookupItem lookupItem; |
131 |
133 |
136 |
138 |
137 //if entry available returns the file path otherwise NULL. |
139 //if entry available returns the file path otherwise NULL. |
138 if ( KErrNone == error ) |
140 if ( KErrNone == error ) |
139 { |
141 { |
140 |
142 |
141 //Get the image path |
|
142 QString imageFile((QChar*)lookupItem.iFilePath.Ptr(), |
|
143 lookupItem.iFilePath.Length()); |
|
144 imagePath = imageFile; |
|
145 |
|
146 maptileStatus = lookupItem.iFetchingStatus; |
143 maptileStatus = lookupItem.iFetchingStatus; |
147 MYLOCLOGSTRING1("getMapTileImage maptileStatus - %d ", maptileStatus ); |
144 MYLOCLOGSTRING1("getMapTileImage maptileStatus - %d ", maptileStatus ); |
148 |
145 |
149 if( maptileStatus == MapTileFetchingNetworkError || |
146 if( maptileStatus == MapTileFetchingCompleted ) |
|
147 { |
|
148 //Get the image path |
|
149 QString imageFile((QChar*)lookupItem.iFilePath.Ptr(), |
|
150 lookupItem.iFilePath.Length()); |
|
151 imagePath = imageFile; |
|
152 |
|
153 if( orientation == Qt::Vertical ) |
|
154 { |
|
155 imagePath.append( MAPTILE_IMAGE_PORTRAIT ); |
|
156 } |
|
157 else |
|
158 { |
|
159 if( sourceType == AddressPlain ) |
|
160 { |
|
161 imagePath.append( MAPTILE_IMAGE_CALENDAR ); |
|
162 } |
|
163 else if ( sourceType == AddressHome || |
|
164 sourceType == AddressPreference || sourceType == AddressWork ) |
|
165 { |
|
166 imagePath.append( MAPTILE_IMAGE_CONTACT ); |
|
167 } |
|
168 imagePath.append( MAPTILE_IMAGE_LANDSCAPE ); |
|
169 } |
|
170 |
|
171 //Check if file exist |
|
172 if( !QFile::exists( imagePath ) ) |
|
173 { |
|
174 imagePath.clear(); |
|
175 maptileStatus = MapTileFetchingUnknownError; |
|
176 } |
|
177 } |
|
178 else if( maptileStatus == MapTileFetchingNetworkError || |
150 maptileStatus == MapTileFetchingInProgress ) |
179 maptileStatus == MapTileFetchingInProgress ) |
151 { |
180 { |
152 switch(sourceType) |
181 switch(sourceType) |
153 { |
182 { |
154 case AddressHome: |
183 case AddressHome: |