"wvtestmain ''" actually still runs all the tests, so skip the warning.
[wvstreams.git] / dbus / wvdbusmarshal.cc
blob05ff3107edb35058107a255ab5438802453ba85c
1 /* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 2004-2006 Net Integration Technologies, Inc.
4 *
5 * Wrapper code for marshalling/demarshalling WvDBusMsg objects. This is
6 * in a separate file from WvDBusMsg in case you want to use a WvDBusMsg
7 * but not our special/gross marshalling code from wvdbusmarshal_c.c.
8 *
9 */
10 #include "wvdbusmsg.h"
11 #undef interface // windows
12 #include <dbus/dbus.h>
14 WvDBusMsg *WvDBusMsg::demarshal(WvBuf &buf)
16 size_t used = 0;
17 DBusMessage *_msg = wvdbus_demarshal(buf.peek(0, buf.used()), buf.used(),
18 &used);
19 buf.get(used);
20 if (_msg)
22 WvDBusMsg *msg = new WvDBusMsg(_msg);
23 dbus_message_unref(_msg);
24 return msg;
26 else
27 return NULL;
31 size_t WvDBusMsg::demarshal_bytes_needed(WvBuf &buf)
33 size_t used = buf.used();
34 return wvdbus_message_length(buf.peek(0, used), used);
38 void WvDBusMsg::marshal(WvBuf &buf)
40 size_t len;
41 char *cbuf;
43 if (wvdbus_marshal(*this, &cbuf, &len))
45 buf.put(cbuf, len);
46 free(cbuf);