logind-user-dbus.c revision b69d29ce049f12d463a589e18561dd10ee8c09f1
/*-*- 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 "logind.h"
#include "logind-user.h"
#include "dbus-common.h"
#define BUS_USER_INTERFACE \
" <interface name=\"org.freedesktop.login1.User\">\n" \
" <method name=\"Terminate\"/>\n" \
" <method name=\"Kill\">\n" \
" <arg name=\"signal\" type=\"s\"/>\n" \
" </method>\n" \
" <property name=\"UID\" type=\"u\" access=\"read\"/>\n" \
" <property name=\"GID\" type=\"u\" access=\"read\"/>\n" \
" <property name=\"Name\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"Timestamp\" type=\"t\" access=\"read\"/>\n" \
" <property name=\"TimestampMonotonic\" type=\"t\" access=\"read\"/>\n" \
" <property name=\"RuntimePath\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"DefaultControlGroup\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"Service\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"Display\" type=\"(so)\" access=\"read\"/>\n" \
" <property name=\"State\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"Sessions\" type=\"a(so)\" access=\"read\"/>\n" \
" <property name=\"IdleHint\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"IdleSinceHint\" type=\"t\" access=\"read\"/>\n" \
" <property name=\"IdleSinceHintMonotonic\" type=\"t\" access=\"read\"/>\n" \
" </interface>\n" \
#define INTROSPECTION \
"<node>\n" \
"</node>\n"
#define INTERFACES_LIST \
"org.freedesktop.login1.User\0"
char *p = NULL;
assert(i);
assert(u);
return -ENOMEM;
if (u->display) {
if (!p)
return -ENOMEM;
} else {
id = "";
path = "/";
}
free(p);
return -ENOMEM;
}
free(p);
if (!dbus_message_iter_close_container(i, &sub))
return -ENOMEM;
return 0;
}
const char *state;
assert(i);
assert(u);
return -ENOMEM;
return 0;
}
assert(i);
assert(u);
return -ENOMEM;
char *p;
return -ENOMEM;
p = session_bus_path(session);
if (!p)
return -ENOMEM;
free(p);
return -ENOMEM;
}
free(p);
return -ENOMEM;
}
if (!dbus_message_iter_close_container(i, &sub))
return -ENOMEM;
return 0;
}
dbus_bool_t b;
assert(i);
assert(u);
b = user_get_idle_hint(u, NULL) > 0;
if (!dbus_message_iter_append_basic(i, DBUS_TYPE_BOOLEAN, &b))
return -ENOMEM;
return 0;
}
uint64_t k;
assert(i);
assert(u);
user_get_idle_hint(u, &t);
if (!dbus_message_iter_append_basic(i, DBUS_TYPE_UINT64, &k))
return -ENOMEM;
return 0;
}
char *t;
int r;
bool success;
assert(i);
assert(u);
if (r < 0)
return r;
free(t);
}
User *u;
unsigned long lu;
int r;
assert(m);
return -EINVAL;
if (r < 0)
return r;
if (!u)
return -ENOENT;
*_u = u;
return 0;
}
static const BusProperty bus_login_user_properties[] = {
{ NULL, }
};
User *u,
DBusMessage *message) {
int r;
assert(u);
r = user_stop(u);
if (r < 0)
if (!reply)
goto oom;
if (!dbus_message_get_args(
&error,
if (r < 0)
if (!reply)
goto oom;
} else {
const BusBoundProperties bps[] = {
{ "org.freedesktop.login1.User", bus_login_user_properties, u },
{ NULL, }
};
}
if (reply) {
goto oom;
}
return DBUS_HANDLER_RESULT_HANDLED;
oom:
if (reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
}
void *userdata) {
User *u;
int r;
if (r < 0) {
if (r == -ENOMEM)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
if (r == -ENOENT) {
DBusError e;
dbus_error_init(&e);
}
}
}
const DBusObjectPathVTable bus_user_vtable = {
};
char *user_bus_path(User *u) {
char *s;
assert(u);
return NULL;
return s;
}
DBusMessage *m;
int r = -ENOMEM;
char *p = NULL;
assert(u);
m = dbus_message_new_signal("/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
if (!m)
return -ENOMEM;
p = user_bus_path(u);
if (!p)
goto finish;
if (!dbus_message_append_args(
m,
goto finish;
goto finish;
r = 0;
free(p);
return r;
}
DBusMessage *m;
int r = -ENOMEM;
char *p = NULL;
assert(u);
if (!u->started)
return 0;
p = user_bus_path(u);
if (!p)
return -ENOMEM;
if (!m)
goto finish;
goto finish;
r = 0;
if (m)
free(p);
return r;
}