forked from flensrocker/vdr-plugin-dbus2vdr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.c
51 lines (41 loc) · 1.66 KB
/
helper.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "helper.h"
#include <vdr/tools.h>
int cDBusHelper::GetNextArg(DBusMessageIter& args, int type, void *value)
{
if (dbus_message_iter_get_arg_type(&args) != type)
return -1;
dbus_message_iter_get_basic(&args, value);
if (dbus_message_iter_next(&args))
return 1;
return 0;
}
void cDBusHelper::SendReply(DBusConnection *conn, DBusMessage *msg, int returncode, const char *message)
{
DBusMessage *reply = dbus_message_new_method_return(msg);
DBusMessageIter args;
dbus_message_iter_init_append(reply, &args);
if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_INT32, &returncode))
esyslog("dbus2vdr: SendReply: out of memory while appending the return-code");
if (message != NULL) {
if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &message))
esyslog("dbus2vdr: SendReply: out of memory while appending the reply-message");
}
dbus_uint32_t serial = 0;
if (!dbus_connection_send(conn, reply, &serial))
esyslog("dbus2vdr: SendReply: out of memory while sending the reply");
dbus_message_unref(reply);
}
void cDBusHelper::SendReply(DBusConnection *conn, DBusMessage *msg, const char *message)
{
DBusMessage *reply = dbus_message_new_method_return(msg);
DBusMessageIter args;
dbus_message_iter_init_append(reply, &args);
if (message != NULL) {
if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &message))
esyslog("dbus2vdr: SendReply: out of memory while appending the reply-message");
}
dbus_uint32_t serial = 0;
if (!dbus_connection_send(conn, reply, &serial))
esyslog("dbus2vdr: SendReply: out of memory while sending the reply");
dbus_message_unref(reply);
}