Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
FMVip_Today
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhenfei.zhang
FMVip_Today
Commits
a07907aa
Commit
a07907aa
authored
Nov 10, 2016
by
NitefullWind
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 新增POS断开socket后关闭窗口并提示。 2. 修改几处log信息。
parent
ce30629e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
8 deletions
+50
-8
FMVip/fmvipdispatcher.cpp
+30
-3
FMVip/fmvipdispatcher.h
+9
-0
FMVip/fmvipforward.cpp
+3
-3
FMVip/fmvipwnd.cpp
+7
-1
FMVipDC/fmsockserver.cpp
+1
-1
No files found.
FMVip/fmvipdispatcher.cpp
View file @
a07907aa
...
...
@@ -17,12 +17,15 @@ FMVipDispatcher::FMVipDispatcher(QObject *parent)
_vindow
(
0
),
isLastOne
(
true
),
_windowReturn
(
0
),
_posSocket
(
new
QTcpSocket
(
this
)),
_sysIcon
(
new
QSystemTrayIcon
)
{
connect
(
this
,
SIGNAL
(
requested
(
QJsonObject
)),
SLOT
(
onRequest
(
QJsonObject
)));
connect
(
this
,
SIGNAL
(
responded
(
QByteArray
)),
SLOT
(
onResponse
(
QByteArray
)));
connect
(
FMVipForward
::
instance
(),
SIGNAL
(
serverResponsed
(
QJsonObject
)),
SLOT
(
onServerResponsed
(
QJsonObject
)));
connect
(
this
,
SIGNAL
(
initSocket
()),
this
,
SLOT
(
onInitSocket
()));
QIcon
icon
=
QIcon
(
":/img_logo.png"
);
_sysIcon
->
setIcon
(
icon
);
_sysIcon
->
setToolTip
(
"FMVIP"
);
...
...
@@ -46,6 +49,12 @@ FMVipDispatcher::~FMVipDispatcher()
delete
_sysIcon
;
_sysIcon
=
NULL
;
}
if
(
_posSocket
!=
nullptr
)
{
delete
_posSocket
;
_posSocket
=
nullptr
;
}
}
void
FMVipDispatcher
::
onQuit
()
...
...
@@ -65,7 +74,7 @@ void FMVipDispatcher::onActiveSysTrayIcon(QSystemTrayIcon::ActivationReason reas
INT
FMVipDispatcher
::
_ParseRequest
(
LPSTR
data
)
{
qDebug
()
<<
"
\n\n\n
POS发来的请求 ===>
\n
"
<<
data
;
qDebug
()
<<
"
POS发来的请求:
"
<<
data
;
QJsonParseError
err
;
QJsonDocument
json
=
QJsonDocument
::
fromJson
(
data
,
&
err
);
if
(
err
.
error
!=
QJsonParseError
::
NoError
)
{
...
...
@@ -89,6 +98,9 @@ INT FMVipDispatcher::_ParseRequest(LPSTR data)
BOOL
FMVipDispatcher
::
_GetResponse
(
LPSTR
&
rsp
,
UINT
&
len
)
{
mutex
.
lock
();
emit
initSocket
();
if
(
_serverRspData
.
isEmpty
())
{
// 服务器还未返回则一直阻塞
...
...
@@ -98,7 +110,7 @@ BOOL FMVipDispatcher::_GetResponse(LPSTR &rsp, UINT &len)
len
=
_serverRspData
.
length
();
mutex
.
unlock
();
qDebug
()
<<
"发给POS
===>
\n
"
<<
rsp
;
qDebug
()
<<
"发给POS
:
"
<<
rsp
;
return
1
;
}
...
...
@@ -221,7 +233,6 @@ void FMVipDispatcher::onServerResponsed(const QJsonObject &rspObj)
}
isLogin
=
false
;
_vindow
->
deleteLater
();
qDebug
()
<<
"delete..."
;
}
QJsonDocument
rspDoc
(
rspObj
);
...
...
@@ -322,3 +333,19 @@ BOOL FMVipDispatcher::isLogined()
QString
account
=
SESSIONDATA_STRING
(
"fm_open_id"
);
return
account
!=
""
;
}
void
FMVipDispatcher
::
onInitSocket
()
{
_posSocket
->
setSocketDescriptor
(
_socket
);
connect
(
_posSocket
,
SIGNAL
(
error
(
QAbstractSocket
::
SocketError
)),
this
,
SLOT
(
onDisconnected
()),
Qt
::
UniqueConnection
);
}
void
FMVipDispatcher
::
onDisconnected
()
{
if
(
_vindow
!=
0
)
{
_vindow
->
close
();
}
FMMsgWnd
::
FailureWnd
(
"操作时间过长,POS已断开Socket连接,请重新操作!"
);
serverIsBusy
.
wakeAll
();
}
FMVip/fmvipdispatcher.h
View file @
a07907aa
...
...
@@ -7,9 +7,11 @@
#include "fmapirelay.h"
#include <QMutex>
#include <QWaitCondition>
#include <QTcpSocket>
#define Err_WindowClose "{\"statusCode\":1001, \"prompt\":0, \"msg\":\"fmv:窗口异常关闭\"}"
#define Err_ErrorFMCMD "{\"statusCode\":1002, \"prompt\":1, \"msg\":\"fmv:无法识别的请求类型\"}"
#define Err_Disconnected "{\"statusCode\":1003, \"prompt\":0, \"msg\":\"fmv:已经POS断开Socket连接\"}"
#define _DEBUG
...
...
@@ -40,6 +42,8 @@ signals:
void
requested
(
const
QJsonObject
&
);
void
responded
(
const
QByteArray
&
);
void
initSocket
();
private
slots
:
void
onRequest
(
const
QJsonObject
&
jsonObj
);
void
onResponse
(
const
QByteArray
&
rsp
);
...
...
@@ -49,6 +53,9 @@ private slots:
void
onDoPost
();
void
onInitSocket
();
void
onDisconnected
();
void
onActiveSysTrayIcon
(
QSystemTrayIcon
::
ActivationReason
);
void
onQuit
();
...
...
@@ -61,6 +68,8 @@ private:
QSystemTrayIcon
*
_sysIcon
;
QTcpSocket
*
_posSocket
;
QMutex
mutex
;
QWaitCondition
serverIsBusy
;
BOOL
requestSuccess
;
...
...
FMVip/fmvipforward.cpp
View file @
a07907aa
...
...
@@ -100,8 +100,8 @@ void FMVipForward::request(const QJsonObject &reqJob)
}
}
qDebug
()
<<
"向服务器发送
===>
\n
"
<<
json
;
qDebug
()
<<
"请求签名
===>
\n
"
<<
signStr
;
qDebug
()
<<
"向服务器发送
:
"
<<
json
;
qDebug
()
<<
"请求签名
:
"
<<
signStr
;
// 设置请求头
_req
.
setHeader
(
QNetworkRequest
::
ContentTypeHeader
,
"application/json"
);
...
...
@@ -177,7 +177,7 @@ void FMVipForward::onServerFinished(QNetworkReply *reply, bool isTimeOut)
QJsonParseError
err
;
QJsonDocument
jdoc
=
QJsonDocument
::
fromJson
(
data
,
&
err
);
qDebug
()
<<
"服务器返回
===>
\n
"
<<
jdoc
;
qDebug
()
<<
"服务器返回
:
"
<<
jdoc
;
if
(
err
.
error
!=
QJsonParseError
::
NoError
||
!
jdoc
.
isObject
())
{
posObj
[
"statusCode"
]
=
1000
;
...
...
FMVip/fmvipwnd.cpp
View file @
a07907aa
...
...
@@ -50,6 +50,7 @@ bool FMVipWnd::setProfile(const QByteArray &d)
void
FMVipWnd
::
reject
()
{
qDebug
()
<<
"窗口关闭"
;
QDialog
::
reject
();
setResult
(
-
1
);
// 关闭时返回-1
deleteLater
();
...
...
@@ -72,11 +73,11 @@ void FMVipWnd::setIsBusy(const bool isBusy)
int
FMVipWnd
::
exec
()
{
qDebug
()
<<
"显示窗口"
;
showNormal
();
::
SetForegroundWindow
((
HWND
)
effectiveWinId
());
::
SetWindowPos
(
(
HWND
)
effectiveWinId
(),
HWND_TOPMOST
,
0
,
0
,
0
,
0
,
SWP_NOMOVE
|
SWP_NOSIZE
|
SWP_SHOWWINDOW
);
// ::SetWindowPos( (HWND)effectiveWinId(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
showNormal
();
::
SetForegroundWindow
((
HWND
)
effectiveWinId
());
...
...
@@ -138,6 +139,11 @@ bool FMVipWnd::nativeEvent(const QByteArray &eventType, void *message, long *res
fMsgDone
=
true
;
break
;
}
case
WA_INACTIVE
:
{
qDebug
()
<<
"窗口失去焦点"
;
activateWindow
();
break
;
}
default
:
break
;
...
...
FMVipDC/fmsockserver.cpp
View file @
a07907aa
...
...
@@ -211,8 +211,8 @@ void FMSockServer::RecvRoutine(DWORD err, DWORD bytes, LPWSAOVERLAPPED overlappe
if
(
io_data
->
relay
)
{
io_data
->
relay
->
Transfer
(
io_data
->
msg
,
response
,
len
);
}
if
(
response
)
{
FMLOG
(
_T
(
"Transfered %s"
),
response
);
send
(
io_data
->
socket
,
response
,
len
,
0
);
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment