1 /*****************************************************************************
2 * wince.cpp: WinCE gui plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
7 * Author: Gildas Bazin <gbazin@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111,
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
31 #if defined( UNDER_CE ) && defined(__MINGW32__)
32 /* This is a gross hack for the wince gcc cross-compiler */
41 /*****************************************************************************
43 *****************************************************************************/
44 static int Open ( vlc_object_t * );
45 static void Close ( vlc_object_t * );
46 static void Run ( intf_thread_t * );
48 /*****************************************************************************
50 *****************************************************************************/
51 #define EMBED_TEXT N_("Embed video in interface")
52 #define EMBED_LONGTEXT N_("Embed the video inside the interface instead " \
53 "of having it in a separate window.")
56 set_description( (char *) _("WinCE interface module") );
57 set_capability( "interface", 100 );
58 set_callbacks( Open, Close );
59 add_shortcut( "wince" );
60 set_program( "wcevlc" );
62 add_bool( "wince-embed", 1, NULL,
63 EMBED_TEXT, EMBED_LONGTEXT, VLC_FALSE );
66 HINSTANCE hInstance = 0;
68 #if !defined(__BUILTIN__)
69 extern "C" BOOL WINAPI
70 DllMain( HANDLE hModule, DWORD fdwReason, LPVOID lpReserved )
72 hInstance = (HINSTANCE)hModule;
77 /* Global variables used by _TOMB() / _FROMB() */
78 wchar_t pwsz_mbtow_wince[2048];
79 char psz_wtomb_wince[2048];
81 /*****************************************************************************
82 * Open: initialize interface
83 *****************************************************************************/
84 static int Open( vlc_object_t *p_this )
86 intf_thread_t *p_intf = (intf_thread_t *)p_this;
88 // Check if the application is running.
89 // If it's running then focus its window and bail out.
90 HWND hwndMain = FindWindow( _T("VLC WinCE"), _T("VLC media player") );
93 SetForegroundWindow( hwndMain );
97 // Allocate instance and initialize some members
98 p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) );
99 if( p_intf->p_sys == NULL )
101 msg_Err( p_intf, "out of memory" );
105 // Suscribe to messages bank
106 p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
109 p_intf->p_sys->p_audio_menu = NULL;
110 p_intf->p_sys->p_video_menu = NULL;
111 p_intf->p_sys->p_navig_menu = NULL;
112 p_intf->p_sys->p_settings_menu = NULL;
114 p_intf->pf_run = Run;
116 p_intf->p_sys->p_input = NULL;
117 p_intf->p_sys->b_playing = 0;
118 p_intf->p_sys->i_playing = -1;
119 p_intf->p_sys->b_slider_free = 1;
120 p_intf->p_sys->i_slider_pos = p_intf->p_sys->i_slider_oldpos = 0;
122 p_intf->p_sys->GetOpenFile = 0;
123 p_intf->p_sys->h_gsgetfile_dll = LoadLibrary( _T("gsgetfile") );
124 if( p_intf->p_sys->h_gsgetfile_dll )
126 p_intf->p_sys->GetOpenFile = (BOOL (WINAPI *)(void *))
127 GetProcAddress( p_intf->p_sys->h_gsgetfile_dll,
128 _T("gsGetOpenFileName") );
131 if( !p_intf->p_sys->GetOpenFile )
132 p_intf->p_sys->GetOpenFile = (BOOL (WINAPI *)(void *))GetOpenFileName;
137 /*****************************************************************************
138 * Close: destroy interface
139 *****************************************************************************/
140 static void Close( vlc_object_t *p_this )
142 intf_thread_t *p_intf = (intf_thread_t *)p_this;
144 if( p_intf->p_sys->p_input )
146 vlc_object_release( p_intf->p_sys->p_input );
149 // Unsuscribe to messages bank
150 msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
152 if( p_intf->p_sys->h_gsgetfile_dll )
153 FreeLibrary( p_intf->p_sys->h_gsgetfile_dll );
156 free( p_intf->p_sys );
159 /*****************************************************************************
161 *****************************************************************************/
162 static void Run( intf_thread_t *p_intf )
165 Interface *pInterface = new Interface();
166 p_intf->p_sys->p_main_window = pInterface;
168 if( !hInstance ) hInstance = GetModuleHandle(NULL);
170 if( !pInterface->InitInstance( hInstance, p_intf ) ) return;
173 while( GetMessage( &msg, NULL, 0, 0 ) > 0 )
175 TranslateMessage( &msg );
176 DispatchMessage( &msg );