Fix crash if key bindings specified in profile cannot be found. Improve
[personal-kdebase.git] / apps / nsplugins / nspluginloader.h
blobd203dc3ef3e452f8f05c26636f4e152615e73786
1 /*
3 This is an encapsulation of the Netscape plugin API.
6 Copyright (c) 2000 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
7 Stefan Schimanski <1Stein@gmx.de>
8 Copyright (c) 2002-2005 George Staikos <staikos@kde.org>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 #ifndef NS_PLUGINLOADER_H
28 #define NS_PLUGINLOADER_H
30 #include <QHash>
31 #include <QObject>
32 #include <QWidget>
33 #include <QtGui/QX11EmbedContainer>
35 #include <KUrl>
36 #include <kdemacros.h>
37 #include <kprocess.h>
39 #define EMBEDCLASS QX11EmbedContainer
41 class OrgKdeNspluginsViewerInterface;
42 class QPushButton;
43 class QGridLayout;
44 class OrgKdeNspluginsInstanceInterface;
46 class NSPluginInstance : public EMBEDCLASS
48 Q_OBJECT
50 public:
51 NSPluginInstance(QWidget *parent, const QString& app, const QString& id, const KUrl& baseUrl);
52 ~NSPluginInstance();
54 void javascriptResult(int id, const QString &result);
56 void pluginResized(int w, int h);
58 private Q_SLOTS:
59 void loadPlugin();
61 protected:
62 void resizeEvent(QResizeEvent *event);
63 void showEvent(QShowEvent *event);
64 void windowChanged(WId w);
65 virtual void focusInEvent( QFocusEvent* event );
66 virtual void focusOutEvent( QFocusEvent* event );
67 private:
68 class NSPluginLoader *_loader;
69 OrgKdeNspluginsInstanceInterface *_instanceInterface;
70 bool inited;
71 bool haveSize;
72 void doLoadPlugin(int w, int h);
73 void embedIfNeeded(int w, int h);
74 void resizePlugin(int w, int h );
76 QPushButton *_button;
77 QGridLayout *_layout;
80 // class exported for the test program
81 class KDE_EXPORT NSPluginLoader : public QObject
83 Q_OBJECT
85 public:
86 NSPluginLoader();
87 ~NSPluginLoader();
89 NSPluginInstance *newInstance(QWidget *parent,
90 const QString& url, const QString& mimeType, bool embed,
91 const QStringList& argn, const QStringList& argv,
92 const QString& ownDBusId, const QString& callbackId, bool reload );
94 static NSPluginLoader *instance();
95 void release();
97 protected:
98 void scanPlugins();
100 QString lookup(const QString &mimeType);
101 QString lookupMimeType(const QString &url);
103 bool loadViewer();
104 void unloadViewer();
106 protected Q_SLOTS:
107 void processTerminated();
109 private:
110 QStringList _searchPaths;
111 QMultiHash<QString, QString> _mapping;
112 QHash<QString, QString> _filetype;
114 KProcess _process;
115 QString _viewerDBusId;
116 OrgKdeNspluginsViewerInterface *_viewer;
118 static NSPluginLoader *s_instance;
119 static int s_refCount;
123 #endif