4 * Copyright (C) 2012 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>
27 msu_async_cb_data_t *msu_async_cb_data_new(msu_task_t *task,
28 msu_upnp_task_complete_t cb)
30 msu_async_cb_data_t *cb_data = g_new0(msu_async_cb_data_t, 1);
32 cb_data->type = task->type;
39 void msu_async_cb_data_delete(msu_async_cb_data_t *cb_data)
42 switch (cb_data->type) {
43 case MSU_TASK_GET_CHILDREN:
45 g_free(cb_data->ut.bas.root_path);
46 if (cb_data->ut.bas.vbs)
47 g_ptr_array_unref(cb_data->ut.bas.vbs);
49 case MSU_TASK_GET_PROP:
50 g_free(cb_data->ut.get_prop.root_path);
52 case MSU_TASK_GET_ALL_PROPS:
53 case MSU_TASK_GET_RESOURCE:
54 g_free(cb_data->ut.get_all.root_path);
55 if (cb_data->ut.get_all.vb)
56 g_variant_builder_unref(cb_data->ut.get_all.vb);
58 case MSU_TASK_UPLOAD_TO_ANY:
60 g_free(cb_data->ut.upload.root_path);
61 g_free(cb_data->ut.upload.mime_type);
63 case MSU_TASK_CREATE_CONTAINER:
64 g_free(cb_data->ut.create_container.root_path);
66 case MSU_TASK_UPDATE_OBJECT:
67 g_free(cb_data->ut.update.current_tag_value);
68 g_free(cb_data->ut.update.new_tag_value);
79 gboolean msu_async_complete_task(gpointer user_data)
81 msu_async_cb_data_t *cb_data = user_data;
83 MSU_LOG_DEBUG("Enter. Error %p", (void *) cb_data->error);
86 cb_data->cb(cb_data->task, cb_data->result, cb_data->error);
87 msu_async_cb_data_delete(cb_data);
92 void msu_async_task_cancelled(GCancellable *cancellable, gpointer user_data)
94 msu_async_cb_data_t *cb_data = user_data;
96 gupnp_service_proxy_cancel_action(cb_data->proxy, cb_data->action);
99 cb_data->error = g_error_new(MSU_ERROR, MSU_ERROR_CANCELLED,
100 "Operation cancelled.");
101 (void) g_idle_add(msu_async_complete_task, cb_data);