summaryrefslogtreecommitdiffstats
path: root/Sluift
diff options
context:
space:
mode:
Diffstat (limited to 'Sluift')
-rw-r--r--Sluift/Lua/Value.cpp4
-rw-r--r--Sluift/SConscript16
-rw-r--r--Sluift/linit.c6
-rw-r--r--Sluift/sluift.cpp29
-rw-r--r--Sluift/sluift.h2
5 files changed, 38 insertions, 19 deletions
diff --git a/Sluift/Lua/Value.cpp b/Sluift/Lua/Value.cpp
index c03e633..3164ec6 100644
--- a/Sluift/Lua/Value.cpp
+++ b/Sluift/Lua/Value.cpp
@@ -6,9 +6,7 @@
#include "Value.h"
-extern "C" {
- #include <lualib.h>
-}
+#include <lualib.h>
#include <boost/variant/apply_visitor.hpp>
#include <Swiften/Base/foreach.h>
diff --git a/Sluift/SConscript b/Sluift/SConscript
index 576eae5..f6388a0 100644
--- a/Sluift/SConscript
+++ b/Sluift/SConscript
@@ -22,6 +22,10 @@ if env["SCONS_STAGE"] == "build" :
myenv.Append(CPPDEFINES = ["SLUIFT_BUILD_DLL"])
elif myenv["PLATFORM"] == "darwin" :
myenv["SHLIBSUFFIX"] = ".so"
+ if env["PLATFORM"] == "win32" :
+ myenv.Append(CFLAGS = ["/TP"])
+ else :
+ myenv.Append(CFLAGS = ["-x", "c++"])
myenv["SLUIFT_VERSION"] = Version.getBuildVersion(env.Dir("#").abspath, "sluift")
def patchLua(env, target, source) :
@@ -51,8 +55,10 @@ if env["SCONS_STAGE"] == "build" :
myenv.SharedLibrary("sluift", ["dll.c"])
if env["PLATFORM"] == "win32" :
- myenv.WindowsBundle("Sluift",
- resources = {"": [
- os.path.join(env["OPENSSL_DIR"], "bin", "ssleay32.dll"),
- os.path.join(env["OPENSSL_DIR"], "bin", "libeay32.dll")
- ]})
+ ssl_libs = []
+ if myenv.get("OPENSSL_DIR", False) :
+ ssl_libs = [
+ os.path.join(env["OPENSSL_DIR"], "bin", "ssleay32.dll"),
+ os.path.join(env["OPENSSL_DIR"], "bin", "libeay32.dll")
+ ]
+ myenv.WindowsBundle("Sluift", resources = {"": ssl_libs})
diff --git a/Sluift/linit.c b/Sluift/linit.c
index bb5d985..73f0522 100644
--- a/Sluift/linit.c
+++ b/Sluift/linit.c
@@ -1,6 +1,6 @@
-#include "lua.h"
-#include "lualib.h"
-#include "lauxlib.h"
+#include <lua.h>
+#include <lualib.h>
+#include <lauxlib.h>
#include "sluift.h"
// A built-in table print function
diff --git a/Sluift/sluift.cpp b/Sluift/sluift.cpp
index 49cfec4..4f762fa 100644
--- a/Sluift/sluift.cpp
+++ b/Sluift/sluift.cpp
@@ -4,16 +4,15 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-extern "C" {
- #include "sluift.h"
- #include <lauxlib.h>
-}
+#include "sluift.h"
+#include <lauxlib.h>
#include <iostream>
#include <string>
#include <deque>
#include <boost/assign/list_of.hpp>
+#include <Swiften/Base/foreach.h>
#include <Swiften/Swiften.h>
#include "Watchdog.h"
@@ -63,11 +62,20 @@ class SluiftClient {
return client;
}
+ ClientOptions& getOptions() {
+ return options;
+ }
+
void connect() {
rosterReceived = false;
client->connect();
}
+ void connect(const std::string& host) {
+ rosterReceived = false;
+ client->connect(host);
+ }
+
void waitConnected() {
Watchdog watchdog(globalTimeout, networkFactories.getTimerFactory());
while (!watchdog.getTimedOut() && client->isActive() && !client->isAvailable()) {
@@ -179,6 +187,7 @@ class SluiftClient {
private:
Client* client;
+ ClientOptions options;
ClientXMLTracer* tracer;
bool rosterReceived;
std::deque<Stanza::ref> pendingEvents;
@@ -196,7 +205,13 @@ static inline SluiftClient* getClient(lua_State* L) {
static int sluift_client_connect(lua_State *L) {
try {
SluiftClient* client = getClient(L);
- client->connect();
+ std::string host(luaL_checkstring(L, 2));
+ if (host.empty()) {
+ client->connect();
+ }
+ else {
+ client->connect(host);
+ }
client->waitConnected();
return 1;
}
@@ -453,12 +468,12 @@ static int sluift_client_set_options(lua_State* L) {
luaL_checktype(L, 2, LUA_TTABLE);
lua_getfield(L, 2, "compress");
if (!lua_isnil(L, -1)) {
- client->getClient()->setUseStreamCompression(lua_toboolean(L, -1));
+ client->getOptions().useStreamCompression = lua_toboolean(L, -1);
}
lua_getfield(L, 2, "tls");
if (!lua_isnil(L, -1)) {
bool useTLS = lua_toboolean(L, -1);
- client->getClient()->setUseTLS(useTLS ? Client::UseTLSWhenAvailable : Client::NeverUseTLS);
+ client->getOptions().useTLS = (useTLS ? ClientOptions::UseTLSWhenAvailable : ClientOptions::NeverUseTLS);
}
lua_pushvalue(L, 1);
return 0;
diff --git a/Sluift/sluift.h b/Sluift/sluift.h
index f28862e..27b4eab 100644
--- a/Sluift/sluift.h
+++ b/Sluift/sluift.h
@@ -12,6 +12,6 @@
#define SLUIFT_API extern
#endif
-#include "lua.h"
+#include <lua.h>
SLUIFT_API int (luaopen_sluift)(lua_State *L);