Dear all,

This is a patch for elm_map downloading progress info.

I added one new signal, one new API and fixed seg fault bug.

- signal : "download" (this signal is called when map_tile is downloaded)
- API : elm_map_utils_downloading_status_get(const Evas_Object *obj, int
*try_num, int *finish_num)
- seg fault : if user select custom map provider, seg fault occurs, because
there is no url_cb in the custom map provider

you can check download progress using these signal & API.
the example is in "test_map.c".

thanks.
Index: src/lib/elm_map.c
===================================================================
--- src/lib/elm_map.c   (리비전 56014)
+++ src/lib/elm_map.c   (작업 사본)
@@ -19,9 +19,9 @@
  *
  * clicked,double - This is called when a user has double-clicked the photo.
  *
- * load,details - Map detailed data load begins.
+ * load,detail - Map detailed data load begins.
  *
- * loaded,details - This is called when all parts of the map are loaded.
+ * loaded,detail - This is called when all parts of the map are loaded.
  *
  * zoom,start - Zoom animation started.
  *
@@ -39,6 +39,8 @@
  *
  * scroll,drag,stop - dragging the contents around has stopped
  *
+ * download- Map image data download.
+ *
  * TODO : doxygen
  */
 
@@ -70,23 +72,30 @@ typedef struct _Map_Sources_Tab
 #define ZOOM_MAX 18
 
 //Zemm min is supposed to be 0
-static char *_mapnik_url_cb(Evas_Object *obj __UNUSED__,int x, int y, int 
zoom);
-static char *_osmarender_url_cb(Evas_Object *obj __UNUSED__,int x, int y, int 
zoom);
-static char *_cyclemap_url_cb(Evas_Object *obj __UNUSED__,int x, int y, int 
zoom);
-static char *_maplint_url_cb(Evas_Object *obj __UNUSED__,int x, int y, int 
zoom);
-static char *_module_url_cb(Evas_Object *obj,int x, int y, int zoom);
+static char *_mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int 
zoom);
+static char *_osmarender_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int 
zoom);
+static char *_cyclemap_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int 
zoom);
+static char *_maplint_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int 
zoom);
+static char *_module_url_cb(Evas_Object *obj, int x, int y, int zoom);
+static char * _custom1_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int 
zoom);
+static char * _custom2_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int 
zoom);
+static char * _custom3_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int 
zoom);
+static char * _custom4_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int 
zoom);
+static char * _custom5_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int 
zoom);
+static char * _custom6_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int 
zoom);
+
 static Map_Sources_Tab map_sources_tab[] =
 {
      {ELM_MAP_SOURCE_MAPNIK, "Mapnik", 0, 18, _mapnik_url_cb},
      {ELM_MAP_SOURCE_OSMARENDER, "Osmarender", 0, 17, _osmarender_url_cb},
      {ELM_MAP_SOURCE_CYCLEMAP, "Cycle Map", 0, 17, _cyclemap_url_cb},
      {ELM_MAP_SOURCE_MAPLINT, "Maplint", 12, 16, _maplint_url_cb},
-     {ELM_MAP_SOURCE_CUSTOM_1, "Custom 1", 0, 18, NULL},
-     {ELM_MAP_SOURCE_CUSTOM_2, "Custom 2", 0, 18, NULL},
-     {ELM_MAP_SOURCE_CUSTOM_3, "Custom 3", 0, 18, NULL},
-     {ELM_MAP_SOURCE_CUSTOM_4, "Custom 4", 0, 18, NULL},
-     {ELM_MAP_SOURCE_CUSTOM_5, "Custom 5", 0, 18, NULL},
-     {ELM_MAP_SOURCE_CUSTOM_6, "Custom 6", 0, 18, NULL},
+     {ELM_MAP_SOURCE_CUSTOM_1, "Custom 1", 0, 18, _custom1_url_cb},
+     {ELM_MAP_SOURCE_CUSTOM_2, "Custom 2", 0, 18, _custom2_url_cb},
+     {ELM_MAP_SOURCE_CUSTOM_3, "Custom 3", 0, 18, _custom3_url_cb},
+     {ELM_MAP_SOURCE_CUSTOM_4, "Custom 4", 0, 18, _custom4_url_cb},
+     {ELM_MAP_SOURCE_CUSTOM_5, "Custom 5", 0, 18, _custom5_url_cb},
+     {ELM_MAP_SOURCE_CUSTOM_6, "Custom 6", 0, 18, _custom6_url_cb},
      {ELM_MAP_SOURCE_MODULE, "Module", 0, 18, _module_url_cb}
 };
 
@@ -252,6 +261,8 @@ struct _Widget_Data
    Elm_Map_Sources source;
    Mod_Api *api;
    Eina_List *s_event_list;
+   int try_num;
+   int finish_num;
 };
 
 struct _Mod_Api
@@ -300,6 +311,7 @@ static const char SIG_SCROLL_DRAG_STOP[] = "scroll
 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
 static const char SIG_ZOOM_START[] = "zoom,start";
 static const char SIG_ZOOM_STOP[] = "zoom,stop";
+static const char SIG_DOWNLOAD[] = "download";
 static const Evas_Smart_Cb_Description _signals[] = {
   {SIG_CHANGED, ""},
   {SIG_CLICKED, ""},
@@ -314,6 +326,7 @@ static const Evas_Smart_Cb_Description _signals[]
   {SIG_ZOOM_CHANGE, ""},
   {SIG_ZOOM_START, ""},
   {SIG_ZOOM_STOP, ""},
+  {SIG_DOWNLOAD, ""},
   {NULL, NULL}
 };
 
@@ -713,6 +726,7 @@ grid_clear(Evas_Object *obj, Grid *g)
             ecore_file_download_abort(gi->job);
             ecore_file_remove(gi->file);
             gi->job = NULL;
+            wd->try_num--;
          }
        if (gi->file)
          eina_stringshare_del(gi->file);
@@ -767,6 +781,10 @@ _tile_downloaded(void *data, const char *file __UN
        DBG("Download failed %s (%d) ", gi->file, status);
        ecore_file_remove(gi->file);
      }
+   else
+     gi->wd->finish_num++;
+
+   evas_object_smart_callback_call(gi->wd->obj, SIG_DOWNLOAD, NULL);
 }
 
 static Grid *
@@ -852,14 +870,6 @@ grid_load(Evas_Object *obj, Grid *g)
          {
             if (gi->want)
               {
-                 wd->preload_num--;
-                 if (!wd->preload_num)
-                   {
-                      
edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
-                                               "elm,state,busy,stop", "elm");
-                      evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL,
-                                                      NULL);
-                   }
                  evas_object_hide(gi->img);
                  //evas_object_hide(gi->txt);
                  evas_object_image_file_set(gi->img, NULL, NULL);
@@ -872,8 +882,18 @@ grid_load(Evas_Object *obj, Grid *g)
                       ecore_file_download_abort(gi->job);
                       ecore_file_remove(gi->file);
                       gi->job = NULL;
+                       wd->try_num--;
                    }
                  gi->download = EINA_FALSE;
+                 wd->preload_num--;
+                 if (!wd->preload_num)
+                   {
+                      
edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
+                                               "elm,state,busy,stop", "elm");
+                      evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL,
+                                                      NULL);
+                   }
+
               }
             else if (gi->have)
               {
@@ -982,8 +1002,10 @@ grid_load(Evas_Object *obj, Grid *g)
                         {
                            DBG("DOWNLOAD %s \t in %s", source, buf2);
                            ecore_file_download(source, buf2, _tile_downloaded, 
NULL, gi, &(gi->job));
-                           if (!gi->job)
-                             DBG("Can't start to download %s", buf);
+                            if (!gi->job)
+                              DBG("Can't start to download %s", buf);
+                            else
+                              wd->try_num++;
                         }
                    }
                  if (source) free(source);
@@ -2658,6 +2680,35 @@ elm_map_paused_markers_get(const Evas_Object *obj)
 }
 
 /**
+ * Get the information of downloading status
+ *
+ * This gets the current downloading status for the map object.
+ *
+ * @param obj The map object
+ * @param try_num the number of download trying map
+ * @param finish_num the number of downloaded map
+ *
+ * @ingroup Map
+ */
+
+EAPI void 
+elm_map_utils_downloading_status_get(const Evas_Object *obj, int *try_num, int 
*finish_num)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return EINA_FALSE;
+
+   if (try_num)
+     {
+        *try_num = wd->try_num;
+     }
+
+   if (finish_num)
+     {
+        *finish_num = wd->finish_num;
+     }
+}
+/**
  * Convert a pixel coordinate (x,y) into a geographic coordinate (longitude, 
latitude).
  *
  * @param obj The map object
@@ -3525,6 +3576,42 @@ _maplint_url_cb(Evas_Object *obj __UNUSED__, int x
 }
 
 static char *
+_custom1_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
+{
+   return strdup("");
+}
+
+static char *
+_custom2_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
+{
+   return strdup("");
+}
+
+static char *
+_custom3_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
+{
+   return strdup("");
+}
+
+static char *
+_custom4_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
+{
+   return strdup("");
+}
+
+static char *
+_custom5_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
+{
+   return strdup("");
+}
+
+static char *
+_custom6_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
+{
+   return strdup("");
+}
+
+static char *
 _module_url_cb(Evas_Object *obj, int x, int y, int zoom)
 {
    char *buf = NULL;
Index: src/bin/test_map.c
===================================================================
--- src/bin/test_map.c  (리비전 56014)
+++ src/bin/test_map.c  (작업 사본)
@@ -55,30 +55,18 @@ my_map_clicked_double(void *data __UNUSED__, Evas_
 }
 
 static void
-my_map_load(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void 
*event_info __UNUSED__)
+my_map_load_detail(void *data, Evas_Object *obj __UNUSED__, void *event_info 
__UNUSED__)
 {
-   printf("load\n");
+   printf("load,detail\n");
 }
 
 static void
-my_map_loaded(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void 
*event_info __UNUSED__)
+my_map_loaded_detail(void *data, Evas_Object *obj __UNUSED__, void *event_info 
__UNUSED__)
 {
-   printf("loaded\n");
+   printf("loaded,detail\n");
 }
 
 static void
-my_map_load_details(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void 
*event_info __UNUSED__)
-{
-   printf("load,details\n");
-}
-
-static void
-my_map_loaded_details(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void 
*event_info __UNUSED__)
-{
-   printf("loaded,details\n");
-}
-
-static void
 my_map_zoom_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void 
*event_info __UNUSED__)
 {
    printf("zoom,start\n");
@@ -129,6 +117,14 @@ my_map_scroll(void *data __UNUSED__, Evas_Object *
 }
 
 static void
+my_map_downloading(void *data, Evas_Object *obj __UNUSED__, void *event_info 
__UNUSED__)
+{
+   int try_num, finish_num;
+   elm_map_utils_downloading_status_get(data, &try_num, &finish_num);
+   printf("downloading : %d / %d\n", finish_num, try_num);
+}
+
+static void
 my_bt_show_reg(void *data, Evas_Object *obj __UNUSED__, void *event_info 
__UNUSED__)
 {
    Eina_Bool b = elm_map_paused_get(data);
@@ -445,10 +441,8 @@ test_map(void *data __UNUSED__, Evas_Object *obj _
         evas_object_smart_callback_add(map, "press", my_map_press, win);
         evas_object_smart_callback_add(map, "longpressed", my_map_longpressed, 
win);
         evas_object_smart_callback_add(map, "clicked,double", 
my_map_clicked_double, win);
-        evas_object_smart_callback_add(map, "load", my_map_load, win);
-        evas_object_smart_callback_add(map, "loaded", my_map_loaded, win);
-        evas_object_smart_callback_add(map, "load,details", 
my_map_load_details, win);
-        evas_object_smart_callback_add(map, "loaded,details", 
my_map_loaded_details, win);
+        evas_object_smart_callback_add(map, "load,detail", my_map_load_detail, 
win);
+        evas_object_smart_callback_add(map, "loaded,detail", 
my_map_loaded_detail, win);
         evas_object_smart_callback_add(map, "zoom,start", my_map_zoom_start, 
win);
         evas_object_smart_callback_add(map, "zoom,stop", my_map_zoom_stop, 
win);
         evas_object_smart_callback_add(map, "zoom,change", my_map_zoom_change, 
win);
@@ -457,6 +451,7 @@ test_map(void *data __UNUSED__, Evas_Object *obj _
         evas_object_smart_callback_add(map, "scroll,drag,start", 
my_map_drag_start, win);
         evas_object_smart_callback_add(map, "scroll,drag,stop", 
my_map_drag_stop, win);
         evas_object_smart_callback_add(map, "scroll", my_map_scroll, win);
+        evas_object_smart_callback_add(map, "downloading", my_map_downloading, 
map);
 
         evas_object_show(map);
 
Index: src/lib/Elementary.h.in
===================================================================
--- src/lib/Elementary.h.in     (리비전 56014)
+++ src/lib/Elementary.h.in     (작업 사본)
@@ -2071,6 +2071,7 @@ extern "C" {
    EAPI Eina_Bool             elm_map_paused_get(const Evas_Object *obj) 
EINA_ARG_NONNULL(1);
    EAPI void                  elm_map_paused_markers_set(Evas_Object *obj, 
Eina_Bool paused) EINA_ARG_NONNULL(1);
    EAPI Eina_Bool             elm_map_paused_markers_get(const Evas_Object 
*obj) EINA_ARG_NONNULL(1);
+   EAPI void                  elm_map_utils_downloading_status_get(const 
Evas_Object *obj, int *try_num, int *finish_num) EINA_ARG_NONNULL(1, 2, 3);
    EAPI void                 elm_map_utils_convert_coord_into_geo(const 
Evas_Object *obj, int x, int y, int size, double *lon, double *lat);
    EAPI void                  elm_map_utils_convert_geo_into_coord(const 
Evas_Object *obj, double lon, double lat, int size, int *x, int *y);
    EAPI Elm_Map_Marker       *elm_map_marker_add(Evas_Object *obj, double lon, 
double lat, Elm_Map_Marker_Class *clas, Elm_Map_Group_Class *clas_group, void 
*data) EINA_ARG_NONNULL(1, 4, 5);
------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to