File: kcmsystemd.h

package info (click to toggle)
kde-config-systemd 1.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 1,560 kB
  • ctags: 688
  • sloc: cpp: 3,306; makefile: 9; sh: 2
file content (142 lines) | stat: -rw-r--r-- 5,713 bytes parent folder | download | duplicates (2)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*******************************************************************************
 * Copyright (C) 2013-2015 Ragnar Thomsen <rthomsen6@gmail.com>                *
 *                                                                             *
 * 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, either version 2 of the License, or (at your option)   *
 * any later version.                                                          *
 *                                                                             *
 * This program is distributed in the hope that it will be useful, but WITHOUT *
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    *
 * more details.                                                               *
 *                                                                             *
 * You should have received a copy of the GNU General Public License along     *
 * with this program. If not, see <http://www.gnu.org/licenses/>.              *
 *******************************************************************************/

#ifndef KCMSYSTEMD_H
#define KCMSYSTEMD_H

#include <QtDBus/QtDBus>
#include <QStandardItemModel>
#include <QSortFilterProxyModel>
#include <QDialog>

#include <KCModule>
#include <KLocalizedString>
#include <KMessageWidget>

#include "ui_kcmsystemd.h"
#include "systemdunit.h"
#include "unitmodel.h"
#include "sortfilterunitmodel.h"
#include "confoption.h"
#include "confmodel.h"
#include "confdelegate.h"

struct unitfile
{
  QString name, status;
  
  bool operator==(const unitfile& right) const
  {
    if (name.section('/',-1) == right.name)
      return true;
    else
      return false;
  }
};

enum dbusConn
{
  systemd, logind
};

enum dbusIface
{
  sysdMgr, sysdUnit, sysdTimer, logdMgr, logdSession
};

class kcmsystemd : public KCModule
{
  Q_OBJECT

  public:
    explicit kcmsystemd(QWidget *parent,  const QVariantList &args);
    ~kcmsystemd();
    void defaults();
    void load();
    void save();

  private:
    Ui::kcmsystemd ui;
    void setupSignalSlots();
    void setupUnitslist();
    void setupConf();
    void setupSessionlist();
    void setupTimerlist();
    void readConfFile(int);
    void authServiceAction(QString, QString, QString, QString, QList<QVariant>);
    bool eventFilter(QObject *, QEvent*);
    void updateUnitCount();
    void displayMsgWidget(KMessageWidget::MessageType type, QString msg);
    QList<SystemdUnit> getUnitsFromDbus(dbusBus bus);
    QVariant getDbusProperty(QString prop, dbusIface ifaceName, QDBusObjectPath path = QDBusObjectPath("/org/freedesktop/systemd1"), dbusBus bus = sys);
    QDBusMessage callDbusMethod(QString method, dbusIface ifaceName, dbusBus bus = sys, const QList<QVariant> &args = QList<QVariant> ());
    QList<QStandardItem *> buildTimerListRow(const SystemdUnit &unit, const QList<SystemdUnit> &list, dbusBus bus);
    void editUnitFile(const QString &filename);

    QList<confOption> confOptList;
    QSortFilterProxyModel *proxyModelConf;
    ConfModel *confModel;
    SortFilterUnitModel *systemUnitFilterModel, *userUnitFilterModel;
    QStandardItemModel *sessionModel, *timerModel;
    UnitModel *systemUnitModel, *userUnitModel;
    QList<SystemdUnit> unitslist, userUnitslist;
    QList<SystemdSession> sessionlist;
    QStringList listConfFiles;
    QString etcDir, userBusPath;
    QMenu *contextMenuUnits;
    QAction *actEnableUnit, *actDisableUnit;
    int systemdVersion, timesLoad = 0, lastUnitRowChecked = -1, lastSessionRowChecked = -1, noActSystemUnits, noActUserUnits;
    qulonglong partPersSizeMB, partVolaSizeMB;
    bool enableUserUnits = true;
    QTimer *timer;
    const QStringList unitTypeSufx = QStringList() << "" << ".target" << ".service" << ".device" << ".mount"
                                                   << ".automount" << ".swap" << ".socket" << ".path"
                                                   << ".timer" << ".snapshot" << ".slice" << ".scope";
    const QString connSystemd = "org.freedesktop.systemd1";
    const QString connLogind = "org.freedesktop.login1";
    const QString pathSysdMgr = "/org/freedesktop/systemd1";
    const QString pathLogdMgr = "/org/freedesktop/login1";
    const QString ifaceMgr = "org.freedesktop.systemd1.Manager";
    const QString ifaceLogdMgr = "org.freedesktop.login1.Manager";
    const QString ifaceUnit = "org.freedesktop.systemd1.Unit";
    const QString ifaceTimer = "org.freedesktop.systemd1.Timer";
    const QString ifaceSession = "org.freedesktop.login1.Session";
    const QString ifaceDbusProp = "org.freedesktop.DBus.Properties";
    QDBusConnection systembus = QDBusConnection::systemBus();

  private slots:
    void slotChkShowUnits(int);
    void slotCmbUnitTypes(int);
    void slotUnitContextMenu(const QPoint &);
    void slotSessionContextMenu(const QPoint &);
    void slotRefreshUnitsList(bool, dbusBus);
    void slotRefreshSessionList();
    void slotRefreshTimerList();
    void slotSystemSystemdReloading(bool);
    void slotUserSystemdReloading(bool);
    void slotSystemUnitsChanged();
    void slotUserUnitsChanged();
    // void slotUnitLoaded(QString, QDBusObjectPath);
    // void slotUnitUnloaded(QString, QDBusObjectPath);
    void slotLogindPropertiesChanged(QString, QVariantMap, QStringList);
    void slotLeSearchUnitChanged(QString);
    void slotConfChanged(const QModelIndex &, const QModelIndex &);
    void slotCmbConfFileChanged(int);
    void slotUpdateTimers();
};

#endif // kcmsystemd_H