1
/* This file is part of the KDE project
2
Copyright (C) 2004 Alexander Dymo <adymo@kdevelop.org>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, USA.
19
#include "kdevplugininfo.h"
26
#include "kdevplugincontroller.h"
28
struct KDevPluginInfo::Private {
30
QString m_rawGenericName;
32
QString m_genericName;
33
QString m_description;
38
QString m_copyrightStatement;
39
QString m_homePageAddress;
40
QString m_bugsEmailAddress;
42
QValueList<KAboutPerson> m_authors;
43
QValueList<KAboutPerson> m_credits;
49
KDevPluginInfo::KDevPluginInfo(const QString &pluginName)
52
d->m_pluginName = pluginName;
54
KService::Ptr offer = KService::serviceByDesktopName(pluginName);
57
d->m_genericName = offer->genericName();
58
d->m_icon = offer->icon();
59
d->m_description = offer->comment();
61
d->m_rawGenericName = offer->untranslatedGenericName();
63
d->m_version = offer->property("X-KDevelop-Plugin-Version").toString();
64
d->m_homePageAddress = offer->property("X-KDevelop-Plugin-Homepage").toString();
65
d->m_bugsEmailAddress = offer->property("X-KDevelop-Plugin-BugsEmailAddress").toString();
66
d->m_copyrightStatement = offer->property("X-KDevelop-Plugin-Copyright").toString();
68
QString lic = offer->property("X-KDevelop-Plugin-License").toString();
70
d->m_licenseType = KAboutData::License_GPL;
71
else if (lic == "LGPL")
72
d->m_licenseType = KAboutData::License_LGPL;
73
else if (lic == "BSD")
74
d->m_licenseType = KAboutData::License_BSD;
75
else if (lic == "QPL")
76
d->m_licenseType = KAboutData::License_QPL;
77
else if (lic == "Artistic")
78
d->m_licenseType = KAboutData::License_Artistic;
79
else if (lic == "Custom")
80
d->m_licenseType = KAboutData::License_Custom;
82
d->m_licenseType = KAboutData::License_Unknown;
84
d->m_data = new KAboutData(d->m_pluginName.ascii(), d->m_rawGenericName.ascii(), "1", 0, d->m_licenseType);
87
kdDebug() << "Unable to load information for plugin: " << pluginName
88
<< ". Check if " << pluginName << ".desktop exists." << endl;
92
KDevPluginInfo::operator KAboutData *() const
97
QString KDevPluginInfo::pluginName() const
99
return d->m_pluginName;
102
QString KDevPluginInfo::genericName() const
104
return d->m_genericName;
107
QString KDevPluginInfo::icon() const
112
QString KDevPluginInfo::description() const
114
return d->m_description;
117
QString KDevPluginInfo::version() const
122
int KDevPluginInfo::licenseType() const
124
return d->m_licenseType;
127
QString KDevPluginInfo::license() const
129
KDevPluginInfo &info = *const_cast<KDevPluginInfo*>(this);
130
// return KAboutData(info).license();
131
KAboutData *data = info;
132
return data->license();
135
QString KDevPluginInfo::copyrightStatement() const
137
return d->m_copyrightStatement;
140
QString KDevPluginInfo::homePageAddress() const
142
return d->m_homePageAddress;
145
QString KDevPluginInfo::bugsEmailAddress() const
147
return d->m_bugsEmailAddress;
150
QVariant KDevPluginInfo::property(const QString &name) const
152
KTrader::OfferList offers = KDevPluginController::queryPlugins(QString("Name='%1'").arg(d->m_pluginName));
153
if (offers.count() == 1)
154
return offers.first()->property(name);
158
QVariant KDevPluginInfo::operator [](const QString &name) const
160
return property(name);
163
QStringList KDevPluginInfo::propertyNames( ) const
165
KTrader::OfferList offers = KDevPluginController::queryPlugins(QString("Name='%1'").arg(d->m_pluginName));
166
if (offers.count() == 1)
167
return offers.first()->propertyNames();
168
return QStringList();
171
void KDevPluginInfo::addAuthor(const char *name, const char *task,
172
const char *emailAddress, const char *webAddress)
174
d->m_authors.append(KAboutPerson(name, task, emailAddress, webAddress));
177
void KDevPluginInfo::addCredit(const char *name, const char *task,
178
const char *emailAddress, const char *webAddress)
180
d->m_credits.append(KAboutPerson(name, task, emailAddress, webAddress));