File: | libbaul-private/baul-vfs-file.c |
Warning: | line 389, column 12 This statement is never executed |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- |
2 | |
3 | baul-vfs-file.c: Subclass of BaulFile to help implement the |
4 | virtual trash directory. |
5 | |
6 | Copyright (C) 1999, 2000, 2001 Eazel, Inc. |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License as |
10 | published by the Free Software Foundation; either version 2 of the |
11 | License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public |
19 | License along with this program; if not, write to the |
20 | Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, |
21 | Boston, MA 02110-1301, USA. |
22 | |
23 | Author: Darin Adler <darin@bentspoon.com> |
24 | */ |
25 | |
26 | #include <config.h> |
27 | |
28 | #include <glib/gi18n.h> |
29 | |
30 | #include <eel/eel-ctk-macros.h> |
31 | |
32 | #include "baul-vfs-file.h" |
33 | #include "baul-directory-notify.h" |
34 | #include "baul-directory-private.h" |
35 | #include "baul-file-private.h" |
36 | #include "baul-autorun.h" |
37 | |
38 | static void baul_vfs_file_init (gpointer object, |
39 | gpointer klass); |
40 | static void baul_vfs_file_class_init (gpointer klass); |
41 | |
42 | EEL_CLASS_BOILERPLATE (BaulVFSFile,static gpointer parent_class; GType baul_vfs_file_get_type (void ) { GType parent_type; static GType type; if (type == 0) { static GTypeInfo info = { sizeof (BaulVFSFileClass), ((void*)0), (( void*)0), (GClassInitFunc) baul_vfs_file_class_init, ((void*) 0), ((void*)0), sizeof (BaulVFSFile), 0, (GInstanceInitFunc) baul_vfs_file_init , ((void*)0) }; parent_type = (baul_file_get_type()); type = g_type_register_static (parent_type, "BaulVFSFile", &info, 0); parent_class = g_type_class_ref (parent_type); } return type; } |
43 | baul_vfs_file,static gpointer parent_class; GType baul_vfs_file_get_type (void ) { GType parent_type; static GType type; if (type == 0) { static GTypeInfo info = { sizeof (BaulVFSFileClass), ((void*)0), (( void*)0), (GClassInitFunc) baul_vfs_file_class_init, ((void*) 0), ((void*)0), sizeof (BaulVFSFile), 0, (GInstanceInitFunc) baul_vfs_file_init , ((void*)0) }; parent_type = (baul_file_get_type()); type = g_type_register_static (parent_type, "BaulVFSFile", &info, 0); parent_class = g_type_class_ref (parent_type); } return type; } |
44 | BAUL_TYPE_FILE)static gpointer parent_class; GType baul_vfs_file_get_type (void ) { GType parent_type; static GType type; if (type == 0) { static GTypeInfo info = { sizeof (BaulVFSFileClass), ((void*)0), (( void*)0), (GClassInitFunc) baul_vfs_file_class_init, ((void*) 0), ((void*)0), sizeof (BaulVFSFile), 0, (GInstanceInitFunc) baul_vfs_file_init , ((void*)0) }; parent_type = (baul_file_get_type()); type = g_type_register_static (parent_type, "BaulVFSFile", &info, 0); parent_class = g_type_class_ref (parent_type); } return type; } |
45 | |
46 | static void |
47 | vfs_file_monitor_add (BaulFile *file, |
48 | gconstpointer client, |
49 | BaulFileAttributes attributes) |
50 | { |
51 | baul_directory_monitor_add_internal |
52 | (file->details->directory, file, |
53 | client, TRUE(!(0)), attributes, NULL((void*)0), NULL((void*)0)); |
54 | } |
55 | |
56 | static void |
57 | vfs_file_monitor_remove (BaulFile *file, |
58 | gconstpointer client) |
59 | { |
60 | baul_directory_monitor_remove_internal |
61 | (file->details->directory, file, client); |
62 | } |
63 | |
64 | static void |
65 | vfs_file_call_when_ready (BaulFile *file, |
66 | BaulFileAttributes file_attributes, |
67 | BaulFileCallback callback, |
68 | gpointer callback_data) |
69 | |
70 | { |
71 | baul_directory_call_when_ready_internal |
72 | (file->details->directory, file, |
73 | file_attributes, FALSE(0), NULL((void*)0), callback, callback_data); |
74 | } |
75 | |
76 | static void |
77 | vfs_file_cancel_call_when_ready (BaulFile *file, |
78 | BaulFileCallback callback, |
79 | gpointer callback_data) |
80 | { |
81 | baul_directory_cancel_callback_internal |
82 | (file->details->directory, file, |
83 | NULL((void*)0), callback, callback_data); |
84 | } |
85 | |
86 | static gboolean |
87 | vfs_file_check_if_ready (BaulFile *file, |
88 | BaulFileAttributes file_attributes) |
89 | { |
90 | return baul_directory_check_if_ready_internal |
91 | (file->details->directory, file, |
92 | file_attributes); |
93 | } |
94 | |
95 | static void |
96 | set_metadata_get_info_callback (GObject *source_object, |
97 | GAsyncResult *res, |
98 | gpointer callback_data) |
99 | { |
100 | BaulFile *file; |
101 | GFileInfo *new_info; |
102 | GError *error; |
103 | |
104 | file = callback_data; |
105 | |
106 | error = NULL((void*)0); |
107 | new_info = g_file_query_info_finish (G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((source_object)), ((g_file_get_type ())))))), res, &error); |
108 | if (new_info != NULL((void*)0)) |
109 | { |
110 | if (baul_file_update_info (file, new_info)) |
111 | { |
112 | baul_file_changed (file); |
113 | } |
114 | g_object_unref (new_info); |
115 | } |
116 | baul_file_unref (file); |
117 | if (error) |
118 | { |
119 | g_error_free (error); |
120 | } |
121 | } |
122 | |
123 | static void |
124 | set_metadata_callback (GObject *source_object, |
125 | GAsyncResult *result, |
126 | gpointer callback_data) |
127 | { |
128 | BaulFile *file; |
129 | GError *error; |
130 | gboolean res; |
131 | |
132 | file = callback_data; |
133 | |
134 | error = NULL((void*)0); |
135 | res = g_file_set_attributes_finish (G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((source_object)), ((g_file_get_type ())))))), |
136 | result, |
137 | NULL((void*)0), |
138 | &error); |
139 | |
140 | if (res) |
141 | { |
142 | g_file_query_info_async (G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((source_object)), ((g_file_get_type ())))))), |
143 | BAUL_FILE_DEFAULT_ATTRIBUTES"standard::*,access::*,mountable::*,time::*,unix::*,owner::*,selinux::*,thumbnail::*,id::filesystem,trash::orig-path,trash::deletion-date,metadata::*", |
144 | 0, |
145 | G_PRIORITY_DEFAULT0, |
146 | NULL((void*)0), |
147 | set_metadata_get_info_callback, file); |
148 | } |
149 | else |
150 | { |
151 | baul_file_unref (file); |
152 | g_error_free (error); |
153 | } |
154 | } |
155 | |
156 | static void |
157 | vfs_file_set_metadata (BaulFile *file, |
158 | const char *key, |
159 | const char *value) |
160 | { |
161 | GFileInfo *info; |
162 | GFile *location; |
163 | char *gio_key; |
164 | |
165 | info = g_file_info_new (); |
166 | |
167 | gio_key = g_strconcat ("metadata::", key, NULL((void*)0)); |
168 | if (value != NULL((void*)0)) |
169 | { |
170 | g_file_info_set_attribute_string (info, gio_key, value); |
171 | } |
172 | else |
173 | { |
174 | /* Unset the key */ |
175 | g_file_info_set_attribute (info, gio_key, |
176 | G_FILE_ATTRIBUTE_TYPE_INVALID, |
177 | NULL((void*)0)); |
178 | } |
179 | g_free (gio_key); |
180 | |
181 | location = baul_file_get_location (file); |
182 | g_file_set_attributes_async (location, |
183 | info, |
184 | 0, |
185 | G_PRIORITY_DEFAULT0, |
186 | NULL((void*)0), |
187 | set_metadata_callback, |
188 | baul_file_ref (file)); |
189 | g_object_unref (location); |
190 | g_object_unref (info); |
191 | } |
192 | |
193 | static void |
194 | vfs_file_set_metadata_as_list (BaulFile *file, |
195 | const char *key, |
196 | char **value) |
197 | { |
198 | GFile *location; |
199 | GFileInfo *info; |
200 | char *gio_key; |
201 | |
202 | info = g_file_info_new (); |
203 | |
204 | gio_key = g_strconcat ("metadata::", key, NULL((void*)0)); |
205 | g_file_info_set_attribute_stringv (info, gio_key, value); |
206 | g_free (gio_key); |
207 | |
208 | location = baul_file_get_location (file); |
209 | g_file_set_attributes_async (location, |
210 | info, |
211 | 0, |
212 | G_PRIORITY_DEFAULT0, |
213 | NULL((void*)0), |
214 | set_metadata_callback, |
215 | baul_file_ref (file)); |
216 | g_object_unref (info); |
217 | g_object_unref (location); |
218 | } |
219 | |
220 | static gboolean |
221 | vfs_file_get_item_count (BaulFile *file, |
222 | guint *count, |
223 | gboolean *count_unreadable) |
224 | { |
225 | if (count_unreadable != NULL((void*)0)) |
226 | { |
227 | *count_unreadable = file->details->directory_count_failed; |
228 | } |
229 | if (!file->details->got_directory_count) |
230 | { |
231 | if (count != NULL((void*)0)) |
232 | { |
233 | *count = 0; |
234 | } |
235 | return FALSE(0); |
236 | } |
237 | if (count != NULL((void*)0)) |
238 | { |
239 | *count = file->details->directory_count; |
240 | } |
241 | return TRUE(!(0)); |
242 | } |
243 | |
244 | static BaulRequestStatus |
245 | vfs_file_get_deep_counts (BaulFile *file, |
246 | guint *directory_count, |
247 | guint *file_count, |
248 | guint *unreadable_directory_count, |
249 | goffset *total_size, |
250 | goffset *total_size_on_disk) |
251 | { |
252 | GFileType type; |
253 | |
254 | if (directory_count != NULL((void*)0)) |
255 | { |
256 | *directory_count = 0; |
257 | } |
258 | if (file_count != NULL((void*)0)) |
259 | { |
260 | *file_count = 0; |
261 | } |
262 | if (unreadable_directory_count != NULL((void*)0)) |
263 | { |
264 | *unreadable_directory_count = 0; |
265 | } |
266 | if (total_size != NULL((void*)0)) |
267 | { |
268 | *total_size = 0; |
269 | } |
270 | if (total_size_on_disk != NULL((void*)0)) |
271 | { |
272 | *total_size_on_disk = 0; |
273 | } |
274 | |
275 | if (!baul_file_is_directory (file)) |
276 | { |
277 | return BAUL_REQUEST_DONE; |
278 | } |
279 | |
280 | if (file->details->deep_counts_status != BAUL_REQUEST_NOT_STARTED) |
281 | { |
282 | if (directory_count != NULL((void*)0)) |
283 | { |
284 | *directory_count = file->details->deep_directory_count; |
285 | } |
286 | if (file_count != NULL((void*)0)) |
287 | { |
288 | *file_count = file->details->deep_file_count; |
289 | } |
290 | if (unreadable_directory_count != NULL((void*)0)) |
291 | { |
292 | *unreadable_directory_count = file->details->deep_unreadable_count; |
293 | } |
294 | if (total_size != NULL((void*)0)) |
295 | { |
296 | *total_size = file->details->deep_size; |
297 | } |
298 | if (total_size_on_disk != NULL((void*)0)) |
299 | { |
300 | *total_size_on_disk = file->details->deep_size_on_disk; |
301 | } |
302 | return file->details->deep_counts_status; |
303 | } |
304 | |
305 | /* For directories, or before we know the type, we haven't started. */ |
306 | type = baul_file_get_file_type (file); |
307 | if (type == G_FILE_TYPE_UNKNOWN |
308 | || type == G_FILE_TYPE_DIRECTORY) |
309 | { |
310 | return BAUL_REQUEST_NOT_STARTED; |
311 | } |
312 | |
313 | /* For other types, we are done, and the zeros are permanent. */ |
314 | return BAUL_REQUEST_DONE; |
315 | } |
316 | |
317 | static gboolean |
318 | vfs_file_get_date (BaulFile *file, |
319 | BaulDateType date_type, |
320 | time_t *date) |
321 | { |
322 | switch (date_type) |
323 | { |
324 | case BAUL_DATE_TYPE_CHANGED: |
325 | /* Before we have info on a file, the date is unknown. */ |
326 | if (file->details->ctime == 0) |
327 | { |
328 | return FALSE(0); |
329 | } |
330 | if (date != NULL((void*)0)) |
331 | { |
332 | *date = file->details->ctime; |
333 | } |
334 | return TRUE(!(0)); |
335 | case BAUL_DATE_TYPE_ACCESSED: |
336 | /* Before we have info on a file, the date is unknown. */ |
337 | if (file->details->atime == 0) |
338 | { |
339 | return FALSE(0); |
340 | } |
341 | if (date != NULL((void*)0)) |
342 | { |
343 | *date = file->details->atime; |
344 | } |
345 | return TRUE(!(0)); |
346 | case BAUL_DATE_TYPE_MODIFIED: |
347 | /* Before we have info on a file, the date is unknown. */ |
348 | if (file->details->mtime == 0) |
349 | { |
350 | return FALSE(0); |
351 | } |
352 | if (date != NULL((void*)0)) |
353 | { |
354 | *date = file->details->mtime; |
355 | } |
356 | return TRUE(!(0)); |
357 | case BAUL_DATE_TYPE_TRASHED: |
358 | /* Before we have info on a file, the date is unknown. */ |
359 | if (file->details->trash_time == 0) |
360 | { |
361 | return FALSE(0); |
362 | } |
363 | if (date != NULL((void*)0)) |
364 | { |
365 | *date = file->details->trash_time; |
366 | } |
367 | return TRUE(!(0)); |
368 | case BAUL_DATE_TYPE_PERMISSIONS_CHANGED: |
369 | /* Before we have info on a file, the date is unknown. */ |
370 | if (file->details->mtime == 0 || file->details->ctime == 0) |
371 | { |
372 | return FALSE(0); |
373 | } |
374 | /* mtime is when the contents changed; ctime is when the |
375 | * contents or the permissions (inc. owner/group) changed. |
376 | * So we can only know when the permissions changed if mtime |
377 | * and ctime are different. |
378 | */ |
379 | if (file->details->mtime == file->details->ctime) |
380 | { |
381 | return FALSE(0); |
382 | } |
383 | if (date != NULL((void*)0)) |
384 | { |
385 | *date = file->details->ctime; |
386 | } |
387 | return TRUE(!(0)); |
388 | } |
389 | return FALSE(0); |
This statement is never executed | |
390 | } |
391 | |
392 | static char * |
393 | vfs_file_get_where_string (BaulFile *file) |
394 | { |
395 | return baul_file_get_parent_uri_for_display (file); |
396 | } |
397 | |
398 | static void |
399 | vfs_file_mount_callback (GObject *source_object, |
400 | GAsyncResult *res, |
401 | gpointer callback_data) |
402 | { |
403 | BaulFileOperation *op; |
404 | GFile *mounted_on; |
405 | GError *error; |
406 | |
407 | op = callback_data; |
408 | |
409 | error = NULL((void*)0); |
410 | mounted_on = g_file_mount_mountable_finish (G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((source_object)), ((g_file_get_type ())))))), |
411 | res, &error); |
412 | baul_file_operation_complete (op, mounted_on, error); |
413 | if (mounted_on) |
414 | { |
415 | g_object_unref (mounted_on); |
416 | } |
417 | if (error) |
418 | { |
419 | g_error_free (error); |
420 | } |
421 | } |
422 | |
423 | |
424 | static void |
425 | vfs_file_mount (BaulFile *file, |
426 | GMountOperation *mount_op, |
427 | GCancellable *cancellable, |
428 | BaulFileOperationCallback callback, |
429 | gpointer callback_data) |
430 | { |
431 | BaulFileOperation *op; |
432 | GError *error; |
433 | GFile *location; |
434 | |
435 | if (file->details->type != G_FILE_TYPE_MOUNTABLE) |
436 | { |
437 | if (callback) |
438 | { |
439 | error = NULL((void*)0); |
440 | g_set_error_literal (&error, G_IO_ERRORg_io_error_quark(), G_IO_ERROR_NOT_SUPPORTED, |
441 | _("This file cannot be mounted")gettext ("This file cannot be mounted")); |
442 | callback (file, NULL((void*)0), error, callback_data); |
443 | g_error_free (error); |
444 | } |
445 | return; |
446 | } |
447 | |
448 | op = baul_file_operation_new (file, callback, callback_data); |
449 | if (cancellable) |
450 | { |
451 | g_object_unref (op->cancellable); |
452 | op->cancellable = g_object_ref (cancellable)((__typeof__ (cancellable)) (g_object_ref) (cancellable)); |
453 | } |
454 | |
455 | location = baul_file_get_location (file); |
456 | g_file_mount_mountable (location, |
457 | 0, |
458 | mount_op, |
459 | op->cancellable, |
460 | vfs_file_mount_callback, |
461 | op); |
462 | g_object_unref (location); |
463 | } |
464 | |
465 | static void |
466 | vfs_file_unmount_callback (GObject *source_object, |
467 | GAsyncResult *res, |
468 | gpointer callback_data) |
469 | { |
470 | BaulFileOperation *op; |
471 | gboolean unmounted; |
472 | GError *error; |
473 | |
474 | op = callback_data; |
475 | |
476 | error = NULL((void*)0); |
477 | unmounted = g_file_unmount_mountable_with_operation_finish (G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((source_object)), ((g_file_get_type ())))))), |
478 | res, &error); |
479 | |
480 | if (!unmounted && |
481 | error->domain == G_IO_ERRORg_io_error_quark() && |
482 | (error->code == G_IO_ERROR_FAILED_HANDLED || |
483 | error->code == G_IO_ERROR_CANCELLED)) |
484 | { |
485 | g_error_free (error); |
486 | error = NULL((void*)0); |
487 | } |
488 | |
489 | baul_file_operation_complete (op, G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((source_object)), ((g_file_get_type ())))))), error); |
490 | if (error) |
491 | { |
492 | g_error_free (error); |
493 | } |
494 | } |
495 | |
496 | static void |
497 | vfs_file_unmount (BaulFile *file, |
498 | GMountOperation *mount_op, |
499 | GCancellable *cancellable, |
500 | BaulFileOperationCallback callback, |
501 | gpointer callback_data) |
502 | { |
503 | BaulFileOperation *op; |
504 | GFile *location; |
505 | |
506 | op = baul_file_operation_new (file, callback, callback_data); |
507 | if (cancellable) |
508 | { |
509 | g_object_unref (op->cancellable); |
510 | op->cancellable = g_object_ref (cancellable)((__typeof__ (cancellable)) (g_object_ref) (cancellable)); |
511 | } |
512 | |
513 | location = baul_file_get_location (file); |
514 | g_file_unmount_mountable_with_operation (location, |
515 | G_MOUNT_UNMOUNT_NONE, |
516 | mount_op, |
517 | op->cancellable, |
518 | vfs_file_unmount_callback, |
519 | op); |
520 | g_object_unref (location); |
521 | } |
522 | |
523 | static void |
524 | vfs_file_eject_callback (GObject *source_object, |
525 | GAsyncResult *res, |
526 | gpointer callback_data) |
527 | { |
528 | BaulFileOperation *op; |
529 | gboolean ejected; |
530 | GError *error; |
531 | |
532 | op = callback_data; |
533 | |
534 | error = NULL((void*)0); |
535 | ejected = g_file_eject_mountable_with_operation_finish (G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((source_object)), ((g_file_get_type ())))))), |
536 | res, &error); |
537 | |
538 | if (!ejected && |
539 | error->domain == G_IO_ERRORg_io_error_quark() && |
540 | (error->code == G_IO_ERROR_FAILED_HANDLED || |
541 | error->code == G_IO_ERROR_CANCELLED)) |
542 | { |
543 | g_error_free (error); |
544 | error = NULL((void*)0); |
545 | } |
546 | |
547 | baul_file_operation_complete (op, G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((source_object)), ((g_file_get_type ())))))), error); |
548 | if (error) |
549 | { |
550 | g_error_free (error); |
551 | } |
552 | } |
553 | |
554 | static void |
555 | vfs_file_eject (BaulFile *file, |
556 | GMountOperation *mount_op, |
557 | GCancellable *cancellable, |
558 | BaulFileOperationCallback callback, |
559 | gpointer callback_data) |
560 | { |
561 | BaulFileOperation *op; |
562 | GFile *location; |
563 | |
564 | op = baul_file_operation_new (file, callback, callback_data); |
565 | if (cancellable) |
566 | { |
567 | g_object_unref (op->cancellable); |
568 | op->cancellable = g_object_ref (cancellable)((__typeof__ (cancellable)) (g_object_ref) (cancellable)); |
569 | } |
570 | |
571 | location = baul_file_get_location (file); |
572 | g_file_eject_mountable_with_operation (location, |
573 | G_MOUNT_UNMOUNT_NONE, |
574 | mount_op, |
575 | op->cancellable, |
576 | vfs_file_eject_callback, |
577 | op); |
578 | g_object_unref (location); |
579 | } |
580 | |
581 | static void |
582 | vfs_file_start_callback (GObject *source_object, |
583 | GAsyncResult *res, |
584 | gpointer callback_data) |
585 | { |
586 | BaulFileOperation *op; |
587 | gboolean started; |
588 | GError *error; |
589 | |
590 | op = callback_data; |
591 | |
592 | error = NULL((void*)0); |
593 | started = g_file_start_mountable_finish (G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((source_object)), ((g_file_get_type ())))))), |
594 | res, &error); |
595 | |
596 | if (!started && |
597 | error->domain == G_IO_ERRORg_io_error_quark() && |
598 | (error->code == G_IO_ERROR_FAILED_HANDLED || |
599 | error->code == G_IO_ERROR_CANCELLED)) |
600 | { |
601 | g_error_free (error); |
602 | error = NULL((void*)0); |
603 | } |
604 | |
605 | baul_file_operation_complete (op, G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((source_object)), ((g_file_get_type ())))))), error); |
606 | if (error) |
607 | { |
608 | g_error_free (error); |
609 | } |
610 | } |
611 | |
612 | |
613 | static void |
614 | vfs_file_start (BaulFile *file, |
615 | GMountOperation *mount_op, |
616 | GCancellable *cancellable, |
617 | BaulFileOperationCallback callback, |
618 | gpointer callback_data) |
619 | { |
620 | BaulFileOperation *op; |
621 | GError *error; |
622 | GFile *location; |
623 | |
624 | if (file->details->type != G_FILE_TYPE_MOUNTABLE) |
625 | { |
626 | if (callback) |
627 | { |
628 | error = NULL((void*)0); |
629 | g_set_error_literal (&error, G_IO_ERRORg_io_error_quark(), G_IO_ERROR_NOT_SUPPORTED, |
630 | _("This file cannot be started")gettext ("This file cannot be started")); |
631 | callback (file, NULL((void*)0), error, callback_data); |
632 | g_error_free (error); |
633 | } |
634 | return; |
635 | } |
636 | |
637 | op = baul_file_operation_new (file, callback, callback_data); |
638 | if (cancellable) |
639 | { |
640 | g_object_unref (op->cancellable); |
641 | op->cancellable = g_object_ref (cancellable)((__typeof__ (cancellable)) (g_object_ref) (cancellable)); |
642 | } |
643 | |
644 | location = baul_file_get_location (file); |
645 | g_file_start_mountable (location, |
646 | 0, |
647 | mount_op, |
648 | op->cancellable, |
649 | vfs_file_start_callback, |
650 | op); |
651 | g_object_unref (location); |
652 | } |
653 | |
654 | static void |
655 | vfs_file_stop_callback (GObject *source_object, |
656 | GAsyncResult *res, |
657 | gpointer callback_data) |
658 | { |
659 | BaulFileOperation *op; |
660 | gboolean stopped; |
661 | GError *error; |
662 | |
663 | op = callback_data; |
664 | |
665 | error = NULL((void*)0); |
666 | stopped = g_file_stop_mountable_finish (G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((source_object)), ((g_file_get_type ())))))), |
667 | res, &error); |
668 | |
669 | if (!stopped && |
670 | error->domain == G_IO_ERRORg_io_error_quark() && |
671 | (error->code == G_IO_ERROR_FAILED_HANDLED || |
672 | error->code == G_IO_ERROR_CANCELLED)) |
673 | { |
674 | g_error_free (error); |
675 | error = NULL((void*)0); |
676 | } |
677 | |
678 | baul_file_operation_complete (op, G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((source_object)), ((g_file_get_type ())))))), error); |
679 | if (error) |
680 | { |
681 | g_error_free (error); |
682 | } |
683 | } |
684 | |
685 | static void |
686 | vfs_file_stop (BaulFile *file, |
687 | GMountOperation *mount_op, |
688 | GCancellable *cancellable, |
689 | BaulFileOperationCallback callback, |
690 | gpointer callback_data) |
691 | { |
692 | BaulFileOperation *op; |
693 | GFile *location; |
694 | |
695 | op = baul_file_operation_new (file, callback, callback_data); |
696 | if (cancellable) |
697 | { |
698 | g_object_unref (op->cancellable); |
699 | op->cancellable = g_object_ref (cancellable)((__typeof__ (cancellable)) (g_object_ref) (cancellable)); |
700 | } |
701 | |
702 | location = baul_file_get_location (file); |
703 | g_file_stop_mountable (location, |
704 | G_MOUNT_UNMOUNT_NONE, |
705 | mount_op, |
706 | op->cancellable, |
707 | vfs_file_stop_callback, |
708 | op); |
709 | g_object_unref (location); |
710 | } |
711 | |
712 | static void |
713 | vfs_file_poll_callback (GObject *source_object, |
714 | GAsyncResult *res, |
715 | gpointer callback_data) |
716 | { |
717 | BaulFileOperation *op; |
718 | gboolean stopped; |
719 | GError *error; |
720 | |
721 | op = callback_data; |
722 | |
723 | error = NULL((void*)0); |
724 | stopped = g_file_poll_mountable_finish (G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((source_object)), ((g_file_get_type ())))))), |
725 | res, &error); |
726 | |
727 | if (!stopped && |
728 | error->domain == G_IO_ERRORg_io_error_quark() && |
729 | (error->code == G_IO_ERROR_FAILED_HANDLED || |
730 | error->code == G_IO_ERROR_CANCELLED)) |
731 | { |
732 | g_error_free (error); |
733 | error = NULL((void*)0); |
734 | } |
735 | |
736 | baul_file_operation_complete (op, G_FILE (source_object)((((GFile*) (void *) g_type_check_instance_cast ((GTypeInstance *) ((source_object)), ((g_file_get_type ())))))), error); |
737 | if (error) |
738 | { |
739 | g_error_free (error); |
740 | } |
741 | } |
742 | |
743 | static void |
744 | vfs_file_poll_for_media (BaulFile *file) |
745 | { |
746 | BaulFileOperation *op; |
747 | GFile *location; |
748 | |
749 | op = baul_file_operation_new (file, NULL((void*)0), NULL((void*)0)); |
750 | |
751 | location = baul_file_get_location (file); |
752 | g_file_poll_mountable (location, |
753 | op->cancellable, |
754 | vfs_file_poll_callback, |
755 | op); |
756 | g_object_unref (location); |
757 | } |
758 | |
759 | static void |
760 | baul_vfs_file_init (gpointer object G_GNUC_UNUSED__attribute__ ((__unused__)), |
761 | gpointer klass G_GNUC_UNUSED__attribute__ ((__unused__))) |
762 | { |
763 | } |
764 | |
765 | static void |
766 | baul_vfs_file_class_init (gpointer klass) |
767 | { |
768 | BaulFileClass *file_class; |
769 | |
770 | file_class = BAUL_FILE_CLASS (klass)((((BaulFileClass*) (void *) g_type_check_class_cast ((GTypeClass *) ((klass)), (baul_file_get_type()))))); |
771 | |
772 | file_class->monitor_add = vfs_file_monitor_add; |
773 | file_class->monitor_remove = vfs_file_monitor_remove; |
774 | file_class->call_when_ready = vfs_file_call_when_ready; |
775 | file_class->cancel_call_when_ready = vfs_file_cancel_call_when_ready; |
776 | file_class->check_if_ready = vfs_file_check_if_ready; |
777 | file_class->get_item_count = vfs_file_get_item_count; |
778 | file_class->get_deep_counts = vfs_file_get_deep_counts; |
779 | file_class->get_date = vfs_file_get_date; |
780 | file_class->get_where_string = vfs_file_get_where_string; |
781 | file_class->set_metadata = vfs_file_set_metadata; |
782 | file_class->set_metadata_as_list = vfs_file_set_metadata_as_list; |
783 | file_class->mount = vfs_file_mount; |
784 | file_class->unmount = vfs_file_unmount; |
785 | file_class->eject = vfs_file_eject; |
786 | file_class->start = vfs_file_start; |
787 | file_class->stop = vfs_file_stop; |
788 | file_class->poll_for_media = vfs_file_poll_for_media; |
789 | } |