Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add methods to create proxy on arbitrary connections #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions codegen_glibmm/templates/proxy.cpp.templ
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,53 @@ void {{ class_name_with_namespace }}::handle_properties_changed(
{% endif %}
}

void {{ class_name_with_namespace }}::create(
const Glib::RefPtr<Gio::DBus::Connection> &connection,
Gio::DBus::ProxyFlags proxyFlags,
const std::string &name,
const std::string &objectPath,
const Gio::SlotAsyncReady &slot,
const Glib::RefPtr<Gio::Cancellable> &cancellable)
{
Gio::DBus::Proxy::create(connection,
name,
objectPath,
"{{ interface.name }}",
slot,
cancellable,
Glib::RefPtr<Gio::DBus::InterfaceInfo>(),
proxyFlags);
}

Glib::RefPtr<{{ class_name_with_namespace }}> {{ class_name_with_namespace }}::createFinish(const Glib::RefPtr<Gio::AsyncResult> &result)
{
Glib::RefPtr<Gio::DBus::Proxy> 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<Gio::DBus::Connection> &connection,
Gio::DBus::ProxyFlags proxyFlags,
const std::string &name,
const std::string &objectPath,
const Glib::RefPtr<Gio::Cancellable> &cancellable)
{
Glib::RefPtr<Gio::DBus::Proxy> proxy =
Gio::DBus::Proxy::create_sync(connection,
name,
objectPath,
"{{ interface.name }}",
cancellable,
Glib::RefPtr<Gio::DBus::InterfaceInfo>(),
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,
Expand Down
15 changes: 14 additions & 1 deletion codegen_glibmm/templates/proxy.h.templ
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,28 @@ namespace {{ namespace }} {

class {{ interface.cpp_class_name_proxy }} : public Glib::ObjectBase {
public:
static void create(const Glib::RefPtr<Gio::DBus::Connection> &connection,
Gio::DBus::ProxyFlags proxyFlags,
const std::string &name,
const std::string &objectPath,
const Gio::SlotAsyncReady &slot,
const Glib::RefPtr<Gio::Cancellable> &cancellable = {});
static void createForBus(Gio::DBus::BusType busType,
Gio::DBus::ProxyFlags proxyFlags,
const std::string &name,
const std::string &objectPath,
const Gio::SlotAsyncReady &slot,
const Glib::RefPtr<Gio::Cancellable> &cancellable = {});

static Glib::RefPtr<{{ interface.cpp_class_name_proxy }}> createForBusFinish (const Glib::RefPtr<Gio::AsyncResult> &result);
static Glib::RefPtr<{{ interface.cpp_class_name_proxy }}> createFinish(const Glib::RefPtr<Gio::AsyncResult> &result);
static Glib::RefPtr<{{ interface.cpp_class_name_proxy }}> create_sync(
const Glib::RefPtr<Gio::DBus::Connection> &connection,
Gio::DBus::ProxyFlags proxyFlags,
const std::string &name,
const std::string &objectPath,
const Glib::RefPtr<Gio::Cancellable> &cancellable = {});

static Glib::RefPtr<{{ interface.cpp_class_name_proxy }}> createForBusFinish (const Glib::RefPtr<Gio::AsyncResult> &result);
Comment on lines +17 to +38
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: maybe reorder so that "create()" and "createForBus()" methods are kept together (and in same order as in proxy.cpp.tmpl)?

static Glib::RefPtr<{{ interface.cpp_class_name_proxy }}> createForBus_sync(
Gio::DBus::BusType busType,
Gio::DBus::ProxyFlags proxyFlags,
Expand Down
47 changes: 47 additions & 0 deletions tests/data/many-types/input_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3102,6 +3102,53 @@ org::gdbus::codegen::glibmm::TestProxy::TestProxy(const Glib::RefPtr<Gio::DBus::
connect(sigc::mem_fun(this, &TestProxy::handle_properties_changed));
}

void org::gdbus::codegen::glibmm::TestProxy::create(
const Glib::RefPtr<Gio::DBus::Connection> &connection,
Gio::DBus::ProxyFlags proxyFlags,
const std::string &name,
const std::string &objectPath,
const Gio::SlotAsyncReady &slot,
const Glib::RefPtr<Gio::Cancellable> &cancellable)
{
Gio::DBus::Proxy::create(connection,
name,
objectPath,
"org.gdbus.codegen.glibmm.Test",
slot,
cancellable,
Glib::RefPtr<Gio::DBus::InterfaceInfo>(),
proxyFlags);
}

Glib::RefPtr<org::gdbus::codegen::glibmm::TestProxy> org::gdbus::codegen::glibmm::TestProxy::createFinish(const Glib::RefPtr<Gio::AsyncResult> &result)
{
Glib::RefPtr<Gio::DBus::Proxy> proxy =
Gio::DBus::Proxy::create_finish(result);
org::gdbus::codegen::glibmm::TestProxy *p =
new org::gdbus::codegen::glibmm::TestProxy(proxy);
return Glib::RefPtr<org::gdbus::codegen::glibmm::TestProxy>(p);
}

Glib::RefPtr<org::gdbus::codegen::glibmm::TestProxy> org::gdbus::codegen::glibmm::TestProxy::create_sync(
const Glib::RefPtr<Gio::DBus::Connection> &connection,
Gio::DBus::ProxyFlags proxyFlags,
const std::string &name,
const std::string &objectPath,
const Glib::RefPtr<Gio::Cancellable> &cancellable)
{
Glib::RefPtr<Gio::DBus::Proxy> proxy =
Gio::DBus::Proxy::create_sync(connection,
name,
objectPath,
"org.gdbus.codegen.glibmm.Test",
cancellable,
Glib::RefPtr<Gio::DBus::InterfaceInfo>(),
proxyFlags);
org::gdbus::codegen::glibmm::TestProxy *p =
new org::gdbus::codegen::glibmm::TestProxy(proxy);
return Glib::RefPtr<org::gdbus::codegen::glibmm::TestProxy>(p);
}

void org::gdbus::codegen::glibmm::TestProxy::createForBus(
Gio::DBus::BusType busType,
Gio::DBus::ProxyFlags proxyFlags,
Expand Down
15 changes: 14 additions & 1 deletion tests/data/many-types/input_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,28 @@ namespace glibmm {

class TestProxy : public Glib::ObjectBase {
public:
static void create(const Glib::RefPtr<Gio::DBus::Connection> &connection,
Gio::DBus::ProxyFlags proxyFlags,
const std::string &name,
const std::string &objectPath,
const Gio::SlotAsyncReady &slot,
const Glib::RefPtr<Gio::Cancellable> &cancellable = {});
static void createForBus(Gio::DBus::BusType busType,
Gio::DBus::ProxyFlags proxyFlags,
const std::string &name,
const std::string &objectPath,
const Gio::SlotAsyncReady &slot,
const Glib::RefPtr<Gio::Cancellable> &cancellable = {});

static Glib::RefPtr<TestProxy> createForBusFinish (const Glib::RefPtr<Gio::AsyncResult> &result);
static Glib::RefPtr<TestProxy> createFinish(const Glib::RefPtr<Gio::AsyncResult> &result);
static Glib::RefPtr<TestProxy> create_sync(
const Glib::RefPtr<Gio::DBus::Connection> &connection,
Gio::DBus::ProxyFlags proxyFlags,
const std::string &name,
const std::string &objectPath,
const Glib::RefPtr<Gio::Cancellable> &cancellable = {});

static Glib::RefPtr<TestProxy> createForBusFinish (const Glib::RefPtr<Gio::AsyncResult> &result);
static Glib::RefPtr<TestProxy> createForBus_sync(
Gio::DBus::BusType busType,
Gio::DBus::ProxyFlags proxyFlags,
Expand Down
47 changes: 47 additions & 0 deletions tests/data/simple/input_proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,53 @@ org::gdbus::codegen::glibmm::TestProxy::TestProxy(const Glib::RefPtr<Gio::DBus::
org::gdbus::codegen::glibmm::Error::initialize();
}

void org::gdbus::codegen::glibmm::TestProxy::create(
const Glib::RefPtr<Gio::DBus::Connection> &connection,
Gio::DBus::ProxyFlags proxyFlags,
const std::string &name,
const std::string &objectPath,
const Gio::SlotAsyncReady &slot,
const Glib::RefPtr<Gio::Cancellable> &cancellable)
{
Gio::DBus::Proxy::create(connection,
name,
objectPath,
"org.gdbus.codegen.glibmm.Test",
slot,
cancellable,
Glib::RefPtr<Gio::DBus::InterfaceInfo>(),
proxyFlags);
}

Glib::RefPtr<org::gdbus::codegen::glibmm::TestProxy> org::gdbus::codegen::glibmm::TestProxy::createFinish(const Glib::RefPtr<Gio::AsyncResult> &result)
{
Glib::RefPtr<Gio::DBus::Proxy> proxy =
Gio::DBus::Proxy::create_finish(result);
org::gdbus::codegen::glibmm::TestProxy *p =
new org::gdbus::codegen::glibmm::TestProxy(proxy);
return Glib::RefPtr<org::gdbus::codegen::glibmm::TestProxy>(p);
}

Glib::RefPtr<org::gdbus::codegen::glibmm::TestProxy> org::gdbus::codegen::glibmm::TestProxy::create_sync(
const Glib::RefPtr<Gio::DBus::Connection> &connection,
Gio::DBus::ProxyFlags proxyFlags,
const std::string &name,
const std::string &objectPath,
const Glib::RefPtr<Gio::Cancellable> &cancellable)
{
Glib::RefPtr<Gio::DBus::Proxy> proxy =
Gio::DBus::Proxy::create_sync(connection,
name,
objectPath,
"org.gdbus.codegen.glibmm.Test",
cancellable,
Glib::RefPtr<Gio::DBus::InterfaceInfo>(),
proxyFlags);
org::gdbus::codegen::glibmm::TestProxy *p =
new org::gdbus::codegen::glibmm::TestProxy(proxy);
return Glib::RefPtr<org::gdbus::codegen::glibmm::TestProxy>(p);
}

void org::gdbus::codegen::glibmm::TestProxy::createForBus(
Gio::DBus::BusType busType,
Gio::DBus::ProxyFlags proxyFlags,
Expand Down
15 changes: 14 additions & 1 deletion tests/data/simple/input_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,28 @@ namespace glibmm {

class TestProxy : public Glib::ObjectBase {
public:
static void create(const Glib::RefPtr<Gio::DBus::Connection> &connection,
Gio::DBus::ProxyFlags proxyFlags,
const std::string &name,
const std::string &objectPath,
const Gio::SlotAsyncReady &slot,
const Glib::RefPtr<Gio::Cancellable> &cancellable = {});
static void createForBus(Gio::DBus::BusType busType,
Gio::DBus::ProxyFlags proxyFlags,
const std::string &name,
const std::string &objectPath,
const Gio::SlotAsyncReady &slot,
const Glib::RefPtr<Gio::Cancellable> &cancellable = {});

static Glib::RefPtr<TestProxy> createForBusFinish (const Glib::RefPtr<Gio::AsyncResult> &result);
static Glib::RefPtr<TestProxy> createFinish(const Glib::RefPtr<Gio::AsyncResult> &result);
static Glib::RefPtr<TestProxy> create_sync(
const Glib::RefPtr<Gio::DBus::Connection> &connection,
Gio::DBus::ProxyFlags proxyFlags,
const std::string &name,
const std::string &objectPath,
const Glib::RefPtr<Gio::Cancellable> &cancellable = {});

static Glib::RefPtr<TestProxy> createForBusFinish (const Glib::RefPtr<Gio::AsyncResult> &result);
static Glib::RefPtr<TestProxy> createForBus_sync(
Gio::DBus::BusType busType,
Gio::DBus::ProxyFlags proxyFlags,
Expand Down