1 /*****************************************************************************
2 * beos_init.cpp: Initialization for BeOS specific features
3 *****************************************************************************
4 * Copyright (C) 1999-2001 VideoLAN
5 * $Id: beos_specific.cpp,v 1.23 2002/06/02 14:26:15 gbazin 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, 1 );
76 /*****************************************************************************
77 * system_Configure: check for system specific configuration options.
78 *****************************************************************************/
79 void system_Configure( vlc_t * )
84 /*****************************************************************************
85 * system_End: destroy the BApplication object.
86 *****************************************************************************/
87 void system_End( vlc_t *p_this )
89 /* Tell the BApplication to die */
90 be_app->PostMessage( B_QUIT_REQUESTED );
92 vlc_thread_join( p_this->p_vlc->p_appthread );
93 vlc_object_destroy( p_this->p_vlc->p_appthread );
95 free( psz_program_path );
98 /*****************************************************************************
99 * system_GetProgramPath: get the full path to the program.
100 *****************************************************************************/
101 char * system_GetProgramPath( void )
103 return( psz_program_path );
106 /* following functions are local */
108 /*****************************************************************************
109 * AppThread: the BApplication thread.
110 *****************************************************************************/
111 static void AppThread( vlc_object_t * p_this )
113 VlcApplication *BeApp = new VlcApplication("application/x-vnd.Ink-vlc");
114 vlc_object_attach( p_this, p_this->p_vlc );
115 BeApp->p_this = p_this;
117 vlc_object_detach_all( p_this );
123 /*****************************************************************************
124 * VlcApplication: application constructor
125 *****************************************************************************/
126 VlcApplication::VlcApplication( char * psz_mimetype )
127 :BApplication( psz_mimetype )
129 /* Nothing to do, we use the default constructor */
132 /*****************************************************************************
133 * ~VlcApplication: application destructor
134 *****************************************************************************/
135 VlcApplication::~VlcApplication( )
137 /* Nothing to do, we use the default destructor */
140 /*****************************************************************************
141 * AboutRequested: called by the system on B_ABOUT_REQUESTED
142 *****************************************************************************/
143 void VlcApplication::AboutRequested( )
146 alert = new BAlert( VOUT_TITLE,
147 "BeOS " VOUT_TITLE "\n\n<www.videolan.org>",
152 /*****************************************************************************
153 * ReadyToRun: called when the BApplication is initialized
154 *****************************************************************************/
155 void VlcApplication::ReadyToRun( )
160 /* Get the program path */
161 be_app->GetAppInfo( &info );
162 BEntry entry( &info.ref );
163 entry.GetPath( &path );
164 path.GetParent( &path );
165 psz_program_path = strdup( path.Path() );
167 /* Tell the main thread we are finished initializing the BApplication */
168 vlc_thread_ready( p_this );