{
template<typename T> struct traits;
+ // GDBusConnection traits specialization.
+ template<>
+ struct traits<GDBusConnection>
+ {
+ struct delete_functor
+ {
+ void
+ operator()(GDBusConnection * p) const
+ {
+ if (p != nullptr)
+ g_object_unref(p);
+ }
+ };
+ };
+
+
// GVariant traits specialization.
template<>
struct traits<GVariant>
template<>
struct traits<GVariantIter>
{
- // Functor to be used in std::unique_ptr<> specialization.
struct delete_functor
{
void
operator()(GMainLoop * p) const
{
if (p != nullptr)
+ g_main_loop_quit(p);
g_main_loop_unref(p);
}
};
{
GError * error = nullptr;
- connection_ = g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &error);
+ connection_.reset(
+ g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &error));
if (connection_ == nullptr) {
unique_ptr<GError> safe_error(error);
GError * error = nullptr;
if (connection_ != nullptr
- && !g_dbus_connection_close_sync(connection_,
+ && !g_dbus_connection_close_sync(connection_.get(),
nullptr,
&error)) {
g_critical("D-Bus connection close failed: %s.\n",
#include <gio/gio.h>
+#include <settingsd/glib_traits.hpp>
+#include <settingsd/unique_ptr.hpp>
+
namespace ivi
{
GDBusConnection *
connection()
{
- return connection_;
+ return connection_.get();
}
private:
private:
/// Underlying connection to D-Bus system bus.
- GDBusConnection * connection_;
+ unique_ptr<GDBusConnection> connection_;
};
}