From daadd6ca0e572fe55d307ff034d8cd3342c1c7c1 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Mon, 24 Sep 2018 16:21:12 +0800 Subject: libqtappfw: bluetooth: add initial API versioning to BluetoothMessage Future rewrite of the Bluetooth binding will have different schema for accessible verbs. Allow clients and middleware to explictly request a version. Bug-AGL: SPEC-1736 Change-Id: I488836a7422aac85b19815d837dabb5230ee47f8 Signed-off-by: Matt Ranostay --- bluetooth/bluetoothmessage.cpp | 9 ++++++--- bluetooth/bluetoothmessage.h | 7 ++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/bluetooth/bluetoothmessage.cpp b/bluetooth/bluetoothmessage.cpp index 52ecbed..d31705c 100644 --- a/bluetooth/bluetoothmessage.cpp +++ b/bluetooth/bluetoothmessage.cpp @@ -23,8 +23,11 @@ bool BluetoothMessage::createRequest(QString verb, QJsonObject parameter) { - if (!verbs.contains(verb)) - return false; + if (m_api_version != "1.0") + return false; - return Message::createRequest("Bluetooth-Manager", verb, parameter); + if (!verbs_v1.contains(verb)) + return false; + + return Message::createRequest("Bluetooth-Manager", verb, parameter); } diff --git a/bluetooth/bluetoothmessage.h b/bluetooth/bluetoothmessage.h index 89aef1a..6284c4e 100644 --- a/bluetooth/bluetoothmessage.h +++ b/bluetooth/bluetoothmessage.h @@ -23,6 +23,9 @@ class BluetoothMessage : public Message { Q_OBJECT public: + explicit BluetoothMessage(QString api_version = "1.0", QObject *parent = 0) { m_api_version = api_version; }; + + // Bluetooth API Schema 1.0 bool isConnectionEvent() { return (this->eventName() == "connection"); }; bool isRequestConfirmationEvent() { return (this->eventName() == "request_confirmation"); }; bool isDeviceAddedEvent() { return (this->eventName() == "device_added"); }; @@ -31,7 +34,7 @@ class BluetoothMessage : public Message bool createRequest(QString verb, QJsonObject parameter); private: - QStringList verbs { + QStringList verbs_v1 { "start_discovery" , "stop_discovery", "power", "remove_device", "pair", "cancel_pair", "connect", "disconnect", "device_priorities", @@ -39,6 +42,8 @@ class BluetoothMessage : public Message "set_avrcp_controls", "send_confirmation", "version", "subscribe", "unsubscribe", }; + + QString m_api_version; }; #endif // BLUETOOTH_MESSAGE_H -- cgit 1.2.3-korg