[Xfce4-commits] r24010 - in xarchiver/branches/xarchiver-psybsd: . icons icons/48x48 icons/scalable libsqueeze pixmaps po src
Stephan Arts
stephan at xfce.org
Thu Nov 30 10:08:26 CET 2006
Author: stephan
Date: 2006-11-30 09:08:26 +0000 (Thu, 30 Nov 2006)
New Revision: 24010
Added:
xarchiver/branches/xarchiver-psybsd/icons/scalable/
xarchiver/branches/xarchiver-psybsd/icons/scalable/Makefile.am
xarchiver/branches/xarchiver-psybsd/libsqueeze/
xarchiver/branches/xarchiver-psybsd/libsqueeze/Makefile.am
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-gnu-tar.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-gnu-tar.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-rar.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-rar.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-unrar.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-unrar.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-zip.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-zip.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/internals.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/internals.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/libxarchiver.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/libxarchiver.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/mime.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/mime.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/slist.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/slist.h
xarchiver/branches/xarchiver-psybsd/pixmaps/archive-add.png
xarchiver/branches/xarchiver-psybsd/pixmaps/archive-extract.png
xarchiver/branches/xarchiver-psybsd/squeeze.desktop.in
xarchiver/branches/xarchiver-psybsd/squeeze.tap
Removed:
xarchiver/branches/xarchiver-psybsd/icons/48x48/xarchiver.png
xarchiver/branches/xarchiver-psybsd/libsqueeze/Makefile.am
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-gnu-tar.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-gnu-tar.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-rar.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-rar.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-unrar.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-unrar.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-zip.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-zip.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/archive.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/internals.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/internals.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/libxarchiver.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/libxarchiver.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/mime.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/mime.h
xarchiver/branches/xarchiver-psybsd/libsqueeze/slist.c
xarchiver/branches/xarchiver-psybsd/libsqueeze/slist.h
xarchiver/branches/xarchiver-psybsd/libxarchiver/
xarchiver/branches/xarchiver-psybsd/pixmaps/xarchiver-add.png
xarchiver/branches/xarchiver-psybsd/pixmaps/xarchiver-extract.png
xarchiver/branches/xarchiver-psybsd/po/xarchiver.pot
xarchiver/branches/xarchiver-psybsd/xarchiver.desktop.in
xarchiver/branches/xarchiver-psybsd/xarchiver.tap
Modified:
xarchiver/branches/xarchiver-psybsd/AUTHORS
xarchiver/branches/xarchiver-psybsd/Makefile.am
xarchiver/branches/xarchiver-psybsd/TODO
xarchiver/branches/xarchiver-psybsd/configure.in.in
xarchiver/branches/xarchiver-psybsd/icons/48x48/Makefile.am
xarchiver/branches/xarchiver-psybsd/icons/Makefile.am
xarchiver/branches/xarchiver-psybsd/pixmaps/Makefile.am
xarchiver/branches/xarchiver-psybsd/po/ChangeLog
xarchiver/branches/xarchiver-psybsd/po/Makevars
xarchiver/branches/xarchiver-psybsd/po/POTFILES.in
xarchiver/branches/xarchiver-psybsd/po/nl.po
xarchiver/branches/xarchiver-psybsd/src/Makefile.am
xarchiver/branches/xarchiver-psybsd/src/add_dialog.c
xarchiver/branches/xarchiver-psybsd/src/add_dialog.h
xarchiver/branches/xarchiver-psybsd/src/application.c
xarchiver/branches/xarchiver-psybsd/src/application.h
xarchiver/branches/xarchiver-psybsd/src/archive_store.c
xarchiver/branches/xarchiver-psybsd/src/archive_store.h
xarchiver/branches/xarchiver-psybsd/src/extract_dialog.c
xarchiver/branches/xarchiver-psybsd/src/extract_dialog.h
xarchiver/branches/xarchiver-psybsd/src/main.c
xarchiver/branches/xarchiver-psybsd/src/main_window.c
xarchiver/branches/xarchiver-psybsd/src/main_window.h
xarchiver/branches/xarchiver-psybsd/src/navigation_bar.c
xarchiver/branches/xarchiver-psybsd/src/navigation_bar.h
xarchiver/branches/xarchiver-psybsd/src/new_dialog.c
xarchiver/branches/xarchiver-psybsd/src/new_dialog.h
xarchiver/branches/xarchiver-psybsd/src/notebook.c
xarchiver/branches/xarchiver-psybsd/src/notebook.h
xarchiver/branches/xarchiver-psybsd/src/path_bar.c
xarchiver/branches/xarchiver-psybsd/src/path_bar.h
xarchiver/branches/xarchiver-psybsd/src/preferences_dialog.c
xarchiver/branches/xarchiver-psybsd/src/preferences_dialog.h
xarchiver/branches/xarchiver-psybsd/src/settings.c
xarchiver/branches/xarchiver-psybsd/src/settings.h
xarchiver/branches/xarchiver-psybsd/src/tool_bar.c
xarchiver/branches/xarchiver-psybsd/src/tool_bar.h
xarchiver/branches/xarchiver-psybsd/src/widget_factory.c
xarchiver/branches/xarchiver-psybsd/src/widget_factory.h
Log:
Renaming xarchiver-psybsd to squeeze (step 1)
Modified: xarchiver/branches/xarchiver-psybsd/AUTHORS
===================================================================
--- xarchiver/branches/xarchiver-psybsd/AUTHORS 2006-11-30 08:57:52 UTC (rev 24009)
+++ xarchiver/branches/xarchiver-psybsd/AUTHORS 2006-11-30 09:08:26 UTC (rev 24010)
@@ -1,3 +1,2 @@
Stephan Arts - psyBSD - <psybsd at gmail.com>
Peter de Ridder - cavalier - <pc.ridder at zonnet.nl>
-Giuseppe Torelli - Colossus - <colossus73 at gmail.com>
Modified: xarchiver/branches/xarchiver-psybsd/Makefile.am
===================================================================
--- xarchiver/branches/xarchiver-psybsd/Makefile.am 2006-11-30 08:57:52 UTC (rev 24009)
+++ xarchiver/branches/xarchiver-psybsd/Makefile.am 2006-11-30 09:08:26 UTC (rev 24010)
@@ -4,22 +4,22 @@
1.8 \
dist-bzip2
-SUBDIRS = icons pixmaps libxarchiver src po
+SUBDIRS = pixmaps libsqueeze src po
wrapperdir = $(libexecdir)/thunar-archive-plugin/
-wrapper_SCRIPTS = xarchiver.tap
+wrapper_SCRIPTS = squeeze.tap
desktopdir = $(datadir)/applications
-desktop_in_files = xarchiver.desktop.in
+desktop_in_files = squeeze.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
-EXTRA_DIST = \
+EXTRA_DIST = config.rpath m4/ChangeLog \
autogen.sh \
intltool-extract.in \
intltool-merge.in \
intltool-update.in \
- xarchiver.tap \
+ squeeze.tap \
gettext.h \
$(desktop_in_files) \
$(wrapper_DATA)
@@ -29,3 +29,5 @@
intltool-merge \
intltool-update \
$(desktop_DATA)
+
+ACLOCAL_AMFLAGS = -I m4
Modified: xarchiver/branches/xarchiver-psybsd/TODO
===================================================================
--- xarchiver/branches/xarchiver-psybsd/TODO 2006-11-30 08:57:52 UTC (rev 24009)
+++ xarchiver/branches/xarchiver-psybsd/TODO 2006-11-30 09:08:26 UTC (rev 24010)
@@ -8,16 +8,9 @@
| IMPORTANT IMPORTANT |
---------------------------------------------------------------
- Fix navigation-bars to work with notebook - DONE
+ Make thunar-vfs dependency optional.
+ Make libxfce4-util dependency optional.
- Close Buttons - DONE
-
- Fix Command-line options - DONE
-
- Toggle navigationbar at runtime - DONE
-
- Save trailing folders for path_bar - DONE
-
Add Accelerators to Notebook
Add Dialog
@@ -34,9 +27,6 @@
Non-default actions
- Make thunar-vfs dependency optional.
- Make libxfce4-util dependency optional.
-
Comment library functions
(explain their purpose)
@@ -67,6 +57,21 @@
BUGS:
- ArchiveStore gets deleted when close button is pressed, archive remains and sends signal when refreshed .
+ Archive does not get freed properly. (mem usage keeps growing when opening and closing same archive)
- Archive does not get freed properly. (mem usage keeps growing when opening and closing same archive)
+ History inside the archive-store is bugged. This shows in archive_store_get_pwd.
+
+ archive-store out-of-sync is buffer-flush... breaks on index 499800: 499800.0 / 300.0 (buffer-size) == 1666.0 remaining 199 items are not flushed
+
+DONE:
+
+ Fix navigation-bars to work with notebook - DONE
+
+ Close Buttons - DONE
+
+ Fix Command-line options - DONE
+
+ Toggle navigationbar at runtime - DONE
+
+ Save trailing folders for path_bar - DONE
+
Modified: xarchiver/branches/xarchiver-psybsd/configure.in.in
===================================================================
--- xarchiver/branches/xarchiver-psybsd/configure.in.in 2006-11-30 08:57:52 UTC (rev 24009)
+++ xarchiver/branches/xarchiver-psybsd/configure.in.in 2006-11-30 09:08:26 UTC (rev 24010)
@@ -3,39 +3,43 @@
dnl The Xfce development team. All rights reserved.
dnl
dnl Originally written for Xfce by Benedikt Meurer <benny at xfce.org>
-dnl Modified by Stephan Arts <psybsd at gmail.com>
+dnl Modified by Stephan Arts <stephan at xfce.org>
dnl
dnl ***************************
dnl *** Version information ***
dnl ***************************
-m4_define([xarchiver_version_branch], [psybsd])
-m4_define([xarchiver_version_major], [0])
-m4_define([xarchiver_version_minor], [4])
-m4_define([xarchiver_version_micro], [9])
-m4_define([xarchiver_version_nano], []) # Leave empty for no nano version
-m4_define([xarchiver_version_build], [r at REVISION@])
-m4_define([xarchiver_version_tag], [svn]) # Leave empty for releases
-m4_define([xarchiver_version], [ifelse(xarchiver_version_branch(), [], [xarchiver_version_major().xarchiver_version_minor().xarchiver_version_micro()ifelse(xarchiver_version_nano(), [], [], [.xarchiver_version_nano()])], [xarchiver_version_branch()])-ifelse(xarchiver_version_tag(), [svn], [xarchiver_version_tag()-xarchiver_version_build()], [xarchiver_version_tag()])])
+m4_define([squeeze_verinfo], [0:1:0])
+m4_define([squeeze_version_branch], [])
+m4_define([squeeze_version_major], [0])
+m4_define([squeeze_version_minor], [0])
+m4_define([squeeze_version_micro], [1])
+m4_define([squeeze_version_nano], []) # Leave empty for no nano version
+m4_define([squeeze_version_build], [r at REVISION@])
+m4_define([squeeze_version_tag], [svn]) # Leave empty for releases
+m4_define([squeeze_version], [ifelse(squeeze_version_branch(), [], [squeeze_version_major().squeeze_version_minor().squeeze_version_micro()ifelse(squeeze_version_nano(), [], [], [.squeeze_version_nano()])], [squeeze_version_branch()])-ifelse(squeeze_version_tag(), [svn], [squeeze_version_tag()-squeeze_version_build()], [squeeze_version_tag()])])
dnl *******************************************
dnl *** Debugging support for SVN snapshots ***
dnl *******************************************
-m4_define([xarchiver_debug_default], [ifelse(xarchiver_version_tag(), [svn], [full], [minimum])])
+m4_define([squeeze_debug_default], [ifelse(squeeze_version_tag(), [svn], [full], [minimum])])
AC_COPYRIGHT([Copyright (c) 2006
The Xfce development team. All rights reserved.
-Written for Xfce by Stephan Arts <psybsd at gmail.com>.])
+Written for Xfce by Stephan Arts <stephan at xfce.org>.])
-AC_INIT([Xarchiver], [xarchiver_version], [])
+AC_INIT([Squeeze], [squeeze_version], [])
AC_PREREQ([2.50])
-XARCHIVER_VERSION=xarchiver_version
-AM_INIT_AUTOMAKE([xarchiver], [$XARCHIVER_VERSION])
+SQUEEZE_VERSION=squeeze_version
+AM_INIT_AUTOMAKE([squeeze], [$SQUEEZE_VERSION])
AM_CONFIG_HEADER([config.h])
AM_MAINTAINER_MODE
+SQUEEZE_VERINFO=squeeze_verinfo
+AC_SUBST(SQUEEZE_VERINFO)
+
dnl check for UNIX variants
AC_AIX
AC_ISC_POSIX
@@ -56,8 +60,8 @@
dnl *** Check for debugging support ***
dnl ***********************************
AC_ARG_ENABLE([debug],
-AC_HELP_STRING([--enable-debug=@<:@no/minimum/yes/full@:>@], [Turn on debugging @<:@default=xarchiver_debug_default@:>@]),
- [], [enable_debug=xarchiver_debug_default])
+AC_HELP_STRING([--enable-debug=@<:@no/minimum/yes/full@:>@], [Turn on debugging @<:@default=squeeze_debug_default@:>@]),
+ [], [enable_debug=squeeze_debug_default])
AC_MSG_CHECKING([whether to enable debugging support])
if test x"$enable_debug" = x"full" -o x"$enable_debug" = x"yes"; then
dnl Print the result
@@ -131,22 +135,22 @@
AC_ARG_ENABLE([pathbar],
[AC_HELP_STRING([--disable-pathbar],
[Do not compile support for a PathBar (default=enabled)])],
- [xa_pathbar=$enableval],
- [xa_pathbar=yes])
-if test "$xa_pathbar" = "yes"; then
+ [sq_pathbar=$enableval],
+ [sq_pathbar=yes])
+if test "$sq_pathbar" = "yes"; then
AC_DEFINE([ENABLE_PATHBAR], [1], [Define if we should include pathbar support])
fi
-AM_CONDITIONAL([ENABLE_PATHBAR], [test "$xa_pathbar" = "yes"])
+AM_CONDITIONAL([ENABLE_PATHBAR], [test "$sq_pathbar" = "yes"])
AC_ARG_ENABLE([toolbar],
[AC_HELP_STRING([--disable-toolbar],
[Do not compile support for a ToolBar (default=enabled)])],
- [xa_toolbar=$enableval],
- [xa_toolbar=yes])
-if test "$xa_toolbar" = "yes"; then
+ [sq_toolbar=$enableval],
+ [sq_toolbar=yes])
+if test "$sq_toolbar" = "yes"; then
AC_DEFINE([ENABLE_TOOLBAR], [1], [Define if we should include toolbar support])
fi
-AM_CONDITIONAL([ENABLE_TOOLBAR], [test "$xa_toolbar" = "yes"])
+AM_CONDITIONAL([ENABLE_TOOLBAR], [test "$sq_toolbar" = "yes"])
dnl check for debugging support
XDT_FEATURE_DEBUG
@@ -155,9 +159,10 @@
Makefile
po/Makefile.in
src/Makefile
-libxarchiver/Makefile
+libsqueeze/Makefile
icons/Makefile
icons/48x48/Makefile
+icons/scalable/Makefile
pixmaps/Makefile
])
Modified: xarchiver/branches/xarchiver-psybsd/icons/48x48/Makefile.am
===================================================================
--- xarchiver/branches/xarchiver-psybsd/icons/48x48/Makefile.am 2006-11-30 08:57:52 UTC (rev 24009)
+++ xarchiver/branches/xarchiver-psybsd/icons/48x48/Makefile.am 2006-11-30 09:08:26 UTC (rev 24010)
@@ -2,7 +2,7 @@
# Inspired by Makefile.am from the Thunar file-manager
iconsdir = $(datadir)/icons/hicolor/48x48/apps
-icons_DATA = xarchiver.png
+icons_DATA = squeeze.png
EXTRA_DIST = $(icons_DATA)
Deleted: xarchiver/branches/xarchiver-psybsd/icons/48x48/xarchiver.png
Modified: xarchiver/branches/xarchiver-psybsd/icons/Makefile.am
===================================================================
--- xarchiver/branches/xarchiver-psybsd/icons/Makefile.am 2006-11-30 08:57:52 UTC (rev 24009)
+++ xarchiver/branches/xarchiver-psybsd/icons/Makefile.am 2006-11-30 09:08:26 UTC (rev 24010)
@@ -1,7 +1,7 @@
# Inspired by Makefile.am from the Thunar file-manager
-SUBDIRS = 48x48
+SUBDIRS = 48x48 scalable
gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
Added: xarchiver/branches/xarchiver-psybsd/icons/scalable/Makefile.am
===================================================================
--- xarchiver/branches/xarchiver-psybsd/icons/scalable/Makefile.am (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/icons/scalable/Makefile.am 2006-11-30 09:08:26 UTC (rev 24010)
@@ -0,0 +1,9 @@
+
+# Inspired by Makefile.am from the Thunar file-manager
+
+iconsdir = $(datadir)/icons/hicolor/scalable/apps
+icons_DATA = squeeze.svg
+
+
+EXTRA_DIST = $(icons_DATA)
+
Copied: xarchiver/branches/xarchiver-psybsd/libsqueeze (from rev 24004, xarchiver/branches/xarchiver-psybsd/libxarchiver)
Deleted: xarchiver/branches/xarchiver-psybsd/libsqueeze/Makefile.am
Copied: xarchiver/branches/xarchiver-psybsd/libsqueeze/Makefile.am (from rev 24005, xarchiver/branches/xarchiver-psybsd/libxarchiver/Makefile.am)
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libsqueeze/Makefile.am (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/libsqueeze/Makefile.am 2006-11-30 09:08:26 UTC (rev 24010)
@@ -0,0 +1,23 @@
+lib_LTLIBRARIES = libsqueeze-1.la
+
+libsqueeze_1_la_SOURCES = \
+ internals.c internals.h \
+ libxarchiver.c libxarchiver.h \
+ mime.c mime.h \
+ slist.c slist.h \
+ archive.c archive.h \
+ archive-support.c archive-support.h \
+ archive-support-zip.c archive-support-zip.h \
+ archive-support-gnu-tar.c archive-support-gnu-tar.h
+
+libsqueeze_1_la_CFLAGS = \
+ $(GLIB_CFLAGS) \
+ $(THUNAR_VFS_CFLAGS)
+
+libsqueeze_1_la_LIBADD =
+
+libsqueeze_1_la_LDFLAGS = \
+ -version-info $(SQUEEZE_VERINFO)
+
+libsqueeze_includedir= \
+ $(includedir)/libsqueeze
Deleted: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-gnu-tar.c
Copied: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-gnu-tar.c (from rev 24005, xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.c)
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-gnu-tar.c (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-gnu-tar.c 2006-11-30 09:08:26 UTC (rev 24010)
@@ -0,0 +1,816 @@
+/*
+ * Copyright (c) 2006 Stephan Arts <psyBSD at gmail.com>
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <glib-object.h>
+#include <gettext.h>
+
+#include "mime.h"
+#include "archive.h"
+#include "archive-support.h"
+#include "archive-support-gnu-tar.h"
+
+#include "internals.h"
+
+enum
+{
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_OVERWRITE = 1,
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_TOUCH,
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_STRIP,
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_KEEP_NEW,
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR_ADD_MODE,
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_SIZE,
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_DATE,
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_TIME,
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_OWNER,
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_RIGHTS
+};
+
+void
+lsq_archive_support_gnu_tar_init(LSQArchiveSupportGnuTar *support);
+void
+lsq_archive_support_gnu_tar_class_init(LSQArchiveSupportGnuTarClass *supportclass);
+
+void
+lsq_archive_support_gnu_tar_compress_watch(GPid pid, gint status, gpointer data);
+void
+lsq_archive_support_gnu_tar_decompress_watch(GPid pid, gint status, gpointer data);
+
+gboolean
+lsq_archive_support_gnu_tar_refresh_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data);
+gboolean
+lsq_archive_support_gnu_tar_compress_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data);
+gboolean
+lsq_archive_support_gnu_tar_decompress_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data);
+
+void
+lsq_archive_support_gnu_tar_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+void
+lsq_archive_support_gnu_tar_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+
+GType
+lsq_archive_support_gnu_tar_get_type ()
+{
+ static GType lsq_archive_support_gnu_tar_type = 0;
+
+ if (!lsq_archive_support_gnu_tar_type)
+ {
+ static const GTypeInfo lsq_archive_support_gnu_tar_info =
+ {
+ sizeof (LSQArchiveSupportGnuTarClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) lsq_archive_support_gnu_tar_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (LSQArchiveSupportGnuTar),
+ 0,
+ (GInstanceInitFunc) lsq_archive_support_gnu_tar_init,
+ };
+
+ lsq_archive_support_gnu_tar_type = g_type_register_static (LSQ_TYPE_ARCHIVE_SUPPORT, "LSQArchiveSupportGnuTar", &lsq_archive_support_gnu_tar_info, 0);
+ }
+ return lsq_archive_support_gnu_tar_type;
+}
+
+void
+lsq_archive_support_gnu_tar_init(LSQArchiveSupportGnuTar *support)
+{
+ /* TODO: free return value of g_find_program_in_path */
+ LSQArchiveSupport *archive_support = LSQ_ARCHIVE_SUPPORT(support);
+ gchar *program_path = NULL;
+
+ archive_support->id = "Gnu Tar";
+
+ if(g_find_program_in_path("gtar"))
+ support->app_name = "gtar";
+ else
+ support->app_name = "tar";
+
+ lsq_archive_support_add_mime(archive_support, "application/x-tar");
+ /* Check for existence of compress -- required for x-tarz */
+ program_path = g_find_program_in_path("compress");
+ if(program_path)
+ {
+ lsq_archive_support_add_mime(archive_support, "application/x-tarz");
+ g_free(program_path);
+ }
+ /* Check for existence of gzip -- required for x-compressed-tar*/
+ program_path = g_find_program_in_path("gzip");
+ if(program_path)
+ {
+ lsq_archive_support_add_mime(archive_support, "application/x-compressed-tar");
+ g_free(program_path);
+ }
+ /* Check for existence of bzip2 -- required for x-bzip-compressed-tar */
+ program_path = g_find_program_in_path("bzip2");
+ if(program_path)
+ {
+ lsq_archive_support_add_mime(archive_support, "application/x-bzip-compressed-tar");
+ g_free(program_path);
+ }
+ /* Check for existence of lzop -- required for x-tzo */
+ program_path = g_find_program_in_path("lzop");
+ if(program_path)
+ {
+ lsq_archive_support_add_mime(archive_support, "application/x-tzo");
+ g_free(program_path);
+ }
+
+ archive_support->add = lsq_archive_support_gnu_tar_add;
+ archive_support->extract = lsq_archive_support_gnu_tar_extract;
+ archive_support->remove = lsq_archive_support_gnu_tar_remove;
+ archive_support->refresh = lsq_archive_support_gnu_tar_refresh;
+}
+
+void
+lsq_archive_support_gnu_tar_class_init(LSQArchiveSupportGnuTarClass *supportclass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (supportclass);
+ GParamSpec *pspec = NULL;
+
+ object_class->set_property = lsq_archive_support_gnu_tar_set_property;
+ object_class->get_property = lsq_archive_support_gnu_tar_get_property;
+
+ pspec = g_param_spec_boolean("extract-overwrite",
+ _("Overwrite existing files"),
+ _("Overwrite existing files on extraction"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_OVERWRITE, pspec);
+
+ pspec = g_param_spec_boolean("extract-touch",
+ _("Touch files"),
+ _("Touch files"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_TOUCH, pspec);
+
+ pspec = g_param_spec_uint("extract-strip",
+ _("Strip directories"),
+ _("Strip directories"),
+ 0,
+ 128,
+ 0,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_STRIP, pspec);
+
+ pspec = g_param_spec_boolean("extract-keep-new",
+ _("Keep newer files"),
+ _("Do not overwrite files newer then those in the archive"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_KEEP_NEW, pspec);
+
+ pspec = g_param_spec_string("add-mode",
+ _("Override permissions"),
+ _("Override permissions"),
+ "",
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_GNU_TAR_ADD_MODE, pspec);
+
+ pspec = g_param_spec_boolean("view-size",
+ _("Size"),
+ _("View filesize"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_SIZE, pspec);
+
+ pspec = g_param_spec_boolean("view-rights",
+ _("Permissions"),
+ _("View permissions"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_RIGHTS, pspec);
+
+ pspec = g_param_spec_boolean("view-owner",
+ _("Owner/Group"),
+ _("View owner/group"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_OWNER, pspec);
+
+ pspec = g_param_spec_boolean("view-date",
+ _("Date"),
+ _("View date"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_DATE, pspec);
+
+ pspec = g_param_spec_boolean("view-time",
+ _("Time"),
+ _("View time"),
+ TRUE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_TIME, pspec);
+
+}
+
+LSQArchiveSupport*
+lsq_archive_support_gnu_tar_new()
+{
+ LSQArchiveSupportGnuTar *support;
+
+ support = g_object_new(LSQ_TYPE_ARCHIVE_SUPPORT_GNU_TAR,
+ "view-time", TRUE,
+ "view-date", TRUE,
+ "view-owner", TRUE,
+ "view-rights", TRUE,
+ "view-size", TRUE,
+ NULL);
+ /*
+ support = g_object_new(LSQ_TYPE_ARCHIVE_SUPPORT_GNU_TAR,
+ "view-time", FALSE,
+ "view-date", FALSE,
+ "view-owner", FALSE,
+ "view-rights", FALSE,
+ "view-size", FALSE,
+ NULL);
+ */
+
+ return LSQ_ARCHIVE_SUPPORT(support);
+}
+
+gint
+lsq_archive_support_gnu_tar_add(LSQArchive *archive, GSList *filenames)
+{
+ if(!LSQ_IS_ARCHIVE_SUPPORT_GNU_TAR(archive->support))
+ {
+ g_critical("Support is not GNU TAR");
+ return -1;
+ }
+
+ if(!lsq_archive_support_mime_supported(archive->support, lsq_mime_info_get_name(archive->mime_info)))
+ {
+ return 1;
+ }
+ else
+ {
+ gchar *command = NULL;
+ archive->files = lsq_concat_filenames(filenames);
+ lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_ADD);
+ if(!g_file_test(archive->path, G_FILE_TEST_EXISTS))
+ {
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-tar"))
+ command = g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name,
+ " -cf ", archive->path,
+ " --mode=", LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_add_mode,
+ " ", archive->files, NULL);
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-tarz"))
+ command = g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name,
+ " -Zcf ", archive->path,
+ " --mode=", LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_add_mode,
+ " ", archive->files, NULL);
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-compressed-tar"))
+ command = g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name,
+ " -zcf ", archive->path,
+ " --mode=", LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_add_mode,
+ " ", archive->files, NULL);
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-bzip-compressed-tar"))
+ command = g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name,
+ " -jcf ", archive->path,
+ " --mode=", LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_add_mode,
+ " ", archive->files, NULL);
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-tzo"))
+ command = g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name,
+ " --use-compress-program=lzop -cf ", archive->path,
+ " --mode=", LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_add_mode,
+ " ", archive->files, NULL);
+ if(command)
+ lsq_execute(command, archive, NULL, NULL, NULL, NULL);
+ } else
+ {
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-tar"))
+ {
+ command = g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name, " -rf ", archive->path, " ", archive->files, NULL);
+ lsq_execute(command, archive, NULL, NULL, NULL, NULL);
+ g_free(command);
+ return 0;
+ }
+ archive->tmp_file = g_strconcat(lsq_tmp_dir, "/xarchiver-XXXXXX" , NULL);
+ g_mkstemp(archive->tmp_file);
+ g_unlink(archive->tmp_file);
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-tarz"))
+ command = g_strconcat("uncompress -c ", archive->path, NULL);
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-compressed-tar"))
+ command = g_strconcat("gunzip -c ", archive->path, NULL);
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-bzip-compressed-tar"))
+ command = g_strconcat("bunzip2 -c ", archive->path, NULL);
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-tzo"))
+ command = g_strconcat("lzop -dc ", archive->path, NULL);
+ lsq_execute(command, archive, lsq_archive_support_gnu_tar_decompress_watch, NULL, lsq_archive_support_gnu_tar_decompress_parse_output, NULL);
+ g_free(command);
+ }
+ }
+ return 0;
+}
+
+gint
+lsq_archive_support_gnu_tar_extract(LSQArchive *archive, gchar *dest_path, GSList *filenames)
+{
+ gchar *command = NULL;
+ gchar *command_options = g_strconcat(
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_extr_keep_newer?" --keep-newer-files ":" ",
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_extr_overwrite?" --overwrite ":" ",
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_extr_touch?" --touch ":" ",
+ NULL
+ );
+
+ if(!LSQ_IS_ARCHIVE_SUPPORT_GNU_TAR(archive->support))
+ {
+ g_critical("Support is not GNU TAR");
+ return -1;
+ }
+
+ if(!lsq_archive_support_mime_supported(archive->support, lsq_mime_info_get_name(archive->mime_info)))
+ {
+ return 1;
+ }
+ else
+ {
+ archive->files = lsq_concat_filenames(filenames);
+ lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_EXTRACT);
+ if(g_file_test(archive->path, G_FILE_TEST_EXISTS))
+ {
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-tar"))
+ {
+ command = g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name, " -xf ", archive->path,
+ " -C \"", dest_path, "\"",
+ command_options,
+ archive->files, NULL);
+ }
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-tarz"))
+ {
+ command = g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name, " -Zxf ", archive->path,
+ " -C \"", dest_path, "\"",
+ command_options,
+ archive->files, NULL);
+ }
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-compressed-tar"))
+ {
+ command = g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name, " -zxf ", archive->path,
+ " -C \"", dest_path, "\"",
+ command_options,
+ archive->files, NULL);
+ }
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-bzip-compressed-tar"))
+ {
+ command = g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name, " -jxf ", archive->path,
+ " -C \"", dest_path, "\"",
+ command_options,
+ archive->files, NULL);
+ }
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-tzo"))
+ {
+ command = g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name, " -xf --use-compress-program=lzop ", archive->path,
+ " -C \"", dest_path, "\"",
+ command_options,
+ archive->files, NULL);
+ }
+ } else
+ {
+ g_free(command_options);
+ return 1;
+ }
+ if(command)
+ {
+ lsq_execute(command, archive, NULL, NULL, NULL, NULL);
+ g_free(command_options);
+ g_free(command);
+ }
+ }
+ return 0;
+}
+
+gint
+lsq_archive_support_gnu_tar_remove(LSQArchive *archive, GSList *filenames)
+{
+ if(!LSQ_IS_ARCHIVE_SUPPORT_GNU_TAR(archive->support))
+ {
+ g_critical("Support is not GNU TAR");
+ return -1;
+ }
+
+ if(!lsq_archive_support_mime_supported(archive->support, lsq_mime_info_get_name(archive->mime_info)))
+ {
+ return 1;
+ }
+ else
+ {
+ gchar *command = NULL;
+ archive->files = lsq_concat_filenames(filenames);
+ lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_REMOVE);
+ if(g_file_test(archive->path, G_FILE_TEST_EXISTS))
+ {
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-tar"))
+ {
+ command = g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name, " -f ", archive->path, " --delete ", archive->files, NULL);
+ lsq_execute(command, archive, NULL, NULL, NULL, NULL);
+ g_free(command);
+ return 0;
+ }
+ archive->tmp_file = g_strconcat(lsq_tmp_dir, "/xarchiver-XXXXXX" , NULL);
+ g_mkstemp(archive->tmp_file);
+ g_unlink(archive->tmp_file);
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-tarz"))
+ command = g_strconcat("uncompress -c ", archive->path, NULL);
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-compressed-tar"))
+ command = g_strconcat("gunzip -c ", archive->path, NULL);
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-bzip-compressed-tar"))
+ command = g_strconcat("bunzip2 -c ", archive->path, NULL);
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-tzo"))
+ command = g_strconcat("lzop -dc ", archive->path, NULL);
+ lsq_execute(command, archive, lsq_archive_support_gnu_tar_decompress_watch, NULL, lsq_archive_support_gnu_tar_decompress_parse_output, NULL);
+ g_free(command);
+ } else
+ return 1;
+ }
+ return 0;
+}
+
+gint
+lsq_archive_support_gnu_tar_refresh(LSQArchive *archive)
+{
+ gchar *command = NULL;
+ guint i = 0;
+ if(!LSQ_IS_ARCHIVE_SUPPORT_GNU_TAR(archive->support))
+ {
+ g_critical("Support is not GNU TAR");
+ return -1;
+ }
+
+ if(!lsq_archive_support_mime_supported(archive->support, lsq_mime_info_get_name(archive->mime_info)))
+ {
+ return 1;
+ }
+ else
+ {
+ i = LSQ_ARCHIVE_PROP_USER;
+ if(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_rights) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_STRING, _("Permissions"));
+ i++;
+ }
+ if(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_owner) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_STRING,_("Owner/Group"));
+ i++;
+ }
+ if(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_size) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_UINT64, _("Size"));
+ i++;
+ }
+ if(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_date) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_STRING, _("Date"));
+ i++;
+ }
+ if(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_time) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_STRING, _("Time"));
+ i++;
+ }
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-tzo"))
+ command = g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name, " --use-compress-program=lzop -tvf " , archive->path, NULL);
+ else
+ command = g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name, " -tvf " , archive->path, NULL);
+ lsq_execute(command, archive, NULL, NULL, lsq_archive_support_gnu_tar_refresh_parse_output, NULL);
+ g_free(command);
+ }
+ return 0;
+}
+
+void
+lsq_archive_support_gnu_tar_decompress_watch(GPid pid, gint status, gpointer data)
+{
+ LSQArchive *archive = data;
+ 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(lsq_mime_info_get_name(archive->mime_info), "application/x-tarz"))
+ command = g_strconcat("compress -c ", archive->tmp_file, NULL);
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-compressed-tar"))
+ command = g_strconcat("gzip -c ", archive->tmp_file, NULL);
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-bzip-compressed-tar"))
+ command = g_strconcat("bzip2 -c ", archive->tmp_file, NULL);
+ if(!g_strcasecmp(lsq_mime_info_get_name(archive->mime_info), "application/x-tzo"))
+ command = g_strconcat("lzop -c ", archive->path, NULL);
+ lsq_execute(command, archive, NULL, NULL, lsq_archive_support_gnu_tar_compress_parse_output, NULL);
+}
+
+gboolean
+lsq_archive_support_gnu_tar_refresh_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data)
+{
+ GIOStatus status = G_IO_STATUS_NORMAL;
+ LSQArchive *archive = data;
+ gchar *line = NULL;
+ LSQEntry *entry;
+ gpointer props[6];
+
+ guint64 size;
+ guint linesize;
+ gint n = 0, a = 0, i = 0, o = 0;
+ gchar *temp_filename = NULL;
+
+ if(!LSQ_IS_ARCHIVE(archive))
+ return FALSE;
+
+
+ if(cond & (G_IO_PRI | G_IO_IN))
+ {
+ for(o = 0; o < 500; o++)
+ {
+ i = 0;
+
+ status = g_io_channel_read_line(ioc, &line, NULL,NULL,NULL);
+ if (line == NULL)
+ break;
+
+ linesize = strlen(line);
+
+ if(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_rights)
+ {
+ line[10] = '\0';
+ props[i] = line;
+ i++;
+ }
+
+
+ for(n=13; n < linesize; ++n)
+ if(line[n] == ' ') break;
+
+ if(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_owner)
+ {
+ line[n] = '\0';
+ props[i] = line+11;
+ i++;
+ }
+
+ for(++n; n < linesize; ++n)
+ if(line[n] >= '0' && line[n] <= '9') break;
+
+ a = n;
+
+ for(; n < linesize; ++n)
+ if(line[n] == ' ') break;
+
+ if(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_size)
+ {
+ line[n] = '\0';
+ size = g_ascii_strtoull(line + a, NULL, 0);
+ props[i] = &size;
+ i++;
+ }
+
+ a = ++n;
+
+ for(; n < linesize; n++) // DATE
+ if(line[n] == ' ') break;
+
+ if(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_date)
+ {
+ line[n] = '\0';
+ props[i] = line + a;
+ i++;
+ }
+
+ a = ++n;
+ for (; n < linesize; n++) // TIME
+ if (line[n] == ' ') break;
+
+ if(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->_view_time)
+ {
+ line[n] = '\0';
+ props[i] = line + a;
+ i++;
+ }
+
+ n++;
+
+ gchar *temp = g_strrstr (&line[n],"->");
+ if (temp )
+ {
+ temp[0] = '\0';
+ }
+
+ temp_filename = g_strchomp(line + n);
+
+ entry = lsq_archive_add_file(archive, temp_filename);
+ lsq_archive_iter_set_propsv(archive, entry, (gconstpointer*)props);
+ g_free(line);
+ }
+ }
+ if(cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
+ {
+ g_io_channel_shutdown ( ioc,TRUE,NULL );
+ g_io_channel_unref (ioc);
+ lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_IDLE);
+ return FALSE;
+ }
+ return TRUE;
+}
+gboolean
+lsq_archive_support_gnu_tar_decompress_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data)
+{
+ FILE *out_file = NULL;
+ LSQArchive *archive = data;
+ gchar *buf = g_new0(gchar, 1024);
+ guint read = 0;
+ GError *error = NULL;
+ gchar *command = NULL;
+
+ if(cond & (G_IO_PRI | G_IO_IN))
+ {
+ out_file = fopen(archive->tmp_file, "ab");
+ if(!out_file)
+ g_critical("Could not open file");
+
+ while(g_io_channel_read_chars(ioc, buf, 1024, &read, &error) == G_IO_STATUS_NORMAL)
+ {
+ if(read)
+ {
+ fwrite(buf, 1, read, out_file);
+ }
+ read = 0;
+ }
+ fclose(out_file);
+ }
+ g_free(buf);
+ if(cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
+ {
+ g_io_channel_shutdown ( ioc,TRUE,NULL );
+ g_io_channel_unref (ioc);
+
+ if(!(cond & G_IO_ERR))
+ {
+ switch(archive->status)
+ {
+ case(LSQ_ARCHIVESTATUS_ADD):
+ g_unlink(archive->path);
+ command = g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name, " -rf ", archive->tmp_file, " ", 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):
+ g_unlink(archive->path);
+ command = g_strconcat(LSQ_ARCHIVE_SUPPORT_GNU_TAR(archive->support)->app_name, " -f ", archive->tmp_file, " --delete ", archive->files, NULL);
+ lsq_execute(command, archive, lsq_archive_support_gnu_tar_compress_watch, NULL, NULL, NULL);
+ g_free(command);
+ break;
+ default:
+ break;
+ }
+ }
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean
+lsq_archive_support_gnu_tar_compress_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data)
+{
+ FILE *out_file = NULL;
+ LSQArchive *archive = data;
+ gchar *buf = g_new0(gchar, 1024);
+ guint read = 0;
+ GError *error = NULL;
+
+ if(cond & (G_IO_PRI | G_IO_IN))
+ {
+ out_file = fopen(archive->path, "ab");
+ if(!out_file)
+ g_critical("Could not open file");
+
+ while(g_io_channel_read_chars(ioc, buf, 1024, &read, &error) == G_IO_STATUS_NORMAL)
+ {
+ if(read)
+ {
+ fwrite(buf, 1, read, out_file);
+ }
+ read = 0;
+ }
+ fclose(out_file);
+ }
+ g_free(buf);
+ if(cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
+ {
+ g_io_channel_shutdown ( ioc,TRUE,NULL );
+ g_io_channel_unref (ioc);
+ if(archive->tmp_file)
+ g_unlink(archive->tmp_file);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void
+lsq_archive_support_gnu_tar_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+ switch(prop_id)
+ {
+/* EXTRACT */
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_OVERWRITE:
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_extr_overwrite = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_TOUCH:
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_extr_touch = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_KEEP_NEW:
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_extr_keep_newer = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_STRIP:
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_extr_strip = g_value_get_uint(value);
+ break;
+/* ADD */
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_ADD_MODE:
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_add_mode = g_value_dup_string(value);
+ break;
+
+/* */
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_SIZE:
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_view_size = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_DATE:
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_view_date = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_TIME:
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_view_time = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_OWNER:
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_view_owner = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_RIGHTS:
+ LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_view_rights = g_value_get_boolean(value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,prop_id,pspec);
+ break;
+ }
+}
+
+void
+lsq_archive_support_gnu_tar_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+ switch(prop_id)
+ {
+/* EXTRACT */
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_OVERWRITE:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_extr_overwrite);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_TOUCH:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_extr_touch);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_STRIP:
+ g_value_set_uint(value, LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_extr_strip);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_EXTRACT_KEEP_NEW:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_extr_keep_newer);
+ break;
+/* ADD */
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_ADD_MODE:
+ g_value_set_string(value, LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_add_mode);
+ break;
+
+/* */
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_SIZE:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_view_size);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_DATE:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_view_date);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_TIME:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_view_time);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_OWNER:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_view_owner);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_GNU_TAR_VIEW_RIGHTS:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_GNU_TAR(object)->_view_rights);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,prop_id,pspec);
+ break;
+ }
+}
Deleted: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-gnu-tar.h
Copied: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-gnu-tar.h (from rev 24005, xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-gnu-tar.h)
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-gnu-tar.h (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-gnu-tar.h 2006-11-30 09:08:26 UTC (rev 24010)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2006 Stephan Arts <psyBSD at gmail.com>
+ *
+ * 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 __LIBXARCHIVER_ARCHIVE_SUPPORT_GNU_TAR_H__
+#define __LIBXARCHIVER_ARCHIVE_SUPPORT_GNU_TAR_H__
+
+G_BEGIN_DECLS
+
+#define LSQ_TYPE_ARCHIVE_SUPPORT_GNU_TAR lsq_archive_support_gnu_tar_get_type()
+
+#define LSQ_ARCHIVE_SUPPORT_GNU_TAR(obj) ( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ LSQ_TYPE_ARCHIVE_SUPPORT_GNU_TAR, \
+ LSQArchiveSupportGnuTar))
+
+#define LSQ_IS_ARCHIVE_SUPPORT_GNU_TAR(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ LSQ_TYPE_ARCHIVE_SUPPORT_GNU_TAR))
+
+#define LSQ_ARCHIVE_SUPPORT_GNU_TAR_CLASS(klass) ( \
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ LSQ_TYPE_ARCHIVE_SUPPORT_GNU_TAR, \
+ LSQArchiveSupportGnuTarClass))
+
+#define LSQ_IS_ARCHIVE_SUPPORT_GNU_TAR_CLASS(klass) ( \
+ G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ LSQ_TYPE_ARCHIVE_SUPPORT_GNU_TAR))
+
+typedef struct _LSQArchiveSupportGnuTar LSQArchiveSupportGnuTar;
+
+struct _LSQArchiveSupportGnuTar
+{
+ LSQArchiveSupport parent;
+ gchar *app_name;
+ gboolean _extr_overwrite;
+ gboolean _extr_touch;
+ guint _extr_strip;
+ gboolean _extr_keep_old;
+ gboolean _extr_keep_newer;
+
+ gchar *_add_mode;
+
+/* Optional properties */
+ gboolean _view_size;
+ gboolean _view_date;
+ gboolean _view_time;
+ gboolean _view_owner;
+ gboolean _view_rights;
+};
+
+typedef struct _LSQArchiveSupportGnuTarClass LSQArchiveSupportGnuTarClass;
+
+struct _LSQArchiveSupportGnuTarClass
+{
+ LSQArchiveSupportClass parent;
+};
+
+GType lsq_archive_support_gnu_tar_get_type(void);
+LSQArchiveSupport * lsq_archive_support_gnu_tar_new();
+
+gint lsq_archive_support_gnu_tar_add(LSQArchive *, GSList *);
+gint lsq_archive_support_gnu_tar_extract(LSQArchive *, gchar *, GSList *);
+gint lsq_archive_support_gnu_tar_remove(LSQArchive *, GSList *);
+gint lsq_archive_support_gnu_tar_refresh(LSQArchive *);
+
+G_END_DECLS
+
+#endif /* __LIBXARCHIVER_ARCHIVE_SUPPORT_GNU_TAR_H__ */
Deleted: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-rar.c
Copied: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-rar.c (from rev 24005, xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-rar.c)
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-rar.c (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-rar.c 2006-11-30 09:08:26 UTC (rev 24010)
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 2006 Stephan Arts <psyBSD at gmail.com>
+ *
+ * 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.
+ */
+
+#define EXO_API_SUBJECT_TO_CHANGE
+
+#include <glib.h>
+#include <glib-object.h>
+#ifdef HAVE_THUNAR_VFS
+#include <thunar-vfs/thunar-vfs.h>
+#else
+#include <gettext.h>
+#endif /* HAVE_THUNAR_VFS */
+
+#include "archive.h"
+#include "archive-support.h"
+#include "archive-support-rar.h"
+
+#include "internals.h"
+
+void
+lsq_archive_support_rar_init(LSQArchiveSupportRar *support);
+void
+lsq_archive_support_rar_class_init(LSQArchiveSupportRarClass *supportclass);
+
+gint
+lsq_archive_support_rar_add(LSQArchive *archive, GSList *filenames);
+gint
+lsq_archive_support_rar_extract(LSQArchive *archive, gchar *dest_path, GSList *filenames);
+gint
+lsq_archive_support_rar_remove(LSQArchive *archive, GSList *filenames);
+
+GType
+lsq_archive_support_rar_get_type ()
+{
+ static GType lsq_archive_support_rar_type = 0;
+
+ if (!lsq_archive_support_rar_type)
+ {
+ static const GTypeInfo lsq_archive_support_rar_info =
+ {
+ sizeof (LSQArchiveSupportRarClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) lsq_archive_support_rar_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (LSQArchiveSupportRar),
+ 0,
+ (GInstanceInitFunc) lsq_archive_support_rar_init,
+ };
+
+ lsq_archive_support_rar_type = g_type_register_static (LSQ_TYPE_ARCHIVE_SUPPORT, "LSQArchiveSupportRar", &lsq_archive_support_rar_info, 0);
+ }
+ return lsq_archive_support_rar_type;
+}
+
+void
+lsq_archive_support_rar_init(LSQArchiveSupportRar *support)
+{
+ LSQArchiveSupport *archive_support = LSQ_ARCHIVE_SUPPORT(support);
+
+ archive_support->id = "Rar";
+
+ lsq_archive_support_add_mime(archive_support, "application/x-rar");
+
+ archive_support->add = lsq_archive_support_rar_add;
+ archive_support->extract = lsq_archive_support_rar_extract;
+ archive_support->remove = lsq_archive_support_rar_remove;
+}
+
+void
+lsq_archive_support_rar_class_init(LSQArchiveSupportRarClass *supportclass)
+{
+ /*
+ GObjectClass *gobject_class = G_OBJECT_CLASS (supportclass);
+ LSQArchiveSupportRarClass *klass = LSQ_ARCHIVE_SUPPORT_RAR_CLASS (supportclass);
+ */
+}
+
+LSQArchiveSupport*
+lsq_archive_support_rar_new()
+{
+ LSQArchiveSupportRar *support = NULL;
+
+ gchar *abs_path = g_find_program_in_path("rar");
+ if(abs_path)
+ {
+ support = g_object_new(LSQ_TYPE_ARCHIVE_SUPPORT_RAR, NULL);
+ g_free(abs_path);
+ }
+
+ return LSQ_ARCHIVE_SUPPORT(support);
+}
+
+gint
+lsq_archive_support_rar_add(LSQArchive *archive, GSList *filenames)
+{
+ if(!LSQ_IS_ARCHIVE_SUPPORT_RAR(archive->support))
+ {
+ g_critical("Support is not rar");
+ return -1;
+ }
+
+ if(!lsq_archive_support_mime_supported(archive->support, archive->mime))
+ {
+ return 1;
+ }
+ else
+ {
+ gchar *command = NULL;
+ gchar *files = lsq_concat_filenames(filenames);
+ if(!g_strcasecmp((gchar *)archive->mime, "application/x-rar"))
+ {
+ command = g_strconcat("rar a -o+ -ep1 -idp", archive->path, " ", files, NULL);
+ lsq_execute(command, archive, NULL, NULL, NULL, NULL);
+ }
+ }
+ return 0;
+}
+
+gint
+lsq_archive_support_rar_extract(LSQArchive *archive, gchar *dest_path, GSList *filenames)
+{
+ if(!LSQ_IS_ARCHIVE_SUPPORT_RAR(archive->support))
+ {
+ g_critical("Support is not Rar");
+ return -1;
+ }
+
+ if(!lsq_archive_support_mime_supported(archive->support, archive->mime))
+ {
+ return 1;
+ }
+ else
+ {
+ gchar *command = NULL;
+ gchar *files = lsq_concat_filenames(filenames);
+ if(g_file_test(archive->path, G_FILE_TEST_EXISTS))
+ {
+ if(!g_strcasecmp((gchar *)archive->mime, "application/x-rar"))
+ {
+ command = g_strconcat("rar x -o+ -idp ", archive->path, " ", files, " ", dest_path, " ", NULL);
+ g_debug("Extracting archive '%s' to '%s'", archive->path, dest_path);
+ lsq_execute(command, archive, NULL, NULL, NULL, NULL);
+ }
+ } else
+ return 1;
+ }
+ return 0;
+}
+
+gint
+lsq_archive_support_rar_remove(LSQArchive *archive, GSList *filenames)
+{
+ if(!LSQ_IS_ARCHIVE_SUPPORT_RAR(archive->support))
+ {
+ g_critical("Support is not rar");
+ return -1;
+ }
+
+ if(!lsq_archive_support_mime_supported(archive->support, archive->mime))
+ {
+ return 1;
+ }
+ else
+ {
+ gchar *command = NULL;
+ gchar *files = lsq_concat_filenames(filenames);
+ if(!g_strcasecmp((gchar *)archive->mime, "application/x-rar"))
+ {
+ command = g_strconcat("rar -d ", archive->path, " ", files, NULL);
+ lsq_execute(command, archive, NULL, NULL, NULL, NULL);
+ }
+ }
+ return 0;
+}
Deleted: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-rar.h
Copied: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-rar.h (from rev 24005, xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-rar.h)
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-rar.h (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-rar.h 2006-11-30 09:08:26 UTC (rev 24010)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2006 Stephan Arts <psyBSD at gmail.com>
+ *
+ * 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 __LIBXARCHIVER_ARCHIVE_SUPPORT_RAR_H__
+#define __LIBXARCHIVER_ARCHIVE_SUPPORT_RAR_H__
+
+G_BEGIN_DECLS
+
+
+#define LSQ_TYPE_ARCHIVE_SUPPORT_RAR lsq_archive_support_rar_get_type()
+
+#define LSQ_ARCHIVE_SUPPORT_RAR(obj) ( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ LSQ_TYPE_ARCHIVE_SUPPORT_RAR, \
+ LSQArchiveSupportRar))
+
+#define LSQ_IS_ARCHIVE_SUPPORT_RAR(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ LSQ_TYPE_ARCHIVE_SUPPORT_RAR))
+
+#define LSQ_ARCHIVE_SUPPORT_RAR_CLASS(klass) ( \
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ LSQ_TYPE_ARCHIVE_SUPPORT_RAR, \
+ LSQArchiveSupportRarClass))
+
+#define LSQ_IS_ARCHIVE_SUPPORT_RAR_CLASS(klass) ( \
+ G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ LSQ_TYPE_ARCHIVE_SUPPORT_RAR))
+
+typedef struct _LSQArchiveSupportRar LSQArchiveSupportRar;
+
+struct _LSQArchiveSupportRar
+{
+ LSQArchiveSupport parent;
+};
+
+typedef struct _LSQArchiveSupportRarClass LSQArchiveSupportRarClass;
+
+struct _LSQArchiveSupportRarClass
+{
+ LSQArchiveSupportClass parent;
+};
+
+GType lsq_archive_support_rar_get_type(void);
+LSQArchiveSupport * lsq_archive_support_rar_new();
+
+gint lsq_archive_support_rar_add(LSQArchive *, GSList *);
+gint lsq_archive_support_rar_extract(LSQArchive *, gchar *, GSList *);
+gint lsq_archive_support_rar_remove(LSQArchive *, GSList *);
+
+G_END_DECLS
+
+#endif /* __LIBXARCHIVER_ARCHIVE_SUPPORT_RAR_H__ */
Deleted: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-unrar.c
Copied: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-unrar.c (from rev 24005, xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-unrar.c)
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-unrar.c (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-unrar.c 2006-11-30 09:08:26 UTC (rev 24010)
@@ -0,0 +1,576 @@
+/*
+ * Copyright (c) 2006 Stephan Arts <psyBSD at gmail.com>
+ *
+ * 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-object.h>
+#include <gettext.h>
+
+#include "mime.h"
+#include "archive.h"
+#include "archive-support.h"
+#include "archive-support-unrar.h"
+
+#include "internals.h"
+
+#define XA_TEST_ACTION_ICON "gtk-index"
+
+enum
+{
+ LSQ_ARCHIVE_SUPPORT_UNRAR_EXTRACT_OVERWRITE = 1,
+ LSQ_ARCHIVE_SUPPORT_UNRAR_ADD_COMPRESSION_LEVEL,
+ LSQ_ARCHIVE_SUPPORT_UNRAR_PASSWORD,
+
+ LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_SIZE,
+ LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_COMPRESSED,
+ LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_DATE,
+ LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_TIME,
+ LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_RATIO,
+ LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_METHOD,
+ LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_CHECKSUM,
+ LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_VERSION
+};
+
+static void
+lsq_archive_support_unrar_init(LSQArchiveSupportUnrar *support);
+static void
+lsq_archive_support_unrar_class_init(LSQArchiveSupportUnrarClass *supportclass);
+
+gboolean
+lsq_archive_support_unrar_refresh_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data);
+
+static void
+lsq_archive_support_unrar_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+static void
+lsq_archive_support_unrar_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+
+static gint lsq_archive_support_unrar_add(LSQArchive *, GSList *);
+static gint lsq_archive_support_unrar_extract(LSQArchive *, gchar *, GSList *);
+static gint lsq_archive_support_unrar_remove(LSQArchive *, GSList *);
+static gint lsq_archive_support_unrar_refresh(LSQArchive *);
+
+static void lsq_archive_support_unrar_integrity_test(LSQArchiveSupport *, LSQArchive *, gpointer);
+
+GType
+lsq_archive_support_unrar_get_type ()
+{
+ static GType lsq_archive_support_unrar_type = 0;
+
+ if (!lsq_archive_support_unrar_type)
+ {
+ static const GTypeInfo lsq_archive_support_unrar_info =
+ {
+ sizeof (LSQArchiveSupportUnrarClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) lsq_archive_support_unrar_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (LSQArchiveSupportUnrar),
+ 0,
+ (GInstanceInitFunc) lsq_archive_support_unrar_init,
+ };
+
+ lsq_archive_support_unrar_type = g_type_register_static (LSQ_TYPE_ARCHIVE_SUPPORT, "LSQArchiveSupportUnrar", &lsq_archive_support_unrar_info, 0);
+ }
+ return lsq_archive_support_unrar_type;
+}
+
+static void
+lsq_archive_support_unrar_init(LSQArchiveSupportUnrar *support)
+{
+ LSQArchiveSupport *archive_support = LSQ_ARCHIVE_SUPPORT(support);
+ LSQCustomAction *custom_action = NULL;
+
+ archive_support->id = "Unrar";
+
+ lsq_archive_support_add_mime(archive_support, "application/unrar");
+ lsq_archive_support_add_mime(archive_support, "application/x-unrar");
+
+ archive_support->add = lsq_archive_support_unrar_add;
+ archive_support->extract = lsq_archive_support_unrar_extract;
+ archive_support->remove = lsq_archive_support_unrar_remove;
+ archive_support->refresh = lsq_archive_support_unrar_refresh;
+
+ custom_action = lsq_custom_action_new("menu-test",
+ _("Test"),
+ /* TRANSATORS: first line is short comment, after newline is long comment */
+ _("Test archive integrity\nTest the integrity of the archive"),
+ XA_TEST_ACTION_ICON,
+ lsq_archive_support_unrar_integrity_test,
+ archive_support,
+ NULL);
+}
+
+static void
+lsq_archive_support_unrar_class_init(LSQArchiveSupportUnrarClass *supportclass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (supportclass);
+ GParamSpec *pspec = NULL;
+
+ object_class->set_property = lsq_archive_support_unrar_set_property;
+ object_class->get_property = lsq_archive_support_unrar_get_property;
+
+ pspec = g_param_spec_string("extract-password",
+ _("Password"),
+ _("Password"),
+ "",
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_UNRAR_PASSWORD, pspec);
+
+ pspec = g_param_spec_boolean("extract-overwrite",
+ _("Overwrite existing files"),
+ _("Overwrite existing files on extraction"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_UNRAR_EXTRACT_OVERWRITE, pspec);
+
+ pspec = g_param_spec_boolean("view-size",
+ _("Filesize"),
+ _("View filesize"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_SIZE, pspec);
+
+ pspec = g_param_spec_boolean("view-time",
+ _("Time"),
+ _("View time"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_TIME, pspec);
+
+ pspec = g_param_spec_boolean("view-date",
+ _("Date"),
+ _("View date"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_DATE, pspec);
+
+ pspec = g_param_spec_boolean("view-ratio",
+ _("Ratio"),
+ _("View ratio"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_RATIO, pspec);
+
+ pspec = g_param_spec_boolean("view-length",
+ _("Length"),
+ _("View length"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_LENGTH, pspec);
+
+ pspec = g_param_spec_boolean("view-method",
+ _("Method"),
+ _("View method"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_METHOD, pspec);
+
+ pspec = g_param_spec_boolean("view-crc32",
+ _("CRC-32"),
+ _("View CRC-32"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_CRC_32, pspec);
+}
+
+LSQArchiveSupport*
+lsq_archive_support_unrar_new()
+{
+ LSQArchiveSupportUnrar *support;
+
+ support = g_object_new(LSQ_TYPE_ARCHIVE_SUPPORT_UNRAR,
+ "view-length", TRUE,
+ "view-size", TRUE,
+ "view-time", TRUE,
+ "view-date", TRUE,
+ "view-ratio", TRUE,
+ "view-crc32", TRUE,
+ "view-method", TRUE,
+ NULL);
+
+ return LSQ_ARCHIVE_SUPPORT(support);
+}
+
+static gint
+lsq_archive_support_unrar_add(LSQArchive *archive, GSList *filenames)
+{
+ if(!LSQ_IS_ARCHIVE_SUPPORT_UNRAR(archive->support))
+ {
+ g_critical("Support is not unrar");
+ return -1;
+ }
+
+ if(!lsq_archive_support_mime_supported(archive->support, lsq_mime_info_get_name(archive->mime_info)))
+ {
+ return 1;
+ }
+ else
+ {
+ gchar *command = NULL;
+ gchar *files = lsq_concat_filenames(filenames);
+ if(!g_strcasecmp((gchar *)lsq_mime_info_get_name(archive->mime_info), "application/x-unrar") ||
+ !g_strcasecmp((gchar *)lsq_mime_info_get_name(archive->mime_info), "application/unrar"))
+ {
+ command = g_strconcat("unrar -r ", archive->path, " ", files, NULL);
+ lsq_execute(command, archive, NULL, NULL, NULL, NULL);
+ }
+ }
+ return 0;
+}
+
+static gint
+lsq_archive_support_unrar_extract(LSQArchive *archive, gchar *dest_path, GSList *filenames)
+{
+ if(!LSQ_IS_ARCHIVE_SUPPORT_UNRAR(archive->support))
+ {
+ g_critical("Support is not Unrar");
+ return -1;
+ }
+
+ if(!lsq_archive_support_mime_supported(archive->support, lsq_mime_info_get_name(archive->mime_info)))
+ {
+ return 1;
+ }
+ else
+ {
+ gchar *command = NULL;
+ gchar *files = lsq_concat_filenames(filenames);
+ if(g_file_test(archive->path, G_FILE_TEST_EXISTS))
+ {
+ if(!g_strcasecmp((gchar *)lsq_mime_info_get_name(archive->mime_info), "application/x-unrar") ||
+ !g_strcasecmp((gchar *)lsq_mime_info_get_name(archive->mime_info), "application/unrar"))
+ {
+ command = g_strconcat("ununrar -o ", archive->path, " ", files, " -d ", dest_path, NULL);
+#ifdef DEBUG
+ g_debug("Extracting archive '%s' to '%s'", archive->path, dest_path);
+#endif /* DEBUG */
+ lsq_execute(command, archive, NULL, NULL, NULL, NULL);
+ }
+ } else
+ return 1;
+ }
+ return 0;
+}
+
+static gint
+lsq_archive_support_unrar_remove(LSQArchive *archive, GSList *filenames)
+{
+ if(!LSQ_IS_ARCHIVE_SUPPORT_UNRAR(archive->support))
+ {
+ g_critical("Support is not unrar");
+ return -1;
+ }
+
+ if(!lsq_archive_support_mime_supported(archive->support, lsq_mime_info_get_name(archive->mime_info)))
+ {
+ return 1;
+ }
+ else
+ {
+ gchar *command = NULL;
+ gchar *files = lsq_concat_filenames(filenames);
+ if(!g_strcasecmp((gchar *)lsq_mime_info_get_name(archive->mime_info), "application/x-unrar") ||
+ !g_strcasecmp((gchar *)lsq_mime_info_get_name(archive->mime_info), "application/unrar"))
+ {
+ command = g_strconcat("unrar -d ", archive->path, " ", files, NULL);
+ lsq_execute(command, archive, NULL, NULL, NULL, NULL);
+ }
+ }
+ return 0;
+}
+
+static gint
+lsq_archive_support_unrar_refresh(LSQArchive *archive)
+{
+ guint i = 0;
+ if(!LSQ_IS_ARCHIVE_SUPPORT_UNRAR(archive->support))
+ {
+ g_critical("Support is not Unrar");
+ return -1;
+ }
+
+ if(!lsq_archive_support_mime_supported(archive->support, lsq_mime_info_get_name(archive->mime_info)))
+ {
+ return 1;
+ }
+ else
+ {
+ i = LSQ_ARCHIVE_PROP_USER;
+ if(LSQ_ARCHIVE_SUPPORT_UNRAR(archive->support)->_view_length) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_UINT64, _("Length"));
+ i++;
+ }
+ if(LSQ_ARCHIVE_SUPPORT_UNRAR(archive->support)->_view_method) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_STRING,_("Method"));
+ i++;
+ }
+ if(LSQ_ARCHIVE_SUPPORT_UNRAR(archive->support)->_view_size) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_UINT64, _("Size"));
+ i++;
+ }
+ if(LSQ_ARCHIVE_SUPPORT_UNRAR(archive->support)->_view_ratio) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_STRING, _("Ratio"));
+ i++;
+ }
+ if(LSQ_ARCHIVE_SUPPORT_UNRAR(archive->support)->_view_date) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_STRING, _("Date"));
+ i++;
+ }
+ if(LSQ_ARCHIVE_SUPPORT_UNRAR(archive->support)->_view_time) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_STRING, _("Time"));
+ i++;
+ }
+ if(LSQ_ARCHIVE_SUPPORT_UNRAR(archive->support)->_view_crc_32) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_STRING, _("CRC-32"));
+ i++;
+ }
+ gchar *command = g_strconcat("ununrar -lv -qq " , archive->path, NULL);
+ lsq_execute(command, archive, NULL, NULL, lsq_archive_support_unrar_refresh_parse_output, NULL);
+ g_free(command);
+ }
+ return 0;
+}
+
+gboolean
+lsq_archive_support_unrar_refresh_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data)
+{
+ GIOStatus status = G_IO_STATUS_NORMAL;
+ LSQArchive *archive = data;
+ gchar *line = NULL;
+ LSQEntry *entry;
+
+ guint64 size;
+ guint64 length;
+ gpointer props[8];
+ gint n = 0, a = 0, i = 0, o = 0;
+ gchar *temp_filename = NULL;
+ gint linesize = 0;
+
+ if(!LSQ_IS_ARCHIVE(archive))
+ return FALSE;
+
+
+ if(cond & (G_IO_PRI | G_IO_IN))
+ {
+ for(o = 0; o < 500; o++)
+ {
+ i = 0;
+
+ status = g_io_channel_read_line(ioc, &line, NULL,NULL,NULL);
+ if (line == NULL)
+ break;
+ /* length, method , size, ratio, date, time, crc-32, filename*/
+ linesize = strlen(line);
+
+ for(n=0; n < linesize && line[n] == ' '; n++);
+ a = n;
+ for(; n < linesize && line[n] != ' '; n++);
+
+ if(LSQ_ARCHIVE_SUPPORT_UNRAR(archive->support)->_view_length)
+ {
+ line[n]='\0';
+ length = g_ascii_strtoull(line + a, NULL, 0);
+ props[i] = &length;
+ i++;
+ }
+ n++;
+
+ for(; n < linesize && line[n] == ' '; n++);
+ a = n;
+ for(; n < linesize && line[n] != ' '; n++);
+
+ if(LSQ_ARCHIVE_SUPPORT_UNRAR(archive->support)->_view_method)
+ {
+ line[n] = '\0';
+ props[i] = line + a;
+ i++;
+ }
+ n++;
+
+ for(; n < linesize && line[n] == ' '; n++);
+ a = n;
+ for(; n < linesize && line[n] != ' '; n++);
+
+ if(LSQ_ARCHIVE_SUPPORT_UNRAR(archive->support)->_view_size)
+ {
+ line[n]='\0';
+ size = g_ascii_strtoull(line + a, NULL, 0);
+ props[i] = &size;
+ i++;
+ }
+ n++;
+
+ for(; n < linesize && line[n] == ' '; n++);
+ a = n;
+ for(; n < linesize && line[n] != ' '; n++);
+
+ if(LSQ_ARCHIVE_SUPPORT_UNRAR(archive->support)->_view_ratio)
+ {
+ line[n] = '\0';
+ props[i] = line + a;
+ i++;
+ }
+ n++;
+
+ for(; n < linesize && line[n] == ' '; n++);
+ a = n;
+ for(; n < linesize && line[n] != ' '; n++);
+
+ if(LSQ_ARCHIVE_SUPPORT_UNRAR(archive->support)->_view_date)
+ {
+ line[n] = '\0';
+ props[i] = line + a;
+ i++;
+ }
+ n++;
+
+ for(; n < linesize && line[n] == ' '; n++);
+ a = n;
+ for(; n < linesize && line[n] != ' '; n++);
+
+ if(LSQ_ARCHIVE_SUPPORT_UNRAR(archive->support)->_view_time)
+ {
+ line[n] = '\0';
+ props[i] = line + a;
+ i++;
+ }
+ n++;
+
+ for(; n < linesize && line[n] == ' '; n++);
+ a = n;
+ for(; n < linesize && line[n] != ' '; n++);
+
+ if(LSQ_ARCHIVE_SUPPORT_UNRAR(archive->support)->_view_crc_32)
+ {
+ line[n] = '\0';
+ props[i] = line + a;
+ i++;
+ }
+ n++;
+
+ for(; n < linesize && line[n] == ' '; n++);
+ temp_filename = g_strchomp(line+n);
+
+ entry = lsq_archive_add_file(archive, temp_filename);
+ lsq_archive_iter_set_propsv(archive, entry, (gconstpointer*)props);
+ g_free(line);
+ }
+ }
+ if(cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
+ {
+#ifdef DEBUG
+ g_debug("shutting down ioc");
+#endif
+ g_io_channel_shutdown ( ioc,TRUE,NULL );
+ g_io_channel_unref (ioc);
+ lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_IDLE);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static void
+lsq_archive_support_unrar_integrity_test(LSQArchiveSupport *support, LSQArchive *archive, gpointer user_data)
+{
+#ifdef DEBUG
+ g_debug("Custom action %s called", __FUNCTION__);
+#endif /* DEBUG */
+}
+
+static void
+lsq_archive_support_unrar_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+ switch(prop_id)
+ {
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_EXTRACT_OVERWRITE:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_extr_overwrite);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_PASSWORD:
+ g_value_set_string (value, LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_extr_password);
+ break;
+
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_SIZE:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_view_size);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_DATE:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_view_date);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_TIME:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_view_time);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_RATIO:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_view_ratio);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_LENGTH:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_view_length);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_METHOD:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_view_method);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_CRC_32:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_view_crc_32);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,prop_id,pspec);
+ break;
+ }
+}
+
+static void
+lsq_archive_support_unrar_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+ switch(prop_id)
+ {
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_EXTRACT_OVERWRITE:
+ LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_extr_overwrite = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_PASSWORD:
+ LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_extr_password = (gchar *)g_value_get_string(value);
+ break;
+
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_SIZE:
+ LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_view_size = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_TIME:
+ LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_view_time = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_DATE:
+ LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_view_date = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_RATIO:
+ LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_view_ratio = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_LENGTH:
+ LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_view_length = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_METHOD:
+ LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_view_method = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_UNRAR_VIEW_CRC_32:
+ LSQ_ARCHIVE_SUPPORT_UNRAR(object)->_view_crc_32 = g_value_get_boolean(value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,prop_id,pspec);
+ break;
+ }
+}
Deleted: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-unrar.h
Copied: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-unrar.h (from rev 24005, xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-unrar.h)
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-unrar.h (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-unrar.h 2006-11-30 09:08:26 UTC (rev 24010)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2006 Stephan Arts <psyBSD at gmail.com>
+ *
+ * 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 Libunrary 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 __LIBXARCHIVER_ARCHIVE_SUPPORT_UNRAR_H__
+#define __LIBXARCHIVER_ARCHIVE_SUPPORT_UNRAR_H__
+
+G_BEGIN_DECLS
+
+
+#define LSQ_TYPE_ARCHIVE_SUPPORT_UNRAR lsq_archive_support_unrar_get_type()
+
+#define LSQ_ARCHIVE_SUPPORT_UNRAR(obj) ( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ LSQ_TYPE_ARCHIVE_SUPPORT_UNRAR, \
+ LSQArchiveSupportUnrar))
+
+#define LSQ_IS_ARCHIVE_SUPPORT_UNRAR(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ LSQ_TYPE_ARCHIVE_SUPPORT_UNRAR))
+
+#define LSQ_ARCHIVE_SUPPORT_UNRAR_CLASS(klass) ( \
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ LSQ_TYPE_ARCHIVE_SUPPORT_UNRAR, \
+ LSQArchiveSupportUnrarClass))
+
+#define LSQ_IS_ARCHIVE_SUPPORT_UNRAR_CLASS(klass) ( \
+ G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ LSQ_TYPE_ARCHIVE_SUPPORT_UNRAR))
+
+typedef struct _LSQArchiveSupportUnrar LSQArchiveSupportUnrar;
+
+struct _LSQArchiveSupportUnrar
+{
+ LSQArchiveSupport parent;
+};
+
+typedef struct _LSQArchiveSupportUnrarClass LSQArchiveSupportUnrarClass;
+
+struct _LSQArchiveSupportUnrarClass
+{
+ LSQArchiveSupportClass parent;
+};
+
+GType lsq_archive_support_unrar_get_type(void);
+LSQArchiveSupport * lsq_archive_support_unrar_new();
+
+gint lsq_archive_support_unrar_extract(LSQArchive *, gchar *, GSList *);
+gint lsq_archive_support_unrar_remove(LSQArchive *, GSList *);
+
+G_END_DECLS
+
+#endif /* __LIBXARCHIVER_ARCHIVE_SUPPORT_UNRAR_H__ */
Deleted: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-zip.c
Copied: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-zip.c (from rev 24005, xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.c)
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-zip.c (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-zip.c 2006-11-30 09:08:26 UTC (rev 24010)
@@ -0,0 +1,570 @@
+/*
+ * Copyright (c) 2006 Stephan Arts <psyBSD at gmail.com>
+ *
+ * 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-object.h>
+#include <gettext.h>
+
+#include "mime.h"
+#include "archive.h"
+#include "archive-support.h"
+#include "archive-support-zip.h"
+
+#include "internals.h"
+
+#define XA_TEST_ACTION_ICON "gtk-index"
+
+enum
+{
+ LSQ_ARCHIVE_SUPPORT_ZIP_EXTRACT_OVERWRITE = 1,
+ LSQ_ARCHIVE_SUPPORT_ZIP_ADD_COMPRESSION_LEVEL,
+ LSQ_ARCHIVE_SUPPORT_ZIP_PASSWORD,
+
+ LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_SIZE,
+ LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_DATE,
+ LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_TIME,
+ LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_RATIO,
+ LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_LENGTH,
+ LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_METHOD,
+ LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_CRC_32
+};
+
+static void
+lsq_archive_support_zip_init(LSQArchiveSupportZip *support);
+static void
+lsq_archive_support_zip_class_init(LSQArchiveSupportZipClass *supportclass);
+
+gboolean
+lsq_archive_support_zip_refresh_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data);
+
+static void
+lsq_archive_support_zip_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+static void
+lsq_archive_support_zip_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+
+static gint lsq_archive_support_zip_add(LSQArchive *, GSList *);
+static gint lsq_archive_support_zip_extract(LSQArchive *, gchar *, GSList *);
+static gint lsq_archive_support_zip_remove(LSQArchive *, GSList *);
+static gint lsq_archive_support_zip_refresh(LSQArchive *);
+
+static void lsq_archive_support_zip_integrity_test(LSQArchiveSupport *, LSQArchive *, gpointer);
+
+GType
+lsq_archive_support_zip_get_type ()
+{
+ static GType lsq_archive_support_zip_type = 0;
+
+ if (!lsq_archive_support_zip_type)
+ {
+ static const GTypeInfo lsq_archive_support_zip_info =
+ {
+ sizeof (LSQArchiveSupportZipClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) lsq_archive_support_zip_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (LSQArchiveSupportZip),
+ 0,
+ (GInstanceInitFunc) lsq_archive_support_zip_init,
+ };
+
+ lsq_archive_support_zip_type = g_type_register_static (LSQ_TYPE_ARCHIVE_SUPPORT, "LSQArchiveSupportZip", &lsq_archive_support_zip_info, 0);
+ }
+ return lsq_archive_support_zip_type;
+}
+
+static void
+lsq_archive_support_zip_init(LSQArchiveSupportZip *support)
+{
+ LSQArchiveSupport *archive_support = LSQ_ARCHIVE_SUPPORT(support);
+ LSQCustomAction *custom_action = NULL;
+
+ archive_support->id = "Zip";
+
+ lsq_archive_support_add_mime(archive_support, "application/zip");
+ lsq_archive_support_add_mime(archive_support, "application/x-zip");
+
+ archive_support->add = lsq_archive_support_zip_add;
+ archive_support->extract = lsq_archive_support_zip_extract;
+ archive_support->remove = lsq_archive_support_zip_remove;
+ archive_support->refresh = lsq_archive_support_zip_refresh;
+
+ custom_action = lsq_custom_action_new("menu-test",
+ _("Test"),
+ /* TRANSATORS: first line is short comment, after newline is long comment */
+ _("Test archive integrity\nTest the integrity of the archive"),
+ XA_TEST_ACTION_ICON,
+ lsq_archive_support_zip_integrity_test,
+ archive_support,
+ NULL);
+ lsq_archive_support_install_action(LSQ_ARCHIVE_SUPPORT(support), custom_action);
+}
+
+static void
+lsq_archive_support_zip_class_init(LSQArchiveSupportZipClass *supportclass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (supportclass);
+ GParamSpec *pspec = NULL;
+
+ object_class->set_property = lsq_archive_support_zip_set_property;
+ object_class->get_property = lsq_archive_support_zip_get_property;
+
+ pspec = g_param_spec_string("extract-password",
+ _("Password"),
+ _("Password"),
+ "",
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_ZIP_PASSWORD, pspec);
+
+ pspec = g_param_spec_boolean("extract-overwrite",
+ _("Overwrite existing files"),
+ _("Overwrite existing files on extraction"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_ZIP_EXTRACT_OVERWRITE, pspec);
+
+ pspec = g_param_spec_boolean("view-compressed-size",
+ _("Compressed Size"),
+ _("View compressed filesize"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_SIZE, pspec);
+
+ pspec = g_param_spec_boolean("view-time",
+ _("Time"),
+ _("View time"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_TIME, pspec);
+
+ pspec = g_param_spec_boolean("view-date",
+ _("Date"),
+ _("View date"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_DATE, pspec);
+
+ pspec = g_param_spec_boolean("view-ratio",
+ _("Ratio"),
+ _("View ratio"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_RATIO, pspec);
+
+ pspec = g_param_spec_boolean("view-uncompressed-size",
+ _("Size"),
+ _("View filesize"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_LENGTH, pspec);
+
+ pspec = g_param_spec_boolean("view-method",
+ _("Method"),
+ _("View method"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_METHOD, pspec);
+
+ pspec = g_param_spec_boolean("view-crc32",
+ _("Checksum"),
+ _("View Checksum"),
+ FALSE,
+ G_PARAM_READWRITE);
+ g_object_class_install_property(object_class, LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_CRC_32, pspec);
+}
+
+LSQArchiveSupport*
+lsq_archive_support_zip_new()
+{
+ LSQArchiveSupportZip *support;
+
+ support = g_object_new(LSQ_TYPE_ARCHIVE_SUPPORT_ZIP,
+ "view-uncompressed-size", TRUE,
+ "view-compressed-size", TRUE,
+ "view-time", TRUE,
+ "view-date", TRUE,
+ "view-ratio", TRUE,
+ "view-crc32", TRUE,
+ "view-method", TRUE,
+ NULL);
+
+ return LSQ_ARCHIVE_SUPPORT(support);
+}
+
+static gint
+lsq_archive_support_zip_add(LSQArchive *archive, GSList *filenames)
+{
+ if(!LSQ_IS_ARCHIVE_SUPPORT_ZIP(archive->support))
+ {
+ g_critical("Support is not zip");
+ return -1;
+ }
+
+ if(!lsq_archive_support_mime_supported(archive->support, lsq_mime_info_get_name(archive->mime_info)))
+ {
+ return 1;
+ }
+ else
+ {
+ gchar *command = NULL;
+ gchar *files = lsq_concat_filenames(filenames);
+ if(!g_strcasecmp((gchar *)lsq_mime_info_get_name(archive->mime_info), "application/x-zip") ||
+ !g_strcasecmp((gchar *)lsq_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);
+ }
+ }
+ return 0;
+}
+
+static gint
+lsq_archive_support_zip_extract(LSQArchive *archive, gchar *dest_path, GSList *filenames)
+{
+ if(!LSQ_IS_ARCHIVE_SUPPORT_ZIP(archive->support))
+ {
+ g_critical("Support is not Zip");
+ return -1;
+ }
+
+ if(!lsq_archive_support_mime_supported(archive->support, lsq_mime_info_get_name(archive->mime_info)))
+ {
+ return 1;
+ }
+ else
+ {
+ gchar *command = NULL;
+ gchar *files = lsq_concat_filenames(filenames);
+ if(g_file_test(archive->path, G_FILE_TEST_EXISTS))
+ {
+ if(!g_strcasecmp((gchar *)lsq_mime_info_get_name(archive->mime_info), "application/x-zip") ||
+ !g_strcasecmp((gchar *)lsq_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
+ return 1;
+ }
+ return 0;
+}
+
+static gint
+lsq_archive_support_zip_remove(LSQArchive *archive, GSList *filenames)
+{
+ if(!LSQ_IS_ARCHIVE_SUPPORT_ZIP(archive->support))
+ {
+ g_critical("Support is not zip");
+ return -1;
+ }
+
+ if(!lsq_archive_support_mime_supported(archive->support, lsq_mime_info_get_name(archive->mime_info)))
+ {
+ return 1;
+ }
+ else
+ {
+ gchar *command = NULL;
+ gchar *files = lsq_concat_filenames(filenames);
+ if(!g_strcasecmp((gchar *)lsq_mime_info_get_name(archive->mime_info), "application/x-zip") ||
+ !g_strcasecmp((gchar *)lsq_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);
+ }
+ }
+ return 0;
+}
+
+static gint
+lsq_archive_support_zip_refresh(LSQArchive *archive)
+{
+ guint i = 0;
+ if(!LSQ_IS_ARCHIVE_SUPPORT_ZIP(archive->support))
+ {
+ g_critical("Support is not Zip");
+ return -1;
+ }
+
+ if(!lsq_archive_support_mime_supported(archive->support, lsq_mime_info_get_name(archive->mime_info)))
+ {
+ return 1;
+ }
+ else
+ {
+ i = LSQ_ARCHIVE_PROP_USER;
+ if(LSQ_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_length) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_UINT64, _("Size"));
+ i++;
+ }
+ if(LSQ_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_method) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_STRING,_("Method"));
+ i++;
+ }
+ if(LSQ_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_size) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_UINT64, _("Compressed Size"));
+ i++;
+ }
+ if(LSQ_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_ratio) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_STRING, _("Ratio"));
+ i++;
+ }
+ if(LSQ_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_date) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_STRING, _("Date"));
+ i++;
+ }
+ if(LSQ_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_time) {
+ lsq_archive_set_property_type(archive, i, G_TYPE_STRING, _("Time"));
+ i++;
+ }
+ if(LSQ_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_crc_32) {
+ lsq_archive_set_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);
+ }
+ return 0;
+}
+
+gboolean
+lsq_archive_support_zip_refresh_parse_output(GIOChannel *ioc, GIOCondition cond, gpointer data)
+{
+ GIOStatus status = G_IO_STATUS_NORMAL;
+ LSQArchive *archive = data;
+ gchar *line = NULL;
+ LSQEntry *entry;
+
+ guint64 size;
+ guint64 length;
+ gpointer props[8];
+ gint n = 0, a = 0, i = 0, o = 0;
+ gchar *temp_filename = NULL;
+ gint linesize = 0;
+
+ if(!LSQ_IS_ARCHIVE(archive))
+ return FALSE;
+
+
+ if(cond & (G_IO_PRI | G_IO_IN))
+ {
+ for(o = 0; o < 500; o++)
+ {
+ i = 0;
+
+ status = g_io_channel_read_line(ioc, &line, NULL,NULL,NULL);
+ if (line == NULL)
+ break;
+ /* length, method , size, ratio, date, time, crc-32, filename*/
+ linesize = strlen(line);
+
+ for(n=0; n < linesize && line[n] == ' '; n++);
+ a = n;
+ for(; n < linesize && line[n] != ' '; n++);
+
+ if(LSQ_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_length)
+ {
+ line[n]='\0';
+ length = g_ascii_strtoull(line + a, NULL, 0);
+ props[i] = &length;
+ i++;
+ }
+ n++;
+
+ for(; n < linesize && line[n] == ' '; n++);
+ a = n;
+ for(; n < linesize && line[n] != ' '; n++);
+
+ if(LSQ_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_method)
+ {
+ line[n] = '\0';
+ props[i] = line + a;
+ i++;
+ }
+ n++;
+
+ for(; n < linesize && line[n] == ' '; n++);
+ a = n;
+ for(; n < linesize && line[n] != ' '; n++);
+
+ if(LSQ_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_size)
+ {
+ line[n]='\0';
+ size = g_ascii_strtoull(line + a, NULL, 0);
+ props[i] = &size;
+ i++;
+ }
+ n++;
+
+ for(; n < linesize && line[n] == ' '; n++);
+ a = n;
+ for(; n < linesize && line[n] != ' '; n++);
+
+ if(LSQ_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_ratio)
+ {
+ line[n] = '\0';
+ props[i] = line + a;
+ i++;
+ }
+ n++;
+
+ for(; n < linesize && line[n] == ' '; n++);
+ a = n;
+ for(; n < linesize && line[n] != ' '; n++);
+
+ if(LSQ_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_date)
+ {
+ line[n] = '\0';
+ props[i] = line + a;
+ i++;
+ }
+ n++;
+
+ for(; n < linesize && line[n] == ' '; n++);
+ a = n;
+ for(; n < linesize && line[n] != ' '; n++);
+
+ if(LSQ_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_time)
+ {
+ line[n] = '\0';
+ props[i] = line + a;
+ i++;
+ }
+ n++;
+
+ for(; n < linesize && line[n] == ' '; n++);
+ a = n;
+ for(; n < linesize && line[n] != ' '; n++);
+
+ if(LSQ_ARCHIVE_SUPPORT_ZIP(archive->support)->_view_crc_32)
+ {
+ line[n] = '\0';
+ props[i] = line + a;
+ i++;
+ }
+ n++;
+
+ for(; n < linesize && line[n] == ' '; n++);
+ temp_filename = g_strchomp(line+n);
+
+ entry = lsq_archive_add_file(archive, temp_filename);
+ lsq_archive_iter_set_propsv(archive, entry, (gconstpointer*)props);
+ g_free(line);
+ }
+ }
+ if(cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL) )
+ {
+ g_io_channel_shutdown ( ioc,TRUE,NULL );
+ g_io_channel_unref (ioc);
+ lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_IDLE);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static void
+lsq_archive_support_zip_integrity_test(LSQArchiveSupport *support, LSQArchive *archive, gpointer user_data)
+{
+#ifdef DEBUG
+ g_debug("Custom action %s called", __FUNCTION__);
+#endif /* DEBUG */
+}
+
+static void
+lsq_archive_support_zip_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+ switch(prop_id)
+ {
+ case LSQ_ARCHIVE_SUPPORT_ZIP_EXTRACT_OVERWRITE:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_ZIP(object)->_extr_overwrite);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_ZIP_PASSWORD:
+ g_value_set_string (value, LSQ_ARCHIVE_SUPPORT_ZIP(object)->_extr_password);
+ break;
+
+ case LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_SIZE:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_ZIP(object)->_view_size);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_DATE:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_ZIP(object)->_view_date);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_TIME:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_ZIP(object)->_view_time);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_RATIO:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_ZIP(object)->_view_ratio);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_LENGTH:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_ZIP(object)->_view_length);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_METHOD:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_ZIP(object)->_view_method);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_CRC_32:
+ g_value_set_boolean(value, LSQ_ARCHIVE_SUPPORT_ZIP(object)->_view_crc_32);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,prop_id,pspec);
+ break;
+ }
+}
+
+static void
+lsq_archive_support_zip_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+ switch(prop_id)
+ {
+ case LSQ_ARCHIVE_SUPPORT_ZIP_EXTRACT_OVERWRITE:
+ LSQ_ARCHIVE_SUPPORT_ZIP(object)->_extr_overwrite = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_ZIP_PASSWORD:
+ LSQ_ARCHIVE_SUPPORT_ZIP(object)->_extr_password = (gchar *)g_value_get_string(value);
+ break;
+
+ case LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_SIZE:
+ LSQ_ARCHIVE_SUPPORT_ZIP(object)->_view_size = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_TIME:
+ LSQ_ARCHIVE_SUPPORT_ZIP(object)->_view_time = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_DATE:
+ LSQ_ARCHIVE_SUPPORT_ZIP(object)->_view_date = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_RATIO:
+ LSQ_ARCHIVE_SUPPORT_ZIP(object)->_view_ratio = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_LENGTH:
+ LSQ_ARCHIVE_SUPPORT_ZIP(object)->_view_length = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_METHOD:
+ LSQ_ARCHIVE_SUPPORT_ZIP(object)->_view_method = g_value_get_boolean(value);
+ break;
+ case LSQ_ARCHIVE_SUPPORT_ZIP_VIEW_CRC_32:
+ LSQ_ARCHIVE_SUPPORT_ZIP(object)->_view_crc_32 = g_value_get_boolean(value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object,prop_id,pspec);
+ break;
+ }
+}
Deleted: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-zip.h
Copied: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-zip.h (from rev 24005, xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support-zip.h)
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-zip.h (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support-zip.h 2006-11-30 09:08:26 UTC (rev 24010)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2006 Stephan Arts <psyBSD at gmail.com>
+ *
+ * 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 __LIBXARCHIVER_ARCHIVE_SUPPORT_ZIP_H__
+#define __LIBXARCHIVER_ARCHIVE_SUPPORT_ZIP_H__
+
+G_BEGIN_DECLS
+
+
+#define LSQ_TYPE_ARCHIVE_SUPPORT_ZIP lsq_archive_support_zip_get_type()
+
+#define LSQ_ARCHIVE_SUPPORT_ZIP(obj) ( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ LSQ_TYPE_ARCHIVE_SUPPORT_ZIP, \
+ LSQArchiveSupportZip))
+
+#define LSQ_IS_ARCHIVE_SUPPORT_ZIP(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ LSQ_TYPE_ARCHIVE_SUPPORT_ZIP))
+
+#define LSQ_ARCHIVE_SUPPORT_ZIP_CLASS(klass) ( \
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ LSQ_TYPE_ARCHIVE_SUPPORT_ZIP, \
+ LSQArchiveSupportZipClass))
+
+#define LSQ_IS_ARCHIVE_SUPPORT_ZIP_CLASS(klass) ( \
+ G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ LSQ_TYPE_ARCHIVE_SUPPORT_ZIP))
+
+typedef struct _LSQArchiveSupportZip LSQArchiveSupportZip;
+
+struct _LSQArchiveSupportZip
+{
+ LSQArchiveSupport parent;
+ gboolean _extr_overwrite;
+ gchar *_extr_password;
+
+ gboolean _view_size;
+ gboolean _view_time;
+ gboolean _view_date;
+ gboolean _view_ratio;
+ gboolean _view_length;
+ gboolean _view_method;
+ gboolean _view_crc_32;
+};
+
+typedef struct _LSQArchiveSupportZipClass LSQArchiveSupportZipClass;
+
+struct _LSQArchiveSupportZipClass
+{
+ LSQArchiveSupportClass parent;
+};
+
+GType lsq_archive_support_zip_get_type(void);
+LSQArchiveSupport * lsq_archive_support_zip_new();
+
+G_END_DECLS
+
+#endif /* __LIBXARCHIVER_ARCHIVE_SUPPORT_ZIP_H__ */
Deleted: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support.c
Copied: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support.c (from rev 24005, xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.c)
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support.c (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support.c 2006-11-30 09:08:26 UTC (rev 24010)
@@ -0,0 +1,329 @@
+/*
+ * Copyright (c) 2006 Stephan Arts <psyBSD at gmail.com>
+ *
+ * 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 <string.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <glib-object.h>
+
+#include "mime.h"
+#include "archive.h"
+#include "archive-support.h"
+
+#include "internals.h"
+
+void
+lsq_archive_support_init(LSQArchiveSupport *support);
+void
+lsq_archive_support_class_init(LSQArchiveSupportClass *supportclass);
+
+/*
+ *
+ */
+GType
+lsq_archive_support_get_type ()
+{
+ static GType lsq_archive_support_type = 0;
+
+ if (!lsq_archive_support_type)
+ {
+ static const GTypeInfo lsq_archive_support_info =
+ {
+ sizeof (LSQArchiveSupportClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) lsq_archive_support_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (LSQArchiveSupport),
+ 0,
+ (GInstanceInitFunc) lsq_archive_support_init,
+ };
+
+ lsq_archive_support_type = g_type_register_static (G_TYPE_OBJECT, "LSQArchiveSupport", &lsq_archive_support_info, 0);
+ }
+ return lsq_archive_support_type;
+}
+
+/*
+ *
+ */
+void
+lsq_archive_support_init(LSQArchiveSupport *support)
+{
+ support->add = NULL;
+ support->extract = NULL;
+ support->remove = NULL;
+ support->refresh = NULL;
+ support->custom_action = NULL;
+}
+
+/*
+ *
+ */
+void
+lsq_archive_support_class_init(LSQArchiveSupportClass *supportclass)
+{
+ /*
+ GObjectClass *gobject_class = G_OBJECT_CLASS (supportclass);
+ LSQArchiveSupportClass *klass = LSQ_ARCHIVE_SUPPORT_CLASS (supportclass);
+ */
+}
+
+/*
+ *
+ */
+LSQArchiveSupport*
+lsq_archive_support_new()
+{
+ LSQArchiveSupport*support;
+
+ support = g_object_new(LSQ_TYPE_ARCHIVE_SUPPORT, NULL);
+
+ return support;
+}
+
+/*
+ *
+ */
+void
+lsq_archive_support_add_mime(LSQArchiveSupport *support, gchar *mime)
+{
+ support->mime = g_slist_prepend(support->mime, mime);
+}
+
+/*
+ *
+ */
+gboolean
+lsq_archive_support_mime_supported(LSQArchiveSupport *support, const gchar *mime)
+{
+ GSList *result = g_slist_find_custom(support->mime, mime, lsq_archive_support_lookup_mime);
+ if(!result)
+ return FALSE;
+ if(!result->data)
+ return FALSE;
+ return TRUE;
+}
+
+/*
+ *
+ */
+gboolean
+lsq_register_support(LSQArchiveSupport *support)
+{
+ if(!LSQ_IS_ARCHIVE_SUPPORT(support))
+ return FALSE;
+
+ lsq_archive_support_list = g_slist_prepend(lsq_archive_support_list, support);
+ g_object_ref(support);
+
+ return TRUE;
+}
+
+/*
+ *
+ */
+LSQArchiveSupport *
+lsq_get_support_for_mime(const gchar *mime)
+{
+ return lsq_get_support_for_mime_from_slist(lsq_archive_support_list, mime);
+}
+
+/*
+ *
+ */
+LSQArchiveSupport *
+lsq_get_support_for_mime_from_slist(GSList *list, const gchar *mime)
+{
+ GSList *result = g_slist_find_custom(list, mime, lsq_archive_support_lookup_support);
+ if(result)
+ return result->data;
+ return NULL;
+}
+
+/*
+ *
+ */
+gint
+lsq_archive_support_lookup_mime(gconstpointer support_mime, gconstpointer mime)
+{
+ return strcmp((gchar *)support_mime, (gchar *)mime);
+}
+
+/*
+ *
+ */
+gint
+lsq_archive_support_lookup_support(gconstpointer support, gconstpointer mime)
+{
+ if(lsq_archive_support_mime_supported(LSQ_ARCHIVE_SUPPORT(support), (gchar *)mime))
+ return 0;
+ else
+ return 1;
+}
+
+gint
+lsq_archive_support_add(LSQArchiveSupport *support, LSQArchive *archive, GSList *files)
+{
+ if(support->add)
+ {
+ lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_ADD);
+ archive->support = support;
+ return support->add(archive, files);
+ }
+ else
+ g_critical("ADD NOT IMPLEMENTED BY SUPPORT OBJECT '%s'", support->id);
+ return -1;
+}
+
+gint
+lsq_archive_support_extract(LSQArchiveSupport *support, LSQArchive *archive, gchar *dest_path, GSList *files)
+{
+ if(support->extract)
+ {
+ lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_EXTRACT);
+ archive->support = support;
+ return support->extract(archive, dest_path, files);
+ }
+ else
+ g_critical("EXTRACT NOT IMPLEMENTED BY SUPPORT OBJECT '%s'", support->id);
+ return -1;
+}
+
+gint
+lsq_archive_support_remove(LSQArchiveSupport *support, LSQArchive *archive, GSList *files)
+{
+ if(support->remove)
+ {
+ lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_REMOVE);
+ archive->support = support;
+ return support->remove(archive, files);
+ }
+ else
+ g_critical("REMOVE NOT IMPLEMENTED BY SUPPORT OBJECT '%s'", support->id);
+ return -1;
+}
+
+gint
+lsq_archive_support_refresh(LSQArchiveSupport *support, LSQArchive *archive)
+{
+ if(support->refresh)
+ {
+ lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_REFRESH);
+ archive->support = support;
+ return support->refresh(archive);
+ }
+ else
+ g_critical("VIEW NOT IMPLEMENTED BY SUPPORT OBJECT '%s'", support->id);
+ return -1;
+}
+
+GSList *
+lsq_archive_support_list_properties(LSQArchiveSupport *support, gchar *prefix)
+{
+ guint _nprops, i;
+ GObjectClass *support_class = G_OBJECT_GET_CLASS(support);
+ GParamSpec **pspecs = g_object_class_list_properties(support_class, &_nprops);
+ GSList *pspec_list = NULL;
+
+/* Reverse the array, because the list gets prepended
+ * Otherwise the option-list gets reversed
+ */
+ for(i = _nprops; i > 0; i--)
+ {
+ if(!strncmp(prefix, g_param_spec_get_name(pspecs[i-1]), strlen(prefix)))
+ {
+ pspec_list = g_slist_prepend(pspec_list, pspecs[i-1]);
+ }
+ }
+ return pspec_list;
+}
+
+void
+lsq_archive_support_install_action(LSQArchiveSupport *support, LSQCustomAction *action)
+{
+ support->custom_action = g_slist_append(support->custom_action, action);
+}
+
+LSQCustomAction*
+lsq_archive_support_find_action(LSQArchiveSupport *support, const gchar *name)
+{
+ GSList *actions = support->custom_action;
+ while(actions)
+ {
+ if(strcmp(((LSQCustomAction*)actions->data)->name, name) == 0)
+ return (LSQCustomAction*)actions->data;
+ actions = actions->next;
+ }
+ return NULL;
+}
+
+LSQCustomAction**
+lsq_archive_support_list_actions(LSQArchiveSupport *support, guint *n_actions)
+{
+ LSQCustomAction** list;
+ guint i = 0;
+ GSList *actions = support->custom_action;
+ (*n_actions) = g_slist_length(actions);
+ list = g_new(LSQCustomAction*, *n_actions);
+ while(actions)
+ {
+ list[i++] = (LSQCustomAction*)actions->data;
+ actions = actions->next;
+ }
+ return list;
+}
+
+LSQCustomAction*
+lsq_custom_action_new(const gchar *name, const gchar *nick, const gchar *blurb, const gchar *icon, LSQCustomActionFunc func, LSQArchiveSupport *support, gpointer user_data)
+{
+ LSQCustomAction *action = g_new(LSQCustomAction, 1);
+ action->name = g_strdup(name);
+ action->nick = g_strdup(nick);
+ action->blurb = g_strdup(blurb);
+ action->icon = g_strdup(icon);
+ action->func = func;
+ action->support = support;
+ action->user_data = user_data;
+ return action;
+}
+
+const gchar*
+lsq_custom_action_get_name(LSQCustomAction *action)
+{
+ return action->name;
+}
+
+const gchar*
+lsq_custom_action_get_nick(LSQCustomAction *action)
+{
+ return action->nick;
+}
+
+const gchar*
+lsq_custom_action_get_blurb(LSQCustomAction *action)
+{
+ return action->blurb;
+}
+
+void
+lsq_custom_action_execute(LSQCustomAction *action, LSQArchive *archive)
+{
+ action->func(action->support, archive, action->user_data);
+}
Deleted: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support.h
Copied: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support.h (from rev 24005, xarchiver/branches/xarchiver-psybsd/libxarchiver/archive-support.h)
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support.h (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/libsqueeze/archive-support.h 2006-11-30 09:08:26 UTC (rev 24010)
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2006 Stephan Arts <psyBSD at gmail.com>
+ *
+ * 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 __LIBXARCHIVER_ARCHIVE_SUPPORT_H__
+#define __LIBXARCHIVER_ARCHIVE_SUPPORT_H__
+
+G_BEGIN_DECLS
+
+
+#define LSQ_TYPE_ARCHIVE_SUPPORT lsq_archive_support_get_type()
+
+#define LSQ_ARCHIVE_SUPPORT(obj) ( \
+ G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ LSQ_TYPE_ARCHIVE_SUPPORT, \
+ LSQArchiveSupport))
+
+#define LSQ_IS_ARCHIVE_SUPPORT(obj) ( \
+ G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ LSQ_TYPE_ARCHIVE_SUPPORT))
+
+#define LSQ_ARCHIVE_SUPPORT_CLASS(klass) ( \
+ G_TYPE_CHECK_CLASS_CAST ((klass), \
+ LSQ_TYPE_ARCHIVE_SUPPORT, \
+ LSQArchiveSupportClass))
+
+#define LSQ_IS_ARCHIVE_SUPPORT_CLASS(klass) ( \
+ G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ LSQ_TYPE_ARCHIVE_SUPPORT))
+
+typedef struct _LSQCustomAction LSQCustomAction;
+typedef struct _LSQArchiveSupport LSQArchiveSupport;
+
+typedef void (*LSQCustomActionFunc) (LSQArchiveSupport *support, LSQArchive *, gpointer user_data);
+
+struct _LSQCustomAction
+{
+ gchar *name;
+ gchar *nick;
+ gchar *blurb;
+ gchar *icon;
+ LSQCustomActionFunc func;
+ LSQArchiveSupport *support;
+ gpointer user_data;
+};
+
+struct _LSQArchiveSupport
+{
+ GObject parent;
+ gchar *id;
+ GSList *mime;
+ GSList *custom_action;
+/*
+ * The following functions should _NOT_ be called directly.
+ *
+ * lsq_archive_support_add()
+ * lsq_archive_support_extract()
+ * lsq_archive_support_remove()
+ * lsq_archive_support_refresh()
+ *
+ * should be called instead.
+ */
+ gint (*add)(LSQArchive *archive, GSList *files);
+ gint (*extract)(LSQArchive *archive, gchar *dest_path, GSList *files);
+ gint (*remove)(LSQArchive *archive, GSList *files);
+ gint (*refresh)(LSQArchive *archive);
+};
+
+typedef struct _LSQArchiveSupportClass LSQArchiveSupportClass;
+
+struct _LSQArchiveSupportClass
+{
+ GObjectClass parent;
+};
+
+GType lsq_archive_support_get_type(void);
+LSQArchiveSupport * lsq_archive_support_new();
+void lsq_archive_support_add_mime(LSQArchiveSupport *support, gchar *mime);
+gboolean lsq_archive_support_mime_supported(LSQArchiveSupport *,const gchar *mime);
+
+gboolean lsq_register_support(LSQArchiveSupport *);
+LSQArchiveSupport * lsq_get_support_for_mime(const gchar *mime);
+LSQArchiveSupport * lsq_get_support_for_mime_from_slist(GSList *list, const gchar *mime);
+
+gint lsq_archive_support_lookup_mime(gconstpointer support_mime, gconstpointer mime);
+gint lsq_archive_support_lookup_support(gconstpointer support, gconstpointer mime);
+
+gint lsq_archive_support_add(LSQArchiveSupport *, LSQArchive *, GSList *);
+gint lsq_archive_support_extract(LSQArchiveSupport *, LSQArchive *, gchar *, GSList *);
+gint lsq_archive_support_remove(LSQArchiveSupport *, LSQArchive *, GSList *);
+gint lsq_archive_support_refresh(LSQArchiveSupport *, LSQArchive *);
+
+GSList * lsq_archive_support_list_properties(LSQArchiveSupport *, gchar *);
+
+void lsq_archive_support_install_action(LSQArchiveSupport *, LSQCustomAction *);
+LSQCustomAction* lsq_archive_support_find_action(LSQArchiveSupport *, const gchar *name);
+LSQCustomAction** lsq_archive_support_list_actions(LSQArchiveSupport *, guint *n_actions);
+
+LSQCustomAction* lsq_custom_action_new(const gchar *name,
+ const gchar *nick,
+ const gchar *blurb,
+ const gchar *icon,
+ LSQCustomActionFunc func,
+ LSQArchiveSupport *support,
+ gpointer user_data);
+const gchar* lsq_custom_action_get_name(LSQCustomAction*);
+const gchar* lsq_custom_action_get_nick(LSQCustomAction*);
+const gchar* lsq_custom_action_get_blurb(LSQCustomAction*);
+const gchar* lsq_custom_action_get_icon_name(LSQCustomAction*);
+void lsq_custom_action_execute(LSQCustomAction*, LSQArchive *);
+
+G_END_DECLS
+
+#endif /* __LIBXARCHIVER_ARCHIVE_SUPPORT_H__ */
Deleted: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive.c
Copied: xarchiver/branches/xarchiver-psybsd/libsqueeze/archive.c (from rev 24005, xarchiver/branches/xarchiver-psybsd/libxarchiver/archive.c)
===================================================================
--- xarchiver/branches/xarchiver-psybsd/libsqueeze/archive.c (rev 0)
+++ xarchiver/branches/xarchiver-psybsd/libsqueeze/archive.c 2006-11-30 09:08:26 UTC (rev 24010)
@@ -0,0 +1,1316 @@
+/* Copyright (c) 2006 Stephan Arts <psyBSD at gmail.com>
+ *
+ * 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 <gettext.h>
+
+#include "mime.h"
+
+#include "archive.h"
+#include "archive-support.h"
+#include "slist.h"
+
+#include "internals.h"
+
+#ifndef LSQ_ENTRY_CHILD_BUFFER_SIZE
+#define LSQ_ENTRY_CHILD_BUFFER_SIZE 500
+#endif
+
+#ifndef LSQ_MIME_DIRECTORY
+#define LSQ_MIME_DIRECTORY "inode/directory"
+#endif
+
+#ifdef LSQ_THREADSAFE
+#define LSQ_ARCHIVE_READ_LOCK(lock) g_static_rw_lock_reader_lock(lock)
+#define LSQ_ARCHIVE_READ_UNLOCK(lock) g_static_rw_lock_reader_unlock(lock)
+#define LSQ_ARCHIVE_WRITE_LOCK(lock) g_static_rw_lock_writer_lock(lock)
+#define LSQ_ARCHIVE_WRITE_UNLOCK(lock) g_static_rw_lock_writer_unlock(lock)
+#else
+#define LSQ_ARCHIVE_READ_LOCK(lock)
+#define LSQ_ARCHIVE_READ_UNLOCK(lock)
+#define LSQ_ARCHIVE_WRITE_LOCK(lock)
+#define LSQ_ARCHIVE_WRITE_UNLOCK(lock)
+#endif
+
+struct _LSQEntry
+{
+ gchar *filename;
+ LSQMimeInfo *mime_info;
+ gpointer props;
+ LSQEntry **children;
+ LSQSList *buffer;
+};
+
+
+static void
+lsq_archive_class_init(LSQArchiveClass *archive_class);
+
+static void
+lsq_archive_init(LSQArchive *archive);
+
+static void
+lsq_archive_finalize(GObject *object);
+
+static GType *
+lsq_archive_get_property_types(LSQArchive *archive, guint size);
+
+static gchar **
+lsq_archive_get_property_names(LSQArchive *archive, guint size);
+
+static LSQEntry *
+lsq_entry_new(LSQArchive *, const gchar *);
+
+static void
+lsq_archive_entry_free(LSQArchive *, LSQEntry *);
+
+static LSQEntry *
+lsq_entry_get_child(const LSQEntry *entry, const gchar *filename);
+
+static void
+lsq_archive_entry_add_child(LSQArchive *, LSQEntry *, LSQEntry *);
+
+static void
+lsq_archive_entry_flush_buffer(LSQArchive *, LSQEntry *);
+
+static gpointer
+lsq_archive_entry_get_props(LSQArchive *, LSQEntry *);
+
+static const gchar *
+lsq_archive_iter_get_prop_str(const LSQArchive *, const LSQArchiveIter *, guint);
+static guint
+lsq_archive_iter_get_prop_uint(const LSQArchive *, const LSQArchiveIter *, guint);
+static guint64
+lsq_archive_iter_get_prop_uint64(const LSQArchive *, const LSQArchiveIter *, guint);
+
+static const gchar *
+lsq_archive_iter_get_filename(const LSQArchive *, const LSQArchiveIter *);
+static const gchar *
+lsq_archive_iter_get_mimetype(const LSQArchive *, const LSQArchiveIter *);
+
+static gint
+lsq_entry_filename_compare(LSQEntry *, LSQEntry *);
+
+gint
+lsq_archive_sort_entry_buffer(LSQEntry *entry1, LSQEntry *entry2)
+{
+ return strcmp(entry1->filename, entry2->filename);
+}
+
+static gint lsq_archive_signals[3];
+
+GType
+lsq_archive_get_type ()
+{
+ static GType lsq_archive_type = 0;
+
+ if (!lsq_archive_type)
+ {
+ static const GTypeInfo lsq_archive_info =
+ {
+ sizeof (LSQArchiveClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) lsq_archive_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (LSQArchive),
+ 0,
+ (GInstanceInitFunc) lsq_archive_init,
+ NULL
+ };
+
+ lsq_archive_type = g_type_register_static (G_TYPE_OBJECT, "LSQArchive", &lsq_archive_info, 0);
+ }
+ return lsq_archive_type;
+}
+
+static void
+lsq_archive_class_init(LSQArchiveClass *archive_class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(archive_class);
+
+ object_class->finalize = lsq_archive_finalize;
+
+ lsq_archive_signals[0] = g_signal_new("lsq_status_changed",
+ G_TYPE_FROM_CLASS(archive_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0,
+ NULL);
+
+ lsq_archive_signals[1] = g_signal_new("lsq_refreshed",
+ G_TYPE_FROM_CLASS(archive_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0,
+ NULL);
+
+ lsq_archive_signals[2] = g_signal_new("lsq_path_changed",
+ G_TYPE_FROM_CLASS(archive_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_STRING,
+ NULL);
+}
+
+static void
+lsq_archive_init(LSQArchive *archive)
+{
+ archive->root_entry = g_new0(LSQEntry, 1);
+ archive->status = LSQ_ARCHIVESTATUS_INIT;
+ archive->old_status = LSQ_ARCHIVESTATUS_INIT;
+#ifdef LSQ_THREADSAFE
+ g_static_rw_lock_init(&archive->rw_lock);
+#endif /* LSQ_THREADSAFE */
+}
+
+/** static void
+ * lsq_archive_finalize(GObject *object)
+ *
+ *
+ */
+static void
+lsq_archive_finalize(GObject *object)
+{
+ g_return_if_fail(LSQ_IS_ARCHIVE(object));
+ LSQArchive *archive = (LSQArchive *)(object);
+ if(archive->path)
+ g_free(archive->path);
+ 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;
+ }
+}
+
+LSQArchive *
+lsq_archive_new(gchar *path, const gchar *mime)
+{
+ LSQArchive *archive;
+
+ archive = g_object_new(lsq_archive_get_type(), NULL);
+
+ if(path)
+ archive->path = g_strdup(path);
+ else
+ archive->path = NULL;
+
+ if(!mime)
+ archive->mime_info = lsq_mime_get_mime_info_for_file(archive->path);
+ else
+ archive->mime_info = lsq_mime_get_mime_info(mime);
+#ifdef DEBUG
+ g_debug("Mime-type: %s", lsq_mime_info_get_name(archive->mime_info));
+#endif
+ if(!lsq_get_support_for_mime(lsq_mime_info_get_name(archive->mime_info)))
+ {
+ g_object_unref(archive);
+ archive = NULL;
+ }
+ return archive;
+}
+
+void
+lsq_archive_set_status(LSQArchive *archive, LSQArchiveStatus status)
+{
+ LSQ_ARCHIVE_WRITE_LOCK(&archive->rw_lock);
+ gchar **path = NULL;
+ gchar *_path = NULL;
+
+ 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[0], 0, archive);
+ if((archive->old_status == LSQ_ARCHIVESTATUS_REFRESH) && (archive->status == LSQ_ARCHIVESTATUS_IDLE))
+ g_signal_emit(G_OBJECT(archive), lsq_archive_signals[1], 0, archive);
+ if((archive->old_status == LSQ_ARCHIVESTATUS_REMOVE) && (archive->files))
+ {
+ path = g_strsplit(archive->files, " ", 2);
+ _path = g_path_get_dirname(path[0]);
+ g_signal_emit(G_OBJECT(archive), lsq_archive_signals[2], 0, archive, _path);
+ g_strfreev(path);
+ g_free(_path);
+ }
+ }
+ }
+ LSQ_ARCHIVE_WRITE_UNLOCK(&archive->rw_lock);
+}
+
+gint
+lsq_stop_archive_child( LSQArchive *archive )
+{
+ lsq_archive_set_status(archive, LSQ_ARCHIVESTATUS_USERBREAK);
+ return 0;
+}
+
+/********************
+ * LSQArchive stuff *
+ ********************/
+
+LSQArchiveIter *
+lsq_archive_add_file(LSQArchive *archive, const gchar *path)
+{
+ LSQ_ARCHIVE_WRITE_LOCK(&archive->rw_lock);
+ guint i = 0;
+ gchar **path_items = g_strsplit_set(path, "/\n", -1);
+ LSQArchiveIter *parent = (LSQArchiveIter*)archive->root_entry;
+ LSQArchiveIter *child = NULL;
+ gchar *basename;
+
+ while(path_items[i])
+ {
+ basename = g_strconcat(path_items[i], path_items[i+1]?"/":NULL, NULL);
+
+ if(basename[0] != '\0')
+ {
+ child = lsq_archive_iter_get_child(archive, parent, basename);
+
+ if(!child)
+ child = lsq_archive_iter_add_child(archive, parent, basename);
+ }
+
+ g_free(basename);
+
+ parent = child;
+ i++;
+ }
+ LSQ_ARCHIVE_WRITE_UNLOCK(&archive->rw_lo