Author: stephan
Date: 2007-02-20 22:53:23 +0000 (Tue, 20 Feb 2007)
New Revision: 25001
Modified:
squeeze/trunk/libsqueeze/archive-command.c
squeeze/trunk/libsqueeze/archive-command.h
squeeze/trunk/libsqueeze/archive.c
squeeze/trunk/po/squeeze.pot
squeeze/trunk/tests/zip/test-add.c
squeeze/trunk/tests/zip/test-zip-add.pl
squeeze/trunk/tests/zip/test-zip-extract.pl
squeeze/trunk/tests/zip/test-zip-refresh.pl
squeeze/trunk/tests/zip/test-zip-remove.pl
Log:
Fixed Error detection and retournation of command structure.
Test-suite now checks both valid and invalid adds.
Modified: squeeze/trunk/libsqueeze/archive-command.c
===================================================================
--- squeeze/trunk/libsqueeze/archive-command.c 2007-02-20 21:47:23 UTC (rev
25000)
+++ squeeze/trunk/libsqueeze/archive-command.c 2007-02-20 22:53:23 UTC (rev
25001)
@@ -35,6 +35,8 @@
lsq_archive_command_init(LSQArchiveCommand *archive);
static void
lsq_archive_command_dispose(GObject *object);
+static void
+lsq_archive_command_finalize(GObject *object);
void
lsq_archive_command_child_watch_func(GPid pid, gint status, gpointer data);
@@ -78,6 +80,7 @@
GObjectClass *object_class = G_OBJECT_CLASS(archive_command_class);
object_class->dispose = lsq_archive_command_dispose;
+ object_class->finalize = lsq_archive_command_finalize;
parent_class = g_type_class_peek(G_TYPE_OBJECT);
@@ -87,6 +90,7 @@
lsq_archive_command_init(LSQArchiveCommand *archive_command)
{
archive_command->parse_stdout = NULL;
+ archive_command->domain = g_quark_from_string("Command");
}
/**
@@ -113,6 +117,21 @@
}
/**
+ * lsq_archive_command_finalize:
+ *
+ * @object: LSQArchiveCommand object
+ *
+ */
+static void
+lsq_archive_command_finalize(GObject *object)
+{
+ LSQArchiveCommand *command = LSQ_ARCHIVE_COMMAND(object);
+ if(command->error)
+ g_error_free(command->error);
+}
+
+
+/**
* lsq_archive_command_new:
* @comment: a description, describing what the command does
* @archive: the archive the command modifies
@@ -229,6 +248,37 @@
void
lsq_archive_command_child_watch_func(GPid pid, gint status, gpointer data)
{
+ LSQArchiveCommand *command = LSQ_ARCHIVE_COMMAND(data);
+ if(WIFEXITED(status))
+ {
+ if(WEXITSTATUS(status))
+ {
+ if(!command->error)
+ {
+ command->error = g_error_new(command->domain,
status, _("Command exited with status %d."), status);
+ }
+ }
+ }
+ if(WIFSIGNALED(status))
+ {
+ switch(WTERMSIG(status))
+ {
+ case SIGHUP:
+ if(!command->error)
+ command->error =
g_error_new(command->domain, status, _("Command interrupted by user"));
+ break;
+ case SIGSEGV:
+ if(!command->error)
+ command->error =
g_error_new(command->domain, status, _("Command received SIGSEGV"));
+ break;
+ case SIGKILL:
+ case SIGINT:
+ if(!command->error)
+ command->error =
g_error_new(command->domain, status, _("Command Terminated"));
+ break;
+ }
+ }
+ g_spawn_close_pid(pid);
g_object_unref(G_OBJECT(data));
}
Modified: squeeze/trunk/libsqueeze/archive-command.h
===================================================================
--- squeeze/trunk/libsqueeze/archive-command.h 2007-02-20 21:47:23 UTC (rev
25000)
+++ squeeze/trunk/libsqueeze/archive-command.h 2007-02-20 22:53:23 UTC (rev
25001)
@@ -41,16 +41,17 @@
struct _LSQArchiveCommand
{
- GObject parent;
- gchar *comment;
- gchar *command;
- LSQArchive *archive;
- GPid child_pid;
- GIOChannel *ioc_in;
- GIOChannel *ioc_out;
- GIOChannel *ioc_err;
- gboolean safe;
-
+ GObject parent;
+ GQuark domain;
+ gchar *comment;
+ gchar *command;
+ LSQArchive *archive;
+ GPid child_pid;
+ GIOChannel *ioc_in;
+ GIOChannel *ioc_out;
+ GIOChannel *ioc_err;
+ gboolean safe;
+ GError *error;
LSQParseFunc parse_stdout;
};
Modified: squeeze/trunk/libsqueeze/archive.c
===================================================================
--- squeeze/trunk/libsqueeze/archive.c 2007-02-20 21:47:23 UTC (rev 25000)
+++ squeeze/trunk/libsqueeze/archive.c 2007-02-20 22:53:23 UTC (rev 25001)
@@ -104,9 +104,10 @@
0,
NULL,
NULL,
- g_cclosure_marshal_VOID__VOID,
+ g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE,
- 0,
+ 1,
+ G_TYPE_POINTER,
NULL);
}
@@ -425,7 +426,14 @@
g_return_if_fail(archive->command_queue->data == command);
archive->command_queue = g_slist_remove(archive->command_queue,
command);
if(archive->command_queue == NULL)
- g_signal_emit(G_OBJECT(archive),
lsq_archive_signals[LSQ_ARCHIVE_SIGNAL_COMMAND_TERMINATED], 0, archive, NULL);
+ {
+ GError *error = NULL;
+ if(command->error)
+ {
+ error = g_error_copy(command->error);
+ }
+ g_signal_emit(G_OBJECT(archive),
lsq_archive_signals[LSQ_ARCHIVE_SIGNAL_COMMAND_TERMINATED], 0, error, NULL);
+ }
}
LSQArchiveCommand *
Modified: squeeze/trunk/po/squeeze.pot
===================================================================
--- squeeze/trunk/po/squeeze.pot 2007-02-20 21:47:23 UTC (rev 25000)
+++ squeeze/trunk/po/squeeze.pot 2007-02-20 22:53:23 UTC (rev 25001)
@@ -8,7 +8,7 @@
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: [EMAIL PROTECTED]"
-"POT-Creation-Date: 2007-02-19 14:20+0100\n"
+"POT-Creation-Date: 2007-02-19 14:36+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <[EMAIL PROTECTED]>\n"
"Language-Team: LANGUAGE <[EMAIL PROTECTED]>\n"
@@ -16,11 +16,11 @@
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
-#: ../libsqueeze/archive.c:292
+#: ../libsqueeze/archive.c:293
msgid "Name"
msgstr ""
-#: ../libsqueeze/archive.c:294
+#: ../libsqueeze/archive.c:295
msgid "Mime type"
msgstr ""
Modified: squeeze/trunk/tests/zip/test-add.c
===================================================================
--- squeeze/trunk/tests/zip/test-add.c 2007-02-20 21:47:23 UTC (rev 25000)
+++ squeeze/trunk/tests/zip/test-add.c 2007-02-20 22:53:23 UTC (rev 25001)
@@ -34,12 +34,17 @@
};
void
-cb_command_terminated(LSQArchive *archive)
+cb_command_terminated(LSQArchive *archive, GError *error)
{
if(loop)
g_main_loop_quit(loop);
else
ret_val = 1;
+ if(error)
+ {
+ g_debug("%s", error->message);
+ ret_val = 1;
+ }
}
int main(int argc, char **argv)
@@ -86,6 +91,5 @@
lsq_shutdown();
thunar_vfs_shutdown();
-
return ret_val;
}
Modified: squeeze/trunk/tests/zip/test-zip-add.pl
===================================================================
--- squeeze/trunk/tests/zip/test-zip-add.pl 2007-02-20 21:47:23 UTC (rev
25000)
+++ squeeze/trunk/tests/zip/test-zip-add.pl 2007-02-20 22:53:23 UTC (rev
25001)
@@ -11,8 +11,13 @@
system(@args) == 0
or die "system @args failed: $?";
-open(ZIP, "unzip -lv -qq $test_file |")
- or die "Cant execute 'zip -lvqq $test_file'";
+unlink $test_file;
[EMAIL PROTECTED] = ("./test-add", "-n", $test_file, "$cwd/data/2.txt");
+system(@args) != 0
+ or die "system @args should fail: $?";
+
+unlink $test_file;
+
print "========================================";
print "========================================\n";
Modified: squeeze/trunk/tests/zip/test-zip-extract.pl
===================================================================
--- squeeze/trunk/tests/zip/test-zip-extract.pl 2007-02-20 21:47:23 UTC (rev
25000)
+++ squeeze/trunk/tests/zip/test-zip-extract.pl 2007-02-20 22:53:23 UTC (rev
25001)
@@ -1 +1,2 @@
#!/usr/bin/env perl
+exit 1;
Modified: squeeze/trunk/tests/zip/test-zip-refresh.pl
===================================================================
--- squeeze/trunk/tests/zip/test-zip-refresh.pl 2007-02-20 21:47:23 UTC (rev
25000)
+++ squeeze/trunk/tests/zip/test-zip-refresh.pl 2007-02-20 22:53:23 UTC (rev
25001)
@@ -1 +1,2 @@
#!/usr/bin/env perl
+exit 1;
Modified: squeeze/trunk/tests/zip/test-zip-remove.pl
===================================================================
--- squeeze/trunk/tests/zip/test-zip-remove.pl 2007-02-20 21:47:23 UTC (rev
25000)
+++ squeeze/trunk/tests/zip/test-zip-remove.pl 2007-02-20 22:53:23 UTC (rev
25001)
@@ -1 +1,2 @@
#!/usr/bin/env perl
+exit 1;
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits