Small test application.

svn path=/trunk/kdebase/nsplugins/; revision=53698
This commit is contained in:
Stefan Schimanski 2000-06-19 17:49:34 +00:00
parent 39f2078686
commit c1d9be1ece
4 changed files with 223 additions and 0 deletions

View file

@ -0,0 +1,8 @@
INCLUDES = $(all_includes) -I$(top_srcdir)/libltdl
METASOURCES = AUTO
noinst_HEADERS = testnsplugin.h
check_PROGRAMS = testnsplugin
testnsplugin_SOURCES = testnsplugin.cpp
testnsplugin_LDFLAGS = $(all_libraries) $(KDE_RPATH)
testnsplugin_LDADD = $(LIB_KDEUI) -L.. -lnsplugin

View file

@ -0,0 +1,143 @@
/*
This is an encapsulation of the Netscape plugin API.
Copyright (c) 2000 Stefan Schimanski <1Stein@gmx.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <qstring.h>
#include <kapp.h>
#include <kcmdlineargs.h>
#include <dcopclient.h>
#include <kdebug.h>
#include <kstdaction.h>
#include <kaction.h>
#include "testnsplugin.h"
#include "../NSPluginClassIface_stub.h"
#include "../nspluginloader.h"
TestNSPlugin::TestNSPlugin()
{
m_loader = NSPluginLoader::instance();
// client area
m_client = new QWidget( this, "m_client" );
setView( m_client );
m_client->show();
m_layout = new QHBoxLayout( m_client );
// file menu
KStdAction::openNew( this, SLOT(newView()), actionCollection());
KStdAction::close( this, SLOT(closeView()), actionCollection());
KStdAction::quit( kapp, SLOT(quit()), actionCollection());
createGUI( "testnspluginui.rc" );
}
TestNSPlugin::~TestNSPlugin()
{
kdDebug() << "-> TestNSPlugin::~TestNSPlugin" << endl;
m_loader->release();
delete m_client;
kdDebug() << "<- TestNSPlugin::~TestNSPlugin" << endl;
}
void TestNSPlugin::newView()
{
//QString src = "file:/home/sschimanski/kimble_themovie.swf";
QString src = "file:/home/sschimanski/in_ani.swf";
//QString src = "http://homepages.tig.com.au/~dkl/swf/promo.swf";
QString mime = "application/x-shockwave-flash";
//QString src = "file:/opt/kde/share/Circuit.jpg";
//QString mime = "image/jpg";
//QString src = "file:/home/sschimanski/hund.avi";
//QString mime = "video/avi";
QStringList _argn, _argv;
_argn << "SRC" << "TYPE" << "WIDTH" << "HEIGHT";
_argv << src << mime << "400" << "100";
QWidget *win = m_loader->NewInstance( m_client, src, mime, 1, _argn, _argv );
/*
_argn << "TYPE" << "WIDTH" << "HEIGHT" << "java_docbase" << "CODE";
_argv << "application/x-java-applet" << "450" << "350" << "file:///none" << "sun/plugin/panel/ControlPanelApplet.class";
QWidget *win = loader->NewInstance(0, "", "application/x-java-applet", 1, _argn, _argv);
*/
if ( win )
{
m_plugins.append( win );
connect( win, SIGNAL(destroyed(NSPluginInstance *)),
this, SLOT(viewDestroyed(NSPluginInstance *)) );
m_layout->addWidget( win );
win->show();
} else
{
kdDebug() << "No widget created" << endl;
}
}
void TestNSPlugin::closeView()
{
kdDebug() << "closeView" << endl;
QWidget *win = m_plugins.last();
if ( win )
{
m_plugins.remove( win );
delete win;
} else
{
kdDebug() << "No widget available" << endl;
}
}
void TestNSPlugin::viewDestroyed( NSPluginInstance *inst )
{
kdDebug() << "TestNSPlugin::viewDestroyed" << endl;
m_plugins.remove( inst );
}
int main(int argc, char *argv[])
{
kdDebug() << "main" << endl;
setvbuf( stderr, NULL, _IONBF, 0 );
KCmdLineArgs::init(argc, argv, "nsplugin", "A Netscape Plugin test program", "0.1");
KApplication *app = new KApplication(argc, argv, "nsplugin");
app->dcopClient()->attach();
app->dcopClient()->registerAs(app.name());
app->dcopClient()->setNotifications(true);
TestNSPlugin *win = new TestNSPlugin;
app->setMainWidget( win );
win->show();
app->exec();
delete app;
kdDebug() << "exit" << endl;
}

View file

@ -0,0 +1,57 @@
/*
This is an encapsulation of the Netscape plugin API.
Copyright (c) 2000 Stefan Schimanski <1Stein@gmx.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __TESTNSPLUGIN_H__
#define __TESTNSPLUGIN_H__
#include <qstring.h>
#include <qwidget.h>
#include <ktmainwindow.h>
#include <qlayout.h>
#include <qlist.h>
class NSPluginLoader;
class NSPluginInstance;
class TestNSPlugin : public KTMainWindow
{
Q_OBJECT
public:
TestNSPlugin();
virtual ~TestNSPlugin();
public slots:
void newView();
void closeView();
void viewDestroyed( NSPluginInstance *inst );
protected:
NSPluginLoader *m_loader;
QList<QWidget> m_plugins;
QWidget *m_client;
QBoxLayout *m_layout;
};
#endif

View file

@ -0,0 +1,15 @@
<!DOCTYPE kpartgui>
<kpartgui name="testnsplugin">
<MenuBar>
<Menu name="file"><text>&amp;File</text>
</Menu>
</MenuBar>
<ToolBar noMerge="1" name="mainToolBar">
<Action name="file_new"/>
<Action name="file_close"/>
<Action name="file_quit"/>
</ToolBar>
</kpartgui>