Commit 27759247 by Carwyn

1.同步基础接口InitService/UninitService

parent 794b72a6
...@@ -17,7 +17,7 @@ void FMPStartEventHandler::handleEvent(const ctkEvent &event) ...@@ -17,7 +17,7 @@ void FMPStartEventHandler::handleEvent(const ctkEvent &event)
{ {
if (_vip) { if (_vip) {
if (event.getProperty(FMP_PROPKEY_AGREED).toBool()) { if (event.getProperty(FMP_PROPKEY_AGREED).toBool()) {
_vip->StartVip(); _vip->TriggerInit();
} }
else { else {
FMP_WARN() << "Refused start request" << event.getTopic(); FMP_WARN() << "Refused start request" << event.getTopic();
......
...@@ -13,16 +13,14 @@ FMPVip::FMPVip(ctkPluginContext *context) ...@@ -13,16 +13,14 @@ FMPVip::FMPVip(ctkPluginContext *context)
FMPLoggerInterface::InitContext(context); FMPLoggerInterface::InitContext(context);
} }
int FMPVip::StopService() void FMPVip::InitService()
{ {
if (!_inited) return FMP_SUCCESS; d_func()->Init();
Q_D(FMPVip);
return d->StopService();
} }
int FMPVip::StartVip() void FMPVip::UninitService()
{ {
Q_D(FMPVip); if (_inited) {
return d->StartVip(); d_func()->Uninit();
}
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
class FMPVipPrivate; class FMPVipPrivate;
class FMPVip : public QObject, public FMPVipInterface class FMPVip : public FMPVipInterface
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(FMPBaseInterface) Q_INTERFACES(FMPBaseInterface)
...@@ -16,8 +16,9 @@ class FMPVip : public QObject, public FMPVipInterface ...@@ -16,8 +16,9 @@ class FMPVip : public QObject, public FMPVipInterface
public: public:
FMPVip(ctkPluginContext *context); FMPVip(ctkPluginContext *context);
int StopService(); protected slots:
int StartVip(); void InitService();
void UninitService();
private: private:
bool _inited; bool _inited;
FMPVipPrivate* d_ptr; FMPVipPrivate* d_ptr;
......
...@@ -7,11 +7,24 @@ ...@@ -7,11 +7,24 @@
* 业务插件接口,必须继承自 FMPluginInterface * 业务插件接口,必须继承自 FMPluginInterface
* @brief The FMPVipInterface class * @brief The FMPVipInterface class
*/ */
class FMPVipInterface : public FMPluginInterface class FMPVipInterface : public QObject, public FMPluginInterface
{ {
Q_OBJECT
Q_INTERFACES(FMPBaseInterface)
Q_INTERFACES(FMPluginInterface)
public: public:
explicit FMPVipInterface(ctkPluginContext *ctx) : FMPluginInterface(ctx) {} explicit FMPVipInterface(ctkPluginContext *ctx) : FMPluginInterface(ctx)
virtual int StartVip() = 0; {
connect(this, &FMPVipInterface::TriggerInit, this, &FMPVipInterface::InitService);
connect(this, &FMPVipInterface::TriggerUninit, this, &FMPVipInterface::UninitService);
}
protected slots:
void InitService() = 0;
void UninitService() = 0;
signals:
void TriggerInit();
void TriggerUninit();
}; };
......
...@@ -14,10 +14,9 @@ ...@@ -14,10 +14,9 @@
FMPVipPrivate::FMPVipPrivate(FMPVip *vip): FMPVipPrivate::FMPVipPrivate(FMPVip *vip):
q_ptr(vip) q_ptr(vip)
{ {
connect(this, &FMPVipPrivate::startVip, this, &FMPVipPrivate::onStartVip);
} }
int FMPVipPrivate::StartVip() int FMPVipPrivate::Init()
{ {
Q_Q(FMPVip); Q_Q(FMPVip);
FMPHomeInterface *home = q->GetService<FMPHomeInterface>(q->_ctx); FMPHomeInterface *home = q->GetService<FMPHomeInterface>(q->_ctx);
...@@ -27,17 +26,21 @@ int FMPVipPrivate::StartVip() ...@@ -27,17 +26,21 @@ int FMPVipPrivate::StartVip()
_settings = q->GetService<FMPSettingsInterface>(q->_ctx); _settings = q->GetService<FMPSettingsInterface>(q->_ctx);
FMPVipSettings::instance()->init(_settings); FMPVipSettings::instance()->init(_settings);
emit startVip(); auto resend = new ReSend();
resend->start();
FMPVipServer::instance();
q->_inited = true; q->_inited = true;
home->notification(QString::fromLocal8Bit("[非码会员]启动成功!")); home->notification(QString::fromLocal8Bit("[非码会员]启动成功!"));
FMP_INFO() << "Vip start"; FMP_INFO() << "Vip start";
} }
return FMP_SUCCESS; return FMP_SUCCESS;
} }
int FMPVipPrivate::StopService() int FMPVipPrivate::Uninit()
{ {
Q_Q(FMPVip); Q_Q(FMPVip);
...@@ -45,11 +48,3 @@ int FMPVipPrivate::StopService() ...@@ -45,11 +48,3 @@ int FMPVipPrivate::StopService()
q->_inited = false; q->_inited = false;
return FMP_SUCCESS; return FMP_SUCCESS;
} }
void FMPVipPrivate::onStartVip()
{
auto resend = new ReSend();
resend->start();
FMPVipServer::instance();
}
...@@ -13,13 +13,8 @@ class FMPVipPrivate : public QObject ...@@ -13,13 +13,8 @@ class FMPVipPrivate : public QObject
public: public:
FMPVipPrivate(FMPVip *vip); FMPVipPrivate(FMPVip *vip);
int StopService(); int Init();
int StartVip(); int Uninit();
signals:
void startVip();
private slots:
void onStartVip();
public: public:
FMPVip *q_ptr; FMPVip *q_ptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment