#include <settingsd/glib_traits.hpp>
#include <settingsd/json_glib_traits.hpp>
#include <settingsd/unique_ptr.hpp>
+#include <settingsd/dbus_signal_callback.hpp>
#include <cstring>
#include <boost/lexical_cast.hpp>
ivi::settings::clock::clock(GDBusConnection * connection,
event_callback const & e)
- : connman_("net.connman.Clock", "/", connection, e)
+ : connman_("net.connman.Clock", "/", connection)
+ , event_callback_(e)
+ , subscription_id_(
+ g_dbus_connection_signal_subscribe(
+ connection,
+ nullptr,
+ connman_.interface_name(),
+ "PropertyChanged",
+ connman_.object_path(),
+ nullptr,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ on_dbus_signal,
+ &event_callback_,
+ nullptr))
{
}
ivi::settings::clock::~clock()
{
+ g_dbus_connection_signal_unsubscribe(
+ connman_.connection(),
+ subscription_id_);
}
std::string const &
#include "connman.hpp"
#include <settingsd/plugin.hpp>
+#include <settingsd/event_callback.hpp>
#include <json-glib/json-glib.h>
/// Underlying connman proxy.
connman connman_;
+ /// Callback through which events will be sent to clients.
+ event_callback event_callback_;
+
+ /// PropertyChanged signal subscription ID.
+ guint const subscription_id_;
+
};
}
#include <settingsd/glib_traits.hpp>
#include <settingsd/unique_ptr.hpp>
-#include <settingsd/dbus_signal_callback.hpp>
#include <cstring>
#include <string>
ivi::settings::connman::connman(char const * interface,
char const * path,
- GDBusConnection * connection,
- event_callback const & e)
+ GDBusConnection * connection)
: proxy_(nullptr)
- , event_callback_(e)
- , subscription_id_(0)
{
static char const name[] = "net.connman"; // Service
throw std::runtime_error(error->message);
}
-
- // Listen for changes to properties.
- subscription_id_ =
- g_dbus_connection_signal_subscribe(
- connection,
- nullptr,
- interface,
- "PropertyChanged",
- path,
- nullptr,
- G_DBUS_SIGNAL_FLAGS_NONE,
- on_dbus_signal,
- &event_callback_,
- nullptr);
}
ivi::settings::connman::~connman()
{
- if (proxy_ != nullptr) {
- g_dbus_connection_signal_unsubscribe(
- g_dbus_proxy_get_connection(G_DBUS_PROXY(proxy_)),
- subscription_id_);
-
+ if (proxy_ != nullptr)
g_object_unref(proxy_);
- }
}
GVariant *
#ifndef IVI_SETTINGS_CONNMAN_HPP
#define IVI_SETTINGS_CONNMAN_HPP
-#include <settingsd/event_callback.hpp>
-
#include <gio/gio.h>
* @param[in] interface Connman D-Bus interface.
* @param[in] path Connman D-Bus object path.
* @param[in] connection Underlying D-Bus connection.
- * @param[in] e Callback through which events will be
- * sent to clients.
*/
connman(char const * interface,
char const * path,
- GDBusConnection * connection,
- event_callback const & e);
+ GDBusConnection * connection);
/// Destructor.
~connman();
/// The proxy used to access the Connman D-Bus API.
GDBusProxy * proxy_;
- /// Callback through which events will be sent to clients.
- event_callback event_callback_;
-
- /// PropertyChanged signal subscription ID.
- guint subscription_id_;
-
};
}
event_callback const & e)
: connman_("net.connman.Manager", // Interface
"/", // Object path
- connection,
- e)
+ connection)
, data_(connection, e)
, technology_added_id_(subscribe_to_signal(connection,
"TechnologyAdded",
}
}
- // Unsubscribe from ServicesChanged signal.
+ // Unsubscribe from ServicesChanged, TechnologyRemoved and
+ // TechnologyAdded signals.
g_dbus_connection_signal_unsubscribe(connman_.connection(),
services_changed_id_);
g_dbus_connection_signal_unsubscribe(connman_.connection(),
// ----------------------------------------------------------------------
ivi::settings::connman_service::connman_service(
- GDBusConnection * connection,
- event_callback const & e)
+ GDBusConnection * connection)
: connection_(connection)
- , event_callback_(e)
{
}
json_reader_end_element(reader);
if (path != nullptr) {
- service s(path, connection_, event_callback_);
+ service s(path, connection_);
s.handle_request(name, reader, response);
}
}
#include "connman.hpp"
#include <settingsd/plugin.hpp>
-#include <settingsd/event_callback.hpp>
#include <gio/gio.h>
public:
/// Constructor.
- connman_service(GDBusConnection * connection,
- event_callback const & e);
+ connman_service(GDBusConnection * connection);
/// Destructor.
~connman_service();
/// The underlying D-Bus connection.
GDBusConnection * const connection_;
- /// Callback through which events will be sent to clients.
- event_callback event_callback_;
-
};
}
ivi::settings::connman_technology::connman_technology(
GDBusConnection * connection,
- connman_manager & manager,
- event_callback const & e)
+ connman_manager & manager)
: connman_("net.connman.Technology", // Interface
"/", // Object path
- connection,
- e)
+ connection)
, manager_(manager)
- , event_callback_(e)
{
}
json_reader_end_element(reader);
if (path != nullptr) {
- technology t(path,
- connman_.connection(),
- manager_,
- event_callback_);
+ technology t(path, connman_.connection(), manager_);
t.handle_request(name, reader, response);
}
}
#include "connman.hpp"
#include <settingsd/plugin.hpp>
-#include <settingsd/event_callback.hpp>
#include <gio/gio.h>
/// Constructor.
connman_technology(GDBusConnection * connection,
- connman_manager & manager,
- event_callback const & e);
+ connman_manager & manager);
/// Destructor.
~connman_technology();
/// The proxy used to access the connman Manager D-Bus API.
connman_manager & manager_;
- /// Callback through which events will be sent to clients.
- event_callback event_callback_;
-
};
}
std::unique_ptr<ivi::settings::plugin> manager(mgr);
std::unique_ptr<ivi::settings::plugin> service(
- new ivi::settings::connman_service(connection, e));
+ new ivi::settings::connman_service(connection));
std::unique_ptr<ivi::settings::plugin> technology(
- new ivi::settings::connman_technology(connection, *mgr, e));
+ new ivi::settings::connman_technology(connection, *mgr));
std::unique_ptr<ivi::settings::plugin> clk(
new ivi::settings::clock(connection, e));
ivi::settings::service::service(std::string service_path,
- GDBusConnection * connection,
- event_callback const & e)
+ GDBusConnection * connection)
: connman_("net.connman.Service", // Interface
service_path.c_str(), // Object path
- connection,
- e)
+ connection)
{
}
* sent to clients.
*/
service(std::string service_path,
- GDBusConnection * connection,
- event_callback const & e);
+ GDBusConnection * connection);
/**
* Handle connman Service object request.
#include "technology.hpp"
#include "connman_manager.hpp"
-#include "service.hpp"
#include <settingsd/response_callback.hpp>
#include <settingsd/glib_traits.hpp>
ivi::settings::technology::technology(char const * path,
GDBusConnection * connection,
- connman_manager & manager,
- event_callback const & e)
+ connman_manager & manager)
: connman_("net.connman.Technology", // Interface
path, // Object path
- connection,
- e)
+ connection)
, manager_(manager)
- , event_callback_(e)
{
}
* @param[in] path The connman technology object path.
* @param[in] connection Underlying D-Bus connection.
* @param[in] manager Connman manager proxy.
- * @param[in] e Callback through which events will be
- * sent to clients.
*/
technology(char const * path,
GDBusConnection * connection,
- connman_manager & manager,
- event_callback const & e);
+ connman_manager & manager);
/**
* Handle connman technology-specific request.
/// The proxy used to access the connman Manager D-Bus API.
connman_manager & manager_;
- /// Callback through which events will be sent to clients.
- event_callback event_callback_;
-
};
}