void notify_group_found(GVariant *group_data);
void notify_group_finish(int ret);
+void notify_device_found(int device_count, GVariant *device_data);
void notify_group_device_invite_result(int ret);
void notify_group_device_eject_result(int ret);
comp_group_type_e type;
} comp_group_t;
+typedef struct {
+ char *device_id;
+ int adapter;
+ int flags;
+ int port;
+ char *addr;
+ int ifindex;
+ char *route_data;
+ char *remote_id;
+ int conn_type;
+ int secure_port;
+ int tcp_port;
+ char *sec_ver;
+ int dev_status;
+} comp_mot_device_t;
+
/* Called when daemon is start. */
int comp_group_initialize();
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);
+ 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)
+void comp_group_add_new_mot_device(comp_mot_device_t *device);
+int comp_group_find_mot_enabled_devices();
+
char *comp_group_invite_get_uuid();
char *comp_group_invite_get_pin();
//Join to device in group (async)
group_emit_finish(group_dbus_get_object(), ret);
}
+void notify_device_found(int device_count, GVariant *device_data)
+{
+ group_emit_device_found(group_dbus_get_object(), device_count, device_data);
+}
+
void notify_group_device_invite_result(int ret)
{
group_emit_device_invite_result(group_dbus_get_object(), ret);
#include <comp_group.h>
GList *found_group_list;
+GList *mot_enb_dev_list = NULL;
static char *group_invite_uuid = NULL;
static char *group_invite_pin = NULL;
}
}
+void _mot_enb_dev_list_free_func(gpointer data)
+{
+ comp_mot_device_t *device = (comp_mot_device_t *)data;
+
+ if (device != NULL) {
+ if (device->device_id != NULL)
+ g_free(device->device_id);
+ if (device->addr != NULL)
+ g_free(device->addr);
+ if (device->route_data != NULL)
+ g_free(device->route_data);
+ if (device->remote_id != NULL)
+ g_free(device->remote_id);
+ if (device->sec_ver != NULL)
+ g_free(device->sec_ver);
+
+ g_free(device);
+ }
+}
+
int comp_group_find(int timeout)
{
int ret;
}
// Find MOT enabled devices
+void comp_group_add_new_mot_device(comp_mot_device_t *device)
+{
+ LOG_BEGIN();
+
+ mot_enb_dev_list = g_list_prepend(mot_enb_dev_list, device);
+
+ LOG_END();
+}
+
+GVariant *comp_group_get_remote_mot_enabled_devices()
+{
+ GVariantBuilder builder;
+ GVariant *group_data;
+ GList *iter = NULL;
+
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("aa{sv}"));
+
+ iter = mot_enb_dev_list;
+ while(iter != NULL) {
+ comp_mot_device_t *device = (comp_mot_device_t *)iter->data;
+
+ g_variant_builder_open(&builder, G_VARIANT_TYPE_VARDICT);
+ g_variant_builder_add(&builder, "{sv}", "DeviceID",
+ g_variant_new_string(device->device_id));
+ g_variant_builder_add(&builder, "{sv}", "Adapter",
+ g_variant_new_int32(device->adapter));
+ g_variant_builder_add(&builder, "{sv}", "Flags",
+ g_variant_new_int32(device->flags));
+ g_variant_builder_add(&builder, "{sv}", "Port",
+ g_variant_new_uint16(device->port));
+ g_variant_builder_add(&builder, "{sv}", "Address",
+ g_variant_new_string(device->addr));
+ g_variant_builder_add(&builder, "{sv}", "Ifindex",
+ g_variant_new_int32(device->ifindex));
+ g_variant_builder_add(&builder, "{sv}", "RouteData",
+ g_variant_new_string(device->route_data));
+ g_variant_builder_add(&builder, "{sv}", "RemoteId",
+ g_variant_new_string(device->remote_id));
+ g_variant_builder_add(&builder, "{sv}", "ConnType",
+ g_variant_new_int32(device->conn_type));
+ g_variant_builder_add(&builder, "{sv}", "SecurePort",
+ g_variant_new_uint16(device->secure_port));
+ g_variant_builder_add(&builder, "{sv}", "TcpPort",
+ g_variant_new_uint16(device->tcp_port));
+ g_variant_builder_add(&builder, "{sv}", "SecVer",
+ g_variant_new_string(device->sec_ver));
+ g_variant_builder_add(&builder, "{sv}", "DeviceStatus",
+ g_variant_new_int32(device->dev_status));
+ g_variant_builder_close(&builder);
+
+ iter = g_list_next(iter);
+ }
+
+ group_data = g_variant_builder_end(&builder);
+
+ return group_data;
+}
+
+void comp_group_notify_mot_enable_device_done(int device_count)
+{
+ GVariant *device_data;
+
+ device_data = comp_group_get_remote_mot_enabled_devices();
+
+ notify_device_found(device_count, device_data);
+
+ LOG_BEGIN();
+
+}
+
int comp_group_find_mot_enabled_devices()
{
int ret;
+
LOG_BEGIN();
+ /* list freeing */
+ g_list_free_full (mot_enb_dev_list, _mot_enb_dev_list_free_func);
+ mot_enb_dev_list = NULL;
+
ret = agent_find_mot_enable_devices();
+ if (ret != COMP_ERROR_NONE) {
+ LOG_ERR("Failed to find mot enable devices : %s",
+ comp_log_get_error_string(ret));
+ }
LOG_END();
#include <comp_log.h>
#include <comp_enum.h>
+#include <comp_group.h>
#define AGENT_SERVER_NAME "net.ma"
#define AGENT_OBJECT_PATH "/net/ma"
GVariant *val;
gsize len = 0;
int mot_enb_devs_cnt = 0;
+ comp_mot_device_t *device;
if (NULL == parameters) {
LOG_ERR("No MOT enabled devices found");
}
g_variant_get(parameters, "(aa{sv})", &iter);
while (g_variant_iter_next(iter, "a{sv}", &iter_row)) {
+ device = g_try_malloc0(sizeof(comp_mot_device_t));
+
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);
+ device->device_id = g_strdup(deviceid);
} else if (strcasecmp(key, "adapter") == 0) {
int adapter = g_variant_get_uint32(val);
LOG_DEBUG("adapter = %d", adapter);
+ device->adapter = adapter;
} else if (strcasecmp(key, "flags") == 0) {
int flags = g_variant_get_uint32(val);
LOG_DEBUG("flags = %d", flags);
+ device->flags = flags;
} else if (strcasecmp(key, "port") == 0) {
int port = g_variant_get_uint16(val);
LOG_DEBUG("port = %d", port);
+ device->port = port;
} else if (strcasecmp(key, "addr") == 0) {
const char *addr = g_variant_get_string(val, &len);
- LOG_DEBUG("addr=%s", addr);
+ LOG_DEBUG("addr = %s", addr);
+ device->addr = g_strdup(addr);
} else if (strcasecmp(key, "ifindex") == 0) {
int ifindex = g_variant_get_uint32(val);
LOG_DEBUG("ifindex = %d", ifindex);
+ device->ifindex = ifindex;
} else if (strcasecmp(key, "routeData") == 0) {
const char *routeData = g_variant_get_string(val, &len);
- LOG_DEBUG("routeData=%s", routeData);
+ LOG_DEBUG("routeData = %s", routeData);
+ device->route_data = g_strdup(routeData);
} else if (strcasecmp(key, "remoteId") == 0) {
const char *remoteId = g_variant_get_string(val, &len);
- LOG_DEBUG("remoteId=%s", remoteId);
+ LOG_DEBUG("remoteId = %s", remoteId);
+ device->remote_id = g_strdup(remoteId);
} else if (strcasecmp(key, "connType") == 0) {
int connType = g_variant_get_uint32(val);
LOG_DEBUG("connType = %d", connType);
+ device->conn_type = connType;
} else if (strcasecmp(key, "securePort") == 0) {
int securePort = g_variant_get_uint16(val);
LOG_DEBUG("securePort = %d", securePort);
+ device->secure_port = securePort;
#ifdef WITH_TCP
} else if (strcasecmp(key, "tcpPort") == 0) {
int tcpPort = g_variant_get_uint16(val);
LOG_DEBUG("tcpPort = %d", tcpPort);
+ device->tcp_port = tcpPort;
}
#endif
else if (strcasecmp(key, "secVer") == 0) {
const char *secVer = g_variant_get_string(val, &len);
- LOG_DEBUG("secVer=%s", secVer);
+ LOG_DEBUG("secVer = %s", secVer);
+ device->sec_ver = g_strdup(secVer);
} else if (strcasecmp(key, "devStatus") == 0) {
int devStatus = g_variant_get_uint32(val);
LOG_DEBUG("devStatus = %d", devStatus);
+ device->dev_status = devStatus;
}
}
g_variant_iter_free(iter_row);
mot_enb_devs_cnt += 1;
+ comp_group_add_new_mot_device(device);
}
g_variant_iter_free(iter);
LOG_DEBUG("mot_enb_devs_cnt = %d", mot_enb_devs_cnt);
+ comp_group_notify_mot_enable_device_done(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
<signal name="Finish">
<arg type="i" name="result" direction="out" />
</signal>
+ <signal name="DeviceFound">
+ <arg type="i" name="device_count" direction="out" />
+ <arg type="aa{sv}" name="device_info" direction="out" />
+ </signal>
<signal name="DeviceInviteResult">
<arg type="i" name="result" direction="out" />
</signal>