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/loader/theme_info.h"
15 #include "theme/utils/logging.h"
16 #include "theme_plugin/theme_info_builder.h"
21 loader::ThemeInfo ThemeParser::Inflate(const std::string id,
22 const std::string pkgid, uid_t uid) {
23 Json::CharReaderBuilder rbuilder;
24 rbuilder["collectComments"] = false;
26 std::ifstream ifs(path_);
29 if (!Json::parseFromStream(rbuilder, ifs, &root, &error)) {
30 LOG(ERROR) << "Failed to read json file: " << error;
35 // FIXME: this parser should parse more theme information.
36 ThemeInfoBuilder builder("testid");
37 builder.PutString("pkgid", pkgid).
38 PutString("uid", std::to_string(uid)).
39 PutString("version", root["version"].asString()).
40 PutString("tool_version", root["tool_version"].asString()).
41 PutString("title", root["header"]["title"].asString()).
42 PutString("description", root["header"]["description"].asString());
44 return builder.Build();
47 int ThemeParser::Commit(ThemeOperation operation,
48 const loader::ThemeInfo& theme) {
50 case ThemeOperation::ADD:
51 LOG(DEBUG) << "Add Theme: " << theme.GetId();
52 // send dbus request at here
54 case ThemeOperation::UPDATE:
55 LOG(DEBUG) << "Update Theme: " << theme.GetId();
56 // send dbus request at here
58 case ThemeOperation::REMOVE:
59 LOG(DEBUG) << "Remove Theme: " << theme.GetId();
60 // send dbus request at here