From f21203af936533c60780569df8c055b8e8640ac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Alburquerque?= Date: Tue, 11 Jan 2011 15:46:39 -0500 Subject: DBus: Use std::string for addresses since they could be a file path. * gio/src/dbusaddress.{ccg,hg}: * gio/src/dbusconnection.{ccg,hg}: * gio/src/dbusserver.{ccg,hg}: Use std::string instead of Glib::ustring for address parameters just to avoid possible errors since DBus address could be a filename path as the "Addresses" section of the DBus introduction seems to imply: http://www.freedesktop.org/wiki/IntroductionToDBus. --- ChangeLog | 12 ++++++++++++ gio/src/dbusaddress.ccg | 26 ++++++++++++-------------- gio/src/dbusaddress.hg | 16 ++++++++-------- gio/src/dbusconnection.ccg | 32 ++++++++++++++++---------------- gio/src/dbusconnection.hg | 32 ++++++++++++++++---------------- gio/src/dbusserver.ccg | 16 ++++++++-------- gio/src/dbusserver.hg | 22 +++++++++++----------- 7 files changed, 83 insertions(+), 73 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f288ba3..83dfff54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2011-01-11 José Alburquerque + + DBus: Use std::string for addresses since they could be a file path. + + * gio/src/dbusaddress.{ccg,hg}: + * gio/src/dbusconnection.{ccg,hg}: + * gio/src/dbusserver.{ccg,hg}: Use std::string instead of + Glib::ustring for address parameters just to avoid possible errors + since DBus address could be a filename path as the "Addresses" + section of the DBus introduction seems to imply: + http://www.freedesktop.org/wiki/IntroductionToDBus. + 2011-01-11 José Alburquerque DBus: Use std::string for guid's. diff --git a/gio/src/dbusaddress.ccg b/gio/src/dbusaddress.ccg index 703a151b..fc45f593 100644 --- a/gio/src/dbusaddress.ccg +++ b/gio/src/dbusaddress.ccg @@ -29,12 +29,12 @@ namespace DBus namespace Address { -bool is_address(const Glib::ustring& string) +bool is_address(const std::string& string) { return static_cast(g_dbus_is_address(string.c_str())); } -bool is_supported(const Glib::ustring& address) +bool is_supported(const std::string& address) { GError* gerror = 0; bool const result = g_dbus_is_supported_address(address.c_str(), &gerror); @@ -43,7 +43,7 @@ bool is_supported(const Glib::ustring& address) return result; } -void get_stream(const Glib::ustring& address, const SlotAsyncReady slot, +void get_stream(const std::string& address, const SlotAsyncReady slot, const Glib::RefPtr& cancellable) { SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); @@ -51,7 +51,7 @@ void get_stream(const Glib::ustring& address, const SlotAsyncReady slot, &SignalProxy_async_callback, slot_copy); } -void get_stream(const Glib::ustring& address, const SlotAsyncReady slot) +void get_stream(const std::string& address, const SlotAsyncReady slot) { SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); g_dbus_address_get_stream(address.c_str(), 0, &SignalProxy_async_callback, @@ -89,7 +89,7 @@ Glib::RefPtr get_stream_finish(const Glib::RefPtr& res) return result; } -Glib::RefPtr get_stream_sync(const Glib::ustring& address, +Glib::RefPtr get_stream_sync(const std::string& address, const Glib::RefPtr& cancellable, std::string& out_guid) { GError* gerror = 0; @@ -106,7 +106,7 @@ Glib::RefPtr get_stream_sync(const Glib::ustring& address, return result; } -Glib::RefPtr get_stream_sync(const Glib::ustring& address, +Glib::RefPtr get_stream_sync(const std::string& address, std::string& out_guid) { GError* gerror = 0; @@ -123,7 +123,7 @@ Glib::RefPtr get_stream_sync(const Glib::ustring& address, return result; } -Glib::RefPtr get_stream_sync(const Glib::ustring& address, +Glib::RefPtr get_stream_sync(const std::string& address, const Glib::RefPtr& cancellable) { GError* gerror = 0; @@ -138,7 +138,7 @@ Glib::RefPtr get_stream_sync(const Glib::ustring& address, return result; } -Glib::RefPtr get_stream_sync(const Glib::ustring& address) +Glib::RefPtr get_stream_sync(const std::string& address) { GError* gerror = 0; @@ -151,13 +151,12 @@ Glib::RefPtr get_stream_sync(const Glib::ustring& address) return result; } -Glib::ustring get_for_bus_sync(BusType bus_type, +std::string get_for_bus_sync(BusType bus_type, const Glib::RefPtr& cancellable) { GError* gerror = 0; - Glib::ustring result = - Glib::ustring(g_dbus_address_get_for_bus_sync( + std::string result(g_dbus_address_get_for_bus_sync( static_cast(bus_type), Glib::unwrap(cancellable), &gerror)); if(gerror) @@ -166,12 +165,11 @@ Glib::ustring get_for_bus_sync(BusType bus_type, return result; } -Glib::ustring get_for_bus_sync(BusType bus_type) +std::string get_for_bus_sync(BusType bus_type) { GError* gerror = 0; - Glib::ustring result = - Glib::ustring(g_dbus_address_get_for_bus_sync( + std::string result(g_dbus_address_get_for_bus_sync( static_cast(bus_type), 0, &gerror)); if(gerror) diff --git a/gio/src/dbusaddress.hg b/gio/src/dbusaddress.hg index f89b8621..5918a599 100644 --- a/gio/src/dbusaddress.hg +++ b/gio/src/dbusaddress.hg @@ -41,7 +41,7 @@ namespace Address * @newin{2,28} * @ingroup DBus */ -bool is_address(const Glib::ustring& string); +bool is_address(const std::string& string); /** Like is_address() but also checks if the library supports the transports * in @a address and that key/value pairs for each transport are valid. @@ -53,7 +53,7 @@ bool is_address(const Glib::ustring& string); * @newin{2,28} * @ingroup DBus */ -bool is_supported(const Glib::ustring& address); +bool is_supported(const std::string& address); /** Asynchronously connects to an endpoint specified by @a address and sets up * the connection so it is in a state to run the client-side of the D-Bus @@ -71,11 +71,11 @@ bool is_supported(const Glib::ustring& address); * @newin{2,28} * @ingroup DBus */ -void get_stream(const Glib::ustring& address, const SlotAsyncReady slot, +void get_stream(const std::string& address, const SlotAsyncReady slot, const Glib::RefPtr& cancellable); /// A non-cancellable version of get_stream(). -void get_stream(const Glib::ustring& address, const SlotAsyncReady slot); +void get_stream(const std::string& address, const SlotAsyncReady slot); /** Finishes an operation started with get_stream(). * @@ -118,11 +118,11 @@ Glib::RefPtr get_stream_finish(const Glib::RefPtr& res); * @newin{2,28} * @ingroup DBus */ -Glib::RefPtr get_stream_sync(const Glib::ustring& address, +Glib::RefPtr get_stream_sync(const std::string& address, const Glib::RefPtr& cancellable, std::string& out_guid); /// A non-cancellable version of get_stream_sync(). -Glib::RefPtr get_stream_sync(const Glib::ustring& address, +Glib::RefPtr get_stream_sync(const std::string& address, std::string& out_guid); /** Synchronously connects to an endpoint specified by @a address and sets up @@ -139,11 +139,11 @@ Glib::RefPtr get_stream_sync(const Glib::ustring& address, * @newin{2,28} * @ingroup DBus */ -Glib::RefPtr get_stream_sync(const Glib::ustring& address, +Glib::RefPtr get_stream_sync(const std::string& address, const Glib::RefPtr& cancellable); /// A non-cancellable version of get_stream_sync(). -Glib::RefPtr get_stream_sync(const Glib::ustring& address); +Glib::RefPtr get_stream_sync(const std::string& address); /** Synchronously looks up the D-Bus address for the well-known message bus * instance specified by @a bus_type. This may involve using various platform diff --git a/gio/src/dbusconnection.ccg b/gio/src/dbusconnection.ccg index ff1ba33f..55103fe1 100644 --- a/gio/src/dbusconnection.ccg +++ b/gio/src/dbusconnection.ccg @@ -333,7 +333,7 @@ DBusConnection::DBusConnection(const Glib::RefPtr& stream, init_async(slot); } -DBusConnection::DBusConnection(const Glib::ustring& address, +DBusConnection::DBusConnection(const std::string& address, const Glib::RefPtr& observer, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, @@ -346,7 +346,7 @@ DBusConnection::DBusConnection(const Glib::ustring& address, init_async(slot, cancellable); } -DBusConnection::DBusConnection(const Glib::ustring& address, +DBusConnection::DBusConnection(const std::string& address, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) @@ -358,7 +358,7 @@ DBusConnection::DBusConnection(const Glib::ustring& address, init_async(slot, cancellable); } -DBusConnection::DBusConnection(const Glib::ustring& address, +DBusConnection::DBusConnection(const std::string& address, const Glib::RefPtr& observer, const SlotAsyncReady& slot, DBusConnectionFlags flags) @@ -370,7 +370,7 @@ DBusConnection::DBusConnection(const Glib::ustring& address, init_async(slot); } -DBusConnection::DBusConnection(const Glib::ustring& address, +DBusConnection::DBusConnection(const std::string& address, const SlotAsyncReady& slot, DBusConnectionFlags flags) : @@ -433,7 +433,7 @@ DBusConnection::DBusConnection(const Glib::RefPtr& stream, init(); } -DBusConnection::DBusConnection(const Glib::ustring& address, +DBusConnection::DBusConnection(const std::string& address, const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) @@ -445,7 +445,7 @@ DBusConnection::DBusConnection(const Glib::ustring& address, init(cancellable); } -DBusConnection::DBusConnection(const Glib::ustring& address, +DBusConnection::DBusConnection(const std::string& address, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) : @@ -456,7 +456,7 @@ DBusConnection::DBusConnection(const Glib::ustring& address, init(cancellable); } -DBusConnection::DBusConnection(const Glib::ustring& address, +DBusConnection::DBusConnection(const std::string& address, const Glib::RefPtr& observer, DBusConnectionFlags flags) : @@ -467,7 +467,7 @@ DBusConnection::DBusConnection(const Glib::ustring& address, init(); } -DBusConnection::DBusConnection(const Glib::ustring& address, +DBusConnection::DBusConnection(const std::string& address, DBusConnectionFlags flags) : _CONSTRUCT("address", (address.empty() ? 0 : address.c_str()), @@ -572,7 +572,7 @@ Glib::RefPtr DBusConnection::create_sync( } //static -void DBusConnection::create_for_address(const Glib::ustring& address, +void DBusConnection::create_for_address(const std::string& address, const Glib::RefPtr& observer, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, @@ -584,7 +584,7 @@ void DBusConnection::create_for_address(const Glib::ustring& address, } //static -void DBusConnection::create_for_address(const Glib::ustring& address, +void DBusConnection::create_for_address(const std::string& address, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) @@ -595,7 +595,7 @@ void DBusConnection::create_for_address(const Glib::ustring& address, } //static -void DBusConnection::create_for_address(const Glib::ustring& address, +void DBusConnection::create_for_address(const std::string& address, const Glib::RefPtr& observer, const SlotAsyncReady& slot, DBusConnectionFlags flags) @@ -606,7 +606,7 @@ void DBusConnection::create_for_address(const Glib::ustring& address, } //static -void DBusConnection::create_for_address(const Glib::ustring& address, +void DBusConnection::create_for_address(const std::string& address, const SlotAsyncReady& slot, DBusConnectionFlags flags) { @@ -617,7 +617,7 @@ void DBusConnection::create_for_address(const Glib::ustring& address, //static Glib::RefPtr DBusConnection::create_for_address_sync( - const Glib::ustring& address, + const std::string& address, const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) @@ -628,7 +628,7 @@ Glib::RefPtr DBusConnection::create_for_address_sync( //static Glib::RefPtr DBusConnection::create_for_address_sync( - const Glib::ustring& address, + const std::string& address, const Glib::RefPtr& cancellable, DBusConnectionFlags flags) { @@ -638,7 +638,7 @@ Glib::RefPtr DBusConnection::create_for_address_sync( //static Glib::RefPtr DBusConnection::create_for_address_sync( - const Glib::ustring& address, + const std::string& address, const Glib::RefPtr& observer, DBusConnectionFlags flags) { @@ -648,7 +648,7 @@ Glib::RefPtr DBusConnection::create_for_address_sync( //static Glib::RefPtr DBusConnection::create_for_address_sync( - const Glib::ustring& address, + const std::string& address, DBusConnectionFlags flags) { return Glib::RefPtr(new DBusConnection(address, flags)); diff --git a/gio/src/dbusconnection.hg b/gio/src/dbusconnection.hg index 8142a2ee..709d1a40 100644 --- a/gio/src/dbusconnection.hg +++ b/gio/src/dbusconnection.hg @@ -116,40 +116,40 @@ protected: const std::string& guid, DBusConnectionFlags flags); - DBusConnection(const Glib::ustring& address, + DBusConnection(const std::string& address, const Glib::RefPtr& observer, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, DBusConnectionFlags flags); - DBusConnection(const Glib::ustring& address, + DBusConnection(const std::string& address, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, DBusConnectionFlags flags); - DBusConnection(const Glib::ustring& address, + DBusConnection(const std::string& address, const Glib::RefPtr& observer, const SlotAsyncReady& slot, DBusConnectionFlags flags); - DBusConnection(const Glib::ustring& address, + DBusConnection(const std::string& address, const SlotAsyncReady& slot, DBusConnectionFlags flags); - DBusConnection(const Glib::ustring& address, + DBusConnection(const std::string& address, const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, DBusConnectionFlags flags); - DBusConnection(const Glib::ustring& address, + DBusConnection(const std::string& address, const Glib::RefPtr& cancellable, DBusConnectionFlags flags); - DBusConnection(const Glib::ustring& address, + DBusConnection(const std::string& address, const Glib::RefPtr& observer, DBusConnectionFlags flags); - DBusConnection(const Glib::ustring& address, + DBusConnection(const std::string& address, DBusConnectionFlags flags); public: @@ -249,26 +249,26 @@ public: _WRAP_METHOD(static Glib::RefPtr create_finish(const Glib::RefPtr& res), g_dbus_connection_new_finish, errthrow) _WRAP_METHOD_DOCS_ONLY(g_dbus_connection_new_for_address) - static void create_for_address(const Glib::ustring& address, + static void create_for_address(const std::string& address, const Glib::RefPtr& observer, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, DBusConnectionFlags flags = Gio::DBUS_CONNECTION_FLAGS_NONE); _WRAP_METHOD_DOCS_ONLY(g_dbus_connection_new_for_address) - static void create_for_address(const Glib::ustring& address, + static void create_for_address(const std::string& address, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, DBusConnectionFlags flags = Gio::DBUS_CONNECTION_FLAGS_NONE); /// Non-cancellable version of create_for_address(). - static void create_for_address(const Glib::ustring& address, + static void create_for_address(const std::string& address, const Glib::RefPtr& observer, const SlotAsyncReady& slot, DBusConnectionFlags flags = Gio::DBUS_CONNECTION_FLAGS_NONE); /// Non-cancellable version of create_for_address(). - static void create_for_address(const Glib::ustring& address, + static void create_for_address(const std::string& address, const SlotAsyncReady& slot, DBusConnectionFlags flags = Gio::DBUS_CONNECTION_FLAGS_NONE); @@ -309,7 +309,7 @@ public: _WRAP_METHOD_DOCS_ONLY(g_dbus_connection_new_for_address_sync) /// @throw Glib::Error. static Glib::RefPtr create_for_address_sync( - const Glib::ustring& address, + const std::string& address, const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, DBusConnectionFlags flags = Gio::DBUS_CONNECTION_FLAGS_NONE); @@ -317,19 +317,19 @@ public: _WRAP_METHOD_DOCS_ONLY(g_dbus_connection_new_for_address_sync) /// @throw Glib::Error. static Glib::RefPtr create_for_address_sync( - const Glib::ustring& address, + const std::string& address, const Glib::RefPtr& cancellable, DBusConnectionFlags flags = Gio::DBUS_CONNECTION_FLAGS_NONE); /// Non-cancellable version of create_for_address_sync(). static Glib::RefPtr create_for_address_sync( - const Glib::ustring& address, + const std::string& address, const Glib::RefPtr& observer, DBusConnectionFlags flags = Gio::DBUS_CONNECTION_FLAGS_NONE); /// Non-cancellable version of create_for_address_sync(). static Glib::RefPtr create_for_address_sync( - const Glib::ustring& address, + const std::string& address, DBusConnectionFlags flags = Gio::DBUS_CONNECTION_FLAGS_NONE); /** Closes the connection. Note that this never causes the process to exit diff --git a/gio/src/dbusserver.ccg b/gio/src/dbusserver.ccg index e88a6b9f..60c39ae0 100644 --- a/gio/src/dbusserver.ccg +++ b/gio/src/dbusserver.ccg @@ -24,7 +24,7 @@ namespace Gio { -DBusServer::DBusServer(const Glib::ustring& address, +DBusServer::DBusServer(const std::string& address, const std::string& guid, const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, @@ -38,7 +38,7 @@ DBusServer::DBusServer(const Glib::ustring& address, init(cancellable); } -DBusServer::DBusServer(const Glib::ustring& address, +DBusServer::DBusServer(const std::string& address, const std::string& guid, const Glib::RefPtr& cancellable, DBusServerFlags flags) @@ -51,7 +51,7 @@ DBusServer::DBusServer(const Glib::ustring& address, init(cancellable); } -DBusServer::DBusServer(const Glib::ustring& address, +DBusServer::DBusServer(const std::string& address, const std::string& guid, const Glib::RefPtr& observer, DBusServerFlags flags) @@ -64,7 +64,7 @@ DBusServer::DBusServer(const Glib::ustring& address, init(); } -DBusServer::DBusServer(const Glib::ustring& address, +DBusServer::DBusServer(const std::string& address, const std::string& guid, DBusServerFlags flags) : _CONSTRUCT("address", @@ -76,7 +76,7 @@ DBusServer::DBusServer(const Glib::ustring& address, init(); } -Glib::RefPtr DBusServer::create_sync(const Glib::ustring& address, +Glib::RefPtr DBusServer::create_sync(const std::string& address, const std::string& guid, const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, @@ -103,7 +103,7 @@ Glib::RefPtr DBusServer::create_sync(const Glib::ustring& address, return result; } -Glib::RefPtr DBusServer::create_sync(const Glib::ustring& address, +Glib::RefPtr DBusServer::create_sync(const std::string& address, const std::string& guid, const Glib::RefPtr& cancellable, DBusServerFlags flags) @@ -128,7 +128,7 @@ Glib::RefPtr DBusServer::create_sync(const Glib::ustring& address, return result; } -Glib::RefPtr DBusServer::create_sync(const Glib::ustring& address, +Glib::RefPtr DBusServer::create_sync(const std::string& address, const std::string& guid, const Glib::RefPtr& observer, DBusServerFlags flags) @@ -154,7 +154,7 @@ Glib::RefPtr DBusServer::create_sync(const Glib::ustring& address, return result; } -Glib::RefPtr DBusServer::create_sync(const Glib::ustring& address, +Glib::RefPtr DBusServer::create_sync(const std::string& address, const std::string& guid, DBusServerFlags flags) { diff --git a/gio/src/dbusserver.hg b/gio/src/dbusserver.hg index 32ea99b9..655ee718 100644 --- a/gio/src/dbusserver.hg +++ b/gio/src/dbusserver.hg @@ -47,23 +47,23 @@ class DBusServer : public Glib::Object, public Initable protected: - DBusServer(const Glib::ustring& address, + DBusServer(const std::string& address, const std::string& guid, const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, DBusServerFlags flags); - DBusServer(const Glib::ustring& address, + DBusServer(const std::string& address, const std::string& guid, const Glib::RefPtr& cancellable, DBusServerFlags flags); - DBusServer(const Glib::ustring& address, + DBusServer(const std::string& address, const std::string& guid, const Glib::RefPtr& observer, DBusServerFlags flags); - DBusServer(const Glib::ustring& address, + DBusServer(const std::string& address, const std::string& guid, DBusServerFlags flags); @@ -71,7 +71,7 @@ public: _WRAP_METHOD_DOCS_ONLY(g_dbus_server_new_sync) /// @throw Glib::Error. - static Glib::RefPtr create_sync(const Glib::ustring& address, + static Glib::RefPtr create_sync(const std::string& address, const std::string& guid, const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, @@ -79,19 +79,19 @@ public: _WRAP_METHOD_DOCS_ONLY(g_dbus_server_new_sync) /// @throw Glib::Error. - static Glib::RefPtr create_sync(const Glib::ustring& address, + static Glib::RefPtr create_sync(const std::string& address, const std::string& guid, const Glib::RefPtr& cancellable, DBusServerFlags flags = Gio::DBUS_SERVER_FLAGS_NONE); /// Non-cancellable version of create_sync(). - static Glib::RefPtr create_sync(const Glib::ustring& address, + static Glib::RefPtr create_sync(const std::string& address, const std::string& guid, const Glib::RefPtr& observer, DBusServerFlags flags = Gio::DBUS_SERVER_FLAGS_NONE); /// Non-cancellable version of create_sync(). - static Glib::RefPtr create_sync(const Glib::ustring& address, + static Glib::RefPtr create_sync(const std::string& address, const std::string& guid, DBusServerFlags flags = Gio::DBUS_SERVER_FLAGS_NONE); @@ -100,12 +100,12 @@ public: _WRAP_METHOD(bool is_active() const, g_dbus_server_is_active) _WRAP_METHOD(std::string get_guid() const, g_dbus_server_get_guid) _WRAP_METHOD(DBusServerFlags get_flags() const, g_dbus_server_get_flags) - _WRAP_METHOD(Glib::ustring get_client_address() const, g_dbus_server_get_client_address) + _WRAP_METHOD(std::string get_client_address() const, g_dbus_server_get_client_address) _WRAP_PROPERTY("active", bool) - _WRAP_PROPERTY("address", Glib::ustring) + _WRAP_PROPERTY("address", std::string) _WRAP_PROPERTY("authentication-observer", Glib::RefPtr) - _WRAP_PROPERTY("client-address", Glib::ustring) + _WRAP_PROPERTY("client-address", std::string) _WRAP_PROPERTY("flags", DBusServerFlags) _WRAP_PROPERTY("guid", std::string) -- cgit v1.2.1