Add an API to access vconf via DBus 44/266444/1 accepted/tizen_6.5_unified tizen_6.5 accepted/tizen/6.5/unified/20211124.060346 submit/tizen_6.5/20211112.095149 submit/tizen_6.5/20211117.045617 submit/tizen_6.5/20211119.073159 submit/tizen_6.5/20211123.064148 submit/tizen_6.5/20211123.090823
authorJaehyun Kim <jeik01.kim@samsung.com>
Wed, 10 Nov 2021 07:50:09 +0000 (16:50 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Fri, 12 Nov 2021 08:43:23 +0000 (17:43 +0900)
Change-Id: I60683458cb7514d76b79d949be22d171409bf51e
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
include/common/network-cm-intf.h
include/internal/network-dbus-request.h
src/network-cm-intf.c
src/network-dbus-request.c

index 40a9a75..679bac8 100755 (executable)
@@ -910,6 +910,20 @@ int net_stop_tcpdump(void *handle);
 gboolean net_get_tcpdump_state(void *handle, gboolean *is_tcpdump_running);
 
 /**
+ * \brief Get vconf value via dbus.
+ *
+ * \param[in]  handle     libnet-client handle.
+ * \param[in]  key        Vconf key.
+ * \param[in]  type       Vconf data type(string, int, bool).
+ * \param[out] ret        Return value.
+ * \param[out] int_value  Vconf value for int or bool type.
+ * \param[out] str_value  Vconf value for string type.
+ *
+ ******************************************************************************************/
+int net_get_vconf_value(void *handle, const char *key, const char *type,
+               int *ret, int *int_value, char **str_value);
+
+/**
  * \}
  */
 
index af38bc4..dac69ad 100755 (executable)
@@ -153,6 +153,8 @@ int _net_dbus_ethernet_eap_enable(gboolean enable, const char *profilename);
 int _net_dbus_ethernet_eap_enabled(const char *profilename, gboolean *enabled);
 int _net_dbus_save_ethernet_eap_connection(network_info_t *network_info,
                net_dev_info_t *net_info);
+int _net_dbus_get_vconf_value(network_info_t *network_info,
+               const char *key, const char *type, int *ret, int *int_value, char **str_value);
 #ifdef __cplusplus
 }
 #endif
index a0dbc66..e10321e 100755 (executable)
@@ -1141,6 +1141,22 @@ EXPORT_API gboolean net_get_tcpdump_state(void *handle, gboolean *is_tcpdump_run
        return Error;
 }
 
+EXPORT_API int net_get_vconf_value(void *handle, const char *key, const char *type,
+               int *ret, int *int_value, char **str_value)
+{
+       __NETWORK_FUNC_ENTER__;
+       net_err_t ret_error = NET_ERR_NONE;
+       network_info_t *network_info = (network_info_t *)handle;
+
+       ret_error = _net_dbus_get_vconf_value(network_info, key, type, ret, int_value, str_value);
+
+       if (ret_error != NET_ERR_NONE)
+               NETWORK_LOG(NETWORK_ERROR, "net_get_vconf_value failed");
+
+       __NETWORK_FUNC_EXIT__;
+       return ret_error;
+}
+
 /**
  * @fn   EXPORT_API int net_close_mesh_connection(const char *profile_name)
  *
index 8e1f4bf..71367fb 100755 (executable)
@@ -499,24 +499,33 @@ GVariant *_net_invoke_dbus_method(network_info_t *network_info,
        GDBusConnection *connection = NULL;
        gboolean created = FALSE;
 
-       if (network_info == NULL || network_info->connection == NULL) {
+       if ((network_info == NULL || network_info->connection == NULL) &&
+                       access(CONTAINER_FILE, F_OK) == 0) {
+
+               connection = g_dbus_connection_new_for_address_sync(
+                               DBUS_HOST_SYSTEM_BUS_ADDRESS,
+                               G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
+                               NULL, NULL, &error);
+               created = TRUE;
+       } else if (network_info == NULL || network_info->connection == NULL) {
                connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
-               if (connection == NULL) {
-                       /* LCOV_EXCL_START */
-                       if (error != NULL) {
-                               NETWORK_LOG(NETWORK_ERROR,
-                                               "Failed to connect to the D-BUS daemon [%s]", error->message);
-                               g_error_free(error);
-                       }
-                       /* LCOV_EXCL_STOP */
-                       return NULL;
-               }
                created = TRUE;
        } else {
                connection = network_info->connection;
                created = FALSE;
        }
 
+       if (connection == NULL) {
+               /* LCOV_EXCL_START */
+               if (error != NULL) {
+                       NETWORK_LOG(NETWORK_ERROR,
+                                       "Failed to connect to the D-BUS daemon [%s]", error->message);
+                       g_error_free(error);
+               }
+               /* LCOV_EXCL_STOP */
+               return NULL;
+       }
+
        reply = g_dbus_connection_call_sync(connection,
                        dest,
                        path,
@@ -2309,3 +2318,34 @@ int _net_dbus_ethernet_eap_enabled(const char* profilename, gboolean *enabled)
        __NETWORK_FUNC_EXIT__;
        return Error;
 }
+
+int _net_dbus_get_vconf_value(network_info_t *network_info,
+               const char *key, const char *type, int *ret, int *int_value, char **str_value)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t ret_error = NET_ERR_NONE;
+       GVariant *message = NULL;
+       GVariant *params = NULL;
+
+       params = g_variant_new("(ss)", key, type);
+       message = _net_invoke_dbus_method(network_info,
+                       NETCONFIG_SERVICE, NETCONFIG_NETWORK_PATH,
+                       NETCONFIG_NETWORK_INTERFACE, "RequestVconfValue", params, &ret_error);
+
+       if (message == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Failed to get vconf value, key: %s", key);
+               __NETWORK_FUNC_EXIT__;
+               return ret_error;
+       }
+
+       g_variant_get(message, "(iis)", ret, int_value, str_value);
+
+       NETWORK_LOG(NETWORK_HIGH, "Vconf key: %s, type: %s, ret: %d, int_value: %d, str_value: %s",
+                       key, type, *ret, *int_value, *str_value);
+
+       g_variant_unref(message);
+
+       __NETWORK_FUNC_EXIT__;
+       return ret_error;
+}