mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
vala: convert from dbus-glib to gdbus
This commit is contained in:
parent
9a57c62944
commit
26742b3fd8
@ -933,7 +933,6 @@ systemadm_SOURCES = \
|
|||||||
|
|
||||||
systemadm_CFLAGS = \
|
systemadm_CFLAGS = \
|
||||||
$(AM_CFLAGS) \
|
$(AM_CFLAGS) \
|
||||||
$(DBUSGLIB_CFLAGS) \
|
|
||||||
$(GTK_CFLAGS) \
|
$(GTK_CFLAGS) \
|
||||||
-Wno-unused-variable \
|
-Wno-unused-variable \
|
||||||
-Wno-unused-function \
|
-Wno-unused-function \
|
||||||
@ -941,13 +940,11 @@ systemadm_CFLAGS = \
|
|||||||
-Wno-format-nonliteral
|
-Wno-format-nonliteral
|
||||||
|
|
||||||
systemadm_VALAFLAGS = \
|
systemadm_VALAFLAGS = \
|
||||||
--pkg=dbus-glib-1 \
|
|
||||||
--pkg=posix \
|
--pkg=posix \
|
||||||
--pkg=gtk+-2.0 \
|
--pkg=gtk+-2.0 \
|
||||||
-g
|
-g
|
||||||
|
|
||||||
systemadm_LDADD = \
|
systemadm_LDADD = \
|
||||||
$(DBUSGLIB_LIBS) \
|
|
||||||
$(GTK_LIBS)
|
$(GTK_LIBS)
|
||||||
|
|
||||||
systemd_gnome_ask_password_agent_SOURCES = \
|
systemd_gnome_ask_password_agent_SOURCES = \
|
||||||
@ -955,7 +952,6 @@ systemd_gnome_ask_password_agent_SOURCES = \
|
|||||||
|
|
||||||
systemd_gnome_ask_password_agent_CFLAGS = \
|
systemd_gnome_ask_password_agent_CFLAGS = \
|
||||||
$(AM_CFLAGS) \
|
$(AM_CFLAGS) \
|
||||||
$(DBUSGLIB_CFLAGS) \
|
|
||||||
$(LIBNOTIFY_CFLAGS) \
|
$(LIBNOTIFY_CFLAGS) \
|
||||||
$(GTK_CFLAGS) \
|
$(GTK_CFLAGS) \
|
||||||
-Wno-unused-variable \
|
-Wno-unused-variable \
|
||||||
@ -964,7 +960,6 @@ systemd_gnome_ask_password_agent_CFLAGS = \
|
|||||||
-Wno-format-nonliteral
|
-Wno-format-nonliteral
|
||||||
|
|
||||||
systemd_gnome_ask_password_agent_VALAFLAGS = \
|
systemd_gnome_ask_password_agent_VALAFLAGS = \
|
||||||
--pkg=dbus-glib-1 \
|
|
||||||
--pkg=posix \
|
--pkg=posix \
|
||||||
--pkg=gtk+-2.0 \
|
--pkg=gtk+-2.0 \
|
||||||
--pkg=linux \
|
--pkg=linux \
|
||||||
@ -978,7 +973,6 @@ systemd_gnome_ask_password_agent_VALAFLAGS += \
|
|||||||
-g
|
-g
|
||||||
|
|
||||||
systemd_gnome_ask_password_agent_LDADD = \
|
systemd_gnome_ask_password_agent_LDADD = \
|
||||||
$(DBUSGLIB_LIBS) \
|
|
||||||
$(LIBNOTIFY_LIBS) \
|
$(LIBNOTIFY_LIBS) \
|
||||||
$(GTK_LIBS)
|
$(GTK_LIBS)
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ AM_CONDITIONAL(HAVE_LIBCRYPTSETUP, [test "$have_libcryptsetup" = "yes"])
|
|||||||
have_gtk=no
|
have_gtk=no
|
||||||
AC_ARG_ENABLE(gtk, AS_HELP_STRING([--disable-gtk], [disable GTK tools]))
|
AC_ARG_ENABLE(gtk, AS_HELP_STRING([--disable-gtk], [disable GTK tools]))
|
||||||
if test "x$enable_gtk" != "xno"; then
|
if test "x$enable_gtk" != "xno"; then
|
||||||
PKG_CHECK_MODULES(GTK, [ gtk+-2.0 gio-unix-2.0 ],
|
PKG_CHECK_MODULES(GTK, [ gtk+-2.0 glib-2.0 > 2.26 gio-unix-2.0 ],
|
||||||
[AC_DEFINE(HAVE_GTK, 1, [Define if GTK is available]) have_gtk=yes], have_gtk=no)
|
[AC_DEFINE(HAVE_GTK, 1, [Define if GTK is available]) have_gtk=yes], have_gtk=no)
|
||||||
AC_SUBST(GTK_CFLAGS)
|
AC_SUBST(GTK_CFLAGS)
|
||||||
AC_SUBST(GTK_LIBS)
|
AC_SUBST(GTK_LIBS)
|
||||||
@ -255,10 +255,6 @@ fi
|
|||||||
AM_CONDITIONAL(HAVE_GTK, [test "$have_gtk" = "yes"])
|
AM_CONDITIONAL(HAVE_GTK, [test "$have_gtk" = "yes"])
|
||||||
|
|
||||||
if test "$have_gtk" = "yes"; then
|
if test "$have_gtk" = "yes"; then
|
||||||
PKG_CHECK_MODULES(DBUSGLIB, [ dbus-glib-1 ])
|
|
||||||
AC_SUBST(DBUSGLIB_CFLAGS)
|
|
||||||
AC_SUBST(DBUSGLIB_LIBS)
|
|
||||||
|
|
||||||
PKG_CHECK_MODULES(LIBNOTIFY, [ libnotify ])
|
PKG_CHECK_MODULES(LIBNOTIFY, [ libnotify ])
|
||||||
PKG_CHECK_EXISTS([ libnotify >= 0.7.0 ], [ libnotify07=yes ])
|
PKG_CHECK_EXISTS([ libnotify >= 0.7.0 ], [ libnotify07=yes ])
|
||||||
|
|
||||||
@ -267,7 +263,7 @@ if test "$have_gtk" = "yes"; then
|
|||||||
fi
|
fi
|
||||||
AM_CONDITIONAL(LIBNOTIFY07, [ test "$libnotify07" = "yes" ])
|
AM_CONDITIONAL(LIBNOTIFY07, [ test "$libnotify07" = "yes" ])
|
||||||
|
|
||||||
AM_PROG_VALAC([0.10])
|
AM_PROG_VALAC([0.11])
|
||||||
AC_SUBST(VAPIDIR)
|
AC_SUBST(VAPIDIR)
|
||||||
AM_CONDITIONAL(HAVE_VALAC, test x"$VALAC" != x)
|
AM_CONDITIONAL(HAVE_VALAC, test x"$VALAC" != x)
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
using Gtk;
|
using Gtk;
|
||||||
using GLib;
|
using GLib;
|
||||||
using DBus;
|
|
||||||
using Linux;
|
using Linux;
|
||||||
using Posix;
|
using Posix;
|
||||||
using Notify;
|
using Notify;
|
||||||
@ -102,14 +101,19 @@ public class MyStatusIcon : StatusIcon {
|
|||||||
activate.connect(status_icon_activate);
|
activate.connect(status_icon_activate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void file_monitor_changed(GLib.File file, GLib.File? other_file, GLib.FileMonitorEvent event_type) throws GLib.Error {
|
void file_monitor_changed(GLib.File file, GLib.File? other_file, GLib.FileMonitorEvent event_type) {
|
||||||
|
|
||||||
if (!file.get_basename().has_prefix("ask."))
|
if (!file.get_basename().has_prefix("ask."))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event_type == FileMonitorEvent.CREATED ||
|
if (event_type == FileMonitorEvent.CREATED ||
|
||||||
event_type == FileMonitorEvent.DELETED)
|
event_type == FileMonitorEvent.DELETED) {
|
||||||
|
try {
|
||||||
look_for_password();
|
look_for_password();
|
||||||
|
} catch (Error e) {
|
||||||
|
show_error(e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void look_for_password() throws GLib.Error {
|
void look_for_password() throws GLib.Error {
|
||||||
@ -198,7 +202,7 @@ public class MyStatusIcon : StatusIcon {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void status_icon_activate() throws GLib.Error {
|
void status_icon_activate() {
|
||||||
|
|
||||||
if (current == null)
|
if (current == null)
|
||||||
return;
|
return;
|
||||||
@ -222,6 +226,7 @@ public class MyStatusIcon : StatusIcon {
|
|||||||
|
|
||||||
int to_process;
|
int to_process;
|
||||||
|
|
||||||
|
try {
|
||||||
Process.spawn_async_with_pipes(
|
Process.spawn_async_with_pipes(
|
||||||
null,
|
null,
|
||||||
{ "/usr/bin/pkexec", "/lib/systemd/systemd-reply-password", result == ResponseType.OK ? "1" : "0", socket },
|
{ "/usr/bin/pkexec", "/lib/systemd/systemd-reply-password", result == ResponseType.OK ? "1" : "0", socket },
|
||||||
@ -240,6 +245,9 @@ public class MyStatusIcon : StatusIcon {
|
|||||||
#else
|
#else
|
||||||
stream.write(password, password.length, null);
|
stream.write(password, password.length, null);
|
||||||
#endif
|
#endif
|
||||||
|
} catch (Error e) {
|
||||||
|
show_error(e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,8 +269,6 @@ int main(string[] args) {
|
|||||||
MyStatusIcon i = new MyStatusIcon();
|
MyStatusIcon i = new MyStatusIcon();
|
||||||
Gtk.main();
|
Gtk.main();
|
||||||
|
|
||||||
} catch (DBus.Error e) {
|
|
||||||
show_error(e.message);
|
|
||||||
} catch (GLib.Error e) {
|
} catch (GLib.Error e) {
|
||||||
show_error(e.message);
|
show_error(e.message);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
using Gtk;
|
using Gtk;
|
||||||
using GLib;
|
using GLib;
|
||||||
using DBus;
|
|
||||||
using Pango;
|
using Pango;
|
||||||
|
|
||||||
static bool user = false;
|
static bool user = false;
|
||||||
@ -79,7 +78,6 @@ public class MainWindow : Window {
|
|||||||
private Button server_snapshot_button;
|
private Button server_snapshot_button;
|
||||||
private Button server_reload_button;
|
private Button server_reload_button;
|
||||||
|
|
||||||
private Connection bus;
|
|
||||||
private Manager manager;
|
private Manager manager;
|
||||||
|
|
||||||
private RightLabel unit_id_label;
|
private RightLabel unit_id_label;
|
||||||
@ -102,9 +100,9 @@ public class MainWindow : Window {
|
|||||||
|
|
||||||
private ComboBox unit_type_combo_box;
|
private ComboBox unit_type_combo_box;
|
||||||
|
|
||||||
public MainWindow() throws DBus.Error {
|
public MainWindow() throws IOError {
|
||||||
title = user ? "systemd User Service Manager" : "systemd System Manager";
|
title = user ? "systemd User Service Manager" : "systemd System Manager";
|
||||||
position = WindowPosition.CENTER;
|
set_position(WindowPosition.CENTER);
|
||||||
set_default_size(1000, 700);
|
set_default_size(1000, 700);
|
||||||
set_border_width(12);
|
set_border_width(12);
|
||||||
destroy.connect(Gtk.main_quit);
|
destroy.connect(Gtk.main_quit);
|
||||||
@ -297,12 +295,10 @@ public class MainWindow : Window {
|
|||||||
|
|
||||||
bbox.pack_start(cancel_button, false, true, 0);
|
bbox.pack_start(cancel_button, false, true, 0);
|
||||||
|
|
||||||
bus = DBus.Bus.get(user ? DBus.BusType.SESSION : DBus.BusType.SYSTEM);
|
manager = Bus.get_proxy_sync(
|
||||||
|
user ? BusType.SESSION : BusType.SYSTEM,
|
||||||
manager = bus.get_object(
|
|
||||||
"org.freedesktop.systemd1",
|
"org.freedesktop.systemd1",
|
||||||
"/org/freedesktop/systemd1",
|
"/org/freedesktop/systemd1");
|
||||||
"org.freedesktop.systemd1.Manager") as Manager;
|
|
||||||
|
|
||||||
manager.unit_new.connect(on_unit_new);
|
manager.unit_new.connect(on_unit_new);
|
||||||
manager.job_new.connect(on_job_new);
|
manager.job_new.connect(on_job_new);
|
||||||
@ -317,7 +313,7 @@ public class MainWindow : Window {
|
|||||||
populate_job_model();
|
populate_job_model();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populate_unit_model() throws DBus.Error {
|
public void populate_unit_model() throws IOError {
|
||||||
unit_model.clear();
|
unit_model.clear();
|
||||||
|
|
||||||
var list = manager.list_units();
|
var list = manager.list_units();
|
||||||
@ -325,18 +321,17 @@ public class MainWindow : Window {
|
|||||||
foreach (var i in list) {
|
foreach (var i in list) {
|
||||||
TreeIter iter;
|
TreeIter iter;
|
||||||
|
|
||||||
Properties p = bus.get_object(
|
Properties p = Bus.get_proxy_sync(
|
||||||
|
user ? BusType.SESSION : BusType.SYSTEM,
|
||||||
"org.freedesktop.systemd1",
|
"org.freedesktop.systemd1",
|
||||||
i.unit_path,
|
i.unit_path);
|
||||||
"org.freedesktop.DBus.Properties") as Properties;
|
|
||||||
|
|
||||||
|
|
||||||
p.properties_changed.connect(on_unit_changed);
|
p.properties_changed.connect(on_unit_changed);
|
||||||
|
|
||||||
Unit u = bus.get_object(
|
Unit u = Bus.get_proxy_sync(
|
||||||
|
user ? BusType.SESSION : BusType.SYSTEM,
|
||||||
"org.freedesktop.systemd1",
|
"org.freedesktop.systemd1",
|
||||||
i.unit_path,
|
i.unit_path);
|
||||||
"org.freedesktop.systemd1.Unit") as Unit;
|
|
||||||
|
|
||||||
unit_model.append(out iter);
|
unit_model.append(out iter);
|
||||||
unit_model.set(iter,
|
unit_model.set(iter,
|
||||||
@ -350,7 +345,7 @@ public class MainWindow : Window {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populate_job_model() throws DBus.Error {
|
public void populate_job_model() throws IOError {
|
||||||
job_model.clear();
|
job_model.clear();
|
||||||
|
|
||||||
var list = manager.list_jobs();
|
var list = manager.list_jobs();
|
||||||
@ -358,17 +353,17 @@ public class MainWindow : Window {
|
|||||||
foreach (var i in list) {
|
foreach (var i in list) {
|
||||||
TreeIter iter;
|
TreeIter iter;
|
||||||
|
|
||||||
Properties p = bus.get_object(
|
Properties p = Bus.get_proxy_sync(
|
||||||
|
user ? BusType.SESSION : BusType.SYSTEM,
|
||||||
"org.freedesktop.systemd1",
|
"org.freedesktop.systemd1",
|
||||||
i.job_path,
|
i.job_path);
|
||||||
"org.freedesktop.DBus.Properties") as Properties;
|
|
||||||
|
|
||||||
p.properties_changed.connect(on_job_changed);
|
p.properties_changed.connect(on_job_changed);
|
||||||
|
|
||||||
Job j = bus.get_object(
|
Job j = Bus.get_proxy_sync(
|
||||||
|
user ? BusType.SESSION : BusType.SYSTEM,
|
||||||
"org.freedesktop.systemd1",
|
"org.freedesktop.systemd1",
|
||||||
i.job_path,
|
i.job_path);
|
||||||
"org.freedesktop.systemd1.Job") as Job;
|
|
||||||
|
|
||||||
job_model.append(out iter);
|
job_model.append(out iter);
|
||||||
job_model.set(iter,
|
job_model.set(iter,
|
||||||
@ -601,7 +596,7 @@ public class MainWindow : Window {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
u.start("replace");
|
u.start("replace");
|
||||||
} catch (DBus.Error e) {
|
} catch (IOError e) {
|
||||||
show_error(e.message);
|
show_error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -614,7 +609,7 @@ public class MainWindow : Window {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
u.stop("replace");
|
u.stop("replace");
|
||||||
} catch (DBus.Error e) {
|
} catch (IOError e) {
|
||||||
show_error(e.message);
|
show_error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -627,7 +622,7 @@ public class MainWindow : Window {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
u.reload("replace");
|
u.reload("replace");
|
||||||
} catch (DBus.Error e) {
|
} catch (IOError e) {
|
||||||
show_error(e.message);
|
show_error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -640,7 +635,7 @@ public class MainWindow : Window {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
u.restart("replace");
|
u.restart("replace");
|
||||||
} catch (DBus.Error e) {
|
} catch (IOError e) {
|
||||||
show_error(e.message);
|
show_error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -653,21 +648,22 @@ public class MainWindow : Window {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
j.cancel();
|
j.cancel();
|
||||||
} catch (DBus.Error e) {
|
} catch (IOError e) {
|
||||||
show_error(e.message);
|
show_error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update_unit_iter(TreeIter iter, string id, Unit u) {
|
public void update_unit_iter(TreeIter iter, string id, Unit u) {
|
||||||
|
|
||||||
|
try {
|
||||||
string t = "";
|
string t = "";
|
||||||
Unit.JobLink jl = u.job;
|
Unit.JobLink jl = u.job;
|
||||||
|
|
||||||
if (jl.id != 0) {
|
if (jl.id != 0) {
|
||||||
Job j = bus.get_object(
|
Job j = Bus.get_proxy_sync(
|
||||||
|
user ? BusType.SESSION : BusType.SYSTEM,
|
||||||
"org.freedesktop.systemd1",
|
"org.freedesktop.systemd1",
|
||||||
jl.path,
|
jl.path);
|
||||||
"org.freedesktop.systemd1.Job") as Job;
|
|
||||||
|
|
||||||
t = j.job_type;
|
t = j.job_type;
|
||||||
}
|
}
|
||||||
@ -680,25 +676,33 @@ public class MainWindow : Window {
|
|||||||
4, u.sub_state,
|
4, u.sub_state,
|
||||||
5, t != "" ? "→ %s".printf(t) : "",
|
5, t != "" ? "→ %s".printf(t) : "",
|
||||||
6, u);
|
6, u);
|
||||||
|
} catch (IOError e) {
|
||||||
|
show_error(e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void on_unit_new(string id, ObjectPath path) {
|
public void on_unit_new(string id, ObjectPath path) {
|
||||||
Properties p = bus.get_object(
|
try {
|
||||||
|
|
||||||
|
Properties p = Bus.get_proxy_sync(
|
||||||
|
user ? BusType.SESSION : BusType.SYSTEM,
|
||||||
"org.freedesktop.systemd1",
|
"org.freedesktop.systemd1",
|
||||||
path,
|
path);
|
||||||
"org.freedesktop.DBus.Properties") as Properties;
|
|
||||||
|
|
||||||
p.properties_changed.connect(on_unit_changed);
|
p.properties_changed.connect(on_unit_changed);
|
||||||
|
|
||||||
TreeIter iter;
|
TreeIter iter;
|
||||||
unit_model.append(out iter);
|
unit_model.append(out iter);
|
||||||
|
|
||||||
Unit u = bus.get_object(
|
Unit u = Bus.get_proxy_sync(
|
||||||
|
user ? BusType.SESSION : BusType.SYSTEM,
|
||||||
"org.freedesktop.systemd1",
|
"org.freedesktop.systemd1",
|
||||||
path,
|
path);
|
||||||
"org.freedesktop.systemd1.Unit") as Unit;
|
|
||||||
|
|
||||||
update_unit_iter(iter, id, u);
|
update_unit_iter(iter, id, u);
|
||||||
|
} catch (IOError e) {
|
||||||
|
show_error(e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update_job_iter(TreeIter iter, uint32 id, Job j) {
|
public void update_job_iter(TreeIter iter, uint32 id, Job j) {
|
||||||
@ -713,22 +717,28 @@ public class MainWindow : Window {
|
|||||||
|
|
||||||
public void on_job_new(uint32 id, ObjectPath path) {
|
public void on_job_new(uint32 id, ObjectPath path) {
|
||||||
|
|
||||||
Properties p = bus.get_object(
|
try {
|
||||||
|
|
||||||
|
Properties p = Bus.get_proxy_sync(
|
||||||
|
user ? BusType.SESSION : BusType.SYSTEM,
|
||||||
"org.freedesktop.systemd1",
|
"org.freedesktop.systemd1",
|
||||||
path,
|
path);
|
||||||
"org.freedesktop.DBus.Properties") as Properties;
|
|
||||||
|
|
||||||
p.properties_changed.connect(on_job_changed);
|
p.properties_changed.connect(on_job_changed);
|
||||||
|
|
||||||
TreeIter iter;
|
TreeIter iter;
|
||||||
job_model.append(out iter);
|
job_model.append(out iter);
|
||||||
|
|
||||||
Job j = bus.get_object(
|
Job j = Bus.get_proxy_sync(
|
||||||
|
user ? BusType.SESSION : BusType.SYSTEM,
|
||||||
"org.freedesktop.systemd1",
|
"org.freedesktop.systemd1",
|
||||||
path,
|
path);
|
||||||
"org.freedesktop.systemd1.Job") as Job;
|
|
||||||
|
|
||||||
update_job_iter(iter, id, j);
|
update_job_iter(iter, id, j);
|
||||||
|
|
||||||
|
} catch (IOError e) {
|
||||||
|
show_error(e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void on_unit_removed(string id, ObjectPath path) {
|
public void on_unit_removed(string id, ObjectPath path) {
|
||||||
@ -775,13 +785,15 @@ public class MainWindow : Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void on_unit_changed(Properties p, string iface, HashTable<string, Value?> changed_properties, string[] invalidated_properties) {
|
public void on_unit_changed(Properties p, string iface, HashTable<string, Value?> changed_properties, string[] invalidated_properties) {
|
||||||
|
|
||||||
|
try {
|
||||||
TreeIter iter;
|
TreeIter iter;
|
||||||
string id;
|
string id;
|
||||||
|
|
||||||
Unit u = bus.get_object(
|
Unit u = Bus.get_proxy_sync(
|
||||||
p.get_bus_name(),
|
user ? BusType.SESSION : BusType.SYSTEM,
|
||||||
p.get_path(),
|
p.get_name(),
|
||||||
"org.freedesktop.systemd1.Unit") as Unit;
|
p.get_object_path());
|
||||||
|
|
||||||
if (!(unit_model.get_iter_first(out iter)))
|
if (!(unit_model.get_iter_first(out iter)))
|
||||||
return;
|
return;
|
||||||
@ -803,16 +815,21 @@ public class MainWindow : Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} while (unit_model.iter_next(ref iter));
|
} while (unit_model.iter_next(ref iter));
|
||||||
|
|
||||||
|
} catch (IOError e) {
|
||||||
|
show_error(e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void on_job_changed(Properties p, string iface, HashTable<string, Value?> changed_properties, string[] invalidated_properties) {
|
public void on_job_changed(Properties p, string iface, HashTable<string, Value?> changed_properties, string[] invalidated_properties) {
|
||||||
|
try {
|
||||||
TreeIter iter;
|
TreeIter iter;
|
||||||
uint32 id;
|
uint32 id;
|
||||||
|
|
||||||
Job j = bus.get_object(
|
Job j = Bus.get_proxy_sync(
|
||||||
p.get_bus_name(),
|
user ? BusType.SESSION : BusType.SYSTEM,
|
||||||
p.get_path(),
|
p.get_name(),
|
||||||
"org.freedesktop.systemd1.Job") as Job;
|
p.get_object_path());
|
||||||
|
|
||||||
if (!(job_model.get_iter_first(out iter)))
|
if (!(job_model.get_iter_first(out iter)))
|
||||||
return;
|
return;
|
||||||
@ -834,6 +851,10 @@ public class MainWindow : Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} while (job_model.iter_next(ref iter));
|
} while (job_model.iter_next(ref iter));
|
||||||
|
|
||||||
|
} catch (IOError e) {
|
||||||
|
show_error(e.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool unit_filter(TreeModel model, TreeIter iter) {
|
public bool unit_filter(TreeModel model, TreeIter iter) {
|
||||||
@ -886,7 +907,7 @@ public class MainWindow : Window {
|
|||||||
public void on_server_reload() {
|
public void on_server_reload() {
|
||||||
try {
|
try {
|
||||||
manager.reload();
|
manager.reload();
|
||||||
} catch (DBus.Error e) {
|
} catch (IOError e) {
|
||||||
show_error(e.message);
|
show_error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -898,7 +919,7 @@ public class MainWindow : Window {
|
|||||||
if (unit_type_combo_box.get_active() != 0)
|
if (unit_type_combo_box.get_active() != 0)
|
||||||
unit_type_combo_box.set_active(8);
|
unit_type_combo_box.set_active(8);
|
||||||
|
|
||||||
} catch (DBus.Error e) {
|
} catch (IOError e) {
|
||||||
show_error(e.message);
|
show_error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -912,10 +933,10 @@ public class MainWindow : Window {
|
|||||||
try {
|
try {
|
||||||
var path = manager.load_unit(t);
|
var path = manager.load_unit(t);
|
||||||
|
|
||||||
Unit u = bus.get_object(
|
Unit u = Bus.get_proxy_sync(
|
||||||
|
user ? BusType.SESSION : BusType.SYSTEM,
|
||||||
"org.freedesktop.systemd1",
|
"org.freedesktop.systemd1",
|
||||||
path,
|
path);
|
||||||
"org.freedesktop.systemd1.Unit") as Unit;
|
|
||||||
|
|
||||||
var m = new MessageDialog(this,
|
var m = new MessageDialog(this,
|
||||||
DialogFlags.DESTROY_WITH_PARENT,
|
DialogFlags.DESTROY_WITH_PARENT,
|
||||||
@ -927,7 +948,7 @@ public class MainWindow : Window {
|
|||||||
m.destroy();
|
m.destroy();
|
||||||
|
|
||||||
show_unit(u);
|
show_unit(u);
|
||||||
} catch (DBus.Error e) {
|
} catch (IOError e) {
|
||||||
show_error(e.message);
|
show_error(e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -941,13 +962,13 @@ public class MainWindow : Window {
|
|||||||
try {
|
try {
|
||||||
string path = manager.get_unit(uri);
|
string path = manager.get_unit(uri);
|
||||||
|
|
||||||
Unit u = bus.get_object(
|
Unit u = Bus.get_proxy_sync(
|
||||||
|
user ? BusType.SESSION : BusType.SYSTEM,
|
||||||
"org.freedesktop.systemd1",
|
"org.freedesktop.systemd1",
|
||||||
path,
|
path);
|
||||||
"org.freedesktop.systemd1.Unit") as Unit;
|
|
||||||
|
|
||||||
show_unit(u);
|
show_unit(u);
|
||||||
} catch (DBus.Error e) {
|
} catch (IOError e) {
|
||||||
show_error(e.message);
|
show_error(e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -987,7 +1008,7 @@ int main(string[] args) {
|
|||||||
window.show_all();
|
window.show_all();
|
||||||
|
|
||||||
Gtk.main();
|
Gtk.main();
|
||||||
} catch (DBus.Error e) {
|
} catch (IOError e) {
|
||||||
show_error(e.message);
|
show_error(e.message);
|
||||||
} catch (GLib.Error e) {
|
} catch (GLib.Error e) {
|
||||||
show_error(e.message);
|
show_error(e.message);
|
||||||
|
@ -17,10 +17,8 @@
|
|||||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||||
***/
|
***/
|
||||||
|
|
||||||
using DBus;
|
|
||||||
|
|
||||||
[DBus (name = "org.freedesktop.systemd1.Manager")]
|
[DBus (name = "org.freedesktop.systemd1.Manager")]
|
||||||
public interface Manager : DBus.Object {
|
public interface Manager : DBusProxy {
|
||||||
|
|
||||||
public struct UnitInfo {
|
public struct UnitInfo {
|
||||||
string id;
|
string id;
|
||||||
@ -46,43 +44,43 @@ public interface Manager : DBus.Object {
|
|||||||
|
|
||||||
public abstract string[] environment { owned get; }
|
public abstract string[] environment { owned get; }
|
||||||
|
|
||||||
public abstract UnitInfo[] list_units() throws DBus.Error;
|
public abstract UnitInfo[] list_units() throws IOError;
|
||||||
public abstract JobInfo[] list_jobs() throws DBus.Error;
|
public abstract JobInfo[] list_jobs() throws IOError;
|
||||||
|
|
||||||
public abstract ObjectPath get_unit(string name) throws DBus.Error;
|
public abstract ObjectPath get_unit(string name) throws IOError;
|
||||||
public abstract ObjectPath get_unit_by_pid(uint32 pid) throws DBus.Error;
|
public abstract ObjectPath get_unit_by_pid(uint32 pid) throws IOError;
|
||||||
public abstract ObjectPath load_unit(string name) throws DBus.Error;
|
public abstract ObjectPath load_unit(string name) throws IOError;
|
||||||
public abstract ObjectPath get_job(uint32 id) throws DBus.Error;
|
public abstract ObjectPath get_job(uint32 id) throws IOError;
|
||||||
|
|
||||||
public abstract ObjectPath start_unit(string name, string mode = "replace") throws DBus.Error;
|
public abstract ObjectPath start_unit(string name, string mode = "replace") throws IOError;
|
||||||
public abstract ObjectPath stop_unit(string name, string mode = "replace") throws DBus.Error;
|
public abstract ObjectPath stop_unit(string name, string mode = "replace") throws IOError;
|
||||||
public abstract ObjectPath reload_unit(string name, string mode = "replace") throws DBus.Error;
|
public abstract ObjectPath reload_unit(string name, string mode = "replace") throws IOError;
|
||||||
public abstract ObjectPath restart_unit(string name, string mode = "replace") throws DBus.Error;
|
public abstract ObjectPath restart_unit(string name, string mode = "replace") throws IOError;
|
||||||
public abstract ObjectPath try_restart_unit(string name, string mode = "replace") throws DBus.Error;
|
public abstract ObjectPath try_restart_unit(string name, string mode = "replace") throws IOError;
|
||||||
public abstract ObjectPath reload_or_restart_unit(string name, string mode = "replace") throws DBus.Error;
|
public abstract ObjectPath reload_or_restart_unit(string name, string mode = "replace") throws IOError;
|
||||||
public abstract ObjectPath reload_or_try_restart_unit(string name, string mode = "replace") throws DBus.Error;
|
public abstract ObjectPath reload_or_try_restart_unit(string name, string mode = "replace") throws IOError;
|
||||||
|
|
||||||
public abstract void reset_failed_unit(string name = "") throws DBus.Error;
|
public abstract void reset_failed_unit(string name = "") throws IOError;
|
||||||
|
|
||||||
public abstract void clear_jobs() throws DBus.Error;
|
public abstract void clear_jobs() throws IOError;
|
||||||
|
|
||||||
public abstract void subscribe() throws DBus.Error;
|
public abstract void subscribe() throws IOError;
|
||||||
public abstract void unsubscribe() throws DBus.Error;
|
public abstract void unsubscribe() throws IOError;
|
||||||
|
|
||||||
public abstract string dump() throws DBus.Error;
|
public abstract string dump() throws IOError;
|
||||||
|
|
||||||
public abstract void reload() throws DBus.Error;
|
public abstract void reload() throws IOError;
|
||||||
public abstract void reexecute() throws DBus.Error;
|
public abstract void reexecute() throws IOError;
|
||||||
public abstract void exit() throws DBus.Error;
|
public abstract void exit() throws IOError;
|
||||||
public abstract void halt() throws DBus.Error;
|
public abstract void halt() throws IOError;
|
||||||
public abstract void power_off() throws DBus.Error;
|
public abstract void power_off() throws IOError;
|
||||||
public abstract void reboot() throws DBus.Error;
|
public abstract void reboot() throws IOError;
|
||||||
public abstract void kexec() throws DBus.Error;
|
public abstract void kexec() throws IOError;
|
||||||
|
|
||||||
public abstract ObjectPath create_snapshot(string name = "", bool cleanup = false) throws DBus.Error;
|
public abstract ObjectPath create_snapshot(string name = "", bool cleanup = false) throws IOError;
|
||||||
|
|
||||||
public abstract void set_environment(string[] names) throws DBus.Error;
|
public abstract void set_environment(string[] names) throws IOError;
|
||||||
public abstract void unset_environment(string[] names) throws DBus.Error;
|
public abstract void unset_environment(string[] names) throws IOError;
|
||||||
|
|
||||||
public abstract signal void unit_new(string id, ObjectPath path);
|
public abstract signal void unit_new(string id, ObjectPath path);
|
||||||
public abstract signal void unit_removed(string id, ObjectPath path);
|
public abstract signal void unit_removed(string id, ObjectPath path);
|
||||||
@ -91,7 +89,7 @@ public interface Manager : DBus.Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[DBus (name = "org.freedesktop.systemd1.Unit")]
|
[DBus (name = "org.freedesktop.systemd1.Unit")]
|
||||||
public interface Unit : DBus.Object {
|
public interface Unit : DBusProxy {
|
||||||
public struct JobLink {
|
public struct JobLink {
|
||||||
uint32 id;
|
uint32 id;
|
||||||
ObjectPath path;
|
ObjectPath path;
|
||||||
@ -136,19 +134,19 @@ public interface Unit : DBus.Object {
|
|||||||
public abstract bool need_daemon_reload { owned get; }
|
public abstract bool need_daemon_reload { owned get; }
|
||||||
public abstract uint64 job_timeout_usec { owned get; }
|
public abstract uint64 job_timeout_usec { owned get; }
|
||||||
|
|
||||||
public abstract ObjectPath start(string mode = "replace") throws DBus.Error;
|
public abstract ObjectPath start(string mode = "replace") throws IOError;
|
||||||
public abstract ObjectPath stop(string mode = "replace") throws DBus.Error;
|
public abstract ObjectPath stop(string mode = "replace") throws IOError;
|
||||||
public abstract ObjectPath reload(string mode = "replace") throws DBus.Error;
|
public abstract ObjectPath reload(string mode = "replace") throws IOError;
|
||||||
public abstract ObjectPath restart(string mode = "replace") throws DBus.Error;
|
public abstract ObjectPath restart(string mode = "replace") throws IOError;
|
||||||
public abstract ObjectPath try_restart(string mode = "replace") throws DBus.Error;
|
public abstract ObjectPath try_restart(string mode = "replace") throws IOError;
|
||||||
public abstract ObjectPath reload_or_restart(string mode = "replace") throws DBus.Error;
|
public abstract ObjectPath reload_or_restart(string mode = "replace") throws IOError;
|
||||||
public abstract ObjectPath reload_or_try_restart(string mode = "replace") throws DBus.Error;
|
public abstract ObjectPath reload_or_try_restart(string mode = "replace") throws IOError;
|
||||||
|
|
||||||
public abstract void reset_failed() throws DBus.Error;
|
public abstract void reset_failed() throws IOError;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DBus (name = "org.freedesktop.systemd1.Job")]
|
[DBus (name = "org.freedesktop.systemd1.Job")]
|
||||||
public interface Job : DBus.Object {
|
public interface Job : DBusProxy {
|
||||||
public struct UnitLink {
|
public struct UnitLink {
|
||||||
string id;
|
string id;
|
||||||
ObjectPath path;
|
ObjectPath path;
|
||||||
@ -159,11 +157,11 @@ public interface Job : DBus.Object {
|
|||||||
public abstract string job_type { owned get; }
|
public abstract string job_type { owned get; }
|
||||||
public abstract UnitLink unit { owned get; }
|
public abstract UnitLink unit { owned get; }
|
||||||
|
|
||||||
public abstract void cancel() throws DBus.Error;
|
public abstract void cancel() throws IOError;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DBus (name = "org.freedesktop.DBus.Properties")]
|
[DBus (name = "org.freedesktop.Properties")]
|
||||||
public interface Properties : DBus.Object {
|
public interface Properties : DBusProxy {
|
||||||
public abstract Value? get(string iface, string property) throws DBus.Error;
|
public abstract Variant? get(string iface, string property) throws IOError;
|
||||||
public abstract signal void properties_changed(string iface, HashTable<string, Value?> changed_properties, string[] invalidated_properties);
|
public abstract signal void properties_changed(string iface, HashTable<string, Variant?> changed_properties, string[] invalidated_properties);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user