mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
Version checker
git-svn-id: http://svn.osgeo.org/qgis/trunk@218 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
ce18faad72
commit
a1d6fdf1ad
@ -53,7 +53,7 @@
|
||||
</kdevdebugger>
|
||||
<kdevtrollproject>
|
||||
<general>
|
||||
<activedir>/src</activedir>
|
||||
<activedir></activedir>
|
||||
</general>
|
||||
<run>
|
||||
<mainprogram>./src/qgis</mainprogram>
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include <qlistview.h>
|
||||
#include <qsettings.h>
|
||||
#include <qtextstream.h>
|
||||
|
||||
#include <qsocket.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
@ -780,3 +780,59 @@ void QgisApp::restoreWindowState()
|
||||
int y = settings.readNumEntry("/qgis/Geometry/y", (dh - 400) / 2);
|
||||
setGeometry(x, y, w, h);
|
||||
}
|
||||
void QgisApp::checkQgisVersion(){
|
||||
|
||||
|
||||
socket = new QSocket( this );
|
||||
connect( socket, SIGNAL(connected()),
|
||||
SLOT(socketConnected()) );
|
||||
connect( socket, SIGNAL(connectionClosed()),
|
||||
SLOT(socketConnectionClosed()) );
|
||||
connect( socket, SIGNAL(readyRead()),
|
||||
SLOT(socketReadyRead()) );
|
||||
connect( socket, SIGNAL(error(int)),
|
||||
SLOT(socketError(int)) );
|
||||
socket->connectToHost("mrcc.com", 4444);
|
||||
}
|
||||
|
||||
void QgisApp::socketConnected(){
|
||||
QTextStream os(socket);
|
||||
versionMessage = "";
|
||||
// send the qgis version string
|
||||
os << qgisVersion << "\r\n";
|
||||
|
||||
|
||||
}
|
||||
void QgisApp::socketConnectionClosed(){
|
||||
// show version message from server
|
||||
QMessageBox::information(this, "QGIS Version Information", versionMessage);
|
||||
}
|
||||
void QgisApp::socketError(int e){
|
||||
// get errror type
|
||||
QString detail;
|
||||
switch(e){
|
||||
case QSocket::ErrConnectionRefused:
|
||||
detail = "Connection refused - server may be down";
|
||||
break;
|
||||
case QSocket::ErrHostNotFound:
|
||||
detail = "QGIS server was not found";
|
||||
break;
|
||||
case QSocket::ErrSocketRead:
|
||||
detail = "Error reading from server";
|
||||
break;
|
||||
}
|
||||
// show version message from server
|
||||
QMessageBox::critical(this, "QGIS Version Information", "Unable to connect to the QGIS Version server\n" + detail);
|
||||
}
|
||||
|
||||
void QgisApp::socketReadyRead()
|
||||
{
|
||||
while(socket->bytesAvailable() > 0){
|
||||
char *data = new char[socket->bytesAvailable() +1];
|
||||
memset(data, '\0', socket->bytesAvailable() +1);
|
||||
socket->readBlock(data, socket->bytesAvailable());
|
||||
versionMessage += data;
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
}
|
@ -29,6 +29,7 @@ class QCursor;
|
||||
class QListView;
|
||||
class QListViewItem;
|
||||
class QgsMapLayer;
|
||||
class QSocket;
|
||||
#include "qgisappbase.h"
|
||||
#include "qgisiface.h"
|
||||
class QgsMapCanvas;
|
||||
@ -111,6 +112,12 @@ class QgisApp:public QgisAppBase
|
||||
void fileOpen();
|
||||
//! Create a new project
|
||||
void fileNew();
|
||||
//! Check qgis version against the qgis version server
|
||||
void checkQgisVersion();
|
||||
void socketConnected();
|
||||
void socketConnectionClosed();
|
||||
void socketReadyRead();
|
||||
void socketError(int e);
|
||||
private:
|
||||
//! Popup menu
|
||||
QPopupMenu * popMenu;
|
||||
@ -132,6 +139,8 @@ class QgisApp:public QgisAppBase
|
||||
//! full path name of the current map file (if it has been saved or loaded)
|
||||
QString fullPath;
|
||||
QgisIface *qgisInterface;
|
||||
QSocket *socket;
|
||||
QString versionMessage;
|
||||
friend class QgisIface;
|
||||
};
|
||||
|
||||
|
@ -74,6 +74,7 @@
|
||||
<action name="actionAddLayer"/>
|
||||
</item>
|
||||
<item text="&Tools" name="PopupMenu_4">
|
||||
<action name="actionCheckQgisVersion"/>
|
||||
<action name="actionPluginManager"/>
|
||||
<action name="actionTestPlugin"/>
|
||||
<action name="actionOptions"/>
|
||||
@ -393,6 +394,14 @@
|
||||
<string>Plugin Manager</string>
|
||||
</property>
|
||||
</action>
|
||||
<action>
|
||||
<property name="name">
|
||||
<cstring>actionCheckQgisVersion</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Check QGIS Version</string>
|
||||
</property>
|
||||
</action>
|
||||
</actions>
|
||||
<images>
|
||||
<image name="image0">
|
||||
@ -562,6 +571,12 @@
|
||||
<receiver>QgisAppBase</receiver>
|
||||
<slot>actionPluginManager_activated()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>actionCheckQgisVersion</sender>
|
||||
<signal>activated()</signal>
|
||||
<receiver>QgisAppBase</receiver>
|
||||
<slot>checkQgisVersion()</slot>
|
||||
</connection>
|
||||
</connections>
|
||||
<includes>
|
||||
<include location="local" impldecl="in implementation">qgisappbase.ui.h</include>
|
||||
@ -589,6 +604,7 @@
|
||||
<slot>fileSaveAs()</slot>
|
||||
<slot>fileNew()</slot>
|
||||
<slot>actionPluginManager_activated()</slot>
|
||||
<slot>checkQgisVersion()</slot>
|
||||
</slots>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
</UI>
|
||||
|
@ -134,3 +134,9 @@ void QgisAppBase::actionPluginManager_activated()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void QgisAppBase::checkQgisVersion()
|
||||
{
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user