file-roller r2326 - in trunk: . data nautilus src
- From: paobac svn gnome org
- To: svn-commits-list gnome org
- Subject: file-roller r2326 - in trunk: . data nautilus src
- Date: Thu, 19 Jun 2008 15:10:12 +0000 (UTC)
Author: paobac
Date: Thu Jun 19 15:10:12 2008
New Revision: 2326
URL: http://svn.gnome.org/viewvc/file-roller?rev=2326&view=rev
Log:
2008-06-19 Paolo Bacchilega <paobac svn gnome org>
* configure.in: bumped version number to differentiate
current development version from the latest released version.
* src/fr-command-7z.h:
* src/fr-command-7z.c (list__process_line, fr_command_7z_list):
Use the technical list, because we need to know whether a file is
encrypted or not.
2008-06-19 Paolo Bacchilega <paobac svn gnome org>
* src/main.c:
* src/fr-command-7z.c:
* src/fr-command-zip.c:
* data/file-roller.desktop.in.in:
renamed MS-DOS executable mime-type from
application/x-ms-dos-executable to application/x-executable
* src/fr-command-zip.c: added support for .cbz files
* src/fr-command-rar.c: added support for .cbr files.
* src/fr-command-cpio.c: Fixed list error when the file type is 'c'.
* src/fr-command-7z.c: Added support for creating self-extracting
zip archives. Added support for reading/writing zip, cbr, cbz archives.
Added support for reading cabinet, arj, rar and iso archives.
Fixes bug #343201 â Use p7zip for RAR archives?
Fixes bug #529395 â file-roller will not open 256 AES zip files
Fixes bug #515194 â PK 4.5 Zip files
Fixes bug #519046 â add x-cbr and x-cbz support
2008-06-19 Paolo Bacchilega <paobac svn gnome org>
* src/main.h:
* src/main.c:
Removed duplicated data. Simplified the way to register commands.
Use the functions fr_command_get_mime_types and
fr_command_get_capabilities to compute the supported mime_types and the
relative capabilities.
* src/fr-command-zoo.c:
* src/fr-command-zip.c:
* src/fr-command-unstuff.c:
* src/fr-command-tar.c:
* src/fr-command-rpm.c:
* src/fr-command-rar.c:
* src/fr-command-lha.c:
* src/fr-command-iso.c:
* src/fr-command-cpio.c:
* src/fr-command-cfile.c:
* src/fr-command-arj.c:
* src/fr-command-ar.c:
* src/fr-command-ace.c:
* src/fr-command-7z.c:
* src/fr-command.h:
* src/fr-command.c:
added two new virtual functions: get_mime_types, get_capabilities.
* src/file-utils.c (is_mime_type): rename type to mime_type.
* nautilus/nautilus-fileroller.c: updated the mime_type list.
* data/file-roller.desktop.in.in: updated the MimeType field.
Modified:
trunk/ChangeLog
trunk/TODO
trunk/configure.in
trunk/data/file-roller.desktop.in.in
trunk/nautilus/nautilus-fileroller.c
trunk/src/file-utils.c
trunk/src/fr-command-7z.c
trunk/src/fr-command-7z.h
trunk/src/fr-command-ace.c
trunk/src/fr-command-ar.c
trunk/src/fr-command-arj.c
trunk/src/fr-command-cfile.c
trunk/src/fr-command-cpio.c
trunk/src/fr-command-iso.c
trunk/src/fr-command-lha.c
trunk/src/fr-command-rar.c
trunk/src/fr-command-rpm.c
trunk/src/fr-command-tar.c
trunk/src/fr-command-unstuff.c
trunk/src/fr-command-zip.c
trunk/src/fr-command-zoo.c
trunk/src/fr-command.c
trunk/src/fr-command.h
trunk/src/fr-process.c
trunk/src/main.c
trunk/src/main.h
Modified: trunk/TODO
==============================================================================
--- trunk/TODO (original)
+++ trunk/TODO Thu Jun 19 15:10:12 2008
@@ -3,28 +3,28 @@
[ ] optimization of the add_folder operation: if the command supports all the
requested options add the folder directly instead of reading the folder
and adding the content in chunks.
-
-[ ] #343201 â Use p7zip for RAR archives?
-
-[ ] #529395 â file-roller will not open 256 AES zip files
- --> use 7z for zip archives (see #515194 â PK 4.5 Zip files).
[ ] #525274 â File roller seems to be unable to create zipfiles without .zip extension
-[ ] #520844 â File roller not cancelling compression
-
[ ] #512825 â Fails extraction of files within directories named '.'
[ ] #508737 â can't add file to the archive if archive name is without extension
-[ ] #519046 â add x-cbr and x-cbz support
-
[ ] #521324 â ALZ archive support
[ ] #482560 â totem-like plugin installer for file-roller
== Done ==
+[x] #343201 â Use p7zip for RAR archives?
+
+[x] #529395 â file-roller will not open 256 AES zip files
+ --> use 7z for zip archives (see #515194 â PK 4.5 Zip files).
+
+[x] #520844 â File roller not cancelling compression
+
+[x] #519046 â add x-cbr and x-cbz support
+
[x] implement the tree_view context menu commands.
[x] Add with wildcard.
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Thu Jun 19 15:10:12 2008
@@ -2,7 +2,7 @@
AC_PREREQ(2.52)
-AC_INIT(file-roller, 2.23.3)
+AC_INIT(file-roller, 2.23.4)
AC_CONFIG_SRCDIR(src/main.c)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AM_CONFIG_HEADER(config.h)
Modified: trunk/data/file-roller.desktop.in.in
==============================================================================
--- trunk/data/file-roller.desktop.in.in (original)
+++ trunk/data/file-roller.desktop.in.in Thu Jun 19 15:10:12 2008
@@ -10,7 +10,7 @@
Type=Application
Icon=file-roller
Categories=GTK;GNOME;Utility;
-MimeType=application/x-ace;application/x-ar;application/x-arj;application/x-bzip;application/x-bzip-compressed-tar;application/x-compress;application/x-compressed-tar;application/x-cpio;application/x-deb;application/x-gtar;application/x-gzip;application/x-lha;application/x-lhz;application/x-rar;application/x-rar-compressed;application/x-tar;application/x-zip;application/x-zip-compressed;application/zip;multipart/x-zip;application/x-rpm;application/x-jar;application/x-war;application/x-ear;application/x-java-archive;application/x-lzma;application/x-lzma-compressed-tar;application/x-lzop;application/x-zoo;application/x-cd-image;application/x-7z-compressed;application/x-gzpostscript;
+MimeType=application/x-7z-compressed;application/x-7z-compressed-tar;application/x-ace;application/x-ar;application/x-arj;application/x-bzip;application/x-bzip-compressed-tar;application/x-bzip1;application/x-bzip1-compressed-tar;application/x-cabinet;application/x-cbr;application/x-cbz;application/x-cd-image;application/x-compress;application/x-compressed-tar;application/x-cpio;application/x-deb;application/x-ear;application/x-executable; application/x-gtar;application/x-gzip;application/x-gzpostscript;application/x-jar;application/x-java-archive;application/x-lha;application/x-lhz;application/x-lzma;application/x-lzma-compressed-tar;application/x-lzop;application/x-lzop-compressed-tar;application/x-rar;application/x-rar-compressed;application/x-rpm;application/x-tar;application/x-tarz;application/x-stuffit;application/x-war;application/x-zip;application/x-zip-compressed;application/x-zoo;application/zip;multipart/x-zip;
X-GNOME-DocPath=file-roller/file-roller.xml
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=file-roller
Modified: trunk/nautilus/nautilus-fileroller.c
==============================================================================
--- trunk/nautilus/nautilus-fileroller.c (original)
+++ trunk/nautilus/nautilus-fileroller.c Thu Jun 19 15:10:12 2008
@@ -141,34 +141,48 @@
static char *mime_types[] = {
- "application/x-ar",
+ "application/x-7z-compressed",
+ "application/x-7z-compressed-tar",
+ "application/x-ace",
+ "application/x-ar",
"application/x-arj",
"application/x-bzip",
"application/x-bzip-compressed-tar",
+ "application/x-bzip1",
+ "application/x-bzip1-compressed-tar",
+ "application/x-cabinet",
+ "application/x-cbr",
+ "application/x-cbz",
+ "application/x-cd-image",
"application/x-compress",
- "application/x-compressed-tar",
+ "application/x-compressed-tar",
+ "application/x-cpio",
"application/x-deb",
+ "application/x-ear",
+ "application/x-executable",
"application/x-gtar",
"application/x-gzip",
+ "application/x-gzpostscript",
+ "application/x-jar",
+ "application/x-java-archive",
"application/x-lha",
"application/x-lhz",
- "application/x-rar",
+ "application/x-lzma",
+ "application/x-lzma-compressed-tar",
+ "application/x-lzop",
+ "application/x-lzop-compressed-tar",
+ "application/x-rar",
"application/x-rar-compressed",
- "application/x-tar",
+ "application/x-rpm",
+ "application/x-tar",
+ "application/x-tarz",
+ "application/x-stuffit",
+ "application/x-war",
"application/x-zip",
"application/x-zip-compressed",
+ "application/x-zoo",
"application/zip",
"multipart/x-zip",
- "application/x-rpm",
- "application/x-jar",
- "application/x-java-archive",
- "application/x-lzma",
- "application/x-lzop",
- "application/x-zoo",
- "application/x-cd-image",
- "application/x-7z-compressed",
- "application/x-gzpostscript",
- "application/x-ms-dos-executable",
NULL
};
Modified: trunk/src/file-utils.c
==============================================================================
--- trunk/src/file-utils.c (original)
+++ trunk/src/file-utils.c Thu Jun 19 15:10:12 2008
@@ -676,10 +676,10 @@
gboolean
-is_mime_type (const char *type,
+is_mime_type (const char *mime_type,
const char *pattern)
{
- return (strncasecmp (type, pattern, strlen (pattern)) == 0);
+ return (strncasecmp (mime_type, pattern, strlen (pattern)) == 0);
}
Modified: trunk/src/fr-command-7z.c
==============================================================================
--- trunk/src/fr-command-7z.c (original)
+++ trunk/src/fr-command-7z.c Thu Jun 19 15:10:12 2008
@@ -99,85 +99,89 @@
}
*/
-static int
-str_rfind (const char *str,
- int c)
-{
- char *tmp = strrchr (str, c);
- return (tmp == NULL) ? -1 : (tmp - str);
-}
-
static void
list__process_line (char *line,
gpointer data)
{
- FrCommand *comm = FR_COMMAND (data);
- FrCommand7z *p7z_comm = FR_COMMAND_7Z (comm);
- FileData *fdata;
- char *name_field;
- char **fields;
+ FrCommand *comm = FR_COMMAND (data);
+ FrCommand7z *p7z_comm = FR_COMMAND_7Z (comm);
+ char **fields;
+ FileData *fdata;
g_return_if_fail (line != NULL);
if (! p7z_comm->list_started) {
- if (strncmp (line, "--------", 8) == 0) {
- p7z_comm->name_index = str_rfind (line, ' ') + 1;
+ if (strncmp (line, "--------", 8) == 0)
p7z_comm->list_started = TRUE;
- }
return;
}
- if (strncmp (line, "--------", 8) == 0) {
- p7z_comm->list_started = FALSE;
+ if (strcmp (line, "") == 0) {
+ if (p7z_comm->fdata != NULL) {
+ fdata = p7z_comm->fdata;
+ if (fdata->dir)
+ fdata->name = dir_name_from_path (fdata->full_path);
+ else
+ fdata->name = g_strdup (file_name_from_path (fdata->full_path));
+ fdata->path = remove_level_from_path (fdata->full_path);
+ fr_command_add_file (comm, fdata);
+ p7z_comm->fdata = NULL;
+ }
return;
}
+
+ if (p7z_comm->fdata == NULL)
+ p7z_comm->fdata = file_data_new ();
- fdata = file_data_new ();
-
- fields = split_line (line, 4);
+ fields = g_strsplit (line, " = ", 2);
- if (g_strv_length (fields) < 4) {
+ if (g_strv_length (fields) < 2) {
g_strfreev (fields);
- file_data_free (fdata);
return;
}
- fdata->size = g_ascii_strtoull (fields[3], NULL, 10);
- fdata->modified = mktime_from_string (fields[0], fields[1]);
- fdata->dir = fields[2][0] == 'D';
+ fdata = p7z_comm->fdata;
+
+ if (strcmp (fields[0], "Path") == 0) {
+ fdata->free_original_path = TRUE;
+ fdata->original_path = g_strdup (fields[1]);
+ fdata->full_path = g_strconcat ((fdata->original_path[0] != '/') ? "/" : "",
+ fdata->original_path,
+ (fdata->dir && (fdata->original_path[strlen (fdata->original_path - 1)] != '/')) ? "/" : "",
+ NULL);
+ }
+ else if (strcmp (fields[0], "Folder") == 0) {
+ fdata->dir = (strcmp (fields[1], "+") == 0);
+ }
+ else if (strcmp (fields[0], "Size") == 0) {
+ fdata->size = g_ascii_strtoull (fields[1], NULL, 10);
+ }
+ else if (strcmp (fields[0], "Modified") == 0) {
+ char **modified_fields;
+
+ modified_fields = g_strsplit (fields[1], " ", 2);
+ fdata->modified = mktime_from_string (modified_fields[0], modified_fields[1]);
+ g_strfreev (modified_fields);
+ }
+ else if (strcmp (fields[0], "Encrypted") == 0) {
+ fdata->encrypted = (strcmp (fields[1], "+") == 0);
+ }
+ else if (strcmp (fields[0], "Attributes") == 0) {
+ }
g_strfreev (fields);
-
- name_field = g_strdup (line + p7z_comm->name_index);
- fdata->free_original_path = TRUE;
- fdata->original_path = g_strdup (name_field);
- fdata->full_path = g_strconcat ((fdata->original_path[0] != '/') ? "/" : "",
- fdata->original_path,
- (fdata->dir && (fdata->original_path[strlen (fdata->original_path - 1)] != '/')) ? "/" : "",
- NULL);
- g_free (name_field);
-
- fdata->link = NULL;
-
- if (fdata->dir)
- fdata->name = dir_name_from_path (fdata->full_path);
- else
- fdata->name = g_strdup (file_name_from_path (fdata->full_path));
- fdata->path = remove_level_from_path (fdata->full_path);
-
- fr_command_add_file (comm, fdata);
}
static void
fr_command_7z_begin_command (FrCommand *comm)
{
- if (is_program_in_path ("7za"))
+ if (is_program_in_path ("7z"))
+ fr_process_begin_command (comm->process, "7z");
+ else if (is_program_in_path ("7za"))
fr_process_begin_command (comm->process, "7za");
else if (is_program_in_path ("7zr"))
fr_process_begin_command (comm->process, "7zr");
- else
- fr_process_begin_command (comm->process, "7z");
}
@@ -188,16 +192,8 @@
{
if (always_specify || ((password != NULL) && (*password != 0))) {
char *arg;
- char *e_password;
-
- e_password = escape_str (password, "\"*?[]'`()$!;");
- if (e_password != NULL) {
- arg = g_strconcat ("-p\"", e_password, "\"", NULL);
- g_free (e_password);
- }
- else
- arg = g_strdup ("-p\"\"");
-
+
+ arg = g_strconcat ("-p", password, NULL);
fr_process_add_arg (comm->process, arg);
g_free (arg);
}
@@ -208,17 +204,26 @@
fr_command_7z_list (FrCommand *comm,
const char *password)
{
+ FrCommand7z *p7z_comm = FR_COMMAND_7Z (comm);
+
fr_process_set_out_line_func (FR_COMMAND (comm)->process,
list__process_line,
comm);
fr_command_7z_begin_command (comm);
fr_process_add_arg (comm->process, "l");
+ fr_process_add_arg (comm->process, "-slt");
fr_process_add_arg (comm->process, "-bd");
fr_process_add_arg (comm->process, "-y");
add_password_arg (comm, password, FALSE);
fr_process_add_arg (comm->process, comm->filename);
fr_process_end_command (comm->process);
+
+ if (p7z_comm->fdata != NULL) {
+ file_data_free (p7z_comm->fdata);
+ p7z_comm->fdata = NULL;
+ }
+ p7z_comm->list_started = FALSE;
fr_process_start (comm->process);
}
@@ -236,15 +241,18 @@
fr_command_7z_begin_command (comm);
+ if (update)
+ fr_process_add_arg (comm->process, "u");
+ else
+ fr_process_add_arg (comm->process, "a");
+
if (base_dir != NULL) {
fr_process_set_working_dir (comm->process, base_dir);
fr_process_add_arg_concat (comm->process, "-w", base_dir, NULL);
}
- if (update)
- fr_process_add_arg (comm->process, "u");
- else
- fr_process_add_arg (comm->process, "a");
+ if (is_mime_type (comm->mime_type, "application/zip"))
+ fr_process_add_arg (comm->process, "-tzip");
fr_process_add_arg (comm->process, "-bd");
fr_process_add_arg (comm->process, "-y");
@@ -262,6 +270,9 @@
fr_process_add_arg (comm->process, "-mx=7"); break;
}
+ if (is_mime_type (comm->mime_type, "application/x-executable"))
+ fr_process_add_arg (comm->process, "-sfx");
+
fr_process_add_arg (comm->process, comm->filename);
for (scan = file_list; scan; scan = scan->next) {
@@ -284,6 +295,9 @@
fr_process_add_arg (comm->process, "-bd");
fr_process_add_arg (comm->process, "-y");
+ if (is_mime_type (comm->mime_type, "application/x-executable"))
+ fr_process_add_arg (comm->process, "-sfx");
+
fr_process_add_arg (comm->process, comm->filename);
for (scan = file_list; scan; scan = scan->next)
@@ -345,26 +359,71 @@
fr_command_7z_handle_error (FrCommand *comm,
FrProcError *error)
{
- if (error->type == FR_PROC_ERROR_COMMAND_ERROR) {
- if (error->status <= 1)
- error->type = FR_PROC_ERROR_NONE;
+ if (error->type != FR_PROC_ERROR_COMMAND_ERROR)
+ return;
+
+ if (error->status <= 1) {
+ error->type = FR_PROC_ERROR_NONE;
+ }
+ else {
+ GList *scan;
+
+ for (scan = g_list_last (comm->process->out.raw); scan; scan = scan->prev) {
+ char *line = scan->data;
+
+ if (strstr (line, "Wrong password?") != NULL) {
+ error->type = FR_PROC_ERROR_ASK_PASSWORD;
+ break;
+ }
+ }
}
}
-static void
-fr_command_7z_set_mime_type (FrCommand *comm,
- const char *mime_type)
+const char *sevenz_mime_types[] = { "application/x-7z-compressed",
+ "application/x-arj",
+ "application/x-cabinet",
+ "application/x-cd-image",
+ /*"application/x-cbr",*/
+ "application/x-cbz",
+ "application/x-executable",
+ "application/x-rar",
+ "application/zip",
+ NULL };
+
+
+const char **
+fr_command_7z_get_mime_types (FrCommand *comm)
{
- FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
+ return sevenz_mime_types;
+}
+
+
+FrCommandCap
+fr_command_7z_get_capabilities (FrCommand *comm,
+ const char *mime_type)
+{
+ FrCommandCap capabilities;
+
+ capabilities = FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
+ if (! is_program_in_path ("7za") && ! is_program_in_path ("7zr") && ! is_program_in_path ("7z"))
+ return capabilities;
+
+ capabilities |= FR_COMMAND_CAP_READ;
+ if (is_mime_type (mime_type, "application/x-7z-compressed"))
+ capabilities |= FR_COMMAND_CAP_WRITE;
+
+ if (is_program_in_path ("7z")) {
+ if (is_mime_type (mime_type, "application/x-cbr")
+ || is_mime_type (mime_type, "application/x-cbz")
+ || is_mime_type (mime_type, "application/x-executable")
+ || is_mime_type (mime_type, "application/zip"))
+ {
+ capabilities |= FR_COMMAND_CAP_WRITE;
+ }
+ }
- comm->capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
- if (is_program_in_path ("7za"))
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
- else if (is_program_in_path ("7zr"))
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
- else if (is_program_in_path ("7z"))
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ return capabilities;
}
@@ -379,13 +438,14 @@
gobject_class->finalize = fr_command_7z_finalize;
- afc->list = fr_command_7z_list;
- afc->add = fr_command_7z_add;
- afc->delete = fr_command_7z_delete;
- afc->extract = fr_command_7z_extract;
- afc->test = fr_command_7z_test;
- afc->handle_error = fr_command_7z_handle_error;
- afc->set_mime_type = fr_command_7z_set_mime_type;
+ afc->list = fr_command_7z_list;
+ afc->add = fr_command_7z_add;
+ afc->delete = fr_command_7z_delete;
+ afc->extract = fr_command_7z_extract;
+ afc->test = fr_command_7z_test;
+ afc->handle_error = fr_command_7z_handle_error;
+ afc->get_mime_types = fr_command_7z_get_mime_types;
+ afc->get_capabilities = fr_command_7z_get_capabilities;
}
Modified: trunk/src/fr-command-7z.h
==============================================================================
--- trunk/src/fr-command-7z.h (original)
+++ trunk/src/fr-command-7z.h Thu Jun 19 15:10:12 2008
@@ -40,8 +40,8 @@
struct _FrCommand7z
{
FrCommand __parent;
- gboolean list_started;
- int name_index;
+ gboolean list_started;
+ FileData *fdata;
};
struct _FrCommand7zClass
Modified: trunk/src/fr-command-ace.c
==============================================================================
--- trunk/src/fr-command-ace.c (original)
+++ trunk/src/fr-command-ace.c Thu Jun 19 15:10:12 2008
@@ -231,15 +231,27 @@
}
-static void
-fr_command_ace_set_mime_type (FrCommand *comm,
- const char *mime_type)
+const char *ace_mime_type[] = { "application/x-ace", NULL };
+
+
+const char **
+fr_command_ace_get_mime_types (FrCommand *comm)
+{
+ return ace_mime_type;
+}
+
+
+FrCommandCap
+fr_command_ace_get_capabilities (FrCommand *comm,
+ const char *mime_type)
{
- FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
+ FrCommandCap capabilities;
- comm->capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
+ capabilities = FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
if (is_program_in_path ("unace"))
- comm->capabilities |= FR_COMMAND_CAP_READ;
+ capabilities |= FR_COMMAND_CAP_READ;
+
+ return capabilities;
}
@@ -254,11 +266,12 @@
gobject_class->finalize = fr_command_ace_finalize;
- afc->list = fr_command_ace_list;
- afc->extract = fr_command_ace_extract;
- afc->test = fr_command_ace_test;
- afc->handle_error = fr_command_ace_handle_error;
- afc->set_mime_type = fr_command_ace_set_mime_type;
+ afc->list = fr_command_ace_list;
+ afc->extract = fr_command_ace_extract;
+ afc->test = fr_command_ace_test;
+ afc->handle_error = fr_command_ace_handle_error;
+ afc->get_mime_types = fr_command_ace_get_mime_types;
+ afc->get_capabilities = fr_command_ace_get_capabilities;
}
Modified: trunk/src/fr-command-ar.c
==============================================================================
--- trunk/src/fr-command-ar.c (original)
+++ trunk/src/fr-command-ar.c Thu Jun 19 15:10:12 2008
@@ -280,15 +280,27 @@
}
-static void
-fr_command_ar_set_mime_type (FrCommand *comm,
- const char *mime_type)
+const char *ar_mime_type[] = { "application/x-ar", NULL };
+
+
+const char **
+fr_command_ar_get_mime_types (FrCommand *comm)
+{
+ return ar_mime_type;
+}
+
+
+FrCommandCap
+fr_command_ar_get_capabilities (FrCommand *comm,
+ const char *mime_type)
{
- FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
+ FrCommandCap capabilities;
- comm->capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
+ capabilities = FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
if (is_program_in_path ("ar"))
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ capabilities |= FR_COMMAND_CAP_READ_WRITE;
+
+ return capabilities;
}
@@ -303,12 +315,13 @@
gobject_class->finalize = fr_command_ar_finalize;
- afc->list = fr_command_ar_list;
- afc->add = fr_command_ar_add;
- afc->delete = fr_command_ar_delete;
- afc->extract = fr_command_ar_extract;
- afc->handle_error = fr_command_ar_handle_error;
- afc->set_mime_type = fr_command_ar_set_mime_type;
+ afc->list = fr_command_ar_list;
+ afc->add = fr_command_ar_add;
+ afc->delete = fr_command_ar_delete;
+ afc->extract = fr_command_ar_extract;
+ afc->handle_error = fr_command_ar_handle_error;
+ afc->get_mime_types = fr_command_ar_get_mime_types;
+ afc->get_capabilities = fr_command_ar_get_capabilities;
}
Modified: trunk/src/fr-command-arj.c
==============================================================================
--- trunk/src/fr-command-arj.c (original)
+++ trunk/src/fr-command-arj.c Thu Jun 19 15:10:12 2008
@@ -320,15 +320,27 @@
}
-static void
-fr_command_arj_set_mime_type (FrCommand *comm,
- const char *mime_type)
+const char *arj_mime_type[] = { "application/x-arj", NULL };
+
+
+const char **
+fr_command_arj_get_mime_types (FrCommand *comm)
+{
+ return arj_mime_type;
+}
+
+
+FrCommandCap
+fr_command_arj_get_capabilities (FrCommand *comm,
+ const char *mime_type)
{
- FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
+ FrCommandCap capabilities;
- comm->capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
+ capabilities = FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
if (is_program_in_path ("arj"))
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ capabilities |= FR_COMMAND_CAP_READ_WRITE;
+
+ return capabilities;
}
@@ -343,13 +355,14 @@
gobject_class->finalize = fr_command_arj_finalize;
- afc->list = fr_command_arj_list;
- afc->add = fr_command_arj_add;
- afc->delete = fr_command_arj_delete;
- afc->extract = fr_command_arj_extract;
- afc->test = fr_command_arj_test;
- afc->handle_error = fr_command_arj_handle_error;
- afc->set_mime_type = fr_command_arj_set_mime_type;
+ afc->list = fr_command_arj_list;
+ afc->add = fr_command_arj_add;
+ afc->delete = fr_command_arj_delete;
+ afc->extract = fr_command_arj_extract;
+ afc->test = fr_command_arj_test;
+ afc->handle_error = fr_command_arj_handle_error;
+ afc->get_mime_types = fr_command_arj_get_mime_types;
+ afc->get_capabilities = fr_command_arj_get_capabilities;
}
Modified: trunk/src/fr-command-cfile.c
==============================================================================
--- trunk/src/fr-command-cfile.c (original)
+++ trunk/src/fr-command-cfile.c Thu Jun 19 15:10:12 2008
@@ -411,34 +411,52 @@
}
-static void
-fr_command_cfile_set_mime_type (FrCommand *comm,
- const char *mime_type)
+const char *cfile_mime_type[] = { "application/x-gzip",
+ "application/x-bzip",
+ "application/x-compress",
+ "application/x-lzma",
+ "application/x-lzop",
+ NULL };
+
+
+const char **
+fr_command_cfile_get_mime_types (FrCommand *comm)
{
- FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
+ return cfile_mime_type;
+}
+
+
+FrCommandCap
+fr_command_cfile_get_capabilities (FrCommand *comm,
+ const char *mime_type)
+{
+ FrCommandCap capabilities;
- if (is_mime_type (comm->mime_type, "application/x-gzip")) {
+ capabilities = FR_COMMAND_CAP_NONE;
+ if (is_mime_type (mime_type, "application/x-gzip")) {
if (is_program_in_path ("gzip"))
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ capabilities |= FR_COMMAND_CAP_READ_WRITE;
}
- else if (is_mime_type (comm->mime_type, "application/x-bzip")) {
+ else if (is_mime_type (mime_type, "application/x-bzip")) {
if (is_program_in_path ("bzip2"))
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ capabilities |= FR_COMMAND_CAP_READ_WRITE;
}
- else if (is_mime_type (comm->mime_type, "application/x-compress")) {
+ else if (is_mime_type (mime_type, "application/x-compress")) {
if (is_program_in_path ("compress"))
- comm->capabilities |= FR_COMMAND_CAP_WRITE;
+ capabilities |= FR_COMMAND_CAP_WRITE;
if (is_program_in_path ("uncompress"))
- comm->capabilities |= FR_COMMAND_CAP_READ;
+ capabilities |= FR_COMMAND_CAP_READ;
}
- else if (is_mime_type (comm->mime_type, "application/x-lzma")) {
+ else if (is_mime_type (mime_type, "application/x-lzma")) {
if (is_program_in_path ("lzma"))
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ capabilities |= FR_COMMAND_CAP_READ_WRITE;
}
- else if (is_mime_type (comm->mime_type, "application/x-lzop")) {
+ else if (is_mime_type (mime_type, "application/x-lzop")) {
if (is_program_in_path ("lzop"))
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ capabilities |= FR_COMMAND_CAP_READ_WRITE;
}
+
+ return capabilities;
}
@@ -465,11 +483,12 @@
gobject_class->finalize = fr_command_cfile_finalize;
- afc->list = fr_command_cfile_list;
- afc->add = fr_command_cfile_add;
- afc->delete = fr_command_cfile_delete;
- afc->extract = fr_command_cfile_extract;
- afc->set_mime_type = fr_command_cfile_set_mime_type;
+ afc->list = fr_command_cfile_list;
+ afc->add = fr_command_cfile_add;
+ afc->delete = fr_command_cfile_delete;
+ afc->extract = fr_command_cfile_extract;
+ afc->get_mime_types = fr_command_cfile_get_mime_types;
+ afc->get_capabilities = fr_command_cfile_get_capabilities;
}
Modified: trunk/src/fr-command-cpio.c
==============================================================================
--- trunk/src/fr-command-cpio.c (original)
+++ trunk/src/fr-command-cpio.c Thu Jun 19 15:10:12 2008
@@ -92,12 +92,10 @@
FrCommand *comm = FR_COMMAND (data);
char **fields;
const char *name_field;
+ int ofs = 0;
g_return_if_fail (line != NULL);
- if (line[0] == 'd') /* Ignore directories. */
- return;
-
fdata = file_data_new ();
#ifdef __sun
@@ -107,14 +105,21 @@
g_strfreev (fields);
name_field = get_last_field (line, 10);
-#else
- fields = split_line (line, 8);
- fdata->size = g_ascii_strtoull (fields[4], NULL, 10);
- fdata->modified = mktime_from_string (fields[5], fields[6], fields[7]);
+#else /* !__sun */
+ if (line[0] == 'c') {
+ fields = split_line (line, 9);
+ ofs = 1;
+ }
+ else {
+ fields = split_line (line, 8);
+ ofs = 0;
+ }
+ fdata->size = g_ascii_strtoull (fields[4+ofs], NULL, 10);
+ fdata->modified = mktime_from_string (fields[5+ofs], fields[6+ofs], fields[7+ofs]);
g_strfreev (fields);
- name_field = get_last_field (line, 9);
-#endif /* __sun */
+ name_field = get_last_field (line, 9+ofs);
+#endif /* !__sun */
fields = g_strsplit (name_field, " -> ", 2);
@@ -123,19 +128,41 @@
fields = g_strsplit (name_field, " link to ", 2);
}
+ fdata->dir = line[0] == 'd';
+
if (*(fields[0]) == '/') {
- fdata->full_path = g_strdup (fields[0]);
- fdata->original_path = fdata->full_path;
- } else {
- fdata->full_path = g_strconcat ("/", fields[0], NULL);
- fdata->original_path = fdata->full_path + 1;
+ char *name = fields[0];
+ if (fdata->dir && (name[strlen (name) - 1] != '/')) {
+ fdata->full_path = g_strconcat (name, "/", NULL);
+ fdata->original_path = g_strdup (fields[0]);
+ fdata->free_original_path = TRUE;
+ }
+ else {
+ fdata->full_path = g_strdup (fields[0]);
+ fdata->original_path = fdata->full_path;
+ }
+ }
+ else {
+ char *name = fields[0];
+ if (fdata->dir && (name[strlen (name) - 1] != '/')) {
+ fdata->full_path = g_strconcat ("/", name, "/", NULL);
+ fdata->original_path = g_strdup (fields[0]);
+ fdata->free_original_path = TRUE;
+ }
+ else {
+ fdata->full_path = g_strconcat ("/", fields[0], NULL);
+ fdata->original_path = fdata->full_path + 1;
+ }
}
if (fields[1] != NULL)
fdata->link = g_strdup (fields[1]);
g_strfreev (fields);
- fdata->name = g_strdup (file_name_from_path (fdata->full_path));
+ if (fdata->dir)
+ fdata->name = dir_name_from_path (fdata->full_path);
+ else
+ fdata->name = g_strdup (file_name_from_path (fdata->full_path));
fdata->path = remove_level_from_path (fdata->full_path);
if (*fdata->name == 0)
@@ -202,15 +229,27 @@
}
-static void
-fr_command_cpio_set_mime_type (FrCommand *comm,
- const char *mime_type)
+const char *cpio_mime_type[] = { "application/x-cpio", NULL };
+
+
+const char **
+fr_command_cpio_get_mime_types (FrCommand *comm)
+{
+ return cpio_mime_type;
+}
+
+
+FrCommandCap
+fr_command_cpio_get_capabilities (FrCommand *comm,
+ const char *mime_type)
{
- FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
+ FrCommandCap capabilities;
- comm->capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
+ capabilities = FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
if (is_program_in_path ("cpio"))
- comm->capabilities |= FR_COMMAND_CAP_READ;
+ capabilities |= FR_COMMAND_CAP_READ;
+
+ return capabilities;
}
@@ -225,9 +264,10 @@
gobject_class->finalize = fr_command_cpio_finalize;
- afc->list = fr_command_cpio_list;
- afc->extract = fr_command_cpio_extract;
- afc->set_mime_type = fr_command_cpio_set_mime_type;
+ afc->list = fr_command_cpio_list;
+ afc->extract = fr_command_cpio_extract;
+ afc->get_mime_types = fr_command_cpio_get_mime_types;
+ afc->get_capabilities = fr_command_cpio_get_capabilities;
}
Modified: trunk/src/fr-command-iso.c
==============================================================================
--- trunk/src/fr-command-iso.c (original)
+++ trunk/src/fr-command-iso.c Thu Jun 19 15:10:12 2008
@@ -198,15 +198,27 @@
}
-static void
-fr_command_iso_set_mime_type (FrCommand *comm,
- const char *mime_type)
+const char *iso_mime_type[] = { "application/x-cd-image", NULL };
+
+
+const char **
+fr_command_iso_get_mime_types (FrCommand *comm)
+{
+ return iso_mime_type;
+}
+
+
+FrCommandCap
+fr_command_iso_get_capabilities (FrCommand *comm,
+ const char *mime_type)
{
- FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
+ FrCommandCap capabilities;
- comm->capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
+ capabilities = FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
if (is_program_in_path ("isoinfo"))
- comm->capabilities |= FR_COMMAND_CAP_READ;
+ capabilities |= FR_COMMAND_CAP_READ;
+
+ return capabilities;
}
@@ -221,9 +233,10 @@
gobject_class->finalize = fr_command_iso_finalize;
- afc->list = fr_command_iso_list;
- afc->extract = fr_command_iso_extract;
- afc->set_mime_type = fr_command_iso_set_mime_type;
+ afc->list = fr_command_iso_list;
+ afc->extract = fr_command_iso_extract;
+ afc->get_mime_types = fr_command_iso_get_mime_types;
+ afc->get_capabilities = fr_command_iso_get_capabilities;
}
Modified: trunk/src/fr-command-lha.c
==============================================================================
--- trunk/src/fr-command-lha.c (original)
+++ trunk/src/fr-command-lha.c Thu Jun 19 15:10:12 2008
@@ -304,15 +304,27 @@
}
-static void
-fr_command_lha_set_mime_type (FrCommand *comm,
- const char *mime_type)
+const char *lha_mime_type[] = { "application/x-lha", NULL };
+
+
+const char **
+fr_command_lha_get_mime_types (FrCommand *comm)
+{
+ return lha_mime_type;
+}
+
+
+FrCommandCap
+fr_command_lha_get_capabilities (FrCommand *comm,
+ const char *mime_type)
{
- FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
+ FrCommandCap capabilities;
- comm->capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
+ capabilities = FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
if (is_program_in_path ("lha"))
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ capabilities |= FR_COMMAND_CAP_READ_WRITE;
+
+ return capabilities;
}
@@ -327,11 +339,12 @@
gobject_class->finalize = fr_command_lha_finalize;
- afc->list = fr_command_lha_list;
- afc->add = fr_command_lha_add;
- afc->delete = fr_command_lha_delete;
- afc->extract = fr_command_lha_extract;
- afc->set_mime_type = fr_command_lha_set_mime_type;
+ afc->list = fr_command_lha_list;
+ afc->add = fr_command_lha_add;
+ afc->delete = fr_command_lha_delete;
+ afc->extract = fr_command_lha_extract;
+ afc->get_mime_types = fr_command_lha_get_mime_types;
+ afc->get_capabilities = fr_command_lha_get_capabilities;
}
Modified: trunk/src/fr-command-rar.c
==============================================================================
--- trunk/src/fr-command-rar.c (original)
+++ trunk/src/fr-command-rar.c Thu Jun 19 15:10:12 2008
@@ -383,17 +383,31 @@
}
-static void
-fr_command_rar_set_mime_type (FrCommand *comm,
- const char *mime_type)
+const char *rar_mime_type[] = { "application/x-cbr",
+ "application/x-rar",
+ NULL };
+
+
+const char **
+fr_command_rar_get_mime_types (FrCommand *comm)
+{
+ return rar_mime_type;
+}
+
+
+FrCommandCap
+fr_command_rar_get_capabilities (FrCommand *comm,
+ const char *mime_type)
{
- FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
+ FrCommandCap capabilities;
- comm->capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
+ capabilities = FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
if (is_program_in_path ("rar"))
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ capabilities |= FR_COMMAND_CAP_READ_WRITE;
else if (is_program_in_path ("unrar"))
- comm->capabilities |= FR_COMMAND_CAP_READ;
+ capabilities |= FR_COMMAND_CAP_READ;
+
+ return capabilities;
}
@@ -408,13 +422,14 @@
gobject_class->finalize = fr_command_rar_finalize;
- afc->list = fr_command_rar_list;
- afc->add = fr_command_rar_add;
- afc->delete = fr_command_rar_delete;
- afc->extract = fr_command_rar_extract;
- afc->test = fr_command_rar_test;
- afc->handle_error = fr_command_rar_handle_error;
- afc->set_mime_type = fr_command_rar_set_mime_type;
+ afc->list = fr_command_rar_list;
+ afc->add = fr_command_rar_add;
+ afc->delete = fr_command_rar_delete;
+ afc->extract = fr_command_rar_extract;
+ afc->test = fr_command_rar_test;
+ afc->handle_error = fr_command_rar_handle_error;
+ afc->get_mime_types = fr_command_rar_get_mime_types;
+ afc->get_capabilities = fr_command_rar_get_capabilities;
}
Modified: trunk/src/fr-command-rpm.c
==============================================================================
--- trunk/src/fr-command-rpm.c (original)
+++ trunk/src/fr-command-rpm.c Thu Jun 19 15:10:12 2008
@@ -201,15 +201,27 @@
}
-static void
-fr_command_rpm_set_mime_type (FrCommand *comm,
- const char *mime_type)
+const char *rpm_mime_type[] = { "application/x-rpm", NULL };
+
+
+const char **
+fr_command_rpm_get_mime_types (FrCommand *comm)
+{
+ return rpm_mime_type;
+}
+
+
+FrCommandCap
+fr_command_rpm_get_capabilities (FrCommand *comm,
+ const char *mime_type)
{
- FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
+ FrCommandCap capabilities;
- comm->capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
+ capabilities = FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
if (is_program_in_path ("rpm2cpio"))
- comm->capabilities |= FR_COMMAND_CAP_READ;
+ capabilities |= FR_COMMAND_CAP_READ;
+
+ return capabilities;
}
@@ -224,9 +236,10 @@
gobject_class->finalize = fr_command_rpm_finalize;
- afc->list = fr_command_rpm_list;
- afc->extract = fr_command_rpm_extract;
- afc->set_mime_type = fr_command_rpm_set_mime_type;
+ afc->list = fr_command_rpm_list;
+ afc->extract = fr_command_rpm_extract;
+ afc->get_mime_types = fr_command_rpm_get_mime_types;
+ afc->get_capabilities = fr_command_rpm_get_capabilities;
}
Modified: trunk/src/fr-command-tar.c
==============================================================================
--- trunk/src/fr-command-tar.c (original)
+++ trunk/src/fr-command-tar.c Thu Jun 19 15:10:12 2008
@@ -794,53 +794,90 @@
}
-static void
-fr_command_tar_set_mime_type (FrCommand *comm,
- const char *mime_type)
+const char *tar_mime_types[] = { "application/x-tar",
+ "application/x-compressed-tar",
+ "application/x-bzip-compressed-tar",
+ "application/x-tarz",
+ "application/x-lzma-compressed-tar",
+ "application/x-lzop-compressed-tar",
+ "application/x-7z-compressed-tar",
+ NULL };
+
+
+const char **
+fr_command_tar_get_mime_types (FrCommand *comm)
{
- FrCommandTar *comm_tar = FR_COMMAND_TAR (comm);
-
- FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
+ return tar_mime_types;
+}
- /* In solaris gtar is present under /usr/sfw/bin */
+
+FrCommandCap
+fr_command_tar_get_capabilities (FrCommand *comm,
+ const char *mime_type)
+{
+ FrCommandCap capabilities;
- comm->capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
+ capabilities = FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
+ /* In solaris gtar is present under /usr/sfw/bin */
if (! is_program_in_path ("tar") && ! is_program_in_path ("/usr/sfw/bin/gtar"))
- return;
+ return capabilities;
- if (is_mime_type (comm->mime_type, "application/x-tar")) {
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ if (is_mime_type (mime_type, "application/x-tar")) {
+ capabilities |= FR_COMMAND_CAP_READ_WRITE;
}
- else if (is_mime_type (comm->mime_type, "application/x-compressed-tar")) {
+ else if (is_mime_type (mime_type, "application/x-compressed-tar")) {
if (is_program_in_path ("gzip"))
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ capabilities |= FR_COMMAND_CAP_READ_WRITE;
}
- else if (is_mime_type (comm->mime_type, "application/x-bzip-compressed-tar")) {
+ else if (is_mime_type (mime_type, "application/x-bzip-compressed-tar")) {
if (is_program_in_path ("bzip2"))
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ capabilities |= FR_COMMAND_CAP_READ_WRITE;
}
- else if (is_mime_type (comm->mime_type, "application/x-tarz")) {
+ else if (is_mime_type (mime_type, "application/x-tarz")) {
if (is_program_in_path ("compress"))
- comm->capabilities |= FR_COMMAND_CAP_WRITE;
+ capabilities |= FR_COMMAND_CAP_WRITE;
if (is_program_in_path ("uncompress"))
- comm->capabilities |= FR_COMMAND_CAP_READ;
+ capabilities |= FR_COMMAND_CAP_READ;
}
- else if (is_mime_type (comm->mime_type, "application/x-lzma-compressed-tar")) {
+ else if (is_mime_type (mime_type, "application/x-lzma-compressed-tar")) {
if (is_program_in_path ("lzma"))
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ capabilities |= FR_COMMAND_CAP_READ_WRITE;
}
- else if (is_mime_type (comm->mime_type, "application/x-lzop-compressed-tar")) {
+ else if (is_mime_type (mime_type, "application/x-lzop-compressed-tar")) {
if (is_program_in_path ("lzop"))
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ }
+ else if (is_mime_type (mime_type, "application/x-7z-compressed-tar")) {
+ char *try_command[3] = { "7za", "7zr", "7z" };
+ int i;
+
+ for (i = 0; i < G_N_ELEMENTS (try_command); i++) {
+ if (is_program_in_path (try_command[i])) {
+ capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ break;
+ }
+ }
}
- else if (is_mime_type (comm->mime_type, "application/x-7z-compressed-tar")) {
+
+ return capabilities;
+}
+
+
+static void
+fr_command_tar_set_mime_type (FrCommand *comm,
+ const char *mime_type)
+{
+ FrCommandTar *comm_tar = FR_COMMAND_TAR (comm);
+
+ FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
+
+ if (is_mime_type (mime_type, "application/x-7z-compressed-tar")) {
char *try_command[3] = { "7za", "7zr", "7z" };
int i;
for (i = 0; i < G_N_ELEMENTS (try_command); i++) {
if (is_program_in_path (try_command[i])) {
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
comm_tar->compress_command = g_strdup (try_command[i]);
break;
}
@@ -860,15 +897,16 @@
gobject_class->finalize = fr_command_tar_finalize;
- afc->list = fr_command_tar_list;
- afc->add = fr_command_tar_add;
- afc->delete = fr_command_tar_delete;
- afc->extract = fr_command_tar_extract;
- afc->handle_error = fr_command_tar_handle_error;
- afc->set_mime_type = fr_command_tar_set_mime_type;
-
- afc->recompress = fr_command_tar_recompress;
- afc->uncompress = fr_command_tar_uncompress;
+ afc->list = fr_command_tar_list;
+ afc->add = fr_command_tar_add;
+ afc->delete = fr_command_tar_delete;
+ afc->extract = fr_command_tar_extract;
+ afc->handle_error = fr_command_tar_handle_error;
+ afc->get_mime_types = fr_command_tar_get_mime_types;
+ afc->get_capabilities = fr_command_tar_get_capabilities;
+ afc->set_mime_type = fr_command_tar_set_mime_type;
+ afc->recompress = fr_command_tar_recompress;
+ afc->uncompress = fr_command_tar_uncompress;
}
Modified: trunk/src/fr-command-unstuff.c
==============================================================================
--- trunk/src/fr-command-unstuff.c (original)
+++ trunk/src/fr-command-unstuff.c Thu Jun 19 15:10:12 2008
@@ -267,15 +267,27 @@
}
-static void
-fr_command_unstuff_set_mime_type (FrCommand *comm,
- const char *mime_type)
+const char *unstuff_mime_type[] = { "application/x-stuffit", NULL };
+
+
+const char **
+fr_command_unstuff_get_mime_types (FrCommand *comm)
+{
+ return unstuff_mime_type;
+}
+
+
+FrCommandCap
+fr_command_unstuff_get_capabilities (FrCommand *comm,
+ const char *mime_type)
{
- FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
+ FrCommandCap capabilities;
- comm->capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
+ capabilities = FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
if (is_program_in_path ("unstuff"))
- comm->capabilities |= FR_COMMAND_CAP_READ;
+ capabilities |= FR_COMMAND_CAP_READ;
+
+ return capabilities;
}
@@ -290,12 +302,13 @@
gobject_class->finalize = fr_command_unstuff_finalize;
- afc->list = fr_command_unstuff_list;
- afc->add = NULL;
- afc->delete = NULL;
- afc->extract = fr_command_unstuff_extract;
- afc->handle_error = fr_command_unstuff_handle_error;
- afc->set_mime_type = fr_command_unstuff_set_mime_type;
+ afc->list = fr_command_unstuff_list;
+ afc->add = NULL;
+ afc->delete = NULL;
+ afc->extract = fr_command_unstuff_extract;
+ afc->handle_error = fr_command_unstuff_handle_error;
+ afc->get_mime_types = fr_command_unstuff_get_mime_types;
+ afc->get_capabilities = fr_command_unstuff_get_capabilities;
}
Modified: trunk/src/fr-command-zip.c
==============================================================================
--- trunk/src/fr-command-zip.c (original)
+++ trunk/src/fr-command-zip.c Thu Jun 19 15:10:12 2008
@@ -359,21 +359,36 @@
}
-static void
-fr_command_zip_set_mime_type (FrCommand *comm,
- const char *mime_type)
+const char *zip_mime_type[] = { "application/x-cbz",
+ "application/x-executable",
+ "application/zip",
+ NULL };
+
+
+const char **
+fr_command_zip_get_mime_types (FrCommand *comm)
+{
+ return zip_mime_type;
+}
+
+
+FrCommandCap
+fr_command_zip_get_capabilities (FrCommand *comm,
+ const char *mime_type)
{
- FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
+ FrCommandCap capabilities;
- comm->capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
+ capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
if (is_program_in_path ("zip")) {
- if (strcmp (comm->mime_type, "application/x-ms-dos-executable") == 0)
- comm->capabilities |= FR_COMMAND_CAP_READ;
+ if (strcmp (mime_type, "application/x-executable") == 0)
+ capabilities |= FR_COMMAND_CAP_READ;
else
- comm->capabilities |= FR_COMMAND_CAP_ALL;
+ capabilities |= FR_COMMAND_CAP_ALL;
}
else if (is_program_in_path ("unzip"))
- comm->capabilities |= FR_COMMAND_CAP_READ;
+ capabilities |= FR_COMMAND_CAP_READ;
+
+ return capabilities;
}
@@ -388,13 +403,14 @@
gobject_class->finalize = fr_command_zip_finalize;
- afc->list = fr_command_zip_list;
- afc->add = fr_command_zip_add;
- afc->delete = fr_command_zip_delete;
- afc->extract = fr_command_zip_extract;
- afc->test = fr_command_zip_test;
- afc->handle_error = fr_command_zip_handle_error;
- afc->set_mime_type = fr_command_zip_set_mime_type;
+ afc->list = fr_command_zip_list;
+ afc->add = fr_command_zip_add;
+ afc->delete = fr_command_zip_delete;
+ afc->extract = fr_command_zip_extract;
+ afc->test = fr_command_zip_test;
+ afc->handle_error = fr_command_zip_handle_error;
+ afc->get_mime_types = fr_command_zip_get_mime_types;
+ afc->get_capabilities = fr_command_zip_get_capabilities;
}
Modified: trunk/src/fr-command-zoo.c
==============================================================================
--- trunk/src/fr-command-zoo.c (original)
+++ trunk/src/fr-command-zoo.c Thu Jun 19 15:10:12 2008
@@ -324,15 +324,27 @@
}
-static void
-fr_command_zoo_set_mime_type (FrCommand *comm,
- const char *mime_type)
+const char *zoo_mime_type[] = { "application/x-zoo", NULL };
+
+
+const char **
+fr_command_zoo_get_mime_types (FrCommand *comm)
+{
+ return zoo_mime_type;
+}
+
+
+FrCommandCap
+fr_command_zoo_get_capabilities (FrCommand *comm,
+ const char *mime_type)
{
- FR_COMMAND_CLASS (parent_class)->set_mime_type (comm, mime_type);
+ FrCommandCap capabilities;
- comm->capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
+ capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
if (is_program_in_path ("zoo"))
- comm->capabilities |= FR_COMMAND_CAP_READ_WRITE;
+ capabilities |= FR_COMMAND_CAP_READ_WRITE;
+
+ return capabilities;
}
@@ -347,12 +359,13 @@
gobject_class->finalize = fr_command_zoo_finalize;
- afc->list = fr_command_zoo_list;
- afc->add = fr_command_zoo_add;
- afc->delete = fr_command_zoo_delete;
- afc->extract = fr_command_zoo_extract;
- afc->test = fr_command_zoo_test;
- afc->set_mime_type = fr_command_zoo_set_mime_type;
+ afc->list = fr_command_zoo_list;
+ afc->add = fr_command_zoo_add;
+ afc->delete = fr_command_zoo_delete;
+ afc->extract = fr_command_zoo_extract;
+ afc->test = fr_command_zoo_test;
+ afc->get_mime_types = fr_command_zoo_get_mime_types;
+ afc->get_capabilities = fr_command_zoo_get_capabilities;
}
Modified: trunk/src/fr-command.c
==============================================================================
--- trunk/src/fr-command.c (original)
+++ trunk/src/fr-command.c Thu Jun 19 15:10:12 2008
@@ -164,11 +164,30 @@
}
+const char **void_mime_types = { NULL };
+
+
+const char **
+base_fr_command_get_mime_types (FrCommand *comm)
+{
+ return void_mime_types;
+}
+
+
+FrCommandCap
+base_fr_command_get_capabilities (FrCommand *comm,
+ const char *mime_type)
+{
+ return FR_COMMAND_CAP_NONE;
+}
+
+
static void
base_fr_command_set_mime_type (FrCommand *comm,
const char *mime_type)
{
comm->mime_type = get_static_string (mime_type);
+ comm->capabilities = fr_command_get_capabilities (comm, comm->mime_type);
}
@@ -305,19 +324,21 @@
gobject_class->set_property = fr_command_set_property;
gobject_class->get_property = fr_command_get_property;
- class->list = base_fr_command_list;
- class->add = base_fr_command_add;
- class->delete = base_fr_command_delete;
- class->extract = base_fr_command_extract;
- class->test = base_fr_command_test;
- class->uncompress = base_fr_command_uncompress;
- class->recompress = base_fr_command_recompress;
- class->handle_error = base_fr_command_handle_error;
- class->set_mime_type = base_fr_command_set_mime_type;
- class->start = NULL;
- class->done = NULL;
- class->progress = NULL;
- class->message = NULL;
+ class->list = base_fr_command_list;
+ class->add = base_fr_command_add;
+ class->delete = base_fr_command_delete;
+ class->extract = base_fr_command_extract;
+ class->test = base_fr_command_test;
+ class->uncompress = base_fr_command_uncompress;
+ class->recompress = base_fr_command_recompress;
+ class->handle_error = base_fr_command_handle_error;
+ class->get_mime_types = base_fr_command_get_mime_types;
+ class->get_capabilities = base_fr_command_get_capabilities;
+ class->set_mime_type = base_fr_command_set_mime_type;
+ class->start = NULL;
+ class->done = NULL;
+ class->progress = NULL;
+ class->message = NULL;
/* signals */
@@ -487,6 +508,7 @@
comm->action = FR_ACTION_LISTING_CONTENT;
fr_process_set_out_line_func (FR_COMMAND (comm)->process, NULL, NULL);
fr_process_set_err_line_func (FR_COMMAND (comm)->process, NULL, NULL);
+ fr_process_use_standard_locale (FR_COMMAND (comm)->process, TRUE);
if (!comm->fake_load)
FR_COMMAND_GET_CLASS (G_OBJECT (comm))->list (comm, password);
@@ -588,6 +610,21 @@
}
+const char **
+fr_command_get_mime_types (FrCommand *comm)
+{
+ return FR_COMMAND_GET_CLASS (G_OBJECT (comm))->get_mime_types (comm);
+}
+
+
+FrCommandCap
+fr_command_get_capabilities (FrCommand *comm,
+ const char *mime_type)
+{
+ return FR_COMMAND_GET_CLASS (G_OBJECT (comm))->get_capabilities (comm, mime_type);
+}
+
+
gboolean
fr_command_is_capable_of (FrCommand *comm,
FrCommandCaps requested_capabilities)
Modified: trunk/src/fr-command.h
==============================================================================
--- trunk/src/fr-command.h (original)
+++ trunk/src/fr-command.h Thu Jun 19 15:10:12 2008
@@ -108,48 +108,48 @@
/*<virtual functions>*/
- void (*list) (FrCommand *comm,
- const char *password);
- void (*add) (FrCommand *comm,
- GList *file_list,
- const char *base_dir,
- gboolean update,
- gboolean recursive,
- const char *password,
- FrCompression compression);
- void (*delete) (FrCommand *comm,
- GList *file_list);
- void (*extract) (FrCommand *comm,
- GList *file_list,
- const char *dest_dir,
- gboolean overwrite,
- gboolean skip_older,
- gboolean junk_paths,
- const char *password);
- void (*test) (FrCommand *comm,
- const char *password);
- void (*uncompress) (FrCommand *comm);
- void (*recompress) (FrCommand *comm,
- FrCompression compression);
- void (*handle_error) (FrCommand *comm,
- FrProcError *error);
-
- /*<protected virtual functions>*/
-
- void (*set_mime_type) (FrCommand *comm,
- const char *mime_type);
+ void (*list) (FrCommand *comm,
+ const char *password);
+ void (*add) (FrCommand *comm,
+ GList *file_list,
+ const char *base_dir,
+ gboolean update,
+ gboolean recursive,
+ const char *password,
+ FrCompression compression);
+ void (*delete) (FrCommand *comm,
+ GList *file_list);
+ void (*extract) (FrCommand *comm,
+ GList *file_list,
+ const char *dest_dir,
+ gboolean overwrite,
+ gboolean skip_older,
+ gboolean junk_paths,
+ const char *password);
+ void (*test) (FrCommand *comm,
+ const char *password);
+ void (*uncompress) (FrCommand *comm);
+ void (*recompress) (FrCommand *comm,
+ FrCompression compression);
+ void (*handle_error) (FrCommand *comm,
+ FrProcError *error);
+ const char ** (*get_mime_types) (FrCommand *comm);
+ FrCommandCap (*get_capabilities) (FrCommand *comm,
+ const char *mime_type);
+ void (*set_mime_type) (FrCommand *comm,
+ const char *mime_type);
/*<signals>*/
- void (*start) (FrCommand *comm,
- FrAction action);
- void (*done) (FrCommand *comm,
- FrAction action,
- FrProcError *error);
- void (*progress) (FrCommand *comm,
- double fraction);
- void (*message) (FrCommand *comm,
- const char *msg);
+ void (*start) (FrCommand *comm,
+ FrAction action);
+ void (*done) (FrCommand *comm,
+ FrAction action,
+ FrProcError *error);
+ void (*progress) (FrCommand *comm,
+ double fraction);
+ void (*message) (FrCommand *comm,
+ const char *msg);
};
GType fr_command_get_type (void);
@@ -180,6 +180,13 @@
FrCompression compression);
gboolean fr_command_is_capable_of (FrCommand *comm,
FrCommandCaps capabilities);
+const char ** fr_command_get_mime_types (FrCommand *comm);
+FrCommandCap fr_command_get_capabilities (FrCommand *comm,
+ const char *mime_type);
+void fr_command_set_mime_type (FrCommand *comm,
+ const char *mime_type);
+gboolean fr_command_is_capable_of (FrCommand *comm,
+ FrCommandCaps capabilities);
/* protected functions */
@@ -191,8 +198,6 @@
int n_files);
void fr_command_add_file (FrCommand *comm,
FileData *fdata);
-void fr_command_set_mime_type (FrCommand *comm,
- const char *mime_type);
/* private functions */
Modified: trunk/src/fr-process.c
==============================================================================
--- trunk/src/fr-process.c (original)
+++ trunk/src/fr-process.c Thu Jun 19 15:10:12 2008
@@ -603,8 +603,10 @@
{
FrProcess *process = user_data;
- if (process->priv->use_standard_locale)
+ if (process->priv->use_standard_locale) {
+ debug (DEBUG_INFO, "LC_ALL=C");
putenv ("LC_ALL=C");
+ }
}
@@ -794,7 +796,8 @@
/* Done */
process->priv->current_command = -1;
-
+ process->priv->use_standard_locale = FALSE;
+
if (process->out.raw != NULL)
process->out.raw = g_list_reverse (process->out.raw);
if (process->err.raw != NULL)
Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c (original)
+++ trunk/src/main.c Thu Jun 19 15:10:12 2008
@@ -79,37 +79,40 @@
static char *default_url = NULL;
FrMimeTypeDescription mime_type_desc[] = {
+ { "application/x-7z-compressed", ".7z", N_("7-Zip (.7z)"), TRUE, TRUE },
+ { "application/x-7z-compressed-tar", ".tar.7z", N_("Tar compressed with 7z (.tar.7z)"), FALSE, TRUE },
{ "application/x-ace", ".ace", N_("Ace (.ace)"), FALSE, FALSE },
{ "application/x-ar", ".ar", N_("Ar (.ar)"), FALSE, TRUE },
{ "application/x-arj", ".arj", N_("Arj (.arj)"), TRUE, TRUE },
{ "application/x-bzip", ".bz2", NULL, FALSE, FALSE },
+ { "application/x-bzip-compressed-tar", ".tar.bz2", N_("Tar compressed with bzip2 (.tar.bz2)"), FALSE, TRUE },
{ "application/x-bzip1", ".bz", NULL, FALSE, FALSE },
+ { "application/x-bzip1-compressed-tar", ".tar.bz", N_("Tar compressed with bzip (.tar.bz)"), FALSE, TRUE },
+ { "application/x-cabinet", ".cab", N_("Cabinet (.cab)"), FALSE, TRUE },
+ { "application/x-cbr", ".cbr", N_("Rar Archived Comic Book (.cbr)"), TRUE, TRUE },
+ { "application/x-cbz", ".cbz", N_("Zip Archived Comic Book (.cbz)"), TRUE, TRUE },
+ { "application/x-cd-image", ".iso", NULL, FALSE, TRUE },
{ "application/x-compress", ".Z", NULL, FALSE, FALSE },
+ { "application/x-compressed-tar", ".tar.gz", N_("Tar compressed with gzip (.tar.gz)"), FALSE, TRUE },
{ "application/x-cpio", ".cpio", NULL, FALSE, TRUE },
{ "application/x-deb", ".deb", NULL, FALSE, TRUE },
- { "application/x-cd-image", ".iso", NULL, FALSE, TRUE },
{ "application/x-ear", ".ear", N_("Ear (.ear)"), TRUE, TRUE },
- { "application/x-ms-dos-executable", ".exe", N_("Self-extracting zip (.exe)"), FALSE, TRUE },
+ { "application/x-executable", ".exe", N_("Self-extracting zip (.exe)"), TRUE, TRUE },
{ "application/x-gzip", ".gz", NULL, FALSE, FALSE },
{ "application/x-jar", ".jar", N_("Jar (.jar)"), TRUE, TRUE },
{ "application/x-lha", ".lzh", N_("Lha (.lzh)"), FALSE, TRUE },
{ "application/x-lzma", ".lzma", NULL, FALSE, FALSE },
+ { "application/x-lzma-compressed-tar", ".tar.lzma", N_("Tar compressed with lzma (.tar.lzma)"), FALSE, TRUE },
{ "application/x-lzop", ".lzo", NULL, FALSE, FALSE },
+ { "application/x-lzop-compressed-tar", ".tar.lzo", N_("Tar compressed with lzop (.tar.lzo)"), FALSE, TRUE },
{ "application/x-rar", ".rar", N_("Rar (.rar)"), TRUE, TRUE },
{ "application/x-rpm", ".rpm", NULL, FALSE, TRUE },
{ "application/x-tar", ".tar", N_("Tar uncompressed (.tar)"), FALSE, TRUE },
- { "application/x-bzip1-compressed-tar", ".tar.bz", N_("Tar compressed with bzip (.tar.bz)"), FALSE, TRUE },
- { "application/x-bzip-compressed-tar", ".tar.bz2", N_("Tar compressed with bzip2 (.tar.bz2)"), FALSE, TRUE },
- { "application/x-compressed-tar", ".tar.gz", N_("Tar compressed with gzip (.tar.gz)"), FALSE, TRUE },
- { "application/x-lzma-compressed-tar", ".tar.lzma", N_("Tar compressed with lzma (.tar.lzma)"), FALSE, TRUE },
- { "application/x-lzop-compressed-tar", ".tar.lzo", N_("Tar compressed with lzop (.tar.lzo)"), FALSE, TRUE },
- { "application/x-7z-compressed-tar", ".tar.7z", N_("Tar compressed with 7z (.tar.7z)"), FALSE, TRUE },
{ "application/x-tarz", ".tar.Z", N_("Tar compressed with compress (.tar.Z)"), FALSE, TRUE },
{ "application/x-stuffit", ".sit", NULL, FALSE, TRUE },
{ "application/x-war", ".war", N_("War (.war)"), TRUE, TRUE },
- { "application/zip", ".zip", N_("Zip (.zip)"), TRUE, TRUE },
{ "application/x-zoo", ".zoo", N_("Zoo (.zoo)"), FALSE, TRUE },
- { "application/x-7z-compressed", ".7z", N_("7-Zip (.7z)"), TRUE, TRUE },
+ { "application/zip", ".zip", N_("Zip (.zip)"), TRUE, TRUE },
{ NULL, NULL, NULL, FALSE, FALSE }
};
@@ -121,10 +124,13 @@
{ ".bin", "application/x-stuffit" },
{ ".bz", "application/x-bzip" },
{ ".bz2", "application/x-bzip" },
+ { ".cab", "application/x-cabinet" },
+ { ".cbr", "application/x-cbr" },
+ { ".cbz", "application/x-cbz" },
{ ".cpio", "application/x-cpio" },
{ ".deb", "application/x-deb" },
{ ".ear", "application/x-ear" },
- { ".exe", "application/x-ms-dos-executable" },
+ { ".exe", "application/x-executable" },
{ ".gz", "application/x-gzip" },
{ ".iso", "application/x-cd-image" },
{ ".jar", "application/x-jar" },
@@ -156,54 +162,10 @@
{ ".zoo", "application/x-zoo" }
};
-int single_file_save_type[32];
-int save_type[32];
-int open_type[32];
-int create_type[32];
-
-FrCommandDescription command_desc[] = {
- { "tar", "application/x-tar", TRUE, TRUE },
- { "zip", "application/zip", TRUE, TRUE },
- { "unzip", "application/zip", TRUE, FALSE },
- { "rar", "application/x-rar", TRUE, TRUE },
- { "unrar", "application/x-rar", TRUE, FALSE },
- { "gzip", "application/x-gzip", TRUE, TRUE },
- { "bzip2", "application/x-bzip", TRUE, TRUE },
- { "unace", "application/x-ace", TRUE, FALSE },
- { "ar", "application/x-ar", TRUE, TRUE },
- { "ar", "application/x-deb", TRUE, FALSE },
- { "arj", "application/x-arj", TRUE, TRUE },
- { "bzip2", "application/x-bzip1", TRUE, FALSE },
- { "compress", "application/x-compress", TRUE, TRUE },
- { "cpio", "application/x-cpio", TRUE, FALSE },
- { "isoinfo", "application/x-cd-image", TRUE, FALSE },
- { "zip", "application/x-ear", TRUE, TRUE },
- { "zip", "application/x-jar", TRUE, TRUE },
- { "zip", "application/x-war", TRUE, TRUE },
- { "zip", "application/x-ms-dos-executable", TRUE, FALSE },
- { "lha", "application/x-lha", TRUE, TRUE },
- { "lzma", "application/x-lzma", TRUE, TRUE },
- { "lzop", "application/x-lzop", TRUE, TRUE },
- { "rpm2cpio", "application/x-rpm", TRUE, FALSE },
- { "uncompress", "application/x-compress", TRUE, FALSE },
- { "unstuff", "application/x-stuffit", TRUE, FALSE },
- { "zoo", "application/x-zoo", TRUE, TRUE },
- { "7za", "application/x-7z-compressed", TRUE, TRUE },
- { "7zr", "application/x-7z-compressed", TRUE, TRUE }
-};
-
-FrCommandDescription tar_command_desc[] = {
- { "gzip", "application/x-compressed-tar", TRUE, TRUE },
- { "bzip2", "application/x-bzip-compressed-tar", TRUE, TRUE },
- /*{ "bzip", "application/x-bzip1-compressed-tar", FALSE, TRUE },*/
- { "lzma", "application/x-lzma-compressed-tar", TRUE, TRUE },
- { "lzop", "application/x-lzop-compressed-tar", TRUE, TRUE },
- { "compress", "application/x-tarz", FALSE, TRUE },
- { "uncompress", "application/x-tarz", TRUE, FALSE },
- { "7za", "application/x-7z-compressed-tar", FALSE, TRUE },
- { "7zr", "application/x-7z-compressed-tar", FALSE, TRUE }
-};
-
+int single_file_save_type[64];
+int save_type[64];
+int open_type[64];
+int create_type[64];
static const GOptionEntry options[] = {
{ "add-to", 'a', 0, G_OPTION_ARG_STRING, &add_to,
@@ -447,13 +409,31 @@
FrRegisteredCommand *
fr_registered_command_new (GType command_type)
{
- FrRegisteredCommand *reg_com;
+ FrRegisteredCommand *reg_com;
+ FrCommand *command;
+ const char **mime_types;
+ int i;
reg_com = g_new0 (FrRegisteredCommand, 1);
reg_com->ref = 1;
reg_com->type = command_type;
reg_com->caps = g_ptr_array_new ();
+ command = (FrCommand*) g_object_new (reg_com->type, NULL);
+ mime_types = fr_command_get_mime_types (command);
+ for (i = 0; mime_types[i] != NULL; i++) {
+ const char *mime_type;
+ FrMimeTypeCap *cap;
+
+ mime_type = get_static_string (mime_types[i]);
+
+ cap = g_new0 (FrMimeTypeCap, 1);
+ cap->mime_type = mime_type;
+ cap->capabilities = fr_command_get_capabilities (command, mime_type);
+ g_ptr_array_add (reg_com->caps, cap);
+ }
+ g_object_unref (command);
+
return reg_com;
}
@@ -477,21 +457,6 @@
}
-void
-fr_registered_command_add_mime_type (FrRegisteredCommand *reg_com,
- const char *mime_type,
- FrCommandCaps capabilities)
-{
- FrMimeTypeCap *cap;
-
- cap = g_new0 (FrMimeTypeCap, 1);
- cap->mime_type = mime_type;
- cap->capabilities = capabilities;
-
- g_ptr_array_add (reg_com->caps, cap);
-}
-
-
FrCommandCaps
fr_registered_command_get_capabilities (FrRegisteredCommand *reg_com,
const char *mime_type)
@@ -511,26 +476,11 @@
void
-register_command (GType command_type, ...)
-{
- va_list args;
- FrRegisteredCommand *command;
- const char *mime_type;
- FrCommandCap capabilities;
-
+register_command (GType command_type)
+{
if (Registered_Commands == NULL)
Registered_Commands = g_ptr_array_sized_new (5);
-
- command = fr_registered_command_new (command_type);
-
- va_start (args, command_type);
- while ((mime_type = va_arg (args, const char *)) != NULL) {
- capabilities = va_arg (args, FrCommandCap);
- fr_registered_command_add_mime_type (command, mime_type, capabilities);
- }
- va_end (args);
-
- g_ptr_array_add (Registered_Commands, command);
+ g_ptr_array_add (Registered_Commands, fr_registered_command_new (command_type));
}
@@ -557,65 +507,21 @@
static void
register_commands (void)
{
- register_command (FR_TYPE_COMMAND_7Z,
- "application/x-7z-compressed", FR_COMMAND_CAP_ALL,
- NULL);
- register_command (FR_TYPE_COMMAND_ACE,
- "application/x-ace", FR_COMMAND_CAP_READ_WRITE | FR_COMMAND_CAP_ARCHIVE_MANY_FILES,
- NULL);
- register_command (FR_TYPE_COMMAND_AR,
- "application/x-ar", FR_COMMAND_CAP_ALL,
- "application/x-deb", FR_COMMAND_CAP_READ | FR_COMMAND_CAP_ARCHIVE_MANY_FILES,
- NULL);
- register_command (FR_TYPE_COMMAND_ARJ,
- "application/x-arj", FR_COMMAND_CAP_ALL,
- NULL);
- register_command (FR_TYPE_COMMAND_CFILE,
- "application/x-gzip", FR_COMMAND_CAP_READ_WRITE,
- "application/x-bzip", FR_COMMAND_CAP_READ_WRITE,
- "application/x-compress", FR_COMMAND_CAP_READ_WRITE,
- "application/x-lzma", FR_COMMAND_CAP_READ_WRITE,
- "application/x-lzop", FR_COMMAND_CAP_READ_WRITE,
- NULL);
- register_command (FR_TYPE_COMMAND_CPIO,
- "application/x-cpio", FR_COMMAND_CAP_ALL,
- NULL);
- register_command (FR_TYPE_COMMAND_ISO,
- "application/x-cd-image", FR_COMMAND_CAP_READ | FR_COMMAND_CAP_ARCHIVE_MANY_FILES,
- NULL);
- register_command (FR_TYPE_COMMAND_JAR,
- "application/x-jar", FR_COMMAND_CAP_ALL,
- NULL);
- register_command (FR_TYPE_COMMAND_LHA,
- "application/x-lha", FR_COMMAND_CAP_ALL,
- NULL);
- register_command (FR_TYPE_COMMAND_RAR,
- "application/x-rar", FR_COMMAND_CAP_ALL,
- NULL);
- register_command (FR_TYPE_COMMAND_RPM,
- "application/x-rpm", FR_COMMAND_CAP_READ | FR_COMMAND_CAP_ARCHIVE_MANY_FILES,
- NULL);
- register_command (FR_TYPE_COMMAND_TAR,
- "application/x-tar", FR_COMMAND_CAP_ALL,
- "application/x-compressed-tar", FR_COMMAND_CAP_ALL,
- "application/x-bzip-compressed-tar", FR_COMMAND_CAP_ALL,
- "application/x-tarz", FR_COMMAND_CAP_ALL,
- "application/x-lzma-compressed-tar", FR_COMMAND_CAP_ALL,
- "application/x-lzop-compressed-tar", FR_COMMAND_CAP_ALL,
- "application/x-7z-compressed-tar", FR_COMMAND_CAP_WRITE | FR_COMMAND_CAP_ARCHIVE_MANY_FILES,
- NULL);
- register_command (FR_TYPE_COMMAND_UNSTUFF,
- "application/x-stuffit", FR_COMMAND_CAP_READ | FR_COMMAND_CAP_ARCHIVE_MANY_FILES,
- NULL);
- register_command (FR_TYPE_COMMAND_ZIP,
- "application/zip", FR_COMMAND_CAP_ALL,
- "application/x-ear", FR_COMMAND_CAP_ALL,
- "application/x-war", FR_COMMAND_CAP_ALL,
- "application/x-ms-dos-executable", FR_COMMAND_CAP_ALL,
- NULL);
- register_command (FR_TYPE_COMMAND_ZOO,
- "application/x-zoo", FR_COMMAND_CAP_ALL,
- NULL);
+ register_command (FR_TYPE_COMMAND_TAR);
+ register_command (FR_TYPE_COMMAND_CFILE);
+ register_command (FR_TYPE_COMMAND_7Z);
+ register_command (FR_TYPE_COMMAND_ZIP);
+ register_command (FR_TYPE_COMMAND_RAR);
+ register_command (FR_TYPE_COMMAND_ARJ);
+ register_command (FR_TYPE_COMMAND_ACE);
+ register_command (FR_TYPE_COMMAND_AR);
+ register_command (FR_TYPE_COMMAND_CPIO);
+ register_command (FR_TYPE_COMMAND_ISO);
+ register_command (FR_TYPE_COMMAND_JAR);
+ register_command (FR_TYPE_COMMAND_LHA);
+ register_command (FR_TYPE_COMMAND_RPM);
+ register_command (FR_TYPE_COMMAND_UNSTUFF);
+ register_command (FR_TYPE_COMMAND_ZOO);
}
@@ -649,9 +555,13 @@
{
int i;
+ if (ext == NULL)
+ return NULL;
+
for (i = G_N_ELEMENTS (file_ext_type) - 1; i >= 0; i--)
- if (strcmp (ext, file_ext_type[i].ext) == 0)
+ if (strcasecmp (ext, file_ext_type[i].ext) == 0)
return get_static_string (file_ext_type[i].mime_type);
+
return NULL;
}
@@ -670,7 +580,7 @@
return NULL;
for (i = G_N_ELEMENTS (file_ext_type) - 1; i >= 0; i--)
- if (strcmp (ext, file_ext_type[i].ext) == 0)
+ if (strcasecmp (ext, file_ext_type[i].ext) == 0)
return ext;
return NULL;
}
@@ -681,7 +591,7 @@
{
int i;
- for (i = 0; i < G_N_ELEMENTS (mime_type_desc); i++)
+ for (i = 0; mime_type_desc[i].mime_type != NULL; i++)
if (strcmp (mime_type_desc[i].mime_type, mime_type) == 0)
return i;
return -1;
@@ -689,60 +599,59 @@
static void
+add_if_non_present (int *a,
+ int *n,
+ int o)
+{
+ int i;
+
+ for (i = 0; i < *n; i++) {
+ if (a[i] == o)
+ return;
+ }
+ a[*n] = o;
+ *n = *n + 1;
+}
+
+
+static void
compute_supported_archive_types (void)
{
- int i, j;
int sf_i = 0, s_i = 0, o_i = 0, c_i = 0;
- int idx;
-
- for (i = 0; i < G_N_ELEMENTS (command_desc); i++) {
- FrCommandDescription comm_desc = command_desc[i];
+ int i;
- if (! is_program_in_path (comm_desc.command))
- continue;
+ for (i = 0; i < Registered_Commands->len; i++) {
+ FrRegisteredCommand *reg_com;
+ int j;
- if (strcmp (comm_desc.command, "tar") == 0) {
- for (j = 0; j < G_N_ELEMENTS (tar_command_desc); j++) {
- FrCommandDescription comm_desc_2 = tar_command_desc[j];
-
- if (!is_program_in_path (comm_desc_2.command))
- continue;
-
- idx = get_mime_type_index (comm_desc_2.mime_type);
- if (idx >= 0) {
- if (comm_desc_2.can_open)
- open_type[o_i++] = idx;
- if (comm_desc_2.can_save) {
- if (mime_type_desc[idx].supports_many_files) {
- save_type[s_i++] = idx;
- if (comm_desc_2.can_open)
- create_type[c_i++] = idx;
- }
- single_file_save_type[sf_i++] = idx;
- }
- }
+ reg_com = g_ptr_array_index (Registered_Commands, i);
+ for (j = 0; j < reg_com->caps->len; j++) {
+ FrMimeTypeCap *cap;
+ int idx;
+
+ cap = g_ptr_array_index (reg_com->caps, j);
+ idx = get_mime_type_index (cap->mime_type);
+ if (idx < 0) {
+ g_warning ("mime type not recognized: %s", cap->mime_type);
+ continue;
}
- }
-
- idx = get_mime_type_index (comm_desc.mime_type);
- if (idx >= 0) {
- if (comm_desc.can_open)
- open_type[o_i++] = idx;
- if (comm_desc.can_save) {
- if (mime_type_desc[idx].supports_many_files) {
- save_type[s_i++] = idx;
- if (comm_desc.can_open)
- create_type[c_i++] = idx;
+ if (cap->capabilities & FR_COMMAND_CAP_READ)
+ add_if_non_present (open_type, &o_i, idx);
+ if (cap->capabilities & FR_COMMAND_CAP_WRITE) {
+ if (cap->capabilities & FR_COMMAND_CAP_ARCHIVE_MANY_FILES) {
+ add_if_non_present (save_type, &s_i, idx);
+ if (cap->capabilities & FR_COMMAND_CAP_WRITE)
+ add_if_non_present (create_type, &c_i, idx);
}
- single_file_save_type[sf_i++] = idx;
+ add_if_non_present (single_file_save_type, &sf_i, idx);
}
- }
+ }
}
-
- open_type[o_i++] = -1;
- save_type[s_i++] = -1;
- single_file_save_type[sf_i++] = -1;
- create_type[s_i++] = -1;
+
+ open_type[o_i] = -1;
+ save_type[s_i] = -1;
+ single_file_save_type[sf_i] = -1;
+ create_type[c_i] = -1;
}
Modified: trunk/src/main.h
==============================================================================
--- trunk/src/main.h (original)
+++ trunk/src/main.h Thu Jun 19 15:10:12 2008
@@ -73,6 +73,6 @@
GType get_command_type_from_mime_type (const char *mime_type,
FrCommandCaps requested_capabilities);
const char * get_mime_type_from_extension (const char *ext);
-const char * get_archive_filename_extension (const char *uri);
+const char * get_archive_filename_extension (const char *uri);
#endif /* MAIN_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]