From 8068f4a7a49f723809778e9194166046a3e5cb38 Mon Sep 17 00:00:00 2001 From: Roger Planas <roger.planas@isode.com> Date: Fri, 20 Dec 2013 11:36:04 +0000 Subject: Sluift: Add message_type to message event Change-Id: I156b4cbec401918377af5fd8f21c9845f665b4cb diff --git a/Sluift/client.cpp b/Sluift/client.cpp index cd675fa..97f9106 100644 --- a/Sluift/client.cpp +++ b/Sluift/client.cpp @@ -364,6 +364,20 @@ static std::string convertPresenceTypeToString(Presence::Type type) { return result; } +static std::string convertMessageTypeToString(Message::Type type) { + std::string result; + + switch (type) { + case Message::Normal: result = "normal"; break; + case Message::Chat: result = "chat"; break; + case Message::Error: result = "error"; break; + case Message::Groupchat: result = "groupchat"; break; + case Message::Headline: result = "headline"; break; + } + + return result; +} + static void pushEvent(lua_State* L, const SluiftClient::Event& event) { switch (event.type) { case SluiftClient::Event::MessageType: { @@ -371,7 +385,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("message"))) ("from", boost::make_shared<Lua::Value>(message->getFrom().toString())) - ("body", boost::make_shared<Lua::Value>(message->getBody())); + ("body", boost::make_shared<Lua::Value>(message->getBody())) + ("message_type", boost::make_shared<Lua::Value>(convertMessageTypeToString(message->getType()))); Lua::pushValue(L, result); Lua::registerTableToString(L, -1); break; -- cgit v0.10.2-6-g49f6