提交 bd93dea3 编写于 作者: D Daniel P. Berrange

Add DBus helper methods for creating reply messages

The test suites often have to create DBus method reply messages
with payloads. Create two helpers for simplifying the process
of creating replies with payloads.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 838d0b04
......@@ -1165,6 +1165,8 @@ virDBusCallMethod;
virDBusCloseSystemBus;
virDBusCreateMethod;
virDBusCreateMethodV;
virDBusCreateReply;
virDBusCreateReplyV;
virDBusGetSessionBus;
virDBusGetSystemBus;
virDBusHasSystemBus;
......
......@@ -1228,6 +1228,66 @@ int virDBusCreateMethod(DBusMessage **call,
}
/**
* virDBusCreateReplyV:
* @reply: pointer to be filled with a method reply message
* @types: type signature for following method arguments
* @args: method arguments
*
* This creates a DBus method reply message and saves a
* pointer to it in @reply.
*
* The @types parameter is a DBus signature describing
* the method call parameters which will be provided
* as variadic args. See virDBusCreateMethodV for a
* description of this parameter.
*/
int virDBusCreateReplyV(DBusMessage **reply,
const char *types,
va_list args)
{
int ret = -1;
if (!(*reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN))) {
virReportOOMError();
goto cleanup;
}
if (virDBusMessageEncodeArgs(*reply, types, args) < 0) {
dbus_message_unref(*reply);
*reply = NULL;
goto cleanup;
}
ret = 0;
cleanup:
return ret;
}
/**
* virDBusCreateReply:
* @reply: pointer to be filled with a method reply message
* @types: type signature for following method arguments
* @...: method arguments
*
* See virDBusCreateReplyV for a description of the
* behaviour of this method.
*/
int virDBusCreateReply(DBusMessage **reply,
const char *types, ...)
{
va_list args;
int ret;
va_start(args, types);
ret = virDBusCreateReplyV(reply, types, args);
va_end(args);
return ret;
}
/**
* virDBusCall:
* @conn: a DBus connection
......
......@@ -53,6 +53,11 @@ int virDBusCreateMethodV(DBusMessage **call,
const char *member,
const char *types,
va_list args);
int virDBusCreateReply(DBusMessage **reply,
const char *types, ...);
int virDBusCreateReplyV(DBusMessage **reply,
const char *types,
va_list args);
int virDBusCallMethod(DBusConnection *conn,
DBusMessage **reply,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册