7#include "RabbitCommonDir.h" 
    8#include "PluginService.h" 
    9#include <QLoggingCategory> 
   11Q_DECLARE_LOGGING_CATEGORY(Service)
 
   21    qDebug(Service) << 
"CService::~CService()";
 
   29        nRet = LoadConfigure();
 
   33    if(!GetParameters() || !GetParameters()->getEnable())
 
   35        qInfo(Service) << 
"The service" << m_pPlugin->
Name() << 
"is disable";
 
   38        qInfo(Service) << 
"The service" << m_pPlugin->
Name() << 
"is start";
 
   43    if(nRet > 0) 
return 0;
 
 
   55        m_pPara->deleteLater();
 
   66    } 
catch (std::exception& e) {
 
   67        qCritical(Service) << 
"OnProcess exception:" << e.what();
 
   69        qCritical(Service) << 
"OnProcess exception";
 
   75        qCritical(Service) << 
"OnProcess fail:", nRet;
 
   78    QTimer::singleShot(nRet, 
this, SLOT(
slotProcess()));
 
 
   83    qWarning(Service) << 
"Need to implement CService::OnProcess()";
 
 
   92int CService::LoadConfigure(
const QString &szDir)
 
   95    QString szFolder = szDir;
 
   97    if(szFolder.isEmpty())
 
   99        szFile = RabbitCommon::CDir::Instance()->GetFileUserConfigure();
 
  100        QSettings set(szFile, QSettings::IniFormat);
 
  101        szFolder = set.value(
"Configure/Folder",
 
  102                 RabbitCommon::CDir::Instance()->GetDirUserConfig()).toString();
 
  103        szFile = set.value(
"Configure/File/" + m_pPlugin->
Id(),
 
  107                       + 
".rrs").toString();
 
  109        szFile = szFolder + QDir::separator() + m_pPlugin->
Id() + 
".rrs";
 
  111    qInfo(Service) << 
"Configure file:" << szFile;
 
  113    if(d.exists(szFile)){
 
  114        nRet = GetParameters()->Load(szFile);
 
  117            qInfo(Service) << 
"Load configure file fail:" << nRet << 
":" << szFile;
 
  124int CService::SaveConfigure(
const QString &szDir)
 
  129        QString szFolder = szDir;
 
  131        if(szFolder.isEmpty())
 
  133            szFile = RabbitCommon::CDir::Instance()->GetFileUserConfigure();
 
  134            QSettings set(szFile, QSettings::IniFormat);
 
  135            szFolder = set.value(
"Configure/Folder",
 
  136                     RabbitCommon::CDir::Instance()->GetDirUserConfig()).toString();
 
  137            szFile = set.value(
"Configure/File/" + m_pPlugin->
Id(),
 
  141                           + 
".rrs").toString();
 
  143            szFile = szFolder + QDir::separator() + m_pPlugin->
Id() + 
".rrs";
 
  145        nRet = GetParameters()->Save(szFile);
 
The service plugin interface.
 
virtual const QString Id() const
ID. Default: Protocol() + "_" + Name()
 
virtual const QString Name() const =0
This name must be the same as the project name (${PROJECT_NAME}).
 
virtual int OnInit()=0
Init service.
 
virtual int Init()
Load parameters, support non-Qt event loop.
 
virtual void slotProcess()
Support non-Qt event loop.
 
virtual int OnClean()=0
Clean service.
 
virtual int OnProcess()
Process service.