static obex_agent_added_cb_t obex_agent_added_cb;
static void *obex_agent_added_cb_data;
+static GList *transfer_watched_list;
static GDBusConnection *_obex_get_session_dbus(void)
{
return id;
}
+static struct obex_watch_result *find_watch_node(const char *path)
+{
+ struct obex_watch_result *node;
+ GList *list, *next;
+
+ DBG("path = %s", path);
+
+ if (!transfer_watched_list ||
+ !g_list_length(transfer_watched_list))
+ return NULL;
+
+ for (list = g_list_first(transfer_watched_list);
+ list; list = next) {
+ next = g_list_next(list);
+ node = list->data;
+
+ if (node && !g_strcmp0(node->path, path))
+ return node;
+ }
+
+ return NULL;
+}
+
static void transfer_properties_changed(GDBusProxy *proxy,
GVariant *changed_properties,
GStrv *invalidated_properties,
g_signal_handler_disconnect(async_node->proxy,
async_node->proxy_id);
+
+ transfer_watched_list = g_list_remove(transfer_watched_list,
+ async_node);
g_object_unref(p_proxy);
g_object_unref(async_node->proxy);
if (async_node->path)
G_CALLBACK(transfer_properties_changed),
async_node);
+ transfer_watched_list = g_list_append(transfer_watched_list,
+ async_node);
+
return 0;
}
+void obex_transfer_clear_notify(char *transfer_path)
+{
+ struct obex_watch_result *async_node;
+
+ DBG("transfer_path = %s", transfer_path);
+
+ if (!transfer_path)
+ return;
+
+ async_node = find_watch_node(transfer_path);
+ if (!async_node)
+ return;
+
+ g_signal_handler_disconnect(async_node->proxy,
+ async_node->proxy_id);
+
+ transfer_watched_list = g_list_remove(transfer_watched_list,
+ async_node);
+
+ g_object_unref(async_node->proxy);
+ if (async_node->path)
+ g_free(async_node->path);
+ g_free(async_node);
+}
+
static void simple_cancle_cb(GObject *object,
GAsyncResult *res, gpointer user_data)
{
if (path == NULL)
return;
+ DBG("path = %s", path);
+
g_dbus_connection_call(connection, "org.bluez.obex",
path,
"org.bluez.obex.Transfer1",
relay_agent = create_relay_agent(sender, agent_path, NULL, pid,
uid, relay_agent_watch_id);
- agent_server_list = g_list_append(agent_list, relay_agent);
+ agent_server_list = g_list_append(agent_server_list, relay_agent);
if (relay_agent_timeout_id > 0) {
g_source_remove(relay_agent_timeout_id);
gpointer user_data)
{
const gchar *sender;
+ gchar *name;
guint transfer_id, agent_id = 0;
DBG("");
return;
}
- if (transfer_id == agent_id)
+ if (transfer_id == agent_id) {
+ name = obex_transfer_get_property_name(
+ relay_agent->transfer_path);
+ if (!name)
+ name = "";
obex_transfer_cancel(relay_agent->transfer_path);
- else {
+ send_pushstatus(relay_agent->address,
+ name, 0, transfer_id, OBEX_TRANSFER_CANCELED,
+ 0, relay_agent->pid);
+ obex_transfer_clear_notify(relay_agent->transfer_path);
+ } else {
comms_error_not_available(invocation);
return;
}
{
const gchar *sender;
struct pending_files *p_file;
+ guint transfer_id;
GList *list, *next;
DBG("+");
obex_transfer_cancel(p_file->path);
}
- free_all_pending_files();
- free_remove_relay_agent();
+ if (relay_client_agent) {
+ obex_session_remove_session(
+ relay_client_agent->session);
+
+ for (list = g_list_first(pending_p_list); list; list = next) {
+ p_file = list->data;
+ next = g_list_next(list);
+
+ if (p_file == NULL)
+ continue;
+
+ if (p_file->path) {
+ transfer_id = obex_get_transfer_id(
+ p_file->path, OBEX_CLIENT);
+ send_pushstatus(relay_client_agent->address,
+ p_file->file_name, 0, transfer_id,
+ OBEX_TRANSFER_CANCELED, 0,
+ relay_client_agent->pid);
+ obex_transfer_clear_notify(p_file->path);
+ }
+ free_pending_files(p_file);
+ }
+
+ free_relay_agent(relay_client_agent);
+ relay_client_agent = NULL;
+ }
+
+ if (g_list_length(agent_list) > 0) {
+ list = g_list_first(agent_list);
+ relay_client_agent = list->data;
+ agent_list = g_list_remove(agent_list, relay_client_agent);
+ obex_create_session(relay_client_agent->address,
+ OBEX_OPP, session_state_cb, NULL);
+ }
g_dbus_method_invocation_return_value(invocation, NULL);