/*************************************************************************** * __________ __ ___. * Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ * $Id$ * * Copyright (C) 2010 Robert Bieber * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * ****************************************************************************/ #include "targetdownloader.h" #include "ui_targetdownloader.h" #include "quazip.h" #include "quazipfile.h" #include "quazipfileinfo.h" #include #include #include #include TargetDownloader::TargetDownloader(QWidget *parent, QString path) : QDialog(parent), ui(new Ui::TargetDownloader), reply(0), cancelled(false) { ui->setupUi(this); QObject::connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); manager = new QNetworkAccessManager(); fout.setFileName(path); if(fout.open(QFile::WriteOnly)) { ui->label->setText(tr("Downloading targetdb")); QNetworkRequest request; request.setUrl(QUrl("http://svn.rockbox.org/viewvc.cgi/trunk/utils/" "themeeditor/resources/targetdb")); request.setRawHeader("User-Agent", "Rockbox Theme Editor"); reply = manager->get(request); QObject::connect(reply, SIGNAL(readyRead()), this, SLOT(dataReceived())); QObject::connect(reply, SIGNAL(finished()), this, SLOT(finished())); QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(progress(qint64,qint64))); } else { ui->label->setText(tr("Error: Couldn't open output file")); } } TargetDownloader::~TargetDownloader() { delete ui; fout.close(); manager->deleteLater(); if(reply) { reply->abort(); reply->deleteLater(); } } void TargetDownloader::cancel() { cancelled = true; if(reply) { reply->abort(); reply->deleteLater(); reply = 0; } fout.close(); fout.remove(); close(); } void TargetDownloader::dataReceived() { fout.write(reply->readAll()); } void TargetDownloader::progress(qint64 bytes, qint64 available) { if(available > 0) { ui->progressBar->setMaximum(available); ui->progressBar->setValue(bytes); } } void TargetDownloader::finished() { if(cancelled) return; fout.close(); reply->deleteLater(); reply = 0; ui->label->setText(tr("Download complete")); hide(); this->deleteLater(); } void TargetDownloader::netError(QNetworkReply::NetworkError code) { ui->label->setText(tr("Network error: ") + reply->errorString()); } void TargetDownloader::closeEvent(QCloseEvent *event) { cancel(); event->accept(); } d='n6' href='#n6'>6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
;             __________               __   ___.
;   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
;   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
;   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
;   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
;                     \/            \/     \/    \/            \/
; $Id$
;
; Copyright (c) 2010 Dominik Riebeling
;
; All files in this archive are subject to the GNU General Public License.
; See the file COPYING in the source tree root for full license agreement.
;
; This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
; KIND, either express or implied.
;

; NSIS installer using Modern UI
; Expects a static build of the Theme Editor (Qt DLLs are not packaged) and to
; find the input files in the source tree (in-tree build).
; This installer uses the ZipDll plugin for font pack extraction
; (http://nsis.sourceforge.net/ZipDLL_plug-in)

!include "MUI2.nsh"

;Name and file
Name "Rockbox Theme Editor"
OutFile "rbthemeeditor-setup.exe"

;Default installation folder
InstallDir "$PROGRAMFILES\Rockbox Theme Editor"

; global registry shortcuts
!define UNINSTALL_HIVE "Software\Microsoft\Windows\CurrentVersion\Uninstall\Rockbox Theme Editor"
!define SETTINGS_HIVE "Software\rockbox.org\Rockbox Theme Editor"

;Get installation folder from registry if available
InstallDirRegKey HKCU "${SETTINGS_HIVE}" ""

SetCompressor /solid lzma
VIAddVersionKey "ProductName" "Rockbox Theme Editor"
VIAddVersionKey "FileVersion" "0.0.0"
VIAddVersionKey "FileDescription" "Editor for the Rockbox Firmware Theme files"
VIAddVersionKey "LegalCopyright" "Contributing Developers"
VIProductVersion "0.0.0.0"
!define MUI_ICON resources\windowicon.ico
; embed XP manifest
XPStyle on

;Interface Configuration. Use Rockbox blue for header.
!define MUI_BGCOLOR b6c6e5
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "themeeditor-setup.bmp"
!define MUI_HEADERIMAGE_RIGHT
!define MUI_ABORTWARNING

;Pages
!insertmacro MUI_PAGE_LICENSE "..\..\docs\COPYING"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

;Languages
!insertmacro MUI_LANGUAGE "English"

;Installer Sections
Section "Theme Editor" SecThemeEditor
    SectionSetFlags ${SecThemeEditor} ${SF_RO}
    SectionIn RO
    SetOutPath "$INSTDIR"
    ; Store installation folder
    WriteRegStr HKCU "${SETTINGS_HIVE}" "" $INSTDIR
    ; files
    CreateDirectory "$INSTDIR"
    File /oname=$INSTDIR\rbthemeeditor.exe release\rbthemeeditor.exe

    ; Create uninstaller and uninstall information
    WriteUninstaller "$INSTDIR\Uninstall.exe"
    WriteRegStr HKLM "${UNINSTALL_HIVE}" "DisplayName" "Rockbox Theme Editor"
    WriteRegStr HKLM "${UNINSTALL_HIVE}" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
    WriteRegStr HKLM "${UNINSTALL_HIVE}" "QuietUninstallString" "$\"$INSTDIR\Uninstall.exe$\" /S"
    WriteRegStr HKLM "${UNINSTALL_HIVE}" "URLInfoAbout" "http://www.rockbox.org/wiki/ThemeEditor"
SectionEnd

Section "Download Fonts Package" SecFontsPackage
    SetOutPath "$INSTDIR"
    NSISdl::download http://download.rockbox.org/daily/fonts/rockbox-fonts.zip "$INSTDIR\rockbox-fonts.zip"
    ZipDLL::extractall "$INSTDIR\rockbox-fonts.zip" "$INSTDIR" <ALL>
    ; the fonts package uses the Rockbox folder structure. Move all fonts into a
    ; flat directory instead.
    Rename "$INSTDIR\.rockbox\fonts" "$INSTDIR\fonts"
    RMDir /r "$INSTDIR\.rockbox"
    WriteRegStr HKCU "${SETTINGS_HIVE}\RBFont" "fontDir" "$INSTDIR\fonts\"
SectionEnd

Section "Start Menu Shortcut" SecShortCuts
    CreateDirectory "$SMPROGRAMS\Rockbox"
    CreateShortCut "$SMPROGRAMS\Rockbox\Theme Editor.lnk" "$INSTDIR\rbthemeeditor.exe"
    CreateShortCut "$SMPROGRAMS\Rockbox\Uninstall Theme Editor.lnk" "$INSTDIR\Uninstall.exe"
SectionEnd

; Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecThemeEditor} \
    "Rockbox Theme Editor. Required."
!insertmacro MUI_DESCRIPTION_TEXT ${SecFontsPackage} \
    "Download and install the Rockbox Fonts package into program folder. \
     This will set the correct path in the program configuration for the current user only."
!insertmacro MUI_DESCRIPTION_TEXT ${SecShortCuts} \
    "Create Shortcut in Start Menu."
!insertmacro MUI_FUNCTION_DESCRIPTION_END

; Uninstaller Section
Section "Uninstall"
    ; files
    Delete "$INSTDIR\Uninstall.exe"
    Delete "$INSTDIR\rbthemeeditor.exe"
    Delete "$INSTDIR\rockbox-fonts.zip"
    ; folders
    RMDir /r "$INSTDIR\fonts"
    RMDir "$INSTDIR"
    ; start menu folder
    RMDir /r "$SMPROGRAMS\Rockbox"

    ; remove registry information
    DeleteRegKey HKLM "${UNINSTALL_HIVE}"
    DeleteRegKey HKCU "Software\rockbox.org\Rockbox Theme Editor"
SectionEnd