Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fmp_takeout
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_takeout
Commits
1f98a6ab
Commit
1f98a6ab
authored
Dec 11, 2017
by
Amnes1a
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改外卖插件的接口形式
parent
726d67ae
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
75 additions
and
62 deletions
+75
-62
fmp_takeout.cpp
+11
-6
fmp_takeout.h
+7
-8
fmp_takeout_i.h
+2
-4
fmp_takeout_p.cpp
+8
-18
fmp_takeout_p.h
+3
-5
fmp_takeout_plugin.cpp
+1
-5
fmp_te_handlers.cpp
+33
-7
fmp_te_handlers.h
+10
-9
No files found.
fmp_takeout.cpp
View file @
1f98a6ab
#include "fmp_takeout_p.h"
#
include
"fmp_takeout_p.h"
#include "fmp_te_handlers.h"
#include "fmp_te_handlers.h"
FMPTakeout
::
FMPTakeout
(
ctkPluginContext
*
context
)
FMPTakeout
::
FMPTakeout
(
const
FMPContext
context
)
:
FMPTakeoutInterface
(
context
),
:
FMPTakeoutInterface
(),
pluginContext
(
context
),
_inited
(
false
),
_inited
(
false
),
_ste_handler
(
new
FMPStartEventHandler
(
this
)),
d_ptr
(
new
FMPTakeoutPrivate
(
this
))
d_ptr
(
new
FMPTakeoutPrivate
(
this
))
{
{
FMPStartEventHandler
*
se
=
new
FMPStartEventHandler
(
_ctx
,
this
);
}
}
FMPTakeout
::~
FMPTakeout
()
FMPTakeout
::~
FMPTakeout
()
...
@@ -19,13 +20,17 @@ FMPTakeout::~FMPTakeout()
...
@@ -19,13 +20,17 @@ FMPTakeout::~FMPTakeout()
void
FMPTakeout
::
InitService
()
void
FMPTakeout
::
InitService
()
{
{
d_func
()
->
Init
();
if
(
_inited
)
return
;
Q_D
(
FMPTakeout
);
d
->
Init
();
}
}
void
FMPTakeout
::
UninitService
()
void
FMPTakeout
::
UninitService
()
{
{
if
(
_inited
)
{
if
(
_inited
)
{
d_func
()
->
Uninit
();
Q_D
(
FMPTakeout
);
d
->
Uninit
();
}
}
}
}
...
...
fmp_takeout.h
View file @
1f98a6ab
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
#include <QObject>
#include <QObject>
#include "fmp_takeout_i.h"
#include "fmp_takeout_i.h"
class
FMPStartEventHandler
;
class
FMPTakeoutPrivate
;
class
FMPTakeoutPrivate
;
class
FMPTakeout
:
public
FMPTakeoutInterface
class
FMPTakeout
:
public
FMPTakeoutInterface
...
@@ -14,22 +16,19 @@ class FMPTakeout : public FMPTakeoutInterface
...
@@ -14,22 +16,19 @@ class FMPTakeout : public FMPTakeoutInterface
Q_DECLARE_PRIVATE
(
FMPTakeout
)
Q_DECLARE_PRIVATE
(
FMPTakeout
)
public
:
public
:
explicit
FMPTakeout
(
c
tkPluginContext
*
context
);
explicit
FMPTakeout
(
c
onst
FMPContext
context
);
virtual
~
FMPTakeout
();
virtual
~
FMPTakeout
();
protected
:
protected
:
void
UninitService
();
void
UninitService
();
void
InitService
();
void
InitService
();
const
FMPContext
GetContext
()
const
{
return
pluginContext
;}
private
:
private
:
bool
_inited
;
bool
_inited
;
FMPTakeoutPrivate
*
d_ptr
;
FMPTakeoutPrivate
*
d_ptr
;
const
FMPContext
pluginContext
;
QPointer
<
FMPStartEventHandler
>
_ste_handler
;
signals
:
public
slots
:
};
};
#endif // FMPTakeout_H
#endif // FMPTakeout_H
fmp_takeout_i.h
View file @
1f98a6ab
#ifndef FMPTAKEOUTINTERFACE_H
#
ifndef
FMPTAKEOUTINTERFACE_H
#define FMPTAKEOUTINTERFACE_H
#define FMPTAKEOUTINTERFACE_H
#include <fmp_plugin_i.h>
#include <fmp_plugin_i.h>
#include "fmp_takeout_def.h"
#include "fmp_takeout_def.h"
/**
/**
...
@@ -15,7 +14,7 @@ class FMPTakeoutInterface : public QObject, public FMPluginInterface
...
@@ -15,7 +14,7 @@ class FMPTakeoutInterface : public QObject, public FMPluginInterface
Q_INTERFACES
(
FMPBaseInterface
)
Q_INTERFACES
(
FMPBaseInterface
)
Q_INTERFACES
(
FMPluginInterface
)
Q_INTERFACES
(
FMPluginInterface
)
public
:
public
:
explicit
FMPTakeoutInterface
(
ctkPluginContext
*
ctx
)
:
FMPluginInterface
(
ctx
)
explicit
FMPTakeoutInterface
(
)
:
FMPluginInterface
(
)
{
{
connect
(
this
,
&
FMPTakeoutInterface
::
TriggerInit
,
this
,
&
FMPTakeoutInterface
::
OnTriggerInit
,
Qt
::
UniqueConnection
);
connect
(
this
,
&
FMPTakeoutInterface
::
TriggerInit
,
this
,
&
FMPTakeoutInterface
::
OnTriggerInit
,
Qt
::
UniqueConnection
);
connect
(
this
,
&
FMPTakeoutInterface
::
TriggerUninit
,
this
,
&
FMPTakeoutInterface
::
OnTriggerUninit
,
Qt
::
UniqueConnection
);
connect
(
this
,
&
FMPTakeoutInterface
::
TriggerUninit
,
this
,
&
FMPTakeoutInterface
::
OnTriggerUninit
,
Qt
::
UniqueConnection
);
...
@@ -32,5 +31,4 @@ protected slots:
...
@@ -32,5 +31,4 @@ protected slots:
Q_DECLARE_INTERFACE
(
FMPTakeoutInterface
,
"com.fmp.takeout"
)
Q_DECLARE_INTERFACE
(
FMPTakeoutInterface
,
"com.fmp.takeout"
)
#endif // FMPTAKEOUTINTERFACE_H
#endif // FMPTAKEOUTINTERFACE_H
fmp_takeout_p.cpp
View file @
1f98a6ab
...
@@ -17,36 +17,27 @@ FMPTakeoutPrivate::FMPTakeoutPrivate(FMPTakeout *parent)
...
@@ -17,36 +17,27 @@ FMPTakeoutPrivate::FMPTakeoutPrivate(FMPTakeout *parent)
}
}
int
FMPTakeoutPrivate
::
Init
()
void
FMPTakeoutPrivate
::
Init
()
{
{
Q_Q
(
FMPTakeout
);
Q_Q
(
FMPTakeout
);
if
(
!
q
)
if
(
q
->
_inited
)
{
{
return
0
;
emit
sgnGetFromHome
()
;
}
}
else
else
{
{
if
(
0
==
q
->
_inited
)
_Home
=
FMP
::
GetService
<
FMPHomeInterface
>
();
{
_Printer
=
FMP
::
GetService
<
FMPPrinterInterface
>
();
_Home
=
q
->
GetService
<
FMPHomeInterface
>
(
q
->
_ctx
);
InitApp
();
_Printer
=
q
->
GetService
<
FMPPrinterInterface
>
(
q
->
_ctx
);
q
->
_inited
=
true
;
InitApp
();
q
->
_inited
=
true
;
return
FMP_SUCCESS
;
}
else
{
emit
sgnGetFromHome
();
return
1
;
}
}
}
}
}
FMPTakeoutPrivate
::~
FMPTakeoutPrivate
()
FMPTakeoutPrivate
::~
FMPTakeoutPrivate
()
{
{
Uninit
();
Uninit
();
}
}
int
FMPTakeoutPrivate
::
Uninit
()
void
FMPTakeoutPrivate
::
Uninit
()
{
{
Q_Q
(
FMPTakeout
);
Q_Q
(
FMPTakeout
);
emit
sgnStopTime
();
emit
sgnStopTime
();
...
@@ -64,7 +55,6 @@ int FMPTakeoutPrivate::Uninit()
...
@@ -64,7 +55,6 @@ int FMPTakeoutPrivate::Uninit()
_settings
=
0
;
_settings
=
0
;
}
}
q
->
_inited
=
false
;
q
->
_inited
=
false
;
return
FMP_SUCCESS
;
}
}
// home 提供接口
// home 提供接口
...
...
fmp_takeout_p.h
View file @
1f98a6ab
#ifndef FMP_TAKEOUT_P_H
#
ifndef
FMP_TAKEOUT_P_H
#define FMP_TAKEOUT_P_H
#define FMP_TAKEOUT_P_H
#include "fmp_takeout.h"
#include "fmp_takeout.h"
...
@@ -11,13 +11,11 @@ class FMPTakeoutPrivate:public QObject
...
@@ -11,13 +11,11 @@ class FMPTakeoutPrivate:public QObject
Q_DECLARE_PUBLIC
(
FMPTakeout
)
Q_DECLARE_PUBLIC
(
FMPTakeout
)
public
:
public
:
explicit
FMPTakeoutPrivate
(
FMPTakeout
*
q
);
explicit
FMPTakeoutPrivate
(
FMPTakeout
*
q
);
int
Init
();
int
Uninit
();
~
FMPTakeoutPrivate
();
~
FMPTakeoutPrivate
();
void
Init
();
void
Uninit
();
void
InitApp
();
void
InitApp
();
private
:
public
:
public
:
FMPTakeout
*
q_ptr
;
FMPTakeout
*
q_ptr
;
FMPHomeInterface
*
_Home
;
FMPHomeInterface
*
_Home
;
...
...
fmp_takeout_plugin.cpp
View file @
1f98a6ab
/*=============================================================================
/*=============================================================================
Library: CTK
Library: CTK
...
@@ -21,9 +21,7 @@
...
@@ -21,9 +21,7 @@
#include "fmp_takeout_plugin_p.h"
#include "fmp_takeout_plugin_p.h"
#include "fmp_takeout.h"
#include "fmp_takeout.h"
#include <QtPlugin>
#include <QtPlugin>
#include <QStringList>
#include <QStringList>
#include <QDebug>
#include <QDebug>
...
@@ -47,8 +45,6 @@ void FMPTakeoutPlugin::stop(ctkPluginContext* context)
...
@@ -47,8 +45,6 @@ void FMPTakeoutPlugin::stop(ctkPluginContext* context)
delete
_takeout_service
;
delete
_takeout_service
;
_takeout_service
=
0
;
_takeout_service
=
0
;
}
}
int
a
=
0
;
}
}
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
...
...
fmp_te_handlers.cpp
View file @
1f98a6ab
#
include
"fmp_logger_i.h"
#include "fmp_te_handlers.h"
#include "fmp_te_handlers.h"
#include "fmp_takeout.h"
#include "fmp_takeout.h"
FMPStartEventHandler
::
FMPStartEventHandler
(
ctkPluginContext
*
ctx
,
FMPTakeout
*
Takeout
)
FMPStartEventHandler
::
FMPStartEventHandler
(
FMPTakeout
*
Takeout
)
:
FMPTakeoutEventHandler
(
FMP_TOPICS_SERVICES
FMPE_SERVICE_ACK_START
"/"
+
QString
::
number
(
ctx
->
getPlugin
()
->
getPluginId
()),
:
FMPTakeoutEventHandler
(
FMP_TOPICS_SERVICES
FMPE_SERVICE_ACK_START
"/"
+
QString
::
number
(
Takeout
->
GetPluginId
()),
Takeout
)
Takeout
),
_ctx
(
ctx
)
{
{
FMPProps
props
;
FMPProps
props
;
props
[
ctkEventConstants
::
EVENT_TOPIC
]
=
_topic
;
props
[
ctkEventConstants
::
EVENT_TOPIC
]
=
_topic
;
_ctx
->
r
egisterService
<
ctkEventHandler
>
(
this
,
props
);
FMP
::
R
egisterService
<
ctkEventHandler
>
(
this
,
props
);
}
}
void
FMPStartEventHandler
::
handleEvent
(
const
ctkEvent
&
event
)
void
FMPStartEventHandler
::
handleEvent
(
const
ctkEvent
&
event
)
...
@@ -19,11 +18,38 @@ void FMPStartEventHandler::handleEvent(const ctkEvent &event)
...
@@ -19,11 +18,38 @@ void FMPStartEventHandler::handleEvent(const ctkEvent &event)
_Takeout
->
TriggerInit
();
_Takeout
->
TriggerInit
();
}
}
else
{
else
{
// FMP_WARN_CTX(_ctx) << "Refused start request
" << event.getTopic();
FMP_WARN
()
<<
"Refused start request
"
<<
event
.
getTopic
();
}
}
}
}
else
{
else
{
// FMP_DEBUG_CTX(_ctx) << "No handler instance for event" << event.getTopic();
FMP_DEBUG
()
<<
"No handler instance for event "
<<
event
.
getTopic
();
}
}
FMPNetWorkEventHandler
::
FMPNetWorkEventHandler
(
FMPTakeout
*
Takeout
)
:
FMPTakeoutEventHandler
(
FMP_TOPICS_SERVICES
FMPE_SERVICE_ACK_START
"/"
+
QString
::
number
(
Takeout
->
GetPluginId
()),
Takeout
)
{
FMPProps
props
;
props
[
ctkEventConstants
::
EVENT_TOPIC
]
=
_topic
;
FMP
::
RegisterService
<
ctkEventHandler
>
(
this
,
props
);
}
void
FMPNetWorkEventHandler
::
handleEvent
(
const
ctkEvent
&
event
)
{
if
(
_Takeout
)
{
if
(
event
.
getProperty
(
FMP_PROPKEY_AGREED
).
toBool
())
{
_Takeout
->
TriggerInit
();
}
else
{
FMP_WARN
()
<<
"Refused start request "
<<
event
.
getTopic
();
}
}
else
{
FMP_DEBUG
()
<<
"No handler instance for event "
<<
event
.
getTopic
();
}
}
}
}
fmp_te_handlers.h
View file @
1f98a6ab
#ifndef FMPTAKEOUTEVENTHANDLER_H
#
ifndef
FMPTAKEOUTEVENTHANDLER_H
#define FMPTAKEOUTEVENTHANDLER_H
#define FMPTAKEOUTEVENTHANDLER_H
#include <QObject>
#include <QObject>
#include <service/event/ctkEventConstants.h>
#include <service/event/ctkEventConstants.h>
#include <service/event/ctkEventHandler.h>
#include <service/event/ctkEventHandler.h>
class
FMPTakeout
;
class
FMPTakeout
;
class
FMPTakeoutEventHandler
:
public
ctkEventHandler
class
FMPTakeoutEventHandler
:
public
ctkEventHandler
{
{
public
:
public
:
...
@@ -17,19 +15,22 @@ protected:
...
@@ -17,19 +15,22 @@ protected:
const
QString
_topic
;
const
QString
_topic
;
};
};
class
FMPStartEventHandler
:
public
QObject
,
public
FMPTakeoutEventHandler
class
FMPStartEventHandler
:
public
QObject
,
public
FMPTakeoutEventHandler
{
{
Q_OBJECT
Q_OBJECT
Q_INTERFACES
(
ctkEventHandler
)
Q_INTERFACES
(
ctkEventHandler
)
public
:
public
:
explicit
FMPStartEventHandler
(
ctkPluginContext
*
ctx
,
FMPTakeout
*
Takeout
);
explicit
FMPStartEventHandler
(
FMPTakeout
*
Takeout
);
void
handleEvent
(
const
ctkEvent
&
event
);
void
handleEvent
(
const
ctkEvent
&
event
);
private
:
ctkPluginContext
*
_ctx
;
};
};
class
FMPNetWorkEventHandler
:
public
QObject
,
public
FMPTakeoutEventHandler
{
Q_OBJECT
Q_INTERFACES
(
ctkEventHandler
)
public
:
explicit
FMPNetWorkEventHandler
(
FMPTakeout
*
Takeout
);
void
handleEvent
(
const
ctkEvent
&
event
);
};
#endif // FMPTAKEOUTEVENTHANDLER_H
#endif // FMPTAKEOUTEVENTHANDLER_H
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