Add uid attribute of ThemeInfo
[platform/core/appfw/tizen-theme-manager.git] / src / theme / loader / theme_info.cc
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "theme/loader/theme_info.h"
18
19 #include <string>
20
21 namespace ttm {
22 namespace loader {
23
24 ThemeInfo::ThemeInfo(const tizen_base::Bundle& bundle) {
25   bundle_ = tizen_base::Bundle(bundle);
26 }
27
28 std::string ThemeInfo::GetId() const {
29   return bundle_.GetString("id");
30 }
31
32 std::string ThemeInfo::GetPkgid() const {
33   return bundle_.GetString("pkgid");
34 }
35
36 uid_t ThemeInfo::GetUid() const {
37   std::string uid_str = bundle_.GetString("uid");
38   return std::stoi(uid_str);
39 }
40
41 std::string ThemeInfo::GetVersion() const {
42   return bundle_.GetString("version");
43 }
44
45 std::string ThemeInfo::GetToolVersion() const {
46   return bundle_.GetString("tool_version");
47 }
48
49 std::string ThemeInfo::GetTitle() const {
50   return bundle_.GetString("title");
51 }
52
53 std::string ThemeInfo::GetResolution() const {
54   return bundle_.GetString("resolution");
55 }
56
57 std::string ThemeInfo::GetPreview() const {
58   return bundle_.GetString("preview");
59 }
60
61 std::string ThemeInfo::GetDescription() const {
62   return bundle_.GetString("description");
63 }
64
65 std::string ThemeInfo::GetString(const std::string& key) const {
66   return bundle_.GetString(key);
67 }
68
69 std::vector<std::string> ThemeInfo::GetStringArray(
70     const std::string& key) const {
71   std::vector<std::string> v = bundle_.GetStringArray(key);
72   return v;
73 }
74
75 int ThemeInfo::GetInt(const std::string& key) const {
76   int val = std::stoi(bundle_.GetString(key));
77   return val;
78 }
79
80 float ThemeInfo::GetFloat(const std::string& key) const {
81   float val = std::stof(bundle_.GetString(key));
82   return val;
83 }
84
85 bool ThemeInfo::GetBool(const std::string& key) const {
86   if (bundle_.GetString(key).compare("true") == 0)
87     return true;
88   else
89     return false;
90 }
91
92 tizen_base::Bundle ThemeInfo::Serialize() const {
93   return bundle_;
94 }
95
96 }  // namespace loader
97 }  // namespace ttm