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
76
|
/***************************************************************************
begin : Sun Oct 3 1999
copyright : (C) 1999 by Peter Putzer
email : putzer@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; version 2. *
* *
***************************************************************************/
#include <ksv_service.h>
#include "leveldb.h"
KSVService::KSVService (const QString &name, const QString &basedir)
: name_ (name),
base_ (basedir)
{
}
KSVService* KSVService::newService (const QString &name, const QString &basedir)
{
struct service service;
int result = ::readServiceInfo (basedir.local8Bit(), name.local8Bit(), &service );
if (!result)
{
KSVService* tmp = new KSVService(name, basedir);
tmp->desc_ = service.desc;
tmp->levels = service.levels;
tmp->kPriority = service.kPriority;
tmp->sPriority = service.sPriority;
return tmp;
}
else
{
return 0L;
}
}
KSVService::~KSVService()
{
}
bool KSVService::isOn (int level) const
{
return !::isOn (base_.local8Bit(), name_.local8Bit(), level );
}
bool KSVService::isConfigured (int level) const
{
return !::isConfigured (base_.local8Bit(), name_.local8Bit(), level);
}
int KSVService::set (int level, bool on)
{
struct service service;
service.name = strdup (name_.local8Bit());
service.desc = strdup (desc_.local8Bit());
service.levels = levels;
service.kPriority = kPriority;
service.sPriority = sPriority;
return ::doSetService ("/etc/rc.d", service, level, on);
}
QString KSVService::description () const
{
return desc_.stripWhiteSpace();
}
|