10 #include "wvdbusmsg.h"
11 #undef interface // windows
12 #include <dbus/dbus.h>
15 static int wvdbus_message_length(
const char *buf,
size_t len)
17 int msglen = dbus_message_demarshal_bytes_needed(buf, len);
21 return DBUS_MINIMUM_HEADER_SIZE;
33 size_t buflen = buf.
used();
34 alignedbuf.put(buf.
peek(0, buflen), buflen);
38 size_t messagelen = wvdbus_message_length((
const char *)
39 alignedbuf.
peek(0, buflen),
46 else if (messagelen > buflen)
51 dbus_error_init(&error);
52 DBusMessage *_msg = dbus_message_demarshal((
const char *)
53 alignedbuf.
peek(0, buflen),
55 if (dbus_error_is_set(&error))
56 dbus_error_free (&error);
62 dbus_message_unref(_msg);
76 size_t used = buf.
used();
77 alignedbuf.put(buf.
peek(0, used), used);
79 return wvdbus_message_length((
const char *)alignedbuf.
peek(0, used), used);
85 DBusMessage *msg = *
this;
87 static uint32_t global_serial = 1000;
88 if (!dbus_message_get_serial(msg))
90 dbus_message_set_serial(msg, ++global_serial);
93 dbus_message_lock (msg);
96 dbus_message_marshal(msg, &cbuf, &len);
static size_t demarshal_bytes_needed(WvBuf &buf)
Given a buffer containing what might be the header of a DBus message, checks how many bytes need to b...
void marshal(WvBuf &buf)
Locks this message, encodes it in DBus binary protocol format, and adds it to the given buffer...
Specialization of WvBufBase for unsigned char type buffers intended for use with raw memory buffers...
size_t used() const
Returns the number of elements in the buffer currently available for reading.
const T * peek(int offset, size_t count)
Returns a const pointer into the buffer at the specified offset to the specified number of elements w...
static WvDBusMsg * demarshal(WvBuf &buf)
Demarshals a new WvDBusMsg from a buffer containing its binary DBus protocol representation.
WvDBusMsg(WvStringParm busname, WvStringParm objectname, WvStringParm ifc, WvStringParm method)
Constructs a new WvDBus message.
const T * get(size_t count)
Reads exactly the specified number of elements and returns a pointer to a storage location owned by t...