From 8070838947cfddc426d251c3ae98d616f1091a65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 22 Oct 2008 15:20:45 +0000 Subject: [PATCH] Finished Plugin updater git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@3537 383ad7c9-94d9-4d36-a494-682f7c89f535 --- widgets/optionsWidget/optionsWidget.cc | 40 ++++++++++++++++++++------ widgets/optionsWidget/optionsWidget.hh | 4 +-- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/widgets/optionsWidget/optionsWidget.cc b/widgets/optionsWidget/optionsWidget.cc index 8caba7e8..4265f096 100644 --- a/widgets/optionsWidget/optionsWidget.cc +++ b/widgets/optionsWidget/optionsWidget.cc @@ -453,7 +453,7 @@ void OptionsWidget::slotGetUpdates() { pluginPath_.clear(); - pluginPath_ = "Plugins"; + pluginPath_ = "Plugins/"; if ( OpenFlipper::Options::isWindows() ) { pluginPath_ += "Windows/"; @@ -485,7 +485,7 @@ void OptionsWidget::slotGetUpdates() { std::cerr << "Downloading " << (url + pluginPath_ + currentUpdateName_).toStdString() << std::endl; updatedPlugins_.pop_front(); - downloadType = COMPONENT; + downloadType = PLUGIN; startDownload(url + pluginPath_ + currentUpdateName_); } @@ -495,15 +495,39 @@ void OptionsWidget::slotGetUpdates() { void OptionsWidget::updateComponent() { std::cerr << "Todo : Update component" << std::endl; - QFileInfo updateFileInfo (QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() + - ".OpenFlipper" + OpenFlipper::Options::dirSeparator() + currentUpdateName_); - if ( ! updateFileInfo.exists() ) { - std::cerr << "Download failed?! " << std::endl; + + QString sourceName = QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() + + ".OpenFlipper" + OpenFlipper::Options::dirSeparator() + currentUpdateName_ ; + + QString targetName = OpenFlipper::Options::applicationDirStr() + "/" + pluginPath_ + currentUpdateName_; + + QFileInfo sourceFileInfo(sourceName); + QFileInfo targetFileInfo(targetName); + + std::cerr << sourceName.toStdString() << std::endl; + std::cerr << targetName.toStdString() << std::endl; + + if ( ! sourceFileInfo.exists() ) { + statusLabel->setText("Download failed!"); + return; } else { + if ( ! targetFileInfo.exists() ) { + statusLabel->setText("plugin target does not exist"); + return; + } + + statusLabel->setText("Installing new file"); + + QFile targetFile(targetName); + targetFile.remove(); + QFile::copy(sourceName,targetName); + + statusLabel->setText("updated " + currentUpdateName_); } -// QString pluginPath_; + + slotGetUpdates(); } bool OptionsWidget::isNewer(QString _current, QString _latest) { @@ -630,7 +654,7 @@ void OptionsWidget::httpRequestFinished(int requestId, bool error) if ( !error ) { if ( downloadType == VERSIONS_FILE ) compareVersions(); - if ( downloadType == COMPONENT ) + if ( downloadType == PLUGIN ) updateComponent(); } } diff --git a/widgets/optionsWidget/optionsWidget.hh b/widgets/optionsWidget/optionsWidget.hh index 848ab95f..8ff83f45 100644 --- a/widgets/optionsWidget/optionsWidget.hh +++ b/widgets/optionsWidget/optionsWidget.hh @@ -66,7 +66,7 @@ private slots: /// Download updates void slotGetUpdates(); - + /// open a dialog to determine the color void getBackgroundColor(); @@ -97,7 +97,7 @@ private: enum DOWNLOAD { NONE, VERSIONS_FILE, - COMPONENT, + PLUGIN, WINDOWS_SETUP } downloadType; -- GitLab