tizen 2.4 release
[framework/location/maps-plugin-here.git] / src / here / here_place.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "here_place.h"
18
19 HERE_PLUGIN_BEGIN_NAMESPACE
20
21 HerePlace::HerePlace(void *pCbFunc, void *pUserData, int nReqId)
22 {
23         m_pDiscoveryQuery = NULL;
24         m_pPlaceDetailsQuery = NULL;
25
26         m_pCbFunc = pCbFunc;
27         m_pUserData = pUserData;
28         m_nReqId = nReqId;
29
30         m_nReplyCnt = 0;
31         m_nReplyIdx = 0;
32         m_szSortBy = NULL;
33 }
34
35 HerePlace::~HerePlace()
36 {
37         if (m_pDiscoveryQuery)
38         {
39                 delete m_pDiscoveryQuery;
40                 m_pDiscoveryQuery = NULL;
41         }
42
43         if (m_pPlaceDetailsQuery)
44         {
45                 delete m_pPlaceDetailsQuery;
46                 m_pPlaceDetailsQuery = NULL;
47         }
48
49         while(!m_PlaceList.empty())
50         {
51                 maps_place_destroy(m_PlaceList.front());
52                 m_PlaceList.pop_front();
53         }
54 }
55
56 here_error_e HerePlace::PrepareDiscoveryQuery()
57 {
58         if (m_pDiscoveryQuery)
59                 return HERE_ERROR_PERMISSION_DENIED;
60
61          m_pDiscoveryQuery = new DiscoveryQuery();
62
63         if (!m_pDiscoveryQuery)
64                 return HERE_ERROR_OUT_OF_MEMORY;
65         else
66                 return HERE_ERROR_NONE;
67 }
68
69 here_error_e HerePlace::PrepareDiscoveryPreference(maps_preference_h hPref)
70 {
71         if (!m_pDiscoveryQuery)
72                 return HERE_ERROR_OUT_OF_MEMORY;
73
74         if (!hPref)
75                 return HERE_ERROR_INVALID_PARAMETER;
76
77
78         int ret;
79         char *szLanguage = NULL;
80         ret = maps_preference_get_language(hPref, &szLanguage);
81         if (ret == MAPS_ERROR_NONE && szLanguage && *szLanguage)
82                 m_pDiscoveryQuery->SetLanguage(szLanguage);
83         g_free(szLanguage);
84
85         int nMaxResults;
86         ret = maps_preference_get_max_results(hPref, &nMaxResults);
87         if (ret == MAPS_ERROR_NONE)
88                 m_pDiscoveryQuery->SetMaxResults((size_t)nMaxResults);
89
90         char *szSortBy;
91         ret = maps_preference_get(hPref, MAPS_PLACE_FILTER_SORT_BY, &szSortBy);
92         if (ret == MAPS_ERROR_NONE)
93                 m_szSortBy = szSortBy;
94
95         return HERE_ERROR_NONE;
96 }
97
98 here_error_e HerePlace::PrepareDiscoveryFilter(maps_place_filter_h hFilter)
99 {
100         if (!m_pDiscoveryQuery)
101                 return HERE_ERROR_OUT_OF_MEMORY;
102
103         if (!hFilter)
104                 return HERE_ERROR_INVALID_PARAMETER;
105
106         int ret;
107         maps_place_category_h mapsCate = NULL;
108         if (maps_place_filter_get_category(hFilter, &mapsCate) == MAPS_ERROR_NONE)
109         {
110                 CategoryList hereCateList;
111                 Category hereCate;
112                 char *szId = NULL, *szName = NULL, *szUrl = NULL;
113
114                 ret = maps_place_category_get_name(mapsCate, &szName);
115                 if (ret == MAPS_ERROR_NONE && szName && *szName)
116                         hereCate.SetTitle(szName);
117                 g_free(szName);
118
119                 ret = maps_place_category_get_url(mapsCate, &szUrl);
120                 if (ret == MAPS_ERROR_NONE && szUrl && *szUrl)
121                         hereCate.SetHref(szUrl);
122                 g_free(szUrl);
123
124                 ret = maps_place_category_get_id(mapsCate, &szId);
125                 if (ret == MAPS_ERROR_NONE && szId && *szId)
126                 {
127                         hereCate.SetCategoryId(CategoryId(szId));
128                         hereCateList.push_back(hereCate);
129                         m_pDiscoveryQuery->SetCategoriesFilter(hereCateList);
130                 }
131                 g_free(szId);
132
133                 maps_place_category_destroy(mapsCate);
134         }
135
136         char *szName = NULL;
137         ret = maps_place_filter_get_place_name(hFilter, &szName);
138         if (ret == MAPS_ERROR_NONE && szName && *szName)
139                 m_pDiscoveryQuery->SetSearchText(szName);
140         g_free(szName);
141
142         return HERE_ERROR_NONE;
143 }
144
145 here_error_e HerePlace::StartDiscoveryPlace(maps_coordinates_h hCoord, int nDistance)
146 {
147         if (!m_pDiscoveryQuery)
148                 return HERE_ERROR_OUT_OF_MEMORY;
149
150         if (!hCoord)
151                 return HERE_ERROR_INVALID_PARAMETER;
152
153
154         if (m_pDiscoveryQuery->GetSearchText().empty())
155         {
156                 m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_EXPLORE);
157
158                 double dLat, dLon;
159                 maps_coordinates_get_latitude(hCoord, &dLat);
160                 maps_coordinates_get_longitude(hCoord, &dLon);
161                 GeoCoordinates geoCoord(dLat, dLon);
162
163                 if (nDistance > 0)
164                 {
165                         GeoBoundingCircle geoCircle(geoCoord, nDistance);
166                         m_pDiscoveryQuery->SetArea(geoCircle);
167                 }
168                 else if (nDistance == 0)
169                 {
170                         m_pDiscoveryQuery->SetProximity(geoCoord);
171                 }
172                 else
173                         return HERE_ERROR_INVALID_PARAMETER;
174
175                 m_nRestReqId = m_pDiscoveryQuery->Execute(*this, NULL);
176
177                 return (m_nRestReqId > 0 ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION);
178         }
179         else
180         {
181                 here_error_e error;
182                 maps_area_h hArea = NULL;
183                 maps_area_create_circle(hCoord, nDistance, &hArea);
184                 error = StartDiscoveryPlaceByAddress(m_pDiscoveryQuery->GetSearchText().data(), hArea);
185                 maps_area_destroy(hArea);
186                 return error;
187         }
188 }
189
190 here_error_e HerePlace::StartDiscoveryPlaceByArea(maps_area_h hArea)
191 {
192         if (!m_pDiscoveryQuery)
193                 return HERE_ERROR_OUT_OF_MEMORY;
194
195         if (!hArea)
196                 return HERE_ERROR_INVALID_PARAMETER;
197
198
199         if (m_pDiscoveryQuery->GetSearchText().empty())
200         {
201                 m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_EXPLORE);
202
203                 maps_area_s *pArea = (maps_area_s*)hArea;
204                 if (pArea->type == MAPS_AREA_RECTANGLE)
205                 {
206                         GeoBoundingBox box(pArea->rect.top_left.longitude, pArea->rect.bottom_right.longitude,
207                                            pArea->rect.bottom_right.latitude, pArea->rect.top_left.latitude);
208                         m_pDiscoveryQuery->SetArea(box);
209                 }
210                 else if (pArea->type == MAPS_AREA_CIRCLE)
211                 {
212                         GeoCoordinates coord(pArea->circle.center.latitude, pArea->circle.center.longitude);
213                         GeoBoundingCircle circle(coord, pArea->circle.radius);
214                         m_pDiscoveryQuery->SetArea(circle);
215                 }
216                 else
217                         return HERE_ERROR_INVALID_PARAMETER;
218
219
220                 m_nRestReqId = m_pDiscoveryQuery->Execute(*this, NULL);
221
222                 return (m_nRestReqId > 0 ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION);
223         }
224         else
225         {
226                 return StartDiscoveryPlaceByAddress(m_pDiscoveryQuery->GetSearchText().data(), hArea);
227         }
228 }
229
230 here_error_e HerePlace::StartDiscoveryPlaceByAddress(const char *szAddr, maps_area_h hArea)
231 {
232         if (!m_pDiscoveryQuery)
233                 return HERE_ERROR_OUT_OF_MEMORY;
234
235         if (!szAddr || (szAddr && strlen(szAddr) <= 0) || !hArea)
236                 return HERE_ERROR_INVALID_PARAMETER;
237
238
239         m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_SEARCH);
240
241         String szSearchText = szAddr;
242         if (m_pDiscoveryQuery->GetSearchText().size())
243                 szSearchText += " " + m_pDiscoveryQuery->GetSearchText();
244         m_pDiscoveryQuery->SetSearchText(szSearchText);
245
246         maps_area_s *pArea = (maps_area_s*)hArea;
247         if (pArea->type == MAPS_AREA_RECTANGLE)
248         {
249                 double dLat1 = pArea->rect.top_left.latitude;
250                 double dLng1 = pArea->rect.top_left.longitude;
251                 double dLat2 = pArea->rect.bottom_right.latitude;
252                 double dLng2 = pArea->rect.bottom_right.longitude;
253                 double dLat = (dLat1 + dLat2) / 2;
254                 double dLng = (dLng1 + dLng2) / 2;
255
256                 GeoCoordinates geoCoord(dLat, dLng);
257                 m_pDiscoveryQuery->SetProximity(geoCoord);
258         }
259         else if(pArea->type == MAPS_AREA_CIRCLE)
260         {
261                 double dLat = pArea->circle.center.latitude;
262                 double dLng = pArea->circle.center.longitude;
263                 GeoCoordinates geoCoord(dLat, dLng);
264                 m_pDiscoveryQuery->SetProximity(geoCoord);
265         }
266
267
268         m_nRestReqId = m_pDiscoveryQuery->Execute(*this, NULL);
269
270         return (m_nRestReqId > 0 ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION);
271 }
272
273 here_error_e HerePlace::PreparePlaceDetailsQuery()
274 {
275         if (m_pPlaceDetailsQuery)
276                 return HERE_ERROR_PERMISSION_DENIED;
277
278         m_pPlaceDetailsQuery = new PlaceDetailsQuery();
279
280         if (!m_pPlaceDetailsQuery)
281                 return HERE_ERROR_OUT_OF_MEMORY;
282         else
283                 return HERE_ERROR_NONE;
284 }
285
286 here_error_e HerePlace::PreparePlaceDetailsPreference(maps_preference_h hPref)
287 {
288         if (!m_pPlaceDetailsQuery)
289                 return HERE_ERROR_OUT_OF_MEMORY;
290
291         if (!hPref)
292                 return HERE_ERROR_INVALID_PARAMETER;
293
294         int ret;
295         char *szLanguage = NULL;
296         ret = maps_preference_get_language(hPref, &szLanguage);
297         if (ret == MAPS_ERROR_NONE && szLanguage && *szLanguage)
298                 m_pPlaceDetailsQuery->SetLanguage(szLanguage);
299         g_free(szLanguage);
300
301         return HERE_ERROR_NONE;
302 }
303
304 here_error_e HerePlace::StartPlaceDetails(const char *szPlaceId)
305 {
306         if (!m_pPlaceDetailsQuery)
307                 return HERE_ERROR_OUT_OF_MEMORY;
308
309         if (!szPlaceId || (szPlaceId && strlen(szPlaceId) <= 0))
310                 return HERE_ERROR_INVALID_PARAMETER;
311
312
313         m_pPlaceDetailsQuery->SetPlaceId(szPlaceId);
314
315
316         m_nRestReqId = m_pPlaceDetailsQuery->Execute(*this, NULL);
317
318         return (m_nRestReqId > 0 ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION);
319 }
320
321 here_error_e HerePlace::StartPlaceDetailsInternal(const char *szUrl)
322 {
323         if (!szUrl || (szUrl && strlen(szUrl) <= 0))
324                 return HERE_ERROR_INVALID_PARAMETER;
325
326
327         std::unique_ptr<PlaceDetailsQuery> pPlaceDetailsQuery (new (std::nothrow)PlaceDetailsQuery());
328
329
330         bool bExcuted = (int)(pPlaceDetailsQuery->Execute(*this, NULL, szUrl) > 0);
331
332         return (bExcuted ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION);
333 }
334
335 void HerePlace::OnDiscoverReply (const DiscoveryReply &Reply)
336 {
337         if (m_bCanceled) /* ignore call back if it was cancelled. */
338         {
339                 delete this;
340                 return;
341         }
342
343         maps_place_h mapsPlace;
344         PlaceItemList herePlaceList = Reply.GetPlaceItems();
345         PlaceItemList::iterator herePlaceIt;
346         SearchItemList hereSearchList = Reply.GetSearchItems();
347         SearchItemList::iterator hereSearchIt;
348         LinkObject hereLinkObj;
349         GeoCoordinates hereCoord;
350         maps_coordinates_h mapsCoord;
351         Category hereCate;
352         maps_place_category_h mapsCate;
353         maps_place_rating_h mapsRating;
354         int error = MAPS_ERROR_UNKNOWN, sub_error;
355         bool is_valid, isPending;
356
357
358         m_nReplyIdx = 0;
359         m_nReplyCnt = herePlaceList.size() + hereSearchList.size();
360
361         if (m_nReplyCnt == 0)
362         {
363                 ((maps_service_search_place_cb)m_pCbFunc)(MAPS_ERROR_NOT_FOUND, m_nReqId,
364                         0, 1, NULL, m_pUserData);
365                 delete this;
366                 return;
367         }
368
369         for (herePlaceIt = herePlaceList.begin();
370                 herePlaceIt != herePlaceList.end() && !m_bCanceled;
371                 herePlaceIt++)
372         {
373                 isPending = false;
374
375                 if ((error = maps_place_create(&mapsPlace)) == MAPS_ERROR_NONE)
376                 {
377                         /* title, uri, id */
378                         hereLinkObj = herePlaceIt->GetLinkObject();
379
380                         if (!hereLinkObj.GetTitle().empty())
381                                 maps_place_set_name(mapsPlace, (char*)hereLinkObj.GetTitle().c_str());
382
383                         if (!hereLinkObj.GetHref().empty())
384                                 maps_place_set_uri(mapsPlace, (char*)hereLinkObj.GetHref().c_str());
385
386                         if (!hereLinkObj.GetId().empty())
387                                 maps_place_set_id(mapsPlace, (char*)hereLinkObj.GetId().c_str());
388
389                         /* icon */
390                         /* type */
391
392                         /* position */
393                         hereCoord = herePlaceIt->GetPosition();
394                         if (maps_coordinates_create(hereCoord.GetLatitude(), hereCoord.GetLongitude(),
395                                 &mapsCoord) == MAPS_ERROR_NONE)
396                         {
397                                 maps_place_set_location(mapsPlace, mapsCoord);
398                                 maps_coordinates_destroy(mapsCoord);
399                         }
400
401                         /* rating (optional) */
402                         if (maps_place_rating_create(&mapsRating) == MAPS_ERROR_NONE)
403                         {
404                                 maps_place_rating_set_average(mapsRating, herePlaceIt->GetAverageRating());
405                                 maps_place_set_rating(mapsPlace, mapsRating);
406                                 maps_place_rating_destroy(mapsRating);
407                         }
408
409                         /* category (optional) */
410                         hereCate = herePlaceIt->GetCategory();
411
412                         maps_item_list_h mapsCateList;
413                         if (maps_item_list_create(&mapsCateList) == MAPS_ERROR_NONE)
414                         {
415                                 if (maps_place_category_create(&mapsCate) == MAPS_ERROR_NONE)
416                                 {
417                                         is_valid = false;
418
419                                         if (!hereCate.GetCategoryId().ToString().empty())
420                                         {
421                                                 sub_error = maps_place_category_set_id(mapsCate,
422                                                                 (char*)hereCate.GetCategoryId().ToString().c_str());
423                                                 is_valid |= (sub_error == MAPS_ERROR_NONE);
424                                         }
425
426                                         if (!hereCate.GetTitle().empty())
427                                         {
428                                                 sub_error = maps_place_category_set_name(mapsCate,
429                                                                 (char*)hereCate.GetTitle().c_str());
430                                                 is_valid |= (sub_error == MAPS_ERROR_NONE);
431                                         }
432
433                                         if (!hereCate.GetHref().empty())
434                                         {
435                                                 sub_error = maps_place_category_set_url(mapsCate,
436                                                                 (char*)hereCate.GetHref().c_str());
437                                                 is_valid |= (sub_error == MAPS_ERROR_NONE);
438                                         }
439
440                                         if (is_valid)
441                                         {
442                                                 maps_item_list_append(mapsCateList, mapsCate, maps_place_category_clone);
443                                                 maps_place_set_categories(mapsPlace, mapsCateList);
444                                                 maps_item_list_remove_all(mapsCateList, maps_place_category_destroy);
445                                         }
446                                         maps_place_category_destroy(mapsCate);
447                                 }
448                                 maps_item_list_destroy(mapsCateList);
449                         }
450
451                         /* distance */
452                         maps_place_set_distance(mapsPlace, (int)herePlaceIt->GetDistance());
453
454                         /* sponser */
455                         /* herePlaceList.GetIsSponsored() */
456
457                         /* vicinity */
458
459                         /* If needed PlaceDetails information, postpone to send a reply */
460                         if(__sending_place_details_query_automatically)
461                         {
462                                 hereLinkObj = herePlaceIt->GetLinkObject();
463                                 if (!hereLinkObj.GetHref().empty() && !hereLinkObj.GetId().empty())
464                                 {
465                                         m_PlaceList.push_back(mapsPlace);
466                                         isPending = true;
467                                         StartPlaceDetailsInternal(hereLinkObj.GetHref().c_str());
468                                         MAPS_LOGD("Add maps_place_h to the pending list. id=%s", hereLinkObj.GetId().data());
469                                 }
470                         }
471                 }
472
473                 if (!isPending) {
474                         m_nReplyIdx++;
475                         m_PlaceList.push_back(mapsPlace);
476                 }
477         }
478
479         for (hereSearchIt = hereSearchList.begin();
480                 hereSearchIt != hereSearchList.end() && !m_bCanceled;
481                 hereSearchIt++)
482         {
483                 error = maps_place_create(&mapsPlace);
484
485                 if(error == MAPS_ERROR_NONE)
486                 {
487                         is_valid = false;
488
489                         // title, uri, szId
490                         hereLinkObj = hereSearchIt->GetLinkObject();
491
492                         if (!hereLinkObj.GetTitle().empty())
493                         {
494                                 sub_error = maps_place_set_name(mapsPlace,
495                                                 (char*)hereLinkObj.GetTitle().c_str());
496                                 is_valid |= (sub_error == MAPS_ERROR_NONE);
497                         }
498
499                         if (!hereLinkObj.GetHref().empty())
500                         {
501                                 sub_error = maps_place_set_uri(mapsPlace,
502                                                 (char*)hereLinkObj.GetHref().c_str());
503                                 is_valid |= (sub_error == MAPS_ERROR_NONE);
504                         }
505
506                         if (!hereLinkObj.GetId().empty())
507                         {
508                                 sub_error = maps_place_set_id(mapsPlace,
509                                                 (char*)hereLinkObj.GetId().c_str());
510                                 is_valid |= (sub_error == MAPS_ERROR_NONE);
511                         }
512                         /* icon */
513                         /* type */
514
515                         if (!is_valid)
516                                 error = MAPS_ERROR_NOT_FOUND;
517                 }
518
519                 m_PlaceList.push_back(mapsPlace);
520                 m_nReplyIdx++;
521         }
522
523
524         if (m_nReplyIdx == m_nReplyCnt - 1)
525         {
526                 __sortList(m_PlaceList);
527         
528                 m_nReplyIdx = 0;
529                 while (m_nReplyIdx < m_nReplyCnt && !m_bCanceled && !m_PlaceList.empty())
530                 {
531                         mapsPlace = m_PlaceList.front();
532                         m_PlaceList.pop_front();
533
534                         /* callback function */
535                         if (((maps_service_search_place_cb)m_pCbFunc)((maps_error_e)error, m_nReqId,
536                                 m_nReplyIdx++, m_nReplyCnt, mapsPlace, m_pUserData) == FALSE)
537                         {
538                                 break;
539                         }
540                 }
541                 delete this;
542         }
543 }
544
545 void HerePlace::OnPlaceDetailsReply (const PlaceDetailsReply &Reply)
546 {
547         if (m_bCanceled) /* ignore call back if it was cancelled. */
548         {
549                 delete this;
550                 return;
551         }
552
553         if (m_nReplyCnt == 0)
554                 m_nReplyCnt = 1;
555
556         PlaceDetails herePlace = Reply.GetPlaceDetails();
557         maps_place_h mapsPlace = NULL;
558         int error = MAPS_ERROR_NONE, sub_error;
559         bool is_valid, isPending = false;
560         char *placeId;
561         int placeIdLen;
562
563         /* Finding maps_place_h which is already pending since DiscoverReply */
564         PlaceList::iterator it;
565         for (it = m_PlaceList.begin(); it != m_PlaceList.end(); it++)
566         {
567                 if (maps_place_get_id(*it, &placeId) == MAPS_ERROR_NONE)
568                 {
569                         placeIdLen = strlen(placeId);
570                         if(!herePlace.GetPlaceId().compare(0, placeIdLen, placeId))
571                         {
572                                 mapsPlace = *it;
573                                 isPending = true;
574                                 g_free(placeId);
575                                 MAPS_LOGD("Found maps_place_h (%p) which is pending since DiscoveryReply", mapsPlace);
576                                 break;
577                         }
578                 }
579                 g_free(placeId);
580         }
581
582         /* If not found, create new handle */
583         if (!mapsPlace)
584                 error = maps_place_create(&mapsPlace);
585
586         if (error == MAPS_ERROR_NONE)
587         {
588                 is_valid = false;
589
590                 /* name */
591                 if (!herePlace.GetName().empty())
592                 {
593                         sub_error = maps_place_set_name(mapsPlace, (char*)herePlace.GetName().c_str());
594                         is_valid |= (sub_error == MAPS_ERROR_NONE);
595                 }
596
597                 /* id */
598                 if (!herePlace.GetPlaceId().empty())
599                 {
600                         sub_error = maps_place_set_id(mapsPlace, (char*)herePlace.GetPlaceId().c_str());
601                         is_valid |= (sub_error == MAPS_ERROR_NONE);
602                 }
603
604                 /* view */
605                 if (!herePlace.GetView().empty())
606                 {
607                         sub_error = maps_place_set_uri(mapsPlace, (char*)herePlace.GetView().c_str());
608                         is_valid |= (sub_error == MAPS_ERROR_NONE);
609                 }
610
611                 if (is_valid)
612                 {
613                         /* icon */
614                         /* maps not supported // herePlace.GetIconPath(); */
615
616                         /* location */
617                         ProcessPlaceLocation(herePlace, mapsPlace);
618
619                         ProcessPlaceContact(herePlace, mapsPlace);
620
621                         ProcessPlaceCategory(herePlace, mapsPlace);
622
623                         /* tags */
624                         /* maps & here not supported */
625
626                         ProcessPlaceImage(herePlace, mapsPlace);
627
628                         ProcessPlaceDetails(herePlace, mapsPlace);
629
630                         ProcessPlaceReviews(herePlace, mapsPlace);
631
632                         ProcessPlaceRatings(herePlace, mapsPlace);
633
634                         ProcessPlaceRated(herePlace, mapsPlace);
635                 }
636                 else
637                 {
638                         error = MAPS_ERROR_NOT_FOUND;
639                 }
640         }
641
642         if (!isPending)
643                 m_PlaceList.push_back(mapsPlace);
644
645         m_nReplyIdx++;
646
647
648         if (m_nReplyIdx == m_nReplyCnt - 1)
649         {
650                 __sortList(m_PlaceList);
651         
652                 m_nReplyIdx = 0;
653                 while (m_nReplyIdx < m_nReplyCnt && !m_bCanceled && !m_PlaceList.empty())
654                 {
655                         mapsPlace = m_PlaceList.front();
656                         m_PlaceList.pop_front();
657
658                         /* callback function */
659                         if (((maps_service_search_place_cb)m_pCbFunc)((maps_error_e)error, m_nReqId,
660                                 m_nReplyIdx++, m_nReplyCnt, mapsPlace, m_pUserData) == FALSE)
661                         {
662                                 break;
663                         }
664                 }
665                 delete this;
666         }
667 }
668
669 void HerePlace::ProcessPlaceLocation(PlaceDetails herePlace, maps_place_h mapsPlace)
670 {
671         GeoLocation hereLocation = herePlace.GetLocation();
672
673         /* position */
674         GeoCoordinates hereCoord = hereLocation.GetDisplayPosition();
675         maps_coordinates_h mapsCoord;
676
677         if (maps_coordinates_create(hereCoord.GetLatitude(),
678                 hereCoord.GetLongitude(), &mapsCoord) == MAPS_ERROR_NONE)
679         {
680                 maps_place_set_location(mapsPlace, mapsCoord);
681                 maps_coordinates_destroy(mapsCoord);
682         }
683
684         /* address */
685         Address hereAddr = hereLocation.GetAddress();
686         maps_address_h mapsAddr;
687         int error;
688         bool is_valid;
689
690         if (maps_address_create(&mapsAddr) == MAPS_ERROR_NONE)
691         {
692                 is_valid = false;
693
694                 if (!hereAddr.GetHouseNumber().empty())
695                 {
696                         error = maps_address_set_building_number(mapsAddr,
697                                         hereAddr.GetHouseNumber().c_str());
698                         is_valid |= (error == MAPS_ERROR_NONE);
699                 }
700
701                 if (!hereAddr.GetStreet().empty())
702                 {
703                         error = maps_address_set_street(mapsAddr, hereAddr.GetStreet().c_str());
704                         is_valid |= (error == MAPS_ERROR_NONE);
705                 }
706
707                 if (!hereAddr.GetDistrict().empty())
708                 {
709                         error = maps_address_set_district(mapsAddr, hereAddr.GetDistrict().c_str());
710                         is_valid |= (error == MAPS_ERROR_NONE);
711                 }
712
713                 if (!hereAddr.GetCity().empty())
714                 {
715                         error = maps_address_set_city(mapsAddr, hereAddr.GetCity().c_str());
716                         is_valid |= (error == MAPS_ERROR_NONE);
717                 }
718
719                 if (!hereAddr.GetState().empty())
720                 {
721                         error = maps_address_set_state(mapsAddr, hereAddr.GetState().c_str());
722                         is_valid |= (error == MAPS_ERROR_NONE);
723                 }
724
725                 if (!hereAddr.GetCountry().empty())
726                 {
727                         error = maps_address_set_country(mapsAddr, hereAddr.GetCountry().c_str());
728                         is_valid |= (error == MAPS_ERROR_NONE);
729                 }
730
731                 if (!hereAddr.GetCountryCode().empty())
732                 {
733                         error = maps_address_set_country_code(mapsAddr, hereAddr.GetCountryCode().c_str());
734                         is_valid |= (error == MAPS_ERROR_NONE);
735                 }
736
737                 if (!hereAddr.GetCounty().empty())
738                 {
739                         error = maps_address_set_county(mapsAddr, hereAddr.GetCounty().c_str());
740                         is_valid |= (error == MAPS_ERROR_NONE);
741                 }
742
743                 if (!hereAddr.GetPostalCode().empty())
744                 {
745                         error = maps_address_set_postal_code(mapsAddr, hereAddr.GetPostalCode().c_str());
746                         is_valid |= (error == MAPS_ERROR_NONE);
747                 }
748
749                 if (!hereAddr.GetLabel().empty())
750                 {
751                         error = maps_address_set_freetext(mapsAddr, hereAddr.GetLabel().c_str());
752                         is_valid |= (error == MAPS_ERROR_NONE);
753                 }
754
755                 if (is_valid)
756                 {
757                         maps_place_set_address(mapsPlace, mapsAddr);
758                 }
759                 maps_address_destroy(mapsAddr);
760         }
761 }
762
763
764 void HerePlace::ProcessPlaceContact(PlaceDetails herePlace, maps_place_h mapsPlace)
765 {
766         /* contact */
767         ContactDetailsList hereContList = herePlace.GetContactDetails();
768         ContactDetailsList::iterator hereCont;
769         maps_item_list_h mapsContList;
770         maps_place_contact_h mapsCont;
771         int error;
772         bool is_valid;
773
774         if (hereContList.empty()) return;
775
776         if (maps_item_list_create(&mapsContList) != MAPS_ERROR_NONE) return;
777
778         for (hereCont = hereContList.begin(); hereCont != hereContList.end(); hereCont++)
779         {
780                 if (maps_place_contact_create(&mapsCont) != MAPS_ERROR_NONE) continue;
781
782                 is_valid = false;
783
784                 if (!hereCont->GetLabel().empty())
785                 {
786                         error = maps_place_contact_set_label(mapsCont,
787                                 (char*)hereCont->GetLabel().c_str());
788                         is_valid |= (error == MAPS_ERROR_NONE);
789                 }
790
791                 if (!hereCont->GetValue().empty())
792                 {
793                         error = maps_place_contact_set_value(mapsCont,
794                                 (char*)hereCont->GetValue().c_str());
795                         is_valid |= (error == MAPS_ERROR_NONE);
796                 }
797
798                 if (!hereCont->GetContactType().empty())
799                 {
800                         error = maps_place_contact_set_type(mapsCont,
801                                 (char*)hereCont->GetContactType().c_str());
802                         is_valid |= (error == MAPS_ERROR_NONE);
803                 }
804
805                 if (is_valid)
806                 {
807                         maps_item_list_append(mapsContList, mapsCont,
808                                 maps_place_contact_clone);
809                 }
810                 maps_place_contact_destroy(mapsCont);
811         }
812
813         if (maps_item_list_items(mapsContList))
814         {
815                 maps_place_set_contacts(mapsPlace, mapsContList);
816                 maps_item_list_remove_all(mapsContList, maps_place_contact_destroy);
817         }
818         maps_item_list_destroy(mapsContList);
819 }
820
821 void HerePlace::ProcessPlaceCategory(PlaceDetails herePlace, maps_place_h mapsPlace)
822 {
823         CategoryList hereCateList = herePlace.GetCategories();
824         CategoryList::iterator hereCate;
825         maps_item_list_h mapsCateList;
826         maps_place_category_h mapsCate;
827         int error;
828         bool is_valid = false;
829
830         if (hereCateList.empty()) return;
831
832         if (maps_item_list_create(&mapsCateList) != MAPS_ERROR_NONE) return;
833
834         // maps-service supports only one category
835         hereCate = hereCateList.begin();
836         if (maps_place_category_create(&mapsCate) == MAPS_ERROR_NONE)
837         {
838                 if (!hereCate->GetCategoryId().ToString().empty())
839                 {
840                         error = maps_place_category_set_id(mapsCate,
841                                 hereCate->GetCategoryId().ToString().c_str());
842                         is_valid |= (error == MAPS_ERROR_NONE);
843                 }
844
845                 if (!hereCate->GetTitle().empty())
846                 {
847                         error = maps_place_category_set_name(mapsCate,
848                                 hereCate->GetTitle().c_str());
849                         is_valid |= (error == MAPS_ERROR_NONE);
850                 }
851
852                 if (!hereCate->GetHref().empty())
853                 {
854                         error = maps_place_category_set_url(mapsCate,
855                                 hereCate->GetHref().c_str());
856                         is_valid |= (error == MAPS_ERROR_NONE);
857                 }
858
859                 if (is_valid)
860                 {
861                         maps_item_list_append(mapsCateList, mapsCate, maps_place_category_clone);
862                 }
863                 maps_place_category_destroy(mapsCate);
864         }
865
866         if (maps_item_list_items(mapsCateList))
867         {
868                 maps_place_set_categories(mapsPlace, mapsCateList);
869                 maps_item_list_remove_all(mapsCateList, maps_place_category_destroy);
870         }
871         maps_item_list_destroy(mapsCateList);
872 }
873
874 void HerePlace::ProcessPlaceImage(PlaceDetails herePlace, maps_place_h mapsPlace)
875
876         ImageContentList hereImageList = herePlace.GetImageContent();
877         ImageContentList::iterator hereImage;
878         maps_item_list_h mapsImageList;
879         maps_place_image_h mapsImage;
880         maps_place_link_object_h mapsImageUser;
881         LinkObject hereImageUser;
882         int error;
883         bool is_valid, is_valid2;
884
885         if (hereImageList.empty()) return;
886
887         if (maps_item_list_create(&mapsImageList) != MAPS_ERROR_NONE) return;
888
889         for (hereImage = hereImageList.begin(); hereImage != hereImageList.end(); hereImage++)
890         {
891                 if (maps_place_image_create(&mapsImage) != MAPS_ERROR_NONE) continue;
892
893                 is_valid = false;
894
895                 /* here not supported
896                 // maps_place_image_set_height(maps_place_image_h mapsPlace, const int height); */
897
898                 /* here not supported
899                 // maps_place_image_set_media(maps_place_image_h mapsPlace, maps_place_media_h media); */
900
901                 if (!hereImage->GetSource().empty())
902                 {
903                         error = maps_place_image_set_url(mapsImage, (char*)hereImage->GetSource().c_str());
904                         is_valid |= (error == MAPS_ERROR_NONE);
905                 }
906
907                 if (!hereImage->GetImageId().empty())
908                 {
909                         error = maps_place_image_set_id(mapsImage, (char*)hereImage->GetImageId().c_str());
910                         is_valid |= (error == MAPS_ERROR_NONE);
911                 }
912
913                 hereImageUser = hereImage->GetUser();
914                 if (maps_place_link_object_create(&mapsImageUser) == MAPS_ERROR_NONE)
915                 {
916                         is_valid2 = false;
917
918                         if (!hereImageUser.GetId().empty())
919                         {
920                                 error = maps_place_link_object_set_id(mapsImageUser,
921                                                 (char*)hereImageUser.GetId().c_str());
922                                 is_valid2 |= (error == MAPS_ERROR_NONE);
923                         }
924
925                         if (!hereImageUser.GetTitle().empty())
926                         {
927                                 error = maps_place_link_object_set_name(mapsImageUser,
928                                                 (char*)hereImageUser.GetTitle().c_str());
929                                 is_valid2 |= (error == MAPS_ERROR_NONE);
930                         }
931
932                         if (!hereImageUser.GetHref().empty())
933                         {
934                                 error = maps_place_link_object_set_string(mapsImageUser,
935                                                 (char*)hereImageUser.GetHref().c_str());
936                                 is_valid2 |= (error == MAPS_ERROR_NONE);
937                         }
938
939                         if (!hereImageUser.GetType().empty())
940                         {
941                                 error = maps_place_link_object_set_type(mapsImageUser,
942                                                 (char*)hereImageUser.GetType().c_str());
943                                 is_valid2 |= (error == MAPS_ERROR_NONE);
944                         }
945
946                         if (is_valid2)
947                         {
948                                 maps_place_image_set_user_link(mapsImage, mapsImageUser);
949                                 is_valid |= is_valid2;
950                         }
951                         maps_place_link_object_destroy(mapsImageUser);
952                 }
953
954                 if (is_valid)
955                 {
956                         maps_item_list_append(mapsImageList, mapsImage, maps_place_image_clone);
957                 }
958                 maps_place_image_destroy(mapsImage);
959         }
960
961         if (maps_item_list_items(mapsImageList))
962         {
963                 maps_place_set_images(mapsPlace, mapsImageList);
964                 maps_item_list_remove_all(mapsImageList, maps_place_image_destroy);
965         }
966         maps_item_list_destroy(mapsImageList);
967 }
968
969 void HerePlace::ProcessPlaceDetails(PlaceDetails herePlace, maps_place_h mapsPlace)
970 {
971         EditorialContentList hereEditList = herePlace.GetEditorialContent();
972         EditorialContentList::iterator hereEdit;
973         maps_item_list_h mapsEditList;
974         maps_place_editorial_h mapsEdit;
975         int error;
976         bool is_valid;
977
978         if (hereEditList.empty()) return;
979
980         if (maps_item_list_create(&mapsEditList) != MAPS_ERROR_NONE) return;
981
982         for (hereEdit = hereEditList.begin(); hereEdit != hereEditList.end(); hereEdit++)
983         {
984                 if (maps_place_editorial_create(&mapsEdit) != MAPS_ERROR_NONE) continue;
985
986                 is_valid = false;
987
988                 if (!hereEdit->GetDescription().empty())
989                 {
990                         error = maps_place_editorial_set_description(mapsEdit,
991                                 (char*)hereEdit->GetDescription().c_str());
992                         is_valid |= (error == MAPS_ERROR_NONE);
993                 }
994
995                 if (!hereEdit->GetLanguage().empty())
996                 {
997                         error = maps_place_editorial_set_language(mapsEdit,
998                                 (char*)hereEdit->GetLanguage().c_str());
999                         is_valid |= (error == MAPS_ERROR_NONE);
1000                 }
1001
1002                 /* maps_place_editorial_set_media(mapsEdit, maps_place_media_h media); */
1003
1004                 if (is_valid)
1005                 {
1006                         maps_item_list_append(mapsEditList, mapsEdit, maps_place_editorial_clone);
1007                 }
1008                 maps_place_editorial_destroy(mapsEdit);
1009         }
1010
1011         if (maps_item_list_items(mapsEditList))
1012         {
1013                 maps_place_set_editorials(mapsPlace, mapsEditList);
1014                 maps_item_list_remove_all(mapsEditList, maps_place_editorial_destroy);
1015         }
1016         maps_item_list_destroy(mapsEditList);
1017 }
1018
1019 void HerePlace::ProcessPlaceReviews(PlaceDetails herePlace, maps_place_h mapsPlace)
1020 {
1021         ReviewContentList hereReviewList = herePlace.GetReviewContent();
1022         ReviewContentList::iterator hereReview;
1023         maps_place_review_h mapsReview;
1024         maps_item_list_h mapsReviewList;
1025         LinkObject hereReviewUser;
1026         maps_place_link_object_h mapsReviewUser;
1027         int error;
1028         bool is_valid, is_valid2;
1029
1030         if (hereReviewList.empty()) return;
1031
1032         if (maps_item_list_create(&mapsReviewList) != MAPS_ERROR_NONE) return;
1033
1034         for (hereReview = hereReviewList.begin(); hereReview != hereReviewList.end(); hereReview++)
1035         {
1036                 if (maps_place_review_create(&mapsReview) != MAPS_ERROR_NONE) continue;
1037
1038                 is_valid = false;
1039
1040                 if (!hereReview->GetDateTime().empty())
1041                 {
1042                         error = maps_place_review_set_date(mapsReview,
1043                                 (char*)hereReview->GetDateTime().c_str());
1044                         is_valid |= (error == MAPS_ERROR_NONE);
1045                 }
1046
1047                 if (!hereReview->GetDescription().empty())
1048                 {
1049                         error = maps_place_review_set_description(mapsReview,
1050                                 (char*)hereReview->GetDescription().c_str());
1051                         is_valid |= (error == MAPS_ERROR_NONE);
1052                 }
1053
1054                 if (!hereReview->GetLanguage().empty())
1055                 {
1056                         error = maps_place_review_set_language(mapsReview,
1057                                 (char*)hereReview->GetLanguage().c_str());
1058                         is_valid |= (error == MAPS_ERROR_NONE);
1059                 }
1060
1061                 /* maps_place_review_set_media(mapsReview, maps_place_media_h media) */
1062
1063                 maps_place_review_set_rating(mapsReview, hereReview->GetRating());
1064
1065                 if (!hereReview->GetTitle().empty())
1066                 {
1067                         error = maps_place_review_set_title(mapsReview,
1068                                 (char*)hereReview->GetTitle().c_str());
1069                         is_valid |= (error == MAPS_ERROR_NONE);
1070                 }
1071
1072                 hereReviewUser = hereReview->GetUser();
1073                 if (maps_place_link_object_create(&mapsReviewUser) == MAPS_ERROR_NONE)
1074                 {
1075                         is_valid2 = false;
1076
1077                         if (!hereReviewUser.GetId().empty())
1078                         {
1079                                 error = maps_place_link_object_set_id(mapsReviewUser,
1080                                         (char*)hereReviewUser.GetId().c_str());
1081                                 is_valid2 |= (error == MAPS_ERROR_NONE);
1082                         }
1083
1084                         if (!hereReviewUser.GetTitle().empty())
1085                         {
1086                                 error = maps_place_link_object_set_name(mapsReviewUser,
1087                                         (char*)hereReviewUser.GetTitle().c_str());
1088                                 is_valid2 |= (error == MAPS_ERROR_NONE);
1089                         }
1090
1091                         if (!hereReviewUser.GetHref().empty())
1092                         {
1093                                 error = maps_place_link_object_set_string(mapsReviewUser,
1094                                         (char*)hereReviewUser.GetHref().c_str());
1095                                 is_valid2 |= (error == MAPS_ERROR_NONE);
1096                         }
1097
1098                         if (!hereReviewUser.GetType().empty())
1099                         {
1100                                 error = maps_place_link_object_set_type(mapsReviewUser,
1101                                         (char*)hereReviewUser.GetType().c_str());
1102                                 is_valid2 |= (error == MAPS_ERROR_NONE);
1103                         }
1104
1105                         if (is_valid2)
1106                         {
1107                                 maps_place_review_set_user_link(mapsReview, mapsReviewUser);
1108                                 is_valid |= is_valid2;
1109                         }
1110                         maps_place_link_object_destroy(mapsReviewUser);
1111                 }
1112
1113                 if (is_valid)
1114                 {
1115                         maps_item_list_append(mapsReviewList, mapsReview, maps_place_review_clone);
1116                 }
1117                 maps_place_review_destroy(mapsReview);
1118         }
1119
1120         if (maps_item_list_items(mapsReviewList))
1121         {
1122                 maps_place_set_reviews(mapsPlace, mapsReviewList);
1123                 maps_item_list_remove_all(mapsReviewList, maps_place_review_destroy);
1124         }
1125         maps_item_list_destroy(mapsReviewList);
1126 }
1127
1128 void HerePlace::ProcessPlaceRatings(PlaceDetails herePlace, maps_place_h mapsPlace)
1129 {
1130         Ratings hereRating = herePlace.GetRatings();
1131         maps_place_rating_h mapsRating;
1132
1133         if (maps_place_rating_create(&mapsRating) != MAPS_ERROR_NONE) return;
1134
1135         maps_place_rating_set_average(mapsRating, hereRating.GetAverage());
1136         maps_place_rating_set_count(mapsRating, hereRating.GetCount());
1137         maps_place_set_rating(mapsPlace, mapsRating);
1138         maps_place_rating_destroy(mapsRating);
1139 }
1140
1141 void HerePlace::ProcessPlaceRated(PlaceDetails herePlace, maps_place_h mapsPlace)
1142 {
1143         RelatedItem hereRelated = herePlace.GetRelatedItem();
1144         maps_place_link_object_h mapsRelated;
1145         int error;
1146         bool is_valid = false;
1147
1148         if (maps_place_link_object_create(&mapsRelated) != MAPS_ERROR_NONE) return;
1149
1150         //need to check if GetId() exist
1151         //maps_place_link_object_set_id(mapsRelated, hereRelated.GetId());
1152
1153         if (!hereRelated.GetTitle().empty())
1154         {
1155                 error = maps_place_link_object_set_name(mapsRelated,
1156                         (char*)hereRelated.GetTitle().c_str());
1157                 is_valid |= (error == MAPS_ERROR_NONE);
1158         }
1159
1160         if (!hereRelated.GetHref().empty())
1161         {
1162                 error = maps_place_link_object_set_string(mapsRelated,
1163                         (char*)hereRelated.GetHref().c_str());
1164                 is_valid |= (error == MAPS_ERROR_NONE);
1165         }
1166
1167         if (!hereRelated.GetType().empty())
1168         {
1169                 error = maps_place_link_object_set_type(mapsRelated,
1170                         (char*)hereRelated.GetType().c_str());
1171                 is_valid |= (error == MAPS_ERROR_NONE);
1172         }
1173
1174         if (is_valid)
1175         {
1176                 maps_place_set_related_link(mapsPlace, mapsRelated);
1177         }
1178         maps_place_link_object_destroy(mapsRelated);
1179 }
1180
1181 bool HerePlace::__compareWithTitle(const maps_place_h &item1, const maps_place_h &item2)
1182 {
1183         bool result = false;
1184         char *str1 = NULL, *str2 = NULL;
1185
1186         if (maps_place_get_name(item1, &str1) == MAPS_ERROR_NONE &&
1187                 maps_place_get_name(item2, &str2) == MAPS_ERROR_NONE)
1188         {
1189                 result = (strcmp(str1, str2) < 0);
1190         }
1191         g_free(str1);
1192         g_free(str2);
1193         return result;
1194 }
1195
1196 bool HerePlace::__compareWithId(const maps_place_h &item1, const maps_place_h &item2)
1197 {
1198         bool result = false;
1199         char *str1 = NULL, *str2 = NULL;
1200
1201         if (maps_place_get_id(item1, &str1) == MAPS_ERROR_NONE &&
1202                 maps_place_get_id(item2, &str2) == MAPS_ERROR_NONE)
1203         {
1204                 result = (strcmp(str1, str2) < 0);
1205         }
1206         g_free(str1);
1207         g_free(str2);
1208         return result;
1209 }
1210
1211 bool HerePlace::__compareWithDistance(const maps_place_h &item1, const maps_place_h &item2)
1212 {
1213         bool result = false;
1214         int num1 = 0, num2 = 0;
1215
1216         if (maps_place_get_distance(item1, &num1) == MAPS_ERROR_NONE &&
1217                 maps_place_get_distance(item2, &num2) == MAPS_ERROR_NONE)
1218         {
1219                 result = (num1 < num2);
1220         }
1221         return result;
1222 }
1223
1224 bool HerePlace::__compareWithRating(const maps_place_h &item1, const maps_place_h &item2)
1225 {
1226         bool result = false;
1227         maps_place_rating_h rat1 = NULL, rat2 = NULL;
1228         double num1 = 0, num2 = 0;      
1229
1230         if (maps_place_get_rating(item1, &rat1) == MAPS_ERROR_NONE &&
1231                 maps_place_get_rating(item2, &rat2) == MAPS_ERROR_NONE)
1232         {
1233                 if (maps_place_rating_get_average(rat1, &num1) == MAPS_ERROR_NONE &&
1234                         maps_place_rating_get_average(rat2, &num2) == MAPS_ERROR_NONE)
1235                 {
1236                         result = (num1 > num2);
1237                 }
1238         }
1239         maps_place_rating_destroy(rat1);
1240         maps_place_rating_destroy(rat2);
1241         return result;
1242 }
1243
1244 bool HerePlace::__compareWithCategoryCb(int index, int total,
1245                                          maps_place_category_h category,
1246                                          void *user_data)
1247 {
1248         user_data = category;
1249         return false;
1250 }
1251
1252 bool HerePlace::__compareWithCategory(const maps_place_h &item1, const maps_place_h &item2)
1253 {
1254         bool result = false;
1255         maps_place_category_h cat1 = NULL, cat2 = NULL;
1256         char *str1 = NULL, *str2 = NULL;
1257
1258         maps_place_foreach_category(item1, __compareWithCategoryCb, &cat1);
1259         maps_place_foreach_category(item2, __compareWithCategoryCb, &cat2);
1260
1261         if (maps_place_category_get_id(item1, &str1) == MAPS_ERROR_NONE &&
1262                 maps_place_category_get_id(item2, &str2) == MAPS_ERROR_NONE)
1263         {
1264                 result = (strcmp(str1, str2) < 0);
1265         }
1266         maps_place_category_destroy(item1);
1267         maps_place_category_destroy(item2);
1268         g_free(str1);
1269         g_free(str2);
1270         return result;
1271 }
1272
1273 void HerePlace::__sortList(PlaceList &list)
1274 {
1275         if (!m_szSortBy) return;
1276
1277         if (!strcmp(m_szSortBy, "name") || !strcmp(m_szSortBy, "title"))
1278         {
1279                 std::sort(list.begin(), list.end(), __compareWithTitle);
1280         }
1281         else if (!strcmp(m_szSortBy, "id"))
1282         {
1283                 std::sort(list.begin(), list.end(), __compareWithId);
1284         }
1285         else if (!strcmp(m_szSortBy, "distance"))
1286         {
1287                 std::sort(list.begin(), list.end(), __compareWithDistance);
1288         }
1289         else if (!strcmp(m_szSortBy, "rate") || !strcmp(m_szSortBy, "rating"))
1290         {
1291                 std::sort(list.begin(), list.end(), __compareWithRating);
1292         }
1293         else if (!strcmp(m_szSortBy, "category"))
1294         {
1295                 std::sort(list.begin(), list.end(), __compareWithCategory);
1296         }
1297 }
1298
1299 HERE_PLUGIN_END_NAMESPACE