summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Planas <roger.planas@isode.com>2018-11-16 11:04:27 (GMT)
committerRoger Planas <roger.planas@isode.com>2018-11-27 14:31:21 (GMT)
commit24ddcdb0a82cbd33deb5b72ad9f86f1c46fc9d13 (patch)
tree50dd6f7d520100e576b8824e137bf3246affd990
parent560b5642eeeee9135e8995c04f99613387a7bfa8 (diff)
downloadswift-24ddcdb0a82cbd33deb5b72ad9f86f1c46fc9d13.zip
swift-24ddcdb0a82cbd33deb5b72ad9f86f1c46fc9d13.tar.bz2
Sluift: Added handling of roster push event
Swiften handles roster push event notifications, but those were not passed to Sluift, so a Sluift client, when querying events, would not be aware if an XMPP server roster pushes. This patch adds extra events types to Sluift so that method for_each_event reports roster pushes notifications. Test-information: Used sluift client to retrieve all items after adding, removing and updating roster items, and now Sluift clients can see these events. Change-Id: Ide5597bf2b39e3cc20014c66ba9153c551eec670
-rw-r--r--Sluift/SluiftClient.cpp15
-rw-r--r--Sluift/SluiftClient.h10
-rw-r--r--Sluift/client.cpp27
3 files changed, 50 insertions, 2 deletions
diff --git a/Sluift/SluiftClient.cpp b/Sluift/SluiftClient.cpp
index 5243ed0..99892a9 100644
--- a/Sluift/SluiftClient.cpp
+++ b/Sluift/SluiftClient.cpp
@@ -38,6 +38,9 @@ SluiftClient::SluiftClient(
38 client->onPresenceReceived.connect(boost::bind(&SluiftClient::handleIncomingPresence, this, _1)); 38 client->onPresenceReceived.connect(boost::bind(&SluiftClient::handleIncomingPresence, this, _1));
39 client->getPubSubManager()->onEvent.connect(boost::bind(&SluiftClient::handleIncomingPubSubEvent, this, _1, _2)); 39 client->getPubSubManager()->onEvent.connect(boost::bind(&SluiftClient::handleIncomingPubSubEvent, this, _1, _2));
40 client->getRoster()->onInitialRosterPopulated.connect(boost::bind(&SluiftClient::handleInitialRosterPopulated, this)); 40 client->getRoster()->onInitialRosterPopulated.connect(boost::bind(&SluiftClient::handleInitialRosterPopulated, this));
41 client->getRoster()->onJIDAdded.connect(boost::bind(&SluiftClient::handleIncomingRosterAdd, this, _1));
42 client->getRoster()->onJIDRemoved.connect(boost::bind(&SluiftClient::handleIncomingRosterRemove, this, _1));
43 client->getRoster()->onJIDUpdated.connect(boost::bind(&SluiftClient::handleIncomingRosterUpdate, this, _1));
41 client->getClientBlockListManager()->getBlockList()->onItemAdded.connect(boost::bind(&SluiftClient::handleIncomingBlockEvent, this, _1)); 44 client->getClientBlockListManager()->getBlockList()->onItemAdded.connect(boost::bind(&SluiftClient::handleIncomingBlockEvent, this, _1));
42 client->getClientBlockListManager()->getBlockList()->onItemRemoved.connect(boost::bind(&SluiftClient::handleIncomingUnblockEvent, this, _1)); 45 client->getClientBlockListManager()->getBlockList()->onItemRemoved.connect(boost::bind(&SluiftClient::handleIncomingUnblockEvent, this, _1));
43} 46}
@@ -192,6 +195,18 @@ void SluiftClient::handleInitialRosterPopulated() {
192 rosterReceived = true; 195 rosterReceived = true;
193} 196}
194 197
198void SluiftClient::handleIncomingRosterAdd(const JID& item) {
199 pendingEvents.push_back(Event(item, Event::RosterAddType));
200}
201
202void SluiftClient::handleIncomingRosterRemove(const JID& item) {
203 pendingEvents.push_back(Event(item, Event::RosterRemoveType));
204}
205
206void SluiftClient::handleIncomingRosterUpdate(const JID& item) {
207 pendingEvents.push_back(Event(item, Event::RosterUpdateType));
208}
209
195void SluiftClient::handleRequestResponse(std::shared_ptr<Payload> response, std::shared_ptr<ErrorPayload> error) { 210void SluiftClient::handleRequestResponse(std::shared_ptr<Payload> response, std::shared_ptr<ErrorPayload> error) {
196 requestResponse = response; 211 requestResponse = response;
197 requestError = error; 212 requestError = error;
diff --git a/Sluift/SluiftClient.h b/Sluift/SluiftClient.h
index 39ff0a8..ac4c582 100644
--- a/Sluift/SluiftClient.h
+++ b/Sluift/SluiftClient.h
@@ -45,7 +45,10 @@ namespace Swift {
45 PresenceType, 45 PresenceType,
46 PubSubEventType, 46 PubSubEventType,
47 BlockEventType, 47 BlockEventType,
48 UnblockEventType 48 UnblockEventType,
49 RosterAddType,
50 RosterRemoveType,
51 RosterUpdateType
49 }; 52 };
50 53
51 Event(std::shared_ptr<Message> stanza) : type(MessageType), stanza(stanza) {} 54 Event(std::shared_ptr<Message> stanza) : type(MessageType), stanza(stanza) {}
@@ -61,7 +64,7 @@ namespace Swift {
61 JID from; 64 JID from;
62 std::shared_ptr<PubSubEventPayload> pubsubEvent; 65 std::shared_ptr<PubSubEventPayload> pubsubEvent;
63 66
64 // Blocklist 67 // Blocklist & Roster Push
65 JID item; 68 JID item;
66 }; 69 };
67 70
@@ -122,6 +125,9 @@ namespace Swift {
122 void handleIncomingBlockEvent(const JID& item); 125 void handleIncomingBlockEvent(const JID& item);
123 void handleIncomingUnblockEvent(const JID& item); 126 void handleIncomingUnblockEvent(const JID& item);
124 void handleInitialRosterPopulated(); 127 void handleInitialRosterPopulated();
128 void handleIncomingRosterAdd(const JID& item);
129 void handleIncomingRosterRemove(const JID& item);
130 void handleIncomingRosterUpdate(const JID& item);
125 void handleRequestResponse(std::shared_ptr<Payload> response, std::shared_ptr<ErrorPayload> error); 131 void handleRequestResponse(std::shared_ptr<Payload> response, std::shared_ptr<ErrorPayload> error);
126 void handleDisconnected(const boost::optional<ClientError>& error); 132 void handleDisconnected(const boost::optional<ClientError>& error);
127 133
diff --git a/Sluift/client.cpp b/Sluift/client.cpp
index ec208bc..24ece85 100644
--- a/Sluift/client.cpp
+++ b/Sluift/client.cpp
@@ -599,6 +599,33 @@ static void pushEvent(lua_State* L, const SluiftClient::Event& event) {
599 Lua::registerTableToString(L, -1); 599 Lua::registerTableToString(L, -1);
600 break; 600 break;
601 } 601 }
602 case SluiftClient::Event::RosterAddType: {
603 Lua::Table result = boost::assign::map_list_of
604 ("type", std::make_shared<Lua::Value>(std::string("rosterpush")))
605 ("jid", std::make_shared<Lua::Value>(event.item.toString()))
606 ("action", std::make_shared<Lua::Value>(std::string("added")));
607 Lua::pushValue(L, result);
608 Lua::registerTableToString(L, -1);
609 break;
610 }
611 case SluiftClient::Event::RosterRemoveType: {
612 Lua::Table result = boost::assign::map_list_of
613 ("type", std::make_shared<Lua::Value>(std::string("rosterpush")))
614 ("jid", std::make_shared<Lua::Value>(event.item.toString()))
615 ("action", std::make_shared<Lua::Value>(std::string("removed")));
616 Lua::pushValue(L, result);
617 Lua::registerTableToString(L, -1);
618 break;
619 }
620 case SluiftClient::Event::RosterUpdateType: {
621 Lua::Table result = boost::assign::map_list_of
622 ("type", std::make_shared<Lua::Value>(std::string("rosterpush")))
623 ("jid", std::make_shared<Lua::Value>(event.item.toString()))
624 ("action", std::make_shared<Lua::Value>(std::string("updated")));
625 Lua::pushValue(L, result);
626 Lua::registerTableToString(L, -1);
627 break;
628 }
602 } 629 }
603} 630}
604 631