Merge pull request #53 from jeez/timeout
authorKenneth Rohde Christiansen <kenneth@webkit.org>
Mon, 5 Aug 2013 16:31:34 +0000 (09:31 -0700)
committerKenneth Rohde Christiansen <kenneth@webkit.org>
Mon, 5 Aug 2013 16:31:34 +0000 (09:31 -0700)
[Bluetooth] Handle timeout in setVisible

1  2 
bluetooth/bluetooth_context_bluez4.cc

@@@ -268,13 -268,23 +268,22 @@@ void BluetoothContext::DeviceFound(std:
  void BluetoothContext::HandleSetAdapterProperty(const picojson::value& msg) {
    std::string property = msg.get("property").to_str();
  
 -  GVariant* value = NULL;
 +  GVariant* value = 0;
    if (property == "Name")
-      value = g_variant_new("s", msg.get("value").to_str().c_str());
-   else if (property == "Discoverable" || property == "Powered")
-      value = g_variant_new("b", msg.get("value").get<bool>());
+     value = g_variant_new("s", msg.get("value").to_str().c_str());
+   else if (property == "Discoverable") {
+     value = g_variant_new("b", msg.get("value").get<bool>());
+     if (msg.contains("timeout")) {
+       const guint32 timeout = static_cast<guint32>(msg.get("timeout").get<double>());
+       g_dbus_proxy_call(adapter_proxy_, "SetProperty",
+           g_variant_new("(sv)", "DiscoverableTimeout", g_variant_new("u", timeout)),
+           G_DBUS_CALL_FLAGS_NONE, 5000, NULL, NULL, NULL);
+     }
+   } else if (property == "Powered")
+     value = g_variant_new("b", msg.get("value").get<bool>());
  
 -  if (!value)
 -    return;
 +  assert(value);
  
    callbacks_map_[property] = msg.get("reply_id").to_str();