logind-user-dbus.c revision ca56b0a68300b035c605bedc5b339128897debfc
/*-*- 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 "strv.h"
#include "bus-util.h"
#include "logind.h"
#include "logind-user.h"
static int property_get_display(
const char *path,
const char *interface,
const char *property,
void *userdata,
sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
assert(u);
if (!p)
return -ENOMEM;
}
static int property_get_state(
const char *path,
const char *interface,
const char *property,
void *userdata,
sd_bus_error *error) {
assert(u);
}
static int property_get_sessions(
const char *path,
const char *interface,
const char *property,
void *userdata,
sd_bus_error *error) {
int r;
assert(u);
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,
sd_bus_error *error) {
assert(u);
}
static int property_get_idle_since_hint(
const char *path,
const char *interface,
const char *property,
void *userdata,
sd_bus_error *error) {
uint64_t k;
assert(u);
user_get_idle_hint(u, &t);
}
static int property_get_linger(
const char *path,
const char *interface,
const char *property,
void *userdata,
sd_bus_error *error) {
int r;
assert(u);
r = user_check_linger_file(u);
}
static int method_terminate(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *error) {
int r;
assert(u);
r = user_stop(u, true);
if (r < 0)
return r;
}
int r;
assert(u);
if (r < 0)
return r;
if (r < 0)
return r;
}
const sd_bus_vtable user_vtable[] = {
SD_BUS_PROPERTY("UID", "u", bus_property_get_uid, offsetof(User, uid), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("GID", "u", bus_property_get_gid, offsetof(User, gid), SD_BUS_VTABLE_PROPERTY_CONST),
SD_BUS_PROPERTY("RuntimePath", "s", NULL, offsetof(User, runtime_path), SD_BUS_VTABLE_PROPERTY_CONST),
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 user_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
int r;
assert(m);
if (!message)
return 0;
if (r < 0)
return r;
} else {
const char *p;
if (!p)
return 0;
}
if (r < 0)
return 0;
if (!user)
return 0;
return 1;
}
char *user_bus_path(User *u) {
char *s;
assert(u);
return NULL;
return s;
}
int user_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
Iterator i;
int r;
char *p;
p = user_bus_path(user);
if (!p)
return -ENOMEM;
r = strv_consume(&l, p);
if (r < 0)
return r;
}
if (message) {
if (r >= 0) {
if (r >= 0) {
if (user) {
r = strv_extend(&l, "/org/freedesktop/login1/user/self");
if (r < 0)
return r;
}
}
}
}
*nodes = l;
l = NULL;
return 1;
}
_cleanup_free_ char *p = NULL;
assert(u);
p = user_bus_path(u);
if (!p)
return -ENOMEM;
return sd_bus_emit_signal(
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
}
_cleanup_free_ char *p = NULL;
char **l;
assert(u);
if (!u->started)
return 0;
p = user_bus_path(u);
if (!p)
return -ENOMEM;
}