2005-06-23 David Zeuthen <david@fubar.dk>
* gnome/applet/vpn-password-dialog.c (child_stdout_data_cb): Send a signal to the child to indicate that we got what we wanted when we see two new-lines right after each other. (nmwa_vpn_request_password): Pass a structure with several members instead of just the passwords git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@741 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:

committed by
David Zeuthen

parent
b88cd2913d
commit
ad6dc012a0
@@ -1,3 +1,11 @@
|
|||||||
|
2005-06-23 David Zeuthen <david@fubar.dk>
|
||||||
|
|
||||||
|
* gnome/applet/vpn-password-dialog.c (child_stdout_data_cb): Send a
|
||||||
|
signal to the child to indicate that we got what we wanted when we
|
||||||
|
see two new-lines right after each other.
|
||||||
|
(nmwa_vpn_request_password): Pass a structure with several members
|
||||||
|
instead of just the passwords
|
||||||
|
|
||||||
2005-06-23 Dan Williams <dcbw@redhat.com>
|
2005-06-23 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* src/NetworkManager.c
|
* src/NetworkManager.c
|
||||||
|
@@ -30,11 +30,19 @@
|
|||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
#include <dbus/dbus-glib.h>
|
#include <dbus/dbus-glib.h>
|
||||||
#include <glib/gi18n-lib.h>
|
#include <glib/gi18n-lib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "applet.h"
|
#include "applet.h"
|
||||||
#include "vpn-password-dialog.h"
|
#include "vpn-password-dialog.h"
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GSList **passwords;
|
||||||
|
int child_stdin;
|
||||||
|
int num_newlines;
|
||||||
|
} IOUserData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
child_finished_cb (GPid pid, gint status, gpointer userdata)
|
child_finished_cb (GPid pid, gint status, gpointer userdata)
|
||||||
{
|
{
|
||||||
@@ -47,7 +55,8 @@ static gboolean
|
|||||||
child_stdout_data_cb (GIOChannel *source, GIOCondition condition, gpointer userdata)
|
child_stdout_data_cb (GIOChannel *source, GIOCondition condition, gpointer userdata)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
GSList **passwords = (GSList **) userdata;
|
IOUserData *io_user_data = (IOUserData *) userdata;
|
||||||
|
GSList **passwords = (GSList **) io_user_data->passwords;
|
||||||
|
|
||||||
if (! (condition & G_IO_IN))
|
if (! (condition & G_IO_IN))
|
||||||
goto out;
|
goto out;
|
||||||
@@ -56,9 +65,18 @@ child_stdout_data_cb (GIOChannel *source, GIOCondition condition, gpointer userd
|
|||||||
int len;
|
int len;
|
||||||
|
|
||||||
len = strlen (str);
|
len = strlen (str);
|
||||||
if (len > 0) {
|
if (len == 1 && str[0] == '\n') {
|
||||||
|
|
||||||
|
/* on second line with a newline newline */
|
||||||
|
if (++io_user_data->num_newlines == 2) {
|
||||||
|
char buf[1];
|
||||||
|
/* terminate the child */
|
||||||
|
write (io_user_data->child_stdin, buf, sizeof (buf));
|
||||||
|
}
|
||||||
|
} else if (len > 0) {
|
||||||
/* remove terminating newline */
|
/* remove terminating newline */
|
||||||
str[len - 1] = '\0';
|
str[len - 1] = '\0';
|
||||||
|
|
||||||
*passwords = g_slist_append (*passwords, str);
|
*passwords = g_slist_append (*passwords, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,6 +94,7 @@ nmwa_vpn_request_password (NMWirelessApplet *applet, const char *name, const cha
|
|||||||
"-r",
|
"-r",
|
||||||
NULL};
|
NULL};
|
||||||
GSList *passwords = NULL;
|
GSList *passwords = NULL;
|
||||||
|
int child_stdin;
|
||||||
int child_stdout;
|
int child_stdout;
|
||||||
GPid child_pid;
|
GPid child_pid;
|
||||||
int child_status;
|
int child_status;
|
||||||
@@ -83,6 +102,7 @@ nmwa_vpn_request_password (NMWirelessApplet *applet, const char *name, const cha
|
|||||||
guint child_stdout_channel_eventid;
|
guint child_stdout_channel_eventid;
|
||||||
GDir *dir;
|
GDir *dir;
|
||||||
char *auth_dialog_binary;
|
char *auth_dialog_binary;
|
||||||
|
IOUserData io_user_data;
|
||||||
|
|
||||||
auth_dialog_binary = NULL;
|
auth_dialog_binary = NULL;
|
||||||
|
|
||||||
@@ -157,7 +177,7 @@ nmwa_vpn_request_password (NMWirelessApplet *applet, const char *name, const cha
|
|||||||
NULL, /* child_setup */
|
NULL, /* child_setup */
|
||||||
NULL, /* user_data */
|
NULL, /* user_data */
|
||||||
&child_pid, /* child_pid */
|
&child_pid, /* child_pid */
|
||||||
NULL, /* standard_input */
|
&child_stdin, /* standard_input */
|
||||||
&child_stdout, /* standard_output */
|
&child_stdout, /* standard_output */
|
||||||
NULL, /* standard_error */
|
NULL, /* standard_error */
|
||||||
NULL)) { /* error */
|
NULL)) { /* error */
|
||||||
@@ -181,9 +201,14 @@ nmwa_vpn_request_password (NMWirelessApplet *applet, const char *name, const cha
|
|||||||
/* catch when child is reaped */
|
/* catch when child is reaped */
|
||||||
g_child_watch_add (child_pid, child_finished_cb, (gpointer) &child_status);
|
g_child_watch_add (child_pid, child_finished_cb, (gpointer) &child_status);
|
||||||
|
|
||||||
|
io_user_data.passwords = &passwords;
|
||||||
|
io_user_data.child_stdin = child_stdin;
|
||||||
|
io_user_data.num_newlines = 0;
|
||||||
|
|
||||||
/* listen to what child has to say */
|
/* listen to what child has to say */
|
||||||
child_stdout_channel = g_io_channel_unix_new (child_stdout);
|
child_stdout_channel = g_io_channel_unix_new (child_stdout);
|
||||||
child_stdout_channel_eventid = g_io_add_watch (child_stdout_channel, G_IO_IN, child_stdout_data_cb, &passwords);
|
child_stdout_channel_eventid = g_io_add_watch (child_stdout_channel, G_IO_IN, child_stdout_data_cb,
|
||||||
|
&io_user_data);
|
||||||
g_io_channel_set_encoding (child_stdout_channel, NULL, NULL);
|
g_io_channel_set_encoding (child_stdout_channel, NULL, NULL);
|
||||||
|
|
||||||
/* recurse mainloop here until the child is finished (child_status is set in child_finished_cb) */
|
/* recurse mainloop here until the child is finished (child_status is set in child_finished_cb) */
|
||||||
|
Reference in New Issue
Block a user