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_MANAGER_GET_ALL_PROPS:
38 case DLS_TASK_GET_ALL_PROPS:
39 case DLS_TASK_GET_RESOURCE:
40 if (cb_data->ut.get_all.vb)
41 g_variant_builder_unref(cb_data->ut.get_all.vb);
43 case DLS_TASK_UPLOAD_TO_ANY:
45 g_free(cb_data->ut.upload.mime_type);
47 case DLS_TASK_UPDATE_OBJECT:
48 g_free(cb_data->ut.update.current_tag_value);
49 g_free(cb_data->ut.update.new_tag_value);
55 if (cb_data->cancellable)
56 g_object_unref(cb_data->cancellable);
59 gboolean dls_async_task_complete(gpointer user_data)
61 dls_async_task_t *cb_data = user_data;
63 DLEYNA_LOG_DEBUG("Enter. Error %p", (void *)cb_data->error);
64 DLEYNA_LOG_DEBUG_NL();
66 if (cb_data->proxy != NULL)
67 g_object_remove_weak_pointer((G_OBJECT(cb_data->proxy)),
68 (gpointer *)&cb_data->proxy);
70 cb_data->cb(&cb_data->task, cb_data->error);
75 void dls_async_task_cancelled_cb(GCancellable *cancellable, gpointer user_data)
77 dls_async_task_t *cb_data = user_data;
79 if (cb_data->proxy != NULL)
80 gupnp_service_proxy_cancel_action(cb_data->proxy,
84 cb_data->error = g_error_new(DLEYNA_SERVER_ERROR,
85 DLEYNA_ERROR_CANCELLED,
86 "Operation cancelled.");
87 (void) g_idle_add(dls_async_task_complete, cb_data);
90 void dls_async_task_cancel(dls_async_task_t *cb_data)
92 if (cb_data->cancellable)
93 g_cancellable_cancel(cb_data->cancellable);