2 * @file event_callback.cpp
4 * @brief Settings plugin event_callback implementation.
6 * @author Ossama Othman @<ossama.othman@@intel.com@>
9 * Copyright 2013 Intel Corporation All Rights Reserved.
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation;
14 * version 2.1 of the License.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301 USA
27 #include <settingsd/event_callback.hpp>
28 #include <settingsd/json_glib_traits.hpp>
29 #include <settingsd/unique_ptr.hpp>
30 #include "manager.hpp"
33 ivi::settings::event_callback::event_callback(manager & mgr)
39 ivi::settings::event_callback::send_event(
40 std::function<void(JsonBuilder *)> event_builder) const
42 unique_ptr<JsonBuilder> const builder = begin_event();
44 // Append settings type-specific JSON formatted events.
45 event_builder(builder.get());
49 return manager_.send_event(builder);
52 ivi::settings::unique_ptr<JsonBuilder>
53 ivi::settings::event_callback::begin_event() const
55 // Construct JSON event string.
56 unique_ptr<JsonBuilder> safe_builder(json_builder_new());
57 JsonBuilder * const builder = safe_builder.get();
59 json_builder_begin_object(builder);
61 json_builder_set_member_name(builder, "type");
62 json_builder_add_string_value(builder, "event");
68 ivi::settings::event_callback::end_event(
69 ivi::settings::unique_ptr<JsonBuilder> const & builder) const
71 json_builder_end_object(builder.get());
79 // indent-tabs-mode: nil