change version checker to run on port 80

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@222 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
gsherman 2003-06-04 04:20:08 +00:00
parent 329f86c488
commit 549525e401
5 changed files with 146 additions and 8 deletions

View File

@ -26,6 +26,7 @@
#include <qscrollview.h>
#include <qstringlist.h>
#include <qmessagebox.h>
#include <qerrormessage.h>
#include <qstatusbar.h>
#include <qlabel.h>
#include <qfiledialog.h>
@ -61,7 +62,7 @@
#include "qgsdbsourceselect.h"
#include "qgsdatabaselayer.h"
#endif
#include "qgsmessageviewer.h"
#include "qgsshapefilelayer.h"
#include "qgslayerproperties.h"
#include "qgsabout.h"
@ -74,6 +75,7 @@
// version
static const char *qgisVersion = "0.0.11pre1 June 2, 2003";
static const int qgisVersionInt = 10;
// cursors
static unsigned char zoom_in_bits[] = {
0xf8, 0x00, 0x06, 0x03, 0x22, 0x02, 0x21, 0x04, 0x21, 0x04, 0xfd, 0x05,
@ -782,8 +784,12 @@ void QgisApp::restoreWindowState()
setGeometry(x, y, w, h);
}
void QgisApp::checkQgisVersion(){
QApplication::setOverrideCursor(Qt::WaitCursor);
/* QUrlOperator op = new QUrlOperator( "http://mrcc.com/qgis/version.txt" );
connect(op, SIGNAL(data()), SLOT(urlData()));
connect(op, SIGNAL(finished(QNetworkOperation)), SLOT(urlFinished(QNetworkOperation)));
op.get(); */
socket = new QSocket( this );
connect( socket, SIGNAL(connected()),
SLOT(socketConnected()) );
@ -793,22 +799,55 @@ void QgisApp::checkQgisVersion(){
SLOT(socketReadyRead()) );
connect( socket, SIGNAL(error(int)),
SLOT(socketError(int)) );
socket->connectToHost("mrcc.com", 4444);
socket->connectToHost("mrcc.com", 80);
}
void QgisApp::socketConnected(){
QTextStream os(socket);
versionMessage = "";
// send the qgis version string
os << qgisVersion << "\r\n";
// os << qgisVersion << "\r\n";
os << "GET /qgis/version.txt HTTP/1.0\n\n";
}
void QgisApp::socketConnectionClosed(){
// show version message from server
QMessageBox::information(this, "QGIS Version Information", versionMessage);
QApplication::restoreOverrideCursor();
// strip the header
QString contentFlag = "#QGIS Version";
int pos = versionMessage.find(contentFlag);
if(pos >-1){
pos += contentFlag.length();
/* std::cout << versionMessage << "\n ";
std::cout << "Pos is " << pos <<"\n"; */
versionMessage = versionMessage.mid(pos);
QStringList parts = QStringList::split("|",versionMessage);
// check the version from the server against our version
QString versionInfo;
int currentVersion = parts[0].toInt();
if(currentVersion > qgisVersionInt){
// show version message from server
versionInfo = "There is a new version of QGIS available\n";
}else{
versionInfo = "You are running the current version of QGIS\n";
}
if(parts.count() > 1){
versionInfo += parts[1] + "\n\nWould you like more information?";;
int result = QMessageBox::information(this,"QGIS Version Information", versionInfo, "Yes", "No");
if(result ==0){
// show more info
QgsMessageViewer *mv = new QgsMessageViewer(this);
mv->setMessage(parts[2]);
mv->exec();
}
}else{
QMessageBox::information(this, "QGIS Version Information", versionInfo);
}
}else{
QMessageBox::warning(this, "QGIS Version Information", "Unable to get current version information from server");
}
}
void QgisApp::socketError(int e){
QApplication::restoreOverrideCursor();
// get errror type
QString detail;
switch(e){

View File

@ -118,6 +118,7 @@ class QgisApp:public QgisAppBase
void socketConnectionClosed();
void socketReadyRead();
void socketError(int e);
/* void urlData(); */
private:
//! Popup menu
QPopupMenu * popMenu;

86
src/qgsmessageviewer.ui Normal file
View File

@ -0,0 +1,86 @@
<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
<class>QgsMessageViewer</class>
<widget class="QDialog">
<property name="name">
<cstring>QgsMessageViewer</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>499</width>
<height>283</height>
</rect>
</property>
<property name="caption">
<string>QGIS Message</string>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QTextEdit" row="0" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>txtMessage</cstring>
</property>
</widget>
<widget class="QPushButton" row="1" column="1">
<property name="name">
<cstring>btnClose</cstring>
</property>
<property name="text">
<string>Close</string>
</property>
</widget>
<spacer row="1" column="0">
<property name="name">
<cstring>spacer1</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>191</width>
<height>31</height>
</size>
</property>
</spacer>
<spacer row="1" column="2">
<property name="name">
<cstring>spacer1_2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>191</width>
<height>31</height>
</size>
</property>
</spacer>
</grid>
</widget>
<connections>
<connection>
<sender>btnClose</sender>
<signal>clicked()</signal>
<receiver>QgsMessageViewer</receiver>
<slot>reject()</slot>
</connection>
</connections>
<includes>
<include location="local" impldecl="in implementation">qgsmessageviewer.ui.h</include>
</includes>
<slots>
<slot>setMessage( QString msg )</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
</UI>

11
src/qgsmessageviewer.ui.h Normal file
View File

@ -0,0 +1,11 @@
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you wish to add, delete or rename functions or slots use
** Qt Designer which will update this file, preserving your code. Create an
** init() function in place of a constructor, and a destroy() function in
** place of a destructor.
*****************************************************************************/
void QgsMessageViewer::setMessage(QString msg){
txtMessage->setText(msg);
}

View File

@ -65,7 +65,8 @@ FORMS += qgisappbase.ui \
qgslayerpropertiesbase.ui \
qgsidentifyresultsbase.ui \
qgsattributetablebase.ui \
qgspluginmanagerbase.ui
qgspluginmanagerbase.ui \
qgsmessageviewer.ui
TEMPLATE = app
CONFIG += debug \
warn_on \