24 #include <kconfiggroup.h>
25 #include <kdesktopfile.h>
30 class PackageMetadataPrivate
33 PackageMetadataPrivate()
49 QString requiredVersion;
55 QStringList requiredDataEngines;
59 : d(new PackageMetadataPrivate(*other.d))
70 : d(new PackageMetadataPrivate)
82 return ! (d->name.isEmpty() ||
83 d->author.isEmpty() ||
84 d->license.isEmpty() ||
90 KDesktopFile cfg(filename);
91 KConfigGroup config = cfg.desktopGroup();
92 config.writeEntry(
"Encoding",
"UTF-8");
94 config.writeEntry(
"Name", d->name);
95 config.writeEntry(
"Icon", d->icon);
96 config.writeEntry(
"Comment", d->description);
97 config.writeEntry(
"Keywords", d->keywords);
98 config.deleteEntry(
"X-KDE-Keywords");
99 config.writeEntry(
"X-KDE-ServiceTypes", d->serviceType);
100 config.deleteEntry(
"ServiceTypes");
101 config.writeEntry(
"X-KDE-PluginInfo-Name", d->pluginName);
102 config.writeEntry(
"X-KDE-PluginInfo-Author", d->author);
103 config.writeEntry(
"X-KDE-PluginInfo-Email", d->email);
104 config.writeEntry(
"X-KDE-PluginInfo-Version", d->version);
105 config.writeEntry(
"X-KDE-PluginInfo-Website", d->website);
106 config.writeEntry(
"X-KDE-PluginInfo-License", d->license);
107 config.writeEntry(
"X-KDE-PluginInfo-Category", d->category);
108 config.writeEntry(
"X-Plasma-API", d->api);
109 config.writeEntry(
"X-KDE-ParentApp", d->app);
110 config.writeEntry(
"Type", d->type);
111 config.writeEntry(
"X-Plasma-RemoteLocation", d->location);
112 config.writeEntry(
"X-Plasma-RequiredDataEngines", d->requiredDataEngines);
117 if (filename.isEmpty()) {
121 KDesktopFile cfg(filename);
122 KConfigGroup config = cfg.desktopGroup();
124 d->name = config.readEntry(
"Name", d->name);
125 d->icon = config.readEntry(
"Icon", d->icon);
126 d->description = config.readEntry(
"Comment", d->description);
127 bool hasKeywords = config.hasKey(
"Keywords");
128 bool hasXKdeKeywords = config.hasKey(
"X-KDE-Keywords");
129 if (hasKeywords && hasXKdeKeywords) {
130 d->keywords = config.readEntry(
"Keywords", d->keywords);
131 d->keywords.append(config.readEntry(
"X-KDE-Keywords", d->keywords));
132 }
else if (hasKeywords) {
133 d->keywords = config.readEntry(
"Keywords", d->keywords);
134 }
else if (hasXKdeKeywords) {
135 d->keywords = config.readEntry(
"X-KDE-Keywords", d->keywords);
137 bool hasServiceTypes = config.hasKey(
"ServiceTypes");
138 bool hasXKdeServiceTypes = config.hasKey(
"X-KDE-ServiceTypes");
139 if (hasServiceTypes && hasXKdeServiceTypes) {
140 d->serviceType = config.readEntry(
"ServiceTypes", d->serviceType);
141 d->serviceType.append(
',');
142 d->serviceType.append(config.readEntry(
"X-KDE-ServiceTypes", d->serviceType));
143 }
else if (hasServiceTypes) {
144 d->serviceType = config.readEntry(
"ServiceTypes", d->serviceType);
145 }
else if (hasXKdeServiceTypes) {
146 d->serviceType = config.readEntry(
"X-KDE-ServiceTypes", d->serviceType);
148 d->pluginName = config.readEntry(
"X-KDE-PluginInfo-Name", d->pluginName);
149 d->author = config.readEntry(
"X-KDE-PluginInfo-Author", d->author);
150 d->email = config.readEntry(
"X-KDE-PluginInfo-Email", d->email);
151 d->version = config.readEntry(
"X-KDE-PluginInfo-Version", d->version);
152 d->website = config.readEntry(
"X-KDE-PluginInfo-Website", d->website);
153 d->license = config.readEntry(
"X-KDE-PluginInfo-License", d->license);
154 d->category = config.readEntry(
"X-KDE-PluginInfo-Category", d->category);
155 d->api = config.readEntry(
"X-Plasma-API", d->api);
156 d->app = config.readEntry(
"X-KDE-ParentApp", d->app);
157 d->type = config.readEntry(
"Type", d->type);
158 d->location = config.readEntry(
"X-Plasma-RemoteLocation", d->location);
159 d->requiredDataEngines = config.readEntry(
"X-Plasma-RequiredDataEngines", d->requiredDataEngines);
169 return d->description;
174 return d->serviceType;
234 return d->requiredVersion;
254 return d->requiredDataEngines;
264 return d->pluginName;
329 d->location = location;