This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch modules/convertible
in repository enlightenment.

View the commit online.

commit a6c5eb3160200582daa9edcb7760f6c06eac4e4a
Author: rafspiny <rafsp...@gmail.com>
AuthorDate: Tue Nov 14 19:12:50 2023 +0100

    WIP
    
    Align header
    
    WIP
    
    Skip rotation on undefined orientation.
    
    Empty
    
    More logs
    
    Remove logs and improve error handling.
    Remove **
---
 src/modules/convertible/dbus_acceleration.c    | 91 ++++++++++++++++----------
 src/modules/convertible/dbus_acceleration.h    |  5 +-
 src/modules/convertible/e-gadget-convertible.c | 15 +----
 src/modules/convertible/e_mod_main.c           | 31 +++++----
 4 files changed, 76 insertions(+), 66 deletions(-)

diff --git a/src/modules/convertible/dbus_acceleration.c b/src/modules/convertible/dbus_acceleration.c
index 6111c69ed..b0aade120 100644
--- a/src/modules/convertible/dbus_acceleration.c
+++ b/src/modules/convertible/dbus_acceleration.c
@@ -110,87 +110,96 @@ Eldbus_Proxy *get_dbus_interface(const char *IFACE)
    return sensor_proxy;
 }
 
-enum screen_rotation access_string_property(const Eldbus_Message *msg, Eldbus_Message_Iter **variant, Eina_Bool* result)
+enum screen_rotation access_string_property(const Eldbus_Message *msg, Eina_Bool* result)
 {
-   const char *type = NULL;
+   char *type = NULL;
    *result = EINA_TRUE;
+   Eldbus_Message_Iter *variant = NULL;
 
-   if (!eldbus_message_arguments_get(msg, "v", variant))
+   if (!eldbus_message_arguments_get(msg, "v", &variant))
    {
       WARN("Error getting arguments.");
       *result = EINA_FALSE;
    }
-   type = eldbus_message_iter_signature_get((*variant));
+   type = eldbus_message_iter_signature_get(variant);
    if (type == NULL)
    {
       WARN("Unable to get the type.");
       *result = EINA_FALSE;
+      free(type);
       return undefined;
    }
 
-   type = eldbus_message_iter_signature_get((*variant));
-   if (type[1])
+   if (type[0] != 's')
    {
-      WARN("It is a complex type, not handle yet.");
+      WARN("Expected type is string(s).");
       *result = EINA_FALSE;
+      free(type);
+      return undefined;
    }
-   if (type[0] != 's')
+   if (type[1])
    {
-      WARN("Expected type is string(s).");
+      WARN("It is a complex type, not handle yet.");
       *result = EINA_FALSE;
    }
-   const char **string_property_value = calloc(PATH_MAX, sizeof(char));
-   if (!eldbus_message_iter_arguments_get((*variant), "s", string_property_value))
+
+   const char *string_property_value;
+   if (!eldbus_message_iter_arguments_get(variant, "s", &string_property_value))
    {
       WARN("error in eldbus_message_iter_arguments_get()");
       *result = EINA_FALSE;
    }
 
    enum screen_rotation rotation = undefined;
-   if (strcmp(ACCELEROMETER_ORIENTATION_RIGHT, *string_property_value) == 0)
+   if (strcmp(ACCELEROMETER_ORIENTATION_RIGHT, string_property_value) == 0)
       rotation = right_up;
-   if (strcmp(ACCELEROMETER_ORIENTATION_LEFT, *string_property_value) == 0)
+   if (strcmp(ACCELEROMETER_ORIENTATION_LEFT, string_property_value) == 0)
       rotation = left_up;
-   if (strcmp(ACCELEROMETER_ORIENTATION_BOTTOM, *string_property_value) == 0)
+   if (strcmp(ACCELEROMETER_ORIENTATION_BOTTOM, string_property_value) == 0)
       rotation = flipped;
-   if (strcmp(ACCELEROMETER_ORIENTATION_NORMAL, *string_property_value) == 0)
+   if (strcmp(ACCELEROMETER_ORIENTATION_NORMAL, string_property_value) == 0)
       rotation = normal;
 
+   if (strcmp(ACCELEROMETER_ORIENTATION_UNDEFINED, string_property_value) == 0)
+       *result = EINA_FALSE;
+
    free((void *) type);
-   free(string_property_value);
    return rotation;
 }
 
 Eina_Bool
-access_bool_property(const Eldbus_Message *msg, Eldbus_Message_Iter **variant, Eina_Bool *boolean_property_value)
+access_bool_property(const Eldbus_Message *msg, Eina_Bool *boolean_property_value)
 {
-   const char *type;
+   char *type;
    Eina_Bool res = EINA_TRUE;
+   Eldbus_Message_Iter *variant = NULL;
 
-   if (!eldbus_message_arguments_get(msg, "v", variant))
+   if (!eldbus_message_arguments_get(msg, "v", &variant))
    {
       WARN("Error getting arguments.");
       res = EINA_FALSE;
    }
-   type = eldbus_message_iter_signature_get((*variant));
+   type = eldbus_message_iter_signature_get(variant);
    if (type == NULL)
    {
       WARN("Unable to get the type.");
       res = EINA_FALSE;
+      free(type);
       return res;
    }
-
-   if (type[1])
+   if (type[0] != 'b')
    {
-      WARN("It is a complex type, not handle yet.");
+      WARN("Expected type is int.");
       res = EINA_FALSE;
+      free(type);
+      return res;
    }
-   if (type[0] != 'b')
+   if (type[1])
    {
-      WARN("Expected type is int.");
+      WARN("It is a complex type, not handle yet.");
       res = EINA_FALSE;
    }
-   if (!eldbus_message_iter_arguments_get((*variant), "b", boolean_property_value))
+   if (!eldbus_message_iter_arguments_get(variant, "b", boolean_property_value))
    {
       WARN("error in eldbus_message_iter_arguments_get()");
       res = EINA_FALSE;
@@ -204,14 +213,13 @@ on_has_accelerometer(void *data, const Eldbus_Message *msg, Eldbus_Pending *pend
 {
    const char *errname, *errmsg;
    Eina_Bool has_accelerometer = EINA_FALSE;
-   Eldbus_Message_Iter *variant = NULL;
 
    if (eldbus_message_error_get(msg, &errname, &errmsg))
    {
       ERR("Error: %s %s", errname, errmsg);
    }
 
-   access_bool_property(msg, &variant, &has_accelerometer);
+   access_bool_property(msg, &has_accelerometer);
    DbusAccelerometer *accelerometer = (DbusAccelerometer *) data;
    accelerometer->has_accelerometer = has_accelerometer;
    DBG("Has Accelerometer: %d", accelerometer->has_accelerometer);
@@ -221,7 +229,7 @@ void
 on_accelerometer_orientation(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
 {
    INF("New orientation received");
-   Instance *inst = (Instance *) data;
+   Instance *inst = data;
 
    if (inst->locked_position == EINA_TRUE)
    {
@@ -232,7 +240,6 @@ on_accelerometer_orientation(void *data, const Eldbus_Message *msg, Eldbus_Pendi
 
    const char *errname, *errmsg;
    enum screen_rotation orientation;
-   Eldbus_Message_Iter *variant = NULL;
    Eina_Bool* result = calloc(1, sizeof(Eina_Bool));
 
    if (eldbus_message_error_get(msg, &errname, &errmsg))
@@ -241,7 +248,7 @@ on_accelerometer_orientation(void *data, const Eldbus_Message *msg, Eldbus_Pendi
       return;
    }
 
-   orientation = access_string_property(msg, &variant, result);
+   orientation = access_string_property(msg, result);
    if (*result == EINA_FALSE)
    {
       INF("Failed to retrieve the orientation from dbus message");
@@ -327,6 +334,7 @@ int _fetch_X_device_input_number()
           {
 	     dev_number = dev_counter;
              DBG("Setting device: %d", dev_number);
+	     break;
           }
           iterator++;
        }
@@ -354,6 +362,7 @@ int _is_device_a_touch_pointer(int dev_counter, int num_properties, char **itera
          }
          DBG("Looks like I found a device with calibration capabilities");
          is_correct_device = EINA_TRUE;
+	     free(result);
       }
       iterator++;
    }
@@ -363,15 +372,26 @@ int _is_device_a_touch_pointer(int dev_counter, int num_properties, char **itera
 void _fetch_and_rotate_screen(const char* randr_id, enum screen_rotation orientation) {
    DBG("Working on screen %s", randr_id);
    E_Randr2_Screen *rotatable_screen = e_randr2_screen_id_find(randr_id);
-   E_Config_Randr2_Screen *screen_randr_cfg = e_randr2_config_screen_find(rotatable_screen, e_randr2_cfg);
+   if (rotatable_screen == NULL)
+   {
+       DBG("Failed to load screen for id %s", randr_id);
+       return;
+   }
+
+    E_Config_Randr2_Screen *screen_randr_cfg = e_randr2_config_screen_find(rotatable_screen, e_randr2_cfg);
+    if (screen_randr_cfg == NULL)
+    {
+        DBG("Failed to load screen configuration for id %s", randr_id);
+        return;
+   }
    int rotation = _convertible_rotation_get(orientation);
    DBG("Screen %s is going to be rotated to %d", randr_id, rotation);
 
-   if (rotation == screen_randr_cfg->rotation)
+   /*if (rotation == screen_randr_cfg->rotation)
    {
       WARN("Screen %s is already rotated to %d degrees", randr_id, rotation);
    } else
-   {
+   {*/
       screen_randr_cfg->rotation = rotation;
       e_randr2_config_apply();
       DBG("Screen %s rotated to %d", randr_id, rotation);
@@ -405,8 +425,9 @@ void _fetch_and_rotate_screen(const char* randr_id, enum screen_rotation orienta
       } else {
          ERR("Unable to fetch coordinates transformation matrix for device %d", x_dev_num);
       }
+      free(result);
       free(matrix);
-   }
+   //}
 }
 
 void
diff --git a/src/modules/convertible/dbus_acceleration.h b/src/modules/convertible/dbus_acceleration.h
index b194ff08d..aa4740241 100644
--- a/src/modules/convertible/dbus_acceleration.h
+++ b/src/modules/convertible/dbus_acceleration.h
@@ -39,12 +39,11 @@ Eldbus_Proxy *get_dbus_interface(const char *IFACE);
 /**
  * Helper function to extract ta string property from the message
  * @param msg The message coming from the get property invocation
- * @param variant
  * @param result 1 if result is ok, 0 if it failed
  * @return Enum specifying the orientation
  */
 enum screen_rotation
-access_string_property(const Eldbus_Message *msg, Eldbus_Message_Iter **variant, Eina_Bool* result);
+access_string_property(const Eldbus_Message *msg, Eina_Bool* result);
 
 /**
  * Helper function to extract ta boolean property from the message
@@ -54,7 +53,7 @@ access_string_property(const Eldbus_Message *msg, Eldbus_Message_Iter **variant,
  * @return
  */
 Eina_Bool
-access_bool_property(const Eldbus_Message *msg, Eldbus_Message_Iter **variant, Eina_Bool *boolean_property_value);
+access_bool_property(const Eldbus_Message *msg, Eina_Bool *boolean_property_value);
 
 /**
  * Callback definition to handle the request of the hasAccelerometer property of DBUS interface net.hadess.SensorProxy
diff --git a/src/modules/convertible/e-gadget-convertible.c b/src/modules/convertible/e-gadget-convertible.c
index 8030bc4ca..ad67bb932 100644
--- a/src/modules/convertible/e-gadget-convertible.c
+++ b/src/modules/convertible/e-gadget-convertible.c
@@ -11,7 +11,7 @@ static Eina_List *instances = NULL;
 void _update_instances(const Instance *current_instance)
 {
     Eina_List *l;
-    Instance *instance = NULL;
+    Instance *instance;
     EINA_LIST_FOREACH(instances, l, instance)
     {
         if (current_instance != instance)
@@ -43,19 +43,6 @@ void _keyboard_signal_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, c
    DBG("Keyboard: Signal %s received from %s", sig, src);
 }
 
-
-/**
- * Callback for gadget creation
- * */
-static void
-_gadget_created(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
-{
-   DBG("Inside gadget created");
-   //    do_orient(inst, e_gadget_site_orient_get(obj), e_gadget_site_anchor_get(obj));
-   evas_object_smart_callback_del_full(obj, "gadget_created", _gadget_created, NULL);
-}
-
-
 void update_instances(Eina_List *new_instances) {
    instances = new_instances;
 }
diff --git a/src/modules/convertible/e_mod_main.c b/src/modules/convertible/e_mod_main.c
index 1d080e8d0..adf54f689 100644
--- a/src/modules/convertible/e_mod_main.c
+++ b/src/modules/convertible/e_mod_main.c
@@ -119,12 +119,12 @@ _gc_shutdown(E_Gadcon_Client *gcc)
 static void
 _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
 {
-   Instance *inst;
+   Instance *current_instance;
    Evas_Coord mw, mh;
-   char buf[4096];
+   char buf[PATH_MAX];
    const char *s = "float";
 
-   inst = gcc->data;
+   current_instance = gcc->data;
    switch (orient)
    {
       case E_GADCON_ORIENT_FLOAT:
@@ -191,13 +191,13 @@ _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
          break;
    }
    snprintf(buf, sizeof(buf), "e,state,orientation,%s", s);
-   edje_object_signal_emit(inst->o_button, buf, "e");
-   edje_object_message_signal_process(inst->o_button);
+   edje_object_signal_emit(current_instance->o_button, buf, "e");
+   edje_object_message_signal_process(current_instance->o_button);
 
    mw = 0, mh = 0;
-   edje_object_size_min_get(inst->o_button, &mw, &mh);
+   edje_object_size_min_get(current_instance->o_button, &mw, &mh);
    if ((mw < 1) || (mh < 1))
-      edje_object_size_min_calc(inst->o_button, &mw, &mh);
+      edje_object_size_min_calc(current_instance->o_button, &mw, &mh);
    if (mw < 4) mw = 4;
    if (mh < 4) mh = 4;
    e_gadcon_client_aspect_set(gcc, mw, mh);
@@ -225,7 +225,7 @@ _gc_icon(const E_Gadcon_Client_Class *client_class EINA_UNUSED, Evas *evas)
 static const char *
 _gc_id_new(const E_Gadcon_Client_Class *client_class EINA_UNUSED)
 {
-   static char buf[4096];
+   static char buf[PATH_MAX];
 
    snprintf(buf, sizeof(buf), "%s.%d", client_class->name,
              eina_list_count(instances) + 1);
@@ -239,16 +239,16 @@ _gc_id_new(const E_Gadcon_Client_Class *client_class EINA_UNUSED)
 static void
 _cb_properties_changed(void *data, const Eldbus_Message *msg)
 {
-   Instance *inst = (Instance *) data;
+   Instance *current_instance = (Instance *) data;
    Eldbus_Message_Iter *array, *invalidate;
    char *iface;
 
    if (!eldbus_message_arguments_get(msg, "sa{sv}as", &iface, &array, &invalidate))
       ERR("Error getting data from properties changed signal.");
    // Given that the property changed, let's get the new value
-   Eldbus_Pending *pending_operation = eldbus_proxy_property_get(inst->accelerometer->sensor_proxy,
+   Eldbus_Pending *pending_operation = eldbus_proxy_property_get(current_instance->accelerometer->sensor_proxy,
                                                                  "AccelerometerOrientation",
-                                                                 on_accelerometer_orientation, inst);
+                                                                 on_accelerometer_orientation, current_instance);
    if (!pending_operation)
       ERR("Error: could not get property AccelerometerOrientation");
 }
@@ -302,18 +302,21 @@ e_modapi_init(E_Module *m)
       E_Randr2_Screen *screen = e_randr2_screen_id_find(zone->randr2_id);
       DBG("name randr2 id %s", zone->randr2_id);
       DBG("rot_90 %i", screen->info.can_rot_90);
+
       // Arbitrarily chosen a condition to check that rotation is enabled
       if (screen->info.can_rot_90 == EINA_TRUE)
          {
-         int max_screen_length = 300;
+         int max_screen_length = 700;
          char *randr2_id =  malloc(sizeof(char) * max_screen_length);
          int copied_chars = eina_strlcpy(randr2_id, zone->randr2_id, max_screen_length);
+
          if (copied_chars > max_screen_length)
             ERR("Screen name %s has been truncated. Cannot handle screens.", randr2_id);
-         if (copied_chars < 0)
+         else if (copied_chars < 0)
             ERR("Can't copy the screen name");
+         else
+            inst->randr2_ids = eina_list_append(inst->randr2_ids, randr2_id);
 
-         inst->randr2_ids = eina_list_append(inst->randr2_ids, randr2_id);
          if (eina_error_get())
             ERR("Memory is low. List allocation failed.");
          }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to