Added MonitorConnection template with 4 arguments.
BUG=chromium-os:17673
TEST=NONE
Change-Id: Icd3d6aa65f8696f9b2dd12b28d638c0cf8f58302
Reviewed-on: http://gerrit.chromium.org/gerrit/4447
Reviewed-by: Zelidrag Hornung <zelidrag@chromium.org>
Tested-by: Toni Barzic <tbarzic@chromium.org>
diff --git a/chromeos/dbus/dbus.h b/chromeos/dbus/dbus.h
index f786b2b..51e836a 100644
--- a/chromeos/dbus/dbus.h
+++ b/chromeos/dbus/dbus.h
@@ -247,7 +247,6 @@
std::string name_;
void (*monitor_)(void*, A1, A2);
void* object_;
-
};
template <typename A1, typename A2, typename A3>
@@ -273,7 +272,32 @@
std::string name_;
void (*monitor_)(void*, A1, A2, A3);
void* object_;
+};
+template <typename A1, typename A2, typename A3, typename A4>
+class MonitorConnection<void (A1, A2, A3, A4)> {
+ public:
+ MonitorConnection(const Proxy& proxy, const char* name,
+ void (*monitor)(void*, A1, A2, A3, A4), void* object)
+ : proxy_(proxy), name_(name), monitor_(monitor), object_(object) {
+ }
+
+ static void Run(::DBusGProxy*, A1 x, A2 y, A3 z, A4 w,
+ MonitorConnection* self) {
+ self->monitor_(self->object_, x, y, z, w);
+ }
+ const Proxy& proxy() const {
+ return proxy_;
+ }
+ const std::string& name() const {
+ return name_;
+ }
+
+ private:
+ Proxy proxy_;
+ std::string name_;
+ void (*monitor_)(void*, A1, A2, A3, A4);
+ void* object_;
};
template <typename A1>
@@ -330,6 +354,27 @@
return result;
}
+template <typename A1, typename A2, typename A3, typename A4>
+MonitorConnection<void (A1, A2, A3, A4)>* Monitor(const Proxy& proxy,
+ const char* name,
+ void (*monitor)(void*, A1, A2, A3, A4),
+ void* object) {
+ typedef MonitorConnection<void (A1, A2, A3, A4)> ConnectionType;
+
+ ConnectionType* result = new ConnectionType(proxy, name, monitor, object);
+
+ ::dbus_g_proxy_add_signal(proxy.gproxy(), name,
+ glib::type_to_gtypeid<A1>(),
+ glib::type_to_gtypeid<A2>(),
+ glib::type_to_gtypeid<A3>(),
+ glib::type_to_gtypeid<A4>(),
+ G_TYPE_INVALID);
+ ::dbus_g_proxy_connect_signal(proxy.gproxy(), name,
+ G_CALLBACK(&ConnectionType::Run),
+ result, NULL);
+ return result;
+}
+
template <typename F>
void Disconnect(MonitorConnection<F>* connection) {
typedef MonitorConnection<F> ConnectionType;