summaryrefslogtreecommitdiffstats
path: root/server/providers/data_provider_be.c
diff options
context:
space:
mode:
Diffstat (limited to 'server/providers/data_provider_be.c')
-rw-r--r--server/providers/data_provider_be.c82
1 files changed, 46 insertions, 36 deletions
diff --git a/server/providers/data_provider_be.c b/server/providers/data_provider_be.c
index 7b491ce78..26a78efb2 100644
--- a/server/providers/data_provider_be.c
+++ b/server/providers/data_provider_be.c
@@ -44,8 +44,8 @@
typedef int (*be_init_fn_t)(TALLOC_CTX *, struct be_mod_ops **, void **);
-static int service_identity(DBusMessage *message, void *data, DBusMessage **r);
-static int service_pong(DBusMessage *message, void *data, DBusMessage **r);
+static int service_identity(DBusMessage *message, struct sbus_conn_ctx *sconn);
+static int service_pong(DBusMessage *message, struct sbus_conn_ctx *sconn);
struct sbus_method mon_sbus_methods[] = {
{ SERVICE_METHOD_IDENTITY, service_identity },
@@ -53,9 +53,9 @@ struct sbus_method mon_sbus_methods[] = {
{ NULL, NULL }
};
-static int be_identity(DBusMessage *message, void *data, DBusMessage **r);
-static int be_check_online(DBusMessage *message, void *data, DBusMessage **r);
-static int be_get_account_info(DBusMessage *message, void *data, DBusMessage **r);
+static int be_identity(DBusMessage *message, struct sbus_conn_ctx *sconn);
+static int be_check_online(DBusMessage *message, struct sbus_conn_ctx *sconn);
+static int be_get_account_info(DBusMessage *message, struct sbus_conn_ctx *sconn);
struct sbus_method be_methods[] = {
{ DP_CLI_METHOD_IDENTITY, be_identity },
@@ -64,19 +64,15 @@ struct sbus_method be_methods[] = {
{ NULL, NULL }
};
-static int service_identity(DBusMessage *message, void *data, DBusMessage **r)
+static int service_identity(DBusMessage *message, struct sbus_conn_ctx *sconn)
{
dbus_uint16_t version = DATA_PROVIDER_VERSION;
- struct sbus_message_handler_ctx *smh_ctx;
struct be_ctx *ctx;
DBusMessage *reply;
dbus_bool_t ret;
void *user_data;
- if (!data) return EINVAL;
- smh_ctx = talloc_get_type(data, struct sbus_message_handler_ctx);
- if (!smh_ctx) return EINVAL;
- user_data = sbus_conn_get_private_data(smh_ctx->conn_ctx);
+ user_data = sbus_conn_get_private_data(sconn);
if (!user_data) return EINVAL;
ctx = talloc_get_type(user_data, struct be_ctx);
if (!ctx) return EINVAL;
@@ -84,47 +80,55 @@ static int service_identity(DBusMessage *message, void *data, DBusMessage **r)
DEBUG(4,("Sending ID reply: (%s,%d)\n", ctx->identity, version));
reply = dbus_message_new_method_return(message);
+ if (!reply) return ENOMEM;
+
ret = dbus_message_append_args(reply,
DBUS_TYPE_STRING, &ctx->identity,
DBUS_TYPE_UINT16, &version,
DBUS_TYPE_INVALID);
if (!ret) {
+ dbus_message_unref(reply);
return EIO;
}
- *r = reply;
+ /* send reply back */
+ sbus_conn_send_reply(sconn, reply);
+ dbus_message_unref(reply);
+
return EOK;
}
-static int service_pong(DBusMessage *message, void *data, DBusMessage **r)
+static int service_pong(DBusMessage *message, struct sbus_conn_ctx *sconn)
{
DBusMessage *reply;
dbus_bool_t ret;
reply = dbus_message_new_method_return(message);
+ if (!reply) return ENOMEM;
+
ret = dbus_message_append_args(reply, DBUS_TYPE_INVALID);
if (!ret) {
+ dbus_message_unref(reply);
return EIO;
}
- *r = reply;
+ /* send reply back */
+ sbus_conn_send_reply(sconn, reply);
+ dbus_message_unref(reply);
+
return EOK;
}
-static int be_identity(DBusMessage *message, void *data, DBusMessage **r)
+static int be_identity(DBusMessage *message, struct sbus_conn_ctx *sconn)
{
dbus_uint16_t version = DATA_PROVIDER_VERSION;
dbus_uint16_t clitype = DP_CLI_BACKEND;
- struct sbus_message_handler_ctx *smh_ctx;
struct be_ctx *ctx;
DBusMessage *reply;
dbus_bool_t ret;
void *user_data;
- if (!data) return EINVAL;
- smh_ctx = talloc_get_type(data, struct sbus_message_handler_ctx);
- if (!smh_ctx) return EINVAL;
- user_data = sbus_conn_get_private_data(smh_ctx->conn_ctx);
+ user_data = sbus_conn_get_private_data(sconn);
if (!user_data) return EINVAL;
ctx = talloc_get_type(user_data, struct be_ctx);
if (!ctx) return EINVAL;
@@ -133,6 +137,8 @@ static int be_identity(DBusMessage *message, void *data, DBusMessage **r)
clitype, version, ctx->name, ctx->domain));
reply = dbus_message_new_method_return(message);
+ if (!reply) return ENOMEM;
+
ret = dbus_message_append_args(reply,
DBUS_TYPE_UINT16, &clitype,
DBUS_TYPE_UINT16, &version,
@@ -140,10 +146,14 @@ static int be_identity(DBusMessage *message, void *data, DBusMessage **r)
DBUS_TYPE_STRING, &ctx->domain,
DBUS_TYPE_INVALID);
if (!ret) {
+ dbus_message_unref(reply);
return EIO;
}
- *r = reply;
+ /* send reply back */
+ sbus_conn_send_reply(sconn, reply);
+ dbus_message_unref(reply);
+
return EOK;
}
@@ -237,9 +247,8 @@ static void online_chk_callback(struct be_req *req, int status,
}
-static int be_check_online(DBusMessage *message, void *data, DBusMessage **r)
+static int be_check_online(DBusMessage *message, struct sbus_conn_ctx *sconn)
{
- struct sbus_message_handler_ctx *smh_ctx;
struct be_online_req *req;
struct be_req *be_req;
struct be_ctx *ctx;
@@ -252,15 +261,13 @@ static int be_check_online(DBusMessage *message, void *data, DBusMessage **r)
dbus_uint32_t err_min;
const char *err_msg;
- if (!data) return EINVAL;
- smh_ctx = talloc_get_type(data, struct sbus_message_handler_ctx);
- if (!smh_ctx) return EINVAL;
- user_data = sbus_conn_get_private_data(smh_ctx->conn_ctx);
+ user_data = sbus_conn_get_private_data(sconn);
if (!user_data) return EINVAL;
ctx = talloc_get_type(user_data, struct be_ctx);
if (!ctx) return EINVAL;
reply = dbus_message_new_method_return(message);
+ if (!reply) return ENOMEM;
/* process request */
be_req = talloc(ctx, struct be_req);
@@ -311,7 +318,10 @@ done:
DBUS_TYPE_INVALID);
if (!dbret) return EIO;
- *r = reply;
+ /* send reply back */
+ sbus_conn_send_reply(sconn, reply);
+ dbus_message_unref(reply);
+
return EOK;
}
@@ -355,9 +365,8 @@ static void acctinfo_callback(struct be_req *req, int status,
talloc_free(req);
}
-static int be_get_account_info(DBusMessage *message, void *data, DBusMessage **r)
+static int be_get_account_info(DBusMessage *message, struct sbus_conn_ctx *sconn)
{
- struct sbus_message_handler_ctx *smh_ctx;
struct be_acct_req *req;
struct be_req *be_req;
struct be_ctx *ctx;
@@ -375,12 +384,8 @@ static int be_get_account_info(DBusMessage *message, void *data, DBusMessage **r
const char *err_msg;
be_req = NULL;
- *r = NULL;
- if (!data) return EINVAL;
- smh_ctx = talloc_get_type(data, struct sbus_message_handler_ctx);
- if (!smh_ctx) return EINVAL;
- user_data = sbus_conn_get_private_data(smh_ctx->conn_ctx);
+ user_data = sbus_conn_get_private_data(sconn);
if (!user_data) return EINVAL;
ctx = talloc_get_type(user_data, struct be_ctx);
if (!ctx) return EINVAL;
@@ -394,12 +399,14 @@ static int be_get_account_info(DBusMessage *message, void *data, DBusMessage **r
DBUS_TYPE_INVALID);
if (!ret) {
DEBUG(1,("Failed, to parse message!\n"));
+ if (dbus_error_is_set(&dbus_error)) dbus_error_free(&dbus_error);
return EIO;
}
DEBUG(4, ("Got request for [%u][%s][%s]\n", type, attrs, filter));
reply = dbus_message_new_method_return(message);
+ if (!reply) return ENOMEM;
if (attrs) {
if (strcmp(attrs, "core") == 0) attr_type = BE_ATTR_CORE;
@@ -489,7 +496,10 @@ done:
DEBUG(4, ("Request processed. Returned %d,%d,%s\n",
err_maj, err_min, err_msg));
- *r = reply;
+ /* send reply back */
+ sbus_conn_send_reply(sconn, reply);
+ dbus_message_unref(reply);
+
return EOK;
}