diff options
author | Edwin Mons <edwin.mons@isode.com> | 2015-04-29 09:21:29 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2015-04-30 09:12:53 (GMT) |
commit | da1d43a2c7ae0468f1d38f40c33a0d11ce4c2daf (patch) | |
tree | c18f7b14131871ebcd4461e8dacaafc3dbf431d9 | |
parent | 1e5ca0c1fe156cd614cfbfce432c40eeadb893fd (diff) | |
download | swift-da1d43a2c7ae0468f1d38f40c33a0d11ce4c2daf.zip swift-da1d43a2c7ae0468f1d38f40c33a0d11ce4c2daf.tar.bz2 |
Honour global sluift timeout setting in add/remove contact
The add_contact and remove_contact calls used a fixed timeout of -1,
which could cause the operation to hang forever, even when a timeout was
set.
Test-Information:
add_contact and remove_contact properly honour global timeout on a
broken connection.
Change-Id: I6bd877a8123ddab87b1f653c0cfda7a6b101dae7
-rw-r--r-- | Sluift/client.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Sluift/client.cpp b/Sluift/client.cpp index 79d988a..f1fc2c7 100644 --- a/Sluift/client.cpp +++ b/Sluift/client.cpp @@ -598,12 +598,14 @@ SLUIFT_LUA_FUNCTION_WITH_HELP( "jid The JID of the contact to add\n" "name The name to use in the contact list\n" "groups An array of group names to add the contact to\n") { Sluift::globals.eventLoop.runOnce(); SluiftClient* client = getClient(L); RosterItemPayload item; + int timeout = getGlobalTimeout(L); + if (lua_type(L, 2) == LUA_TTABLE) { lua_getfield(L, 2, "jid"); const char* rawJID = lua_tostring(L, -1); if (rawJID) { item.setJID(std::string(rawJID)); } @@ -636,13 +638,13 @@ SLUIFT_LUA_FUNCTION_WITH_HELP( client->getRoster(); if (!client->getClient()->getRoster()->containsJID(item.getJID())) { RosterPayload::ref roster = boost::make_shared<RosterPayload>(); roster->addItem(item); Sluift::Response response = client->sendVoidRequest( - SetRosterRequest::create(roster, client->getClient()->getIQRouter()), -1); + SetRosterRequest::create(roster, client->getClient()->getIQRouter()), timeout); if (response.error) { return response.convertToLuaResult(L); } } client->getClient()->getSubscriptionManager()->requestSubscription(item.getJID()); lua_pushboolean(L, true); @@ -656,18 +658,19 @@ SLUIFT_LUA_FUNCTION_WITH_HELP( "jid the JID of the contact to remove\n", "" ) { Sluift::globals.eventLoop.runOnce(); SluiftClient* client = getClient(L); JID jid(Lua::checkString(L, 2)); + int timeout = getGlobalTimeout(L); RosterPayload::ref roster = boost::make_shared<RosterPayload>(); roster->addItem(RosterItemPayload(JID(Lua::checkString(L, 2)), "", RosterItemPayload::Remove)); return client->sendVoidRequest( - SetRosterRequest::create(roster, client->getClient()->getIQRouter()), -1).convertToLuaResult(L); + SetRosterRequest::create(roster, client->getClient()->getIQRouter()), timeout).convertToLuaResult(L); } SLUIFT_LUA_FUNCTION_WITH_HELP( Client, confirm_subscription, "Confirm subscription of a contact.", "self\n" |