response_callback.hpp \
glib_traits.hpp \
json_glib_traits.hpp \
- smart_ptr.hpp \
+ unique_ptr.hpp \
dbus_signal_callback.hpp
{
namespace settings
{
- template<typename T> class smart_ptr;
class manager;
/**
* The appropriate "header" information will be prepended to the
* event.
*/
- smart_ptr<JsonBuilder> begin_event();
+ unique_ptr<JsonBuilder> begin_event();
/**
* End the JSON formatted event to the Settings app request.
*/
- void end_event(smart_ptr<JsonBuilder> const & builder);
+ void end_event(unique_ptr<JsonBuilder> const & builder);
private:
*
* @brief @c GLib traits.
*
+ * This header contains traits specific to GLib types.
+ *
* @author Ossama Othman @<ossama.othman@@intel.com@>
*
* @copyright @par
{
template<typename T> struct traits;
+ // GVariant traits specialization.
template<>
struct traits<GVariant>
{
- static void
- release(GVariant * p)
+ struct delete_functor
{
- if (p != nullptr)
- g_variant_unref(p);
- }
+ void
+ operator()(GVariant * p) const
+ {
+ if (p != nullptr)
+ g_variant_unref(p);
+ }
+ };
};
+ // GVariantIter traits specialization.
template<>
struct traits<GVariantIter>
{
- static void release(GVariantIter * p) { g_variant_iter_free(p); }
+ // Functor to be used in std::unique_ptr<> specialization.
+ struct delete_functor
+ {
+ void
+ operator()(GVariantIter * p) const
+ {
+ g_variant_iter_free(p);
+ }
+ };
};
+ // gchar traits specialization.
template<>
struct traits<gchar>
{
- static void release(gchar * p) { g_free(p); }
+ struct delete_functor
+ {
+ void
+ operator()(gchar * p) const
+ {
+ g_free(p);
+ }
+ };
};
+ // GError traits specialization.
template<>
struct traits<GError>
{
- static void release(GError * p)
+ struct delete_functor
{
- if (p != nullptr)
- g_error_free(p);
- }
+ void
+ operator()(GError * p) const
+ {
+ if (p != nullptr)
+ g_error_free(p);
+ }
+ };
};
+ // GMainLoop traits specialization.
template<>
struct traits<GMainLoop>
{
- static void release(GMainLoop * p)
+ struct delete_functor
{
- if (p != nullptr)
- g_main_loop_unref(p);
- }
+ void
+ operator()(GMainLoop * p) const
+ {
+ if (p != nullptr)
+ g_main_loop_unref(p);
+ }
+ };
};
}
}
+
#endif /* IVI_SETTINGS_GLIB_TRAITS_HPP */
*
* @brief @c JSON-GLib traits.
*
+ * This header contains traits specific to JSON-GLib types.
+ *
* @author Ossama Othman @<ossama.othman@@intel.com@>
*
* @copyright @par
{
namespace settings
{
+ /**
+ * @struct gobject_delete_functor
+ *
+ * @brief Release @c GObject subclasses.
+ *
+ * This functor is used to release @c GObject classes. It may be
+ * used anywhere a C++ functor with a function call operator of
+ * the form:
+ * @c void operator()(T * p) const
+ * is required, such as for the @c std::unique_ptr<> "@c deleter"
+ * template or constructor parameter.
+ */
+ template<typename T>
+ struct gobject_delete_functor
+ {
+ void
+ operator()(T * p) const
+ {
+ if (p != nullptr)
+ g_object_unref(G_OBJECT(p));
+ }
+ };
+
template<typename T> struct traits;
+ // JsonNode traits specialization.
template<>
struct traits<JsonNode>
{
- static void release(JsonNode * p) { json_node_free(p); }
+ struct delete_functor
+ {
+ void
+ operator()(JsonNode * p) const
+ {
+ json_node_free(p);
+ }
+ };
};
+ // JsonParser traits specialization.
template<>
struct traits<JsonParser>
{
- static void
- release(JsonParser * p)
- {
- if (p != nullptr)
- g_object_unref(p);
- }
+ typedef gobject_delete_functor<JsonParser> delete_functor;
};
+ // JsonReader traits specialization.
template<>
struct traits<JsonReader>
{
- static void
- release(JsonReader * p)
- {
- if (p != nullptr)
- g_object_unref(p);
- }
+ typedef gobject_delete_functor<JsonReader> delete_functor;
};
+ // JsonBuilder traits specialization.
template<>
struct traits<JsonBuilder>
{
- static void
- release(JsonBuilder * p)
- {
- if (p != nullptr)
- g_object_unref(p);
- }
+ typedef gobject_delete_functor<JsonBuilder> delete_functor;
};
+ // JsonGenerator traits specialization.
template<>
struct traits<JsonGenerator>
{
- static void
- release(JsonGenerator * p)
- {
- if (p != nullptr)
- g_object_unref(p);
- }
+ typedef gobject_delete_functor<JsonGenerator> delete_functor;
};
}
{
namespace settings
{
- template<typename T> class smart_ptr;
-
/**
* @class response_callback response_callback.hpp <settingsd/response_callback.hpp>
*
*
* @param[in] result @c "succeeded" or @c "failed"
*/
- smart_ptr<JsonBuilder> begin_response(char const * result);
+ unique_ptr<JsonBuilder> begin_response(char const * result);
/**
* End the JSON formatted response to the Settings app request.
*/
- void end_response(smart_ptr<JsonBuilder> const & builder);
+ void end_response(unique_ptr<JsonBuilder> const & builder);
private:
#ifndef IVI_SETTINGS_SEND_CALLBACK_HPP
#define IVI_SETTINGS_SEND_CALLBACK_HPP
+#include <settingsd/json_glib_traits.hpp>
+#include <settingsd/unique_ptr.hpp>
+
#include <libwebsockets.h>
-#include <json-glib/json-glib.h>
namespace ivi
{
namespace settings
{
- template<typename T> class smart_ptr;
-
/**
* @class send_callback
*
* pre-marshalled (in-memory) payload.
*/
bool send_payload(char const * send_type,
- smart_ptr<JsonBuilder> const & builder);
+ unique_ptr<JsonBuilder> const & builder);
/**
* Check if the WebSocket instance @a wsi corresponds to this
+++ /dev/null
-/**
- * @file smart_ptr.hpp
- *
- * @brief C++11 style smart pointer for use by settings plug-ins.
- *
- * @author Ossama Othman @<ossama.othman@@intel.com@>
- *
- * @copyright @par
- * Copyright 2013 Intel Corporation All Rights Reserved.
- * @par
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License.
- * @par
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- * @par
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef IVI_SETTINGS_SMART_PTR_HPP
-#define IVI_SETTINGS_SMART_PTR_HPP
-
-#include <cstddef>
-#include <utility>
-#include <functional>
-
-
-namespace ivi
-{
- namespace settings
- {
- /**
- * @class smart_ptr
- *
- * @brief C++11 style smart pointer for use by settings plug-ins.
- *
- * This class exposes a C++11-style smart pointer interface to
- * allow RAII based handling of resources provided by third party
- * libraries, such as Glib. Core functionality is implemented in
- * traits that this class template leverages.
- */
- template<typename T>
- class smart_ptr
- {
- public:
- typedef T * pointer;
- typedef T element_type;
- typedef traits<T> traits_type;
-
- constexpr smart_ptr() : p_(nullptr) {}
-
- constexpr smart_ptr(std::nullptr_t) : p_(nullptr) {}
-
- explicit smart_ptr(pointer p) : p_(p) {}
-
- smart_ptr(smart_ptr&& u) : p_(u.p_) { u.p_ = nullptr; }
-
- ~smart_ptr() { traits_type::release(p_); }
-
- smart_ptr &
- operator=(smart_ptr && r)
- {
- if (this != &r) {
- smart_ptr<T> tmp(r);
- swap(tmp);
- }
-
- return *this;
- }
-
- smart_ptr &
- operator=(std::nullptr_t)
- {
- reset(nullptr);
-
- return *this;
- }
-
- pointer
- release()
- {
- pointer const old = p_;
- p_ = nullptr;
-
- return old;
- }
-
- void
- reset(pointer p = pointer())
- {
- smart_ptr<T> tmp(p);
- swap(tmp);
- }
-
- void swap(smart_ptr& other) { std::swap(p_, other.p_); }
-
- pointer get() const { return p_; }
-
- explicit operator bool() const { return p_ != nullptr; }
-
- typename std::add_lvalue_reference<T>::type
- operator*() const
- {
- /**
- * @todo Throw exception if @c p_ @c == @c nullptr.
- */
- return *p_;
- }
-
- pointer operator->() const { return p_; }
-
- private:
-
- /**
- * @name Prevent copying
- */
- //@{
- smart_ptr(smart_ptr const &) = delete;
- smart_ptr & operator=(smart_ptr const &) = delete;
- //@}
-
- private:
-
- /// Pointer to the object being managed.
- T * p_;
-
- };
-
- template<typename T1, typename T2>
- bool
- operator==(smart_ptr<T1> const & x, smart_ptr<T2> const & y)
- {
- return x.get() == y.get();
- }
-
- template<typename T1, typename T2>
- bool
- operator!=(smart_ptr<T1> const & x, smart_ptr<T2> const & y)
- {
- return x.get() != y.get();
- }
-
- template<typename T1, typename T2>
- bool
- operator<(smart_ptr<T1> const & x, smart_ptr<T2> const & y)
- {
- typedef typename
- std::common_type<typename smart_ptr<T1>::pointer,
- typename smart_ptr<T2>::pointer>::type type;
-
- return std::less<type>()(x.get(), y.get());
- }
-
-
- template<typename T1, typename T2>
- bool operator<=(smart_ptr<T1> const & x, smart_ptr<T2> const & y)
- {
- return !(y < x);
- }
-
- template<typename T1, typename T2>
- bool
- operator>(smart_ptr<T1> const & x, smart_ptr<T2> const & y)
- {
- return (y < x);
- }
-
- template<typename T1, typename T2>
- bool
- operator>=(smart_ptr<T1> const & x, smart_ptr<T2> const & y)
- {
- return !(x < y);
- }
-
- template<typename T>
- bool
- operator==(smart_ptr<T> const & x, std::nullptr_t) noexcept
- {
- return !x;
- }
-
- template<typename T>
- bool
- operator==(std::nullptr_t, smart_ptr<T> const & x) noexcept
- {
- return !x;
- }
-
- template<typename T>
- bool
- operator!=(smart_ptr<T> const & x, std::nullptr_t) noexcept
- {
- return static_cast<bool>(x);
- }
-
- template<typename T>
- bool
- operator!=(std::nullptr_t, smart_ptr<T> const & x) noexcept
- {
- return static_cast<bool>(x);
- }
-
- template<typename T>
- bool
- operator<(smart_ptr<T> const & x, std::nullptr_t)
- {
- return std::less<typename smart_ptr<T>::pointer>()(x.get(), nullptr);
- }
-
- template<typename T>
- bool
- operator<(std::nullptr_t, smart_ptr<T> const & y)
- {
- return std::less<typename smart_ptr<T>::pointer>()(nullptr, y.get());
- }
-
- template<typename T>
- bool
- operator<=(smart_ptr<T> const & x, std::nullptr_t)
- {
- return nullptr < x;
- }
-
- template<typename T>
- bool
- operator<=(std::nullptr_t, smart_ptr<T> const & y)
- {
- return y < nullptr;
- }
-
- template<typename T>
- bool
- operator>(smart_ptr<T> const & x, std::nullptr_t)
- {
- return !(nullptr < x);
- }
-
- template<typename T>
- bool
- operator>(std::nullptr_t, smart_ptr<T> const & y)
- {
- return !(y < nullptr);
- }
-
- template<typename T>
- bool
- operator>=(smart_ptr<T> const & x, std::nullptr_t)
- {
- return !(x < nullptr);
- }
-
- template<typename T>
- bool
- operator>=(std::nullptr_t, smart_ptr<T> const & y)
- {
- return !(nullptr < y);
- }
-
- }
-}
-
-namespace std
-{
- template<typename T>
- void
- swap(ivi::settings::smart_ptr<T> & lhs,
- ivi::settings::smart_ptr<T> & rhs)
- {
- lhs.swap(rhs);
- }
-
- template<typename T>
- struct hash<ivi::settings::smart_ptr<T>>
- {
- typedef ivi::settings::smart_ptr<T> argument_type;
- typedef std::size_t result_type;
-
- hash();
-
- result_type
- operator()(argument_type const & p) const
- {
- typedef typename argument_type::pointer key_type;
-
- return hash<key_type>(p.get());
- }
- };
-}
-
-#endif /* IVI_SETTINGS_SMART_PTR_HPP */
-
-
-// Local Variables:
-// mode:c++
-// c-basic-offset:2
-// indent-tabs-mode: nil
-// End:
--- /dev/null
+/**
+ * @file unique_ptr.hpp
+ *
+ * @brief C++11 style @c unique_ptr for use by settings plug-ins.
+ *
+ * @author Ossama Othman @<ossama.othman@@intel.com@>
+ *
+ * @copyright @par
+ * Copyright 2013 Intel Corporation All Rights Reserved.
+ * @par
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ * @par
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ * @par
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef IVI_SETTINGS_UNIQUE_PTR_HPP
+#define IVI_SETTINGS_UNIQUE_PTR_HPP
+
+#include <memory>
+
+
+namespace ivi
+{
+ namespace settings
+ {
+ /**
+ * @typedef unique_ptr
+ *
+ * @brief C++11 style unique pointer for use by settings plug-ins.
+ *
+ * This type alias exposes a C++11-style @c unique_ptr interface
+ * to allow RAII based handling of resources provided by third
+ * party libraries, such as Glib. Core functionality is
+ * implemented in traits that this type alias leverages.
+ */
+ template<typename T> using unique_ptr =
+ ::std::unique_ptr<T,
+ typename traits<T>::delete_functor>;
+ }
+}
+
+#endif /* IVI_SETTINGS_UNIQUE_PTR_HPP */
+
+
+// Local Variables:
+// mode:c++
+// c-basic-offset:2
+// indent-tabs-mode: nil
+// End:
#include <settingsd/event_callback.hpp>
#include <settingsd/json_glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include "manager.hpp"
ivi::settings::event_callback::send_event(
std::function<void(JsonBuilder *)> event_builder)
{
- smart_ptr<JsonBuilder> const builder = begin_event();
+ unique_ptr<JsonBuilder> const builder = begin_event();
// Append settings type-specific JSON formatted events.
event_builder(builder.get());
return manager_.send_event(builder);
}
-ivi::settings::smart_ptr<JsonBuilder>
+ivi::settings::unique_ptr<JsonBuilder>
ivi::settings::event_callback::begin_event()
{
// Construct JSON event string.
- smart_ptr<JsonBuilder> safe_builder(json_builder_new());
+ unique_ptr<JsonBuilder> safe_builder(json_builder_new());
JsonBuilder * const builder = safe_builder.get();
json_builder_begin_object(builder);
void
ivi::settings::event_callback::end_event(
- ivi::settings::smart_ptr<JsonBuilder> const & builder)
+ ivi::settings::unique_ptr<JsonBuilder> const & builder)
{
json_builder_end_object(builder.get());
}
#include <settingsd/plugin.hpp>
#include <settingsd/response_callback.hpp>
#include <settingsd/json_glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <gmodule.h>
return;
}
- smart_ptr<JsonParser> const parser(json_parser_new());
+ unique_ptr<JsonParser> const parser(json_parser_new());
json_parser_load_from_data(parser.get(), request.c_str(), -1, nullptr);
JsonReader * const reader = json_reader_new(json_parser_get_root(parser.get()));
- smart_ptr<JsonReader> const safe_reader(reader);
+ unique_ptr<JsonReader> const safe_reader(reader);
// Retrieve setting name and transcation ID from the JSON request
// string.
bool
ivi::settings::manager::send_event(
- smart_ptr<JsonBuilder> const & builder)
+ unique_ptr<JsonBuilder> const & builder)
{
bool success = true;
*
* @return @c true on success.
*/
- bool send_event(smart_ptr<JsonBuilder> const & builder);
+ bool send_event(unique_ptr<JsonBuilder> const & builder);
private:
#include <settingsd/response_callback.hpp>
#include <settingsd/json_glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
ivi::settings::response_callback::response_callback(
ivi::settings::response_callback::send_response(
std::function<void(JsonBuilder *)> response_builder)
{
- smart_ptr<JsonBuilder> const builder = begin_response("succeeded");
+ unique_ptr<JsonBuilder> const builder = begin_response("succeeded");
// Append successful Settings app results to the JSON formatted
// response.
bool
ivi::settings::response_callback::send_error(std::string error_message)
{
- smart_ptr<JsonBuilder> builder = begin_response("failed");
+ unique_ptr<JsonBuilder> builder = begin_response("failed");
json_builder_set_member_name(builder.get(), "reason");;
json_builder_add_string_value(builder.get(), error_message.c_str());
json_builder_add_string_value(builder, value.c_str());
}
-ivi::settings::smart_ptr<JsonBuilder>
+ivi::settings::unique_ptr<JsonBuilder>
ivi::settings::response_callback::begin_response(char const * result)
{
// Construct JSON response.
- smart_ptr<JsonBuilder> safe_builder(json_builder_new());
+ unique_ptr<JsonBuilder> safe_builder(json_builder_new());
JsonBuilder * const builder = safe_builder.get();
json_builder_begin_object(builder);
void
ivi::settings::response_callback::end_response(
- ivi::settings::smart_ptr<JsonBuilder> const & builder)
+ ivi::settings::unique_ptr<JsonBuilder> const & builder)
{
json_builder_end_object(builder.get());
}
#include <settingsd/send_callback.hpp>
#include <settingsd/glib_traits.hpp>
#include <settingsd/json_glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <cstring>
#include <vector>
bool
ivi::settings::send_callback::send_payload(
char const * send_type,
- smart_ptr<JsonBuilder> const & builder)
+ unique_ptr<JsonBuilder> const & builder)
{
- smart_ptr<JsonGenerator> const generator(json_generator_new());
- smart_ptr<JsonNode> const root(json_builder_get_root(builder.get()));
+ unique_ptr<JsonGenerator> const generator(json_generator_new());
+ unique_ptr<JsonNode> const root(json_builder_get_root(builder.get()));
json_generator_set_root(generator.get(), root.get());
gchar * const data =
json_generator_to_data(generator.get(), nullptr);
- smart_ptr<gchar> safe_data(data);
+ unique_ptr<gchar> safe_data(data);
if (data == nullptr) {
g_critical("Unable to generate JSON formatted %s payload:\n",
#include <settingsd/response_callback.hpp>
#include <settingsd/glib_traits.hpp>
#include <settingsd/json_glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <cstring>
#include <boost/lexical_cast.hpp>
ivi::settings::clock::handle_request(std::string request,
response_callback response)
{
- smart_ptr<JsonParser> const parser(json_parser_new());
+ unique_ptr<JsonParser> const parser(json_parser_new());
json_parser_load_from_data(parser.get(), request.c_str(), -1, nullptr);
JsonReader * const reader =
json_reader_new(json_parser_get_root(parser.get()));
- smart_ptr<JsonReader> safe_reader(reader);
+ unique_ptr<JsonReader> safe_reader(reader);
char const * name = nullptr;
if (json_reader_read_member(reader, "name")) {
"Unrecognized " + id() + " request name: " + name);
}
- smart_ptr<GError> safe_error(error);
+ unique_ptr<GError> safe_error(error);
if (success) {
? "<invalid_string>"
: updates));
} else {
- smart_ptr<GVariant> const current_value(get_property(name, error));
+ unique_ptr<GVariant> const current_value(get_property(name, error));
if (current_value != nullptr) {
char const * value =
return;
}
- smart_ptr<GVariant> const current_value(get_property(name, error));
+ unique_ptr<GVariant> const current_value(get_property(name, error));
if (current_value != nullptr) {
char const * value =
response_callback /* response */,
GError *& error)
{
- smart_ptr<GVariant> const ret(
+ unique_ptr<GVariant> const ret(
connman_.set_property(name, value, error));
return ret.get() != nullptr;
{
constexpr gint const timeout = 5000; // milliseconds
- smart_ptr<GVariant> const dictionary(
+ unique_ptr<GVariant> const dictionary(
g_dbus_proxy_call_sync(connman_.proxy(),
"GetProperties",
nullptr, // No parameters
nullptr, // Not cancellable
&error));
- smart_ptr<GVariant> value;
+ unique_ptr<GVariant> value;
if (dictionary != nullptr) {
GVariantIter * i = nullptr;
g_variant_get(dictionary.get(), "(a{sv})", &i);
- smart_ptr<GVariantIter> const iter(i);
+ unique_ptr<GVariantIter> const iter(i);
gchar * pname = nullptr;
GVariant * pvalue = nullptr;
while (g_variant_iter_next(i, "{sv}", &pname, &pvalue)) {
- smart_ptr<gchar> const name(pname);
+ unique_ptr<gchar> const name(pname);
value.reset(pvalue);
// Check if this is the property we want.
#include "connman.hpp"
#include <settingsd/glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <settingsd/dbus_signal_callback.hpp>
#include <cstring>
nullptr, // GCancellable
&error);
- smart_ptr<GError> safe_error(error);
+ unique_ptr<GError> safe_error(error);
if (proxy_ == nullptr) {
g_printerr("Unable to create D-Bus proxy for (\"%s\", \"%s\"): %s\n",
#include <settingsd/dbus_signal_callback.hpp>
#include <settingsd/glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <cstring>
{
constexpr gint const timeout = 5000; // milliseconds
- smart_ptr<GVariant> const dictionary(
+ unique_ptr<GVariant> const dictionary(
g_dbus_proxy_call_sync(connman_.proxy(),
"GetTechnologies",
nullptr, // No parameters
if (dictionary != nullptr) {
GVariantIter * i = nullptr;
g_variant_get(dictionary.get(), "(a(oa{sv}))", &i);
- smart_ptr<GVariantIter> const safe_i(i);
+ unique_ptr<GVariantIter> const safe_i(i);
- for (smart_ptr<GVariant> child(g_variant_iter_next_value(i));
+ for (unique_ptr<GVariant> child(g_variant_iter_next_value(i));
child != nullptr;
child.reset(g_variant_iter_next_value(i))) {
// The object path is the first tuple element.
- smart_ptr<GVariant> const tmp(
+ unique_ptr<GVariant> const tmp(
g_variant_get_child_value(child.get(), 0));
char const * object =
#include "service.hpp"
#include <settingsd/glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <settingsd/response_callback.hpp>
#include <chrono>
constexpr gint const timeout = 10000; // milliseconds
GError * error = nullptr;
- smart_ptr<GVariant> const ret(
+ unique_ptr<GVariant> const ret(
g_dbus_proxy_call_sync(connman_.proxy(),
name, // "Connect", "Disconect", ...
nullptr, // No parameters
nullptr, // Not cancellable
&error));
- smart_ptr<GError> safe_error;
+ unique_ptr<GError> safe_error;
if (ret != nullptr) {
// Nothing to add to successful response.
#include <settingsd/response_callback.hpp>
#include <settingsd/glib_traits.hpp>
#include <settingsd/json_glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <cstring>
#include <chrono>
ivi::settings::technology::handle_request(std::string request,
response_callback response)
{
- smart_ptr<JsonParser> const parser(json_parser_new());
+ unique_ptr<JsonParser> const parser(json_parser_new());
json_parser_load_from_data(parser.get(), request.c_str(), -1, nullptr);
- smart_ptr<JsonReader> const safe_reader(
+ unique_ptr<JsonReader> const safe_reader(
json_reader_new(json_parser_get_root(parser.get())));
JsonReader * const reader = safe_reader.get();
return;
}
- smart_ptr<GVariant> const property(
+ unique_ptr<GVariant> const property(
get_property("Powered", G_VARIANT_TYPE_BOOLEAN, response));
if (property != nullptr) {
GError * error = nullptr;
- smart_ptr<GVariant> ret(
+ unique_ptr<GVariant> ret(
connman_.set_property(name,
g_variant_new_boolean(enable),
error));
- smart_ptr<GError> safe_error(error);
+ unique_ptr<GError> safe_error(error);
if (ret != nullptr) {
// Nothing to add to successful response.
constexpr gint const timeout = 10000; // milliseconds
GError * error = nullptr;
- smart_ptr<GVariant> const ret(
+ unique_ptr<GVariant> const ret(
g_dbus_proxy_call_sync(connman_.proxy(),
"Scan",
nullptr, // No parameters
nullptr, // Not cancellable
&error));
- smart_ptr<GError> safe_error(error);
+ unique_ptr<GError> safe_error(error);
if (ret != nullptr) {
send_services(response, error);
ivi::settings::technology::send_services(response_callback response,
GError *& error)
{
- smart_ptr<GVariant> const services(manager_.get_services(error));
+ unique_ptr<GVariant> const services(manager_.get_services(error));
if (services != nullptr) {
response.send_response(
{
GError * error = nullptr;
- smart_ptr<GVariant> const properties(
+ unique_ptr<GVariant> const properties(
manager_.get_properties(technology_, error));
- smart_ptr<GError> safe_error(error);
+ unique_ptr<GError> safe_error(error);
- smart_ptr<GVariant> property;
+ unique_ptr<GVariant> property;
if (properties != nullptr) {
property.reset(
g_variant_lookup_value(properties.get(), name, type));
#include "websocket_server.hpp"
#include <settingsd/glib_traits.hpp>
-#include <settingsd/smart_ptr.hpp>
+#include <settingsd/unique_ptr.hpp>
#include <glib.h>
#include <iostream>
// Glib related events, including GDbus related signal handlers,
// will handled in this (main) thread.
- settings::smart_ptr<GMainLoop> const loop(g_main_loop_new(nullptr, false));
+ settings::unique_ptr<GMainLoop> const loop(g_main_loop_new(nullptr, false));
g_main_loop_run(loop.get());
}
catch (std::exception & e) {