summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Planas <roger.planas@isode.com>2014-07-03 13:09:06 (GMT)
committerSwift Review <review@swift.im>2014-07-18 14:20:54 (GMT)
commite3ff5f241bf6e41829d36502e75f585d9620737e (patch)
treebff095606e0e18c63f2d2f7b6404de580addd793 /Sluift/component.cpp
parent00375bb2ac48dae174889ed9cea8dc8de55e1efd (diff)
downloadswift-contrib-e3ff5f241bf6e41829d36502e75f585d9620737e.zip
swift-contrib-e3ff5f241bf6e41829d36502e75f585d9620737e.tar.bz2
Sluift: Add 'show' parameter option to send_presence methods
Change-Id: I9fbd4514f6bc0d46738154abce495519e43ad46b
Diffstat (limited to 'Sluift/component.cpp')
-rw-r--r--Sluift/component.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/Sluift/component.cpp b/Sluift/component.cpp
index 0c400b3..6ae78ec 100644
--- a/Sluift/component.cpp
+++ b/Sluift/component.cpp
@@ -33,18 +33,19 @@
#include <Sluift/Lua/Check.h>
#include <Sluift/Lua/Value.h>
#include <Sluift/Lua/Exception.h>
#include <Sluift/Lua/LuaUtils.h>
#include <Sluift/globals.h>
#include <Sluift/ElementConvertors/StanzaConvertor.h>
#include <Sluift/ElementConvertors/IQConvertor.h>
#include <Sluift/ElementConvertors/PresenceConvertor.h>
#include <Sluift/ElementConvertors/MessageConvertor.h>
+#include <Sluift/ElementConvertors/StatusShowConvertor.h>
using namespace Swift;
namespace lambda = boost::lambda;
static inline SluiftComponent* getComponent(lua_State* L) {
return *Lua::checkUserData<SluiftComponent>(L, 1);
}
static inline int getGlobalTimeout(lua_State* L) {
@@ -253,18 +254,19 @@ SLUIFT_LUA_FUNCTION_WITH_HELP(
Component, send_presence,
"Send presence.",
"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"
"from the JID to send the message from\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"
"type the type of message to send (`available`, `error`, `probe`, `subscribe`, `subscribed`, `unavailable`, `unsubscribe`, `unsubscribed`)\n"
"payloads payloads to add to the presence\n"
) {
Sluift::globals.eventLoop.runOnce();
boost::shared_ptr<Presence> presence = boost::make_shared<Presence>();
int index = 2;
if (lua_isstring(L, index)) {
@@ -281,18 +283,21 @@ SLUIFT_LUA_FUNCTION_WITH_HELP(
if (boost::optional<std::string> value = Lua::getStringField(L, index, "status")) {
presence->setStatus(*value);
}
if (boost::optional<int> value = Lua::getIntField(L, index, "priority")) {
presence->setPriority(*value);
}
if (boost::optional<std::string> value = Lua::getStringField(L, index, "type")) {
presence->setType(PresenceConvertor::convertPresenceTypeFromString(*value));
}
+ if (boost::optional<std::string> value = Lua::getStringField(L, index, "show")) {
+ presence->setShow(StatusShowConvertor::convertStatusShowTypeFromString(*value));
+ }
std::vector< boost::shared_ptr<Payload> > payloads = getPayloadsFromTable(L, index);
presence->addPayloads(payloads.begin(), payloads.end());
}
getComponent(L)->getComponent()->sendPresence(presence);
lua_pushvalue(L, 1);
return 0;
}