~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to lib/interfaces/kdevplugininfo.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2004 Alexander Dymo <adymo@kdevelop.org>
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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.
 
18
*/
 
19
#include "kdevplugininfo.h"
 
20
 
 
21
#include <qvariant.h>
 
22
 
 
23
#include <kservice.h>
 
24
#include <kdebug.h>
 
25
 
 
26
#include "kdevplugincontroller.h"
 
27
 
 
28
struct KDevPluginInfo::Private {
 
29
    QString m_pluginName;
 
30
    QString m_rawGenericName;
 
31
    
 
32
    QString m_genericName;
 
33
    QString m_description;
 
34
    QString m_icon;
 
35
    
 
36
    QString m_version;
 
37
    int m_licenseType;
 
38
    QString m_copyrightStatement;
 
39
    QString m_homePageAddress;
 
40
    QString m_bugsEmailAddress;
 
41
    
 
42
    QValueList<KAboutPerson> m_authors;
 
43
    QValueList<KAboutPerson> m_credits;
 
44
    
 
45
    KAboutData *m_data;
 
46
};
 
47
 
 
48
 
 
49
KDevPluginInfo::KDevPluginInfo(const QString &pluginName)
 
50
    :d(new Private())
 
51
{
 
52
    d->m_pluginName = pluginName;
 
53
    
 
54
    KService::Ptr offer = KService::serviceByDesktopName(pluginName);
 
55
    if (offer != 0)
 
56
    {
 
57
        d->m_genericName = offer->genericName();
 
58
        d->m_icon = offer->icon();
 
59
        d->m_description = offer->comment();
 
60
        
 
61
        d->m_rawGenericName = offer->untranslatedGenericName();
 
62
        
 
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();
 
67
        
 
68
        QString lic = offer->property("X-KDevelop-Plugin-License").toString();
 
69
        if (lic == "GPL")
 
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;
 
81
        else
 
82
            d->m_licenseType = KAboutData::License_Unknown;            
 
83
 
 
84
        d->m_data = new KAboutData(d->m_pluginName.ascii(), d->m_rawGenericName.ascii(), "1", 0, d->m_licenseType);
 
85
    }
 
86
    else
 
87
        kdDebug() << "Unable to load information for plugin: " << pluginName 
 
88
            << ". Check if " << pluginName << ".desktop exists." << endl;
 
89
}
 
90
 
 
91
 
 
92
KDevPluginInfo::operator KAboutData *() const
 
93
{
 
94
    return d->m_data;
 
95
}
 
96
 
 
97
QString KDevPluginInfo::pluginName() const
 
98
{
 
99
    return d->m_pluginName;
 
100
}
 
101
 
 
102
QString KDevPluginInfo::genericName() const
 
103
{
 
104
    return d->m_genericName;
 
105
}
 
106
 
 
107
QString KDevPluginInfo::icon() const
 
108
{
 
109
    return d->m_icon;
 
110
}
 
111
 
 
112
QString KDevPluginInfo::description() const
 
113
{
 
114
    return d->m_description;
 
115
}
 
116
 
 
117
QString KDevPluginInfo::version() const
 
118
{
 
119
    return d->m_version;
 
120
}
 
121
 
 
122
int KDevPluginInfo::licenseType() const
 
123
{
 
124
    return d->m_licenseType;
 
125
}
 
126
 
 
127
QString KDevPluginInfo::license() const
 
128
{
 
129
    KDevPluginInfo &info = *const_cast<KDevPluginInfo*>(this);
 
130
//    return KAboutData(info).license();
 
131
    KAboutData *data = info;
 
132
    return data->license();
 
133
}
 
134
 
 
135
QString KDevPluginInfo::copyrightStatement() const
 
136
{
 
137
    return d->m_copyrightStatement;
 
138
}
 
139
 
 
140
QString KDevPluginInfo::homePageAddress() const
 
141
{
 
142
    return d->m_homePageAddress;
 
143
}
 
144
 
 
145
QString KDevPluginInfo::bugsEmailAddress() const
 
146
{
 
147
    return d->m_bugsEmailAddress;
 
148
}
 
149
 
 
150
QVariant KDevPluginInfo::property(const QString &name) const
 
151
{
 
152
    KTrader::OfferList offers = KDevPluginController::queryPlugins(QString("Name='%1'").arg(d->m_pluginName));
 
153
    if (offers.count() == 1)
 
154
        return offers.first()->property(name);
 
155
    return QVariant();
 
156
}
 
157
 
 
158
QVariant KDevPluginInfo::operator [](const QString &name) const
 
159
{
 
160
    return property(name);
 
161
}
 
162
 
 
163
QStringList KDevPluginInfo::propertyNames( ) const
 
164
{
 
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();
 
169
}
 
170
 
 
171
void KDevPluginInfo::addAuthor(const char *name, const char *task,
 
172
    const char *emailAddress, const char *webAddress)
 
173
{
 
174
    d->m_authors.append(KAboutPerson(name, task, emailAddress, webAddress));
 
175
}
 
176
 
 
177
void KDevPluginInfo::addCredit(const char *name, const char *task,
 
178
    const char *emailAddress, const char *webAddress)
 
179
{
 
180
    d->m_credits.append(KAboutPerson(name, task, emailAddress, webAddress));
 
181
}