MESSAGE(" - Start building src directories")
ADD_SUBDIRECTORY(src/d2d-manager)
ADD_SUBDIRECTORY(src/d2d-subowner)
-ADD_SUBDIRECTORY(src/fn-manager)
+ADD_SUBDIRECTORY(src/companion-manager)
ADD_SUBDIRECTORY(test)
ADD_SUBDIRECTORY(capi)
-SET(CAPI_FN "capi-network-familynet")
+SET(CAPI_FN "capi-network-companion")
FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
" \\
- --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/src/familynet_gdbus \\
- --interface-prefix org.tizen.familynet. \\
- ${CMAKE_CURRENT_SOURCE_DIR}/src/familynet_gdbus.xml \\
+ --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/src/companion_gdbus \\
+ --interface-prefix org.tizen.companion. \\
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/companion_gdbus.xml \\
")
SET(INC_DIR include)
INCLUDE_DIRECTORIES(${INC_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
-SET(SOURCES src/familynet.c
- src/familynet_gdbus.c)
+SET(SOURCES src/companion.c
+ src/companion_gdbus.c)
ADD_LIBRARY(${CAPI_FN} SHARED ${SOURCES})
--- /dev/null
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=@libdir@
+includedir=/usr/include/
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
+
+++ /dev/null
-
-# Package Information for pkg-config
-
-prefix=@PREFIX@
-exec_prefix=/usr
-libdir=@libdir@
-includedir=/usr/include/
-
-Name: @PC_NAME@
-Description: @PACKAGE_DESCRIPTION@
-Version: @VERSION@
-Requires: @PC_REQUIRED@
-Libs: -L${libdir} @PC_LDFLAGS@
-Cflags: -I${includedir}
-
ADD_EXECUTABLE(${COMP_DEMO} ${COMP_DEMO_SOURCES})
TARGET_LINK_LIBRARIES(${COMP_DEMO}
- ${daemon_pkgs_LIBRARIES} capi-network-familynet)
+ ${daemon_pkgs_LIBRARIES} capi-network-companion)
INSTALL(TARGETS ${COMP_DEMO} DESTINATION bin/)
#include <glib.h>
#include <sys/time.h>
-#include <familynet.h>
+#include <companion.h>
#define BUFFER_LEN 100
#define TEST_CASE_MAX 5
return true;
}
-int familynet_initialize_test(void)
+int companion_initialize_test(void)
{
int ret = 0;
BEGIN();
- ret = familynet_initialize();
+ ret = companion_initialize();
if (ret == 0)
TC_PRT("Initialize successful");
return ret;
}
-int familynet_group_create_test(void)
+int companion_group_create_test(void)
{
int ret = 0;
char input_str[50] = {0, };
return -1;
}
- ret = familynet_group_create(input_str);
+ ret = companion_group_create(input_str);
if (ret == 0)
TC_PRT("Group create successful");
return ret;
}
-bool _group_found_cb(familynet_group_type_e type, familynet_group_h group, void *user_data)
+bool _group_found_cb(companion_group_type_e type, companion_group_h group, void *user_data)
{
char *uri_path;
- familynet_group_information_get_uri_path(group, &uri_path);
+ companion_group_information_get_uri_path(group, &uri_path);
TC_PRT("found group type : %d, uri : %s", type, uri_path);
}
}
-int familynet_group_find_test(void)
+int companion_group_find_test(void)
{
int ret = 0;
int input_int = 0;
TC_PRT("default timeout value [%d]", input_int);
}
- familynet_group_find(input_int, _group_found_cb, _group_finish_cb, NULL);
+ companion_group_find(input_int, _group_found_cb, _group_finish_cb, NULL);
if (ret == 0)
TC_PRT("group find successful");
return ret;
}
-int familynet_group_get_found_groups_test(void)
+int companion_group_get_found_groups_test(void)
{
int ret = 0;
int input_int = 0;
int count;
- familynet_group_h *groups;
+ companion_group_h *groups;
BEGIN();
- ret = familynet_group_get_found_groups(&groups ,&count);
+ ret = companion_group_get_found_groups(&groups ,&count);
if (ret == 0)
TC_PRT("group find successful");
TC_PRT("Found groups device count : ", count);
for (int i = 0; i < count; i++) {
- familynet_group_type_e type;
+ companion_group_type_e type;
char *uri_path;
- familynet_group_information_get_type(groups[i], &type);
- familynet_group_information_get_uri_path(groups[i], &uri_path);
+ companion_group_information_get_type(groups[i], &type);
+ companion_group_information_get_uri_path(groups[i], &uri_path);
TC_PRT("%d. type : %d, uri path : %s", i+1, type, uri_path);
}
return ret;
}
-int familynet_deinitialize_test(void)
+int companion_deinitialize_test(void)
{
int ret = 0;
BEGIN();
- ret = familynet_deinitialize();
+ ret = companion_deinitialize();
if (ret == 0)
TC_PRT("Initialize successful");
tc_table_t tc_table[] = {
/* manager api */
- {"familynet_initialize_test", 1, familynet_initialize_test},
- {"familynet_group_create_test", 2, familynet_group_create_test},
- {"familynet_group_find_test", 3, familynet_group_find_test},
- {"familynet_group_get_found_groups_test", 4, familynet_group_get_found_groups_test},
- {"familynet_deinitialize_test", TEST_CASE_MAX, familynet_deinitialize_test},
+ {"companion_initialize_test", 1, companion_initialize_test},
+ {"companion_group_create_test", 2, companion_group_create_test},
+ {"companion_group_find_test", 3, companion_group_find_test},
+ {"companion_group_get_found_groups_test", 4, companion_group_get_found_groups_test},
+ {"companion_deinitialize_test", TEST_CASE_MAX, companion_deinitialize_test},
/*-----------*/
{"Finish", 0x0000, NULL},
TC_PRT("Finished");
- familynet_deinitialize_test();
+ companion_deinitialize_test();
g_main_loop_quit(main_loop);
return ret;
--- /dev/null
+#ifndef __COMPANION_H__
+#define __COMPANION_H__
+
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef enum {
+ COMPANION_GROUP_TYPE_MINE = 0,
+ COMPANION_GROUP_TYPE_REMOTE,
+} companion_group_type_e;
+
+typedef void *companion_group_h;
+typedef void *companion_device_h;
+
+typedef bool (*companion_group_found_cb)(companion_group_type_e type, companion_group_h group, void *user_data);
+typedef bool (*companion_device_found_cb)(companion_device_h device, void *user_data);
+typedef void (*companion_group_finish_cb)(int result, void *user_data);
+
+
+
+/* Management Module APIs*/
+int companion_initialize(); /* initialize gdbus connection with manager daemon */
+int companion_deinitialize(); /* deinitialize gdbus connection with manager daemon */
+
+/* Group Module APIs*/
+/* companion_group_create : craete group in my daemon */
+int companion_group_create(char *group_name); /* O */
+/* companion_group_find : find groups in my daemon + remote groups in network */
+int companion_group_find(int timeout, companion_group_found_cb found_cb, companion_group_finish_cb finish_cb, void *user_data); /* O */
+/* companion_group_find : find groups in my daemon + remote groups in network */
+int companion_group_get_found_groups(companion_group_h **groups, int *count); /* O */
+/* companion_group_join : join to remote group. if group handle is my daemon's, then the api return fail error */
+int companion_group_join(companion_group_h group, companion_group_finish_cb callback, void *user_data);
+/* companion_group_join : leave from remote group. if group handle is my daemon's, then the api return fail error */
+int companion_group_leave(companion_group_h group, companion_group_finish_cb callback, void *user_data);
+/* companion_group_delete : remove group. if group handle is remote group, then the api return fail error */
+int companion_group_delete(companion_group_h group);
+int companion_group_merge(companion_group_h dest_group, companion_group_h src_group);
+
+/* Group Device Module */
+/* The "Group Device" is element of group. Only one group device per target.
+ I do not like this " group device " term. :/
+ If you have any good terms, I would appreciate your suggestions.*/
+
+/* companion_group_device_find : Find the group devices on the network. (exclude myself) */
+int companion_device_find(int timeout, companion_device_found_cb found_cb,
+ companion_group_finish_cb finish_cb, void *user_data);
+
+/* companion_group_device_invite : Invite a remote group device to my group. */
+int companion_device_invite(companion_group_h group,
+ companion_device_h group_device, companion_group_finish_cb callback, void *user_data); //Join to device in group (async)
+
+/* companion_group_device_eject : Eject a remote group device from my group. */
+int companion_device_eject(companion_group_h group,
+ companion_device_h group_device, companion_group_finish_cb callback, void *user_data); //dismiss from group (async)
+
+/* Group Information Module */
+int companion_group_information_get_type(companion_group_h group, companion_group_type_e *type);
+int companion_group_information_get_resource_type(companion_group_h group, char **resource_type);
+int companion_group_information_get_uri_path(companion_group_h group, char **uri_path);
+
+/* Group Device Information Module */
+/* I think the information in the group device is the same as the "device informations" */
+
+/*
+int companion_group_device_information_get_ip?(companion_group_device_h group_handle, ???);
+int companion_group_device_information_get_address?(companion_group_device_h group_handle, ???);
+int companion_group_device_information_get_???(companion_group_device_h group_handle, ???);
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+#ifndef __COMPANION_DEBUG_H__
+#define __COMPANION_DEBUG_H__
+
+#include <stdio.h>
+
+#define COLOR_BLACK "\033[0;30m"
+#define COLOR_RED "\033[0;31m"
+#define COLOR_GREEN "\033[0;32m"
+#define COLOR_BROWN "\033[0;33m"
+#define COLOR_BLUE "\033[0;34m"
+#define COLOR_PURPLE "\033[0;35m"
+#define COLOR_CYAN "\033[0;36m"
+#define COLOR_GRAY "\033[0;37m"
+#define COLOR_END "\033[0;m"
+#define LOG_TAG "COMP_MANAGER_CAPI"
+
+#define _ERR(fmt, ...) \
+ do { \
+ LOGE(COLOR_RED fmt COLOR_END, ##__VA_ARGS__); \
+ } while (0)
+
+#define _INFO(fmt, ...) \
+ do { \
+ LOGI(COLOR_GREEN fmt COLOR_END, ##__VA_ARGS__); \
+ } while (0)
+
+#define _WARN(fmt, ...) \
+ do { \
+ LOGI(COLOR_BROWN fmt COLOR_END, ##__VA_ARGS__); \
+ } while (0)
+
+#define _DBG(fmt, ...) \
+ do { \
+ LOGD(fmt, ##__VA_ARGS__); \
+ } while (0)
+
+#define _BEGIN() \
+ do { \
+ LOGD(COLOR_BLUE "BEGIN >>>>" COLOR_END); \
+ } while (0)
+
+#define _END() \
+ do { \
+ LOGD(COLOR_BLUE "END <<<<" COLOR_END); \
+ } while (0)
+
+#define cond_expr_ret(expr, val) \
+ do { \
+ if (expr) { \
+ _ERR("[precond fail] expr : %s, ret : %d\n", #expr, val); \
+ return (val); \
+ } \
+ } while (0)
+
+#define cond_ret(val) \
+ do { \
+ if (val) { \
+ _ERR("[precond fail] ret : %d\n", val); \
+ return (val); \
+ } \
+ } while (0)
+
+#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args)
+#define TC_PRT(format, args...) PRT(format"\n", ##args)
+
+#endif
+++ /dev/null
-#ifndef __FAMILYNET_H__
-#define __FAMILYNET_H__
-
-#include <tizen.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum {
- FAMILYNET_GROUP_TYPE_MINE = 0,
- FAMILYNET_GROUP_TYPE_REMOTE,
-} familynet_group_type_e;
-
-typedef void *familynet_group_h;
-typedef void *familynet_group_device_h;
-
-typedef bool (*familynet_group_found_cb)(familynet_group_type_e type, familynet_group_h group, void *user_data);
-typedef void (*familynet_group_finish_cb)(int result, void *user_data);
-
-typedef bool (*familynet_group_device_found_cb)(familynet_group_device_h group, void *user_data);
-
-/* Management Module APIs*/
-int familynet_initialize(); /* initialize gdbus connection with manager daemon */
-int familynet_deinitialize(); /* deinitialize gdbus connection with manager daemon */
-
-/* Group Module APIs*/
-/* familynet_group_create : craete group in my daemon */
-int familynet_group_create(char *group_name); /* O */
-/* familynet_group_find : find groups in my daemon + remote groups in network */
-int familynet_group_find(int timeout, familynet_group_found_cb found_cb, familynet_group_finish_cb finish_cb, void *user_data); /* O */
-/* familynet_group_find : find groups in my daemon + remote groups in network */
-int familynet_group_get_found_groups(familynet_group_h **groups, int *count); /* O */
-/* familynet_group_join : join to remote group. if group handle is my daemon's, then the api return fail error */
-int familynet_group_join(familynet_group_h group, familynet_group_finish_cb callback, void *user_data);
-/* familynet_group_join : leave from remote group. if group handle is my daemon's, then the api return fail error */
-int familynet_group_leave(familynet_group_h group, familynet_group_finish_cb callback, void *user_data);
-/* familynet_group_delete : remove group. if group handle is remote group, then the api return fail error */
-int familynet_group_delete(familynet_group_h group);
-int familynet_group_merge(familynet_group_h dest_group, familynet_group_h src_group);
-
-/* Group Device Module */
-/* The "Group Device" is element of group. Only one group device per target.
- I do not like this " group device " term. :/
- If you have any good terms, I would appreciate your suggestions.*/
-
-/* familynet_group_device_find : Find the group devices on the network. (exclude myself) */
-int familynet_group_device_find(int timeout, familynet_group_device_found_cb found_cb,
- familynet_group_finish_cb finish_cb, void *user_data);
-
-/* familynet_group_device_invite : Invite a remote group device to my group. */
-int familynet_group_device_invite(familynet_group_h group,
- familynet_group_device_h group_device, familynet_group_finish_cb callback, void *user_data); //Join to device in group (async)
-
-/* familynet_group_device_eject : Eject a remote group device from my group. */
-int familynet_group_device_eject(familynet_group_h group,
- familynet_group_device_h group_device, familynet_group_finish_cb callback, void *user_data); //dismiss from group (async)
-
-/* Group Information Module */
-int familynet_group_information_get_type(familynet_group_h group, familynet_group_type_e *type);
-int familynet_group_information_get_resource_type(familynet_group_h group, char **resource_type);
-int familynet_group_information_get_uri_path(familynet_group_h group, char **uri_path);
-
-/* Group Device Information Module */
-/* I think the information in the group device is the same as the "device informations" */
-
-/*
-int familynet_group_device_information_get_ip?(familynet_group_device_h group_handle, ???);
-int familynet_group_device_information_get_address?(familynet_group_device_h group_handle, ???);
-int familynet_group_device_information_get_???(familynet_group_device_h group_handle, ???);
-*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
+++ /dev/null
-#ifndef __MTP_DEBUG_H__
-#define __MTP_DEBUG_H__
-
-#include <stdio.h>
-
-#define COLOR_BLACK "\033[0;30m"
-#define COLOR_RED "\033[0;31m"
-#define COLOR_GREEN "\033[0;32m"
-#define COLOR_BROWN "\033[0;33m"
-#define COLOR_BLUE "\033[0;34m"
-#define COLOR_PURPLE "\033[0;35m"
-#define COLOR_CYAN "\033[0;36m"
-#define COLOR_GRAY "\033[0;37m"
-#define COLOR_END "\033[0;m"
-#define LOG_TAG "FN_MANAGER_CAPI"
-
-#define _ERR(fmt, ...) \
- do { \
- LOGE(COLOR_RED fmt COLOR_END, ##__VA_ARGS__); \
- } while (0)
-
-#define _INFO(fmt, ...) \
- do { \
- LOGI(COLOR_GREEN fmt COLOR_END, ##__VA_ARGS__); \
- } while (0)
-
-#define _WARN(fmt, ...) \
- do { \
- LOGI(COLOR_BROWN fmt COLOR_END, ##__VA_ARGS__); \
- } while (0)
-
-#define _DBG(fmt, ...) \
- do { \
- LOGD(fmt, ##__VA_ARGS__); \
- } while (0)
-
-#define _BEGIN() \
- do { \
- LOGD(COLOR_BLUE "BEGIN >>>>" COLOR_END); \
- } while (0)
-
-#define _END() \
- do { \
- LOGD(COLOR_BLUE "END <<<<" COLOR_END); \
- } while (0)
-
-#define cond_expr_ret(expr, val) \
- do { \
- if (expr) { \
- _ERR("[precond fail] expr : %s, ret : %d\n", #expr, val); \
- return (val); \
- } \
- } while (0)
-
-#define cond_ret(val) \
- do { \
- if (val) { \
- _ERR("[precond fail] ret : %d\n", val); \
- return (val); \
- } \
- } while (0)
-
-#define PRT(format, args...) printf("%s:%d() "format, __FUNCTION__, __LINE__, ##args)
-#define TC_PRT(format, args...) PRT(format"\n", ##args)
-
-#endif
--- /dev/null
+#include <stdio.h>
+#include <unistd.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <stdlib.h>
+
+#include <dlog.h>
+#include <companion.h>
+#include <companion_debug.h>
+#include <companion_gdbus.h>
+
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+
+#define COMP_DBUS_SERVICE "org.tizen.companion"
+#define COMP_DBUS_GROUP_PATH "/org/tizen/companion/group"
+
+Group *group_proxy = NULL;
+
+int ref_count = 0;
+bool __is_initialized = false;
+
+#define COMPANION_LOCK \
+do { \
+ pthread_mutex_lock(&mutex); \
+} while (0);
+
+#define COMPANION_UNLOCK \
+do { \
+ pthread_mutex_unlock(&mutex); \
+} while (0);
+
+typedef struct _companion_group_t
+{
+ char *uri_path;
+ char *device_id;
+ char *group_name;
+ char *host_addr;
+ char *resource_type;
+ companion_group_type_e type;
+} companion_group_t;
+
+typedef struct _event_cb_t {
+ companion_group_found_cb found_cb;
+ companion_group_finish_cb finish_cb;
+ void *user_data;
+} event_cb_t;
+
+static __thread GSList *event_cb_list = NULL;
+
+static companion_group_t *_create_group_handle(char *uri_path, char *device_id,
+ char *group_name, char *host_addr, char *resource_type, companion_group_type_e type)
+{
+ companion_group_t *group = g_new0(companion_group_t, 1);
+
+ group->uri_path = g_strdup(uri_path);
+ group->device_id = g_strdup(device_id);
+ group->group_name = g_strdup(group_name);
+ group->host_addr = g_strdup(host_addr);
+ group->resource_type = g_strdup(resource_type);
+ group->type = type;
+
+ return group;
+}
+
+static void _group_found_cb(Group *object,
+ GVariant *va, gpointer user_data)
+{
+ GVariantIter *iter = NULL;
+ const gchar *key;
+ GVariant *key_value;
+ companion_group_t *group = NULL;
+ char *uri_path;
+ char *device_id;
+ char *group_name;
+ char *host_addr;
+ char *resource_type;
+ companion_group_type_e type;
+
+ g_variant_get(va, "a{sv}", &iter);
+ while (g_variant_iter_loop(iter, "{sv}", &key, &key_value)) {
+ if (g_strcmp0(key, "URI") == 0) {
+ uri_path = g_variant_get_string(key_value, NULL);
+ } else if (g_strcmp0(key, "DeviceID") == 0) {
+ device_id = g_variant_get_string(key_value, NULL);
+ } else if (g_strcmp0(key, "GroupName") == 0) {
+ group_name = g_variant_get_string(key_value, NULL);
+ } else if (g_strcmp0(key, "HostAddress") == 0) {
+ host_addr = g_variant_get_string(key_value, NULL);
+ } else if (g_strcmp0(key, "GroupDeviceType") == 0) {
+ resource_type = g_variant_get_string(key_value, NULL);
+ } else if (g_strcmp0(key, "GroupType") == 0) {
+ type = g_variant_get_int32(key_value);
+ }
+ }
+
+ g_variant_iter_free(iter);
+
+ group = _create_group_handle(uri_path, device_id, group_name, host_addr, resource_type, type);
+
+ for (GSList *l = event_cb_list; l != NULL; l = l->next) {
+ event_cb_t *event_s = (event_cb_t *)l->data;
+ event_s->found_cb(type, group, event_s->user_data);
+ }
+}
+
+static void _finish_cb(Group *object,
+ gint ret, gpointer user_data)
+{
+ for (GSList *l = event_cb_list; l != NULL; l = l->next) {
+ event_cb_t *event_s = (event_cb_t *)l->data;
+ event_s->finish_cb(ret, event_s->user_data);
+ }
+}
+
+static void _group_proxy_init(void)
+{
+ GError *error = NULL;
+
+ group_proxy = group_proxy_new_for_bus_sync(
+ G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ COMP_DBUS_SERVICE,
+ COMP_DBUS_GROUP_PATH,
+ NULL,
+ &error);
+
+ g_signal_connect(group_proxy, "group-found", G_CALLBACK(_group_found_cb), NULL);
+ g_signal_connect(group_proxy, "finish", G_CALLBACK(_finish_cb), NULL);
+}
+
+static void _group_proxy_deinit(void)
+{
+ group_proxy = NULL;
+}
+
+static int _gdbus_initialize(void)
+{
+ int ret = 0;
+
+ _group_proxy_init();
+
+ if (group_proxy == NULL)
+ ret = -1; /* LCOV_EXCL_LINE */
+
+ return ret;
+}
+
+static int _gdbus_deinitialize(void)
+{
+ int ret = 0;
+
+ _group_proxy_deinit();
+
+ return ret;
+}
+
+int companion_initialize()
+{
+ int ret = 0;
+
+ _BEGIN();
+
+ COMPANION_LOCK;
+
+ if (__is_initialized == false) {
+ ret = _gdbus_initialize();
+ __is_initialized = true;
+ }
+ ref_count++;
+
+ COMPANION_UNLOCK;
+
+ _END();
+
+ return ret;
+}
+
+int companion_deinitialize()
+{
+ int ret = 0;
+
+ _BEGIN();
+
+ COMPANION_LOCK;
+
+ if (ref_count > 0)
+ ref_count--;
+
+ if (__is_initialized == true && ref_count == 0) {
+ ret = _gdbus_deinitialize();
+ __is_initialized = false;
+ }
+
+ COMPANION_UNLOCK;
+
+ _END();
+
+ return ret;
+
+}
+
+int companion_group_create(char *group_name)
+{
+ int ret = 0;
+ companion_group_t *group;
+ GError *error = NULL;
+
+ /* create group to daemon using gdbus */
+ group_call_create_sync(group_proxy, group_name, &ret, NULL, &error);
+
+ return ret;
+}
+
+int companion_group_find(int timeout, companion_group_found_cb found_cb, companion_group_finish_cb finish_cb, void *user_data)
+{
+ int ret = 0;
+ GError *error = NULL;
+
+ /* set event cb */
+ event_cb_t *event_t;
+
+ event_t = g_try_new0(event_cb_t, 1);
+ if (event_t == NULL)
+ return -1;
+
+ event_t->found_cb = found_cb;
+ event_t->finish_cb = finish_cb;
+ event_t->user_data = user_data;
+
+ event_cb_list = g_slist_prepend(event_cb_list, event_t);
+
+ /* get groups from daemon using gdbus */
+ group_call_find_sync(group_proxy, timeout, &ret, NULL, &error);
+
+ return ret;
+}
+
+int companion_group_get_found_groups(companion_group_h **groups, int *count)
+{
+ int ret = 0;
+ bool result = false;
+ GVariant *va = NULL;
+ GError *error = NULL;
+
+ /* get groups from daemon using gdbus */
+ group_call_get_found_groups_sync(group_proxy, &ret, &va, NULL, &error);
+ *count = g_variant_n_children(va);
+
+ _ERR("get found groups : %d", *count);
+
+ if (*count > 0) {
+ GVariantIter *iter = NULL, *iter_row = NULL;
+ GVariant *key_value;
+ const gchar *key;
+ guint i = 0;
+
+ *groups = g_new0(companion_group_h, *count);
+
+ g_variant_get(va, "aa{sv}", &iter);
+ while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
+ companion_group_t *group = NULL;
+ companion_group_type_e type;
+ char *uri_path;
+ char *device_id;
+ char *group_name;
+ char *host_addr;
+ char *resource_type;
+
+ while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) {
+ if (g_strcmp0(key, "URI") == 0) {
+ uri_path = g_variant_get_string(key_value, NULL);
+ } else if (g_strcmp0(key, "DeviceID") == 0) {
+ device_id = g_variant_get_string(key_value, NULL);
+ } else if (g_strcmp0(key, "GroupName") == 0) {
+ group_name = g_variant_get_string(key_value, NULL);
+ } else if (g_strcmp0(key, "HostAddress") == 0) {
+ host_addr = g_variant_get_string(key_value, NULL);
+ } else if (g_strcmp0(key, "GroupDeviceType") == 0) {
+ resource_type = g_variant_get_string(key_value, NULL);
+ } else if (g_strcmp0(key, "GroupType") == 0) {
+ type = g_variant_get_int32(key_value);
+ }
+ }
+ g_variant_iter_free(iter_row);
+
+ group = _create_group_handle(uri_path,
+ device_id, group_name, host_addr, resource_type, type);
+
+ (*groups)[i++] = (companion_group_h)group;
+ }
+ g_variant_iter_free(iter);
+ }
+ g_variant_unref(va);
+
+ return ret;
+}
+
+/* group merge */
+int companion_group_merge(companion_group_h dest_group, companion_group_h src_group)
+{
+ return 0;
+}
+
+int companion_group_information_get_type(companion_group_h group, companion_group_type_e *type)
+{
+ *type = ((companion_group_t *)group)->type;
+
+ return 0;
+}
+
+int companion_group_information_get_resource_type(companion_group_h group, char **resource_type)
+{
+ *resource_type = g_strdup(((companion_group_t *)group)->resource_type);
+
+ return 0;
+}
+
+int companion_group_information_get_uri_path(companion_group_h group, char **uri_path)
+{
+ *uri_path = g_strdup(((companion_group_t *)group)->uri_path);
+
+ return 0;
+}
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!DOCTYPE node PUBLIC
+ "-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
+ "http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
+
+<node>
+ <interface name="org.tizen.companion.group">
+ <!-- Method definitions -->
+ <method name="Create">
+ <arg type="s" name="group_name" direction="in"/>
+ <arg type="i" name="result" direction="out"/>
+ </method>
+ <method name="Find">
+ <arg type="i" name="timeout" direction="in" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+ <method name="GetFoundGroups">
+ <arg type="i" name="result" direction="out" />
+ <arg type="aa{sv}" name="groups" direction="out" />
+ </method>
+ <method name="Join">
+ <arg type="i" name="group_count" direction="out" />
+ <arg type="aa{sv}" name="groups" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+ <method name="Leave">
+ <arg type="i" name="group_count" direction="out" />
+ <arg type="aa{sv}" name="groups" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+ <method name="Delete">
+ <arg type="i" name="group_count" direction="out" />
+ <arg type="aa{sv}" name="groups" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+ <method name="DeviceFind">
+ <arg type="i" name="group_count" direction="out" />
+ <arg type="aa{sv}" name="groups" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+ <method name="DeviceInvite">
+ <arg type="i" name="group_count" direction="out" />
+ <arg type="aa{sv}" name="groups" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+ <method name="DeviceEject">
+ <arg type="i" name="group_count" direction="out" />
+ <arg type="aa{sv}" name="groups" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <!-- Signal (D-Bus) definitions -->
+ <signal name="GroupFound">
+ <arg type="a{sv}" name="group_info" direction="out" />
+ </signal>
+ <signal name="Finish">
+ <arg type="i" name="result" direction="out" />
+ </signal>
+ </interface>
+</node>
+++ /dev/null
-#include <stdio.h>
-#include <unistd.h>
-#include <glib.h>
-#include <gio/gio.h>
-#include <stdlib.h>
-
-#include <dlog.h>
-#include <familynet.h>
-#include <familynet_debug.h>
-#include <familynet_gdbus.h>
-
-static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-
-#define FN_DBUS_SERVICE "org.tizen.familynet"
-#define FN_DBUS_GROUP_PATH "/org/tizen/familynet/group"
-
-Group *group_proxy = NULL;
-
-int ref_count = 0;
-bool __is_initialized = false;
-
-#define FAMILYNET_LOCK \
-do { \
- pthread_mutex_lock(&mutex); \
-} while (0);
-
-#define FAMILYNET_UNLOCK \
-do { \
- pthread_mutex_unlock(&mutex); \
-} while (0);
-
-typedef struct _familynet_group_t
-{
- char *uri_path;
- char *device_id;
- char *group_name;
- char *host_addr;
- char *resource_type;
- familynet_group_type_e type;
-} familynet_group_t;
-
-typedef struct _event_cb_t {
- familynet_group_found_cb found_cb;
- familynet_group_finish_cb finish_cb;
- void *user_data;
-} event_cb_t;
-
-static __thread GSList *event_cb_list = NULL;
-
-static familynet_group_t *_create_group_handle(char *uri_path, char *device_id,
- char *group_name, char *host_addr, char *resource_type, familynet_group_type_e type)
-{
- familynet_group_t *group = g_new0(familynet_group_t, 1);
-
- group->uri_path = g_strdup(uri_path);
- group->device_id = g_strdup(device_id);
- group->group_name = g_strdup(group_name);
- group->host_addr = g_strdup(host_addr);
- group->resource_type = g_strdup(resource_type);
- group->type = type;
-
- return group;
-}
-
-static void _group_found_cb(Group *object,
- GVariant *va, gpointer user_data)
-{
- GVariantIter *iter = NULL;
- const gchar *key;
- GVariant *key_value;
- familynet_group_t *group = NULL;
- char *uri_path;
- char *device_id;
- char *group_name;
- char *host_addr;
- char *resource_type;
- familynet_group_type_e type;
-
- g_variant_get(va, "a{sv}", &iter);
- while (g_variant_iter_loop(iter, "{sv}", &key, &key_value)) {
- if (g_strcmp0(key, "URI") == 0) {
- uri_path = g_variant_get_string(key_value, NULL);
- } else if (g_strcmp0(key, "DeviceID") == 0) {
- device_id = g_variant_get_string(key_value, NULL);
- } else if (g_strcmp0(key, "GroupName") == 0) {
- group_name = g_variant_get_string(key_value, NULL);
- } else if (g_strcmp0(key, "HostAddress") == 0) {
- host_addr = g_variant_get_string(key_value, NULL);
- } else if (g_strcmp0(key, "GroupDeviceType") == 0) {
- resource_type = g_variant_get_string(key_value, NULL);
- } else if (g_strcmp0(key, "GroupType") == 0) {
- type = g_variant_get_int32(key_value);
- }
- }
-
- g_variant_iter_free(iter);
-
- group = _create_group_handle(uri_path, device_id, group_name, host_addr, resource_type, type);
-
- for (GSList *l = event_cb_list; l != NULL; l = l->next) {
- event_cb_t *event_s = (event_cb_t *)l->data;
- event_s->found_cb(type, group, event_s->user_data);
- }
-}
-
-static void _finish_cb(Group *object,
- gint ret, gpointer user_data)
-{
- for (GSList *l = event_cb_list; l != NULL; l = l->next) {
- event_cb_t *event_s = (event_cb_t *)l->data;
- event_s->finish_cb(ret, event_s->user_data);
- }
-}
-
-static void _group_proxy_init(void)
-{
- GError *error = NULL;
-
- group_proxy = group_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- FN_DBUS_SERVICE,
- FN_DBUS_GROUP_PATH,
- NULL,
- &error);
-
- g_signal_connect(group_proxy, "group-found", G_CALLBACK(_group_found_cb), NULL);
- g_signal_connect(group_proxy, "finish", G_CALLBACK(_finish_cb), NULL);
-}
-
-static void _group_proxy_deinit(void)
-{
- group_proxy = NULL;
-}
-
-static int _gdbus_initialize(void)
-{
- int ret = 0;
-
- _group_proxy_init();
-
- if (group_proxy == NULL)
- ret = -1; /* LCOV_EXCL_LINE */
-
- return ret;
-}
-
-static int _gdbus_deinitialize(void)
-{
- int ret = 0;
-
- _group_proxy_deinit();
-
- return ret;
-}
-
-int familynet_initialize()
-{
- int ret = 0;
-
- _BEGIN();
-
- FAMILYNET_LOCK;
-
- if (__is_initialized == false) {
- ret = _gdbus_initialize();
- __is_initialized = true;
- }
- ref_count++;
-
- FAMILYNET_UNLOCK;
-
- _END();
-
- return ret;
-}
-
-int familynet_deinitialize()
-{
- int ret = 0;
-
- _BEGIN();
-
- FAMILYNET_LOCK;
-
- if (ref_count > 0)
- ref_count--;
-
- if (__is_initialized == true && ref_count == 0) {
- ret = _gdbus_deinitialize();
- __is_initialized = false;
- }
-
- FAMILYNET_UNLOCK;
-
- _END();
-
- return ret;
-
-}
-
-int familynet_group_create(char *group_name)
-{
- int ret = 0;
- familynet_group_t *group;
- GError *error = NULL;
-
- /* create group to daemon using gdbus */
- group_call_create_sync(group_proxy, group_name, &ret, NULL, &error);
-
- return ret;
-}
-
-int familynet_group_find(int timeout, familynet_group_found_cb found_cb, familynet_group_finish_cb finish_cb, void *user_data)
-{
- int ret = 0;
- GError *error = NULL;
-
- /* set event cb */
- event_cb_t *event_t;
-
- event_t = g_try_new0(event_cb_t, 1);
- if (event_t == NULL)
- return -1;
-
- event_t->found_cb = found_cb;
- event_t->finish_cb = finish_cb;
- event_t->user_data = user_data;
-
- event_cb_list = g_slist_prepend(event_cb_list, event_t);
-
- /* get groups from daemon using gdbus */
- group_call_find_sync(group_proxy, timeout, &ret, NULL, &error);
-
- return ret;
-}
-
-int familynet_group_get_found_groups(familynet_group_h **groups, int *count)
-{
- int ret = 0;
- bool result = false;
- GVariant *va = NULL;
- GError *error = NULL;
-
- /* get groups from daemon using gdbus */
- group_call_get_found_groups_sync(group_proxy, &ret, &va, NULL, &error);
- *count = g_variant_n_children(va);
-
- _ERR("get found groups : %d", *count);
-
- if (*count > 0) {
- GVariantIter *iter = NULL, *iter_row = NULL;
- GVariant *key_value;
- const gchar *key;
- guint i = 0;
-
- *groups = g_new0(familynet_group_h, *count);
-
- g_variant_get(va, "aa{sv}", &iter);
- while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
- familynet_group_t *group = NULL;
- familynet_group_type_e type;
- char *uri_path;
- char *device_id;
- char *group_name;
- char *host_addr;
- char *resource_type;
-
- while (g_variant_iter_loop(iter_row, "{sv}", &key, &key_value)) {
- if (g_strcmp0(key, "URI") == 0) {
- uri_path = g_variant_get_string(key_value, NULL);
- } else if (g_strcmp0(key, "DeviceID") == 0) {
- device_id = g_variant_get_string(key_value, NULL);
- } else if (g_strcmp0(key, "GroupName") == 0) {
- group_name = g_variant_get_string(key_value, NULL);
- } else if (g_strcmp0(key, "HostAddress") == 0) {
- host_addr = g_variant_get_string(key_value, NULL);
- } else if (g_strcmp0(key, "GroupDeviceType") == 0) {
- resource_type = g_variant_get_string(key_value, NULL);
- } else if (g_strcmp0(key, "GroupType") == 0) {
- type = g_variant_get_int32(key_value);
- }
- }
- g_variant_iter_free(iter_row);
-
- group = _create_group_handle(uri_path,
- device_id, group_name, host_addr, resource_type, type);
-
- (*groups)[i++] = (familynet_group_h)group;
- }
- g_variant_iter_free(iter);
- }
- g_variant_unref(va);
-
- return ret;
-}
-
-/* group merge */
-int familynet_group_merge(familynet_group_h dest_group, familynet_group_h src_group)
-{
- return 0;
-}
-
-int familynet_group_information_get_type(familynet_group_h group, familynet_group_type_e *type)
-{
- *type = ((familynet_group_t *)group)->type;
-
- return 0;
-}
-
-int familynet_group_information_get_resource_type(familynet_group_h group, char **resource_type)
-{
- *resource_type = g_strdup(((familynet_group_t *)group)->resource_type);
-
- return 0;
-}
-
-int familynet_group_information_get_uri_path(familynet_group_h group, char **uri_path)
-{
- *uri_path = g_strdup(((familynet_group_t *)group)->uri_path);
-
- return 0;
-}
-
+++ /dev/null
-/*
- * Generated by gdbus-codegen 2.40.2. DO NOT EDIT.
- *
- * The license of this code is the same as for the source it was derived from.
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include "familynet_gdbus.h"
-
-#include <string.h>
-#ifdef G_OS_UNIX
-# include <gio/gunixfdlist.h>
-#endif
-
-typedef struct
-{
- GDBusArgInfo parent_struct;
- gboolean use_gvariant;
-} _ExtendedGDBusArgInfo;
-
-typedef struct
-{
- GDBusMethodInfo parent_struct;
- const gchar *signal_name;
- gboolean pass_fdlist;
-} _ExtendedGDBusMethodInfo;
-
-typedef struct
-{
- GDBusSignalInfo parent_struct;
- const gchar *signal_name;
-} _ExtendedGDBusSignalInfo;
-
-typedef struct
-{
- GDBusPropertyInfo parent_struct;
- const gchar *hyphen_name;
- gboolean use_gvariant;
-} _ExtendedGDBusPropertyInfo;
-
-typedef struct
-{
- GDBusInterfaceInfo parent_struct;
- const gchar *hyphen_name;
-} _ExtendedGDBusInterfaceInfo;
-
-typedef struct
-{
- const _ExtendedGDBusPropertyInfo *info;
- guint prop_id;
- GValue orig_value; /* the value before the change */
-} ChangedProperty;
-
-static void
-_changed_property_free (ChangedProperty *data)
-{
- g_value_unset (&data->orig_value);
- g_free (data);
-}
-
-static gboolean
-_g_strv_equal0 (gchar **a, gchar **b)
-{
- gboolean ret = FALSE;
- guint n;
- if (a == NULL && b == NULL)
- {
- ret = TRUE;
- goto out;
- }
- if (a == NULL || b == NULL)
- goto out;
- if (g_strv_length (a) != g_strv_length (b))
- goto out;
- for (n = 0; a[n] != NULL; n++)
- if (g_strcmp0 (a[n], b[n]) != 0)
- goto out;
- ret = TRUE;
-out:
- return ret;
-}
-
-static gboolean
-_g_variant_equal0 (GVariant *a, GVariant *b)
-{
- gboolean ret = FALSE;
- if (a == NULL && b == NULL)
- {
- ret = TRUE;
- goto out;
- }
- if (a == NULL || b == NULL)
- goto out;
- ret = g_variant_equal (a, b);
-out:
- return ret;
-}
-
-G_GNUC_UNUSED static gboolean
-_g_value_equal (const GValue *a, const GValue *b)
-{
- gboolean ret = FALSE;
- g_assert (G_VALUE_TYPE (a) == G_VALUE_TYPE (b));
- switch (G_VALUE_TYPE (a))
- {
- case G_TYPE_BOOLEAN:
- ret = (g_value_get_boolean (a) == g_value_get_boolean (b));
- break;
- case G_TYPE_UCHAR:
- ret = (g_value_get_uchar (a) == g_value_get_uchar (b));
- break;
- case G_TYPE_INT:
- ret = (g_value_get_int (a) == g_value_get_int (b));
- break;
- case G_TYPE_UINT:
- ret = (g_value_get_uint (a) == g_value_get_uint (b));
- break;
- case G_TYPE_INT64:
- ret = (g_value_get_int64 (a) == g_value_get_int64 (b));
- break;
- case G_TYPE_UINT64:
- ret = (g_value_get_uint64 (a) == g_value_get_uint64 (b));
- break;
- case G_TYPE_DOUBLE:
- {
- /* Avoid -Wfloat-equal warnings by doing a direct bit compare */
- gdouble da = g_value_get_double (a);
- gdouble db = g_value_get_double (b);
- ret = memcmp (&da, &db, sizeof (gdouble)) == 0;
- }
- break;
- case G_TYPE_STRING:
- ret = (g_strcmp0 (g_value_get_string (a), g_value_get_string (b)) == 0);
- break;
- case G_TYPE_VARIANT:
- ret = _g_variant_equal0 (g_value_get_variant (a), g_value_get_variant (b));
- break;
- default:
- if (G_VALUE_TYPE (a) == G_TYPE_STRV)
- ret = _g_strv_equal0 (g_value_get_boxed (a), g_value_get_boxed (b));
- else
- g_critical ("_g_value_equal() does not handle type %s", g_type_name (G_VALUE_TYPE (a)));
- break;
- }
- return ret;
-}
-
-/* ------------------------------------------------------------------------
- * Code for interface org.tizen.familynet.group
- * ------------------------------------------------------------------------
- */
-
-/**
- * SECTION:Group
- * @title: Group
- * @short_description: Generated C code for the org.tizen.familynet.group D-Bus interface
- *
- * This section contains code for working with the <link linkend="gdbus-interface-org-tizen-familynet-group.top_of_page">org.tizen.familynet.group</link> D-Bus interface in C.
- */
-
-/* ---- Introspection data for org.tizen.familynet.group ---- */
-
-static const _ExtendedGDBusArgInfo _group_method_info_create_IN_ARG_group_name =
-{
- {
- -1,
- (gchar *) "group_name",
- (gchar *) "s",
- NULL
- },
- FALSE
-};
-
-static const _ExtendedGDBusArgInfo * const _group_method_info_create_IN_ARG_pointers[] =
-{
- &_group_method_info_create_IN_ARG_group_name,
- NULL
-};
-
-static const _ExtendedGDBusArgInfo _group_method_info_create_OUT_ARG_result =
-{
- {
- -1,
- (gchar *) "result",
- (gchar *) "i",
- NULL
- },
- FALSE
-};
-
-static const _ExtendedGDBusArgInfo * const _group_method_info_create_OUT_ARG_pointers[] =
-{
- &_group_method_info_create_OUT_ARG_result,
- NULL
-};
-
-static const _ExtendedGDBusMethodInfo _group_method_info_create =
-{
- {
- -1,
- (gchar *) "Create",
- (GDBusArgInfo **) &_group_method_info_create_IN_ARG_pointers,
- (GDBusArgInfo **) &_group_method_info_create_OUT_ARG_pointers,
- NULL
- },
- "handle-create",
- FALSE
-};
-
-static const _ExtendedGDBusArgInfo _group_method_info_find_OUT_ARG_group_count =
-{
- {
- -1,
- (gchar *) "group_count",
- (gchar *) "i",
- NULL
- },
- FALSE
-};
-
-static const _ExtendedGDBusArgInfo _group_method_info_find_OUT_ARG_groups =
-{
- {
- -1,
- (gchar *) "groups",
- (gchar *) "aa{sv}",
- NULL
- },
- FALSE
-};
-
-static const _ExtendedGDBusArgInfo _group_method_info_find_OUT_ARG_result =
-{
- {
- -1,
- (gchar *) "result",
- (gchar *) "i",
- NULL
- },
- FALSE
-};
-
-static const _ExtendedGDBusArgInfo * const _group_method_info_find_OUT_ARG_pointers[] =
-{
- &_group_method_info_find_OUT_ARG_group_count,
- &_group_method_info_find_OUT_ARG_groups,
- &_group_method_info_find_OUT_ARG_result,
- NULL
-};
-
-static const _ExtendedGDBusMethodInfo _group_method_info_find =
-{
- {
- -1,
- (gchar *) "Find",
- NULL,
- (GDBusArgInfo **) &_group_method_info_find_OUT_ARG_pointers,
- NULL
- },
- "handle-find",
- FALSE
-};
-
-static const _ExtendedGDBusMethodInfo * const _group_method_info_pointers[] =
-{
- &_group_method_info_create,
- &_group_method_info_find,
- NULL
-};
-
-static const _ExtendedGDBusInterfaceInfo _group_interface_info =
-{
- {
- -1,
- (gchar *) "org.tizen.familynet.group",
- (GDBusMethodInfo **) &_group_method_info_pointers,
- NULL,
- NULL,
- NULL
- },
- "group",
-};
-
-
-/**
- * group_interface_info:
- *
- * Gets a machine-readable description of the <link linkend="gdbus-interface-org-tizen-familynet-group.top_of_page">org.tizen.familynet.group</link> D-Bus interface.
- *
- * Returns: (transfer none): A #GDBusInterfaceInfo. Do not free.
- */
-GDBusInterfaceInfo *
-group_interface_info (void)
-{
- return (GDBusInterfaceInfo *) &_group_interface_info.parent_struct;
-}
-
-/**
- * group_override_properties:
- * @klass: The class structure for a #GObject<!-- -->-derived class.
- * @property_id_begin: The property id to assign to the first overridden property.
- *
- * Overrides all #GObject properties in the #Group interface for a concrete class.
- * The properties are overridden in the order they are defined.
- *
- * Returns: The last property id.
- */
-guint
-group_override_properties (GObjectClass *klass, guint property_id_begin)
-{
- return property_id_begin - 1;
-}
-
-
-
-/**
- * Group:
- *
- * Abstract interface type for the D-Bus interface <link linkend="gdbus-interface-org-tizen-familynet-group.top_of_page">org.tizen.familynet.group</link>.
- */
-
-/**
- * GroupIface:
- * @parent_iface: The parent interface.
- * @handle_create: Handler for the #Group::handle-create signal.
- * @handle_find: Handler for the #Group::handle-find signal.
- *
- * Virtual table for the D-Bus interface <link linkend="gdbus-interface-org-tizen-familynet-group.top_of_page">org.tizen.familynet.group</link>.
- */
-
-typedef GroupIface GroupInterface;
-G_DEFINE_INTERFACE (Group, group, G_TYPE_OBJECT);
-
-static void
-group_default_init (GroupIface *iface)
-{
- /* GObject signals for incoming D-Bus method calls: */
- /**
- * Group::handle-create:
- * @object: A #Group.
- * @invocation: A #GDBusMethodInvocation.
- * @arg_group_name: Argument passed by remote caller.
- *
- * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-tizen-familynet-group.Create">Create()</link> D-Bus method.
- *
- * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call group_complete_create() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
- *
- * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
- */
- g_signal_new ("handle-create",
- G_TYPE_FROM_INTERFACE (iface),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GroupIface, handle_create),
- g_signal_accumulator_true_handled,
- NULL,
- g_cclosure_marshal_generic,
- G_TYPE_BOOLEAN,
- 2,
- G_TYPE_DBUS_METHOD_INVOCATION, G_TYPE_STRING);
-
- /**
- * Group::handle-find:
- * @object: A #Group.
- * @invocation: A #GDBusMethodInvocation.
- *
- * Signal emitted when a remote caller is invoking the <link linkend="gdbus-method-org-tizen-familynet-group.Find">Find()</link> D-Bus method.
- *
- * If a signal handler returns %TRUE, it means the signal handler will handle the invocation (e.g. take a reference to @invocation and eventually call group_complete_find() or e.g. g_dbus_method_invocation_return_error() on it) and no order signal handlers will run. If no signal handler handles the invocation, the %G_DBUS_ERROR_UNKNOWN_METHOD error is returned.
- *
- * Returns: %TRUE if the invocation was handled, %FALSE to let other signal handlers run.
- */
- g_signal_new ("handle-find",
- G_TYPE_FROM_INTERFACE (iface),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GroupIface, handle_find),
- g_signal_accumulator_true_handled,
- NULL,
- g_cclosure_marshal_generic,
- G_TYPE_BOOLEAN,
- 1,
- G_TYPE_DBUS_METHOD_INVOCATION);
-
-}
-
-/**
- * group_call_create:
- * @proxy: A #GroupProxy.
- * @arg_group_name: Argument to pass with the method invocation.
- * @cancellable: (allow-none): A #GCancellable or %NULL.
- * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
- * @user_data: User data to pass to @callback.
- *
- * Asynchronously invokes the <link linkend="gdbus-method-org-tizen-familynet-group.Create">Create()</link> D-Bus method on @proxy.
- * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
- * You can then call group_call_create_finish() to get the result of the operation.
- *
- * See group_call_create_sync() for the synchronous, blocking version of this method.
- */
-void
-group_call_create (
- Group *proxy,
- const gchar *arg_group_name,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- g_dbus_proxy_call (G_DBUS_PROXY (proxy),
- "Create",
- g_variant_new ("(s)",
- arg_group_name),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- cancellable,
- callback,
- user_data);
-}
-
-/**
- * group_call_create_finish:
- * @proxy: A #GroupProxy.
- * @out_result: (out): Return location for return parameter or %NULL to ignore.
- * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to group_call_create().
- * @error: Return location for error or %NULL.
- *
- * Finishes an operation started with group_call_create().
- *
- * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
- */
-gboolean
-group_call_create_finish (
- Group *proxy,
- gint *out_result,
- GAsyncResult *res,
- GError **error)
-{
- GVariant *_ret;
- _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
- if (_ret == NULL)
- goto _out;
- g_variant_get (_ret,
- "(i)",
- out_result);
- g_variant_unref (_ret);
-_out:
- return _ret != NULL;
-}
-
-/**
- * group_call_create_sync:
- * @proxy: A #GroupProxy.
- * @arg_group_name: Argument to pass with the method invocation.
- * @out_result: (out): Return location for return parameter or %NULL to ignore.
- * @cancellable: (allow-none): A #GCancellable or %NULL.
- * @error: Return location for error or %NULL.
- *
- * Synchronously invokes the <link linkend="gdbus-method-org-tizen-familynet-group.Create">Create()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
- *
- * See group_call_create() for the asynchronous version of this method.
- *
- * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
- */
-gboolean
-group_call_create_sync (
- Group *proxy,
- const gchar *arg_group_name,
- gint *out_result,
- GCancellable *cancellable,
- GError **error)
-{
- GVariant *_ret;
- _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
- "Create",
- g_variant_new ("(s)",
- arg_group_name),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- cancellable,
- error);
- if (_ret == NULL)
- goto _out;
- g_variant_get (_ret,
- "(i)",
- out_result);
- g_variant_unref (_ret);
-_out:
- return _ret != NULL;
-}
-
-/**
- * group_call_find:
- * @proxy: A #GroupProxy.
- * @cancellable: (allow-none): A #GCancellable or %NULL.
- * @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
- * @user_data: User data to pass to @callback.
- *
- * Asynchronously invokes the <link linkend="gdbus-method-org-tizen-familynet-group.Find">Find()</link> D-Bus method on @proxy.
- * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
- * You can then call group_call_find_finish() to get the result of the operation.
- *
- * See group_call_find_sync() for the synchronous, blocking version of this method.
- */
-void
-group_call_find (
- Group *proxy,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- g_dbus_proxy_call (G_DBUS_PROXY (proxy),
- "Find",
- g_variant_new ("()"),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- cancellable,
- callback,
- user_data);
-}
-
-/**
- * group_call_find_finish:
- * @proxy: A #GroupProxy.
- * @out_group_count: (out): Return location for return parameter or %NULL to ignore.
- * @out_groups: (out): Return location for return parameter or %NULL to ignore.
- * @out_result: (out): Return location for return parameter or %NULL to ignore.
- * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to group_call_find().
- * @error: Return location for error or %NULL.
- *
- * Finishes an operation started with group_call_find().
- *
- * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
- */
-gboolean
-group_call_find_finish (
- Group *proxy,
- gint *out_group_count,
- GVariant **out_groups,
- gint *out_result,
- GAsyncResult *res,
- GError **error)
-{
- GVariant *_ret;
- _ret = g_dbus_proxy_call_finish (G_DBUS_PROXY (proxy), res, error);
- if (_ret == NULL)
- goto _out;
- g_variant_get (_ret,
- "(i@aa{sv}i)",
- out_group_count,
- out_groups,
- out_result);
- g_variant_unref (_ret);
-_out:
- return _ret != NULL;
-}
-
-/**
- * group_call_find_sync:
- * @proxy: A #GroupProxy.
- * @out_group_count: (out): Return location for return parameter or %NULL to ignore.
- * @out_groups: (out): Return location for return parameter or %NULL to ignore.
- * @out_result: (out): Return location for return parameter or %NULL to ignore.
- * @cancellable: (allow-none): A #GCancellable or %NULL.
- * @error: Return location for error or %NULL.
- *
- * Synchronously invokes the <link linkend="gdbus-method-org-tizen-familynet-group.Find">Find()</link> D-Bus method on @proxy. The calling thread is blocked until a reply is received.
- *
- * See group_call_find() for the asynchronous version of this method.
- *
- * Returns: (skip): %TRUE if the call succeded, %FALSE if @error is set.
- */
-gboolean
-group_call_find_sync (
- Group *proxy,
- gint *out_group_count,
- GVariant **out_groups,
- gint *out_result,
- GCancellable *cancellable,
- GError **error)
-{
- GVariant *_ret;
- _ret = g_dbus_proxy_call_sync (G_DBUS_PROXY (proxy),
- "Find",
- g_variant_new ("()"),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- cancellable,
- error);
- if (_ret == NULL)
- goto _out;
- g_variant_get (_ret,
- "(i@aa{sv}i)",
- out_group_count,
- out_groups,
- out_result);
- g_variant_unref (_ret);
-_out:
- return _ret != NULL;
-}
-
-/**
- * group_complete_create:
- * @object: A #Group.
- * @invocation: (transfer full): A #GDBusMethodInvocation.
- * @result: Parameter to return.
- *
- * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-tizen-familynet-group.Create">Create()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
- *
- * This method will free @invocation, you cannot use it afterwards.
- */
-void
-group_complete_create (
- Group *object,
- GDBusMethodInvocation *invocation,
- gint result)
-{
- g_dbus_method_invocation_return_value (invocation,
- g_variant_new ("(i)",
- result));
-}
-
-/**
- * group_complete_find:
- * @object: A #Group.
- * @invocation: (transfer full): A #GDBusMethodInvocation.
- * @group_count: Parameter to return.
- * @groups: Parameter to return.
- * @result: Parameter to return.
- *
- * Helper function used in service implementations to finish handling invocations of the <link linkend="gdbus-method-org-tizen-familynet-group.Find">Find()</link> D-Bus method. If you instead want to finish handling an invocation by returning an error, use g_dbus_method_invocation_return_error() or similar.
- *
- * This method will free @invocation, you cannot use it afterwards.
- */
-void
-group_complete_find (
- Group *object,
- GDBusMethodInvocation *invocation,
- gint group_count,
- GVariant *groups,
- gint result)
-{
- g_dbus_method_invocation_return_value (invocation,
- g_variant_new ("(i@aa{sv}i)",
- group_count,
- groups,
- result));
-}
-
-/* ------------------------------------------------------------------------ */
-
-/**
- * GroupProxy:
- *
- * The #GroupProxy structure contains only private data and should only be accessed using the provided API.
- */
-
-/**
- * GroupProxyClass:
- * @parent_class: The parent class.
- *
- * Class structure for #GroupProxy.
- */
-
-struct _GroupProxyPrivate
-{
- GData *qdata;
-};
-
-static void group_proxy_iface_init (GroupIface *iface);
-
-#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
-G_DEFINE_TYPE_WITH_CODE (GroupProxy, group_proxy, G_TYPE_DBUS_PROXY,
- G_ADD_PRIVATE (GroupProxy)
- G_IMPLEMENT_INTERFACE (TYPE_GROUP, group_proxy_iface_init));
-
-#else
-G_DEFINE_TYPE_WITH_CODE (GroupProxy, group_proxy, G_TYPE_DBUS_PROXY,
- G_IMPLEMENT_INTERFACE (TYPE_GROUP, group_proxy_iface_init));
-
-#endif
-static void
-group_proxy_finalize (GObject *object)
-{
- GroupProxy *proxy = GROUP_PROXY (object);
- g_datalist_clear (&proxy->priv->qdata);
- G_OBJECT_CLASS (group_proxy_parent_class)->finalize (object);
-}
-
-static void
-group_proxy_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec G_GNUC_UNUSED)
-{
-}
-
-static void
-group_proxy_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec G_GNUC_UNUSED)
-{
-}
-
-static void
-group_proxy_g_signal (GDBusProxy *proxy,
- const gchar *sender_name G_GNUC_UNUSED,
- const gchar *signal_name,
- GVariant *parameters)
-{
- _ExtendedGDBusSignalInfo *info;
- GVariantIter iter;
- GVariant *child;
- GValue *paramv;
- guint num_params;
- guint n;
- guint signal_id;
- info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_group_interface_info.parent_struct, signal_name);
- if (info == NULL)
- return;
- num_params = g_variant_n_children (parameters);
- paramv = g_new0 (GValue, num_params + 1);
- g_value_init (¶mv[0], TYPE_GROUP);
- g_value_set_object (¶mv[0], proxy);
- g_variant_iter_init (&iter, parameters);
- n = 1;
- while ((child = g_variant_iter_next_value (&iter)) != NULL)
- {
- _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.args[n - 1];
- if (arg_info->use_gvariant)
- {
- g_value_init (¶mv[n], G_TYPE_VARIANT);
- g_value_set_variant (¶mv[n], child);
- n++;
- }
- else
- g_dbus_gvariant_to_gvalue (child, ¶mv[n++]);
- g_variant_unref (child);
- }
- signal_id = g_signal_lookup (info->signal_name, TYPE_GROUP);
- g_signal_emitv (paramv, signal_id, 0, NULL);
- for (n = 0; n < num_params + 1; n++)
- g_value_unset (¶mv[n]);
- g_free (paramv);
-}
-
-static void
-group_proxy_g_properties_changed (GDBusProxy *_proxy,
- GVariant *changed_properties,
- const gchar *const *invalidated_properties)
-{
- GroupProxy *proxy = GROUP_PROXY (_proxy);
- guint n;
- const gchar *key;
- GVariantIter *iter;
- _ExtendedGDBusPropertyInfo *info;
- g_variant_get (changed_properties, "a{sv}", &iter);
- while (g_variant_iter_next (iter, "{&sv}", &key, NULL))
- {
- info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_group_interface_info.parent_struct, key);
- g_datalist_remove_data (&proxy->priv->qdata, key);
- if (info != NULL)
- g_object_notify (G_OBJECT (proxy), info->hyphen_name);
- }
- g_variant_iter_free (iter);
- for (n = 0; invalidated_properties[n] != NULL; n++)
- {
- info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_group_interface_info.parent_struct, invalidated_properties[n]);
- g_datalist_remove_data (&proxy->priv->qdata, invalidated_properties[n]);
- if (info != NULL)
- g_object_notify (G_OBJECT (proxy), info->hyphen_name);
- }
-}
-
-static void
-group_proxy_init (GroupProxy *proxy)
-{
-#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
- proxy->priv = group_proxy_get_instance_private (proxy);
-#else
- proxy->priv = G_TYPE_INSTANCE_GET_PRIVATE (proxy, TYPE_GROUP_PROXY, GroupProxyPrivate);
-#endif
-
- g_dbus_proxy_set_interface_info (G_DBUS_PROXY (proxy), group_interface_info ());
-}
-
-static void
-group_proxy_class_init (GroupProxyClass *klass)
-{
- GObjectClass *gobject_class;
- GDBusProxyClass *proxy_class;
-
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = group_proxy_finalize;
- gobject_class->get_property = group_proxy_get_property;
- gobject_class->set_property = group_proxy_set_property;
-
- proxy_class = G_DBUS_PROXY_CLASS (klass);
- proxy_class->g_signal = group_proxy_g_signal;
- proxy_class->g_properties_changed = group_proxy_g_properties_changed;
-
-#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
- g_type_class_add_private (klass, sizeof (GroupProxyPrivate));
-#endif
-}
-
-static void
-group_proxy_iface_init (GroupIface *iface)
-{
-}
-
-/**
- * group_proxy_new:
- * @connection: A #GDBusConnection.
- * @flags: Flags from the #GDBusProxyFlags enumeration.
- * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
- * @object_path: An object path.
- * @cancellable: (allow-none): A #GCancellable or %NULL.
- * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
- * @user_data: User data to pass to @callback.
- *
- * Asynchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-tizen-familynet-group.top_of_page">org.tizen.familynet.group</link>. See g_dbus_proxy_new() for more details.
- *
- * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
- * You can then call group_proxy_new_finish() to get the result of the operation.
- *
- * See group_proxy_new_sync() for the synchronous, blocking version of this constructor.
- */
-void
-group_proxy_new (
- GDBusConnection *connection,
- GDBusProxyFlags flags,
- const gchar *name,
- const gchar *object_path,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- g_async_initable_new_async (TYPE_GROUP_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.tizen.familynet.group", NULL);
-}
-
-/**
- * group_proxy_new_finish:
- * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to group_proxy_new().
- * @error: Return location for error or %NULL
- *
- * Finishes an operation started with group_proxy_new().
- *
- * Returns: (transfer full) (type GroupProxy): The constructed proxy object or %NULL if @error is set.
- */
-Group *
-group_proxy_new_finish (
- GAsyncResult *res,
- GError **error)
-{
- GObject *ret;
- GObject *source_object;
- source_object = g_async_result_get_source_object (res);
- ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
- g_object_unref (source_object);
- if (ret != NULL)
- return GROUP (ret);
- else
- return NULL;
-}
-
-/**
- * group_proxy_new_sync:
- * @connection: A #GDBusConnection.
- * @flags: Flags from the #GDBusProxyFlags enumeration.
- * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
- * @object_path: An object path.
- * @cancellable: (allow-none): A #GCancellable or %NULL.
- * @error: Return location for error or %NULL
- *
- * Synchronously creates a proxy for the D-Bus interface <link linkend="gdbus-interface-org-tizen-familynet-group.top_of_page">org.tizen.familynet.group</link>. See g_dbus_proxy_new_sync() for more details.
- *
- * The calling thread is blocked until a reply is received.
- *
- * See group_proxy_new() for the asynchronous version of this constructor.
- *
- * Returns: (transfer full) (type GroupProxy): The constructed proxy object or %NULL if @error is set.
- */
-Group *
-group_proxy_new_sync (
- GDBusConnection *connection,
- GDBusProxyFlags flags,
- const gchar *name,
- const gchar *object_path,
- GCancellable *cancellable,
- GError **error)
-{
- GInitable *ret;
- ret = g_initable_new (TYPE_GROUP_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-connection", connection, "g-object-path", object_path, "g-interface-name", "org.tizen.familynet.group", NULL);
- if (ret != NULL)
- return GROUP (ret);
- else
- return NULL;
-}
-
-
-/**
- * group_proxy_new_for_bus:
- * @bus_type: A #GBusType.
- * @flags: Flags from the #GDBusProxyFlags enumeration.
- * @name: A bus name (well-known or unique).
- * @object_path: An object path.
- * @cancellable: (allow-none): A #GCancellable or %NULL.
- * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
- * @user_data: User data to pass to @callback.
- *
- * Like group_proxy_new() but takes a #GBusType instead of a #GDBusConnection.
- *
- * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
- * You can then call group_proxy_new_for_bus_finish() to get the result of the operation.
- *
- * See group_proxy_new_for_bus_sync() for the synchronous, blocking version of this constructor.
- */
-void
-group_proxy_new_for_bus (
- GBusType bus_type,
- GDBusProxyFlags flags,
- const gchar *name,
- const gchar *object_path,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- g_async_initable_new_async (TYPE_GROUP_PROXY, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.tizen.familynet.group", NULL);
-}
-
-/**
- * group_proxy_new_for_bus_finish:
- * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to group_proxy_new_for_bus().
- * @error: Return location for error or %NULL
- *
- * Finishes an operation started with group_proxy_new_for_bus().
- *
- * Returns: (transfer full) (type GroupProxy): The constructed proxy object or %NULL if @error is set.
- */
-Group *
-group_proxy_new_for_bus_finish (
- GAsyncResult *res,
- GError **error)
-{
- GObject *ret;
- GObject *source_object;
- source_object = g_async_result_get_source_object (res);
- ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
- g_object_unref (source_object);
- if (ret != NULL)
- return GROUP (ret);
- else
- return NULL;
-}
-
-/**
- * group_proxy_new_for_bus_sync:
- * @bus_type: A #GBusType.
- * @flags: Flags from the #GDBusProxyFlags enumeration.
- * @name: A bus name (well-known or unique).
- * @object_path: An object path.
- * @cancellable: (allow-none): A #GCancellable or %NULL.
- * @error: Return location for error or %NULL
- *
- * Like group_proxy_new_sync() but takes a #GBusType instead of a #GDBusConnection.
- *
- * The calling thread is blocked until a reply is received.
- *
- * See group_proxy_new_for_bus() for the asynchronous version of this constructor.
- *
- * Returns: (transfer full) (type GroupProxy): The constructed proxy object or %NULL if @error is set.
- */
-Group *
-group_proxy_new_for_bus_sync (
- GBusType bus_type,
- GDBusProxyFlags flags,
- const gchar *name,
- const gchar *object_path,
- GCancellable *cancellable,
- GError **error)
-{
- GInitable *ret;
- ret = g_initable_new (TYPE_GROUP_PROXY, cancellable, error, "g-flags", flags, "g-name", name, "g-bus-type", bus_type, "g-object-path", object_path, "g-interface-name", "org.tizen.familynet.group", NULL);
- if (ret != NULL)
- return GROUP (ret);
- else
- return NULL;
-}
-
-
-/* ------------------------------------------------------------------------ */
-
-/**
- * GroupSkeleton:
- *
- * The #GroupSkeleton structure contains only private data and should only be accessed using the provided API.
- */
-
-/**
- * GroupSkeletonClass:
- * @parent_class: The parent class.
- *
- * Class structure for #GroupSkeleton.
- */
-
-struct _GroupSkeletonPrivate
-{
- GValue *properties;
- GList *changed_properties;
- GSource *changed_properties_idle_source;
- GMainContext *context;
- GMutex lock;
-};
-
-static void
-_group_skeleton_handle_method_call (
- GDBusConnection *connection G_GNUC_UNUSED,
- const gchar *sender G_GNUC_UNUSED,
- const gchar *object_path G_GNUC_UNUSED,
- const gchar *interface_name,
- const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
- GroupSkeleton *skeleton = GROUP_SKELETON (user_data);
- _ExtendedGDBusMethodInfo *info;
- GVariantIter iter;
- GVariant *child;
- GValue *paramv;
- guint num_params;
- guint num_extra;
- guint n;
- guint signal_id;
- GValue return_value = G_VALUE_INIT;
- info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);
- g_assert (info != NULL);
- num_params = g_variant_n_children (parameters);
- num_extra = info->pass_fdlist ? 3 : 2; paramv = g_new0 (GValue, num_params + num_extra);
- n = 0;
- g_value_init (¶mv[n], TYPE_GROUP);
- g_value_set_object (¶mv[n++], skeleton);
- g_value_init (¶mv[n], G_TYPE_DBUS_METHOD_INVOCATION);
- g_value_set_object (¶mv[n++], invocation);
- if (info->pass_fdlist)
- {
-#ifdef G_OS_UNIX
- g_value_init (¶mv[n], G_TYPE_UNIX_FD_LIST);
- g_value_set_object (¶mv[n++], g_dbus_message_get_unix_fd_list (g_dbus_method_invocation_get_message (invocation)));
-#else
- g_assert_not_reached ();
-#endif
- }
- g_variant_iter_init (&iter, parameters);
- while ((child = g_variant_iter_next_value (&iter)) != NULL)
- {
- _ExtendedGDBusArgInfo *arg_info = (_ExtendedGDBusArgInfo *) info->parent_struct.in_args[n - num_extra];
- if (arg_info->use_gvariant)
- {
- g_value_init (¶mv[n], G_TYPE_VARIANT);
- g_value_set_variant (¶mv[n], child);
- n++;
- }
- else
- g_dbus_gvariant_to_gvalue (child, ¶mv[n++]);
- g_variant_unref (child);
- }
- signal_id = g_signal_lookup (info->signal_name, TYPE_GROUP);
- g_value_init (&return_value, G_TYPE_BOOLEAN);
- g_signal_emitv (paramv, signal_id, 0, &return_value);
- if (!g_value_get_boolean (&return_value))
- g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD, "Method %s is not implemented on interface %s", method_name, interface_name);
- g_value_unset (&return_value);
- for (n = 0; n < num_params + num_extra; n++)
- g_value_unset (¶mv[n]);
- g_free (paramv);
-}
-
-static GVariant *
-_group_skeleton_handle_get_property (
- GDBusConnection *connection G_GNUC_UNUSED,
- const gchar *sender G_GNUC_UNUSED,
- const gchar *object_path G_GNUC_UNUSED,
- const gchar *interface_name G_GNUC_UNUSED,
- const gchar *property_name,
- GError **error,
- gpointer user_data)
-{
- GroupSkeleton *skeleton = GROUP_SKELETON (user_data);
- GValue value = G_VALUE_INIT;
- GParamSpec *pspec;
- _ExtendedGDBusPropertyInfo *info;
- GVariant *ret;
- ret = NULL;
- info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_group_interface_info.parent_struct, property_name);
- g_assert (info != NULL);
- pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
- if (pspec == NULL)
- {
- g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
- }
- else
- {
- g_value_init (&value, pspec->value_type);
- g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);
- ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));
- g_value_unset (&value);
- }
- return ret;
-}
-
-static gboolean
-_group_skeleton_handle_set_property (
- GDBusConnection *connection G_GNUC_UNUSED,
- const gchar *sender G_GNUC_UNUSED,
- const gchar *object_path G_GNUC_UNUSED,
- const gchar *interface_name G_GNUC_UNUSED,
- const gchar *property_name,
- GVariant *variant,
- GError **error,
- gpointer user_data)
-{
- GroupSkeleton *skeleton = GROUP_SKELETON (user_data);
- GValue value = G_VALUE_INIT;
- GParamSpec *pspec;
- _ExtendedGDBusPropertyInfo *info;
- gboolean ret;
- ret = FALSE;
- info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_group_interface_info.parent_struct, property_name);
- g_assert (info != NULL);
- pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);
- if (pspec == NULL)
- {
- g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %s", property_name);
- }
- else
- {
- if (info->use_gvariant)
- g_value_set_variant (&value, variant);
- else
- g_dbus_gvariant_to_gvalue (variant, &value);
- g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);
- g_value_unset (&value);
- ret = TRUE;
- }
- return ret;
-}
-
-static const GDBusInterfaceVTable _group_skeleton_vtable =
-{
- _group_skeleton_handle_method_call,
- _group_skeleton_handle_get_property,
- _group_skeleton_handle_set_property,
- {NULL}
-};
-
-static GDBusInterfaceInfo *
-group_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
-{
- return group_interface_info ();
-}
-
-static GDBusInterfaceVTable *
-group_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton G_GNUC_UNUSED)
-{
- return (GDBusInterfaceVTable *) &_group_skeleton_vtable;
-}
-
-static GVariant *
-group_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)
-{
- GroupSkeleton *skeleton = GROUP_SKELETON (_skeleton);
-
- GVariantBuilder builder;
- guint n;
- g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
- if (_group_interface_info.parent_struct.properties == NULL)
- goto out;
- for (n = 0; _group_interface_info.parent_struct.properties[n] != NULL; n++)
- {
- GDBusPropertyInfo *info = _group_interface_info.parent_struct.properties[n];
- if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)
- {
- GVariant *value;
- value = _group_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "org.tizen.familynet.group", info->name, NULL, skeleton);
- if (value != NULL)
- {
- g_variant_take_ref (value);
- g_variant_builder_add (&builder, "{sv}", info->name, value);
- g_variant_unref (value);
- }
- }
- }
-out:
- return g_variant_builder_end (&builder);
-}
-
-static void
-group_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)
-{
-}
-
-static void group_skeleton_iface_init (GroupIface *iface);
-#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
-G_DEFINE_TYPE_WITH_CODE (GroupSkeleton, group_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
- G_ADD_PRIVATE (GroupSkeleton)
- G_IMPLEMENT_INTERFACE (TYPE_GROUP, group_skeleton_iface_init));
-
-#else
-G_DEFINE_TYPE_WITH_CODE (GroupSkeleton, group_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
- G_IMPLEMENT_INTERFACE (TYPE_GROUP, group_skeleton_iface_init));
-
-#endif
-static void
-group_skeleton_finalize (GObject *object)
-{
- GroupSkeleton *skeleton = GROUP_SKELETON (object);
- g_list_free_full (skeleton->priv->changed_properties, (GDestroyNotify) _changed_property_free);
- if (skeleton->priv->changed_properties_idle_source != NULL)
- g_source_destroy (skeleton->priv->changed_properties_idle_source);
- g_main_context_unref (skeleton->priv->context);
- g_mutex_clear (&skeleton->priv->lock);
- G_OBJECT_CLASS (group_skeleton_parent_class)->finalize (object);
-}
-
-static void
-group_skeleton_init (GroupSkeleton *skeleton)
-{
-#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38
- skeleton->priv = group_skeleton_get_instance_private (skeleton);
-#else
- skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, TYPE_GROUP_SKELETON, GroupSkeletonPrivate);
-#endif
-
- g_mutex_init (&skeleton->priv->lock);
- skeleton->priv->context = g_main_context_ref_thread_default ();
-}
-
-static void
-group_skeleton_class_init (GroupSkeletonClass *klass)
-{
- GObjectClass *gobject_class;
- GDBusInterfaceSkeletonClass *skeleton_class;
-
- gobject_class = G_OBJECT_CLASS (klass);
- gobject_class->finalize = group_skeleton_finalize;
-
- skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);
- skeleton_class->get_info = group_skeleton_dbus_interface_get_info;
- skeleton_class->get_properties = group_skeleton_dbus_interface_get_properties;
- skeleton_class->flush = group_skeleton_dbus_interface_flush;
- skeleton_class->get_vtable = group_skeleton_dbus_interface_get_vtable;
-
-#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38
- g_type_class_add_private (klass, sizeof (GroupSkeletonPrivate));
-#endif
-}
-
-static void
-group_skeleton_iface_init (GroupIface *iface)
-{
-}
-
-/**
- * group_skeleton_new:
- *
- * Creates a skeleton object for the D-Bus interface <link linkend="gdbus-interface-org-tizen-familynet-group.top_of_page">org.tizen.familynet.group</link>.
- *
- * Returns: (transfer full) (type GroupSkeleton): The skeleton object.
- */
-Group *
-group_skeleton_new (void)
-{
- return GROUP (g_object_new (TYPE_GROUP_SKELETON, NULL));
-}
-
-/* ------------------------------------------------------------------------
- * Code for Object, ObjectProxy and ObjectSkeleton
- * ------------------------------------------------------------------------
- */
-
-/**
- * SECTION:Object
- * @title: Object
- * @short_description: Specialized GDBusObject types
- *
- * This section contains the #Object, #ObjectProxy, and #ObjectSkeleton types which make it easier to work with objects implementing generated types for D-Bus interfaces.
- */
-
-/**
- * Object:
- *
- * The #Object type is a specialized container of interfaces.
- */
-
-/**
- * ObjectIface:
- * @parent_iface: The parent interface.
- *
- * Virtual table for the #Object interface.
- */
-
-typedef ObjectIface ObjectInterface;
-G_DEFINE_INTERFACE_WITH_CODE (Object, object, G_TYPE_OBJECT, g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_DBUS_OBJECT));
-
-static void
-object_default_init (ObjectIface *iface)
-{
- /**
- * Object:group:
- *
- * The #Group instance corresponding to the D-Bus interface <link linkend="gdbus-interface-org-tizen-familynet-group.top_of_page">org.tizen.familynet.group</link>, if any.
- *
- * Connect to the #GObject::notify signal to get informed of property changes.
- */
- g_object_interface_install_property (iface, g_param_spec_object ("group", "group", "group", TYPE_GROUP, G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS));
-
-}
-
-/**
- * object_get_group:
- * @object: A #Object.
- *
- * Gets the #Group instance for the D-Bus interface <link linkend="gdbus-interface-org-tizen-familynet-group.top_of_page">org.tizen.familynet.group</link> on @object, if any.
- *
- * Returns: (transfer full): A #Group that must be freed with g_object_unref() or %NULL if @object does not implement the interface.
- */
-Group *object_get_group (Object *object)
-{
- GDBusInterface *ret;
- ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.tizen.familynet.group");
- if (ret == NULL)
- return NULL;
- return GROUP (ret);
-}
-
-
-/**
- * object_peek_group: (skip)
- * @object: A #Object.
- *
- * Like object_get_group() but doesn't increase the reference count on the returned object.
- *
- * <warning>It is not safe to use the returned object if you are on another thread than the one where the #GDBusObjectManagerClient or #GDBusObjectManagerServer for @object is running.</warning>
- *
- * Returns: (transfer none): A #Group or %NULL if @object does not implement the interface. Do not free the returned object, it is owned by @object.
- */
-Group *object_peek_group (Object *object)
-{
- GDBusInterface *ret;
- ret = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.tizen.familynet.group");
- if (ret == NULL)
- return NULL;
- g_object_unref (ret);
- return GROUP (ret);
-}
-
-
-static void
-object_notify (GDBusObject *object, GDBusInterface *interface)
-{
- _ExtendedGDBusInterfaceInfo *info = (_ExtendedGDBusInterfaceInfo *) g_dbus_interface_get_info (interface);
- /* info can be NULL if the other end is using a D-Bus interface we don't know
- * anything about, for example old generated code in this process talking to
- * newer generated code in the other process. */
- if (info != NULL)
- g_object_notify (G_OBJECT (object), info->hyphen_name);
-}
-
-/**
- * ObjectProxy:
- *
- * The #ObjectProxy structure contains only private data and should only be accessed using the provided API.
- */
-
-/**
- * ObjectProxyClass:
- * @parent_class: The parent class.
- *
- * Class structure for #ObjectProxy.
- */
-
-static void
-object_proxy__object_iface_init (ObjectIface *iface G_GNUC_UNUSED)
-{
-}
-
-static void
-object_proxy__g_dbus_object_iface_init (GDBusObjectIface *iface)
-{
- iface->interface_added = object_notify;
- iface->interface_removed = object_notify;
-}
-
-
-G_DEFINE_TYPE_WITH_CODE (ObjectProxy, object_proxy, G_TYPE_DBUS_OBJECT_PROXY,
- G_IMPLEMENT_INTERFACE (TYPE_OBJECT, object_proxy__object_iface_init)
- G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, object_proxy__g_dbus_object_iface_init));
-
-static void
-object_proxy_init (ObjectProxy *object G_GNUC_UNUSED)
-{
-}
-
-static void
-object_proxy_set_property (GObject *gobject,
- guint prop_id,
- const GValue *value G_GNUC_UNUSED,
- GParamSpec *pspec)
-{
- G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
-}
-
-static void
-object_proxy_get_property (GObject *gobject,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- ObjectProxy *object = OBJECT_PROXY (gobject);
- GDBusInterface *interface;
-
- switch (prop_id)
- {
- case 1:
- interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.tizen.familynet.group");
- g_value_take_object (value, interface);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
- break;
- }
-}
-
-static void
-object_proxy_class_init (ObjectProxyClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->set_property = object_proxy_set_property;
- gobject_class->get_property = object_proxy_get_property;
-
- g_object_class_override_property (gobject_class, 1, "group");
-}
-
-/**
- * object_proxy_new:
- * @connection: A #GDBusConnection.
- * @object_path: An object path.
- *
- * Creates a new proxy object.
- *
- * Returns: (transfer full): The proxy object.
- */
-ObjectProxy *
-object_proxy_new (GDBusConnection *connection,
- const gchar *object_path)
-{
- g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
- g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
- return OBJECT_PROXY (g_object_new (TYPE_OBJECT_PROXY, "g-connection", connection, "g-object-path", object_path, NULL));
-}
-
-/**
- * ObjectSkeleton:
- *
- * The #ObjectSkeleton structure contains only private data and should only be accessed using the provided API.
- */
-
-/**
- * ObjectSkeletonClass:
- * @parent_class: The parent class.
- *
- * Class structure for #ObjectSkeleton.
- */
-
-static void
-object_skeleton__object_iface_init (ObjectIface *iface G_GNUC_UNUSED)
-{
-}
-
-
-static void
-object_skeleton__g_dbus_object_iface_init (GDBusObjectIface *iface)
-{
- iface->interface_added = object_notify;
- iface->interface_removed = object_notify;
-}
-
-G_DEFINE_TYPE_WITH_CODE (ObjectSkeleton, object_skeleton, G_TYPE_DBUS_OBJECT_SKELETON,
- G_IMPLEMENT_INTERFACE (TYPE_OBJECT, object_skeleton__object_iface_init)
- G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, object_skeleton__g_dbus_object_iface_init));
-
-static void
-object_skeleton_init (ObjectSkeleton *object G_GNUC_UNUSED)
-{
-}
-
-static void
-object_skeleton_set_property (GObject *gobject,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- ObjectSkeleton *object = OBJECT_SKELETON (gobject);
- GDBusInterfaceSkeleton *interface;
-
- switch (prop_id)
- {
- case 1:
- interface = g_value_get_object (value);
- if (interface != NULL)
- {
- g_warn_if_fail (IS_GROUP (interface));
- g_dbus_object_skeleton_add_interface (G_DBUS_OBJECT_SKELETON (object), interface);
- }
- else
- {
- g_dbus_object_skeleton_remove_interface_by_name (G_DBUS_OBJECT_SKELETON (object), "org.tizen.familynet.group");
- }
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
- break;
- }
-}
-
-static void
-object_skeleton_get_property (GObject *gobject,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- ObjectSkeleton *object = OBJECT_SKELETON (gobject);
- GDBusInterface *interface;
-
- switch (prop_id)
- {
- case 1:
- interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.tizen.familynet.group");
- g_value_take_object (value, interface);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
- break;
- }
-}
-
-static void
-object_skeleton_class_init (ObjectSkeletonClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- gobject_class->set_property = object_skeleton_set_property;
- gobject_class->get_property = object_skeleton_get_property;
-
- g_object_class_override_property (gobject_class, 1, "group");
-}
-
-/**
- * object_skeleton_new:
- * @object_path: An object path.
- *
- * Creates a new skeleton object.
- *
- * Returns: (transfer full): The skeleton object.
- */
-ObjectSkeleton *
-object_skeleton_new (const gchar *object_path)
-{
- g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
- return OBJECT_SKELETON (g_object_new (TYPE_OBJECT_SKELETON, "g-object-path", object_path, NULL));
-}
-
-/**
- * object_skeleton_set_group:
- * @object: A #ObjectSkeleton.
- * @interface_: (allow-none): A #Group or %NULL to clear the interface.
- *
- * Sets the #Group instance for the D-Bus interface <link linkend="gdbus-interface-org-tizen-familynet-group.top_of_page">org.tizen.familynet.group</link> on @object.
- */
-void object_skeleton_set_group (ObjectSkeleton *object, Group *interface_)
-{
- g_object_set (G_OBJECT (object), "group", interface_, NULL);
-}
-
-
-/* ------------------------------------------------------------------------
- * Code for ObjectManager client
- * ------------------------------------------------------------------------
- */
-
-/**
- * SECTION:ObjectManagerClient
- * @title: ObjectManagerClient
- * @short_description: Generated GDBusObjectManagerClient type
- *
- * This section contains a #GDBusObjectManagerClient that uses object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc.
- */
-
-/**
- * ObjectManagerClient:
- *
- * The #ObjectManagerClient structure contains only private data and should only be accessed using the provided API.
- */
-
-/**
- * ObjectManagerClientClass:
- * @parent_class: The parent class.
- *
- * Class structure for #ObjectManagerClient.
- */
-
-G_DEFINE_TYPE (ObjectManagerClient, object_manager_client, G_TYPE_DBUS_OBJECT_MANAGER_CLIENT);
-
-static void
-object_manager_client_init (ObjectManagerClient *manager G_GNUC_UNUSED)
-{
-}
-
-static void
-object_manager_client_class_init (ObjectManagerClientClass *klass G_GNUC_UNUSED)
-{
-}
-
-/**
- * object_manager_client_get_proxy_type:
- * @manager: A #GDBusObjectManagerClient.
- * @object_path: The object path of the remote object (unused).
- * @interface_name: (allow-none): Interface name of the remote object or %NULL to get the object proxy #GType.
- * @user_data: User data (unused).
- *
- * A #GDBusProxyTypeFunc that maps @interface_name to the generated #GDBusObjectProxy<!-- -->- and #GDBusProxy<!-- -->-derived types.
- *
- * Returns: A #GDBusProxy<!-- -->-derived #GType if @interface_name is not %NULL, otherwise the #GType for #ObjectProxy.
- */
-GType
-object_manager_client_get_proxy_type (GDBusObjectManagerClient *manager G_GNUC_UNUSED, const gchar *object_path G_GNUC_UNUSED, const gchar *interface_name, gpointer user_data G_GNUC_UNUSED)
-{
- static gsize once_init_value = 0;
- static GHashTable *lookup_hash;
- GType ret;
-
- if (interface_name == NULL)
- return TYPE_OBJECT_PROXY;
- if (g_once_init_enter (&once_init_value))
- {
- lookup_hash = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_insert (lookup_hash, (gpointer) "org.tizen.familynet.group", GSIZE_TO_POINTER (TYPE_GROUP_PROXY));
- g_once_init_leave (&once_init_value, 1);
- }
- ret = (GType) GPOINTER_TO_SIZE (g_hash_table_lookup (lookup_hash, interface_name));
- if (ret == (GType) 0)
- ret = G_TYPE_DBUS_PROXY;
- return ret;
-}
-
-/**
- * object_manager_client_new:
- * @connection: A #GDBusConnection.
- * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
- * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
- * @object_path: An object path.
- * @cancellable: (allow-none): A #GCancellable or %NULL.
- * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
- * @user_data: User data to pass to @callback.
- *
- * Asynchronously creates #GDBusObjectManagerClient using object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new() for more details.
- *
- * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
- * You can then call object_manager_client_new_finish() to get the result of the operation.
- *
- * See object_manager_client_new_sync() for the synchronous, blocking version of this constructor.
- */
-void
-object_manager_client_new (
- GDBusConnection *connection,
- GDBusObjectManagerClientFlags flags,
- const gchar *name,
- const gchar *object_path,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- g_async_initable_new_async (TYPE_OBJECT_MANAGER_CLIENT, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "flags", flags, "name", name, "connection", connection, "object-path", object_path, "get-proxy-type-func", object_manager_client_get_proxy_type, NULL);
-}
-
-/**
- * object_manager_client_new_finish:
- * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to object_manager_client_new().
- * @error: Return location for error or %NULL
- *
- * Finishes an operation started with object_manager_client_new().
- *
- * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
- */
-GDBusObjectManager *
-object_manager_client_new_finish (
- GAsyncResult *res,
- GError **error)
-{
- GObject *ret;
- GObject *source_object;
- source_object = g_async_result_get_source_object (res);
- ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
- g_object_unref (source_object);
- if (ret != NULL)
- return G_DBUS_OBJECT_MANAGER (ret);
- else
- return NULL;
-}
-
-/**
- * object_manager_client_new_sync:
- * @connection: A #GDBusConnection.
- * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
- * @name: (allow-none): A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.
- * @object_path: An object path.
- * @cancellable: (allow-none): A #GCancellable or %NULL.
- * @error: Return location for error or %NULL
- *
- * Synchronously creates #GDBusObjectManagerClient using object_manager_client_get_proxy_type() as the #GDBusProxyTypeFunc. See g_dbus_object_manager_client_new_sync() for more details.
- *
- * The calling thread is blocked until a reply is received.
- *
- * See object_manager_client_new() for the asynchronous version of this constructor.
- *
- * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
- */
-GDBusObjectManager *
-object_manager_client_new_sync (
- GDBusConnection *connection,
- GDBusObjectManagerClientFlags flags,
- const gchar *name,
- const gchar *object_path,
- GCancellable *cancellable,
- GError **error)
-{
- GInitable *ret;
- ret = g_initable_new (TYPE_OBJECT_MANAGER_CLIENT, cancellable, error, "flags", flags, "name", name, "connection", connection, "object-path", object_path, "get-proxy-type-func", object_manager_client_get_proxy_type, NULL);
- if (ret != NULL)
- return G_DBUS_OBJECT_MANAGER (ret);
- else
- return NULL;
-}
-
-
-/**
- * object_manager_client_new_for_bus:
- * @bus_type: A #GBusType.
- * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
- * @name: A bus name (well-known or unique).
- * @object_path: An object path.
- * @cancellable: (allow-none): A #GCancellable or %NULL.
- * @callback: A #GAsyncReadyCallback to call when the request is satisfied.
- * @user_data: User data to pass to @callback.
- *
- * Like object_manager_client_new() but takes a #GBusType instead of a #GDBusConnection.
- *
- * When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
- * You can then call object_manager_client_new_for_bus_finish() to get the result of the operation.
- *
- * See object_manager_client_new_for_bus_sync() for the synchronous, blocking version of this constructor.
- */
-void
-object_manager_client_new_for_bus (
- GBusType bus_type,
- GDBusObjectManagerClientFlags flags,
- const gchar *name,
- const gchar *object_path,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
-{
- g_async_initable_new_async (TYPE_OBJECT_MANAGER_CLIENT, G_PRIORITY_DEFAULT, cancellable, callback, user_data, "flags", flags, "name", name, "bus-type", bus_type, "object-path", object_path, "get-proxy-type-func", object_manager_client_get_proxy_type, NULL);
-}
-
-/**
- * object_manager_client_new_for_bus_finish:
- * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to object_manager_client_new_for_bus().
- * @error: Return location for error or %NULL
- *
- * Finishes an operation started with object_manager_client_new_for_bus().
- *
- * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
- */
-GDBusObjectManager *
-object_manager_client_new_for_bus_finish (
- GAsyncResult *res,
- GError **error)
-{
- GObject *ret;
- GObject *source_object;
- source_object = g_async_result_get_source_object (res);
- ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error);
- g_object_unref (source_object);
- if (ret != NULL)
- return G_DBUS_OBJECT_MANAGER (ret);
- else
- return NULL;
-}
-
-/**
- * object_manager_client_new_for_bus_sync:
- * @bus_type: A #GBusType.
- * @flags: Flags from the #GDBusObjectManagerClientFlags enumeration.
- * @name: A bus name (well-known or unique).
- * @object_path: An object path.
- * @cancellable: (allow-none): A #GCancellable or %NULL.
- * @error: Return location for error or %NULL
- *
- * Like object_manager_client_new_sync() but takes a #GBusType instead of a #GDBusConnection.
- *
- * The calling thread is blocked until a reply is received.
- *
- * See object_manager_client_new_for_bus() for the asynchronous version of this constructor.
- *
- * Returns: (transfer full) (type ObjectManagerClient): The constructed object manager client or %NULL if @error is set.
- */
-GDBusObjectManager *
-object_manager_client_new_for_bus_sync (
- GBusType bus_type,
- GDBusObjectManagerClientFlags flags,
- const gchar *name,
- const gchar *object_path,
- GCancellable *cancellable,
- GError **error)
-{
- GInitable *ret;
- ret = g_initable_new (TYPE_OBJECT_MANAGER_CLIENT, cancellable, error, "flags", flags, "name", name, "bus-type", bus_type, "object-path", object_path, "get-proxy-type-func", object_manager_client_get_proxy_type, NULL);
- if (ret != NULL)
- return G_DBUS_OBJECT_MANAGER (ret);
- else
- return NULL;
-}
-
-
+++ /dev/null
-/*
- * Generated by gdbus-codegen 2.40.2. DO NOT EDIT.
- *
- * The license of this code is the same as for the source it was derived from.
- */
-
-#ifndef __FAMILYNET_GDBUS_H__
-#define __FAMILYNET_GDBUS_H__
-
-#include <gio/gio.h>
-
-G_BEGIN_DECLS
-
-
-/* ------------------------------------------------------------------------ */
-/* Declarations for org.tizen.familynet.group */
-
-#define TYPE_GROUP (group_get_type ())
-#define GROUP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_GROUP, Group))
-#define IS_GROUP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_GROUP))
-#define GROUP_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), TYPE_GROUP, GroupIface))
-
-struct _Group;
-typedef struct _Group Group;
-typedef struct _GroupIface GroupIface;
-
-struct _GroupIface
-{
- GTypeInterface parent_iface;
-
- gboolean (*handle_create) (
- Group *object,
- GDBusMethodInvocation *invocation,
- const gchar *arg_group_name);
-
- gboolean (*handle_find) (
- Group *object,
- GDBusMethodInvocation *invocation);
-
-};
-
-GType group_get_type (void) G_GNUC_CONST;
-
-GDBusInterfaceInfo *group_interface_info (void);
-guint group_override_properties (GObjectClass *klass, guint property_id_begin);
-
-
-/* D-Bus method call completion functions: */
-void group_complete_create (
- Group *object,
- GDBusMethodInvocation *invocation,
- gint result);
-
-void group_complete_find (
- Group *object,
- GDBusMethodInvocation *invocation,
- gint group_count,
- GVariant *groups,
- gint result);
-
-
-
-/* D-Bus method calls: */
-void group_call_create (
- Group *proxy,
- const gchar *arg_group_name,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-
-gboolean group_call_create_finish (
- Group *proxy,
- gint *out_result,
- GAsyncResult *res,
- GError **error);
-
-gboolean group_call_create_sync (
- Group *proxy,
- const gchar *arg_group_name,
- gint *out_result,
- GCancellable *cancellable,
- GError **error);
-
-void group_call_find (
- Group *proxy,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-
-gboolean group_call_find_finish (
- Group *proxy,
- gint *out_group_count,
- GVariant **out_groups,
- gint *out_result,
- GAsyncResult *res,
- GError **error);
-
-gboolean group_call_find_sync (
- Group *proxy,
- gint *out_group_count,
- GVariant **out_groups,
- gint *out_result,
- GCancellable *cancellable,
- GError **error);
-
-
-
-/* ---- */
-
-#define TYPE_GROUP_PROXY (group_proxy_get_type ())
-#define GROUP_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_GROUP_PROXY, GroupProxy))
-#define GROUP_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_GROUP_PROXY, GroupProxyClass))
-#define GROUP_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_GROUP_PROXY, GroupProxyClass))
-#define IS_GROUP_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_GROUP_PROXY))
-#define IS_GROUP_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_GROUP_PROXY))
-
-typedef struct _GroupProxy GroupProxy;
-typedef struct _GroupProxyClass GroupProxyClass;
-typedef struct _GroupProxyPrivate GroupProxyPrivate;
-
-struct _GroupProxy
-{
- /*< private >*/
- GDBusProxy parent_instance;
- GroupProxyPrivate *priv;
-};
-
-struct _GroupProxyClass
-{
- GDBusProxyClass parent_class;
-};
-
-GType group_proxy_get_type (void) G_GNUC_CONST;
-
-void group_proxy_new (
- GDBusConnection *connection,
- GDBusProxyFlags flags,
- const gchar *name,
- const gchar *object_path,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-Group *group_proxy_new_finish (
- GAsyncResult *res,
- GError **error);
-Group *group_proxy_new_sync (
- GDBusConnection *connection,
- GDBusProxyFlags flags,
- const gchar *name,
- const gchar *object_path,
- GCancellable *cancellable,
- GError **error);
-
-void group_proxy_new_for_bus (
- GBusType bus_type,
- GDBusProxyFlags flags,
- const gchar *name,
- const gchar *object_path,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-Group *group_proxy_new_for_bus_finish (
- GAsyncResult *res,
- GError **error);
-Group *group_proxy_new_for_bus_sync (
- GBusType bus_type,
- GDBusProxyFlags flags,
- const gchar *name,
- const gchar *object_path,
- GCancellable *cancellable,
- GError **error);
-
-
-/* ---- */
-
-#define TYPE_GROUP_SKELETON (group_skeleton_get_type ())
-#define GROUP_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_GROUP_SKELETON, GroupSkeleton))
-#define GROUP_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_GROUP_SKELETON, GroupSkeletonClass))
-#define GROUP_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_GROUP_SKELETON, GroupSkeletonClass))
-#define IS_GROUP_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_GROUP_SKELETON))
-#define IS_GROUP_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_GROUP_SKELETON))
-
-typedef struct _GroupSkeleton GroupSkeleton;
-typedef struct _GroupSkeletonClass GroupSkeletonClass;
-typedef struct _GroupSkeletonPrivate GroupSkeletonPrivate;
-
-struct _GroupSkeleton
-{
- /*< private >*/
- GDBusInterfaceSkeleton parent_instance;
- GroupSkeletonPrivate *priv;
-};
-
-struct _GroupSkeletonClass
-{
- GDBusInterfaceSkeletonClass parent_class;
-};
-
-GType group_skeleton_get_type (void) G_GNUC_CONST;
-
-Group *group_skeleton_new (void);
-
-
-/* ---- */
-
-#define TYPE_OBJECT (object_get_type ())
-#define OBJECT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_OBJECT, Object))
-#define IS_OBJECT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_OBJECT))
-#define OBJECT_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), TYPE_OBJECT, Object))
-
-struct _Object;
-typedef struct _Object Object;
-typedef struct _ObjectIface ObjectIface;
-
-struct _ObjectIface
-{
- GTypeInterface parent_iface;
-};
-
-GType object_get_type (void) G_GNUC_CONST;
-
-Group *object_get_group (Object *object);
-Group *object_peek_group (Object *object);
-
-#define TYPE_OBJECT_PROXY (object_proxy_get_type ())
-#define OBJECT_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_OBJECT_PROXY, ObjectProxy))
-#define OBJECT_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_OBJECT_PROXY, ObjectProxyClass))
-#define OBJECT_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_OBJECT_PROXY, ObjectProxyClass))
-#define IS_OBJECT_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_OBJECT_PROXY))
-#define IS_OBJECT_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_OBJECT_PROXY))
-
-typedef struct _ObjectProxy ObjectProxy;
-typedef struct _ObjectProxyClass ObjectProxyClass;
-typedef struct _ObjectProxyPrivate ObjectProxyPrivate;
-
-struct _ObjectProxy
-{
- /*< private >*/
- GDBusObjectProxy parent_instance;
- ObjectProxyPrivate *priv;
-};
-
-struct _ObjectProxyClass
-{
- GDBusObjectProxyClass parent_class;
-};
-
-GType object_proxy_get_type (void) G_GNUC_CONST;
-ObjectProxy *object_proxy_new (GDBusConnection *connection, const gchar *object_path);
-
-#define TYPE_OBJECT_SKELETON (object_skeleton_get_type ())
-#define OBJECT_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_OBJECT_SKELETON, ObjectSkeleton))
-#define OBJECT_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_OBJECT_SKELETON, ObjectSkeletonClass))
-#define OBJECT_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_OBJECT_SKELETON, ObjectSkeletonClass))
-#define IS_OBJECT_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_OBJECT_SKELETON))
-#define IS_OBJECT_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_OBJECT_SKELETON))
-
-typedef struct _ObjectSkeleton ObjectSkeleton;
-typedef struct _ObjectSkeletonClass ObjectSkeletonClass;
-typedef struct _ObjectSkeletonPrivate ObjectSkeletonPrivate;
-
-struct _ObjectSkeleton
-{
- /*< private >*/
- GDBusObjectSkeleton parent_instance;
- ObjectSkeletonPrivate *priv;
-};
-
-struct _ObjectSkeletonClass
-{
- GDBusObjectSkeletonClass parent_class;
-};
-
-GType object_skeleton_get_type (void) G_GNUC_CONST;
-ObjectSkeleton *object_skeleton_new (const gchar *object_path);
-void object_skeleton_set_group (ObjectSkeleton *object, Group *interface_);
-
-/* ---- */
-
-#define TYPE_OBJECT_MANAGER_CLIENT (object_manager_client_get_type ())
-#define OBJECT_MANAGER_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_OBJECT_MANAGER_CLIENT, ObjectManagerClient))
-#define OBJECT_MANAGER_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TYPE_OBJECT_MANAGER_CLIENT, ObjectManagerClientClass))
-#define OBJECT_MANAGER_CLIENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_OBJECT_MANAGER_CLIENT, ObjectManagerClientClass))
-#define IS_OBJECT_MANAGER_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_OBJECT_MANAGER_CLIENT))
-#define IS_OBJECT_MANAGER_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_OBJECT_MANAGER_CLIENT))
-
-typedef struct _ObjectManagerClient ObjectManagerClient;
-typedef struct _ObjectManagerClientClass ObjectManagerClientClass;
-typedef struct _ObjectManagerClientPrivate ObjectManagerClientPrivate;
-
-struct _ObjectManagerClient
-{
- /*< private >*/
- GDBusObjectManagerClient parent_instance;
- ObjectManagerClientPrivate *priv;
-};
-
-struct _ObjectManagerClientClass
-{
- GDBusObjectManagerClientClass parent_class;
-};
-
-GType object_manager_client_get_type (void) G_GNUC_CONST;
-
-GType object_manager_client_get_proxy_type (GDBusObjectManagerClient *manager, const gchar *object_path, const gchar *interface_name, gpointer user_data);
-
-void object_manager_client_new (
- GDBusConnection *connection,
- GDBusObjectManagerClientFlags flags,
- const gchar *name,
- const gchar *object_path,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-GDBusObjectManager *object_manager_client_new_finish (
- GAsyncResult *res,
- GError **error);
-GDBusObjectManager *object_manager_client_new_sync (
- GDBusConnection *connection,
- GDBusObjectManagerClientFlags flags,
- const gchar *name,
- const gchar *object_path,
- GCancellable *cancellable,
- GError **error);
-
-void object_manager_client_new_for_bus (
- GBusType bus_type,
- GDBusObjectManagerClientFlags flags,
- const gchar *name,
- const gchar *object_path,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-GDBusObjectManager *object_manager_client_new_for_bus_finish (
- GAsyncResult *res,
- GError **error);
-GDBusObjectManager *object_manager_client_new_for_bus_sync (
- GBusType bus_type,
- GDBusObjectManagerClientFlags flags,
- const gchar *name,
- const gchar *object_path,
- GCancellable *cancellable,
- GError **error);
-
-
-G_END_DECLS
-
-#endif /* __FAMILYNET_GDBUS_H__ */
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<!DOCTYPE node PUBLIC
- "-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
- "http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
-
-<node>
- <interface name="org.tizen.familynet.group">
- <!-- Method definitions -->
- <method name="Create">
- <arg type="s" name="group_name" direction="in"/>
- <arg type="i" name="result" direction="out"/>
- </method>
- <method name="Find">
- <arg type="i" name="timeout" direction="in" />
- <arg type="i" name="result" direction="out" />
- </method>
- <method name="GetFoundGroups">
- <arg type="i" name="result" direction="out" />
- <arg type="aa{sv}" name="groups" direction="out" />
- </method>
- <method name="Join">
- <arg type="i" name="group_count" direction="out" />
- <arg type="aa{sv}" name="groups" direction="out" />
- <arg type="i" name="result" direction="out" />
- </method>
- <method name="Leave">
- <arg type="i" name="group_count" direction="out" />
- <arg type="aa{sv}" name="groups" direction="out" />
- <arg type="i" name="result" direction="out" />
- </method>
- <method name="Delete">
- <arg type="i" name="group_count" direction="out" />
- <arg type="aa{sv}" name="groups" direction="out" />
- <arg type="i" name="result" direction="out" />
- </method>
- <method name="DeviceFind">
- <arg type="i" name="group_count" direction="out" />
- <arg type="aa{sv}" name="groups" direction="out" />
- <arg type="i" name="result" direction="out" />
- </method>
- <method name="DeviceInvite">
- <arg type="i" name="group_count" direction="out" />
- <arg type="aa{sv}" name="groups" direction="out" />
- <arg type="i" name="result" direction="out" />
- </method>
- <method name="DeviceEject">
- <arg type="i" name="group_count" direction="out" />
- <arg type="aa{sv}" name="groups" direction="out" />
- <arg type="i" name="result" direction="out" />
- </method>
-
- <!-- Signal (D-Bus) definitions -->
- <signal name="GroupFound">
- <arg type="a{sv}" name="group_info" direction="out" />
- </signal>
- <signal name="Finish">
- <arg type="i" name="result" direction="out" />
- </signal>
- </interface>
-</node>
-gdbus-codegen --interface-prefix org.tizen.familynet \
- --generate-c-code familynet_gdbus \
+gdbus-codegen --interface-prefix org.tizen.companion \
+ --generate-c-code companion_gdbus \
--c-generate-object-manager \
- familynet_gdbus.xml \
+ companion_gdbus.xml \
-SET(FN_UNIT_TEST "familynet_unit_test")
+SET(COMP_UNIT_TEST "companion_unit_test")
-SET(FN_UNIT_TEST_SOURCES
- familynet_unit_test.cpp
+SET(COMP_UNIT_TEST_SOURCES
+ companion_unit_test.cpp
)
-ADD_EXECUTABLE(${FN_UNIT_TEST} ${FN_UNIT_TEST_SOURCES})
+ADD_EXECUTABLE(${COMP_UNIT_TEST} ${COMP_UNIT_TEST_SOURCES})
-TARGET_LINK_LIBRARIES(${FN_UNIT_TEST}
- ${daemon_pkgs_LIBRARIES} capi-network-familynet)
+TARGET_LINK_LIBRARIES(${COMP_UNIT_TEST}
+ ${daemon_pkgs_LIBRARIES} capi-network-companion)
-INSTALL(TARGETS ${FN_UNIT_TEST} DESTINATION bin/)
+INSTALL(TARGETS ${COMP_UNIT_TEST} DESTINATION bin/)
--- /dev/null
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <unistd.h>
+#include <glib.h>
+#include <dlog.h>
+#include <companion.h>
+#include <iostream>
+
+using namespace std;
+
+using ::testing::EmptyTestEventListener;
+using ::testing::InitGoogleTest;
+using ::testing::Test;
+using ::testing::TestCase;
+using ::testing::TestEventListeners;
+using ::testing::TestInfo;
+using ::testing::TestPartResult;
+using ::testing::UnitTest;
+
+TEST(companion, companion_initialize_p) {
+
+}
+
+TEST(companion, companion_initialize_n) {
+
+}
+
+TEST(companion, companion_deinitialize_p) {
+
+}
+
+TEST(companion, companion_deinitialize_n) {
+
+}
+
+TEST(companion, companion_group_create_p) {
+ cout << "TEST START" << endl;
+
+ int ret;
+
+ companion_initialize();
+ ret = companion_group_create("group1");
+
+ cout << "TEST END :" << ret << endl;
+}
+
+GMainLoop *main_loop = NULL;
+
+bool _companion_group_found_cb(companion_group_type_e type, companion_group_h group_handle, void *user_data)
+{
+ char *uri_path;
+ companion_group_information_get_uri_path(group_handle, &uri_path);
+
+ cout << "group type : " << type << ", uri : " << uri_path << endl;
+
+ return true;
+}
+
+void _companion_finish_cb(int result, void *user_data)
+{
+ cout << "find finish : " << result << endl;
+ g_main_loop_quit(main_loop);
+
+ companion_group_h *groups;
+ int count;
+
+ companion_group_get_found_groups(&groups, &count);
+ cout << "Found groups device count : " << count << endl;
+
+ for (int i = 0; i < count; i++) {
+ companion_group_type_e type;
+ char *uri_path;
+ companion_group_information_get_type(groups[i], &type);
+ companion_group_information_get_uri_path(groups[i], &uri_path);
+ cout << i+1 << ". device group type : " << type << ", uri_path : " << uri_path << endl;
+ }
+}
+
+TEST(companion, companion_group_find_p) {
+ cout << "TEST START" << endl;
+ companion_initialize();
+ main_loop = g_main_loop_new(NULL, FALSE);
+ companion_group_find(5, _companion_group_found_cb, _companion_finish_cb, main_loop);
+ g_main_loop_run(main_loop);
+ cout << "TEST END" << endl;
+}
+
+int main(int argc, char **argv) {
+ InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
+++ /dev/null
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-#include <unistd.h>
-#include <glib.h>
-#include <dlog.h>
-#include <familynet.h>
-#include <iostream>
-
-using namespace std;
-
-using ::testing::EmptyTestEventListener;
-using ::testing::InitGoogleTest;
-using ::testing::Test;
-using ::testing::TestCase;
-using ::testing::TestEventListeners;
-using ::testing::TestInfo;
-using ::testing::TestPartResult;
-using ::testing::UnitTest;
-
-TEST(familynet, familynet_initialize_p) {
-
-}
-
-TEST(familynet, familynet_initialize_n) {
-
-}
-
-TEST(familynet, familynet_deinitialize_p) {
-
-}
-
-TEST(familynet, familynet_deinitialize_n) {
-
-}
-
-TEST(familynet, familynet_group_create_p) {
- cout << "TEST START" << endl;
-
- int ret;
-
- familynet_initialize();
- ret = familynet_group_create("group1");
-
- cout << "TEST END :" << ret << endl;
-}
-
-GMainLoop *main_loop = NULL;
-
-bool _familynet_group_found_cb(familynet_group_type_e type, familynet_group_h group_handle, void *user_data)
-{
- char *uri_path;
- familynet_group_information_get_uri_path(group_handle, &uri_path);
-
- cout << "group type : " << type << ", uri : " << uri_path << endl;
-
- return true;
-}
-
-void _familynet_finish_cb(int result, void *user_data)
-{
- cout << "find finish : " << result << endl;
- g_main_loop_quit(main_loop);
-
- familynet_group_h *groups;
- int count;
-
- familynet_group_get_found_groups(&groups, &count);
- cout << "Found groups device count : " << count << endl;
-
- for (int i = 0; i < count; i++) {
- familynet_group_type_e type;
- char *uri_path;
- familynet_group_information_get_type(groups[i], &type);
- familynet_group_information_get_uri_path(groups[i], &uri_path);
- cout << i+1 << ". device group type : " << type << ", uri_path : " << uri_path << endl;
- }
-}
-
-TEST(familynet, familynet_group_find_p) {
- cout << "TEST START" << endl;
- familynet_initialize();
- main_loop = g_main_loop_new(NULL, FALSE);
- familynet_group_find(5, _familynet_group_found_cb, _familynet_finish_cb, main_loop);
- g_main_loop_run(main_loop);
- cout << "TEST END" << endl;
-}
-
-int main(int argc, char **argv) {
- InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
+++ /dev/null
-<manifest>
- <request>
- <domain name="_" />
- </request>
-</manifest>
Source7: net.fnm.service
Source8: d2ds.service
Source9: net.d2ds.service
-Source10: capi-network-familynet.manifest
+Source10: capi-network-companion.manifest
BuildRequires: cmake
BuildRequires: pkgconfig(iotivity)
%defattr(-,root,root,-)
%{_bindir}/%{name}
%{_bindir}/d2d-subowner
-%{_bindir}/fn-manager
+%{_bindir}/companion-manager
%attr(644,root,root) %{_datadir}/dbus-1/system-services/*
%attr(644,root,root) %{_unitdir}/d2dm.service
%attr(644,root,root) %{_unitdir}/fnm.service
%attr(750,network_fw,network_fw) %{_sbindir}/subownerclient
%files capi
-%manifest capi-network-familynet.manifest
+%manifest capi-network-companion.manifest
%defattr(-,root,root,-)
-%{_libdir}/libcapi-network-familynet.so*
+%{_libdir}/libcapi-network-companion.so*
%files capi-devel
%{_includedir}/*.h
%{_libdir}/pkgconfig/*.pc
-%{_libdir}/libcapi-network-familynet.so
-%attr(777,root,root) %{_bindir}/familynet_unit_test
+%{_libdir}/libcapi-network-companion.so
+%attr(777,root,root) %{_bindir}/companion_unit_test
%attr(777,root,root) %{_bindir}/companion_demo
--- /dev/null
+MESSAGE("===================================================================")
+MESSAGE("Building...companion-manager")
+MESSAGE("===================================================================")
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
+EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
+ " \\
+ --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/src/companion_gdbus \\
+ --interface-prefix org.tizen.companion. \\
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/companion_gdbus.xml \\
+ ")
+
+MESSAGE(" - Set source folder")
+FILE(GLOB COMP_MANAGER_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c)
+
+SET(COMP_MANAGER "companion-manager")
+ADD_EXECUTABLE(${COMP_MANAGER} ${COMP_MANAGER_SRCS})
+TARGET_LINK_LIBRARIES(${COMP_MANAGER} ${daemon_pkgs_LIBRARIES} pthread)
+INSTALL(TARGETS ${COMP_MANAGER} DESTINATION bin)
--- /dev/null
+#ifndef __COMP_CONTEXT_H__
+#define __COMP_CONTEXT_H__
+
+#include <glib.h>
+#include <comp_log.h>
+#include <unistd.h>
+#include <gio/gio.h>
+#include <companion_gdbus.h>
+#include <sys/types.h>
+
+typedef struct {
+ GMainLoop *main_loop;
+ //GDBusConnection *connection;
+
+ // resource list
+ GList *resource_list[COMP_RESOURCE_TYPE_MAX];
+
+ char *device_uuid;
+ int operation_resource_count;
+} comp_context_t;
+
+int comp_context_create();
+int comp_context_destroy();
+void comp_context_mutex_lock();
+void comp_context_mutex_unlock();
+
+comp_context_t *comp_context_get_context();
+
+#endif
--- /dev/null
+#ifndef __COMP_ENUM_H__
+#define __COMP_ENUM_H__
+
+#include <tizen.h>
+
+#define TIZEN_ERROR_COMP 0
+
+/* error enum */
+typedef enum {
+ COMP_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
+ COMP_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
+ COMP_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+ COMP_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+ COMP_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ COMP_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
+ COMP_ERROR_COMM_ERROR = TIZEN_ERROR_COMP | 0x01, /**< communication error */
+ COMP_ERROR_RX = TIZEN_ERROR_COMP | 0x02, /**< RX error */
+ COMP_ERROR_TX = TIZEN_ERROR_COMP | 0x03, /**< TX error */
+ COMP_ERROR_PLUGIN_FAIL = TIZEN_ERROR_COMP | 0x04, /**< Plugin failed */
+ COMP_ERROR_OPERATION_FAILED = TIZEN_ERROR_COMP | 0x05, /**< Operation Failed */
+ COMP_ERROR_ALREADY_IN_PROGRESS = TIZEN_ERROR_COMP | 0x06, /**< Already initilized */
+ COMP_ERROR_UNKNOWN = -999,
+} comp_error_e;
+
+/* resource type enum */
+typedef enum {
+ COMP_RESOURCE_TYPE_GROUP = 0,
+ COMP_RESOURCE_TYPE_DEVICE = 0,
+ COMP_RESOURCE_TYPE_OPERATION,
+ COMP_RESOURCE_TYPE_MAX
+} comp_resource_type_e;
+
+/* group type enum */
+typedef enum {
+ COMP_GROUP_DEVICE = 0,
+ COMP_GROUP_REMOTE_DEVICE,
+} comp_group_type_e;
+
+#endif
--- /dev/null
+#ifndef __COMP_GDBUS_H__
+#define __COMP_GDBUS_H__
+
+#include <comp_gdbus_group.h>
+
+#define COMP_DBUS_SERVICE "org.tizen.companion"
+#define COMP_DBUS_GROUP_PATH "/org/tizen/companion/group"
+
+int comp_gdbus_init();
+
+#endif
--- /dev/null
+#ifndef __COMP_GDBUS_GROUP_H__
+#define __COMP_GDBUS_GROUP_H__
+
+#include <comp_group.h>
+
+Group *group_dbus_get_object();
+
+gboolean group_create(Group *group, GDBusMethodInvocation *invocation, gchar *group_name,
+ gpointer user_data);
+
+gboolean group_find(Group *group, GDBusMethodInvocation *invocation, gint timeout,
+ gpointer user_data);
+
+gboolean group_get_found_groups(Group *group, GDBusMethodInvocation *invocation,
+ gpointer user_data);
+
+gboolean group_join(Group *group, GDBusMethodInvocation *invocation,
+ gpointer user_data);
+
+gboolean group_leave(Group *group, GDBusMethodInvocation *invocation,
+ gpointer user_data);
+
+gboolean group_delete(Group *group, GDBusMethodInvocation *invocation,
+ gpointer user_data);
+
+gboolean group_device_find(Group *group, GDBusMethodInvocation *invocation,
+ gpointer user_data);
+
+gboolean group_device_invite(Group *group, GDBusMethodInvocation *invocation,
+ gchar *uuid, gchar *pin, gpointer user_data);
+
+gboolean group_device_eject(Group *group, GDBusMethodInvocation *invocation,
+ gchar *uuid, gpointer user_data);
+
+void notify_group_found(GVariant *group_data);
+void notify_group_finish(int ret);
+void notify_group_device_invite_result(int ret);
+void notify_group_device_eject_result(int ret);
+
+#endif
--- /dev/null
+#ifndef __COMP_GROUP_H__
+#define __COMP_GROUP_H__
+
+#include <comp_iot.h>
+
+typedef struct {
+ char *uri_path;
+ char *device_id;
+ char *host_addr;
+ char *group_name;
+ char *resource_type;
+ comp_group_type_e type;
+} comp_group_t;
+
+/* Called when daemon is start. */
+int comp_group_initialize();
+
+/* create group and destroy */
+int comp_group_create(char* name);
+int comp_group_destroy(comp_group_t *handle);
+
+/* Find Remote groups */
+int comp_group_find(int timeout);
+GVariant *comp_group_get_found_groups();
+int comp_group_add_new(char *uri_path, char *device_id, char *device_name,
+ char *host_addr, char *resource_type, comp_group_type_e type);
+
+/* Join the remote devices in my daemon */
+int comp_group_get_groups(comp_group_t ***handles, int *count); //Get all of group in my daemon
+int comp_group_get_remote_devices(/* callback */); //Get all of device in network (Async)
+
+char *comp_group_invite_get_uuid();
+char *comp_group_invite_get_pin();
+//Join to device in group (async)
+int comp_group_invite(gchar *uuid, gchar *pin);
+void comp_group_notify_group_invite(int result);
+
+//dismiss from group (async)
+int comp_group_dismiss(gchar *uuid);
+void comp_group_notify_group_dismiss(int result);
+
+/* Join to remote device group */
+int comp_group_get_remote_groups(/* callback */); //Get all of group in network (Async)
+int comp_group_join_to(/* callback */); //Join this device to in certain remote group (Async)
+int comp_group_leave_from(/* callback */); //leave from certain remote group (Async)
+
+/* Called when daemon is end. */
+int comp_group_deinitialize();
+
+int comp_group_get_group_name(comp_group_t *handle, char **name);
+int comp_group_get_group_type(comp_group_t *handle, int *type);
+int comp_group_get_group_device_type(comp_group_t *handle);
+int comp_group_get_group_device_id(comp_group_t *handle);
+
+/* notify */
+int comp_group_event_handler(/*callback*/); // event hadnler
+
+#endif
--- /dev/null
+#ifndef __COMP_IOT_H__
+#define __COMP_IOT_H__
+
+#include <comp_resource.h>
+
+#define SVR_PATH "/tmp/.svr.dat"
+
+int comp_iot_initialize();
+int comp_iot_add_resource(comp_resource_type_e resource_type, char *uri);
+int comp_iot_delete_resource(comp_resource_type_e resource_type);
+int comp_iot_discovery_resource(comp_resource_type_e resource_type, int timeout);
+int comp_iot_deinitialize();
+
+#endif
--- /dev/null
+#ifndef __COMP_LOG_H__
+#define __COMP_LOG_H__
+
+#include <dlog.h>
+#include <comp_enum.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define COLOR_RED "\033[0;31m"
+#define COLOR_GREEN "\033[0;32m"
+#define COLOR_BROWN "\033[0;33m"
+#define COLOR_BLUE "\033[0;34m"
+#define COLOR_PURPLE "\033[0;35m"
+#define COLOR_CYAN "\033[0;36m"
+#define COLOR_LIGHTBLUE "\033[0;37m"
+#define COLOR_END "\033[0;m"
+
+#define LOG_TAG "COMP_MANAGER"
+
+#define LOG_DEBUG(fmt, ...) \
+ do { \
+ LOGD(COLOR_BROWN" " fmt COLOR_END, ##__VA_ARGS__); \
+ } while (0)
+#define LOG_ERR(fmt, ...) \
+ do { \
+ LOGE(COLOR_RED" " fmt COLOR_END, ##__VA_ARGS__); \
+ } while (0)
+#define LOG_BEGIN() \
+ do { \
+ LOGD(COLOR_BLUE "BEGIN >>>>"COLOR_END); \
+ } while (0)
+#define LOG_END() \
+ do { \
+ LOGD(COLOR_BLUE "END <<<<"COLOR_END); \
+ } while (0)
+
+const char *comp_log_get_error_string(int result);
+
+#endif
--- /dev/null
+#ifndef __COMP_MANAGER_H__
+#define __COMP_MANAGER_H__
+
+#include <comp_log.h>
+#include <comp_group.h>
+#include <comp_resource.h>
+#include <comp_gdbus.h>
+
+#endif
--- /dev/null
+/******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *****************************************************************/
+ #ifndef __COMP_MOT_AGENT_H__
+ #define __COMP_MOT_AGENT_H__
+
+ int agent_dbus_start();
+int agent_dbus_stop();
+
+int agent_enable();
+int agent_disable();
+int agent_get_ownerid(char* deviceid);
+int agent_find_mot_enable_devices();
+int agent_find_mowned_devices();
+int agent_mot_device(char* uuid_str, char *pin);
+int agent_pairwise(char* target1, char *subject1, char *uri1,
+ char *rt1, char *interface1, int permission1, char* target2, char *subject2, char *uri2,
+ char *rt2, char *interface2, int permission2);
+int agent_remove_mo_at_device(char* uuid_str);
+int agent_remove_myowned_device(char* uuid_str);
+
+ #endif /* __COMP_MOT_AGENT_H__ */
\ No newline at end of file
--- /dev/null
+#ifndef __COMP_RESOURCE_H__
+#define __COMP_RESOURCE_H__
+
+#include <iotcon.h>
+#include <comp_context.h>
+
+typedef struct {
+ comp_resource_type_e resource_type;
+ char *type;
+ char *uri_prefix;
+ uint8_t policies;
+} comp_rd_t;
+
+typedef struct {
+ iotcon_resource_h resource;
+ char *uri;
+} comp_re_t;
+
+int comp_resource_append(comp_resource_type_e resource_type, char *uri, iotcon_resource_h resource);
+char *comp_resource_get_type(comp_resource_type_e resource_type);
+char *comp_resource_get_uri_prefix(comp_resource_type_e resource_type);
+uint8_t comp_resource_get_policies(comp_resource_type_e resource_type);
+void comp_resource_print_list();
+int comp_resource_get_resource_from_uri(comp_resource_type_e resource_type,
+ char *uri, iotcon_resource_h *parent_resource);
+
+#endif
--- /dev/null
+#include <comp_context.h>
+
+static pthread_mutex_t context_lock = PTHREAD_MUTEX_INITIALIZER;
+static comp_context_t *_comp_ctx;
+
+int comp_context_create()
+{
+ _comp_ctx = g_new0(comp_context_t, 1);
+ if (!_comp_ctx) {
+ LOG_DEBUG("create mtp_context is failed");
+ return COMP_ERROR_UNKNOWN;
+ }
+
+ return COMP_ERROR_NONE;
+}
+
+void comp_context_mutex_lock()
+{
+ LOG_DEBUG("context mutex lock");
+ pthread_mutex_lock(&context_lock);
+}
+
+void comp_context_mutex_unlock()
+{
+ LOG_DEBUG("context mutex unlock");
+ pthread_mutex_unlock(&context_lock);
+}
+
+int comp_context_destroy()
+{
+ return COMP_ERROR_NONE;
+}
+
+comp_context_t *comp_context_get_context()
+{
+ return _comp_ctx;
+}
+
--- /dev/null
+#include <comp_gdbus.h>
+#include <sys/types.h>
+
+static Group *group_skeleton;
+
+Group *group_dbus_get_object()
+{
+ return group_skeleton;
+}
+
+static bool __group_init(GDBusConnection *connection)
+{
+ gboolean ret = FALSE;
+ GError *error = NULL;
+
+ GDBusObjectManagerServer *group;
+
+ // Add interface to default object path
+ group_skeleton = group_skeleton_new();
+
+ // Register for method callbacks as signal callbacks
+ g_signal_connect(group_skeleton,
+ "handle-create",
+ G_CALLBACK(group_create),
+ NULL);
+
+ g_signal_connect(group_skeleton,
+ "handle-find",
+ G_CALLBACK(group_find),
+ NULL);
+
+ g_signal_connect(group_skeleton,
+ "handle-get-found-groups",
+ G_CALLBACK(group_get_found_groups),
+ NULL);
+
+ g_signal_connect(group_skeleton,
+ "handle-join",
+ G_CALLBACK(group_join),
+ NULL);
+
+ g_signal_connect(group_skeleton,
+ "handle-leave",
+ G_CALLBACK(group_leave),
+ NULL);
+
+ g_signal_connect(group_skeleton,
+ "handle-delete",
+ G_CALLBACK(group_delete),
+ NULL);
+
+ g_signal_connect(group_skeleton,
+ "handle-delete",
+ G_CALLBACK(group_device_find),
+ NULL);
+
+ g_signal_connect(group_skeleton,
+ "handle-device-invite",
+ G_CALLBACK(group_device_invite),
+ NULL);
+
+ g_signal_connect(group_skeleton,
+ "handle-device-eject",
+ G_CALLBACK(group_device_eject),
+ NULL);
+
+ group = g_dbus_object_manager_server_new(COMP_DBUS_GROUP_PATH);
+
+ // Set connection to 'manager'
+ g_dbus_object_manager_server_set_connection(group, connection);
+
+ // Export 'group' interface on FN DBUS
+ ret = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(group_skeleton),
+ connection, COMP_DBUS_GROUP_PATH, &error);
+
+ if (ret == FALSE) {
+ LOG_DEBUG("Can not skeleton_export %s", error->message);
+ g_error_free(error);
+ }
+
+ return ret;
+}
+
+
+
+static void on_bus_acquired(GDBusConnection *connection, const gchar *path,
+ gpointer user_data)
+{
+ if (__group_init(connection) == false) {
+ LOG_DEBUG("Can not signal connect");
+ }
+}
+
+static void on_name_acquired(GDBusConnection *connection, const gchar *name,
+ gpointer user_data)
+{
+ LOG_DEBUG("on_name_acquired : %s", name);
+}
+
+static void on_name_lost(GDBusConnection *connnection, const gchar *name,
+ gpointer user_data)
+{
+ LOG_DEBUG("on_name_lost : %s", name);
+}
+
+int comp_gdbus_init()
+{
+ g_bus_own_name(G_BUS_TYPE_SYSTEM, COMP_DBUS_SERVICE, G_BUS_NAME_OWNER_FLAGS_NONE,
+ on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL);
+
+ return 0;
+}
--- /dev/null
+#include <comp_gdbus_group.h>
+
+/* GDBUS Group Layer */
+/* In this gdbus group layer, Please call the "fn_group" service layer function.*/
+
+gboolean group_create(Group *group, GDBusMethodInvocation *invocation, gchar *group_name,
+ gpointer user_data)
+{
+ gint result = 0;
+
+ LOG_DEBUG("group create called using dbus successful");
+
+ result = comp_group_create(group_name);
+
+ group_complete_create(group, invocation, result);
+
+ return TRUE;
+}
+
+gboolean group_find(Group *group, GDBusMethodInvocation *invocation, gint timeout,
+ gpointer user_data)
+{
+ gint result = 0;
+
+ LOG_DEBUG("group find called using dbus successful");
+
+ comp_group_find(timeout);
+
+ group_complete_find(group, invocation, result);
+ return TRUE;
+}
+
+gboolean group_get_found_groups(Group *group, GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ gint result = 0;
+ GVariant *group_data;
+
+ LOG_DEBUG("get found groups called using dbus successful");
+
+ group_data = comp_group_get_found_groups();
+
+ group_complete_get_found_groups(group, invocation, result, group_data);
+ return TRUE;
+}
+
+gboolean group_join(Group *group, GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ //group_complete_join(group, invocation, result);
+
+ return TRUE;
+}
+
+gboolean group_leave(Group *group, GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ //group_complete_leave(group, invocation, result);
+
+ return TRUE;
+}
+
+gboolean group_delete(Group *group, GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ //group_complete_delete(group, invocation, result);
+
+ return TRUE;
+}
+
+gboolean group_device_find(Group *group, GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ //group_complete_device_find(group, invocation, result);
+
+ return TRUE;
+}
+
+gboolean group_device_invite(Group *group, GDBusMethodInvocation *invocation,
+ gchar *uuid, gchar *pin, gpointer user_data)
+{
+ gint result = 0;
+
+ LOG_DEBUG("group device invite eject using dbus successful");
+
+ result = comp_group_invite(uuid, pin);
+
+ group_complete_device_invite(group, invocation, result);
+
+ return TRUE;
+}
+
+gboolean group_device_eject(Group *group, GDBusMethodInvocation *invocation,
+ gchar *uuid, gpointer user_data)
+{
+ gint result = 0;
+
+ LOG_DEBUG("group device eject called using dbus successful");
+
+ result = comp_group_dismiss(uuid);
+
+ group_complete_device_eject(group, invocation, result);
+
+ return TRUE;
+}
+
+void notify_group_found(GVariant *group_data)
+{
+ group_emit_group_found(group_dbus_get_object(), group_data);
+}
+
+void notify_group_finish(int ret)
+{
+ group_emit_finish(group_dbus_get_object(), ret);
+}
+
+void notify_group_device_invite_result(int ret)
+{
+ group_emit_device_invite_result(group_dbus_get_object(), ret);
+}
+
+void notify_group_device_eject_result(int ret)
+{
+ group_emit_device_eject_result(group_dbus_get_object(), ret);
+}
--- /dev/null
+#include <comp_group.h>
+
+GList *found_group_list;
+static char *group_invite_uuid = NULL;
+static char *group_invite_pin = NULL;
+
+/* Called when daemon is start. */
+int comp_group_initialize()
+{
+ //Initialize memory of context
+
+}
+
+/* create group and destroy */
+int comp_group_create(char* name)
+{
+ int ret;
+
+ LOG_BEGIN();
+
+
+ ret = comp_iot_add_resource(COMP_RESOURCE_TYPE_GROUP, name);
+ if (ret != COMP_ERROR_NONE) {
+ LOG_ERR("Add resource is failed : %s", comp_log_get_error_string(ret));
+ }
+
+
+ /* A own group device is included in the created group by default. */
+ /* I would like to use multiple group device resource for this created group resources.
+ If there is a better way, please change it.
+
+ Group/Jihoon (Group (In this daemon))
+ - Group/Device123123 (Group Device (In this daemon))
+ - Group/Device3321 (Group Device (remote))
+ - Group/Device1101 (Group Device (remote))
+ */
+
+ comp_resource_print_list();
+
+ LOG_END();
+
+ return COMP_ERROR_NONE;
+}
+
+int comp_group_destroy(comp_group_t *handle)
+{
+
+}
+
+void _free_func (gpointer data)
+{
+ comp_group_t *group = (comp_group_t *)data;
+
+ if (group != NULL) {
+ if (group->uri_path != NULL)
+ g_free(group->uri_path);
+ if (group->device_id != NULL)
+ g_free(group->device_id);
+ if (group->group_name != NULL)
+ g_free(group->group_name);
+ if (group->host_addr != NULL)
+ g_free(group->host_addr);
+ if (group->resource_type != NULL)
+ g_free(group->resource_type);
+
+ g_free(group);
+ }
+}
+
+int comp_group_find(int timeout)
+{
+ int ret;
+
+ LOG_BEGIN();
+
+ /* list freeing */
+ g_list_free_full (found_group_list, _free_func);
+ found_group_list = NULL;
+
+ ret = comp_iot_discovery_resource(COMP_RESOURCE_TYPE_GROUP, timeout);
+ if (ret != COMP_ERROR_NONE) {
+ LOG_ERR("Failed to discover resource : %s",
+ comp_log_get_error_string(ret));
+ }
+
+ LOG_END();
+
+ return COMP_ERROR_NONE;
+}
+
+GVariant *comp_group_get_found_groups()
+{
+ GVariantBuilder builder;
+ GVariant *group_data;
+ GList *iter = NULL;
+
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
+
+ iter = found_group_list;
+ while(iter != NULL) {
+ comp_group_t *group = (comp_group_t *)iter->data;
+
+ g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add(&builder, "{sv}", "URI",
+ g_variant_new_string(group->uri_path));
+ g_variant_builder_add(&builder, "{sv}", "DeviceID",
+ g_variant_new_string(group->device_id));
+ g_variant_builder_add(&builder, "{sv}", "GroupName",
+ g_variant_new_string(group->group_name));
+ g_variant_builder_add(&builder, "{sv}", "HostAddress",
+ g_variant_new_string(group->host_addr));
+ g_variant_builder_add(&builder, "{sv}", "GroupDeviceType",
+ g_variant_new_string(group->resource_type));
+ /*When we get found groups, we can get my groups also. */
+ g_variant_builder_add(&builder, "{sv}", "GroupType",
+ g_variant_new_int32(group->type));
+ g_variant_builder_close(&builder);
+
+ iter = g_list_next(iter);
+ }
+
+ group_data = g_variant_builder_end(&builder);
+
+ return group_data;
+}
+
+int comp_group_add_new(char *uri_path, char *device_id, char *device_name,
+ char *host_addr, char *resource_type, comp_group_type_e type)
+{
+ int ret;
+ comp_group_t *group;
+ GVariantBuilder builder;
+ GVariant *group_data;
+
+ LOG_BEGIN();
+
+ group = g_try_malloc0(sizeof(comp_group_t));
+ group->uri_path = g_strdup(uri_path);
+ group->device_id = g_strdup(device_id);
+ group->group_name = g_strdup(device_name);
+ group->host_addr = g_strdup(host_addr);
+ group->resource_type = g_strdup(resource_type);
+ group->type = type;
+
+ found_group_list = g_list_prepend(found_group_list, group);
+
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
+
+ g_variant_builder_add(&builder, "{sv}", "URI",
+ g_variant_new_string(group->uri_path));
+ g_variant_builder_add(&builder, "{sv}", "DeviceID",
+ g_variant_new_string(group->device_id));
+ g_variant_builder_add(&builder, "{sv}", "GroupName",
+ g_variant_new_string(group->group_name));
+ g_variant_builder_add(&builder, "{sv}", "HostAddress",
+ g_variant_new_string(group->host_addr));
+ g_variant_builder_add(&builder, "{sv}", "GroupDeviceType",
+ g_variant_new_string(group->resource_type));
+ g_variant_builder_add(&builder, "{sv}", "GroupType",
+ g_variant_new_int32(group->type));
+
+ group_data = g_variant_builder_end(&builder);
+
+ notify_group_found(group_data);
+
+ LOG_END();
+
+ return COMP_ERROR_NONE;
+}
+
+/* Join the remote devices in my daemon */
+int comp_group_get_groups(comp_group_t ***handles, int *count){} //Get all of group in my daemon
+int comp_group_get_remote_devices(/* callback */){} //Get all of device in network (Async)
+
+char *comp_group_invite_get_uuid()
+{
+ return group_invite_uuid;
+}
+
+char *comp_group_invite_get_pin()
+{
+ return group_invite_pin;
+}
+
+void comp_group_notify_group_invite(int result)
+{
+ LOG_DEBUG("Notify group invite %d", result);
+
+ g_free(group_invite_uuid);
+ group_invite_uuid = NULL;
+
+ g_free(group_invite_pin);
+ group_invite_pin = NULL;
+
+ notify_group_device_invite_result(result);
+}
+
+//Join to device in group (async)
+int comp_group_invite(gchar *uuid, gchar *pin)
+{
+ int ret;
+
+ LOG_BEGIN();
+
+ ret = agent_find_mot_enable_devices();
+
+ g_free(group_invite_uuid);
+ g_free(group_invite_pin);
+
+ group_invite_uuid = g_strdup(uuid);
+ group_invite_pin = g_strdup(pin);
+
+ LOG_END();
+
+ return ret;
+}
+
+void comp_group_notify_group_dismiss(int result)
+{
+ LOG_DEBUG("Notify group eject %d", result);
+
+ notify_group_device_eject_result(result);
+}
+
+//dismiss from group (async)
+int comp_group_dismiss(gchar *uuid)
+{
+ int ret;
+
+ LOG_BEGIN();
+
+ ret = agent_remove_mo_at_device(uuid);
+
+ LOG_END();
+
+ return ret;
+}
+
+/* Join to remote device group */
+int comp_group_get_remote_groups(/* callback */){} //Get all of group in network (Async)
+int comp_group_join_to(/* callback */){} //Join this device to in certain remote group (Async)
+int comp_group_leave_from(/* callback */){} //leave from certain remote group (Async)
+
+/* Called when daemon is end. */
+int comp_group_deinitialize(){}
+
+int comp_group_get_group_name(comp_group_t *handle, char **name){}
+int comp_group_get_group_type(comp_group_t *handle, int *type){}
+int comp_group_get_group_device_type(comp_group_t *handle){}
+int comp_group_get_group_device_id(comp_group_t *handle){}
+
--- /dev/null
+#include <comp_iot.h>
+#include <comp_group.h>
+
+static bool _request_device_info(iotcon_device_info_h info, iotcon_error_e result,
+ void *user_data)
+{
+ int ret;
+ char *device_id = NULL;
+
+ LOG_DEBUG("device info found");
+
+ ret = iotcon_device_info_get_property(info, IOTCON_DEVICE_INFO_ID, &device_id);
+ if (IOTCON_ERROR_NONE != ret) {
+ return false;
+ }
+
+ LOG_DEBUG("device_id : %s", device_id);
+
+ comp_context_t *comp_ctx = comp_context_get_context();
+ comp_ctx->device_uuid = g_strdup(device_id);
+
+ /*
+ "Group device" resource
+ The Group device resource is only one per device.
+ resource type is core.fn.group.device
+ This resource has device information as an attribute.
+ The resource uri is /fn/group/device + certain uuid.
+ ex) /fn/group/device123123
+ */
+ //fn_iot_add_resource(FN_RESOURCE_TYPE_GROUP_DEVICE, fn_ctx->device_uuid);
+
+ return false;
+}
+
+int comp_iot_initialize()
+{
+ int ret = iotcon_initialize(SVR_PATH);
+ if (IOTCON_ERROR_NONE != ret) {
+ LOG_ERR("iotcon_initialize: Failed %s", get_error_message(ret));
+ return false;
+ }
+
+ LOG_DEBUG("iotcon_initialize : %s", get_error_message(ret));
+ ret = iotcon_find_device_info(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_ALL,
+ NULL, _request_device_info, NULL);
+
+ if (IOTCON_ERROR_NONE != ret) {
+ LOG_ERR("iotcon_find_device_info: Failed %s", get_error_message(ret));
+ return false;
+ }
+
+ /*
+ "operation" resource
+ The operation resource is a control command channel between daemon and daemon.
+ resource type is core.fn.operation
+ Within this function we create a default operation resource. (uri is /fn/operation/1)
+ If we need more control channels, increase the number.
+ ex) /fn/operation/2, /fn/operation/3
+ */
+ comp_iot_add_resource(COMP_RESOURCE_TYPE_OPERATION, "1");
+
+ return COMP_ERROR_NONE;
+}
+
+static void _request_handler(iotcon_resource_h resource, iotcon_request_h request,
+ void *user_data)
+{
+ LOG_DEBUG("thread id is ");
+ //get resource element from fn resource list or, parsing resource uri
+
+ //if request type is "get" and resource type is "group",
+ //then OWNER send device information to CLIENT(Device info Exchange)
+ //if request type is "put" and resource type is "operation",
+ //then It is join request. CLIENT send device information to OWNER(Device info Exchange)
+ //resource type "operation" don't have "get" request type.
+}
+
+int comp_iot_add_resource(comp_resource_type_e resource_type, char *uri)
+{
+ iotcon_resource_h resource = NULL;
+ iotcon_resource_types_h resource_types = NULL;
+ iotcon_resource_interfaces_h resource_ifaces = NULL;
+ char uri_path[PATH_MAX] = {0,};
+
+ int ret = iotcon_resource_types_create(&resource_types);
+ if (IOTCON_ERROR_NONE != ret) {
+ LOG_ERR("iotcon_resource_types_create failed! : %s", get_error_message(ret));
+ goto EXIT;
+ }
+
+ ret = iotcon_resource_types_add(resource_types, comp_resource_get_type(resource_type));
+ if (IOTCON_ERROR_NONE != ret) {
+ LOG_ERR("iotcon_resource_types_add failed! : %s", get_error_message(ret));
+ goto EXIT;
+ }
+
+ ret = iotcon_resource_interfaces_create(&resource_ifaces);
+ if (IOTCON_ERROR_NONE != ret) {
+ LOG_ERR("iotcon_resource_interfaces_create failed! : %s", get_error_message(ret));
+ goto EXIT;
+ }
+
+ ret = iotcon_resource_interfaces_add(resource_ifaces, IOTCON_INTERFACE_DEFAULT);
+ if (IOTCON_ERROR_NONE != ret) {
+ LOG_ERR("iotcon_resource_interfaces_add failed! : %s", get_error_message(ret));
+ goto EXIT;
+ }
+
+ strncpy(uri_path, comp_resource_get_uri_prefix(resource_type), PATH_MAX);
+ strncat(uri_path, uri, PATH_MAX);
+
+ LOG_DEBUG("[ADD] resource uri is %s", uri_path);
+ //name duplication check
+
+ ret = iotcon_resource_create(uri_path, resource_types, resource_ifaces,
+ comp_resource_get_policies(resource_type), _request_handler, NULL, &resource);
+ if (IOTCON_ERROR_NONE != ret) {
+ LOG_ERR("iotcon_resource_create failed! : %s", get_error_message(ret));
+ goto EXIT;
+ }
+
+ //get resource list of resource type
+ ret = comp_resource_append(resource_type, uri, resource);
+ if (COMP_ERROR_NONE != ret) {
+ LOG_ERR("comp_resource_append failed! : %s", comp_log_get_error_string(ret));
+ goto EXIT;
+ }
+
+EXIT:
+ if (resource_types != NULL)
+ iotcon_resource_types_destroy(resource_types);
+
+ if (resource_ifaces != NULL)
+ iotcon_resource_interfaces_destroy(resource_ifaces);
+
+ return COMP_ERROR_NONE;
+}
+
+static bool _get_res_type_cb(const char *string, void *user_data)
+{
+ char **resource_type = user_data;
+
+ *resource_type = g_strdup(string);
+
+ LOG_DEBUG("resource type : %s", *resource_type);
+
+ return IOTCON_FUNC_CONTINUE;
+}
+
+int found_device_count = 0;
+
+static bool _found_resource(iotcon_remote_resource_h resource,
+ iotcon_error_e result, void *user_data)
+{
+ int ret;
+ char *resource_uri_path = NULL;
+ iotcon_resource_types_h resource_types;
+ char *resource_device_id;
+ char *resource_device_name;
+ char *resource_host;
+ char *resource_type;
+ comp_group_type_e group_type;
+
+ LOG_DEBUG("Resource Found");
+
+ /* get the resource URI */
+ ret = iotcon_remote_resource_get_uri_path(resource, &resource_uri_path);
+ if (IOTCON_ERROR_NONE != ret) {
+ LOG_ERR("Failed to get resource uri path");
+ return IOTCON_FUNC_CONTINUE;
+ }
+ LOG_DEBUG("resource uri : %s", resource_uri_path);
+
+ /* get the resource device id */
+ ret = iotcon_remote_resource_get_device_id(resource, &resource_device_id);
+ if (IOTCON_ERROR_NONE != ret) {
+ LOG_ERR("Failed to get resource device id");
+ return IOTCON_FUNC_CONTINUE;
+ }
+ LOG_DEBUG("resource device id : %s", resource_device_id);
+
+ /* get the resource device name */
+ ret = iotcon_remote_resource_get_device_name(resource,
+ &resource_device_name);
+ if (IOTCON_ERROR_NONE != ret) {
+ LOG_ERR("Failed to get resource device name");
+ return IOTCON_FUNC_CONTINUE;
+ }
+ LOG_DEBUG("resource device name : %s", resource_device_name);
+
+ /* get the resource host address */
+ ret = iotcon_remote_resource_get_host_address(resource, &resource_host);
+ if (IOTCON_ERROR_NONE != ret) {
+ LOG_ERR("Failed to get resource host address");
+ return IOTCON_FUNC_CONTINUE;
+ }
+ LOG_DEBUG("resource host : %s", resource_host);
+
+ ret = iotcon_remote_resource_get_types(resource, &resource_types);
+ if (IOTCON_ERROR_NONE != ret) {
+ LOG_ERR("Failed to get resource types");
+ return IOTCON_FUNC_CONTINUE;
+ }
+
+ ret = iotcon_resource_types_foreach(resource_types, _get_res_type_cb,
+ &resource_type);
+ if (IOTCON_ERROR_NONE != ret) {
+ LOG_ERR("Failed to get foreach resource types");
+ return IOTCON_FUNC_CONTINUE;
+ }
+
+ comp_context_t *comp_ctx = comp_context_get_context();
+ if (strcmp(resource_device_id, comp_ctx->device_uuid) == 0)
+ group_type = COMP_GROUP_DEVICE;
+ else
+ group_type = COMP_GROUP_REMOTE_DEVICE;
+
+ comp_group_add_new(resource_uri_path, resource_device_id,
+ resource_device_name, resource_host, resource_type, group_type);
+ found_device_count++;
+
+ g_free(resource_type);
+
+ return IOTCON_FUNC_CONTINUE;
+}
+
+static gboolean _timeout_cb(gpointer data)
+{
+ int ret = -1;
+ if (found_device_count > 0)
+ ret = 0;
+
+ notify_group_finish(ret);
+
+ return false;
+}
+
+int comp_iot_discovery_resource(comp_resource_type_e resource_type, int timeout)
+{
+ int ret;
+ iotcon_query_h query;
+
+ found_device_count = 0;
+
+ ret = iotcon_set_timeout(timeout);
+ if (IOTCON_ERROR_NONE != ret) {
+ LOG_ERR("Failed to set timeout value");
+ return COMP_ERROR_OPERATION_FAILED;
+ }
+
+ ret = iotcon_query_create(&query);
+ if (IOTCON_ERROR_NONE != ret) {
+ LOG_ERR("Failed to create iotcon query");
+ return COMP_ERROR_OPERATION_FAILED;
+ }
+
+ ret = iotcon_query_set_resource_type(query,
+ comp_resource_get_type(resource_type));
+ if (IOTCON_ERROR_NONE != ret) {
+ LOG_ERR("Failed to set iotcon query resource type");
+ return COMP_ERROR_OPERATION_FAILED;
+ }
+
+ LOG_DEBUG("find resource : %s", get_error_message(ret));
+
+ ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS,
+ IOTCON_CONNECTIVITY_IP | IOTCON_CONNECTIVITY_PREFER_UDP,
+ query, _found_resource, NULL);
+
+ g_timeout_add_seconds(timeout + 1, _timeout_cb, NULL);
+
+ LOG_DEBUG("find resource : %s", get_error_message(ret));
+
+ return ret;
+}
+
+int comp_iot_delete_resource(comp_resource_type_e resource_type)
+{
+ //delete resource from resource list using resource_type and index
+ //delete DB
+ return COMP_ERROR_NONE;
+}
+
+int comp_iot_deinitialize()
+{
+ return COMP_ERROR_NONE;
+}
--- /dev/null
+#include <comp_log.h>
+
+const char *comp_log_get_error_string(int result) {
+ switch (result) {
+ case COMP_ERROR_NONE:
+ return "COMP_ERROR_NONE";
+ case COMP_ERROR_IO_ERROR:
+ return "COMP_ERROR_IO_ERROR";
+ case COMP_ERROR_INVALID_PARAMETER:
+ return "COMP_ERROR_INVALID_PARAMETER";
+ case COMP_ERROR_OUT_OF_MEMORY:
+ return "COMP_ERROR_OUT_OF_MEMORY";
+ case COMP_ERROR_PERMISSION_DENIED:
+ return "COMP_ERROR_PERMISSION_DENIED";
+ case COMP_ERROR_NOT_SUPPORTED:
+ return "COMP_ERROR_NOT_SUPPORTED";
+ case COMP_ERROR_COMM_ERROR:
+ return "COMP_ERROR_COMM_ERROR";
+ case COMP_ERROR_RX:
+ return "COMP_ERROR_RX";
+ case COMP_ERROR_TX:
+ return "COMP_ERROR_RX";
+ case COMP_ERROR_PLUGIN_FAIL:
+ return "COMP_ERROR_PLUGIN_FAIL";
+ case COMP_ERROR_OPERATION_FAILED:
+ return "COMP_ERROR_OPERATION_FAILED";
+ default:
+ return "UNKNOWN";
+ }
+}
--- /dev/null
+#include <comp_manager.h>
+#include <comp_mot_agent.h>
+
+int main(int argc, char *argv[])
+{
+ int ret;
+
+ LOG_DEBUG("COMP Manager start");
+
+ //1. create & get context
+ ret = comp_context_create();
+ if (ret != COMP_ERROR_NONE) {
+ LOG_ERR("COMP context create failed : %s", comp_log_get_error_string(ret));
+ goto EXIT;
+ }
+
+ //3. iotivity iniatlize
+ ret = comp_iot_initialize();
+ if (ret != COMP_ERROR_NONE) {
+ LOG_ERR("COMP iot initialize failed : %s", comp_log_get_error_string(ret));
+ goto EXIT;
+ }
+
+ //4. dbus interface initialize
+ ret = comp_gdbus_init();
+ if (ret != COMP_ERROR_NONE) {
+ LOG_ERR("COMP gdbus initialize failed : %s", comp_log_get_error_string(ret));
+ goto EXIT;
+ }
+
+ //5. Make TX interface
+
+ //example code
+ //6. group mgr initialize
+ ret = comp_group_initialize();
+ if (ret != COMP_ERROR_NONE) {
+ LOG_ERR("COMP group initialize failed : %s", comp_log_get_error_string(ret));
+ goto EXIT;
+ }
+
+ //7. operation mgr initialize
+ ret = agent_dbus_start();
+ if (ret != COMP_ERROR_NONE) {
+ LOG_ERR("MOT agent interface initialize failed : %s", comp_log_get_error_string(ret));
+ goto EXIT;
+ }
+ agent_enable();
+
+ //8. g main loop run
+ comp_context_t *comp_ctx = comp_context_get_context();
+ comp_ctx->main_loop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(comp_ctx->main_loop);
+
+EXIT:
+ //9. deinitialize phase
+ agent_disable();
+ ret = agent_dbus_stop();
+ if (ret != COMP_ERROR_NONE)
+ LOG_ERR("MOT agent interface deinitialize failed : %s", comp_log_get_error_string(ret));
+
+ ret = comp_group_deinitialize();
+ if (ret != COMP_ERROR_NONE)
+ LOG_ERR("COMP group deinitialize failed : %s", comp_log_get_error_string(ret));
+
+ ret = comp_iot_deinitialize();
+ if (ret != COMP_ERROR_NONE)
+ LOG_ERR("COMP iot deinitialize failed : %s", comp_log_get_error_string(ret));
+
+ ret = comp_context_destroy();
+ if (ret != COMP_ERROR_NONE)
+ LOG_ERR("COMP context destroy failed : %s", comp_log_get_error_string(ret));
+
+ LOG_DEBUG("COMP Manager exit");
+
+ return 0;
+}
--- /dev/null
+/******************************************************************
+ *
+ * Copyright 2016 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ *****************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <error.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <comp_log.h>
+#include <comp_enum.h>
+
+#define AGENT_SERVER_NAME "net.d2ds"
+#define AGENT_OBJECT_PATH "/net/d2ds"
+#define AGENT_SERVICE_INTERFACE "net.d2ds"
+
+#define AGENT_ENABLER_NAME "net.d2ds.enabler"
+#define AGENT_ENABLER_OBJ_PATH "/net/d2ds/enabler"
+#define AGENT_ENABLER_INTERFACE "net.d2ds.enabler"
+
+#define NOTUSED(var) (var = var)
+
+#define AGENT_DBUS_PROXY_TIMEOUT ((9.5 + 2) * 1000) /**< default timeout for GDBus */
+
+struct agent_s {
+ GDBusProxy *gproxy_agent_service;
+ gpointer dbus_connection;
+ GCancellable *ca;
+ GList *dbus_sub_ids;
+};
+struct agent_s agent;
+
+int agent_get_ownerid(char* deviceid)
+{
+ GVariant *variant = NULL;
+ int result = COMP_ERROR_NONE;
+ GError *error = NULL;
+
+ if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
+ LOG_ERR("I/O error");
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "get_ownerid",
+ NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (variant) {
+ g_variant_get(variant, "(si)", deviceid, &result);
+ LOGD("get_ownerid status 0x%x", result);
+ } else if (error) {
+ LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ return result;
+}
+
+int agent_find_mot_enable_devices()
+{
+ GVariant *variant = NULL;
+ int result = COMP_ERROR_NONE;
+ GError *error = NULL;
+
+ if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
+ LOG_ERR("I/O error");
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "disc_mot_enb_devs",
+ NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (variant) {
+ g_variant_get(variant, "(i)", &result);
+ LOGD("disc_mot_enb_devs status 0x%x", result);
+ } else if (error) {
+ LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ return result;
+}
+
+int agent_find_mowned_devices()
+{
+ GVariant *variant = NULL;
+ int result = COMP_ERROR_NONE;
+ GError *error = NULL;
+
+ if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
+ LOG_ERR("I/O error");
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "disc_mowned_devs",
+ NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (variant) {
+ g_variant_get(variant, "(i)", &result);
+ LOGD("disc_mowned_devs status 0x%x", result);
+ } else if (error) {
+ LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ return result;
+}
+
+int agent_mot_device(char* uuid_str, char *pin)
+{
+ GVariant *variant = NULL;
+ int result = COMP_ERROR_NONE;
+ GError *error = NULL;
+
+ if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
+ LOG_ERR("I/O error");
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "mot",
+ g_variant_new("(ss)", uuid_str, pin), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (variant) {
+ g_variant_get(variant, "(i)", &result);
+ LOGD("mot status 0x%x", result);
+ } else if (error) {
+ LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ return result;
+}
+
+int agent_pairwise(char* target1, char *subject1, char *uri1,
+ char *rt1, char *interface1, int permission1, char* target2, char *subject2, char *uri2,
+ char *rt2, char *interface2, int permission2)
+{
+ GVariant *variant = NULL;
+ int result = COMP_ERROR_NONE;
+ GError *error = NULL;
+
+ if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
+ LOG_ERR("I/O error");
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "pairwise",
+ g_variant_new("(sssssisssssi)",
+ target1, subject1, uri1, rt1, interface1, permission1,
+ target2, subject2, uri2, rt2, interface2, permission2),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (variant) {
+ g_variant_get(variant, "(i)", &result);
+ LOGD("pairwise status 0x%x", result);
+ } else if (error) {
+ LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ return result;
+}
+
+int agent_remove_mo_at_device(char* uuid_str)
+{
+ GVariant *variant = NULL;
+ int result = COMP_ERROR_NONE;
+ GError *error = NULL;
+
+ if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
+ LOG_ERR("I/O error");
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "remove_mo",
+ g_variant_new("(s)", uuid_str), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (variant) {
+ g_variant_get(variant, "(i)", &result);
+ LOGD("remove_mo status 0x%x", result);
+ } else if (error) {
+ LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ return result;
+}
+
+int agent_remove_myowned_device(char* uuid_str)
+{
+ GVariant *variant = NULL;
+ int result = COMP_ERROR_NONE;
+ GError *error = NULL;
+
+ if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
+ LOG_ERR("I/O error");
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "unpair",
+ g_variant_new("(s)", uuid_str), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (variant) {
+ g_variant_get(variant, "(i)", &result);
+ LOGD("remove_mo status 0x%x", result);
+ } else if (error) {
+ LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ return result;
+}
+
+int agent_enable()
+{
+ GVariant *variant = NULL;
+ int result = COMP_ERROR_NONE;
+ GError *error = NULL;
+
+ if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
+ LOG_ERR("I/O error");
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ variant = g_dbus_connection_call_sync(agent.dbus_connection,
+ AGENT_ENABLER_NAME, AGENT_ENABLER_OBJ_PATH, AGENT_ENABLER_INTERFACE,
+ "enable", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (variant) {
+ g_variant_get(variant, "(i)", &result);
+ LOG_DEBUG("MOT Agent Enabled status 0x%x", result);
+ } else if (error) {
+ LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ return result;
+}
+
+int agent_disable()
+{
+ GVariant *variant = NULL;
+ int result = COMP_ERROR_NONE;
+ GError *error = NULL;
+
+ if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
+ LOG_ERR("I/O error");
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ variant = g_dbus_connection_call_sync(agent.dbus_connection,
+ AGENT_ENABLER_NAME, AGENT_ENABLER_OBJ_PATH, AGENT_ENABLER_INTERFACE,
+ "disable", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (variant) {
+ g_variant_get(variant, "(i)", &result);
+ LOG_DEBUG("MOT Agent Disabled status 0x%x", result);
+ } else if (error) {
+ LOGE("Failed DBus call [%s]", error->message);
+ g_error_free(error);
+ return COMP_ERROR_IO_ERROR;
+ }
+ return result;
+}
+
+static int _close_gdbus_call()
+{
+ /* CHECK: is connection ref count required? */
+ g_object_unref(agent.dbus_connection);
+ agent.dbus_connection = NULL;
+
+ return COMP_ERROR_NONE;
+}
+
+static void _dbus_name_owner_notify(GObject *object, GParamSpec *pspec,
+ gpointer *userdata)
+{
+ GDBusProxy *proxy = G_DBUS_PROXY(object);
+ gchar *name_owner = g_dbus_proxy_get_name_owner(proxy);
+
+ NOTUSED(userdata);
+
+ LOG_DEBUG("Name owner notify [%s]", name_owner);
+
+ if (NULL == name_owner)
+ _close_gdbus_call( );
+
+ g_free(name_owner);
+}
+
+static int _create_gdbus_call()
+{
+ int id;
+ GError *error = NULL;
+
+ if (agent.dbus_connection != NULL)
+ return COMP_ERROR_ALREADY_IN_PROGRESS;
+
+ agent.dbus_connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (NULL == agent.dbus_connection) {
+ if (error != NULL) {
+ LOG_ERR("Failed to connect to the D-BUS daemon [%s]", error->message);
+ g_error_free(error);
+ }
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ id = g_signal_connect(agent.dbus_connection, "notify::g-name-owner",
+ G_CALLBACK(_dbus_name_owner_notify), &agent);
+ if (0 == id) {
+ LOGE("g_signal_connect() Fail");
+ g_object_unref(agent.dbus_connection);
+ agent.dbus_connection = NULL;
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ return COMP_ERROR_NONE;
+}
+
+static GDBusProxy *_get_proxy_service()
+{
+ GDBusProxy *proxy = NULL;
+
+ if (NULL == agent.gproxy_agent_service) {
+ proxy = g_dbus_proxy_new_sync(agent.dbus_connection, G_DBUS_PROXY_FLAGS_NONE, NULL,
+ AGENT_SERVER_NAME, AGENT_OBJECT_PATH, AGENT_SERVICE_INTERFACE,
+ NULL, NULL);
+ } else
+ proxy = agent.gproxy_agent_service;
+
+ return proxy;
+}
+
+static gboolean __perform_mot(gpointer data)
+{
+ int ret;
+ char *uuid, *pin;
+
+ uuid = comp_group_invite_get_uuid();
+ pin = comp_group_invite_get_pin();
+
+ LOG_DEBUG("Perform MOT uuid: %s pin: %s", uuid, pin);
+
+ ret = agent_mot_device(uuid, pin);
+
+ if (ret != COMP_ERROR_NONE)
+ comp_group_notify_group_invite(ret);
+}
+
+static void _agent_signal_handler(GDBusConnection *connection,
+ const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
+ const gchar *signal_name, GVariant *parameters, gpointer userdata)
+{
+ int result = COMP_ERROR_NONE;
+ struct agent_s *h = userdata;
+
+ if (NULL == h) {
+ LOG_ERR("user_data is null");
+ return;
+ }
+
+ LOG_DEBUG("signal received = %s", signal_name);
+
+ if (0 == g_strcmp0(signal_name, "subowner_enabled")) {
+ g_variant_get(parameters, "(i)", &result);
+ LOG_DEBUG("Result : %d", result);
+ } else if (0 == g_strcmp0(signal_name, "disc_mot_enb_devs_done")) {
+ GVariantIter *iter = NULL;
+ GVariantIter *iter_row = NULL;
+
+ gchar *key;
+ GVariant *val;
+ gsize len = 0;
+ int mot_enb_devs_cnt = 0;
+
+ if (NULL == parameters) {
+ LOG_ERR("No MOT enabled devices found");
+ return;
+ }
+ g_variant_get(parameters, "(aa{sv})", &iter);
+ while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
+ while (g_variant_iter_loop(iter_row, "{sv}", &key, &val)) {
+ if (strcasecmp(key, "deviceId") == 0) {
+ const char *deviceid = g_variant_get_string(val, &len);
+ LOG_DEBUG("deviceId=%s", deviceid);
+ } else if (strcasecmp(key, "adapter") == 0) {
+ int adapter = g_variant_get_uint32(val);
+ LOG_DEBUG("adapter = %d", adapter);
+ } else if (strcasecmp(key, "adapter") == 0) {
+ int flags = g_variant_get_uint32(val);
+ LOG_DEBUG("flags = %d", flags);
+ } else if (strcasecmp(key, "port") == 0) {
+ int port = g_variant_get_uint16(val);
+ LOG_DEBUG("port = %d", port);
+ } else if (strcasecmp(key, "addr") == 0) {
+ const char *addr = g_variant_get_string(val, &len);
+ LOG_DEBUG("addr=%s", addr);
+ } else if (strcasecmp(key, "ifindex") == 0) {
+ int ifindex = g_variant_get_uint32(val);
+ LOG_DEBUG("ifindex = %d", ifindex);
+ } else if (strcasecmp(key, "routeData") == 0) {
+ const char *routeData = g_variant_get_string(val, &len);
+ LOG_DEBUG("routeData=%s", routeData);
+ } else if (strcasecmp(key, "remoteId") == 0) {
+ const char *remoteId = g_variant_get_string(val, &len);
+ LOG_DEBUG("remoteId=%s", remoteId);
+ } else if (strcasecmp(key, "connType") == 0) {
+ int connType = g_variant_get_uint32(val);
+ LOG_DEBUG("connType = %d", connType);
+ } else if (strcasecmp(key, "securePort") == 0) {
+ int securePort = g_variant_get_uint16(val);
+ LOG_DEBUG("securePort = %d", securePort);
+#ifdef WITH_TCP
+ } else if (strcasecmp(key, "tcpPort") == 0) {
+ int tcpPort = g_variant_get_uint16(val);
+ LOG_DEBUG("tcpPort = %d", tcpPort);
+ }
+#endif
+ else if (strcasecmp(key, "secVer") == 0) {
+ const char *secVer = g_variant_get_string(val, &len);
+ LOG_DEBUG("secVer=%s", secVer);
+ } else if (strcasecmp(key, "ifindex") == 0) {
+ int devStatus = g_variant_get_uint32(val);
+ LOG_DEBUG("devStatus = %d", devStatus);
+ }
+ }
+ g_variant_iter_free(iter_row);
+ mot_enb_devs_cnt += 1;
+ }
+
+ g_variant_iter_free(iter);
+
+ LOG_DEBUG("mot_enb_devs_cnt = %d", mot_enb_devs_cnt);
+
+ if (mot_enb_devs_cnt > 0) // do mot
+ g_idle_add(__perform_mot, NULL);
+ else // No device notify group invite fail
+ comp_group_notify_group_invite(COMP_ERROR_OPERATION_FAILED);
+
+ } else if (0 == g_strcmp0(signal_name, "disc_mowned_devs_done")) {
+ GVariantIter *iter = NULL;
+ GVariantIter *iter_row = NULL;
+
+ gchar *key;
+ GVariant *val;
+ gsize len = 0;
+
+ if (NULL == parameters) {
+ LOG_ERR("No Multiple Owned devices found");
+ return;
+ }
+ g_variant_get(parameters, "(aa{sv})", &iter);
+ while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
+ while (g_variant_iter_loop(iter_row, "{sv}", &key, &val)) {
+ if (strcasecmp(key, "deviceId") == 0) {
+ const char *deviceid = g_variant_get_string(val, &len);
+ LOG_DEBUG("deviceId=%s", deviceid);
+ } else if (strcasecmp(key, "adapter") == 0) {
+ int adapter = g_variant_get_uint32(val);
+ LOG_DEBUG("adapter = %d", adapter);
+ } else if (strcasecmp(key, "adapter") == 0) {
+ int flags = g_variant_get_uint32(val);
+ LOG_DEBUG("flags = %d", flags);
+ } else if (strcasecmp(key, "port") == 0) {
+ int port = g_variant_get_uint16(val);
+ LOG_DEBUG("port = %d", port);
+ } else if (strcasecmp(key, "addr") == 0) {
+ const char *addr = g_variant_get_string(val, &len);
+ LOG_DEBUG("addr=%s", addr);
+ } else if (strcasecmp(key, "ifindex") == 0) {
+ int ifindex = g_variant_get_uint32(val);
+ LOG_DEBUG("ifindex = %d", ifindex);
+ } else if (strcasecmp(key, "routeData") == 0) {
+ const char *routeData = g_variant_get_string(val, &len);
+ LOG_DEBUG("routeData=%s", routeData);
+ } else if (strcasecmp(key, "remoteId") == 0) {
+ const char *remoteId = g_variant_get_string(val, &len);
+ LOG_DEBUG("remoteId=%s", remoteId);
+ } else if (strcasecmp(key, "connType") == 0) {
+ int connType = g_variant_get_uint32(val);
+ LOG_DEBUG("connType = %d", connType);
+ } else if (strcasecmp(key, "securePort") == 0) {
+ int securePort = g_variant_get_uint16(val);
+ LOG_DEBUG("securePort = %d", securePort);
+#ifdef WITH_TCP
+ } else if (strcasecmp(key, "tcpPort") == 0) {
+ int tcpPort = g_variant_get_uint16(val);
+ LOG_DEBUG("tcpPort = %d", tcpPort);
+ }
+#endif
+ else if (strcasecmp(key, "secVer") == 0) {
+ const char *secVer = g_variant_get_string(val, &len);
+ LOG_DEBUG("secVer=%s", secVer);
+ } else if (strcasecmp(key, "ifindex") == 0) {
+ int devStatus = g_variant_get_uint32(val);
+ LOG_DEBUG("devStatus = %d", devStatus);
+ }
+ }
+ g_variant_iter_free(iter_row);
+ }
+ g_variant_iter_free(iter);
+ } else if (0 == g_strcmp0(signal_name, "acl_done")) {
+ g_variant_get(parameters, "(i)", &result);
+ LOG_DEBUG("Result : %d", result);
+ } else if (0 == g_strcmp0(signal_name, "cred_done")) {
+ g_variant_get(parameters, "(i)", &result);
+ LOG_DEBUG("Result : %d", result);
+ } else if (0 == g_strcmp0(signal_name, "mot_done")) {
+ g_variant_get(parameters, "(i)", &result);
+ LOG_DEBUG("Result : %d", result);
+
+ comp_group_notify_group_invite(result);
+ } else if (0 == g_strcmp0(signal_name, "remove_mo_done")) {
+ g_variant_get(parameters, "(i)", &result);
+ LOG_DEBUG("Result : %d", result);
+
+ comp_group_notify_group_dismiss(result);
+ } else if (0 == g_strcmp0(signal_name, "pairwise_done")) {
+ g_variant_get(parameters, "(i)", &result);
+ LOG_DEBUG("Result : %d", result);
+ } else if (0 == g_strcmp0(signal_name, "unpair_done")) {
+ g_variant_get(parameters, "(i)", &result);
+ LOG_DEBUG("Result : %d", result);
+ }
+}
+static int _subscribe_event()
+{
+ unsigned int id;
+ struct agent_s *h = &agent;
+
+ /* subowner_enabled */
+ id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
+ "subowner_enabled", AGENT_OBJECT_PATH, NULL,
+ G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
+ if (0 == id) {
+ LOG_ERR("g_dbus_connection_signal_subscribe(subowner_enabled) Fail(%d)", errno);
+ return -1;
+ }
+ h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
+ LOG_DEBUG("subscribed for (subowner_enabled) signal %d", id);
+
+ /* disc_mot_enb_devs_done */
+ id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
+ "disc_mot_enb_devs_done", AGENT_OBJECT_PATH, NULL,
+ G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
+ if (0 == id) {
+ LOG_ERR("g_dbus_connection_signal_subscribe(disc_mot_enb_devs_done) Fail(%d)", errno);
+ return -1;
+ }
+ h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
+ LOG_DEBUG("subscribed for (disc_mot_enb_devs_done) signal %d", id);
+
+ /* disc_mowned_devs_done */
+ id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
+ "disc_mowned_devs_done", AGENT_OBJECT_PATH, NULL,
+ G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
+ if (0 == id) {
+ LOG_ERR("g_dbus_connection_signal_subscribe(disc_mowned_devs_done) Fail(%d)", errno);
+ return -1;
+ }
+ h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
+ LOG_DEBUG("subscribed for (disc_mowned_devs_done) signal %d", id);
+
+ /* mot_done */
+ id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
+ "mot_done", AGENT_OBJECT_PATH, NULL,
+ G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
+ if (0 == id) {
+ LOG_ERR("g_dbus_connection_signal_subscribe(mot_done) Fail(%d)", errno);
+ return -1;
+ }
+ h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
+ LOG_DEBUG("subscribed for (mot_done) signal %d", id);
+
+ /* remove_mo_done */
+ id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
+ "remove_mo_done", AGENT_OBJECT_PATH, NULL,
+ G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
+ if (0 == id) {
+ LOG_ERR("g_dbus_connection_signal_subscribe(remove_mo_done) Fail(%d)", errno);
+ return -1;
+ }
+ h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
+ LOG_DEBUG("subscribed for (remove_mo_done) signal %d", id);
+
+ /* acl_done */
+ id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
+ "acl_done", AGENT_OBJECT_PATH, NULL,
+ G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
+ if (0 == id) {
+ LOG_ERR("g_dbus_connection_signal_subscribe(acl_done) Fail(%d)", errno);
+ return -1;
+ }
+ h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
+ LOG_DEBUG("subscribed for (acl_done) signal %d", id);
+
+ /*cred_done */
+ id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
+ "cred_done", AGENT_OBJECT_PATH, NULL,
+ G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
+ if (0 == id) {
+ LOG_ERR("g_dbus_connection_signal_subscribe(cred_done) Fail(%d)", errno);
+ return -1;
+ }
+ h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
+ LOG_DEBUG("subscribed for (cred_done) signal %d", id);
+
+ /*unpair_done */
+ id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
+ "unpair_done", AGENT_OBJECT_PATH, NULL,
+ G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
+ if (0 == id) {
+ LOG_ERR("g_dbus_connection_signal_subscribe(unpair_done) Fail(%d)", errno);
+ return -1;
+ }
+ h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
+ LOG_DEBUG("subscribed for (unpair_done) signal %d", id);
+
+ /*pairwise_done */
+ id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
+ "pairwise_done", AGENT_OBJECT_PATH, NULL,
+ G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
+ if (0 == id) {
+ LOG_ERR("g_dbus_connection_signal_subscribe(pairwise_done) Fail(%d)", errno);
+ return -1;
+ }
+ h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
+ LOG_DEBUG("subscribed for (pairwise_done) signal %d", id);
+
+ return 0;
+}
+
+static void _on_unsubscribe_ids(gpointer data, gpointer userdata)
+{
+ unsigned int id = GPOINTER_TO_UINT(data);
+ struct agent_s *h = (struct agent_s*)userdata;
+ if (NULL == h) {
+ LOG_ERR("Invaild parameter");
+ return;
+ }
+ LOG_DEBUG("[Signal unsubscribe] : %d", id);
+ g_dbus_connection_signal_unsubscribe(h->dbus_connection, id);
+}
+static void _unsubscribe_event()
+{
+ g_list_foreach(agent.dbus_sub_ids, _on_unsubscribe_ids, &agent);
+ g_list_free(agent.dbus_sub_ids);
+ agent.dbus_sub_ids = NULL;
+}
+
+int agent_dbus_start( )
+{
+ int ret = COMP_ERROR_NONE;
+
+ ret = _create_gdbus_call();
+ if (COMP_ERROR_NONE != ret)
+ return ret;
+
+ agent.ca = g_cancellable_new();
+
+ /* Create all proxies here */
+ agent.gproxy_agent_service = _get_proxy_service();
+ if (NULL == agent.gproxy_agent_service) {
+ LOG_ERR("Couldn't get _get_proxy_service");
+ return COMP_ERROR_IO_ERROR;
+ }
+
+ g_dbus_proxy_set_default_timeout(
+ G_DBUS_PROXY(agent.gproxy_agent_service), AGENT_DBUS_PROXY_TIMEOUT);
+
+ /* Subscribe events */
+ _subscribe_event();
+
+ return COMP_ERROR_NONE;
+}
+
+int agent_dbus_stop()
+{
+ int ret = COMP_ERROR_NONE;
+
+ _unsubscribe_event();
+
+ /* Unref all proxies here */
+ if (agent.gproxy_agent_service) {
+ g_object_unref(agent.gproxy_agent_service);
+ agent.gproxy_agent_service = NULL;
+ }
+
+ g_cancellable_cancel(agent.ca);
+ g_object_unref(agent.ca);
+ agent.ca = NULL;
+
+ ret = _close_gdbus_call();
+ return ret;
+}
+
--- /dev/null
+#include <comp_resource.h>
+
+/* resource_type, type, uri, policies */
+static comp_rd_t comp_rds[] = {
+ {COMP_RESOURCE_TYPE_GROUP, "core.comp.group", "/comp/group/",
+ IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE},
+ {COMP_RESOURCE_TYPE_GROUP, "core.comp.device", "/comp/device/",
+ IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE},
+ {COMP_RESOURCE_TYPE_OPERATION, "core.comp.operation", "/comp/operation/",
+ IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE},
+};
+
+int comp_resource_append(comp_resource_type_e resource_type, char *uri, iotcon_resource_h resource)
+{
+ comp_context_t *comp_ctx = comp_context_get_context();
+ GList *list = comp_ctx->resource_list[resource_type];
+
+ //append resource handle / name to list
+ comp_re_t *element = g_new0(comp_re_t, 1);
+ element->resource = resource;
+ element->uri = g_strdup(uri);
+ list = g_list_append(list, element);
+
+ comp_ctx->resource_list[resource_type] = list;
+
+ return 0;
+}
+
+int comp_resource_get_resource_from_uri(comp_resource_type_e resource_type,
+ char *uri, iotcon_resource_h *parent_resource)
+{
+ comp_context_t *comp_ctx = comp_context_get_context();
+ GList *list = comp_ctx->resource_list[resource_type];
+
+ GList *l;
+ for (l = list; l != NULL; l = l->next) {
+ comp_re_t *re = (comp_re_t *)l->data;
+
+ if (strcmp(re->uri, uri) == 0) {
+ LOG_DEBUG("Resource found - type : %d uri : %s", resource_type, uri);
+ *parent_resource = re->resource;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+char *comp_resource_get_type(comp_resource_type_e resource_type)
+{
+ return comp_rds[resource_type].type;
+}
+
+char *comp_resource_get_uri_prefix(comp_resource_type_e resource_type)
+{
+ return comp_rds[resource_type].uri_prefix;
+}
+
+uint8_t comp_resource_get_policies(comp_resource_type_e resource_type)
+{
+ return comp_rds[resource_type].policies;
+}
+
+void __print_foreach_resource(gpointer data, gpointer user_data)
+{
+ comp_re_t *re = (comp_re_t *)data;
+ LOG_DEBUG(" ** resource : %x, uri : %s", re->resource, re->uri);
+}
+
+void comp_resource_print_list()
+{
+ comp_context_t *comp_ctx = comp_context_get_context();
+
+ LOG_DEBUG("-------------------Print resource list-----------------------");
+
+ for (int i = 0; i < COMP_RESOURCE_TYPE_MAX; i++) {
+ LOG_DEBUG("Resource type %d list length : %d", i, g_list_length(comp_ctx->resource_list[i]));
+ g_list_foreach(comp_ctx->resource_list[i], __print_foreach_resource, NULL);
+ }
+
+ LOG_DEBUG("-------------------Print resource list end-------------------");
+}
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!DOCTYPE node PUBLIC
+ "-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
+ "http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
+
+<node>
+ <interface name="org.tizen.companion.group">
+ <!-- Method definitions -->
+ <method name="Create">
+ <arg type="s" name="group_name" direction="in"/>
+ <arg type="i" name="result" direction="out"/>
+ </method>
+ <method name="Find">
+ <arg type="i" name="timeout" direction="in" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+ <method name="GetFoundGroups">
+ <arg type="i" name="result" direction="out" />
+ <arg type="aa{sv}" name="groups" direction="out" />
+ </method>
+ <method name="Join">
+ <arg type="i" name="group_count" direction="out" />
+ <arg type="aa{sv}" name="groups" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+ <method name="Leave">
+ <arg type="i" name="group_count" direction="out" />
+ <arg type="aa{sv}" name="groups" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+ <method name="Delete">
+ <arg type="i" name="group_count" direction="out" />
+ <arg type="aa{sv}" name="groups" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+ <method name="DeviceFind">
+ <arg type="i" name="group_count" direction="out" />
+ <arg type="aa{sv}" name="groups" direction="out" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+ <method name="DeviceInvite">
+ <arg type="s" name="uuid" direction="in" />
+ <arg type="s" name="pin" direction="in" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+ <method name="DeviceEject">
+ <arg type="s" name="uuid" direction="in" />
+ <arg type="i" name="result" direction="out" />
+ </method>
+
+ <!-- Signal (D-Bus) definitions -->
+ <signal name="GroupFound">
+ <arg type="a{sv}" name="group_info" direction="out" />
+ </signal>
+ <signal name="Finish">
+ <arg type="i" name="result" direction="out" />
+ </signal>
+ <signal name="DeviceInviteResult">
+ <arg type="i" name="result" direction="out" />
+ </signal>
+ <signal name="DeviceEjectResult">
+ <arg type="i" name="result" direction="out" />
+ </signal>
+ </interface>
+</node>
--- /dev/null
+gdbus-codegen --interface-prefix org.tizen.companion \
+ --generate-c-code companion_gdbus \
+ --c-generate-object-manager \
+ companion_gdbus.xml \
+++ /dev/null
-MESSAGE("===================================================================")
-MESSAGE("Building...fn-manager")
-MESSAGE("===================================================================")
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-
-FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
-EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
- " \\
- --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/src/familynet_gdbus \\
- --interface-prefix org.tizen.familynet. \\
- ${CMAKE_CURRENT_SOURCE_DIR}/src/familynet_gdbus.xml \\
- ")
-
-MESSAGE(" - Set source folder")
-FILE(GLOB FN_MANAGER_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c)
-
-SET(FN_MANAGER "fn-manager")
-ADD_EXECUTABLE(${FN_MANAGER} ${FN_MANAGER_SRCS})
-TARGET_LINK_LIBRARIES(${FN_MANAGER} ${daemon_pkgs_LIBRARIES} pthread)
-INSTALL(TARGETS ${FN_MANAGER} DESTINATION bin)
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *****************************************************************/
- #ifndef __COMP_MOT_AGENT_H__
- #define __COMP_MOT_AGENT_H__
-
- int agent_dbus_start();
-int agent_dbus_stop();
-
-int agent_enable();
-int agent_disable();
-int agent_get_ownerid(char* deviceid);
-int agent_find_mot_enable_devices();
-int agent_find_mowned_devices();
-int agent_mot_device(char* uuid_str, char *pin);
-int agent_pairwise(char* target1, char *subject1, char *uri1,
- char *rt1, char *interface1, int permission1, char* target2, char *subject2, char *uri2,
- char *rt2, char *interface2, int permission2);
-int agent_remove_mo_at_device(char* uuid_str);
-int agent_remove_myowned_device(char* uuid_str);
-
- #endif /* __COMP_MOT_AGENT_H__ */
\ No newline at end of file
+++ /dev/null
-#ifndef __FN_CONTEXT_H__
-#define __FN_CONTEXT_H__
-
-#include <glib.h>
-#include <fn_log.h>
-#include <unistd.h>
-#include <gio/gio.h>
-#include <familynet_gdbus.h>
-#include <sys/types.h>
-
-typedef struct {
- GMainLoop *main_loop;
- //GDBusConnection *connection;
-
- // resource list
- GList *resource_list[FN_RESOURCE_TYPE_MAX];
-
- char *device_uuid;
- int operation_resource_count;
-} fn_context_t;
-
-int fn_context_create();
-int fn_context_destroy();
-void fn_context_mutex_lock();
-void fn_context_mutex_unlock();
-
-fn_context_t *fn_context_get_context();
-
-#endif
+++ /dev/null
-#ifndef __FN_ENUM_H__
-#define __FN_ENUM_H__
-
-#include <tizen.h>
-
-#define TIZEN_ERROR_FN 0
-
-/* error enum */
-typedef enum {
- FN_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
- FN_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
- FN_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- FN_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
- FN_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
- FN_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
- FN_ERROR_COMM_ERROR = TIZEN_ERROR_FN | 0x01, /**< communication error */
- FN_ERROR_RX = TIZEN_ERROR_FN | 0x02, /**< RX error */
- FN_ERROR_TX = TIZEN_ERROR_FN | 0x03, /**< TX error */
- FN_ERROR_PLUGIN_FAIL = TIZEN_ERROR_FN | 0x04, /**< Plugin failed */
- FN_ERROR_OPERATION_FAILED = TIZEN_ERROR_FN | 0x05, /**< Operation Failed */
- FN_ERROR_ALREADY_IN_PROGRESS = TIZEN_ERROR_FN | 0x06, /**< Already initilized */
- FN_ERROR_UNKNOWN = -999,
-} fn_error_e;
-
-/* resource type enum */
-typedef enum {
- FN_RESOURCE_TYPE_GROUP = 0,
- FN_RESOURCE_TYPE_OPERATION,
- FN_RESOURCE_TYPE_MAX
-} fn_resource_type_e;
-
-/* group type enum */
-typedef enum {
- FN_GROUP_DEVICE = 0,
- FN_GROUP_REMOTE_DEVICE,
-} fn_group_type_e;
-
-#endif
+++ /dev/null
-#ifndef __FN_GDBUS_H__
-#define __FN_GDBUS_H__
-
-#include <fn_gdbus_group.h>
-
-#define FN_DBUS_SERVICE "org.tizen.familynet"
-#define FN_DBUS_GROUP_PATH "/org/tizen/familynet/group"
-
-int fn_gdbus_init();
-
-#endif
+++ /dev/null
-#ifndef __FN_GDBUS_GROUP_H__
-#define __FN_GDBUS_GROUP_H__
-
-#include <fn_group.h>
-
-Group *group_dbus_get_object();
-
-gboolean group_create(Group *group, GDBusMethodInvocation *invocation, gchar *group_name,
- gpointer user_data);
-
-gboolean group_find(Group *group, GDBusMethodInvocation *invocation, gint timeout,
- gpointer user_data);
-
-gboolean group_get_found_groups(Group *group, GDBusMethodInvocation *invocation,
- gpointer user_data);
-
-gboolean group_join(Group *group, GDBusMethodInvocation *invocation,
- gpointer user_data);
-
-gboolean group_leave(Group *group, GDBusMethodInvocation *invocation,
- gpointer user_data);
-
-gboolean group_delete(Group *group, GDBusMethodInvocation *invocation,
- gpointer user_data);
-
-gboolean group_device_find(Group *group, GDBusMethodInvocation *invocation,
- gpointer user_data);
-
-gboolean group_device_invite(Group *group, GDBusMethodInvocation *invocation,
- gchar *uuid, gchar *pin, gpointer user_data);
-
-gboolean group_device_eject(Group *group, GDBusMethodInvocation *invocation,
- gchar *uuid, gpointer user_data);
-
-void notify_group_found(GVariant *group_data);
-void notify_group_finish(int ret);
-void notify_group_device_invite_result(int ret);
-void notify_group_device_eject_result(int ret);
-
-#endif
+++ /dev/null
-#ifndef __FN_GROUP_H__
-#define __FN_GROUP_H__
-
-#include <fn_iot.h>
-
-typedef struct {
- char *uri_path;
- char *device_id;
- char *host_addr;
- char *group_name;
- char *resource_type;
- fn_group_type_e type;
-} fn_group_t;
-
-/* Called when daemon is start. */
-int fn_group_initialize();
-
-/* create group and destroy */
-int fn_group_create(char* name);
-int fn_group_destroy(fn_group_t *handle);
-
-/* Find Remote groups */
-int fn_group_find(int timeout);
-GVariant *fn_group_get_found_groups();
-int fn_group_add_new(char *uri_path, char *device_id, char *device_name,
- char *host_addr, char *resource_type, fn_group_type_e type);
-
-/* Join the remote devices in my daemon */
-int fn_group_get_groups(fn_group_t ***handles, int *count); //Get all of group in my daemon
-int fn_group_get_remote_devices(/* callback */); //Get all of device in network (Async)
-
-char *fn_group_invite_get_uuid();
-char *fn_group_invite_get_pin();
-//Join to device in group (async)
-int fn_group_invite(gchar *uuid, gchar *pin);
-void fn_group_notify_group_invite(int result);
-
-//dismiss from group (async)
-int fn_group_dismiss(gchar *uuid);
-void fn_group_notify_group_dismiss(int result);
-
-/* Join to remote device group */
-int fn_group_get_remote_groups(/* callback */); //Get all of group in network (Async)
-int fn_group_join_to(/* callback */); //Join this device to in certain remote group (Async)
-int fn_group_leave_from(/* callback */); //leave from certain remote group (Async)
-
-/* Called when daemon is end. */
-int fn_group_deinitialize();
-
-int fn_group_get_group_name(fn_group_t *handle, char **name);
-int fn_group_get_group_type(fn_group_t *handle, int *type);
-int fn_group_get_group_device_type(fn_group_t *handle);
-int fn_group_get_group_device_id(fn_group_t *handle);
-
-/* notify */
-int fn_group_event_handler(/*callback*/); // event hadnler
-
-#endif
+++ /dev/null
-#ifndef __FN_IOT_H__
-#define __FN_IOT_H__
-
-#include <fn_resource.h>
-
-#define SVR_PATH "/tmp/.svr.dat"
-
-int fn_iot_initialize();
-int fn_iot_add_resource(fn_resource_type_e resource_type, char *uri);
-int fn_iot_delete_resource(fn_resource_type_e resource_type);
-int fn_iot_discovery_resource(fn_resource_type_e resource_type, int timeout);
-int fn_iot_deinitialize();
-
-#endif
+++ /dev/null
-#ifndef __FN_LOG_H__
-#define __FN_LOG_H__
-
-#include <dlog.h>
-#include <fn_enum.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define COLOR_RED "\033[0;31m"
-#define COLOR_GREEN "\033[0;32m"
-#define COLOR_BROWN "\033[0;33m"
-#define COLOR_BLUE "\033[0;34m"
-#define COLOR_PURPLE "\033[0;35m"
-#define COLOR_CYAN "\033[0;36m"
-#define COLOR_LIGHTBLUE "\033[0;37m"
-#define COLOR_END "\033[0;m"
-
-#define LOG_TAG "FN_MANAGER"
-
-#define LOG_DEBUG(fmt, ...) \
- do { \
- LOGD(COLOR_BROWN" " fmt COLOR_END, ##__VA_ARGS__); \
- } while (0)
-#define LOG_ERR(fmt, ...) \
- do { \
- LOGE(COLOR_RED" " fmt COLOR_END, ##__VA_ARGS__); \
- } while (0)
-#define LOG_BEGIN() \
- do { \
- LOGD(COLOR_BLUE "BEGIN >>>>"COLOR_END); \
- } while (0)
-#define LOG_END() \
- do { \
- LOGD(COLOR_BLUE "END <<<<"COLOR_END); \
- } while (0)
-
-const char *fn_log_get_error_string(int result);
-
-#endif
+++ /dev/null
-#ifndef __FN_MANAGER_H__
-#define __FN_MANAGER_H__
-
-#include <fn_log.h>
-#include <fn_group.h>
-#include <fn_resource.h>
-#include <fn_gdbus.h>
-
-#endif
+++ /dev/null
-#ifndef __FN_RESOURCE_H__
-#define __FN_RESOURCE_H__
-
-#include <iotcon.h>
-#include <fn_context.h>
-
-typedef struct {
- fn_resource_type_e resource_type;
- char *type;
- char *uri_prefix;
- uint8_t policies;
-} fn_rd_t;
-
-typedef struct {
- iotcon_resource_h resource;
- char *uri;
-} fn_re_t;
-
-int fn_resource_append(fn_resource_type_e resource_type, char *uri, iotcon_resource_h resource);
-char *fn_resource_get_type(fn_resource_type_e resource_type);
-char *fn_resource_get_uri_prefix(fn_resource_type_e resource_type);
-uint8_t fn_resource_get_policies(fn_resource_type_e resource_type);
-void fn_resource_print_list();
-int fn_resource_get_resource_from_uri(fn_resource_type_e resource_type,
- char *uri, iotcon_resource_h *parent_resource);
-
-#endif
+++ /dev/null
-/******************************************************************
- *
- * Copyright 2016 Samsung Electronics All Rights Reserved.
- *
- *
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *****************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <error.h>
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#include <fn_log.h>
-#include <fn_enum.h>
-
-#define AGENT_SERVER_NAME "net.d2ds"
-#define AGENT_OBJECT_PATH "/net/d2ds"
-#define AGENT_SERVICE_INTERFACE "net.d2ds"
-
-#define AGENT_ENABLER_NAME "net.d2ds.enabler"
-#define AGENT_ENABLER_OBJ_PATH "/net/d2ds/enabler"
-#define AGENT_ENABLER_INTERFACE "net.d2ds.enabler"
-
-#define NOTUSED(var) (var = var)
-
-#define AGENT_DBUS_PROXY_TIMEOUT ((9.5 + 2) * 1000) /**< default timeout for GDBus */
-
-struct agent_s {
- GDBusProxy *gproxy_agent_service;
- gpointer dbus_connection;
- GCancellable *ca;
- GList *dbus_sub_ids;
-};
-struct agent_s agent;
-
-int agent_get_ownerid(char* deviceid)
-{
- GVariant *variant = NULL;
- int result = FN_ERROR_NONE;
- GError *error = NULL;
-
- if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
- LOG_ERR("I/O error");
- return FN_ERROR_IO_ERROR;
- }
-
- variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "get_ownerid",
- NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (variant) {
- g_variant_get(variant, "(si)", deviceid, &result);
- LOGD("get_ownerid status 0x%x", result);
- } else if (error) {
- LOGE("Failed DBus call [%s]", error->message);
- g_error_free(error);
- return FN_ERROR_IO_ERROR;
- }
-
- return result;
-}
-
-int agent_find_mot_enable_devices()
-{
- GVariant *variant = NULL;
- int result = FN_ERROR_NONE;
- GError *error = NULL;
-
- if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
- LOG_ERR("I/O error");
- return FN_ERROR_IO_ERROR;
- }
-
- variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "disc_mot_enb_devs",
- NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (variant) {
- g_variant_get(variant, "(i)", &result);
- LOGD("disc_mot_enb_devs status 0x%x", result);
- } else if (error) {
- LOGE("Failed DBus call [%s]", error->message);
- g_error_free(error);
- return FN_ERROR_IO_ERROR;
- }
-
- return result;
-}
-
-int agent_find_mowned_devices()
-{
- GVariant *variant = NULL;
- int result = FN_ERROR_NONE;
- GError *error = NULL;
-
- if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
- LOG_ERR("I/O error");
- return FN_ERROR_IO_ERROR;
- }
-
- variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "disc_mowned_devs",
- NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (variant) {
- g_variant_get(variant, "(i)", &result);
- LOGD("disc_mowned_devs status 0x%x", result);
- } else if (error) {
- LOGE("Failed DBus call [%s]", error->message);
- g_error_free(error);
- return FN_ERROR_IO_ERROR;
- }
-
- return result;
-}
-
-int agent_mot_device(char* uuid_str, char *pin)
-{
- GVariant *variant = NULL;
- int result = FN_ERROR_NONE;
- GError *error = NULL;
-
- if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
- LOG_ERR("I/O error");
- return FN_ERROR_IO_ERROR;
- }
-
- variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "mot",
- g_variant_new("(ss)", uuid_str, pin), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (variant) {
- g_variant_get(variant, "(i)", &result);
- LOGD("mot status 0x%x", result);
- } else if (error) {
- LOGE("Failed DBus call [%s]", error->message);
- g_error_free(error);
- return FN_ERROR_IO_ERROR;
- }
-
- return result;
-}
-
-int agent_pairwise(char* target1, char *subject1, char *uri1,
- char *rt1, char *interface1, int permission1, char* target2, char *subject2, char *uri2,
- char *rt2, char *interface2, int permission2)
-{
- GVariant *variant = NULL;
- int result = FN_ERROR_NONE;
- GError *error = NULL;
-
- if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
- LOG_ERR("I/O error");
- return FN_ERROR_IO_ERROR;
- }
-
- variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "pairwise",
- g_variant_new("(sssssisssssi)",
- target1, subject1, uri1, rt1, interface1, permission1,
- target2, subject2, uri2, rt2, interface2, permission2),
- G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (variant) {
- g_variant_get(variant, "(i)", &result);
- LOGD("pairwise status 0x%x", result);
- } else if (error) {
- LOGE("Failed DBus call [%s]", error->message);
- g_error_free(error);
- return FN_ERROR_IO_ERROR;
- }
-
- return result;
-}
-
-int agent_remove_mo_at_device(char* uuid_str)
-{
- GVariant *variant = NULL;
- int result = FN_ERROR_NONE;
- GError *error = NULL;
-
- if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
- LOG_ERR("I/O error");
- return FN_ERROR_IO_ERROR;
- }
-
- variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "remove_mo",
- g_variant_new("(s)", uuid_str), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (variant) {
- g_variant_get(variant, "(i)", &result);
- LOGD("remove_mo status 0x%x", result);
- } else if (error) {
- LOGE("Failed DBus call [%s]", error->message);
- g_error_free(error);
- return FN_ERROR_IO_ERROR;
- }
-
- return result;
-}
-
-int agent_remove_myowned_device(char* uuid_str)
-{
- GVariant *variant = NULL;
- int result = FN_ERROR_NONE;
- GError *error = NULL;
-
- if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
- LOG_ERR("I/O error");
- return FN_ERROR_IO_ERROR;
- }
-
- variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "unpair",
- g_variant_new("(s)", uuid_str), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (variant) {
- g_variant_get(variant, "(i)", &result);
- LOGD("remove_mo status 0x%x", result);
- } else if (error) {
- LOGE("Failed DBus call [%s]", error->message);
- g_error_free(error);
- return FN_ERROR_IO_ERROR;
- }
-
- return result;
-}
-
-int agent_enable()
-{
- GVariant *variant = NULL;
- int result = FN_ERROR_NONE;
- GError *error = NULL;
-
- if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
- LOG_ERR("I/O error");
- return FN_ERROR_IO_ERROR;
- }
-
- variant = g_dbus_connection_call_sync(agent.dbus_connection,
- AGENT_ENABLER_NAME, AGENT_ENABLER_OBJ_PATH, AGENT_ENABLER_INTERFACE,
- "enable", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (variant) {
- g_variant_get(variant, "(i)", &result);
- LOG_DEBUG("MOT Agent Enabled status 0x%x", result);
- } else if (error) {
- LOGE("Failed DBus call [%s]", error->message);
- g_error_free(error);
- return FN_ERROR_IO_ERROR;
- }
-
- return result;
-}
-
-int agent_disable()
-{
- GVariant *variant = NULL;
- int result = FN_ERROR_NONE;
- GError *error = NULL;
-
- if (NULL == agent.dbus_connection || NULL == agent.gproxy_agent_service) {
- LOG_ERR("I/O error");
- return FN_ERROR_IO_ERROR;
- }
-
- variant = g_dbus_connection_call_sync(agent.dbus_connection,
- AGENT_ENABLER_NAME, AGENT_ENABLER_OBJ_PATH, AGENT_ENABLER_INTERFACE,
- "disable", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
- if (variant) {
- g_variant_get(variant, "(i)", &result);
- LOG_DEBUG("MOT Agent Disabled status 0x%x", result);
- } else if (error) {
- LOGE("Failed DBus call [%s]", error->message);
- g_error_free(error);
- return FN_ERROR_IO_ERROR;
- }
- return result;
-}
-
-static int _close_gdbus_call()
-{
- /* CHECK: is connection ref count required? */
- g_object_unref(agent.dbus_connection);
- agent.dbus_connection = NULL;
-
- return FN_ERROR_NONE;
-}
-
-static void _dbus_name_owner_notify(GObject *object, GParamSpec *pspec,
- gpointer *userdata)
-{
- GDBusProxy *proxy = G_DBUS_PROXY(object);
- gchar *name_owner = g_dbus_proxy_get_name_owner(proxy);
-
- NOTUSED(userdata);
-
- LOG_DEBUG("Name owner notify [%s]", name_owner);
-
- if (NULL == name_owner)
- _close_gdbus_call( );
-
- g_free(name_owner);
-}
-
-static int _create_gdbus_call()
-{
- int id;
- GError *error = NULL;
-
- if (agent.dbus_connection != NULL)
- return FN_ERROR_ALREADY_IN_PROGRESS;
-
- agent.dbus_connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (NULL == agent.dbus_connection) {
- if (error != NULL) {
- LOG_ERR("Failed to connect to the D-BUS daemon [%s]", error->message);
- g_error_free(error);
- }
- return FN_ERROR_IO_ERROR;
- }
-
- id = g_signal_connect(agent.dbus_connection, "notify::g-name-owner",
- G_CALLBACK(_dbus_name_owner_notify), &agent);
- if (0 == id) {
- LOGE("g_signal_connect() Fail");
- g_object_unref(agent.dbus_connection);
- agent.dbus_connection = NULL;
- return FN_ERROR_IO_ERROR;
- }
-
- return FN_ERROR_NONE;
-}
-
-static GDBusProxy *_get_proxy_service()
-{
- GDBusProxy *proxy = NULL;
-
- if (NULL == agent.gproxy_agent_service) {
- proxy = g_dbus_proxy_new_sync(agent.dbus_connection, G_DBUS_PROXY_FLAGS_NONE, NULL,
- AGENT_SERVER_NAME, AGENT_OBJECT_PATH, AGENT_SERVICE_INTERFACE,
- NULL, NULL);
- } else
- proxy = agent.gproxy_agent_service;
-
- return proxy;
-}
-
-static gboolean __perform_mot(gpointer data)
-{
- int ret;
- char *uuid, *pin;
-
- uuid = fn_group_invite_get_uuid();
- pin = fn_group_invite_get_pin();
-
- LOG_DEBUG("Perform MOT uuid: %s pin: %s", uuid, pin);
-
- ret = agent_mot_device(uuid, pin);
-
- if (ret != FN_ERROR_NONE)
- fn_group_notify_group_invite(ret);
-}
-
-static void _agent_signal_handler(GDBusConnection *connection,
- const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
- const gchar *signal_name, GVariant *parameters, gpointer userdata)
-{
- int result = FN_ERROR_NONE;
- struct agent_s *h = userdata;
-
- if (NULL == h) {
- LOG_ERR("user_data is null");
- return;
- }
-
- LOG_DEBUG("signal received = %s", signal_name);
-
- if (0 == g_strcmp0(signal_name, "subowner_enabled")) {
- g_variant_get(parameters, "(i)", &result);
- LOG_DEBUG("Result : %d", result);
- } else if (0 == g_strcmp0(signal_name, "disc_mot_enb_devs_done")) {
- GVariantIter *iter = NULL;
- GVariantIter *iter_row = NULL;
-
- gchar *key;
- GVariant *val;
- gsize len = 0;
- int mot_enb_devs_cnt = 0;
-
- if (NULL == parameters) {
- LOG_ERR("No MOT enabled devices found");
- return;
- }
- g_variant_get(parameters, "(aa{sv})", &iter);
- while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
- while (g_variant_iter_loop(iter_row, "{sv}", &key, &val)) {
- if (strcasecmp(key, "deviceId") == 0) {
- const char *deviceid = g_variant_get_string(val, &len);
- LOG_DEBUG("deviceId=%s", deviceid);
- } else if (strcasecmp(key, "adapter") == 0) {
- int adapter = g_variant_get_uint32(val);
- LOG_DEBUG("adapter = %d", adapter);
- } else if (strcasecmp(key, "adapter") == 0) {
- int flags = g_variant_get_uint32(val);
- LOG_DEBUG("flags = %d", flags);
- } else if (strcasecmp(key, "port") == 0) {
- int port = g_variant_get_uint16(val);
- LOG_DEBUG("port = %d", port);
- } else if (strcasecmp(key, "addr") == 0) {
- const char *addr = g_variant_get_string(val, &len);
- LOG_DEBUG("addr=%s", addr);
- } else if (strcasecmp(key, "ifindex") == 0) {
- int ifindex = g_variant_get_uint32(val);
- LOG_DEBUG("ifindex = %d", ifindex);
- } else if (strcasecmp(key, "routeData") == 0) {
- const char *routeData = g_variant_get_string(val, &len);
- LOG_DEBUG("routeData=%s", routeData);
- } else if (strcasecmp(key, "remoteId") == 0) {
- const char *remoteId = g_variant_get_string(val, &len);
- LOG_DEBUG("remoteId=%s", remoteId);
- } else if (strcasecmp(key, "connType") == 0) {
- int connType = g_variant_get_uint32(val);
- LOG_DEBUG("connType = %d", connType);
- } else if (strcasecmp(key, "securePort") == 0) {
- int securePort = g_variant_get_uint16(val);
- LOG_DEBUG("securePort = %d", securePort);
-#ifdef WITH_TCP
- } else if (strcasecmp(key, "tcpPort") == 0) {
- int tcpPort = g_variant_get_uint16(val);
- LOG_DEBUG("tcpPort = %d", tcpPort);
- }
-#endif
- else if (strcasecmp(key, "secVer") == 0) {
- const char *secVer = g_variant_get_string(val, &len);
- LOG_DEBUG("secVer=%s", secVer);
- } else if (strcasecmp(key, "ifindex") == 0) {
- int devStatus = g_variant_get_uint32(val);
- LOG_DEBUG("devStatus = %d", devStatus);
- }
- }
- g_variant_iter_free(iter_row);
- mot_enb_devs_cnt += 1;
- }
-
- g_variant_iter_free(iter);
-
- LOG_DEBUG("mot_enb_devs_cnt = %d", mot_enb_devs_cnt);
-
- if (mot_enb_devs_cnt > 0) // do mot
- g_idle_add(__perform_mot, NULL);
- else // No device notify group invite fail
- fn_group_notify_group_invite(FN_ERROR_OPERATION_FAILED);
-
- } else if (0 == g_strcmp0(signal_name, "disc_mowned_devs_done")) {
- GVariantIter *iter = NULL;
- GVariantIter *iter_row = NULL;
-
- gchar *key;
- GVariant *val;
- gsize len = 0;
-
- if (NULL == parameters) {
- LOG_ERR("No Multiple Owned devices found");
- return;
- }
- g_variant_get(parameters, "(aa{sv})", &iter);
- while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
- while (g_variant_iter_loop(iter_row, "{sv}", &key, &val)) {
- if (strcasecmp(key, "deviceId") == 0) {
- const char *deviceid = g_variant_get_string(val, &len);
- LOG_DEBUG("deviceId=%s", deviceid);
- } else if (strcasecmp(key, "adapter") == 0) {
- int adapter = g_variant_get_uint32(val);
- LOG_DEBUG("adapter = %d", adapter);
- } else if (strcasecmp(key, "adapter") == 0) {
- int flags = g_variant_get_uint32(val);
- LOG_DEBUG("flags = %d", flags);
- } else if (strcasecmp(key, "port") == 0) {
- int port = g_variant_get_uint16(val);
- LOG_DEBUG("port = %d", port);
- } else if (strcasecmp(key, "addr") == 0) {
- const char *addr = g_variant_get_string(val, &len);
- LOG_DEBUG("addr=%s", addr);
- } else if (strcasecmp(key, "ifindex") == 0) {
- int ifindex = g_variant_get_uint32(val);
- LOG_DEBUG("ifindex = %d", ifindex);
- } else if (strcasecmp(key, "routeData") == 0) {
- const char *routeData = g_variant_get_string(val, &len);
- LOG_DEBUG("routeData=%s", routeData);
- } else if (strcasecmp(key, "remoteId") == 0) {
- const char *remoteId = g_variant_get_string(val, &len);
- LOG_DEBUG("remoteId=%s", remoteId);
- } else if (strcasecmp(key, "connType") == 0) {
- int connType = g_variant_get_uint32(val);
- LOG_DEBUG("connType = %d", connType);
- } else if (strcasecmp(key, "securePort") == 0) {
- int securePort = g_variant_get_uint16(val);
- LOG_DEBUG("securePort = %d", securePort);
-#ifdef WITH_TCP
- } else if (strcasecmp(key, "tcpPort") == 0) {
- int tcpPort = g_variant_get_uint16(val);
- LOG_DEBUG("tcpPort = %d", tcpPort);
- }
-#endif
- else if (strcasecmp(key, "secVer") == 0) {
- const char *secVer = g_variant_get_string(val, &len);
- LOG_DEBUG("secVer=%s", secVer);
- } else if (strcasecmp(key, "ifindex") == 0) {
- int devStatus = g_variant_get_uint32(val);
- LOG_DEBUG("devStatus = %d", devStatus);
- }
- }
- g_variant_iter_free(iter_row);
- }
- g_variant_iter_free(iter);
- } else if (0 == g_strcmp0(signal_name, "acl_done")) {
- g_variant_get(parameters, "(i)", &result);
- LOG_DEBUG("Result : %d", result);
- } else if (0 == g_strcmp0(signal_name, "cred_done")) {
- g_variant_get(parameters, "(i)", &result);
- LOG_DEBUG("Result : %d", result);
- } else if (0 == g_strcmp0(signal_name, "mot_done")) {
- g_variant_get(parameters, "(i)", &result);
- LOG_DEBUG("Result : %d", result);
-
- fn_group_notify_group_invite(result);
- } else if (0 == g_strcmp0(signal_name, "remove_mo_done")) {
- g_variant_get(parameters, "(i)", &result);
- LOG_DEBUG("Result : %d", result);
-
- fn_group_notify_group_dismiss(result);
- } else if (0 == g_strcmp0(signal_name, "pairwise_done")) {
- g_variant_get(parameters, "(i)", &result);
- LOG_DEBUG("Result : %d", result);
- } else if (0 == g_strcmp0(signal_name, "unpair_done")) {
- g_variant_get(parameters, "(i)", &result);
- LOG_DEBUG("Result : %d", result);
- }
-}
-static int _subscribe_event()
-{
- unsigned int id;
- struct agent_s *h = &agent;
-
- /* subowner_enabled */
- id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
- "subowner_enabled", AGENT_OBJECT_PATH, NULL,
- G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
- if (0 == id) {
- LOG_ERR("g_dbus_connection_signal_subscribe(subowner_enabled) Fail(%d)", errno);
- return -1;
- }
- h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
- LOG_DEBUG("subscribed for (subowner_enabled) signal %d", id);
-
- /* disc_mot_enb_devs_done */
- id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
- "disc_mot_enb_devs_done", AGENT_OBJECT_PATH, NULL,
- G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
- if (0 == id) {
- LOG_ERR("g_dbus_connection_signal_subscribe(disc_mot_enb_devs_done) Fail(%d)", errno);
- return -1;
- }
- h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
- LOG_DEBUG("subscribed for (disc_mot_enb_devs_done) signal %d", id);
-
- /* disc_mowned_devs_done */
- id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
- "disc_mowned_devs_done", AGENT_OBJECT_PATH, NULL,
- G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
- if (0 == id) {
- LOG_ERR("g_dbus_connection_signal_subscribe(disc_mowned_devs_done) Fail(%d)", errno);
- return -1;
- }
- h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
- LOG_DEBUG("subscribed for (disc_mowned_devs_done) signal %d", id);
-
- /* mot_done */
- id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
- "mot_done", AGENT_OBJECT_PATH, NULL,
- G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
- if (0 == id) {
- LOG_ERR("g_dbus_connection_signal_subscribe(mot_done) Fail(%d)", errno);
- return -1;
- }
- h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
- LOG_DEBUG("subscribed for (mot_done) signal %d", id);
-
- /* remove_mo_done */
- id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
- "remove_mo_done", AGENT_OBJECT_PATH, NULL,
- G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
- if (0 == id) {
- LOG_ERR("g_dbus_connection_signal_subscribe(remove_mo_done) Fail(%d)", errno);
- return -1;
- }
- h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
- LOG_DEBUG("subscribed for (remove_mo_done) signal %d", id);
-
- /* acl_done */
- id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
- "acl_done", AGENT_OBJECT_PATH, NULL,
- G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
- if (0 == id) {
- LOG_ERR("g_dbus_connection_signal_subscribe(acl_done) Fail(%d)", errno);
- return -1;
- }
- h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
- LOG_DEBUG("subscribed for (acl_done) signal %d", id);
-
- /*cred_done */
- id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
- "cred_done", AGENT_OBJECT_PATH, NULL,
- G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
- if (0 == id) {
- LOG_ERR("g_dbus_connection_signal_subscribe(cred_done) Fail(%d)", errno);
- return -1;
- }
- h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
- LOG_DEBUG("subscribed for (cred_done) signal %d", id);
-
- /*unpair_done */
- id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
- "unpair_done", AGENT_OBJECT_PATH, NULL,
- G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
- if (0 == id) {
- LOG_ERR("g_dbus_connection_signal_subscribe(unpair_done) Fail(%d)", errno);
- return -1;
- }
- h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
- LOG_DEBUG("subscribed for (unpair_done) signal %d", id);
-
- /*pairwise_done */
- id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL, AGENT_SERVER_NAME,
- "pairwise_done", AGENT_OBJECT_PATH, NULL,
- G_DBUS_CALL_FLAGS_NONE, _agent_signal_handler, h, NULL);
- if (0 == id) {
- LOG_ERR("g_dbus_connection_signal_subscribe(pairwise_done) Fail(%d)", errno);
- return -1;
- }
- h->dbus_sub_ids = g_list_append(h->dbus_sub_ids, GUINT_TO_POINTER(id));
- LOG_DEBUG("subscribed for (pairwise_done) signal %d", id);
-
- return 0;
-}
-
-static void _on_unsubscribe_ids(gpointer data, gpointer userdata)
-{
- unsigned int id = GPOINTER_TO_UINT(data);
- struct agent_s *h = (struct agent_s*)userdata;
- if (NULL == h) {
- LOG_ERR("Invaild parameter");
- return;
- }
- LOG_DEBUG("[Signal unsubscribe] : %d", id);
- g_dbus_connection_signal_unsubscribe(h->dbus_connection, id);
-}
-static void _unsubscribe_event()
-{
- g_list_foreach(agent.dbus_sub_ids, _on_unsubscribe_ids, &agent);
- g_list_free(agent.dbus_sub_ids);
- agent.dbus_sub_ids = NULL;
-}
-
-int agent_dbus_start( )
-{
- int ret = FN_ERROR_NONE;
-
- ret = _create_gdbus_call();
- if (FN_ERROR_NONE != ret)
- return ret;
-
- agent.ca = g_cancellable_new();
-
- /* Create all proxies here */
- agent.gproxy_agent_service = _get_proxy_service();
- if (NULL == agent.gproxy_agent_service) {
- LOG_ERR("Couldn't get _get_proxy_service");
- return FN_ERROR_IO_ERROR;
- }
-
- g_dbus_proxy_set_default_timeout(
- G_DBUS_PROXY(agent.gproxy_agent_service), AGENT_DBUS_PROXY_TIMEOUT);
-
- /* Subscribe events */
- _subscribe_event();
-
- return FN_ERROR_NONE;
-}
-
-int agent_dbus_stop()
-{
- int ret = FN_ERROR_NONE;
-
- _unsubscribe_event();
-
- /* Unref all proxies here */
- if (agent.gproxy_agent_service) {
- g_object_unref(agent.gproxy_agent_service);
- agent.gproxy_agent_service = NULL;
- }
-
- g_cancellable_cancel(agent.ca);
- g_object_unref(agent.ca);
- agent.ca = NULL;
-
- ret = _close_gdbus_call();
- return ret;
-}
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<!DOCTYPE node PUBLIC
- "-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
- "http://standards.freedesktop.org/dbus/1.0/introspect.dtd">
-
-<node>
- <interface name="org.tizen.familynet.group">
- <!-- Method definitions -->
- <method name="Create">
- <arg type="s" name="group_name" direction="in"/>
- <arg type="i" name="result" direction="out"/>
- </method>
- <method name="Find">
- <arg type="i" name="timeout" direction="in" />
- <arg type="i" name="result" direction="out" />
- </method>
- <method name="GetFoundGroups">
- <arg type="i" name="result" direction="out" />
- <arg type="aa{sv}" name="groups" direction="out" />
- </method>
- <method name="Join">
- <arg type="i" name="group_count" direction="out" />
- <arg type="aa{sv}" name="groups" direction="out" />
- <arg type="i" name="result" direction="out" />
- </method>
- <method name="Leave">
- <arg type="i" name="group_count" direction="out" />
- <arg type="aa{sv}" name="groups" direction="out" />
- <arg type="i" name="result" direction="out" />
- </method>
- <method name="Delete">
- <arg type="i" name="group_count" direction="out" />
- <arg type="aa{sv}" name="groups" direction="out" />
- <arg type="i" name="result" direction="out" />
- </method>
- <method name="DeviceFind">
- <arg type="i" name="group_count" direction="out" />
- <arg type="aa{sv}" name="groups" direction="out" />
- <arg type="i" name="result" direction="out" />
- </method>
- <method name="DeviceInvite">
- <arg type="s" name="uuid" direction="in" />
- <arg type="s" name="pin" direction="in" />
- <arg type="i" name="result" direction="out" />
- </method>
- <method name="DeviceEject">
- <arg type="s" name="uuid" direction="in" />
- <arg type="i" name="result" direction="out" />
- </method>
-
- <!-- Signal (D-Bus) definitions -->
- <signal name="GroupFound">
- <arg type="a{sv}" name="group_info" direction="out" />
- </signal>
- <signal name="Finish">
- <arg type="i" name="result" direction="out" />
- </signal>
- <signal name="DeviceInviteResult">
- <arg type="i" name="result" direction="out" />
- </signal>
- <signal name="DeviceEjectResult">
- <arg type="i" name="result" direction="out" />
- </signal>
- </interface>
-</node>
+++ /dev/null
-#include <fn_context.h>
-
-static pthread_mutex_t context_lock = PTHREAD_MUTEX_INITIALIZER;
-static fn_context_t *_fn_ctx;
-
-int fn_context_create()
-{
- _fn_ctx = g_new0(fn_context_t, 1);
- if (!_fn_ctx) {
- LOG_DEBUG("create mtp_context is failed");
- return FN_ERROR_UNKNOWN;
- }
-
- return FN_ERROR_NONE;
-}
-
-void fn_context_mutex_lock()
-{
- LOG_DEBUG("context mutex lock");
- pthread_mutex_lock(&context_lock);
-}
-
-void fn_context_mutex_unlock()
-{
- LOG_DEBUG("context mutex unlock");
- pthread_mutex_unlock(&context_lock);
-}
-
-int fn_context_destroy()
-{
- return FN_ERROR_NONE;
-}
-
-fn_context_t *fn_context_get_context()
-{
- return _fn_ctx;
-}
-
+++ /dev/null
-#include <fn_gdbus.h>
-#include <sys/types.h>
-
-static Group *group_skeleton;
-
-Group *group_dbus_get_object()
-{
- return group_skeleton;
-}
-
-static bool __group_init(GDBusConnection *connection)
-{
- gboolean ret = FALSE;
- GError *error = NULL;
-
- GDBusObjectManagerServer *group;
-
- // Add interface to default object path
- group_skeleton = group_skeleton_new();
-
- // Register for method callbacks as signal callbacks
- g_signal_connect(group_skeleton,
- "handle-create",
- G_CALLBACK(group_create),
- NULL);
-
- g_signal_connect(group_skeleton,
- "handle-find",
- G_CALLBACK(group_find),
- NULL);
-
- g_signal_connect(group_skeleton,
- "handle-get-found-groups",
- G_CALLBACK(group_get_found_groups),
- NULL);
-
- g_signal_connect(group_skeleton,
- "handle-join",
- G_CALLBACK(group_join),
- NULL);
-
- g_signal_connect(group_skeleton,
- "handle-leave",
- G_CALLBACK(group_leave),
- NULL);
-
- g_signal_connect(group_skeleton,
- "handle-delete",
- G_CALLBACK(group_delete),
- NULL);
-
- g_signal_connect(group_skeleton,
- "handle-delete",
- G_CALLBACK(group_device_find),
- NULL);
-
- g_signal_connect(group_skeleton,
- "handle-device-invite",
- G_CALLBACK(group_device_invite),
- NULL);
-
- g_signal_connect(group_skeleton,
- "handle-device-eject",
- G_CALLBACK(group_device_eject),
- NULL);
-
- group = g_dbus_object_manager_server_new(FN_DBUS_GROUP_PATH);
-
- // Set connection to 'manager'
- g_dbus_object_manager_server_set_connection(group, connection);
-
- // Export 'group' interface on FN DBUS
- ret = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(group_skeleton),
- connection, FN_DBUS_GROUP_PATH, &error);
-
- if (ret == FALSE) {
- LOG_DEBUG("Can not skeleton_export %s", error->message);
- g_error_free(error);
- }
-
- return ret;
-}
-
-
-
-static void on_bus_acquired(GDBusConnection *connection, const gchar *path,
- gpointer user_data)
-{
- if (__group_init(connection) == false) {
- LOG_DEBUG("Can not signal connect");
- }
-}
-
-static void on_name_acquired(GDBusConnection *connection, const gchar *name,
- gpointer user_data)
-{
- LOG_DEBUG("on_name_acquired : %s", name);
-}
-
-static void on_name_lost(GDBusConnection *connnection, const gchar *name,
- gpointer user_data)
-{
- LOG_DEBUG("on_name_lost : %s", name);
-}
-
-int fn_gdbus_init()
-{
- g_bus_own_name(G_BUS_TYPE_SYSTEM, FN_DBUS_SERVICE, G_BUS_NAME_OWNER_FLAGS_NONE,
- on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL);
-
- return 0;
-}
+++ /dev/null
-#include <fn_gdbus_group.h>
-
-/* GDBUS Group Layer */
-/* In this gdbus group layer, Please call the "fn_group" service layer function.*/
-
-gboolean group_create(Group *group, GDBusMethodInvocation *invocation, gchar *group_name,
- gpointer user_data)
-{
- gint result = 0;
-
- LOG_DEBUG("group create called using dbus successful");
-
- result = fn_group_create(group_name);
-
- group_complete_create(group, invocation, result);
-
- return TRUE;
-}
-
-gboolean group_find(Group *group, GDBusMethodInvocation *invocation, gint timeout,
- gpointer user_data)
-{
- gint result = 0;
-
- LOG_DEBUG("group find called using dbus successful");
-
- fn_group_find(timeout);
-
- group_complete_find(group, invocation, result);
- return TRUE;
-}
-
-gboolean group_get_found_groups(Group *group, GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
- gint result = 0;
- GVariant *group_data;
-
- LOG_DEBUG("get found groups called using dbus successful");
-
- group_data = fn_group_get_found_groups();
-
- group_complete_get_found_groups(group, invocation, result, group_data);
- return TRUE;
-}
-
-gboolean group_join(Group *group, GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
- //group_complete_join(group, invocation, result);
-
- return TRUE;
-}
-
-gboolean group_leave(Group *group, GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
- //group_complete_leave(group, invocation, result);
-
- return TRUE;
-}
-
-gboolean group_delete(Group *group, GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
- //group_complete_delete(group, invocation, result);
-
- return TRUE;
-}
-
-gboolean group_device_find(Group *group, GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
- //group_complete_device_find(group, invocation, result);
-
- return TRUE;
-}
-
-gboolean group_device_invite(Group *group, GDBusMethodInvocation *invocation,
- gchar *uuid, gchar *pin, gpointer user_data)
-{
- gint result = 0;
-
- LOG_DEBUG("group device invite eject using dbus successful");
-
- result = fn_group_invite(uuid, pin);
-
- group_complete_device_invite(group, invocation, result);
-
- return TRUE;
-}
-
-gboolean group_device_eject(Group *group, GDBusMethodInvocation *invocation,
- gchar *uuid, gpointer user_data)
-{
- gint result = 0;
-
- LOG_DEBUG("group device eject called using dbus successful");
-
- result = fn_group_dismiss(uuid);
-
- group_complete_device_eject(group, invocation, result);
-
- return TRUE;
-}
-
-void notify_group_found(GVariant *group_data)
-{
- group_emit_group_found(group_dbus_get_object(), group_data);
-}
-
-void notify_group_finish(int ret)
-{
- group_emit_finish(group_dbus_get_object(), ret);
-}
-
-void notify_group_device_invite_result(int ret)
-{
- group_emit_device_invite_result(group_dbus_get_object(), ret);
-}
-
-void notify_group_device_eject_result(int ret)
-{
- group_emit_device_eject_result(group_dbus_get_object(), ret);
-}
+++ /dev/null
-#include <fn_group.h>
-
-GList *found_group_list;
-static char *group_invite_uuid = NULL;
-static char *group_invite_pin = NULL;
-
-/* Called when daemon is start. */
-int fn_group_initialize()
-{
- //Initialize memory of context
-
-}
-
-/* create group and destroy */
-int fn_group_create(char* name)
-{
- int ret;
-
- LOG_BEGIN();
-
-
- ret = fn_iot_add_resource(FN_RESOURCE_TYPE_GROUP, name);
- if (ret != FN_ERROR_NONE) {
- LOG_ERR("Add resource is failed : %s", fn_log_get_error_string(ret));
- }
-
-
- /* A own group device is included in the created group by default. */
- /* I would like to use multiple group device resource for this created group resources.
- If there is a better way, please change it.
-
- Group/Jihoon (Group (In this daemon))
- - Group/Device123123 (Group Device (In this daemon))
- - Group/Device3321 (Group Device (remote))
- - Group/Device1101 (Group Device (remote))
- */
-
- fn_resource_print_list();
-
- LOG_END();
-
- return FN_ERROR_NONE;
-}
-
-int fn_group_destroy(fn_group_t *handle)
-{
-
-}
-
-void _free_func (gpointer data)
-{
- fn_group_t *group = (fn_group_t *)data;
-
- if (group != NULL) {
- if (group->uri_path != NULL)
- g_free(group->uri_path);
- if (group->device_id != NULL)
- g_free(group->device_id);
- if (group->group_name != NULL)
- g_free(group->group_name);
- if (group->host_addr != NULL)
- g_free(group->host_addr);
- if (group->resource_type != NULL)
- g_free(group->resource_type);
-
- g_free(group);
- }
-}
-
-int fn_group_find(int timeout)
-{
- int ret;
-
- LOG_BEGIN();
-
- /* list freeing */
- g_list_free_full (found_group_list, _free_func);
- found_group_list = NULL;
-
- ret = fn_iot_discovery_resource(FN_RESOURCE_TYPE_GROUP, timeout);
- if (ret != FN_ERROR_NONE) {
- LOG_ERR("Failed to discover resource : %s",
- fn_log_get_error_string(ret));
- }
-
- LOG_END();
-
- return FN_ERROR_NONE;
-}
-
-GVariant *fn_group_get_found_groups()
-{
- GVariantBuilder builder;
- GVariant *group_data;
- GList *iter = NULL;
-
- g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
-
- iter = found_group_list;
- while(iter != NULL) {
- fn_group_t *group = (fn_group_t *)iter->data;
-
- g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT);
- g_variant_builder_add(&builder, "{sv}", "URI",
- g_variant_new_string(group->uri_path));
- g_variant_builder_add(&builder, "{sv}", "DeviceID",
- g_variant_new_string(group->device_id));
- g_variant_builder_add(&builder, "{sv}", "GroupName",
- g_variant_new_string(group->group_name));
- g_variant_builder_add(&builder, "{sv}", "HostAddress",
- g_variant_new_string(group->host_addr));
- g_variant_builder_add(&builder, "{sv}", "GroupDeviceType",
- g_variant_new_string(group->resource_type));
- /*When we get found groups, we can get my groups also. */
- g_variant_builder_add(&builder, "{sv}", "GroupType",
- g_variant_new_int32(group->type));
- g_variant_builder_close(&builder);
-
- iter = g_list_next(iter);
- }
-
- group_data = g_variant_builder_end(&builder);
-
- return group_data;
-}
-
-int fn_group_add_new(char *uri_path, char *device_id, char *device_name,
- char *host_addr, char *resource_type, fn_group_type_e type)
-{
- int ret;
- fn_group_t *group;
- GVariantBuilder builder;
- GVariant *group_data;
-
- LOG_BEGIN();
-
- group = g_try_malloc0(sizeof(fn_group_t));
- group->uri_path = g_strdup(uri_path);
- group->device_id = g_strdup(device_id);
- group->group_name = g_strdup(device_name);
- group->host_addr = g_strdup(host_addr);
- group->resource_type = g_strdup(resource_type);
- group->type = type;
-
- found_group_list = g_list_prepend(found_group_list, group);
-
- g_variant_builder_init(&builder, G_VARIANT_TYPE("a{sv}"));
-
- g_variant_builder_add(&builder, "{sv}", "URI",
- g_variant_new_string(group->uri_path));
- g_variant_builder_add(&builder, "{sv}", "DeviceID",
- g_variant_new_string(group->device_id));
- g_variant_builder_add(&builder, "{sv}", "GroupName",
- g_variant_new_string(group->group_name));
- g_variant_builder_add(&builder, "{sv}", "HostAddress",
- g_variant_new_string(group->host_addr));
- g_variant_builder_add(&builder, "{sv}", "GroupDeviceType",
- g_variant_new_string(group->resource_type));
- g_variant_builder_add(&builder, "{sv}", "GroupType",
- g_variant_new_int32(group->type));
-
- group_data = g_variant_builder_end(&builder);
-
- notify_group_found(group_data);
-
- LOG_END();
-
- return FN_ERROR_NONE;
-}
-
-/* Join the remote devices in my daemon */
-int fn_group_get_groups(fn_group_t ***handles, int *count){} //Get all of group in my daemon
-int fn_group_get_remote_devices(/* callback */){} //Get all of device in network (Async)
-
-char *fn_group_invite_get_uuid()
-{
- return group_invite_uuid;
-}
-
-char *fn_group_invite_get_pin()
-{
- return group_invite_pin;
-}
-
-void fn_group_notify_group_invite(int result)
-{
- LOG_DEBUG("Notify group invite %d", result);
-
- g_free(group_invite_uuid);
- group_invite_uuid = NULL;
-
- g_free(group_invite_pin);
- group_invite_pin = NULL;
-
- notify_group_device_invite_result(result);
-}
-
-//Join to device in group (async)
-int fn_group_invite(gchar *uuid, gchar *pin)
-{
- int ret;
-
- LOG_BEGIN();
-
- ret = agent_find_mot_enable_devices();
-
- g_free(group_invite_uuid);
- g_free(group_invite_pin);
-
- group_invite_uuid = g_strdup(uuid);
- group_invite_pin = g_strdup(pin);
-
- LOG_END();
-
- return ret;
-}
-
-void fn_group_notify_group_dismiss(int result)
-{
- LOG_DEBUG("Notify group eject %d", result);
-
- notify_group_device_eject_result(result);
-}
-
-//dismiss from group (async)
-int fn_group_dismiss(gchar *uuid)
-{
- int ret;
-
- LOG_BEGIN();
-
- ret = agent_remove_mo_at_device(uuid);
-
- LOG_END();
-
- return ret;
-}
-
-/* Join to remote device group */
-int fn_group_get_remote_groups(/* callback */){} //Get all of group in network (Async)
-int fn_group_join_to(/* callback */){} //Join this device to in certain remote group (Async)
-int fn_group_leave_from(/* callback */){} //leave from certain remote group (Async)
-
-/* Called when daemon is end. */
-int fn_group_deinitialize(){}
-
-int fn_group_get_group_name(fn_group_t *handle, char **name){}
-int fn_group_get_group_type(fn_group_t *handle, int *type){}
-int fn_group_get_group_device_type(fn_group_t *handle){}
-int fn_group_get_group_device_id(fn_group_t *handle){}
-
+++ /dev/null
-#include <fn_log.h>
-
-const char *fn_log_get_error_string(int result) {
- switch (result) {
- case FN_ERROR_NONE:
- return "FN_ERROR_NONE";
- case FN_ERROR_IO_ERROR:
- return "FN_ERROR_IO_ERROR";
- case FN_ERROR_INVALID_PARAMETER:
- return "FN_ERROR_INVALID_PARAMETER";
- case FN_ERROR_OUT_OF_MEMORY:
- return "FN_ERROR_OUT_OF_MEMORY";
- case FN_ERROR_PERMISSION_DENIED:
- return "FN_ERROR_PERMISSION_DENIED";
- case FN_ERROR_NOT_SUPPORTED:
- return "FN_ERROR_NOT_SUPPORTED";
- case FN_ERROR_COMM_ERROR:
- return "FN_ERROR_COMM_ERROR";
- case FN_ERROR_RX:
- return "FN_ERROR_RX";
- case FN_ERROR_TX:
- return "FN_ERROR_RX";
- case FN_ERROR_PLUGIN_FAIL:
- return "FN_ERROR_PLUGIN_FAIL";
- case FN_ERROR_OPERATION_FAILED:
- return "FN_ERROR_OPERATION_FAILED";
- default:
- return "UNKNOWN";
- }
-}
+++ /dev/null
-#include <fn_manager.h>
-#include <comp_mot_agent.h>
-
-int main(int argc, char *argv[])
-{
- int ret;
-
- LOG_DEBUG("FN Manager start");
-
- //1. create & get context
- ret = fn_context_create();
- if (ret != FN_ERROR_NONE) {
- LOG_ERR("FN context create failed : %s", fn_log_get_error_string(ret));
- goto EXIT;
- }
-
- //3. iotivity iniatlize
- ret = fn_iot_initialize();
- if (ret != FN_ERROR_NONE) {
- LOG_ERR("FN iot initialize failed : %s", fn_log_get_error_string(ret));
- goto EXIT;
- }
-
- //4. dbus interface initialize
- ret = fn_gdbus_init();
- if (ret != FN_ERROR_NONE) {
- LOG_ERR("FN gdbus initialize failed : %s", fn_log_get_error_string(ret));
- goto EXIT;
- }
-
- //5. Make TX interface
-
- //example code
- //6. group mgr initialize
- ret = fn_group_initialize();
- if (ret != FN_ERROR_NONE) {
- LOG_ERR("FN group initialize failed : %s", fn_log_get_error_string(ret));
- goto EXIT;
- }
-
- //7. operation mgr initialize
- ret = agent_dbus_start();
- if (ret != FN_ERROR_NONE) {
- LOG_ERR("MOT agent interface initialize failed : %s", fn_log_get_error_string(ret));
- goto EXIT;
- }
- agent_enable();
-
- //8. g main loop run
- fn_context_t *fn_ctx = fn_context_get_context();
- fn_ctx->main_loop = g_main_loop_new(NULL, FALSE);
- g_main_loop_run(fn_ctx->main_loop);
-
-EXIT:
- //9. deinitialize phase
- agent_disable();
- ret = agent_dbus_stop();
- if (ret != FN_ERROR_NONE)
- LOG_ERR("MOT agent interface deinitialize failed : %s", fn_log_get_error_string(ret));
-
- ret = fn_group_deinitialize();
- if (ret != FN_ERROR_NONE)
- LOG_ERR("FN group deinitialize failed : %s", fn_log_get_error_string(ret));
-
- ret = fn_iot_deinitialize();
- if (ret != FN_ERROR_NONE)
- LOG_ERR("FN iot deinitialize failed : %s", fn_log_get_error_string(ret));
-
- ret = fn_context_destroy();
- if (ret != FN_ERROR_NONE)
- LOG_ERR("FN context destroy failed : %s", fn_log_get_error_string(ret));
-
- LOG_DEBUG("FN Manager exit");
-
- return 0;
-}
+++ /dev/null
-#include <fn_resource.h>
-
-/* resource_type, type, uri, policies */
-static fn_rd_t fn_rds[] = {
- {FN_RESOURCE_TYPE_GROUP, "core.fn.group", "/fn/group/",
- IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE},
- {FN_RESOURCE_TYPE_OPERATION, "core.fn.operation", "/fn/operation/",
- IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE},
-};
-
-int fn_resource_append(fn_resource_type_e resource_type, char *uri, iotcon_resource_h resource)
-{
- fn_context_t *fn_ctx = fn_context_get_context();
- GList *list = fn_ctx->resource_list[resource_type];
-
- //append resource handle / name to list
- fn_re_t *element = g_new0(fn_re_t, 1);
- element->resource = resource;
- element->uri = g_strdup(uri);
- list = g_list_append(list, element);
-
- fn_ctx->resource_list[resource_type] = list;
-
- return 0;
-}
-
-int fn_resource_get_resource_from_uri(fn_resource_type_e resource_type,
- char *uri, iotcon_resource_h *parent_resource)
-{
- fn_context_t *fn_ctx = fn_context_get_context();
- GList *list = fn_ctx->resource_list[resource_type];
-
- GList *l;
- for (l = list; l != NULL; l = l->next) {
- fn_re_t *re = (fn_re_t *)l->data;
-
- if (strcmp(re->uri, uri) == 0) {
- LOG_DEBUG("Resource found - type : %d uri : %s", resource_type, uri);
- *parent_resource = re->resource;
- return 0;
- }
- }
-
- return -1;
-}
-
-char *fn_resource_get_type(fn_resource_type_e resource_type)
-{
- return fn_rds[resource_type].type;
-}
-
-char *fn_resource_get_uri_prefix(fn_resource_type_e resource_type)
-{
- return fn_rds[resource_type].uri_prefix;
-}
-
-uint8_t fn_resource_get_policies(fn_resource_type_e resource_type)
-{
- return fn_rds[resource_type].policies;
-}
-
-void __print_foreach_resource(gpointer data, gpointer user_data)
-{
- fn_re_t *re = (fn_re_t *)data;
- LOG_DEBUG(" ** resource : %x, uri : %s", re->resource, re->uri);
-}
-
-void fn_resource_print_list()
-{
- fn_context_t *fn_ctx = fn_context_get_context();
-
- LOG_DEBUG("-------------------Print resource list-----------------------");
-
- for (int i = 0; i < FN_RESOURCE_TYPE_MAX; i++) {
- LOG_DEBUG("Resource type %d list length : %d", i, g_list_length(fn_ctx->resource_list[i]));
- g_list_foreach(fn_ctx->resource_list[i], __print_foreach_resource, NULL);
- }
-
- LOG_DEBUG("-------------------Print resource list end-------------------");
-}
-
+++ /dev/null
-gdbus-codegen --interface-prefix org.tizen.familynet \
- --generate-c-code familynet_gdbus \
- --c-generate-object-manager \
- familynet_gdbus.xml \