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 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
29 #include <string.h> /* strerror() */
42 /*****************************************************************************
44 *****************************************************************************/
46 /* IDs for the controls and the menu commands */
49 Notebook_Event = 1000,
61 NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
62 NetPort1_Event, NetPort2_Event, NetPort3_Event,
63 NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
66 SubsFileSettings_Event,
69 /*****************************************************************************
71 *****************************************************************************/
73 /*****************************************************************************
75 *****************************************************************************/
76 OpenDialog::OpenDialog( intf_thread_t *_p_intf, HINSTANCE _hInst,
77 int _i_access_method, int _i_arg, int _i_method )
82 i_current_access_method = _i_access_method;
87 /***********************************************************************
93 Processes messages sent to the main window.
95 ***********************************************************************/
96 LRESULT OpenDialog::WndProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
101 INITCOMMONCONTROLSEX iccex; // INITCOMMONCONTROLSEX structure
105 LRESULT lResult = CBaseWindow::WndProc( hwnd, msg, wp, lp, pbProcessed );
106 BOOL bWasProcessed = *pbProcessed;
112 shidi.dwMask = SHIDIM_FLAGS;
113 shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN |
114 SHIDIF_FULLSCREENNOMENUBAR;//SHIDIF_SIZEDLGFULLSCREEN;
116 SHInitDialog( &shidi );
118 //Create the menubar.
119 memset( &mbi, 0, sizeof(SHMENUBARINFO) );
120 mbi.cbSize = sizeof(SHMENUBARINFO);
121 mbi.hwndParent = hwnd;
122 mbi.nToolBarId = IDR_DUMMYMENU;
123 mbi.hInstRes = hInst;
127 if( !SHCreateMenuBar( &mbi ) )
129 MessageBox( hwnd, _T("SHCreateMenuBar failed"),
130 _T("Error"), MB_OK );
136 // Get the client area rect to put the panels in
137 GetClientRect( hwnd, &rcClient );
139 /* Create MRL combobox */
140 mrl_box = CreateWindow( _T("STATIC"),
141 _FROMMB(_("Media Resource Locator (MRL)")),
142 WS_CHILD | WS_VISIBLE | SS_LEFT,
143 5, 10, rcClient.right, 15, hwnd, 0, hInst, 0 );
145 mrl_label = CreateWindow( _T("STATIC"), _FROMMB(_("Open:")),
146 WS_CHILD | WS_VISIBLE | SS_LEFT,
147 5, 10 + 15 + 10, 40, 15, hwnd, 0, hInst, 0 );
149 mrl_combo = CreateWindow( _T("COMBOBOX"), _T(""),
150 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL |
151 CBS_SORT | WS_VSCROLL, 45, 10 + 15 + 10 - 3,
152 rcClient.right - 50 - 5, 5*15 + 6, hwnd,
155 // No tooltips for ComboBox
157 label = CreateWindow( _T("STATIC"),
158 _FROMMB(_("Alternatively, you can build an MRL "
159 "using one of the following predefined "
161 WS_CHILD | WS_VISIBLE | SS_LEFT,
162 5, 10 + 2*(15 + 10), rcClient.right - 2*5, 2*15,
165 /* Create notebook */
166 iccex.dwSize = sizeof (INITCOMMONCONTROLSEX);
167 iccex.dwSize = ICC_TAB_CLASSES;
168 InitCommonControlsEx (&iccex);
170 notebook = CreateWindowEx( 0, WC_TABCONTROL, NULL,
171 WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
172 5, 10 + 4*15 + 2*10, rcClient.right - 2*5,
173 rcClient.bottom - MENU_HEIGHT - 15 - 10 - 10 - (10 + 4*15 + 2*10),
174 hwnd, NULL, hInst, NULL );
176 tcItem.mask = TCIF_TEXT;
177 tcItem.pszText = _T("File");
178 TabCtrl_InsertItem( notebook, 0, &tcItem );
179 tcItem.pszText = _T("Network");
180 TabCtrl_InsertItem( notebook, 1, &tcItem );
182 switch( i_current_access_method )
185 TabCtrl_SetCurSel( notebook, 0 );
188 TabCtrl_SetCurSel( notebook, 1 );
200 if( LOWORD(wp) == IDOK )
203 EndDialog( hwnd, LOWORD( wp ) );
206 if( HIWORD(wp) == BN_CLICKED )
208 if( (HWND)lp == net_radios[0] )
210 OnNetTypeChange( NetRadio1_Event );
212 } else if( (HWND)lp == net_radios[1] )
214 OnNetTypeChange( NetRadio2_Event );
216 } else if( (HWND)lp == net_radios[2] )
218 OnNetTypeChange( NetRadio3_Event );
220 } else if( (HWND)lp == net_radios[3] )
222 OnNetTypeChange( NetRadio4_Event );
224 } else if( (HWND)lp == subsfile_checkbox )
228 } else if( (HWND)lp == subsfile_button )
230 OnSubsFileSettings( hwnd );
232 } else if( (HWND)lp == browse_button )
234 SHFullScreen( GetForegroundWindow(), SHFS_HIDESIPBUTTON );
239 if( HIWORD(wp) == EN_CHANGE )
241 if( (HWND)lp == net_addrs[1] )
243 OnNetPanelChange( NetAddr2_Event );
244 } else if( (HWND)lp == net_addrs[2] )
246 OnNetPanelChange( NetAddr3_Event );
247 } else if( (HWND)lp == net_addrs[3] )
249 OnNetPanelChange( NetAddr4_Event );
250 } else if( (HWND)lp == net_ports[0] )
252 OnNetPanelChange( NetPort1_Event );
253 } else if( (HWND)lp == net_ports[1] )
255 OnNetPanelChange( NetPort2_Event );
258 if( HIWORD(wp) == CBN_EDITUPDATE )
260 if ((HWND)lp == file_combo)
266 *pbProcessed = bWasProcessed;
271 if( (((NMHDR *)lp)->code) == TCN_SELCHANGE )
277 *pbProcessed = bWasProcessed;
282 // the message was not processed
283 // indicate if the base class handled it
284 *pbProcessed = bWasProcessed;
292 /*****************************************************************************
294 *****************************************************************************/
295 void OpenDialog::FilePanel( HWND hwnd )
298 GetWindowRect( notebook, &rc);
300 /* Create browse file line */
301 file_combo = CreateWindow( _T("COMBOBOX"), _T(""),
302 WS_CHILD | WS_VISIBLE | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL,
303 rc.left + 10, rc.top + 10 - 3, rc.right - 10 - (rc.left + 10),
304 5*15 + 6, hwnd, NULL, hInst, NULL );
306 browse_button = CreateWindow( _T("BUTTON"), _T("Browse..."),
307 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
308 rc.left + 10, rc.top + 10 + 15 + 10 - 3, 80, 15 + 6,
309 hwnd, NULL, hInst, NULL );
311 /* Create Subtitles File checkox */
312 subsfile_checkbox = CreateWindow( _T("BUTTON"), _T("Subtitle options"),
313 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
314 rc.left + 10, rc.top + 10 + 2*(15 + 10), 15, 15,
315 hwnd, NULL, hInst, NULL );
316 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_UNCHECKED, 0 );
318 subsfile_label = CreateWindow( _T("STATIC"), _T("Subtitle options"),
319 WS_CHILD | WS_VISIBLE | SS_LEFT,
320 rc.left + 10 + 15 + 10, rc.top + 10 + 2*(15 + 10), 100, 15,
321 hwnd, NULL, hInst, NULL);
323 subsfile_button = CreateWindow( _T("BUTTON"), _T("Settings..."),
324 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_DISABLED,
325 rc.right - 80 - 10, rc.top + 10 + 2*(15 + 10) - 3, 80, 15 + 6,
326 hwnd, NULL, hInst, NULL );
328 char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
329 if( psz_subsfile && *psz_subsfile )
331 SendMessage( subsfile_checkbox, BM_SETCHECK, BST_CHECKED, 0 );
332 EnableWindow( subsfile_button, TRUE );
333 string sz_subsfile = "sub-file=";
334 sz_subsfile += psz_subsfile;
335 subsfile_mrl.push_back( sz_subsfile );
337 if( psz_subsfile ) free( psz_subsfile );
340 void OpenDialog::NetPanel( HWND hwnd )
342 INITCOMMONCONTROLSEX ic;
351 static struct net_type net_type_array[] =
353 { _T("UDP/RTP"), 82 },
354 { _T("UDP/RTP Multicast"), 140 },
355 { _T("HTTP/FTP/MMS"), 90 },
360 GetWindowRect( notebook, &rc);
363 net_radios[0] = CreateWindow( _T("BUTTON"), net_type_array[0].szAnsi,
364 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
365 rc.left + 5, rc.top + 10, 15, 15,
366 hwnd, NULL, hInst, NULL);
368 net_label[0] = CreateWindow( _T("STATIC"), net_type_array[0].szAnsi,
369 WS_CHILD | WS_VISIBLE | SS_LEFT,
370 rc.left + 5 + 15 + 5, rc.top + 10, net_type_array[0].length, 15,
371 hwnd, NULL, hInst, NULL);
373 i_net_ports[0] = config_GetInt( p_intf, "server-port" );
375 net_port_label[0] = CreateWindow( _T("STATIC"), _T("Port"),
376 WS_CHILD | WS_VISIBLE | SS_LEFT,
377 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
378 hwnd, NULL, hInst, NULL);
380 wUnicode = new WCHAR[80];
381 swprintf( wUnicode, _T("%d"), i_net_ports[0] );
382 net_ports[0] = CreateWindow( _T("EDIT"), wUnicode,
383 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
384 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
385 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6, hwnd, NULL, hInst, NULL );
388 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
389 ic.dwICC = ICC_UPDOWN_CLASS;
390 InitCommonControlsEx(&ic);
392 hUpdown[0] = CreateUpDownControl(
393 WS_CHILD | WS_VISIBLE | WS_BORDER | UDS_ALIGNRIGHT |
394 UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
395 0, 0, 0, 0, hwnd, NULL, hInst,
396 net_ports[0], 16000, 0, i_net_ports[0]);
398 /* UDP/RTP Multicast row */
399 net_radios[1] = CreateWindow( _T("BUTTON"), net_type_array[1].szAnsi,
400 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
401 rc.left + 5, rc.top + 10 + 15 + 10, 15, 15,
402 hwnd, NULL, hInst, NULL);
404 net_label[1] = CreateWindow( _T("STATIC"), net_type_array[1].szAnsi,
405 WS_CHILD | WS_VISIBLE | SS_LEFT,
406 rc.left + 5 + 15 + 5, rc.top + 10 + 15 + 10,
407 net_type_array[1].length, 15, hwnd, NULL, hInst, NULL );
409 net_addrs_label[1] = CreateWindow( _T("STATIC"), _T("Address"),
410 WS_CHILD | WS_VISIBLE | SS_LEFT,
411 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 50, 15,
412 hwnd, NULL, hInst, NULL);
414 net_addrs[1] = CreateWindow( _T("EDIT"), _T(""),
415 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
416 rc.left + 5 + 50 + 5, rc.top + 10 + 2*(15 + 10) - 3,
417 rc.right - 5 - (rc.left + 5 + 50 + 5), 15 + 6,
418 hwnd, NULL, hInst, NULL);
420 net_port_label[1] = CreateWindow( _T("STATIC"), _T("Port"),
421 WS_CHILD | WS_VISIBLE | SS_LEFT,
422 rc.left + 5 , rc.top + 10 + 3*(15 + 10), 30, 15,
423 hwnd, NULL, hInst, NULL);
425 i_net_ports[1] = i_net_ports[0];
427 wUnicode = new WCHAR[80];
428 swprintf( wUnicode, _T("%d"), i_net_ports[1] );
429 net_ports[1] = CreateWindow( _T("EDIT"), wUnicode,
430 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
431 rc.left + 5 + 30 + 5, rc.top + 10 + 3*(15 + 10) - 3,
432 rc.right - 5 -(rc.left + 5 + 30 + 5), 15 + 6,
433 hwnd, NULL, hInst, NULL );
436 ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
437 ic.dwICC = ICC_UPDOWN_CLASS;
438 InitCommonControlsEx(&ic);
440 hUpdown[1] = CreateUpDownControl( WS_CHILD | WS_VISIBLE | WS_BORDER |
441 UDS_ALIGNRIGHT | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
442 0, 0, 0, 0, hwnd, NULL, hInst,
443 net_ports[1], 16000, 0, i_net_ports[1] );
445 /* HTTP and RTSP rows */
446 net_radios[2] = CreateWindow( _T("BUTTON"), net_type_array[2].szAnsi,
447 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
448 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5,
449 rc.top + 10, 15, 15, hwnd, NULL, hInst, NULL );
451 net_label[2] = CreateWindow( _T("STATIC"), net_type_array[2].szAnsi,
452 WS_CHILD | WS_VISIBLE | SS_LEFT,
453 rc.left + 5 + 15 + 5 + net_type_array[0].length + 5 + 15 + 5,
454 rc.top + 10, net_type_array[2].length, 15,
455 hwnd, NULL, hInst, NULL );
457 net_addrs_label[2] = CreateWindow( _T("STATIC"), _T("URL"),
458 WS_CHILD | WS_VISIBLE | SS_LEFT,
459 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
460 hwnd, NULL, hInst, NULL );
462 net_addrs[2] = CreateWindow( _T("EDIT"), _T(""),
463 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
464 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
465 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
466 hwnd, NULL, hInst, NULL);
468 net_radios[3] = CreateWindow( _T("BUTTON"), net_type_array[3].szAnsi,
469 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
470 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5,
471 rc.top + 10 + 15 + 10, 15, 15, hwnd, NULL, hInst, NULL );
473 net_label[3] = CreateWindow( _T("STATIC"), net_type_array[3].szAnsi,
474 WS_CHILD | WS_VISIBLE | SS_LEFT,
475 rc.left + 5 + 15 + 5 + net_type_array[1].length + 5 + 15 + 5,
476 rc.top + 10 + 15 + 10, net_type_array[3].length, 15,
477 hwnd, NULL, hInst, NULL );
479 net_addrs_label[3] = CreateWindow( _T("STATIC"), _T("URL"),
480 WS_CHILD | WS_VISIBLE | SS_LEFT,
481 rc.left + 5 , rc.top + 10 + 2*(15 + 10), 30, 15,
482 hwnd, NULL, hInst, NULL );
484 net_addrs[3] = CreateWindow( _T("EDIT"), _T("rtsp://"),
485 WS_CHILD | WS_VISIBLE | WS_BORDER | SS_LEFT | ES_AUTOHSCROLL,
486 rc.left + 5 + 30 + 5, rc.top + 10 + 2*(15 + 10) - 3,
487 rc.right - 5 - (rc.left + 5 + 30 + 5), 15 + 6,
488 hwnd, NULL, hInst, NULL );
490 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
493 void OpenDialog::UpdateMRL()
495 UpdateMRL( i_current_access_method );
498 void OpenDialog::UpdateMRL( int i_access_method )
500 string demux, mrltemp;
507 i_current_access_method = i_access_method;
509 switch( i_access_method )
512 //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
513 size = GetWindowTextLength( file_combo ) + 1;
514 wUnicode = new WCHAR[ size ];
515 GetWindowText( file_combo, wUnicode, size );
516 mrltemp = _TOMB(wUnicode);
522 mrltemp = "udp" + demux + "://";
523 if( i_net_ports[0] !=
524 config_GetInt( p_intf, "server-port" ) )
526 szAnsi = new char[50];
527 sprintf( szAnsi, "@:%d", i_net_ports[0] );
534 mrltemp = "udp" + demux + "://@";
535 size = Edit_GetTextLength( net_addrs[1] );
536 wUnicode = new WCHAR[size + 1]; //Add 1 for the NULL
537 Edit_GetText( net_addrs[1], wUnicode, size + 1);
538 mrltemp += _TOMB(wUnicode);
540 if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
542 szAnsi = new char[50];
543 sprintf( szAnsi, ":%d", i_net_ports[1] );
551 size = Edit_GetTextLength( net_addrs[2] );
552 wUnicode = new WCHAR[size + 1]; //Add 1 for the NULL
553 Edit_GetText( net_addrs[2], wUnicode, size + 1);
554 size = WideCharToMultiByte( CP_ACP, 0, wUnicode, -1, NULL, 0, NULL, &bTemp );
555 szAnsi = new char[size];
556 WideCharToMultiByte( CP_ACP, 0, wUnicode, -1, szAnsi, size, NULL, &bTemp );
558 if( !strstr( szAnsi, "http://" ) )
560 mrltemp = "http" + demux + "://";
568 size = Edit_GetTextLength( net_addrs[3] );
569 wUnicode = new WCHAR[size + 1]; //Add 1 for the NULL
570 Edit_GetText( net_addrs[3], wUnicode, size + 1);
571 size = WideCharToMultiByte( CP_ACP, 0, wUnicode, -1, NULL, 0, NULL, &bTemp );
572 szAnsi = new char[size];
573 WideCharToMultiByte( CP_ACP, 0, wUnicode, -1, szAnsi, size, NULL, &bTemp );
575 if( !strstr( szAnsi, "rtsp://" ) )
577 mrltemp = "rtsp" + demux + "://";
588 SetWindowText( mrl_combo, _FROMMB(mrltemp.c_str()) );
591 void OpenDialog::OnPageChange()
593 if( TabCtrl_GetCurSel( notebook ) == 0 )
595 for( int i=0; i<4; i++ )
597 SetWindowPos( net_radios[i], HWND_BOTTOM, 0, 0, 0, 0,
598 SWP_NOMOVE | SWP_NOSIZE );
599 SetWindowPos( net_label[i], HWND_BOTTOM, 0, 0, 0, 0,
600 SWP_NOMOVE | SWP_NOSIZE );
604 SetWindowPos( file_combo, HWND_TOP, 0, 0, 0, 0,
605 SWP_NOMOVE | SWP_NOSIZE );
606 SetWindowPos( browse_button, HWND_TOP, 0, 0, 0, 0,
607 SWP_NOMOVE | SWP_NOSIZE );
608 SetWindowPos( subsfile_checkbox, HWND_TOP, 0, 0, 0, 0,
609 SWP_NOMOVE | SWP_NOSIZE );
610 SetWindowPos( subsfile_label, HWND_TOP, 0, 0, 0, 0,
611 SWP_NOMOVE | SWP_NOSIZE );
612 SetWindowPos( subsfile_button, HWND_TOP, 0, 0, 0, 0,
613 SWP_NOMOVE | SWP_NOSIZE );
615 i_current_access_method = FILE_ACCESS;
617 else if ( TabCtrl_GetCurSel( notebook ) == 1 )
619 SetWindowPos( file_combo, HWND_BOTTOM, 0, 0, 0, 0,
620 SWP_NOMOVE | SWP_NOSIZE );
621 SetWindowPos( browse_button, HWND_BOTTOM, 0, 0, 0, 0,
622 SWP_NOMOVE | SWP_NOSIZE );
623 SetWindowPos( subsfile_checkbox, HWND_BOTTOM, 0, 0, 0, 0,
624 SWP_NOMOVE | SWP_NOSIZE );
625 SetWindowPos( subsfile_label, HWND_BOTTOM, 0, 0, 0, 0,
626 SWP_NOMOVE | SWP_NOSIZE );
627 SetWindowPos( subsfile_button, HWND_BOTTOM, 0, 0, 0, 0,
628 SWP_NOMOVE | SWP_NOSIZE );
630 for( int i=0; i<4; i++ )
632 SetWindowPos( net_radios[i], HWND_TOP, 0, 0, 0, 0,
633 SWP_NOMOVE | SWP_NOSIZE );
634 SendMessage( net_radios[i], BM_SETCHECK, BST_UNCHECKED, 0 );
635 SetWindowPos( net_label[i], HWND_TOP, 0, 0, 0, 0,
636 SWP_NOMOVE | SWP_NOSIZE );
638 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
639 SWP_NOMOVE | SWP_NOSIZE );
640 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
641 SWP_NOMOVE | SWP_NOSIZE );
642 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
643 SWP_NOMOVE | SWP_NOSIZE );
645 SendMessage( net_radios[0], BM_SETCHECK, BST_CHECKED, 0 );
647 i_current_access_method = NET_ACCESS;
653 void OpenDialog::OnOk()
658 size = GetWindowTextLength( mrl_combo ) + 1;
659 wUnicode = new WCHAR[ size ];
660 GetWindowText( mrl_combo, wUnicode, size ); // a remplacer par ComboBox_GetText( mrl_combo, wUnicode, size )
661 mrl = SeparateEntries( wUnicode );
662 ComboBox_AddString( mrl_combo, wUnicode );
663 if( ComboBox_GetCount( mrl_combo ) > 10 )
664 ComboBox_DeleteString( mrl_combo, 0 );
665 ComboBox_SetCurSel( mrl_combo, ComboBox_GetCount( mrl_combo ) - 1 );
668 /* Update the playlist */
669 playlist_t *p_playlist =
670 (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
672 if( p_playlist == NULL ) return;
674 for( int i = 0; i < (int)mrl.size(); i++ )
676 vlc_bool_t b_start = !i && i_open_arg;
677 playlist_item_t *p_item =
678 playlist_ItemNew( p_intf, (const char*)mrl[i].c_str(),
679 (const char *)mrl[i].c_str() );
682 while( i + 1 < (int)mrl.size() &&
683 ((const char *)mrl[i + 1].c_str())[0] == ':' )
685 playlist_ItemAddOption( p_item, mrl[i + 1].c_str() );
689 /* Get the options from the subtitles dialog */
690 if( (SendMessage( subsfile_checkbox, BM_GETCHECK, 0, 0 ) & BST_CHECKED)
691 && subsfile_mrl.size() )
693 for( int j = 0; j < (int)subsfile_mrl.size(); j++ )
695 playlist_ItemAddOption( p_item, subsfile_mrl[j].c_str() );
699 int i_id = playlist_AddItem( p_playlist, p_item,
700 PLAYLIST_APPEND, PLAYLIST_END );
704 playlist_Control( p_playlist, PLAYLIST_ITEMPLAY , p_item );
708 //TogglePlayButton( PLAYING_S );
710 vlc_object_release( p_playlist );
713 /*****************************************************************************
714 * File panel event methods.
715 *****************************************************************************/
716 void OpenDialog::OnFilePanelChange()
718 UpdateMRL( FILE_ACCESS );
721 void OpenDialog::OnFileBrowse()
724 TCHAR DateiName[80+1] = _T("\0");
725 static TCHAR szFilter[] = _T("All (*.*)\0*.*\0");
731 memset(&ofn, 0, sizeof(OPENFILENAME));
732 ofn.lStructSize = sizeof (OPENFILENAME);
733 ofn.hwndOwner = NULL;
734 ofn.hInstance = hInst;
735 ofn.lpstrFilter = szFilter;
736 ofn.lpstrCustomFilter = NULL;
737 ofn.nMaxCustFilter = 0;
738 ofn.nFilterIndex = 1;
739 ofn.lpstrFile = (LPTSTR) DateiName;
741 ofn.lpstrFileTitle = NULL;
742 ofn.nMaxFileTitle = 40;
743 ofn.lpstrInitialDir = NULL;
744 ofn.lpstrTitle = _T("Open File");
747 ofn.nFileExtension = 0;
748 ofn.lpstrDefExt = NULL;
751 ofn.lpTemplateName = NULL;
752 if( GetOpenFileName((LPOPENFILENAME) &ofn) )
754 size = WideCharToMultiByte( CP_ACP, 0, ofn.lpstrFile, -1, NULL,
756 psz_filename = ( char * )malloc( size );
757 WideCharToMultiByte( CP_ACP, 0, ofn.lpstrFile, -1, psz_filename,
758 size, NULL, &bTemp );
760 if( strchr( psz_filename, ' ' ) )
763 path += psz_filename;
769 SetWindowText( file_combo, _FROMMB(path.c_str()) );
770 ComboBox_AddString( file_combo, _FROMMB(path.c_str()) );
771 if( ComboBox_GetCount( file_combo ) > 10 )
772 ComboBox_DeleteString( file_combo, 0 );
774 UpdateMRL( FILE_ACCESS );
778 /*****************************************************************************
779 * Net panel event methods.
780 *****************************************************************************/
781 void OpenDialog::OnNetPanelChange( int event )
787 if( event >= NetPort1_Event && event <= NetPort2_Event )
789 size = Edit_GetTextLength( net_ports[event - NetPort1_Event] );
790 wUnicode = new WCHAR[size + 1]; //Add 1 for the NULL
791 Edit_GetText( net_ports[event - NetPort1_Event], wUnicode, size + 1);
792 swscanf( wUnicode, _T("%d"), &port );
793 i_net_ports[event - NetPort1_Event] = port;
797 UpdateMRL( NET_ACCESS );
800 void OpenDialog::OnNetTypeChange( int event )
804 i_net_type = event - NetRadio1_Event;
806 if( event == NetRadio1_Event )
808 SetWindowPos( net_port_label[0], HWND_TOP, 0, 0, 0, 0,
809 SWP_NOMOVE | SWP_NOSIZE );
810 SetWindowPos( net_ports[0], HWND_TOP, 0, 0, 0, 0,
811 SWP_NOMOVE | SWP_NOSIZE );
812 SetWindowPos( hUpdown[0], HWND_TOP, 0, 0, 0, 0,
813 SWP_NOMOVE | SWP_NOSIZE );
815 else if( event == NetRadio2_Event )
817 SetWindowPos( net_addrs_label[1], HWND_TOP, 0, 0, 0, 0,
818 SWP_NOMOVE | SWP_NOSIZE );
819 SetWindowPos( net_addrs[1], HWND_TOP, 0, 0, 0, 0,
820 SWP_NOMOVE | SWP_NOSIZE );
821 SetWindowPos( net_port_label[1], HWND_TOP, 0, 0, 0, 0,
822 SWP_NOMOVE | SWP_NOSIZE );
823 SetWindowPos( net_ports[1], HWND_TOP, 0, 0, 0, 0,
824 SWP_NOMOVE | SWP_NOSIZE );
825 SetWindowPos( hUpdown[1], HWND_TOP, 0, 0, 0, 0,
826 SWP_NOMOVE | SWP_NOSIZE );
828 else if( event == NetRadio3_Event )
830 SetWindowPos( net_addrs_label[2], HWND_TOP, 0, 0, 0, 0,
831 SWP_NOMOVE | SWP_NOSIZE );
832 SetWindowPos( net_addrs[2], HWND_TOP, 0, 0, 0, 0,
833 SWP_NOMOVE | SWP_NOSIZE );
835 else if( event == NetRadio4_Event )
837 SetWindowPos( net_addrs_label[3], HWND_TOP, 0, 0, 0, 0,
838 SWP_NOMOVE | SWP_NOSIZE );
839 SetWindowPos( net_addrs[3], HWND_TOP, 0, 0, 0, 0,
840 SWP_NOMOVE | SWP_NOSIZE );
843 UpdateMRL( NET_ACCESS );
846 void OpenDialog::DisableNETCtrl()
848 for( int i=0; i<4; i++ )
850 SetWindowPos( net_port_label[i], HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
851 SetWindowPos( net_ports[i], HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
852 SetWindowPos( hUpdown[i], HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
854 SetWindowPos( net_addrs_label[i], HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
855 SetWindowPos( net_addrs[i], HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
858 UpdateMRL( FILE_ACCESS );
861 /*****************************************************************************
862 * Subtitles file event methods.
863 *****************************************************************************/
864 void OpenDialog::OnSubsFileEnable()
866 EnableWindow( subsfile_button, ( SendMessage( subsfile_checkbox,
867 BM_GETCHECK, 0, 0 ) & BST_CHECKED ) ? TRUE : FALSE );
870 void OpenDialog::OnSubsFileSettings( HWND hwnd )
873 /* Show/hide the open dialog */
874 SubsFileDialog *subsfile_dialog = new SubsFileDialog( p_intf, hInst );
875 DialogBoxParam( hInst, (LPCTSTR)IDD_DUMMY, hwnd,
876 (DLGPROC)subsfile_dialog->BaseWndProc,
877 (long)subsfile_dialog );
879 subsfile_mrl.clear();
881 for( int i = 0; i < subsfile_dialog->subsfile_mrl.size(); i++ )
882 subsfile_mrl.push_back( subsfile_dialog->subsfile_mrl[i] );
884 delete subsfile_dialog;
887 /*****************************************************************************
889 *****************************************************************************/
890 vector<string> SeparateEntries( LPWSTR entries )
893 vlc_bool_t b_quotes_mode = VLC_FALSE;
894 vector<string> entries_array;
895 LPWSTR entry = new TCHAR[ wcslen(entries) + 1 ];
897 LPWSTR strToken = entries;
898 length = wcscspn( strToken, _T(" \t\r\n\"") );
899 swprintf( entry, _T("") );
901 while( strToken - entries < wcslen(entries) )
903 wcsncat( entry, strToken, length );
905 wcsncat( entry, strToken + length, 1 );
907 if( !b_quotes_mode && strToken[length] == _T('\"') )
909 /* Enters quotes mode */
910 entry[ wcslen(entry) - 1 ] = NULL;
911 b_quotes_mode = VLC_TRUE;
913 else if( b_quotes_mode && strToken[length] == _T('\"') )
915 /* Finished the quotes mode */
916 entry[ wcslen(entry) - 1 ] = NULL;
917 if( wcscmp( entry, _T("") ) != 0 )
919 entries_array.push_back( _TOMB(entry) );
921 swprintf( entry, _T("") );
922 b_quotes_mode = VLC_FALSE;
924 else if( !b_quotes_mode && strToken[length] != _T('\"') )
926 /* we found a non-quoted standalone string */
927 if( strToken + length - entries < wcslen(entries) ||/*token.HasMoreTokens() ||*/ //FIX ME IF YOU CAN
928 strToken[length] == _T(' ') ||
929 strToken[length] == _T('\t') ||
930 strToken[length] == _T('\r') ||
931 strToken[length] == _T('\n') )
932 entry[ wcslen(entry) - 1 ]/*strToken[length]*/ = NULL;
933 if( wcscmp( entry, _T("") ) != 0 )
935 entries_array.push_back( _TOMB(entry) );
937 swprintf( entry, _T("") );
942 strToken += length + 1;
943 length = wcscspn( strToken, _T(" \t\r\n\"") );
946 if( wcscmp( entry, _T("") ) != 0 )
948 entries_array.push_back( _TOMB(entry) );
951 return entries_array;