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>
29 void dls_async_task_delete(dls_async_task_t *cb_data)
31 switch (cb_data->task.type) {
32 case DLS_TASK_GET_CHILDREN:
34 if (cb_data->ut.bas.vbs)
35 g_ptr_array_unref(cb_data->ut.bas.vbs);
37 case DLS_TASK_GET_ALL_PROPS:
38 case DLS_TASK_GET_RESOURCE:
39 if (cb_data->ut.get_all.vb)
40 g_variant_builder_unref(cb_data->ut.get_all.vb);
42 case DLS_TASK_UPLOAD_TO_ANY:
44 g_free(cb_data->ut.upload.mime_type);
46 case DLS_TASK_UPDATE_OBJECT:
47 g_free(cb_data->ut.update.current_tag_value);
48 g_free(cb_data->ut.update.new_tag_value);
54 if (cb_data->cancellable)
55 g_object_unref(cb_data->cancellable);
58 gboolean dls_async_task_complete(gpointer user_data)
60 dls_async_task_t *cb_data = user_data;
62 DLEYNA_LOG_DEBUG("Enter. Error %p", (void *)cb_data->error);
63 DLEYNA_LOG_DEBUG_NL();
65 if (cb_data->proxy != NULL)
66 g_object_remove_weak_pointer((G_OBJECT(cb_data->proxy)),
67 (gpointer *)&cb_data->proxy);
69 cb_data->cb(&cb_data->task, cb_data->error);
74 void dls_async_task_cancelled_cb(GCancellable *cancellable, gpointer user_data)
76 dls_async_task_t *cb_data = user_data;
78 if (cb_data->proxy != NULL)
79 gupnp_service_proxy_cancel_action(cb_data->proxy,
83 cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
84 DLEYNA_ERROR_CANCELLED,
85 "Operation cancelled.");
86 (void) g_idle_add(dls_async_task_complete, cb_data);
89 void dls_async_task_cancel(dls_async_task_t *cb_data)
91 if (cb_data->cancellable)
92 g_cancellable_cancel(cb_data->cancellable);