2 Copyright (c) 2000 Matthias Elter <elter@kde.org>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include <kservicegroup.h>
24 #include <kapplication.h>
33 #include <sys/types.h>
34 #include <sys/utsname.h>
36 bool KCGlobal::_root
= false;
37 QStringList
KCGlobal::_types
;
38 QString
KCGlobal::_uname
= "";
39 QString
KCGlobal::_hname
= "";
40 QString
KCGlobal::_kdeversion
= "";
41 QString
KCGlobal::_isystem
= "";
42 QString
KCGlobal::_irelease
= "";
43 QString
KCGlobal::_iversion
= "";
44 QString
KCGlobal::_imachine
= "";
45 QString
KCGlobal::_baseGroup
= "";
47 void KCGlobal::init() {
50 if (!gethostname(buf
, sizeof(buf
)))
51 buf
[sizeof(buf
)-1] ='\0';
52 QString
hostname(buf
);
54 setHostName(hostname
);
55 setUserName(KUser().loginName());
56 setRoot(getuid() == 0);
58 setKDEVersion(KDE::versionString());
63 setSystemName(info
.sysname
);
64 setSystemRelease(info
.release
);
65 setSystemVersion(info
.version
);
66 setSystemMachine(info
.machine
);
69 void KCGlobal::setType(const QByteArray
& s
) {
70 QString string
= s
.toLower();
71 _types
= string
.split( ',');
74 QString
KCGlobal::baseGroup() {
75 if (_baseGroup
.isEmpty() ) {
76 KServiceGroup::Ptr group
= KServiceGroup::baseGroup("info");
78 _baseGroup
= group
->relPath();
79 kDebug() << "Found basegroup = " << _baseGroup
;
82 // Compatibility with old behaviour, in case of missing .directory files.
83 if (_baseGroup
.isEmpty()) {
84 kWarning() << "No K menu group with X-KDE-BaseGroup=info found ! Defaulting to Settings/Information/";
85 _baseGroup
= QLatin1String("Settings/Information/");