aboutsummaryrefslogtreecommitdiffstats
path: root/thermometer
diff options
context:
space:
mode:
authorSantiago Carot-Nemesio <sancane@gmail.com>2011-10-24 19:04:04 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2011-11-02 11:55:05 +0200
commit5fa4b3d10f3389fed6cc08ffdf8b35cbbdc71340 (patch)
tree4ea5aa6ee3cd27c9a5f3e39657ec7e1941d02d7e /thermometer
parente4d4359c59cf1ac223bbe95e1e4290b4cc917c27 (diff)
downloadbluez-5fa4b3d10f3389fed6cc08ffdf8b35cbbdc71340.tar.gz
bluez-5fa4b3d10f3389fed6cc08ffdf8b35cbbdc71340.tar.xz
bluez-5fa4b3d10f3389fed6cc08ffdf8b35cbbdc71340.zip
Implement D-Bus unregister watcher function
Diffstat (limited to 'thermometer')
-rw-r--r--thermometer/thermometer.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index e444dd2f..a1075156 100644
--- a/thermometer/thermometer.c
+++ b/thermometer/thermometer.c
@@ -450,6 +450,11 @@ static void enable_final_measurement(struct thermometer *t)
/* TODO: enable final measurements */
}
+static void disable_final_measurement(struct thermometer *t)
+{
+ /* TODO: disable final measurements */
+}
+
static void watcher_exit(DBusConnection *conn, void *user_data)
{
/* TODO: Watcher disconnected */
@@ -510,9 +515,28 @@ static DBusMessage *register_watcher(DBusConnection *conn, DBusMessage *msg,
static DBusMessage *unregister_watcher(DBusConnection *conn, DBusMessage *msg,
void *data)
{
- /* TODO: */
- return g_dbus_create_error(msg, ERROR_INTERFACE ".ThermometerError",
- "Function not implemented.");
+ const gchar *sender = dbus_message_get_sender(msg);
+ struct thermometer *t = data;
+ struct watcher *watcher;
+ gchar *path;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
+
+ watcher = find_watcher(t, sender, path);
+ if (watcher == NULL)
+ return btd_error_does_not_exist(msg);
+
+ DBG("Thermometer watcher %s unregistered", path);
+
+ t->fwatchers = g_slist_remove(t->fwatchers, watcher);
+ destroy_watcher(watcher);
+
+ if (g_slist_length(t->fwatchers) == 0)
+ disable_final_measurement(t);
+
+ return dbus_message_new_method_return(msg);
}
static DBusMessage *enable_intermediate(DBusConnection *conn, DBusMessage *msg,