summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Sluift/client.cpp')
-rw-r--r--Sluift/client.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Sluift/client.cpp b/Sluift/client.cpp
index 7d0924f..6376e9d 100644
--- a/Sluift/client.cpp
+++ b/Sluift/client.cpp
@@ -1,45 +1,44 @@
/*
* Copyright (c) 2013-2016 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/Base/foreach.h>
#include <Swiften/Disco/ClientDiscoManager.h>
#include <Swiften/Elements/DiscoInfo.h>
-#include <Swiften/Elements/MAMQuery.h>
#include <Swiften/Elements/Message.h>
#include <Swiften/Elements/Presence.h>
#include <Swiften/Elements/RawXMLPayload.h>
#include <Swiften/Elements/RosterItemPayload.h>
#include <Swiften/Elements/RosterPayload.h>
#include <Swiften/Elements/SoftwareVersion.h>
#include <Swiften/JID/JID.h>
#include <Swiften/Presence/PresenceSender.h>
#include <Swiften/Presence/SubscriptionManager.h>
#include <Swiften/Queries/GenericRequest.h>
#include <Swiften/Queries/IQRouter.h>
#include <Swiften/Queries/Requests/GetSoftwareVersionRequest.h>
#include <Swiften/Roster/SetRosterRequest.h>
#include <Swiften/Roster/XMPPRoster.h>
#include <Swiften/Roster/XMPPRosterItem.h>
#include <Swiften/TLS/PKCS12Certificate.h>
#include <Sluift/ElementConvertors/IQConvertor.h>
#include <Sluift/ElementConvertors/MessageConvertor.h>
#include <Sluift/ElementConvertors/PresenceConvertor.h>
#include <Sluift/ElementConvertors/StanzaConvertor.h>
#include <Sluift/ElementConvertors/StatusShowConvertor.h>
#include <Sluift/Lua/Check.h>
#include <Sluift/Lua/Exception.h>
#include <Sluift/Lua/FunctionRegistration.h>
#include <Sluift/Lua/LuaUtils.h>
#include <Sluift/Lua/Value.h>
#include <Sluift/SluiftClient.h>
#include <Sluift/globals.h>
@@ -460,72 +459,74 @@ SLUIFT_LUA_FUNCTION_WITH_HELP(
SLUIFT_LUA_FUNCTION_WITH_HELP(
Client, get_options,
"Returns a table with all the connection options of this client.",
"self\n",
""
) {
Sluift::globals.eventLoop.runOnce();
SluiftClient* client = getClient(L);
Lua::Table optionsTable = boost::assign::map_list_of
("host", std::make_shared<Lua::Value>(client->getOptions().manualHostname))
("port", std::make_shared<Lua::Value>(client->getOptions().manualPort))
("ack", std::make_shared<Lua::Value>(client->getOptions().useAcks))
("compress", std::make_shared<Lua::Value>(client->getOptions().useStreamCompression))
("tls", std::make_shared<Lua::Value>(client->getOptions().useTLS == ClientOptions::NeverUseTLS ? false : true))
("bosh_url", std::make_shared<Lua::Value>(client->getOptions().boshURL.toString()))
("allow_plain_without_tls", std::make_shared<Lua::Value>(client->getOptions().allowPLAINWithoutTLS));
pushValue(L, optionsTable);
Lua::registerTableToString(L, -1);
return 1;
}
static void pushEvent(lua_State* L, const SluiftClient::Event& event) {
switch (event.type) {
case SluiftClient::Event::MessageType: {
Message::ref message = std::dynamic_pointer_cast<Message>(event.stanza);
Lua::Table result = boost::assign::map_list_of
("type", std::make_shared<Lua::Value>(std::string("message")))
("from", std::make_shared<Lua::Value>(message->getFrom().toString()))
+ ("to", std::make_shared<Lua::Value>(message->getTo().toString()))
("body", std::make_shared<Lua::Value>(message->getBody().get_value_or("")))
("message_type", std::make_shared<Lua::Value>(MessageConvertor::convertMessageTypeToString(message->getType())));
Lua::pushValue(L, result);
addPayloadsToTable(L, message->getPayloads());
Lua::registerTableToString(L, -1);
break;
}
case SluiftClient::Event::PresenceType: {
Presence::ref presence = std::dynamic_pointer_cast<Presence>(event.stanza);
Lua::Table result = boost::assign::map_list_of
("type", std::make_shared<Lua::Value>(std::string("presence")))
("from", std::make_shared<Lua::Value>(presence->getFrom().toString()))
+ ("to", std::make_shared<Lua::Value>(presence->getTo().toString()))
("status", std::make_shared<Lua::Value>(presence->getStatus()))
("presence_type", std::make_shared<Lua::Value>(PresenceConvertor::convertPresenceTypeToString(presence->getType())));
Lua::pushValue(L, result);
addPayloadsToTable(L, presence->getPayloads());
Lua::registerTableToString(L, -1);
break;
}
case SluiftClient::Event::PubSubEventType: {
Sluift::globals.elementConvertor.convertToLua(L, event.pubsubEvent);
lua_pushstring(L, "pubsub");
lua_setfield(L, -2, "type");
lua_pushstring(L, event.from.toString().c_str());
lua_setfield(L, -2, "from");
lua_rawgeti(L, LUA_REGISTRYINDEX, Sluift::globals.coreLibIndex);
lua_getfield(L, -1, "process_pubsub_event");
lua_pushvalue(L, -3);
lua_call(L, 1, 0);
lua_pop(L, 1);
}
}
}
struct CallUnaryLuaPredicateOnEvent {
CallUnaryLuaPredicateOnEvent(lua_State* L, int index) : L(L), index(index) {
}
bool operator()(const SluiftClient::Event& event) {
lua_pushvalue(L, index);
pushEvent(L, event);