4 * Copyright (C) 2012-2013 Intel Corporation. All rights reserved.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU Lesser General Public License,
8 * version 2.1, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 * Mark Ryan <mark.d.ryan@intel.com>
23 #include <libdleyna/core/error.h>
24 #include <libdleyna/core/log.h>
28 void dlr_async_task_delete(dlr_async_task_t *task)
30 if (task->free_private)
31 task->free_private(task->private);
32 if (task->cancellable)
33 g_object_unref(task->cancellable);
36 gboolean dlr_async_task_complete(gpointer user_data)
38 dlr_async_task_t *cb_data = user_data;
40 DLEYNA_LOG_DEBUG("Enter. %s %s", cb_data->error ? "Error:" : "Success.",
41 cb_data->error ? cb_data->error->message : "");
42 DLEYNA_LOG_DEBUG_NL();
44 if (cb_data->proxy != NULL)
45 g_object_remove_weak_pointer((G_OBJECT(cb_data->proxy)),
46 (gpointer *)&cb_data->proxy);
48 cb_data->cb(&cb_data->task, cb_data->error);
53 void dlr_async_task_cancelled(GCancellable *cancellable, gpointer user_data)
55 dlr_async_task_t *cb_data = user_data;
57 if (cb_data->proxy != NULL)
58 gupnp_service_proxy_cancel_action(cb_data->proxy,
62 cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
63 DLEYNA_ERROR_CANCELLED,
64 "Operation cancelled.");
66 (void) g_idle_add(dlr_async_task_complete, cb_data);
69 void dlr_async_task_cancel(dlr_async_task_t *task)
71 if (task->cancellable)
72 g_cancellable_cancel(task->cancellable);