Fix crash if key bindings specified in profile cannot be found. Improve
[personal-kdebase.git] / apps / nsplugins / test / testnsplugin.cpp
blobacf9d92315323c5c9a114f82d44b9d6edb56386a
1 /*
2 This is an encapsulation of the Netscape plugin API.
4 Copyright (c) 2000 Stefan Schimanski <1Stein@gmx.de>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include "testnsplugin.h"
23 #include "../nspluginloader.h"
25 #include <stdio.h>
27 #include <QHBoxLayout>
29 #include <kactioncollection.h>
30 #include <kapplication.h>
31 #include <kcmdlineargs.h>
32 #include <kdebug.h>
33 #include <kstandardaction.h>
34 #include <kaction.h>
38 TestNSPlugin::TestNSPlugin()
40 m_loader = NSPluginLoader::instance();
42 // client area
43 m_client = new QWidget( this );
44 setCentralWidget( m_client );
45 m_client->show();
46 m_layout = new QHBoxLayout( m_client );
47 m_layout->setMargin( 0 );
48 m_layout->setSpacing( 0 );
50 // file menu
51 actionCollection()->addAction(KStandardAction::Open, this, SLOT(newView()));
52 actionCollection()->addAction(KStandardAction::Close, this, SLOT(closeView()));
53 actionCollection()->addAction(KStandardAction::Quit,kapp,SLOT(quit()));
55 createGUI( "testnspluginui.rc" );
59 TestNSPlugin::~TestNSPlugin()
61 kDebug() << "-> TestNSPlugin::~TestNSPlugin";
62 m_loader->release();
63 kDebug() << "<- TestNSPlugin::~TestNSPlugin";
67 void TestNSPlugin::newView()
69 QStringList _argn, _argv;
71 //QString src = "file:/home/sschimanski/kimble_themovie.swf";
72 //QString src = "file:/home/sschimanski/in_ani.swf";
73 //QString src = "http://homepages.tig.com.au/~dkl/swf/promo.swf";
74 //QString mime = "application/x-shockwave-flash";
76 _argn << "name" << "controls" << "console";
77 _argv << "audio" << "ControlPanel" << "Clip1";
78 QString src = "http://welt.is-kunden.de:554/ramgen/welt/avmedia/realaudio/0701lw177135.rm";
79 // QString src = "nothing";
80 QString mime = "audio/x-pn-realaudio-plugin";
82 _argn << "SRC" << "TYPE" << "WIDTH" << "HEIGHT";
83 _argv << src << mime << "400" << "100";
84 QWidget *win = m_loader->newInstance( m_client, src, mime, 1, _argn, _argv, QString("appid"), QString("callbackid"), false );
87 _argn << "TYPE" << "WIDTH" << "HEIGHT" << "java_docbase" << "CODE";
88 _argv << "application/x-java-applet" << "450" << "350" << "file:///none" << "sun/plugin/panel/ControlPanelApplet.class";
89 QWidget *win = loader->NewInstance(0, "", "application/x-java-applet", 1, _argn, _argv);
92 if ( win )
94 m_plugins.append( win );
95 connect( win, SIGNAL(destroyed(NSPluginInstance *)),
96 this, SLOT(viewDestroyed(NSPluginInstance *)) );
97 m_layout->addWidget( win );
98 win->show();
99 } else
101 kDebug() << "No widget created";
105 void TestNSPlugin::closeView()
107 kDebug() << "closeView";
108 QWidget *win = m_plugins.last();
109 if ( win )
111 m_plugins.removeAll( win );
112 delete win;
113 } else
115 kDebug() << "No widget available";
120 void TestNSPlugin::viewDestroyed( NSPluginInstance *inst )
122 kDebug() << "TestNSPlugin::viewDestroyed";
123 m_plugins.removeAll( inst );
127 int main(int argc, char *argv[])
129 kDebug() << "main";
130 setvbuf( stderr, NULL, _IONBF, 0 );
131 KCmdLineArgs::init(argc, argv, "nsplugin", 0, ki18n("testnsplugin"), "0.1", ki18n("A Netscape Plugin test program"));
133 KApplication app("nsplugin");
135 TestNSPlugin win;
136 win.show();
137 app.exec();
140 #include "testnsplugin.moc"