dbus-job.c revision 718db96199eb307751264e4163555662c9a389fa
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "log.h"
#include "sd-bus.h"
#include "selinux-access.h"
#include "job.h"
#include "dbus-job.h"
#include "dbus-client-track.h"
static int property_get_unit(
const char *path,
const char *interface,
const char *property,
void *userdata) {
_cleanup_free_ char *p = NULL;
assert(j);
p = unit_dbus_path(j->unit);
if (!p)
return -ENOMEM;
}
assert(j);
job_finish_and_invalidate(j, JOB_CANCELED, true);
}
const sd_bus_vtable bus_job_vtable[] = {
SD_BUS_PROPERTY("State", "s", property_get_state, offsetof(Job, state), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
};
Iterator i;
sd_bus *b;
unsigned n, m;
int r;
assert(j);
m = set_size(j->subscribed);
if (n <= 0 && m <= 0)
return 0;
if (n == 1 && m == 0)
else if (n == 0 && m == 1)
else
if (one_destination)
return send_message(one_destination->bus, isempty(one_destination->name) ? NULL : one_destination->name, j);
/* Send to everybody */
r = send_message(b, NULL, j);
if (r < 0)
return r;
}
return 0;
}
_cleanup_free_ char *p = NULL;
int r;
assert(j);
p = job_dbus_path(j);
if (!p)
return -ENOMEM;
bus,
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"JobNew",
&m);
if (r < 0)
return r;
if (r < 0)
return r;
}
_cleanup_free_ char *p = NULL;
assert(j);
p = job_dbus_path(j);
if (!p)
return -ENOMEM;
}
void bus_job_send_change_signal(Job *j) {
int r;
assert(j);
if (j->in_dbus_queue) {
j->in_dbus_queue = false;
}
if (r < 0)
j->sent_dbus_new_signal = true;
}
_cleanup_free_ char *p = NULL;
int r;
assert(j);
p = job_dbus_path(j);
if (!p)
return -ENOMEM;
bus,
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"JobRemoved",
&m);
if (r < 0)
return r;
if (r < 0)
return r;
}
void bus_job_send_removed_signal(Job *j) {
int r;
assert(j);
if (!j->sent_dbus_new_signal)
r = foreach_client(j, send_removed_signal);
if (r < 0)
return;
}