Added Sparkle to Telldus Center

This commit is contained in:
Micke Prag 2008-12-29 20:22:45 +00:00
parent d7751732ef
commit 79356beb32
9 changed files with 179 additions and 4 deletions

View file

@ -0,0 +1,9 @@
/*
* Copyright (C) 2008 Remko Troncon
*/
#include "AutoUpdater.h"
AutoUpdater::~AutoUpdater()
{
}

View file

@ -0,0 +1,11 @@
#ifndef AUTOUPDATER_H
#define AUTOUPDATER_H
class AutoUpdater
{
public:
virtual ~AutoUpdater();
virtual void checkForUpdates() = 0;
};
#endif

View file

@ -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

View file

@ -0,0 +1,27 @@
/*
* Copyright (C) 2008 Remko Troncon
*/
#include "CocoaInitializer.h"
#include <AppKit/AppKit.h>
#include <Cocoa/Cocoa.h>
#include <QtDebug>
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;
}

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>tellduscenter</string>
<key>CFBundleExecutable</key>
<string>TelldusCenter</string>
<key>CFBundleIdentifier</key>
<string>com.telldus.center</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Telldus Center</string>
<key>CFBundleShortVersionString</key>
<string>Telldus Center 1.3.0</string>
<key>CFBundleVersion</key>
<string>1.3.0</string>
</dict>
</plist>

View file

@ -0,0 +1,25 @@
/*
* Copyright (C) 2008 Remko Troncon
*/
#ifndef SPARKLEAUTOUPDATER_H
#define SPARKLEAUTOUPDATER_H
#include <QString>
#include "AutoUpdater.h"
class SparkleAutoUpdater : public AutoUpdater
{
public:
SparkleAutoUpdater(const QString& url);
~SparkleAutoUpdater();
void checkForUpdates();
private:
class Private;
Private* d;
};
#endif

View file

@ -0,0 +1,37 @@
/*
* Copyright (C) 2008 Remko Troncon
*/
#include "SparkleAutoUpdater.h"
#include <Cocoa/Cocoa.h>
#include <Sparkle/Sparkle.h>
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];
}

View file

@ -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

View file

@ -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();
}