1 /*****************************************************************************
2 * kde.cpp : KDE plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: kde.cpp,v 1.7 2002/02/24 20:51:10 gbazin Exp $
7 * Authors: Andres Krapf <dae@chez.com> Sun Mar 25 2001
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 #include "kde_common.h"
26 #include "kde_interface.h"
32 #include <kaboutdata.h>
33 #include <kcmdlineargs.h>
35 #include <kmainwindow.h>
36 #include <kstdaction.h>
39 /*****************************************************************************
40 * Capabilities defined in the other files.
41 *****************************************************************************/
42 static void intf_getfunctions( function_list_t * p_function_list );
44 /*****************************************************************************
45 * Build configuration tree.
46 *****************************************************************************/
54 SET_DESCRIPTION( "KDE interface module" )
55 ADD_CAPABILITY( INTF, 80 )
60 intf_getfunctions( &p_module->p_functions->intf );
63 MODULE_DEACTIVATE_START
64 MODULE_DEACTIVATE_STOP
68 /*****************************************************************************
70 *****************************************************************************/
77 KThread ( KThread &thread ) { };
78 KThread &operator= ( KThread &thread ) { return ( *this ); };
80 intf_thread_t *p_intf;
83 KThread(intf_thread_t *p_intf);
86 // These methods get exported to the core
87 static int probe ( probedata_t *p_data );
88 static int open ( intf_thread_t *p_intf );
89 static void close ( intf_thread_t *p_intf );
90 static void run ( intf_thread_t *p_intf );
93 /*****************************************************************************
94 * Functions exported as capabilities.
95 *****************************************************************************/
96 static void intf_getfunctions( function_list_t * p_function_list )
98 p_function_list->pf_probe = KThread::probe;
99 p_function_list->functions.intf.pf_open = KThread::open;
100 p_function_list->functions.intf.pf_close = KThread::close;
101 p_function_list->functions.intf.pf_run = KThread::run;
104 /*****************************************************************************
105 * KThread::KThread: KDE interface constructor
106 *****************************************************************************/
107 KThread::KThread(intf_thread_t *p_intf)
109 this->p_intf = p_intf;
111 p_intf->p_sys->p_about =
112 new KAboutData( "VideoLAN Client", I18N_NOOP("Kvlc"), VERSION,
113 "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,
114 "(C) 1996, 1997, 1998, 1999, 2000, 2001 - the VideoLAN Team", 0, 0, "dae@chez.com");
116 char *authors[][2] = {
117 { "Régis Duchesne", "<regis@via.ecp.fr>" },
118 { "Michel Lespinasse", "<walken@zoy.org>" },
119 { "Olivier Pomel", "<pomel@via.ecp.fr>" },
120 { "Pierre Baillet", "<oct@zoy.org>" },
121 { "Jean-Philippe Grimaldi", "<jeanphi@via.ecp.fr>" },
122 { "Andres Krapf", "<dae@via.ecp.fr>" },
123 { "Christophe Massiot", "<massiot@via.ecp.fr>" },
124 { "Vincent Seguin", "<seguin@via.ecp.fr>" },
125 { "Benoit Steiner", "<benny@via.ecp.fr>" },
126 { "Arnaud de Bossoreille de Ribou", "<bozo@via.ecp.fr>" },
127 { "Jean-Marc Dressler", "<polux@via.ecp.fr>" },
128 { "Gaël Hendryckx", "<jimmy@via.ecp.fr>" },
129 { "Samuel Hocevar","<sam@zoy.org>" },
130 { "Brieuc Jeunhomme", "<bbp@via.ecp.fr>" },
131 { "Michel Kaempf", "<maxx@via.ecp.fr>" },
132 { "Stéphane Borel", "<stef@via.ecp.fr>" },
133 { "Renaud Dartus", "<reno@via.ecp.fr>" },
134 { "Henri Fallon", "<henri@via.ecp.fr>" },
138 for ( int i = 0; NULL != authors[i][0]; i++ ) {
139 p_intf->p_sys->p_about->addAuthor( authors[i][0], 0, authors[i][1] );
143 char *argv[] = { p_main->psz_arg0, NULL };
144 KCmdLineArgs::init( argc, argv, p_intf->p_sys->p_about );
146 p_intf->p_sys->p_app = new KApplication();
147 p_intf->p_sys->p_window = new KInterface(p_intf);
148 p_intf->p_sys->p_window->setCaption( VOUT_TITLE " (KDE interface)" );
151 /*****************************************************************************
152 * KThread::~KThread: KDE interface destructor
153 *****************************************************************************/
156 /* XXX: can be deleted if the user closed the window ! */
157 //delete p_intf->p_sys->p_window;
159 delete p_intf->p_sys->p_app;
160 delete p_intf->p_sys->p_about;
163 /*****************************************************************************
164 * KThread::probe: probe the interface and return a score
165 *****************************************************************************
166 * This function tries to initialize KDE and returns a score to the
167 * plugin manager so that it can select the best plugin.
168 *****************************************************************************/
169 int KThread::probe(probedata_t *p_data )
174 /*****************************************************************************
175 * KThread::open: initialize and create window
176 *****************************************************************************/
177 int KThread::open(intf_thread_t *p_intf)
179 /* Allocate instance and initialize some members */
180 p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) );
181 if( p_intf->p_sys == NULL )
183 intf_ErrMsg( "intf error: %s", strerror(ENOMEM) );
187 p_intf->p_sys->p_thread = new KThread(p_intf);
191 /*****************************************************************************
192 * KThread::close: destroy interface window
193 *****************************************************************************/
194 void KThread::close(intf_thread_t *p_intf)
196 delete p_intf->p_sys->p_thread;
197 free( p_intf->p_sys );
200 /*****************************************************************************
201 * KThread::run: KDE thread
202 *****************************************************************************
203 * This part of the interface is in a separate thread so that we can call
204 * exec() from within it without annoying the rest of the program.
205 *****************************************************************************/
206 void KThread::run(intf_thread_t *p_intf)
208 p_intf->p_sys->p_window->show();
209 p_intf->p_sys->p_app->exec();