return COMP_ERROR_IO_ERROR;
}
- found_device_count = 0;
-
variant = g_dbus_proxy_call_sync(agent.gproxy_agent_service, "disc_mot_enb_devs",
g_variant_new("(i)", timeout), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
if (variant) {
return COMP_ERROR_IO_ERROR;
}
+ if (result == 0)
+ found_device_count = 0;
+
g_timeout_add_seconds(timeout + 1, _find_device_timeout_cb, NULL);
return result;
g_variant_get(parameters, "(i)", &result);
LOG_DEBUG("Result : %d", result);
} else if (0 == g_strcmp0(signal_name, "disc_mot_enb_devs_done")) {
+ comp_group_notify_mot_enable_device_done();
+ } else if (0 == g_strcmp0(signal_name, "mot_enb_devs_added")) {
GVariantIter *iter = NULL;
- GVariantIter *iter_row = NULL;
gchar *key;
GVariant *val;
gsize len = 0;
- int mot_enb_devs_cnt = 0;
comp_mot_device_t *device;
comp_context_t *comp_ctx = comp_context_get_context();
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)) {
- 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);
- if (comp_ctx && (FALSE == comp_ctx->mot_me) &&
- strcasecmp(deviceid, comp_ctx->device_uuid) == 0) {
- g_timeout_add(10, __perform_mot_me, NULL);
- comp_ctx->mot_me = TRUE;
- }
- 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_int32(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);
- device->addr = g_strdup(addr);
- } else if (strcasecmp(key, "ifindex") == 0) {
- int ifindex = g_variant_get_int32(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);
- 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);
- 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);
- 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_get(parameters, "(a{sv})", &iter);
+ device = g_try_malloc0(sizeof(comp_mot_device_t));
+
+ while (g_variant_iter_loop(iter, "{sv}", &key, &val)) {
+ if (strcasecmp(key, "deviceId") == 0) {
+ const char *deviceid = g_variant_get_string(val, &len);
+ if (comp_ctx && (FALSE == comp_ctx->mot_me) &&
+ strcasecmp(deviceid, comp_ctx->device_uuid) == 0) {
+ g_timeout_add(10, __perform_mot_me, NULL);
+ comp_ctx->mot_me = TRUE;
}
+ 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_int32(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);
+ device->addr = g_strdup(addr);
+ } else if (strcasecmp(key, "ifindex") == 0) {
+ int ifindex = g_variant_get_int32(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);
+ 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);
+ 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;
}
- g_variant_iter_free(iter_row);
-
- comp_context_t *comp_ctx = comp_context_get_context();
- if (strcmp(device->device_id, comp_ctx->device_uuid) != 0) {
- mot_enb_devs_cnt += 1;
- comp_group_add_new_mot_device(device);
- } else {
- LOG_DEBUG("It is my mowned device. Store the mowned device in daemon");
- comp_group_change_mowned_device(device);
+#endif
+ else if (strcasecmp(key, "secVer") == 0) {
+ const char *secVer = g_variant_get_string(val, &len);
+ 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);
- LOG_DEBUG("mot_enb_devs_cnt = %d", mot_enb_devs_cnt);
- found_device_count = mot_enb_devs_cnt;
- comp_group_notify_mot_enable_device_done(mot_enb_devs_cnt);
-
+ if (strcmp(device->device_id, comp_ctx->device_uuid) != 0) {
+ found_device_count += 1;
+ comp_group_add_new_mot_device(device);
+ } else {
+ LOG_DEBUG("It is my mowned device. Store the mowned device in daemon");
+ comp_group_change_mowned_device(device);
+ }
} else if (0 == g_strcmp0(signal_name, "disc_mowned_devs_done")) {
GVariantIter *iter = NULL;
GVariantIter *iter_row = NULL;
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);
+ /* mot_enb_devs_added */
+ id = g_dbus_connection_signal_subscribe(h->dbus_connection, NULL,
+ AGENT_SERVER_NAME, "mot_enb_devs_added", 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_enb_devs_added) 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_enb_devs_added) 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,