1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /*
3  * Libbrasero-misc
4  * Copyright (C) Philippe Rouquier 2005-2009 <bonfire-app@wanadoo.fr>
5  *
6  * Libbrasero-misc is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * The Libbrasero-misc authors hereby grant permission for non-GPL compatible
12  * GStreamer plugins to be used and distributed together with GStreamer
13  * and Libbrasero-misc. This permission is above and beyond the permissions granted
14  * by the GPL license by which Libbrasero-burn is covered. If you modify this code
15  * you may extend this exception to your version of the code, but you are not
16  * obligated to do so. If you do not wish to do so, delete this exception
17  * statement from your version.
18  *
19  * Libbrasero-misc is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU Library General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to:
26  * 	The Free Software Foundation, Inc.,
27  * 	51 Franklin Street, Fifth Floor
28  * 	Boston, MA  02110-1301, USA.
29  */
30 
31 #ifndef _BRASERO_IO_H_
32 #define _BRASERO_IO_H_
33 
34 #include <glib-object.h>
35 #include <gtk/gtk.h>
36 
37 #include "brasero-async-task-manager.h"
38 
39 G_BEGIN_DECLS
40 
41 typedef enum {
42 	BRASERO_IO_INFO_NONE			= 0,
43 	BRASERO_IO_INFO_MIME			= 1,
44 	BRASERO_IO_INFO_ICON			= 1,
45 	BRASERO_IO_INFO_PERM			= 1 << 1,
46 	BRASERO_IO_INFO_METADATA		= 1 << 2,
47 	BRASERO_IO_INFO_METADATA_THUMBNAIL	= 1 << 3,
48 	BRASERO_IO_INFO_RECURSIVE		= 1 << 4,
49 	BRASERO_IO_INFO_CHECK_PARENT_SYMLINK	= 1 << 5,
50 	BRASERO_IO_INFO_METADATA_MISSING_CODEC	= 1 << 6,
51 
52 	BRASERO_IO_INFO_FOLLOW_SYMLINK		= 1 << 7,
53 
54 	BRASERO_IO_INFO_URGENT			= 1 << 9,
55 	BRASERO_IO_INFO_IDLE			= 1 << 10
56 } BraseroIOFlags;
57 
58 
59 typedef enum {
60 	BRASERO_IO_PHASE_START		= 0,
61 	BRASERO_IO_PHASE_DOWNLOAD,
62 	BRASERO_IO_PHASE_END
63 } BraseroIOPhase;
64 
65 #define BRASERO_IO_XFER_DESTINATION	"xfer::destination"
66 
67 #define BRASERO_IO_PLAYLIST_TITLE	"playlist::title"
68 #define BRASERO_IO_IS_PLAYLIST		"playlist::is_playlist"
69 #define BRASERO_IO_PLAYLIST_ENTRIES_NUM	"playlist::entries_num"
70 
71 #define BRASERO_IO_COUNT_NUM		"count::num"
72 #define BRASERO_IO_COUNT_SIZE		"count::size"
73 #define BRASERO_IO_COUNT_INVALID	"count::invalid"
74 
75 #define BRASERO_IO_THUMBNAIL		"metadata::thumbnail"
76 
77 #define BRASERO_IO_LEN			"metadata::length"
78 #define BRASERO_IO_ISRC			"metadata::isrc"
79 #define BRASERO_IO_TITLE		"metadata::title"
80 #define BRASERO_IO_ARTIST		"metadata::artist"
81 #define BRASERO_IO_ALBUM		"metadata::album"
82 #define BRASERO_IO_GENRE		"metadata::genre"
83 #define BRASERO_IO_COMPOSER		"metadata::composer"
84 #define BRASERO_IO_HAS_AUDIO		"metadata::has_audio"
85 #define BRASERO_IO_HAS_VIDEO		"metadata::has_video"
86 #define BRASERO_IO_IS_SEEKABLE		"metadata::is_seekable"
87 
88 #define BRASERO_IO_HAS_DTS			"metadata::audio::wav::has_dts"
89 
90 #define BRASERO_IO_CHANNELS		"metadata::audio::channels"
91 #define BRASERO_IO_RATE				"metadata::audio::rate"
92 
93 #define BRASERO_IO_DIR_CONTENTS_ADDR	"image::directory::address"
94 
95 typedef struct _BraseroIOJobProgress BraseroIOJobProgress;
96 
97 typedef void		(*BraseroIOResultCallback)	(GObject *object,
98 							 GError *error,
99 							 const gchar *uri,
100 							 GFileInfo *info,
101 							 gpointer callback_data);
102 
103 typedef void		(*BraseroIOProgressCallback)	(GObject *object,
104 							 BraseroIOJobProgress *info,
105 							 gpointer callback_data);
106 
107 typedef void		(*BraseroIODestroyCallback)	(GObject *object,
108 							 gboolean cancel,
109 							 gpointer callback_data);
110 
111 typedef gboolean	(*BraseroIOCompareCallback)	(gpointer data,
112 							 gpointer user_data);
113 
114 
115 struct _BraseroIOJobCallbacks {
116 	BraseroIOResultCallback callback;
117 	BraseroIODestroyCallback destroy;
118 	BraseroIOProgressCallback progress;
119 
120 	guint ref;
121 
122 	/* Whether we are returning something for this base */
123 	guint in_use:1;
124 };
125 typedef struct _BraseroIOJobCallbacks BraseroIOJobCallbacks;
126 
127 struct _BraseroIOJobBase {
128 	GObject *object;
129 	BraseroIOJobCallbacks *methods;
130 };
131 typedef struct _BraseroIOJobBase BraseroIOJobBase;
132 
133 struct _BraseroIOResultCallbackData {
134 	gpointer callback_data;
135 	gint ref;
136 };
137 typedef struct _BraseroIOResultCallbackData BraseroIOResultCallbackData;
138 
139 struct _BraseroIOJob {
140 	gchar *uri;
141 	BraseroIOFlags options;
142 
143 	const BraseroIOJobBase *base;
144 	BraseroIOResultCallbackData *callback_data;
145 };
146 typedef struct _BraseroIOJob BraseroIOJob;
147 
148 #define BRASERO_IO_JOB(data)	((BraseroIOJob *) (data))
149 
150 void
151 brasero_io_job_free (gboolean cancelled,
152 		     BraseroIOJob *job);
153 
154 void
155 brasero_io_set_job (BraseroIOJob *self,
156 		    const BraseroIOJobBase *base,
157 		    const gchar *uri,
158 		    BraseroIOFlags options,
159 		    BraseroIOResultCallbackData *callback_data);
160 
161 void
162 brasero_io_push_job (BraseroIOJob *job,
163 		     const BraseroAsyncTaskType *type);
164 
165 void
166 brasero_io_return_result (const BraseroIOJobBase *base,
167 			  const gchar *uri,
168 			  GFileInfo *info,
169 			  GError *error,
170 			  BraseroIOResultCallbackData *callback_data);
171 
172 
173 typedef GtkWindow *	(* BraseroIOGetParentWinCb)	(gpointer user_data);
174 
175 void
176 brasero_io_set_parent_window_callback (BraseroIOGetParentWinCb callback,
177                                        gpointer user_data);
178 
179 void
180 brasero_io_shutdown (void);
181 
182 /* NOTE: The split in methods and objects was
183  * done to prevent jobs sharing the same methods
184  * to return their results concurently. In other
185  * words only one job among those sharing the
186  * same methods can return its results. */
187 
188 BraseroIOJobBase *
189 brasero_io_register (GObject *object,
190 		     BraseroIOResultCallback callback,
191 		     BraseroIODestroyCallback destroy,
192 		     BraseroIOProgressCallback progress);
193 
194 BraseroIOJobBase *
195 brasero_io_register_with_methods (GObject *object,
196                                   BraseroIOJobCallbacks *methods);
197 
198 BraseroIOJobCallbacks *
199 brasero_io_register_job_methods (BraseroIOResultCallback callback,
200                                  BraseroIODestroyCallback destroy,
201                                  BraseroIOProgressCallback progress);
202 
203 void
204 brasero_io_job_base_free (BraseroIOJobBase *base);
205 
206 void
207 brasero_io_cancel_by_base (BraseroIOJobBase *base);
208 
209 void
210 brasero_io_find_urgent (const BraseroIOJobBase *base,
211 			BraseroIOCompareCallback callback,
212 			gpointer callback_data);
213 
214 void
215 brasero_io_load_directory (const gchar *uri,
216 			   const BraseroIOJobBase *base,
217 			   BraseroIOFlags options,
218 			   gpointer callback_data);
219 void
220 brasero_io_get_file_info (const gchar *uri,
221 			  const BraseroIOJobBase *base,
222 			  BraseroIOFlags options,
223 			  gpointer callback_data);
224 void
225 brasero_io_get_file_count (GSList *uris,
226 			   const BraseroIOJobBase *base,
227 			   BraseroIOFlags options,
228 			   gpointer callback_data);
229 void
230 brasero_io_parse_playlist (const gchar *uri,
231 			   const BraseroIOJobBase *base,
232 			   BraseroIOFlags options,
233 			   gpointer callback_data);
234 
235 guint64
236 brasero_io_job_progress_get_read (BraseroIOJobProgress *progress);
237 
238 guint64
239 brasero_io_job_progress_get_total (BraseroIOJobProgress *progress);
240 
241 BraseroIOPhase
242 brasero_io_job_progress_get_phase (BraseroIOJobProgress *progress);
243 
244 guint
245 brasero_io_job_progress_get_file_processed (BraseroIOJobProgress *progress);
246 
247 G_END_DECLS
248 
249 #endif /* _BRASERO_IO_H_ */
250