]> git.sesse.net Git - vlc/blobdiff - plugins/beos/intf_beos.cpp
* Ported Glide and MGA plugins to the new module API. MGA never worked,
[vlc] / plugins / beos / intf_beos.cpp
index 711841019067505c7f7c00578388a8718b890d64..1ff3d8b466e5d03441f578d11df6fb11c47952bd 100644 (file)
@@ -1,10 +1,11 @@
 /*****************************************************************************
  * intf_beos.cpp: beos interface
  *****************************************************************************
- * Copyright (C) 1999, 2000 VideoLAN
+ * Copyright (C) 1999, 2000, 2001 VideoLAN
+ * $Id: intf_beos.cpp,v 1.10 2001/02/20 07:49:12 sam Exp $
  *
- * Authors:
- * Jean-Marc Dressler
+ * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
+ *          Samuel Hocevar <sam@zoy.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,6 +22,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME beos
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
 
 #include <stdio.h>
 #include <stdlib.h>                                      /* malloc(), free() */
-#include <sys/types.h>                        /* on BSD, uio.h needs types.h */
-#include <sys/uio.h>                                            /* "input.h" */
+
 #include <kernel/OS.h>
+#include <storage/Path.h>
 #include <View.h>
 #include <Application.h>
 #include <Message.h>
+#include <NodeInfo.h>
 #include <Locker.h>
 #include <DirectWindow.h>
+
 #include <malloc.h>
 #include <string.h>
 
@@ -45,13 +51,11 @@ extern "C"
 #include "common.h"
 #include "threads.h"
 #include "mtime.h"
-#include "plugins.h"
-
-#include "input.h"
-#include "video.h"
-#include "video_output.h"
+#include "tests.h"
+#include "modules.h"
 
 #include "intf_msg.h"
+#include "intf_plst.h"
 #include "interface.h"
 
 #include "main.h"
@@ -72,10 +76,10 @@ typedef struct intf_sys_s
  * InterfaceWindow
  *****************************************************************************/
  
-InterfaceWindow::InterfaceWindow( BRect frame, const char *name , intf_thread_t  *p_intf )
-    : BWindow(frame, name, B_TITLED_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
+InterfaceWindow::InterfaceWindow( BRect frame, const char *name , intf_thread_t  *p_interface )
+    : BWindow(frame, name, B_TITLED_WINDOW, B_NOT_ZOOMABLE)
 {
-    p_interface = p_intf;
+    p_intf = p_interface;
     SetName( "interface" );
     
     BView * p_view;
@@ -102,9 +106,24 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
     {
     case B_KEY_DOWN:
         p_message->FindString( "bytes", (const char **)&psz_key );
-        p_interface->p_sys->i_key = psz_key[0];
+        p_intf->p_sys->i_key = psz_key[0];
         break;
         
+    case B_SIMPLE_DATA:
+        {
+            entry_ref ref;
+            if( p_message->FindRef( "refs", &ref ) == B_OK )
+            {
+                BPath path( &ref );
+                char * psz_name = strdup(path.Path());
+                intf_WarnMsg( 1, "intf: dropped text/uri-list data `%s'",
+                              psz_name );
+                intf_PlstAdd( p_main->p_playlist, PLAYLIST_END, psz_name );
+            }
+
+        }
+        break;
+
     default:
         BWindow::MessageReceived( p_message );
         break;
@@ -117,67 +136,86 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
 
 bool InterfaceWindow::QuitRequested()
 {
+    p_intf->b_die = 1;
+
     return( false );
 }
 
-
 extern "C"
 {
 
 /*****************************************************************************
- * intf_BeCreate: initialize dummy interface
+ * Local prototypes.
  *****************************************************************************/
-int intf_BeCreate( intf_thread_t *p_intf )
+static int  intf_Probe     ( probedata_t *p_data );
+static int  intf_Open      ( intf_thread_t *p_intf );
+static void intf_Close     ( intf_thread_t *p_intf );
+static void intf_Run       ( intf_thread_t *p_intf );
+
+/*****************************************************************************
+ * Functions exported as capabilities. They are declared as static so that
+ * we don't pollute the namespace too much.
+ *****************************************************************************/
+void _M( intf_getfunctions )( function_list_t * p_function_list )
+{
+    p_function_list->pf_probe = intf_Probe;
+    p_function_list->functions.intf.pf_open  = intf_Open;
+    p_function_list->functions.intf.pf_close = intf_Close;
+    p_function_list->functions.intf.pf_run   = intf_Run;
+}
+
+/*****************************************************************************
+ * intf_Probe: probe the interface and return a score
+ *****************************************************************************
+ * This function tries to initialize Gnome and returns a score to the
+ * plugin manager so that it can select the best plugin.
+ *****************************************************************************/
+static int intf_Probe( probedata_t *p_data )
+{
+    if( TestMethod( INTF_METHOD_VAR, "beos" ) )
+    {
+        return( 999 );
+    }
+
+    return( 100 );
+}
+
+/*****************************************************************************
+ * intf_Open: initialize dummy interface
+ *****************************************************************************/
+static int intf_Open( intf_thread_t *p_intf )
 {
     /* Allocate instance and initialize some members */
     p_intf->p_sys = (intf_sys_t*) malloc( sizeof( intf_sys_t ) );
     if( p_intf->p_sys == NULL )
     {
-        intf_ErrMsg("error: %s\n", strerror(ENOMEM));
+        intf_ErrMsg("error: %s", strerror(ENOMEM));
         return( 1 );
     }
     p_intf->p_sys->i_key = -1;
     
     /* Create the interface window */
     p_intf->p_sys->p_window =
-        new InterfaceWindow( BRect( 100, 100, 200, 200 ), "Interface :)", p_intf );
+        new InterfaceWindow( BRect( 50, 50, 400, 100 ),
+                             VOUT_TITLE " (BeOS interface)", p_intf );
     if( p_intf->p_sys->p_window == 0 )
     {
         free( p_intf->p_sys );
-        intf_ErrMsg( "error: cannot allocate memory for InterfaceWindow\n" );
+        intf_ErrMsg( "error: cannot allocate memory for InterfaceWindow" );
         return( 1 );
     }
     
-    /* Spawn video output thread */
-    if( p_main->b_video )
-    {
-        p_intf->p_vout = vout_CreateThread( NULL, 0, 0, 0, NULL, 0, NULL );
-        if( p_intf->p_vout == NULL )                                /* error */
-        {
-            intf_ErrMsg("intf error: can't create output thread\n" );
-            return( 1 );
-        }
-    }
+    /* Bind normal keys. */
+    intf_AssignNormalKeys( p_intf );
+
     return( 0 );
 }
 
 /*****************************************************************************
- * intf_BeDestroy: destroy dummy interface
+ * intf_Close: destroy dummy interface
  *****************************************************************************/
-void intf_BeDestroy( intf_thread_t *p_intf )
+static void intf_Close( intf_thread_t *p_intf )
 {
-    /* Close input thread, if any (blocking) */
-    if( p_intf->p_input )
-    {
-        input_DestroyThread( p_intf->p_input, NULL );
-    }
-
-    /* Close video output thread, if any (blocking) */
-    if( p_intf->p_vout )
-    {
-        vout_DestroyThread( p_intf->p_vout, NULL );
-    }
-
     /* Destroy the interface window */
     p_intf->p_sys->p_window->Lock();
     p_intf->p_sys->p_window->Quit();    
@@ -188,14 +226,24 @@ void intf_BeDestroy( intf_thread_t *p_intf )
 
 
 /*****************************************************************************
- * intf_BeManage: event loop
+ * intf_Run: event loop
  *****************************************************************************/
-void intf_BeManage( intf_thread_t *p_intf )
+static void intf_Run( intf_thread_t *p_intf )
 {
-    if( p_intf->p_sys->i_key != -1 )
+    while( !p_intf->b_die )
     {
-        intf_ProcessKey( p_intf, p_intf->p_sys->i_key );
-        p_intf->p_sys->i_key = -1;
+        /* Manage core vlc functions through the callback */
+        p_intf->pf_manage( p_intf );
+
+        /* Manage keys */
+        if( p_intf->p_sys->i_key != -1 )
+        {
+            intf_ProcessKey( p_intf, p_intf->p_sys->i_key );
+            p_intf->p_sys->i_key = -1;
+        }
+
+        /* Wait a bit */
+        msleep( INTF_IDLE_SLEEP );
     }
 }