Commit 27759247 by Carwyn

1.同步基础接口InitService/UninitService

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