提交 fb0b744f 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

Add an sample db. we will build it in postgresql, while using sqlite for debug.

上级 12439d47
Using FireFox Sqlite Manager Add-in to modify this db.
\ No newline at end of file
......@@ -4,6 +4,7 @@
#include "../ZoomPipeline_FuncSvr/smartlink/st_msg_applayer.h"
#include <QSettings>
#include <time.h>
#include <QMessageBox>
using namespace SmartLink;
MainDialog::MainDialog(QWidget *parent) :
QDialog(parent),
......@@ -159,6 +160,43 @@ void MainDialog::on_pushButton_regisit_clicked()
//3/10 possibility to send a data block to server
client->SendData(array);
}
void MainDialog::on_pushButton_Login_clicked()
{
saveIni();
quint16 nMsgLen = sizeof(SMARTLINK_MSG_APP::tag_app_layer_header)
+sizeof(stMsg_HostLogonReq);
QByteArray array(sizeof(SMARTLINK_MSG) + nMsgLen - 1,0);
char * ptr = array.data();
SMARTLINK_MSG * pMsg = (SMARTLINK_MSG *)ptr;
SMARTLINK_MSG_APP * pApp = (SMARTLINK_MSG_APP *)(((unsigned char *)
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = 1;
pMsg->SerialNum = 0;
pMsg->Priority = 1;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(0xffffffff) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(0x00000001) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = 0x01;
pApp->header.MsgType = 0x1001;
pApp->header.MsgFmtVersion = 0x01;
QString strSerial = ui->plainTextEdit_boxSerialNum->toPlainText();
memcpy ( pApp->MsgUnion.msg_HostLogonReq.HostSerialNum,
strSerial.toStdString().c_str(),64);
pApp->MsgUnion.msg_HostLogonReq.ID = ui->lineEdit_boxid->text().toUInt();
//3/10 possibility to send a data block to server
client->SendData(array);
}
//!deal one message, affect m_currentRedOffset,m_currentMessageSize,m_currentHeader
//!return bytes Used.
int MainDialog::filter_message(const QByteArray & block, int offset)
......@@ -299,6 +337,17 @@ int MainDialog::deal_current_message_block()
.arg(pApp->MsgUnion.msg_HostRegistRsp.TextInfo)
);
}
else if (pApp->header.MsgType==0x1801)
{
if (pApp->MsgUnion.msg_HostLogonRsp.DoneCode==0)
QMessageBox::information(this,tr("Succeed!"),tr("Log in succeed!"));
else
QMessageBox::information(this,tr("Failed!"),tr("Log in Failed!"));
displayMessage(tr("Res = %1, Text = %2")
.arg(pApp->MsgUnion.msg_HostLogonRsp.DoneCode)
.arg(pApp->MsgUnion.msg_HostLogonRsp.TextInfo)
);
}
m_currentBlock = QByteArray();
......
......@@ -58,6 +58,7 @@ public slots:
void on_pushButton_connect_clicked();
void on_pushButton_regisit_clicked();
void on_pushButton_Login_clicked();
};
#endif // MAINDIALOG_H
......@@ -138,6 +138,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_Login">
<property name="text">
<string>Log in</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
......
......@@ -11,6 +11,7 @@ st_clientNode::st_clientNode(st_client_table * pClientTable, QObject * pClientSo
m_uuid = 0xffffffff;//Not Valid
m_pClientTable = pClientTable;
bTermSet = false;
m_bLoggedIn= false;
m_last_Report = QDateTime::currentDateTime();
memset(&m_current_app_header,0,sizeof(SMARTLINK_MSG_APP));
}
......@@ -150,6 +151,7 @@ int st_clientNode::filter_message(const QByteArray & block, int offset)
//This Message is Over. Start a new one.
m_currentMessageSize = 0;
m_currentBlock = QByteArray();
m_current_app_header.header.MsgType = 0x00;
continue;
}
}
......@@ -172,6 +174,7 @@ int st_clientNode::filter_message(const QByteArray & block, int offset)
//This Message is Over. Start a new one.
m_currentMessageSize = 0;
m_currentBlock = QByteArray();
m_current_app_header.header.MsgType = 0x00;
continue;
}
} // end if there is more bytes to append
......@@ -182,6 +185,7 @@ int st_clientNode::filter_message(const QByteArray & block, int offset)
.arg((int)(ptrCurrData[0])).arg((int)(ptrCurrData[1])));
m_currentMessageSize = 0;
m_currentBlock = QByteArray();
m_current_app_header.header.MsgType = 0x00;
offset = blocklen;
emit evt_close_client(this->sock());
......@@ -218,6 +222,7 @@ int st_clientNode::deal_current_message_block()
{
emit evt_Message(tr("Client ID is invalid! Close client immediatly."));
m_currentBlock = QByteArray();
m_current_app_header.header.MsgType = 0x00;
emit evt_close_client(this->sock());
return 0;
}
......@@ -243,6 +248,7 @@ int st_clientNode::deal_current_message_block()
//Do Nothing
emit evt_Message(tr("Broadcast Message is not currently supported."));
m_currentBlock = QByteArray();
m_current_app_header.header.MsgType = 0x00;
}
else if (m_currentHeader.destin_id==0xFFFFFFFD)
......@@ -251,6 +257,7 @@ int st_clientNode::deal_current_message_block()
//Do Nothing
emit evt_Message(tr("Broadcast Message is not currently supported."));
m_currentBlock = QByteArray();
m_current_app_header.header.MsgType = 0x00;
}
else
......@@ -270,6 +277,7 @@ int st_clientNode::deal_current_message_block()
{
emit evt_SendDataToClient(destin_node->sock(),m_currentBlock);
m_currentBlock = QByteArray();
m_current_app_header.header.MsgType = 0x00;
}
}
......
......@@ -80,6 +80,9 @@ protected:
QDateTime m_last_Report;
//log in
bool m_bLoggedIn;
signals:
void evt_SendDataToClient(QObject * objClient,const QByteArray & dtarray);
void evt_BroadcastData(QObject * objFromClient,const QByteArray & dtarray);
......
......@@ -73,6 +73,9 @@ bool st_clientNode::RegisitNewNode()
{
reply.ID = ncurrid;
reply.DoneCode = 1;
m_bUUIDRecieved = true;
m_uuid = ncurrid;
m_pClientTable->regisitClientUUID(this);
strcpy(reply.TextInfo,"Re-regisit Succeed.");
}
else
......@@ -82,6 +85,9 @@ bool st_clientNode::RegisitNewNode()
{
reply.DoneCode = 0;
strcpy(reply.TextInfo,"First-regisit Succeed.");
m_bUUIDRecieved = true;
m_uuid = reply.ID;
m_pClientTable->regisitClientUUID(this);
}
else
strcpy(reply.TextInfo,"Equip ID resource error.");
......@@ -205,6 +211,10 @@ bool st_clientNode::LoginSvr()
{
reply.TextInfo[0] = 0;
reply.DoneCode = 0;
m_bUUIDRecieved = true;
m_uuid = ncurrid;
m_pClientTable->regisitClientUUID(this);
}
else
strcpy(reply.TextInfo,"ID Not matched.");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册