summaryrefslogtreecommitdiffstats
path: root/map/map.cpp
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2019-08-01 18:56:33 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2019-08-02 19:18:36 -0700
commit9cae4551c16d66a2139b50830749bfcc770ed17c (patch)
treed247fc3e4be9dac1b0492fa087536b0fd6ac4d05 /map/map.cpp
parent9d2600f4b4dcbdd3820910967eb00a9b00cd8a17 (diff)
libqtappfw: bluetooth-map: add support for list_messages + message verbs
Bug-AGL: SPEC-2561 Change-Id: I5c4df78a15cb009a742148a86432729deb434693 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'map/map.cpp')
-rw-r--r--map/map.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/map/map.cpp b/map/map.cpp
index eb3d5e0..38f682a 100644
--- a/map/map.cpp
+++ b/map/map.cpp
@@ -46,6 +46,26 @@ void Map::compose(QString recipient, QString message)
delete tmsg;
}
+void Map::message(QString handle)
+{
+ MapMessage *tmsg = new MapMessage();
+ QJsonObject parameter;
+ parameter.insert("handle", handle);
+ tmsg->createRequest("message", parameter);
+ m_mloop->sendMessage(tmsg);
+ delete tmsg;
+}
+
+void Map::listMessages(QString folder)
+{
+ MapMessage *tmsg = new MapMessage();
+ QJsonObject parameter;
+ parameter.insert("folder", folder);
+ tmsg->createRequest("list_messages", parameter);
+ m_mloop->sendMessage(tmsg);
+ delete tmsg;
+}
+
void Map::onConnected()
{
MapMessage *tmsg = new MapMessage();
@@ -54,6 +74,8 @@ void Map::onConnected()
tmsg->createRequest("subscribe", parameter);
m_mloop->sendMessage(tmsg);
delete tmsg;
+
+ listMessages();
}
void Map::onDisconnected()
@@ -74,6 +96,17 @@ void Map::onMessageReceived(MessageType type, Message *msg)
if (tmsg->isNotificationEvent()) {
emit notificationEvent(tmsg->eventData().toVariantMap());
}
+ } else if (msg->isReply() && type == ResponseRequestMessage) {
+ ResponseMessage *tmsg = qobject_cast<ResponseMessage*>(msg);
+
+ if (tmsg->requestVerb() == "list_messages") {
+ QString folder = tmsg->requestParameters().value("folder").toString();
+ QVariantMap listing = tmsg->replyData().value("messages").toObject().toVariantMap();
+ emit listMessagesResult(folder, listing);
+ } else if (tmsg->requestVerb() == "message") {
+ QString handle = tmsg->requestParameters().value("handle").toString();
+ emit messageResult(handle, tmsg->replyData().toVariantMap());
+ }
}
msg->deleteLater();