summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--SConstruct24
-rw-r--r--SwifTools/AutoUpdater/AutoUpdater.cpp8
-rw-r--r--SwifTools/AutoUpdater/AutoUpdater.h10
-rw-r--r--SwifTools/AutoUpdater/SparkleAutoUpdater.h18
-rw-r--r--SwifTools/AutoUpdater/SparkleAutoUpdater.mm33
-rw-r--r--SwifTools/SConscript4
6 files changed, 97 insertions, 0 deletions
diff --git a/SConstruct b/SConstruct
index e4ef041..98cd348 100644
--- a/SConstruct
+++ b/SConstruct
@@ -156,6 +156,12 @@ if int(ARGUMENTS.get("V", 0)) == 0:
env["TESTCOMSTR"] = colorize("TEST", "$SOURCE", "yellow")
#Progress(colorize("DEP", "$TARGET", "red")
+def checkObjCHeader(context, header) :
+ context.Message("Checking for Objective-C header " + header + " ... ")
+ ret = context.TryCompile("#include <Cocoa/Cocoa.h>\n#include <" + header + ">", ".m")
+ context.Result(ret)
+ return ret
+
################################################################################
# Platform configuration
################################################################################
@@ -165,6 +171,9 @@ if ARGUMENTS.get("force-configure", 0) :
conf = Configure(conf_env)
+conf.CheckCXX()
+conf.CheckCC()
+
if conf.CheckLib("z") :
env.Append(LIBS = "z")
env["ZLIB_FLAGS"] = ""
@@ -202,6 +211,21 @@ if env["PLATFORM"] != "win32" and env["PLATFORM"] != "darwin" :
env["XSS_FLAGS"] = xss_flags
conf.Finish()
+# Sparkle
+env["HAVE_SPARKLE"] = 0
+if env["PLATFORM"] == "darwin" :
+ sparkle_flags = {
+ "FRAMEWORKPATH": ["/Library/Frameworks"],
+ "FRAMEWORKS": ["Sparkle"]
+ }
+ sparkle_env = conf_env.Clone()
+ sparkle_env.MergeFlags(sparkle_flags)
+ conf = Configure(sparkle_env, custom_tests = { "CheckObjCHeader" : checkObjCHeader })
+ if conf.CheckObjCHeader("Sparkle/Sparkle.h") :
+ env["HAVE_SPARKLE"] = 1
+ env["SPARKLE_FLAGS"] = sparkle_flags
+ conf.Finish()
+
# LibXML
conf = Configure(conf_env)
if conf.CheckCHeader("libxml/parser.h") and conf.CheckLib("xml2") :
diff --git a/SwifTools/AutoUpdater/AutoUpdater.cpp b/SwifTools/AutoUpdater/AutoUpdater.cpp
new file mode 100644
index 0000000..cd0eb0b
--- /dev/null
+++ b/SwifTools/AutoUpdater/AutoUpdater.cpp
@@ -0,0 +1,8 @@
+#include "SwifTools/AutoUpdater/AutoUpdater.h"
+
+namespace Swift {
+
+AutoUpdater::~AutoUpdater() {
+}
+
+}
diff --git a/SwifTools/AutoUpdater/AutoUpdater.h b/SwifTools/AutoUpdater/AutoUpdater.h
new file mode 100644
index 0000000..c1a73f1
--- /dev/null
+++ b/SwifTools/AutoUpdater/AutoUpdater.h
@@ -0,0 +1,10 @@
+#pragma once
+
+namespace Swift {
+ class AutoUpdater {
+ public:
+ virtual ~AutoUpdater();
+
+ virtual void checkForUpdates() = 0;
+ };
+}
diff --git a/SwifTools/AutoUpdater/SparkleAutoUpdater.h b/SwifTools/AutoUpdater/SparkleAutoUpdater.h
new file mode 100644
index 0000000..37053fc
--- /dev/null
+++ b/SwifTools/AutoUpdater/SparkleAutoUpdater.h
@@ -0,0 +1,18 @@
+#pragma once
+
+#include "Swiften/Base/String.h"
+#include "SwifTools/AutoUpdater/AutoUpdater.h"
+
+namespace Swift {
+ class SparkleAutoUpdater : public AutoUpdater {
+ public:
+ SparkleAutoUpdater(const String& url);
+ ~SparkleAutoUpdater();
+
+ void checkForUpdates();
+
+ private:
+ class Private;
+ Private* d;
+ };
+}
diff --git a/SwifTools/AutoUpdater/SparkleAutoUpdater.mm b/SwifTools/AutoUpdater/SparkleAutoUpdater.mm
new file mode 100644
index 0000000..30e2ae2
--- /dev/null
+++ b/SwifTools/AutoUpdater/SparkleAutoUpdater.mm
@@ -0,0 +1,33 @@
+#include "SwifTools/AutoUpdater/SparkleAutoUpdater.h"
+
+#include <Cocoa/Cocoa.h>
+#include <Sparkle/Sparkle.h>
+
+namespace Swift {
+
+class SparkleAutoUpdater::Private {
+ public:
+ SUUpdater* updater;
+};
+
+SparkleAutoUpdater::SparkleAutoUpdater(const String& url) {
+ d = new Private;
+
+ d->updater = [SUUpdater sharedUpdater];
+ [d->updater retain];
+
+ NSURL* nsurl = [NSURL URLWithString:
+ [NSString stringWithUTF8String: url.getUTF8Data()]];
+ [d->updater setFeedURL: nsurl];
+}
+
+SparkleAutoUpdater::~SparkleAutoUpdater() {
+ [d->updater release];
+ delete d;
+}
+
+void SparkleAutoUpdater::checkForUpdates() {
+ [d->updater checkForUpdatesInBackground];
+}
+
+}
diff --git a/SwifTools/SConscript b/SwifTools/SConscript
index 2ae4e4e..92e82be 100644
--- a/SwifTools/SConscript
+++ b/SwifTools/SConscript
@@ -13,9 +13,13 @@ sources = [
"Idle/ActualIdleDetector.cpp",
"Idle/IdleQuerier.cpp",
"Idle/PlatformIdleQuerier.cpp",
+ "AutoUpdater/AutoUpdater.cpp",
"Linkify.cpp",
]
+if myenv.get("HAVE_SPARKLE", 0) :
+ sources += ["AutoUpdater/SparkleAutoUpdater.mm"]
+
if myenv["PLATFORM"] == "win32" :
sources += ["Idle/WindowsIdleQuerier.cpp"]
elif myenv["PLATFORM"] == "darwin" :