You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
182 lines
5.2 KiB
182 lines
5.2 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
11 years ago
|
Copyright (C) 2004 Alexander Dymo <adymo@kdevelop.org>
|
||
15 years ago
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU Library General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU Library General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
15 years ago
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
15 years ago
|
*/
|
||
11 years ago
|
#include "tdevplugininfo.h"
|
||
15 years ago
|
|
||
15 years ago
|
#include <tqvariant.h>
|
||
15 years ago
|
|
||
|
#include <kservice.h>
|
||
|
#include <kdebug.h>
|
||
|
|
||
11 years ago
|
#include "tdevplugincontroller.h"
|
||
15 years ago
|
|
||
11 years ago
|
struct TDevPluginInfo::Private {
|
||
15 years ago
|
TQString m_pluginName;
|
||
|
TQString m_rawGenericName;
|
||
15 years ago
|
|
||
15 years ago
|
TQString m_genericName;
|
||
|
TQString m_description;
|
||
|
TQString m_icon;
|
||
15 years ago
|
|
||
15 years ago
|
TQString m_version;
|
||
15 years ago
|
int m_licenseType;
|
||
15 years ago
|
TQString m_copyrightStatement;
|
||
|
TQString m_homePageAddress;
|
||
|
TQString m_bugsEmailAddress;
|
||
15 years ago
|
|
||
12 years ago
|
TQValueList<TDEAboutPerson> m_authors;
|
||
|
TQValueList<TDEAboutPerson> m_credits;
|
||
15 years ago
|
|
||
12 years ago
|
TDEAboutData *m_data;
|
||
15 years ago
|
};
|
||
|
|
||
|
|
||
11 years ago
|
TDevPluginInfo::TDevPluginInfo(const TQString &pluginName)
|
||
15 years ago
|
:d(new Private())
|
||
|
{
|
||
|
d->m_pluginName = pluginName;
|
||
|
|
||
|
KService::Ptr offer = KService::serviceByDesktopName(pluginName);
|
||
|
if (offer != 0)
|
||
|
{
|
||
|
d->m_genericName = offer->genericName();
|
||
|
d->m_icon = offer->icon();
|
||
|
d->m_description = offer->comment();
|
||
|
|
||
|
d->m_rawGenericName = offer->untranslatedGenericName();
|
||
|
|
||
13 years ago
|
d->m_version = offer->property("X-TDevelop-Plugin-Version").toString();
|
||
|
d->m_homePageAddress = offer->property("X-TDevelop-Plugin-Homepage").toString();
|
||
|
d->m_bugsEmailAddress = offer->property("X-TDevelop-Plugin-BugsEmailAddress").toString();
|
||
|
d->m_copyrightStatement = offer->property("X-TDevelop-Plugin-Copyright").toString();
|
||
15 years ago
|
|
||
13 years ago
|
TQString lic = offer->property("X-TDevelop-Plugin-License").toString();
|
||
15 years ago
|
if (lic == "GPL")
|
||
12 years ago
|
d->m_licenseType = TDEAboutData::License_GPL;
|
||
15 years ago
|
else if (lic == "LGPL")
|
||
12 years ago
|
d->m_licenseType = TDEAboutData::License_LGPL;
|
||
15 years ago
|
else if (lic == "BSD")
|
||
12 years ago
|
d->m_licenseType = TDEAboutData::License_BSD;
|
||
15 years ago
|
else if (lic == "QPL")
|
||
12 years ago
|
d->m_licenseType = TDEAboutData::License_QPL;
|
||
15 years ago
|
else if (lic == "Artistic")
|
||
12 years ago
|
d->m_licenseType = TDEAboutData::License_Artistic;
|
||
15 years ago
|
else if (lic == "Custom")
|
||
12 years ago
|
d->m_licenseType = TDEAboutData::License_Custom;
|
||
15 years ago
|
else
|
||
12 years ago
|
d->m_licenseType = TDEAboutData::License_Unknown;
|
||
15 years ago
|
|
||
12 years ago
|
d->m_data = new TDEAboutData(d->m_pluginName.ascii(), d->m_rawGenericName.ascii(), "1", 0, d->m_licenseType);
|
||
15 years ago
|
}
|
||
|
else
|
||
|
kdDebug() << "Unable to load information for plugin: " << pluginName
|
||
|
<< ". Check if " << pluginName << ".desktop exists." << endl;
|
||
|
}
|
||
|
|
||
|
|
||
11 years ago
|
TDevPluginInfo::operator TDEAboutData *() const
|
||
15 years ago
|
{
|
||
|
return d->m_data;
|
||
|
}
|
||
|
|
||
11 years ago
|
TQString TDevPluginInfo::pluginName() const
|
||
15 years ago
|
{
|
||
|
return d->m_pluginName;
|
||
|
}
|
||
|
|
||
11 years ago
|
TQString TDevPluginInfo::genericName() const
|
||
15 years ago
|
{
|
||
|
return d->m_genericName;
|
||
|
}
|
||
|
|
||
11 years ago
|
TQString TDevPluginInfo::icon() const
|
||
15 years ago
|
{
|
||
|
return d->m_icon;
|
||
|
}
|
||
|
|
||
11 years ago
|
TQString TDevPluginInfo::description() const
|
||
15 years ago
|
{
|
||
|
return d->m_description;
|
||
|
}
|
||
|
|
||
11 years ago
|
TQString TDevPluginInfo::version() const
|
||
15 years ago
|
{
|
||
|
return d->m_version;
|
||
|
}
|
||
|
|
||
11 years ago
|
int TDevPluginInfo::licenseType() const
|
||
15 years ago
|
{
|
||
|
return d->m_licenseType;
|
||
|
}
|
||
|
|
||
11 years ago
|
TQString TDevPluginInfo::license() const
|
||
15 years ago
|
{
|
||
11 years ago
|
TDevPluginInfo &info = *const_cast<TDevPluginInfo*>(this);
|
||
12 years ago
|
// return TDEAboutData(info).license();
|
||
|
TDEAboutData *data = info;
|
||
15 years ago
|
return data->license();
|
||
|
}
|
||
|
|
||
11 years ago
|
TQString TDevPluginInfo::copyrightStatement() const
|
||
15 years ago
|
{
|
||
|
return d->m_copyrightStatement;
|
||
|
}
|
||
|
|
||
11 years ago
|
TQString TDevPluginInfo::homePageAddress() const
|
||
15 years ago
|
{
|
||
|
return d->m_homePageAddress;
|
||
|
}
|
||
|
|
||
11 years ago
|
TQString TDevPluginInfo::bugsEmailAddress() const
|
||
15 years ago
|
{
|
||
|
return d->m_bugsEmailAddress;
|
||
|
}
|
||
|
|
||
11 years ago
|
TQVariant TDevPluginInfo::property(const TQString &name) const
|
||
15 years ago
|
{
|
||
11 years ago
|
TDETrader::OfferList offers = TDevPluginController::queryPlugins(TQString("Name='%1'").arg(d->m_pluginName));
|
||
15 years ago
|
if (offers.count() == 1)
|
||
|
return offers.first()->property(name);
|
||
15 years ago
|
return TQVariant();
|
||
15 years ago
|
}
|
||
|
|
||
11 years ago
|
TQVariant TDevPluginInfo::operator [](const TQString &name) const
|
||
15 years ago
|
{
|
||
|
return property(name);
|
||
|
}
|
||
|
|
||
11 years ago
|
TQStringList TDevPluginInfo::propertyNames( ) const
|
||
15 years ago
|
{
|
||
11 years ago
|
TDETrader::OfferList offers = TDevPluginController::queryPlugins(TQString("Name='%1'").arg(d->m_pluginName));
|
||
15 years ago
|
if (offers.count() == 1)
|
||
|
return offers.first()->propertyNames();
|
||
15 years ago
|
return TQStringList();
|
||
15 years ago
|
}
|
||
|
|
||
11 years ago
|
void TDevPluginInfo::addAuthor(const char *name, const char *task,
|
||
15 years ago
|
const char *emailAddress, const char *webAddress)
|
||
|
{
|
||
12 years ago
|
d->m_authors.append(TDEAboutPerson(name, task, emailAddress, webAddress));
|
||
15 years ago
|
}
|
||
|
|
||
11 years ago
|
void TDevPluginInfo::addCredit(const char *name, const char *task,
|
||
15 years ago
|
const char *emailAddress, const char *webAddress)
|
||
|
{
|
||
12 years ago
|
d->m_credits.append(TDEAboutPerson(name, task, emailAddress, webAddress));
|
||
15 years ago
|
}
|