connection.h
Go to the documentation of this file.
1/*
2 *
3 * D-Bus++ - C++ bindings for D-Bus
4 *
5 * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com>
6 *
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24
25#ifndef __DBUSXX_CONNECTION_H
26#define __DBUSXX_CONNECTION_H
27
28#include <list>
29
30#include "api.h"
31#include "types.h"
32#include "util.h"
33#include "message.h"
34#include "pendingcall.h"
35
36namespace DBus
37{
38
39class Connection;
40
42
43typedef std::list<Connection> ConnectionList;
44
45class ObjectAdaptor;
46class Dispatcher;
47
49{
50public:
51
52 static Connection SystemBus();
53
54 static Connection SessionBus();
55
57
58 struct Private;
59
60 typedef std::list<Private *> PrivatePList;
61
63
64 Connection(const char *address, bool priv = true);
65
66 Connection(const Connection &c);
67
68 virtual ~Connection();
69
71
72 bool operator == (const Connection &) const;
73
130 void add_match(const char *rule);
131
144 void remove_match(const char *rule, bool throw_on_error);
145
157 bool add_filter(MessageSlot &s);
158
168 void remove_filter(MessageSlot &s);
169
200 bool unique_name(const char *n);
201
217 const char *unique_name() const;
218
263 bool register_bus();
264
276 bool connected() const;
277
315 void disconnect();
316
329 void exit_on_disconnect(bool exit);
330
334 void flush();
335
356 bool send(const Message &msg, unsigned int *serial = NULL);
357
383 Message send_blocking(Message &msg, int timeout = -1);
384
410 PendingCall send_async(Message &msg, int timeout = -1);
411
412 void request_name(const char *name, int flags = 0);
413
414 unsigned long sender_unix_uid(const char *sender);
415
429 bool has_name(const char *name);
430
447 bool start_service(const char *name, unsigned long flags);
448
449 const std::vector<std::string>& names();
450
451 void set_timeout(int timeout);
452
453 int get_timeout();
454
455private:
456
458
459private:
460
463
464 friend class ObjectAdaptor; // needed in order to register object paths for a connection
465};
466
467} /* namespace DBus */
468
469#endif//__DBUSXX_CONNECTION_H
#define DXXAPILOCAL
Definition api.h:32
#define DXXAPI
Definition api.h:36
bool connected() const
Gets whether the connection is currently open.
void exit_on_disconnect(bool exit)
Set whether _exit() should be called when the connection receives a disconnect signal.
static Connection SystemBus()
void remove_match(const char *rule, bool throw_on_error)
Removes a previously-added match rule "by value" (the most recently-added identical rule gets removed...
bool has_name(const char *name)
Asks the bus whether a certain name has an owner.
Connection(Private *)
void flush()
Blocks until the outgoing message queue is empty.
void request_name(const char *name, int flags=0)
Message send_blocking(Message &msg, int timeout=-1)
Sends a message and blocks a certain time period while waiting for a reply.
bool add_filter(MessageSlot &s)
Adds a message filter.
Dispatcher * setup(Dispatcher *)
bool start_service(const char *name, unsigned long flags)
Starts a service that will request ownership of the given name.
void remove_filter(MessageSlot &s)
Removes a previously-added message filter.
friend class ObjectAdaptor
Definition connection.h:464
void add_match(const char *rule)
Adds a match rule to match messages going through the message bus.
static Connection ActivationBus()
bool send(const Message &msg, unsigned int *serial=NULL)
Adds a message to the outgoing message queue.
unsigned long sender_unix_uid(const char *sender)
RefPtrI< Private > _pvt
Definition connection.h:461
PendingCall send_async(Message &msg, int timeout=-1)
Queues a message to send, as with send(), but also returns a DBusPendingCall used to receive a reply ...
static Connection SessionBus()
std::list< Private * > PrivatePList
Definition connection.h:60
DXXAPILOCAL void init()
bool register_bus()
Registers a connection with the bus.
bool unique_name(const char *n)
Sets the unique name of the connection, as assigned by the message bus.
void set_timeout(int timeout)
void disconnect()
Closes a private connection, so no further data can be sent or received.
const std::vector< std::string > & names()
Slot< bool, const Message & > MessageSlot
Definition connection.h:41
std::list< Connection > ConnectionList
Definition connection.h:43