2006-02-26 Dan Williams <dcbw@redhat.com>
* configure.in gnome/applet/Makefile.am - Conditionalize all the notify stuff Merge most of Chris Aillon's notification patch: * gnome/applet/applet-notifications.[ch] - New files; show a notification * gnome/applet/applet-dbus-devices.[ch] - (nmwa_dbus_device_activated, nmwa_dbus_device_activated_cb, nmwa_dbus_device_deactivated, nmwa_dbus_device_deactivated_cb): new functions, do the right thing when a device change occurs * gnome/applet/applet-dbus.c - (nmwa_dbus_filter): Split out DeviceNowActive and DeviceNoLongerActive signals, so we can handle them specially * gnome/applet/applet.[ch] - nmwa_schedule_vpn_login_banner -> nmwa_show_vpn_login_banner - nmwa_schedule_vpn_failure_alert -> nmwa_show_vpn_failure_alert - (nmwa_notify_state): remove - (nmwa_update_state); remove call to nmwa_notify_state, since the notification work is now done when the appropriate dbus signals are received. - (nmwa_show_vpn_login_banner, nmwa_show_vpn_failure_alert): don't defer execution of the notification/dialog stuff. That was an artifact of the previous multi-threaded nature of the applet and is now pointless. - (nmwa_notify_vpn_failure, nmwa_notify_vpn_login_banner): remove, no longer needed. Function folded into applet-notifications.c * src/NetworkManagerPolicy.c - (nm_policy_activation_finish): send the AP along with the device status change signal, if the connection is wireless. Should fix the race where applet would show a connection to "unknown" git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1498 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
39
ChangeLog
39
ChangeLog
@@ -1,3 +1,42 @@
|
||||
2006-02-26 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* configure.in
|
||||
gnome/applet/Makefile.am
|
||||
- Conditionalize all the notify stuff
|
||||
|
||||
Merge most of Chris Aillon's notification patch:
|
||||
|
||||
* gnome/applet/applet-notifications.[ch]
|
||||
- New files; show a notification
|
||||
|
||||
* gnome/applet/applet-dbus-devices.[ch]
|
||||
- (nmwa_dbus_device_activated, nmwa_dbus_device_activated_cb,
|
||||
nmwa_dbus_device_deactivated, nmwa_dbus_device_deactivated_cb):
|
||||
new functions, do the right thing when a device change occurs
|
||||
|
||||
* gnome/applet/applet-dbus.c
|
||||
- (nmwa_dbus_filter): Split out DeviceNowActive and DeviceNoLongerActive
|
||||
signals, so we can handle them specially
|
||||
|
||||
* gnome/applet/applet.[ch]
|
||||
- nmwa_schedule_vpn_login_banner -> nmwa_show_vpn_login_banner
|
||||
- nmwa_schedule_vpn_failure_alert -> nmwa_show_vpn_failure_alert
|
||||
- (nmwa_notify_state): remove
|
||||
- (nmwa_update_state); remove call to nmwa_notify_state, since the
|
||||
notification work is now done when the appropriate dbus signals
|
||||
are received.
|
||||
- (nmwa_show_vpn_login_banner, nmwa_show_vpn_failure_alert): don't
|
||||
defer execution of the notification/dialog stuff. That was an
|
||||
artifact of the previous multi-threaded nature of the applet
|
||||
and is now pointless.
|
||||
- (nmwa_notify_vpn_failure, nmwa_notify_vpn_login_banner): remove,
|
||||
no longer needed. Function folded into applet-notifications.c
|
||||
|
||||
* src/NetworkManagerPolicy.c
|
||||
- (nm_policy_activation_finish): send the AP along with the device
|
||||
status change signal, if the connection is wireless. Should
|
||||
fix the race where applet would show a connection to "unknown"
|
||||
|
||||
2006-02-25 Robert Love <rml@novell.com>
|
||||
|
||||
Add WPA Enterprise support:
|
||||
|
@@ -165,6 +165,7 @@ if test "x$enable_notify" != "xno"; then
|
||||
AC_DEFINE_UNQUOTED([ENABLE_NOTIFY], [1],
|
||||
[Enable notifications with libnotify])
|
||||
fi
|
||||
AM_CONDITIONAL(WITH_NOTIFY, test x"$enable_notify" != xno)
|
||||
|
||||
PKG_CHECK_MODULES(LIBNL, libnl-1)
|
||||
AC_SUBST(LIBNL_CFLAGS)
|
||||
|
@@ -17,7 +17,6 @@ nm_applet_CPPFLAGS = \
|
||||
$(LIBGNOMEUI_CFLAGS) \
|
||||
$(PANEL_APPLET_CFLAGS) \
|
||||
$(GNOME_KEYRING_CFLAGS) \
|
||||
$(NOTIFY_CFLAGS) \
|
||||
-DICONDIR=\""$(datadir)/pixmaps"\" \
|
||||
-DGLADEDIR=\""$(gladedir)"\" \
|
||||
-DBINDIR=\""$(bindir)"\" \
|
||||
@@ -31,6 +30,10 @@ nm_applet_CPPFLAGS = \
|
||||
-DVERSION=\"$(VERSION)\" \
|
||||
$(NULL)
|
||||
|
||||
if WITH_NOTIFY
|
||||
nm_applet_CPPFLAGS += $(NOTIFY_CFLAGS)
|
||||
endif
|
||||
|
||||
nm_applet_SOURCES = \
|
||||
main.c \
|
||||
applet.c \
|
||||
@@ -91,6 +94,10 @@ nm_applet_SOURCES = \
|
||||
gconf-helpers.h \
|
||||
$(NULL)
|
||||
|
||||
if WITH_NOTIFY
|
||||
nm_applet_SOURCES += applet-notifications.c applet-notifications.h
|
||||
endif
|
||||
|
||||
nm_applet_LDADD = \
|
||||
$(DBUS_LIBS) \
|
||||
$(HAL_LIBS) \
|
||||
@@ -102,11 +109,14 @@ nm_applet_LDADD = \
|
||||
$(GCONF_LIBS) \
|
||||
$(LIBGNOMEUI_LIBS) \
|
||||
$(GNOME_KEYRING_LIBS) \
|
||||
$(NOTIFY_LIBS) \
|
||||
$(top_builddir)/utils/libnmutils.la \
|
||||
$(top_builddir)/libnm-util/libnm-util.la \
|
||||
$(NULL)
|
||||
|
||||
if WITH_NOTIFY
|
||||
nm_applet_LDADD += $(NOTIFY_LIBS)
|
||||
endif
|
||||
|
||||
|
||||
gladedir = $(datadir)/nm-applet
|
||||
glade_DATA = wireless-applet.glade keyring.png
|
||||
|
@@ -24,11 +24,16 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NOTIFY
|
||||
#include <libnotify/notify.h>
|
||||
#endif
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <dbus/dbus.h>
|
||||
#include <dbus/dbus-glib-lowlevel.h>
|
||||
#include "applet-notifications.h"
|
||||
#include "applet-dbus-devices.h"
|
||||
#include "applet-dbus.h"
|
||||
#include "applet.h"
|
||||
@@ -865,6 +870,130 @@ void nmwa_dbus_device_update_one_device (NMWirelessApplet *applet, const char *d
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct _DeviceActivatedCBData
|
||||
{
|
||||
NMWirelessApplet *applet;
|
||||
char *essid;
|
||||
} DeviceActivatedCBData;
|
||||
|
||||
static void free_device_activated_cb_data (DeviceActivatedCBData *obj)
|
||||
{
|
||||
if (!obj)
|
||||
return;
|
||||
|
||||
obj->applet = NULL;
|
||||
if (obj->essid)
|
||||
g_free (obj->essid);
|
||||
|
||||
memset (obj, 0, sizeof (DeviceActivatedCBData));
|
||||
g_free (obj);
|
||||
}
|
||||
|
||||
static void nmwa_dbus_device_activated_cb (DBusPendingCall *pcall, void *user_data)
|
||||
{
|
||||
DeviceActivatedCBData * cb_data = (DeviceActivatedCBData*) user_data;
|
||||
NMWirelessApplet * applet = cb_data->applet;
|
||||
char * essid = cb_data->essid;
|
||||
NetworkDevice * active_device;
|
||||
char * message = NULL;
|
||||
char * icon = NULL;
|
||||
|
||||
nmwa_dbus_device_properties_cb (pcall, applet);
|
||||
|
||||
/* Don't show anything if the applet isn't shown */
|
||||
if (!GTK_WIDGET_VISIBLE (GTK_WIDGET (applet)))
|
||||
goto out;
|
||||
|
||||
#ifdef ENABLE_NOTIFY
|
||||
active_device = nmwa_get_first_active_device (applet->device_list);
|
||||
if (active_device && network_device_is_wireless (active_device))
|
||||
{
|
||||
if (applet->is_adhoc)
|
||||
{
|
||||
message = g_strdup_printf (_("You are now connected to the Ad-Hoc wireless network '%s'."), essid);
|
||||
icon = "nm-adhoc";
|
||||
}
|
||||
else
|
||||
{
|
||||
message = g_strdup_printf (_("You are now connected to the wireless network '%s'."), essid);
|
||||
icon = "nm-device-wireless";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
message = g_strdup (_("You are now connected to the wired network."));
|
||||
icon = "nm-device-wired";
|
||||
}
|
||||
|
||||
nm_info ("%s", message);
|
||||
|
||||
nmwa_send_event_notification (applet, NOTIFY_URGENCY_LOW, _("Connection Established"), message, icon);
|
||||
g_free (message);
|
||||
#endif
|
||||
|
||||
out:
|
||||
free_device_activated_cb_data (cb_data);
|
||||
}
|
||||
|
||||
|
||||
void nmwa_dbus_device_activated (NMWirelessApplet *applet, const char *dev_path, const char *essid)
|
||||
{
|
||||
DBusMessage * message;
|
||||
DBusPendingCall * pcall = NULL;
|
||||
DeviceActivatedCBData *cb_data = NULL;
|
||||
|
||||
g_return_if_fail (applet != NULL);
|
||||
g_return_if_fail (dev_path != NULL);
|
||||
|
||||
cb_data = g_malloc0 (sizeof (DeviceActivatedCBData));
|
||||
cb_data->applet = applet;
|
||||
if (essid)
|
||||
cb_data->essid = g_strdup (essid);
|
||||
|
||||
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, dev_path, NM_DBUS_INTERFACE_DEVICES, "getProperties")))
|
||||
{
|
||||
dbus_connection_send_with_reply (applet->connection, message, &pcall, -1);
|
||||
if (pcall)
|
||||
dbus_pending_call_set_notify (pcall, nmwa_dbus_device_activated_cb, cb_data, NULL);
|
||||
dbus_message_unref (message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void nmwa_dbus_device_deactivated_cb (DBusPendingCall *pcall, void *user_data)
|
||||
{
|
||||
NMWirelessApplet * applet = (NMWirelessApplet *) user_data;
|
||||
|
||||
nmwa_dbus_device_properties_cb (pcall, applet);
|
||||
|
||||
#ifdef ENABLE_NOTIFY
|
||||
/* Don't show anything if the applet isn't shown */
|
||||
if (GTK_WIDGET_VISIBLE (GTK_WIDGET (applet)))
|
||||
{
|
||||
nmwa_send_event_notification (applet, NOTIFY_URGENCY_NORMAL, _("Disconnected"),
|
||||
_("The network connection has been disconnected."), "nm-no-connection");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void nmwa_dbus_device_deactivated (NMWirelessApplet *applet, const char *dev_path)
|
||||
{
|
||||
DBusMessage * message;
|
||||
DBusPendingCall * pcall = NULL;
|
||||
|
||||
g_return_if_fail (applet != NULL);
|
||||
g_return_if_fail (dev_path != NULL);
|
||||
|
||||
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, dev_path, NM_DBUS_INTERFACE_DEVICES, "getProperties")))
|
||||
{
|
||||
dbus_connection_send_with_reply (applet->connection, message, &pcall, -1);
|
||||
if (pcall)
|
||||
dbus_pending_call_set_notify (pcall, nmwa_dbus_device_deactivated_cb, applet, NULL);
|
||||
dbus_message_unref (message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmwa_dbus_update_devices_cb
|
||||
|
@@ -42,6 +42,8 @@ void nmwa_dbus_update_dialup (NMWirelessApplet *applet);
|
||||
void nmwa_dbus_dialup_activate_connection (NMWirelessApplet *applet, const char *name);
|
||||
void nmwa_dbus_dialup_deactivate_connection (NMWirelessApplet *applet, const char *name);
|
||||
void nmwa_dbus_device_update_one_device (NMWirelessApplet *applet, const char *dev_path);
|
||||
void nmwa_dbus_device_activated (NMWirelessApplet *applet, const char *dev_path, const char *essid);
|
||||
void nmwa_dbus_device_deactivated (NMWirelessApplet *applet, const char *dev_path);
|
||||
void nmwa_dbus_device_remove_one_device (NMWirelessApplet *applet, const char *dev_path);
|
||||
|
||||
void nmwa_dbus_device_update_one_network (NMWirelessApplet *applet, const char *dev_path, const char *net_path, const char *active_net_path);
|
||||
|
@@ -123,8 +123,6 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
|
||||
}
|
||||
}
|
||||
else if ( dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceAdded")
|
||||
|| dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNowActive")
|
||||
|| dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNoLongerActive")
|
||||
|| dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceActivating")
|
||||
|| dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceCarrierOn")
|
||||
|| dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceCarrierOff"))
|
||||
@@ -134,6 +132,23 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
|
||||
if (dbus_message_get_args (message, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID))
|
||||
nmwa_dbus_device_update_one_device (applet, path);
|
||||
}
|
||||
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNowActive"))
|
||||
{
|
||||
char *path = NULL;
|
||||
char *essid = NULL;
|
||||
|
||||
if (dbus_message_get_args (message, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_STRING, &essid, DBUS_TYPE_INVALID))
|
||||
nmwa_dbus_device_activated (applet, path, essid);
|
||||
else if (dbus_message_get_args (message, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID))
|
||||
nmwa_dbus_device_activated (applet, path, NULL);
|
||||
}
|
||||
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNoLongerActive"))
|
||||
{
|
||||
char *path = NULL;
|
||||
|
||||
if (dbus_message_get_args (message, NULL, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID))
|
||||
nmwa_dbus_device_deactivated (applet, path);
|
||||
}
|
||||
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceRemoved"))
|
||||
{
|
||||
char *path = NULL;
|
||||
@@ -210,7 +225,7 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
|
||||
char *error_msg;
|
||||
|
||||
if (dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &vpn_name, DBUS_TYPE_STRING, &error_msg, DBUS_TYPE_INVALID)) {
|
||||
nmwa_schedule_vpn_failure_alert (applet, member, vpn_name, error_msg);
|
||||
nmwa_show_vpn_failure_alert (applet, member, vpn_name, error_msg);
|
||||
/* clear the 'last_attempt_success' key in gconf so we prompt for password next time */
|
||||
nmwa_dbus_vpn_set_last_attempt_status (applet, vpn_name, FALSE);
|
||||
}
|
||||
@@ -224,7 +239,7 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
|
||||
{
|
||||
char *stripped = g_strstrip (g_strdup (banner));
|
||||
|
||||
nmwa_schedule_vpn_login_banner (applet, vpn_name, stripped);
|
||||
nmwa_show_vpn_login_banner (applet, vpn_name, stripped);
|
||||
g_free (stripped);
|
||||
|
||||
/* set the 'last_attempt_success' key in gconf so we DON'T prompt for password next time */
|
||||
|
46
gnome/applet/applet-notifications.c
Normal file
46
gnome/applet/applet-notifications.c
Normal file
@@ -0,0 +1,46 @@
|
||||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* Christopher Aillon <caillon@redhat.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* (C) Copyright 2005 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <libnotify/notify.h>
|
||||
#include "applet-notifications.h"
|
||||
|
||||
void
|
||||
nmwa_send_event_notification (NMWirelessApplet *applet,
|
||||
NotifyUrgency urgency,
|
||||
const char *summary,
|
||||
const char *message,
|
||||
const char *icon)
|
||||
{
|
||||
NotifyNotification *notification;
|
||||
|
||||
g_return_if_fail (applet != NULL);
|
||||
g_return_if_fail (summary != NULL);
|
||||
g_return_if_fail (message != NULL);
|
||||
|
||||
if (!notify_is_initted ())
|
||||
notify_init ("NetworkManager");
|
||||
|
||||
notification = notify_notification_new (summary, message,
|
||||
icon ? icon : GTK_STOCK_NETWORK, GTK_WIDGET (applet));
|
||||
notify_notification_set_urgency (notification, urgency);
|
||||
notify_notification_show (notification, NULL);
|
||||
}
|
||||
|
34
gnome/applet/applet-notifications.h
Normal file
34
gnome/applet/applet-notifications.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* Christopher Aillon <caillon@redhat.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* (C) Copyright 2005 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef NM_NOTIFICATION_H__
|
||||
#define NM_NOTIFICATION_H__
|
||||
|
||||
#include "applet.h"
|
||||
|
||||
void
|
||||
nmwa_send_event_notification (NMWirelessApplet *applet,
|
||||
NotifyUrgency urgency,
|
||||
const char *summary,
|
||||
const char *message,
|
||||
const char *icon);
|
||||
|
||||
#endif /* NM_NOTIFICATION_H__ */
|
@@ -53,6 +53,7 @@
|
||||
#include "applet-dbus-devices.h"
|
||||
#include "applet-dbus-vpn.h"
|
||||
#include "applet-dbus-info.h"
|
||||
#include "applet-notifications.h"
|
||||
#include "other-network-dialog.h"
|
||||
#include "passphrase-dialog.h"
|
||||
#include "menu-items.h"
|
||||
@@ -363,56 +364,27 @@ static void nmwa_about_cb (NMWirelessApplet *applet)
|
||||
#endif
|
||||
}
|
||||
|
||||
typedef struct DialogCBData
|
||||
{
|
||||
NMWirelessApplet *applet;
|
||||
char *msg;
|
||||
char *title;
|
||||
} DialogCBData;
|
||||
|
||||
static void free_dialog_cb_data (DialogCBData *data)
|
||||
{
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
g_free (data->msg);
|
||||
g_free (data->title);
|
||||
memset (data, 0, sizeof (DialogCBData));
|
||||
g_free (data);
|
||||
}
|
||||
|
||||
#ifndef ENABLE_NOTIFY
|
||||
static void vpn_failure_dialog_close_cb (GtkWidget *dialog, gpointer user_data)
|
||||
{
|
||||
DialogCBData *data;
|
||||
|
||||
if ((data = g_object_get_data (G_OBJECT (dialog), "data")))
|
||||
{
|
||||
g_object_set_data (G_OBJECT (dialog), "data", NULL);
|
||||
free_dialog_cb_data (data);
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmwa_show_vpn_failure_dialog
|
||||
*
|
||||
* Present the VPN failure dialog.
|
||||
*
|
||||
*/
|
||||
static gboolean nmwa_show_vpn_failure_dialog (DialogCBData *cb_data)
|
||||
static void
|
||||
nmwa_show_vpn_failure_dialog (const char *title,
|
||||
const char *msg)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
g_return_val_if_fail (cb_data != NULL, FALSE);
|
||||
g_return_val_if_fail (cb_data->msg != NULL, FALSE);
|
||||
g_return_val_if_fail (cb_data->title != NULL, FALSE);
|
||||
g_return_val_if_fail (title != NULL, FALSE);
|
||||
g_return_val_if_fail (msg != NULL, FALSE);
|
||||
|
||||
dialog = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, cb_data->msg, NULL);
|
||||
dialog = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_ERROR,
|
||||
GTK_BUTTONS_OK, msg, NULL);
|
||||
gtk_window_set_title (GTK_WINDOW (dialog), cb_data->title);
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (vpn_failure_dialog_close_cb), NULL);
|
||||
g_signal_connect (dialog, "close", G_CALLBACK (vpn_failure_dialog_close_cb), NULL);
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
g_signal_connect (dialog, "close", G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
g_object_set_data (G_OBJECT (dialog), "data", cb_data);
|
||||
|
||||
/* Bash focus-stealing prevention in the face */
|
||||
@@ -420,44 +392,6 @@ static gboolean nmwa_show_vpn_failure_dialog (DialogCBData *cb_data)
|
||||
gtk_widget_realize (dialog);
|
||||
gdk_x11_window_set_user_time (dialog->window, gtk_get_current_event_time ());
|
||||
gtk_widget_show_all (dialog);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ENABLE_NOTIFY
|
||||
/*
|
||||
* nmwa_notify_vpn_failure
|
||||
*
|
||||
* Notify the user of that the VPN connection failed
|
||||
*
|
||||
*/
|
||||
static gboolean nmwa_notify_vpn_failure (DialogCBData *cb_data)
|
||||
{
|
||||
NotifyNotification * n;
|
||||
NotifyUrgency urgency = NOTIFY_URGENCY_NORMAL;
|
||||
char * icon = NULL;
|
||||
|
||||
g_return_val_if_fail (cb_data != NULL, FALSE);
|
||||
g_return_val_if_fail (cb_data->msg != NULL, FALSE);
|
||||
g_return_val_if_fail (cb_data->title != NULL, FALSE);
|
||||
|
||||
if (!notify_is_initted ())
|
||||
notify_init ("NetworkManager");
|
||||
|
||||
icon = g_strdup ("gnome-lockscreen");
|
||||
urgency = NOTIFY_URGENCY_CRITICAL;
|
||||
|
||||
n = notify_notification_new (cb_data->title, cb_data->msg, icon,
|
||||
(GtkWidget *) cb_data->applet);
|
||||
notify_notification_set_urgency (n, urgency);
|
||||
notify_notification_show (n, NULL);
|
||||
g_object_unref (n);
|
||||
g_free (icon);
|
||||
free_dialog_cb_data (cb_data);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -468,147 +402,87 @@ static gboolean nmwa_notify_vpn_failure (DialogCBData *cb_data)
|
||||
* Schedule display of a VPN failure message.
|
||||
*
|
||||
*/
|
||||
void nmwa_schedule_vpn_failure_alert (NMWirelessApplet *applet, const char *member, const char *vpn_name, const char *error_msg)
|
||||
void nmwa_show_vpn_failure_alert (NMWirelessApplet *applet, const char *member, const char *vpn_name, const char *error_msg)
|
||||
{
|
||||
DialogCBData *cb_data = NULL;
|
||||
gchar *error_head = NULL;
|
||||
gchar *error_desc = NULL;
|
||||
gchar *error_data = NULL;
|
||||
char *title = NULL;
|
||||
char *desc = NULL;
|
||||
|
||||
g_return_if_fail (applet != NULL);
|
||||
g_return_if_fail (member != NULL);
|
||||
g_return_if_fail (vpn_name != NULL);
|
||||
g_return_if_fail (error_msg != NULL);
|
||||
|
||||
cb_data = g_malloc0 (sizeof (DialogCBData));
|
||||
cb_data->applet = applet;
|
||||
|
||||
if (!strcmp (member, NM_DBUS_VPN_SIGNAL_LOGIN_FAILED))
|
||||
{
|
||||
error_head = g_strdup (_("VPN Login Failure"));
|
||||
error_desc = g_strdup_printf (_("Could not start the VPN connection '%s' due to a login failure."), vpn_name);
|
||||
title = g_strdup (_("VPN Login Failure"));
|
||||
desc = g_strdup_printf (_("Could not start the VPN connection '%s' due to a login failure."), vpn_name);
|
||||
}
|
||||
else if (!strcmp (member, NM_DBUS_VPN_SIGNAL_LAUNCH_FAILED))
|
||||
{
|
||||
error_head = g_strdup (_("VPN Start Failure"));
|
||||
error_desc = g_strdup_printf (_("Could not start the VPN connection '%s' due to a failure launching the VPN program."), vpn_name);
|
||||
title = g_strdup (_("VPN Start Failure"));
|
||||
desc = g_strdup_printf (_("Could not start the VPN connection '%s' due to a failure launching the VPN program."), vpn_name);
|
||||
}
|
||||
else if (!strcmp (member, NM_DBUS_VPN_SIGNAL_CONNECT_FAILED))
|
||||
{
|
||||
error_head = g_strdup (_("VPN Connect Failure"));
|
||||
error_desc = g_strdup_printf (_("Could not start the VPN connection '%s' due to a connection error."), vpn_name);
|
||||
title = g_strdup (_("VPN Connect Failure"));
|
||||
desc = g_strdup_printf (_("Could not start the VPN connection '%s' due to a connection error."), vpn_name);
|
||||
}
|
||||
else if (!strcmp (member, NM_DBUS_VPN_SIGNAL_VPN_CONFIG_BAD))
|
||||
{
|
||||
error_head = g_strdup (_("VPN Configuration Error"));
|
||||
error_desc = g_strdup_printf (_("The VPN connection '%s' was not correctly configured."), vpn_name);
|
||||
title = g_strdup (_("VPN Configuration Error"));
|
||||
desc = g_strdup_printf (_("The VPN connection '%s' was not correctly configured."), vpn_name);
|
||||
}
|
||||
else if (!strcmp (member, NM_DBUS_VPN_SIGNAL_IP_CONFIG_BAD))
|
||||
{
|
||||
error_head = g_strdup (_("VPN Connect Failure"));
|
||||
error_desc = g_strdup_printf (_("Could not start the VPN connection '%s' because the VPN server did not return an adequate network configuration."), vpn_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
free_dialog_cb_data (cb_data);
|
||||
return;
|
||||
title = g_strdup (_("VPN Connect Failure"));
|
||||
desc = g_strdup_printf (_("Could not start the VPN connection '%s' because the VPN server did not return an adequate network configuration."), vpn_name);
|
||||
}
|
||||
|
||||
error_data = g_strdup_printf (_("The VPN service said: \"%s\""), error_msg);
|
||||
if (title && desc)
|
||||
{
|
||||
char * msg;
|
||||
|
||||
#ifdef ENABLE_NOTIFY
|
||||
cb_data->title = g_strdup (error_head);
|
||||
cb_data->msg = g_strdup_printf ("\n%s\n\n%s", error_desc, error_data);
|
||||
g_idle_add ((GSourceFunc) nmwa_notify_vpn_failure, cb_data);
|
||||
msg = g_strdup_printf ("\n%s\n%s", desc, error_msg);
|
||||
nmwa_send_event_notification (applet, NOTIFY_URGENCY_CRITICAL,
|
||||
title, msg, "gnome-lockscreen");
|
||||
#else
|
||||
cb_data->title = g_strdup (_("VPN Error"));
|
||||
cb_data->msg = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n"
|
||||
"%s\n\n%s", error_head, error_desc, error_data);
|
||||
g_idle_add ((GSourceFunc) nmwa_show_vpn_failure_dialog, cb_data);
|
||||
msg = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n"
|
||||
"%s\n\n%s", title, desc, error_msg);
|
||||
nmwa_show_vpn_failure_dialog (title, msg);
|
||||
#endif
|
||||
g_free (error_head);
|
||||
g_free (error_desc);
|
||||
g_free (error_data);
|
||||
g_free (msg);
|
||||
}
|
||||
|
||||
g_free (title);
|
||||
g_free (desc);
|
||||
}
|
||||
|
||||
|
||||
#ifndef ENABLE_NOTIFY
|
||||
static void vpn_login_banner_dialog_close_cb (GtkWidget *dialog, gpointer user_data)
|
||||
{
|
||||
DialogCBData *data;
|
||||
|
||||
if ((data = g_object_get_data (G_OBJECT (dialog), "data")))
|
||||
{
|
||||
g_object_set_data (G_OBJECT (dialog), "data", NULL);
|
||||
free_dialog_cb_data (data);
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmwa_show_vpn_login_banner_dialog
|
||||
*
|
||||
* Present the VPN login banner dialog.
|
||||
*
|
||||
*/
|
||||
static gboolean nmwa_show_vpn_login_banner_dialog (gpointer user_data)
|
||||
static void
|
||||
nmwa_show_vpn_login_banner_dialog (const char *title,
|
||||
const char *msg)
|
||||
{
|
||||
DialogCBData *cb_data = (DialogCBData *) user_data;
|
||||
GtkWidget *dialog;
|
||||
|
||||
g_return_val_if_fail (cb_data != NULL, FALSE);
|
||||
g_return_val_if_fail (cb_data->msg != NULL, FALSE);
|
||||
|
||||
dialog = gtk_message_dialog_new_with_markup (NULL, 0, GTK_MESSAGE_INFO,
|
||||
GTK_BUTTONS_OK, cb_data->msg, NULL);
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (vpn_login_banner_dialog_close_cb), NULL);
|
||||
g_signal_connect (dialog, "close", G_CALLBACK (vpn_login_banner_dialog_close_cb), NULL);
|
||||
g_object_set_data (G_OBJECT (dialog), "data", cb_data);
|
||||
GTK_BUTTONS_OK, msg, NULL);
|
||||
gtk_window_set_title (GTK_WINDOW (dialog), title);
|
||||
g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
g_signal_connect (dialog, "close", G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
|
||||
/* Bash focus-stealing prevention in the face */
|
||||
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER_ALWAYS);
|
||||
gtk_widget_realize (dialog);
|
||||
gdk_x11_window_set_user_time (dialog->window, gtk_get_current_event_time ());
|
||||
gtk_widget_show_all (dialog);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_NOTIFY
|
||||
/*
|
||||
* nmwa_notify_vpn_login_banner
|
||||
*
|
||||
* Notify the user of that the VPN's login banner
|
||||
*
|
||||
*/
|
||||
static gboolean nmwa_notify_vpn_login_banner (DialogCBData *cb_data)
|
||||
{
|
||||
NotifyNotification * n;
|
||||
NotifyUrgency urgency = NOTIFY_URGENCY_NORMAL;
|
||||
char * icon = NULL;
|
||||
|
||||
g_return_val_if_fail (cb_data != NULL, FALSE);
|
||||
g_return_val_if_fail (cb_data->msg != NULL, FALSE);
|
||||
g_return_val_if_fail (cb_data->title != NULL, FALSE);
|
||||
|
||||
if (!notify_is_initted ())
|
||||
notify_init ("NetworkManager");
|
||||
|
||||
icon = g_strdup ("gnome-lockscreen");
|
||||
urgency = NOTIFY_URGENCY_LOW;
|
||||
|
||||
n = notify_notification_new (cb_data->title, cb_data->msg, icon,
|
||||
(GtkWidget *) cb_data->applet);
|
||||
notify_notification_set_urgency (n, urgency);
|
||||
notify_notification_show (n, NULL);
|
||||
g_object_unref (n);
|
||||
g_free (icon);
|
||||
free_dialog_cb_data (cb_data);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -619,30 +493,26 @@ static gboolean nmwa_notify_vpn_login_banner (DialogCBData *cb_data)
|
||||
* Schedule a display of the VPN banner
|
||||
*
|
||||
*/
|
||||
void nmwa_schedule_vpn_login_banner (NMWirelessApplet *applet, const char *vpn_name, const char *banner)
|
||||
void nmwa_show_vpn_login_banner (NMWirelessApplet *applet, const char *vpn_name, const char *banner)
|
||||
{
|
||||
DialogCBData * cb_data = NULL;
|
||||
char *msg2;
|
||||
const char * title;
|
||||
char * msg;
|
||||
|
||||
g_return_if_fail (applet != NULL);
|
||||
g_return_if_fail (vpn_name != NULL);
|
||||
g_return_if_fail (banner != NULL);
|
||||
|
||||
cb_data = g_malloc0 (sizeof (DialogCBData));
|
||||
cb_data->applet = applet;
|
||||
|
||||
msg2 = g_strdup_printf (_("VPN connection '%s' said:"), vpn_name);
|
||||
|
||||
title = _("VPN Login Message");
|
||||
#ifdef ENABLE_NOTIFY
|
||||
cb_data->title = g_strdup (_("VPN Login Message"));
|
||||
cb_data->msg = g_strdup_printf ("\n%s\n\n%s", msg2, banner);
|
||||
g_idle_add ((GSourceFunc) nmwa_notify_vpn_login_banner, cb_data);
|
||||
msg = g_strdup_printf ("\n%s", banner);
|
||||
nmwa_send_event_notification (applet, NOTIFY_URGENCY_LOW,
|
||||
title, msg, "gnome-lockscreen");
|
||||
#else
|
||||
cb_data->msg = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s\n\n\"%s\"",
|
||||
_("VPN Login Message"), msg2, banner);
|
||||
g_idle_add ((GSourceFunc) nmwa_show_vpn_login_banner_dialog, cb_data);
|
||||
msg = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
|
||||
title, banner);
|
||||
nmwa_show_vpn_login_banner_dialog (title, msg);
|
||||
#endif
|
||||
g_free (msg2);
|
||||
g_free (msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -1161,81 +1031,6 @@ static gboolean animation_timeout (NMWirelessApplet *applet)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmwa_notify_state
|
||||
*
|
||||
* Notify the user of change in connectivity
|
||||
*
|
||||
*/
|
||||
static void nmwa_notify_state (NMWirelessApplet *applet, NetworkDevice *act_dev, WirelessNetwork *active_network)
|
||||
{
|
||||
#ifdef ENABLE_NOTIFY
|
||||
NotifyNotification * n;
|
||||
NotifyUrgency urgency = NOTIFY_URGENCY_NORMAL;
|
||||
char * title = NULL;
|
||||
char * msg = NULL;
|
||||
char * icon = NULL;
|
||||
static int state = NM_STATE_ASLEEP;
|
||||
|
||||
if (!notify_is_initted ())
|
||||
notify_init ("NetworkManager");
|
||||
|
||||
switch (applet->nm_state)
|
||||
{
|
||||
case NM_STATE_ASLEEP:
|
||||
case NM_STATE_DISCONNECTED:
|
||||
title = g_strdup (_("Disconnected"));
|
||||
msg = g_strdup (_("The network connection has been disconnected."));
|
||||
icon = g_strdup ("nm-no-connection");
|
||||
urgency = NOTIFY_URGENCY_CRITICAL;
|
||||
break;
|
||||
|
||||
case NM_STATE_CONNECTED:
|
||||
title = g_strdup (_("Connected"));
|
||||
if (network_device_is_wired (act_dev))
|
||||
{
|
||||
msg = g_strdup (_("Connected to a wired network interface."));
|
||||
icon = g_strdup ("nm-device-wired");
|
||||
urgency = NOTIFY_URGENCY_LOW;
|
||||
}
|
||||
else if (network_device_is_wireless (act_dev))
|
||||
{
|
||||
if (applet->is_adhoc)
|
||||
{
|
||||
msg = g_strdup (_("An ad-hoc wireless network connection has been established."));
|
||||
icon = g_strdup ("nm-adhoc");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = g_strdup_printf (_("A wireless network connection to '%s' has been established."),
|
||||
active_network ? wireless_network_get_essid (active_network) : "(unknown)");
|
||||
icon = g_strdup ("nm-device-wireless");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (state != applet->nm_state && title && msg && icon) {
|
||||
n = notify_notification_new (title, msg, icon, (GtkWidget *) applet);
|
||||
notify_notification_set_urgency (n, urgency);
|
||||
|
||||
notify_notification_show (n, NULL);
|
||||
|
||||
g_object_unref (n);
|
||||
}
|
||||
g_free (icon);
|
||||
g_free (msg);
|
||||
g_free (title);
|
||||
|
||||
state = applet->nm_state;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmwa_update_state
|
||||
*
|
||||
@@ -1297,9 +1092,7 @@ static void nmwa_update_state (NMWirelessApplet *applet)
|
||||
tip = g_strdup_printf (_("Wireless network connection to '%s' (%d%%)"),
|
||||
active_network ? wireless_network_get_essid (active_network) : "(unknown)", strength);
|
||||
}
|
||||
|
||||
pixbuf = nmwa_get_connected_icon (applet, act_dev);
|
||||
|
||||
break;
|
||||
|
||||
case NM_STATE_CONNECTING:
|
||||
@@ -1361,8 +1154,6 @@ done:
|
||||
show_applet = FALSE;
|
||||
}
|
||||
|
||||
nmwa_notify_state (applet, act_dev, active_network);
|
||||
|
||||
/* determine if we should hide the notification icon */
|
||||
if (show_applet)
|
||||
gtk_widget_show (GTK_WIDGET (applet));
|
||||
|
@@ -139,8 +139,8 @@ NetworkDevice * nmwa_get_device_for_nm_path (GSList *dev_list, const char *nm_
|
||||
NMWirelessApplet * nmwa_new (void);
|
||||
void nmwa_schedule_warning_dialog (NMWirelessApplet *applet, const char *msg);
|
||||
gboolean nmwa_driver_notify (gpointer user_data);
|
||||
void nmwa_schedule_vpn_failure_alert (NMWirelessApplet *applet, const char *member, const char *vpn_name, const char *error_msg);
|
||||
void nmwa_schedule_vpn_login_banner (NMWirelessApplet *applet, const char *vpn_name, const char *banner);
|
||||
void nmwa_show_vpn_failure_alert (NMWirelessApplet *applet, const char *member, const char *vpn_name, const char *error_msg);
|
||||
void nmwa_show_vpn_login_banner (NMWirelessApplet *applet, const char *vpn_name, const char *banner);
|
||||
|
||||
NetworkDevice * nmwa_get_first_active_device (GSList *dev_list);
|
||||
VPNConnection * nmwa_get_first_active_vpn_connection (NMWirelessApplet *applet);
|
||||
|
@@ -51,6 +51,7 @@ static gboolean nm_policy_activation_finish (NMActRequest *req)
|
||||
{
|
||||
NMDevice *dev = NULL;
|
||||
NMData *data = NULL;
|
||||
NMAccessPoint * ap = NULL;
|
||||
|
||||
g_return_val_if_fail (req != NULL, FALSE);
|
||||
|
||||
@@ -60,10 +61,13 @@ static gboolean nm_policy_activation_finish (NMActRequest *req)
|
||||
dev = nm_act_request_get_dev (req);
|
||||
g_assert (dev);
|
||||
|
||||
if (nm_device_is_802_11_wireless (dev))
|
||||
ap = nm_act_request_get_ap (req);
|
||||
|
||||
nm_device_activation_success_handler (dev, req);
|
||||
|
||||
nm_info ("Activation (%s) successful, device activated.", nm_device_get_iface (dev));
|
||||
nm_dbus_schedule_device_status_change_signal (data, dev, NULL, DEVICE_NOW_ACTIVE);
|
||||
nm_dbus_schedule_device_status_change_signal (data, dev, ap, DEVICE_NOW_ACTIVE);
|
||||
nm_schedule_state_change_signal_broadcast (data);
|
||||
|
||||
return FALSE;
|
||||
|
Reference in New Issue
Block a user