comparison rdf/PluginRDFDescription.cpp @ 1845:6f626cfdba51

Pull out Provider struct
author Chris Cannam
date Mon, 20 Apr 2020 18:45:47 +0100
parents 5b1b03c1d8d4
children 9762a7f084a0
comparison
equal deleted inserted replaced
1844:5b1b03c1d8d4 1845:6f626cfdba51
78 PluginRDFDescription::getPluginMaker() const 78 PluginRDFDescription::getPluginMaker() const
79 { 79 {
80 return m_pluginMaker; 80 return m_pluginMaker;
81 } 81 }
82 82
83 QString 83 Provider
84 PluginRDFDescription::getPluginInfoURL() const 84 PluginRDFDescription::getPluginProvider() const
85 { 85 {
86 return m_pluginInfoURL; 86 return m_provider;
87 }
88
89 QString
90 PluginRDFDescription::getPluginDownloadURL() const
91 {
92 return m_pluginDownloadURL;
93 }
94
95 std::set<PluginRDFDescription::DownloadType>
96 PluginRDFDescription::getPluginDownloadTypes() const
97 {
98 return m_pluginDownloadTypes;
99 }
100
101 std::map<QString, PluginRDFDescription::Pack>
102 PluginRDFDescription::getPluginFoundInPacks() const
103 {
104 return m_pluginFoundInPacks;
105 } 87 }
106 88
107 QStringList 89 QStringList
108 PluginRDFDescription::getOutputIds() const 90 PluginRDFDescription::getOutputIds() const
109 { 91 {
232 214
233 n = index->complete 215 n = index->complete
234 (Triple(plugin, index->expand("foaf:page"), Node())); 216 (Triple(plugin, index->expand("foaf:page"), Node()));
235 217
236 if (n.type == Node::URI && n.value != "") { 218 if (n.type == Node::URI && n.value != "") {
237 m_pluginInfoURL = n.value; 219 m_provider.infoUrl = n.value;
238 } 220 }
239 221
240 // There may be more than one library node claiming this 222 // There may be more than one library node claiming this
241 // plugin. That's because older RDF descriptions tend to use a 223 // plugin. That's because older RDF descriptions tend to use a
242 // library node URI derived from the description's own URI, so it 224 // library node URI derived from the description's own URI, so it
259 241
260 n = index->complete 242 n = index->complete
261 (Triple(libn, index->expand("foaf:page"), Node())); 243 (Triple(libn, index->expand("foaf:page"), Node()));
262 244
263 if (n.type == Node::URI && n.value != "") { 245 if (n.type == Node::URI && n.value != "") {
264 m_pluginInfoURL = n.value; 246 m_provider.infoUrl = n.value;
265 } 247 }
266 248
267 n = index->complete 249 n = index->complete
268 (Triple(libn, index->expand("doap:download-page"), Node())); 250 (Triple(libn, index->expand("doap:download-page"), Node()));
269 251
270 if (n.type == Node::URI && n.value != "") { 252 if (n.type == Node::URI && n.value != "") {
271 m_pluginDownloadURL = n.value; 253 m_provider.downloadUrl = n.value;
272 254
273 n = index->complete 255 n = index->complete
274 (Triple(libn, index->expand("vamp:has_source"), Node())); 256 (Triple(libn, index->expand("vamp:has_source"), Node()));
275 if (n.type == Node::Literal && n.value == "true") { 257 if (n.type == Node::Literal && n.value == "true") {
276 m_pluginDownloadTypes.insert(DownloadSourceCode); 258 m_provider.downloadTypes.insert(Provider::DownloadSourceCode);
277 } 259 }
278 260
279 Nodes binaries = index->match 261 Nodes binaries = index->match
280 (Triple(libn, index->expand("vamp:has_binary"), Node())) 262 (Triple(libn, index->expand("vamp:has_binary"), Node()))
281 .objects(); 263 .objects();
282 264
283 for (Node bin: binaries) { 265 for (Node bin: binaries) {
284 if (bin.type != Node::Literal) continue; 266 if (bin.type != Node::Literal) continue;
285 if (bin.value == "linux32") { 267 if (bin.value == "linux32") {
286 m_pluginDownloadTypes.insert(DownloadLinux32); 268 m_provider.downloadTypes.insert(Provider::DownloadLinux32);
287 } else if (bin.value == "linux64") { 269 } else if (bin.value == "linux64") {
288 m_pluginDownloadTypes.insert(DownloadLinux64); 270 m_provider.downloadTypes.insert(Provider::DownloadLinux64);
289 } else if (bin.value == "win32") { 271 } else if (bin.value == "win32") {
290 m_pluginDownloadTypes.insert(DownloadWindows); 272 m_provider.downloadTypes.insert(Provider::DownloadWindows);
291 } else if (bin.value == "osx") { 273 } else if (bin.value == "osx") {
292 m_pluginDownloadTypes.insert(DownloadMac); 274 m_provider.downloadTypes.insert(Provider::DownloadMac);
293 } 275 }
294 } 276 }
295 } 277 }
296 278
297 Nodes packs = index->match 279 Nodes packs = index->match
302 << libn << endl; 284 << libn << endl;
303 285
304 for (Node packn: packs) { 286 for (Node packn: packs) {
305 if (packn.type != Node::URI) continue; 287 if (packn.type != Node::URI) continue;
306 288
307 Pack pack; 289 QString packName;
290 QString packUrl;
308 n = index->complete 291 n = index->complete
309 (Triple(packn, index->expand("dc:title"), Node())); 292 (Triple(packn, index->expand("dc:title"), Node()));
310 if (n.type == Node::Literal) { 293 if (n.type == Node::Literal) {
311 pack.name = n.value; 294 packName = n.value;
312 } 295 }
313 n = index->complete 296 n = index->complete
314 (Triple(packn, index->expand("foaf:page"), Node())); 297 (Triple(packn, index->expand("foaf:page"), Node()));
315 if (n.type == Node::URI) { 298 if (n.type == Node::URI) {
316 pack.downloadURL = n.value; 299 packUrl = n.value;
317 } 300 }
318 301
319 if (pack.name != "" && pack.downloadURL != "") { 302 if (packName != "" && packUrl != "") {
320 m_pluginFoundInPacks[packn.value] = pack; 303 m_provider.foundInPacks[packName] = packUrl;
321 } 304 }
322 } 305 }
323 } 306 }
324 307
325 #ifdef DEBUG_PLUGIN_RDF_DESCRIPTION 308 #ifdef DEBUG_PLUGIN_RDF_DESCRIPTION
327 SVCERR << " * id: " << m_pluginId << endl; 310 SVCERR << " * id: " << m_pluginId << endl;
328 SVCERR << " * uri: <" << m_pluginUri << ">" << endl; 311 SVCERR << " * uri: <" << m_pluginUri << ">" << endl;
329 SVCERR << " * name: " << m_pluginName << endl; 312 SVCERR << " * name: " << m_pluginName << endl;
330 SVCERR << " * description: " << m_pluginDescription << endl; 313 SVCERR << " * description: " << m_pluginDescription << endl;
331 SVCERR << " * maker: " << m_pluginMaker << endl; 314 SVCERR << " * maker: " << m_pluginMaker << endl;
332 SVCERR << " * info url: <" << m_pluginInfoURL << ">" << endl; 315 SVCERR << " * info url: <" << m_provider.infoUrl << ">" << endl;
333 SVCERR << " * download url: <" << m_pluginDownloadURL << ">" << endl; 316 SVCERR << " * download url: <" << m_provider.downloadUrl << ">" << endl;
334 SVCERR << " * download types:" << endl; 317 SVCERR << " * download types:" << endl;
335 for (auto t: m_pluginDownloadTypes) { 318 for (auto t: m_provider.downloadTypes) {
336 SVCERR << " * " << int(t) << endl; 319 SVCERR << " * " << int(t) << endl;
337 } 320 }
338 SVCERR << " * packs:" << endl; 321 SVCERR << " * packs:" << endl;
339 for (auto t: m_pluginFoundInPacks) { 322 for (auto t: m_provider.foundInPacks) {
340 SVCERR << " * " << t.first << " { name: " << t.second.name 323 SVCERR << " * " << t.first
341 << ", download url: " << t.second.downloadURL << " }" << endl; 324 << ", download url: <" << t.second << ">" << endl;
342 } 325 }
343 SVCERR << endl; 326 SVCERR << endl;
344 #endif 327 #endif
345 328
346 return true; 329 return true;