~ubuntu-branches/ubuntu/natty/gvfs/natty

« back to all changes in this revision

Viewing changes to .pc/debian-changes-1.7.3-0ubuntu1/daemon/gvfsjobopeniconforread.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-03-22 11:11:57 UTC
  • Revision ID: james.westby@ubuntu.com-20110322111157-tn8edztqci0xr9hk
Correctly update using merge-upstream otherwise the diff will be reverted
in the diff.gz.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* GIO - GLib Input, Output and Streaming Library
2
 
 * 
3
 
 * Copyright (C) 2006-2007 Red Hat, Inc.
4
 
 *
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.
9
 
 *
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.
14
 
 *
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.
19
 
 *
20
 
 * Author: Alexander Larsson <alexl@redhat.com>
21
 
 */
22
 
 
23
 
#include <config.h>
24
 
 
25
 
#include <unistd.h>
26
 
#include <sys/types.h>
27
 
#include <sys/socket.h>
28
 
#include <sys/un.h>
29
 
 
30
 
#include <glib.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"
37
 
 
38
 
G_DEFINE_TYPE (GVfsJobOpenIconForRead, g_vfs_job_open_icon_for_read, G_VFS_TYPE_JOB_OPEN_FOR_READ)
39
 
 
40
 
static void         run          (GVfsJob        *job);
41
 
static gboolean     try          (GVfsJob        *job);
42
 
 
43
 
static void
44
 
g_vfs_job_open_icon_for_read_finalize (GObject *object)
45
 
{
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);
48
 
}
49
 
 
50
 
static void
51
 
g_vfs_job_open_icon_for_read_class_init (GVfsJobOpenIconForReadClass *klass)
52
 
{
53
 
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
54
 
  GVfsJobClass *job_class = G_VFS_JOB_CLASS (klass);
55
 
 
56
 
  gobject_class->finalize = g_vfs_job_open_icon_for_read_finalize;
57
 
  job_class->run = run;
58
 
  job_class->try = try;
59
 
}
60
 
 
61
 
static void
62
 
g_vfs_job_open_icon_for_read_init (GVfsJobOpenIconForRead *job)
63
 
{
64
 
}
65
 
 
66
 
GVfsJob *
67
 
g_vfs_job_open_icon_for_read_new (DBusConnection *connection,
68
 
                                  DBusMessage *message,
69
 
                                  GVfsBackend *backend)
70
 
{
71
 
  GVfsJobOpenIconForRead *job;
72
 
  GVfsJobOpenForRead *job_open_for_read;
73
 
  DBusMessage *reply;
74
 
  DBusError derror;
75
 
  int path_len;
76
 
  const char *path_data;
77
 
 
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,
82
 
                              0))
83
 
    {
84
 
      reply = dbus_message_new_error (message,
85
 
                                      derror.name,
86
 
                                      derror.message);
87
 
      dbus_error_free (&derror);
88
 
 
89
 
      dbus_connection_send (connection, reply, NULL);
90
 
      return NULL;
91
 
    }
92
 
 
93
 
  job = g_object_new (G_VFS_TYPE_JOB_OPEN_ICON_FOR_READ,
94
 
                      "message", message,
95
 
                      "connection", connection,
96
 
                      NULL);
97
 
 
98
 
  job_open_for_read = G_VFS_JOB_OPEN_FOR_READ (job);
99
 
 
100
 
  job->icon_id = g_strndup (path_data, path_len);
101
 
  job_open_for_read->backend = backend;
102
 
 
103
 
  return G_VFS_JOB (job);
104
 
}
105
 
 
106
 
static void
107
 
run (GVfsJob *job)
108
 
{
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);
112
 
 
113
 
  if (class->open_icon_for_read == NULL)
114
 
    {
115
 
      g_vfs_job_failed (job, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
116
 
                        _("Operation not supported by backend"));
117
 
      return;
118
 
    }
119
 
 
120
 
  class->open_icon_for_read (op_job_open_for_read->backend,
121
 
                             op_job,
122
 
                             op_job->icon_id);
123
 
}
124
 
 
125
 
static gboolean
126
 
try (GVfsJob *job)
127
 
{
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);
131
 
 
132
 
  if (class->try_open_icon_for_read == NULL)
133
 
    return FALSE;
134
 
 
135
 
  return class->try_open_icon_for_read (op_job_open_for_read->backend,
136
 
                                        op_job,
137
 
                                        op_job->icon_id);
138
 
}