1 /* this file is part of evince, a gnome document viewer
3 * Copyright (C) 2005 Red Hat, Inc
5 * Evince is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * Evince is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
25 #include "ev-job-xfer.h"
26 #include "ev-document-types.h"
28 #include <glib/gi18n.h>
31 #include <libgnomevfs/gnome-vfs-uri.h>
32 #include <libgnomevfs/gnome-vfs-utils.h>
33 #include <libgnomevfs/gnome-vfs-ops.h>
35 static void ev_job_xfer_init (EvJobXfer *job);
36 static void ev_job_xfer_class_init (EvJobXferClass *class);
38 G_DEFINE_TYPE (EvJobXfer, ev_job_xfer, EV_TYPE_JOB)
40 static void ev_job_xfer_init (EvJobXfer *job) { /* Do Nothing */ }
43 ev_job_xfer_dispose (GObject *object)
45 EvJobXfer *job = EV_JOB_XFER (object);
53 g_error_free (job->error);
57 (* G_OBJECT_CLASS (ev_job_xfer_parent_class)->dispose) (object);
61 ev_job_xfer_class_init (EvJobXferClass *class)
65 oclass = G_OBJECT_CLASS (class);
67 oclass->dispose = ev_job_xfer_dispose;
72 ev_job_xfer_new (const gchar *uri)
76 job = g_object_new (EV_TYPE_JOB_XFER, NULL);
78 job->uri = g_strdup (uri);
84 ev_job_xfer_run (EvJobXfer *job)
90 g_return_if_fail (EV_IS_JOB_XFER (job));
93 g_error_free (job->error);
97 vfs_uri = gnome_vfs_uri_new (job->uri);
99 if (!gnome_vfs_uri_exists (vfs_uri)) {
100 g_set_error (&job->error,
103 _("The file %s does not exist."),
106 EV_JOB (job)->finished = TRUE;
110 gnome_vfs_uri_unref (vfs_uri);
112 document_type = ev_document_type_lookup (job->uri, &mime_type);
114 if (document_type != G_TYPE_INVALID) {
115 EV_JOB (job)->document = g_object_new (document_type, NULL);
117 g_set_error (&job->error,
120 _("Unhandled MIME type: '%s'"),
121 mime_type ? mime_type : "<Unknown MIME Type>");
122 EV_JOB (job)->finished = TRUE;
126 EV_JOB (job)->finished = TRUE;