diff options
Diffstat (limited to 'ncpwrapper.c')
-rw-r--r-- | ncpwrapper.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/ncpwrapper.c b/ncpwrapper.c index cdec0c5..0a7cf25 100644 --- a/ncpwrapper.c +++ b/ncpwrapper.c @@ -4,6 +4,7 @@ #include "ncpwrapper.h" #include "dialogs.h" +gboolean mounted = TRUE; static void cb_child_watch( GPid pid, @@ -38,6 +39,8 @@ cb_out_watch( GIOChannel *channel, g_free( tmp ); } + /* Receved some message - not mounted */ + mounted = FALSE; show_message( GTK_MESSAGE_INFO,"%s", "ncpmount output","%s",string->str); g_string_free(string, TRUE); @@ -57,6 +60,9 @@ cb_err_watch( GIOChannel *channel, if( cond == G_IO_HUP ) { g_io_channel_unref( channel ); + /* hangup signal - if mounted then show message */ + if(mounted) + show_message( GTK_MESSAGE_INFO,"Mounting succesfull", "","Mounted to \"%s\" directory.",cmd_params.mount_point); return( FALSE ); } /* @@ -77,16 +83,15 @@ cb_err_watch( GIOChannel *channel, } + /* Receved some message - not mounted */ + mounted = FALSE; + show_message( GTK_MESSAGE_ERROR,"%s", "ncpmount error","%s",string->str); g_string_free(string, TRUE); return( TRUE ); } -/* - TODO - jak odchytit uspesne mountnuti??? -*/ - void run_ncpmount() { @@ -95,8 +100,7 @@ void run_ncpmount() GPid pid; gint out, err; gboolean ret; - const gchar *command = get_ncpmount_command(); - + gchar *command = get_ncpmount_command(NULL); gchar **argv = g_strsplit(command, " ", 0); puts (command); @@ -106,6 +110,7 @@ void run_ncpmount() /* gchar *argv[] = {"/usr/bin/ncpmount", "-v", NULL};*/ + mounted = TRUE; /* Spawn child process */ ret = g_spawn_async_with_pipes( NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, @@ -114,7 +119,6 @@ void run_ncpmount() { g_warning( "SPAWN FAILED" ); show_message( GTK_MESSAGE_ERROR,"ERROR: %s", "Spawn failed!","%s",gerror->message); - g_error_free(gerror); return; } @@ -133,6 +137,9 @@ void run_ncpmount() #endif /* Add watches to channels */ - g_io_add_watch( out_ch, G_IO_IN | G_IO_HUP, (GIOFunc)cb_out_watch, NULL ); g_io_add_watch( err_ch, G_IO_IN | G_IO_HUP, (GIOFunc)cb_err_watch, NULL ); + g_io_add_watch( out_ch, G_IO_IN | G_IO_HUP, (GIOFunc)cb_out_watch, NULL ); + + g_strfreev(argv); + g_free(command); } |