always thanks for your good comments, but..
for me... it takes too much time to decipher your mail. :):):)

1. moved global value (hash) to widget structure.
2. fix stringshare bug
3. fix found | !found bug

please review new patch.

On Mon, Feb 21, 2011 at 3:55 PM, Carsten Haitzler <ras...@rasterman.com>wrote:

> On Mon, 21 Feb 2011 15:14:38 +0900 sangho park <gouach...@gmail.com> said:
>
> oh there it is. hmmm. i missed that. well i don't see a choice other than
> constructing the hash on the fly. but then you need to rebuild it all the
> time.
> ok ok, but tou need to make the hash table part of the map obj - not a
> global.
> you set eh agent on the map obj - but then use a global hash - and when
> freed u
> dont set it to NULL either. ripe for a segv. so move the hash back into the
> per-obj data but keep the agent as its own stringshare field. when you
> replace
> it - also update the hash. mind you your "if found in hash add has entry"
> shoudl be if !found then add, then set to agent string val.
>
> > the hash value is used by ecore_file_download_full.
> > + ecore_file_download_full(source, buf2, _tile_downloaded, NULL, gi,
> > &(gi->job), ua);
> >
> > 7th parameter of the function can be http headers, but elm_map uses only
> > 'User-Agent'.
> > if I don't use hash, what's your recommendation to use
> > ecore_file_download_full?
> >
> > please show me the way~~ :)
> >
> >
> > On Mon, Feb 21, 2011 at 2:47 PM, Carsten Haitzler <ras...@rasterman.com
> >wrote:
> >
> > > On Mon, 21 Feb 2011 10:27:25 +0900 sangho park <gouach...@gmail.com>
> said:
> > >
> > > a bit better... so now time to nitpick; \(^u^)/ <- yay!
> > >
> > > hash... why? didn't i just say not to use it?:
> > >
> > > +static Eina_Hash *ua = NULL;
> > > ...
> > > +   if (ua) eina_hash_free(ua);
> > > ...
> > > +   if (!ua) ua= eina_hash_string_small_new(NULL);
> > > +   if (eina_hash_find(ua, "User-Agent")) eina_hash_add(ua,
> "User-Agent",
> > > wd->user_agent);
> > > +   else eina_hash_set(ua, "User-Agent", wd->user_agent);
> > >
> > > > thanks raster.. elm_button is good example for me.
> > > > pls review my new patch.
> > > >
> > > > On Sun, Feb 20, 2011 at 11:01 PM, Carsten Haitzler
> > > > <ras...@rasterman.com>wrote:
> > > >
> > > > > On Fri, 18 Feb 2011 17:06:58 +0900 sangho park <
> gouach...@gmail.com>
> > > said:
> > > > >
> > > > > man your implementation is strange. why did you add a whole hash
> table
> > > to
> > > > > store
> > > > > a single string key with a single string value attached to it? why
> > > don't
> > > > > you
> > > > > just do it like all other elm widgets that need strings - like
> let's
> > > say
> > > > > elm_button does with the label?
> > > > >
> > > > > > Dear all,
> > > > > >
> > > > > > This is a patch for elm_map for setting user-agent.
> > > > > >
> > > > > > - Add elm_map_user_agent_set
> > > > > > - Add elm_map_user_agent_get
> > > > > > - modify doxygen
> > > > > >
> > > > > > elm_map uses OSM(OpenStreetMap), but we can add custom map
> provider.
> > > > > > If custom map provider server filters robot out (currently
> default
> > > > > > user-agent is 'curl'),
> > > > > > we need some APIs to set/get user-agent.
> > > > > >
> > > > > > pls review this patch.
> > > > > >
> > > > > > Thanks.
> > > > > > BR
> > > > >
> > > > >
> > > > > --
> > > > > ------------- Codito, ergo sum - "I code, therefore I am"
> > > --------------
> > > > > The Rasterman (Carsten Haitzler)    ras...@rasterman.com
> > > > >
> > > > >
> > >
> > >
> > > --
> > > ------------- Codito, ergo sum - "I code, therefore I am"
> --------------
> > > The Rasterman (Carsten Haitzler)    ras...@rasterman.com
> > >
> > >
>
>
> --
> ------------- Codito, ergo sum - "I code, therefore I am" --------------
> The Rasterman (Carsten Haitzler)    ras...@rasterman.com
>
>
Index: elementary/src/lib/Elementary.h.in
===================================================================
--- elementary/src/lib/Elementary.h.in  (리비전 57107)
+++ elementary/src/lib/Elementary.h.in  (작업 사본)
@@ -2118,6 +2118,8 @@ extern "C" {
    EAPI int                   elm_map_source_zoom_min_get(Elm_Map_Sources 
source);
    EAPI int                   elm_map_source_zoom_max_get(Elm_Map_Sources 
source);
    EAPI const char           *elm_map_source_name_get(Elm_Map_Sources source);
+   EAPI void                  elm_map_user_agent_set(Evas_Object *obj, const 
char *user_agent) EINA_ARG_NONNULL(1, 2);
+   EAPI const char           *elm_map_user_agent_get(Evas_Object *obj) 
EINA_ARG_NONNULL(1);
    /* smart callbacks called:
     * "clicked" - when image clicked
     * "press" - when mouse/finger held down initially on image
Index: elementary/src/lib/elm_map.c
===================================================================
--- elementary/src/lib/elm_map.c        (리비전 57107)
+++ elementary/src/lib/elm_map.c        (작업 사본)
@@ -5,7 +5,8 @@
  * @defgroup Map Map
  * @ingroup Elementary
  *
- * This is a widget specifically for displaying the free map OpenStreetMap.
+ * This is a widget specifically for displaying the map. It uses basically
+ * OpenStreetMap provider. but it can be added custom providers.
  *
  * Signals that you can add callbacks for are:
  *
@@ -263,6 +264,9 @@ struct _Widget_Data
    Eina_List *s_event_list;
    int try_num;
    int finish_num;
+
+   Eina_Hash *ua;
+   const char *user_agent;
 };
 
 struct _Mod_Api
@@ -1001,7 +1005,7 @@ grid_load(Evas_Object *obj, Grid *g)
                       else
                         {
                            DBG("DOWNLOAD %s \t in %s", source, buf2);
-                           ecore_file_download(source, buf2, _tile_downloaded, 
NULL, gi, &(gi->job));
+                           ecore_file_download_full(source, buf2, 
_tile_downloaded, NULL, gi, &(gi->job), wd->ua);
                             if (!gi->job)
                               DBG("Can't start to download %s", buf);
                             else
@@ -1432,6 +1436,8 @@ _del_hook(Evas_Object *obj)
    if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
    if (wd->long_timer) ecore_timer_del(wd->long_timer);
    if ((wd->api) && (wd->api->obj_unhook)) wd->api->obj_unhook(obj);
+   if (wd->user_agent) eina_stringshare_del(wd->user_agent);
+   if (wd->ua) eina_hash_free(wd->ua);
 
    free(wd);
 }
@@ -3544,7 +3550,48 @@ elm_map_source_name_get(Elm_Map_Sources source)
    return map_sources_tab[source].name;
 }
 
+/**
+ * Set the user agent of the widget map.
+ *
+ * @param obj The map object
+ * @param user_agent the user agent of the widget map
+ *
+ * @ingroup Map
+ */
+EAPI void
+elm_map_user_agent_set(Evas_Object *obj, const char *user_agent)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype);
+   Widget_Data *wd = elm_widget_data_get(obj);
 
+   if (!wd) return;
+   if (!wd->user_agent) wd->user_agent = eina_stringshare_add(user_agent);
+   else eina_stringshare_replace(&wd->user_agent, user_agent);
+   
+   if (!wd->ua) wd->ua = eina_hash_string_small_new(NULL);
+   if (!eina_hash_find(wd->ua, "User-Agent")) eina_hash_add(wd->ua, 
"User-Agent", user_agent);
+   else eina_hash_set(wd->ua, "User-Agent", user_agent);
+}
+
+/**
+ * Get the user agent of the widget map.
+ *
+ * @param obj The map object
+ * @return The user agent of the widget map
+ *
+ * @ingroup Map
+ */
+EAPI const char *
+elm_map_user_agent_get(Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) NULL;
+   Widget_Data *wd = elm_widget_data_get(obj);
+
+   if (!wd) return NULL;
+   return wd->user_agent;
+}
+
+
 static char *
 _mapnik_url_cb(Evas_Object *obj __UNUSED__, int x, int y, int zoom)
 {
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to