Update to v0.4.0
[profile/ivi/dLeyna.git] / dleyna-server / libdleyna / server / task.h
1 /*
2  * dLeyna
3  *
4  * Copyright (C) 2012-2013 Intel Corporation. All rights reserved.
5  *
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.
9  *
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
13  * for more details.
14  *
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.
18  *
19  * Mark Ryan <mark.d.ryan@intel.com>
20  *
21  */
22
23 #ifndef DLS_TASK_H__
24 #define DLS_TASK_H__
25
26 #include <gio/gio.h>
27 #include <glib.h>
28
29 #include <libdleyna/core/connector.h>
30 #include <libdleyna/core/task-atom.h>
31
32 #include "server.h"
33
34 enum dls_task_type_t_ {
35         DLS_TASK_GET_VERSION,
36         DLS_TASK_GET_SERVERS,
37         DLS_TASK_RESCAN,
38         DLS_TASK_GET_CHILDREN,
39         DLS_TASK_GET_ALL_PROPS,
40         DLS_TASK_GET_PROP,
41         DLS_TASK_SEARCH,
42         DLS_TASK_BROWSE_OBJECTS,
43         DLS_TASK_GET_RESOURCE,
44         DLS_TASK_SET_PREFER_LOCAL_ADDRESSES,
45         DLS_TASK_SET_PROTOCOL_INFO,
46         DLS_TASK_UPLOAD_TO_ANY,
47         DLS_TASK_UPLOAD,
48         DLS_TASK_GET_UPLOAD_STATUS,
49         DLS_TASK_GET_UPLOAD_IDS,
50         DLS_TASK_CANCEL_UPLOAD,
51         DLS_TASK_DELETE_OBJECT,
52         DLS_TASK_CREATE_CONTAINER,
53         DLS_TASK_CREATE_CONTAINER_IN_ANY,
54         DLS_TASK_UPDATE_OBJECT,
55         DLS_TASK_GET_OBJECT_METADATA,
56         DLS_TASK_CREATE_REFERENCE,
57         DLS_TASK_GET_ICON,
58         DLS_TASK_MANAGER_GET_ALL_PROPS,
59         DLS_TASK_MANAGER_GET_PROP,
60         DLS_TASK_MANAGER_SET_PROP
61 };
62 typedef enum dls_task_type_t_ dls_task_type_t;
63
64 typedef void (*dls_cancel_task_t)(void *handle);
65
66 typedef struct dls_task_get_children_t_ dls_task_get_children_t;
67 struct dls_task_get_children_t_ {
68         gboolean containers;
69         gboolean items;
70         guint start;
71         guint count;
72         GVariant *filter;
73         gchar *sort_by;
74 };
75
76 typedef struct dls_task_get_props_t_ dls_task_get_props_t;
77 struct dls_task_get_props_t_ {
78         gchar *interface_name;
79 };
80
81 typedef struct dls_task_get_prop_t_ dls_task_get_prop_t;
82 struct dls_task_get_prop_t_ {
83         gchar *prop_name;
84         gchar *interface_name;
85 };
86
87 typedef struct dls_task_set_prop_t_ dls_task_set_prop_t;
88 struct dls_task_set_prop_t_ {
89         gchar *prop_name;
90         gchar *interface_name;
91         GVariant *params;
92 };
93
94 typedef struct dls_task_search_t_ dls_task_search_t;
95 struct dls_task_search_t_ {
96         gchar *query;
97         guint start;
98         guint count;
99         gchar *sort_by;
100         GVariant *filter;
101 };
102
103 typedef struct dls_task_browse_objects_t_ dls_task_browse_objects_t;
104 struct dls_task_browse_objects_t_ {
105         GVariant *objects;
106         GVariant *filter;
107 };
108
109 typedef struct dls_task_get_resource_t_ dls_task_get_resource_t;
110 struct dls_task_get_resource_t_ {
111         gchar *protocol_info;
112         GVariant *filter;
113 };
114
115 typedef struct dls_task_set_prefer_local_addresses_t_
116                                         dls_task_set_prefer_local_addresses_t;
117 struct dls_task_set_prefer_local_addresses_t_ {
118         gboolean prefer;
119 };
120
121 typedef struct dls_task_set_protocol_info_t_ dls_task_set_protocol_info_t;
122 struct dls_task_set_protocol_info_t_ {
123         gchar *protocol_info;
124 };
125
126 typedef struct dls_task_upload_t_ dls_task_upload_t;
127 struct dls_task_upload_t_ {
128         gchar *display_name;
129         gchar *file_path;
130 };
131
132 typedef struct dls_task_upload_action_t_ dls_task_upload_action_t;
133 struct dls_task_upload_action_t_ {
134         guint upload_id;
135 };
136
137 typedef struct dls_task_create_container_t_ dls_task_create_container_t;
138 struct dls_task_create_container_t_ {
139         gchar *display_name;
140         gchar *type;
141         GVariant *child_types;
142 };
143
144 typedef struct dls_task_update_t_ dls_task_update_t;
145 struct dls_task_update_t_ {
146         GVariant *to_add_update;
147         GVariant *to_delete;
148 };
149
150 typedef struct dls_task_create_reference_t_ dls_task_create_reference_t;
151 struct dls_task_create_reference_t_ {
152         gchar *item_path;
153 };
154
155 typedef struct dls_task_target_info_t_ dls_task_target_info_t;
156 struct dls_task_target_info_t_ {
157         gchar *path;
158         gchar *root_path;
159         gchar *id;
160         dls_device_t *device;
161 };
162
163 typedef struct dls_task_get_icon_t_ dls_task_get_icon_t;
164 struct dls_task_get_icon_t_ {
165         gchar *mime_type;
166         gchar *resolution;
167 };
168
169 typedef struct dls_task_t_ dls_task_t;
170 struct dls_task_t_ {
171         dleyna_task_atom_t atom; /* pseudo inheritance - MUST be first field */
172         dls_task_type_t type;
173         dls_task_target_info_t target;
174         const gchar *result_format;
175         GVariant *result;
176         dleyna_connector_msg_id_t invocation;
177         gboolean synchronous;
178         gboolean multiple_retvals;
179         union {
180                 dls_task_get_children_t get_children;
181                 dls_task_get_props_t get_props;
182                 dls_task_get_prop_t get_prop;
183                 dls_task_set_prop_t set_prop;
184                 dls_task_search_t search;
185                 dls_task_get_resource_t resource;
186                 dls_task_set_prefer_local_addresses_t prefer_local_addresses;
187                 dls_task_set_protocol_info_t protocol_info;
188                 dls_task_upload_t upload;
189                 dls_task_upload_action_t upload_action;
190                 dls_task_create_container_t create_container;
191                 dls_task_update_t update;
192                 dls_task_create_reference_t create_reference;
193                 dls_task_get_icon_t get_icon;
194                 dls_task_browse_objects_t browse_objects;
195         } ut;
196 };
197
198 dls_task_t *dls_task_rescan_new(dleyna_connector_msg_id_t invocation);
199
200 dls_task_t *dls_task_get_version_new(dleyna_connector_msg_id_t invocation);
201
202 dls_task_t *dls_task_get_servers_new(dleyna_connector_msg_id_t invocation);
203
204 dls_task_t *dls_task_get_children_new(dleyna_connector_msg_id_t invocation,
205                                       const gchar *path, GVariant *parameters,
206                                       gboolean items, gboolean containers,
207                                       GError **error);
208
209 dls_task_t *dls_task_get_children_ex_new(dleyna_connector_msg_id_t invocation,
210                                          const gchar *path,
211                                          GVariant *parameters, gboolean items,
212                                          gboolean containers,
213                                          GError **error);
214
215 dls_task_t *dls_task_get_prop_new(dleyna_connector_msg_id_t invocation,
216                                   const gchar *path, GVariant *parameters,
217                                   GError **error);
218
219 dls_task_t *dls_task_get_props_new(dleyna_connector_msg_id_t invocation,
220                                    const gchar *path, GVariant *parameters,
221                                    GError **error);
222
223 dls_task_t *dls_task_search_new(dleyna_connector_msg_id_t invocation,
224                                 const gchar *path, GVariant *parameters,
225                                 GError **error);
226
227 dls_task_t *dls_task_search_ex_new(dleyna_connector_msg_id_t invocation,
228                                    const gchar *path, GVariant *parameters,
229                                    GError **error);
230
231 dls_task_t *dls_task_browse_objects_new(dleyna_connector_msg_id_t invocation,
232                                         const gchar *path, GVariant *parameters,
233                                         GError **error);
234
235 dls_task_t *dls_task_get_resource_new(dleyna_connector_msg_id_t invocation,
236                                       const gchar *path, GVariant *parameters,
237                                       GError **error);
238
239 dls_task_t *dls_task_set_protocol_info_new(dleyna_connector_msg_id_t invocation,
240                                            GVariant *parameters);
241
242 dls_task_t *dls_task_prefer_local_addresses_new(
243                                         dleyna_connector_msg_id_t invocation,
244                                         GVariant *parameters);
245
246 dls_task_t *dls_task_upload_to_any_new(dleyna_connector_msg_id_t invocation,
247                                        const gchar *path, GVariant *parameters,
248                                        GError **error);
249
250 dls_task_t *dls_task_upload_new(dleyna_connector_msg_id_t invocation,
251                                 const gchar *path, GVariant *parameters,
252                                 GError **error);
253
254 dls_task_t *dls_task_get_upload_status_new(dleyna_connector_msg_id_t invocation,
255                                            const gchar *path,
256                                            GVariant *parameters,
257                                            GError **error);
258
259 dls_task_t *dls_task_get_upload_ids_new(dleyna_connector_msg_id_t invocation,
260                                         const gchar *path,
261                                         GError **error);
262
263 dls_task_t *dls_task_cancel_upload_new(dleyna_connector_msg_id_t invocation,
264                                        const gchar *path,
265                                        GVariant *parameters,
266                                        GError **error);
267
268 dls_task_t *dls_task_delete_new(dleyna_connector_msg_id_t invocation,
269                                 const gchar *path,
270                                 GError **error);
271
272 dls_task_t *dls_task_create_container_new_generic(
273                                         dleyna_connector_msg_id_t invocation,
274                                         dls_task_type_t type,
275                                         const gchar *path,
276                                         GVariant *parameters,
277                                         GError **error);
278
279 dls_task_t *dls_task_create_reference_new(dleyna_connector_msg_id_t invocation,
280                                           dls_task_type_t type,
281                                           const gchar *path,
282                                           GVariant *parameters,
283                                           GError **error);
284
285 dls_task_t *dls_task_update_new(dleyna_connector_msg_id_t invocation,
286                                 const gchar *path, GVariant *parameters,
287                                 GError **error);
288
289 dls_task_t *dls_task_get_metadata_new(dleyna_connector_msg_id_t invocation,
290                                       const gchar *path,
291                                       GError **error);
292
293 dls_task_t *dls_task_get_icon_new(dleyna_connector_msg_id_t invocation,
294                                   const gchar *path, GVariant *parameters,
295                                   GError **error);
296
297 dls_task_t *dls_task_manager_get_prop_new(dleyna_connector_msg_id_t invocation,
298                                           const gchar *path,
299                                           GVariant *parameters,
300                                           GError **error);
301
302 dls_task_t *dls_task_manager_get_props_new(dleyna_connector_msg_id_t invocation,
303                                            const gchar *path,
304                                            GVariant *parameters,
305                                            GError **error);
306
307 dls_task_t *dls_task_manager_set_prop_new(dleyna_connector_msg_id_t invocation,
308                                           const gchar *path,
309                                           GVariant *parameters,
310                                           GError **error);
311
312 void dls_task_cancel(dls_task_t *task);
313
314 void dls_task_complete(dls_task_t *task);
315
316 void dls_task_fail(dls_task_t *task, GError *error);
317
318 void dls_task_delete(dls_task_t *task);
319
320 #endif /* DLS_TASK_H__ */