summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdwin Mons <edwin.mons@isode.com>2013-11-26 08:31:09 (GMT)
committerSwift Review <review@swift.im>2013-11-27 18:43:48 (GMT)
commitacd19fa05d8a7fa2ebac9d6534ee203368f1a3e9 (patch)
tree0fb374efcd854206c9c494eb4dcbe3713f1f074e
parent78df31e45cf9f6c90a82c2a9265b2e3bb509570d (diff)
downloadswift-acd19fa05d8a7fa2ebac9d6534ee203368f1a3e9.zip
swift-acd19fa05d8a7fa2ebac9d6534ee203368f1a3e9.tar.bz2
Add presence_type to presence event
Change-Id: I3de5cd5ce1d84d6ce6a4b02af939ed5e0eb721f0
-rw-r--r--Sluift/client.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/Sluift/client.cpp b/Sluift/client.cpp
index c1be73e..2ca62d6 100644
--- a/Sluift/client.cpp
+++ b/Sluift/client.cpp
@@ -325,7 +325,7 @@ SLUIFT_LUA_FUNCTION(Client, set_options) {
}
lua_getfield(L, 2, "port");
if (!lua_isnil(L, -1)) {
- client->getOptions().manualPort = lua_tointeger(L, -1);
+ client->getOptions().manualPort = boost::numeric_cast<int>(lua_tointeger(L, -1));
}
lua_getfield(L, 2, "ack");
if (!lua_isnil(L, -1)) {
@@ -352,6 +352,23 @@ SLUIFT_LUA_FUNCTION(Client, set_options) {
return 0;
}
+static std::string convertPresenceTypeToString(Presence::Type type) {
+ std::string result;
+
+ switch (type) {
+ case Presence::Available: result = "available"; break;
+ case Presence::Error: result = "error"; break;
+ case Presence::Probe: result = "probe"; break;
+ case Presence::Subscribe: result = "subscribe"; break;
+ case Presence::Subscribed: result = "subscribed"; break;
+ case Presence::Unavailable: result = "unavailable"; break;
+ case Presence::Unsubscribe: result = "unsubscribe"; break;
+ case Presence::Unsubscribed: result = "unsubscribed"; break;
+ }
+
+ return result;
+}
+
static void pushEvent(lua_State* L, const SluiftClient::Event& event) {
switch (event.type) {
case SluiftClient::Event::MessageType: {
@@ -369,7 +386,8 @@ static void pushEvent(lua_State* L, const SluiftClient::Event& event) {
Lua::Table result = boost::assign::map_list_of
("type", boost::make_shared<Lua::Value>(std::string("presence")))
("from", boost::make_shared<Lua::Value>(presence->getFrom().toString()))
- ("status", boost::make_shared<Lua::Value>(presence->getStatus()));
+ ("status", boost::make_shared<Lua::Value>(presence->getStatus()))
+ ("presence_type", boost::make_shared<Lua::Value>(convertPresenceTypeToString(presence->getType())));
Lua::pushValue(L, result);
if (!presence->getPayloads().empty()) {
const std::vector<boost::shared_ptr<Payload> > payloads = presence->getPayloads();