1
/* GIO - GLib Input, Output and Streaming Library
3
* Copyright (C) 2006-2007 Red Hat, Inc.
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General
16
* Public License along with this library; if not, write to the
17
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18
* Boston, MA 02111-1307, USA.
20
* Author: Alexander Larsson <alexl@redhat.com>
26
#include <sys/types.h>
27
#include <sys/socket.h>
31
#include <dbus/dbus.h>
32
#include <glib/gi18n.h>
33
#include "gvfsreadchannel.h"
34
#include "gvfsjobopeniconforread.h"
35
#include "gvfsdbusutils.h"
36
#include "gvfsdaemonutils.h"
38
G_DEFINE_TYPE (GVfsJobOpenIconForRead, g_vfs_job_open_icon_for_read, G_VFS_TYPE_JOB_OPEN_FOR_READ)
40
static void run (GVfsJob *job);
41
static gboolean try (GVfsJob *job);
44
g_vfs_job_open_icon_for_read_finalize (GObject *object)
46
if (G_OBJECT_CLASS (g_vfs_job_open_icon_for_read_parent_class)->finalize)
47
(*G_OBJECT_CLASS (g_vfs_job_open_icon_for_read_parent_class)->finalize) (object);
51
g_vfs_job_open_icon_for_read_class_init (GVfsJobOpenIconForReadClass *klass)
53
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
54
GVfsJobClass *job_class = G_VFS_JOB_CLASS (klass);
56
gobject_class->finalize = g_vfs_job_open_icon_for_read_finalize;
62
g_vfs_job_open_icon_for_read_init (GVfsJobOpenIconForRead *job)
67
g_vfs_job_open_icon_for_read_new (DBusConnection *connection,
71
GVfsJobOpenIconForRead *job;
72
GVfsJobOpenForRead *job_open_for_read;
76
const char *path_data;
78
dbus_error_init (&derror);
79
if (!dbus_message_get_args (message, &derror,
80
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
81
&path_data, &path_len,
84
reply = dbus_message_new_error (message,
87
dbus_error_free (&derror);
89
dbus_connection_send (connection, reply, NULL);
93
job = g_object_new (G_VFS_TYPE_JOB_OPEN_ICON_FOR_READ,
95
"connection", connection,
98
job_open_for_read = G_VFS_JOB_OPEN_FOR_READ (job);
100
job->icon_id = g_strndup (path_data, path_len);
101
job_open_for_read->backend = backend;
103
return G_VFS_JOB (job);
109
GVfsJobOpenIconForRead *op_job = G_VFS_JOB_OPEN_ICON_FOR_READ (job);
110
GVfsJobOpenForRead *op_job_open_for_read = G_VFS_JOB_OPEN_FOR_READ (job);
111
GVfsBackendClass *class = G_VFS_BACKEND_GET_CLASS (op_job_open_for_read->backend);
113
if (class->open_icon_for_read == NULL)
115
g_vfs_job_failed (job, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
116
_("Operation not supported by backend"));
120
class->open_icon_for_read (op_job_open_for_read->backend,
128
GVfsJobOpenIconForRead *op_job = G_VFS_JOB_OPEN_ICON_FOR_READ (job);
129
GVfsJobOpenForRead *op_job_open_for_read = G_VFS_JOB_OPEN_FOR_READ (job);
130
GVfsBackendClass *class = G_VFS_BACKEND_GET_CLASS (op_job_open_for_read->backend);
132
if (class->try_open_icon_for_read == NULL)
135
return class->try_open_icon_for_read (op_job_open_for_read->backend,