2 * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
3 * Copyright (C) 2016 The Qt Company Ltd.
4 * Copyright (c) 2018 TOYOTA MOTOR CORPORATION
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #include "hmi-debug.h"
22 class AppInfo::Private : public QSharedData {
25 Private(const Private& other);
49 AppInfo::Private::Private() : width(-1), height(-1) {}
51 AppInfo::Private::Private(const Private& other)
54 version(other.version),
58 description(other.description),
59 shortname(other.shortname),
61 iconPath(other.iconPath),
63 progress(other.progress),
64 serverid(other.serverid),
65 wgtpath(other.wgtpath),
66 filename(other.filename),
67 categoryid(other.categoryid),
68 categoryname(other.categoryname),
69 deviceid(other.deviceid),
70 devicename(other.devicename),
71 createdtime(other.createdtime) {}
73 AppInfo::AppInfo() : d(new Private) {}
75 AppInfo::AppInfo(const QString& icon, const QString& name, const QString& id)
82 AppInfo::AppInfo(const AppInfo& other) : d(other.d) {}
84 AppInfo::~AppInfo() {}
86 AppInfo& AppInfo::operator=(const AppInfo& other) {
91 QString AppInfo::id() const {
95 QString AppInfo::version() const {
99 int AppInfo::width() const {
103 int AppInfo::height() const {
107 QString AppInfo::name() const {
111 QString AppInfo::description() const {
112 return d->description;
115 QString AppInfo::shortname() const {
119 QString AppInfo::author() const {
123 QString AppInfo::iconPath() const {
127 AppInfo::AppState AppInfo::state() const {
131 qreal AppInfo::progress() const {
135 QString AppInfo::serverId() const {
138 QString AppInfo::wgtPath() const {
141 QString AppInfo::fileName() const {
145 QString AppInfo::categoryId() const {
146 return d->categoryid;
148 QString AppInfo::categoryName() const {
149 return d->categoryname;
151 QString AppInfo::deviceId() const {
154 QString AppInfo::deviceName() const {
155 return d->devicename;
157 double AppInfo::createdTime() const {
158 return d->createdtime;
161 void AppInfo::setState(const AppState state) {
165 void AppInfo::setProgress(const qreal progress) {
166 d->progress = progress;
169 void AppInfo::read(const QJsonObject& json) {
170 d->id = json["id"].toString();
171 d->version = json["version"].toString();
172 d->width = json["width"].toInt();
173 d->height = json["height"].toInt();
174 d->name = json["name"].toString();
175 d->description = json["description"].toString();
176 d->shortname = json["shortname"].toString();
177 d->author = json["author"].toString();
178 d->iconPath = json["icon"].toString();
182 void AppInfo::readFromServer(const QJsonObject& json) {
183 d->name = json["appName"].toString();
184 d->description = json["appAbstract"].toString();
185 d->version = json["versionName"].toString();
186 d->id = json["appIdCustom"].toString() + "@" + d->version;
187 d->serverid = json["appId"].toString();
188 d->wgtpath = json["verFilePath"].toString();
189 d->filename = json["verFilePath"].toString().section('/', -1);
190 d->author = json["developerName"].toString();
191 d->categoryid = json["typeId"].toString();
192 d->categoryname = json["typeName"].toString();
193 d->deviceid = json["appDeviceTypeId"].toString();
194 d->devicename = json["appDeviceTypeName"].toString();
195 d->createdtime = json["updateDate"].toDouble();
196 // d->iconPath = json["icon"].toString();
197 d->iconPath = "file:///var/local/lib/afm/applications/launcher/0.1/icon.svg";