Commit d8368d22 authored by Jan Möbius's avatar Jan Möbius
Browse files

Basic update checker

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@2865 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 422052e3
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include "optionsWidget.hh" #include "optionsWidget.hh"
#include <iostream> #include <iostream>
#include <OpenFlipper/common/GlobalOptions.hh> #include <OpenFlipper/common/GlobalOptions.hh>
#include <QtNetwork>
OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyBinding>& _core, QWidget *parent) OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyBinding>& _core, QWidget *parent)
...@@ -48,6 +48,10 @@ OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyB ...@@ -48,6 +48,10 @@ OptionsWidget::OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyB
connect(applyButton,SIGNAL(clicked()),this,SLOT(slotApply())); connect(applyButton,SIGNAL(clicked()),this,SLOT(slotApply()));
connect(cancelButton,SIGNAL(clicked()),this,SLOT(slotCancel())); connect(cancelButton,SIGNAL(clicked()),this,SLOT(slotCancel()));
// connect(checkUpdateButton,SIGNAL(clicked()),this,SLOT(slotCheckUpdates()));
} }
void OptionsWidget::showEvent ( QShowEvent * event ) { void OptionsWidget::showEvent ( QShowEvent * event ) {
...@@ -58,7 +62,7 @@ void OptionsWidget::showEvent ( QShowEvent * event ) { ...@@ -58,7 +62,7 @@ void OptionsWidget::showEvent ( QShowEvent * event ) {
toolbox->setChecked( !OpenFlipper::Options::hideToolbox() ); toolbox->setChecked( !OpenFlipper::Options::hideToolbox() );
logger->setChecked( !OpenFlipper::Options::hideLogger() ); logger->setChecked( !OpenFlipper::Options::hideLogger() );
enableLogFile->setChecked( OpenFlipper::Options::logFileEnabled() ); enableLogFile->setChecked( OpenFlipper::Options::logFileEnabled() );
//paths //paths
logFile->setText( OpenFlipper::Options::logFile() ); logFile->setText( OpenFlipper::Options::logFile() );
...@@ -142,3 +146,96 @@ void OptionsWidget::slotApply() { ...@@ -142,3 +146,96 @@ void OptionsWidget::slotApply() {
void OptionsWidget::slotCancel() { void OptionsWidget::slotCancel() {
hide(); hide();
} }
// void OptionsWidget::slotCheckUpdates() {
// // QUrl url("https://www.graphics.rwth-aachen.de/restricted/OpenFlipper-SIL/Versions.txt");
// // url.setUserName("");
// // url.setPassord("");
//
// QString ServerMainURL = updateURL->text() + "Versions.txt";
// QUrl url(ServerMainURL);
//
// if ( ! updateUser->text().isEmpty() )
// url.setUserName(updateUser->text());
//
// if ( ! updatePass->text().isEmpty() )
// url.setPassword(updatePass->text());
//
// QFileInfo fileInfo( QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() +
// ".OpenFlipper" + OpenFlipper::Options::dirSeparator() + "ServerVersions.txt");
// QString fileName = fileInfo.filePath();
//
// if (QFile::exists(fileName)) {
// QFile::remove(fileName);
// std::cerr << "File exists, removing it" << std::endl;
// }
//
// file = new QFile(fileName);
// if (!file->open(QIODevice::WriteOnly)) {
// std::cerr << "Unable to Open local file for writing" << std::endl;
// delete file;
// file = 0;
// } else {
// QHttp* http = new QHttp;
// QHttp::ConnectionMode mode = url.scheme().toLower() == "https" ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp;
// http->setHost(url.host(), mode, url.port() == -1 ? 0 : url.port());
//
// if (!url.userName().isEmpty())
// http->setUser(url.userName(), url.password());
//
// // httpRequestAborted = false;
// QByteArray path = QUrl::toPercentEncoding(url.path(), "!$&'()*+,;=:@/");
// if (path.isEmpty())
// path = "/";
//
// int httpGetId = http->get(path, file);
//
// // !!! Does not work because get is non blocking
// file->close();
//
// delete file;
//
// // progressDialog->setWindowTitle(tr("HTTP"));
// // progressDialog->setLabelText(tr("Downloading %1.").arg(fileName));
// // downloadButton->setEnabled(false);
// }
// }
//
// void HttpWindow::httpRequestFinished(int requestId, bool error)
// {
// if (requestId != httpGetId)
// return;
// if (httpRequestAborted) {
// if (file) {
// file->close();
// file->remove();
// delete file;
// file = 0;
// }
//
// progressDialog->hide();
// return;
// }
//
// if (requestId != httpGetId)
// return;
//
// progressDialog->hide();
// file->close();
//
// if (error) {
// file->remove();
// QMessageBox::information(this, tr("HTTP"),
// tr("Download failed: %1.")
// .arg(http->errorString()));
// } else {
// QString fileName = QFileInfo(QUrl(urlLineEdit->text()).path()).fileName();
// statusLabel->setText(tr("Downloaded %1 to current directory.").arg(fileName));
// }
//
// downloadButton->setEnabled(true);
// delete file;
// file = 0;
// }
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
// it under the terms of the GNU Lesser General Public License as published by // it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// OpenFlipper is distributed in the hope that it will be useful, // OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details. // GNU Lesser General Public License for more details.
// //
// You should have received a copy of the GNU Lesser General Public License // You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>. // along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
// //
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
class OptionsWidget : public QWidget, public Ui::OptionsWidget class OptionsWidget : public QWidget, public Ui::OptionsWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyBinding>& _core, QWidget *parent = 0 ); OptionsWidget(std::vector<PluginInfo>& _plugins, std::vector<KeyBinding>& _core, QWidget *parent = 0 );
...@@ -59,6 +59,9 @@ class OptionsWidget : public QWidget, public Ui::OptionsWidget ...@@ -59,6 +59,9 @@ class OptionsWidget : public QWidget, public Ui::OptionsWidget
/// Only hide widget /// Only hide widget
void slotCancel(); void slotCancel();
/// Checks for updates
// void slotCheckUpdates();
protected: protected:
void showEvent ( QShowEvent * event ); void showEvent ( QShowEvent * event );
...@@ -66,7 +69,7 @@ class OptionsWidget : public QWidget, public Ui::OptionsWidget ...@@ -66,7 +69,7 @@ class OptionsWidget : public QWidget, public Ui::OptionsWidget
//key-bindings //key-bindings
std::vector<PluginInfo>& plugins_; std::vector<PluginInfo>& plugins_;
std::vector<KeyBinding>& coreKeys_; std::vector<KeyBinding>& coreKeys_;
}; };
#endif //OPTIONSWIDGET_HH #endif //OPTIONSWIDGET_HH
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<string/> <string/>
</property> </property>
<property name="currentIndex" > <property name="currentIndex" >
<number>0</number> <number>4</number>
</property> </property>
<property name="usesScrollButtons" > <property name="usesScrollButtons" >
<bool>true</bool> <bool>true</bool>
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>545</width> <width>545</width>
<height>409</height> <height>401</height>
</rect> </rect>
</property> </property>
<attribute name="title" > <attribute name="title" >
...@@ -128,6 +128,14 @@ ...@@ -128,6 +128,14 @@
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="paths" > <widget class="QWidget" name="paths" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>545</width>
<height>401</height>
</rect>
</property>
<attribute name="title" > <attribute name="title" >
<string>Paths</string> <string>Paths</string>
</attribute> </attribute>
...@@ -157,7 +165,7 @@ ...@@ -157,7 +165,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>545</width> <width>545</width>
<height>409</height> <height>401</height>
</rect> </rect>
</property> </property>
<attribute name="title" > <attribute name="title" >
...@@ -237,7 +245,7 @@ ...@@ -237,7 +245,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>545</width> <width>545</width>
<height>409</height> <height>401</height>
</rect> </rect>
</property> </property>
<attribute name="title" > <attribute name="title" >
...@@ -245,7 +253,99 @@ ...@@ -245,7 +253,99 @@
</attribute> </attribute>
<layout class="QHBoxLayout" name="horizontalLayout_2" > <layout class="QHBoxLayout" name="horizontalLayout_2" >
<item> <item>
<widget class="QTreeWidget" name="keyTree" /> <widget class="QTreeWidget" name="keyTree" >
<column>
<property name="text" >
<string>1</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="Updates" >
<attribute name="title" >
<string>Updates</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5" >
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3" >
<item>
<layout class="QVBoxLayout" name="verticalLayout_3" >
<item>
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>URL for updates</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Username</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6" >
<property name="text" >
<string>Password</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4" >
<item>
<widget class="QLineEdit" name="updateURL" />
</item>
<item>
<widget class="QLineEdit" name="updateUser" />
</item>
<item>
<widget class="QLineEdit" name="updatePass" />
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4" >
<item>
<widget class="QPushButton" name="checkUpdateButton" >
<property name="text" >
<string>Check</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>242</height>
</size>
</property>
</spacer>
</item> </item>
</layout> </layout>
</widget> </widget>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment