summaryrefslogtreecommitdiffstats
path: root/Sluift
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-03-04 19:36:44 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-03-04 19:36:44 (GMT)
commitf310de4bc115a724b0e9de520707607095f6b16e (patch)
tree322f72aa173b0d07337419056e14d605827ff2cd /Sluift
parent3b1d44842367b730688ee3a2069a25912cd2721e (diff)
downloadswift-f310de4bc115a724b0e9de520707607095f6b16e.zip
swift-f310de4bc115a724b0e9de520707607095f6b16e.tar.bz2
Sluift: Spin the event loop on some commands
Diffstat (limited to 'Sluift')
-rw-r--r--Sluift/sluift.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/Sluift/sluift.cpp b/Sluift/sluift.cpp
index 324c94e..5750dd2 100644
--- a/Sluift/sluift.cpp
+++ b/Sluift/sluift.cpp
@@ -224,22 +224,31 @@ static int sluift_client_disconnect(lua_State *L) {
}
static int sluift_client_set_version(lua_State *L) {
- SluiftClient* client = getClient(L);
- luaL_checktype(L, 2, LUA_TTABLE);
- lua_getfield(L, 2, "name");
- const char* rawName = lua_tostring(L, -1);
- lua_getfield(L, 2, "version");
- const char* rawVersion = lua_tostring(L, -1);
- lua_getfield(L, 2, "os");
- const char* rawOS = lua_tostring(L, -1);
- client->setSoftwareVersion(rawName ? rawName : "", rawVersion ? rawVersion : "", rawOS ? rawOS : "");
- lua_pop(L, 3);
- lua_pushvalue(L, 1);
- return 1;
+ try {
+ eventLoop.runUntilEvents();
+
+ SluiftClient* client = getClient(L);
+ luaL_checktype(L, 2, LUA_TTABLE);
+ lua_getfield(L, 2, "name");
+ const char* rawName = lua_tostring(L, -1);
+ lua_getfield(L, 2, "version");
+ const char* rawVersion = lua_tostring(L, -1);
+ lua_getfield(L, 2, "os");
+ const char* rawOS = lua_tostring(L, -1);
+ client->setSoftwareVersion(rawName ? rawName : "", rawVersion ? rawVersion : "", rawOS ? rawOS : "");
+ lua_pop(L, 3);
+ lua_pushvalue(L, 1);
+ return 1;
+ }
+ catch (const SluiftException& e) {
+ return luaL_error(L, e.getReason().c_str());
+ }
}
static int sluift_client_get_roster(lua_State *L) {
try {
+ eventLoop.runUntilEvents();
+
SluiftClient* client = getClient(L);
Lua::Table rosterTable;
foreach(const XMPPRosterItem& item, client->getRoster()) {