diff options
author | Dan Williams <dcbw@redhat.com> | 2004-08-11 18:14:02 +0000 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2004-08-11 18:14:02 +0000 |
commit | d06aa3e6ff592adc77a4346a08bfd1c56fefdba4 (patch) | |
tree | 1502d6facafb01f312fcca43fdc806736f7ad442 /info-daemon | |
parent | 8e04fc11ff799bf369c59f7f2fc29916b7b6b9f5 (diff) | |
download | NetworkManager-d06aa3e6ff592adc77a4346a08bfd1c56fefdba4.tar.gz |
2004-08-11 Dan Williams <dcbw@redhat.com>
* info-daemon/NetworkManagerInfo.c:
- (main): clean up Seth's code style
* info-daemon/NetworkManagerInfoDbus.c:
- Use the more aptly-named path/service/interface constants from NetworkManager
- Don't return empty strings ("") as object paths ever, instead return errors
* panel-applet/NMWirelessApplet.c:
- Clean up Seth's code style
* src/NetworkManager.[ch]
- (nm_remove_device_from_list): remove anything having to do with pending_device
- (main, nm_print_usage): change --daemon=[yes|no] -> --no-daemon
* src/NetworkManagerAPList.[ch]
- Move Iter struct right above the iter functions to preserve opacity
- (nm_ap_list_remove_ap): implement
- (nm_ap_list_update_network): deal with errors returned from nm_dbus_get_network_priority(),
remove AP if NetworkManagerInfo doesn't know anything about it
- (nm_ap_list_diff): user NMAPList iterators
- (nm_ap_list_print_members): implement debugging function
* src/NetworkManagerDbus.[ch]
- (nm_dbus_nm_get_active_device): remove anything to do with pending_device
- (nm_dbus_get_user_key_for_network): remove DBusPendingCall stuff (unused),
and move the actual key setting stuff into NetworkManagerDevice.c
- (nm_dbus_get_network_priority): return -1 now on errors
- (nm_dbus_nmi_filter): fix strcmp() error that caused PreferredNetworkUpdate signals to
get lost, and force the active device to update its "best" ap when AP lists change
- (nm_dbus_nm_message_handler): Update conditions for returning "connecting" for a "status"
method call due to pending_device member removal
* src/NetworkManagerDevice.[ch]
- Move NMDevice structure to the top
- Add a wireless scan mutex and a best_ap mutex to the Wireless Options structure
- Remove Pending Action stuff from everywhere
- (nm_device_activation_*): We now "begin" activation and start a thread to do the
activation for us. This thread blocks until all conditions for activation have
been met (ie for wireless devices, we need a valid WEP key and a "best" ap), and
then setup up the interface and runs dhclient. We have to do this because there
is no guaruntee how long dhclient takes, and while we are blocking on it, we cannot
run our main loop and respond to dbus method calls or HAL device removals/inserts
- (nm_device_set_user_key_for_network): Move logic here from NetworkManagerDbus.c so we
can tell nm_device_activation_worker() that we've got a key
- (nm_device_*_best_ap): lock access to best_ap member of Wireless Options structure
- (nm_device_get_path_for_ap): dumb it down so the list doesn't lock against itself when
diffing (AP appear/disappear signal functions make sure the AP is actually in the device's
list)
- (nm_device_update_best_ap): move logic from nm_wireless_is_ap_better() here
* src/NetworkManagerPolicy.c
- Remove anything to do with pending_device
- Adjust device activation to deal with activation-in-worker-thread
* src/NetworkManagerUtils.c
- Clean up locking debugging a bit
* src/NetworkManagerWireless.[ch]
- (nm_wireless_is_ap_better): remove, stick logic in nm_device_update_best_ap(). This function
was badly named and is better as a device function
* panel-applet/.cvsignore: add
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@46 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Diffstat (limited to 'info-daemon')
-rw-r--r-- | info-daemon/NetworkManagerInfo.c | 3 | ||||
-rw-r--r-- | info-daemon/NetworkManagerInfoDbus.c | 82 |
2 files changed, 51 insertions, 34 deletions
diff --git a/info-daemon/NetworkManagerInfo.c b/info-daemon/NetworkManagerInfo.c index 56fab50f32..c2318bc734 100644 --- a/info-daemon/NetworkManagerInfo.c +++ b/info-daemon/NetworkManagerInfo.c @@ -168,7 +168,8 @@ int main( int argc, char *argv[] ) GMainLoop *loop; guint notify_id; - struct poptOption options[] = { + struct poptOption options[] = + { { "no-daemon", 'n', POPT_ARG_NONE, NULL, 0, "Don't detatch from the console and run in the background.", NULL }, { NULL, '\0', 0, NULL, 0, NULL, NULL } diff --git a/info-daemon/NetworkManagerInfoDbus.c b/info-daemon/NetworkManagerInfoDbus.c index 58f934e42d..565fcff57e 100644 --- a/info-daemon/NetworkManagerInfoDbus.c +++ b/info-daemon/NetworkManagerInfoDbus.c @@ -30,13 +30,24 @@ #include "NetworkManagerInfoDbus.h" #include "NetworkManagerInfoPassphraseDialog.h" -#define NMI_DBUS_NMI_OBJECT_PATH_PREFIX "/org/freedesktop/NetworkManagerInfo" -#define NMI_DBUS_NMI_NAMESPACE "org.freedesktop.NetworkManagerInfo" -#define NM_DBUS_NM_OBJECT_PATH_PREFIX "/org/freedesktop/NetworkManager" -#define NM_DBUS_NM_NAMESPACE "org.freedesktop.NetworkManager" -#define NM_DBUS_NM_DEVICES_OBJECT_PATH_PREFIX "/org/freedesktop/NetworkManager/Devices" -#define NM_DBUS_NM_DEVICES_NAMESPACE "org.freedesktop.NetworkManager.Devices" +#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager" +#define NM_DBUS_PATH "/org/freedesktop/NetworkManager" +#define NM_DBUS_INTERFACE "org.freedesktop.NetworkManager" +#define NM_DBUS_PATH_DEVICES "/org/freedesktop/NetworkManager/Devices" +#define NM_DBUS_INTERFACE_DEVICES "org.freedesktop.NetworkManager.Devices" + +#define NMI_DBUS_SERVICE "org.freedesktop.NetworkManagerInfo" +#define NMI_DBUS_PATH "/org/freedesktop/NetworkManagerInfo" +#define NMI_DBUS_INTERFACE "org.freedesktop.NetworkManagerInfo" + + +/* + * nmi_network_type_valid + * + * Helper to validate network types NMI can deal with + * + */ inline gboolean nmi_network_type_valid (NMINetworkType type) { if ((type == NETWORK_TYPE_TRUSTED) || (type == NETWORK_TYPE_PREFERRED)) @@ -113,11 +124,7 @@ void nmi_dbus_return_user_key (DBusConnection *connection, const char *device, g_return_if_fail (network != NULL); g_return_if_fail (passphrase != NULL); - message = dbus_message_new_method_call (NM_DBUS_NM_NAMESPACE, - NM_DBUS_NM_OBJECT_PATH_PREFIX, - NM_DBUS_NM_NAMESPACE, - "setKeyForNetwork"); - if (message == NULL) + if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "setKeyForNetwork"))) { fprintf (stderr, "nmi_dbus_return_user_key(): Couldn't allocate the dbus message\n"); return; @@ -161,7 +168,7 @@ void nmi_dbus_signal_update_network (DBusConnection *connection, const char *net default: return; } - message = dbus_message_new_signal (NMI_DBUS_NMI_OBJECT_PATH_PREFIX, NMI_DBUS_NMI_NAMESPACE, signal); + message = dbus_message_new_signal (NMI_DBUS_PATH, NMI_DBUS_INTERFACE, signal); if (!message) { fprintf (stderr, "nmi_dbus_signal_update_network(): Not enough memory for new dbus message!\n"); @@ -200,14 +207,14 @@ static DBusMessage *nmi_dbus_get_networks (NMIAppInfo *info, DBusMessage *messag dbus_error_init (&error); if (!dbus_message_get_args (message, &error, DBUS_TYPE_INT32, &type, DBUS_TYPE_INVALID)) { - reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_NMI_NAMESPACE, "InvalidArguments", + reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments", "NetworkManagerInfo::getNetworks called with invalid arguments."); return (reply_message); } if (!nmi_network_type_valid (type)) { - reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_NMI_NAMESPACE, "InvalidArguments", + reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments", "NetworkManagerInfo::getNetworks called with an invalid network type %d.", type); return (reply_message); } @@ -222,16 +229,20 @@ static DBusMessage *nmi_dbus_get_networks (NMIAppInfo *info, DBusMessage *messag /* List all allowed access points that gconf knows about */ element = dir_list = gconf_client_all_dirs (info->gconf_client, path, NULL); - reply_message = dbus_message_new_method_return (message); - dbus_message_iter_init (reply_message, &iter); - dbus_message_iter_append_array (&iter, &iter_array, DBUS_TYPE_STRING); - if (!dir_list) - dbus_message_iter_append_string (&iter_array, ""); + { + reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "NoNetworks", + "There were are no %s networks stored.", + type == NETWORK_TYPE_TRUSTED ? "trusted" : (type == NETWORK_TYPE_PREFERRED ? "preferred" : "unknown")); + } else { gboolean value_added = FALSE; + reply_message = dbus_message_new_method_return (message); + dbus_message_iter_init (reply_message, &iter); + dbus_message_iter_append_array (&iter, &iter_array, DBUS_TYPE_STRING); + /* Append the essid of every allowed or ignored access point we know of * to a string array in the dbus message. */ @@ -256,7 +267,12 @@ static DBusMessage *nmi_dbus_get_networks (NMIAppInfo *info, DBusMessage *messag /* Make sure that there's at least one array element if all the gconf calls failed */ if (!value_added) - dbus_message_iter_append_string (&iter_array, ""); + { + dbus_message_unref (reply_message); + reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "NoNetworks", + "There were are no %s networks stored.", + type == NETWORK_TYPE_TRUSTED ? "trusted" : (type == NETWORK_TYPE_PREFERRED ? "preferred" : "unknown")); + } } return (reply_message); @@ -288,7 +304,7 @@ static DBusMessage *nmi_dbus_get_network_prio (NMIAppInfo *info, DBusMessage *me || !nmi_network_type_valid (type) || (strlen (network) <= 0)) { - reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_NMI_NAMESPACE, "InvalidArguments", + reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments", "NetworkManagerInfo::get*NetworkPriority called with invalid arguments."); return (reply_message); } @@ -313,7 +329,7 @@ static DBusMessage *nmi_dbus_get_network_prio (NMIAppInfo *info, DBusMessage *me } else { - reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_NMI_NAMESPACE, "BadNetworkData", + reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadNetworkData", "NetworkManagerInfo::get*NetworkPriority could not access data for network '%s'", network); } @@ -347,7 +363,7 @@ static DBusMessage *nmi_dbus_get_network_essid (NMIAppInfo *info, DBusMessage *m || !nmi_network_type_valid (type) || (strlen (network) <= 0)) { - reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_NMI_NAMESPACE, "InvalidArguments", + reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments", "NetworkManagerInfo::get*NetworkEssid called with invalid arguments."); return (reply_message); } @@ -372,7 +388,7 @@ static DBusMessage *nmi_dbus_get_network_essid (NMIAppInfo *info, DBusMessage *m } else { - reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_NMI_NAMESPACE, "BadNetworkData", + reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "BadNetworkData", "NetworkManagerInfo::get*NetworkEssid could not access data for network '%s'", network); } @@ -406,7 +422,7 @@ static DBusMessage *nmi_dbus_get_network_key (NMIAppInfo *info, DBusMessage *mes || !nmi_network_type_valid (type) || (strlen (network) <= 0)) { - reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_NMI_NAMESPACE, "InvalidArguments", + reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "InvalidArguments", "NetworkManagerInfo::get*NetworkKey called with invalid arguments."); return (reply_message); } @@ -479,7 +495,7 @@ static DBusHandlerResult nmi_dbus_nmi_message_handler (DBusConnection *connectio reply_message = nmi_dbus_get_network_key (info, message); else { - reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_NMI_NAMESPACE, "UnknownMethod", + reply_message = nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "UnknownMethod", "NetworkManagerInfo knows nothing about the method %s for object %s", method, path); } @@ -518,9 +534,9 @@ static DBusHandlerResult nmi_dbus_filter (DBusConnection *connection, DBusMessag g_return_val_if_fail (info != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED); - if (dbus_message_is_signal (message, NM_DBUS_NM_NAMESPACE, "WirelessNetworkAppeared")) + if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "WirelessNetworkAppeared")) appeared = TRUE; - else if (dbus_message_is_signal (message, NM_DBUS_NM_NAMESPACE, "WirelessNetworkDisappeared")) + else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "WirelessNetworkDisappeared")) disappeared = TRUE; if (appeared || disappeared) @@ -560,14 +576,14 @@ int nmi_dbus_service_init (DBusConnection *dbus_connection, NMIAppInfo *info) DBusObjectPathVTable nmi_vtable = { &nmi_dbus_nmi_unregister_handler, &nmi_dbus_nmi_message_handler, NULL, NULL, NULL, NULL }; dbus_error_init (&dbus_error); - dbus_bus_acquire_service (dbus_connection, NMI_DBUS_NMI_NAMESPACE, 0, &dbus_error); + dbus_bus_acquire_service (dbus_connection, NMI_DBUS_SERVICE, 0, &dbus_error); if (dbus_error_is_set (&dbus_error)) { fprintf (stderr, "nmi_dbus_service_init() could not acquire its service. dbus_bus_acquire_service() says: '%s'\n", dbus_error.message); return (-1); } - if (!dbus_connection_register_object_path (dbus_connection, NMI_DBUS_NMI_OBJECT_PATH_PREFIX, &nmi_vtable, info)) + if (!dbus_connection_register_object_path (dbus_connection, NMI_DBUS_PATH, &nmi_vtable, info)) { fprintf (stderr, "nmi_dbus_service_init() could not register a handler for NetworkManagerInfo. Not enough memory?\n"); return (-1); @@ -579,9 +595,9 @@ int nmi_dbus_service_init (DBusConnection *dbus_connection, NMIAppInfo *info) dbus_error_init (&dbus_error); dbus_bus_add_match (dbus_connection, "type='signal'," - "interface='"NM_DBUS_NM_NAMESPACE"'," - "sender='"NM_DBUS_NM_NAMESPACE"'," - "path='"NM_DBUS_NM_OBJECT_PATH_PREFIX"'", &dbus_error); + "interface='" NM_DBUS_INTERFACE "'," + "sender='" NM_DBUS_SERVICE "'," + "path='" NM_DBUS_PATH "'", &dbus_error); if (dbus_error_is_set (&dbus_error)) return (-1); |