summaryrefslogtreecommitdiff
path: root/src/SparkleAutoUpdater.mm
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2013-02-24 03:54:53 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2013-02-24 03:54:53 (GMT)
commitca41979ee514f642c506e4f4d81461f19b587bf2 (patch)
treef31feb004d0b724d5240c8a227c7f0c886939a1b /src/SparkleAutoUpdater.mm
parenteff16283358217b43b310269a72e0cb47357a8b3 (diff)
parentabc9da96c89b337377ee62ac29ee54e4e7b0a514 (diff)
Merge branch 'master' of github.com:openscad/openscad into issue11_2
Conflicts: RELEASE_NOTES openscad.pro src/mainwin.cc
Diffstat (limited to 'src/SparkleAutoUpdater.mm')
-rw-r--r--src/SparkleAutoUpdater.mm72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/SparkleAutoUpdater.mm b/src/SparkleAutoUpdater.mm
new file mode 100644
index 0000000..c52e2bb
--- /dev/null
+++ b/src/SparkleAutoUpdater.mm
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2008 Remko Troncon. BSD license
+ * Copyright (C) 2013 Marius Kintel. BSD license
+ */
+
+#include "SparkleAutoUpdater.h"
+
+#include <Cocoa/Cocoa.h>
+#include <Sparkle/Sparkle.h>
+
+NSString *const SUEnableSnapshotsKey = @"SUEnableSnapshots";
+
+class SparkleAutoUpdater::Private
+{
+public:
+ SUUpdater* updater;
+};
+
+SparkleAutoUpdater::SparkleAutoUpdater()
+{
+ d = new Private;
+
+ d->updater = [SUUpdater sharedUpdater];
+ [d->updater retain];
+
+ updateFeed();
+}
+
+SparkleAutoUpdater::~SparkleAutoUpdater()
+{
+ [d->updater release];
+ delete d;
+}
+
+void SparkleAutoUpdater::checkForUpdates()
+{
+ [d->updater checkForUpdatesInBackground];
+}
+
+void SparkleAutoUpdater::setAutomaticallyChecksForUpdates(bool on)
+{
+ [d->updater setAutomaticallyChecksForUpdates:on];
+}
+
+bool SparkleAutoUpdater::automaticallyChecksForUpdates()
+{
+ return [d->updater automaticallyChecksForUpdates];
+}
+
+void SparkleAutoUpdater::setEnableSnapshots(bool on)
+{
+ [[NSUserDefaults standardUserDefaults] setBool:on forKey:SUEnableSnapshotsKey];
+ updateFeed();
+}
+
+bool SparkleAutoUpdater::enableSnapshots()
+{
+ return [[NSUserDefaults standardUserDefaults] boolForKey:SUEnableSnapshotsKey];
+}
+
+QString SparkleAutoUpdater::lastUpdateCheckDate()
+{
+ NSDate *date = [d->updater lastUpdateCheckDate];
+ NSString *datestring = date ? [NSString stringWithFormat:@"Last checked: %@", date] : @"";
+ return QString::fromUtf8([datestring UTF8String]);
+}
+
+void SparkleAutoUpdater::updateFeed()
+{
+ NSString *urlstring = [NSString stringWithFormat:@"http://openscad.org/appcast%@.xml", enableSnapshots() ? @"-snapshots" : @""];
+ [d->updater setFeedURL:[NSURL URLWithString:urlstring]];
+}
contact: Jan Huwald // Impressum