Remove unused gdbus APIs based on char string 06/254506/1
authorHyotaek Shim <hyotaek.shim@samsung.com>
Thu, 4 Mar 2021 02:17:58 +0000 (11:17 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Thu, 4 Mar 2021 02:17:58 +0000 (11:17 +0900)
Change-Id: I6ddb7dd5948c5268f7da0b3977d25059b7898110
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
src/libgdbus/dbus-system.c
src/libgdbus/dbus-system.h

index 5df1959..6ef7c6d 100644 (file)
@@ -115,7 +115,6 @@ dbus_handle_s * _dbus_handle_get_default_connection(void)
 dbus_object_handle_s * _dbus_handle_lookup_object(GList *list_obj, const char *obj_path);
 dbus_interface_s * _dbus_handle_lookup_interface(GList *list_iface, const char *iface_name);
 dbus_method_s * _dbus_handle_lookup_method(GList *list_methods, const char *method_name);
-static GVariant* _append_variant(const char *signature, const char *param[]);
 
 dbus_interface_s *_iface_u_to_s(const dbus_interface_u *iface_u)
 {
@@ -1670,83 +1669,6 @@ int _check_type_string_is_container(const char *signature)
        return TRUE;
 }
 
-/* todo: looks like garbage... */
-static GVariant* _append_variant(const char *signature, const char *param[])
-{
-       char *ch;
-       int i;
-       int pi;
-       int int_type;
-       gboolean bool_type;
-       unsigned long long int64_type;
-       GVariant *ret;
-       int len;
-       char container[255];// The maximum length of a signature is 255.
-       const char *sig = signature;
-       GVariantBuilder *builder = NULL;
-
-       if (!signature || !param)
-               return 0;
-
-       /* workaround for user fault "(i) != i" but we treat this as same signature */
-       /* G_VARIANT_TYPE("si") return NULL */
-       /* todo: actually user have to use correct signature */
-       if (!_check_type_string_is_container(signature)) {
-               snprintf(container, sizeof(container) - 1, "(%s)", signature);
-               sig = container;
-       }
-       if (!g_variant_type_is_container(G_VARIANT_TYPE(sig)))
-               _E("signature (%s) is not container type", signature);
-
-       builder = g_variant_builder_new(G_VARIANT_TYPE(sig));
-       len = strlen(sig);
-       pi = 0;
-       for (ch = (char *)sig, i = 0; i < len; ++i, ++ch) {
-               switch (*ch) {
-               case '(':
-               case ')':
-                       continue;
-               case 'b':
-                       bool_type = (atoi(param[pi++]) == 0 ? FALSE : TRUE);
-                       g_variant_builder_add(builder, "b", bool_type);
-                       break;
-               case 'i':
-                       int_type = atoi(param[pi++]);
-                       g_variant_builder_add(builder, "i", int_type);
-                       break;
-               case 'u':
-                       int_type = strtoul(param[pi++], NULL, 10);
-                       g_variant_builder_add(builder, "u", int_type);
-                       break;
-               case 't':
-                       int64_type = atoll(param[pi++]);
-                       g_variant_builder_add(builder, "t", int64_type);
-                       break;
-               case 's':
-                       g_variant_builder_add(builder, "s", param[pi++]);
-                       break;
-               case 'a':
-                       ++ch;
-                       switch (*ch) {
-                       case 'y':
-                               g_variant_builder_add(builder, "^ay", param[pi++]);
-                               ++i;
-                               break;
-                       default:
-                               break;
-                       }
-                       break;
-               default:
-                       break;
-               }
-       }
-       ret = g_variant_builder_end(builder);
-       g_variant_builder_clear(builder);
-       g_variant_builder_unref(builder);
-
-       return ret;
-}
-
 int dbus_handle_emit_dbus_signal(const char *dest,
                                        const char *path,
                                        const char *iface,
@@ -1941,91 +1863,6 @@ gint* dbus_handle_get_unix_fd_list(GDBusMethodInvocation *invocation, int *size)
        return g_unix_fd_list_steal_fds(fd_list, NULL);
 }
 
-GVariant *dbus_handle_method_with_unix_fd_list_sync_with_reply(const char *dest,
-                                                       const char *path,
-                                                       const char *iface,
-                                                       const char *method,
-                                                       const char *signature,
-                                                       const char *param[],
-                                                       int *in_fdlist,
-                                                       int in_size,
-                                                       int **out_fdlist,
-                                                       int *out_size)
-{
-       GError *err = NULL;
-       GVariant * var = NULL;
-       GVariant * ret = NULL;
-       dbus_handle_s *dh = NULL;
-       GUnixFDList *g_infdlist = NULL;
-       GUnixFDList *g_outfdlist = NULL;
-
-       if (!dest || !path || !iface || !method) {
-               _E("wrong parameters dest(%s) path(%s) iface(%s) method(%s)", dest, path, iface, method);
-               return NULL;
-       }
-       if (in_fdlist && in_size == 0) {
-               _E("wrong in_fdlist is not null but in_size is 0");
-               return NULL;
-       }
-
-       dh = _dbus_handle_get_default_connection();
-       if (!dh) {
-               _E("failed to get default connection, bustype:%d", (int)dbus_handle_get_default_bus_type());
-               return NULL;
-       }
-
-       if (signature && param)
-               var = _append_variant(signature, param);
-
-       /* append fd */
-       if (in_fdlist) {
-               g_infdlist = g_unix_fd_list_new_from_array(in_fdlist, in_size);
-               if (!g_infdlist) {
-                       _E("failed to g_unix_fd_list_new_from_array\n");
-                       goto out;
-               }
-               //g_infdlist = g_unix_fd_list_new();
-               //if (g_unix_fd_list_append(g_infdlist, in_fdlist[0], &err) < 0) {
-       }
-
-       ret = g_dbus_connection_call_with_unix_fd_list_sync(dh->conn,
-               dest, path, iface, method,
-               var, NULL,
-               G_DBUS_CALL_FLAGS_NONE,
-               -1,
-               g_infdlist, &g_outfdlist,
-               NULL,
-               &err);
-       if (!ret || err) {
-               if (err) {
-                       _E("failed to g_dbus_connection_call_with_unix_fd_list_sync:%s", err->message);
-                       g_error_free(err);
-               } else {
-                       _E("failed to g_dbus_connection_call_with_unix_fd_list_sync:");
-                       if (var)
-                               g_variant_unref(var);
-                       if (g_infdlist)
-                               g_object_unref(g_infdlist);
-               }
-               goto out;
-       }
-
-       /* fds to out array */
-       if (g_outfdlist) {
-               *out_size = g_unix_fd_list_get_length(g_outfdlist);
-               if (*out_size == 0)
-                       goto out;
-
-               *out_fdlist = g_unix_fd_list_steal_fds(g_outfdlist, NULL);
-       }
-
-out:
-       if (g_outfdlist)
-               g_object_unref(g_outfdlist);
-
-       return ret;
-}
-
 GVariant *dbus_handle_method_with_unix_fd_list_sync_with_reply_var(const char *dest,
                                                                const char *path,
                                                                const char *iface,
@@ -2103,62 +1940,6 @@ out:
        return ret;
 }
 
-int dbus_handle_method_sync(const char *dest,
-                       const char *path,
-                       const char *iface,
-                       const char *method,
-                       const char *signature,
-                       const char *param[])
-{
-       int result;
-       gboolean result_bool;
-       GVariant *reply = NULL;
-       GVariant * var = NULL;
-       GError *err = NULL;
-       dbus_handle_s *dh = NULL;
-
-       if (!dest || !path || !iface || !method) {
-               _E("wrong parameters dest(%s) path(%s) iface(%s) method(%s)", dest, path, iface, method);
-               return -1;
-       }
-
-       dh = _dbus_handle_get_default_connection();
-       if (!dh) {
-               _E("failed to get default connection, bustype:%d", (int)dbus_handle_get_default_bus_type());
-               return -ECOMM;
-       }
-
-       if (signature && param)
-               var = _append_variant(signature, param);
-
-       reply = g_dbus_connection_call_sync(dh->conn,
-                       dest, path, iface, method,
-                       var, NULL, G_DBUS_CALL_FLAGS_NONE, DBUS_REPLY_TIMEOUT, NULL, &err);
-       if (!reply || err) {
-               if (err) {
-                       _E("failed to g_dbus_connection_call_sync:%s", err->message);
-                       g_error_free(err);
-               } else {
-                       _E("failed to g_dbus_connection_call_sync");
-                       g_variant_unref(var);
-               }
-               return -ECOMM;
-       }
-
-       if (g_strcmp0("(i)", g_variant_get_type_string(reply)) == 0) {
-               g_variant_get(reply, "(i)", &result);
-       } else if (g_strcmp0("(b)", g_variant_get_type_string(reply)) == 0) {
-               g_variant_get(reply, "(b)", &result_bool);
-               result = (int)result_bool;
-       } else {
-               result = -ENOMSG;
-       }
-
-       g_variant_unref(reply);
-
-       return result;
-}
-
 int dbus_handle_method_sync_var(const char *dest,
                                const char *path,
                                const char *iface,
@@ -2192,93 +1973,6 @@ int dbus_handle_method_sync_var(const char *dest,
        return result;
 }
 
-int dbus_handle_method_sync_timeout(const char *dest,
-                                       const char *path,
-                                       const char *iface,
-                                       const char *method,
-                                       const char *signature,
-                                       const char *param[],
-                                       int timeout)
-{
-       dbus_handle_s *dh = NULL;
-       GError *err = NULL;
-       GVariant * var = NULL;
-       GVariant * reply = NULL;
-       int result = 0;
-
-       if (!dest || !path || !iface || !method) {
-               _E("wrong parameters dest(%s) path(%s) iface(%s) method(%s)", dest, path, iface, method);
-               return -1;
-       }
-
-       dh = _dbus_handle_get_default_connection();
-       if (!dh) {
-               _E("failed to get default connection, bustype:%d", (int)dbus_handle_get_default_bus_type());
-               return -EPERM;
-       }
-
-       if (signature && param)
-               var = _append_variant(signature, param);
-
-       reply = g_dbus_connection_call_sync(dh->conn,
-                       dest, path, iface, method,
-                       var, NULL,
-                       G_DBUS_CALL_FLAGS_NONE,
-                       timeout,
-                       NULL,
-                       &err);
-       if (!reply || err) {
-               _E("failed to g_dbus_connection_call_sync:%s", err->message);
-               g_error_free(err);
-               return -1;
-       }
-
-       if (g_strcmp0("(i)", g_variant_get_type_string(reply)) == 0)
-               g_variant_get(reply, "(i)", &result);
-       else
-               result = -ENOMSG;
-
-       g_variant_unref(reply);
-
-       return result;
-}
-
-int dbus_handle_method_async(const char *dest,
-                               const char *path,
-                               const char *iface,
-                               const char *method,
-                               const char *signature,
-                               const char *param[])
-{
-       GVariant * var = NULL;
-       dbus_handle_s *dh = NULL;
-
-       if (!dest || !path || !iface || !method) {
-               _E("wrong parameters dest(%s) path(%s) iface(%s) method(%s)", dest, path, iface, method);
-               return -1;
-       }
-
-       dh = _dbus_handle_get_default_connection();
-       if (!dh) {
-               _E("failed to get default connection, bustype:%d", (int)dbus_handle_get_default_bus_type());
-               return -1;
-       }
-
-       if (signature && param)
-               var = _append_variant(signature, param);
-
-       g_dbus_connection_call(dh->conn,
-                               dest, path, iface, method,
-                               var, NULL,
-                               G_DBUS_CALL_FLAGS_NONE,
-                               -1,
-                               NULL,
-                               NULL,
-                               NULL);
-
-       return 0;
-}
-
 int dbus_handle_method_async_var(const char *dest,
                                        const char *path,
                                        const char *iface,
@@ -2339,66 +2033,6 @@ out:
                free(data);
 }
 
-int dbus_handle_method_async_with_reply(const char *dest,
-                                       const char *path,
-                                       const char *iface,
-                                       const char *method,
-                                       const char *signature,
-                                       const char *param[],
-                                       dbus_pending_cb cb,
-                                       int timeout_msec,
-                                       void *data)
-{
-       dbus_handle_s *dh = NULL;
-       pending_call_data *pdata = NULL;
-       GVariant * var = NULL;
-       int ret = 0;
-
-       if (!dest || !path || !iface || !method) {
-               _E("wrong parameters dest(%s) path(%s) iface(%s) method(%s)", dest, path, iface, method);
-               return -1;
-       }
-
-       if (timeout_msec < -1) {
-               _E("wrong timeout %d", timeout_msec);
-               return -1;
-       }
-
-       dh = _dbus_handle_get_default_connection();
-       if (!dh) {
-               _E("failed to get default connection, bustype:%d", (int)dbus_handle_get_default_bus_type());
-               return -EPERM;
-       }
-
-       if (signature && param)
-               var = _append_variant(signature, param);
-
-       if (cb) {
-               pdata = (pending_call_data*)malloc(sizeof(pending_call_data));
-               if (!pdata) {
-                       ret = -ENOMEM;
-                       goto err;
-               }
-
-               pdata->func = cb;
-               pdata->data = data;
-       }
-       g_dbus_connection_call(dh->conn,
-                               dest, path, iface, method,
-                               var, NULL,
-                               G_DBUS_CALL_FLAGS_NONE,
-                               timeout_msec,
-                               NULL,
-                               (GAsyncReadyCallback)_cb_pending,
-                               pdata);
-
-       return ret;
-err:
-       if (var)
-               g_variant_unref(var);
-       return ret;
-}
-
 int dbus_handle_method_async_with_reply_var(const char *dest,
                                        const char *path,
                                        const char *iface,
index 29fa58f..df591b2 100644 (file)
@@ -100,51 +100,18 @@ int dbus_handle_add_dbus_object                   (dbus_handle_h handle,
 
 int dbus_handle_register_dbus_object_all       (dbus_handle_h handle);
 
-
-int dbus_handle_method_sync                    (const char *dest,
-                                               const char *path,
-                                               const char *interface,
-                                               const char *method,
-                                               const char *sig,
-                                               const char *param[]);
-
 int dbus_handle_method_sync_var                        (const char *dest,
                                                const char *path,
                                                const char *iface,
                                                const char *method,
                                                GVariant *param);
 
-int dbus_handle_method_sync_timeout            (const char *dest,
-                                               const char *path,
-                                               const char *interface,
-                                               const char *method,
-                                               const char *sig,
-                                               const char *param[],
-                                               int timeout);
-
-int dbus_handle_method_async                   (const char *dest,
-                                               const char *path,
-                                               const char *interface,
-                                               const char *method,
-                                               const char *sig,
-                                               const char *param[]);
-
 int dbus_handle_method_async_var               (const char *dest,
                                                const char *path,
                                                const char *iface,
                                                const char *method,
                                                GVariant *param);
 
-int dbus_handle_method_async_with_reply                (const char *dest,
-                                               const char *path,
-                                               const char *iface,
-                                               const char *method,
-                                               const char *signature,
-                                               const char *param[],
-                                               dbus_pending_cb cb,
-                                               int timeout_msec,
-                                               void *data);
-
 int dbus_handle_method_async_with_reply_var    (const char *dest,
                                                const char *path,
                                                const char *iface,
@@ -170,17 +137,6 @@ GVariant *dbus_handle_method_sync_with_reply_var_timeout   (const char *dest,
 gint* dbus_handle_get_unix_fd_list                             (GDBusMethodInvocation *invocation,
                                                                int *size);
 
-GVariant *dbus_handle_method_with_unix_fd_list_sync_with_reply (const char *dest,
-                                                               const char *path,
-                                                               const char *iface,
-                                                               const char *method,
-                                                               const char *signature,
-                                                               const char *param[],
-                                                               int *in_fdlist,
-                                                               int in_size,
-                                                               int **out_fdlist,
-                                                               int *out_size);
-
 GVariant *dbus_handle_method_with_unix_fd_list_sync_with_reply_var(const char *dest,
                                                                const char *path,
                                                                const char *iface,