MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / CServiceManager

Method CServiceManager

Service/ServiceManager.cpp:20–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18Q_LOGGING_CATEGORY(Service, "Service")
19
20CServiceManager::CServiceManager(int argc, char **argv, const QString& appName, const QString &name)
21 : QtService<QCoreApplication>(argc, argv, name)
22{
23 // Add default parameters
24 QStringList args;
25 for (int i = 0; i < argc; ++i)
26 args.append(QString::fromLocal8Bit(argv[i]));
27 if(args.size() >= 2)
28 {
29 QString a = args.at(1);
30 if (a == QLatin1String("-s") || a == QLatin1String("-save"))
31 {
32 createApplication(argc, argv);
33 application()->setApplicationName(appName);
34 QString szDir;
35 if(args.size() >= 3)
36 szDir = args.at(2);
37 if(szDir.isEmpty())
38 szDir = RabbitCommon::CDir::Instance()->GetDirUserConfig();
39 if(!szDir.isEmpty())
40 {
41 // Make sure the plugin is loaded only after the application is created
42 if(!m_Plugins)
43 m_Plugins = QSharedPointer<CManagePlugins>(new CManagePlugins());
44 foreach(auto p, m_Plugins->m_Plugins)
45 {
46 if(p)
47 {
48 CService* pService = p->NewService();
49 if(pService)
50 pService->SaveConfigure(szDir);
51 }
52 }
53
54#ifdef HAVE_ICE
55 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure(),
56 QSettings::IniFormat);
57 CICE::Instance()->GetParameter()->Save(set);
58 set.sync();
59#endif
60 application()->quit();
61 return;
62 }
63 } else if (a == QLatin1String("-h") || a == QLatin1String("-help")) {
64 exec();
65 printf("\t-s(ave) [Directory] \t: Generate configuration file in [Directory]\n");
66 throw std::invalid_argument("Help argument");
67 }
68 }
69
70#ifdef HAVE_ICE
71 QSettings set(RabbitCommon::CDir::Instance()->GetFileUserConfigure(),
72 QSettings::IniFormat);
73 CICE::Instance()->GetParameter()->Load(set);
74#endif
75}
76
77CServiceManager::~CServiceManager()

Callers

nothing calls this directly

Calls 5

quitMethod · 0.80
isEmptyMethod · 0.45
SaveMethod · 0.45
GetParameterMethod · 0.45
LoadMethod · 0.45

Tested by

no test coverage detected