Don't pass blank path through dbus

git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@41 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2004-08-06 19:43:37 +00:00
parent 0505220a13
commit 00a4a641d6
2 changed files with 41 additions and 9 deletions

View file

@ -162,15 +162,24 @@ static int nmwa_timeout_handler (NMWirelessApplet *applet)
if (!applet->connection) if (!applet->connection)
applet->connection = nmwa_dbus_init (applet); applet->connection = nmwa_dbus_init (applet);
if (applet->nm_active && (active_device = nmwa_dbus_get_active_wireless_device (applet->connection))) if (applet->nm_active)
{ {
if ((active_device = nmwa_dbus_get_active_wireless_device (applet->connection)))
{
fprintf( stderr, "showing\n");
applet->have_active_device = TRUE; applet->have_active_device = TRUE;
nmwa_update_state (applet); nmwa_update_state (applet);
gtk_widget_show (GTK_WIDGET (applet)); gtk_widget_show (GTK_WIDGET (applet));
dbus_free (active_device); dbus_free (active_device);
} }
else else
fprintf( stderr, "timeout_handler(): active_device was nULL\n");
}
else
{
fprintf( stderr, "hiding\n");
gtk_widget_hide (GTK_WIDGET (applet)); gtk_widget_hide (GTK_WIDGET (applet));
}
return (TRUE); return (TRUE);
} }

View file

@ -53,6 +53,8 @@ char * nmwa_dbus_get_string (DBusConnection *connection, const char *path, const
g_return_val_if_fail (path != NULL, NULL); g_return_val_if_fail (path != NULL, NULL);
g_return_val_if_fail (method != NULL, NULL); g_return_val_if_fail (method != NULL, NULL);
fprintf( stderr, "path = '%s', method = '%s' interface = '%s'\n", path, method, NM_DBUS_INTERFACE);
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, NM_DBUS_INTERFACE, method))) if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, NM_DBUS_INTERFACE, method)))
{ {
fprintf (stderr, "Couldn't allocate the dbus message\n"); fprintf (stderr, "Couldn't allocate the dbus message\n");
@ -85,6 +87,7 @@ char * nmwa_dbus_get_string (DBusConnection *connection, const char *path, const
dbus_message_unref (reply); dbus_message_unref (reply);
dbus_message_unref (message); dbus_message_unref (message);
fprintf (stderr, "getstring done\n");
return (string); return (string);
} }
@ -104,6 +107,8 @@ gint32 nmwa_dbus_get_int (DBusConnection *connection, const char *path, const ch
g_return_val_if_fail (path != NULL, 0); g_return_val_if_fail (path != NULL, 0);
g_return_val_if_fail (method != NULL, 0); g_return_val_if_fail (method != NULL, 0);
fprintf( stderr, "getint() path = '%s', method = '%s' interface = '%s'\n", path, method, NM_DBUS_INTERFACE);
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, NM_DBUS_INTERFACE, method))) if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, NM_DBUS_INTERFACE, method)))
{ {
fprintf (stderr, "Couldn't allocate the dbus message\n"); fprintf (stderr, "Couldn't allocate the dbus message\n");
@ -133,6 +138,7 @@ gint32 nmwa_dbus_get_int (DBusConnection *connection, const char *path, const ch
dbus_message_unref (reply); dbus_message_unref (reply);
dbus_message_unref (message); dbus_message_unref (message);
fprintf( stderr, "end getint\n");
return (num); return (num);
} }
@ -152,6 +158,8 @@ double nmwa_dbus_get_double (DBusConnection *connection, const char *path, const
g_return_val_if_fail (path != NULL, 0); g_return_val_if_fail (path != NULL, 0);
g_return_val_if_fail (method != NULL, 0); g_return_val_if_fail (method != NULL, 0);
fprintf( stderr, "getdouble(): path = '%s', method = '%s' interface = '%s'\n", path, method, NM_DBUS_INTERFACE);
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, NM_DBUS_INTERFACE, method))) if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, NM_DBUS_INTERFACE, method)))
{ {
fprintf (stderr, "Couldn't allocate the dbus message\n"); fprintf (stderr, "Couldn't allocate the dbus message\n");
@ -204,6 +212,8 @@ char **nmwa_dbus_get_string_array (DBusConnection *connection, const char *path,
g_return_val_if_fail (method != NULL, NULL); g_return_val_if_fail (method != NULL, NULL);
g_return_val_if_fail (num_items != NULL, NULL); g_return_val_if_fail (num_items != NULL, NULL);
fprintf( stderr, "getstringarray() path = '%s', method = '%s' interface = '%s'\n", path, method, NM_DBUS_INTERFACE);
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, NM_DBUS_INTERFACE, method))) if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, NM_DBUS_INTERFACE, method)))
{ {
fprintf (stderr, "Couldn't allocate the dbus message\n"); fprintf (stderr, "Couldn't allocate the dbus message\n");
@ -234,6 +244,7 @@ char **nmwa_dbus_get_string_array (DBusConnection *connection, const char *path,
dbus_message_unref (reply); dbus_message_unref (reply);
dbus_message_unref (message); dbus_message_unref (message);
fprintf( stderr, "getstringarray() done\n");
return (array); return (array);
} }
@ -252,6 +263,8 @@ char * nmwa_dbus_get_active_wireless_device (DBusConnection *connection)
return (NULL); return (NULL);
if ((active_device = active_device = nmwa_dbus_get_string (connection, NM_DBUS_PATH, "getActiveDevice"))) if ((active_device = active_device = nmwa_dbus_get_string (connection, NM_DBUS_PATH, "getActiveDevice")))
{
if (strlen (active_device) > 0)
{ {
int type; int type;
@ -261,12 +274,15 @@ char * nmwa_dbus_get_active_wireless_device (DBusConnection *connection)
dbus_free (active_device); dbus_free (active_device);
active_device = NULL; active_device = NULL;
} }
else
fprintf (stderr, "nmwa_dbus_get_active_wireless_device(): device GOOD\n");
} }
else else
fprintf (stderr, "nmwa_dbus_get_active_wireless_device(): could not get string from dbus\n"); {
dbus_free (active_device);
active_device = NULL;
}
}
fprintf( stderr, "get_active_device() returning '%s'\n", active_device);
return (active_device); return (active_device);
} }
@ -308,13 +324,19 @@ fprintf( stderr, "!active_network\n");
/* Get each of the networks in turn and add them to the menu */ /* Get each of the networks in turn and add them to the menu */
if ((networks = nmwa_dbus_get_string_array (connection, active_device, "getNetworks", &num_items))) if ((networks = nmwa_dbus_get_string_array (connection, active_device, "getNetworks", &num_items)))
{ {
fprintf ( stderr, "foobar\n");
if (strlen (networks[0]) == 0) if (strlen (networks[0]) == 0)
{
fprintf ( stderr, "foobar2\n");
nmwa_add_menu_item ("No wireless networks found...", FALSE, user_data); nmwa_add_menu_item ("No wireless networks found...", FALSE, user_data);
}
else else
{ {
fprintf ( stderr, "foobar3\n");
int i; int i;
for (i = 0; i < num_items; i++) for (i = 0; i < num_items; i++)
{ {
fprintf ( stderr, "foobar %d\n", i + 10);
char *name = nmwa_dbus_get_string (connection, networks[i], "getName"); char *name = nmwa_dbus_get_string (connection, networks[i], "getName");
nmwa_add_menu_item (name, (strcmp (networks[i], active_network) == 0), user_data); nmwa_add_menu_item (name, (strcmp (networks[i], active_network) == 0), user_data);
dbus_free (name); dbus_free (name);
@ -325,6 +347,7 @@ fprintf( stderr, "!active_network\n");
else else
fprintf( stderr, "!networks\n"); fprintf( stderr, "!networks\n");
fprintf( stderr, "done iwth menu population\n");
dbus_free (active_device); dbus_free (active_device);
} }
@ -407,7 +430,7 @@ DBusConnection * nmwa_dbus_init (gpointer user_data)
if (!dbus_connection_add_filter (connection, nmwa_dbus_filter, user_data, NULL)) if (!dbus_connection_add_filter (connection, nmwa_dbus_filter, user_data, NULL))
return (NULL); return (NULL);
dbus_connection_set_exit_on_disconnect (connection, FALSE); // dbus_connection_set_exit_on_disconnect (connection, FALSE);
dbus_connection_setup_with_g_main (connection, NULL); dbus_connection_setup_with_g_main (connection, NULL);
dbus_bus_add_match(connection, dbus_bus_add_match(connection,