}
g_variant_get(output, "(a(issssssisibii))", &iter);
- if (g_variant_iter_n_children(iter) == 0) {
- DMSG("Failed to get DeviceList from gvariant.");
- g_variant_iter_free(iter);
- return;
- }
while (g_variant_iter_loop(iter, "(issssssisibii)",
NULL, NULL, NULL,
break;
}
- g_variant_iter_free(iter);
-
ret = dbus_handle_method_async_with_reply_var(STORAGED_BUS_NAME,
STORAGED_PATH_BLOCK_MANAGER,
STORAGED_INTERFACE_BLOCK_MANAGER,
g_variant_new("(s)", type));
if (!msg) {
- _E("Failed to call dbus method(%s)", METHOD_BLOCK_GETMMCPRIMARY);
+ _E("Failed to call dbus method(%s): no reply", METHOD_BLOCK_GETMMCPRIMARY);
return ret;
}
g_variant_get(msg, "(a(issssssisibii))", &iter);
- if (g_variant_iter_n_children(iter) == 0) {
- _E("Failed to get DeviceList from gvariant.");
- g_variant_iter_free(iter);
- return ret;
- }
-
while (g_variant_iter_loop(iter, "(issssssisibii)",
NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, &val)) {
ret = TRUE;
}
- g_variant_iter_free(iter);
-
_I("Success. (%s): %d", METHOD_BLOCK_GETDEVICELIST, ret);
return ret;
}
g_variant_new("(s)", type));
if (!msg) {
- _E("Failed to call dbus method(%s)", METHOD_BLOCK_GETMMCPRIMARY);
+ _E("Failed to call dbus method(%s): no reply", METHOD_BLOCK_GETMMCPRIMARY);
return ret;
}
g_variant_get(msg, "(a(issssssisibi))", &iter);
- if (g_variant_iter_n_children(iter) == 0) {
- _E("Failed to get DeviceList2 from gvariant.");
- g_variant_iter_free(iter);
- return ret;
- }
-
while (g_variant_iter_loop(iter, "(issssssisibi)",
NULL, &val, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL)) {
ret = TRUE;
}
- g_variant_iter_free(iter);
-
_I("Success. %s: %d", METHOD_BLOCK_GETDEVICELIST2, ret);
return ret;
}
char *type = NULL;
enum block_device_type block_type;
int i;
- int item_cnt = 0;
GVariantBuilder *builder = NULL;
- const char *error = NULL;
g_variant_get(param, "(s)", &type);
+
if (!type) {
_E("Delivered type is NULL.");
- error = "Delivered type is NULL";
goto out;
}
block_type = get_bdev_type_from_type_string(type);
if (block_type == BLOCK_UNKNOWN_DEV) {
_E("Invalid type (%s) is requested.", type);
- error = "Invalid type is requested";
goto out;
}
builder = g_variant_builder_new(G_VARIANT_TYPE("a(issssssisibii)"));
- item_cnt = 0;
for (i = 0; i < THREAD_MAX; i++) {
pthread_mutex_lock(&(th_manager[i].mutex));
data->primary,
data->flags,
data->id);
- ++item_cnt;
}
pthread_mutex_unlock(&(th_manager[i].mutex));
}
- /* if nothing is added, then gvariant(empty body) is generated */
- if (item_cnt == 0) {
- _E("Not found matched device(%s).", type);
- error = "Not found matched device";
- goto out;
- }
-
reply = g_variant_new("(a(issssssisibii))", builder);
+ g_variant_builder_unref(builder);
out:
- if (builder)
- g_variant_builder_unref(builder);
-
g_free(type);
-
if (!reply)
- g_dbus_method_invocation_return_error(invocation,
- G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
- "%s", error);
+ reply = dbus_handle_new_g_variant_tuple();
return reply;
}
char *type = NULL;
enum block_device_type block_type;
int i;
- int item_cnt;
GVariantBuilder *builder = NULL;
- const char *error = NULL;
g_variant_get(param, "(s)", &type);
if (!type) {
_E("Delivered type is NULL.");
- error = "Delivered type is NULL";
goto out;
}
block_type = get_bdev_type_from_type_string(type);
if (block_type == BLOCK_UNKNOWN_DEV) {
_E("Invalid type (%s) is requested.", type);
- error = "Invalid type is requested";
goto out;
}
builder = g_variant_builder_new(G_VARIANT_TYPE("a(issssssisibi)"));
- item_cnt = 0;
for (i = 0; i < THREAD_MAX; i++) {
pthread_mutex_lock(&(th_manager[i].mutex));
data->state,
data->primary,
data->flags);
- ++item_cnt;
}
pthread_mutex_unlock(&(th_manager[i].mutex));
}
- /* if nothing is added, then gvariant(empty body) is generated */
- if (item_cnt == 0) {
- _E("Not found matched device(%s).", type);
- error = "Not found matched device";
- goto out;
- }
-
reply = g_variant_new("(a(issssssisibi))", builder);
+ g_variant_builder_unref(builder);
out:
- if (builder)
- g_variant_builder_unref(builder);
-
g_free(type);
-
- if (!reply)
- g_dbus_method_invocation_return_error(invocation,
- G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
- "%s", error);
return reply;
}