1 // Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache 2.0 license that can be
3 // found in the LICENSE file.
5 #include "theme_plugin/theme_parser.h"
14 #include "theme/dbus/request_broker.h"
15 #include "theme/loader/theme_info.h"
16 #include "theme/utils/logging.h"
17 #include "theme_plugin/theme_info_builder.h"
22 loader::ThemeInfo ThemeParser::Inflate(const std::string id,
23 const std::string pkgid, uid_t uid) {
24 Json::CharReaderBuilder rbuilder;
25 rbuilder["collectComments"] = false;
27 std::ifstream ifs(path_);
30 if (!Json::parseFromStream(rbuilder, ifs, &root, &error)) {
31 LOG(ERROR) << "Failed to read json file: " << error;
36 // FIXME: this parser should parse more theme information.
37 ThemeInfoBuilder builder("testid");
38 builder.PutString("pkgid", pkgid).
39 PutString("uid", std::to_string(uid)).
40 PutString("version", root["version"].asString()).
41 PutString("tool_version", root["tool_version"].asString()).
42 PutString("title", root["header"]["title"].asString()).
43 PutString("description", root["header"]["description"].asString());
45 return builder.Build();
48 using ttm::dbus::Command;
49 using ttm::dbus::RequestBroker;
50 int ThemeParser::Commit(ThemeOperation operation,
51 const loader::ThemeInfo& theme) {
52 tizen_base::Bundle theme_info = theme.Serialize();
53 tizen_base::Bundle reply;
55 case ThemeOperation::ADD:
56 LOG(DEBUG) << "Add Theme: " << theme.GetId();
57 reply = RequestBroker::GetInst().SendData(Command::ADD, theme_info);
59 case ThemeOperation::UPDATE:
60 LOG(DEBUG) << "Update Theme: " << theme.GetId();
61 reply = RequestBroker::GetInst().SendData(Command::UPDATE, theme_info);
63 case ThemeOperation::REMOVE:
64 LOG(DEBUG) << "Remove Theme: " << theme.GetId();
65 reply = RequestBroker::GetInst().SendData(Command::REMOVE, theme_info);