* beos_init.cpp: Initialization for BeOS specific features
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: beos_specific.cpp,v 1.25 2002/08/29 23:53:22 massiot Exp $
+ * $Id: beos_specific.cpp,v 1.26 2002/09/30 18:30:28 titer Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
*
#include <Roster.h>
#include <Path.h>
#include <Alert.h>
+#include <Message.h>
+#include <Window.h>
+
#include <stdio.h>
#include <string.h> /* strdup() */
#include <malloc.h> /* free() */
virtual void ReadyToRun();
virtual void AboutRequested();
+ virtual void RefsReceived(BMessage* message);
+ virtual void MessageReceived(BMessage* message);
+
+private:
+ BWindow* fInterfaceWindow;
+ BMessage* fRefsMessage;
};
/*****************************************************************************
*****************************************************************************/
static char * psz_program_path;
+//const uint32 INTERFACE_CREATED = 'ifcr'; /* message sent from interface */
+#include "../../modules/gui/beos/MsgVals.h"
+
extern "C"
{
* VlcApplication: application constructor
*****************************************************************************/
VlcApplication::VlcApplication( char * psz_mimetype )
- :BApplication( psz_mimetype )
+ :BApplication( psz_mimetype ),
+ fInterfaceWindow( NULL ),
+ fRefsMessage( NULL )
{
/* Nothing to do, we use the default constructor */
}
VlcApplication::~VlcApplication( )
{
/* Nothing to do, we use the default destructor */
+ delete fRefsMessage;
}
/*****************************************************************************
/* 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;
+ }
+ default:
+ BApplication::MessageReceived(message);
+ }
+}