{
dbus_interface_s *iface_s = (dbus_interface_s *)user_data;
const dbus_method_s *methods;
- GVariant *result = NULL;
+ GVariant *reply = NULL;
/* todo: ghash ? */
methods = _dbus_handle_lookup_method(iface_s->list_methods, name);
if (methods) {
- result = methods->func(conn, sender, path, iface, name, param, invocation, get_dh_from_oh(iface_s->oh));
+ reply = methods->func(conn, sender, path, iface, name, param, invocation, get_dh_from_oh(iface_s->oh));
/* async, maybe they will reply...maybe.. */
- if (!result)
+ if (!reply)
return;
} else {
_E("no methods");
}
- g_dbus_method_invocation_return_value(invocation, result);
+ g_dbus_method_invocation_return_value(invocation, reply);
}
static GDBusInterfaceVTable path_vtable = {_method_call_handler};
dcl_dbus_handle();
dbus_object_handle_s *oh = NULL;
dbus_interface_s *ih = NULL;
- int ret = 0;
+ int ret_dbus = 0;
if (!dh) {
dh = _dbus_handle_get_default_connection();
if (ih && ih->list_methods)
_D("method list len %d", g_list_length(ih->list_methods));*/
- ret = _dbus_handle_register_dbus_object(dh, oh->path, ih);
- if (ret <= 0)
- _E("failed to register dbus object%d", ret);
+ ret_dbus = _dbus_handle_register_dbus_object(dh, oh->path, ih);
+ if (ret_dbus <= 0)
+ _E("failed to register dbus object%d", ret_dbus);
}
}
const char *iface,
const char *method,
GVariant *param,
- GVariant **reply)
+ GVariant **out_reply)
{
GError *err = NULL;
- GVariant *ret = NULL;
- int err_val = 0;
+ GVariant *reply = NULL;
+ int ret = 0;
dbus_handle_s *dh = NULL;
if (!dest || !path || !iface || !method) {
return -ECOMM;
}
- ret = g_dbus_connection_call_sync(dh->conn,
+ reply = g_dbus_connection_call_sync(dh->conn,
dest, path, iface, method,
param, NULL,
G_DBUS_CALL_FLAGS_NONE,
DBUS_REPLY_TIMEOUT,
NULL,
&err);
- if (!ret || err) {
+ if (!reply || err) {
if (err) {
_E("failed to g_dbus_connection_call_sync:%s", err->message);
if (g_error_matches(err, G_DBUS_ERROR, G_DBUS_ERROR_ACCESS_DENIED))
- err_val = -EPERM;
+ ret = -EPERM;
else
- err_val = -ECOMM;
+ ret = -ECOMM;
g_error_free(err);
- return err_val;
+ return ret;
} else {
_E("failed to g_dbus_connection_call_sync");
}
return -ECOMM;
}
- if(reply)
- *reply = ret;
+ if(out_reply)
+ *out_reply = reply;
else
- g_variant_unref(ret);
+ g_variant_unref(reply);
- return err_val;
+ return ret;
}
int dbus_handle_method_sync_with_reply_var_timeout(const char *dest, const char *path,
- const char *iface, const char *method, GVariant *param, GVariant **reply, int timeout)
+ const char *iface, const char *method, GVariant *param, GVariant **out_reply, int timeout)
{
GError *err = NULL;
- GVariant *ret;
+ GVariant *reply;
dbus_handle_s *dh = NULL;
if (!dest || !path || !iface || !method) {
return -ECOMM;
}
- ret = g_dbus_connection_call_sync(dh->conn,
+ reply = g_dbus_connection_call_sync(dh->conn,
dest, path, iface, method,
param, NULL,
G_DBUS_CALL_FLAGS_NONE,
timeout,
NULL,
&err);
- if (!ret || err) {
+ if (!reply || err) {
if (err) {
_E("failed to g_dbus_connection_call_sync:%s", err->message);
g_error_free(err);
return -ECOMM;
}
- if(reply)
- *reply = ret;
+ if(out_reply)
+ *out_reply = reply;
else
- g_variant_unref(ret);
+ g_variant_unref(reply);
return 0;
}
va_list args)
{
GError *err = NULL;
- GVariant * reply = NULL;
+ GVariant *reply = NULL;
char *key, *value;
int ret = 0;
GVariant *var;
const char *iface,
const char *method,
GVariant *param,
- GVariant **reply,
+ GVariant **out_reply,
int *in_fdlist,
int in_size,
int **out_fdlist,
int *out_size)
{
- int err_val = 0;
- GVariant *ret = NULL;
+ int ret = 0;
+ GVariant *reply = NULL;
GError *err = NULL;
dbus_handle_s *dh = NULL;
GUnixFDList *g_infdlist = NULL;
g_infdlist = g_unix_fd_list_new_from_array(in_fdlist, in_size);
if (!g_infdlist) {
_E("failed to g_unix_fd_list_new_from_array\n");
- err_val = -EAGAIN;
+ ret = -EAGAIN;
goto out;
}
//g_infdlist = g_unix_fd_list_new();
}
/* send message */
- ret = g_dbus_connection_call_with_unix_fd_list_sync(dh->conn,
+ reply = g_dbus_connection_call_with_unix_fd_list_sync(dh->conn,
dest, path, iface, method,
param, NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
g_infdlist, &g_outfdlist,
NULL, &err);
- if (!ret || err) {
+ if (!reply || err) {
if (err) {
_E("failed to g_dbus_connection_call_with_unix_fd_list_sync:%s", err->message);
g_error_free(err);
if (g_infdlist)
g_object_unref(g_infdlist);
}
- err_val = -EAGAIN;
+ ret = -EAGAIN;
goto out;
}
- if(reply)
- *reply = ret;
+ if(out_reply)
+ *out_reply = reply;
else
- g_variant_unref(ret);
+ g_variant_unref(reply);
/* copy fds to out array */
if (g_outfdlist) {
out:
if (g_outfdlist)
g_object_unref(g_outfdlist);
- return err_val;
+ return ret;
}
int dbus_handle_method_sync_var(const char *dest,
int dbus_connection_get_sender_pid(GDBusConnection *conn, const char * sender)
{
GError *err = NULL;
- GVariant *vret = NULL;
+ GVariant *reply = NULL;
pid_t pid = 0;
if (!conn) {
return -1;
}
- vret = g_dbus_connection_call_sync(conn,
+ reply = g_dbus_connection_call_sync(conn,
"org.freedesktop.DBus", "/", "org.freedesktop.DBus", "GetConnectionUnixProcessID",
g_variant_new("(s)", sender), NULL,
G_DBUS_CALL_FLAGS_NONE,
DBUS_REPLY_TIMEOUT,
NULL,
&err);
- if (!vret || err) {
+ if (!reply || err) {
_E("failed to g_dbus_connection_call_sync:%s", err->message);
g_error_free(err);
return -1;
}
- g_variant_get(vret, "(u)", &pid);
- g_variant_unref(vret);
+ g_variant_get(reply, "(u)", &pid);
+ g_variant_unref(reply);
return pid;
}
int dbus_handle_get_sender_credentials(dbus_handle_h handle, const char *name, GDBusCredentials *creds)
{
dcl_dbus_handle();
- GVariant *vret = NULL;
+ GVariant *reply = NULL;
GError *err = NULL;
GVariantIter *iter = NULL;
char * item;
return -1;
}
}
- vret = g_dbus_connection_call_sync(dh->conn,
+ reply = g_dbus_connection_call_sync(dh->conn,
DBUS_BUS_NAME,
DBUS_OBJECT_PATH,
DBUS_INTERFACE_NAME,
DBUS_REPLY_TIMEOUT,
NULL,
&err);
- if (!vret || err) {
+ if (!reply || err) {
_E("failed to g_dbus_connection_call_sync:%s", err->message);
return -1;
}
- g_variant_get(vret, "(a{sv})", &iter);
+ g_variant_get(reply, "(a{sv})", &iter);
while (g_variant_iter_loop(iter, "{sv}", &item, &sub)) {
if (!g_strcmp0(item, "UnixUserID")) {
if (iter)
g_variant_iter_free(iter);
- if (vret)
- g_variant_unref(vret);
+ if (reply)
+ g_variant_unref(reply);
return 0;
}
int _get_cmdline_name(pid_t pid, char *cmdline, size_t cmdline_size)
{
- int fd, ret;
+ int fd, ret_file;
char buf[PATH_MAX + 1];
char *filename;
return -1;
}
- ret = read(fd, buf, PATH_MAX);
+ ret_file = read(fd, buf, PATH_MAX);
close(fd);
- if (ret < 0)
+ if (ret_file < 0)
return -1;
buf[PATH_MAX] = '\0';
{
dcl_dbus_handle();
GError *err = NULL;
- GVariant *vret = NULL;
+ GVariant *reply = NULL;
GVariantIter *iter = NULL;
gchar **strv = NULL;
gchar *str = NULL;
}
}
- vret = g_dbus_connection_call_sync(dh->conn,
+ reply = g_dbus_connection_call_sync(dh->conn,
"org.freedesktop.DBus",
"/",
"org.freedesktop.DBus",
DBUS_REPLY_TIMEOUT,
NULL,
&err);
- if (!vret || err) {
+ if (!reply || err) {
_E("failed to g_dbus_connection_call_sync:%s", err->message);
g_error_free(err);
return NULL;
}
- g_variant_get(vret, "(as)", &iter);
+ g_variant_get(reply, "(as)", &iter);
strv = g_new(gchar *, g_variant_iter_n_children(iter) + 1);
i = 0;
strv[i] = NULL;
g_variant_iter_free(iter);
- g_variant_unref(vret);
+ g_variant_unref(reply);
return strv;
}
int check_systemd_active(void)
{
int ret = FALSE;
- GVariant *msg = NULL;
+ GVariant *reply = NULL;
GVariant *var = NULL;
char *state;
"org.freedesktop.DBus.Properties",
"Get",
g_variant_new("(ss)", "org.freedesktop.systemd1.Unit", "ActiveState"),
- &msg);
+ &reply);
if (ret < 0)
return ret;
- if (!msg)
+ if (!reply)
return -EBADMSG;
- if (!g_variant_get_safe(msg, "(v)", &var)) {
+ if (!g_variant_get_safe(reply, "(v)", &var)) {
_E("reply is not variant type");
ret = -EBADMSG;
goto out;
out:
if (var)
g_variant_unref(var);
- if (msg)
- g_variant_unref(msg);
+ if (reply)
+ g_variant_unref(reply);
return ret;
}
{
GVariant *reply = NULL;
GVariant *val = NULL;
- int ret = 0;
+ int ret_dbus = 0;
if (!property)
return NULL;
- ret = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
+ ret_dbus = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
SYSTEMD_DBUS_PATH,
DBUS_IFACE_DBUS_PROPERTIES,
"Get",
g_variant_new("(ss)", SYSTEMD_DBUS_MANAGER_IFACE, property),
&reply);
- if (!reply || !g_variant_get_safe(reply, "(v)", &val) || ret < 0)
+ if (ret_dbus < 0 || !g_variant_get_safe(reply, "(v)", &val))
_E("Failed to get variant");
if (reply)
g_variant_unref(reply);
char *escaped;
GVariant *reply = NULL;
GVariant *val = NULL;
- int ret = 0;
+ int ret_dbus = 0;
if (!unit || !property)
return NULL;
escaped = systemd_get_unit_dbus_path(unit);
- ret = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
+ ret_dbus = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
escaped,
DBUS_IFACE_DBUS_PROPERTIES,
"Get",
g_variant_new("(ss)", SYSTEMD_DBUS_UNIT_IFACE, property),
&reply);
- if (!reply || !g_variant_get_safe(reply, "(v)", &val) || ret < 0)
+ if (ret_dbus < 0 || !g_variant_get_safe(reply, "(v)", &val))
_E("Failed to get variant");
if (reply)
g_variant_unref(reply);
char *escaped;
GVariant *reply = NULL;
GVariant *val = NULL;
- int ret = 0;
+ int ret_dbus = 0;
if (!unit || !property)
return NULL;
escaped = systemd_get_unit_dbus_path(unit);
- ret = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
+ ret_dbus = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
escaped,
DBUS_IFACE_DBUS_PROPERTIES,
"Get",
g_variant_new("(ss)", SYSTEMD_DBUS_SERVICE_IFACE, property),
&reply);
- if (!reply || !g_variant_get_safe(reply, "(v)", &val) || ret < 0)
+ if (ret_dbus < 0 || !g_variant_get_safe(reply, "(v)", &val))
_E("Failed to get variant");
if (reply)
g_variant_unref(reply);