# DBus-C++

## Desktop Communication Bus System

libdbus-c-- Documentation 0.9.0

- Files
- Data Structures
- Globals
- Main Page

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
36 namespace DBus
37{
38
39 class Connection;
40
41 typedef Slot<bool, const Message &> MessageSlot;
42
43 typedef std::list<Connection> ConnectionList;
44
45 class ObjectAdaptor;
46 class Dispatcher;
47
48 class DXXAPI Connection
49{
50 public:
51
52 static Connection SystemBus();
53
54 static Connection SessionBus();
55
56 static Connection ActivationBus();
57
58 struct Private;
59
60 typedef std::list<Private *> PrivatePList;
61
62 Connection(Private *);
63
64 Connection(const char *address, bool priv = true);
65
66 Connection(const Connection &c);
67
68 virtual ~Connection();
69
70 Dispatcher *setup(Dispatcher *);
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
455 private:
456
457 DXXAPILOCAL void init();
458
459 private:
460
461 RefPtrI<Private> _pvt;
462 int _timeout;
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
api.h
DXXAPILOCAL
#define DXXAPILOCAL
Definition api.h:32
DXXAPI
#define DXXAPI
Definition api.h:36
DBus::Connection
Definition connection.h:49
DBus::Connection::connected
bool connected() const
Gets whether the connection is currently open.
Definition connection.cpp:290
DBus::Connection::exit_on_disconnect
void exit_on_disconnect(bool exit)
Set whether _exit() should be called when the connection receives a disconnect signal.
Definition connection.cpp:301
DBus::Connection::SystemBus
static Connection SystemBus()
Definition connection.cpp:190
DBus::Connection::remove_match
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...
Definition connection.cpp:332
DBus::Connection::has_name
bool has_name(const char *name)
Asks the bus whether a certain name has an owner.
Definition connection.cpp:438
DBus::Connection::Connection
Connection(Private *)
Definition connection.cpp:222
DBus::Connection::flush
void flush()
Blocks until the outgoing message queue is empty.
Definition connection.cpp:316
DBus::Connection::request_name
void request_name(const char *name, int flags=0)
Definition connection.cpp:399
DBus::Connection::send_blocking
Message send_blocking(Message &msg, int timeout=-1)
Sends a message and blocks a certain time period while waiting for a reply.
Definition connection.cpp:369
DBus::Connection::add_filter
bool add_filter(MessageSlot &s)
Adds a message filter.
Definition connection.cpp:352
DBus::Connection::setup
Dispatcher * setup(Dispatcher *)
Definition connection.cpp:239
DBus::Connection::start_service
bool start_service(const char *name, unsigned long flags)
Starts a service that will request ownership of the given name.
Definition connection.cpp:454
DBus::Connection::remove_filter
void remove_filter(MessageSlot &s)
Removes a previously-added message filter.
Definition connection.cpp:358
DBus::Connection::_timeout
int _timeout
Definition connection.h:462
DBus::Connection::ObjectAdaptor
friend class ObjectAdaptor
Definition connection.h:464
DBus::Connection::add_match
void add_match(const char *rule)
Adds a match rule to match messages going through the message bus.
Definition connection.cpp:321
DBus::Connection::get_timeout
int get_timeout()
Definition connection.cpp:470
DBus::Connection::ActivationBus
static Connection ActivationBus()
Definition connection.cpp:200
DBus::Connection::send
bool send(const Message &msg, unsigned int *serial=NULL)
Adds a message to the outgoing message queue.
Definition connection.cpp:364
DBus::Connection::sender_unix_uid
unsigned long sender_unix_uid(const char *sender)
Definition connection.cpp:427
DBus::Connection::_pvt
RefPtrI< Private > _pvt
Definition connection.h:461
DBus::Connection::send_async
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 ...
Definition connection.cpp:388
DBus::Connection::SessionBus
static Connection SessionBus()
Definition connection.cpp:195
DBus::Connection::PrivatePList
std::list< Private * > PrivatePList
Definition connection.h:60
DBus::Connection::init
DXXAPILOCAL void init()
DBus::Connection::register_bus
bool register_bus()
Registers a connection with the bus.
Definition connection.cpp:279
DBus::Connection::unique_name
bool unique_name(const char *n)
Sets the unique name of the connection, as assigned by the message bus.
Definition connection.cpp:306
DBus::Connection::set_timeout
void set_timeout(int timeout)
Definition connection.cpp:465
DBus::Connection::disconnect
void disconnect()
Closes a private connection, so no further data can be sent or received.
Definition connection.cpp:295
DBus::Connection::names
const std::vector< std::string > & names()
Definition connection.cpp:449
DBus::Dispatcher
Definition dispatcher.h:152
DBus::Message
Definition message.h:159
DBus::ObjectAdaptor
Definition object.h:117
DBus::PendingCall
Definition pendingcall.h:38
DBus::RefPtrI
Definition util.h:114
DBus::Slot
Definition util.h:226
message.h
DBus
Definition connection_p.h:42
DBus::MessageSlot
Slot< bool, const Message & > MessageSlot
Definition connection.h:41
DBus::ConnectionList
std::list< Connection > ConnectionList
Definition connection.h:43
pendingcall.h
DBus::Connection::Private
Definition connection_p.h:45
types.h
util.h