2 * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "launchpad-glib/app_info.hh"
19 #include <bundle_internal.h>
23 #include <aul_keys.hh>
27 AppInfo::Builder& AppInfo::Builder::SetAppId(const tizen_base::Bundle& b) {
28 app_id_ = b.GetString(kAulAppId);
32 AppInfo::Builder& AppInfo::Builder::SetAppPath(const tizen_base::Bundle& b) {
33 app_path_ = b.GetString(kAulExec);
37 AppInfo::Builder& AppInfo::Builder::SetOriginalAppPath(
38 const tizen_base::Bundle& b) {
39 original_app_path_ = b.GetString(kAulExec);
43 AppInfo::Builder& AppInfo::Builder::SetPkgType(const tizen_base::Bundle& b) {
44 pkg_type_ = b.GetString(kAulPackageType);
48 AppInfo::Builder& AppInfo::Builder::SetAppType(const tizen_base::Bundle& b) {
49 app_type_ = b.GetString(kAulAppType);
53 AppInfo::Builder& AppInfo::Builder::SetHwacc(const tizen_base::Bundle& b) {
54 hwacc_ = b.GetString(kAulHwAcc);
58 AppInfo::Builder& AppInfo::Builder::SetTaskmanage(const tizen_base::Bundle& b) {
59 taskmanage_ = b.GetString(kAulTaskManage);
63 AppInfo::Builder& AppInfo::Builder::SetPkgId(const tizen_base::Bundle& b) {
64 pkg_id_ = b.GetString(kAulPkgId);
68 AppInfo::Builder& AppInfo::Builder::SetCompType(const tizen_base::Bundle& b) {
69 comp_type_ = b.GetString(kAulCompType);
73 AppInfo::Builder& AppInfo::Builder::SetInternalPool(
74 const tizen_base::Bundle& b) {
75 internal_pool_ = b.GetString(kAulInternalPool);
79 AppInfo::Builder& AppInfo::Builder::SetRootPath(const tizen_base::Bundle& b) {
80 root_path_ = b.GetString(kAulRootPath);
84 AppInfo::Builder& AppInfo::Builder::SetLoaderName(const tizen_base::Bundle& b) {
85 loader_name_ = b.GetString(kAulLoaderName);
89 AppInfo::Builder& AppInfo::Builder::SetGlobal(const tizen_base::Bundle& b) {
90 if (b.GetString(kAulIsGlobal) == "true")
98 AppInfo::Builder& AppInfo::Builder::SetBundle(tizen_base::Bundle b) {
103 AppInfo::Builder::operator AppInfo*() {
104 return new (std::nothrow) AppInfo(std::move(app_id_), std::move(app_path_),
105 std::move(original_app_path_), std::move(pkg_type_), std::move(app_type_),
106 std::move(hwacc_), std::move(taskmanage_), std::move(pkg_id_),
107 std::move(comp_type_), std::move(internal_pool_), std::move(root_path_),
108 std::move(loader_name_), global_, std::move(b_));
111 AppInfo* AppInfo::Create(tizen_base::Bundle b) {
112 return Builder().SetAppId(b)
114 .SetOriginalAppPath(b)
125 .SetBundle(std::move(b));
128 const std::string& AppInfo::GetAppId() const {
132 const std::string& AppInfo::GetAppPath() const {
136 const std::string& AppInfo::GetOriginalAppPath() const {
137 return original_app_path_;
140 const std::string& AppInfo::GetPkgType() const {
144 const std::string& AppInfo::GetAppType() const {
148 const std::string& AppInfo::GetHwacc() const {
152 const std::string& AppInfo::GetTaskmanage() const {
156 const std::string& AppInfo::GetPkgId() const {
160 const std::string& AppInfo::GetCompType() const {
164 const std::string& AppInfo::GetInternalPool() const {
165 return internal_pool_;
168 const std::string& AppInfo::GetRootPath() const {
172 const std::string& AppInfo::GetLoaderName() const {
176 const bool AppInfo::IsGlobal() const {
180 const tizen_base::Bundle& AppInfo::GetBundle() const {
184 void AppInfo::WriteToParcel(tizen_base::Parcel* parcel) const {
185 parcel->WriteString(app_id_);
186 parcel->WriteString(app_path_);
187 parcel->WriteString(original_app_path_);
188 parcel->WriteString(pkg_type_);
189 parcel->WriteString(app_type_);
190 parcel->WriteString(hwacc_);
191 parcel->WriteString(taskmanage_);
192 parcel->WriteString(pkg_id_);
193 parcel->WriteString(comp_type_);
194 parcel->WriteString(internal_pool_);
195 parcel->WriteString(root_path_);
196 parcel->WriteString(loader_name_);
197 parcel->WriteBool(global_);
199 bundle_raw* b_raw = nullptr;
201 bundle_encode(b_.GetHandle(), &b_raw, &len);
202 std::string raw(b_raw != nullptr ? reinterpret_cast<const char*>(b_raw) : "");
203 bundle_free_encoded_rawdata(&b_raw);
204 parcel->WriteString(raw);
207 void AppInfo::ReadFromParcel(tizen_base::Parcel* parcel) {
208 app_id_ = parcel->ReadString();
209 app_path_ = parcel->ReadString();
210 original_app_path_ = parcel->ReadString();
211 pkg_type_ = parcel->ReadString();
212 app_type_ = parcel->ReadString();
213 hwacc_ = parcel->ReadString();
214 taskmanage_ = parcel->ReadString();
215 pkg_id_ = parcel->ReadString();
216 comp_type_ = parcel->ReadString();
217 internal_pool_ = parcel->ReadString();
218 root_path_ = parcel->ReadString();
219 loader_name_ = parcel->ReadString();
220 parcel->ReadBool(&global_);
222 auto raw = parcel->ReadString();
224 b_ = tizen_base::Bundle(raw);
227 AppInfo::AppInfo(std::string app_id, std::string app_path,
228 std::string original_app_path, std::string pkg_type, std::string app_type,
229 std::string hwacc, std::string taskmanage, std::string pkg_id,
230 std::string comp_type, std::string internal_pool, std::string root_path,
231 std::string loader_name, bool global, tizen_base::Bundle b)
232 : app_id_(std::move(app_id)),
233 app_path_(std::move(app_path)),
234 original_app_path_(std::move(original_app_path)),
235 pkg_type_(std::move(pkg_type)),
236 app_type_(std::move(app_type)),
237 hwacc_(std::move(hwacc)),
238 taskmanage_(std::move(taskmanage)),
239 pkg_id_(std::move(pkg_id)),
240 comp_type_(std::move(comp_type)),
241 internal_pool_(std::move(internal_pool)),
242 root_path_(std::move(root_path)),
243 loader_name_(std::move(loader_name)),
247 } // namespace launchpad