Newer
Older

alexandr.kravchenko
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "DapServiceClientNativeMacOS.h"
#include <QtDebug>
#include <QMessageBox>
DapServiceClientNativeMacOS::DapServiceClientNativeMacOS()
{
QString dapServiceNameToLower = QString(DAP_SERVICE_NAME).toLower();
QString cmd = QString("ps -C %1 > /dev/null").arg(DAP_SERVICE_NAME);
m_checkIsServiceRunningCommand = strdup(cmd.toLatin1().data());
m_cmdTemplate = QString("service " + dapServiceNameToLower) + " %1";
qDebug() << "command for check is service running: " << m_checkIsServiceRunningCommand;
}
DapServiceClientNativeMacOS::~DapServiceClientNativeMacOS()
{
delete m_checkIsServiceRunningCommand;
}
bool DapServiceClientNativeMacOS::isServiceRunning()
{
m_isServiceRunning =true;// (::system(m_checkIsServiceRunningCommand) == 0);
return m_isServiceRunning;
}
DapServiceError DapServiceClientNativeMacOS::serviceRestart()
{
qDebug() << "Restart service name" << m_cmdTemplate.arg("restart").toLatin1().data();
int retCode = ::system(m_cmdTemplate.arg("restart").toLatin1().data());
qDebug() << "Restart result code:" << retCode;
if(retCode != 0) {
return DapServiceError::USER_COMMAND_ABORT;
}
return DapServiceError::NO_ERRORS;
}
/**
* @brief SapNetworkClientNativeMacOS::serviceStart
*/
DapServiceError DapServiceClientNativeMacOS::serviceStart()
{
// yes better use restart
int ret = ::system(m_cmdTemplate.arg("restart").toLatin1().data());
qDebug() << "serviceStart Result: " << ret;
if(ret != 0) {
return DapServiceError::USER_COMMAND_ABORT;
}
return DapServiceError::NO_ERRORS;
}
/**
* @brief SapServiceClientNativeMacOS::serviceStop
*/
DapServiceError DapServiceClientNativeMacOS::serviceStop()
{
int ret = ::system(m_cmdTemplate.arg("stop").toLatin1().data());
qDebug() << "serviceStop result:" << ret;
if(ret != 0) {
return DapServiceError::USER_COMMAND_ABORT;
}
return DapServiceError::NO_ERRORS;
}
/**
* @brief SapServiceClientNativeMacOS::serviceInstallAndRun
*/
DapServiceError DapServiceClientNativeMacOS::serviceInstallAndRun()
{
return serviceStart();
}