X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmisc%2Fbeos_specific.cpp;h=7ddd9fd48d2266cdca8aec57492549efbf58fca1;hb=743502ebb1619cde44cb86b9fe6d9ac9867dc422;hp=e98dd891be09ced5f54a107f28d6caf7e0bb3499;hpb=f8570a695a92e33309f238df9eec1044651f63e6;p=vlc diff --git a/src/misc/beos_specific.cpp b/src/misc/beos_specific.cpp index e98dd891be..7ddd9fd48d 100644 --- a/src/misc/beos_specific.cpp +++ b/src/misc/beos_specific.cpp @@ -1,8 +1,8 @@ /***************************************************************************** - * beos_init.cpp: Initialization for BeOS specific features + * beos_init.cpp: Initialization for BeOS specific features ***************************************************************************** - * Copyright (C) 1999-2001 VideoLAN - * $Id: beos_specific.cpp,v 1.23 2002/06/02 14:26:15 gbazin Exp $ + * Copyright (C) 1999-2004 VideoLAN + * $Id: beos_specific.cpp,v 1.37 2004/01/25 17:16:06 zorglub Exp $ * * Authors: Jean-Marc Dressler * @@ -10,7 +10,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -24,9 +24,12 @@ #include #include #include +#include +#include + #include #include /* strdup() */ -#include /* free() */ +#include /* free() */ extern "C" { @@ -46,12 +49,22 @@ public: virtual void ReadyToRun(); virtual void AboutRequested(); + virtual void RefsReceived(BMessage* message); + virtual void MessageReceived(BMessage* message); + virtual bool QuitRequested(); + +private: + BWindow* fInterfaceWindow; + BMessage* fRefsMessage; + bool fReadyToQuit; }; /***************************************************************************** * Static vars *****************************************************************************/ -static char * psz_program_path; + +#include "../../modules/gui/beos/MsgVals.h" +#define REALLY_QUIT 'requ' extern "C" { @@ -66,19 +79,19 @@ static void AppThread( vlc_object_t *p_appthread ); *****************************************************************************/ void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] ) { - p_this->p_vlc->p_appthread = + p_this->p_libvlc->p_appthread = (vlc_object_t *)vlc_object_create( p_this, sizeof(vlc_object_t) ); /* Create the BApplication thread and wait for initialization */ - vlc_thread_create( p_this->p_vlc->p_appthread, "app thread", AppThread, 1 ); + vlc_thread_create( p_this->p_libvlc->p_appthread, "app thread", AppThread, + VLC_THREAD_PRIORITY_LOW, VLC_TRUE ); } /***************************************************************************** * system_Configure: check for system specific configuration options. *****************************************************************************/ -void system_Configure( vlc_t * ) +void system_Configure( vlc_t *, int *pi_argc, char *ppsz_argv[] ) { - } /***************************************************************************** @@ -87,20 +100,12 @@ void system_Configure( vlc_t * ) void system_End( vlc_t *p_this ) { /* Tell the BApplication to die */ - be_app->PostMessage( B_QUIT_REQUESTED ); + be_app->PostMessage( REALLY_QUIT ); - vlc_thread_join( p_this->p_vlc->p_appthread ); - vlc_object_destroy( p_this->p_vlc->p_appthread ); + vlc_thread_join( p_this->p_libvlc->p_appthread ); + vlc_object_destroy( p_this->p_libvlc->p_appthread ); - free( psz_program_path ); -} - -/***************************************************************************** - * system_GetProgramPath: get the full path to the program. - *****************************************************************************/ -char * system_GetProgramPath( void ) -{ - return( psz_program_path ); + free( p_this->p_libvlc->psz_vlcpath ); } /* following functions are local */ @@ -110,11 +115,12 @@ char * system_GetProgramPath( void ) *****************************************************************************/ static void AppThread( vlc_object_t * p_this ) { - VlcApplication *BeApp = new VlcApplication("application/x-vnd.Ink-vlc"); + VlcApplication * BeApp = + new VlcApplication("application/x-vnd.videolan-vlc"); vlc_object_attach( p_this, p_this->p_vlc ); BeApp->p_this = p_this; BeApp->Run(); - vlc_object_detach_all( p_this ); + vlc_object_detach( p_this ); delete BeApp; } @@ -124,7 +130,10 @@ static void AppThread( vlc_object_t * p_this ) * VlcApplication: application constructor *****************************************************************************/ VlcApplication::VlcApplication( char * psz_mimetype ) - :BApplication( psz_mimetype ) + :BApplication( psz_mimetype ), + fInterfaceWindow( NULL ), + fRefsMessage( NULL ), + fReadyToQuit( false ) { /* Nothing to do, we use the default constructor */ } @@ -135,6 +144,7 @@ VlcApplication::VlcApplication( char * psz_mimetype ) VlcApplication::~VlcApplication( ) { /* Nothing to do, we use the default destructor */ + delete fRefsMessage; } /***************************************************************************** @@ -143,9 +153,9 @@ VlcApplication::~VlcApplication( ) void VlcApplication::AboutRequested( ) { BAlert *alert; - alert = new BAlert( VOUT_TITLE, - "BeOS " VOUT_TITLE "\n\n", - "Ok" ); + alert = new BAlert( "VLC " PACKAGE_VERSION, + "VLC " PACKAGE_VERSION " for BeOS\n\n" + "", "OK"); alert->Go( NULL ); } @@ -155,15 +165,78 @@ void VlcApplication::AboutRequested( ) void VlcApplication::ReadyToRun( ) { BPath path; - app_info info; + app_info info; /* Get the program path */ - be_app->GetAppInfo( &info ); - BEntry entry( &info.ref ); - entry.GetPath( &path ); + be_app->GetAppInfo( &info ); + BEntry entry( &info.ref ); + entry.GetPath( &path ); path.GetParent( &path ); - psz_program_path = strdup( path.Path() ); + p_this->p_libvlc->psz_vlcpath = strdup( path.Path() ); /* Tell the main thread we are finished initializing the BApplication */ vlc_thread_ready( p_this ); } + +/***************************************************************************** + * RefsReceived: called when files are sent to our application + * (for example when the user drops fils onto our icon) + *****************************************************************************/ +void VlcApplication::RefsReceived(BMessage* message) +{ + if (fInterfaceWindow) + fInterfaceWindow->PostMessage(message); + else { + delete fRefsMessage; + fRefsMessage = new BMessage(*message); + } +} + +/***************************************************************************** + * MessageReceived: a BeOS applications main message loop + * Since VlcApplication and interface are separated + * in the vlc binary and the interface plugin, + * we use this method to "stick" them together. + * The interface will post a message to the global + * "be_app" pointer when the interface is created + * containing a pointer to the interface window. + * In this way, we can keep a B_REFS_RECEIVED message + * in store for the interface window to handle later. + *****************************************************************************/ +void VlcApplication::MessageReceived(BMessage* message) +{ + switch (message->what) { + case INTERFACE_CREATED: { + BWindow* interfaceWindow; + if (message->FindPointer("window", (void**)&interfaceWindow) == B_OK) { + fInterfaceWindow = interfaceWindow; + if (fRefsMessage) { + fInterfaceWindow->PostMessage(fRefsMessage); + delete fRefsMessage; + fRefsMessage = NULL; + } + } + break; + } + + case REALLY_QUIT: + fReadyToQuit = true; + PostMessage( B_QUIT_REQUESTED ); + break; + + default: + BApplication::MessageReceived(message); + } +} + +bool VlcApplication::QuitRequested() +{ + if( !fReadyToQuit ) + { + p_this->p_vlc->b_die = 1; + return false; + } + + BApplication::QuitRequested(); + return true; +}