</method>
<method name='CancelAdvertiseService'>
<arg type='u' name='adv_id' direction='in'/>
+ <arg type='i' name='tech' direction='in'/>
<arg type='i' name='error_code' direction='out'/>
</method>
<method name='SeekService'>
Name: asp-manager
Summary: ASP(application service platform) manager
-Version: 0.0.1
+Version: 0.0.2
Release: 2
Group: Network & Connectivity/Other
License: Apache-2.0
GVariantIter *iter = NULL;
GVariant* var = NULL;
gchar *key = NULL;
- gchar *value = NULL;
+ gchar *key_str = NULL;
+ gchar *value_str = NULL;
+ __ASP_LOG_FUNC_ENTER__;
if (key_only) {
g_variant_get(variant, "as", &iter);
- while (g_variant_iter_loop(iter, "s", &key))
- g_hash_table_insert(hash, key, NULL);
+ while (g_variant_iter_loop(iter, "s", &key)) {
+ key_str = g_strdup(key);
+ g_hash_table_insert(hash, key_str, NULL);
+ }
} else {
g_variant_get(variant, "a{sv}", &iter);
while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
- value = g_variant_dup_string(var, NULL);
- g_hash_table_insert(hash, key, value);
+
+ key_str = g_strdup(key);
+ value_str = g_variant_dup_string(var, NULL);
+ g_hash_table_insert(hash, key_str, value_str);
}
}
+ __ASP_LOG_FUNC_EXIT__;
+ return;
}
static gboolean __asp_manager_gdbus_advertise_service(AspService *object,
}
result = asp_service_advertise(&service, 0);
+ g_hash_table_remove_all(service.service_info_map);
if (result < 0) {
ASP_LOGE("Failed to advertise service");
ASP_RETURN_SERVICE_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
}
result = asp_service_advertise(&service, 1);
+ g_hash_table_remove_all(service.service_info_map);
if (result < 0) {
ASP_LOGE("Failed to change service status");
ASP_RETURN_SERVICE_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
static gboolean __asp_manager_gdbus_cancel_advertise_service(AspService *object,
GDBusMethodInvocation *invocation,
const guint adv_id,
+ const guint tech,
const gboolean *user_data)
{
__ASP_LOG_FUNC_ENTER__;
memset(&service, 0x0, sizeof(asp_service_advertise_s));
service.adv_id = adv_id;
+ service.discovery_tech = tech;
result = asp_service_cancel_advertise(&service);
if (result < 0) {
ASP_LOGE("Failed to cancel advertise service");
}
result = asp_service_seek(&service, &search_id);
+ g_hash_table_remove_all(service.service_info_map);
if (result < 0) {
ASP_LOGE("Failed to seek service");
ASP_RETURN_SERVICE_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
goto out;
}
- if (search_id == 0) {
- ASP_LOGE("Invalid parameter");
- ASP_RETURN_SERVICE_ERR(invocation, -ASP_ERROR_INVALIED_PARAMS);
- goto out;
- }
-
memset(&service, 0x0, sizeof(asp_service_seek_s));
service.search_id = search_id;
result = asp_service_cancel_seek(&service);
ASP_LOGD("session ID [%u] session mac [%s]", session_id, session_mac);
macaddr_atoe(session_mac, mac_addr);
- if(pin_str != NULL)
+ if (pin_str != NULL)
pin = (guint32)atoi(pin_str);
res = asp_session_confirm_session(mac_addr, session_id, confirmed, pin);
if (!res) {
gchar session_mac_str[MACSTR_LEN + 1] = {0,};
gchar pin_str[MACSTR_LEN + 1] = {0,};
- if(info_length != 0) {
+ if (info_length != 0) {
session_info_str = g_try_malloc0(info_length + 1);
memcpy(session_info_str, session_info, info_length);
}
gpointer key, value;
g_hash_table_iter_init(&iter, hash);
- while (g_hash_table_iter_next(&iter, &key, &value))
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
+ ASP_LOGD("%s %s", key, value);
g_variant_builder_add(&builder, "{sv}", key, g_variant_new_string(value));
+ }
return g_variant_builder_end(&builder);
}
{
GVariantBuilder builder;
- g_variant_builder_init(&builder, G_VARIANT_TYPE("(as)"));
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("as"));
GHashTableIter iter;
gpointer key, value;
return;
}
+static void __service_info_to_g_hash(const gchar *service_info,
+ GHashTable *service_info_map)
+{
+ const gchar *key = NULL;
+ const gchar *value = NULL;
+ gsize pos = 0;
+ gsize key_length = 0;
+ gsize value_length = 0;
+ gsize info_length = 0;
+
+ info_length = strlen(service_info);
+
+ while (service_info[pos] != '\0' && pos < info_length) {
+ key = &service_info[pos];
+ while (service_info[pos] != '=' && pos < info_length) {
+ key_length++;
+ pos++;
+ }
+
+ if (pos >= info_length - 1) {
+ g_hash_table_replace(service_info_map, g_strndup(key, key_length),
+ g_strdup(""));
+ break;
+ }
+
+ pos++;
+ value = &service_info[pos];
+ while (service_info[pos] != ',' && pos < info_length) {
+ value_length++;
+ pos++;
+ }
+
+ g_hash_table_replace(service_info_map, g_strndup(key, key_length),
+ g_strndup(value, value_length));
+ ASP_LOGD("Insert (%s, %s) to hash.", key, value);
+
+ if (service_info[pos] == ',' && pos == info_length)
+ break;
+ }
+ return;
+}
+
void asp_tech_p2p_process_search_result(GDBusConnection *connection,
const gchar *object_path, GVariant *parameters)
{
GVariantIter *iter = NULL;
GVariant *var = NULL;
+ GHashTable *service_info_map = NULL;
asp_event_data event;
const gchar *service_mac = NULL;
const gchar *key = NULL;
guint32 advertisement_id = 0;
guint32 config_method = 0;
gchar *instance_name = NULL;
- gchar *service_info = NULL;
guint8 status = 0;
if (!parameters) {
instance_name = g_strdup(str);
} else if (!g_strcmp0(key, "status")) {
g_variant_get(var, "y", &status);
- } else {
+ } else if (!g_strcmp0(key, "service_info")) {
+ g_variant_get(var, "&s", &str);
+ service_info_map = g_hash_table_new_full(g_str_hash,
+ g_str_equal, g_free, g_free);
+ __service_info_to_g_hash(str, service_info_map);
+ } else {
;/* Do Nothing */
}
}
memcpy(event.search_result.service_mac, service_mac, MACSTR_LEN + 1);
event.search_result.device_name = device_name;
event.search_result.instance_name = instance_name;
- event.search_result.service_info = NULL;
+ event.search_result.service_info = service_info_map;
asp_manager_event(NULL, ASP_EVENT_SEARCH_RESULT, &event);
g_free(device_name);
g_free(instance_name);
- g_free(service_info);
+ g_hash_table_remove_all(service_info_map);
__ASP_LOG_FUNC_EXIT__;
return;
}
}
- if(peer_ip == NULL) {
+ if (peer_ip == NULL) {
ASP_LOGE("Invalid peer IP address");
return;
}