manifest->res_version = strdup(pkg_info->res_version().c_str());
manifest->light_user_switch_mode = strdup("default");
+ for (auto& pair : pkg_info->labels()) {
+ label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
+ if (!label) {
+ LOG(ERROR) << "Out of memory";
+ return false;
+ }
+ if (!pair.first.empty())
+ label->lang = strdup(pair.first.c_str());
+ else
+ label->lang = strdup(DEFAULT_LOCALE);
+ label->text = strdup(pair.second.c_str());
+ manifest->label = g_list_append(manifest->label, label);
+ }
+
+ // icon_x has much more information than this. This is temporary implementaion
+ for (auto& pair : pkg_info->icons()) {
+ icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
+ if (!icon) {
+ LOG(ERROR) << "Out of memory";
+ return false;
+ }
+ if (!pair.first.empty())
+ icon->lang = strdup(pair.first.c_str());
+ else
+ icon->lang = strdup(DEFAULT_LOCALE);
+ icon->text = strdup(pair.second.c_str());
+ manifest->icon = g_list_append(manifest->icon, icon);
+ }
+
return true;
}
constexpr const char kResourceVersion[] = "@res-version";
constexpr const char kApiVersion[] = "@api-version";
constexpr const char kManifestKey[] = "manifest";
+constexpr const char kLabelKey[] = "label";
+constexpr const char kLabelLangKey[] = "@lang";
+constexpr const char kLabelTextKey[] = "#text";
+const char kIconKey[] = "icon";
+const char kIconLangKey[] = "@lang";
+const char kIconTextKey[] = "#text";
const std::set<std::string> kPackageTypeAllowedValues =
{"rpk"};
pkg_info->set_res_version(res_version);
pkg_info->set_api_version(api_version);
+ for (auto label_dict : parser::GetOneOrMany(&manifest_dict, kLabelKey, "")) {
+ std::string lang;
+ std::string text;
+ label_dict->GetString(kLabelLangKey, &lang);
+ label_dict->GetString(kLabelTextKey, &text);
+ pkg_info->AddLabel(lang, text);
+ }
+
+ for (auto icon_dict : parser::GetOneOrMany(&manifest_dict, kIconKey, "")) {
+ std::string lang;
+ std::string text;
+ icon_dict->GetString(kIconLangKey, &lang);
+ icon_dict->GetString(kIconTextKey, &text);
+ pkg_info->AddIcon(lang, text);
+ }
+
return true;
}
namespace rpk {
namespace parse {
+using LangTextPair = std::pair<std::string, std::string>;
+
class PackageInfo : public parser::ManifestData {
public:
/**
api_version_ = std::move(api_version);
}
+ void AddLabel(const std::string& lang, const std::string& text) {
+ labels_.emplace_back(lang, text);
+ }
+
+ void AddIcon(const std::string& lang, const std::string& text) {
+ icons_.emplace_back(lang, text);
+ }
+
/**
* @brief xmlns
* @return xmlns string
return api_version_;
}
+ const std::vector<LangTextPair>& labels() const {
+ return labels_;
+ }
+
+ const std::vector<LangTextPair>& icons() const {
+ return icons_;
+ }
+
private:
std::string xmlns_;
std::string package_;
std::string res_type_;
std::string res_version_;
std::string api_version_;
+
+ std::vector<LangTextPair> labels_;
+ std::vector<LangTextPair> icons_;
};
/**