summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Planas <roger.planas@isode.com>2017-01-30 12:34:13 (GMT)
committerRoger Planas <roger.planas@isode.com>2017-01-31 09:38:27 (GMT)
commitf4599f51c153dc59cd074bbd212b9c17347cd05b (patch)
treedaac9bd2215d9e4cf3967fc85785fecd05561f94 /Sluift/client.cpp
parentf3e46add7f512180833f91c3442ee9fb059b5f0c (diff)
downloadswift-f4599f51c153dc59cd074bbd212b9c17347cd05b.zip
swift-f4599f51c153dc59cd074bbd212b9c17347cd05b.tar.bz2
Sluift: Add client methods for adding and removing JIDs from blocklist
A previous commit added a get_block_list() client method to retrieve the list of blocked items. This patch extends that and adds capabilities to add and remove items to such list. Test-information: Tested with client and was able to successfully add items to list, delete and delete all Also tried to delete a non existing item and it rightly complained. Change-Id: Iabbfdbd9e74ddc9740db5c9871b8355210aa0727
Diffstat (limited to 'Sluift/client.cpp')
-rw-r--r--Sluift/client.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/Sluift/client.cpp b/Sluift/client.cpp
index 53e253f..d2b50fa 100644
--- a/Sluift/client.cpp
+++ b/Sluift/client.cpp
@@ -224,6 +224,52 @@ SLUIFT_LUA_FUNCTION_WITH_HELP(
}
SLUIFT_LUA_FUNCTION_WITH_HELP(
+ Client, add_block,
+ "Adds a user or domain to the blocking list.",
+ "self\n",
+ "jid the JID of the user or domain to add to the blocking list\n"
+
+) {
+ SluiftClient* client = getClient(L);
+ JID jid(Lua::checkString(L, 2));
+ int timeout = getGlobalTimeout(L);
+
+ std::shared_ptr<BlockPayload> payload = std::make_shared<BlockPayload>(std::vector<JID>(1, jid));
+ return client->sendRequest(
+ std::make_shared< GenericRequest<BlockPayload> >(IQ::Set, JID(), payload, client->getClient()->getIQRouter()), timeout).convertToLuaResult(L);
+}
+
+SLUIFT_LUA_FUNCTION_WITH_HELP(
+ Client, remove_block,
+ "Removes a user or domain from the blocking list.",
+ "self\n",
+ "jid the JID of the user or domain to remove from the blocking list\n"
+
+) {
+ SluiftClient* client = getClient(L);
+ JID jid(Lua::checkString(L, 2));
+ int timeout = getGlobalTimeout(L);
+
+ std::shared_ptr<UnblockPayload> payload = std::make_shared<UnblockPayload>(std::vector<JID>(1, jid));
+ return client->sendRequest(
+ std::make_shared< GenericRequest<UnblockPayload> >(IQ::Set, JID(), payload, client->getClient()->getIQRouter()), timeout).convertToLuaResult(L);
+}
+
+SLUIFT_LUA_FUNCTION_WITH_HELP(
+ Client, remove_all_block,
+ "Removes all users and domains from the blocking list.",
+ "self\n",
+ ""
+) {
+ SluiftClient* client = getClient(L);
+ int timeout = getGlobalTimeout(L);
+
+ std::shared_ptr<UnblockPayload> payload = std::make_shared<UnblockPayload>(std::vector<JID>());
+ return client->sendRequest(
+ std::make_shared< GenericRequest<UnblockPayload> >(IQ::Set, JID(), payload, client->getClient()->getIQRouter()), timeout).convertToLuaResult(L);
+}
+
+SLUIFT_LUA_FUNCTION_WITH_HELP(
Client, send_message,
"Send a message.",
"self\n"