summaryrefslogtreecommitdiffstats
path: root/dbus
diff options
context:
space:
mode:
authornona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-19 03:20:03 +0000
committernona@chromium.org <nona@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-19 03:20:03 +0000
commit7e1942af8a3fd104735e9c3b7b8800772b8c13b6 (patch)
tree30363ea070da75f795988eeb5eb277c782ff7266 /dbus
parent9a5e6aeed9bf7bf92dc2d5a8fb7e92f26a9b9116 (diff)
downloadchromium_src-7e1942af8a3fd104735e9c3b7b8800772b8c13b6.zip
chromium_src-7e1942af8a3fd104735e9c3b7b8800772b8c13b6.tar.gz
chromium_src-7e1942af8a3fd104735e9c3b7b8800772b8c13b6.tar.bz2
Extends dbus module to accept user specified addresses.
To connect ibus-daemon, needs to extend dbus module to accept user specified addresses. The ibus provides text inputting features and it is already used in Chrome OS. The ibus uses dbus protocol but using the ibus-daemon instead of the dbus-daemon. BUG=chromium-os:26334 TEST=ran dbus_unittests Review URL: http://codereview.chromium.org/10021044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132933 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus')
-rw-r--r--dbus/bus.cc19
-rw-r--r--dbus/bus.h26
2 files changed, 38 insertions, 7 deletions
diff --git a/dbus/bus.cc b/dbus/bus.cc
index 91ba252..6e9209b 100644
--- a/dbus/bus.cc
+++ b/dbus/bus.cc
@@ -186,7 +186,8 @@ Bus::Bus(const Options& options)
async_operations_set_up_(false),
shutdown_completed_(false),
num_pending_watches_(0),
- num_pending_timeouts_(0) {
+ num_pending_timeouts_(0),
+ address_(options.address) {
// This is safe to call multiple times.
dbus_threads_init_default();
// The origin message loop is unnecessary if the client uses synchronous
@@ -288,11 +289,19 @@ bool Bus::Connect() {
return true;
ScopedDBusError error;
- const DBusBusType dbus_bus_type = static_cast<DBusBusType>(bus_type_);
- if (connection_type_ == PRIVATE) {
- connection_ = dbus_bus_get_private(dbus_bus_type, error.get());
+ if (bus_type_ == CUSTOM_ADDRESS) {
+ if (connection_type_ == PRIVATE) {
+ connection_ = dbus_connection_open_private(address_.c_str(), error.get());
+ } else {
+ connection_ = dbus_connection_open(address_.c_str(), error.get());
+ }
} else {
- connection_ = dbus_bus_get(dbus_bus_type, error.get());
+ const DBusBusType dbus_bus_type = static_cast<DBusBusType>(bus_type_);
+ if (connection_type_ == PRIVATE) {
+ connection_ = dbus_bus_get_private(dbus_bus_type, error.get());
+ } else {
+ connection_ = dbus_bus_get(dbus_bus_type, error.get());
+ }
}
if (!connection_) {
LOG(ERROR) << "Failed to connect to the bus: "
diff --git a/dbus/bus.h b/dbus/bus.h
index 8e3ceea..b015eb9 100644
--- a/dbus/bus.h
+++ b/dbus/bus.h
@@ -135,10 +135,12 @@ class Bus : public base::RefCountedThreadSafe<Bus> {
public:
// Specifies the bus type. SESSION is used to communicate with per-user
// services like GNOME applications. SYSTEM is used to communicate with
- // system-wide services like NetworkManager.
+ // system-wide services like NetworkManager. CUSTOM_ADDRESS is used to
+ // communicate with an user specified address.
enum BusType {
SESSION = DBUS_BUS_SESSION,
- SYSTEM = DBUS_BUS_SYSTEM,
+ SYSTEM = DBUS_BUS_SYSTEM,
+ CUSTOM_ADDRESS,
};
// Specifies the connection type. PRIVATE should usually be used unless
@@ -170,6 +172,24 @@ class Bus : public base::RefCountedThreadSafe<Bus> {
// 1) Already running.
// 2) Has a MessageLoopForIO.
scoped_refptr<base::MessageLoopProxy> dbus_thread_message_loop_proxy;
+
+ // Specifies the server addresses to be connected. If you want to
+ // communicate with non dbus-daemon such as ibus-daemon, set |bus_type| to
+ // CUSTOM_ADDRESS, and |address| to the D-Bus server address you want to
+ // connect to. The format of this address value is the dbus address style
+ // which is described in
+ // http://dbus.freedesktop.org/doc/dbus-specification.html#addresses
+ //
+ // EXAMPLE USAGE:
+ // dbus::Bus::Options options;
+ // options.bus_type = CUSTOM_ADDRESS;
+ // options.address.assign("unix:path=/tmp/dbus-XXXXXXX");
+ // // Set up other options
+ // dbus::Bus bus(options);
+ //
+ // // Do something.
+ //
+ std::string address;
};
// Creates a Bus object. The actual connection will be established when
@@ -526,6 +546,8 @@ class Bus : public base::RefCountedThreadSafe<Bus> {
int num_pending_watches_;
int num_pending_timeouts_;
+ std::string address_;
+
DISALLOW_COPY_AND_ASSIGN(Bus);
};