2008-02-20 Dan Williams <dcbw@redhat.com>
* src/NetworkManagerPolicy.c - (nm_policy_device_change_check): get scope off the connection, not using the manager helper * src/nm-manager.c src/nm-manager.h - (get_scope_for_proxy): rename from get_type_for_proxy() - (connection_get_settings_cb): set scope and path on connection, not using GObject data items - (get_connection_for_proxy): don't need to return path, since that can be gotten from the connection - (get_connection_for_proxy): get path off the connection, not from parameters - (connection_removed_cb, connection_updated_cb): don't need to get path from get_connection_for_proxy(); get scope off the connection instead of using GObject data items - (connection_added_default_handler, add_one_connection_element): use nm_connection_get_path() not nm_manager_get_connection_dbus_path() - (nm_manager_get_connection_dbus_path): remove - (nm_manager_get_connection_scope): remove git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3335 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
23
ChangeLog
23
ChangeLog
@@ -1,3 +1,26 @@
|
|||||||
|
2008-02-20 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
* src/NetworkManagerPolicy.c
|
||||||
|
- (nm_policy_device_change_check): get scope off the connection, not
|
||||||
|
using the manager helper
|
||||||
|
|
||||||
|
* src/nm-manager.c
|
||||||
|
src/nm-manager.h
|
||||||
|
- (get_scope_for_proxy): rename from get_type_for_proxy()
|
||||||
|
- (connection_get_settings_cb): set scope and path on connection, not
|
||||||
|
using GObject data items
|
||||||
|
- (get_connection_for_proxy): don't need to return path, since that
|
||||||
|
can be gotten from the connection
|
||||||
|
- (get_connection_for_proxy): get path off the connection, not from
|
||||||
|
parameters
|
||||||
|
- (connection_removed_cb, connection_updated_cb): don't need to get
|
||||||
|
path from get_connection_for_proxy(); get scope off the connection
|
||||||
|
instead of using GObject data items
|
||||||
|
- (connection_added_default_handler, add_one_connection_element): use
|
||||||
|
nm_connection_get_path() not nm_manager_get_connection_dbus_path()
|
||||||
|
- (nm_manager_get_connection_dbus_path): remove
|
||||||
|
- (nm_manager_get_connection_scope): remove
|
||||||
|
|
||||||
2008-02-20 Dan Williams <dcbw@redhat.com>
|
2008-02-20 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* Global rename of NMConnectionSettings -> NMExportedConnection to cut down
|
* Global rename of NMConnectionSettings -> NMExportedConnection to cut down
|
||||||
|
@@ -321,12 +321,12 @@ nm_policy_device_change_check (gpointer user_data)
|
|||||||
* don't switch.
|
* don't switch.
|
||||||
*/
|
*/
|
||||||
if ( old_connection
|
if ( old_connection
|
||||||
&& (nm_manager_get_connection_scope (old_connection) == NM_CONNECTION_SCOPE_SYSTEM)
|
&& (nm_connection_get_scope (old_connection) == NM_CONNECTION_SCOPE_SYSTEM)
|
||||||
&& (nm_manager_get_connection_scope (connection) == NM_CONNECTION_SCOPE_USER))
|
&& (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_USER))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if ( (nm_manager_get_connection_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM)
|
if ( (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM)
|
||||||
&& (nm_manager_get_connection_scope (old_connection) == NM_CONNECTION_SCOPE_USER)) {
|
&& (nm_connection_get_scope (old_connection) == NM_CONNECTION_SCOPE_USER)) {
|
||||||
do_switch = TRUE;
|
do_switch = TRUE;
|
||||||
nm_info ("SWITCH: found system connection '%s (%s)', overrides"
|
nm_info ("SWITCH: found system connection '%s (%s)', overrides"
|
||||||
" current connection '%s (%s)'.",
|
" current connection '%s (%s)'.",
|
||||||
|
@@ -28,9 +28,6 @@ static gboolean impl_manager_get_active_connections (NMManager *manager,
|
|||||||
|
|
||||||
static gboolean impl_manager_sleep (NMManager *manager, gboolean sleep, GError **err);
|
static gboolean impl_manager_sleep (NMManager *manager, gboolean sleep, GError **err);
|
||||||
|
|
||||||
static const char * nm_manager_get_connection_dbus_path (NMManager *manager,
|
|
||||||
NMConnection *connection);
|
|
||||||
|
|
||||||
static gboolean poke_system_settings_daemon_cb (gpointer user_data);
|
static gboolean poke_system_settings_daemon_cb (gpointer user_data);
|
||||||
|
|
||||||
/* Legacy 0.6 compatibility interface */
|
/* Legacy 0.6 compatibility interface */
|
||||||
@@ -432,7 +429,7 @@ nm_manager_class_init (NMManagerClass *manager_class)
|
|||||||
#define DBUS_TYPE_G_DICT_OF_DICTS (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_STRING_VARIANT_HASHTABLE))
|
#define DBUS_TYPE_G_DICT_OF_DICTS (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, DBUS_TYPE_G_STRING_VARIANT_HASHTABLE))
|
||||||
|
|
||||||
static NMConnectionScope
|
static NMConnectionScope
|
||||||
get_type_for_proxy (DBusGProxy *proxy)
|
get_scope_for_proxy (DBusGProxy *proxy)
|
||||||
{
|
{
|
||||||
const char *bus_name = dbus_g_proxy_get_bus_name (proxy);
|
const char *bus_name = dbus_g_proxy_get_bus_name (proxy);
|
||||||
|
|
||||||
@@ -468,7 +465,7 @@ free_get_settings_info (gpointer data)
|
|||||||
g_signal_emit (info->manager,
|
g_signal_emit (info->manager,
|
||||||
signals[CONNECTIONS_ADDED],
|
signals[CONNECTIONS_ADDED],
|
||||||
0,
|
0,
|
||||||
get_type_for_proxy (info->proxy));
|
get_scope_for_proxy (info->proxy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,6 +513,11 @@ connection_get_settings_cb (DBusGProxy *proxy,
|
|||||||
if (connection == NULL)
|
if (connection == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
scope = get_scope_for_proxy (proxy);
|
||||||
|
|
||||||
|
nm_connection_set_path (connection, path);
|
||||||
|
nm_connection_set_scope (connection, scope);
|
||||||
|
|
||||||
g_object_set_data_full (G_OBJECT (connection),
|
g_object_set_data_full (G_OBJECT (connection),
|
||||||
NM_MANAGER_CONNECTION_PROXY_TAG,
|
NM_MANAGER_CONNECTION_PROXY_TAG,
|
||||||
proxy,
|
proxy,
|
||||||
@@ -527,7 +529,6 @@ connection_get_settings_cb (DBusGProxy *proxy,
|
|||||||
(GDestroyNotify) g_object_unref);
|
(GDestroyNotify) g_object_unref);
|
||||||
|
|
||||||
priv = NM_MANAGER_GET_PRIVATE (manager);
|
priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||||
scope = get_type_for_proxy (proxy);
|
|
||||||
switch (scope) {
|
switch (scope) {
|
||||||
case NM_CONNECTION_SCOPE_USER:
|
case NM_CONNECTION_SCOPE_USER:
|
||||||
g_hash_table_insert (priv->user_connections,
|
g_hash_table_insert (priv->user_connections,
|
||||||
@@ -545,10 +546,6 @@ connection_get_settings_cb (DBusGProxy *proxy,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (connection),
|
|
||||||
NM_MANAGER_CONNECTION_TYPE_TAG,
|
|
||||||
GUINT_TO_POINTER (scope));
|
|
||||||
|
|
||||||
/* If the connection-added signal is supposed to be batched, don't
|
/* If the connection-added signal is supposed to be batched, don't
|
||||||
* emit the single connection-added here.
|
* emit the single connection-added here.
|
||||||
*/
|
*/
|
||||||
@@ -569,17 +566,13 @@ out:
|
|||||||
static NMConnection *
|
static NMConnection *
|
||||||
get_connection_for_proxy (NMManager *manager,
|
get_connection_for_proxy (NMManager *manager,
|
||||||
DBusGProxy *proxy,
|
DBusGProxy *proxy,
|
||||||
GHashTable **out_hash,
|
GHashTable **out_hash)
|
||||||
const char **out_path)
|
|
||||||
{
|
{
|
||||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||||
NMConnection *connection = NULL;
|
NMConnection *connection = NULL;
|
||||||
const char *path = dbus_g_proxy_get_path (proxy);
|
const char *path = dbus_g_proxy_get_path (proxy);
|
||||||
|
|
||||||
if (out_path)
|
switch (get_scope_for_proxy (proxy)) {
|
||||||
*out_path = path;
|
|
||||||
|
|
||||||
switch (get_type_for_proxy (proxy)) {
|
|
||||||
case NM_CONNECTION_SCOPE_USER:
|
case NM_CONNECTION_SCOPE_USER:
|
||||||
*out_hash = priv->user_connections;
|
*out_hash = priv->user_connections;
|
||||||
connection = g_hash_table_lookup (priv->user_connections, path);
|
connection = g_hash_table_lookup (priv->user_connections, path);
|
||||||
@@ -599,19 +592,17 @@ get_connection_for_proxy (NMManager *manager,
|
|||||||
static void
|
static void
|
||||||
remove_connection (NMManager *manager,
|
remove_connection (NMManager *manager,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
GHashTable *hash,
|
GHashTable *hash)
|
||||||
const char *path)
|
|
||||||
{
|
{
|
||||||
NMConnectionScope scope;
|
|
||||||
|
|
||||||
/* Destroys the connection, then associated DBusGProxy due to the
|
/* Destroys the connection, then associated DBusGProxy due to the
|
||||||
* weak reference notify function placed on the connection when it
|
* weak reference notify function placed on the connection when it
|
||||||
* was created.
|
* was created.
|
||||||
*/
|
*/
|
||||||
g_object_ref (connection);
|
g_object_ref (connection);
|
||||||
g_hash_table_remove (hash, path);
|
g_hash_table_remove (hash, nm_connection_get_path (connection));
|
||||||
scope = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG));
|
g_signal_emit (manager, signals[CONNECTION_REMOVED], 0,
|
||||||
g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection, scope);
|
connection,
|
||||||
|
nm_connection_get_scope (connection));
|
||||||
g_object_unref (connection);
|
g_object_unref (connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,11 +612,10 @@ connection_removed_cb (DBusGProxy *proxy, gpointer user_data)
|
|||||||
NMManager * manager = NM_MANAGER (user_data);
|
NMManager * manager = NM_MANAGER (user_data);
|
||||||
NMConnection *connection = NULL;
|
NMConnection *connection = NULL;
|
||||||
GHashTable *hash = NULL;
|
GHashTable *hash = NULL;
|
||||||
const char *path;
|
|
||||||
|
|
||||||
connection = get_connection_for_proxy (manager, proxy, &hash, &path);
|
connection = get_connection_for_proxy (manager, proxy, &hash);
|
||||||
if (connection)
|
if (connection)
|
||||||
remove_connection (manager, connection, hash, path);
|
remove_connection (manager, connection, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -635,30 +625,26 @@ connection_updated_cb (DBusGProxy *proxy, GHashTable *settings, gpointer user_da
|
|||||||
NMConnection *new_connection;
|
NMConnection *new_connection;
|
||||||
NMConnection *old_connection;
|
NMConnection *old_connection;
|
||||||
GHashTable *hash;
|
GHashTable *hash;
|
||||||
const char *path;
|
|
||||||
gboolean valid = FALSE;
|
gboolean valid = FALSE;
|
||||||
|
|
||||||
old_connection = get_connection_for_proxy (manager, proxy, &hash, &path);
|
old_connection = get_connection_for_proxy (manager, proxy, &hash);
|
||||||
if (!old_connection)
|
g_return_if_fail (old_connection != NULL);
|
||||||
return;
|
|
||||||
|
|
||||||
new_connection = nm_connection_new_from_hash (settings);
|
new_connection = nm_connection_new_from_hash (settings);
|
||||||
if (!new_connection) {
|
if (!new_connection) {
|
||||||
/* New connection invalid, remove existing connection */
|
/* New connection invalid, remove existing connection */
|
||||||
remove_connection (manager, old_connection, hash, path);
|
remove_connection (manager, old_connection, hash);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
g_object_unref (new_connection);
|
g_object_unref (new_connection);
|
||||||
|
|
||||||
valid = nm_connection_replace_settings (old_connection, settings);
|
valid = nm_connection_replace_settings (old_connection, settings);
|
||||||
if (valid) {
|
if (valid) {
|
||||||
NMConnectionScope scope;
|
g_signal_emit (manager, signals[CONNECTION_UPDATED], 0,
|
||||||
|
old_connection,
|
||||||
scope = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (old_connection),
|
nm_connection_get_scope (old_connection));
|
||||||
NM_MANAGER_CONNECTION_TYPE_TAG));
|
|
||||||
g_signal_emit (manager, signals[CONNECTION_UPDATED], 0, old_connection, scope);
|
|
||||||
} else {
|
} else {
|
||||||
remove_connection (manager, old_connection, hash, path);
|
remove_connection (manager, old_connection, hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -947,10 +933,10 @@ emit_removed (gpointer key, gpointer value, gpointer user_data)
|
|||||||
{
|
{
|
||||||
NMManager *manager = NM_MANAGER (user_data);
|
NMManager *manager = NM_MANAGER (user_data);
|
||||||
NMConnection *connection = NM_CONNECTION (value);
|
NMConnection *connection = NM_CONNECTION (value);
|
||||||
NMConnectionScope scope;
|
|
||||||
|
|
||||||
scope = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG));
|
g_signal_emit (manager, signals[CONNECTION_REMOVED], 0,
|
||||||
g_signal_emit (manager, signals[CONNECTION_REMOVED], 0, connection, scope);
|
connection,
|
||||||
|
nm_connection_get_scope (connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -1361,7 +1347,6 @@ connection_added_default_handler (NMManager *manager,
|
|||||||
{
|
{
|
||||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (manager);
|
||||||
PendingConnectionInfo *info = priv->pending_connection_info;
|
PendingConnectionInfo *info = priv->pending_connection_info;
|
||||||
const char *path;
|
|
||||||
gboolean success;
|
gboolean success;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
@@ -1371,8 +1356,7 @@ connection_added_default_handler (NMManager *manager,
|
|||||||
if (scope != info->scope)
|
if (scope != info->scope)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
path = nm_manager_get_connection_dbus_path (manager, connection);
|
if (strcmp (info->connection_path, nm_connection_get_path (connection)))
|
||||||
if (strcmp (info->connection_path, path))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Will destroy below; can't be valid during the initial activation start */
|
/* Will destroy below; can't be valid during the initial activation start */
|
||||||
@@ -1504,16 +1488,13 @@ add_one_connection_element (NMManager *manager,
|
|||||||
const char *service_name = NULL;
|
const char *service_name = NULL;
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
const char *specific_object;
|
const char *specific_object;
|
||||||
gpointer type_ptr;
|
|
||||||
|
|
||||||
req = nm_device_get_act_request (device);
|
req = nm_device_get_act_request (device);
|
||||||
g_assert (req);
|
g_assert (req);
|
||||||
|
|
||||||
connection = nm_act_request_get_connection (req);
|
connection = nm_act_request_get_connection (req);
|
||||||
type_ptr = g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG);
|
|
||||||
g_return_val_if_fail (type_ptr != NULL, NULL);
|
|
||||||
|
|
||||||
switch ((NMConnectionScope) GPOINTER_TO_UINT (type_ptr)) {
|
switch (nm_connection_get_scope (connection)) {
|
||||||
case NM_CONNECTION_SCOPE_USER:
|
case NM_CONNECTION_SCOPE_USER:
|
||||||
service_name = NM_DBUS_SERVICE_USER_SETTINGS;
|
service_name = NM_DBUS_SERVICE_USER_SETTINGS;
|
||||||
break;
|
break;
|
||||||
@@ -1548,7 +1529,7 @@ add_one_connection_element (NMManager *manager,
|
|||||||
g_value_take_boxed (&entry, dbus_g_type_specialized_construct (type));
|
g_value_take_boxed (&entry, dbus_g_type_specialized_construct (type));
|
||||||
dbus_g_type_struct_set (&entry,
|
dbus_g_type_struct_set (&entry,
|
||||||
0, service_name,
|
0, service_name,
|
||||||
1, nm_manager_get_connection_dbus_path (manager, connection),
|
1, nm_connection_get_path (connection),
|
||||||
2, specific_object ? specific_object : "/",
|
2, specific_object ? specific_object : "/",
|
||||||
3, dev_array,
|
3, dev_array,
|
||||||
G_MAXUINT);
|
G_MAXUINT);
|
||||||
@@ -1793,21 +1774,3 @@ nm_manager_get_connection_by_object_path (NMManager *manager,
|
|||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
|
||||||
nm_manager_get_connection_dbus_path (NMManager *manager,
|
|
||||||
NMConnection *connection)
|
|
||||||
{
|
|
||||||
DBusGProxy *proxy;
|
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_MANAGER (manager), NULL);
|
|
||||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
|
|
||||||
|
|
||||||
proxy = g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_PROXY_TAG);
|
|
||||||
if (!DBUS_IS_G_PROXY (proxy)) {
|
|
||||||
nm_warning ("Couldn't get dbus proxy for connection.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dbus_g_proxy_get_path (proxy);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@@ -19,7 +19,6 @@
|
|||||||
#define NM_MANAGER_WIRELESS_HARDWARE_ENABLED "wireless-hardware-enabled"
|
#define NM_MANAGER_WIRELESS_HARDWARE_ENABLED "wireless-hardware-enabled"
|
||||||
|
|
||||||
#define NM_MANAGER_CONNECTION_PROXY_TAG "dbus-proxy"
|
#define NM_MANAGER_CONNECTION_PROXY_TAG "dbus-proxy"
|
||||||
#define NM_MANAGER_CONNECTION_TYPE_TAG "service-type"
|
|
||||||
#define NM_MANAGER_CONNECTION_SECRETS_PROXY_TAG "dbus-secrets-proxy"
|
#define NM_MANAGER_CONNECTION_SECRETS_PROXY_TAG "dbus-secrets-proxy"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -90,17 +89,4 @@ NMConnection * nm_manager_get_connection_by_object_path (NMManager *manager,
|
|||||||
NMConnectionScope scope,
|
NMConnectionScope scope,
|
||||||
const char *path);
|
const char *path);
|
||||||
|
|
||||||
static inline NMConnectionScope
|
|
||||||
nm_manager_get_connection_scope (NMConnection *connection)
|
|
||||||
{
|
|
||||||
NMConnectionScope scope;
|
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), NM_CONNECTION_SCOPE_UNKNOWN);
|
|
||||||
|
|
||||||
scope = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), NM_MANAGER_CONNECTION_TYPE_TAG));
|
|
||||||
if (scope != NM_CONNECTION_SCOPE_USER && scope != NM_CONNECTION_SCOPE_SYSTEM)
|
|
||||||
scope = NM_CONNECTION_SCOPE_UNKNOWN;
|
|
||||||
return scope;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* NM_MANAGER_H */
|
#endif /* NM_MANAGER_H */
|
||||||
|
Reference in New Issue
Block a user