gnome-bluetooth r438 - trunk/common
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-bluetooth r438 - trunk/common
- Date: Tue, 3 Mar 2009 17:04:32 +0000 (UTC)
Author: hadess
Date: Tue Mar 3 17:04:32 2009
New Revision: 438
URL: http://svn.gnome.org/viewvc/gnome-bluetooth?rev=438&view=rev
Log:
Add state-changed signal
And fix status when getting the power state. Add
a few FIXMEs.
Modified:
trunk/common/bluetooth-killswitch.c
trunk/common/bluetooth-killswitch.h
Modified: trunk/common/bluetooth-killswitch.c
==============================================================================
--- trunk/common/bluetooth-killswitch.c (original)
+++ trunk/common/bluetooth-killswitch.c Tue Mar 3 17:04:32 2009
@@ -31,6 +31,13 @@
#include "bluetooth-killswitch.h"
+enum {
+ STATE_CHANGED,
+ LAST_SIGNAL
+};
+
+static int signals[LAST_SIGNAL] = { 0 };
+
#define BLUETOOTH_KILLSWITCH_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
BLUETOOTH_TYPE_KILLSWITCH, BluetoothKillswitchPrivate))
@@ -38,7 +45,7 @@
struct _BluetoothIndKillswitch {
char *udi;
DBusPendingCall *call;
- gboolean killed;
+ gboolean killed; //FIXME Change this to be a KillswitchState
};
typedef struct _BluetoothKillswitchPrivate BluetoothKillswitchPrivate;
@@ -60,12 +67,15 @@
gint32 power;
GList *l;
+ priv->num_remaining_answers--;
+
reply = dbus_pending_call_steal_reply(call);
if (dbus_message_get_args(reply, NULL, DBUS_TYPE_INT32, &power,
DBUS_TYPE_INVALID) == FALSE) {
dbus_message_unref(reply);
- return;
+ //FIXME ind->killed is wrong in that case
+ goto done;
}
/* Look for the killswitch */
@@ -73,14 +83,18 @@
BluetoothIndKillswitch *ind = l->data;
if (call != ind->call)
continue;
- ind->killed = (power > 0);
ind->call = NULL;
- priv->num_remaining_answers--;
break;
}
dbus_message_unref(reply);
dbus_pending_call_unref (call);
+
+done:
+ if (priv->num_remaining_answers == 0)
+ g_signal_emit (G_OBJECT (killswitch),
+ signals[STATE_CHANGED],
+ 0, bluetooth_killswitch_get_state (killswitch));
}
static void
@@ -92,12 +106,15 @@
GList *l;
gint32 power;
+ priv->num_remaining_answers--;
+
reply = dbus_pending_call_steal_reply (call);
if (dbus_message_get_args(reply, NULL, DBUS_TYPE_INT32, &power,
DBUS_TYPE_INVALID) == FALSE) {
dbus_message_unref(reply);
- return;
+ //FIXME might be, might not, ind->killed is wrong
+ goto done;
}
/* Look for the killswitch */
@@ -105,16 +122,19 @@
BluetoothIndKillswitch *ind = l->data;
if (call != ind->call)
continue;
- ind->killed = (power > 0);
+ ind->killed = (power == 0);
ind->call = NULL;
- priv->num_remaining_answers--;
break;
}
dbus_message_unref(reply);
dbus_pending_call_unref (call);
- //g_object_notify (G_OBJECT (killswitch), "killed");
+done:
+ if (priv->num_remaining_answers == 0)
+ g_signal_emit (G_OBJECT (killswitch),
+ signals[STATE_CHANGED],
+ 0, bluetooth_killswitch_get_state (killswitch));
}
void
@@ -199,6 +219,7 @@
}
ind->call = call;
+ ind->killed = !value;
priv->num_remaining_answers++;
dbus_pending_call_set_notify(call, setpower_reply, killswitch, NULL);
@@ -376,6 +397,16 @@
g_type_class_add_private(klass, sizeof(BluetoothKillswitchPrivate));
object_class->finalize = bluetooth_killswitch_finalize;
+
+ signals[STATE_CHANGED] =
+ g_signal_new ("state-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (BluetoothKillswitchClass, state_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE, 1, G_TYPE_INT);
+
}
BluetoothKillswitch *
Modified: trunk/common/bluetooth-killswitch.h
==============================================================================
--- trunk/common/bluetooth-killswitch.h (original)
+++ trunk/common/bluetooth-killswitch.h Tue Mar 3 17:04:32 2009
@@ -57,6 +57,8 @@
struct _BluetoothKillswitchClass {
GObjectClass parent_class;
+
+ void (*state_changed) (BluetoothKillswitch *killswitch, KillswitchState state);
};
GType bluetooth_killswitch_get_type(void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]