half baked auto update (won't affect compile anyway)
update wscript, fix typos in c and mm files
Change-Id: I5eab74662c53d39cd91d621b20c0506da019c09b
diff --git a/gui/chronosharegui.cpp b/gui/chronosharegui.cpp
index cbcafe2..d37b985 100644
--- a/gui/chronosharegui.cpp
+++ b/gui/chronosharegui.cpp
@@ -41,6 +41,9 @@
#ifdef ADHOC_SUPPORTED
, m_executor (1)
#endif
+#ifdef SPARKLE_SUPPORTED
+ , m_autoUpdate(0)
+#endif
{
setWindowTitle("Settings");
@@ -147,6 +150,9 @@
#ifdef ADHOC_SUPPORTED
delete m_wifiAction;
#endif
+#ifdef SPARKLE_SUPPORTED
+ delete m_autoUpdate;
+#endif
delete m_openFolder;
delete m_viewSettings;
delete m_changeFolder;
@@ -208,6 +214,11 @@
connect (m_wifiAction, SIGNAL (toggled(bool)), this, SLOT(onAdHocChange(bool)));
#endif
+#ifdef SPARKLE_SUPPORTED
+ m_autoUpdate = new QAction (tr("Check For Updates"), this);
+ connect (m_autoUpdate, SIGNAL(triggered()), this, SLOT(onCheckForUpdates()));
+#endif
+
// create the "quit program" action
m_quitProgram = new QAction(tr("&Quit"), this);
connect(m_quitProgram, SIGNAL(triggered()), qApp, SLOT(quit()));
@@ -279,6 +290,14 @@
#endif
}
+#ifdef SPARKLE_SUPPORTED
+void
+ChronoShareGui::onCheckForUpdates()
+{
+ m_autoUpdate->checkForUpdates();
+}
+#endif
+
void ChronoShareGui::setIcon()
{
// set the icon image
diff --git a/gui/chronosharegui.h b/gui/chronosharegui.h
index eba4c12..8403a66 100644
--- a/gui/chronosharegui.h
+++ b/gui/chronosharegui.h
@@ -25,6 +25,11 @@
#include "adhoc.h"
+#if __APPLE__ && HAVE_SPARKLE
+#define SPARKLE_SUPPORTED 1
+#include "auto-update.h"
+#endif
+
#include <QtGui>
#include <QWidget>
#include <QSystemTrayIcon>
@@ -70,7 +75,9 @@
// click on adhoc button
void onAdHocChange (bool state); // cannot be protected with #ifdef. otherwise something fishy with QT
-
+#ifdef SPARKLE_SUPPORTED
+ void onCheckForUpdates();
+#endif
private:
// create actions that result from clicking a menu option
@@ -109,6 +116,7 @@
QAction* m_viewSettings; // chronoShare settings
QAction* m_changeFolder; // change the shared folder action
QAction* m_quitProgram; // quit program action
+ QAction *m_checkForUpdates;
QAction *m_wifiAction;
@@ -133,6 +141,9 @@
Executor m_executor;
#endif
+#ifdef SPARKLE_SUPPORTED
+ AutoUpdate *m_autoUpdate;
+#endif
// QString m_settingsFilePath; // settings file path
// QString m_settings;
};
diff --git a/osx/auto-update/auto-update.h b/osx/auto-update/auto-update.h
new file mode 100644
index 0000000..14caa32
--- /dev/null
+++ b/osx/auto-update/auto-update.h
@@ -0,0 +1,8 @@
+#ifndef AUTO_UPDATE_H
+#define AUTO_UPDATE_H
+class AutoUpdate
+{
+ public:
+ virtual void checkForUpdates() = 0;
+};
+#endif
diff --git a/osx/auto-update/sparkle-auto-update.h b/osx/auto-update/sparkle-auto-update.h
new file mode 100644
index 0000000..9050bff
--- /dev/null
+++ b/osx/auto-update/sparkle-auto-update.h
@@ -0,0 +1,15 @@
+#ifndef SPARKLE_AUTO_UPDATE_H
+#define SPARKLE_AUTO_UPDATE_H
+#include "auto-update.h"
+#include <QString>
+class SparkleAutoUpdate : public AutoUpdate
+{
+public:
+ SparkleAutoUpdate (const QString &url);
+ ~SparkleAutoUpdate ();
+ virtual void checkForUpdates();
+private:
+ class Private;
+ Private *d;
+}
+#endif
diff --git a/osx/auto-update/sparkle-auto-update.mm b/osx/auto-update/sparkle-auto-update.mm
new file mode 100644
index 0000000..be49b55
--- /dev/null
+++ b/osx/auto-update/sparkle-auto-update.mm
@@ -0,0 +1,28 @@
+#include "sparkle-auto-update.h"
+#import <Sparkle/Sparkle.h>
+
+class SparkleAutoUpdate::Private
+{
+ public:
+ SUUpdater *updater;
+};
+
+SparkleAutoUpdate::SparkleAutoUpdate(const QString &updateUrl)
+{
+ d = new Private;
+ d->updater = [SUUpdater sharedUpdater];
+ [d->updater setAutomaticallyChecksForUpdates:YES];
+ NSURL *url = [NSURL URLWithString: [NSString stringWithUTF8String: updateUrl.toUtf8().data()]];
+ [d->updater setFeedURL: url];
+}
+
+SparkleAutoUpdate::~SparkleAutoUpdate()
+{
+ delete d;
+ // presummably SUUpdater handles garbage collection
+}
+
+void SparkleAutoUpdate::checkForUpdates()
+{
+ [d->updater checkForUpdatesInBackground];
+}
diff --git a/wscript b/wscript
index f2d7b1d..e8725b6 100644
--- a/wscript
+++ b/wscript
@@ -1,4 +1,5 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+import os
VERSION='0.1'
APPNAME='chronoshare'
@@ -13,6 +14,35 @@
opt.load('compiler_c compiler_cxx boost ccnx protoc qt4')
+def check_framework(conf, name, **kwargs):
+ frameworkLocations = (os.environ.get('HOME') + '/Library/Frameworks'
+ , '/opt/local/Library/Frameworks'
+ , '/Library/Frameworks'
+ , '/Network/Library/Frameworks'
+ , '/System/Library/Frameworks'
+ )
+ uselib = name.upper()
+ frameworkName = name + ".framework"
+ found = False
+ for frameworkLocation in frameworkLocations:
+ dynamicLib = os.path.join(frameworkLocation, frameworkName, name)
+ if os.path.exists(dynamicLib):
+ conf.env.append_unique('FRAMEWORK_' + uselib, name)
+ conf.msg('Checking for %s' % name, dynamicLib, 'GREEN')
+ conf.env.append_unique('INCLUDES_' + uselib, os.path.join(frameworkLocation, frameworkName, 'Headers'))
+ found = True
+ define_name = kwargs.get('define_name', None)
+ if define_name is not None:
+ conf.define(define_name, 1)
+ break
+
+ if not found:
+ mandatory = kwargs.get('mandatory', True)
+ if mandatory:
+ conf.fatal('Cannot find ' + frameworkName)
+ else:
+ conf.msg('Checking for %s' % name, False, 'YELLOW')
+
def configure(conf):
conf.load("compiler_c compiler_cxx")
@@ -25,6 +55,12 @@
if Utils.unversioned_sys_platform () == "darwin":
conf.check_cxx(framework_name='Foundation', uselib_store='OSX_FOUNDATION', cxxflags="-ObjC++", mandatory=False)
conf.check_cxx(framework_name='CoreWLAN', uselib_store='OSX_COREWLAN', cxxflags="-ObjC++", define_name='HAVE_COREWLAN', mandatory=False)
+ conf.check_cxx(framework_name='Sparkle', uselib_store='SPARKLE', cxxflags='-ObjC++', define_name='HAVE_SPARKLE', mandatory=False)
+ #check_framework(conf, 'Sparkle', define_name='HAVE_SPARKLE', mandatory=False)
+ if conf.get_define('HAVE_SPARKLE'):
+ conf.env.SPARKLE = True
+ else:
+ conf.env.SPARKLE = False
if not conf.check_cfg(package='openssl', args=['--cflags', '--libs'], uselib_store='SSL', mandatory=False):
libcrypto = conf.check_cc(lib='crypto',
@@ -167,7 +203,12 @@
</plist>'''
qt.mac_app = "ChronoShare.app"
qt.mac_plist = app_plist % "ChronoShare"
- qt.use += " OSX_FOUNDATION OSX_COREWLAN adhoc"
+ if not bld.env['SPARKLE']:
+ qt.use += " OSX_FOUNDATION OSX_COREWLAN adhoc"
+ else:
+ qt.use += " OSX_SPARKLE OSX_FOUNDATION OSX_COREWLAN adhoc"
+ qt.source.append("osx/auto-update/sparkle-auto-update.mm")
+ qt.includes += " osx/auto-update"
# qt.use += " OSX_FOUNDATION OSX_COREWLAN adhoc"