1
/* This file is part of the KDE project
2
Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
3
Copyright (C) 1999 David Faure <faure@kde.org>
4
Copyright (C) 1999 Torben Weis <weis@kde.org>
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
#include <kparts/factory.h>
23
#include "konq_factory.h"
26
#include <konq_settings.h>
28
#include <kaboutdata.h>
30
#include <kmessagebox.h>
37
KAboutData *KonqFactory::s_aboutData = 0;
39
KonqViewFactory::KonqViewFactory( KLibFactory *factory, const QStringList &args,
41
: m_factory( factory ), m_args( args ), m_createBrowser( createBrowser )
43
if ( m_createBrowser )
44
m_args << QString::fromLatin1( "Browser/View" );
47
KParts::ReadOnlyPart *KonqViewFactory::create( QWidget *parentWidget, const char *widgetName,
48
QObject * parent, const char *name )
55
if ( m_factory->inherits( "KParts::Factory" ) )
57
if ( m_createBrowser )
58
obj = static_cast<KParts::Factory *>(m_factory)->createPart( parentWidget, widgetName, parent, name, "Browser/View", m_args );
61
obj = static_cast<KParts::Factory *>(m_factory)->createPart( parentWidget, widgetName, parent, name, "KParts::ReadOnlyPart", m_args );
65
if ( m_createBrowser )
66
obj = m_factory->create( parentWidget, name, "Browser/View", m_args );
69
obj = m_factory->create( parentWidget, name, "KParts::ReadOnlyPart", m_args );
72
if ( !obj->inherits( "KParts::ReadOnlyPart" ) )
73
kdError(1202) << "Part " << obj << " (" << obj->className() << ") doesn't inherit KParts::ReadOnlyPart !" << endl;
75
return static_cast<KParts::ReadOnlyPart *>(obj);
78
KonqViewFactory KonqFactory::createView( const QString &serviceType,
79
const QString &serviceName,
80
KService::Ptr *serviceImpl,
81
KTrader::OfferList *partServiceOffers,
82
KTrader::OfferList *appServiceOffers,
85
kdDebug(1202) << "Trying to create view for \"" << serviceType << "\"" << endl;
87
// We need to get those in any case
88
KTrader::OfferList offers, appOffers;
91
getOffers( serviceType, &offers, &appOffers );
93
if ( partServiceOffers )
94
(*partServiceOffers) = offers;
95
if ( appServiceOffers )
96
(*appServiceOffers) = appOffers;
98
// We ask ourselves whether to do it or not only if no service was specified.
99
// If it was (from the View menu or from RMB + Embedding service), just do it.
100
forceAutoEmbed |= !serviceName.isEmpty();
101
// Or if we have no associated app anyway, then embed.
102
forceAutoEmbed |= appOffers.isEmpty() && !offers.isEmpty();
104
if ( ! forceAutoEmbed )
106
if ( ! KonqFMSettings::settings()->shouldEmbed( serviceType ) )
108
kdDebug(1202) << "KonqFMSettings says: don't embed this servicetype" << endl;
109
return KonqViewFactory();
113
KService::Ptr service = 0L;
115
// Look for this service
116
if ( !serviceName.isEmpty() )
118
KTrader::OfferList::Iterator it = offers.begin();
119
for ( ; it != offers.end() && !service ; ++it )
121
if ( (*it)->desktopEntryName() == serviceName )
123
kdDebug(1202) << "Found requested service " << serviceName << endl;
129
KLibFactory *factory = 0L;
133
kdDebug(1202) << "Trying to open lib for requested service " << service->desktopEntryName() << endl;
134
factory = KLibLoader::self()->factory( QFile::encodeName(service->library()) );
136
KMessageBox::error(0,
137
i18n("There was an error loading the module %1.\nThe diagnostics is:\n%2")
138
.arg(service->name()).arg(KLibLoader::self()->lastErrorMessage()));
141
KTrader::OfferList::Iterator it = offers.begin();
142
for ( ; !factory && it != offers.end() ; ++it )
145
// Allowed as default ?
146
QVariant prop = service->property( "X-KDE-BrowserView-AllowAsDefault" );
147
kdDebug(1202) << service->desktopEntryName() << " : X-KDE-BrowserView-AllowAsDefault is valid : " << prop.isValid() << endl;
148
if ( !prop.isValid() || prop.toBool() ) // defaults to true
150
//kdDebug(1202) << "Trying to open lib for service " << service->name() << endl;
151
// Try loading factory
152
factory = KLibLoader::self()->factory( QFile::encodeName(service->library()) );
154
KMessageBox::error(0,
155
i18n("There was an error loading the module %1.\nThe diagnostics is:\n%2")
156
.arg(service->name()).arg(KLibLoader::self()->lastErrorMessage()));
157
// If this works, we exit the loop.
159
kdDebug(1202) << "Not allowed as default " << service->desktopEntryName() << endl;
163
(*serviceImpl) = service;
167
kdWarning(1202) << "KonqFactory::createView : no factory" << endl;
168
return KonqViewFactory();
173
QVariant prop = service->property( "X-KDE-BrowserView-Args" );
175
if ( prop.isValid() )
177
QString argStr = prop.toString();
178
args = QStringList::split( " ", argStr );
181
return KonqViewFactory( factory, args, service->serviceTypes().contains( "Browser/View" ) );
184
void KonqFactory::getOffers( const QString & serviceType,
185
KTrader::OfferList *partServiceOffers,
186
KTrader::OfferList *appServiceOffers )
188
if ( appServiceOffers )
190
*appServiceOffers = KTrader::self()->query( serviceType, "Application",
191
"DesktopEntryName != 'kfmclient' and DesktopEntryName != 'kfmclient_dir' and DesktopEntryName != 'kfmclient_html'",
195
if ( partServiceOffers )
197
*partServiceOffers = KTrader::self()->query( serviceType, "KParts/ReadOnlyPart",
198
QString::null, QString::null );
203
const KAboutData *KonqFactory::aboutData()
207
s_aboutData = new KAboutData( "konqueror", I18N_NOOP("Konqueror"),
209
I18N_NOOP("Web browser, file manager, ..."),
210
KAboutData::License_GPL,
211
I18N_NOOP("(c) 1999-2003, The Konqueror developers"),
213
I18N_NOOP("http://konqueror.kde.org") );
214
s_aboutData->addAuthor( "David Faure", I18N_NOOP("developer (parts, I/O lib) and maintainer"), "faure@kde.org" );
215
s_aboutData->addAuthor( "Simon Hausmann", I18N_NOOP("developer (framework, parts)"), "hausmann@kde.org" );
216
s_aboutData->addAuthor( "Michael Reiher", I18N_NOOP("developer (framework)"), "michael.reiher@gmx.de" );
217
s_aboutData->addAuthor( "Matthias Welk", I18N_NOOP("developer"), "welk@fokus.gmd.de" );
218
s_aboutData->addAuthor( "Alexander Neundorf", I18N_NOOP("developer (List views)"), "neundorf@kde.org" );
219
s_aboutData->addAuthor( "Michael Brade", I18N_NOOP("developer (List views, I/O lib)"), "brade@kde.org" );
220
s_aboutData->addAuthor( "Lars Knoll", I18N_NOOP("developer (HTML rendering engine)"), "knoll@kde.org" );
221
s_aboutData->addAuthor( "Antti Koivisto", I18N_NOOP("developer (HTML rendering engine)"), "koivisto@kde.org" );
222
s_aboutData->addAuthor( "Dirk Mueller", I18N_NOOP("developer (HTML rendering engine)"), "mueller@kde.org" );
223
s_aboutData->addAuthor( "Peter Kelly", I18N_NOOP("developer (HTML rendering engine)"), "pmk@post.com" );
224
s_aboutData->addAuthor( "Waldo Bastian", I18N_NOOP("developer (HTML rendering engine, I/O lib)"), "bastian@kde.org" );
225
s_aboutData->addAuthor( "Matt Koss", I18N_NOOP("developer (I/O lib)"), "koss@miesto.sk" );
226
s_aboutData->addAuthor( "Alex Zepeda", I18N_NOOP("developer (I/O lib)"), "zipzippy@sonic.net" );
227
s_aboutData->addAuthor( "Stephan Kulow", I18N_NOOP("developer (I/O lib)"), "coolo@kde.org" );
228
s_aboutData->addAuthor( "Richard Moore", I18N_NOOP("developer (Java applet support)"), "rich@kde.org" );
229
s_aboutData->addAuthor( "Dima Rogozin", I18N_NOOP("developer (Java applet support)"), "dima@mercury.co.il" );
230
s_aboutData->addAuthor( "Wynn Wilkes", I18N_NOOP("developer (Java 2 security manager support,\n and other major improvements to applet support)"), "wynnw@calderasystems.com" );
231
s_aboutData->addAuthor( "Harri Porten", I18N_NOOP("developer (JavaScript)"), "porten@kde.org" );
232
s_aboutData->addAuthor( "Stefan Schimanski", I18N_NOOP("developer (Netscape plugin support)"), "schimmi@kde.org" );
233
s_aboutData->addAuthor( "George Staikos", I18N_NOOP("developer (SSL, Netscape plugins)"), "staikos@kde.org" );
234
s_aboutData->addAuthor( "Dawit Alemayehu",I18N_NOOP("developer (I/O lib, Authentication support)"), "adawit@kde.org" );
235
s_aboutData->addAuthor( "Carsten Pfeiffer",I18N_NOOP("developer (framework)"), "pfeiffer@kde.org" );
236
s_aboutData->addAuthor( "Torsten Rahn", I18N_NOOP("graphics/icons"), "torsten@kde.org" );
237
s_aboutData->addAuthor( "Torben Weis", I18N_NOOP("kfm author"), "weis@kde.org" );
238
s_aboutData->addAuthor( "Joseph Wenninger", I18N_NOOP("developer (navigation panel framework)"),"jowenn@kde.org");