]> git.sesse.net Git - vlc/blobdiff - src/misc/beos_specific.cpp
Attempt to port new BeOS features from the stable branch.
[vlc] / src / misc / beos_specific.cpp
index 72ef7c7226ee3b9f1b03a2edfe7a8785706d3570..21a2d5c0381b51268d620fa3d028e3f96b3f39a0 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
  *
@@ -24,6 +24,9 @@
 #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() */
@@ -46,6 +49,12 @@ public:
 
     virtual void ReadyToRun();
     virtual void AboutRequested();
+    virtual void RefsReceived(BMessage* message);
+    virtual void MessageReceived(BMessage* message);
+    
+private:
+    BWindow*     fInterfaceWindow;
+    BMessage*    fRefsMessage;
 };
 
 /*****************************************************************************
@@ -53,6 +62,9 @@ public:
  *****************************************************************************/
 static char *         psz_program_path;
 
+//const uint32 INTERFACE_CREATED = 'ifcr';  /* message sent from interface */
+#include "../../modules/gui/beos/MsgVals.h"
+
 extern "C"
 {
 
@@ -125,7 +137,9 @@ 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 )
 {
     /* Nothing to do, we use the default constructor */
 }
@@ -136,6 +150,7 @@ VlcApplication::VlcApplication( char * psz_mimetype )
 VlcApplication::~VlcApplication( )
 {
     /* Nothing to do, we use the default destructor */
+    delete fRefsMessage;
 }
 
 /*****************************************************************************
@@ -168,3 +183,48 @@ void VlcApplication::ReadyToRun( )
     /* 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);
+       }
+}