├── .gitignore ├── AutoUpdater.cpp ├── AutoUpdater.h ├── CocoaInitializer.h ├── CocoaInitializer.mm ├── Info.plist ├── README.md ├── Sparkle.framework ├── SparkleAutoUpdater.h ├── SparkleAutoUpdater.mm ├── main.cpp └── mixing-cocoa-and-qt.pro /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | .qmake.stash 3 | *.app 4 | Makefile 5 | -------------------------------------------------------------------------------- /AutoUpdater.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Remko Troncon 3 | */ 4 | 5 | #include "AutoUpdater.h" 6 | 7 | AutoUpdater::~AutoUpdater() 8 | { 9 | } 10 | -------------------------------------------------------------------------------- /AutoUpdater.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Remko Troncon 3 | */ 4 | 5 | #ifndef AUTOUPDATER_H 6 | #define AUTOUPDATER_H 7 | 8 | class AutoUpdater 9 | { 10 | public: 11 | virtual ~AutoUpdater(); 12 | 13 | virtual void checkForUpdates() = 0; 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /CocoaInitializer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Remko Troncon 3 | */ 4 | 5 | #ifndef COCOAINITIALIZER_H 6 | #define COCOAINITIALIZER_H 7 | 8 | class CocoaInitializer 9 | { 10 | public: 11 | CocoaInitializer(); 12 | ~CocoaInitializer(); 13 | 14 | private: 15 | class Private; 16 | Private* d; 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /CocoaInitializer.mm: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Remko Troncon 3 | */ 4 | 5 | #include "CocoaInitializer.h" 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | class CocoaInitializer::Private 12 | { 13 | public: 14 | NSAutoreleasePool* autoReleasePool_; 15 | }; 16 | 17 | CocoaInitializer::CocoaInitializer() 18 | { 19 | d = new CocoaInitializer::Private(); 20 | NSApplicationLoad(); 21 | d->autoReleasePool_ = [[NSAutoreleasePool alloc] init]; 22 | } 23 | 24 | CocoaInitializer::~CocoaInitializer() 25 | { 26 | [d->autoReleasePool_ release]; 27 | delete d; 28 | } 29 | -------------------------------------------------------------------------------- /Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | sparkletestapp 9 | CFBundleGetInfoString 10 | Sparkle Test App 11 | CFBundleIdentifier 12 | be.el-tramo.mixing-cocoa-and-qt 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | Sparkle Test App 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | SparkleTestApp 1.0 21 | CFBundleSignature 22 | sparkletestapp 23 | CFBundleVersion 24 | 1.0 25 | CSResourcesFileMapped 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | See 2 | -------------------------------------------------------------------------------- /Sparkle.framework: -------------------------------------------------------------------------------- 1 | /Library/Frameworks/Sparkle.framework -------------------------------------------------------------------------------- /SparkleAutoUpdater.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Remko Troncon 3 | */ 4 | 5 | #ifndef SPARKLEAUTOUPDATER_H 6 | #define SPARKLEAUTOUPDATER_H 7 | 8 | #include 9 | 10 | #include "AutoUpdater.h" 11 | 12 | class SparkleAutoUpdater : public AutoUpdater 13 | { 14 | public: 15 | SparkleAutoUpdater(const QString& url); 16 | ~SparkleAutoUpdater(); 17 | 18 | void checkForUpdates(); 19 | 20 | private: 21 | class Private; 22 | Private* d; 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /SparkleAutoUpdater.mm: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Remko Troncon 3 | */ 4 | 5 | #include "SparkleAutoUpdater.h" 6 | 7 | #include 8 | #include 9 | 10 | class SparkleAutoUpdater::Private 11 | { 12 | public: 13 | SUUpdater* updater; 14 | }; 15 | 16 | SparkleAutoUpdater::SparkleAutoUpdater(const QString& aUrl) 17 | { 18 | d = new Private; 19 | 20 | d->updater = [SUUpdater sharedUpdater]; 21 | [d->updater retain]; 22 | 23 | NSURL* url = [NSURL URLWithString: 24 | [NSString stringWithUTF8String: aUrl.toUtf8().data()]]; 25 | [d->updater setFeedURL: url]; 26 | } 27 | 28 | SparkleAutoUpdater::~SparkleAutoUpdater() 29 | { 30 | [d->updater release]; 31 | delete d; 32 | } 33 | 34 | void SparkleAutoUpdater::checkForUpdates() 35 | { 36 | [d->updater checkForUpdatesInBackground]; 37 | } 38 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Remko Troncon 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | #ifdef Q_OS_MAC 9 | #include "CocoaInitializer.h" 10 | #include "SparkleAutoUpdater.h" 11 | #endif 12 | 13 | int main(int argc, char* argv[]) 14 | { 15 | QApplication app(argc, argv); 16 | QLabel l("This is an auto-updating application"); 17 | l.show(); 18 | 19 | AutoUpdater* updater; 20 | #ifdef Q_OS_MAC 21 | CocoaInitializer initializer; 22 | updater = new SparkleAutoUpdater("http://el-tramo.be/files/blog/mixing-cocoa-and-qt/appcast.xml"); 23 | #endif 24 | if (updater) { 25 | updater->checkForUpdates(); 26 | } 27 | return app.exec(); 28 | } 29 | -------------------------------------------------------------------------------- /mixing-cocoa-and-qt.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = app 2 | 3 | QT += widgets 4 | 5 | HEADERS += \ 6 | $$PWD/AutoUpdater.h 7 | 8 | SOURCES += \ 9 | $$PWD/AutoUpdater.cpp \ 10 | $$PWD/main.cpp 11 | 12 | mac { 13 | HEADERS += \ 14 | $$PWD/SparkleAutoUpdater.h \ 15 | $$PWD/CocoaInitializer.h 16 | 17 | OBJECTIVE_SOURCES += \ 18 | $$PWD/SparkleAutoUpdater.mm \ 19 | $$PWD/CocoaInitializer.mm 20 | 21 | QMAKE_LFLAGS += -F. 22 | QMAKE_CXXFLAGS += -F. 23 | QMAKE_CFLAGS += -F. 24 | QMAKE_OBJECTIVE_CFLAGS += -F. 25 | LIBS += -framework Sparkle -framework AppKit 26 | 27 | # FIXME: Stopped working. Need to fix this. 28 | #QMAKE_INFO_PLIST = Info.plist 29 | QMAKE_POST_LINK = mkdir mixing-cocoa-and-qt.app/Contents/Frameworks && cp -r /Library/Frameworks/Sparkle.framework mixing-cocoa-and-qt.app/Contents/Frameworks 30 | } 31 | --------------------------------------------------------------------------------