[Xfce4-commits] [apps/squeeze] 04/04: Updated squeeze-cli to the new libsqueeze

noreply at xfce.org noreply at xfce.org
Wed Oct 29 18:13:45 CET 2014


This is an automated email from the git hooks/post-receive script.

peter pushed a commit to branch peter/libsqueeze
in repository apps/squeeze.

commit c60cf114c118bd18065ae0528cc1a4c9c08dfcdd
Author: Peter de Ridder <peter at xfce.org>
Date:   Wed Oct 29 18:13:03 2014 +0100

    Updated squeeze-cli to the new libsqueeze
---
 squeeze-cli/cli.c  |   82 ++++++++++++++++++++++++++++++----------------------
 squeeze-cli/main.c |    2 +-
 2 files changed, 49 insertions(+), 35 deletions(-)

diff --git a/squeeze-cli/cli.c b/squeeze-cli/cli.c
index 05cd174..fad072f 100644
--- a/squeeze-cli/cli.c
+++ b/squeeze-cli/cli.c
@@ -19,6 +19,7 @@
 #include <glib.h>
 #include <glib/gprintf.h>
 #include <gio/gio.h>
+#include <libxfce4util/libxfce4util.h>
 
 #include <libsqueeze/libsqueeze.h>
 
@@ -63,14 +64,13 @@ sq_cli_new ( void )
 gint
 sq_cli_extract_archive ( SQCli *cli, GFile *file, gchar *dest_path )
 {
-    LSQArchive *lp_archive = NULL;
-    if ( 0 != lsq_open_archive( file, &lp_archive ) )
+    GError *error = NULL;
+    LSQArchive *lp_archive = lsq_open_archive( file, &error);
+    LSQExecuteContext *ctx;
+    if ( NULL == lp_archive )
     {
-        /*
-         * Could not open archive (mime type not supported or file did not exist)
-         * Should be a more specific error message.
-         */ 
-        g_error( "%s", _("Could not open archive, MIME-type unsupported or file does not exist") );
+        g_error( "%s: %s", _("Could not open archive"), error->message );
+        g_clear_error( &error );
         return 1;
     }
     if ( NULL == dest_path )
@@ -78,17 +78,22 @@ sq_cli_extract_archive ( SQCli *cli, GFile *file, gchar *dest_path )
         lsq_close_archive( lp_archive );
         return 1;
     }
-    if ( FALSE == lsq_archive_operate( lp_archive, LSQ_COMMAND_TYPE_EXTRACT, NULL, dest_path ) )
+    ctx = lsq_archive_operate( lp_archive, LSQ_COMMAND_TYPE_EXTRACT, NULL, dest_path, NULL, &error );
+    if ( NULL == ctx )
     {
-        g_warning( "%s", _("Squeeze cannot extract this archive type,\nthe application to support this is missing.") );
+        g_warning( "%s: %s", _("Squeeze cannot extract the archive"), error->message );
+        g_clear_error( &error );
     }
+    g_object_unref( ctx );
     return 0;
 }
 
 gint
 sq_cli_new_archive ( SQCli *cli, GFile *file, GSList *files )
 {
+    GError *error = NULL;
     LSQArchive *lp_archive = NULL;
+    LSQExecuteContext *ctx;
 
     if ( NULL == file )
     {
@@ -96,28 +101,30 @@ sq_cli_new_archive ( SQCli *cli, GFile *file, GSList *files )
     }
     else
     {
-        if ( 0 != lsq_new_archive( file, FALSE, &lp_archive ) )
+        lp_archive = lsq_new_archive( file, NULL, FALSE, &error );
+        if ( NULL == lp_archive )
         {
-            /*
-             * Could not open archive (mime type not supported or file did not exist)
-             * Should be a more specific error message.
-             */ 
-            g_error( "%s", _("Could not open archive, MIME-type unsupported or file exists") );
+            g_error( "%s: %s", _("Could not open archive"), error->message );
+            g_clear_error( &error );
             return 1;
         }
     }
-    if ( FALSE == lsq_archive_operate( lp_archive, LSQ_COMMAND_TYPE_ADD, NULL, NULL ) )
+    ctx = lsq_archive_operate( lp_archive, LSQ_COMMAND_TYPE_ADD, NULL, NULL, NULL, &error );
+    if ( NULL == ctx )
     {
-        /* FIXME: show warning dialog */
-        g_warning( "%s", _("Squeeze cannot add files to this archive type,\nthe application to support this is missing.") );
+        g_warning( "%s: %s", _("Squeeze cannot add files to the archive"), error->message );
+        g_clear_error( &error );
     }
+    g_object_unref( ctx );
     return 0;
 }
 
 gint
 sq_cli_add_archive ( SQCli *cli, GFile *file, GSList *files )
 {
+    GError *error = NULL;
     LSQArchive *lp_archive = NULL;
+    LSQExecuteContext *ctx;
 
     if ( NULL == file )
     {
@@ -125,39 +132,46 @@ sq_cli_add_archive ( SQCli *cli, GFile *file, GSList *files )
     }
     else
     {
-        if ( 0 != lsq_open_archive( file, &lp_archive ) )
+        lp_archive = lsq_open_archive( file, &error);
+        if ( NULL == lp_archive )
         {
-            /*
-             * Could not open archive (mime type not supported or file did not exist)
-             * Should be a more specific error message.
-             */ 
-            g_error( "%s", _("Could not open archive, MIME-type unsupported or file does not exist") );
+            g_error( "%s: %s", _("Could not open archive"), error->message );
+            g_clear_error( &error );
             return 1;
         }
     }
-    if ( FALSE == lsq_archive_operate( lp_archive, LSQ_COMMAND_TYPE_ADD, NULL, NULL ) )
+    ctx = lsq_archive_operate( lp_archive, LSQ_COMMAND_TYPE_ADD, NULL, NULL, NULL, &error );
+    if ( NULL == ctx )
     {
-        /* FIXME: show warning dialog */
-        g_warning( "%s", _("Squeeze cannot add files to this archive type,\nthe application to support this is missing.") );
+        g_warning( "%s: %s", _("Squeeze cannot add files to the archive"), error->message );
+        g_clear_error( &error );
     }
+    g_object_unref( ctx );
     return 0;
 }
 
 gint
 sq_cli_open_archive ( SQCli *cli, GFile *file )
 {
-    LSQArchive *archive = NULL;
-
-    if ( 0 != lsq_open_archive( file, &archive ) )
+    GError *error = NULL;
+    LSQArchive *lp_archive = lsq_open_archive( file, &error);
+    LSQExecuteContext *ctx;
+    if ( NULL == lp_archive )
     {
-        g_error( "%s", _("Failed to open file") );
+        g_error( "%s: %s", _("Could not open archive"), error->message );
+        g_clear_error( &error );
         return 1;
     }
     else
     {
-        g_signal_connect( archive, "refreshed", G_CALLBACK(sq_cli_refreshed_cb), cli );
-        lsq_archive_operate( archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL );
-        g_object_ref( cli );
+        g_signal_connect( lp_archive, "refreshed", G_CALLBACK(sq_cli_refreshed_cb), g_object_ref( cli ) );
+        ctx = lsq_archive_operate( lp_archive, LSQ_COMMAND_TYPE_REFRESH, NULL, NULL, NULL, &error );
+        if ( NULL == ctx )
+        {
+            g_object_unref( cli );
+            g_warning( "%s: %s", _("Squeeze cannot list the content of the archive"), error->message );
+            g_clear_error( &error );
+        }
     }
     return 0;
 }
diff --git a/squeeze-cli/main.c b/squeeze-cli/main.c
index 3fc843b..b697df0 100644
--- a/squeeze-cli/main.c
+++ b/squeeze-cli/main.c
@@ -19,6 +19,7 @@
 #include <glib.h>
 #include <glib-object.h>
 #include <gio/gio.h>
+#include <libxfce4util/libxfce4util.h>
 
 #include <libsqueeze/libsqueeze.h>
 
@@ -137,7 +138,6 @@ main ( int argc, char **argv )
         return 0;
     }
 
-    g_type_init();
     main_loop = g_main_loop_new( NULL, FALSE );
 
     lsq_init();

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list