Author: stephan
Date: 2007-02-09 23:16:07 +0000 (Fri, 09 Feb 2007)
New Revision: 24940
Added:
squeeze/trunk/libsqueeze/archive-command.c
squeeze/trunk/libsqueeze/archive-command.h
Modified:
squeeze/trunk/libsqueeze/Makefile.am
squeeze/trunk/libsqueeze/archive-support-compr.c
squeeze/trunk/libsqueeze/archive-support-gnu-tar.c
squeeze/trunk/libsqueeze/archive-support-zip.c
squeeze/trunk/libsqueeze/archive-support.c
squeeze/trunk/libsqueeze/archive.c
squeeze/trunk/libsqueeze/archive.h
squeeze/trunk/libsqueeze/internals.c
squeeze/trunk/libsqueeze/libsqueeze.c
Log:
added archive-command to libsqueeze
Modified: squeeze/trunk/libsqueeze/Makefile.am
===================================================================
--- squeeze/trunk/libsqueeze/Makefile.am 2007-02-09 14:38:53 UTC (rev
24939)
+++ squeeze/trunk/libsqueeze/Makefile.am 2007-02-09 23:16:07 UTC (rev
24940)
@@ -5,12 +5,13 @@
libsqueeze.c libsqueeze.h \
slist.c slist.h \
archive.c archive.h \
+ archive-command.c archive-command.h \
archive-tempfs.c archive-tempfs.h \
archive-support.c archive-support.h \
- archive-support-zip.c archive-support-zip.h \
- archive-support-rar.c archive-support-rar.h \
- archive-support-compr.c archive-support-compr.h \
- archive-support-gnu-tar.c archive-support-gnu-tar.h
+ archive-support-zip.c archive-support-zip.h
+# archive-support-rar.c archive-support-rar.h \
+# archive-support-compr.c archive-support-compr.h \
+# archive-support-gnu-tar.c archive-support-gnu-tar.h
libsqueeze_1_la_CFLAGS = \
$(GLIB_CFLAGS) \
Added: squeeze/trunk/libsqueeze/archive-command.c
===================================================================
--- squeeze/trunk/libsqueeze/archive-command.c (rev 0)
+++ squeeze/trunk/libsqueeze/archive-command.c 2007-02-09 23:16:07 UTC (rev
24940)
@@ -0,0 +1,152 @@
+/*
+ * 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 of the License, 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 Library 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 <config.h>
+#include <string.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <glib-object.h>
+#include <signal.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <thunar-vfs/thunar-vfs.h>
+
+#include "archive.h"
+#include "archive-command.h"
+
+static void
+lsq_archive_command_class_init(LSQArchiveCommandClass *);
+static void
+lsq_archive_command_init(LSQArchiveCommand *archive);
+static void
+lsq_archive_command_dispose(GObject *object);
+
+//static gint lsq_archive_command_signals[0];
+
+static GObjectClass *parent_class;
+
+GType
+lsq_archive_command_get_type ()
+{
+ static GType lsq_archive_command_type = 0;
+
+ if (!lsq_archive_command_type)
+ {
+ static const GTypeInfo lsq_archive_command_info =
+ {
+ sizeof (LSQArchiveCommandClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) lsq_archive_command_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (LSQArchiveCommand),
+ 0,
+ (GInstanceInitFunc) lsq_archive_command_init,
+ NULL
+ };
+
+ lsq_archive_command_type = g_type_register_static
(G_TYPE_OBJECT, "LSQArchiveCommand", &lsq_archive_command_info, 0);
+ }
+ return lsq_archive_command_type;
+}
+
+static void
+lsq_archive_command_class_init(LSQArchiveCommandClass *archive_command_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(archive_command_class);
+
+ object_class->dispose = lsq_archive_command_dispose;
+
+ parent_class = g_type_class_peek(G_TYPE_OBJECT);
+
+}
+
+static void
+lsq_archive_command_init(LSQArchiveCommand *archive_command)
+{
+}
+
+/**
+ * lsq_archive_command_dispose:
+ *
+ * @object: LSQArchiveCommand object
+ *
+ */
+static void
+lsq_archive_command_dispose(GObject *object)
+{
+ LSQArchiveCommand *archive_command = LSQ_ARCHIVE_COMMAND(object);
+ lsq_archive_dequeue(archive_command->archive, archive_command);
+}
+
+/**
+ * lsq_archive_command_new:
+ * @comment: a description, describing what the command does
+ * @archive: the archive the command modifies
+ * @command: a formatted string defining the command to be executed.
+ *
+ *
+ * %%1$s is the application to be executed.
+ *
+ * %%2$s are the files to be appended
+ *
+ * Returns: a new LSQArchiveCommand object
+ */
+LSQArchiveCommand *
+lsq_archive_command_new(const gchar *comment, LSQArchive *archive, const gchar
*command)
+{
+ LSQArchiveCommand *archive_command;
+
+ archive_command = g_object_new(lsq_archive_command_get_type(), NULL);
+
+ archive_command->command = g_strdup(command);
+ archive_command->archive = archive;
+
+ lsq_archive_enqueue(archive, archive_command);
+
+ return archive_command;
+}
+
+/**
+ * lsq_archive_command_run:
+ * @archive_command: the archive_command to be run
+ *
+ * Returns: true on success
+ */
+gboolean
+lsq_archive_command_run(LSQArchiveCommand *archive_command)
+{
+ const gchar *files = g_object_get_data(G_OBJECT(archive_command),
"files");
+ const gchar *options = g_object_get_data(G_OBJECT(archive_command),
"options");
+
+ if(files == NULL)
+ files = "";
+ if(options == NULL)
+ options = "";
+
+ gchar *command = g_strdup_printf(archive_command->command,
archive_command->archive->path, files, options);
+
+ g_free(command);
+
+ return TRUE;
+}
+
+gboolean
+lsq_archive_command_stop(LSQArchiveCommand *command)
+{
+ return TRUE;
+}
Added: squeeze/trunk/libsqueeze/archive-command.h
===================================================================
--- squeeze/trunk/libsqueeze/archive-command.h (rev 0)
+++ squeeze/trunk/libsqueeze/archive-command.h 2007-02-09 23:16:07 UTC (rev
24940)
@@ -0,0 +1,78 @@
+/*
+ * 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 of the License, 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 Library 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 __LIBSQUEEZE_ARCHIVE_COMMAND_H__
+#define __LIBSQUEEZE_ARCHIVE_COMMAND_H__
+G_BEGIN_DECLS
+
+#define LSQ_ARCHIVE_COMMAND(obj) ( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ lsq_archive_command_get_type(), \
+ LSQArchiveCommand))
+
+#define LSQ_IS_ARCHIVE_COMMAND(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ lsq_archive_command_get_type()))
+
+#define LSQ_ARCHIVE_COMMAND_CLASS(class) ( \
+ G_TYPE_CHECK_CLASS_CAST ((class), \
+ lsq_archive_command_get_type(), \
+ LSQArchiveCommandClass))
+
+#define LSQ_IS_ARCHIVE_COMMAND_CLASS(class) ( \
+ G_TYPE_CHECK_CLASS_TYPE ((class), \
+ lsq_archive_command_get_type()))
+
+
+struct _LSQArchiveCommand
+{
+ GObject parent;
+ gchar *comment;
+ gchar *command;
+ LSQArchive *archive;
+ GPid child_pid;
+ GIOChannel *ioc_in;
+ GIOChannel *ioc_out;
+ GIOChannel *ioc_err;
+ gboolean intrusive;
+};
+
+typedef struct _LSQArchiveCommandClass LSQArchiveCommandClass;
+
+struct _LSQArchiveCommandClass
+{
+ GObjectClass parent;
+};
+
+/*
+GType lsq_archive_command_get_type(void)
G_GNUC_INTERNAL;
+LSQArchiveCommand *lsq_archive_command_new(const gchar *comment,
+ LSQArchive *archive,
+ const gchar *command)
G_GNUC_INTERNAL;
+
+void lsq_archive_command_run(LSQArchiveCommand *command)
G_GNUC_INTERNAL;
+*/
+GType lsq_archive_command_get_type(void);
+LSQArchiveCommand *lsq_archive_command_new(const gchar *comment,
+ LSQArchive *archive,
+ const gchar *command);
+
+gboolean lsq_archive_command_run(LSQArchiveCommand *command);
+
+gboolean lsq_archive_command_stop(LSQArchiveCommand *command);
+
+G_END_DECLS
+
+#endif /* __LIBSQUEEZE_ARCHIVE_COMMAND_H__ */
Modified: squeeze/trunk/libsqueeze/archive-support-compr.c
===================================================================
--- squeeze/trunk/libsqueeze/archive-support-compr.c 2007-02-09 14:38:53 UTC
(rev 24939)
+++ squeeze/trunk/libsqueeze/archive-support-compr.c 2007-02-09 23:16:07 UTC
(rev 24940)
@@ -215,13 +215,6 @@
return 0;
}
-void
-lsq_archive_support_compr_passive_watch(GPid pid, gint status, gpointer data)
-{
- LSQArchive *archive = data;
- archive->child_pid = 0;
-}
-
static gint
lsq_archive_support_compr_refresh(LSQArchive *archive)
{
Modified: squeeze/trunk/libsqueeze/archive-support-gnu-tar.c
===================================================================
--- squeeze/trunk/libsqueeze/archive-support-gnu-tar.c 2007-02-09 14:38:53 UTC
(rev 24939)
+++ squeeze/trunk/libsqueeze/archive-support-gnu-tar.c 2007-02-09 23:16:07 UTC
(rev 24940)
@@ -528,18 +528,9 @@
}
void
-lsq_archive_support_gnu_tar_passive_watch(GPid pid, gint status, gpointer data)
-{
- LSQArchive *archive = data;
- if(!((archive->status == LSQ_ARCHIVESTATUS_ADD) || (archive->status ==
LSQ_ARCHIVESTATUS_REMOVE)))
- archive->child_pid = 0;
-}
-
-void
lsq_archive_support_gnu_tar_compress_watch(GPid pid, gint status, gpointer
data)
{
LSQArchive *archive = data;
- archive->child_pid = 0;
gchar *command = NULL;
if(!g_strcasecmp(thunar_vfs_mime_info_get_name(archive->mime_info),
"application/x-tarz"))
@@ -721,13 +712,11 @@
switch(archive->status)
{
case(LSQ_ARCHIVESTATUS_ADD):
- archive->child_pid = 0;
command =
g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name, " -rf \"",
out_filename, "\" ", g_object_get_data(G_OBJECT(archive), LSQ_ARCHIVE_FILES),
NULL);
lsq_execute(command, archive,
lsq_archive_support_gnu_tar_compress_watch, NULL, NULL, NULL);
g_free(command);
break;
case(LSQ_ARCHIVESTATUS_REMOVE):
- archive->child_pid = 0;
command =
g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name, " -f \"",
out_filename, "\" --delete ", g_object_get_data(G_OBJECT(archive),
LSQ_ARCHIVE_FILES), NULL);
lsq_execute(command, archive,
lsq_archive_support_gnu_tar_compress_watch, NULL, NULL, NULL);
g_free(command);
@@ -775,7 +764,6 @@
g_io_channel_unref (ioc);
if(g_object_get_data(G_OBJECT(archive), LSQ_ARCHIVE_TEMP_FILE))
g_unlink(g_object_get_data(G_OBJECT(archive),
LSQ_ARCHIVE_TEMP_FILE));
- archive->child_pid = 0;
lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_IDLE);
return FALSE;
}
Modified: squeeze/trunk/libsqueeze/archive-support-zip.c
===================================================================
--- squeeze/trunk/libsqueeze/archive-support-zip.c 2007-02-09 14:38:53 UTC
(rev 24939)
+++ squeeze/trunk/libsqueeze/archive-support-zip.c 2007-02-09 23:16:07 UTC
(rev 24940)
@@ -25,6 +25,7 @@
#include "archive.h"
#include "archive-support.h"
#include "archive-support-zip.h"
+#include "archive-command.h"
#include "internals.h"
@@ -198,6 +199,7 @@
static gint
lsq_archive_support_zip_add(LSQArchive *archive, GSList *filenames)
{
+ LSQArchiveCommand *archive_command = NULL;
if(!LSQ_IS_ARCHIVE_SUPPORT_ZIP(archive->support))
{
g_critical("Support is not zip");
@@ -210,16 +212,16 @@
}
else
{
- gchar *command = NULL;
- gchar *files = lsq_concat_filenames(filenames);
- gchar *archive_path = g_shell_quote(archive->path);
if(!g_strcasecmp((gchar
*)thunar_vfs_mime_info_get_name(archive->mime_info), "application/x-zip") ||
!g_strcasecmp((gchar
*)thunar_vfs_mime_info_get_name(archive->mime_info), "application/zip"))
{
- command = g_strconcat("zip -r ", archive_path, " ",
files, NULL);
- lsq_execute(command, archive, NULL, NULL, NULL, NULL);
+ gchar *files = lsq_concat_filenames(filenames);
+
+ archive_command = lsq_archive_command_new("", archive,
"zip -r %1$s %2$s");
+ g_object_set(archive_command, "files", files);
+ g_free(files);
+ g_object_unref(archive_command);
}
- g_free(archive_path);
}
return 0;
}
@@ -227,6 +229,8 @@
static gint
lsq_archive_support_zip_extract(LSQArchive *archive, const gchar
*extract_path, GSList *filenames)
{
+ LSQArchiveCommand *archive_command = NULL;
+ gchar *dest_path = NULL;
if(!LSQ_IS_ARCHIVE_SUPPORT_ZIP(archive->support))
{
g_critical("Support is not Zip");
@@ -239,26 +243,23 @@
}
else
{
- gchar *command = NULL;
- gchar *files = lsq_concat_filenames(filenames);
- gchar *archive_path = g_shell_quote(archive->path);
- gchar *dest_path = g_shell_quote(extract_path);
- if(archive->file_info) /* FIXME */
+ if(!g_strcasecmp((gchar
*)thunar_vfs_mime_info_get_name(archive->mime_info), "application/x-zip") ||
+ !g_strcasecmp((gchar
*)thunar_vfs_mime_info_get_name(archive->mime_info), "application/zip"))
{
- if(!g_strcasecmp((gchar
*)thunar_vfs_mime_info_get_name(archive->mime_info), "application/x-zip") ||
- !g_strcasecmp((gchar
*)thunar_vfs_mime_info_get_name(archive->mime_info), "application/zip"))
- {
- command = g_strconcat("unzip -o ",
archive_path, " ", files, " -d ", dest_path, NULL);
- lsq_execute(command, archive, NULL, NULL, NULL,
NULL);
- }
- } else
- {
+ gchar *files = lsq_concat_filenames(filenames);
+ if(extract_path)
+ dest_path = g_shell_quote(extract_path);
+
+ gchar *options = g_strconcat(" -d ", dest_path, NULL);
+
+ archive_command = lsq_archive_command_new("", archive,
"zip -o %1$s %2$s %3$s");
+ g_object_set(archive_command, "files", files);
+ g_object_set(archive_command, "options", options);
+ g_object_unref(archive_command);
g_free(dest_path);
- g_free(archive_path);
- return 1;
- }
- g_free(dest_path);
- g_free(archive_path);
+ g_free(options);
+ g_free(files);
+ }
}
return 0;
}
@@ -266,6 +267,7 @@
static gint
lsq_archive_support_zip_remove(LSQArchive *archive, GSList *filenames)
{
+ LSQArchiveCommand *archive_command = NULL;
if(!LSQ_IS_ARCHIVE_SUPPORT_ZIP(archive->support))
{
g_critical("Support is not zip");
@@ -278,16 +280,16 @@
}
else
{
- gchar *command = NULL;
- gchar *files = lsq_concat_filenames(filenames);
- gchar *archive_path = g_shell_quote(archive->path);
if(!g_strcasecmp((gchar
*)thunar_vfs_mime_info_get_name(archive->mime_info), "application/x-zip") ||
!g_strcasecmp((gchar
*)thunar_vfs_mime_info_get_name(archive->mime_info), "application/zip"))
{
- command = g_strconcat("zip -d ", archive_path, " ",
files, NULL);
- lsq_execute(command, archive, NULL, NULL, NULL, NULL);
+ gchar *files = lsq_concat_filenames(filenames);
+
+ archive_command = lsq_archive_command_new("", archive,
"zip -d %1$s %2$s");
+ g_object_set(archive_command, "files", files);
+ g_free(files);
+ g_object_unref(archive_command);
}
- g_free(archive_path);
}
return 0;
}
@@ -296,6 +298,7 @@
lsq_archive_support_zip_refresh(LSQArchive *archive)
{
guint i = 0;
+ LSQArchiveCommand *archive_command = NULL;
if(!LSQ_IS_ARCHIVE_SUPPORT_ZIP(archive->support))
{
g_critical("Support is not Zip");
@@ -310,7 +313,6 @@
{
lsq_archive_clear_entry_property_types(archive);
i = LSQ_ARCHIVE_PROP_USER;
- gchar *archive_path = g_shell_quote(archive->path);
if(LSQ_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_length) {
lsq_archive_set_entry_property_type(archive, i,
G_TYPE_UINT64, _("Size"));
i++;
@@ -339,10 +341,7 @@
lsq_archive_set_entry_property_type(archive, i,
G_TYPE_STRING, _("Checksum"));
i++;
}
- gchar *command = g_strconcat("unzip -lv -qq ", archive_path,
NULL);
- lsq_execute(command, archive, NULL, NULL,
lsq_archive_support_zip_refresh_parse_output, NULL);
- g_free(command);
- g_free(archive_path);
+ archive_command = lsq_archive_command_new("", archive, "unzip
-lv -qq %1$s");
}
return 0;
}
@@ -476,7 +475,6 @@
{
g_io_channel_shutdown ( ioc,TRUE,NULL );
g_io_channel_unref (ioc);
- lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_IDLE);
return FALSE;
}
return TRUE;
Modified: squeeze/trunk/libsqueeze/archive-support.c
===================================================================
--- squeeze/trunk/libsqueeze/archive-support.c 2007-02-09 14:38:53 UTC (rev
24939)
+++ squeeze/trunk/libsqueeze/archive-support.c 2007-02-09 23:16:07 UTC (rev
24940)
@@ -1,7 +1,4 @@
-/*
- * Copyright (c) 2006 Stephan Arts <[EMAIL PROTECTED]>
- *
- * This program is free software; you can redistribute it and/or modify
+/* 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 of the License, or
* (at your option) any later version.
@@ -203,7 +200,6 @@
{
if(support->add)
{
- lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_ADD);
archive->support = support;
return support->add(archive, files);
}
@@ -217,7 +213,6 @@
{
if(support->extract)
{
- lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_EXTRACT);
archive->support = support;
return support->extract(archive, dest_path, files);
}
@@ -231,26 +226,6 @@
{
if(support->remove)
{
- const gchar *path;
- GSList *iter = archive->files;
- while(iter)
- {
- g_free(iter->data);
- iter = g_slist_next(iter);
- }
- g_slist_free(archive->files);
- iter = archive->files = g_slist_copy(files);
- /* TODO: is add children really nesecery? */
- lsq_archive_add_children(archive, files);
- while(iter)
- {
- path = (const gchar*)iter->data;
- iter->data = g_strdup(path);
- lsq_archive_del_file(archive, path);
- iter = g_slist_next(iter);
- }
- lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_REMOVE);
- archive->support = support;
return support->remove(archive, files);
}
else
@@ -263,7 +238,6 @@
{
if(support->refresh)
{
- lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_REFRESH);
archive->support = support;
return support->refresh(archive);
}
@@ -278,20 +252,6 @@
if(support->extract)
{
archive->support = support;
- lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_PREPARE_VIEW);
- GSList *iter = archive->files;
- while(iter)
- {
- g_free(iter->data);
- iter = g_slist_next(iter);
- }
- g_slist_free(archive->files);
- iter = archive->files = g_slist_copy(files);
- while(iter)
- {
- iter->data = g_strdup(iter->data);
- iter = g_slist_next(iter);
- }
if(support->extract(archive, lsq_tempfs_get_root_dir(archive),
files))
return -1;
return 0;
@@ -301,23 +261,6 @@
return -1;
}
-void
-lsq_archive_support_view_prepared(LSQArchive *archive, GSList *files, gpointer
user_data)
-{
- gchar *full_file;
- while(files)
- {
- lsq_tempfs_chmod(archive, files->data, 0400);
- full_file = g_strconcat(lsq_tempfs_get_root_dir(archive), "/",
files->data, NULL);
-#ifdef DEBUG
- g_debug("Open file: '%s'", full_file);
-#endif
- exo_url_show(full_file, NULL, NULL);
- g_free(full_file);
- files = g_slist_next(files);
- }
-}
-
guint64
lsq_archive_support_get_max_n_files(LSQArchiveSupport *support)
{
@@ -424,19 +367,3 @@
{
action->callback->notify_func(action, message);
}
-
-/**
- * gboolean
- * lsq_archive_support_can_stop(LSQArchiveSupport *support)
- *
- * Returns: TRUE if there is no risk of corrupting the archive when closing
the support-app
- * FALSE otherwise, there should be a warning dialog to let the user
proceed anyway.
- *
- */
-gboolean
-lsq_archive_support_can_stop(LSQArchiveSupport *support, LSQArchive *archive)
-{
- if(lsq_archive_get_status(archive) == LSQ_ARCHIVESTATUS_REFRESH)
- return TRUE;
- return FALSE;
-}
Modified: squeeze/trunk/libsqueeze/archive.c
===================================================================
--- squeeze/trunk/libsqueeze/archive.c 2007-02-09 14:38:53 UTC (rev 24939)
+++ squeeze/trunk/libsqueeze/archive.c 2007-02-09 23:16:07 UTC (rev 24940)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2006 Stephan Arts <[EMAIL PROTECTED]>
- *
+/*
* 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 of the License, or
@@ -96,8 +95,10 @@
static const gchar *
lsq_archive_iter_get_mimetype(const LSQArchive *, const LSQArchiveIter *);
+/*
static gchar *
lsq_archive_get_iter_part(const LSQArchive *archive, const gchar *path);
+*/
static gint
lsq_entry_filename_compare(LSQEntry *, LSQEntry *);
@@ -204,9 +205,6 @@
lsq_archive_init(LSQArchive *archive)
{
archive->root_entry = g_new0(LSQEntry, 1);
- archive->status = LSQ_ARCHIVESTATUS_INIT;
- archive->old_status = LSQ_ARCHIVESTATUS_INIT;
- archive->files = NULL;
#ifdef LSQ_THREADSAFE
g_static_rw_lock_init(&archive->rw_lock);
#endif /* LSQ_THREADSAFE */
@@ -232,17 +230,6 @@
thunar_vfs_mime_info_unref(archive->mime_info);
lsq_archive_entry_free(archive, archive->root_entry);
- switch(archive->status)
- {
- case(LSQ_ARCHIVESTATUS_IDLE):
- case(LSQ_ARCHIVESTATUS_ERROR):
- case(LSQ_ARCHIVESTATUS_USERBREAK):
- break;
- default:
- if(archive->child_pid)
- kill ( archive->child_pid , SIGHUP);
- break;
- }
lsq_tempfs_clean_root_dir(archive);
lsq_opened_archive_list = g_slist_remove(lsq_opened_archive_list,
object);
}
@@ -299,55 +286,9 @@
return archive;
}
-void
-lsq_archive_set_status(LSQArchive *archive, LSQArchiveStatus status)
-{
- gchar *_path = NULL;
- gchar *_path_ = NULL;
- GSList *iter;
-
- if(LSQ_IS_ARCHIVE(archive))
- {
- if(archive->status != status)
- {
- archive->old_status = archive->status;
- archive->status = status;
- g_signal_emit(G_OBJECT(archive),
lsq_archive_signals[LSQ_ARCHIVE_SIGNAL_STATUS_CHANGED], 0, NULL);
- if((archive->old_status == LSQ_ARCHIVESTATUS_REFRESH)
&& (archive->status == LSQ_ARCHIVESTATUS_IDLE))
- g_signal_emit(G_OBJECT(archive),
lsq_archive_signals[LSQ_ARCHIVE_SIGNAL_REFRESHED], 0, NULL);
- if((archive->old_status ==
LSQ_ARCHIVESTATUS_PREPARE_VIEW))// && (archive->status ==
LSQ_ARCHIVESTATUS_IDLE))
- {
- g_signal_emit(G_OBJECT(archive),
lsq_archive_signals[LSQ_ARCHIVE_SIGNAL_VIEW_PREPARED], 0, archive->files, NULL);
- iter = archive->files;
- while(iter)
- {
- g_free(iter->data);
- iter = g_slist_next(iter);
- }
- g_slist_free(archive->files);
- archive->files = NULL;
- }
-
- if((archive->old_status == LSQ_ARCHIVESTATUS_REMOVE) &&
(archive->files))
- {
- /* FIXME: can not be space in path */
- _path = archive->files->data;
- _path = g_shell_unquote(_path, NULL);
- _path_ = lsq_archive_get_iter_part(archive,
_path);
- g_signal_emit(G_OBJECT(archive),
lsq_archive_signals[LSQ_ARCHIVE_SIGNAL_PATH_CHANGED], 0, _path_, NULL);
- g_free(_path_);
- g_free(_path);
- g_slist_free(archive->files);
- archive->files = NULL;
- }
- }
- }
-}
-
gint
lsq_stop_archive_child( LSQArchive *archive )
{
- lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_USERBREAK);
return 0;
}
@@ -599,6 +540,7 @@
return entry;
}
+/*
static gchar *
lsq_archive_get_iter_part(const LSQArchive *archive, const gchar *path)
{
@@ -616,12 +558,12 @@
iter[0] = strdup("/");
}
- while(iter[1]) /* next iter must exist */
+ while(iter[1]) // next iter must exist
{
if((*iter)[0])
{
entry = lsq_archive_iter_get_child(archive, entry,
*iter);
- if(!entry) /*&& lsq_archive_iter_is_directory(archive,
entry))*/
+ if(!entry) //&& lsq_archive_iter_is_directory(archive,
entry))
{
break;
}
@@ -643,6 +585,7 @@
return result;
}
+*/
/******************
* LSQEntry stuff *
@@ -1548,61 +1491,6 @@
return thunar_vfs_mime_info_get_name(archive->mime_info);
}
-LSQArchiveStatus
-lsq_archive_get_status(LSQArchive *archive)
-{
- g_return_val_if_fail(LSQ_IS_ARCHIVE(archive), LSQ_ARCHIVESTATUS_ERROR);
- return archive->status;
-}
-
-LSQArchiveStatus
-lsq_archive_get_old_status(LSQArchive *archive)
-{
- g_return_val_if_fail(LSQ_IS_ARCHIVE(archive), LSQ_ARCHIVESTATUS_ERROR);
- return archive->old_status;
-}
-
-const gchar *
-lsq_archive_get_status_msg(LSQArchive *archive)
-{
- const gchar *msg = "";
- g_return_val_if_fail(LSQ_IS_ARCHIVE(archive), "");
-
- switch(archive->status)
- {
- case LSQ_ARCHIVESTATUS_INIT:
- msg = N_("Initializing archive");
- break;
- case LSQ_ARCHIVESTATUS_REFRESH:
- msg = N_("Refreshing archive contents");
- break;
- case LSQ_ARCHIVESTATUS_ADD:
- msg = N_("Adding file(s) to archive");
- break;
- case LSQ_ARCHIVESTATUS_EXTRACT:
- msg = N_("Extracting file(s) from archive");
- break;
- case LSQ_ARCHIVESTATUS_REMOVE:
- msg = N_("Removing file(s) from archive");
- break;
- case LSQ_ARCHIVESTATUS_IDLE:
- msg = N_("Done");
- break;
- case LSQ_ARCHIVESTATUS_PREPARE_VIEW:
- msg = N_("Extracting file(s) to temporary directory");
- case LSQ_ARCHIVESTATUS_CUSTOM:
- msg = N_("Performing an extended action");
- break;
- case LSQ_ARCHIVESTATUS_USERBREAK:
- msg = N_("Cancelled");
- break;
- case LSQ_ARCHIVESTATUS_ERROR:
- msg = N_("Error");
- break;
- }
- return msg;
-}
-
void
lsq_archive_iter_get_icon_name(const LSQArchive *archive, const LSQArchiveIter
*iter, GValue *value, GtkIconTheme *icon_theme)
{
@@ -1634,10 +1522,15 @@
}
}
-gboolean
-lsq_archive_stop(LSQArchive *archive)
+void
+lsq_archive_enqueue(LSQArchive *archive, LSQArchiveCommand *command)
{
- if(archive->child_pid)
- kill ( archive->child_pid , SIGHUP);
- return TRUE;
+ archive->command_queue = g_slist_append(archive->command_queue,
command);
}
+
+void
+lsq_archive_dequeue(LSQArchive *archive, LSQArchiveCommand *command)
+{
+ g_return_if_fail(archive->command_queue->data == command);
+ archive->command_queue = g_slist_remove(archive->command_queue,
command);
+}
Modified: squeeze/trunk/libsqueeze/archive.h
===================================================================
--- squeeze/trunk/libsqueeze/archive.h 2007-02-09 14:38:53 UTC (rev 24939)
+++ squeeze/trunk/libsqueeze/archive.h 2007-02-09 23:16:07 UTC (rev 24940)
@@ -1,6 +1,4 @@
/*
- * Copyright (c) 2006 Stephan Arts <[EMAIL PROTECTED]>
- *
* 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 of the License, or
@@ -19,19 +17,7 @@
#define __LIBSQUEEZE_ARCHIVE_H__
G_BEGIN_DECLS
-typedef enum
-{
- LSQ_ARCHIVESTATUS_INIT = 0,
- LSQ_ARCHIVESTATUS_IDLE,
- LSQ_ARCHIVESTATUS_ADD,
- LSQ_ARCHIVESTATUS_EXTRACT,
- LSQ_ARCHIVESTATUS_REMOVE,
- LSQ_ARCHIVESTATUS_REFRESH,
- LSQ_ARCHIVESTATUS_ERROR,
- LSQ_ARCHIVESTATUS_PREPARE_VIEW,
- LSQ_ARCHIVESTATUS_CUSTOM,
- LSQ_ARCHIVESTATUS_USERBREAK
-} LSQArchiveStatus;
+typedef struct _LSQArchiveCommand LSQArchiveCommand;
enum
{
@@ -77,17 +63,8 @@
GType *entry_property_types;
gchar **entry_property_names;
LSQEntry *root_entry;
- LSQArchiveStatus status;
- LSQArchiveStatus old_status;
- gchar *status_msg;
- gdouble progress;
- GPid child_pid;
- GIOChannel *ioc_in;
- GIOChannel *ioc_out;
- GIOChannel *ioc_err;
gpointer support;
- GSList *files;
- gboolean has_passwd;
+ GSList *command_queue;
struct {
guint64 archive_size;
guint64 content_size;
@@ -108,10 +85,6 @@
GType lsq_archive_get_type(void);
LSQArchive *lsq_archive_new(gchar *, const gchar *) G_GNUC_INTERNAL;
-void lsq_archive_set_status(LSQArchive *archive,
LSQArchiveStatus status) G_GNUC_INTERNAL;
-LSQArchiveStatus lsq_archive_get_status(LSQArchive *archive);
-const gchar * lsq_archive_get_status_msg(LSQArchive *archive);
-LSQArchiveStatus lsq_archive_get_old_status(LSQArchive *archive);
const gchar * lsq_archive_get_filename(LSQArchive *archive);
const gchar * lsq_archive_get_mimetype(LSQArchive *archive);
@@ -149,6 +122,9 @@
void lsq_archive_add_children(LSQArchive *, GSList *)
G_GNUC_INTERNAL;
+void lsq_archive_enqueue(LSQArchive *archive, LSQArchiveCommand
*command);
+void lsq_archive_dequeue(LSQArchive *archive, LSQArchiveCommand
*command);
+
G_END_DECLS
#endif /* __LIBSQUEEZE_ARCHIVE_H__ */
Modified: squeeze/trunk/libsqueeze/internals.c
===================================================================
--- squeeze/trunk/libsqueeze/internals.c 2007-02-09 14:38:53 UTC (rev
24939)
+++ squeeze/trunk/libsqueeze/internals.c 2007-02-09 23:16:07 UTC (rev
24940)
@@ -39,7 +39,7 @@
static gint
lsq_opened_archives_lookup_archive(gconstpointer open_archive, gconstpointer
path);
-
+/*
void
lsq_default_child_watch_func(GPid pid, gint status, gpointer data)
{
@@ -137,6 +137,7 @@
}
return 0;
}
+*/
gchar *
lsq_concat_filenames(GSList *filenames)
Modified: squeeze/trunk/libsqueeze/libsqueeze.c
===================================================================
--- squeeze/trunk/libsqueeze/libsqueeze.c 2007-02-09 14:38:53 UTC (rev
24939)
+++ squeeze/trunk/libsqueeze/libsqueeze.c 2007-02-09 23:16:07 UTC (rev
24940)
@@ -38,14 +38,13 @@
lsq_tmp_dir = g_get_tmp_dir();
lsq_mime_database = thunar_vfs_mime_database_get_default();
- lsq_register_support(lsq_archive_support_gnu_tar_new());
lsq_register_support(lsq_archive_support_zip_new());
- lsq_register_support(lsq_archive_support_rar_new());
- lsq_register_support(lsq_archive_support_compr_new());
/*
TODO: Implement right commands in unrar
- lsq_register_support(lsq_archive_support_unrar_new());
+ lsq_register_support(lsq_archive_support_gnu_tar_new());
+ lsq_register_support(lsq_archive_support_rar_new());
+ lsq_register_support(lsq_archive_support_compr_new());
*/
lsq_relative_base_path = thunar_vfs_path_new(current_dir, NULL);
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits