mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-03-23 00:20:43 +01:00
2005-08-26 Christopher Aillon <caillon@redhat.com>
* Fix up VPN state handling between the applet and NetworkManager, so that the applet doesn't show a VPN as connected when one really is not - The applet no longer has a pointer to the active VPN's name, but tracks each VPNs state individually - NM no longer has a "getActiveVPNConnection" method - NM no longer broadcasts the "VPNConnectionChange" signal - NM now broadcasts a "VPNConnectionStateChange" signal whenever the state of a VPN changes git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@902 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
7126181b5c
commit
2ea235020b
12 changed files with 153 additions and 188 deletions
26
ChangeLog
26
ChangeLog
|
|
@ -1,12 +1,24 @@
|
|||
2005-08-26 Christopher Aillon <caillon@redhat.com>
|
||||
|
||||
* Fix up VPN state handling between the applet and NetworkManager,
|
||||
so that the applet doesn't show a VPN as connected when one
|
||||
really is not
|
||||
- The applet no longer has a pointer to the active VPN's
|
||||
name, but tracks each VPNs state individually
|
||||
- NM no longer has a "getActiveVPNConnection" method
|
||||
- NM no longer broadcasts the "VPNConnectionChange" signal
|
||||
- NM now broadcasts a "VPNConnectionStateChange" signal
|
||||
whenever the state of a VPN changes
|
||||
|
||||
2005-08-26 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* gnome/applet/applet-dbus-devices.c
|
||||
gnome/applet/applet-dbus-vpn.c
|
||||
- Remove calls to dbus_pending_call_ref() because we already
|
||||
"own" the pending call
|
||||
- Remove calls to dbus_pending_call_get_completed() because
|
||||
when we are in the callback, the pending call is completed
|
||||
by definition
|
||||
* gnome/applet/applet-dbus-devices.c
|
||||
gnome/applet/applet-dbus-vpn.c
|
||||
- Remove calls to dbus_pending_call_ref() because we already
|
||||
"own" the pending call
|
||||
- Remove calls to dbus_pending_call_get_completed() because
|
||||
when we are in the callback, the pending call is completed
|
||||
by definition
|
||||
|
||||
2005-08-22 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
|
|
|
|||
|
|
@ -38,82 +38,49 @@ static void nmwa_free_gui_vpn_connections (NMWirelessApplet *applet);
|
|||
static void nmwa_free_dbus_vpn_connections (NMWirelessApplet *applet);
|
||||
static void nmwa_dbus_vpn_schedule_copy (NMWirelessApplet *applet);
|
||||
|
||||
/*
|
||||
* nmwa_dbus_vpn_get_active_vpn_connection_cb
|
||||
*
|
||||
* Callback from nmwa_dbus_vpn_get_active_vpn_connection
|
||||
*
|
||||
*/
|
||||
static void nmwa_dbus_vpn_get_active_vpn_connection_cb (DBusPendingCall *pcall, void *user_data)
|
||||
{
|
||||
DBusMessage * reply;
|
||||
NMWirelessApplet * applet = (NMWirelessApplet *) user_data;
|
||||
const char * act_vpn;
|
||||
|
||||
g_return_if_fail (pcall != NULL);
|
||||
g_return_if_fail (applet != NULL);
|
||||
|
||||
if (!(reply = dbus_pending_call_steal_reply (pcall)))
|
||||
goto out;
|
||||
|
||||
if ( dbus_message_is_error (reply, NM_DBUS_NO_ACTIVE_VPN_CONNECTION)
|
||||
|| dbus_message_is_error (reply, NM_DBUS_NO_VPN_CONNECTIONS))
|
||||
{
|
||||
/* Remove the active VPN connection if one exists */
|
||||
if (applet->dbus_active_vpn_name)
|
||||
{
|
||||
g_free (applet->dbus_active_vpn_name);
|
||||
applet->dbus_active_vpn_name = NULL;
|
||||
}
|
||||
|
||||
dbus_message_unref (reply);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &act_vpn, DBUS_TYPE_INVALID))
|
||||
{
|
||||
g_free (applet->dbus_active_vpn_name);
|
||||
if (strlen (act_vpn))
|
||||
applet->dbus_active_vpn_name = g_strdup (act_vpn);
|
||||
else
|
||||
applet->dbus_active_vpn_name = NULL;
|
||||
}
|
||||
dbus_message_unref (reply);
|
||||
|
||||
out:
|
||||
applet->vpn_pending_call_list = g_slist_remove (applet->vpn_pending_call_list, pcall);
|
||||
nmwa_dbus_vpn_schedule_copy (applet);
|
||||
|
||||
dbus_pending_call_unref (pcall);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmwa_dbus_vpn_get_active_vpn_connection
|
||||
*
|
||||
* Get the active VPN connection from NetworkManager
|
||||
* Get the active VPN connection from the dbus side of the applet
|
||||
*
|
||||
*/
|
||||
void nmwa_dbus_vpn_get_active_vpn_connection (NMWirelessApplet *applet)
|
||||
VPNConnection *nmwa_dbus_vpn_get_active_vpn_connection (NMWirelessApplet *applet)
|
||||
{
|
||||
DBusMessage * message;
|
||||
DBusPendingCall * pcall = NULL;
|
||||
GSList *elt;
|
||||
|
||||
g_return_val_if_fail (applet != NULL, NULL);
|
||||
|
||||
for (elt = applet->dbus_vpn_connections; elt; elt = g_slist_next (elt))
|
||||
{
|
||||
VPNConnection *vpn = (VPNConnection*) elt->data;
|
||||
NMVPNState vpn_state = nmwa_vpn_connection_get_state (vpn);
|
||||
|
||||
if (vpn_state == NM_VPN_STATE_STARTED)
|
||||
return vpn;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* nmwa_dbus_vpn_update_vpn_connection_state
|
||||
*
|
||||
* Sets the state for a dbus vpn connection and schedules a copy to the applet gui.
|
||||
*/
|
||||
void nmwa_dbus_vpn_update_vpn_connection_state (NMWirelessApplet *applet, const char *vpn_name, NMVPNState vpn_state)
|
||||
{
|
||||
VPNConnection *vpn;
|
||||
|
||||
g_return_if_fail (applet != NULL);
|
||||
|
||||
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH_VPN, NM_DBUS_INTERFACE_VPN, "getActiveVPNConnection")))
|
||||
vpn = nmwa_vpn_connection_find_by_name (applet->dbus_vpn_connections, vpn_name);
|
||||
if (vpn != NULL)
|
||||
{
|
||||
dbus_connection_send_with_reply (applet->connection, message, &pcall, -1);
|
||||
dbus_message_unref (message);
|
||||
if (pcall)
|
||||
{
|
||||
dbus_pending_call_set_notify (pcall, nmwa_dbus_vpn_get_active_vpn_connection_cb, applet, NULL);
|
||||
applet->vpn_pending_call_list = g_slist_append (applet->vpn_pending_call_list, pcall);
|
||||
}
|
||||
nmwa_vpn_connection_set_state (vpn, vpn_state);
|
||||
nmwa_dbus_vpn_schedule_copy (applet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
typedef struct VpnPropsCBData
|
||||
{
|
||||
NMWirelessApplet * applet;
|
||||
|
|
@ -144,7 +111,9 @@ static void nmwa_dbus_vpn_properties_cb (DBusPendingCall *pcall, void *user_data
|
|||
const char * name;
|
||||
const char * user_name;
|
||||
const char * service;
|
||||
|
||||
NMVPNState state;
|
||||
dbus_uint32_t state_int;
|
||||
|
||||
g_return_if_fail (pcall != NULL);
|
||||
g_return_if_fail (cb_data != NULL);
|
||||
g_return_if_fail (cb_data->applet != NULL);
|
||||
|
|
@ -157,34 +126,28 @@ static void nmwa_dbus_vpn_properties_cb (DBusPendingCall *pcall, void *user_data
|
|||
|
||||
if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR)
|
||||
{
|
||||
if (dbus_message_is_error (reply, NM_DBUS_INVALID_VPN_CONNECTION))
|
||||
{
|
||||
VPNConnection * vpn;
|
||||
|
||||
if (applet->dbus_active_vpn_name && cb_data->name && !strcmp (applet->dbus_active_vpn_name, cb_data->name))
|
||||
{
|
||||
g_free (applet->dbus_active_vpn_name);
|
||||
applet->dbus_active_vpn_name = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
dbus_message_unref (reply);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &user_name, DBUS_TYPE_STRING, &service, DBUS_TYPE_INVALID))
|
||||
if (dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &user_name,
|
||||
DBUS_TYPE_STRING, &service, DBUS_TYPE_UINT32, &state_int, DBUS_TYPE_INVALID))
|
||||
{
|
||||
VPNConnection * vpn;
|
||||
|
||||
state = (NMVPNState) state_int;
|
||||
|
||||
/* If its already there, update the service, otherwise add it to the list */
|
||||
if ((vpn = nmwa_vpn_connection_find_by_name (applet->dbus_vpn_connections, name)))
|
||||
{
|
||||
nmwa_vpn_connection_set_service (vpn, service);
|
||||
nmwa_vpn_connection_set_state (vpn, state);
|
||||
}
|
||||
else
|
||||
{
|
||||
vpn = nmwa_vpn_connection_new (name);
|
||||
nmwa_vpn_connection_set_service (vpn, service);
|
||||
nmwa_vpn_connection_set_state (vpn, state);
|
||||
applet->dbus_vpn_connections = g_slist_append (applet->dbus_vpn_connections, vpn);
|
||||
}
|
||||
}
|
||||
|
|
@ -321,12 +284,6 @@ void nmwa_dbus_vpn_remove_one_vpn_connection (NMWirelessApplet *applet, const ch
|
|||
if ((vpn = nmwa_vpn_connection_find_by_name (applet->dbus_vpn_connections, vpn_name)))
|
||||
{
|
||||
applet->dbus_vpn_connections = g_slist_remove (applet->dbus_vpn_connections, vpn);
|
||||
if (applet->dbus_active_vpn_name != NULL &&
|
||||
!strcmp (applet->dbus_active_vpn_name, nmwa_vpn_connection_get_name (vpn)))
|
||||
{
|
||||
g_free (applet->dbus_active_vpn_name);
|
||||
applet->dbus_active_vpn_name = NULL;
|
||||
}
|
||||
nmwa_vpn_connection_unref (vpn);
|
||||
nmwa_dbus_vpn_schedule_copy (applet);
|
||||
}
|
||||
|
|
@ -350,13 +307,8 @@ static gboolean nmwa_dbus_vpn_connections_lock_and_copy (NMWirelessApplet *apple
|
|||
/* Only copy over if we have a complete data model */
|
||||
if (g_slist_length (applet->vpn_pending_call_list) == 0)
|
||||
{
|
||||
VPNConnection * act_vpn = NULL;
|
||||
GSList * elt;
|
||||
|
||||
/* Match up the active vpn with a device in the list */
|
||||
if (applet->dbus_active_vpn_name)
|
||||
act_vpn = nmwa_vpn_connection_find_by_name (applet->dbus_vpn_connections, applet->dbus_active_vpn_name);
|
||||
|
||||
/* Now copy the data over to the GUI side */
|
||||
g_mutex_lock (applet->data_mutex);
|
||||
|
||||
|
|
@ -370,14 +322,7 @@ static gboolean nmwa_dbus_vpn_connections_lock_and_copy (NMWirelessApplet *apple
|
|||
|
||||
new_vpn = nmwa_vpn_connection_copy (src_vpn);
|
||||
if (new_vpn)
|
||||
{
|
||||
applet->gui_vpn_connections = g_slist_append (applet->gui_vpn_connections, new_vpn);
|
||||
if (src_vpn == act_vpn)
|
||||
{
|
||||
nmwa_vpn_connection_ref (new_vpn);
|
||||
applet->gui_active_vpn = new_vpn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_mutex_unlock (applet->data_mutex);
|
||||
|
|
@ -413,10 +358,6 @@ static void nmwa_free_gui_vpn_connections (NMWirelessApplet *applet)
|
|||
{
|
||||
g_return_if_fail (applet != NULL);
|
||||
|
||||
if (applet->gui_active_vpn)
|
||||
nmwa_vpn_connection_unref (applet->gui_active_vpn);
|
||||
applet->gui_active_vpn = NULL;
|
||||
|
||||
if (applet->gui_vpn_connections)
|
||||
{
|
||||
g_slist_foreach (applet->gui_vpn_connections, (GFunc) nmwa_vpn_connection_unref, NULL);
|
||||
|
|
@ -428,13 +369,8 @@ static void nmwa_free_gui_vpn_connections (NMWirelessApplet *applet)
|
|||
|
||||
static void nmwa_free_dbus_vpn_connections (NMWirelessApplet *applet)
|
||||
{
|
||||
GSList *elt;
|
||||
|
||||
g_return_if_fail (applet != NULL);
|
||||
|
||||
g_free (applet->dbus_active_vpn_name);
|
||||
applet->dbus_active_vpn_name = NULL;
|
||||
|
||||
if (applet->dbus_vpn_connections)
|
||||
{
|
||||
g_slist_foreach (applet->dbus_vpn_connections, (GFunc) nmwa_vpn_connection_unref, NULL);
|
||||
|
|
|
|||
|
|
@ -30,10 +30,9 @@
|
|||
void nmwa_dbus_vpn_update_one_vpn_connection (NMWirelessApplet *applet, const char *vpn_name);
|
||||
void nmwa_dbus_vpn_update_vpn_connections (NMWirelessApplet *applet);
|
||||
void nmwa_dbus_vpn_remove_one_vpn_connection (NMWirelessApplet *applet, const char *vpn_name);
|
||||
void nmwa_dbus_vpn_get_active_vpn_connection (NMWirelessApplet *applet);
|
||||
|
||||
void nmwa_dbus_vpn_activate_connection (DBusConnection *connection, const char *name, GSList *passwords);
|
||||
void nmwa_dbus_vpn_deactivate_connection (DBusConnection *connection);
|
||||
|
||||
void nmwa_dbus_vpn_update_vpn_connection_state (NMWirelessApplet *applet, const char *vpn_name, NMVPNState vpn_state);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -520,9 +520,16 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
|
|||
if (dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID))
|
||||
nmwa_dbus_vpn_update_one_vpn_connection (applet, name);
|
||||
}
|
||||
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE_VPN, "VPNConnectionChange")) /* Active VPN connection changed */
|
||||
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE_VPN, "VPNConnectionStateChange")) /* Active VPN connection changed */
|
||||
{
|
||||
nmwa_dbus_vpn_get_active_vpn_connection (applet);
|
||||
char *name = NULL;
|
||||
NMVPNState vpn_state;
|
||||
dbus_uint32_t vpn_state_int;
|
||||
if (dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &name, DBUS_TYPE_UINT32, &vpn_state_int, DBUS_TYPE_INVALID))
|
||||
{
|
||||
vpn_state = (NMVPNState) vpn_state_int;
|
||||
nmwa_dbus_vpn_update_vpn_connection_state (applet, name, vpn_state);
|
||||
}
|
||||
}
|
||||
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE_VPN, "VPNConnectionRemoved"))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -597,8 +597,8 @@ void nmwa_schedule_vpn_login_banner_dialog (NMWirelessApplet *applet, const char
|
|||
g_return_if_fail (banner != NULL);
|
||||
|
||||
msg2 = g_strdup_printf (_("VPN connection '%s' said:"), vpn_name);
|
||||
msg = g_strdup_printf (_("<span weight=\"bold\" size=\"larger\">%s</span>\n\n"
|
||||
"%s\n\n\"%s\""), _("VPN Login Message"), msg2, banner);
|
||||
msg = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s\n\n\"%s\"",
|
||||
_("VPN Login Message"), msg2, banner);
|
||||
g_free (msg2);
|
||||
|
||||
g_idle_add ((GSourceFunc) nmwa_show_vpn_login_banner_dialog, msg);
|
||||
|
|
@ -865,16 +865,39 @@ out:
|
|||
}
|
||||
|
||||
|
||||
VPNConnection* nmwa_get_active_vpn_connection (NMWirelessApplet *applet)
|
||||
{
|
||||
VPNConnection *vpn;
|
||||
NMVPNState vpn_state;
|
||||
GSList *elt;
|
||||
|
||||
elt = applet->gui_vpn_connections;
|
||||
|
||||
for (; elt; elt = g_slist_next (elt))
|
||||
{
|
||||
vpn = (VPNConnection*) elt->data;
|
||||
vpn_state = nmwa_vpn_connection_get_state (vpn);
|
||||
if (vpn_state == NM_VPN_STATE_STARTED)
|
||||
return vpn;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void nmwa_set_icon (NMWirelessApplet *applet, GdkPixbuf *new_icon)
|
||||
{
|
||||
GdkPixbuf *composite;
|
||||
VPNConnection *vpn;
|
||||
|
||||
g_return_if_fail (applet != NULL);
|
||||
g_return_if_fail (new_icon != NULL);
|
||||
|
||||
composite = gdk_pixbuf_copy (new_icon);
|
||||
|
||||
if (applet->gui_active_vpn)
|
||||
vpn = nmwa_get_active_vpn_connection (applet);
|
||||
|
||||
if (vpn)
|
||||
{
|
||||
int dest_x = gdk_pixbuf_get_width (new_icon) - gdk_pixbuf_get_width (applet->vpn_lock_icon);
|
||||
int dest_y = gdk_pixbuf_get_height (new_icon) - gdk_pixbuf_get_height (applet->vpn_lock_icon) - 2;
|
||||
|
|
@ -1029,13 +1052,13 @@ static void nmwa_update_state (NMWirelessApplet *applet)
|
|||
{
|
||||
gboolean show_applet = TRUE;
|
||||
gboolean need_animation = FALSE;
|
||||
gboolean active_vpn = FALSE;
|
||||
GdkPixbuf * pixbuf = NULL;
|
||||
GdkPixbuf * progress = NULL;
|
||||
gint strength = -1;
|
||||
char * tip = NULL;
|
||||
WirelessNetwork * active_network = NULL;
|
||||
NetworkDevice * act_dev = NULL;
|
||||
VPNConnection *vpn;
|
||||
|
||||
g_mutex_lock (applet->data_mutex);
|
||||
|
||||
|
|
@ -1109,11 +1132,12 @@ done:
|
|||
if (!applet->tooltips)
|
||||
applet->tooltips = gtk_tooltips_new ();
|
||||
|
||||
if (applet->gui_active_vpn != NULL) {
|
||||
vpn = nmwa_get_active_vpn_connection (applet);
|
||||
if (vpn != NULL) {
|
||||
char *newtip;
|
||||
char *vpntip;
|
||||
|
||||
vpntip = g_strdup_printf (_("VPN connection to '%s'"), nmwa_vpn_connection_get_name (applet->gui_active_vpn));
|
||||
vpntip = g_strdup_printf (_("VPN connection to '%s'"), nmwa_vpn_connection_get_name (vpn));
|
||||
newtip = g_strconcat (tip, "\n", vpntip, NULL);
|
||||
g_free (vpntip);
|
||||
g_free (tip);
|
||||
|
|
@ -1292,7 +1316,8 @@ static void nmwa_menu_vpn_item_activate (GtkMenuItem *item, gpointer user_data)
|
|||
const char *name = nmwa_vpn_connection_get_name (vpn);
|
||||
GSList *passwords;
|
||||
|
||||
if (vpn != applet->gui_active_vpn)
|
||||
VPNConnection *active_vpn = nmwa_get_active_vpn_connection (applet);
|
||||
if (vpn != active_vpn)
|
||||
{
|
||||
char *gconf_key;
|
||||
char *escaped_name;
|
||||
|
|
@ -1656,6 +1681,7 @@ static void nmwa_menu_add_vpn_menu (GtkWidget *menu, NMWirelessApplet *applet)
|
|||
GtkMenu *vpn_menu;
|
||||
GtkMenuItem *other_item;
|
||||
GSList *elt;
|
||||
VPNConnection *active_vpn;
|
||||
|
||||
g_return_if_fail (menu != NULL);
|
||||
g_return_if_fail (applet != NULL);
|
||||
|
|
@ -1663,6 +1689,8 @@ static void nmwa_menu_add_vpn_menu (GtkWidget *menu, NMWirelessApplet *applet)
|
|||
item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("_VPN Connections")));
|
||||
|
||||
vpn_menu = GTK_MENU (gtk_menu_new ());
|
||||
active_vpn = nmwa_get_active_vpn_connection (applet);
|
||||
|
||||
for (elt = applet->gui_vpn_connections; elt; elt = g_slist_next (elt))
|
||||
{
|
||||
GtkCheckMenuItem *vpn_item;
|
||||
|
|
@ -1673,7 +1701,7 @@ static void nmwa_menu_add_vpn_menu (GtkWidget *menu, NMWirelessApplet *applet)
|
|||
nmwa_vpn_connection_ref (vpn);
|
||||
g_object_set_data (G_OBJECT (vpn_item), "vpn", vpn);
|
||||
|
||||
if (applet->gui_active_vpn && (strcmp (vpn_name, nmwa_vpn_connection_get_name (applet->gui_active_vpn)) == 0))
|
||||
if (active_vpn && active_vpn == vpn)
|
||||
gtk_check_menu_item_set_active (vpn_item, TRUE);
|
||||
|
||||
g_signal_connect (G_OBJECT (vpn_item), "activate", G_CALLBACK (nmwa_menu_vpn_item_activate), applet);
|
||||
|
|
@ -1693,7 +1721,7 @@ static void nmwa_menu_add_vpn_menu (GtkWidget *menu, NMWirelessApplet *applet)
|
|||
|
||||
other_item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("_Disconnect VPN...")));
|
||||
g_signal_connect (G_OBJECT (other_item), "activate", G_CALLBACK (nmwa_menu_disconnect_vpn_item_activate), applet);
|
||||
if (!applet->gui_active_vpn)
|
||||
if (!active_vpn)
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (other_item), FALSE);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (vpn_menu), GTK_WIDGET (other_item));
|
||||
|
||||
|
|
@ -2399,12 +2427,10 @@ static GtkWidget * nmwa_get_instance (NMWirelessApplet *applet)
|
|||
applet->nm_running = FALSE;
|
||||
applet->dev_pending_call_list = NULL;
|
||||
applet->dbus_device_list = NULL;
|
||||
applet->dbus_active_vpn_name = NULL;
|
||||
applet->dbus_vpn_connections = NULL;
|
||||
applet->dbus_nm_state = NM_STATE_DISCONNECTED;
|
||||
applet->vpn_pending_call_list = NULL;
|
||||
applet->gui_device_list = NULL;
|
||||
applet->gui_active_vpn = NULL;
|
||||
applet->gui_vpn_connections = NULL;
|
||||
applet->dialup_list = NULL;
|
||||
applet->gui_nm_state = NM_STATE_DISCONNECTED;
|
||||
|
|
|
|||
|
|
@ -103,10 +103,8 @@ typedef struct
|
|||
GSList * dialup_list;
|
||||
|
||||
GSList * gui_vpn_connections;
|
||||
VPNConnection * gui_active_vpn;
|
||||
|
||||
GSList * vpn_pending_call_list;
|
||||
char * dbus_active_vpn_name;
|
||||
GSList * dbus_vpn_connections;
|
||||
|
||||
GdkPixbuf * no_connection_icon;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ struct VPNConnection
|
|||
int refcount;
|
||||
char *name;
|
||||
char *service;
|
||||
NMVPNState state;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -55,7 +56,8 @@ VPNConnection *nmwa_vpn_connection_copy (VPNConnection *src_vpn)
|
|||
dst_vpn->refcount = 1;
|
||||
dst_vpn->name = g_strdup (src_vpn->name);
|
||||
dst_vpn->service = src_vpn->service ? g_strdup (src_vpn->service) : NULL;
|
||||
|
||||
dst_vpn->state = src_vpn->state;
|
||||
|
||||
return dst_vpn;
|
||||
}
|
||||
|
||||
|
|
@ -134,4 +136,16 @@ VPNConnection *nmwa_vpn_connection_find_by_name (GSList *list, const char *name)
|
|||
return vpn;
|
||||
}
|
||||
|
||||
NMVPNState nmwa_vpn_connection_get_state (VPNConnection *vpn)
|
||||
{
|
||||
g_return_val_if_fail (vpn != NULL, NM_VPN_STATE_UNKNOWN);
|
||||
|
||||
return vpn->state;
|
||||
}
|
||||
|
||||
void nmwa_vpn_connection_set_state (VPNConnection *vpn, NMVPNState state)
|
||||
{
|
||||
g_return_if_fail (vpn != NULL);
|
||||
|
||||
vpn->state = state;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ const char * nmwa_vpn_connection_get_name (VPNConnection *vpn);
|
|||
const char * nmwa_vpn_connection_get_service (VPNConnection *vpn);
|
||||
void nmwa_vpn_connection_set_service (VPNConnection *vpn, const char *service);
|
||||
|
||||
NMVPNState nmwa_vpn_connection_get_state (VPNConnection *vpn);
|
||||
void nmwa_vpn_connection_set_state (VPNConnection *vpn, NMVPNState state);
|
||||
|
||||
VPNConnection * nmwa_vpn_connection_find_by_name (GSList *list, const char *name);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -59,33 +59,34 @@ void nm_dbus_vpn_signal_vpn_connection_update (DBusConnection *con, NMVPNConnect
|
|||
dbus_message_unref (message);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_dbus_vpn_signal_vpn_connection_change
|
||||
*
|
||||
* Notifies the bus that the current VPN connection, if any, has changed.
|
||||
* nm_dbus_vpn_signal_vpn_connection_state_change
|
||||
*
|
||||
* Notifies the bus that a VPN connection's state has changed.
|
||||
*/
|
||||
void nm_dbus_vpn_signal_vpn_connection_change (DBusConnection *con, NMVPNConnection *vpn)
|
||||
void nm_dbus_vpn_signal_vpn_connection_state_change (DBusConnection *con, NMVPNConnection *vpn)
|
||||
{
|
||||
DBusMessage *message;
|
||||
const char *vpn_name;
|
||||
NMVPNService *service;
|
||||
NMVPNState vpn_state;
|
||||
|
||||
g_return_if_fail (con != NULL);
|
||||
g_return_if_fail (vpn != NULL);
|
||||
|
||||
if (!(message = dbus_message_new_signal (NM_DBUS_PATH_VPN, NM_DBUS_INTERFACE_VPN, "VPNConnectionChange")))
|
||||
if (!(message = dbus_message_new_signal (NM_DBUS_PATH_VPN, NM_DBUS_INTERFACE_VPN, "VPNConnectionStateChange")))
|
||||
{
|
||||
nm_warning ("Not enough memory for new dbus message!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (vpn)
|
||||
vpn_name = nm_vpn_connection_get_name (vpn);
|
||||
else
|
||||
vpn_name = "";
|
||||
dbus_message_append_args (message, DBUS_TYPE_STRING, &vpn_name, DBUS_TYPE_INVALID);
|
||||
vpn_name = nm_vpn_connection_get_name (vpn);
|
||||
service = nm_vpn_connection_get_service (vpn);
|
||||
vpn_state = nm_vpn_service_get_state (service);
|
||||
|
||||
dbus_message_append_args (message, DBUS_TYPE_STRING, &vpn_name, DBUS_TYPE_UINT32, &vpn_state, DBUS_TYPE_INVALID);
|
||||
if (!dbus_connection_send (con, message, NULL))
|
||||
nm_warning ("Could not raise the VPNConnectionChange signal!");
|
||||
nm_warning ("Could not raise the VPNConnectionStateChange signal!");
|
||||
|
||||
dbus_message_unref (message);
|
||||
}
|
||||
|
|
@ -619,12 +620,16 @@ static DBusMessage *nm_dbus_vpn_get_vpn_connection_properties (DBusConnection *c
|
|||
if ((vpn_con = nm_vpn_manager_find_connection_by_name (data->data->vpn_manager, name)))
|
||||
{
|
||||
const char *user_name;
|
||||
const char *service;
|
||||
const char *service_name;
|
||||
NMVPNService *service;
|
||||
NMVPNState state;
|
||||
|
||||
user_name = nm_vpn_connection_get_user_name (vpn_con);
|
||||
service = nm_vpn_service_get_service_name (nm_vpn_connection_get_service (vpn_con));
|
||||
service = nm_vpn_connection_get_service (vpn_con);
|
||||
service_name = nm_vpn_service_get_service_name (service);
|
||||
state = nm_vpn_service_get_state (service);
|
||||
|
||||
dbus_message_append_args (reply, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &user_name, DBUS_TYPE_STRING, &service, DBUS_TYPE_INVALID);
|
||||
dbus_message_append_args (reply, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &user_name, DBUS_TYPE_STRING, &service_name, DBUS_TYPE_UINT32, &state, DBUS_TYPE_INVALID);
|
||||
good = TRUE;
|
||||
}
|
||||
}
|
||||
|
|
@ -636,40 +641,6 @@ static DBusMessage *nm_dbus_vpn_get_vpn_connection_properties (DBusConnection *c
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_dbus_vpn_get_active_vpn_connection
|
||||
*
|
||||
* Return the name of the currently active VPN connection.
|
||||
*
|
||||
*/
|
||||
static DBusMessage *nm_dbus_vpn_get_active_vpn_connection (DBusConnection *connection, DBusMessage *message, NMDbusCBData *data)
|
||||
{
|
||||
DBusMessage *reply = NULL;
|
||||
const char *name;
|
||||
NMVPNConnection *vpn = NULL;
|
||||
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
g_return_val_if_fail (data->data != NULL, NULL);
|
||||
g_return_val_if_fail (connection != NULL, NULL);
|
||||
g_return_val_if_fail (message != NULL, NULL);
|
||||
|
||||
/* Check for no VPN Manager */
|
||||
if (!data->data->vpn_manager)
|
||||
return nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_VPN, "NoVPNConnections", "There are no available VPN connections.");
|
||||
|
||||
if (!(vpn = nm_vpn_manager_get_active_vpn_connection (data->data->vpn_manager)))
|
||||
return nm_dbus_create_error_message (message, NM_DBUS_INTERFACE_VPN, "NoActiveVPNConnection", "There is no active VPN connection.");
|
||||
|
||||
if (!(reply = dbus_message_new_method_return (message)))
|
||||
return NULL;
|
||||
|
||||
name = nm_vpn_connection_get_name (vpn);
|
||||
dbus_message_append_args (reply, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_dbus_vpn_activate_connection
|
||||
*
|
||||
|
|
@ -755,7 +726,6 @@ NMDbusMethodList *nm_dbus_vpn_methods_setup (void)
|
|||
|
||||
nm_dbus_method_list_add_method (list, "getVPNConnections", nm_dbus_vpn_get_vpn_connections);
|
||||
nm_dbus_method_list_add_method (list, "getVPNConnectionProperties", nm_dbus_vpn_get_vpn_connection_properties);
|
||||
nm_dbus_method_list_add_method (list, "getActiveVPNConnection", nm_dbus_vpn_get_active_vpn_connection);
|
||||
nm_dbus_method_list_add_method (list, "activateVPNConnection", nm_dbus_vpn_activate_connection);
|
||||
nm_dbus_method_list_add_method (list, "deactivateVPNConnection", nm_dbus_vpn_deactivate_connection);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,14 +26,13 @@
|
|||
#include "nm-vpn-manager.h"
|
||||
#include "nm-vpn-connection.h"
|
||||
|
||||
|
||||
void nm_dbus_vpn_schedule_vpn_connections_update (NMData *app_data);
|
||||
void nm_dbus_vpn_update_one_vpn_connection (DBusConnection *connection, const char *vpn, NMData *data);
|
||||
|
||||
void nm_dbus_vpn_signal_vpn_connection_update (DBusConnection *con, NMVPNConnection *vpn, const char *signal);
|
||||
void nm_dbus_vpn_signal_vpn_connection_change (DBusConnection *con, NMVPNConnection *vpn);
|
||||
void nm_dbus_vpn_signal_vpn_failed (DBusConnection *con, const char *signal, NMVPNConnection *vpn, const char *error_msg);
|
||||
void nm_dbus_vpn_signal_vpn_login_banner (DBusConnection *con, NMVPNConnection *vpn, const char *banner);
|
||||
void nm_dbus_vpn_signal_vpn_connection_state_change (DBusConnection *con, NMVPNConnection *vpn);
|
||||
|
||||
char ** nm_dbus_vpn_get_routes (DBusConnection *connection, NMVPNConnection *vpn, int *num_items);
|
||||
|
||||
|
|
|
|||
|
|
@ -226,8 +226,6 @@ static void nm_vpn_manager_set_active_vpn_connection (NMVPNManager *manager, NMV
|
|||
manager->active_device = NULL;
|
||||
}
|
||||
|
||||
nm_dbus_vpn_signal_vpn_connection_change (manager->app_data->dbus_connection, con);
|
||||
|
||||
/* If passed NULL (clear active connection) there's nothing more to do */
|
||||
if (!con)
|
||||
return;
|
||||
|
|
@ -570,13 +568,17 @@ gboolean nm_vpn_manager_process_signal (NMVPNManager *manager, DBusMessage *mess
|
|||
}
|
||||
else if (dbus_message_is_signal (message, service_name, NM_DBUS_VPN_SIGNAL_STATE_CHANGE))
|
||||
{
|
||||
NMVPNState old_state;
|
||||
NMVPNState new_state;
|
||||
dbus_uint32_t old_state_int;
|
||||
dbus_uint32_t new_state_int;
|
||||
|
||||
if (dbus_message_get_args (message, NULL, DBUS_TYPE_UINT32, &old_state, DBUS_TYPE_UINT32, &new_state, DBUS_TYPE_INVALID))
|
||||
if (dbus_message_get_args (message, NULL, DBUS_TYPE_UINT32, &old_state_int, DBUS_TYPE_UINT32, &new_state_int, DBUS_TYPE_INVALID))
|
||||
{
|
||||
NMVPNState old_state = (NMVPNState) old_state_int;
|
||||
NMVPNState new_state = (NMVPNState) new_state_int;
|
||||
|
||||
nm_info ("VPN service '%s' signaled new state %d, old state %d.", service_name, new_state, old_state);
|
||||
nm_vpn_service_set_state (service, new_state);
|
||||
nm_dbus_vpn_signal_vpn_connection_state_change (manager->app_data->dbus_connection, active);
|
||||
|
||||
/* If the VPN daemon state is now stopped and it was starting, clear the active connection */
|
||||
if (((new_state == NM_VPN_STATE_STOPPED) || (new_state == NM_VPN_STATE_SHUTDOWN) || (new_state == NM_VPN_STATE_STOPPING))
|
||||
|
|
@ -634,8 +636,7 @@ gboolean nm_vpn_manager_process_name_owner_changed (NMVPNManager *manager, const
|
|||
{
|
||||
/* VPN service went away. */
|
||||
nm_vpn_service_set_state (service, NM_VPN_STATE_SHUTDOWN);
|
||||
nm_vpn_manager_set_active_vpn_connection (manager, NULL);
|
||||
nm_dbus_vpn_signal_vpn_connection_change (manager->app_data->dbus_connection, active);
|
||||
nm_dbus_vpn_signal_vpn_connection_state_change (manager->app_data->dbus_connection, active);
|
||||
}
|
||||
|
||||
nm_vpn_connection_unref (active);
|
||||
|
|
@ -761,7 +762,6 @@ void nm_vpn_manager_deactivate_vpn_connection (NMVPNManager *manager)
|
|||
dbus_message_unref (message);
|
||||
|
||||
out:
|
||||
nm_vpn_manager_set_active_vpn_connection (manager, NULL);
|
||||
nm_vpn_connection_unref (active);
|
||||
|
||||
if ((dev = nm_get_active_device (manager->app_data)))
|
||||
|
|
|
|||
|
|
@ -915,6 +915,7 @@ static void nm_vpnc_dbus_process_helper_ip4_config (DBusConnection *con, DBusMes
|
|||
}
|
||||
|
||||
dbus_message_unref (signal);
|
||||
nm_vpnc_set_state (data, NM_VPN_STATE_STARTED);
|
||||
success = TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue