724
#ifdef HAVE_NETWORK_MANAGER
726
state_notify (DBusPendingCall *pending, gpointer data)
718
network_monitor_signal (GDBusProxy *proxy,
719
const gchar *sender_name,
720
const gchar *signal_name,
721
GVariant *parameters,
728
DBusMessage *msg = dbus_pending_call_steal_reply (pending);
733
if (dbus_message_get_type (msg) == DBUS_MESSAGE_TYPE_METHOD_RETURN) {
734
dbus_uint32_t result;
736
if (dbus_message_get_args (msg, NULL,
737
DBUS_TYPE_UINT32, &result,
738
DBUS_TYPE_INVALID)) {
739
if (result == NM_STATE_CONNECTED) {
724
if (g_str_equal (signal_name, "StateChanged")) {
725
if (g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(u)"))) {
728
g_variant_get (parameters, "(u)", &state);
730
if (state == NM_STATE_CONNECTED) {
740
731
update_weather_infos ();
745
dbus_message_unref (msg);
749
check_network (DBusConnection *connection)
751
DBusMessage *message;
752
DBusPendingCall *reply;
754
message = dbus_message_new_method_call (NM_DBUS_SERVICE,
758
if (dbus_connection_send_with_reply (connection, message, &reply, -1)) {
759
dbus_pending_call_set_notify (reply, state_notify, NULL, NULL);
760
dbus_pending_call_unref (reply);
763
dbus_message_unref (message);
766
static DBusHandlerResult
767
filter_func (DBusConnection *connection,
768
DBusMessage *message,
771
if (dbus_message_is_signal (message,
774
check_network (connection);
776
return DBUS_HANDLER_RESULT_HANDLED;
779
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
783
738
setup_network_monitor (void)
787
static DBusGConnection *bus = NULL;
788
DBusConnection *dbus;
792
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
794
g_warning ("Couldn't connect to system bus: %s",
796
g_error_free (error);
740
static GDBusProxy *proxy;
741
GError *error = NULL;
744
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
745
G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
746
NULL, NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE,
750
g_warning ("Couldn't create NetworkManager proxy: %s",
752
g_error_free (error);
801
dbus_error_init (&derror);
802
dbus = dbus_g_connection_get_connection (bus);
803
dbus_connection_add_filter (dbus, filter_func, NULL, NULL);
804
dbus_bus_add_match (dbus,
806
"interface='" NM_DBUS_INTERFACE "'",
808
if (dbus_error_is_set (&derror)) {
809
g_warning ("Couldn't register signal handler: %s: %s",
810
derror.name, derror.message);
811
dbus_error_free (&derror);
756
g_signal_connect (proxy, "g-signal", G_CALLBACK (network_monitor_signal), NULL);