diff --git a/widgets/optionsWidget/optionsWidget.cc b/widgets/optionsWidget/optionsWidget.cc index 8caba7e8eb7e431d434ff6ee47580749a31c8608..4265f0966c85a0e45719af3bd39d47c3218afa23 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 848ab95f9a33fdfee37974e40eee8b617beb4e58..8ff83f4543d669b770e004d82c18c9964b483a76 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;