1 /*****************************************************************************
2 * open.cpp : WinCE gui plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2000-2004 VideoLAN
7 * Authors: Marodon Cedric <cedric_marodon@yahoo.fr>
8 * Gildas Bazin <gbazin@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
32 #include <stdlib.h> /* malloc(), free() */
47 /*****************************************************************************
49 *****************************************************************************/
51 /* IDs for the controls and the menu commands */
54 Notebook_Event = 1000,
66 NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
67 NetPort1_Event, NetPort2_Event, NetPort3_Event,
68 NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
71 SubsFileSettings_Event,
74 /*****************************************************************************
76 *****************************************************************************/
78 /*****************************************************************************
80 *****************************************************************************/
81 OpenDialog::OpenDialog( intf_thread_t *_p_intf, HINSTANCE _hInst,
82 int _i_access_method, int _i_arg, int _i_method )
87 i_current_access_method = _i_access_method;
92 /***********************************************************************
98 Processes messages sent to the main window.
100 ***********************************************************************/
101 LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
106 INITCOMMONCONTROLSEX iccex; // INITCOMMONCONTROLSEX structure
110 LRESULT lResult = CBaseWindow::WndProc( hwnd, msg, wp, lp, pbProcessed );
111 BOOL bWasProcessed = *pbProcessed;
117 shidi.dwMask = SHIDIM_FLAGS;
118 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
119 SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
121 SHInitDialog( &shidi );
123 //Create the menubar.
124 memset( &mbi, 0, sizeof(SHMENUBARINFO) );
125 mbi.cbSize = sizeof(SHMENUBARINFO);
126 mbi.hwndParent = hwnd;
127 mbi.nToolBarId = IDR_DUMMYMENU;
128 mbi.hInstRes = hInst;
132 if( !SHCreateMenuBar( &mbi ) )
134 MessageBox( hwnd, _T("SHCreateMenuBar failed"),
135 _T("Error"), MB_OK );
141 // Get the client area rect to put the panels in
142 GetClientRect( hwnd, &rcClient );
144 /* Create MRL combobox */
145 mrl_box = CreateWindow( _T("STATIC"),
146 _FROMMB(_("Media Resource Locator (MRL)")),
147 WS_CHILD | WS_VISIBLE | SS_LEFT,
148 5, 10, rcClient.right, 15, hwnd, 0, hInst, 0 );
150 mrl_label = CreateWindow( _T("STATIC"), _FROMMB(_("Open:")),
151 WS_CHILD | WS_VISIBLE | SS_LEFT,
152 5, 10 + 15 + 10, 40, 15, hwnd, 0, hInst, 0 );
154 mrl_combo = CreateWindow( _T("COMBOBOX"), _T(""),
155 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL |
156 CBS_SORT | WS_VSCROLL, 45, 10 + 15 + 10 - 3,
157 rcClient.right - 50 - 5, 5*15 + 6, hwnd,
160 // No tooltips for ComboBox
162 label = CreateWindow( _T("STATIC"),
163 _FROMMB(_("Alternatively, you can build an MRL "
164 "using one of the following predefined "
166 WS_CHILD | WS_VISIBLE | SS_LEFT,
167 5, 10 + 2*(15 + 10), rcClient.right - 2*5, 2*15,
170 /* Create notebook */
171 iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
172 iccex.dwSize = ICC_TAB_CLASSES;
173 InitCommonControlsEx (&iccex);
175 notebook = CreateWindowEx( 0, WC_TABCONTROL, NULL,
176 WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
177 5, 10 + 4*15 + 2*10, rcClient.right - 2*5,
178 rcClient.bottom - MENU_HEIGHT - 15 - 10 - 10 - (10 + 4*15 + 2*10),
179 hwnd, NULL, hInst, NULL );
181 tcItem.mask = TCIF_TEXT;
182 tcItem.pszText = _T("File");
183 TabCtrl_InsertItem( notebook, 0, &tcItem );
184 tcItem.pszText = _T("Network");
185 TabCtrl_InsertItem( notebook, 1, &tcItem );
187 switch( i_current_access_method )
190 TabCtrl_SetCurSel( notebook, 0 );
193 TabCtrl_SetCurSel( notebook, 1 );
205 if( LOWORD(wp) == IDOK )
208 EndDialog( hwnd, LOWORD( wp ) );
211 if( HIWORD(wp) == BN_CLICKED )
213 if( (HWND)lp == net_radios[0] )
215 OnNetTypeChange( NetRadio1_Event );
217 } else if( (HWND)lp == net_radios[1] )
219 OnNetTypeChange( NetRadio2_Event );
221 } else if( (HWND)lp == net_radios[2] )
223 OnNetTypeChange( NetRadio3_Event );
225 } else if( (HWND)lp == net_radios[3] )
227 OnNetTypeChange( NetRadio4_Event );
229 } else if( (HWND)lp == subsfile_checkbox )
233 } else if( (HWND)lp == subsfile_button )
235 OnSubsFileSettings( hwnd );
237 } else if( (HWND)lp == browse_button )
239 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
244 if( HIWORD(wp) == EN_CHANGE )
246 if( (HWND)lp == net_addrs[1] )
248 OnNetPanelChange( NetAddr2_Event );
249 } else if( (HWND)lp == net_addrs[2] )
251 OnNetPanelChange( NetAddr3_Event );
252 } else if( (HWND)lp == net_addrs[3] )
254 OnNetPanelChange( NetAddr4_Event );
255 } else if( (HWND)lp == net_ports[0] )
257 OnNetPanelChange( NetPort1_Event );
258 } else if( (HWND)lp == net_ports[1] )
260 OnNetPanelChange( NetPort2_Event );
263 if( HIWORD(wp) == CBN_EDITUPDATE )
265 if ((HWND)lp == file_combo)
271 *pbProcessed = bWasProcessed;
276 if( (((NMHDR *)lp)->code) == TCN_SELCHANGE )
282 *pbProcessed = bWasProcessed;
287 // the message was not processed
288 // indicate if the base class handled it
289 *pbProcessed = bWasProcessed;
297 /*****************************************************************************
299 *****************************************************************************/
300 void OpenDialog::FilePanel( HWND hwnd )
303 GetWindowRect( notebook, &rc);
305 /* Create browse file line */
306 file_combo = CreateWindow( _T("COMBOBOX"), _T(""),
307 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL,
308 rc.left + 10, rc.top + 10 - 3, rc.right - 10 - (rc.left + 10),
309 5*15 + 6, hwnd, NULL, hInst, NULL );
311 browse_button = CreateWindow( _T("BUTTON"), _T("Browse..."),
312 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
313 rc.left + 10, rc.top + 10 + 15 + 10 - 3, 80, 15 + 6,
314 hwnd, NULL, hInst, NULL );
316 /* Create Subtitles File checkox */
317 subsfile_checkbox = CreateWindow( _T("BUTTON"), _T("Subtitle options"),
318 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
319 rc.left + 10, rc.top + 10 + 2*(15 + 10), 15, 15,
320 hwnd, NULL, hInst, NULL );
321 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );
323 subsfile_label = CreateWindow( _T("STATIC"), _T("Subtitle options"),
324 WS_CHILD | WS_VISIBLE | SS_LEFT,
325 rc.left + 10 + 15 + 10, rc.top + 10 + 2*(15 + 10), 100, 15,
326 hwnd, NULL, hInst, NULL);
328 subsfile_button = CreateWindow( _T("BUTTON"), _T("Settings..."),
329 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_DISABLED,
330 rc.right - 80 - 10, rc.top + 10 + 2*(15 + 10) - 3, 80, 15 + 6,
331 hwnd, NULL, hInst, NULL );
333 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
334 if( psz_subsfile && *psz_subsfile )
336 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_CHECKED, 0 );
337 EnableWindow( subsfile_button, TRUE );
338 string sz_subsfile = "sub-file=";
339 sz_subsfile += psz_subsfile;
340 subsfile_mrl.push_back( sz_subsfile );
342 if( psz_subsfile ) free( psz_subsfile );
345 void OpenDialog::NetPanel( HWND hwnd )
347 INITCOMMONCONTROLSEX ic;
356 static struct net_type net_type_array[] =
358 { _T("UDP/RTP"), 82 },
359 { _T("UDP/RTP Multicast"), 140 },
360 { _T("HTTP/FTP/MMS"), 90 },
365 GetWindowRect( notebook, &rc);
368 net_radios[0] = CreateWindow( _T("BUTTON"), net_type_array[0].szAnsi,
369 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
370 rc.left + 5, rc.top + 10, 15, 15,
371 hwnd, NULL, hInst, NULL);
373 net_label[0] = CreateWindow( _T("STATIC"), net_type_array[0].szAnsi,
374 WS_CHILD | WS_VISIBLE | SS_LEFT,
375 rc.left + 5 + 15 + 5, rc.top + 10, net_type_array[0].length, 15,
376 hwnd, NULL, hInst, NULL);
378 i_net_ports[0] = config_GetInt( p_intf, "server-port" );
380 net_port_label[0] = CreateWindow( _T("STATIC"), _T("Port"),
381 WS_CHILD | WS_VISIBLE | SS_LEFT,
382 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
383 hwnd, NULL, hInst, NULL);
385 wUnicode = new WCHAR[80];
386 swprintf( wUnicode, _T("%d"), i_net_ports[0] );
387 net_ports[0] = CreateWindow( _T("EDIT"), wUnicode,
388 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
389 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
390 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6, hwnd, NULL, hInst, NULL );
393 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
394 ic.dwICC = ICC_UPDOWN_CLASS;
395 InitCommonControlsEx(&ic);
397 hUpdown[0] = CreateUpDownControl(
398 WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT |
399 UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
400 0, 0, 0, 0, hwnd, NULL, hInst,
401 net_ports[0], 16000, 0, i_net_ports[0]);
403 /* UDP/RTP Multicast row */
404 net_radios[1] = CreateWindow( _T("BUTTON"), net_type_array[1].szAnsi,
405 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
406 rc.left + 5, rc.top + 10 + 15 + 10, 15, 15,
407 hwnd, NULL, hInst, NULL);
409 net_label[1] = CreateWindow( _T("STATIC"), net_type_array[1].szAnsi,
410 WS_CHILD | WS_VISIBLE | SS_LEFT,
411 rc.left + 5 + 15 + 5, rc.top + 10 + 15 + 10,
412 net_type_array[1].length, 15, hwnd, NULL, hInst, NULL );
414 net_addrs_label[1] = CreateWindow( _T("STATIC"), _T("Address"),
415 WS_CHILD | WS_VISIBLE | SS_LEFT,
416 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 50, 15,
417 hwnd, NULL, hInst, NULL);
419 net_addrs[1] = CreateWindow( _T("EDIT"), _T(""),
420 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
421 rc.left + 5 + 50 + 5, rc.top + 10 + 2*(15 + 10) - 3,
422 rc.right - 5 - (rc.left + 5 + 50 + 5), 15 + 6,
423 hwnd, NULL, hInst, NULL);
425 net_port_label[1] = CreateWindow( _T("STATIC"), _T("Port"),
426 WS_CHILD | WS_VISIBLE | SS_LEFT,
427 rc.left + 5 , rc.top + 10 + 3*(15 + 10), 30, 15,
428 hwnd, NULL, hInst, NULL);
430 i_net_ports[1] = i_net_ports[0];
432 wUnicode = new WCHAR[80];
433 swprintf( wUnicode, _T("%d"), i_net_ports[1] );
434 net_ports[1] = CreateWindow( _T("EDIT"), wUnicode,
435 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
436 rc.left + 5 + 30 + 5, rc.top + 10 + 3*(15 + 10) - 3,
437 rc.right - 5 -(rc.left + 5 + 30 + 5), 15 + 6,
438 hwnd, NULL, hInst, NULL );
441 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
442 ic.dwICC = ICC_UPDOWN_CLASS;
443 InitCommonControlsEx(&ic);
445 hUpdown[1] = CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER |
446 UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
447 0, 0, 0, 0, hwnd, NULL, hInst,
448 net_ports[1], 16000, 0, i_net_ports[1] );
450 /* HTTP and RTSP rows */
451 net_radios[2] = CreateWindow( _T("BUTTON"), net_type_array[2].szAnsi,
452 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
453 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5,
454 rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
456 net_label[2] = CreateWindow( _T("STATIC"), net_type_array[2].szAnsi,
457 WS_CHILD | WS_VISIBLE | SS_LEFT,
458 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5 + 15 + 5,
459 rc.top + 10, net_type_array[2].length, 15,
460 hwnd, NULL, hInst, NULL );
462 net_addrs_label[2] = CreateWindow( _T("STATIC"), _T("URL"),
463 WS_CHILD | WS_VISIBLE | SS_LEFT,
464 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
465 hwnd, NULL, hInst, NULL );
467 net_addrs[2] = CreateWindow( _T("EDIT"), _T(""),
468 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
469 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
470 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
471 hwnd, NULL, hInst, NULL);
473 net_radios[3] = CreateWindow( _T("BUTTON"), net_type_array[3].szAnsi,
474 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
475 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5,
476 rc.top + 10 + 15 + 10, 15, 15, hwnd, NULL, hInst, NULL );
478 net_label[3] = CreateWindow( _T("STATIC"), net_type_array[3].szAnsi,
479 WS_CHILD | WS_VISIBLE | SS_LEFT,
480 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5 + 15 + 5,
481 rc.top + 10 + 15 + 10, net_type_array[3].length, 15,
482 hwnd, NULL, hInst, NULL );
484 net_addrs_label[3] = CreateWindow( _T("STATIC"), _T("URL"),
485 WS_CHILD | WS_VISIBLE | SS_LEFT,
486 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
487 hwnd, NULL, hInst, NULL );
489 net_addrs[3] = CreateWindow( _T("EDIT"), _T("rtsp://"),
490 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
491 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
492 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
493 hwnd, NULL, hInst, NULL );
495 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
498 void OpenDialog::UpdateMRL()
500 UpdateMRL( i_current_access_method );
503 void OpenDialog::UpdateMRL( int i_access_method )
505 string demux, mrltemp;
512 i_current_access_method = i_access_method;
514 switch( i_access_method )
517 //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
518 size = GetWindowTextLength( file_combo ) + 1;
519 wUnicode = new WCHAR[ size ];
520 GetWindowText( file_combo, wUnicode, size );
521 mrltemp = _TOMB(wUnicode);
527 mrltemp = "udp" + demux + "://";
528 if( i_net_ports[0] !=
529 config_GetInt( p_intf, "server-port" ) )
531 szAnsi = new char[50];
532 sprintf( szAnsi, "@:%d", i_net_ports[0] );
539 mrltemp = "udp" + demux + "://@";
540 size = Edit_GetTextLength( net_addrs[1] );
541 wUnicode = new WCHAR[size + 1]; //Add 1 for the NULL
542 Edit_GetText( net_addrs[1], wUnicode, size + 1);
543 mrltemp += _TOMB(wUnicode);
545 if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
547 szAnsi = new char[50];
548 sprintf( szAnsi, ":%d", i_net_ports[1] );
556 size = Edit_GetTextLength( net_addrs[2] );
557 wUnicode = new WCHAR[size + 1]; //Add 1 for the NULL
558 Edit_GetText( net_addrs[2], wUnicode, size + 1);
559 size = WideCharToMultiByte( CP_ACP, 0, wUnicode, -1, NULL, 0, NULL, &bTemp );
560 szAnsi = new char[size];
561 WideCharToMultiByte( CP_ACP, 0, wUnicode, -1, szAnsi, size, NULL, &bTemp );
563 if( !strstr( szAnsi, "http://" ) )
565 mrltemp = "http" + demux + "://";
573 size = Edit_GetTextLength( net_addrs[3] );
574 wUnicode = new WCHAR[size + 1]; //Add 1 for the NULL
575 Edit_GetText( net_addrs[3], wUnicode, size + 1);
576 size = WideCharToMultiByte( CP_ACP, 0, wUnicode, -1, NULL, 0, NULL, &bTemp );
577 szAnsi = new char[size];
578 WideCharToMultiByte( CP_ACP, 0, wUnicode, -1, szAnsi, size, NULL, &bTemp );
580 if( !strstr( szAnsi, "rtsp://" ) )
582 mrltemp = "rtsp" + demux + "://";
593 SetWindowText( mrl_combo, _FROMMB(mrltemp.c_str()) );
596 void OpenDialog::OnPageChange()
598 if( TabCtrl_GetCurSel( notebook ) == 0 )
600 for( int i=0; i<4; i++ )
602 SetWindowPos( net_radios[i], HWND_BOTTOM, 0, 0, 0, 0,
603 SWP_NOMOVE | SWP_NOSIZE );
604 SetWindowPos( net_label[i], HWND_BOTTOM, 0, 0, 0, 0,
605 SWP_NOMOVE | SWP_NOSIZE );
609 SetWindowPos( file_combo, HWND_TOP, 0, 0, 0, 0,
610 SWP_NOMOVE | SWP_NOSIZE );
611 SetWindowPos( browse_button, HWND_TOP, 0, 0, 0, 0,
612 SWP_NOMOVE | SWP_NOSIZE );
613 SetWindowPos( subsfile_checkbox, HWND_TOP, 0, 0, 0, 0,
614 SWP_NOMOVE | SWP_NOSIZE );
615 SetWindowPos( subsfile_label, HWND_TOP, 0, 0, 0, 0,
616 SWP_NOMOVE | SWP_NOSIZE );
617 SetWindowPos( subsfile_button, HWND_TOP, 0, 0, 0, 0,
618 SWP_NOMOVE | SWP_NOSIZE );
620 i_current_access_method = FILE_ACCESS;
622 else if ( TabCtrl_GetCurSel( notebook ) == 1 )
624 SetWindowPos( file_combo, HWND_BOTTOM, 0, 0, 0, 0,
625 SWP_NOMOVE | SWP_NOSIZE );
626 SetWindowPos( browse_button, HWND_BOTTOM, 0, 0, 0, 0,
627 SWP_NOMOVE | SWP_NOSIZE );
628 SetWindowPos( subsfile_checkbox, HWND_BOTTOM, 0, 0, 0, 0,
629 SWP_NOMOVE | SWP_NOSIZE );
630 SetWindowPos( subsfile_label, HWND_BOTTOM, 0, 0, 0, 0,
631 SWP_NOMOVE | SWP_NOSIZE );
632 SetWindowPos( subsfile_button, HWND_BOTTOM, 0, 0, 0, 0,
633 SWP_NOMOVE | SWP_NOSIZE );
635 for( int i=0; i<4; i++ )
637 SetWindowPos( net_radios[i], HWND_TOP, 0, 0, 0, 0,
638 SWP_NOMOVE | SWP_NOSIZE );
639 SendMessage( net_radios[i], BM_SETCHECK, BST_UNCHECKED, 0 );
640 SetWindowPos( net_label[i], HWND_TOP, 0, 0, 0, 0,
641 SWP_NOMOVE | SWP_NOSIZE );
643 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
644 SWP_NOMOVE | SWP_NOSIZE );
645 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
646 SWP_NOMOVE | SWP_NOSIZE );
647 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
648 SWP_NOMOVE | SWP_NOSIZE );
650 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
652 i_current_access_method = NET_ACCESS;
658 void OpenDialog::OnOk()
663 size = GetWindowTextLength( mrl_combo ) + 1;
664 wUnicode = new WCHAR[ size ];
665 GetWindowText( mrl_combo, wUnicode, size ); // a remplacer par ComboBox_GetText( mrl_combo, wUnicode, size )
666 mrl = SeparateEntries( wUnicode );
667 ComboBox_AddString( mrl_combo, wUnicode );
668 if( ComboBox_GetCount( mrl_combo ) > 10 )
669 ComboBox_DeleteString( mrl_combo, 0 );
670 ComboBox_SetCurSel( mrl_combo, ComboBox_GetCount( mrl_combo ) - 1 );
673 /* Update the playlist */
674 playlist_t *p_playlist =
675 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
677 if( p_playlist == NULL ) return;
679 for( int i = 0; i < (int)mrl.size(); i++ )
681 vlc_bool_t b_start = !i && i_open_arg;
682 playlist_item_t *p_item =
683 playlist_ItemNew( p_intf, (const char*)mrl[i].c_str(),
684 (const char *)mrl[i].c_str() );
687 while( i + 1 < (int)mrl.size() &&
688 ((const char *)mrl[i + 1].c_str())[0] == ':' )
690 playlist_ItemAddOption( p_item, mrl[i + 1].c_str() );
694 /* Get the options from the subtitles dialog */
695 if( (SendMessage( subsfile_checkbox, BM_GETCHECK, 0, 0 ) & BST_CHECKED)
696 && subsfile_mrl.size() )
698 for( int j = 0; j < (int)subsfile_mrl.size(); j++ )
700 playlist_ItemAddOption( p_item, subsfile_mrl[j].c_str() );
704 int i_id = playlist_AddItem( p_playlist, p_item,
705 PLAYLIST_APPEND, PLAYLIST_END );
709 playlist_Control( p_playlist, PLAYLIST_ITEMPLAY , p_item );
713 //TogglePlayButton( PLAYING_S );
715 vlc_object_release( p_playlist );
718 /*****************************************************************************
719 * File panel event methods.
720 *****************************************************************************/
721 void OpenDialog::OnFilePanelChange()
723 UpdateMRL( FILE_ACCESS );
726 void OpenDialog::OnFileBrowse()
729 TCHAR DateiName[80+1] = _T("\0");
730 static TCHAR szFilter[] = _T("All (*.*)\0*.*\0");
736 memset(&ofn, 0, sizeof(OPENFILENAME));
737 ofn.lStructSize = sizeof (OPENFILENAME);
738 ofn.hwndOwner = NULL;
739 ofn.hInstance = hInst;
740 ofn.lpstrFilter = szFilter;
741 ofn.lpstrCustomFilter = NULL;
742 ofn.nMaxCustFilter = 0;
743 ofn.nFilterIndex = 1;
744 ofn.lpstrFile = (LPTSTR) DateiName;
746 ofn.lpstrFileTitle = NULL;
747 ofn.nMaxFileTitle = 40;
748 ofn.lpstrInitialDir = NULL;
749 ofn.lpstrTitle = _T("Open File");
752 ofn.nFileExtension = 0;
753 ofn.lpstrDefExt = NULL;
756 ofn.lpTemplateName = NULL;
757 if( GetOpenFileName((LPOPENFILENAME) &ofn) )
759 size = WideCharToMultiByte( CP_ACP, 0, ofn.lpstrFile, -1, NULL,
761 psz_filename = ( char * )malloc( size );
762 WideCharToMultiByte( CP_ACP, 0, ofn.lpstrFile, -1, psz_filename,
763 size, NULL, &bTemp );
765 if( strchr( psz_filename, ' ' ) )
768 path += psz_filename;
774 SetWindowText( file_combo, _FROMMB(path.c_str()) );
775 ComboBox_AddString( file_combo, _FROMMB(path.c_str()) );
776 if( ComboBox_GetCount( file_combo ) > 10 )
777 ComboBox_DeleteString( file_combo, 0 );
779 UpdateMRL( FILE_ACCESS );
783 /*****************************************************************************
784 * Net panel event methods.
785 *****************************************************************************/
786 void OpenDialog::OnNetPanelChange( int event )
792 if( event >= NetPort1_Event && event <= NetPort2_Event )
794 size = Edit_GetTextLength( net_ports[event - NetPort1_Event] );
795 wUnicode = new WCHAR[size + 1]; //Add 1 for the NULL
796 Edit_GetText( net_ports[event - NetPort1_Event], wUnicode, size + 1);
797 swscanf( wUnicode, _T("%d"), &port );
798 i_net_ports[event - NetPort1_Event] = port;
802 UpdateMRL( NET_ACCESS );
805 void OpenDialog::OnNetTypeChange( int event )
809 i_net_type = event - NetRadio1_Event;
811 if( event == NetRadio1_Event )
813 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
814 SWP_NOMOVE | SWP_NOSIZE );
815 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
816 SWP_NOMOVE | SWP_NOSIZE );
817 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
818 SWP_NOMOVE | SWP_NOSIZE );
820 else if( event == NetRadio2_Event )
822 SetWindowPos( net_addrs_label[1], HWND_TOP, 0, 0, 0, 0,
823 SWP_NOMOVE | SWP_NOSIZE );
824 SetWindowPos( net_addrs[1], HWND_TOP, 0, 0, 0, 0,
825 SWP_NOMOVE | SWP_NOSIZE );
826 SetWindowPos( net_port_label[1], HWND_TOP, 0, 0, 0, 0,
827 SWP_NOMOVE | SWP_NOSIZE );
828 SetWindowPos( net_ports[1], HWND_TOP, 0, 0, 0, 0,
829 SWP_NOMOVE | SWP_NOSIZE );
830 SetWindowPos( hUpdown[1], HWND_TOP, 0, 0, 0, 0,
831 SWP_NOMOVE | SWP_NOSIZE );
833 else if( event == NetRadio3_Event )
835 SetWindowPos( net_addrs_label[2], HWND_TOP, 0, 0, 0, 0,
836 SWP_NOMOVE | SWP_NOSIZE );
837 SetWindowPos( net_addrs[2], HWND_TOP, 0, 0, 0, 0,
838 SWP_NOMOVE | SWP_NOSIZE );
840 else if( event == NetRadio4_Event )
842 SetWindowPos( net_addrs_label[3], HWND_TOP, 0, 0, 0, 0,
843 SWP_NOMOVE | SWP_NOSIZE );
844 SetWindowPos( net_addrs[3], HWND_TOP, 0, 0, 0, 0,
845 SWP_NOMOVE | SWP_NOSIZE );
848 UpdateMRL( NET_ACCESS );
851 void OpenDialog::DisableNETCtrl()
853 for( int i=0; i<4; i++ )
855 SetWindowPos( net_port_label[i], HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
856 SetWindowPos( net_ports[i], HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
857 SetWindowPos( hUpdown[i], HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
859 SetWindowPos( net_addrs_label[i], HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
860 SetWindowPos( net_addrs[i], HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
863 UpdateMRL( FILE_ACCESS );
866 /*****************************************************************************
867 * Subtitles file event methods.
868 *****************************************************************************/
869 void OpenDialog::OnSubsFileEnable()
871 EnableWindow( subsfile_button, ( SendMessage( subsfile_checkbox,
872 BM_GETCHECK, 0, 0 ) & BST_CHECKED ) ? TRUE : FALSE );
875 void OpenDialog::OnSubsFileSettings( HWND hwnd )
878 /* Show/hide the open dialog */
879 SubsFileDialog *subsfile_dialog = new SubsFileDialog( p_intf, hInst );
880 DialogBoxParam( hInst, (LPCTSTR)IDD_DUMMY, hwnd,
881 (DLGPROC)subsfile_dialog->BaseWndProc,
882 (long)subsfile_dialog );
884 subsfile_mrl.clear();
886 for( int i = 0; i < subsfile_dialog->subsfile_mrl.size(); i++ )
887 subsfile_mrl.push_back( subsfile_dialog->subsfile_mrl[i] );
889 delete subsfile_dialog;
892 /*****************************************************************************
894 *****************************************************************************/
895 vector<string> SeparateEntries( LPWSTR entries )
898 vlc_bool_t b_quotes_mode = VLC_FALSE;
899 vector<string> entries_array;
900 LPWSTR entry = new TCHAR[ wcslen(entries) + 1 ];
902 LPWSTR strToken = entries;
903 length = wcscspn( strToken, _T(" \t\r\n\"") );
904 swprintf( entry, _T("") );
906 while( strToken - entries < wcslen(entries) )
908 wcsncat( entry, strToken, length );
910 wcsncat( entry, strToken + length, 1 );
912 if( !b_quotes_mode && strToken[length] == _T('\"') )
914 /* Enters quotes mode */
915 entry[ wcslen(entry) - 1 ] = NULL;
916 b_quotes_mode = VLC_TRUE;
918 else if( b_quotes_mode && strToken[length] == _T('\"') )
920 /* Finished the quotes mode */
921 entry[ wcslen(entry) - 1 ] = NULL;
922 if( wcscmp( entry, _T("") ) != 0 )
924 entries_array.push_back( _TOMB(entry) );
926 swprintf( entry, _T("") );
927 b_quotes_mode = VLC_FALSE;
929 else if( !b_quotes_mode && strToken[length] != _T('\"') )
931 /* we found a non-quoted standalone string */
932 if( strToken + length - entries < wcslen(entries) ||/*token.HasMoreTokens() ||*/ //FIX ME IF YOU CAN
933 strToken[length] == _T(' ') ||
934 strToken[length] == _T('\t') ||
935 strToken[length] == _T('\r') ||
936 strToken[length] == _T('\n') )
937 entry[ wcslen(entry) - 1 ]/*strToken[length]*/ = NULL;
938 if( wcscmp( entry, _T("") ) != 0 )
940 entries_array.push_back( _TOMB(entry) );
942 swprintf( entry, _T("") );
947 strToken += length + 1;
948 length = wcscspn( strToken, _T(" \t\r\n\"") );
951 if( wcscmp( entry, _T("") ) != 0 )
953 entries_array.push_back( _TOMB(entry) );
956 return entries_array;