3 * D-Bus++ - C++ bindings for D-Bus
5 * Copyright (C) 2005-2009 Paolo Durante <shackan@gmail.com>
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.
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.
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
25 #ifndef __DBUSXX_CONNECTION_H
26 #define __DBUSXX_CONNECTION_H
34 #include "pendingcall.h"
40 typedef Slot
<bool, const Message
&> MessageSlot
;
42 typedef std::list
<Connection
> ConnectionList
;
48 class DBUSXXAPI Connection
52 static Connection
system_bus(Dispatcher
*dispatcher
= NULL
);
53 static Connection
system_bus_private(Dispatcher
*dispatcher
= NULL
);
55 static Connection
session_bus(Dispatcher
*dispatcher
= NULL
);
56 static Connection
session_bus_private(Dispatcher
*dispatcher
= NULL
);
58 static Connection
activation_bus(Dispatcher
*dispatcher
= NULL
);
59 static Connection
activation_bus_private(Dispatcher
*dispatcher
= NULL
);
63 typedef std::list
<Private
*> PrivatePList
;
67 Connection(RefPtrI
<Private
>);
69 Connection(const char *address
, bool priv
, Dispatcher
*dispatcher
= NULL
);
71 Connection(const Connection
&c
);
73 virtual ~Connection();
75 bool operator == (const Connection
&) const;
77 Connection
&operator = (const Connection
&);
79 void add_match(const char *rule
);
81 void remove_match(const char *rule
);
83 bool add_filter(MessageSlot
&);
85 void remove_filter(MessageSlot
&);
87 bool unique_name(const char *n
);
89 const char *unique_name() const;
93 bool connected() const;
97 void exit_on_disconnect(bool exit
);
101 bool send(const Message
&, unsigned int *serial
= NULL
);
103 Message
send_blocking(Message
&msg
, int timeout
= -1);
105 PendingCall
send_async(Message
&msg
, ObjectProxy
*proxy
, const PendingCallSlot
&slot
, void* data
, int timeout
);
107 void request_name(const char *name
, int flags
= 0);
109 bool has_name(const char *name
);
111 bool start_service(const char *name
, unsigned long flags
);
113 const std::vector
<std::string
>& names();
117 DBUSXXAPILOCAL
void init();
121 RefPtrI
<Private
> _pvt
;
123 friend class ObjectAdaptor
; // needed in order to register object paths for a connection
126 class DBUSXXAPI CallInfo
131 CallInfo(const Connection
&c
, const Message
&m
);
132 CallInfo(const Connection
&c
, const PendingCall
&pc
);
134 const Connection
&conn() const { return _conn
; }
135 const Message
&msg() const { return _msg
; }
136 const Error
&error() const { return _error
; }
138 uint32_t sender_pid();
139 uint32_t sender_uid();
141 CallInfo
&operator = (const CallInfo
& info
);
150 } /* namespace DBus */
152 #endif//__DBUSXX_CONNECTION_H