Commit a5dd14c3 authored by Dan Williams's avatar Dan Williams
Browse files

2005-04-27 Dan Williams <dcbw@redhat.com>

        * Merge the applet and the info-daemon, and move the converged
                applet under gnome/applet
        * Move libnm_glib to gnome/libnm_glib
        * Convert most dbus calls between the applet, info-daemon, and NM
                into async calls
        * Fix a few things valgrind noticed
        * Make NM broadcast state more reliably


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@586 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent b0a5d64b
2005-04-27 Dan Williams <dcbw@redhat.com>
* Merge the applet and the info-daemon, and move the converged
applet under gnome/applet
* Move libnm_glib to gnome/libnm_glib
* Convert most dbus calls between the applet, info-daemon, and NM
into async calls
* Fix a few things valgrind noticed
* Make NM broadcast state more reliably
2005-04-22 Pawan chitrakar <pawan@nplinux.org>
* configure.in: Added ne in ALL_LINGUAS
......
SUBDIRS = utils dhcpcd src libnm_glib dispatcher-daemon $(notification_icon_dir) info-daemon vpn-daemons initscript test po
SUBDIRS = utils dhcpcd src dispatcher-daemon gnome vpn-daemons initscript test po
EXTRA_DIST = CONTRIBUTING NetworkManager.pc.in NetworkManager.h
......
......@@ -44,12 +44,14 @@
/*
* Some common errors
*/
#define NM_DBUS_NO_ACTIVE_NET_ERROR "org.freedesktop.NetworkManager.NoActiveNetwork"
#define NM_DBUS_NO_ACTIVE_DEVICE_ERROR "org.freedesktop.NetworkManager.NoActiveDevice"
#define NM_DBUS_NO_DEVICES_ERROR "org.freedesktop.NetworkManager.NoDevices"
#define NM_DBUS_NO_NETWORKS_ERROR "org.freedesktop.NetworkManager.NoNetworks"
#define NM_DBUS_NO_ACTIVE_DEVICE_ERROR "org.freedesktop.NetworkManager.NoActiveDevice"
#define NM_DBUS_NO_ACTIVE_NET_ERROR "org.freedesktop.NetworkManager.NoActiveNetwork"
#define NM_DBUS_NO_ACTIVE_VPN_CONNECTION "org.freedesktop.NetworkManager.VPNConnections.NoActiveVPNConnection"
#define NM_DBUS_NO_VPN_CONNECTIONS "org.freedesktop.NetworkManager.VPNConnections.NoVPNConnections"
#define NM_DBUS_INVALID_VPN_CONNECTION "org.freedesktop.NetworkManager.VPNConnections.InvalidVPNConnection"
#define NM_DBUS_VPN_STARTING_IN_PROGRESS "StartingInProgress"
#define NM_DBUS_VPN_ALREADY_STARTED "AlreadyStarted"
......@@ -58,12 +60,36 @@
#define NM_DBUS_VPN_WRONG_STATE "WrongState"
#define NM_DBUS_VPN_BAD_ARGUMENTS "BadArguments"
/*
* VPN daemon signals
*/
#define NM_DBUS_VPN_SIGNAL_LOGIN_FAILED "LoginFailed"
#define NM_DBUS_VPN_SIGNAL_CONFIG_BAD "ConfigurationBad"
#define NM_DBUS_VPN_SIGNAL_STATE_CHANGE "StateChange"
#define NM_DBUS_VPN_SIGNAL_IP4_CONFIG "IP4Config"
/*
* NetworkManager signals
*/
#define NM_DBUS_SIGNAL_STATE_CHANGE "StateChange"
/*
* Types of NetworkManager devices
*/
typedef enum NMState
{
NM_STATE_UNKNOWN = 0,
NM_STATE_ASLEEP,
NM_STATE_SCANNING,
NM_STATE_CONNECTING,
NM_STATE_CONNECTED,
NM_STATE_DISCONNECTED
} NMState;
/*
* Types of NetworkManager devices
*/
......@@ -161,10 +187,4 @@ typedef enum NMVPNState
NM_VPN_STATE_STOPPED
} NMVPNState;
/*
* Info-daemon specific preference locations
*/
#define NMI_GCONF_WIRELESS_NETWORKS_PATH "/system/networking/wireless/networks"
#endif
......@@ -193,15 +193,6 @@ AC_DEFINE_UNQUOTED(NM_NAMED_BINARY_PATH, "$with_named", [Define to path of named
AC_DEFINE_UNQUOTED(NM_NAMED_DATA_DIR, "$with_named_dir", [Define to path of named data directory])
AC_DEFINE_UNQUOTED(NM_NAMED_USER, "$with_named_user", [Define to named username])
AC_ARG_ENABLE(notification-icon, AC_HELP_STRING([--enable-notification-icon], [builds the wireless applet as a notification icon]), enable_notification_icon=$enableval, enable_notification_icon=yes)
AM_CONDITIONAL(BUILD_NOTIFICATION_ICON, test x$enable_notification_icon = xyes)
if test x$enable_notification_icon == xyes ; then
AC_DEFINE_UNQUOTED(BUILD_NOTIFICATION_ICON, "$BUILD_NOTIFICATION_ICON", [Should we build the notification icon instead of the applet])
notification_icon_dir="panel-applet"
AC_SUBST(notification_icon_dir)
fi
#### find the actual value for $prefix that we'll end up with
## (I know this is broken and should be done in the Makefile, but
## that's a major pain and almost nobody actually seems to care)
......@@ -274,11 +265,14 @@ src/named-manager/Makefile
src/vpn-manager/Makefile
src/backends/Makefile
dispatcher-daemon/Makefile
info-daemon/Makefile
gnome/Makefile
gnome/applet/Makefile
gnome/applet/icons/Makefile
gnome/libnm_glib/libnm_glib.pc
gnome/libnm_glib/Makefile
panel-applet/Makefile
panel-applet/icons/Makefile
dhcpcd/Makefile
libnm_glib/Makefile
test/Makefile
initscript/Makefile
initscript/RedHat/Makefile
......@@ -287,7 +281,6 @@ initscript/Debian/Makefile
initscript/Slackware/Makefile
po/Makefile.in
NetworkManager.pc
libnm_glib/libnm_glib.pc
vpn-daemons/Makefile
vpn-daemons/vpnc/Makefile
])
......
SUBDIRS = applet libnm_glib
SUBDIRS=icons
NULL=
INCLUDES = -I${top_srcdir} -I${top_srcdir}/utils
libexec_PROGRAMS = nm-applet
nm_applet_CFLAGS = \
$(DBUS_CFLAGS) \
$(GTHREAD_CFLAGS) \
$(HAL_CFLAGS) \
$(DBUS_GLIB_CFLAGS) \
$(GLADE_CFLAGS) \
$(GTK_CFLAGS) \
$(GCONF_CFLAGS) \
$(LIBGNOMEUI_CFLAGS) \
$(PANEL_APPLET_CFLAGS) \
$(GNOMEKEYRING_CFLAGS) \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DGLADEDIR=\""$(gladedir)"\" \
-DDBUS_API_SUBJECT_TO_CHANGE \
-DG_DISABLE_DEPRECATED \
-DGDK_DISABLE_DEPRECATED \
-DGNOME_DISABLE_DEPRECATED \
-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-DVERSION=\"$(VERSION)\" \
$(NULL)
nm_applet_SOURCES = \
main.c \
applet.c \
applet.h \
applet-dbus.c \
applet-dbus.h \
applet-dbus-devices.c \
applet-dbus-devices.h \
applet-dbus-vpn.c \
applet-dbus-vpn.h \
applet-dbus-info.c \
applet-dbus-info.h \
wireless-network.c \
wireless-network.h \
nm-device.c \
nm-device.h \
other-network-dialog.c \
other-network-dialog.h \
passphrase-dialog.c \
passphrase-dialog.h \
menu-items.c \
menu-items.h \
gtkcellview.c \
gtkcellview.h \
gtkcellrendererprogress.c \
gtkcellrendererprogress.h \
eggtrayicon.c \
eggtrayicon.h \
vpn-password-dialog.c \
vpn-password-dialog.h \
vpn-connection.c \
vpn-connection.h \
$(NULL)
nm_applet_LDADD = \
$(DBUS_LIBS) \
$(HAL_LIBS) \
$(GTHREAD_LIBS) \
$(GLADE_LIBS) \
$(DBUS_GLIB_LIBS) \
$(PANEL_APPLET_LIBS) \
$(GTK_LIBS) \
$(GCONF_LIBS) \
$(LIBGNOMEUI_LIBS) \
$(GNOMEKEYRING_LIBS) \
$(top_builddir)/utils/libnmutils.la \
$(NULL)
gladedir = $(datadir)/NetworkManagerNotification
glade_DATA = wireless-applet.glade keyring.png
dbusservicedir = $(DBUS_SYS_DIR)
dbusservice_DATA = nm-applet.conf
CLEANFILES = $(server_DATA) *.bak *.gladep
EXTRA_DIST = \
$(glade_DATA) \
$(NULL)
This diff is collapsed.
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@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 2004-2005 Red Hat, Inc.
*/
#ifndef APPLET_DBUS_DEVICES_H
#define APPLET_DBUS_DEVICES_H
#include <glib.h>
#include <dbus/dbus.h>
#include "NetworkManager.h"
#include "applet.h"
#include "nm-device.h"
#include "wireless-network.h"
void nmwa_dbus_update_one_vpn_connection (DBusConnection *connection, const char *name, NMWirelessApplet *applet, gboolean is_active);
void nmwa_dbus_update_vpn_connections (NMWirelessApplet *applet);
gboolean nmwa_dbus_update_active_device_strength (NMWirelessApplet *applet);
void nmwa_dbus_update_nm_state (NMWirelessApplet *applet);
void nmwa_dbus_get_active_device (NMWirelessApplet *applet);
void nmwa_dbus_update_devices (NMWirelessApplet *applet);
void nmwa_dbus_device_update_one_device (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);
void nmwa_dbus_device_remove_one_network (NMWirelessApplet *applet, const char *dev_path, const char *net_path);
void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, WirelessNetwork *net, NMEncKeyType key_type, const char *passphrase);
void nmwa_dbus_create_network (DBusConnection *connection, NetworkDevice *dev, const char *essid, NMEncKeyType key_type, const char *passphrase);
#endif
/* NetworkManagerInfo -- Manage allowed access points and provide a UI
* for WEP key entry
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@redhat.com>
*
......@@ -17,18 +17,18 @@
* 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 2004 Red Hat, Inc.
* (C) Copyright 2004-2005 Red Hat, Inc.
*/
#ifndef NETWORK_MANAGER_INFO_PASSPHRASE_DIALOG_H
#define NETWORK_MANAGER_INFO_PASSPHRASE_DIALOG_H
#ifndef APPLET_DBUS_INFO_H
#define APPLET_DBUS_INFO_H
#include "NetworkManagerInfo.h"
#include <dbus/dbus.h>
#include "nm-device.h"
#include "wireless-network.h"
int nmi_passphrase_dialog_init (NMIAppInfo *info);
DBusHandlerResult nmi_dbus_info_message_handler (DBusConnection *connection, DBusMessage *message, void *user_data);
void nmi_passphrase_dialog_show (const char *device, const char *network, NMIAppInfo *info);
void nmi_passphrase_dialog_cancel (NMIAppInfo *info);
void nmi_dbus_return_user_key (DBusConnection *connection, DBusMessage *message, const char *passphrase, const int key_type);
#endif
/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@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 2004-2005 Red Hat, Inc.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <glib/gi18n.h>
#include <stdio.h>
#include <string.h>
#include <dbus/dbus.h>
#include "applet-dbus-vpn.h"
#include "applet-dbus.h"
#include "applet.h"
#include "vpn-connection.h"
#include "nm-utils.h"
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
*
*/
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);
dbus_pending_call_ref (pcall);
if (!dbus_pending_call_get_completed (pcall))
goto out;
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))
{
dbus_message_unref (reply);
goto out;
}
if (dbus_message_get_args (reply, NULL, DBUS_TYPE_OBJECT_PATH, &act_vpn, DBUS_TYPE_INVALID))
{
g_free (applet->dbus_active_vpn_name);
applet->dbus_active_vpn_name = g_strdup (act_vpn);
}
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
*
*/
void nmwa_dbus_vpn_get_active_vpn_connection (NMWirelessApplet *applet)
{
DBusMessage * message;
DBusPendingCall * pcall = NULL;
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")))
{
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);
}
}
}
typedef struct VpnPropsCBData
{
NMWirelessApplet * applet;
char * name;
} VpnPropsCBData;
void free_vpn_props_cb_data (VpnPropsCBData *data)
{
if (data)
{
g_free (data->name);
memset (data, 0, sizeof (VpnPropsCBData));
g_free (data);
}
}
/*
* nmwa_dbus_vpn_properties_cb
*
* Callback for each VPN connection we called "getVPNConnectionProperties" on.
*
*/
void nmwa_dbus_vpn_properties_cb (DBusPendingCall *pcall, void *user_data)
{
DBusMessage * reply;
VpnPropsCBData * cb_data = user_data;
NMWirelessApplet * applet;
const char * name;
const char * user_name;
g_return_if_fail (pcall != NULL);
g_return_if_fail (cb_data != NULL);
g_return_if_fail (cb_data->applet != NULL);
g_return_if_fail (cb_data->name != NULL);
dbus_pending_call_ref (pcall);
applet = cb_data->applet;
if (!dbus_pending_call_get_completed (pcall))
goto out;
if (!(reply = dbus_pending_call_steal_reply (pcall)))
goto out;
if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR)
{
if (dbus_message_is_error (reply, NM_DBUS_INVALID_VPN_CONNECTION))
{
VPNConnection * vpn;
if ((vpn = nmwa_vpn_connection_find_by_name (applet->dbus_vpn_connections, cb_data->name)))
{
applet->dbus_vpn_connections = g_slist_remove (applet->dbus_vpn_connections, vpn);
nmwa_vpn_connection_unref (vpn);
if (applet->dbus_active_vpn == vpn);
{
nmwa_vpn_connection_unref (vpn);
applet->dbus_active_vpn = 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_INVALID))
{
VPNConnection * vpn;
/* If its already there, update the user_name, otherwise add it to the list */
if ((vpn = nmwa_vpn_connection_find_by_name (applet->dbus_vpn_connections, name)))
nmwa_vpn_connection_set_user_name (vpn, user_name);
else
{
vpn = nmwa_vpn_connection_new (name);
nmwa_vpn_connection_set_user_name (vpn, user_name);
applet->dbus_vpn_connections = g_slist_append (applet->dbus_vpn_connections, vpn);
}
}
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_update_one_vpn_connection
*
* Get properties on one VPN connection
*
*/
void nmwa_dbus_vpn_update_one_vpn_connection (NMWirelessApplet *applet, const char *vpn_name)
{
DBusMessage * message;
DBusPendingCall * pcall = NULL;
g_return_if_fail (applet != NULL);
g_return_if_fail (vpn_name != NULL);
nmwa_dbus_vpn_get_active_vpn_connection (applet);
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH_VPN, NM_DBUS_INTERFACE_VPN, "getVPNConnectionProperties")))
{
dbus_message_append_args (message, DBUS_TYPE_STRING, &vpn_name, DBUS_TYPE_INVALID);
dbus_connection_send_with_reply (applet->connection, message, &pcall, -1);
dbus_message_unref (message);
if (pcall)
{
VpnPropsCBData * cb_data = g_malloc0 (sizeof (VpnPropsCBData));
cb_data->applet = applet;
cb_data->name = g_strdup (vpn_name);
dbus_pending_call_set_notify (pcall, nmwa_dbus_vpn_properties_cb, cb_data, (DBusFreeFunction) free_vpn_props_cb_data);
applet->vpn_pending_call_list = g_slist_append (applet->vpn_pending_call_list, pcall);
}
}
}
/*
* nmwa_dbus_vpn_update_vpn_connections_cb
*
* nmwa_dbus_vpn_update_vpn_connections callback.
*
*/
void nmwa_dbus_vpn_update_vpn_connections_cb (DBusPendingCall *pcall, void *user_data)
{
DBusMessage * reply;
NMWirelessApplet * applet = (NMWirelessApplet *) user_data;
char ** vpn_names;
int num_vpn_names;
g_return_if_fail (pcall != NULL);
g_return_if_fail (applet != NULL);
dbus_pending_call_ref (pcall);
if (!dbus_pending_call_get_completed (pcall))
goto out;
if (!(reply = dbus_pending_call_steal_reply (pcall)))
goto out;
if (dbus_message_is_error (reply, NM_DBUS_NO_VPN_CONNECTIONS))
{
dbus_message_unref (reply);
goto out;
}
if (dbus_message_get_args (reply, NULL, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &vpn_names, &num_vpn_names, DBUS_TYPE_INVALID))
{
char ** item;
/* For each connection, fire off a "getVPNConnectionProperties" call */
for (item = vpn_names; *item; item++)
nmwa_dbus_vpn_update_one_vpn_connection (applet, *item);
dbus_free_string_array (vpn_names);
}
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_update_vpn_connections
*
* Do a full update of vpn connections from NetworkManager
*
*/
void nmwa_dbus_vpn_update_vpn_connections (NMWirelessApplet *applet)
{
DBusMessage * message;
DBusPendingCall * pcall;
nmwa_free_dbus_vpn_connections (applet);
nmwa_dbus_vpn_get_active_vpn_connection (applet);
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH_VPN, NM_DBUS_INTERFACE_VPN, "getVPNConnections")))
{
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_update_vpn_connections_cb, applet, NULL);
applet->vpn_pending_call_list = g_slist_append (applet->vpn_pending_call_list, pcall);
}
}
}