diff options
-rw-r--r-- | Sluift/SluiftClient.cpp | 15 | ||||
-rw-r--r-- | Sluift/SluiftClient.h | 10 | ||||
-rw-r--r-- | Sluift/client.cpp | 27 |
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 @@ -40,2 +40,5 @@ SluiftClient::SluiftClient( client->getRoster()->onInitialRosterPopulated.connect(boost::bind(&SluiftClient::handleInitialRosterPopulated, this)); + client->getRoster()->onJIDAdded.connect(boost::bind(&SluiftClient::handleIncomingRosterAdd, this, _1)); + client->getRoster()->onJIDRemoved.connect(boost::bind(&SluiftClient::handleIncomingRosterRemove, this, _1)); + client->getRoster()->onJIDUpdated.connect(boost::bind(&SluiftClient::handleIncomingRosterUpdate, this, _1)); client->getClientBlockListManager()->getBlockList()->onItemAdded.connect(boost::bind(&SluiftClient::handleIncomingBlockEvent, this, _1)); @@ -194,2 +197,14 @@ void SluiftClient::handleInitialRosterPopulated() { +void SluiftClient::handleIncomingRosterAdd(const JID& item) { + pendingEvents.push_back(Event(item, Event::RosterAddType)); +} + +void SluiftClient::handleIncomingRosterRemove(const JID& item) { + pendingEvents.push_back(Event(item, Event::RosterRemoveType)); +} + +void SluiftClient::handleIncomingRosterUpdate(const JID& item) { + pendingEvents.push_back(Event(item, Event::RosterUpdateType)); +} + void SluiftClient::handleRequestResponse(std::shared_ptr<Payload> response, std::shared_ptr<ErrorPayload> error) { diff --git a/Sluift/SluiftClient.h b/Sluift/SluiftClient.h index 39ff0a8..ac4c582 100644 --- a/Sluift/SluiftClient.h +++ b/Sluift/SluiftClient.h @@ -47,3 +47,6 @@ namespace Swift { BlockEventType, - UnblockEventType + UnblockEventType, + RosterAddType, + RosterRemoveType, + RosterUpdateType }; @@ -63,3 +66,3 @@ namespace Swift { - // Blocklist + // Blocklist & Roster Push JID item; @@ -124,2 +127,5 @@ namespace Swift { void handleInitialRosterPopulated(); + void handleIncomingRosterAdd(const JID& item); + void handleIncomingRosterRemove(const JID& item); + void handleIncomingRosterUpdate(const JID& item); void handleRequestResponse(std::shared_ptr<Payload> response, std::shared_ptr<ErrorPayload> error); diff --git a/Sluift/client.cpp b/Sluift/client.cpp index ec208bc..24ece85 100644 --- a/Sluift/client.cpp +++ b/Sluift/client.cpp @@ -601,2 +601,29 @@ static void pushEvent(lua_State* L, const SluiftClient::Event& event) { } + case SluiftClient::Event::RosterAddType: { + Lua::Table result = boost::assign::map_list_of + ("type", std::make_shared<Lua::Value>(std::string("rosterpush"))) + ("jid", std::make_shared<Lua::Value>(event.item.toString())) + ("action", std::make_shared<Lua::Value>(std::string("added"))); + Lua::pushValue(L, result); + Lua::registerTableToString(L, -1); + break; + } + case SluiftClient::Event::RosterRemoveType: { + Lua::Table result = boost::assign::map_list_of + ("type", std::make_shared<Lua::Value>(std::string("rosterpush"))) + ("jid", std::make_shared<Lua::Value>(event.item.toString())) + ("action", std::make_shared<Lua::Value>(std::string("removed"))); + Lua::pushValue(L, result); + Lua::registerTableToString(L, -1); + break; + } + case SluiftClient::Event::RosterUpdateType: { + Lua::Table result = boost::assign::map_list_of + ("type", std::make_shared<Lua::Value>(std::string("rosterpush"))) + ("jid", std::make_shared<Lua::Value>(event.item.toString())) + ("action", std::make_shared<Lua::Value>(std::string("updated"))); + Lua::pushValue(L, result); + Lua::registerTableToString(L, -1); + break; + } } |