summaryrefslogtreecommitdiffstats
path: root/Sluift
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-03-02 21:56:23 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-03-02 21:56:43 (GMT)
commit7ebb858551e626555bf52ec9f97f9f6de06f0081 (patch)
tree3af0b97bbcf3cf2cea55d7f254cb03d3419e6dbd /Sluift
parent296e8efad5684f6d8a90af8c3719d6581f9f9f3d (diff)
downloadswift-7ebb858551e626555bf52ec9f97f9f6de06f0081.zip
swift-7ebb858551e626555bf52ec9f97f9f6de06f0081.tar.bz2
Sluift: Added subscription confirm/cancel.
Diffstat (limited to 'Sluift')
-rw-r--r--Sluift/sluift.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/Sluift/sluift.cpp b/Sluift/sluift.cpp
index 98922cb..5d24276 100644
--- a/Sluift/sluift.cpp
+++ b/Sluift/sluift.cpp
@@ -253,6 +253,7 @@ static int sluift_client_get_roster(lua_State *L) {
}
Lua::Value groups(std::vector<Lua::Value>(item.getGroups().begin(), item.getGroups().end()));
Lua::Table itemTable = boost::assign::map_list_of
+ ("jid", boost::make_shared<Lua::Value>(item.getJID().toString()))
("name", boost::make_shared<Lua::Value>(item.getName()))
("subscription", boost::make_shared<Lua::Value>(subscription))
("groups", boost::make_shared<Lua::Value>(std::vector<Lua::Value>(item.getGroups().begin(), item.getGroups().end())));
@@ -504,6 +505,32 @@ static int sluift_client_remove_contact(lua_State* L) {
}
}
+static int sluift_client_confirm_subscription(lua_State* L) {
+ try {
+ eventLoop.runOnce();
+ SluiftClient* client = getClient(L);
+ JID jid(luaL_checkstring(L, 2));
+ client->getClient()->getSubscriptionManager()->confirmSubscription(jid);
+ return 0;
+ }
+ catch (const SluiftException& e) {
+ return luaL_error(L, e.getReason().c_str());
+ }
+}
+
+static int sluift_client_cancel_subscription(lua_State* L) {
+ try {
+ eventLoop.runOnce();
+ SluiftClient* client = getClient(L);
+ JID jid(luaL_checkstring(L, 2));
+ client->getClient()->getSubscriptionManager()->cancelSubscription(jid);
+ return 0;
+ }
+ catch (const SluiftException& e) {
+ return luaL_error(L, e.getReason().c_str());
+ }
+}
+
static int sluift_client_gc (lua_State *L) {
SluiftClient* client = getClient(L);
delete client;
@@ -529,6 +556,8 @@ static const luaL_reg sluift_client_functions[] = {
{"get_next_event", sluift_client_get_next_event},
{"add_contact", sluift_client_add_contact},
{"remove_contact", sluift_client_remove_contact},
+ {"confirm_subscription", sluift_client_confirm_subscription},
+ {"cancel_subscription", sluift_client_cancel_subscription},
{"__gc", sluift_client_gc},
{NULL, NULL}
};