/usr/include/wvstreams/wvdbusmsg.h is in libwvstreams-dev 4.6.1-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | /* -*- Mode: C++ -*-
* Worldvisions Weaver Software:
* Copyright (C) 2004-2006 Net Integration Technologies, Inc.
*
* Pathfinder Software:
* Copyright (C) 2007, Carillon Information Security Inc.
*
* This library is licensed under the LGPL, please read LICENSE for details.
*
* WvDBusMsg is intended to be an easy-to-use abstraction over the low-level
* D-Bus DBusMessage structure. It represents a message being passed around on
* the bus.
*/
#ifndef __WVDBUSMSG_H
#define __WVDBUSMSG_H
#include "wvstringlist.h"
#include "wvbuf.h"
#include <stdint.h>
struct DBusMessageIter;
struct DBusMessage;
class WvDBusMsg;
class WvDBusConn;
class WvDBusMsg
{
public:
/**
* Constructs a new WvDBus message. If destination is blank, no
* destination is set; this is appropriate when using D-BUS in a
* peer-to-peer context (no message bus).
*/
WvDBusMsg(WvStringParm busname, WvStringParm objectname,
WvStringParm ifc, WvStringParm method);
/**
* Constructs a new WvDBus message, copying it out of an old one.
*/
WvDBusMsg(WvDBusMsg &_msg);
/**
* Constructs a new WvDBus message from an existing low-level D-Bus
* message.
*/
WvDBusMsg(DBusMessage *_msg);
virtual ~WvDBusMsg();
operator DBusMessage* () const;
/**
* Demarshals a new WvDBusMsg from a buffer containing its binary DBus
* protocol representation. You're responsible for freeing the object
* when done. Returns NULL if the object can't be extracted from the
* buffer.
* (Implementation in wvdbusmarshal.cc)
*/
static WvDBusMsg *demarshal(WvBuf &buf);
/**
* Given a buffer containing what might be the header of a DBus message,
* checks how many bytes need to be in the buffer in order for it to
* contain a whole message. If the return value is <= the number of
* bytes already in the buffer, then demarshal() will succeed (or the
* incoming message is corrupt).
* (Implementation in wvdbusmarshal.cc)
*/
static size_t demarshal_bytes_needed(WvBuf &buf);
/**
* Locks this message, encodes it in DBus binary protocol format, and
* adds it to the given buffer. This message becomes locked and can
* no longer be append()ed to. You can marshal it more than once,
* however (but it will always have the same serial number!!)
* (Implementation in wvdbusmarshal.cc)
*/
void marshal(WvBuf &buf);
WvString get_sender() const;
WvString get_dest() const;
WvString get_path() const;
WvString get_interface() const;
WvString get_member() const;
WvString get_error() const;
uint32_t get_serial() const;
uint32_t get_replyserial() const;
bool is_reply() const;
operator WvString() const;
void get_arglist(WvStringList &list) const;
WvString get_argstr() const;
/**
* The following methods are designed to allow appending various
* arguments to the message.
*/
WvDBusMsg &append(const char *s);
WvDBusMsg &append(bool b);
WvDBusMsg &append(signed char c);
WvDBusMsg &append(unsigned char c);
WvDBusMsg &append(int16_t i);
WvDBusMsg &append(uint16_t i);
WvDBusMsg &append(int32_t i);
WvDBusMsg &append(uint32_t i);
WvDBusMsg &append(int64_t i);
WvDBusMsg &append(uint64_t i);
WvDBusMsg &append(double d);
/**
* Start a variant.
*/
WvDBusMsg &variant_start(WvStringParm element_type);
/**
* End a variant.
*/
WvDBusMsg &variant_end();
/**
* Start a struct. Elements append()ed after this will be inside the
* struct, and you should be careful that you append the right types in
* the right order. Finish using struct_end().
*/
WvDBusMsg &struct_start(WvStringParm element_type);
/**
* End a struct started with struct_start().
*/
WvDBusMsg &struct_end();
/**
* Start an array. Elements append()ed after this will be inside the
* array. Finish using array_end().
*/
WvDBusMsg &array_start(WvStringParm element_type);
/**
* End an array started with array_start().
*/
WvDBusMsg &array_end();
/**
* Start a variant-array. Elements append()ed after this will be inside
* the array. Finish using varray_end().
*
* A variant-array is like an array, but is enclosed automatically inside
* a variant object. This is useful for arrays of arrays, where each
* inner array is of a different type.
*/
WvDBusMsg &varray_start(WvStringParm element_type);
/**
* End an array started with array_start().
*/
WvDBusMsg &varray_end();
/**
* Generate a message that will be a reply to this one.
*/
WvDBusMsg reply();
/**
* Return true if this message is an error response.
*/
bool iserror() const;
/**
* A shortcut for sending this message on the given connection.
* Equivalent to conn.send(*this).
*/
void send(WvDBusConn &conn);
class Iter
{
public:
DBusMessageIter *const first, *const it;
mutable WvString s;
bool rewound;
Iter(const WvDBusMsg &_msg);
Iter(const WvDBusMsg::Iter &_it);
Iter(const DBusMessageIter &_first);
~Iter();
/**
* Rewinds the iterator to make it point to an imaginary element
* preceeding the first element of the list.
*/
void rewind();
/**
* Returns the data type of the current element. Not usually needed,
* as the iterator converts elements automatically between most types.
*/
int type() const;
/**
* Returns a sub-iterator for walking through recursive types, such
* as arrays, structs, and variants.
*
* You don't strictly need to call this for variants; get_str() and
* friends will do the right thing.
*/
Iter open() const;
/**
* Moves the iterator along the list to point to the next element.
*
* If the iterator had just been rewound, it now points to the
* first element of the list.
*/
bool next();
/**
* Same as next(), but returns *this instead so you can convert the
* new item to the right value type. Note: this doesn't do error
* checking to see if the parameter exists.
*/
Iter &getnext()
{ next(); return *this; }
/**
* Returns: true if the current link is valid
*/
bool cur() const;
/**
* Fill a WvStringList with a string for each element of the iter.
*/
void get_all(WvStringList &list);
/**
* Return a WvString representation of all elements in a single
* string.
*/
WvString get_all();
/**
* Get the current element as a string (possible for all types).
*/
WvString get_str() const;
/**
* Get the current element as an int64_t
* (possible for all integer types)
*/
int64_t get_int() const;
operator int64_t() const { return get_int(); }
operator int32_t() const { return get_int(); }
operator int16_t() const { return get_int(); }
operator int8_t() const { return get_int(); }
operator bool() const { return get_int() != 0; }
/**
* Get the current element as a uint64_t
* (possible for all integer types)
*/
uint64_t get_uint() const;
operator uint64_t() const { return get_uint(); }
operator uint32_t() const { return get_uint(); }
operator uint16_t() const { return get_uint(); }
operator uint8_t() const { return get_uint(); }
/**
* Get the current element as a double
* (possible for all integer and floating point types)
*/
double get_double() const;
operator double() const { return get_double(); }
operator float() const { return get_double(); }
/**
* Returns a pointer to the WvString at the iterator's current
* location. Needed so that WvIterStuff() will work.
*/
WvString *ptr() const;
operator WvString() const { return *ptr(); }
WvIterStuff(WvString);
};
protected:
mutable DBusMessage *msg;
WvList<DBusMessageIter> itlist;
};
class WvDBusSignal : public WvDBusMsg
{
public:
WvDBusSignal(WvStringParm objectname, WvStringParm ifc,
WvStringParm name);
};
class WvDBusError : public WvDBusMsg
{
DBusMessage *setup1(WvDBusMsg &in_reply_to,
WvStringParm errname, WvStringParm message);
void setup2();
public:
WvDBusError(WvDBusMsg &in_reply_to,
WvStringParm errname, WvStringParm message)
: WvDBusMsg(setup1(in_reply_to, errname, message))
{
setup2();
}
WvDBusError(WvDBusMsg &in_reply_to,
WvStringParm errname, WVSTRING_FORMAT_DECL)
: WvDBusMsg(setup1(in_reply_to, errname,
WvString(WVSTRING_FORMAT_CALL)))
{
setup2();
}
};
#endif // __WVDBUSMSG_H
|