logind-seat-dbus.c revision 28383ba18963cdedd98ced271b3425f7321119b7
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2011 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 <errno.h>
#include <string.h>
#include "util.h"
#include "bus-util.h"
#include "strv.h"
#include "bus-errors.h"
#include "logind.h"
#include "logind-seat.h"
static int property_get_active_session(
const char *path,
const char *interface,
const char *property,
void *userdata) {
_cleanup_free_ char *p = NULL;
assert(s);
if (!p)
return -ENOMEM;
}
static int property_get_can_multi_session(
const char *path,
const char *interface,
const char *property,
void *userdata) {
assert(s);
}
static int property_get_can_tty(
const char *path,
const char *interface,
const char *property,
void *userdata) {
assert(s);
}
static int property_get_can_graphical(
const char *path,
const char *interface,
const char *property,
void *userdata) {
assert(s);
}
static int property_get_sessions(
const char *path,
const char *interface,
const char *property,
void *userdata) {
int r;
assert(s);
if (r < 0)
return r;
_cleanup_free_ char *p = NULL;
p = session_bus_path(session);
if (!p)
return -ENOMEM;
if (r < 0)
return r;
}
if (r < 0)
return r;
return 1;
}
static int property_get_idle_hint(
const char *path,
const char *interface,
const char *property,
void *userdata) {
assert(s);
}
static int property_get_idle_since_hint(
const char *path,
const char *interface,
const char *property,
void *userdata) {
uint64_t u;
int r;
assert(s);
r = seat_get_idle_hint(s, &t);
if (r < 0)
return r;
}
int r;
assert(s);
r = seat_stop_sessions(s);
if (r < 0)
}
const char *name;
int r;
assert(s);
if (r < 0)
if (!session)
return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_NO_SUCH_SESSION, "No session '%s' known", name);
return sd_bus_reply_method_errorf(bus, message, BUS_ERROR_SESSION_NOT_ON_SEAT, "Session %s not on seat %s", name, s->id);
r = session_activate(session);
if (r < 0)
}
const sd_bus_vtable seat_vtable[] = {
SD_BUS_PROPERTY("ActiveSession", "(so)", property_get_active_session, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("CanGraphical", "b", property_get_can_graphical, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Sessions", "a(so)", property_get_sessions, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("IdleSinceHint", "t", property_get_idle_since_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("IdleSinceHintMonotonic", "t", property_get_idle_since_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
};
int seat_object_find(sd_bus *bus, const char *path, const char *interface, void **found, void *userdata) {
int r;
assert(m);
if (!message)
return 0;
if (r < 0)
return 0;
if (r <= 0)
return 0;
return 0;
} else {
_cleanup_free_ char *e = NULL;
const char *p;
if (!p)
return 0;
e = sd_bus_label_unescape(p);
if (!e)
return -ENOMEM;
if (!seat)
return 0;
}
return 1;
}
char *seat_bus_path(Seat *s) {
_cleanup_free_ char *t = NULL;
assert(s);
t = sd_bus_label_escape(s->id);
if (!t)
return NULL;
return strappend("/org/freedesktop/login1/seat/", t);
}
_cleanup_strv_free_ char **l = NULL;
Iterator i;
int r;
char *p;
p = seat_bus_path(seat);
if (!p)
return -ENOMEM;
r = strv_push(&l, p);
if (r < 0) {
free(p);
return r;
}
}
*nodes = l;
l = NULL;
return 1;
}
_cleanup_free_ char *p = NULL;
assert(s);
p = seat_bus_path(s);
if (!p)
return -ENOMEM;
return sd_bus_emit_signal(
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"so", s->id, p);
}
_cleanup_free_ char *p = NULL;
char **l;
assert(s);
if (!s->started)
return 0;
p = seat_bus_path(s);
if (!p)
return -ENOMEM;
}