From 79356beb32b7869293a818e2967fd59cfcf9383a Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Mon, 29 Dec 2008 20:22:45 +0000 Subject: [PATCH] Added Sparkle to Telldus Center --- telldus-gui/TelldusCenter/AutoUpdater.cpp | 9 +++++ telldus-gui/TelldusCenter/AutoUpdater.h | 11 ++++++ telldus-gui/TelldusCenter/CocoaInitializer.h | 19 ++++++++++ telldus-gui/TelldusCenter/CocoaInitializer.mm | 27 ++++++++++++++ telldus-gui/TelldusCenter/Info.plist | 24 ++++++++++++ .../TelldusCenter/SparkleAutoUpdater.h | 25 +++++++++++++ .../TelldusCenter/SparkleAutoUpdater.mm | 37 +++++++++++++++++++ telldus-gui/TelldusCenter/TelldusCenter.pro | 17 +++++++-- telldus-gui/TelldusCenter/main.cpp | 14 +++++++ 9 files changed, 179 insertions(+), 4 deletions(-) create mode 100644 telldus-gui/TelldusCenter/AutoUpdater.cpp create mode 100644 telldus-gui/TelldusCenter/AutoUpdater.h create mode 100644 telldus-gui/TelldusCenter/CocoaInitializer.h create mode 100644 telldus-gui/TelldusCenter/CocoaInitializer.mm create mode 100644 telldus-gui/TelldusCenter/Info.plist create mode 100644 telldus-gui/TelldusCenter/SparkleAutoUpdater.h create mode 100644 telldus-gui/TelldusCenter/SparkleAutoUpdater.mm diff --git a/telldus-gui/TelldusCenter/AutoUpdater.cpp b/telldus-gui/TelldusCenter/AutoUpdater.cpp new file mode 100644 index 00000000..9b94ad32 --- /dev/null +++ b/telldus-gui/TelldusCenter/AutoUpdater.cpp @@ -0,0 +1,9 @@ +/* + * Copyright (C) 2008 Remko Troncon + */ + +#include "AutoUpdater.h" + +AutoUpdater::~AutoUpdater() +{ +} diff --git a/telldus-gui/TelldusCenter/AutoUpdater.h b/telldus-gui/TelldusCenter/AutoUpdater.h new file mode 100644 index 00000000..130725d0 --- /dev/null +++ b/telldus-gui/TelldusCenter/AutoUpdater.h @@ -0,0 +1,11 @@ +#ifndef AUTOUPDATER_H +#define AUTOUPDATER_H + +class AutoUpdater +{ +public: + virtual ~AutoUpdater(); + virtual void checkForUpdates() = 0; +}; + +#endif diff --git a/telldus-gui/TelldusCenter/CocoaInitializer.h b/telldus-gui/TelldusCenter/CocoaInitializer.h new file mode 100644 index 00000000..4761a973 --- /dev/null +++ b/telldus-gui/TelldusCenter/CocoaInitializer.h @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2008 Remko Troncon + */ + +#ifndef COCOAINITIALIZER_H +#define COCOAINITIALIZER_H + +class CocoaInitializer +{ + public: + CocoaInitializer(); + ~CocoaInitializer(); + + private: + class Private; + Private* d; +}; + +#endif diff --git a/telldus-gui/TelldusCenter/CocoaInitializer.mm b/telldus-gui/TelldusCenter/CocoaInitializer.mm new file mode 100644 index 00000000..fc1916d4 --- /dev/null +++ b/telldus-gui/TelldusCenter/CocoaInitializer.mm @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2008 Remko Troncon + */ + +#include "CocoaInitializer.h" + +#include +#include +#include + +class CocoaInitializer::Private { +public: + NSAutoreleasePool* autoReleasePool_; +}; + +CocoaInitializer::CocoaInitializer() +{ + d = new CocoaInitializer::Private(); + NSApplicationLoad(); + d->autoReleasePool_ = [[NSAutoreleasePool alloc] init]; +} + +CocoaInitializer::~CocoaInitializer() +{ + [d->autoReleasePool_ release]; + delete d; +} diff --git a/telldus-gui/TelldusCenter/Info.plist b/telldus-gui/TelldusCenter/Info.plist new file mode 100644 index 00000000..5fd55514 --- /dev/null +++ b/telldus-gui/TelldusCenter/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleIconFile + + CFBundlePackageType + APPL + CFBundleSignature + tellduscenter + CFBundleExecutable + TelldusCenter + CFBundleIdentifier + com.telldus.center + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Telldus Center + CFBundleShortVersionString + Telldus Center 1.3.0 + CFBundleVersion + 1.3.0 + + diff --git a/telldus-gui/TelldusCenter/SparkleAutoUpdater.h b/telldus-gui/TelldusCenter/SparkleAutoUpdater.h new file mode 100644 index 00000000..eba96a9f --- /dev/null +++ b/telldus-gui/TelldusCenter/SparkleAutoUpdater.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2008 Remko Troncon + */ + +#ifndef SPARKLEAUTOUPDATER_H +#define SPARKLEAUTOUPDATER_H + +#include + +#include "AutoUpdater.h" + +class SparkleAutoUpdater : public AutoUpdater +{ +public: + SparkleAutoUpdater(const QString& url); + ~SparkleAutoUpdater(); + + void checkForUpdates(); + +private: + class Private; + Private* d; +}; + +#endif diff --git a/telldus-gui/TelldusCenter/SparkleAutoUpdater.mm b/telldus-gui/TelldusCenter/SparkleAutoUpdater.mm new file mode 100644 index 00000000..82d2afe9 --- /dev/null +++ b/telldus-gui/TelldusCenter/SparkleAutoUpdater.mm @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2008 Remko Troncon + */ + +#include "SparkleAutoUpdater.h" + +#include +#include + +class SparkleAutoUpdater::Private +{ +public: + SUUpdater* updater; +}; + +SparkleAutoUpdater::SparkleAutoUpdater(const QString& aUrl) +{ + d = new Private; + + d->updater = [SUUpdater sharedUpdater]; + [d->updater retain]; + + NSURL* url = [NSURL URLWithString: + [NSString stringWithUTF8String: aUrl.toUtf8().data()]]; + [d->updater setFeedURL: url]; +} + +SparkleAutoUpdater::~SparkleAutoUpdater() +{ + [d->updater release]; + delete d; +} + +void SparkleAutoUpdater::checkForUpdates() +{ + [d->updater checkForUpdatesInBackground]; +} diff --git a/telldus-gui/TelldusCenter/TelldusCenter.pro b/telldus-gui/TelldusCenter/TelldusCenter.pro index 510b8376..f006cf01 100644 --- a/telldus-gui/TelldusCenter/TelldusCenter.pro +++ b/telldus-gui/TelldusCenter/TelldusCenter.pro @@ -5,11 +5,20 @@ TARGET = TelldusCenter TEMPLATE = app SOURCES += main.cpp \ mainwindow.cpp \ - tellduscenterapplication.cpp + tellduscenterapplication.cpp \ + autoupdater.cpp HEADERS += mainwindow.h \ - tellduscenterapplication.h + tellduscenterapplication.h \ + autoupdater.h \ + CocoaInitializer.h FORMS += RESOURCES += resource.qrc -macx:LIBS += -lTelldusGui \ - -L../TelldusGui +macx { + HEADERS += sparkleautoupdater.h + LIBS += -framework TelldusGui -framework Sparkle + OBJECTIVE_SOURCES += SparkleAutoUpdater.mm \ + CocoaInitializer.mm + QMAKE_INFO_PLIST = Info.plist +} !macx:LIBS += -ltelldus-gui +VERSION = 1.3.0 diff --git a/telldus-gui/TelldusCenter/main.cpp b/telldus-gui/TelldusCenter/main.cpp index cdda2ee0..75aaa40d 100644 --- a/telldus-gui/TelldusCenter/main.cpp +++ b/telldus-gui/TelldusCenter/main.cpp @@ -1,6 +1,11 @@ #include "tellduscenterapplication.h" #include "mainwindow.h" +#ifdef Q_WS_MAC +#include "CocoaInitializer.h" +#include "SparkleAutoUpdater.h" +#endif + int main(int argc, char *argv[]) { Q_INIT_RESOURCE( resource ); @@ -10,5 +15,14 @@ int main(int argc, char *argv[]) MainWindow *w = new MainWindow(); w->show(); + AutoUpdater* updater = 0; +#ifdef Q_WS_MAC + CocoaInitializer initializer; + updater = new SparkleAutoUpdater("file:///Users/micke/Documents/dev/appcast.xml"); +#endif + if (updater) { + //updater->checkForUpdates(); + } + return application.exec(); }