]> git.sesse.net Git - vlc/blob - src/misc/beos_specific.cpp
9fcebb6d0836ad08600022d7b09d7d7aff3c1db9
[vlc] / src / misc / beos_specific.cpp
1 /*****************************************************************************
2  * beos_init.cpp: Initialization for BeOS specific features 
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  *
6  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  * 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
21  *****************************************************************************/
22 #include "defs.h"
23
24 #include <Application.h>
25 #include <Roster.h>
26 #include <Path.h>
27 #include <stdio.h>
28 #include <malloc.h>
29
30 extern "C"
31 {
32 #include "common.h"
33 #include "threads.h"
34 #include "mtime.h"
35 }
36 #include "beos_specific.h"
37
38
39
40 /*****************************************************************************
41  * Static vars
42  *****************************************************************************/
43 static vlc_thread_t beos_app_thread;
44 static char * psz_beos_program_path;
45
46
47 extern "C"
48 {
49
50 void beos_AppThread( void * args )
51 {
52     BApplication * BeApp = new BApplication("application/x-VLC");
53     BeApp->Run();
54     delete BeApp;
55 }
56
57 void beos_Create( void )
58 {
59     int i_lenght;
60     BPath path;
61     app_info info; 
62     
63     vlc_thread_create( &beos_app_thread, "app thread", (vlc_thread_func_t)beos_AppThread, 0 );
64     msleep( 100000 );
65     // FIXME: we need to verify that be_app is initialized and the msleep is not enough
66     //        but the following code does not work as it should and I have no good
67     //        solution at the moment.
68     //while( be_app == NULL )
69     //    msleep( 5000 );
70     
71     be_app->GetAppInfo(&info); 
72     BEntry entry(&info.ref); 
73     entry.GetPath(&path); 
74     path.GetParent(&path);
75     i_lenght = strlen( path.Path() );
76     psz_beos_program_path = (char*) malloc( i_lenght+1 ); /* XXX */
77     strcpy( psz_beos_program_path, path.Path() );
78 }
79
80 void beos_Destroy( void )
81 {
82     free( psz_beos_program_path ); /* XXX */
83     be_app->PostMessage( B_QUIT_REQUESTED );
84     vlc_thread_join( beos_app_thread );
85 }
86
87 char * beos_GetProgramPath( void )
88 {
89     return( psz_beos_program_path );
90 }
91
92 } /* extern "C" */