summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Sluift/client.cpp')
-rw-r--r--Sluift/client.cpp51
1 files changed, 45 insertions, 6 deletions
diff --git a/Sluift/client.cpp b/Sluift/client.cpp
index ae2f610..814ad45 100644
--- a/Sluift/client.cpp
+++ b/Sluift/client.cpp
@@ -1,12 +1,10 @@
/*
- * Copyright (c) 2013-2017 Isode Limited.
+ * Copyright (c) 2013-2018 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <boost/assign/list_of.hpp>
-#include <boost/lambda/bind.hpp>
-#include <boost/lambda/lambda.hpp>
#include <Swiften/Base/IDGenerator.h>
#include <Swiften/Disco/ClientDiscoManager.h>
@@ -42,7 +40,6 @@
#include <Sluift/globals.h>
using namespace Swift;
-namespace lambda = boost::lambda;
static inline SluiftClient* getClient(lua_State* L) {
return *Lua::checkUserData<SluiftClient>(L, 1);
@@ -302,6 +299,7 @@ SLUIFT_LUA_FUNCTION_WITH_HELP(
"body the body of the message. Can alternatively be specified using the `body` option\n",
"to the JID to send the message to\n"
+ "id the id to set on the stanza\n"
"body the body of the message\n"
"subject the subject of the MUC room to set\n"
"type the type of message to send (`normal`, `chat`, `error`, `groupchat`, `headline`)\n"
@@ -310,6 +308,7 @@ SLUIFT_LUA_FUNCTION_WITH_HELP(
Sluift::globals.eventLoop.runOnce();
JID to;
boost::optional<std::string> body;
+ boost::optional<std::string> id;
boost::optional<std::string> subject;
std::vector<std::shared_ptr<Payload> > payloads;
int index = 2;
@@ -327,6 +326,10 @@ SLUIFT_LUA_FUNCTION_WITH_HELP(
to = *value;
}
+ if (boost::optional<std::string> value = Lua::getStringField(L, index, "id")) {
+ id = value;
+ }
+
if (boost::optional<std::string> value = Lua::getStringField(L, index, "body")) {
body = value;
}
@@ -353,6 +356,9 @@ SLUIFT_LUA_FUNCTION_WITH_HELP(
if (body && !body->empty()) {
message->setBody(*body);
}
+ if (id) {
+ message->setID(*id);
+ }
if (subject) {
message->setSubject(*subject);
}
@@ -372,7 +378,8 @@ SLUIFT_LUA_FUNCTION_WITH_HELP(
"self\n"
"body the text of the presence. Can alternatively be specified using the `status` option\n",
- "to the JID to send the message to\n"
+ "to the JID to send the presence to\n"
+ "id the id to set on the stanza\n"
"status the text of the presence\n"
"show the availability of the presence (`online`, `ffc`, `away`, `xa`, `dnd`)\n"
"priority the priority of the presence\n"
@@ -391,6 +398,9 @@ SLUIFT_LUA_FUNCTION_WITH_HELP(
if (boost::optional<std::string> value = Lua::getStringField(L, index, "to")) {
presence->setTo(*value);
}
+ if (boost::optional<std::string> id = Lua::getStringField(L, index, "id")) {
+ presence->setID(*id);
+ }
if (boost::optional<std::string> value = Lua::getStringField(L, index, "status")) {
presence->setStatus(*value);
}
@@ -602,6 +612,33 @@ static void pushEvent(lua_State* L, const SluiftClient::Event& event) {
Lua::registerTableToString(L, -1);
break;
}
+ 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;
+ }
}
}
@@ -659,7 +696,9 @@ SLUIFT_LUA_FUNCTION(Client, get_next_event) {
}
else if (type) {
event = client->getNextEvent(
- timeout, lambda::bind(&SluiftClient::Event::type, lambda::_1) == *type);
+ timeout, [&](const SluiftClient::Event& event) {
+ return event.type == *type;
+ });
}
else {
event = client->getNextEvent(timeout);