svnno****@sourc*****
svnno****@sourc*****
Tue Feb 17 09:04:13 JST 2009
Revision: 3722 http://svn.sourceforge.jp/view?root=kazehakase&view=rev&rev=3722 Author: ikezoe Date: 2009-02-17 09:04:12 +0900 (Tue, 17 Feb 2009) Log Message: ----------- * src/net/kz-file.[ch]: Removed. Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/src/net/Makefile.am kazehakase/trunk/src/net/kz-io.c Removed Paths: ------------- kazehakase/trunk/src/net/kz-file.c kazehakase/trunk/src/net/kz-file.h Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2009-02-16 23:01:42 UTC (rev 3721) +++ kazehakase/trunk/ChangeLog 2009-02-17 00:04:12 UTC (rev 3722) @@ -1,6 +1,7 @@ 2009-02-17 Hiroyuki Ikezoe <poinc****@ikezo*****> * src/bookmarks/kz-bookmark-file.c: Use KzDownloader instead of GIO. + * src/net/kz-file.[ch]: Removed. 2009-02-16 Hiroyuki Ikezoe <poinc****@ikezo*****> Modified: kazehakase/trunk/src/net/Makefile.am =================================================================== --- kazehakase/trunk/src/net/Makefile.am 2009-02-16 23:01:42 UTC (rev 3721) +++ kazehakase/trunk/src/net/Makefile.am 2009-02-17 00:04:12 UTC (rev 3722) @@ -18,7 +18,6 @@ libkznet_public_h_sources = \ kz-io.h \ - kz-file.h \ kz-http.h \ kz-xmlrpc.h @@ -32,7 +31,6 @@ libkznet_la_SOURCES = \ kz-io.c \ - kz-file.c \ kz-http.c \ kz-xmlrpc.c \ uri.c uri.h \ Deleted: kazehakase/trunk/src/net/kz-file.c =================================================================== --- kazehakase/trunk/src/net/kz-file.c 2009-02-16 23:01:42 UTC (rev 3721) +++ kazehakase/trunk/src/net/kz-file.c 2009-02-17 00:04:12 UTC (rev 3722) @@ -1,241 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Copyright (C) 2003 Hiroyuki Ikezoe - * Copyright (C) 2003 Takuro Ashie - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include <glib/gi18n.h> -#include "kz-file.h" - -static void set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void dispose (GObject *object); - -static void file_start (KzIO *io); -static GIOStatus read_from_io (KzIO *io, - GIOChannel *iochannel); -static GIOStatus write_to_io (KzIO *io, - GIOChannel *iochannel); - -typedef struct _KzFilePrivate KzFilePrivate; -struct _KzFilePrivate -{ - gchar *filename; -}; -#define KZ_FILE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KZ_TYPE_FILE, KzFilePrivate)) - -enum { - PROP_0, - PROP_FILENAME -}; - -#define BUFFER_SIZE 1024 - -G_DEFINE_TYPE(KzFile, kz_file, KZ_TYPE_IO) - -static void -kz_file_class_init (KzFileClass *klass) -{ - GObjectClass *object_class; - KzIOClass *io_class; - - object_class = G_OBJECT_CLASS(klass); - io_class = KZ_IO_CLASS(klass); - - object_class->dispose = dispose; - object_class->set_property = set_property; - object_class->get_property = get_property; - - io_class->read_from_io = read_from_io; - io_class->write_to_io = write_to_io; - io_class->io_start = file_start; - - g_object_class_install_property( - object_class, - PROP_FILENAME, - g_param_spec_string( - "filename", - _("Filename"), - _("The Filename of the local file"), - NULL, - G_PARAM_READWRITE)); - g_type_class_add_private (object_class, sizeof(KzFilePrivate)); -} - - -static void -kz_file_init (KzFile *file) -{ - KzFilePrivate *priv = KZ_FILE_GET_PRIVATE (file); - - priv->filename = NULL; -} - - -static void -dispose (GObject *object) -{ - KzFilePrivate *priv = KZ_FILE_GET_PRIVATE (object); - - if (priv->filename) - { - g_free(priv->filename); - } - priv->filename = NULL; - - if (G_OBJECT_CLASS (kz_file_parent_class)->dispose) - G_OBJECT_CLASS (kz_file_parent_class)->dispose(object); -} - - -static void -set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - KzFilePrivate *priv = KZ_FILE_GET_PRIVATE (object); - - switch (prop_id) - { - case PROP_FILENAME: - g_free(priv->filename); - priv->filename = g_value_dup_string(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - - -static void -get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - KzFilePrivate *priv = KZ_FILE_GET_PRIVATE (object); - - switch (prop_id) - { - case PROP_FILENAME: - g_value_set_string(value, priv->filename); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - - - -KzFile * -kz_file_new (const gchar *uri) -{ - KzFile *file; - - file = g_object_new(KZ_TYPE_FILE, - "filename", uri, - NULL); - - return file; -} - - -static GIOStatus -kz_file_prepare_iochannel (KzIO *io) -{ - GIOStatus iostatus; - gchar *filename; - KzFilePrivate *priv = KZ_FILE_GET_PRIVATE (io); - - filename = priv->filename; - - if (kz_io_get_mode(io) == KZ_IO_READ) - { - if (g_file_test(filename, G_FILE_TEST_EXISTS) == FALSE) - { - KZ_IO_CLASS (kz_file_parent_class)->io_error(io); - return G_IO_STATUS_ERROR; - } - io->iochannel = g_io_channel_new_file(filename, "r", NULL); - } - else if (kz_io_get_mode(io) == KZ_IO_WRITE) - io->iochannel = g_io_channel_new_file(filename, "w", NULL); - - iostatus = g_io_channel_set_encoding(io->iochannel, - NULL, - NULL); - return iostatus; -} - - -static GIOStatus -read_from_io(KzIO *io, GIOChannel *iochannel) -{ - GIOStatus iostatus; - gsize bytes_read; - gchar buffer[BUFFER_SIZE]; - - /* Read the data into our buffer */ - iostatus = g_io_channel_read_chars(iochannel, buffer, - sizeof(buffer), - &bytes_read, - NULL); - - if (iostatus == G_IO_STATUS_NORMAL) - { - KZ_IO_CLASS (kz_file_parent_class)->io_to_buffer(io, bytes_read, buffer); - /* Check for EOF */ - if (bytes_read == 0) - iostatus = G_IO_STATUS_EOF; - } - return iostatus; -} - - -static GIOStatus -write_to_io(KzIO *io, GIOChannel *iochannel) -{ - KZ_IO_CLASS (kz_file_parent_class)->buffer_to_io(io, 0, NULL); - return G_IO_STATUS_NORMAL; -} - - -static void -file_start (KzIO *io) -{ - GIOStatus iostatus; - iostatus = kz_file_prepare_iochannel(io); - - if (iostatus != G_IO_STATUS_NORMAL) - { - KZ_IO_CLASS (kz_file_parent_class)->io_error(io); - return; - } - - /* call io_set_iochannel, start to loading */ - KZ_IO_CLASS (kz_file_parent_class)->io_set_channel(io); -} Deleted: kazehakase/trunk/src/net/kz-file.h =================================================================== --- kazehakase/trunk/src/net/kz-file.h 2009-02-16 23:01:42 UTC (rev 3721) +++ kazehakase/trunk/src/net/kz-file.h 2009-02-17 00:04:12 UTC (rev 3722) @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Copyright (C) 2003 Hiroyuki Ikezoe - * Copyright (C) 2003 Takuro Ashie - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __KZ_FILE_H__ -#define __KZ_FILE_H__ - -#include <glib-object.h> -#include "kz-io.h" - -G_BEGIN_DECLS - -#define KZ_TYPE_FILE (kz_file_get_type ()) -#define KZ_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KZ_TYPE_FILE, KzFile)) -#define KZ_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KZ_TYPE_FILE, KzFileClass)) -#define KZ_IS_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KZ_TYPE_FILE)) -#define KZ_IS_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KZ_TYPE_FILE)) -#define KZ_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KZ_TYPE_FILE, KzFileClass)) - -typedef struct _KzFile KzFile; -typedef struct _KzFileClass KzFileClass; - -struct _KzFile -{ - KzIO parent; -}; - -struct _KzFileClass -{ - KzIOClass parent_class; -}; - -GType kz_file_get_type (void) G_GNUC_CONST; -KzFile *kz_file_new (const gchar *uri); - -G_END_DECLS - -#endif /* __KZ_FILE_H__ */ Modified: kazehakase/trunk/src/net/kz-io.c =================================================================== --- kazehakase/trunk/src/net/kz-io.c 2009-02-16 23:01:42 UTC (rev 3721) +++ kazehakase/trunk/src/net/kz-io.c 2009-02-17 00:04:12 UTC (rev 3722) @@ -29,7 +29,6 @@ #include "kz-io.h" #include "kz-http.h" -#include "kz-file.h" #include "kz-marshalers.h" #define BUFFER_SIZE 1024 @@ -362,14 +361,6 @@ { /* io = KZ_IO(kz_ftp_new(uri)); */ } - else if (g_str_has_prefix(uri, "file://")) - { - io = KZ_IO(kz_file_new(uri + 7)); - } - else - { - io = KZ_IO(kz_file_new(uri)); - } return io; }