From 9ef33e864f43873deee430309c60e7e7209ee0b5 Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Mon, 28 Oct 2019 16:13:28 +0300 Subject: [PATCH] Add methods to create proxy on arbitrary connections --- codegen_glibmm/templates/proxy.cpp.templ | 47 ++++++++++++++++++++++++ codegen_glibmm/templates/proxy.h.templ | 15 +++++++- tests/data/many-types/input_proxy.cpp | 47 ++++++++++++++++++++++++ tests/data/many-types/input_proxy.h | 15 +++++++- tests/data/simple/input_proxy.cpp | 47 ++++++++++++++++++++++++ tests/data/simple/input_proxy.h | 15 +++++++- 6 files changed, 183 insertions(+), 3 deletions(-) diff --git a/codegen_glibmm/templates/proxy.cpp.templ b/codegen_glibmm/templates/proxy.cpp.templ index 3ed2c93..7be6c63 100644 --- a/codegen_glibmm/templates/proxy.cpp.templ +++ b/codegen_glibmm/templates/proxy.cpp.templ @@ -210,6 +210,53 @@ void {{ class_name_with_namespace }}::handle_properties_changed( {% endif %} } +void {{ class_name_with_namespace }}::create( + const Glib::RefPtr &connection, + Gio::DBus::ProxyFlags proxyFlags, + const std::string &name, + const std::string &objectPath, + const Gio::SlotAsyncReady &slot, + const Glib::RefPtr &cancellable) +{ + Gio::DBus::Proxy::create(connection, + name, + objectPath, + "{{ interface.name }}", + slot, + cancellable, + Glib::RefPtr(), + proxyFlags); +} + +Glib::RefPtr<{{ class_name_with_namespace }}> {{ class_name_with_namespace }}::createFinish(const Glib::RefPtr &result) +{ + Glib::RefPtr proxy = + Gio::DBus::Proxy::create_finish(result); + {{ class_name_with_namespace }} *p = + new {{ class_name_with_namespace }}(proxy); + return Glib::RefPtr<{{ class_name_with_namespace }}>(p); +} + +Glib::RefPtr<{{ class_name_with_namespace }}> {{ class_name_with_namespace }}::create_sync( + const Glib::RefPtr &connection, + Gio::DBus::ProxyFlags proxyFlags, + const std::string &name, + const std::string &objectPath, + const Glib::RefPtr &cancellable) +{ + Glib::RefPtr proxy = + Gio::DBus::Proxy::create_sync(connection, + name, + objectPath, + "{{ interface.name }}", + cancellable, + Glib::RefPtr(), + proxyFlags); + {{ class_name_with_namespace }} *p = + new {{ class_name_with_namespace }}(proxy); + return Glib::RefPtr<{{ class_name_with_namespace }}>(p); +} + void {{ class_name_with_namespace }}::createForBus( Gio::DBus::BusType busType, Gio::DBus::ProxyFlags proxyFlags, diff --git a/codegen_glibmm/templates/proxy.h.templ b/codegen_glibmm/templates/proxy.h.templ index febdda4..bfbf324 100644 --- a/codegen_glibmm/templates/proxy.h.templ +++ b/codegen_glibmm/templates/proxy.h.templ @@ -14,6 +14,12 @@ namespace {{ namespace }} { class {{ interface.cpp_class_name_proxy }} : public Glib::ObjectBase { public: + static void create(const Glib::RefPtr &connection, + Gio::DBus::ProxyFlags proxyFlags, + const std::string &name, + const std::string &objectPath, + const Gio::SlotAsyncReady &slot, + const Glib::RefPtr &cancellable = {}); static void createForBus(Gio::DBus::BusType busType, Gio::DBus::ProxyFlags proxyFlags, const std::string &name, @@ -21,8 +27,15 @@ public: const Gio::SlotAsyncReady &slot, const Glib::RefPtr &cancellable = {}); - static Glib::RefPtr<{{ interface.cpp_class_name_proxy }}> createForBusFinish (const Glib::RefPtr &result); + static Glib::RefPtr<{{ interface.cpp_class_name_proxy }}> createFinish(const Glib::RefPtr &result); + static Glib::RefPtr<{{ interface.cpp_class_name_proxy }}> create_sync( + const Glib::RefPtr &connection, + Gio::DBus::ProxyFlags proxyFlags, + const std::string &name, + const std::string &objectPath, + const Glib::RefPtr &cancellable = {}); + static Glib::RefPtr<{{ interface.cpp_class_name_proxy }}> createForBusFinish (const Glib::RefPtr &result); static Glib::RefPtr<{{ interface.cpp_class_name_proxy }}> createForBus_sync( Gio::DBus::BusType busType, Gio::DBus::ProxyFlags proxyFlags, diff --git a/tests/data/many-types/input_proxy.cpp b/tests/data/many-types/input_proxy.cpp index 4e01e8f..c4d391e 100644 --- a/tests/data/many-types/input_proxy.cpp +++ b/tests/data/many-types/input_proxy.cpp @@ -3102,6 +3102,53 @@ org::gdbus::codegen::glibmm::TestProxy::TestProxy(const Glib::RefPtr &connection, + Gio::DBus::ProxyFlags proxyFlags, + const std::string &name, + const std::string &objectPath, + const Gio::SlotAsyncReady &slot, + const Glib::RefPtr &cancellable) +{ + Gio::DBus::Proxy::create(connection, + name, + objectPath, + "org.gdbus.codegen.glibmm.Test", + slot, + cancellable, + Glib::RefPtr(), + proxyFlags); +} + +Glib::RefPtr org::gdbus::codegen::glibmm::TestProxy::createFinish(const Glib::RefPtr &result) +{ + Glib::RefPtr proxy = + Gio::DBus::Proxy::create_finish(result); + org::gdbus::codegen::glibmm::TestProxy *p = + new org::gdbus::codegen::glibmm::TestProxy(proxy); + return Glib::RefPtr(p); +} + +Glib::RefPtr org::gdbus::codegen::glibmm::TestProxy::create_sync( + const Glib::RefPtr &connection, + Gio::DBus::ProxyFlags proxyFlags, + const std::string &name, + const std::string &objectPath, + const Glib::RefPtr &cancellable) +{ + Glib::RefPtr proxy = + Gio::DBus::Proxy::create_sync(connection, + name, + objectPath, + "org.gdbus.codegen.glibmm.Test", + cancellable, + Glib::RefPtr(), + proxyFlags); + org::gdbus::codegen::glibmm::TestProxy *p = + new org::gdbus::codegen::glibmm::TestProxy(proxy); + return Glib::RefPtr(p); +} + void org::gdbus::codegen::glibmm::TestProxy::createForBus( Gio::DBus::BusType busType, Gio::DBus::ProxyFlags proxyFlags, diff --git a/tests/data/many-types/input_proxy.h b/tests/data/many-types/input_proxy.h index efe34b2..a6daab6 100644 --- a/tests/data/many-types/input_proxy.h +++ b/tests/data/many-types/input_proxy.h @@ -13,6 +13,12 @@ namespace glibmm { class TestProxy : public Glib::ObjectBase { public: + static void create(const Glib::RefPtr &connection, + Gio::DBus::ProxyFlags proxyFlags, + const std::string &name, + const std::string &objectPath, + const Gio::SlotAsyncReady &slot, + const Glib::RefPtr &cancellable = {}); static void createForBus(Gio::DBus::BusType busType, Gio::DBus::ProxyFlags proxyFlags, const std::string &name, @@ -20,8 +26,15 @@ class TestProxy : public Glib::ObjectBase { const Gio::SlotAsyncReady &slot, const Glib::RefPtr &cancellable = {}); - static Glib::RefPtr createForBusFinish (const Glib::RefPtr &result); + static Glib::RefPtr createFinish(const Glib::RefPtr &result); + static Glib::RefPtr create_sync( + const Glib::RefPtr &connection, + Gio::DBus::ProxyFlags proxyFlags, + const std::string &name, + const std::string &objectPath, + const Glib::RefPtr &cancellable = {}); + static Glib::RefPtr createForBusFinish (const Glib::RefPtr &result); static Glib::RefPtr createForBus_sync( Gio::DBus::BusType busType, Gio::DBus::ProxyFlags proxyFlags, diff --git a/tests/data/simple/input_proxy.cpp b/tests/data/simple/input_proxy.cpp index c1e91b6..4581ad9 100644 --- a/tests/data/simple/input_proxy.cpp +++ b/tests/data/simple/input_proxy.cpp @@ -130,6 +130,53 @@ org::gdbus::codegen::glibmm::TestProxy::TestProxy(const Glib::RefPtr &connection, + Gio::DBus::ProxyFlags proxyFlags, + const std::string &name, + const std::string &objectPath, + const Gio::SlotAsyncReady &slot, + const Glib::RefPtr &cancellable) +{ + Gio::DBus::Proxy::create(connection, + name, + objectPath, + "org.gdbus.codegen.glibmm.Test", + slot, + cancellable, + Glib::RefPtr(), + proxyFlags); +} + +Glib::RefPtr org::gdbus::codegen::glibmm::TestProxy::createFinish(const Glib::RefPtr &result) +{ + Glib::RefPtr proxy = + Gio::DBus::Proxy::create_finish(result); + org::gdbus::codegen::glibmm::TestProxy *p = + new org::gdbus::codegen::glibmm::TestProxy(proxy); + return Glib::RefPtr(p); +} + +Glib::RefPtr org::gdbus::codegen::glibmm::TestProxy::create_sync( + const Glib::RefPtr &connection, + Gio::DBus::ProxyFlags proxyFlags, + const std::string &name, + const std::string &objectPath, + const Glib::RefPtr &cancellable) +{ + Glib::RefPtr proxy = + Gio::DBus::Proxy::create_sync(connection, + name, + objectPath, + "org.gdbus.codegen.glibmm.Test", + cancellable, + Glib::RefPtr(), + proxyFlags); + org::gdbus::codegen::glibmm::TestProxy *p = + new org::gdbus::codegen::glibmm::TestProxy(proxy); + return Glib::RefPtr(p); +} + void org::gdbus::codegen::glibmm::TestProxy::createForBus( Gio::DBus::BusType busType, Gio::DBus::ProxyFlags proxyFlags, diff --git a/tests/data/simple/input_proxy.h b/tests/data/simple/input_proxy.h index 1070ef4..c927e48 100644 --- a/tests/data/simple/input_proxy.h +++ b/tests/data/simple/input_proxy.h @@ -13,6 +13,12 @@ namespace glibmm { class TestProxy : public Glib::ObjectBase { public: + static void create(const Glib::RefPtr &connection, + Gio::DBus::ProxyFlags proxyFlags, + const std::string &name, + const std::string &objectPath, + const Gio::SlotAsyncReady &slot, + const Glib::RefPtr &cancellable = {}); static void createForBus(Gio::DBus::BusType busType, Gio::DBus::ProxyFlags proxyFlags, const std::string &name, @@ -20,8 +26,15 @@ class TestProxy : public Glib::ObjectBase { const Gio::SlotAsyncReady &slot, const Glib::RefPtr &cancellable = {}); - static Glib::RefPtr createForBusFinish (const Glib::RefPtr &result); + static Glib::RefPtr createFinish(const Glib::RefPtr &result); + static Glib::RefPtr create_sync( + const Glib::RefPtr &connection, + Gio::DBus::ProxyFlags proxyFlags, + const std::string &name, + const std::string &objectPath, + const Glib::RefPtr &cancellable = {}); + static Glib::RefPtr createForBusFinish (const Glib::RefPtr &result); static Glib::RefPtr createForBus_sync( Gio::DBus::BusType busType, Gio::DBus::ProxyFlags proxyFlags,