summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2014-05-03 21:05:34 +0800
committerIru Cai <mytbk920423@gmail.com>2014-05-03 21:05:34 +0800
commit3967964a84440f9b208e5d42beb6b9fc841da7d6 (patch)
tree6363cf78dd359824a7f85aee869d5858895107e3
parentad5f034e13797f1846d3f967e6db0f6137e1f1f3 (diff)
downloadfqterm-3967964a84440f9b208e5d42beb6b9fc841da7d6.tar.xz
code cleaning: disable autoupdate
-rw-r--r--src/fqterm/fqterm_autoupdate.cpp178
-rw-r--r--src/fqterm/fqterm_autoupdate.h61
-rw-r--r--src/fqterm/fqterm_frame.cpp13
3 files changed, 1 insertions, 251 deletions
diff --git a/src/fqterm/fqterm_autoupdate.cpp b/src/fqterm/fqterm_autoupdate.cpp
deleted file mode 100644
index 0f49c38..0000000
--- a/src/fqterm/fqterm_autoupdate.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-/***************************************************************************
- * fqterm, a terminal emulator for both BBS and *nix. *
- * Copyright (C) 2008 fqterm development group. *
- * *
- * 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 program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. *
- ***************************************************************************/
-
-#include "fqterm_autoupdate.h"
-#include "fqterm_config.h"
-#include "fqterm_trace.h"
-#include "fqterm_param.h"
-
-#include <QDesktopServices>
-#include <QFile>
-#include <QHttp>
-#include <QMessageBox>
-#include <QString>
-#include <QUrl>
-
-namespace FQTerm {
-
-////////////////////////////////////////////////
-static int versionCompare(QString lhs, QString rhs) {
- //0 -- lhs == rhs, -1 -- lhs > rhs, 1 -- lhs < rhs
-
- int versionEnd = lhs.indexOf('-');
- if (versionEnd != -1) {
- lhs = lhs.mid(0, versionEnd);
- }
- versionEnd = rhs.indexOf('-');
- if (versionEnd != -1) {
- rhs = rhs.mid(0, versionEnd);
- }
- QStringList lhsList = lhs.split(".");
- QStringList rhsList = rhs.split(".");
- if (lhsList.size() != 3 || rhsList.size() != 3) {
- return 0; //something is wrong
- }
- for (int i = 0; i < 3; ++i) {
- if (lhsList[i].toInt() < rhsList[i].toInt()) {
- return 1;
- }
- else if (lhsList[i].toInt() > rhsList[i].toInt()) {
- return -1;
- }
- }
- return 0;
-}
-///////////////////////////////////////////////
-
-void FQTermAutoUpdater::checkUpdate() {
- QString fileName = FQTermPref::getInstance()->poolDir_ + "VersionInfo";
- if (QFile::exists(fileName)) {
- QFile::remove(fileName);
- }
- versionInfoFile_ = new QFile(fileName, this);
- if (!versionInfoFile_->open(QIODevice::WriteOnly)) {
- delete versionInfoFile_;
- return;
- }
- FQ_VERIFY(connect(updateChecker_, SIGNAL(requestFinished(int, bool)),
- this, SLOT(checkRequestFinished(int, bool))));
- FQ_VERIFY(connect(updateChecker_, SIGNAL(done(bool)),
- this, SLOT(httpDone(bool))));
-
- const QString versionInfoURL = "http://fqterm.googlecode.com/svn/trunk/VersionInfo";
- QUrl url(versionInfoURL);
- QHttp::ConnectionMode mode = url.scheme().toLower() == "https" ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp;
- updateChecker_->setHost(url.host(), mode, url.port() == -1 ? 0 : url.port());
- if (!url.userName().isEmpty())
- updateChecker_->setUser(url.userName(), url.password());
- checkRequestId_ = updateChecker_->get(url.path(), versionInfoFile_);
-}
-
-QString FQTermAutoUpdater::getNewestVersion() {
-#if defined(WIN32)
- const QString platform = "FQWin";
-#elif defined(__unix__) && !defined(__APPLE__)
- const QString platform = "FQLinux";
-#else
- const QString platform = "FQMac";
-#endif
- FQTermConfig versionInfo(FQTermPref::getInstance()->poolDir_ + "VersionInfo");
- QString ver = versionInfo.getItemValue(platform, "version");
- if (ver.isEmpty()) {
- return FQTERM_VERSION_STRING;
- }
- return ver;
-}
-
-void FQTermAutoUpdater::promptUpdate() {
- const QString updateURL = "http://code.google.com/p/fqterm/downloads/list";
- QMessageBox msgBox(QMessageBox::Information, tr("FQTerm Update Notifier"),
- tr("FQTerm update available.\nPress OK to visit our download list,\nDiscard for a future prompt,\nIgnore for no more notification."),
- QMessageBox::Ok | QMessageBox::Discard | QMessageBox::Ignore);
- switch (msgBox.exec()) {
- case QMessageBox::Ok:
- QDesktopServices::openUrl(updateURL);
- break;
- case QMessageBox::Discard:
- break;
- case QMessageBox::Ignore:
- config_->setItemValue("global", "newestversion", getNewestVersion());
- config_->setItemValue("global", "updateprompt", "0");
- break;
- }
-}
-
-void FQTermAutoUpdater::checkRequestFinished(int requestId, bool error){
-
- if (checkDone_ || requestId != checkRequestId_) {
- return;
- }
- if (!error) {
- checkDone_ = true;
- }
-}
-
-void FQTermAutoUpdater::httpDone(bool err) {
- if (!err) {
- versionInfoFile_->flush();
- if (checkDone_) {
- QString newestVersionRecorded = config_->getItemValue("global", "newestversion");
- if (newestVersionRecorded.isEmpty()) {
- newestVersionRecorded = FQTERM_VERSION_STRING;
- config_->setItemValue("global", "newestversion", newestVersionRecorded);
- }
- QString newestVersionReleased = getNewestVersion();
-
- QString updatePrompt = config_->getItemValue("global", "updateprompt");
- if (updatePrompt == "0") {
- //if newest version > recorded version, still prompt.
- if (versionCompare(newestVersionRecorded, newestVersionReleased) > 0) {
- config_->setItemValue("global", "updateprompt", "1");
- promptUpdate();
- }
- }
- else {
- config_->setItemValue("global", "updateprompt", "1");
- //if newest version > version in use, prompt.
- if (versionCompare(FQTERM_VERSION_STRING, newestVersionReleased) > 0) {
- promptUpdate();
- }
- }
- }
- }
- deleteLater();
-}
-
-FQTermAutoUpdater::FQTermAutoUpdater(QObject* parent, FQTermConfig* config)
-: QObject(parent),
- config_(config),
- versionInfoFile_(0),
- checkDone_(false) {
- updateChecker_ = new QHttp(this);
-}
-
-FQTermAutoUpdater::~FQTermAutoUpdater()
-{
-
-}
-
-} //FQTerm namespace
-
-#include "fqterm_autoupdate.moc"
diff --git a/src/fqterm/fqterm_autoupdate.h b/src/fqterm/fqterm_autoupdate.h
deleted file mode 100644
index 0ad8aaf..0000000
--- a/src/fqterm/fqterm_autoupdate.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/***************************************************************************
- * fqterm, a terminal emulator for both BBS and *nix. *
- * Copyright (C) 2008 fqterm development group. *
- * *
- * 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 program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. *
- ***************************************************************************/
-
-#ifndef FQTERM_AUTO_UPDATE_H
-#define FQTERM_AUTO_UPDATE_H
-
-#include <QObject>
-
-class QHttp;
-class QFile;
-class QString;
-
-namespace FQTerm {
-
-class FQTermConfig;
-
-class FQTermAutoUpdater : public QObject{
-
- Q_OBJECT;
-
-public:
- FQTermAutoUpdater(QObject* parent, FQTermConfig* config);
- ~FQTermAutoUpdater();
-
- void checkUpdate();
-
-protected slots:
- void checkRequestFinished(int requestId, bool error);
- void httpDone(bool err);
-
-private:
- QString getNewestVersion();
- void promptUpdate();
-
- FQTermConfig* config_;
- QHttp * updateChecker_;
- QFile * versionInfoFile_;
- int checkRequestId_;
- bool checkDone_;
-};
-
-} //namespace FQTerm
-
-#endif
diff --git a/src/fqterm/fqterm_frame.cpp b/src/fqterm/fqterm_frame.cpp
index 1a9899b..99bb61c 100644
--- a/src/fqterm/fqterm_frame.cpp
+++ b/src/fqterm/fqterm_frame.cpp
@@ -44,7 +44,6 @@
#include <QStatusBar>
#include <QStyleFactory>
#include <QTime>
-#include <QDate>
#include <QSizePolicy>
#include <QTimer>
#include <QToolBar>
@@ -59,7 +58,6 @@
#include "fqterm.h"
#include "fqterm_path.h"
-//#include "fqterm_autoupdate.h"
#include "fqterm_config.h"
#include "fqterm_frame.h"
#include "fqterm_param.h"
@@ -181,16 +179,7 @@ FQTermFrame::FQTermFrame()
statusBar()->addWidget(statusBar_, 0);
installEventFilter(this);
-/*
- QDate lastCheckDate = QDate::fromString(config_->getItemValue("global", "lastcheckupdate"));
- QDate currentDate = QDate::currentDate();
- if (!lastCheckDate.isValid() || lastCheckDate.daysTo(currentDate) >= 31) {
- FQTermAutoUpdater* autoUpdater =
- new FQTermAutoUpdater(this, config_);
- autoUpdater->checkUpdate();
- config_->setItemValue("global", "lastcheckupdate", currentDate.toString());
- }
-*/
+
serverThread_ = new FQTermMiniServerThread();
if (FQTermPref::getInstance()->runServer_)
serverThread_->start();