Commit 92df268e authored by Andres Krapf's avatar Andres Krapf

initial import - still buggy, crashes on exit, etc.

the playlist and the popup are unimplemented.
parent d072e40d
###############################################################################
# vlc (VideoLAN Client) kde module Makefile
# (c)2001 VideoLAN
###############################################################################
#
# Objects
#
PLUGIN_KDE = kde.o \
kdeinterface.o \
kinterfacemain.o \
kvlcslider.o \
kdiskdialog.o \
knetdialog.o \
ktitlemenu.o
PLUGIN_KDE_MOC = kinterfacemain.moc.o \
kvlcslider.moc.o \
kdiskdialog.moc.o \
knetdialog.moc.o \
ktitlemenu.moc.o
#BUILTIN_KDE = $(PLUGIN_KDE:%.o=BUILTIN_%.o)
#BUILTIN_KDE_MOC = $(PLUGIN_KDE_MOC:%.o=BUILTIN_%.o)
ALL_OBJ = $(PLUGIN_KDE) $(PLUGIN_KDE_MOC) $(BUILTIN_KDE) $(BUILTIN_KDE_MOC)
#
# Virtual targets
#
include ../../Makefile.modules
$(PLUGIN_KDE): %.o: .dep/%.dpp
$(PLUGIN_KDE): %.o: %.cpp
$(CC) $(CFLAGS) $(PCFLAGS) -I/usr/include/kde -I/usr/include/qt -c -o $@ $<
$(PLUGIN_KDE_MOC): %.o: .dep/%.dpp
$(PLUGIN_KDE_MOC): %.o: %.cpp
$(CC) $(CFLAGS) $(PCFLAGS) -I/usr/include/kde -I/usr/include/qt -c -o $@ $<
$(PLUGIN_KDE_MOC:%.moc.o=%.moc.cpp): %.moc.cpp: %.h
moc $< -o $@
#$(BUILTIN_KDE): BUILTIN_%.o: .dep/%.dpp
#$(BUILTIN_KDE): BUILTIN_%.o: %.cpp
# $(CC) $(CFLAGS) -DBUILTIN -I/usr/include/kde -I/usr/include/qt -c -o $@ $<
#$(BUILTIN_KDE_MOC): BUILTIN_%.o: dep/%.dpp
#$(BUILTIN_KDE_MOC): BUILTIN_%.o: %.cpp
# $(CC) $(CFLAGS) -DBUILTIN -I/usr/include/kde -I/usr/include/qt -c -o $@ $<
#$(BUILTIN_KDE_MOC: %.moc.o=%.cpp): %.moc.cpp: %.h
# $(MOC) $< -o $@
#
# Real targets
#
../../lib/kde.so: $(PLUGIN_KDE) $(PLUGIN_KDE_MOC)
$(CC) $(PCFLAGS) -o $@ $^ $(PLCFLAGS) $(LIB_KDE) -lkfile
#../../lib/kde.a: $(BUILTIN_KDE)
# ar r $@ $^
# $(RANLIB) $@
/***************************************************************************
intf_plugin.h - description
-------------------
begin : Mon Apr 9 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#ifndef _INTF_PLUGIN_H_
#define _INTF_PLUGIN_H_
extern "C"
{
#include "modules_inner.h"
#include "defs.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "tests.h"
#include "modules.h"
#include "stream_control.h"
#include "input_ext-intf.h"
#include "intf_msg.h"
#include "intf_playlist.h"
#include "interface.h"
#include "main.h"
}
#endif /* _INTF_PLUGIN_H_ */
\ No newline at end of file
/***************************************************************************
kde.cpp - description
-------------------
begin : Sun Mar 25 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#define MODULE_NAME kde
#include "intf_plugin.h"
extern "C"
{
/*****************************************************************************
* Build configuration tree.
*****************************************************************************/
MODULE_CONFIG_START
ADD_WINDOW( "Configuration for KDE module" )
ADD_COMMENT( "Ha, ha -- nothing to configure yet" )
MODULE_CONFIG_END
/*****************************************************************************
* Capabilities defined in the other files.
*****************************************************************************/
void _M( intf_getfunctions )( function_list_t * p_function_list );
/*****************************************************************************
* InitModule: get the module structure and configuration.
*****************************************************************************
* We have to fill psz_name, psz_longname and psz_version. These variables
* will be strdup()ed later by the main application because the module can
* be unloaded later to save memory, and we want to be able to access this
* data even after the module has been unloaded.
*****************************************************************************/
MODULE_INIT
{
p_module->psz_name = MODULE_STRING;
p_module->psz_longname = "KDE interface module";
p_module->psz_version = VERSION;
p_module->i_capabilities = MODULE_CAPABILITY_NULL
| MODULE_CAPABILITY_INTF;
return( 0 );
}
/*****************************************************************************
* ActivateModule: set the module to an usable state.
*****************************************************************************
* This function fills the capability functions and the configuration
* structure. Once ActivateModule() has been called, the i_usage can
* be set to 0 and calls to NeedModule() be made to increment it. To unload
* the module, one has to wait until i_usage == 0 and call DeactivateModule().
*****************************************************************************/
MODULE_ACTIVATE
{
p_module->p_functions =
( module_functions_t * )malloc( sizeof( module_functions_t ) );
if( p_module->p_functions == NULL )
{
return( -1 );
}
_M( intf_getfunctions )( &p_module->p_functions->intf );
p_module->p_config = p_config;
return( 0 );
}
/*****************************************************************************
* DeactivateModule: make sure the module can be unloaded.
*****************************************************************************
* This function must only be called when i_usage == 0. If it successfully
* returns, i_usage can be set to -1 and the module unloaded. Be careful to
* lock usage_lock during the whole process.
*****************************************************************************/
MODULE_DEACTIVATE
{
free( p_module->p_functions );
return( 0 );
}
} /* extern "C" */
/***************************************************************************
kdeinterface.cpp - description
-------------------
begin : Sun Mar 25 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#define MODULE_NAME kde
#include "intf_plugin.h"
#include "kdeinterface.h"
#include "kinterfacemain.h"
#include <iostream>
#include <kaction.h>
#include <kapp.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <klocale.h>
#include <kmainwindow.h>
#include <kstdaction.h>
#include <qwidget.h>
/*****************************************************************************
* Functions exported as capabilities.
*****************************************************************************/
extern "C"
{
void _M( intf_getfunctions )( function_list_t * p_function_list )
{
p_function_list->pf_probe = KDEInterface::probe;
p_function_list->functions.intf.pf_open = KDEInterface::open;
p_function_list->functions.intf.pf_close = KDEInterface::close;
p_function_list->functions.intf.pf_run = KDEInterface::run;
}
}
/*****************************************************************************
* KDEInterface::KDEInterface: KDE interface constructor
*****************************************************************************/
KDEInterface::KDEInterface(intf_thread_t *p_intf)
{
fAboutData = new KAboutData("VideoLAN Client", I18N_NOOP("Kvlc"),
VERSION,
"This is the VideoLAN client, a DVD and MPEG player. It can play MPEG and MPEG 2 files from a file or from a network source.", KAboutData::License_GPL,
"(C) 1996, 1997, 1998, 1999, 2000, 2001 - the VideoLAN Team", 0, 0, "dae@chez.com");
char *authors[][2] = {
{ "Rgis Duchesne", "<regis@via.ecp.fr>" },
{ "Michel Lespinasse", "<walken@zoy.org>" },
{ "Olivier Pomel", "<pomel@via.ecp.fr>" },
{ "Pierre Baillet", "<oct@zoy.org>" },
{ "Jean-Philippe Grimaldi", "<jeanphi@via.ecp.fr>" },
{ "Andres Krapf", "<dae@via.ecp.fr>" },
{ "Christophe Massiot", "<massiot@via.ecp.fr>" },
{ "Vincent Seguin", "<seguin@via.ecp.fr>" },
{ "Benoit Steiner", "<benny@via.ecp.fr>" },
{ "Arnaud de Bossoreille de Ribou", "<bozo@via.ecp.fr>" },
{ "Jean-Marc Dressler", "<polux@via.ecp.fr>" },
{ "Gal Hendryckx", "<jimmy@via.ecp.fr>" },
{ "Samuel Hocevar","<sam@zoy.org>" },
{ "Brieuc Jeunhomme", "<bbp@via.ecp.fr>" },
{ "Michel Kaempf", "<maxx@via.ecp.fr>" },
{ "Stphane Borel", "<stef@via.ecp.fr>" },
{ "Renaud Dartus", "<reno@via.ecp.fr>" },
{ "Henri Fallon", "<henri@via.ecp.fr>" },
{ NULL, NULL },
};
for ( int i = 0; NULL != authors[i][0]; i++ ) {
fAboutData->addAuthor( authors[i][0], 0, authors[i][1] );
}
int argc = 1;
char *argv[] = { "" };
KCmdLineArgs::init( argc, argv, fAboutData );
fApplication = new KApplication();
fWindow = new KInterfaceMain(p_intf);
fWindow->setCaption( VOUT_TITLE " (KDE interface)" );
}
/*****************************************************************************
* KDEInterface::~KDEInterface: KDE interface destructor
*****************************************************************************/
KDEInterface::~KDEInterface()
{
cerr << "entering ~KDEInterface()\n";
// delete ( fApplication );
cerr << "leaving ~KDEInterface()\n";
}
/*****************************************************************************
* KDEInterface::probe: probe the interface and return a score
*****************************************************************************
* This function tries to initialize KDE and returns a score to the
* plugin manager so that it can select the best plugin.
*****************************************************************************/
int KDEInterface::probe(probedata_t *p_data )
{
if ( TestMethod( INTF_METHOD_VAR, "kde" ) )
{
return ( 999 );
}
if ( TestProgram( "kvlc" ) )
{
return ( 180 );
}
return ( 80 );
}
/*****************************************************************************
* KDEInterface::open: initialize and create window
*****************************************************************************/
int KDEInterface::open(intf_thread_t *p_intf)
{
p_intf->p_sys = (intf_sys_s*) new KDEInterface(p_intf); // XXX static_cast ?
return ( 0 );
}
/*****************************************************************************
* KDEInterface::close: destroy interface window
*****************************************************************************/
void KDEInterface::close(intf_thread_t *p_intf)
{
// delete ( ( KDEInterface* ) p_intf->p_sys );
}
/*****************************************************************************
* KDEInterface::run: KDE thread
*****************************************************************************
* This part of the interface is in a separate thread so that we can call
* exec() from within it without annoying the rest of the program.
*****************************************************************************/
void KDEInterface::run(intf_thread_t *p_intf)
{
// XXX static_cast ?
KDEInterface *kdeInterface = (KDEInterface*) p_intf->p_sys;
kdeInterface->fWindow->show();
kdeInterface->fApplication->exec();
}
/***************************************************************************
kdeinterface.h - description
-------------------
begin : Sun Mar 25 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#ifndef _KDEINTERFACE_H_
#define _KDEINTERFACE_H_
class KApplication;
class KInterfaceMain;
class KAboutData;
class KDEInterface
{
private:
KDEInterface ( KDEInterface &kdeInterface ) {};
KDEInterface &operator= ( KDEInterface &kdeInterface ) { return ( *this ); };
public:
KDEInterface(intf_thread_t *p_intf);
~KDEInterface();
// These methods get exported to the core
static int probe ( probedata_t *p_data );
static int open ( intf_thread_t *p_intf );
static void close ( intf_thread_t *p_intf );
static void run ( intf_thread_t *p_intf );
private:
KApplication *fApplication;
KInterfaceMain *fWindow;
KAboutData *fAboutData;
};
#endif /* _KDEINTERFACE_H_ */
/***************************************************************************
kdiskdialog.cpp - description
-------------------
begin : Sat Apr 7 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#include "kdiskdialog.h"
#include <qhbox.h>
#include <qlabel.h>
#include <qradiobutton.h>
#include <qspinbox.h>
#include <qstring.h>
#include <qvbox.h>
#include <qvbuttongroup.h>
#include <qvgroupbox.h>
#include <qwidget.h>
#include <kdialogbase.h>
#include <klineedit.h>
KDiskDialog::KDiskDialog( QWidget *parent, const char *name ) :
KDialogBase( parent, name, true, QString::null, Ok|Cancel, Ok, true )
{
QVBox *pageVBox = makeVBoxMainWidget();
QHBox *deviceSelectHBox = new QHBox( pageVBox );
deviceSelectHBox->setSpacing( 5 );
fButtonGroup = new QVButtonGroup( "Disk type", deviceSelectHBox );
fDVDButton = new QRadioButton( "DVD", fButtonGroup);
fDVDButton->setChecked( true );
fVCDButton = new QRadioButton( "VCD", fButtonGroup);
fVCDButton->setEnabled( false );
QVGroupBox *startVBox = new QVGroupBox( "Starting position", deviceSelectHBox );
QHBox *titleHBox = new QHBox( startVBox );
QLabel *titleLabel = new QLabel( "Title ", titleHBox );
fTitle = new QSpinBox( titleHBox );
QHBox *chapterHBox = new QHBox( startVBox );
QLabel *chapterLabel = new QLabel( "Chapter ", chapterHBox );
fChapter = new QSpinBox( chapterHBox );
QHBox *deviceNameHBox = new QHBox( pageVBox );
QLabel *deviceNameLabel = new QLabel( "Device name ", deviceNameHBox );
fLineEdit = new KLineEdit( "/dev/dvd", deviceNameHBox );
}
KDiskDialog::~KDiskDialog()
{
}
QString KDiskDialog::type() const
{
if ( fDVDButton->isChecked() )
{
return ( QString("dvd") );
}
else
{
return ( QString("vcd") );
}
}
QString KDiskDialog::device() const
{
return ( fLineEdit->text() );
}
int KDiskDialog::title() const
{
return ( fTitle->value() );
}
int KDiskDialog::chapter() const
{
return ( fChapter->value() );
}
\ No newline at end of file
/***************************************************************************
kdiskdialog.h - description
-------------------
begin : Sat Apr 7 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#ifndef KDISKDIALOG_H
#define KDISKDIALOG_H
#include <kdialogbase.h>
#include <qstring.h>
class QVButtonGroup;
class QRadioButton;
class QSpinBox;
class KLineEdit;
/**
*@author andres
*/
class KDiskDialog : public KDialogBase {
Q_OBJECT
public:
KDiskDialog( QWidget *parent=0, const char *name=0 );
~KDiskDialog();
QString type() const;
QString device() const;
int title() const;
int chapter() const;
private:
QVButtonGroup *fButtonGroup;
QRadioButton *fDVDButton;
QRadioButton *fVCDButton;
QSpinBox *fTitle;
QSpinBox *fChapter;
KLineEdit *fLineEdit;
};
#endif
/***************************************************************************
kinterfacemain.cpp - description
-------------------
begin : Sun Mar 25 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#include "kdiskdialog.h"
#include "kinterfacemain.h"
#include "knetdialog.h"
#include "ktitlemenu.h"
#include "kvlcslider.h"
#include <iostream>
#include <kaction.h>
#include <kfiledialog.h>
#include <klocale.h>
#include <kstdaction.h>
#include <kurl.h>
#include <kurldrag.h>
#include <qcursor.h>
#include <qdragobject.h>
#include <qtimer.h>
#define ID_STATUS_MSG 1
#define ID_DATE 2
#define ID_STREAM_SOURCE 3
KInterfaceMain::KInterfaceMain( intf_thread_t *p_intf, QWidget *parent,
const char *name ) : KMainWindow(parent,name)
{
setAcceptDrops(true);
fInterfaceThread = p_intf;
fDiskDialog = new KDiskDialog( this );
fNetDialog = new KNetDialog( this );
fTitleMenu = new KTitleMenu( fInterfaceThread, this );
fSlider = new KVLCSlider( QSlider::Horizontal, this );
connect( fSlider, SIGNAL( userChanged( int ) ), this, SLOT( slotSliderMoved( int ) ) );
connect( fSlider, SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderChanged( int ) ) );
setCentralWidget(fSlider);
fTimer = new QTimer( this );
connect( fTimer, SIGNAL( timeout() ), this, SLOT( slotManage() ) );
fTimer->start( 100 );
resize( 400, 30 );
///////////////////////////////////////////////////////////////////
// call inits to invoke all other construction parts
// XXX could we move this up ?
initStatusBar();
initActions();
// add certain calls to the popup menu
fileOpen->plug( fTitleMenu );
fileOpenRecent->plug( fTitleMenu );
diskOpen->plug( fTitleMenu );
streamOpen->plug( fTitleMenu );
play->plug( fTitleMenu );
pause->plug( fTitleMenu );
slow->plug( fTitleMenu );
fast->plug( fTitleMenu );
fileClose->plug( fTitleMenu );
fileQuit->plug( fTitleMenu );
}
KInterfaceMain::~KInterfaceMain()
{
}
void KInterfaceMain::initActions()
{
fileOpen = KStdAction::open(this, SLOT(slotFileOpen()), actionCollection());
fileOpenRecent = KStdAction::openRecent(this, SLOT(slotFileOpenRecent(const KURL&)), actionCollection());
fileClose = KStdAction::close(this, SLOT(slotFileClose()), actionCollection());
fileQuit = KStdAction::quit(this, SLOT(slotFileQuit()), actionCollection());
viewToolBar = KStdAction::showToolbar(this, SLOT(slotViewToolBar()), actionCollection());
viewStatusBar = KStdAction::showStatusbar(this, SLOT(slotViewStatusBar()), actionCollection());
diskOpen = new KAction( i18n( "Open &Disk" ), 0, 0, this, SLOT( slotOpenDisk() ), actionCollection(), "open_disk" );
streamOpen = new KAction( i18n( "Open &Stream" ), 0, 0, this, SLOT( slotOpenStream() ), actionCollection(), "open_stream" );
play = new KAction( i18n( "&Play" ), 0, 0, this, SLOT( slotPlay() ), actionCollection(), "play" );
pause = new KAction( i18n( "P&ause" ), 0, 0, this, SLOT( slotPause() ), actionCollection(), "pause" );
stop = new KAction( i18n( "&Stop" ), 0, 0, this, SLOT( slotStop() ), actionCollection(), "stop" );
backward = new KAction( i18n( "&Backward" ), 0, 0, this, SLOT( slotBackward() ), actionCollection(), "backward" );
forward = new KAction( i18n( "&Forward" ), 0, 0, this, SLOT( slotForward() ), actionCollection(), "forward" );
slow = new KAction( i18n( "&Slow" ), 0, 0, this, SLOT( slotSlow() ), actionCollection(), "slow" );
fast = new KAction( i18n( "Fas&t" ), 0, 0, this, SLOT( slotFast() ), actionCollection(), "fast" );
fileOpen->setStatusText(i18n("Opens an existing document"));
fileOpenRecent->setStatusText(i18n("Opens a recently used file"));
fileClose->setStatusText(i18n("Closes the actual document"));
fileQuit->setStatusText(i18n("Quits the application"));
viewToolBar->setStatusText(i18n("Enables/disables the toolbar"));
viewStatusBar->setStatusText(i18n("Enables/disables the statusbar"));
diskOpen->setStatusText( i18n( "Opens a disk") );
streamOpen->setStatusText( i18n( "Opens a network stream" ) );
play->setStatusText( i18n( "Starts playback" ) );
pause->setStatusText( i18n( "Pauses playback" ) );
stop->setStatusText( i18n( "Stops playback" ) );
backward->setStatusText( i18n( "Backward" ) );
forward->setStatusText( i18n( "Forward" ) );
slow->setStatusText( i18n( "Slow" ) );
fast->setStatusText( i18n( "Fast" ) );
// use the absolute path to your ktestui.rc file for testing purpose in createGUI();
createGUI("plugins/kde/kvlcui.rc");
}
void KInterfaceMain::initStatusBar()
{
///////////////////////////////////////////////////////////////////
// STATUSBAR
// TODO: add your own items you need for displaying current application status.
statusBar()->insertItem(i18n("Ready."), ID_STATUS_MSG, 1, false);
statusBar()->setItemAlignment( ID_STATUS_MSG, AlignLeft | AlignVCenter );
statusBar()->insertItem( "0:00:00", ID_DATE, 0, true );
}
/////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATION
/////////////////////////////////////////////////////////////////////
void KInterfaceMain::slotFileOpen()
{
slotStatusMsg( i18n( "Opening file..." ) );
KURL url=KFileDialog::getOpenURL( QString::null,
i18n( "*|All files" ), this, i18n( "Open File..." ) );
if( !url.isEmpty() )
{
fileOpenRecent->addURL( url );