free(folders_struct.names);
g_variant_unref(folder_list_var);
- }
- // TODO MAP place for you else 1
+
+ } else if (strcasecmp(signal_name, BT_MAP_FILTER_FIELDS_COMPLETE) == 0) {
+ BT_DBG("BT_MAP_LIST_FOLDERS_COMPLETE");
+
+ const char *session_id = NULL;
+ GVariant *value;
+ int request_id = 0;
+ int i = 0;
+ bt_map_list_filter_fields_info_t fields_info = {0,};
+
+ g_variant_get(parameters, "(ivsi)", &result, &value, &session_id, &request_id);
+
+ if (__bt_is_request_id_exist(request_id) == FALSE) {
+ BT_ERR("Different request id!");
+ return;
+ }
+
+ if (value) {
+ GVariantIter *iter = NULL;
+ g_variant_get(value, "(as)", &iter);
+ fields_info.size = g_variant_iter_n_children(iter);
+ char* field = NULL;
+
+ fields_info.fields = malloc(fields_info.size * sizeof(char*));
+ while (g_variant_iter_loop(iter, "s", &field)) {
+ fields_info.fields[i] = strdup(field);
+ i++;
+ }
+ }
+
+ _bt_common_event_cb(BLUETOOTH_EVENT_MAP_LIST_FILTER_FIELD_COMPLETE,
+ request_id, &fields_info,
+ event_info->cb, event_info->user_data);
+
+ while(--i >= 0) {
+ free(fields_info.fields[i]);
+ fields_info.fields[i] = NULL;
+ }
+ free(fields_info.fields);
+
+ __bt_remove_push_request_id(request_id);
+ g_variant_unref(value);
+ }
+
// TODO MAP place for you else 2
// TODO MAP place for you else 3
// TODO MAP place for you else 4
BT_EXPORT_API int bluetooth_map_client_list_filter_fields(
bt_map_client_session_info_s *session)
{
- BT_DBG("bluetooth_map_client_list_filter_fields");
- int result = BLUETOOTH_ERROR_INTERNAL;
+ BT_DBG("bluetooth_map_client_list_filter_fields");
+ int result = BLUETOOTH_ERROR_NONE;
+ bt_user_info_t *user_info;
- /* TODO: MAP */
+ BT_CHECK_ENABLED(return);
+ BT_CHECK_PARAMETER(session->session_path, return);
- return result;
+ user_info = _bt_get_user_data(BT_COMMON);
+ retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ BT_INIT_PARAMS();
+ BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_array_append_vals(in_param1, session->session_path, strlen(session->session_path)+1);
+
+ result = _bt_send_request_async(BT_OBEX_SERVICE, BT_MAP_LIST_FILTER_FIELDS,
+ in_param1, in_param2, in_param3, in_param4,
+ user_info->cb, user_info->user_data);
+
+ BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ return result;
}
BT_EXPORT_API int bluetooth_map_client_list_messages(
request_id = g_array_index(out_param1, int, 0);
BT_DBG("request_id : %d", request_id);
_bt_add_push_request_id(request_id);
+ } else if (cb_data->service_function == BT_MAP_LIST_FILTER_FIELDS) {
+ request_id = g_array_index(out_param1, int, 0);
+ BT_DBG("request_id : %d", request_id);
+ _bt_add_push_request_id(request_id);
}
// TODO MAP place for your own if 1
// TODO MAP place for your own if 2
case BT_MAP_LIST_FILTER_FIELDS: {
BT_DBG("BT_MAP_LIST_FILTER_FIELDS");
- /* TODO: MAP */
+ char* session_id = (char *)g_variant_get_data(in_param1);
- result = BLUETOOTH_ERROR_NOT_SUPPORT;
+ result = _bt_map_client_list_filter_fields(request_id, context, session_id);
+ if (result == BLUETOOTH_ERROR_NONE) {
+ BT_DBG("_bt_map_client_list_filter_fields succeed");
+ }
break;
}
signal = BT_MAP_LIST_FOLDERS_COMPLETE;
BT_INFO_C("Completed list folders operation[MAP]");
break;
- // TODO MAP place for your own case 1
+ case BLUETOOTH_EVENT_MAP_LIST_FILTER_FIELD_COMPLETE:
+ signal = BT_MAP_FILTER_FIELDS_COMPLETE;
+ BT_INFO_C("Completed list filters field operation[MAP]");
+ break;
// TODO MAP place for your own case 2
// TODO MAP place for your own case 3
// TODO MAP place for your own case 4
return result;
}
-int _bt_map_client_list_filter_fields(const char* session_id)
+static void __bt_list_filter_fields_cb(GDBusProxy *proxy,
+ GAsyncResult *res, gpointer user_data)
{
BT_DBG("+");
- /* TODO: MAP */
+ GError *error = NULL;
+ GVariant *value, *in_param, *param;
+
+ int result = BLUETOOTH_ERROR_NONE;
+ int request_id;
+ char* session_id = NULL;
+ char** fields = NULL;
+ int size = 0;
+
+ in_param = (GVariant*) user_data;
+ g_variant_get(in_param, "(is)", &request_id, &session_id);
+
+ value = g_dbus_proxy_call_finish(proxy, res, &error);
+
+ if (error) {
+ BT_ERR("%s", error->message);
+ g_clear_error(&error);
+ result = BLUETOOTH_ERROR_INTERNAL;
+ }
+
+ param = g_variant_new("(ivsi)", result, value, session_id, request_id);
+
+ _bt_send_event(BT_MAP_CLIENT_EVENT, BLUETOOTH_EVENT_MAP_LIST_FILTER_FIELD_COMPLETE,
+ param);
+
+ g_variant_unref(value);
+ g_variant_unref(in_param);
+
+ BT_DBG("-");
+}
+
+int _bt_map_client_list_filter_fields(int request_id, GDBusMethodInvocation *context, const char* session_id)
+{
+ BT_DBG("+");
+
+ GError *err = NULL;
+ GDBusConnection *g_conn;
+ GDBusProxy *message_proxy;
+ GVariantBuilder *builder;
+ GVariant *ret = NULL;
+ int result = BLUETOOTH_ERROR_NONE;
+
+ retv_if(session_id == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
+
+ g_conn = _bt_gdbus_get_session_gconn();
+ retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ GVariant *out_param = g_variant_new_from_data((const GVariantType *)"ay",
+ &request_id, sizeof(int),
+ TRUE, NULL, NULL);
+
+ g_dbus_method_invocation_return_value(context,
+ g_variant_new("(iv)", result, out_param));
+
+
+ message_proxy = g_dbus_proxy_new_sync(g_conn,
+ G_DBUS_PROXY_FLAGS_NONE, NULL,
+ BT_OBEX_SERVICE_NAME, session_id,
+ BT_OBEX_MESSAGE_INTERFACE, NULL, &err);
+
+ retv_if(message_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+ GVariant *param = g_variant_new("(is)",
+ request_id, session_id);
+
+ g_dbus_proxy_call(message_proxy,
+ "ListFilterFields", g_variant_new("()"),
+ G_DBUS_CALL_FLAGS_NONE, -1,
+ NULL,
+ (GAsyncReadyCallback)__bt_list_filter_fields_cb,
+ (void*)param);
BT_DBG("-");
int _bt_map_client_set_folder(const char* session_id, const char* name);
int _bt_map_client_list_folders(int request_id, GDBusMethodInvocation *context,
const char* session_id, int offset, int maxcount);
-int _bt_map_client_list_filter_fields(const char* session_id);
+int _bt_map_client_list_filter_fields(int request_id, GDBusMethodInvocation *context,
+ const char* session_id);
int _bt_map_client_list_messages(
const char* session_id,
const char* folder,
BLUETOOTH_EVENT_MAP_GET_MESSAGE_COMPLETE,
BLUETOOTH_EVENT_MAP_GET_MESSAGE_INVALID_ARGUMENTS,
BLUETOOTH_EVENT_MAP_GET_MESSAGE_FAILED,
+ BLUETOOTH_EVENT_MAP_LIST_FILTER_FIELD_COMPLETE,
BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE = BLUETOOTH_EVENT_OBEX_SERVER_BASE,
/* Obex server authorize event*/
} bt_opc_transfer_info_t;
/* TODO: MAP client structures, see above */
+/**
+ * Stucture to Map filter fields
+ */
+typedef struct {
+ char **fields;
+ int size;
+} bt_map_list_filter_fields_info_t;
/* Obex Server transfer type */
#define TRANSFER_PUT "PUT"
int maxcount
);
+/**
+ * @fn int bluetooth_map_client_list_filter_fields(bt_map_session_info_s* session)
+ * @brief Return all available fields that can be used in Fields filter.
+ *
+ * This function is a asynchronous call.
+ *
+ * @return BLUETOOTH_ERROR_NONE - Success \n
+ * BLUETOOTH_ERROR_DEVICE_NOT_ENABLED - Device is not enabled \n
+ * BLUETOOTH_ERROR_INTERNAL - Update inbox failed \n
+ *
+ * @exception None
+ * @param[in] session Information about session.
+ * @remark None
+ */
int bluetooth_map_client_list_filter_fields(
bt_map_client_session_info_s *session
);
#define BT_MAP_CONNECTED "MapConnected"
#define BT_MAP_DISCONNECTED "MapDisconnected"
#define BT_MAP_LIST_FOLDERS_COMPLETE "ListFoldersComplete"
-// TODO MAP place for your define 1
+#define BT_MAP_FILTER_FIELDS_COMPLETE "MapListFiltersFieldComplete"
// TODO MAP place for your define 2
// TODO MAP place for your define 3
// TODO MAP place for your define 4