2005-01-25 Dan Williams <dcbw@redhat.com>
* configure.in - Check DBUS version in configure, and set the C macros DBUS_VERSION_[MAJOR,MINOR,MICRO] * info-daemon/NetworkManagerInfoDbus.c - Remove #if 0-d section of code that quit NMI if NM went away. * panel-applet/NMWirelessAppletDbus.c - Trap the "ServiceOwnerChanged" signal that's new in dbus-0.23 * src/NetworkManager.c src/NetworkManagerMain.h src/NetworkManagerDbus.c - Trap the "ServiceOwnerChanged" signal that's new in dbus-0.23 - Make updating of our Allowed Wireless Network lists from NMI an idle function in the main thread now, with a high priority. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@398 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
19
ChangeLog
19
ChangeLog
@@ -1,3 +1,22 @@
|
||||
2005-01-25 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* configure.in
|
||||
- Check DBUS version in configure, and set the C macros
|
||||
DBUS_VERSION_[MAJOR,MINOR,MICRO]
|
||||
|
||||
* info-daemon/NetworkManagerInfoDbus.c
|
||||
- Remove #if 0-d section of code that quit NMI if NM went away.
|
||||
|
||||
* panel-applet/NMWirelessAppletDbus.c
|
||||
- Trap the "ServiceOwnerChanged" signal that's new in dbus-0.23
|
||||
|
||||
* src/NetworkManager.c
|
||||
src/NetworkManagerMain.h
|
||||
src/NetworkManagerDbus.c
|
||||
- Trap the "ServiceOwnerChanged" signal that's new in dbus-0.23
|
||||
- Make updating of our Allowed Wireless Network lists from NMI
|
||||
an idle function in the main thread now, with a high priority.
|
||||
|
||||
2005-01-24 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* panel-applet/gtkcellview.[ch]
|
||||
|
34
configure.in
34
configure.in
@@ -84,7 +84,39 @@ AC_CHECK_LIB(iw, iw_scan, [ IWLIB=-liw ],
|
||||
[AC_MSG_ERROR(wireless-tools 27.pre23 not installed or not functional)], [])
|
||||
AC_SUBST(IWLIB)
|
||||
|
||||
PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.20)
|
||||
PKG_CHECK_MODULES(DBUS, dbus-glib-1 >= 0.22)
|
||||
|
||||
##### Find out the version of DBUS we're using
|
||||
dbus_version=`pkg-config --modversion dbus-1`
|
||||
DBUS_VERSION_MAJOR=`echo $dbus_version | awk -F. '{print $1}'`
|
||||
DBUS_VERSION_MINOR=`echo $dbus_version | awk -F. '{print $2}'`
|
||||
DBUS_VERSION_MICRO=`echo $dbus_version | awk -F. '{print $3}'`
|
||||
if test "z$DBUS_VERSION_MAJOR" = "z"; then
|
||||
DBUS_VERSION_MAJOR="0"
|
||||
fi
|
||||
if test "z$DBUS_VERSION_MINOR" = "z"; then
|
||||
DBUS_VERSION_MINOR="0"
|
||||
fi
|
||||
if test "z$DBUS_VERSION_MICRO" = "z"; then
|
||||
DBUS_VERSION_MICRO="0"
|
||||
fi
|
||||
|
||||
if test "z$DBUS_VERSION_MAJOR" = "z0" -a "z$DBUS_VERSION_MINOR" = "z0" -a "z$DBUS_VERSION_MICRO" = "z0"; then
|
||||
echo "Error: Couldn't determine the version of your DBUS package."
|
||||
echo " This is probably an error in this script, please report it"
|
||||
echo " along with the following information:"
|
||||
echo " Base DBUS version ='$dbus_version'"
|
||||
echo " DBUS_VERSION_MAJOR='$DBUS_VERSION_MAJOR'"
|
||||
echo " DBUS_VERSION_MINOR='$DBUS_VERSION_MINOR'"
|
||||
echo " DBUS_VERSION_MICRO='$DBUS_VERSION_MICRO'"
|
||||
exit 1
|
||||
else
|
||||
|
||||
echo "Your dbus version is $DBUS_VERSION_MAJOR,$DBUS_VERSION_MINOR,$DBUS_VERSION_MICRO."
|
||||
DBUS_CFLAGS="$DBUS_CFLAGS -DDBUS_VERSION_MAJOR=$DBUS_VERSION_MAJOR"
|
||||
DBUS_CFLAGS="$DBUS_CFLAGS -DDBUS_VERSION_MINOR=$DBUS_VERSION_MINOR"
|
||||
DBUS_CFLAGS="$DBUS_CFLAGS -DDBUS_VERSION_MICRO=$DBUS_VERSION_MICRO"
|
||||
fi
|
||||
AC_SUBST(DBUS_CFLAGS)
|
||||
AC_SUBST(DBUS_LIBS)
|
||||
|
||||
|
@@ -766,56 +766,6 @@ static DBusHandlerResult nmi_dbus_filter (DBusConnection *connection, DBusMessag
|
||||
dbus_free (dev);
|
||||
dbus_free (net);
|
||||
}
|
||||
#if 0
|
||||
else if (dbus_message_is_signal (message, DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS, "ServiceDeleted"))
|
||||
{
|
||||
char *service;
|
||||
DBusError error;
|
||||
|
||||
dbus_error_init (&error);
|
||||
if (dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &service, DBUS_TYPE_INVALID))
|
||||
{
|
||||
if (strcmp (service, NM_DBUS_SERVICE) == 0)
|
||||
{
|
||||
if (info->shutdown_timeout != NULL)
|
||||
g_source_destroy (info->shutdown_timeout);
|
||||
|
||||
info->shutdown_timeout = g_timeout_source_new (30000);
|
||||
if (info->shutdown_timeout != NULL)
|
||||
{
|
||||
g_source_set_callback (info->shutdown_timeout,
|
||||
shutdown_callback,
|
||||
info,
|
||||
NULL);
|
||||
|
||||
g_source_attach (info->shutdown_timeout, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dbus_error_is_set (&error))
|
||||
dbus_error_free (&error);
|
||||
}
|
||||
else if (dbus_message_is_signal (message, DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS, "ServiceCreated"))
|
||||
{
|
||||
char *service;
|
||||
DBusError error;
|
||||
|
||||
dbus_error_init (&error);
|
||||
if (dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &service, DBUS_TYPE_INVALID))
|
||||
{
|
||||
if (strcmp (service, NM_DBUS_SERVICE) == 0 &&
|
||||
info->shutdown_timeout != NULL)
|
||||
{
|
||||
g_source_destroy (info->shutdown_timeout);
|
||||
info->shutdown_timeout = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (dbus_error_is_set (&error))
|
||||
dbus_error_free (&error);
|
||||
}
|
||||
#endif
|
||||
|
||||
return (handled ? DBUS_HANDLER_RESULT_HANDLED : DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
||||
}
|
||||
|
@@ -1057,29 +1057,28 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
|
||||
{
|
||||
NMWirelessApplet *applet = (NMWirelessApplet *)user_data;
|
||||
gboolean handled = TRUE;
|
||||
DBusError error;
|
||||
|
||||
g_return_val_if_fail (applet != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
||||
g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
||||
g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
||||
|
||||
dbus_error_init (&error);
|
||||
|
||||
#if (DBUS_VERSION_MAJOR == 0 && DBUS_VERSION_MINOR == 22)
|
||||
/* Old signal names for dbus <= 0.22 */
|
||||
if (dbus_message_is_signal (message, DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS, "ServiceCreated"))
|
||||
{
|
||||
char *service;
|
||||
DBusError error;
|
||||
|
||||
dbus_error_init (&error);
|
||||
if ( dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &service, DBUS_TYPE_INVALID)
|
||||
&& (strcmp (service, NM_DBUS_SERVICE) == 0) && (applet->applet_state == APPLET_STATE_NO_NM))
|
||||
applet->applet_state = APPLET_STATE_NO_CONNECTION;
|
||||
if (dbus_error_is_set (&error))
|
||||
dbus_error_free (&error);
|
||||
}
|
||||
else if (dbus_message_is_signal (message, DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS, "ServiceDeleted"))
|
||||
{
|
||||
char *service;
|
||||
DBusError error;
|
||||
|
||||
dbus_error_init (&error);
|
||||
if (dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &service, DBUS_TYPE_INVALID))
|
||||
{
|
||||
if (strcmp (service, NM_DBUS_SERVICE) == 0)
|
||||
@@ -1087,9 +1086,43 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
|
||||
else if (strcmp (service, NMI_DBUS_SERVICE) == 0)
|
||||
gtk_main_quit (); /* Just die if NetworkManagerInfo dies */
|
||||
}
|
||||
if (dbus_error_is_set (&error))
|
||||
dbus_error_free (&error);
|
||||
}
|
||||
#elif (DBUS_VERSION_MAJOR == 0 && DBUS_VERSION_MINOR == 23)
|
||||
if (dbus_message_is_signal (message, DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS, "ServiceOwnerChanged"))
|
||||
{
|
||||
/* New signal for dbus 0.23... */
|
||||
char *service;
|
||||
char *old_owner;
|
||||
char *new_owner;
|
||||
|
||||
if ( dbus_message_get_args (message, &error,
|
||||
DBUS_TYPE_STRING, &service,
|
||||
DBUS_TYPE_STRING, &old_owner,
|
||||
DBUS_TYPE_STRING, &new_owner,
|
||||
DBUS_TYPE_INVALID))
|
||||
{
|
||||
gboolean old_owner_good = (old_owner && (strlen (old_owner) > 0));
|
||||
gboolean new_owner_good = (new_owner && (strlen (new_owner) > 0));
|
||||
|
||||
if ( (strcmp (service, NM_DBUS_SERVICE))
|
||||
&& (!old_owner_good && new_owner_good) /* Equivalent to old ServiceCreated signal */
|
||||
&& (applet->applet_state == APPLET_STATE_NO_NM))
|
||||
{
|
||||
/* NetworkManager started up */
|
||||
applet->applet_state = APPLET_STATE_NO_CONNECTION;
|
||||
}
|
||||
else if (old_owner_good && !new_owner_good) /* Equivalent to old ServiceDeleted signal */
|
||||
{
|
||||
if (strcmp (service, NM_DBUS_SERVICE) == 0)
|
||||
applet->applet_state = APPLET_STATE_NO_NM;
|
||||
else if (strcmp (service, NMI_DBUS_SERVICE) == 0)
|
||||
gtk_main_quit (); /* Die if NetworkManagerInfo dies */
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
#error "Unrecognized version of DBUS."
|
||||
#endif
|
||||
else if ( dbus_message_is_signal (message, NM_DBUS_INTERFACE, "WirelessNetworkAppeared")
|
||||
|| dbus_message_is_signal (message, NM_DBUS_INTERFACE, "WirelessNetworkDisappeared"))
|
||||
{
|
||||
@@ -1106,6 +1139,9 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
|
||||
else
|
||||
handled = FALSE;
|
||||
|
||||
if (dbus_error_is_set (&error))
|
||||
dbus_error_free (&error);
|
||||
|
||||
return (handled ? DBUS_HANDLER_RESULT_HANDLED : DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
||||
}
|
||||
|
||||
|
@@ -733,8 +733,10 @@ int main( int argc, char *argv[] )
|
||||
nm_data_free (nm_data);
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
nm_data->info_daemon_avail = nm_dbus_is_info_daemon_running (nm_data->dbus_connection);
|
||||
nm_data->update_ap_lists = TRUE;
|
||||
|
||||
/* If NMI is running, grab allowed wireless network lists from it ASAP */
|
||||
if (nm_dbus_is_info_daemon_running (nm_data->dbus_connection))
|
||||
nm_policy_schedule_allowed_ap_list_update (nm_data);
|
||||
|
||||
/* Right before we init hal, we have to make sure our mainloop integration function
|
||||
* knows about our GMainContext. HAL doesn't give us any way to pass that into its
|
||||
|
@@ -1136,6 +1136,7 @@ static DBusHandlerResult nm_dbus_nmi_filter (DBusConnection *connection, DBusMes
|
||||
const char *object_path;
|
||||
const char *method;
|
||||
gboolean handled = FALSE;
|
||||
DBusError error;
|
||||
|
||||
g_return_val_if_fail (data != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
||||
g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
||||
@@ -1147,55 +1148,65 @@ static DBusHandlerResult nm_dbus_nmi_filter (DBusConnection *connection, DBusMes
|
||||
|
||||
/* syslog (LOG_DEBUG, "nm_dbus_nmi_filter() got method %s for path %s", method, object_path); */
|
||||
|
||||
dbus_error_init (&error);
|
||||
|
||||
if ( (strcmp (object_path, NMI_DBUS_PATH) == 0)
|
||||
&& dbus_message_is_signal (message, NMI_DBUS_INTERFACE, "WirelessNetworkUpdate"))
|
||||
{
|
||||
char *network = NULL;
|
||||
DBusError error;
|
||||
|
||||
dbus_error_init (&error);
|
||||
if (!dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &network, DBUS_TYPE_INVALID))
|
||||
return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
||||
|
||||
if (dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &network, DBUS_TYPE_INVALID))
|
||||
{
|
||||
/* Update a single wireless network's data */
|
||||
syslog (LOG_DEBUG, "NetworkManagerInfo triggered update of wireless network '%s'", network);
|
||||
nm_ap_list_update_network_from_nmi (data->allowed_ap_list, network, data);
|
||||
dbus_free (network);
|
||||
handled = TRUE;
|
||||
}
|
||||
}
|
||||
#if (DBUS_VERSION_MAJOR == 0 && DBUS_VERSION_MINOR == 22)
|
||||
else if (dbus_message_is_signal (message, DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS, "ServiceCreated"))
|
||||
{
|
||||
/* Only for dbus <= 0.22 */
|
||||
char *service;
|
||||
DBusError error;
|
||||
|
||||
dbus_error_init (&error);
|
||||
if ( dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &service, DBUS_TYPE_INVALID)
|
||||
&& (strcmp (service, NMI_DBUS_SERVICE) == 0))
|
||||
{
|
||||
data->update_ap_lists = TRUE;
|
||||
data->info_daemon_avail = TRUE;
|
||||
nm_policy_schedule_state_update (data);
|
||||
nm_policy_schedule_allowed_ap_list_update (data);
|
||||
}
|
||||
/* Don't set handled = TRUE since other filter functions on this dbus connection
|
||||
* may want to know about service signals.
|
||||
*/
|
||||
}
|
||||
else if (dbus_message_is_signal (message, DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS, "ServiceDeleted"))
|
||||
#elif (DBUS_VERSION_MAJOR == 0 && DBUS_VERSION_MINOR == 23)
|
||||
else if (dbus_message_is_signal (message, DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS, "ServiceOwnerChanged"))
|
||||
{
|
||||
/* New signal for dbus 0.23... */
|
||||
char *service;
|
||||
DBusError error;
|
||||
char *old_owner;
|
||||
char *new_owner;
|
||||
|
||||
dbus_error_init (&error);
|
||||
if ( dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &service, DBUS_TYPE_INVALID)
|
||||
if ( dbus_message_get_args (message, &error,
|
||||
DBUS_TYPE_STRING, &service,
|
||||
DBUS_TYPE_STRING, &old_owner,
|
||||
DBUS_TYPE_STRING, &new_owner,
|
||||
DBUS_TYPE_INVALID)
|
||||
&& (strcmp (service, NMI_DBUS_SERVICE) == 0))
|
||||
{
|
||||
data->update_ap_lists = TRUE;
|
||||
data->info_daemon_avail = FALSE;
|
||||
nm_policy_schedule_state_update (data);
|
||||
}
|
||||
/* Don't set handled = TRUE since other filter functions on this dbus connection
|
||||
* may want to know about service signals.
|
||||
gboolean old_owner_good = (old_owner && (strlen (old_owner) > 0));
|
||||
gboolean new_owner_good = (new_owner && (strlen (new_owner) > 0));
|
||||
|
||||
/* Service didn't used to have an owner, now it does. Equivalent to
|
||||
* "ServiceCreated" signal in dbus <= 0.22
|
||||
*/
|
||||
if (!old_owner_good && new_owner_good)
|
||||
nm_policy_schedule_allowed_ap_list_update (data);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#error "Unrecognized version of DBUS."
|
||||
#endif
|
||||
|
||||
if (dbus_error_is_set (&error))
|
||||
dbus_error_free (&error);
|
||||
|
||||
return (handled ? DBUS_HANDLER_RESULT_HANDLED : DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
||||
}
|
||||
|
@@ -44,7 +44,6 @@ typedef struct NMData
|
||||
DBusConnection *dbus_connection;
|
||||
GMainContext *main_context;
|
||||
GMainLoop *main_loop;
|
||||
gboolean info_daemon_avail;
|
||||
gboolean enable_test_devices;
|
||||
|
||||
guint state_modified_idle_id;
|
||||
@@ -57,7 +56,6 @@ typedef struct NMData
|
||||
|
||||
gboolean forcing_device;
|
||||
|
||||
gboolean update_ap_lists;
|
||||
struct NMAccessPointList *allowed_ap_list;
|
||||
struct NMAccessPointList *invalid_ap_list;
|
||||
} NMData;
|
||||
|
@@ -320,19 +320,6 @@ static gboolean nm_policy_state_update (gpointer user_data)
|
||||
|
||||
app_data->state_modified_idle_id = 0;
|
||||
|
||||
/* If the info daemon is now running, get our trusted/preferred ap lists from it */
|
||||
if (app_data->info_daemon_avail && app_data->update_ap_lists)
|
||||
{
|
||||
/* Query info daemon for network lists if its now running */
|
||||
if (app_data->allowed_ap_list)
|
||||
nm_ap_list_unref (app_data->allowed_ap_list);
|
||||
app_data->allowed_ap_list = nm_ap_list_new (NETWORK_TYPE_ALLOWED);
|
||||
if (app_data->allowed_ap_list)
|
||||
nm_ap_list_populate_from_nmi (app_data->allowed_ap_list, app_data);
|
||||
|
||||
app_data->update_ap_lists = FALSE;
|
||||
}
|
||||
|
||||
/* If we're currently waiting for a force-device operation to complete, don't try
|
||||
* to change devices. We'll be notified of what device to switch to explicitly
|
||||
* when the force-device operation completes.
|
||||
@@ -455,9 +442,56 @@ void nm_policy_schedule_device_switch (NMDevice *switch_to_dev, NMData *app_data
|
||||
g_source_set_callback (source, nm_policy_state_update, cb_data, NULL);
|
||||
app_data->state_modified_idle_id = g_source_attach (source, app_data->main_context);
|
||||
g_source_unref (source);
|
||||
|
||||
}
|
||||
|
||||
g_static_mutex_unlock (&mutex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* nm_policy_allowed_ap_list_update
|
||||
*
|
||||
* Requery NetworkManagerInfo for a list of updated
|
||||
* allowed wireless networks.
|
||||
*
|
||||
*/
|
||||
static gboolean nm_policy_allowed_ap_list_update (gpointer user_data)
|
||||
{
|
||||
NMData *data = (NMData *)user_data;
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
syslog (LOG_INFO, "Updating allowed wireless network lists.");
|
||||
|
||||
/* Query info daemon for network lists if its now running */
|
||||
if (data->allowed_ap_list)
|
||||
nm_ap_list_unref (data->allowed_ap_list);
|
||||
data->allowed_ap_list = nm_ap_list_new (NETWORK_TYPE_ALLOWED);
|
||||
if (data->allowed_ap_list)
|
||||
nm_ap_list_populate_from_nmi (data->allowed_ap_list, data);
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_policy_schedule_allowed_ap_list_update
|
||||
*
|
||||
* Schedule an update of the allowed AP list in the main thread.
|
||||
*
|
||||
*/
|
||||
void nm_policy_schedule_allowed_ap_list_update (NMData *app_data)
|
||||
{
|
||||
GSource *source = NULL;
|
||||
|
||||
g_return_if_fail (app_data != NULL);
|
||||
g_return_if_fail (app_data->main_context != NULL);
|
||||
|
||||
source = g_idle_source_new ();
|
||||
/* We want this idle source to run before any other idle source */
|
||||
g_source_set_priority (source, G_PRIORITY_HIGH_IDLE);
|
||||
g_source_set_callback (source, nm_policy_allowed_ap_list_update, app_data, NULL);
|
||||
g_source_attach (source, app_data->main_context);
|
||||
g_source_unref (source);
|
||||
}
|
||||
|
@@ -37,6 +37,8 @@ void nm_policy_schedule_state_update (NMData *app_data);
|
||||
|
||||
void nm_policy_schedule_device_switch (NMDevice *dev, NMData *app_data);
|
||||
|
||||
void nm_policy_schedule_allowed_ap_list_update (NMData *app_data);
|
||||
|
||||
gboolean nm_policy_activation_finish (gpointer user_data);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user