FU Logo
  • Startseite
  • Kontakt
  • Impressum
  • Home
  • Listenauswahl
  • Anleitungen

[linux-minidisc] qhimdtransfer windows autoupdate feature

<-- thread -->
<-- date -->
  • From: Thomas Arp <manner.moe@gmx.de>
  • To: "linux-minidisc@lists.fu-berlin.de" <linux-minidisc@lists.fu-berlin.de>
  • Date: Wed, 23 Jan 2013 02:02:22 +0100
  • Subject: [linux-minidisc] qhimdtransfer windows autoupdate feature

Hi,
i've tested winsparkle [1] for autoupdate feature on windows machines.

As winsparkle binaries are build with msvc, i created a dll import library libwinsparkle.a (attached to this mail) with libtool to make it linkable to projects using gcc.

I also created a sample appcast rss feed winsparkle checks for new versions on my web server [2]. This contains the last windows installer package with the corresponding version number (0.9.5). When i increase the "sparkle:version" winsparkle detects this and starts the download (if choosen).
So i think this will work fine.

QHiMDUpdate base class can be used for mac autoupdate feature using sparkle, too.

Thomas

[1] http://winsparkle.org
[2] http://mannermoe.dyndns.org/minidisc/minidisc.rss

>From 6fe0243b8271f86953271ddc26ac53bd0ec089a4 Mon Sep 17 00:00:00 2001
From: Thomas Arp <manner.moe@gmx.de>
Date: Wed, 23 Jan 2013 01:34:09 +0100
Subject: [PATCH] implemented windows autoupdate routine using winsparkle

---
 qhimdtransfer/icons.qrc            |  1 +
 qhimdtransfer/main.cpp             |  4 +--
 qhimdtransfer/qhimddummyupdate.cpp |  6 ++++
 qhimdtransfer/qhimdmainwindow.cpp  | 10 +++++++
 qhimdtransfer/qhimdmainwindow.h    |  3 ++
 qhimdtransfer/qhimdmainwindow.ui   | 15 +++++++++-
 qhimdtransfer/qhimdtransfer.pro    | 12 +++++---
 qhimdtransfer/qhimdupdate.h        | 25 +++++++++++++++++
 qhimdtransfer/qhimdwinupdate.cpp   | 56 ++++++++++++++++++++++++++++++++++++++
 9 files changed, 125 insertions(+), 7 deletions(-)
 create mode 100644 qhimdtransfer/qhimddummyupdate.cpp
 create mode 100644 qhimdtransfer/qhimdupdate.h
 create mode 100644 qhimdtransfer/qhimdwinupdate.cpp

diff --git a/qhimdtransfer/icons.qrc b/qhimdtransfer/icons.qrc
index 2f44f90..7c721ad 100755
--- a/qhimdtransfer/icons.qrc
+++ b/qhimdtransfer/icons.qrc
@@ -14,5 +14,6 @@
         <file>icons/arrow_download.png</file>
         <file>icons/arrow_upload.png</file>
         <file>icons/qhimdtransfer_24.png</file>
+        <file>icons/update.png</file>
     </qresource>
 </RCC>
diff --git a/qhimdtransfer/main.cpp b/qhimdtransfer/main.cpp
index 91ae588..b28fcb0 100644
--- a/qhimdtransfer/main.cpp
+++ b/qhimdtransfer/main.cpp
@@ -23,8 +23,8 @@ int main(int argc, char *argv[])
     // try cwd, then standard translation directory
     trans.load(transfile) || trans.load(transfile, transdir);
     a.installTranslator(&trans);
-    a.setOrganizationName("linux-minidisc");
-    a.setApplicationName("QHiMDTransfer");
+    a.setOrganizationName(ORG_NAME);
+    a.setApplicationName(APP_NAME);
 
     QHiMDMainWindow w;
     w.show();
diff --git a/qhimdtransfer/qhimddummyupdate.cpp b/qhimdtransfer/qhimddummyupdate.cpp
new file mode 100644
index 0000000..cd2ab46
--- /dev/null
+++ b/qhimdtransfer/qhimddummyupdate.cpp
@@ -0,0 +1,6 @@
+#include "qhimdupdate.h"
+
+QHiMDUpdate * createUpdate()
+{
+    return new QHiMDUpdate();
+}
diff --git a/qhimdtransfer/qhimdmainwindow.cpp b/qhimdtransfer/qhimdmainwindow.cpp
index e2675d9..01db25b 100644
--- a/qhimdtransfer/qhimdmainwindow.cpp
+++ b/qhimdtransfer/qhimdmainwindow.cpp
@@ -398,11 +398,16 @@ QHiMDMainWindow::QHiMDMainWindow(QWidget *parent)
     ui->himd_devices->hide();
     if(!autodetect_init())
         ui->statusBar->showMessage(" autodetection disabled", 10000);
+    update = createUpdate();
+    ui->action_Update->setEnabled(update->is_active());
+    if(update->is_active())
+        update->check_for_updates();
 }
 
 QHiMDMainWindow::~QHiMDMainWindow()
 {
     save_window_settings();
+    update->cleanup_updatecheck();
     delete ui;
 }
 
@@ -573,3 +578,8 @@ void QHiMDMainWindow::on_download_button_clicked()
 {
     /*download_of(localmodel.filePath(ui->localScan->currentIndex()));*/
 }
+
+void QHiMDMainWindow::on_action_Update_triggered()
+{
+    update->check_for_updates();
+}
diff --git a/qhimdtransfer/qhimdmainwindow.h b/qhimdtransfer/qhimdmainwindow.h
index 85be8ae..8ca62ff 100644
--- a/qhimdtransfer/qhimdmainwindow.h
+++ b/qhimdtransfer/qhimdmainwindow.h
@@ -9,6 +9,7 @@
 #include "qhimduploaddialog.h"
 #include "qhimddetection.h"
 #include "qhimdmodel.h"
+#include "qhimdupdate.h"
 #include "../libhimd/himd.h"
 #include <tlist.h>
 #include <fileref.h>
@@ -41,6 +42,7 @@ private:
     QHiMDTracksModel trackmodel;
     QHiMDFileSystemModel localmodel;
     QSettings settings;
+    QHiMDUpdate * update;
     QString dumpmp3(const QHiMDTrack & trk, QString file);
     QString dumpoma(const QHiMDTrack & trk, QString file);
     QString dumppcm(const QHiMDTrack & trk, QString file);
@@ -68,6 +70,7 @@ private slots:
     void himd_removed(QString path);
     void on_himd_devices_activated(QString device);
     void on_download_button_clicked();
+    void on_action_Update_triggered();
 
 signals:
     void himd_busy(QString path);
diff --git a/qhimdtransfer/qhimdmainwindow.ui b/qhimdtransfer/qhimdmainwindow.ui
index b55845f..ecc3b3f 100644
--- a/qhimdtransfer/qhimdmainwindow.ui
+++ b/qhimdtransfer/qhimdmainwindow.ui
@@ -174,7 +174,7 @@
      <x>0</x>
      <y>0</y>
      <width>784</width>
-     <height>18</height>
+     <height>20</height>
     </rect>
    </property>
    <widget class="QMenu" name="menu_Action">
@@ -199,6 +199,7 @@
     </property>
     <addaction name="action_Help"/>
     <addaction name="action_About"/>
+    <addaction name="action_Update"/>
    </widget>
    <addaction name="menu_Action"/>
    <addaction name="menu"/>
@@ -313,6 +314,18 @@
     <string>&amp;Connect</string>
    </property>
   </action>
+  <action name="action_Update">
+   <property name="icon">
+    <iconset resource="icons.qrc">
+     <normaloff>:/icons/update.png</normaloff>:/icons/update.png</iconset>
+   </property>
+   <property name="text">
+    <string>U&amp;pdate</string>
+   </property>
+   <property name="toolTip">
+    <string>Check for updates</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <resources>
diff --git a/qhimdtransfer/qhimdtransfer.pro b/qhimdtransfer/qhimdtransfer.pro
index 236b5e9..dc4775b 100644
--- a/qhimdtransfer/qhimdtransfer.pro
+++ b/qhimdtransfer/qhimdtransfer.pro
@@ -50,7 +50,8 @@ HEADERS += qhimdaboutdialog.h \
     qhimduploaddialog.h \
     qhimdmainwindow.h \
     qhimdmodel.h \
-    qhimddetection.h
+    qhimddetection.h \
+    qhimdupdate.h
 FORMS += qhimdaboutdialog.ui \
     qhimdformatdialog.ui \
     qhimduploaddialog.ui \
@@ -62,13 +63,16 @@ SOURCES += main.cpp \
     qhimdmainwindow.cpp \
     qhimdmodel.cpp \
     qhimddetection.cpp
-win32:SOURCES += qhimdwindetection.cpp
-else:SOURCES += qhimddummydetection.cpp
+win32:SOURCES += qhimdwindetection.cpp \
+    qhimdwinupdate.cpp
+else:SOURCES += qhimddummydetection.cpp \
+    qhimddummyupdate.cpp
 RESOURCES += icons.qrc
 PKGCONFIG += sox \
     taglib
 win32:LIBS += -lsetupapi \
-    -lcfgmgr32
+    -lcfgmgr32 \
+    -lwinsparkle
 win32:RC_FILE = qhimdtransfer.rc
 mac:ICON = qhimdtransfer.icns
 
diff --git a/qhimdtransfer/qhimdupdate.h b/qhimdtransfer/qhimdupdate.h
new file mode 100644
index 0000000..57ca0fd
--- /dev/null
+++ b/qhimdtransfer/qhimdupdate.h
@@ -0,0 +1,25 @@
+#ifndef QHIMDUPDATE_H
+#define QHIMDUPDATE_H
+
+#define APP_NAME "QHiMDTransfer"
+#define ORG_NAME "linux-minidisc"
+
+/* dummy update class, subclass QHiMDWinUpdate is used as a wrapper for winsparkle,
+ * TODO: create QHiMDMacUpdate subclass as a sparkle wrapper class for mac and create corresponding appcast rss feed,
+ */
+
+class QHiMDUpdate {
+
+protected:
+    bool active;
+public:
+    QHiMDUpdate() {active = false;}
+    ~QHiMDUpdate() {}
+    virtual bool is_active() {return active;}
+    virtual void check_for_updates() {}
+    virtual void cleanup_updatecheck() {}
+};
+
+QHiMDUpdate * createUpdate();
+
+#endif // QHIMDUPDATE_H
diff --git a/qhimdtransfer/qhimdwinupdate.cpp b/qhimdtransfer/qhimdwinupdate.cpp
new file mode 100644
index 0000000..fd0dff0
--- /dev/null
+++ b/qhimdtransfer/qhimdwinupdate.cpp
@@ -0,0 +1,56 @@
+#include "qhimdupdate.h"
+
+/* a sample appcast rss feed for qhimdtransfer can be found on my web server for testing
+ * TODO: create release notes html site, so winsparkle can display it if an update is available
+ */
+#define WIN_APPCAST_URL "http://mannermoe.dyndns.org/minidisc/minidisc.rss";
+
+#include <winsparkle.h>
+#include <stdlib.h>
+#include <string.h>
+
+class QHiMDWinUpdate : public QHiMDUpdate {
+
+public:
+    QHiMDWinUpdate();
+    ~QHiMDWinUpdate();
+    virtual void check_for_updates();
+    virtual void cleanup_updatecheck();
+};
+
+QHiMDUpdate * createUpdate()
+{
+    return new QHiMDWinUpdate();
+}
+
+QHiMDWinUpdate::QHiMDWinUpdate()
+{
+    wchar_t org[strlen(ORG_NAME)+1], app[strlen(APP_NAME)+1], vers[strlen(VER)+1];
+    size_t t;
+
+    /* convert char* to wchar_t* needed by win_sparkle_set_app_details(),
+     * alternatively create another rc file storing winapi versioninfo data*/
+    t = mbstowcs(org, ORG_NAME, sizeof(org));
+    t = mbstowcs(app, APP_NAME, sizeof(app));
+    t = mbstowcs(vers, VER, sizeof(vers));
+
+    win_sparkle_set_appcast_url(WIN_APPCAST_URL);
+    win_sparkle_set_app_details(org, app, vers);
+    win_sparkle_init();
+    active = true;
+}
+
+QHiMDWinUpdate::~QHiMDWinUpdate()
+{
+    cleanup_updatecheck();
+}
+
+void QHiMDWinUpdate::check_for_updates()
+{
+    win_sparkle_check_update_with_ui();
+}
+
+void QHiMDWinUpdate::cleanup_updatecheck()
+{
+    win_sparkle_cleanup();
+}
-- 
1.8.0.msysgit.0

Attachment: libwinsparkle.a
Description: Binary data

<-- thread -->
<-- date -->
  • Follow-Ups:
    • Re: [linux-minidisc] qhimdtransfer windows autoupdate feature
      • From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
  • linux-minidisc - January 2013 - Archives indexes sorted by:
    [ thread ] [ subject ] [ author ] [ date ]
  • Complete archive of the linux-minidisc mailing list
  • More info on this list...

Hilfe

  • FAQ
  • Dienstbeschreibung
  • ZEDAT Beratung
  • postmaster@lists.fu-berlin.de

Service-Navigation

  • Startseite
  • Listenauswahl

Einrichtung Mailingliste

  • ZEDAT-Portal
  • Mailinglisten Portal