Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fmp_home
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
fmp_home
Commits
4ab00faf
Commit
4ab00faf
authored
Jun 16, 2017
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
花之林对接
parent
06108fca
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
108 additions
and
5 deletions
+108
-5
fmp_he_handlers.cpp
+17
-0
fmp_he_handlers.h
+7
-0
fmp_home.cpp
+7
-0
fmp_home.h
+1
-0
fmp_home.pro
+1
-0
fmp_home_navwindow.cpp
+34
-2
fmp_home_navwindow.h
+12
-0
fmp_home_p.cpp
+23
-2
fmp_home_p.h
+5
-0
version.h
+1
-1
No files found.
fmp_he_handlers.cpp
View file @
4ab00faf
...
...
@@ -51,3 +51,20 @@ void FMPUpgradeAckEventHandler::handleEvent(const ctkEvent &event)
}
}
FMPPayResultEventHandler
::
FMPPayResultEventHandler
(
ctkPluginContext
*
ctx
,
FMPHome
*
home
)
:
FMPHomeEventHandler
(
"payResult"
,
home
,
ctx
)
{
}
void
FMPPayResultEventHandler
::
handleEvent
(
const
ctkEvent
&
event
)
{
if
(
_home
)
{
QString
ack_topic
=
event
.
getTopic
();
//! com/fmp/services/REQ_START/id
QVariant
var
=
event
.
getProperty
(
"pay_result"
);
qDebug
()
<<
"json:"
<<
var
.
toByteArray
();
_home
->
payReturn
(
var
.
toByteArray
());
}
}
fmp_he_handlers.h
View file @
4ab00faf
...
...
@@ -34,4 +34,11 @@ public:
void
handleEvent
(
const
ctkEvent
&
event
);
};
class
FMPPayResultEventHandler
:
FMPHomeEventHandler
{
public
:
explicit
FMPPayResultEventHandler
(
ctkPluginContext
*
ctx
,
FMPHome
*
home
);
void
handleEvent
(
const
ctkEvent
&
event
);
};
#endif // FMP_MANAGER_EVENT_HANDLERS_H
fmp_home.cpp
View file @
4ab00faf
...
...
@@ -79,3 +79,10 @@ void FMPHome::notification(const QString &msg, const QString &title,
return
d
->
notification
(
msg
,
title
,
icon
,
mecs
);
}
void
FMPHome
::
payReturn
(
const
QByteArray
&
json
)
{
Q_D
(
FMPHome
);
//d->onPayDataReturn(json);
emit
d
->
dataReturn
(
json
);
}
fmp_home.h
View file @
4ab00faf
...
...
@@ -30,6 +30,7 @@ public:
bool
stopBlink
(
FMPluginInterface
*
ctkPlugin
);
void
notification
(
const
QString
&
msg
,
const
QString
&
title
=
QString
::
fromLocal8Bit
(
FMP_APPNAME
),
QSystemTrayIcon
::
MessageIcon
icon
=
QSystemTrayIcon
::
Information
,
int
mecs
=
1000
);
void
payReturn
(
const
QByteArray
&
json
);
protected
slots
:
virtual
void
InitService
();
...
...
fmp_home.pro
View file @
4ab00faf
...
...
@@ -8,6 +8,7 @@ TEMPLATE = lib
QT
+=
core
gui
network
concurrent
greaterThan
(
QT_MAJOR_VERSION
,
4
)
:
QT
+=
widgets
QT
+=
network
CONFIG
+=
c
++
11
...
...
fmp_home_navwindow.cpp
View file @
4ab00faf
...
...
@@ -28,11 +28,11 @@ NavWindow::NavWindow(QWidget *parent) :
connect
(
this
,
SIGNAL
(
startBlink
()),
ui
->
navMainBtn
,
SLOT
(
start
()));
connect
(
this
,
SIGNAL
(
stopBlink
()),
ui
->
navMainBtn
,
SLOT
(
stop
()));
btns
.
push_back
(
std
::
make_pair
(
"payment"
,
QString
::
fromLocal8Bit
(
"非码支付"
)));
//
btns.push_back(std::make_pair("payment", QString::fromLocal8Bit("非码支付")));
// btns.push_back(std::make_pair("vip", QString::fromLocal8Bit("非码会员")));
btns
.
push_back
(
std
::
make_pair
(
"takeout"
,
QString
::
fromLocal8Bit
(
"非码外卖"
)));
// btns.push_back(std::make_pair("coupons", QString::fromLocal8Bit("码多多")));
btns
.
push_back
(
std
::
make_pair
(
"tool"
,
QString
::
fromLocal8Bit
(
"设置"
)));
//
btns.push_back(std::make_pair("tool", QString::fromLocal8Bit("设置")));
MenuUiProp
.
distance
=
100
;
MenuUiProp
.
beginAngle
=
-
(
PI
/
2
);
...
...
@@ -51,6 +51,13 @@ NavWindow::NavWindow(QWidget *parent) :
connect
(
ui
->
navMainBtn
,
SIGNAL
(
moved
(
QPoint
)),
this
,
SLOT
(
onMoved
(
QPoint
)));
connect
(
this
,
SIGNAL
(
navImageChanged
()),
this
,
SLOT
(
onNavImageChanged
()));
//创建socket
_socketServer
=
new
QTcpServer
();
bool
result
=
_socketServer
->
listen
(
QHostAddress
::
Any
,
23770
);
if
(
!
result
)
FMP_INFO
()
<<
"socket listen failed!"
;
connect
(
_socketServer
,
SIGNAL
(
newConnection
()),
this
,
SLOT
(
acceptSocketConnection
()));
}
NavWindow
::~
NavWindow
()
...
...
@@ -324,3 +331,28 @@ void NavWindow::showMessage(const QString &title, const QString &msg, QSystemTra
{
_systemTrayIcon
->
showMessage
(
title
,
msg
,
icon
,
mecs
);
}
void
NavWindow
::
acceptSocketConnection
()
{
_socketClient
=
_socketServer
->
nextPendingConnection
();
connect
(
_socketClient
,
SIGNAL
(
disconnected
()),
_socketClient
,
SLOT
(
deleteLater
()));
connect
(
_socketClient
,
SIGNAL
(
readyRead
()),
this
,
SLOT
(
readSocketClient
()));
FMP_INFO
()
<<
"connection: "
;
}
void
NavWindow
::
readSocketClient
()
{
QByteArray
str
=
_socketClient
->
readAll
();
FMP_INFO
()
<<
"socket recv data:"
<<
str
;
emit
PayDataReceived
(
str
);
}
void
NavWindow
::
OnSendToClient
(
const
QByteArray
&
json
)
{
qDebug
()
<<
"write json:"
<<
json
;
if
(
_socketClient
&&
_socketClient
->
state
()
==
_socketClient
->
ConnectedState
){
_socketClient
->
write
(
json
);
_socketClient
->
waitForBytesWritten
();
_socketClient
->
disconnectFromHost
();
}
}
fmp_home_navwindow.h
View file @
4ab00faf
...
...
@@ -9,6 +9,7 @@
#include <QFuture>
#include <QSemaphore>
#include <QSystemTrayIcon>
#include <QtNetwork>
namespace
Ui
{
class
NavWindow
;
...
...
@@ -81,8 +82,16 @@ public slots:
void
showMessage
(
const
QString
&
title
,
const
QString
&
msg
,
QSystemTrayIcon
::
MessageIcon
icon
=
QSystemTrayIcon
::
Information
,
int
mecs
=
1000
);
/**
* @brief 接受socket连接
*/
void
acceptSocketConnection
();
void
readSocketClient
();
void
OnSendToClient
(
const
QByteArray
&
json
);
signals
:
void
menuBtnClicked
(
QString
btnName
);
void
PayDataReceived
(
const
QByteArray
&
json
);
/**
* @brief startBlink
...
...
@@ -136,6 +145,9 @@ private:
//! System tray icon.
QSystemTrayIcon
*
_systemTrayIcon
;
QTcpServer
*
_socketServer
;
QTcpSocket
*
_socketClient
;
private
:
void
initSystemTrayIcon
();
void
initMenu
();
...
...
fmp_home_p.cpp
View file @
4ab00faf
...
...
@@ -37,11 +37,13 @@ int FMPHomePrivate::Init()
_navWindow
=
new
NavWindow
;
FMPStartEventHandler
*
handler
=
new
FMPStartEventHandler
(
q
->
_ctx
,
q
);
FMPPayResultEventHandler
*
hResult
=
new
FMPPayResultEventHandler
(
q
->
_ctx
,
q
);
_navWindow
->
show
();
//
_navWindow->show();
connect
(
_navWindow
,
SIGNAL
(
menuBtnClicked
(
QString
)),
this
,
SLOT
(
onMenuBtnClicked
(
QString
)));
connect
(
_navWindow
,
&
NavWindow
::
pluginActived
,
this
,
&
FMPHomePrivate
::
onPluginActived
);
connect
(
_navWindow
,
SIGNAL
(
PayDataReceived
(
const
QByteArray
)),
this
,
SLOT
(
onPayDataReceived
(
const
QByteArray
)));
connect
(
this
,
&
FMPHomePrivate
::
dataReturn
,
_navWindow
,
&
NavWindow
::
OnSendToClient
);
login
();
// 启动外卖
...
...
@@ -161,3 +163,22 @@ void FMPHomePrivate::onMenuBtnClicked(QString btnName)
FMP_WARN
()
<<
"service not available"
;
}
}
void
FMPHomePrivate
::
onPayDataReceived
(
const
QByteArray
&
json
)
{
Q_Q
(
FMPHome
);
FMPePayInterface
*
svc
=
0
;
svc
=
q
->
GetService
<
FMPePayInterface
>
(
q
->
_ctx
);
if
(
svc
){
svc
->
ControlPayJson
(
json
);
svc
->
StartService
();
}
else
{
FMP_WARN
()
<<
"service not available"
;
}
}
void
FMPHomePrivate
::
onPayDataReturn
(
const
QByteArray
&
json
)
{
_navWindow
->
OnSendToClient
(
json
);
}
fmp_home_p.h
View file @
4ab00faf
...
...
@@ -32,6 +32,8 @@ public:
public
slots
:
void
onMenuBtnClicked
(
QString
btnName
);
void
onPluginActived
(
FMPBaseInterface
*
plugin
);
void
onPayDataReceived
(
const
QByteArray
&
json
);
void
onPayDataReturn
(
const
QByteArray
&
json
);
public
:
FMPHome
*
q_ptr
;
...
...
@@ -40,6 +42,9 @@ public:
QString
_userName
;
QString
_errorMsg
;
signals
:
void
dataReturn
(
const
QByteArray
&
json
);
private
:
NavWindow
*
_navWindow
;
FMPSettingsInterface
*
_settings
;
...
...
version.h
View file @
4ab00faf
...
...
@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD 1
5
#define VER_BUILD 1
6
//! Convert version numbers to string
#define _STR(S) #S
...
...
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