Fix ticket #343 (autoscroll and resizable not being set after restart).
Formatting.
Whitespace Removal.
Variable cleanup.
Add missing 'static' declaration on private function.
Move EAPI functions to be together in the source before local functions.

git-svn-id: 6ac5796aeae0cef97fb47bcc287d4ce899c6fa6e@41246 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/bin/e_gadcon.c
+++ src/bin/e_gadcon.c
@@ -132,9 +132,10 @@
 {
    int pos, size, prev_pos, prev_size;

-   struct {
-      int min_seq, max_seq;
-   } state_info;
+   struct
+     {
+        int min_seq, max_seq;
+     } state_info;

    E_Smart_Data *sd;
    Eina_List *items;
@@ -276,18 +277,18 @@
 EAPI E_Gadcon *
 e_gadcon_swallowed_new(const char *name, int id, Evas_Object *obj, char *swallow_name)
 {
-   E_Gadcon    *gc;
-   Eina_List   *l;
-   Evas_Coord   x, y, w, h;
-   const char  *drop_types[] = { "enlightenment/gadcon_client" };
-
+   E_Gadcon *gc;
+   Eina_List *l;
+   Evas_Coord x, y, w, h;
+   const char *drop_types[] = { "enlightenment/gadcon_client" };
+
    gc = E_OBJECT_ALLOC(E_Gadcon, E_GADCON_TYPE, _e_gadcon_free);
    if (!gc) return NULL;
-
+
    gc->name = eina_stringshare_add(name);
    gc->id = id;
    gc->layout_policy = E_GADCON_LAYOUT_POLICY_PANEL;
-
+
    gc->edje.o_parent = obj;
    gc->edje.swallow_name = eina_stringshare_add(swallow_name);

@@ -295,11 +296,11 @@
    gc->evas = evas_object_evas_get(obj);
    gc->o_container = e_gadcon_layout_add(gc->evas);
    evas_object_geometry_get(gc->o_container, &x, &y, &w, &h);
-   gc->drop_handler = e_drop_handler_add(E_OBJECT(gc), gc,
-					 _e_gadcon_cb_dnd_enter, _e_gadcon_cb_dnd_move,
-					 _e_gadcon_cb_dnd_leave, _e_gadcon_cb_drop,
-					 drop_types, 1,
-					 x, y, w, h);
+   gc->drop_handler =
+     e_drop_handler_add(E_OBJECT(gc), gc,
+                        _e_gadcon_cb_dnd_enter, _e_gadcon_cb_dnd_move,
+                        _e_gadcon_cb_dnd_leave, _e_gadcon_cb_drop,
+                        drop_types, 1, x, y, w, h);
    evas_object_event_callback_add(gc->o_container, EVAS_CALLBACK_MOVE,
 				  _e_gadcon_cb_moveresize, gc);
    evas_object_event_callback_add(gc->o_container, EVAS_CALLBACK_RESIZE,
@@ -318,8 +319,7 @@
 	E_Config_Gadcon *cf_gc;

 	cf_gc = l->data;
-	if ((!strcmp(cf_gc->name, gc->name)) &&
-	    (cf_gc->id == gc->id))
+	if ((!strcmp(cf_gc->name, gc->name)) && (cf_gc->id == gc->id))
 	  {
 	     gc->cf = cf_gc;
 	     break;
@@ -352,7 +352,6 @@
 {
    E_OBJECT_CHECK(gc);
    E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
-
    gc->min_size_request.func = func;
    gc->min_size_request.data = data;
 }
@@ -362,7 +361,6 @@
 {
    E_OBJECT_CHECK(gc);
    E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
-
    gc->resize_request.func = func;
    gc->resize_request.data = data;
 }
@@ -372,7 +370,6 @@
 {
    E_OBJECT_CHECK(gc);
    E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
-
    gc->frame_request.func = func;
    gc->frame_request.data = data;
 }
@@ -382,7 +379,6 @@
 {
    E_OBJECT_CHECK(gc);
    E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
-
    gc->populate_class.func = func;
    gc->populate_class.data = data;
 }
@@ -401,7 +397,7 @@
 e_gadcon_populate(E_Gadcon *gc)
 {
    Eina_List *l;
-
+
    E_OBJECT_CHECK(gc);
    E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
    e_gadcon_layout_freeze(gc->o_container);
@@ -446,7 +442,7 @@
 		    e_gadcon_layout_pack_options_set(gcc->o_frame, gcc);
 		  else if (gcc->o_base)
 		    e_gadcon_layout_pack_options_set(gcc->o_base, gcc);
-
+
 		  e_gadcon_client_autoscroll_set(gcc, cf_gcc->autoscroll);
 		  e_gadcon_client_resizable_set(gcc, cf_gcc->resizable);
 		  if (gcc->client_class->func.orient)
@@ -466,7 +462,7 @@
 e_gadcon_unpopulate(E_Gadcon *gc)
 {
    E_Gadcon_Client *gcc;
-
+
    E_OBJECT_CHECK(gc);
    E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
    while (gc->clients)
@@ -487,7 +483,7 @@
 e_gadcon_populate_class(E_Gadcon *gc, const E_Gadcon_Client_Class *cc)
 {
    Eina_List *l;
-
+
    E_OBJECT_CHECK(gc);
    E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
    e_gadcon_layout_freeze(gc->o_container);
@@ -522,6 +518,8 @@
 		  else if (gcc->o_base)
 		    e_gadcon_layout_pack_options_set(gcc->o_base, gcc);

+		  e_gadcon_client_autoscroll_set(gcc, cf_gcc->autoscroll);
+		  e_gadcon_client_resizable_set(gcc, cf_gcc->resizable);
 		  if (gcc->client_class->func.orient)
 		    gcc->client_class->func.orient(gcc, gc->orient);

@@ -540,7 +538,7 @@
 {
    Eina_List *l;
    int horiz = 0;
-
+
    E_OBJECT_CHECK(gc);
    E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
    if (gc->orient == orient) return;
@@ -574,7 +572,7 @@
    for (l = gc->clients; l; l = l->next)
      {
 	E_Gadcon_Client *gcc;
-
+
 	gcc = l->data;
 	e_box_orientation_set(gcc->o_box, horiz);
 	if (gcc->client_class->func.orient)
@@ -587,7 +585,7 @@
 e_gadcon_edit_begin(E_Gadcon *gc)
 {
    Eina_List *l;
-
+
    E_OBJECT_CHECK(gc);
    E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
    e_gadcon_layout_freeze(gc->o_container);
@@ -596,7 +594,7 @@
    for (l = gc->clients; l; l = l->next)
      {
 	E_Gadcon_Client *gcc;
-
+
 	gcc = l->data;
 	e_gadcon_client_edit_begin(gcc);
      }
@@ -607,7 +605,7 @@
 e_gadcon_edit_end(E_Gadcon *gc)
 {
    Eina_List *l;
-
+
    E_OBJECT_CHECK(gc);
    E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
    e_gadcon_layout_freeze(gc->o_container);
@@ -615,7 +613,7 @@
    for (l = gc->clients; l; l = l->next)
      {
 	E_Gadcon_Client *gcc;
-
+
 	gcc = l->data;
 	e_gadcon_client_edit_end(gcc);
      }
@@ -627,11 +625,11 @@
 e_gadcon_all_edit_begin(void)
 {
    Eina_List *l;
-
+
    for (l = gadcons; l; l = l->next)
      {
 	E_Gadcon *gc;
-
+
 	gc = l->data;
 	e_gadcon_edit_begin(gc);
      }
@@ -641,11 +639,11 @@
 e_gadcon_all_edit_end(void)
 {
    Eina_List *l;
-
+
    for (l = gadcons; l; l = l->next)
      {
 	E_Gadcon *gc;
-
+
 	gc = l->data;
 	e_gadcon_edit_end(gc);
      }
@@ -703,9 +701,8 @@
 }

 EAPI void
-e_gadcon_util_lock_func_set(E_Gadcon *gc,
-				   void (*func) (void *data, int lock),
-				   void *data)
+e_gadcon_util_lock_func_set(E_Gadcon *gc, void (*func) (void *data, int lock),
+                            void *data)
 {
    E_OBJECT_CHECK(gc);
    E_OBJECT_TYPE_CHECK(gc, E_GADCON_TYPE);
@@ -714,8 +711,7 @@
 }

 EAPI void
-e_gadcon_util_urgent_show_func_set(E_Gadcon *gc,
-				   void (*func) (void *data),
+e_gadcon_util_urgent_show_func_set(E_Gadcon *gc, void (*func) (void *data),
 				   void *data)
 {
    E_OBJECT_CHECK(gc);
@@ -791,16 +787,16 @@
 EAPI E_Config_Gadcon_Client *
 e_gadcon_client_config_new(E_Gadcon *gc, const char *name)
 {
-   E_Gadcon_Client_Class  *cc;
+   E_Gadcon_Client_Class *cc;
    E_Config_Gadcon_Client *cf_gcc;

    E_OBJECT_CHECK_RETURN(gc, NULL);
    E_OBJECT_TYPE_CHECK_RETURN(gc, E_GADCON_TYPE, NULL);
    if (!name) return NULL;
-
    cc = eina_hash_find(providers, name);
    if (!cc) return NULL;
-   if (!_e_gadcon_client_class_feature_check(cc, "id_new", cc->func.id_new)) return NULL;
+   if (!_e_gadcon_client_class_feature_check(cc, "id_new", cc->func.id_new))
+     return NULL;

    cf_gcc = E_NEW(E_Config_Gadcon_Client, 1);
    if (!cf_gcc) return NULL;
@@ -821,7 +817,6 @@
 e_gadcon_client_config_del(E_Config_Gadcon *cf_gc, E_Config_Gadcon_Client *cf_gcc)
 {
    if (!cf_gcc) return;
-
    if (cf_gcc->name) eina_stringshare_del(cf_gcc->name);
    if (cf_gcc->id) eina_stringshare_del(cf_gcc->id);
    if (cf_gcc->style) eina_stringshare_del(cf_gcc->style);
@@ -833,10 +828,11 @@
 e_gadcon_client_new(E_Gadcon *gc, const char *name, const char *id, const char *style, Evas_Object *base_obj)
 {
    E_Gadcon_Client *gcc;
-
+
    E_OBJECT_CHECK_RETURN(gc, NULL);
    E_OBJECT_TYPE_CHECK_RETURN(gc, E_GADCON_TYPE, NULL);
-   gcc = E_OBJECT_ALLOC(E_Gadcon_Client, E_GADCON_CLIENT_TYPE, _e_gadcon_client_free);
+   gcc = E_OBJECT_ALLOC(E_Gadcon_Client, E_GADCON_CLIENT_TYPE,
+                        _e_gadcon_client_free);
    if (!gcc) return NULL;
    gcc->name = eina_stringshare_add(name);
    gcc->gadcon = gc;
@@ -914,12 +910,10 @@
 e_gadcon_client_edit_begin(E_Gadcon_Client *gcc)
 {
    Evas_Coord x, y, w, h;
-
+
    E_OBJECT_CHECK(gcc);
    E_OBJECT_TYPE_CHECK(gcc, E_GADCON_CLIENT_TYPE);
-
    if (gcc->o_control) return;
-
    e_gadcon_locked_set(gcc->gadcon, 1);
    gcc->gadcon->editing = 1;
    gcc->o_control = edje_object_add(gcc->gadcon->evas);
@@ -931,7 +925,8 @@
    else return; /* make clang happy */
    evas_object_move(gcc->o_control, x, y);
    evas_object_resize(gcc->o_control, w, h);
-   e_theme_edje_object_set(gcc->o_control, "base/theme/gadman", "e/gadman/control");
+   e_theme_edje_object_set(gcc->o_control, "base/theme/gadman",
+                           "e/gadman/control");

    if ((gcc->autoscroll) || (gcc->resizable))
      {
@@ -946,7 +941,7 @@
 	edje_object_signal_emit(gcc->o_control, "e,state,vsize,off", "e");
      }
    edje_object_signal_emit(gcc->o_control, "e,state,move,on", "e");
-
+
    gcc->o_event = evas_object_rectangle_add(gcc->gadcon->evas);
    evas_object_color_set(gcc->o_event, 0, 0, 0, 0);
    evas_object_repeat_events_set(gcc->o_event, 1);
@@ -984,23 +979,31 @@
 				   _e_gadcon_cb_signal_resize_right_stop, gcc);
    edje_object_signal_callback_add(gcc->o_control, "e,action,resize,down,go", "",
 				   _e_gadcon_cb_signal_resize_right_go, gcc);
-
-   evas_object_event_callback_add(gcc->o_event, EVAS_CALLBACK_MOUSE_DOWN, _e_gadcon_cb_client_mouse_down, gcc);
-   evas_object_event_callback_add(gcc->o_event, EVAS_CALLBACK_MOUSE_UP, _e_gadcon_cb_client_mouse_up, gcc);
-   evas_object_event_callback_add(gcc->o_event, EVAS_CALLBACK_MOUSE_IN, _e_gadcon_cb_client_mouse_in, gcc);
-   evas_object_event_callback_add(gcc->o_event, EVAS_CALLBACK_MOUSE_OUT, _e_gadcon_cb_client_mouse_out, gcc);
+
+   evas_object_event_callback_add(gcc->o_event, EVAS_CALLBACK_MOUSE_DOWN,
+                                  _e_gadcon_cb_client_mouse_down, gcc);
+   evas_object_event_callback_add(gcc->o_event, EVAS_CALLBACK_MOUSE_UP,
+                                  _e_gadcon_cb_client_mouse_up, gcc);
+   evas_object_event_callback_add(gcc->o_event, EVAS_CALLBACK_MOUSE_IN,
+                                  _e_gadcon_cb_client_mouse_in, gcc);
+   evas_object_event_callback_add(gcc->o_event, EVAS_CALLBACK_MOUSE_OUT,
+                                  _e_gadcon_cb_client_mouse_out, gcc);

    if (gcc->o_frame)
      {
-	evas_object_event_callback_add(gcc->o_frame, EVAS_CALLBACK_MOVE, _e_gadcon_cb_client_move, gcc);
-	evas_object_event_callback_add(gcc->o_frame, EVAS_CALLBACK_RESIZE, _e_gadcon_cb_client_resize, gcc);
+	evas_object_event_callback_add(gcc->o_frame, EVAS_CALLBACK_MOVE,
+                                       _e_gadcon_cb_client_move, gcc);
+	evas_object_event_callback_add(gcc->o_frame, EVAS_CALLBACK_RESIZE,
+                                       _e_gadcon_cb_client_resize, gcc);
      }
    else if (gcc->o_base)
      {
-	evas_object_event_callback_add(gcc->o_base, EVAS_CALLBACK_MOVE, _e_gadcon_cb_client_move, gcc);
-	evas_object_event_callback_add(gcc->o_base, EVAS_CALLBACK_RESIZE, _e_gadcon_cb_client_resize, gcc);
-     }
-
+	evas_object_event_callback_add(gcc->o_base, EVAS_CALLBACK_MOVE,
+                                       _e_gadcon_cb_client_move, gcc);
+	evas_object_event_callback_add(gcc->o_base, EVAS_CALLBACK_RESIZE,
+                                       _e_gadcon_cb_client_resize, gcc);
+     }
+
    evas_object_show(gcc->o_event);
    evas_object_show(gcc->o_control);
 }
@@ -1012,18 +1015,22 @@

    E_OBJECT_CHECK(gcc);
    E_OBJECT_TYPE_CHECK(gcc, E_GADCON_CLIENT_TYPE);
-
+
    if (gcc->o_frame)
      {
-	evas_object_event_callback_del(gcc->o_frame, EVAS_CALLBACK_MOVE, _e_gadcon_cb_client_move);
-	evas_object_event_callback_del(gcc->o_frame, EVAS_CALLBACK_RESIZE, _e_gadcon_cb_client_resize);
+	evas_object_event_callback_del(gcc->o_frame, EVAS_CALLBACK_MOVE,
+                                       _e_gadcon_cb_client_move);
+	evas_object_event_callback_del(gcc->o_frame, EVAS_CALLBACK_RESIZE,
+                                       _e_gadcon_cb_client_resize);
      }
    else if (gcc->o_base)
      {
-	evas_object_event_callback_del(gcc->o_base, EVAS_CALLBACK_MOVE, _e_gadcon_cb_client_move);
-	evas_object_event_callback_del(gcc->o_base, EVAS_CALLBACK_RESIZE, _e_gadcon_cb_client_resize);
-     }
-
+	evas_object_event_callback_del(gcc->o_base, EVAS_CALLBACK_MOVE,
+                                       _e_gadcon_cb_client_move);
+	evas_object_event_callback_del(gcc->o_base, EVAS_CALLBACK_RESIZE,
+                                       _e_gadcon_cb_client_resize);
+     }
+
    if (gcc->moving)
      {
 	gcc->moving = 0;
@@ -1033,13 +1040,12 @@
    gcc->o_event = NULL;
    if (gcc->o_control) evas_object_del(gcc->o_control);
    gcc->o_control = NULL;
-
+
    for (l = gcc->gadcon->clients; l; l = l->next)
      {
 	E_Gadcon_Client *client = NULL;
-
-	client = l->data;
-	if (!client) continue;
+
+	if (!(client = l->data)) continue;
 	if (client->o_control) return;
      }
    gcc->gadcon->editing = 0;
@@ -1131,7 +1137,8 @@
    if ((!gcc->autoscroll) && (!gcc->resizable))
      {
 	if (gcc->o_frame)
-	  e_gadcon_layout_pack_min_size_set(gcc->o_frame, w + gcc->pad.w, h + gcc->pad.h);
+	  e_gadcon_layout_pack_min_size_set(gcc->o_frame, w + gcc->pad.w,
+                                            h + gcc->pad.h);
 	else if (gcc->o_base)
 	  e_gadcon_layout_pack_min_size_set(gcc->o_base, w, h);
      }
@@ -1149,7 +1156,8 @@
      {
 	if (gcc->o_frame)
 	  {
-	     e_gadcon_layout_pack_aspect_pad_set(gcc->o_frame, gcc->pad.w, gcc->pad.h);
+	     e_gadcon_layout_pack_aspect_pad_set(gcc->o_frame, gcc->pad.w,
+                                                 gcc->pad.h);
 	     e_gadcon_layout_pack_aspect_set(gcc->o_frame, w, h);
 	  }
 	else if (gcc->o_base)
@@ -1163,13 +1171,14 @@
 {
    E_OBJECT_CHECK(gcc);
    E_OBJECT_TYPE_CHECK(gcc, E_GADCON_CLIENT_TYPE);
-
+
    gcc->autoscroll = autoscroll;
    if (gcc->autoscroll)
      {
 	if (gcc->o_frame)
 	  {
-	     e_gadcon_layout_pack_aspect_pad_set(gcc->o_frame, gcc->pad.w, gcc->pad.h);
+	     e_gadcon_layout_pack_aspect_pad_set(gcc->o_frame, gcc->pad.w,
+                                                 gcc->pad.h);
 	     e_gadcon_layout_pack_aspect_set(gcc->o_frame, 0, 0);
 	     e_gadcon_layout_pack_min_size_set(gcc->o_frame, 0, 0);
 	  }
@@ -1183,14 +1192,19 @@
      {
 	if (gcc->o_frame)
 	  {
-	     e_gadcon_layout_pack_aspect_pad_set(gcc->o_frame, gcc->pad.w, gcc->pad.h);
-	     e_gadcon_layout_pack_aspect_set(gcc->o_frame, gcc->aspect.w, gcc->aspect.h);
-	     e_gadcon_layout_pack_min_size_set(gcc->o_frame, gcc->min.w, gcc->min.h);
+	     e_gadcon_layout_pack_aspect_pad_set(gcc->o_frame, gcc->pad.w,
+                                                 gcc->pad.h);
+	     e_gadcon_layout_pack_aspect_set(gcc->o_frame, gcc->aspect.w,
+                                             gcc->aspect.h);
+	     e_gadcon_layout_pack_min_size_set(gcc->o_frame, gcc->min.w,
+                                               gcc->min.h);
 	  }
 	else if (gcc->o_base)
 	  {
-	     e_gadcon_layout_pack_min_size_set(gcc->o_base, gcc->min.w, gcc->min.h);
-	     e_gadcon_layout_pack_aspect_set(gcc->o_base, gcc->aspect.w, gcc->aspect.h);
+	     e_gadcon_layout_pack_min_size_set(gcc->o_base, gcc->min.w,
+                                               gcc->min.h);
+	     e_gadcon_layout_pack_aspect_set(gcc->o_base, gcc->aspect.w,
+                                             gcc->aspect.h);
 	  }
      }
 }
@@ -1200,13 +1214,14 @@
 {
    E_OBJECT_CHECK(gcc);
    E_OBJECT_TYPE_CHECK(gcc, E_GADCON_CLIENT_TYPE);
-
+
    gcc->resizable = resizable;
    if (gcc->resizable)
      {
 	if (gcc->o_frame)
 	  {
-	     e_gadcon_layout_pack_aspect_pad_set(gcc->o_frame, gcc->pad.w, gcc->pad.h);
+	     e_gadcon_layout_pack_aspect_pad_set(gcc->o_frame, gcc->pad.w,
+                                                 gcc->pad.h);
 	     e_gadcon_layout_pack_aspect_set(gcc->o_frame, 0, 0);
 	     e_gadcon_layout_pack_min_size_set(gcc->o_frame, 0, 0);
 	  }
@@ -1220,14 +1235,19 @@
      {
 	if (gcc->o_frame)
 	  {
-	     e_gadcon_layout_pack_aspect_pad_set(gcc->o_frame, gcc->pad.w, gcc->pad.h);
-	     e_gadcon_layout_pack_aspect_set(gcc->o_frame, gcc->aspect.w, gcc->aspect.h);
-	     e_gadcon_layout_pack_min_size_set(gcc->o_frame, gcc->min.w, gcc->min.h);
+	     e_gadcon_layout_pack_aspect_pad_set(gcc->o_frame, gcc->pad.w,
+                                                 gcc->pad.h);
+	     e_gadcon_layout_pack_aspect_set(gcc->o_frame, gcc->aspect.w,
+                                             gcc->aspect.h);
+	     e_gadcon_layout_pack_min_size_set(gcc->o_frame, gcc->min.w,
+                                               gcc->min.h);
 	  }
 	else if (gcc->o_base)
 	  {
-	     e_gadcon_layout_pack_min_size_set(gcc->o_base, gcc->min.w, gcc->min.h);
-	     e_gadcon_layout_pack_aspect_set(gcc->o_base, gcc->aspect.w, gcc->aspect.h);
+	     e_gadcon_layout_pack_min_size_set(gcc->o_base, gcc->min.w,
+                                               gcc->min.h);
+	     e_gadcon_layout_pack_aspect_set(gcc->o_base, gcc->aspect.w,
+                                             gcc->aspect.h);
 	  }
      }
 }
@@ -1240,12 +1260,9 @@
    E_OBJECT_CHECK(gcc);
    E_OBJECT_TYPE_CHECK(gcc, E_GADCON_CLIENT_TYPE);
    if (!e_gadcon_canvas_zone_geometry_get(gcc->gadcon, &gx, &gy, NULL, NULL)) return 0;
-
-   if (gcc->o_base)
-     evas_object_geometry_get(gcc->o_base, x, y, w, h);
+   if (gcc->o_base) evas_object_geometry_get(gcc->o_base, x, y, w, h);
    if (x) *x += gx;
    if (y) *y += gy;
-
    return 1;
 }

@@ -1262,7 +1279,7 @@
 {
    E_Menu *mn;
    E_Menu_Item *mi;
-
+
    E_OBJECT_CHECK(gcc);
    E_OBJECT_TYPE_CHECK(gcc, E_GADCON_CLIENT_TYPE);

@@ -1277,7 +1294,7 @@
 	if ((gcc->style) && (!strcmp(gcc->style, E_GADCON_CLIENT_STYLE_PLAIN)))
 	  e_menu_item_toggle_set(mi, 1);
 	e_menu_item_callback_set(mi, _e_gadcon_client_cb_menu_style_plain, gcc);
-
+
 	mi = e_menu_item_new(mn);
 	e_menu_item_label_set(mi, _("Inset"));
 	e_util_menu_item_theme_icon_set(mi, "enlightenment/inset");
@@ -1311,7 +1328,7 @@

 	mi = e_menu_item_new(menu);
 	e_menu_item_separator_set(mi, 1);
-
+
 	if (!gcc->o_control)
 	  {
 		mi = e_menu_item_new(menu);
@@ -1329,7 +1346,6 @@
      {
 	mi = e_menu_item_new(menu);
 	e_menu_item_separator_set(mi, 1);
-
 	gcc->gadcon->menu_attach.func(gcc->gadcon->menu_attach.data, gcc, menu);
      }
 }
@@ -1363,9 +1379,7 @@
 e_gadcon_locked_set(E_Gadcon *gc, int lock)
 {
    if (gc->locked_set.func)
-     {
-	gc->locked_set.func(gc->locked_set.data, lock);
-     }
+     gc->locked_set.func(gc->locked_set.data, lock);
 }

 EAPI void
@@ -1385,7 +1399,7 @@
      {
 	Evas_Coord w, h;
 	double d;
-
+
 	evas_object_geometry_get(gcc->o_box, NULL, NULL, &w, &h);
         if (e_box_orientation_get(gcc->o_box))
 	  {
@@ -1414,6 +1428,50 @@
 {
    gcc->scroll_cb.func = func;
    gcc->scroll_cb.data = data;
+}
+
+EAPI Eina_Bool
+e_gadcon_site_is_shelf(E_Gadcon_Site site)
+{
+   return (site == E_GADCON_SITE_SHELF);
+}
+
+EAPI Eina_Bool
+e_gadcon_site_is_desktop(E_Gadcon_Site site)
+{
+   return (site == E_GADCON_SITE_DESKTOP);
+}
+
+EAPI Eina_Bool
+e_gadcon_site_is_efm_toolbar(E_Gadcon_Site site)
+{
+   return (site == E_GADCON_SITE_EFM_TOOLBAR);
+}
+
+EAPI Eina_Bool
+e_gadcon_site_is_any_toolbar(E_Gadcon_Site site)
+{
+   switch (site)
+     {
+        // there should be all toolbar sities identifiers
+      case E_GADCON_SITE_TOOLBAR:
+      case E_GADCON_SITE_EFM_TOOLBAR:
+        return EINA_TRUE;
+     }
+   return EINA_FALSE;
+}
+
+EAPI Eina_Bool
+e_gadcon_site_is_not_toolbar(E_Gadcon_Site site)
+{
+   switch (site)
+     {
+        // there should be all toolbar sities identifiers
+      case E_GADCON_SITE_TOOLBAR:
+      case E_GADCON_SITE_EFM_TOOLBAR:
+        return EINA_FALSE;
+     }
+   return EINA_TRUE;
 }

 /* local subsystem functions */
@@ -1465,9 +1523,9 @@
 static void
 _e_gadcon_moveresize_handle(E_Gadcon_Client *gcc)
 {
-   Evas_Coord x, y, w, h;
-
-   evas_object_geometry_get(gcc->o_box, &x, &y, &w, &h);
+   Evas_Coord w, h;
+
+   evas_object_geometry_get(gcc->o_box, NULL, NULL, &w, &h);
    if ((gcc->autoscroll) || (gcc->resizable))
      {
 	if (e_box_orientation_get(gcc->o_box))
@@ -1496,7 +1554,7 @@
 {
    E_Gadcon_Client *gcc;
    double d, v;
-
+
    gcc = data;
    d = gcc->scroll_wanted - gcc->scroll_pos;
    if (d < 0) d = -d;
@@ -1515,7 +1573,7 @@
 _e_gadcon_cb_client_scroll_animator(void *data)
 {
    E_Gadcon_Client *gcc;
-
+
    gcc = data;
    if (e_box_orientation_get(gcc->o_box))
      e_box_align_set(gcc->o_box, 1.0 - gcc->scroll_pos, 0.5);
@@ -1539,7 +1597,7 @@
    Evas_Event_Mouse_Move *ev;
    E_Gadcon_Client *gcc;
    Evas_Coord x, y;
-
+
    ev = event_info;
    gcc = data;
    evas_object_geometry_get(gcc->o_box, &x, &y, NULL, NULL);
@@ -1551,7 +1609,7 @@
 _e_gadcon_cb_client_frame_moveresize(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
    E_Gadcon_Client *gcc;
-
+
    gcc = data;
    _e_gadcon_moveresize_handle(gcc);
 }
@@ -1623,9 +1681,9 @@
 static void
 _e_gadcon_client_inject(E_Gadcon *gc, E_Gadcon_Client *gcc, int x, int y)
 {
-   Eina_List  *l;
-   Evas_Coord  cx, cy, cw, ch;
-   int         seq = 1;
+   Eina_List *l;
+   Evas_Coord cx, cy, cw, ch;
+   int seq = 1;

    /* Check if the gadcon client is in place */
    if (!gcc->hidden)
@@ -1691,12 +1749,12 @@
 _e_gadcon_cb_min_size_request(void *data, Evas_Object *obj, void *event_info)
 {
    E_Gadcon *gc;
-
+
    gc = data;
    if (gc->min_size_request.func)
      {
 	Evas_Coord w, h;
-
+
 	e_gadcon_layout_min_size_get(gc->o_container, &w, &h);
 	gc->min_size_request.func(gc->min_size_request.data, gc, w, h);
      }
@@ -1705,8 +1763,8 @@
 static void
 _e_gadcon_cb_size_request(void *data, Evas_Object *obj, void *event_info)
 {
-   E_Gadcon   *gc;
-
+   E_Gadcon *gc;
+
    gc = data;
    if (gc->resize_request.func)
      {
@@ -1724,7 +1782,6 @@
    Evas_Coord x, y, w, h;

    gc = data;
-
    evas_object_geometry_get(gc->o_container, &x, &y, &w, &h);
    if (gc->drop_handler)
      e_drop_handler_geometry_set(gc->drop_handler, x, y, w, h);
@@ -1735,7 +1792,7 @@
 {
    Evas_Event_Mouse_Down *ev;
    E_Gadcon_Client *gcc;
-
+
    gcc = data;
    ev = event_info;
    if (ev->button == 3)
@@ -1763,9 +1820,10 @@
 	     mi = e_menu_item_new(mn);
 	     e_menu_item_separator_set(mi, 1);

-	     gcc->gadcon->menu_attach.func(gcc->gadcon->menu_attach.data, gcc, mn);
-	  }
-
+	     gcc->gadcon->menu_attach.func(gcc->gadcon->menu_attach.data,
+                                           gcc, mn);
+	  }
+
 	if (gcc->gadcon->toolbar)
 	  ecore_x_pointer_xy_get(zone->container->win, &cx, &cy);
 	else
@@ -1787,14 +1845,18 @@
 static void
 _e_gadcon_cb_client_mouse_in(void *data, Evas *evas, Evas_Object *obj, void *event_info)
 {
-   E_Gadcon_Client *gcc = data;
+   E_Gadcon_Client *gcc;
+
+   gcc = data;
    edje_object_signal_emit(gcc->o_control, "e,state,focused", "e");
 }

 static void
 _e_gadcon_cb_client_mouse_out(void *data, Evas *evas, Evas_Object *obj, void *event_info)
 {
-   E_Gadcon_Client *gcc = data;
+   E_Gadcon_Client *gcc;
+
+   gcc = data;
    edje_object_signal_emit(gcc->o_control, "e,state,unfocused", "e");
 }

@@ -1803,7 +1865,7 @@
 {
    E_Gadcon_Client *gcc;
    Evas_Coord x, y;
-
+
    gcc = data;
    evas_object_geometry_get(obj, &x, &y, NULL, NULL);
    if (gcc->o_control) evas_object_move(gcc->o_control, x, y);
@@ -1815,7 +1877,7 @@
 {
    E_Gadcon_Client *gcc;
    Evas_Coord w, h;
-
+
    gcc = data;
    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
    if (gcc->o_control) evas_object_resize(gcc->o_control, w, h);
@@ -1837,8 +1899,7 @@
 static void
 _e_gadcon_client_move_stop(E_Gadcon_Client *gcc)
 {
-   gcc->moving = 0;
-
+   gcc->moving = 0;
    gcc->state_info.state = E_LAYOUT_ITEM_STATE_NONE;
    gcc->state_info.resist = 0;
    _e_gadcon_layout_smart_sync_clients(gcc->gadcon);
@@ -1848,13 +1909,13 @@
 _e_gadcon_client_move_go(E_Gadcon_Client *gcc)
 {
    Evas_Coord x, y, w, h;
-   int        cx, cy;
-
+   int cx, cy;
+
    if (!gcc->moving) return;
    evas_pointer_canvas_xy_get(gcc->gadcon->evas, &cx, &cy);
    x = cx - gcc->dx;
    y = cy - gcc->dy;
-
+
    gcc->state_info.flags = E_GADCON_LAYOUT_ITEM_LOCK_POSITION | E_GADCON_LAYOUT_ITEM_LOCK_ABSOLUTE;
    _e_gadcon_client_current_position_sync(gcc);
    if (e_gadcon_layout_orientation_get(gcc->gadcon->o_container))
@@ -1897,7 +1958,6 @@
 	     gcc->state_info.state = E_LAYOUT_ITEM_STATE_POS_DEC;
 	  }
      }
-

    if (gcc->o_frame)
      evas_object_geometry_get(gcc->o_frame, NULL, NULL, &w, &h);
@@ -1962,7 +2022,6 @@
 _e_gadconclient_resize_stop(E_Gadcon_Client *gcc)
 {
    gcc->resizing = 0;
-
    gcc->state_info.state = E_LAYOUT_ITEM_STATE_NONE;
    _e_gadcon_layout_smart_sync_clients(gcc->gadcon);
    _e_gadcon_client_save(gcc);
@@ -1985,14 +2044,15 @@
 {
    E_Gadcon_Client *gcc;
    Evas_Coord x, y, w, h;
-
+
    gcc = data;
    if (!gcc->resizing) return;
    evas_pointer_canvas_xy_get(gcc->gadcon->evas, &x, &y);
    x = x - gcc->dx;
    y = y - gcc->dy;

-   gcc->state_info.flags = E_GADCON_LAYOUT_ITEM_LOCK_POSITION | E_GADCON_LAYOUT_ITEM_LOCK_ABSOLUTE;
+   gcc->state_info.flags = E_GADCON_LAYOUT_ITEM_LOCK_POSITION |
+     E_GADCON_LAYOUT_ITEM_LOCK_ABSOLUTE;

    if (gcc->o_frame)
      evas_object_geometry_get(gcc->o_frame, NULL, NULL, &w, &h);
@@ -2033,8 +2093,7 @@
 	else if (gcc->o_base)
 	  e_gadcon_layout_pack_request_set(gcc->o_base, gcc->config.pos + y, h - y);
 	evas_object_geometry_get(gcc->gadcon->o_container, NULL, NULL, &w, &h);
-	gcc->config.res = h;
-
+	gcc->config.res = h;
      }
    gcc->dx += x;
    gcc->dy += y;
@@ -2057,14 +2116,15 @@
 {
    E_Gadcon_Client *gcc;
    Evas_Coord x, y, w, h;
-
+
    gcc = data;
    if (!gcc->resizing) return;
    evas_pointer_canvas_xy_get(gcc->gadcon->evas, &x, &y);
    x = x - gcc->dx;
    y = y - gcc->dy;

-   gcc->state_info.flags = E_GADCON_LAYOUT_ITEM_LOCK_POSITION | E_GADCON_LAYOUT_ITEM_LOCK_ABSOLUTE;
+   gcc->state_info.flags = E_GADCON_LAYOUT_ITEM_LOCK_POSITION |
+     E_GADCON_LAYOUT_ITEM_LOCK_ABSOLUTE;

    if (gcc->o_frame)
      evas_object_geometry_get(gcc->o_frame, NULL, NULL, &w, &h);
@@ -2139,8 +2199,8 @@
 _e_gadcon_cb_dnd_enter(void *data, const char *type, void *event)
 {
    E_Event_Dnd_Enter *ev;
-   E_Gadcon          *gc;
-   E_Gadcon_Client   *gcc;
+   E_Gadcon *gc;
+   E_Gadcon_Client *gcc;

    ev = event;
    gc = data;
@@ -2150,7 +2210,7 @@
    if (gcc->gadcon == gc)
      {
 	/* We have re-entered the gadcon we left, revive gadcon client */
-	Evas_Coord   dx, dy;
+	Evas_Coord dx, dy;
 	Evas_Object *o;

 	if (e_gadcon_layout_orientation_get(gc->o_container))
@@ -2185,11 +2245,11 @@
 	     if (!gcc->style)
 	       {
 		  new_gcc = cc->func.init(gc, gcc->name, gcc->cf->id,
-				       cc->default_style);
+                                          cc->default_style);
 	       }
 	     else
 	       new_gcc = cc->func.init(gc, gcc->name, gcc->cf->id,
-				    gcc->style);
+                                       gcc->style);

 	     if (new_gcc)
 	       {
@@ -2226,8 +2286,8 @@
 _e_gadcon_cb_dnd_move(void *data, const char *type, void *event)
 {
    E_Event_Dnd_Move *ev;
-   E_Gadcon         *gc;
-   E_Gadcon_Client  *gcc = NULL;
+   E_Gadcon *gc;
+   E_Gadcon_Client *gcc = NULL;

    ev = event;
    gc = data;
@@ -2238,7 +2298,7 @@
    else if (new_gcc->gadcon == gc) gcc = new_gcc;
    if (gcc)
      {
-	Evas_Coord   dx, dy;
+	Evas_Coord dx, dy;
 	Evas_Object *o;

 	if (gcc->state_info.resist > 0)
@@ -2261,9 +2321,11 @@
 	if (o)
 	  {
 	     if (e_gadcon_layout_orientation_get(gc->o_container))
-	       e_gadcon_layout_pack_request_set(o, gcc->config.pos, gcc->config.size);
+	       e_gadcon_layout_pack_request_set(o, gcc->config.pos,
+                                                gcc->config.size);
 	     else
-	       e_gadcon_layout_pack_request_set(o, gcc->config.pos, gcc->config.size);
+	       e_gadcon_layout_pack_request_set(o, gcc->config.pos,
+                                                gcc->config.size);
 	  }
 	e_gadcon_layout_thaw(gc->o_container);
      }
@@ -2272,8 +2334,9 @@
 static void
 _e_gadcon_cb_dnd_leave(void *data, const char *type, void *event)
 {
-   E_Gadcon *gc = data;
-
+   E_Gadcon *gc;
+
+   gc = data;
    /* If we exit the starting container hide the gadcon visual */
    if (drag_gcc->gadcon == gc) e_gadcon_client_hide(drag_gcc);

@@ -2288,9 +2351,10 @@
 static void
 _e_gadcon_cb_drop(void *data, const char *type, void *event)
 {
-   E_Gadcon         *gc = data;
-   E_Gadcon_Client  *gcc = NULL;
-
+   E_Gadcon *gc;
+   E_Gadcon_Client *gcc = NULL;
+
+   gc = data;
    if (drag_gcc->gadcon == gc) gcc = drag_gcc;
    else if ((new_gcc) && (new_gcc->gadcon == gc)) gcc = new_gcc;
    else return;  /* make clang happy */
@@ -2319,10 +2383,8 @@
 {
    E_Gadcon_Client *gcc;

-   gcc = data;
-   if (!gcc) return;
-   if (gcc->gadcon)
-     e_gadcon_locked_set(gcc->gadcon, 0);
+   if (!(gcc = data)) return;
+   if (gcc->gadcon) e_gadcon_locked_set(gcc->gadcon, 0);
    if (!gcc->menu) return;
    e_object_del(E_OBJECT(gcc->menu));
    gcc->menu = NULL;
@@ -2332,7 +2394,7 @@
 _e_gadcon_client_cb_instant_edit_timer(void *data)
 {
    E_Gadcon_Client *gcc;
-
+
    gcc = data;
    e_gadcon_client_edit_begin(gcc);
    _e_gadcon_client_move_start(gcc);
@@ -2345,10 +2407,9 @@
 {
    Evas_Event_Mouse_Down *ev;
    E_Gadcon_Client *gcc;
-
+
    ev = event_info;
    gcc = data;
-
    if (gcc->menu) return;
    if (ev->button == 3)
      {
@@ -2363,7 +2424,6 @@
 	gcc->menu = mn;

 	e_gadcon_client_util_menu_items_append(gcc, mn, 0);
-
 	e_gadcon_canvas_zone_geometry_get(gcc->gadcon, &cx, &cy, &cw, &ch);
         zone = gcc->gadcon->zone;
         if (!zone) zone = e_util_zone_current_get(e_manager_current_get());
@@ -2376,7 +2436,8 @@
      {
 	if ((!gcc->o_control) && (gcc->gadcon->instant_edit))
 	  {
-	     if (gcc->instant_edit_timer) ecore_timer_del(gcc->instant_edit_timer);
+	     if (gcc->instant_edit_timer)
+               ecore_timer_del(gcc->instant_edit_timer);
 	     gcc->instant_edit_timer =
 	       ecore_timer_add(1.0, _e_gadcon_client_cb_instant_edit_timer,
 			       gcc);
@@ -2389,10 +2450,9 @@
 {
    Evas_Event_Mouse_Up *ev;
    E_Gadcon_Client *gcc;
-
+
    ev = event_info;
    gcc = data;
-
    if ((ev->button == 1) && (gcc->gadcon->instant_edit))
      {
 	if (gcc->instant_edit_timer)
@@ -2402,7 +2462,6 @@
 	  }
 	if (gcc->o_control)
 	  {
-	     printf("EDIT END\n");
 	     _e_gadcon_client_move_stop(gcc);
 	     e_gadcon_client_edit_end(gcc);
 	  }
@@ -2412,12 +2471,12 @@
 static void
 _e_gadcon_client_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
-   E_Gadcon_Client *gcc = data;
-
+   E_Gadcon_Client *gcc;
+
+   gcc = data;
    if ((gcc->gadcon->instant_edit))
      {
-	if (gcc->o_control)
-	  _e_gadcon_client_move_go(gcc);
+	if (gcc->o_control) _e_gadcon_client_move_go(gcc);
      }
 }

@@ -2426,7 +2485,7 @@
 {
    E_Gadcon_Client *gcc;
    E_Gadcon *gc;
-
+
    gcc = data;
    gc = gcc->gadcon;
    if (gcc->style) eina_stringshare_del(gcc->style);
@@ -2441,7 +2500,7 @@
 {
    E_Gadcon_Client *gcc;
    E_Gadcon *gc;
-
+
    gcc = data;
    gc = gcc->gadcon;
    if (gcc->style) eina_stringshare_del(gcc->style);
@@ -2469,7 +2528,7 @@
 _e_gadcon_client_cb_menu_resizable(void *data, E_Menu *m, E_Menu_Item *mi)
 {
    E_Gadcon_Client *gcc;
-
+
    gcc = data;
    e_gadcon_layout_freeze(gcc->gadcon->o_container);
    if (gcc->resizable) gcc->resizable = 0;
@@ -2483,7 +2542,7 @@
 _e_gadcon_client_cb_menu_edit(void *data, E_Menu *m, E_Menu_Item *mi)
 {
    E_Gadcon_Client *gcc;
-
+
    gcc = data;
    if (gcc->o_control)
      e_gadcon_client_edit_end(gcc);
@@ -2527,41 +2586,41 @@

 struct _E_Smart_Data
 {
-   Evas_Coord       x, y, w, h;
-   Evas_Object     *obj;
-   Evas_Object     *clip;
-   unsigned char    horizontal : 1;
-   unsigned char    doing_config : 1;
-   unsigned char    redo_config : 1;
-   Eina_List       *items;
-   int              frozen;
-   Evas_Coord       minw, minh, req;
+   Evas_Coord x, y, w, h;
+   Evas_Object *obj, *clip;
+   unsigned char horizontal : 1;
+   unsigned char doing_config : 1;
+   unsigned char redo_config : 1;
+   Eina_List *items;
+   int frozen;
+   Evas_Coord minw, minh, req;
 };

 struct _E_Gadcon_Layout_Item
 {
-   E_Smart_Data    *sd;
-   struct {
-      int           pos, size, size2, res, prev_pos, prev_size;
-   } ask;
-   int              hookp;
-   struct {
-      int           w, h;
-   } min, aspect, aspect_pad;
+   E_Smart_Data *sd;
+   struct
+     {
+        int pos, size, size2, res, prev_pos, prev_size;
+     } ask;
+   int hookp;
+   struct
+     {
+        int w, h;
+     } min, aspect, aspect_pad;

    E_Gadcon_Client *gcc;

-   Evas_Coord       x, y, w, h;
-   Evas_Object     *obj;
-   unsigned char    can_move : 1;
+   Evas_Coord x, y, w, h;
+   Evas_Object *obj;
+   unsigned char can_move : 1;
 };

 /* local subsystem functions */
 static E_Gadcon_Layout_Item *_e_gadcon_layout_smart_adopt(E_Smart_Data *sd, Evas_Object *obj);
-static void        _e_gadcon_layout_smart_disown(Evas_Object *obj);
-static void        _e_gadcon_layout_smart_item_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void        _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd);
-
+static void _e_gadcon_layout_smart_disown(Evas_Object *obj);
+static void _e_gadcon_layout_smart_item_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd);
 static void _e_gadcon_layout_smart_init(void);
 static void _e_gadcon_layout_smart_add(Evas_Object *obj);
 static void _e_gadcon_layout_smart_del(Evas_Object *obj);
@@ -2572,10 +2631,8 @@
 static void _e_gadcon_layout_smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
 static void _e_gadcon_layout_smart_clip_set(Evas_Object *obj, Evas_Object *clip);
 static void _e_gadcon_layout_smart_clip_unset(Evas_Object *obj);
-
 static void _e_gadcon_layout_smart_min_cur_size_calc(E_Smart_Data *sd, int *min, int *mino, int *cur);
-void _e_gadcon_layout_smart_gadcons_width_adjust(E_Smart_Data *sd, int min, int cur);
-
+static void _e_gadcon_layout_smart_gadcons_width_adjust(E_Smart_Data *sd, int min, int cur);
 static int _e_gadcon_layout_smart_sort_by_sequence_number_cb(const void *d1, const void *d2);
 static int _e_gadcon_layout_smart_sort_by_position_cb(const void *d1, const void *d2);

@@ -2596,7 +2653,6 @@
    E_Smart_Data *sd;

    if (!obj) return;
-
    sd = evas_object_smart_data_get(obj);
    if (!sd) return;
    if (((sd->horizontal) && (horizontal)) ||
@@ -2611,7 +2667,6 @@
    E_Smart_Data *sd;

    if (!obj) return 0;
-
    sd = evas_object_smart_data_get(obj);
    if (!sd) return 0;
    return sd->horizontal;
@@ -2623,7 +2678,6 @@
    E_Smart_Data *sd;

    if (!obj) return;
-
    sd = evas_object_smart_data_get(obj);
    if (!sd) return;
    sd->frozen++;
@@ -2635,7 +2689,6 @@
    E_Smart_Data *sd;

    if (!obj) return;
-
    sd = evas_object_smart_data_get(obj);
    if (!sd) return;
    sd->frozen--;
@@ -2651,10 +2704,8 @@
    Evas_Coord tw = 0, th = 0;
  */
    if (!obj) return;
-
    sd = evas_object_smart_data_get(obj);
    if (!sd) return;
-
    if (w) *w = sd->minw;
    if (h) *h = sd->minh;

@@ -2689,10 +2740,8 @@
    Evas_Coord tw = 0, th = 0;

    if (!obj) return;
-
    sd = evas_object_smart_data_get(obj);
    if (!sd) return;
-
    if (sd->horizontal)
      tw = sd->req;
    else
@@ -2725,7 +2774,6 @@
    E_Smart_Data *sd;

    if (!obj) return 0;
-
    sd = evas_object_smart_data_get(obj);
    if (!sd) return 0;
    _e_gadcon_layout_smart_adopt(sd, child);
@@ -2746,24 +2794,27 @@
    int xx;

    if (!obj) return;
-
    bi = evas_object_data_get(obj, "e_gadcon_layout_data");
    if (!bi) return;
    xx = bi->ask.pos + (bi->ask.size / 2);
    if (xx < (bi->ask.res / 3))
-     { /* hooked to start */
+     {
+        /* hooked to start */
 	bi->ask.size = size;
      }
    else if (xx > ((2 * bi->ask.res) / 3))
-     { /* hooked to end */
+     {
+        /* hooked to end */
 	bi->ask.pos = (bi->ask.pos + bi->ask.size) - size;
 	bi->ask.size = size;
      }
    else
-     { /* hooked to middle */
+     {
+        /* hooked to middle */
 	if ((bi->ask.pos <= (bi->ask.res / 2)) &&
 	    ((bi->ask.pos + bi->ask.size) > (bi->ask.res / 2)))
-	  { /* straddles middle */
+	  {
+             /* straddles middle */
 	     if (bi->ask.res > 2)
 	       bi->ask.pos = (bi->ask.res / 2) +
 	       (((bi->ask.pos + (bi->ask.size / 2) -
@@ -2796,7 +2847,6 @@
    E_Gadcon_Layout_Item *bi;

    if (!obj) return;
-
    bi = evas_object_data_get(obj, "e_gadcon_layout_data");
    if (!bi) return;
    if (bi->sd->horizontal)
@@ -2819,7 +2869,6 @@
    E_Gadcon_Layout_Item *bi, *bi2;

    if (!obj) return;
-
    bi = evas_object_data_get(obj, "e_gadcon_layout_data");
    if (!bi) return;
    bi->ask.res = gcc->config.res;
@@ -2828,15 +2877,13 @@
    bi->gcc = gcc;

    ok = 0;
-   if (!gcc->state_info.seq)
-     ok = 1;
+   if (!gcc->state_info.seq) ok = 1;

    seq = 1;
    for (l = bi->sd->items; l; l = l->next)
      {
 	bi2 = evas_object_data_get(l->data, "e_gadcon_layout_data");
 	if (bi == bi2) continue;
-
 	if (bi->gcc->state_info.seq == bi2->gcc->state_info.seq)
 	  ok = 1;

@@ -2859,7 +2906,6 @@
    E_Gadcon_Layout_Item *bi;

    if (!obj) return;
-
    bi = evas_object_data_get(obj, "e_gadcon_layout_data");
    if (!bi) return;
    bi->min.w = w;
@@ -2873,7 +2919,6 @@
    E_Gadcon_Layout_Item *bi;

    if (!obj) return;
-
    bi = evas_object_data_get(obj, "e_gadcon_layout_data");
    if (!bi) return;
    bi->aspect.w = w;
@@ -2887,7 +2932,6 @@
    E_Gadcon_Layout_Item *bi;

    if (!obj) return;
-
    bi = evas_object_data_get(obj, "e_gadcon_layout_data");
    if (!bi) return;
    bi->aspect_pad.w = w;
@@ -2901,7 +2945,6 @@
    E_Smart_Data *sd;

    if (!obj) return;
-
    bi = evas_object_data_get(obj, "e_gadcon_layout_data");
    if (!bi) return;
    sd = bi->sd;
@@ -2918,7 +2961,6 @@
    E_Gadcon_Layout_Item *bi;

    if (!obj) return NULL;
-
    bi = calloc(1, sizeof(E_Gadcon_Layout_Item));
    if (!bi) return NULL;
    bi->sd = sd;
@@ -2941,7 +2983,6 @@
    E_Gadcon_Layout_Item *bi;

    if (!obj) return;
-
    bi = evas_object_data_get(obj, "e_gadcon_layout_data");
    if (!bi) return;
    if (!bi->sd->items)
@@ -2949,8 +2990,7 @@
 	if (evas_object_visible_get(bi->sd->clip))
 	  evas_object_hide(bi->sd->clip);
      }
-   evas_object_event_callback_del(obj,
-				  EVAS_CALLBACK_DEL,
+   evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL,
 				  _e_gadcon_layout_smart_item_del_hook);
    evas_object_smart_member_del(obj);
    evas_object_clip_unset(obj);
@@ -2962,7 +3002,6 @@
 _e_gadcon_layout_smart_item_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
    if (!obj) return;
-
    e_gadcon_layout_unpack(obj);
 }

@@ -2975,8 +3014,7 @@
    Eina_List *list = NULL;
    E_Gadcon_Layout_Item *bi;
    E_Layout_Item_Container *lc;
-   int i;
-   int set_prev_pos = 0;
+   int i, set_prev_pos = 0;

    if (sd->frozen) return;
    if (sd->doing_config)
@@ -3026,7 +3064,8 @@
      }
    _e_gadcon_layout_smart_gadcons_width_adjust(sd, min, cur);

-   if (((sd->horizontal) && (sd->w <= sd->req)) || ((!sd->horizontal) && (sd->h <= sd->req)))
+   if (((sd->horizontal) && (sd->w <= sd->req)) ||
+       ((!sd->horizontal) && (sd->h <= sd->req)))
      {
 	_e_gadcon_layout_smart_gadcon_position_shrinked_mode(sd);
 	set_prev_pos = 0;
@@ -3048,14 +3087,12 @@
 	set_prev_pos = 1;
      }

-
    sd->items = eina_list_sort(sd->items, eina_list_count(sd->items),
 			      _e_gadcon_layout_smart_sort_by_position_cb);
    for (l = sd->items, i = 1; l; l = l->next, i++)
      {
 	bi = evas_object_data_get(l->data, "e_gadcon_layout_data");
-	if (bi->gcc->gadcon->editing)
-	  bi->gcc->state_info.seq = i;
+	if (bi->gcc->gadcon->editing) bi->gcc->state_info.seq = i;

 	if (set_prev_pos)
 	  {
@@ -3091,12 +3128,12 @@
 	       bi->gcc->state_info.flags &= ~E_GADCON_LAYOUT_ITEM_LOCK_ABSOLUTE;
 	  }
      }
-
+
    for (l = sd->items; l; l = l->next)
      {
 	E_Gadcon_Layout_Item *bi;
 	Evas_Object *obj;
-
+
 	obj = l->data;
 	bi = evas_object_data_get(obj, "e_gadcon_layout_data");
 	if (!bi) continue;
@@ -3168,10 +3205,7 @@
 	       _e_gadcon_layout_smart_color_set,
 	       _e_gadcon_layout_smart_clip_set,
 	       _e_gadcon_layout_smart_clip_unset,
-	       NULL,
-	       NULL,
-	       NULL,
-	       NULL
+	       NULL, NULL, NULL, NULL
 	  };
 	_e_smart = evas_smart_class_new(&sc);
      }
@@ -3183,7 +3217,6 @@
    E_Smart_Data *sd;

    if (!obj) return;
-
    sd = calloc(1, sizeof(E_Smart_Data));
    if (!sd) return;
    sd->obj = obj;
@@ -3206,13 +3239,12 @@
    E_Smart_Data *sd;

    if (!obj) return;
-
    sd = evas_object_smart_data_get(obj);
    if (!sd) return;
    while (sd->items)
      {
 	Evas_Object *child;
-
+
 	child = sd->items->data;
 	e_gadcon_layout_unpack(child);
      }
@@ -3226,20 +3258,19 @@
    E_Smart_Data *sd;

    if (!obj) return;
-
    sd = evas_object_smart_data_get(obj);
    if (!sd) return;
    if ((x == sd->x) && (y == sd->y)) return;
      {
 	Eina_List *l;
 	Evas_Coord dx, dy;
-
+
 	dx = x - sd->x;
 	dy = y - sd->y;
 	for (l = sd->items; l; l = l->next)
 	  {
 	     Evas_Coord ox, oy;
-
+
 	     evas_object_geometry_get(l->data, &ox, &oy, NULL, NULL);
 	     evas_object_move(l->data, ox + dx, oy + dy);
 	  }
@@ -3254,7 +3285,6 @@
    E_Smart_Data *sd;

    if (!obj) return;
-
    sd = evas_object_smart_data_get(obj);
    if (!sd) return;
    if ((w == sd->w) && (h == sd->h)) return;
@@ -3269,7 +3299,6 @@
    E_Smart_Data *sd;

    if (!obj) return;
-
    sd = evas_object_smart_data_get(obj);
    if (!sd) return;
    if (sd->items) evas_object_show(sd->clip);
@@ -3281,7 +3310,6 @@
    E_Smart_Data *sd;

    if (!obj) return;
-
    sd = evas_object_smart_data_get(obj);
    if (!sd) return;
    evas_object_hide(sd->clip);
@@ -3293,7 +3321,6 @@
    E_Smart_Data *sd;

    if (!obj) return;
-
    sd = evas_object_smart_data_get(obj);
    if (!sd) return;
    evas_object_color_set(sd->clip, r, g, b, a);
@@ -3305,7 +3332,6 @@
    E_Smart_Data *sd;

    if (!obj) return;
-
    sd = evas_object_smart_data_get(obj);
    if (!sd) return;
    evas_object_clip_set(sd->clip, clip);
@@ -3317,12 +3343,10 @@
    E_Smart_Data *sd;

    if (!obj) return;
-
    sd = evas_object_smart_data_get(obj);
    if (!sd) return;
    evas_object_clip_unset(sd->clip);
 }
-

 /*
  * @min - the minimum width required by all the gadcons
@@ -3404,7 +3428,6 @@

    bi = evas_object_data_get(d1, "e_gadcon_layout_data");
    bi2 = evas_object_data_get(d2, "e_gadcon_layout_data");
-
    if (bi->sd->horizontal)
      {
 	if (bi->ask.size2 > bi->min.w)
@@ -3502,15 +3525,14 @@
    return 0;
 }

-void
+static void
 _e_gadcon_layout_smart_gadcons_width_adjust(E_Smart_Data *sd, int min, int cur)
 {
    E_Gadcon_Layout_Item *bi2 = NULL;
    E_Gadcon_Layout_Item *bi = NULL;
    Eina_List *l, *l2;
    int need, limit, reduce_total, reduce;
-   int max_size;
-   int c;
+   int max_size, c;

    if (sd->horizontal)
      {
@@ -3541,7 +3563,7 @@
      }

    sd->items = eina_list_sort(sd->items, eina_list_count(sd->items),
-			      _e_gadcon_layout_smart_width_smart_sort_reverse_cb);
+			      _e_gadcon_layout_smart_width_smart_sort_reverse_cb);

    __adjust_size_again:
    for (l = sd->items, c = 0; l; l = l->next)
@@ -3550,7 +3572,7 @@
 	  {
 	     bi = evas_object_data_get(l->data, "e_gadcon_layout_data");
 	     bi2 = evas_object_data_get(l->next->data, "e_gadcon_layout_data");
-
+
 	     if (bi->ask.size2 > bi2->ask.size2)
 	       {
 		  limit = bi2->ask.size2;
@@ -3561,14 +3583,13 @@
 	  }
      }

-   if (eina_list_count(sd->items) == 1)
-     c = 1;
-
+   if (eina_list_count(sd->items) == 1) c = 1;
+
    if (l)
      {
 	reduce = bi->ask.size2 - limit;
 	reduce_total = reduce * c;
-
+
 	if (reduce_total <= need)
 	  {
 	     for (l2 = l; l2; l2 = l2->prev)
@@ -3583,7 +3604,7 @@
 	else
 	  {
 	     int reduce_by, c2;
-
+
 	     while (need)
 	       {
 		  reduce_by = 1;
@@ -3607,7 +3628,7 @@
    else
      {
 	int reduce_by, c2;
-
+
 	while (need)
 	  {
 	     reduce_by = 1;
@@ -3640,7 +3661,6 @@
    if ((!bi->gcc->state_info.seq) && (!bi2->gcc->state_info.seq)) return 0;
    else if (!bi->gcc->state_info.seq) return 1;
    else if (!bi2->gcc->state_info.seq) return -1;
-
    return bi->gcc->state_info.seq - bi2->gcc->state_info.seq;
 }

@@ -3651,9 +3671,7 @@

    bi = evas_object_data_get(d1, "e_gadcon_layout_data");
    bi2 = evas_object_data_get(d2, "e_gadcon_layout_data");
-
-   if (bi->sd->horizontal)
-     return (bi->x - bi2->x);
+   if (bi->sd->horizontal) return (bi->x - bi2->x);
    return (bi->y - bi2->y);
 }

@@ -3664,10 +3682,8 @@

    lc = d1;
    lc2 = d2;
-
    if (lc->pos < lc2->pos) return -1;
    else if (lc->pos > lc2->pos) return 1;
-
    return 0;
 }

@@ -3678,7 +3694,6 @@

    bi = d1;
    bi2 = d2;
-
    return (bi->gcc->state_info.seq - bi2->gcc->state_info.seq);
 }

@@ -3745,7 +3760,7 @@
 		       tp = l->next->data;
 		       l->next->data = l->data;
 		       l->data = tp;
-
+
 		       bi2 = evas_object_data_get(tp, "e_gadcon_layout_data");
 		       bi->gcc->config.pos = bi->ask.pos = bi2->ask.pos;
 		       bi->gcc->state_info.flags &= ~E_GADCON_LAYOUT_ITEM_LOCK_ABSOLUTE;
@@ -3771,10 +3786,10 @@
 		    {
 		       E_Gadcon_Layout_Item *bi2;
 		       void *tp;
+
 		       tp = l->prev->data;
 		       l->prev->data = l->data;
 		       l->data = tp;
-
 		       bi2 = evas_object_data_get(tp, "e_gadcon_layout_data");
 		       bi->gcc->config.pos = bi->ask.pos = bi2->ask.pos;
 		       bi->gcc->state_info.flags &= ~E_GADCON_LAYOUT_ITEM_LOCK_ABSOLUTE;
@@ -3808,7 +3823,7 @@
 	     bi->gcc->config.pos = bi->gcc->state_info.prev_pos;
 	  }
      }
-
+
    for (l = sd->items; l; l = l->next)
      {
 	bi = evas_object_data_get(l->data, "e_gadcon_layout_data");
@@ -3862,22 +3877,26 @@
 	  {
 	     xx = bi->ask.pos + (bi->ask.size / 2);
 	     if (xx < (bi->ask.res / 3))
-	       { /* hooked to start */
+	       {
+                  /* hooked to start */
 		  bi->x = bi->ask.pos;
 		  bi->w = bi->ask.size2;
 		  bi->hookp = 0;
 	       }
 	     else if (xx > ((2 * bi->ask.res) / 3))
-	       { /* hooked to end */
+	       {
+                  /* hooked to end */
 		  bi->x = (bi->ask.pos - bi->ask.res) + sd->w;
 		  bi->w = bi->ask.size2;
 		  bi->hookp = bi->ask.res;
 	       }
 	     else
-	       { /* hooked to middle */
+	       {
+                  /* hooked to middle */
 		  if ((bi->ask.pos <= (bi->ask.res / 2)) &&
 		      ((bi->ask.pos + bi->ask.size2) > (bi->ask.res / 2)))
-		    { /* straddles middle */
+		    {
+                       /* straddles middle */
 		       if (bi->ask.res > 2)
 			 bi->x = (sd->w / 2) +
 			 (((bi->ask.pos + (bi->ask.size2 / 2) -
@@ -3889,7 +3908,8 @@
 		       bi->w = bi->ask.size2;
 		    }
 		  else
-		    { /* either side of middle */
+		    {
+                       /* either side of middle */
 		       bi->x = (bi->ask.pos - (bi->ask.res / 2)) + (sd->w / 2);
 		       bi->w = bi->ask.size2;
 		    }
@@ -3900,22 +3920,26 @@
 	  {
 	     yy = bi->ask.pos + (bi->ask.size2 / 2);
 	     if (yy < (bi->ask.res / 3))
-	       { /* hooked to start */
+	       {
+                  /* hooked to start */
 		  bi->y = bi->ask.pos;
 		  bi->h = bi->ask.size2;
 		  bi->hookp = 0;
 	       }
 	     else if (yy > ((2 * bi->ask.res) / 3))
-	       { /* hooked to end */
+	       {
+                  /* hooked to end */
 		  bi->y = (bi->ask.pos - bi->ask.res) + sd->h;
 		  bi->h = bi->ask.size2;
 		  bi->hookp = bi->ask.res;
 	       }
 	     else
-	       { /* hooked to middle */
+	       {
+                  /* hooked to middle */
 		  if ((bi->ask.pos <= (bi->ask.res / 2)) &&
 		      ((bi->ask.pos + bi->ask.size2) > (bi->ask.res / 2)))
-		    { /* straddles middle */
+		    {
+                       /* straddles middle */
 		       if (bi->ask.res > 2)
 			 bi->y = (sd->h / 2) +
 			 (((bi->ask.pos + (bi->ask.size2 / 2) -
@@ -3927,7 +3951,8 @@
 		       bi->h = bi->ask.size2;
 		    }
 		  else
-		    { /* either side of middle */
+		    {
+                       /* either side of middle */
 		       bi->y = (bi->ask.pos - (bi->ask.res / 2)) + (sd->h / 2);
 		       bi->h = bi->ask.size2;
 		    }
@@ -3984,7 +4009,7 @@
    E_Layout_Item_Container *lc_moving = NULL, *lc_back, *lc, *lc3;
    E_Gadcon_Layout_Item *bi, *bi_moving;

-   if (!list || !*list) return;
+   if ((!list) || (!*list)) return;

    for (l = *list; l; l = l->next)
      {
@@ -4068,11 +4093,10 @@
 	if (!ok)
 	  {
 	     int pos, prev_pos, stop;
-	     for (l = *list; (l) && (l->data != lc_moving); l = l->next);
-
+
+	     for (l = *list; (l) && (l->data != lc_moving); l = l->next);
 	     pos = lc_moving->pos + lc_moving->size;
 	     prev_pos = lc_moving_prev_pos;
-
 	     if ((l) && (l->next))
 	       {
 		  stop = 0;
@@ -4269,7 +4293,7 @@
 	       {
 		  if (!l2) l2 = *list;
 		  else l2 = l2->next;
-
+
 		  for (; l2 != l; l2 = l2->next)
 		    {
 		       lc = l2->data;
@@ -4558,6 +4582,7 @@
 		      (lc2->state_info.min_seq < lc->state_info.max_seq)))
 	       {
 		  int shift = 0;
+
 		  _e_gadcon_layout_smart_containers_merge(sd, lc, lc2);

 		  for (l = lc->items; l; l = l->next)
@@ -4686,6 +4711,7 @@
 	       {
 		  int move_lc1 = 1;
 		  int move_lc2 = 1;
+
 		  for (l = lc->items; l; l = l->next)
 		    {
 		       bi = l->data;
@@ -4757,6 +4783,7 @@
 		      (lc2->state_info.min_seq < lc->state_info.max_seq)))
 	       {
 		  int shift = 0;
+
 		  _e_gadcon_layout_smart_containers_merge(sd, lc, lc2);

 		  for (l = lc->items; l; l = l->next)
@@ -4951,7 +4978,6 @@
 	  bi->w = (*lc_moving)->prev_size;
 	else
 	  bi->h = (*lc_moving)->prev_size;
-
      }
    _e_gadcon_layout_smart_position_items_inside_container(sd, (*lc_moving));
    (*lc_moving)->state = E_LAYOUT_ITEM_CONTAINER_STATE_POS_LOCKED;
@@ -5048,7 +5074,7 @@
 			 }
 		       *lc_moving = lc_back;
 		       _e_gadcon_layout_smart_position_items_inside_container(sd, *lc_moving);
-
+
 		       if (((*lc_moving)->state != E_LAYOUT_ITEM_CONTAINER_STATE_POS_INC) &&
 			   ((*lc_moving)->state != E_LAYOUT_ITEM_CONTAINER_STATE_POS_DEC))
 			 {
@@ -5143,49 +5169,3 @@
 	populate_idler = NULL;
      }
 }
-
-EAPI Eina_Bool
-e_gadcon_site_is_shelf      (E_Gadcon_Site site)
-{
-   return site == E_GADCON_SITE_SHELF;
-}
-
-EAPI Eina_Bool
-e_gadcon_site_is_desktop    (E_Gadcon_Site site)
-{
-   return site == E_GADCON_SITE_DESKTOP;
-}
-
-EAPI Eina_Bool
-e_gadcon_site_is_efm_toolbar(E_Gadcon_Site site)
-{
-   return site == E_GADCON_SITE_EFM_TOOLBAR;
-}
-
-EAPI Eina_Bool
-e_gadcon_site_is_any_toolbar(E_Gadcon_Site site)
-{
-   switch (site)
-     {
-        // there should be all toolbar sities identifiers
-        case E_GADCON_SITE_TOOLBAR:
-        case E_GADCON_SITE_EFM_TOOLBAR:
-           return EINA_TRUE;
-     }
-
-   return EINA_FALSE;
-}
-
-EAPI Eina_Bool
-e_gadcon_site_is_not_toolbar(E_Gadcon_Site site)
-{
-   switch (site)
-     {
-        // there should be all toolbar sities identifiers
-        case E_GADCON_SITE_TOOLBAR:
-        case E_GADCON_SITE_EFM_TOOLBAR:
-           return EINA_FALSE;
-     }
-
-   return EINA_TRUE;
-}


jplist: Make strndup argument const to silence compiler warning

--- src/jplist.c
+++ src/jplist.c
@@ -66,7 +66,7 @@
 }

 #ifndef HAVE_STRNDUP
-static char* strndup(char* str, size_t len)
+static char* strndup(const char* str, size_t len)
 {
     char *newstr = (char *)malloc(len+1);
     if (newstr) {


fixed bug in ctts packing for isma and adobe

--- src/media_tools/ismacryp.c
+++ src/media_tools/ismacryp.c
@@ -515,6 +515,8 @@

 	GF_LOG(GF_LOG_INFO, GF_LOG_AUTHOR, ("[CENC/ISMA] Decrypting track ID %d - KMS: %s%s\n", tci->trackID, tci->KMS_URI, use_sel_enc ? " - Selective Decryption" : ""));

+	if (gf_isom_has_time_offset(mp4, track)) gf_isom_set_cts_packing(mp4, track, GF_TRUE);
+
 	/*start as initialized*/
 	prev_sample_encrypted = 1;
 	/* decrypt each sample */
@@ -578,6 +580,7 @@
 	if (e) {
 		GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[CENC/ISMA] Error ISMACryp signature from trackID %d: %s\n", tci->trackID, gf_error_to_string(e)));
 	}
+	gf_isom_set_cts_packing(mp4, track, GF_FALSE);

 	/*remove all IPMP ptrs*/
 	esd = gf_isom_get_esd(mp4, track, 1);
@@ -1559,6 +1562,8 @@
 		return GF_OK;
 	}

+	if (gf_isom_has_time_offset(mp4, track)) gf_isom_set_cts_packing(mp4, track, GF_TRUE);
+
 	esd = gf_isom_get_esd(mp4, track, 1);
 	if (esd && (esd->decoderConfig->streamType == GF_STREAM_OD)) {
 		gf_odf_desc_del((GF_Descriptor *) esd);
@@ -1920,6 +1925,8 @@
 		goto exit;
 	}

+	if (gf_isom_has_time_offset(mp4, track)) gf_isom_set_cts_packing(mp4, track, GF_TRUE);
+
 	/* decrypt each sample */
 	count = gf_isom_get_sample_count(mp4, track);
 	buffer = (char*)gf_malloc(sizeof(char) * max_size);
@@ -2193,6 +2200,8 @@
 	/*Adobe's protection scheme does not support selective key*/
 	memcpy(tci->key, tci->keys[0], 16);

+	if (gf_isom_has_time_offset(mp4, track)) gf_isom_set_cts_packing(mp4, track, GF_TRUE);
+
 	e = gf_isom_set_adobe_protection(mp4, track, 1, GF_ISOM_ADOBE_SCHEME, 1, GF_TRUE, tci->metadata, tci->metadata_len);
 	if (e) goto  exit;

@@ -2281,6 +2290,7 @@

 		gf_set_progress("Adobe's protection scheme Encrypt", i+1, count);
 	}
+	gf_isom_set_cts_packing(mp4, track, GF_FALSE);

 exit:
 	if (samp) gf_isom_sample_del(&samp);
@@ -2320,6 +2330,8 @@
 	}

 	memcpy(tci->key, tci->keys[0], 16);
+
+	if (gf_isom_has_time_offset(mp4, track)) gf_isom_set_cts_packing(mp4, track, GF_TRUE);

 	count = gf_isom_get_sample_count(mp4, track);
 	gf_isom_set_nalu_extract_mode(mp4, track, GF_ISOM_NALU_EXTRACT_INSPECT);
@@ -2390,6 +2402,7 @@
 	if (e) {
 		GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[ADOBE] Error Adobe's protection scheme signature from trackID %d: %s\n", tci->trackID, gf_error_to_string(e)));
 	}
+	gf_isom_set_cts_packing(mp4, track, GF_FALSE);

 exit:
 	if (mc) gf_crypt_close(mc);


filled in perm_matrix

filled in perm_matrix

--- src/reorder.c
+++ src/reorder.c
@@ -279,9 +279,24 @@
   idx_t const * const perm,
   matrix_t * retmat)
 {
-
+  idx_t const I = mat->I;
+  idx_t const J = mat->J;
+
+  if(retmat == NULL) {
+    retmat = (matrix_t *) malloc(sizeof(matrix_t));
+    retmat->I = I;
+    retmat->J = J;
+    retmat->vals = (val_t *) malloc(I * J * sizeof(val_t));
+  }
+
+  for(idx_t i=0; i < I; ++i) {
+    for(idx_t j=0; j < J; ++j) {
+      retmat->vals[j + (i*J)] = mat->vals[j + (perm[i] * J)];
+    }
+  }

   return retmat;
 }

+


fixed bug using isma E&A on hevc

fixed bug using isma E&A on hevc

--- src/media_tools/ismacryp.c
+++ src/media_tools/ismacryp.c
@@ -485,7 +485,7 @@
 {
 	GF_Err e;
 	Bool use_sel_enc;
-	u32 track, count, i, j, si, is_avc;
+	u32 track, count, i, j, si, otype, is_nalu;
 	GF_ISOSample *samp;
 	GF_ISMASample *ismasamp;
 	GF_Crypt *mc;
@@ -495,9 +495,9 @@
 	GF_ESD *esd;

 	track = gf_isom_get_track_by_id(mp4, tci->trackID);
-	e = gf_isom_get_ismacryp_info(mp4, track, 1, &is_avc, NULL, NULL, NULL, NULL, &use_sel_enc, &IV_size, NULL);
+	e = gf_isom_get_ismacryp_info(mp4, track, 1, &otype, NULL, NULL, NULL, NULL, &use_sel_enc, &IV_size, NULL);
 	if (e) return e;
-	is_avc = (is_avc==GF_ISOM_BOX_TYPE_264B) ? 1 : 0;
+	is_nalu = ((otype==GF_ISOM_BOX_TYPE_264B) || (otype==GF_ISOM_BOX_TYPE_265B)) ? 1 : 0;

 	mc = gf_crypt_open(GF_AES_128, GF_CTR);
@@ -543,7 +543,7 @@
 		gf_isom_ismacryp_delete_sample(ismasamp);

 		/*replace AVC start codes (0x00000001) by nalu size*/
-		if (is_avc) {
+		if (is_nalu) {
 			u32 nalu_size;
 			u32 remain = samp->dataLength;
 			char *start, *end;
@@ -638,7 +638,7 @@
 	GF_ISOSample *samp;
 	GF_ISMASample *isamp;
 	GF_Crypt *mc;
-	u32 i, count, di, track, IV_size, rand, avc_size_length;
+	u32 i, count, di, track, IV_size, rand, avc_size_length, hevc_size_length;
 	u64 BSO, range_end;
 	GF_ESD *esd;
 	GF_IPMPPtr *ipmpdp;
@@ -650,7 +650,7 @@
 	GF_Err e;
 	Bool prev_sample_encryped, has_crypted_samp;

-	avc_size_length = 0;
+	avc_size_length = hevc_size_length = 0;
 	track = gf_isom_get_track_by_id(mp4, tci->trackID);
 	if (!track) {
 		GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[CENC/ISMA] Cannot find TrackID %d in input file - skipping\n", tci->trackID));
@@ -664,6 +664,7 @@
 	}
 	if (esd) {
 		if ((esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_AVC) || (esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_SVC)) avc_size_length = 1;
+		else if ((esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_HEVC) || (esd->decoderConfig->objectTypeIndication==GPAC_OTI_VIDEO_LHVC)) hevc_size_length = 1;
 		gf_odf_desc_del((GF_Descriptor*) esd);
 	}
 	if (avc_size_length) {
@@ -671,7 +672,16 @@
 		avc_size_length = avccfg->nal_unit_size;
 		gf_odf_avc_cfg_del(avccfg);
 		if (avc_size_length != 4) {
-			GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[CENC/ISMA] Cannot encrypt AVC/H264 track with %d size_length field - onmy 4 supported\n", avc_size_length));
+			GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[CENC/ISMA] Cannot encrypt AVC/H264 track with %d size_length field - only 4 supported\n", avc_size_length));
+			return GF_NOT_SUPPORTED;
+		}
+	}
+	if (hevc_size_length) {
+		GF_HEVCConfig *hvccfg = gf_isom_hevc_config_get(mp4, track, 1);
+		avc_size_length = hvccfg->nal_unit_size;
+		gf_odf_hevc_cfg_del(hvccfg);
+		if (avc_size_length != 4) {
+			GF_LOG(GF_LOG_ERROR, GF_LOG_AUTHOR, ("[CENC/ISMA] Cannot encrypt HEVC/H265 track with %d size_length field - only 4 supported\n", avc_size_length));
 			return GF_NOT_SUPPORTED;
 		}
 	}


fix method map bux

fix method map bux

--- src/request.c
+++ src/request.c
@@ -23,7 +23,7 @@

 const char *get_method_name(http_request_method_t method)
 {
-	for (int i = GET; i <= DELETE - GET + 1; i++) {
+	for (int i = 0; i < DELETE - GET + 1; i++) {
 		if (method == method_name_map[i].method) {
 			return method_name_map[i].name;
 		}


Use the 'to' vector to determine the loop count.

--- src/mesa/math/m_copy_tmp.h
+++ src/mesa/math/m_copy_tmp.h
@@ -34,7 +34,7 @@
    GLfloat (*t)[4] = (GLfloat (*)[4])to->start;				\
    GLfloat *from = f->start;						\
    GLuint stride = f->stride;				        	\
-   GLuint count = f->count;						\
+   GLuint count = to->count;						\
    GLuint i;								\
 									\
    if (BITS)								\


modules/app: use new error_packet functions

Signed-off-by: Bruno Dilly <ea4fb6320c1221b6a559089d8ab97ffc53fc6586@intel.com>

--- src/modules/flow/app/app.c
+++ src/modules/flow/app/app.c
@@ -188,10 +188,8 @@
     int r;

     r = unsetenv(var_name);
-    if (r < 0) {
-        return sol_flow_send_error_packet(node, errno,
-            sol_util_strerrora(errno));
-    }
+    if (r < 0)
+        return sol_flow_send_error_packet_errno(node, errno);

     return 0;
 }
@@ -239,10 +237,8 @@
         return 0;

     r = setenv(mdata->name, mdata->value, mdata->overwrite);
-    if (r < 0) {
-        return sol_flow_send_error_packet(node, errno,
-            sol_util_strerrora(errno));
-    }
+    if (r < 0)
+        return sol_flow_send_error_packet_errno(node, errno);

     return 0;
 }


Fixed wrong initialization when gain voltage equal zero

--- src/motors/motor_control.c
+++ src/motors/motor_control.c
@@ -248,9 +248,14 @@
     motors[motIdx].current.k = (-motors[motIdx].parameter_motor.rotation) * GAIN_KILO * ((float) GAIN_ADC) / motors[motIdx].parameter_motor.bridge.current_gain;
     motors[motIdx].current.offset = ((int)(motors[motIdx].parameter_motor.bridge.current_offset / ((float) GAIN_ADC)));
     // Convert gain volt in [mV]
-    motors[motIdx].volt.k = motors[motIdx].parameter_motor.bridge.volt_gain * GAIN_ADC;
-    motors[motIdx].volt.offset = (int)(motors[motIdx].parameter_motor.bridge.volt_offset / motors[motIdx].volt.k);
-    motors[motIdx].volt.k *= GAIN_KILO;
+    if(motors[motIdx].parameter_motor.bridge.volt_gain == 0) {
+        motors[motIdx].volt.offset = (int)(GAIN_KILO*motors[motIdx].parameter_motor.bridge.volt_offset);
+        motors[motIdx].volt.k = 1;
+    } else {
+        motors[motIdx].volt.k = motors[motIdx].parameter_motor.bridge.volt_gain * GAIN_ADC;
+        motors[motIdx].volt.offset = (int)(motors[motIdx].parameter_motor.bridge.volt_offset / motors[motIdx].volt.k);
+        motors[motIdx].volt.k *= GAIN_KILO;
+    }
 }

 motor_t init_motor_constraints() {


resolve BUGFIX null dereference

resolve BUGFIX null dereference

--- src/resolve.c
+++ src/resolve.c
@@ -2581,7 +2581,7 @@
                     }

                     /* make value canonical (remove module name prefix) unless it was specified with it */
-                    if (!strchr(llist_value, ':') && (llist->value_type & LY_TYPE_IDENT)
+                    if (llist_value && !strchr(llist_value, ':') && (llist->value_type & LY_TYPE_IDENT)
                             && !strncmp(llist->value_str, lyd_node_module(sibling)->name, strlen(lyd_node_module(sibling)->name))
                             && (llist->value_str[strlen(lyd_node_module(sibling)->name)] == ':')) {
                         data_val = llist->value_str + strlen(lyd_node_module(sibling)->name) + 1;


fixed backwards memset argument order

fixed backwards memset argument order

svn: r16191

--- src/mzscheme/src/portfun.c
+++ src/mzscheme/src/portfun.c
@@ -942,7 +942,7 @@
     } else {
       char *vb;
       vb = scheme_malloc_atomic(size + 1);
-      memset(vb, size + 1, 0); /* must initialize for security */
+      memset(vb, 0, size + 1); /* must initialize for security */
       bstr = scheme_make_sized_byte_string(vb, size, 0);
     }
     a[0] = bstr;


bump version in libacm.h too

bump version in libacm.h too

--- src/libacm.h
+++ src/libacm.h
@@ -19,7 +19,7 @@
 #ifndef __LIBACM_H
 #define __LIBACM_H

-#define LIBACM_VERSION "0.9.2"
+#define LIBACM_VERSION "1.0-svn"

 #define ACM_ID		0x032897
 #define ACM_WORD	2


a more efficient way to detect error caused by case-foldeing file system

bk: 3cdae96dUW0qPVeREO7SbQ2ih2HIbQ

--- src/resolve.c
+++ src/resolve.c
@@ -2165,181 +2165,34 @@
 }

 /*
- * Make sure there are no edited files, no RENAMES, and {r,m}.files and
- * apply all files.
- */
-private	int
-pass4_apply(opts *opts)
-{
-	sccs	*r, *l;
-	int	offset = strlen(ROOT2RESYNC) + 1;	/* RESYNC/ */
-	int	eperm = 0, first = 1, flags, ret;
-	int	getFlags = GET_EXPAND;
-	FILE	*f = 0;
-	FILE	*save;
-	char	buf[MAXPATH];
-	char	key[MAXKEY];
-	char 	realname[MAXPATH];
-	MDBM	*permDB = mdbm_mem();
-	char	*cmd = "apply";
-
-	if (opts->log) fprintf(opts->log, "==== Pass 4 ====\n");
-	opts->pass = 4;
-
-	unfinished(opts);
-
-	/*
-	 * Call the pre-apply trigger if there is one so that we have
-	 * one last chance to bail out.
-	 */
-	putenv("BK_CSETLIST=BitKeeper/etc/csets-in");
-	if (getenv("BK_REMOTE") && streq(getenv("BK_REMOTE"), "YES")) {
-		cmd = "remote apply";
-	}
-	if (!opts->logging && (ret = trigger(cmd,  "pre"))) {
-		switch (ret) {
-		    case 3: flags = CLEAN_MVRESYNC; break;
-		    case 2: flags = CLEAN_RESYNC; break;
-		    default: flags = CLEAN_RESYNC|CLEAN_PENDING; break;
-		}
-		mdbm_close(permDB);
-		resolve_cleanup(opts, CLEAN_NOSHOUT|flags);
-	}
-
-	/*
-	 * Pass 4a - check for edited files and build up a list of files to
-	 * backup and remove.
-	 */
-	chdir(RESYNC2ROOT);
-	save = fopen(BACKUP_LIST, "w+");
-	unlink(PASS4_TODO);
-	sprintf(key, "bk sfind %s > " PASS4_TODO, ROOT2RESYNC);
-	if (system(key) || !(f = fopen(PASS4_TODO, "r+")) || !save) {
-		fprintf(stderr, "Unable to create|open " PASS4_TODO);
-		fclose(save);
-		mdbm_close(permDB);
-		resolve_cleanup(opts, 0);
-	}
-	chmod(PASS4_TODO, 0666);
-	while (fnext(buf, f)) {
-		chop(buf);
-		/*
-		 * We want to check the checksum here and here only
-		 * before we throw it over the wall.
-		 */
-		unless (r = sccs_init(buf, INIT_SAVEPROJ, opts->resync_proj)) {
-			fprintf(stderr,
-			    "resolve: can't init %s - abort.\n", buf);
-			fclose(save);
-			fprintf(stderr, "resolve: no files were applied.\n");
-			resolve_cleanup(opts, 0);
-		}
-#define	F ADMIN_FORMAT|ADMIN_TIME|ADMIN_BK
-		if (sccs_admin(r, 0, SILENT|F, 0, 0, 0, 0, 0, 0, 0, 0)) {
-			sccs_admin(r, 0, F, 0, 0, 0, 0, 0, 0, 0, 0);
-			fprintf(stderr, "resolve: bad file %s;\n", r->sfile);
-			fprintf(stderr, "resolve: no files were applied.\n");
-			fclose(save);
-			mdbm_close(permDB);
-			resolve_cleanup(opts, 0);
-		}
-		if (writeCheck(r, permDB) && first) {
-			first = 0;
-			eperm = 1;
-		}
-		sccs_sdelta(r, sccs_ino(r), key);
-		sccs_free(r);
-		if (l = sccs_keyinit(key, INIT, opts->local_proj, opts->idDB)) {
-			/*
-			 * This should not happen, the repository is locked.
-			 */
-			if (sccs_clean(l, SILENT)) {
-				fprintf(stderr,
-				    "\nWill not overwrite edited %s\n",
-				    l->gfile);
-				fclose(save);
-				resolve_cleanup(opts, 0);
-			}
-			fprintf(save, "%s\n", l->sfile);
-			sccs_free(l);
-		}
-	}
-	fclose(save);
-	mdbm_close(permDB);
-
-	if (eperm) {
-		getMsg("write_perms", 0, 0, stderr);
-		resolve_cleanup(opts, 0);
-	}
-
-	/*
-	 * Pass 4b.
-	 * Save the list of files and then remove them.
-	 */
-	if (size(BACKUP_LIST) > 0) {
-		unlink(BACKUP_SFIO);
-		if (sysio(BACKUP_LIST, BACKUP_SFIO, 0,
-						"bk", "sfio", "-omq", SYS)) {
-			fprintf(stderr,
-			    "Unable to create backup %s from %s\n",
-			    BACKUP_SFIO, BACKUP_LIST);
-			fclose(save);
-			resolve_cleanup(opts, 0);
-		}
-		save = fopen(BACKUP_LIST, "rt");
-		assert(save);
-		while (fnext(buf, save)) {
-			chop(buf);
-			if (opts->log) fprintf(stdlog, "unlink(%s)\n", buf);
-			rm_sfile(buf, 1);
-		}
-		fclose(save);
-	}
-
-	/*
-	 * Pass 4c - apply the files.
-	 */
-	unless (save = fopen(APPLIED, "w+")) {
-		restore(opts);
-		resolve_cleanup(opts, 0);
-	}
+ * Return true if we detected a case folding File system
+ */
+private int
+isCaseFoldingFS()
+{
+	char	s_cset[] = CHANGESET;
+	char	*p;
+
+	p = strrchr(s_cset, '/');
+	assert(p && (p[1] == 's'));
+	p[1] = 'S';  /* change to upper case */
+	return (exists(s_cset));
+}
+
+/*
+ * Make sure the file name did not change case orientation after we copied it
+ */
+private int
+chkCaseChg(FILE *f)
+{
+	char	buf[MAXPATH], realname[MAXPATH];
+
 	fflush(f);
 	rewind(f);
-
-	/*
-	 * Get user preference from the local config file
-	 */
-	if (strieq("edit", user_preference("checkout"))) getFlags = GET_EDIT;
-
 	while (fnext(buf, f)) {
-		chop(buf);
-		/*
-		 * We want to get the part of the path without the RESYNC.
-		 */
-		if (exists(&buf[offset])) {
-			fprintf(stderr,
-			    "resolve: failed to remove conflict %s\n",
-			    &buf[offset]);
-			unapply(save);
-			restore(opts);
-			resolve_cleanup(opts, 0);
-		}
-		if (opts->log) {
-			fprintf(stdlog, "copy(%s, %s)\n", buf, &buf[offset]);
-		}
-		if (copyAndGet(buf, &buf[offset], opts->local_proj, getFlags)) {
-			perror("copy");
-			fprintf(stderr,
-			    "copy(%s, %s) failed\n", buf, &buf[offset]);
-			unapply(save);
-			restore(opts);
-			resolve_cleanup(opts, 0);
-		} else {
-			opts->applied++;
-		}
-		fprintf(save, "%s\n", &buf[offset]);
-		getRealName(&buf[offset], localDB, realname);
-		unless (streq(&buf[offset], realname)) {
+		chomp(buf);
+		getRealName(buf, localDB, realname);
+		unless (streq(buf, realname)) {
 			char	*case_folding_err =
 "\n\
 ============================================================================\n\
@@ -2372,20 +2225,201 @@
 Got:\n\
     %s -> %s\n\
 ============================================================================\n";
-			opts->applied--;
-			if (strcasecmp(&buf[offset], realname) == 0) {
+			if (strcasecmp(buf, realname) == 0) {
 				fprintf(stderr, case_folding_err, buf,
-				    &buf[offset], buf, realname, &buf[offset]);
+				    		buf, buf, realname, buf);
 			} else {
-				fprintf(stderr, unknown_err, buf,
-						&buf[offset], buf, realname);
+				fprintf(stderr, unknown_err,
+						buf, buf, buf, realname);
 			}
+			return (-1);
+		}
+	}
+	return (0);
+}
+
+/*
+ * Make sure there are no edited files, no RENAMES, and {r,m}.files and
+ * apply all files.
+ */
+private	int
+pass4_apply(opts *opts)
+{
+	sccs	*r, *l;
+	int	offset = strlen(ROOT2RESYNC) + 1;	/* RESYNC/ */
+	int	eperm = 0, first = 1, flags, ret;
+	int	getFlags = GET_EXPAND;
+	FILE	*f = 0;
+	FILE	*save = 0;
+	char	buf[MAXPATH];
+	char	key[MAXKEY];
+	MDBM	*permDB = mdbm_mem();
+	char	*cmd = "apply";
+
+	if (opts->log) fprintf(opts->log, "==== Pass 4 ====\n");
+	opts->pass = 4;
+
+	unfinished(opts);
+
+	/*
+	 * Call the pre-apply trigger if there is one so that we have
+	 * one last chance to bail out.
+	 */
+	putenv("BK_CSETLIST=BitKeeper/etc/csets-in");
+	if (getenv("BK_REMOTE") && streq(getenv("BK_REMOTE"), "YES")) {
+		cmd = "remote apply";
+	}
+	if (!opts->logging && (ret = trigger(cmd,  "pre"))) {
+		switch (ret) {
+		    case 3: flags = CLEAN_MVRESYNC; break;
+		    case 2: flags = CLEAN_RESYNC; break;
+		    default: flags = CLEAN_RESYNC|CLEAN_PENDING; break;
+		}
+		mdbm_close(permDB);
+		resolve_cleanup(opts, CLEAN_NOSHOUT|flags);
+	}
+
+	/*
+	 * Pass 4a - check for edited files and build up a list of files to
+	 * backup and remove.
+	 */
+	chdir(RESYNC2ROOT);
+	save = fopen(BACKUP_LIST, "w+");
+	unlink(PASS4_TODO);
+	sprintf(key, "bk sfind %s > " PASS4_TODO, ROOT2RESYNC);
+	if (system(key) || !(f = fopen(PASS4_TODO, "r+")) || !save) {
+		fprintf(stderr, "Unable to create|open " PASS4_TODO);
+		fclose(save);
+		mdbm_close(permDB);
+		resolve_cleanup(opts, 0);
+	}
+	chmod(PASS4_TODO, 0666);
+	while (fnext(buf, f)) {
+		chop(buf);
+		/*
+		 * We want to check the checksum here and here only
+		 * before we throw it over the wall.
+		 */
+		unless (r = sccs_init(buf, INIT_SAVEPROJ, opts->resync_proj)) {
+			fprintf(stderr,
+			    "resolve: can't init %s - abort.\n", buf);
+			fclose(save);
+			fprintf(stderr, "resolve: no files were applied.\n");
+			resolve_cleanup(opts, 0);
+		}
+#define	F ADMIN_FORMAT|ADMIN_TIME|ADMIN_BK
+		if (sccs_admin(r, 0, SILENT|F, 0, 0, 0, 0, 0, 0, 0, 0)) {
+			sccs_admin(r, 0, F, 0, 0, 0, 0, 0, 0, 0, 0);
+			fprintf(stderr, "resolve: bad file %s;\n", r->sfile);
+			fprintf(stderr, "resolve: no files were applied.\n");
+			fclose(save);
+			mdbm_close(permDB);
+			resolve_cleanup(opts, 0);
+		}
+		if (writeCheck(r, permDB) && first) {
+			first = 0;
+			eperm = 1;
+		}
+		sccs_sdelta(r, sccs_ino(r), key);
+		sccs_free(r);
+		if (l = sccs_keyinit(key, INIT, opts->local_proj, opts->idDB)) {
+			/*
+			 * This should not happen, the repository is locked.
+			 */
+			if (sccs_clean(l, SILENT)) {
+				fprintf(stderr,
+				    "\nWill not overwrite edited %s\n",
+				    l->gfile);
+				fclose(save);
+				resolve_cleanup(opts, 0);
+			}
+			fprintf(save, "%s\n", l->sfile);
+			sccs_free(l);
+		}
+	}
+	fclose(save);
+	mdbm_close(permDB);
+
+	if (eperm) {
+		getMsg("write_perms", 0, 0, stderr);
+		resolve_cleanup(opts, 0);
+	}
+
+	/*
+	 * Pass 4b.
+	 * Save the list of files and then remove them.
+	 */
+	if (size(BACKUP_LIST) > 0) {
+		unlink(BACKUP_SFIO);
+		if (sysio(BACKUP_LIST, BACKUP_SFIO, 0,
+						"bk", "sfio", "-omq", SYS)) {
+			fprintf(stderr,
+			    "Unable to create backup %s from %s\n",
+			    BACKUP_SFIO, BACKUP_LIST);
+			fclose(save);
+			resolve_cleanup(opts, 0);
+		}
+		save = fopen(BACKUP_LIST, "rt");
+		assert(save);
+		while (fnext(buf, save)) {
+			chop(buf);
+			if (opts->log) fprintf(stdlog, "unlink(%s)\n", buf);
+			rm_sfile(buf, 1);
+		}
+		fclose(save);
+	}
+
+	/*
+	 * Pass 4c - apply the files.
+	 */
+	unless (save = fopen(APPLIED, "w+")) {
+		restore(opts);
+		resolve_cleanup(opts, 0);
+	}
+	fflush(f);
+	rewind(f);
+
+	/*
+	 * Get user preference from the local config file
+	 */
+	if (strieq("edit", user_preference("checkout"))) getFlags = GET_EDIT;
+
+	while (fnext(buf, f)) {
+		chop(buf);
+		/*
+		 * We want to get the part of the path without the RESYNC.
+		 */
+		if (exists(&buf[offset])) {
+			fprintf(stderr,
+			    "resolve: failed to remove conflict %s\n",
+			    &buf[offset]);
 			unapply(save);
 			restore(opts);
 			resolve_cleanup(opts, 0);
 		}
+		if (opts->log) {
+			fprintf(stdlog, "copy(%s, %s)\n", buf, &buf[offset]);
+		}
+		if (copyAndGet(buf, &buf[offset], opts->local_proj, getFlags)) {
+			perror("copy");
+			fprintf(stderr,
+			    "copy(%s, %s) failed\n", buf, &buf[offset]);
+err:			unapply(save);
+			restore(opts);
+			resolve_cleanup(opts, 0);
+		} else {
+			opts->applied++;
+		}
+		fprintf(save, "%s\n", &buf[offset]);
 	}
 	fclose(f);
+
+ 	/*
+	 * If case folding file system , make sure file name
+	 * did not change case after we copied it
+	 */
+	if (isCaseFoldingFS() && chkCaseChg(save)) goto err;
+
 	unless (opts->quiet) {
 		fprintf(stderr,
 		    "resolve: applied %d files in pass 4\n", opts->applied);
@@ -2394,8 +2428,9 @@
 		fprintf(stderr,
 		    "resolve: running consistency check, please wait...\n");
 	}
-	fflush(save); /*  important */
+
 	if (strieq("yes", user_preference("partial_check"))) {
+		fflush(save); /*  important */
 		ret = run_check(APPLIED);
 	} else {
 		ret = run_check(0);
@@ -2406,9 +2441,7 @@
 		 * Clean up any gfiles we may have pulled out to run check.
 		 */
 		system("bk clean BitKeeper/etc");
-		unapply(save);
-		restore(opts);
-		resolve_cleanup(opts, 0);
+		goto err;
 	}
 	fclose(save);
 	unlink(BACKUP_LIST);


Removed redundant statement

Removed redundant statement

--- src/seshigh.c
+++ src/seshigh.c
@@ -665,7 +665,6 @@
         rr->output_format = match_syntax;
     if (match_schema)
         rr->schema = odr_strdup(rr->stream, match_schema);
-    return 0;
 #else
     (*assoc->init->bend_fetch)(assoc->backend, rr);
 #endif


glusterd: handle a crash in dump_version_cbk (in handshake)

reset 'frame->local' to NULL before STACK_DESTROY(), which prevents
freeing of valid 'peerctx' pointer.

Signed-off-by: Amar Tumballi <amar@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>

BUG: 2485 ([glusterfs-3.1.3qa2]: Core generated due to SegFault in glusterd_rpc_notify)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2485

--- xlators/mgmt/glusterd/src/glusterd-handshake.c
+++ xlators/mgmt/glusterd/src/glusterd-handshake.c
@@ -389,6 +389,7 @@
                 }
         }

+        frame->local = NULL;
         STACK_DESTROY (frame->root);

         if (ret != 0)


fix ls->hold going to the fromt

fix ls->hold going to the fromt

--- src/lmacro.c
+++ src/lmacro.c
@@ -97,6 +97,19 @@
 }

 void init_reczio(LexState *ls) {
+  if (ls->current != EOZ) {
+    /* macro_str = macro_str .. ls->current */
+    lua_pushstring(ls->L, cast(const char *, &ls->current));
+    lua_concat(ls->L, 2);
+
+    /* if ls->hold then macro_str = macro_str .. ls->hold end */
+    if (ls->hold != -1) {
+      lua_pushstring(ls->L, cast(const char *, &ls->hold));
+      ls->hold = -1;
+      lua_concat(ls->L, 2);
+    }
+  }
+
   ZioWrapperData* data = luaM_new(ls->L, ZioWrapperData);
   data->size = lua_rawlen(ls->L, -1);
   data->reg_ref = luaL_ref(ls->L, LUA_REGISTRYINDEX); /* pops str */
@@ -115,12 +128,6 @@
 void save_substitution_string(LexState *ls) {
   /* if the function call returns a non-empty string, add to the lex queue */
   if (lua_type(ls->L, -1) == LUA_TSTRING && lua_rawlen(ls->L, -1) > 0) {
-    if (ls->current != EOZ) {
-      /* macro_str = macro_str .. ls->current */
-      lua_pushstring(ls->L, cast(const char *, &ls->current));
-      lua_concat(ls->L, 2);
-    }
-
     init_reczio(ls);
     next(ls);
   } else {


[t:2542] Fix some bugs in the PUT loader.
Put, once it has returned one error, will continue to return errors (-1)

git-svn-id: b5c078ec0b4d3a50497e9dd3081db18a5b4f16e5@19682 c7de825b-a66e-492c-adef-691d508d4ae1

--- src/loader.c
+++ src/loader.c
@@ -258,7 +258,7 @@

     // skip put if error already found
     if ( loader->i->err_errno != 0 ) {
-        return 0;
+        return -1;
     }

     if ( loader->i->loader_flags & LOADER_USE_PUTS ) {
@@ -292,7 +292,7 @@

         // deliberately return content free value
         //   - must call error_callback to get error info
-        return -1;
+        return -1;
     }
     return 0;
 }
@@ -304,7 +304,12 @@
         if ( loader->i->error_callback != NULL ) {
             loader->i->error_callback(loader->i->dbs[loader->i->err_i], loader->i->err_i, loader->i->err_errno, &loader->i->err_key, &loader->i->err_val, loader->i->error_extra);
         }
-        r = toku_brt_loader_abort(loader->i->brt_loader, TRUE);
+        if ( !(loader->i->loader_flags & LOADER_USE_PUTS ) ) {
+            r = toku_brt_loader_abort(loader->i->brt_loader, TRUE);
+        }
+        else {
+            r = loader->i->err_errno;
+        }
     }
     else { // no error outstanding
         if ( !(loader->i->loader_flags & LOADER_USE_PUTS ) ) {


Rewritten last rename + miscellanea changes.

--- src/log/fs.c
+++ src/log/fs.c
@@ -250,20 +250,20 @@

     dir = opendir(dirname);
     if (dir) {
+      baselen = strlen(basename);
+
       while ((de = readdir(dir))) {
         pos = strrchr(de->d_name, '.');
-        if (pos &&
-            (size_t)(pos - de->d_name) == strlen(basename) &&
-            strncmp(basename, de->d_name, strlen(basename)) == 0 &&
-            atoi((++pos)) > max)
-          max = atoi(pos);
+        if (pos && atoi(pos+1) > max &&
+            (size_t)(pos - de->d_name) == baselen &&
+            strncmp(basename, de->d_name, baselen) == 0)
+          max = atoi(pos+1);
       }
     }
     closedir(dir);

     /* rename each file increasing the suffix */
-
     strcpy(newname, name);
     newname[namelen]='.';

@@ -283,12 +283,11 @@
         (void)rename(oldname, newname);
       }
     }
+
     /* rename the main file to .1  */
-
-    newname = (char *)malloc((strlen(name) + 3) * sizeof(char));
     if (newname) {
-      strcpy(newname, name);
-      strcat(newname, ".1");
+      newname[namelen+1]='1';
+      newname[namelen+2]='\0';
       if (rename(name, newname) == -1)
         res = 0;
       result = 1;


Add basic logging header

Add basic logging header

error: pathspec 'src/logger.h' did not match any file(s) known to git

--- src/logger.h
+++ src/logger.h
@@ -0,0 +1,15 @@
+#ifndef ARGPARSE_LOGGER_H
+#define ARGPARSE_LOGGER_H
+
+#ifdef DEBUG
+
+#include <stdio.h>
+#define LOG(format, ...) fprintf(stderr, "%s:%s:%d:"format"\n", PACKAGE, __FILE__, __LINE__, __VA_ARGS__)
+
+#else
+
+#define LOG(format, ...)
+
+#endif // DEBUG
+
+#endif // ARGPARSE_LOGGER_H


move "conn closed by client" from INFO to DEBUG

--- src/shervin.c
+++ src/shervin.c
@@ -47,7 +47,7 @@

   ev_io_stop(l, eio);
   free(eio);
-  fgaj_i("c%p closed by client", eio);
+  fgaj_d("c%p closed by client", eio);
 }

 static void shv_handle_cb(struct ev_loop *l, struct ev_io *eio, int revents)


Testing P + FF for shooter.

Testing P + FF for shooter.

--- src/shooter.c
+++ src/shooter.c
@@ -47,30 +47,40 @@
 }

 void runShooter() {
+//	if (shooterTargetSpeed != 0) {
+//		float error = shooterSpeed - shooterTargetSpeed;
+//		if (fabsf(error) < 100) {
+//			setShooterMotor(89);
+//			printf(".7 %f %d\n\r", shooterSpeed, shooterTargetSpeed);
+//		} else if (fabsf(error) < 200) {
+//			if (error < 0){
+//				setShooterMotor(114);
+//				printf(".9 %f %d\n\r", shooterSpeed, shooterTargetSpeed);
+//			}
+//			else {
+//				setShooterMotor(63);
+//				printf(".5 %f %d\n\r", shooterSpeed, shooterTargetSpeed);
+//			}
+//		} else {
+//			if (error < 0) {
+//				setShooterMotor(127);
+//				printf("1 %f %d\n\r", shooterSpeed, shooterTargetSpeed);
+//			}
+//			else {
+//				setShooterMotor(38);
+//				printf(".3 %f %d\n\r", shooterSpeed, shooterTargetSpeed);
+//			}
+//		}
+//	}
+//	else {
+//		setShooterMotor(0);
+//	}
 	if (shooterTargetSpeed != 0) {
-		float error = shooterSpeed - shooterTargetSpeed;
-		if (fabsf(error) < 100) {
-			setShooterMotor(100);
-			printf(".8 %f %d\n\r", shooterSpeed, shooterTargetSpeed);
-		} else if (fabsf(error) < 200) {
-			if (error < 0){
-				setShooterMotor(114);
-				printf(".9 %f %d\n\r", shooterSpeed, shooterTargetSpeed);
-			}
-			else {
-				setShooterMotor(63);
-				printf(".5 %f %d\n\r", shooterSpeed, shooterTargetSpeed);
-			}
-		} else {
-			if (error < 0) {
-				setShooterMotor(127);
-				printf("1 %f %d\n\r", shooterSpeed, shooterTargetSpeed);
-			}
-			else {
-				setShooterMotor(38);
-				printf(".3 %f %d\n\r", shooterSpeed, shooterTargetSpeed);
-			}
-		}
+		float error = (shooterSpeed - shooterTargetSpeed) * -1;
+		float Kp = 0.0;
+		float feedForward = .6;
+		float power = ((error * Kp) + feedForward) * 127;
+		setShooterMotor(power);
 	}
 	else {
 		setShooterMotor(0);


Fix the temperature for the Aeris Atmos AI 2.

The temperature sign bit is reversed for this model.

--- src/oceanic_atom2_parser.c
+++ src/oceanic_atom2_parser.c
@@ -45,6 +45,7 @@
 #define VEO20       0x4359
 #define VEO30       0x435A
 #define ZENAIR      0x4442
+#define ATMOSAI2    0x4443
 #define PROPLUS21   0x4444
 #define GEO20       0x4446
 #define VT4         0x4447
@@ -515,7 +516,8 @@
 					if (parser->model == DG03 || parser->model == PROPLUS3)
 						sign = (~data[offset + 5] & 0x04) >> 2;
 					else if (parser->model == ATOM2 || parser->model == PROPLUS21 ||
-						parser->model == EPICA || parser->model == EPICB)
+						parser->model == EPICA || parser->model == EPICB ||
+						parser->model == ATMOSAI2)
 						sign = (data[offset + 0] & 0x80) >> 7;
 					else
 						sign = (~data[offset + 0] & 0x80) >> 7;


Add comment about yaz_srw_decode hack

Add comment about yaz_srw_decode hack

--- src/srwutil.c
+++ src/srwutil.c
@@ -296,7 +296,9 @@
                 *srw_pdu = (Z_SRW_PDU*) (*soap_package)->u.generic->p;
                 yaz_srw_decodeauth(*srw_pdu, hreq, 0, 0, decode);

-                if ((*soap_package)->u.generic->no == 3) /* SRU 2 ! */
+                /* last entry in handlers - SRU 2.0 - is turned into
+                   offset 0.. due to other pieces relying on it */
+                if ((*soap_package)->u.generic->no == 3)
                     (*soap_package)->u.generic->no = 0;
                 if ((*srw_pdu)->which == Z_SRW_searchRetrieve_request &&
                     (*srw_pdu)->u.request->database == 0)


[ fix ] missing exit prototype, include stdlib.h

--- src/st-term.c
+++ src/st-term.c
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <stdlib.h>
 /* According to POSIX.1-2001 */
 #include <sys/select.h>
 #include <string.h>


minor sampler improvement

minor sampler improvement

--- src/sampler.h
+++ src/sampler.h
@@ -23,7 +23,9 @@
 enum GLBSamplerWrap
 {
     GLB_CLAMP_TO_EDGE   = GL_CLAMP_TO_EDGE,
+    GLB_CLAMP           = GL_CLAMP_TO_EDGE,
     GLB_MIRRORED_REPEAT = GL_MIRRORED_REPEAT,
+    GLB_MIRRORED        = GL_MIRRORED_REPEAT,
     GLB_REPEAT          = GL_REPEAT,
     GLB_CLAMP_TO_BORDER = GL_CLAMP_TO_BORDER
 };


primSTFix: replaced too clever (for me anyway :-) version with a simpler (and working) one.


cleaning up reset errors code

cleaning up reset errors code


Change enum declaration so it works better in Swift.

--- SSPullToRefresh/SSPullToRefreshView.h
+++ SSPullToRefresh/SSPullToRefreshView.h
@@ -30,7 +30,7 @@
 // }
 //

-typedef enum {
+typedef NS_ENUM(NSUInteger, SSPullToRefreshViewState) {
 	/// Most will say "Pull to refresh" in this state
 	SSPullToRefreshViewStateNormal,

@@ -42,7 +42,7 @@

 	/// The view has finished loading and is animating
 	SSPullToRefreshViewStateClosing
-} SSPullToRefreshViewState;
+};

 @protocol SSPullToRefreshViewDelegate;
 @protocol SSPullToRefreshContentView;


make tym.call() async

make tym.call() async

--- src/builtin.c
+++ src/builtin.c
@@ -365,11 +365,11 @@
 typedef struct {
   Context* context;
   int ref;
-} TimeoutNotation;
+} TimeoutCallbackNotation;

 static int timeout_callback(void* user_data)
 {
-  TimeoutNotation* notation = (TimeoutNotation*) user_data;
+  TimeoutCallbackNotation* notation = (TimeoutCallbackNotation*)user_data;

   lua_State* L = notation->context->lua;
   lua_rawgeti(L, LUA_REGISTRYINDEX, notation->ref);
@@ -398,7 +398,7 @@

   lua_pushvalue(L, 1);
   int ref = luaL_ref(L, LUA_REGISTRYINDEX);
-  TimeoutNotation* notation = g_malloc0(sizeof(TimeoutNotation));
+  TimeoutCallbackNotation* notation = g_malloc0(sizeof(TimeoutCallbackNotation));
   notation->context = context;
   notation->ref = ref;
   int tag = g_timeout_add_full(G_PRIORITY_DEFAULT, interval, (GSourceFunc)timeout_callback, notation, g_free);
@@ -573,23 +573,23 @@
 static GVariant* table_to_variant(lua_State* L, int table_index)
 {
   luaL_argcheck(L, lua_istable(L, table_index), table_index, "table expected");
-  size_t param_len = lua_rawlen(L, table_index);
-  GVariant** vv = g_malloc0_n(param_len, sizeof(char*));
+  size_t num_params = lua_rawlen(L, table_index);
+  GVariant** vv = g_malloc0_n(num_params, sizeof(char*));
   int i = 0;
-  while (i < param_len) {
+  while (i < num_params) {
     lua_rawgeti(L, table_index, i + 1); // args[table_index][i+1]
     vv[i] = g_variant_new_string(lua_tostring(L, -1));
     lua_pop(L, 1);
     i += 1;
   }
-  GVariant* p = g_variant_new_tuple(vv, param_len);
+  GVariant* p = g_variant_new_tuple(vv, num_params);
   g_free(vv);
   return p;
 }

+/* usage tym.signal(0, 'hook', {'param'}) */
 static int builtin_signal(lua_State* L)
 {
-  /* usage tym.signal(0, 'hook', {'param'}) */
   int target_id = luaL_checkinteger(L, 1);
   const char* signal_name = luaL_checkstring(L, 2);
   GVariant* params = lua_gettop(L) >= 3
@@ -610,20 +610,103 @@
   return 0;
 }

+typedef struct {
+  Context* context;
+  int ref;
+} CallCallbackNotation;
+
+void push_value_by_gvariant(lua_State* L, GVariant* v) {
+  if (g_variant_is_of_type(v, G_VARIANT_TYPE_INT32)) {
+    lua_pushinteger(L, g_variant_get_int32(v));
+  } else if (g_variant_is_of_type(v, G_VARIANT_TYPE_STRING)) {
+    char* s = NULL;
+    g_variant_get(v, "s", &s);
+    lua_pushstring(L, s);
+    g_free(s);
+  } else if (g_variant_is_of_type(v, G_VARIANT_TYPE_ARRAY) || g_variant_is_of_type(v, G_VARIANT_TYPE_TUPLE)) {
+    lua_newtable(L);
+    size_t num = g_variant_n_children(v);
+    int i = 0;
+    while (i < num) {
+      GVariant* e = g_variant_get_child_value(v, i);
+      push_value_by_gvariant(L, e);
+      lua_rawseti(L, -2, i + 1);
+      i += 1;
+    }
+  } else {
+    lua_pushstring(L, g_variant_print(v, false));
+  }
+}
+
+void call_callback(GObject* source_object, GAsyncResult* res, void* user_data)
+{
+  GError* error = NULL;
+  TimeoutCallbackNotation* notation = (TimeoutCallbackNotation*)user_data;
+  Context* context = notation->context;
+  lua_State* L = context->lua;
+
+  GDBusConnection* conn = g_application_get_dbus_connection(app->gapp);
+  GVariant* result = g_dbus_connection_call_finish(conn, res, &error);
+
+  lua_rawgeti(L, LUA_REGISTRYINDEX, notation->ref);
+  if (!lua_isfunction(L, -1)) {
+    lua_pop(L, 1); // pop none-function
+    context_log_warn(context, true, "tried to call non-function");
+    return;
+  }
+
+  int num_args = 0;
+  if (error) {
+    char* m = g_strdup_printf("DBus error: '%s'", error->message);
+    luaX_warn(L, "%s", m);
+    lua_pushstring(L, m);
+    g_error_free(error);
+    g_free(m);
+    num_args = 1;
+  } else {
+    dd("DBus method call result: `%s`", g_variant_print(result, true));
+    int num_result = g_variant_n_children(result);
+    int i = 0;
+    while (i < num_result) {
+      GVariant* e = g_variant_get_child_value(result, i);
+      push_value_by_gvariant(L, e);
+      i += 1;
+    }
+    num_args = num_result;
+  }
+
+  if (lua_pcall(L, num_args, 0, 0) != LUA_OK) {
+    luaX_warn(L, "Error in timeout function: '%s'", lua_tostring(L, -1));
+    lua_pop(L, 1); // error
+  }
+}
+
+/* usage: tym.call(0, 'eval', {'return 1+2'}, function(...) end) */
 static int builtin_call(lua_State* L)
 {
-  /* usage tym.call(0, 'exec', {'param'}) */
+  Context* context = (Context*)lua_touserdata(L, lua_upvalueindex(1));
   int target_id = luaL_checkinteger(L, 1);
   const char* method_name = luaL_checkstring(L, 2);
-  GVariant* params = lua_gettop(L) >= 3
-    ? table_to_variant(L, 3)
-    : g_variant_new("()");
+  GVariant* params = table_to_variant(L, 3);
+
+  bool has_cb = lua_gettop(L) >= 4;
+
+  CallCallbackNotation* notation = NULL;
+  GAsyncReadyCallback cb = NULL;
+  if (has_cb) {
+    luaL_argcheck(L, lua_isfunction(L, 4), 4, "function expected");
+    lua_pushvalue(L, 4);
+    int ref = luaL_ref(L, LUA_REGISTRYINDEX);
+    notation = (CallCallbackNotation*)g_malloc(sizeof(CallCallbackNotation*));
+    notation->context = context;
+    notation->ref = ref;
+    cb = (GAsyncReadyCallback)call_callback;
+  }

   GDBusConnection* conn = g_application_get_dbus_connection(app->gapp);
-  GError* error = NULL;
   char* object_path = g_strdup_printf(TYM_OBJECT_PATH_FMT_INT, target_id);
-  /* TODO: make this async */
-  GVariant* result = g_dbus_connection_call_sync(
+
+  g_dbus_connection_call(
       conn,        // conn
       TYM_APP_ID,  // bus_name
       object_path, // object_path
@@ -632,33 +715,13 @@
       params,      // parameters
       NULL,        // reply_type
       G_DBUS_CALL_FLAGS_NONE, // flags
-      10000,        // timeout
+      1000,        // timeout
       NULL,        // cancellable
-      &error
+      cb,          // callback
+      notation     // user_data
   );
   g_free(object_path);
-  if (error) {
-    luaX_warn(L, "DBus error: '%s'", error->message);
-    g_error_free(error);
-    return 0;
-  }
-
-  size_t result_len = g_variant_n_children(result);
-  int i = 0;
-  dd("result type %s", g_variant_get_type_string(result));
-  while (i < result_len) {
-    GVariant* v = g_variant_get_child_value(result, i);
-    if (g_variant_is_of_type(v, G_VARIANT_TYPE_INT32)) {
-      lua_pushinteger(L, g_variant_get_int32(v));
-    } else if (g_variant_is_of_type(v, G_VARIANT_TYPE_INT32)) {
-      lua_pushstring(L, g_variant_get_bytestring(v));
-    } else {
-      lua_pushstring(L, g_variant_print(v, true));
-    }
-    i += 1;
-  }
-
-  return result_len;
+  return 0;
 }

 static int builtin_check_mod_state(lua_State* L)


[#4127] Correctly set traffic class and so linger.

Motivation:

The method implementions for setSoLinger(...) and setTrafficClass(...) were swapped by mistake.

Modifications:

Use the correct implementation for setSoLinger(...) and setTrafficClass(...)

Result:

Correct behaviour when setSoLinger(...) and setTrafficClass(...) are used with the epoll transport.

--- transport-native-epoll/src/main/c/io_netty_channel_epoll_Native.c
+++ transport-native-epoll/src/main/c/io_netty_channel_epoll_Native.c
@@ -1217,10 +1217,6 @@
 }

 JNIEXPORT void JNICALL Java_io_netty_channel_epoll_Native_setSoLinger(JNIEnv* env, jclass clazz, jint fd, jint optval) {
-    setOption(env, fd, IPPROTO_IP, IP_TOS, &optval, sizeof(optval));
-}
-
-JNIEXPORT void JNICALL Java_io_netty_channel_epoll_Native_setTrafficClass(JNIEnv* env, jclass clazz, jint fd, jint optval) {
     struct linger solinger;
     if (optval < 0) {
         solinger.l_onoff = 0;
@@ -1230,6 +1226,10 @@
         solinger.l_linger = optval;
     }
     setOption(env, fd, SOL_SOCKET, SO_LINGER, &solinger, sizeof(solinger));
+}
+
+JNIEXPORT void JNICALL Java_io_netty_channel_epoll_Native_setTrafficClass(JNIEnv* env, jclass clazz, jint fd, jint optval) {
+    setOption(env, fd, IPPROTO_IP, IP_TOS, &optval, sizeof(optval));
 }

 JNIEXPORT void JNICALL Java_io_netty_channel_epoll_Native_setBroadcast(JNIEnv* env, jclass clazz, jint fd, jint optval) {


fix segv when clear map object in for-in loop

--- src/builtin.h
+++ src/builtin.h
@@ -1503,8 +1503,8 @@
 YDSH_METHOD map_clear(RuntimeContext &ctx) {
     SUPPRESS_WARNING(map_clear);
     Map_Object *obj = typeAs<Map_Object>(LOCAL(0));
+    obj->refValueMap().clear();
     obj->initIterator();
-    obj->refValueMap().clear();
     RET_VOID;
 }


More minor changes

More minor changes

--- src/c/clock.c
+++ src/c/clock.c
@@ -137,7 +137,7 @@
   show_time = true;
   accel_tap_service_unsubscribe();

-  start_animation( 0, 2000, false );
+  start_animation( 0, 1000, false );

   show_time_apptimer = app_timer_register( 10 * 1000, timer_timeout_proc, 0 );
 }


Extract osync_queue_stop_thread() from osync_queue_free()

git-svn-id: c84d288072f89a5d247ff1cec484dbd0eb473012@867 53f5c7ee-bee3-0310-bbc5-ea0e15fffd5e

--- opensync/opensync_queue.c
+++ opensync/opensync_queue.c
@@ -367,19 +367,27 @@
 	return NULL;
 }

+void osync_queue_stop_thread(OSyncQueue *queue)
+{
+	if (queue->thread) {
+		osync_thread_stop(queue->thread);
+		osync_thread_free(queue->thread);
+		queue->thread = NULL;
+	}
+}
+
 void osync_queue_free(OSyncQueue *queue)
 {
 	osync_trace(TRACE_ENTRY, "%s(%p)", __func__, queue);

+	osync_queue_stop_thread(queue);
+
 	if (queue->source)
 		g_source_destroy(queue->source);

 	if (queue->name)
 		g_free(queue->name);

-	osync_thread_stop(queue->thread);
-	osync_thread_free(queue->thread);
-
 	g_free(queue);

 	osync_trace(TRACE_EXIT, "%s", __func__);


android/client: Fix set_info command

android/client: Fix set_info command

Although this command is not implemented by BlueZ, make sure it is
callable from haltest so at least the IPC can be tested.

Also memset() the hid_info parameter to not pass uninitialized data
around.

--- android/client/if-hh.c
+++ android/client/if-hh.c
@@ -229,6 +229,9 @@

 /* set_info */

+/* Same completion as connect_c */
+#define set_info_c connect_c
+
 static void set_info_p(int argc, const char **argv)
 {
 	bt_bdaddr_t addr;
@@ -236,8 +239,11 @@

 	RETURN_IF_NULL(if_hh);
 	VERIFY_ADDR_ARG(2, &addr);
-	/* TODO: set_info does not seem to be called anywhere */
-
+
+	memset(&hid_info, 0, sizeof(hid_info));
+
+	/* This command is intentionally not supported. See comment from
+	 * bt_hid_info() in android/hidhost.c */
 	EXEC(if_hh->set_info, &addr, hid_info);
 }

@@ -416,7 +422,7 @@
 	STD_METHODCH(connect, "<addr>"),
 	STD_METHODCH(disconnect, "<addr>"),
 	STD_METHODCH(virtual_unplug, "<addr>"),
-	STD_METHOD(set_info),
+	STD_METHODCH(set_info, "<addr>"),
 	STD_METHODCH(get_protocol, "<addr> <mode>"),
 	STD_METHODCH(set_protocol, "<addr> <mode>"),
 	STD_METHODCH(get_report, "<addr> <type> <report_id> <size>"),


Fix some empty vector references

Fix some empty vector references

>>> backports bitcoin/bitcoin@f478d98fe49d3c0c0f2c79b3f8d9dbfc1aafd407

streams.h has some methods that can be tricked into dereferencing
null pointers or end() iterators. Fix this.

--- src/streams.h
+++ src/streams.h
@@ -130,7 +130,8 @@

     void insert(iterator it, std::vector<char>::const_iterator first, std::vector<char>::const_iterator last)
     {
-        assert(last - first >= 0);
+        if (last == first) return;
+        assert(last - first > 0);
         if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos) {
             // special case for inserting at the front when there's room
             nReadPos -= (last - first);
@@ -142,7 +143,8 @@
 #if !defined(_MSC_VER) || _MSC_VER >= 1300
     void insert(iterator it, const char* first, const char* last)
     {
-        assert(last - first >= 0);
+        if (last == first) return;
+        assert(last - first > 0);
         if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos) {
             // special case for inserting at the front when there's room
             nReadPos -= (last - first);
@@ -211,6 +213,8 @@

     void read(char* pch, size_t nSize)
     {
+        if (nSize == 0) return;
+
         // Read from the beginning of the buffer
         unsigned int nReadPosNext = nReadPos + nSize;
         if (nReadPosNext >= vch.size()) {


streams: Create VectorReader stream interface for vectors.

This is a read analogue for the existing CVectorWriter.

--- src/streams.h
+++ src/streams.h
@@ -137,6 +137,80 @@
     const int nVersion;
     std::vector<unsigned char>& vchData;
     size_t nPos;
+};
+
+/** Minimal stream for reading from an existing vector by reference
+ */
+class VectorReader
+{
+private:
+    const int m_type;
+    const int m_version;
+    const std::vector<unsigned char>& m_data;
+    size_t m_pos = 0;
+
+public:
+
+    /*
+     * @param[in]  type Serialization Type
+     * @param[in]  version Serialization Version (including any flags)
+     * @param[in]  data Referenced byte vector to overwrite/append
+     * @param[in]  pos Starting position. Vector index where reads should start.
+     */
+    VectorReader(int type, int version, const std::vector<unsigned char>& data, size_t pos)
+        : m_type(type), m_version(version), m_data(data)
+    {
+        seek(pos);
+    }
+
+    /*
+     * (other params same as above)
+     * @param[in]  args  A list of items to deserialize starting at pos.
+     */
+    template <typename... Args>
+    VectorReader(int type, int version, const std::vector<unsigned char>& data, size_t pos,
+                  Args&&... args)
+        : VectorReader(type, version, data, pos)
+    {
+        ::UnserializeMany(*this, std::forward<Args>(args)...);
+    }
+
+    template<typename T>
+    VectorReader& operator>>(T& obj)
+    {
+        // Unserialize from this stream
+        ::Unserialize(*this, obj);
+        return (*this);
+    }
+
+    int GetVersion() const { return m_version; }
+    int GetType() const { return m_type; }
+
+    size_t size() const { return m_data.size() - m_pos; }
+    bool empty() const { return m_data.size() == m_pos; }
+
+    void read(char* dst, size_t n)
+    {
+        if (n == 0) {
+            return;
+        }
+
+        // Read from the beginning of the buffer
+        size_t pos_next = m_pos + n;
+        if (pos_next > m_data.size()) {
+            throw std::ios_base::failure("VectorReader::read(): end of data");
+        }
+        memcpy(dst, m_data.data() + m_pos, n);
+        m_pos = pos_next;
+    }
+
+    void seek(size_t n)
+    {
+        m_pos += n;
+        if (m_pos > m_data.size()) {
+            throw std::ios_base::failure("VectorReader::seek(): end of data");
+        }
+    }
 };

 /** Double ended buffer combining vector and stream-like interfaces.


Import src/strlcpy.c from ccid 1.4.19.

Import src/strlcpy.c from ccid 1.4.19.

--- src/strlcpy.c
+++ src/strlcpy.c
@@ -17,7 +17,7 @@
  */

 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include <config.h>
 #endif

 #ifndef HAVE_STRLCPY


[HBOutputForShellCommand] mark the functions as nullable

--- HBOutputForShellCommand.h
+++ HBOutputForShellCommand.h
@@ -11,7 +11,7 @@
  * of the command.
  * @returns The output of the provided command.
  */
-NSString *HBOutputForShellCommandWithReturnCode(NSString *command, int *returnCode);
+NSString * _Nullable HBOutputForShellCommandWithReturnCode(NSString *command, int *returnCode);

 /**
  * Executes a shell command and returns its output.
@@ -20,7 +20,7 @@
  * @returns The output of the provided command, or nil if the command returned
  * with a code other than 0.
  */
-NSString *HBOutputForShellCommand(NSString *command);
+NSString * _Nullable HBOutputForShellCommand(NSString *command);

 __END_DECLS
 NS_ASSUME_NONNULL_END


Update sys_net.c

Update sys_net.c

Added missing overflow check

--- src/sys_net.c
+++ src/sys_net.c
@@ -4131,7 +4131,7 @@
 		}
 		pAdapterInfo = pAdapterInfo->Next;    // Progress through linked list
 	  }
-	  while(pAdapterInfo);                   // Terminate if last adapter
+	  while(pAdapterInfo && i < maxcount);                   // Terminate if last adapter
   }
   return i;
 }
@@ -4151,7 +4151,7 @@

 	} else {
 		/* Try to figure out what DNS server to use */
-		for (; fgets(line, sizeof(line), fp) != NULL; )
+		for (; fgets(line, sizeof(line), fp) != NULL && i < maxcount; )
 		{
 			linep = line;
 			//Remove whitespace