summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorme_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac>2013-04-13 21:49:33 +0000
committerme_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac>2013-04-13 21:49:33 +0000
commitdca2bef4e32e631c2eabc387261b4be680016095 (patch)
treee86b72543d0738633abc94c5ef9607bb757422a6
parent5c2175f675751f63ffa47ffde156620cc6f77abd (diff)
downloadpica-pica-dca2bef4e32e631c2eabc387261b4be680016095.tar.gz
pica-pica-dca2bef4e32e631c2eabc387261b4be680016095.zip
notifications about protocol version incompatibility implemented
git-svn-id: svn://localhost/project_picapica/trunk@236 fb96df88-216d-11de-830c-f3023f12d8ac
-rwxr-xr-xPICA_client.c9
-rwxr-xr-xPICA_client.h5
-rw-r--r--pica-client/mainwindow.cpp11
-rw-r--r--pica-client/mainwindow.h1
-rw-r--r--pica-client/msguirouter.cpp8
-rw-r--r--pica-client/msguirouter.h1
-rw-r--r--pica-client/nodethread.cpp20
-rw-r--r--pica-client/nodethread.h2
-rw-r--r--pica-client/skynet.cpp1
-rw-r--r--pica-client/skynet.h1
10 files changed, 53 insertions, 6 deletions
diff --git a/PICA_client.c b/PICA_client.c
index 5456ae5..ef8c638 100755
--- a/PICA_client.c
+++ b/PICA_client.c
@@ -829,8 +829,13 @@ while (cid->init_resp_ok == 0);
if (cid->init_resp_ok != 1)
{
if (cid->init_resp_ok == -1)
- ret_err = PICA_ERRVERDIFFER;
-
+ {
+ if (cid->node_ver_major > PICA_PROTO_VER_HIGH ||
+ (cid->node_ver_major == PICA_PROTO_VER_HIGH && cid->node_ver_minor > PICA_PROTO_VER_LOW))
+ ret_err = PICA_ERRPROTONEW;
+ else
+ ret_err = PICA_ERRPROTOOLD;
+ }
goto error_ret_5;
}
diff --git a/PICA_client.h b/PICA_client.h
index f2913e8..d98a607 100755
--- a/PICA_client.h
+++ b/PICA_client.h
@@ -58,7 +58,7 @@ typedef unsigned __int16 uint16_t;
#define PICA_ERRSSL -3
#define PICA_ERRSOCK -4
#define PICA_ERRSERV -5
-#define PICA_ERRVERDIFFER -6
+//#define PICA_ERRVERDIFFER -6
#define PICA_ERRNOTFOUND -7
#define PICA_ERRNOPEERCERT -8
#define PICA_ERRINVPEERCERT -9
@@ -67,6 +67,9 @@ typedef unsigned __int16 uint16_t;
#define PICA_ERRMSGSIZE -12
#define PICA_ERRDNSRESOLVE -13
+#define PICA_ERRPROTOOLD -14
+#define PICA_ERRPROTONEW -15
+
//#define PICA_CHNMSGBUFLEN 104
#define PICA_CHANREADBUFSIZE 65536
diff --git a/pica-client/mainwindow.cpp b/pica-client/mainwindow.cpp
index 2df04db..40b2544 100644
--- a/pica-client/mainwindow.cpp
+++ b/pica-client/mainwindow.cpp
@@ -26,9 +26,9 @@ MainWindow::MainWindow(QWidget *parent) :
status->setMinimumHeight(36);
notifications->setMinimumHeight(48);
- layout->addWidget(notifications, 1, Qt::AlignTop);
- layout->addWidget(bt_showhide_notifications, 0, Qt::AlignRight);
layout->addWidget(contact_list, 8);
+ layout->addWidget(bt_showhide_notifications, 0, Qt::AlignRight);
+ layout->addWidget(notifications, 1, Qt::AlignBottom);
layout->addWidget(status,0,Qt::AlignBottom);
centralWidget()->setLayout(layout);
@@ -133,5 +133,12 @@ void MainWindow::showhide_click()
hide_notifications();
}
+void MainWindow::AddNotification(QString &text)
+{
+ notifications->addItem(text);
+ notifications->item(notifications->count() -1) ->setForeground(QBrush(QColor(230, 10, 10, 196)));
+ show_notifications();
+}
+
diff --git a/pica-client/mainwindow.h b/pica-client/mainwindow.h
index 552db9b..b324ec7 100644
--- a/pica-client/mainwindow.h
+++ b/pica-client/mainwindow.h
@@ -23,6 +23,7 @@ public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
+ void AddNotification(QString &text);
protected:
private:
diff --git a/pica-client/msguirouter.cpp b/pica-client/msguirouter.cpp
index d032bb1..9750d4d 100644
--- a/pica-client/msguirouter.cpp
+++ b/pica-client/msguirouter.cpp
@@ -1,6 +1,7 @@
#include "msguirouter.h"
#include "dialogs/forgedcertdialog.h"
#include "history.h"
+#include "mainwindow.h"
/*
@@ -20,6 +21,7 @@ MsgUIRouter::MsgUIRouter(QObject *parent) :
connect(skynet, SIGNAL(UnableToDeliver(quint32,QString)), this, SLOT(delivery_failed(quint32,QString)));
connect(skynet, SIGNAL(Delivered(quint32)), this, SLOT(delivered(quint32)));
connect(skynet, SIGNAL(CertificateForged(quint32,QString,QString)), this, SLOT(scary_cert_message(quint32,QString,QString)));
+ connect(skynet, SIGNAL(ErrMsgFromNode(QString)), this, SLOT(notification(QString)));
}
@@ -98,3 +100,9 @@ void MsgUIRouter::scary_cert_message(quint32 peer_id, QString received_cert, QSt
ForgedCertDialog fcd(peer_id, received_cert, stored_cert);
fcd.exec();
}
+
+void MsgUIRouter::notification(QString text)
+{
+ if (mainwindow)
+ mainwindow->AddNotification(text);
+}
diff --git a/pica-client/msguirouter.h b/pica-client/msguirouter.h
index 5988878..2ae0007 100644
--- a/pica-client/msguirouter.h
+++ b/pica-client/msguirouter.h
@@ -27,6 +27,7 @@ public slots:
void delivered(quint32 to);
void scary_cert_message(quint32 peer_id, QString received_cert, QString stored_cert);
+ void notification(QString text);
private:
QMap<quint32,ChatWindow*> chatwindows;
diff --git a/pica-client/nodethread.cpp b/pica-client/nodethread.cpp
index 1524cbd..aa41b04 100644
--- a/pica-client/nodethread.cpp
+++ b/pica-client/nodethread.cpp
@@ -1,5 +1,6 @@
#include "nodethread.h"
#include "mainwindow.h"
+#include "../PICA_proto.h"
QMutex NodeThread::finished_mutex;
@@ -64,6 +65,25 @@ void NodeThread::run()
exit = 1;
break;
+ case PICA_ERRPROTONEW:
+
+ emit ErrorMsg(QString("Node %1:%2 has newer protocol version. Please check if update for pica-client is available")
+ .arg(node_addr.address)
+ .arg(node_addr.port)
+ );
+ exit = 1;
+ break;
+
+ case PICA_ERRPROTOOLD:
+
+ emit ErrorMsg(QString("Node %1:%2 has older protocol. Disconnected.")
+ .arg(node_addr.address)
+ .arg(node_addr.port)
+ );
+
+ exit = 1;
+ break;
+
default:
exit = 1;
}
diff --git a/pica-client/nodethread.h b/pica-client/nodethread.h
index 1d17fda..79de4d0 100644
--- a/pica-client/nodethread.h
+++ b/pica-client/nodethread.h
@@ -32,7 +32,7 @@ private:
signals:
void NodeStatusChanged(QString addr, quint16 port, bool alive);
void ConnectedToNode(QString addr, quint16 port, NodeThread *thread);
-
+ void ErrorMsg(QString msg);
public slots:
};
diff --git a/pica-client/skynet.cpp b/pica-client/skynet.cpp
index 76b86a0..c86c22c 100644
--- a/pica-client/skynet.cpp
+++ b/pica-client/skynet.cpp
@@ -193,6 +193,7 @@ void SkyNet::Join(Accounts::AccountRecord &accrec)
connect(threads.last(), SIGNAL(finished()),this,SLOT(nodethread_finished()));
connect(threads.last(), SIGNAL(NodeStatusChanged(QString,quint16,bool)), this, SLOT(node_status_changed(QString,quint16,bool)));
connect(threads.last(), SIGNAL(ConnectedToNode(QString,quint16,NodeThread*)), this, SLOT(nodethread_connected(QString,quint16,NodeThread*)));
+ connect(threads.last(), SIGNAL(ErrorMsg(QString)), this, SIGNAL(ErrMsgFromNode(QString)));
}
}
diff --git a/pica-client/skynet.h b/pica-client/skynet.h
index 21d760c..4612e35 100644
--- a/pica-client/skynet.h
+++ b/pica-client/skynet.h
@@ -30,6 +30,7 @@ signals:
void LostSelfAwareness();
void PeerCertificateReceived(quint32 peer_id, QString cert_pem, bool *verified);
void CertificateForged(quint32 peer_id, QString received_cert, QString stored_cert);
+ void ErrMsgFromNode(QString msg);
private:
Nodes nodes;