From 4508f46e8b3b42f2d062566ecbc741daf5cf1338 Mon Sep 17 00:00:00 2001
From: Matt Ranostay <matt.ranostay@konsulko.com>
Date: Fri, 5 Oct 2018 22:51:54 +0800
Subject: libqtappfw: bluetooth: add binding version 2.0 verbs

Add initial set of Bluetooth binding version 2.0 (rewrite) verbs for
the BluetoothMessage

Bug-AGL: SPEC-1736
Change-Id: Ie0ee68b0ba652e9163746b397c14dd925c85a9fb
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
---
 bluetooth/bluetoothmessage.cpp | 12 ++++++++----
 bluetooth/bluetoothmessage.h   | 12 ++++++++++++
 2 files changed, 20 insertions(+), 4 deletions(-)

(limited to 'bluetooth')

diff --git a/bluetooth/bluetoothmessage.cpp b/bluetooth/bluetoothmessage.cpp
index d31705c..9eef02f 100644
--- a/bluetooth/bluetoothmessage.cpp
+++ b/bluetooth/bluetoothmessage.cpp
@@ -23,11 +23,15 @@
 
 bool BluetoothMessage::createRequest(QString verb, QJsonObject parameter)
 {
-    if (m_api_version != "1.0")
-        return false;
+    if (m_api_version == "1.0") {
+        if (!verbs_v1.contains(verb))
+            return false;
+    }
 
-    if (!verbs_v1.contains(verb))
-        return false;
+    if (m_api_version == "2.0") {
+        if (!verbs_v2.contains(verb))
+            return false;
+    }
 
     return Message::createRequest("Bluetooth-Manager", verb, parameter);
 }
diff --git a/bluetooth/bluetoothmessage.h b/bluetooth/bluetoothmessage.h
index 6284c4e..0a26322 100644
--- a/bluetooth/bluetoothmessage.h
+++ b/bluetooth/bluetoothmessage.h
@@ -31,6 +31,11 @@ class BluetoothMessage : public Message
         bool isDeviceAddedEvent() { return (this->eventName() == "device_added"); };
         bool isDeviceRemovedEvent() { return (this->eventName() == "device_removed"); };
         bool isDeviceUpdatedEvent() { return (this->eventName() == "device_updated"); };
+
+        // Bluetooth API Schema 2.0
+        bool isDeviceChangesEvent() { return (this->eventName() == "device_changes"); };
+        bool isAgentEvent() { return (this->eventName() == "agent"); };
+
         bool createRequest(QString verb, QJsonObject parameter);
 
     private:
@@ -43,6 +48,13 @@ class BluetoothMessage : public Message
             "subscribe",           "unsubscribe",
         };
 
+        QStringList verbs_v2 {
+            "connect",             "disconnect",        "managed_objects",
+            "adapter_state",       "pair",              "cancel_pairing",
+            "confirm_pairing",     "remove_device",     "version",
+            "subscribe",           "unsubscribe",
+        };
+
         QString m_api_version;
 };
 
-- 
cgit