Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
colorEagleStdio
zoompipeline
提交
9bc41c98
zoompipeline
项目概览
colorEagleStdio
/
zoompipeline
通知
181
Star
12
Fork
4
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
zoompipeline
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9bc41c98
编写于
2月 26, 2014
作者:
丁劲犇
😸
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
finished 0x1003 msg, need test in future works
上级
748802aa
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
151 addition
and
47 deletion
+151
-47
ZoomPipeline_FuncSvr/smartlink/st_clientnode_app_imp.cpp
ZoomPipeline_FuncSvr/smartlink/st_clientnode_app_imp.cpp
+21
-41
ZoomPipeline_FuncSvr/smartlink/st_clientnode_applayer.cpp
ZoomPipeline_FuncSvr/smartlink/st_clientnode_applayer.cpp
+119
-2
ZoomPipeline_FuncSvr/smartlink/st_clientnode_applayer.h
ZoomPipeline_FuncSvr/smartlink/st_clientnode_applayer.h
+3
-0
ZoomPipeline_FuncSvr/smartlink/st_clientnode_basetrans.cpp
ZoomPipeline_FuncSvr/smartlink/st_clientnode_basetrans.cpp
+4
-4
ZoomPipeline_FuncSvr/smartlink/st_clientnode_basetrans.h
ZoomPipeline_FuncSvr/smartlink/st_clientnode_basetrans.h
+4
-0
未找到文件。
ZoomPipeline_FuncSvr/smartlink/st_clientnode_app_imp.cpp
浏览文件 @
9bc41c98
...
...
@@ -7,6 +7,7 @@
#include <QMutexLocker>
#include <QSettings>
#include <QSqlError>
#include <QSet>
namespace
SmartLink
{
//0x0001 msg, stMsg_HostRegistReq
bool
st_clientNodeAppLayer
::
RegisitNewBoxNode
()
...
...
@@ -200,7 +201,11 @@ bool st_clientNodeAppLayer::LoginBox()
m_bUUIDRecieved
=
true
;
m_uuid
=
ncurrid
;
m_pClientTable
->
regisitClientUUID
(
this
);
if
(
false
==
loadRelations
())
{
strcpy
(
reply
.
TextInfo
,
"Error, fail to load relations from db."
);
reply
.
DoneCode
=
3
;
}
}
else
strcpy
(
reply
.
TextInfo
,
"ID Not matched."
);
...
...
@@ -311,6 +316,11 @@ bool st_clientNodeAppLayer::LoginClient()
m_bUUIDRecieved
=
true
;
m_uuid
=
ncurrid
;
m_pClientTable
->
regisitClientUUID
(
this
);
if
(
false
==
loadRelations
())
{
strcpy
(
reply
.
TextInfo
,
"Error, fail to load relations from db."
);
reply
.
DoneCode
=
3
;
}
}
else
strcpy
(
reply
.
TextInfo
,
"UserID Is Invalid.Accunt locked by svr"
);
...
...
@@ -427,56 +437,26 @@ bool st_clientNodeAppLayer::Box2Svr_UploadUserTable()
stMsg_UploadUserListRsp
&
reply
=
pApp
->
MsgUnion
.
msg_UploadUserListRsp
;
reply
.
DoneCode
=
3
;
reply
.
DoneCode
=
1
;
strcpy
(
reply
.
TextInfo
,
"Unknown error"
);
//Check the database, find current equipment info
QSqlDatabase
db
=
m_pClientTable
->
dbRes
()
->
databse
(
m_pClientTable
->
Database_UserAcct
());
if
(
db
.
isValid
()
==
true
&&
db
.
isOpen
()
==
true
)
{
QSqlQuery
query
(
db
);
QString
sql
=
"select user_name,user_id,password from users where user_name = ? and password = ?;"
;
query
.
prepare
(
sql
);
// query.addBindValue(strUserName);
// query.addBindValue(strPasswd);
if
(
true
==
query
.
exec
())
{
if
(
query
.
next
())
{
bool
bOk
=
false
;
quint32
ncurrid
=
query
.
value
(
1
).
toUInt
(
&
bOk
);
if
(
bOk
==
true
)
if
(
loadRelations
()
==
true
)
{
if
(
ncurrid
>=
(
unsigned
int
)
0x80000000
&&
ncurrid
<=
(
unsigned
int
)
0xAFFFFFFF
)
for
(
quint32
i
=
0
;
i
<
pAppLayer
->
MsgUnion
.
msg_UploadUserListReq
.
UserNum
&&
i
<
4096
;
i
++
)
{
reply
.
TextInfo
[
0
]
=
0
;
reply
.
DoneCode
=
0
;
}
else
strcpy
(
reply
.
TextInfo
,
"UserID Is Invalid.Accunt locked by svr"
);
}
else
strcpy
(
reply
.
TextInfo
,
"UserID Is Invalid.Accunt locked by svr"
);
if
(
bIsValidUserId
(
pAppLayer
->
MsgUnion
.
msg_UploadUserListReq
.
pUserIDList
[
i
])
==
false
)
continue
;
m_matched_nodes
.
insert
(
pAppLayer
->
MsgUnion
.
msg_UploadUserListReq
.
pUserIDList
[
i
]);
}
else
if
(
true
==
saveRelations
())
{
// No such device
strcpy
(
reply
.
TextInfo
,
"No such user or password."
);
}
}
else
{
strcpy
(
reply
.
TextInfo
,
"Server Access Error."
);
emit
evt_Message
(
tr
(
"Database Access Error :"
)
+
query
.
lastError
().
text
());
reply
.
DoneCode
=
0
;
strcpy
(
reply
.
TextInfo
,
"Succeeded."
);
}
}
else
{
//Server db is currently not accessable, wait.
strcpy
(
reply
.
TextInfo
,
"
Server Not Accessable Now
."
);
strcpy
(
reply
.
TextInfo
,
"
Failed to load current relations from db
."
);
}
...
...
ZoomPipeline_FuncSvr/smartlink/st_clientnode_applayer.cpp
浏览文件 @
9bc41c98
#include "st_clientnode_applayer.h"
#include "st_client_table.h"
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
namespace
SmartLink
{
st_clientNodeAppLayer
::
st_clientNodeAppLayer
(
st_client_table
*
pClientTable
,
QObject
*
pClientSock
,
QObject
*
parent
)
:
st_clientNode_baseTrans
(
pClientTable
,
pClientSock
,
parent
)
...
...
@@ -12,6 +15,120 @@ st_clientNodeAppLayer::st_clientNodeAppLayer(st_client_table * pClientTable, QOb
}
bool
st_clientNodeAppLayer
::
loadRelations
()
{
QSqlDatabase
db
=
m_pClientTable
->
dbRes
()
->
databse
(
m_pClientTable
->
Database_UserAcct
());
if
(
db
.
isValid
()
==
true
&&
db
.
isOpen
()
==
true
)
{
QString
sql
=
"select "
;
if
(
m_serialNum
[
0
]
!=
0
)
sql
+=
"user_id from relations where equip_id = ?;"
;
else
if
(
m_username
[
0
]
!=
0
)
sql
+=
"equip_id from relations where user_id = ?;"
;
else
{
emit
evt_Message
(
tr
(
"try to save relations before login!"
));
return
false
;
}
QSqlQuery
query
(
db
);
query
.
prepare
(
sql
);
query
.
addBindValue
((
quint32
)
m_uuid
);
if
(
false
==
query
.
exec
())
{
emit
evt_Message
(
tr
(
"try to get relations Failed! "
)
+
query
.
lastError
().
text
());
return
false
;
}
m_matched_nodes
.
clear
();
while
(
query
.
next
())
{
quint32
val
=
query
.
value
(
0
).
toUInt
();
m_matched_nodes
.
insert
(
val
);
}
return
true
;
}
else
{
//Server db is currently not accessable, wait.
emit
evt_Message
(
"Server Not Accessable Now."
);
}
return
false
;
}
bool
st_clientNodeAppLayer
::
saveRelations
()
{
QSqlDatabase
db
=
m_pClientTable
->
dbRes
()
->
databse
(
m_pClientTable
->
Database_UserAcct
());
if
(
db
.
isValid
()
==
true
&&
db
.
isOpen
()
==
true
)
{
QString
sql
=
"delete from relations where "
;
if
(
m_serialNum
[
0
]
!=
0
)
{
QSqlQuery
query
(
db
);
sql
+=
"equip_id = ?;"
;
query
.
prepare
(
sql
);
query
.
addBindValue
((
quint32
)
m_uuid
);
if
(
false
==
query
.
exec
())
{
emit
evt_Message
(
tr
(
"try to del old relations Failed! "
)
+
query
.
lastError
().
text
());
return
false
;
}
}
else
if
(
m_username
[
0
]
!=
0
)
{
QSqlQuery
query
(
db
);
sql
+=
"user_id = ?;"
;
query
.
prepare
(
sql
);
query
.
addBindValue
((
quint32
)
m_uuid
);
if
(
false
==
query
.
exec
())
{
emit
evt_Message
(
tr
(
"try to del old relations Failed! "
)
+
query
.
lastError
().
text
());
return
false
;
}
}
else
{
emit
evt_Message
(
tr
(
"try to save relations before login!"
));
return
false
;
}
sql
=
"insert into relations (equip_id,user_id) values (?,?);"
;
//the forigen key can automatic avoid non-existing values.
foreach
(
quint32
nodeid
,
m_matched_nodes
)
{
QSqlQuery
query
(
db
);
if
(
m_serialNum
[
0
]
!=
0
)
{
if
(
bIsValidUserId
(
nodeid
)
==
false
)
continue
;
query
.
prepare
(
sql
);
query
.
addBindValue
((
quint32
)
m_uuid
);
query
.
addBindValue
(
nodeid
);
}
else
if
(
m_username
[
0
]
!=
0
)
{
if
(
bIsValidEquipId
(
nodeid
)
==
false
)
continue
;
query
.
prepare
(
sql
);
query
.
addBindValue
(
nodeid
);
query
.
addBindValue
((
quint32
)
m_uuid
);
}
if
(
false
==
query
.
exec
())
{
emit
evt_Message
(
tr
(
"try to insert new relations Failed! "
)
+
query
.
lastError
().
text
());
return
false
;
}
}
return
true
;
}
else
{
//Server db is currently not accessable, wait.
emit
evt_Message
(
"Server Not Accessable Now."
);
}
return
false
;
}
//!deal current message
int
st_clientNodeAppLayer
::
deal_current_message_block
()
...
...
@@ -32,7 +149,7 @@ int st_clientNodeAppLayer::deal_current_message_block()
}
else
{
if
(
m_currentHeader
.
source_id
>=
0x00010000
&&
m_currentHeader
.
source_id
<=
0x0FFFFFFF
)
if
(
bIsValidEquipId
(
m_currentHeader
.
source_id
)
)
{
//Deal Box->Svr Msgs
if
(
false
==
Deal_Box2Svr_Msgs
())
...
...
@@ -42,7 +159,7 @@ int st_clientNodeAppLayer::deal_current_message_block()
emit
evt_close_client
(
this
->
sock
());
}
}
else
if
(
m_currentHeader
.
source_id
>=
(
unsigned
int
)
0x80000000
&&
m_currentHeader
.
source_id
<=
(
unsigned
int
)
0xAFFFFFFF
)
else
if
(
bIsValidUserId
(
m_currentHeader
.
source_id
)
)
{
//Deal Client->Svr Msgs
}
...
...
ZoomPipeline_FuncSvr/smartlink/st_clientnode_applayer.h
浏览文件 @
9bc41c98
...
...
@@ -15,6 +15,9 @@ class st_clientNodeAppLayer : public st_clientNode_baseTrans
public:
explicit
st_clientNodeAppLayer
(
st_client_table
*
pClientTable
,
QObject
*
pClientSock
,
QObject
*
parent
=
0
);
protected:
bool
loadRelations
();
bool
saveRelations
();
//!in App-Layer, it Split the messages into dealers.
int
deal_current_message_block
();
//!Message Dealers, imp in st_clientnode_msgdeal.cpp
...
...
ZoomPipeline_FuncSvr/smartlink/st_clientnode_basetrans.cpp
浏览文件 @
9bc41c98
...
...
@@ -193,14 +193,14 @@ int st_clientNode_baseTrans::deal_current_message_block()
//First, get uuid as soon as possible
if
(
m_bUUIDRecieved
==
false
)
{
if
(
m_currentHeader
.
source_id
>=
0x00010000
&&
m_currentHeader
.
source_id
<=
0x0FFFFFFF
)
if
(
bIsValidEquipId
(
m_currentHeader
.
source_id
)
)
{
m_bUUIDRecieved
=
true
;
m_uuid
=
m_currentHeader
.
source_id
;
//regisit client node to hash-table;
m_pClientTable
->
regisitClientUUID
(
this
);
}
else
if
(
m_currentHeader
.
source_id
>=
(
unsigned
int
)
0x80000000
&&
m_currentHeader
.
source_id
<=
(
unsigned
int
)
0xAFFFFFFF
)
else
if
(
bIsValidUserId
(
m_currentHeader
.
source_id
)
)
{
m_bUUIDRecieved
=
true
;
m_uuid
=
m_currentHeader
.
source_id
;
...
...
@@ -220,9 +220,9 @@ int st_clientNode_baseTrans::deal_current_message_block()
}
else
{
if
(
!
(
(
m_currentHeader
.
source_id
>=
0x00010000
&&
m_currentHeader
.
source_id
<=
0x0FFFFFFF
)
if
(
!
(
bIsValidEquipId
(
m_currentHeader
.
source_id
)
||
(
m_currentHeader
.
source_id
>=
(
unsigned
int
)
0x80000000
&&
m_currentHeader
.
source_id
<=
(
unsigned
int
)
0xAFFFFFFF
)
bIsValidUserId
(
m_currentHeader
.
source_id
)
||
(
m_currentHeader
.
source_id
==
0xffffffff
)
))
...
...
ZoomPipeline_FuncSvr/smartlink/st_clientnode_basetrans.h
浏览文件 @
9bc41c98
...
...
@@ -47,6 +47,10 @@ protected:
//!in Trans-Layer, it does nothing.
virtual
int
deal_current_message_block
();
//judge whether id is valid.
bool
bIsValidEquipId
(
quint32
id
){
return
id
>=
0x00010000
&&
id
<=
0x0FFFFFFF
;}
bool
bIsValidUserId
(
quint32
id
){
return
id
>=
(
unsigned
int
)
0x80000000
&&
id
<=
(
unsigned
int
)
0xAFFFFFFF
;}
protected:
//The current Read Offset, from m_list_RawData's beginning
int
m_currentReadOffset
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录