1 /*****************************************************************************
2 * beos_init.cpp: Initialization for BeOS specific features
3 *****************************************************************************
4 * Copyright (C) 1999-2001 VideoLAN
5 * $Id: beos_specific.cpp,v 1.25 2002/08/29 23:53:22 massiot Exp $
7 * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
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 *****************************************************************************/
23 #include <Application.h>
28 #include <string.h> /* strdup() */
29 #include <malloc.h> /* free() */
36 /*****************************************************************************
37 * The VlcApplication class
38 *****************************************************************************/
39 class VlcApplication : public BApplication
44 VlcApplication(char* );
47 virtual void ReadyToRun();
48 virtual void AboutRequested();
51 /*****************************************************************************
53 *****************************************************************************/
54 static char * psz_program_path;
59 /*****************************************************************************
61 *****************************************************************************/
62 static void AppThread( vlc_object_t *p_appthread );
64 /*****************************************************************************
65 * system_Init: create a BApplication object and fill in program path.
66 *****************************************************************************/
67 void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
69 p_this->p_vlc->p_appthread =
70 (vlc_object_t *)vlc_object_create( p_this, sizeof(vlc_object_t) );
72 /* Create the BApplication thread and wait for initialization */
73 vlc_thread_create( p_this->p_vlc->p_appthread, "app thread", AppThread,
74 VLC_THREAD_PRIORITY_LOW, VLC_TRUE );
77 /*****************************************************************************
78 * system_Configure: check for system specific configuration options.
79 *****************************************************************************/
80 void system_Configure( vlc_t * )
85 /*****************************************************************************
86 * system_End: destroy the BApplication object.
87 *****************************************************************************/
88 void system_End( vlc_t *p_this )
90 /* Tell the BApplication to die */
91 be_app->PostMessage( B_QUIT_REQUESTED );
93 vlc_thread_join( p_this->p_vlc->p_appthread );
94 vlc_object_destroy( p_this->p_vlc->p_appthread );
96 free( psz_program_path );
99 /*****************************************************************************
100 * system_GetProgramPath: get the full path to the program.
101 *****************************************************************************/
102 char * system_GetProgramPath( void )
104 return( psz_program_path );
107 /* following functions are local */
109 /*****************************************************************************
110 * AppThread: the BApplication thread.
111 *****************************************************************************/
112 static void AppThread( vlc_object_t * p_this )
114 VlcApplication *BeApp = new VlcApplication("application/x-vnd.Ink-vlc");
115 vlc_object_attach( p_this, p_this->p_vlc );
116 BeApp->p_this = p_this;
118 vlc_object_detach( p_this );
124 /*****************************************************************************
125 * VlcApplication: application constructor
126 *****************************************************************************/
127 VlcApplication::VlcApplication( char * psz_mimetype )
128 :BApplication( psz_mimetype )
130 /* Nothing to do, we use the default constructor */
133 /*****************************************************************************
134 * ~VlcApplication: application destructor
135 *****************************************************************************/
136 VlcApplication::~VlcApplication( )
138 /* Nothing to do, we use the default destructor */
141 /*****************************************************************************
142 * AboutRequested: called by the system on B_ABOUT_REQUESTED
143 *****************************************************************************/
144 void VlcApplication::AboutRequested( )
147 alert = new BAlert( VOUT_TITLE,
148 "BeOS " VOUT_TITLE "\n\n<www.videolan.org>",
153 /*****************************************************************************
154 * ReadyToRun: called when the BApplication is initialized
155 *****************************************************************************/
156 void VlcApplication::ReadyToRun( )
161 /* Get the program path */
162 be_app->GetAppInfo( &info );
163 BEntry entry( &info.ref );
164 entry.GetPath( &path );
165 path.GetParent( &path );
166 psz_program_path = strdup( path.Path() );
168 /* Tell the main thread we are finished initializing the BApplication */
169 vlc_thread_ready( p_this );