Add 2017 to copyright
[staging/HomeScreen.git] / interfaces / src / appframework.cpp
1 /*
2  * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
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 "include/appframework.hpp"
18
19 #include <QtCore/QJsonObject>
20
21 class AppInfo::Private : public QSharedData
22 {
23 public:
24     Private();
25     Private(const Private &other);
26
27     QString id;
28     QString version;
29     int width;
30     int height;
31     QString name;
32     QString description;
33     QString shortname;
34     QString author;
35     QString iconPath;
36 };
37
38 AppInfo::Private::Private()
39     : width(-1)
40     , height(-1)
41 {
42 }
43
44 AppInfo::Private::Private(const Private &other)
45     : QSharedData(other)
46     , id(other.id)
47     , version(other.version)
48     , width(other.width)
49     , height(other.height)
50     , name(other.name)
51     , description(other.description)
52     , shortname(other.shortname)
53     , author(other.author)
54     , iconPath(other.iconPath)
55 {
56 }
57
58 AppInfo::AppInfo()
59     : d(new Private)
60 {
61 }
62
63 AppInfo::AppInfo(const AppInfo &other)
64     : d(other.d)
65 {
66 }
67
68 AppInfo::~AppInfo()
69 {
70 }
71
72 AppInfo &AppInfo::operator =(const AppInfo &other)
73 {
74     d = other.d;
75     return *this;
76 }
77
78 QString AppInfo::id() const
79 {
80     return d->id;
81 }
82
83 QString AppInfo::version() const
84 {
85     return d->version;
86 }
87
88 int AppInfo::width() const
89 {
90     return d->width;
91 }
92
93 int AppInfo::height() const
94 {
95     return d->height;
96 }
97
98 QString AppInfo::name() const
99 {
100     return d->name;
101 }
102
103 QString AppInfo::description() const
104 {
105     return d->description;
106 }
107
108 QString AppInfo::shortname() const
109 {
110     return d->shortname;
111 }
112
113 QString AppInfo::author() const
114 {
115     return d->author;
116 }
117
118 QString AppInfo::iconPath() const
119 {
120     return d->iconPath;
121 }
122
123 void AppInfo::read(const QJsonObject &json)
124 {
125     d->id = json["id"].toString();
126     d->version = json["version"].toString();
127     d->width = json["width"].toInt();
128     d->height = json["height"].toInt();
129     d->name = json["name"].toString();
130     d->description = json["description"].toString();
131     d->shortname = json["shortname"].toString();
132     d->author = json["author"].toString();
133     d->iconPath = json["iconPath"].toString();
134 }
135
136 QDBusArgument &operator <<(QDBusArgument &argument, const AppInfo &appInfo)
137 {
138     argument.beginStructure();
139     argument << appInfo.d->id;
140     argument << appInfo.d->version;
141     argument << appInfo.d->width;
142     argument << appInfo.d->height;
143     argument << appInfo.d->name;
144     argument << appInfo.d->description;
145     argument << appInfo.d->shortname;
146     argument << appInfo.d->author;
147     argument << appInfo.d->iconPath;
148     argument.endStructure();
149
150     return argument;
151 }
152
153 const QDBusArgument &operator >>(const QDBusArgument &argument, AppInfo &appInfo)
154 {
155     argument.beginStructure();
156     argument >> appInfo.d->id;
157     argument >> appInfo.d->version;
158     argument >> appInfo.d->width;
159     argument >> appInfo.d->height;
160     argument >> appInfo.d->name;
161     argument >> appInfo.d->description;
162     argument >> appInfo.d->shortname;
163     argument >> appInfo.d->author;
164     argument >> appInfo.d->iconPath;
165     argument.endStructure();
166     return argument;
167 }