0d13d04ee2babb4cadd8561b7837bd0f9ab1993a
[vlc.git] / modules / gui / wxwindows / open.cpp
1 /*****************************************************************************
2  * open.cpp : wxWindows plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000-2001 VideoLAN
5  * $Id: open.cpp,v 1.11 2003/04/01 00:18:29 gbazin Exp $
6  *
7  * Authors: Gildas Bazin <gbazin@netcourrier.com>
8  *
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.
13  *
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.
18  *
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, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <stdlib.h>                                      /* malloc(), free() */
28 #include <errno.h>                                                 /* ENOMEM */
29 #include <string.h>                                            /* strerror() */
30 #include <stdio.h>
31
32 #include <vlc/vlc.h>
33
34 #ifdef WIN32                                                 /* mingw32 hack */
35 #undef Yield
36 #undef CreateDialog
37 #endif
38
39 /* Let vlc take care of the i18n stuff */
40 #define WXINTL_NO_GETTEXT_MACRO
41
42 #include <wx/wxprec.h>
43 #include <wx/wx.h>
44 #include <wx/notebook.h>
45 #include <wx/textctrl.h>
46 #include <wx/combobox.h>
47 #include <wx/spinctrl.h>
48 #include <wx/statline.h>
49
50 #include <vlc/intf.h>
51
52 #include "wxwindows.h"
53
54 #ifndef wxRB_SINGLE
55 #   define wxRB_SINGLE 0
56 #endif
57
58 /*****************************************************************************
59  * Event Table.
60  *****************************************************************************/
61
62 /* IDs for the controls and the menu commands */
63 enum
64 {
65     Notebook_Event = wxID_HIGHEST,
66     MRL_Event,
67
68     FileBrowse_Event,
69     FileName_Event,
70
71     DiscType_Event,
72     DiscDevice_Event,
73     DiscTitle_Event,
74     DiscChapter_Event,
75
76     NetType_Event,
77     NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
78     NetPort1_Event, NetPort2_Event, NetPort3_Event, NetPort4_Event,
79     NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
80
81     SoutEnable_Event,
82     SoutSettings_Event,
83
84     DemuxDump_Event,
85     DemuxDumpEnable_Event,
86     DemuxDumpBrowse_Event,
87 };
88
89 BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
90     /* Button events */
91     EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
92     EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
93
94     EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)
95
96     EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange) 
97
98     /* Events generated by the file panel */
99     EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
100     EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
101
102     /* Events generated by the disc panel */
103     EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
104     EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
105     EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
106     EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
107     EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
108     EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
109
110     /* Events generated by the net panel */
111     EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
112     EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
113     EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
114     EVT_RADIOBUTTON(NetRadio4_Event, OpenDialog::OnNetTypeChange)
115     EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
116     EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChange)
117     EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
118     EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChange)
119     EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
120     EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChange)
121     EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
122     EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
123     EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange)
124
125     /* Events generated by the stream output buttons */
126     EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
127     EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
128
129     /* Events generated by the demux dump buttons */
130     EVT_CHECKBOX(DemuxDumpEnable_Event, OpenDialog::OnDemuxDumpEnable)
131     EVT_TEXT(DemuxDump_Event, OpenDialog::OnDemuxDumpChange)
132     EVT_BUTTON(DemuxDumpBrowse_Event, OpenDialog::OnDemuxDumpBrowse)
133
134 END_EVENT_TABLE()
135
136 /*****************************************************************************
137  * Constructor.
138  *****************************************************************************/
139 OpenDialog::OpenDialog( intf_thread_t *_p_intf, Interface *_p_main_interface,
140                         int i_access_method ):
141     wxDialog( _p_main_interface, -1, _("Open Target"), wxDefaultPosition,
142              wxDefaultSize, wxDEFAULT_FRAME_STYLE )
143 {
144     /* Initializations */
145     p_intf = _p_intf;
146     p_main_interface = _p_main_interface;
147
148     /* Create a panel to put everything in */
149     wxPanel *panel = new wxPanel( this, -1 );
150     panel->SetAutoLayout( TRUE );
151
152     /* Create MRL combobox */
153     wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
154     wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
155                                _("Media Resource Locator (MRL)") );
156     wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
157                                                         wxHORIZONTAL );
158     wxStaticText *mrl_label = new wxStaticText( panel, -1,
159                                                 _("Open Target:") );
160     mrl_combo = new wxComboBox( panel, MRL_Event, mrl,
161                                 wxPoint(20,25), wxSize(120, -1),
162                                 0, NULL );
163     mrl_sizer->Add( mrl_label, 0, wxEXPAND | wxALL, 5 );
164     mrl_sizer->Add( mrl_combo, 1, wxEXPAND | wxALL, 5 );
165     mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
166
167
168     /* Create Static Text */
169     wxStaticText *label = new wxStaticText( panel, -1,
170         _("Alternatively, you can build an MRL using one of the "
171           "following predefined targets:") );
172
173     /* Create Stream Output checkox */
174     wxFlexGridSizer *sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
175     sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
176                                            _("Stream output") );
177     sout_checkbox->SetToolTip( _("Use VLC has a stream server") );
178     sout_sizer->Add( sout_checkbox, 0,
179                      wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
180     sout_button = new wxButton( panel, SoutSettings_Event, _("Settings...") );
181     sout_button->Disable();
182
183     char *psz_sout = config_GetPsz( p_intf, "sout" );
184     if( psz_sout && *psz_sout )
185     {
186         sout_checkbox->SetValue(TRUE);
187         sout_button->Enable();
188     }
189     if( psz_sout ) free( psz_sout );
190
191     sout_sizer->Add( sout_button, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
192
193     /* Create Demux Dump checkox */
194     wxBoxSizer *demuxdump_sizer = new wxBoxSizer( wxHORIZONTAL );
195     demuxdump_checkbox = new wxCheckBox( panel, DemuxDumpEnable_Event,
196                                _("Capture input stream") );
197     demuxdump_checkbox->SetToolTip(
198                            _("Capture the stream you are playing to a file") );
199     demuxdump_textctrl = new wxTextCtrl( panel, DemuxDump_Event,
200                                          "", wxDefaultPosition, wxDefaultSize,
201                                          wxTE_PROCESS_ENTER);
202     demuxdump_button = new wxButton( panel, DemuxDumpBrowse_Event,
203                                      _("Browse...") );
204
205     char *psz_demuxdump = config_GetPsz( p_intf, "demuxdump-file" );
206     if( psz_demuxdump && *psz_demuxdump )
207     {
208         demuxdump_textctrl->SetValue( psz_demuxdump );
209     }
210     if( psz_demuxdump ) free( psz_demuxdump );
211
212     demuxdump_textctrl->Disable();
213     demuxdump_button->Disable();
214     demuxdump_sizer->Add( demuxdump_checkbox, 0,
215                           wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 10 );
216     demuxdump_sizer->Add( demuxdump_button, 0,
217                           wxALL | wxALIGN_CENTER_VERTICAL, 10 );
218     demuxdump_sizer->Add( demuxdump_textctrl, 1, wxALL, 10 );
219
220     /* Separation */
221     wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
222
223     /* Create the buttons */
224     wxButton *ok_button = new wxButton( panel, wxID_OK, _("OK") );
225     ok_button->SetDefault();
226     wxButton *cancel_button = new wxButton( panel, wxID_CANCEL, _("Cancel") );
227
228     /* Create notebook */
229     wxNotebook *notebook = new wxNotebook( panel, Notebook_Event );
230     wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
231
232     notebook->AddPage( FilePanel( notebook ), _("File"),
233                        i_access_method == FILE_ACCESS );
234     notebook->AddPage( DiscPanel( notebook ), _("Disc"),
235                        i_access_method == DISC_ACCESS );
236     notebook->AddPage( NetPanel( notebook ), _("Network"),
237                        i_access_method == NET_ACCESS );
238 #ifndef WIN32
239     notebook->AddPage( SatPanel( notebook ), _("Satellite"),
240                        i_access_method == SAT_ACCESS );
241 #endif
242
243     /* Update Disc panel */
244     wxCommandEvent dummy_event;
245     OnDiscTypeChange( dummy_event );
246
247     /* Update Net panel */
248     dummy_event.SetId( NetRadio1_Event );
249     OnNetTypeChange( dummy_event );
250
251     /* Update MRL */
252     wxNotebookEvent event = wxNotebookEvent( wxEVT_NULL, 0, i_access_method );
253     OnPageChange( event );
254
255     /* Place everything in sizers */
256     wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
257     button_sizer->Add( ok_button, 0, wxALL, 5 );
258     button_sizer->Add( cancel_button, 0, wxALL, 5 );
259     button_sizer->Layout();
260     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
261     wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
262     panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
263     panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
264     panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
265     panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
266     panel_sizer->Add( demuxdump_sizer, 0, wxEXPAND | wxALIGN_LEFT | wxALL, 5 );
267     panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
268     panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
269     panel_sizer->Layout();
270     panel->SetSizerAndFit( panel_sizer );
271     main_sizer->Add( panel, 1, wxGROW, 0 );
272     main_sizer->Layout();
273     SetSizerAndFit( main_sizer );
274 }
275
276 OpenDialog::~OpenDialog()
277 {
278 }
279
280 /*****************************************************************************
281  * Private methods.
282  *****************************************************************************/
283 wxPanel *OpenDialog::FilePanel( wxWindow* parent )
284 {
285     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
286                                   wxSize(200, 200) );
287
288     wxBoxSizer *sizer = new wxBoxSizer( wxHORIZONTAL );
289
290     file_combo = new wxComboBox( panel, FileName_Event, "",
291                                  wxPoint(20,25), wxSize(200, -1), 0, NULL );
292     wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
293                                             _("Browse...") );
294     sizer->Add( file_combo, 1, wxALL, 5 );
295     sizer->Add( browse_button, 0, wxALL, 5 );
296
297     panel->SetSizerAndFit( sizer );
298     return panel;
299 }
300
301 wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
302 {
303     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
304                                   wxSize(200, 200) );
305
306     wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
307     wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
308
309     static const wxString disc_type_array[] =
310     {
311         _("DVD"),
312         _("DVD (menus support)"),
313         _("VCD")
314     };
315
316     disc_type = new wxRadioBox( panel, DiscType_Event, _("Disc type"),
317                                 wxDefaultPosition, wxDefaultSize,
318                                 WXSIZEOF(disc_type_array), disc_type_array,
319                                 WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
320     sizer_row->Add( disc_type, 0, wxEXPAND | wxALL, 5 );
321
322     wxStaticText *label = new wxStaticText( panel, -1, _("Device name") );
323     disc_device = new wxTextCtrl( panel, DiscDevice_Event, "",
324                                   wxDefaultPosition, wxDefaultSize,
325                                   wxTE_PROCESS_ENTER);
326
327     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
328     sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
329
330     label = new wxStaticText( panel, -1, _("Title") );
331     disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
332
333     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
334     sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
335
336     label = new wxStaticText( panel, -1, _("Chapter") );
337     disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
338     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
339     sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
340     sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
341
342     panel->SetSizerAndFit( sizer_row );
343     return panel;
344 }
345
346 wxPanel *OpenDialog::NetPanel( wxWindow* parent )
347 {
348     int i;
349     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
350                                   wxSize(200, 200) );
351
352     wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
353     wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
354
355     static const wxString net_type_array[] =
356     {
357         _("UDP/RTP"),
358         _("UDP/RTP Multicast"),
359         _("Channel server"),
360         _("HTTP/FTP/MMS")
361     };
362
363     for( i=0; i<4; i++ )
364     {
365         net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
366                                            net_type_array[i],
367                                            wxDefaultPosition, wxDefaultSize,
368                                            wxRB_SINGLE );
369
370         net_subpanels[i] = new wxPanel( panel, -1,
371                                         wxDefaultPosition, wxDefaultSize );
372     }
373
374     /* UDP/RTP row */
375     wxFlexGridSizer *subpanel_sizer;
376     wxStaticText *label;
377     int val = config_GetInt( p_intf, "server-port" );
378     subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
379     label = new wxStaticText( net_subpanels[0], -1, _("Port") );
380     net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
381                                    wxString::Format("%d", val),
382                                    wxDefaultPosition, wxDefaultSize,
383                                    wxSP_ARROW_KEYS,
384                                    0, 16000, val);
385
386     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
387     subpanel_sizer->Add( net_ports[0], 1,
388                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
389     net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
390     net_radios[0]->SetValue( TRUE );
391
392     /* UDP/RTP Multicast row */
393     subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
394     label = new wxStaticText( net_subpanels[1], -1, _("Address") );
395     net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, "",
396                                    wxDefaultPosition, wxDefaultSize,
397                                    wxTE_PROCESS_ENTER);
398     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
399     subpanel_sizer->Add( net_addrs[1], 1,
400                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
401
402     label = new wxStaticText( net_subpanels[1], -1, _("Port") );
403     net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
404                                    wxString::Format("%d", val),
405                                    wxDefaultPosition, wxDefaultSize,
406                                    wxSP_ARROW_KEYS,
407                                    0, 16000, val);
408
409     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
410     subpanel_sizer->Add( net_ports[1], 1,
411                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
412     net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
413
414     /* Channel server row */
415     subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
416     label = new wxStaticText( net_subpanels[2], -1, _("Address") );
417     net_addrs[2] = new wxTextCtrl( net_subpanels[2], NetAddr3_Event, "",
418                                    wxDefaultPosition, wxDefaultSize,
419                                    wxTE_PROCESS_ENTER);
420     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
421     subpanel_sizer->Add( net_addrs[2], 1,
422                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
423
424     label = new wxStaticText( net_subpanels[2], -1, _("Port") );
425     net_ports[2] = new wxSpinCtrl( net_subpanels[2], NetPort3_Event,
426                                    wxString::Format("%d", val),
427                                    wxDefaultPosition, wxDefaultSize,
428                                    wxSP_ARROW_KEYS,
429                                    0, 16000, val);
430
431     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
432     subpanel_sizer->Add( net_ports[2], 1,
433                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
434     net_subpanels[2]->SetSizerAndFit( subpanel_sizer );
435
436     /* HTTP row */
437     subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
438     label = new wxStaticText( net_subpanels[3], -1, _("URL") );
439     net_addrs[3] = new wxTextCtrl( net_subpanels[3], NetAddr4_Event, "",
440                                    wxDefaultPosition, wxSize( 200, -1 ),
441                                    wxTE_PROCESS_ENTER);
442     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
443     subpanel_sizer->Add( net_addrs[3], 1,
444                          wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
445     net_subpanels[3]->SetSizerAndFit( subpanel_sizer );
446
447     /* Stuff everything into the main panel */
448     for( i=0; i<4; i++ )
449     {
450         sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
451         sizer->Add( net_subpanels[i], 1,
452                     wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
453     }
454
455     sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
456
457     panel->SetSizerAndFit( sizer_row );
458     return panel;
459 }
460
461 wxPanel *OpenDialog::SatPanel( wxWindow* parent )
462 {
463     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
464                                   wxSize(200, 200) );
465     return panel;
466 }
467
468 void OpenDialog::UpdateMRL( int i_access_method )
469 {
470     wxString demux;
471
472     i_current_access_method = i_access_method;
473
474     /* Check if the user asked for demuxdump */
475     if( demuxdump_checkbox->GetValue() )
476     {
477         demux = "/demuxdump";
478     }
479
480     switch( i_access_method )
481     {
482     case FILE_ACCESS:
483         mrl = "file" + demux + "://" + file_combo->GetValue();
484         break;
485     case DISC_ACCESS:
486         mrl = ( disc_type->GetSelection() == 0 ? "dvdold" :
487                 disc_type->GetSelection() == 1 ? "dvd" : "vcd" )
488                   + demux + "://"
489                   + disc_device->GetLineText(0)
490                   + wxString::Format( "@%d:%d",
491                                       disc_title->GetValue(),
492                                       disc_chapter->GetValue() );
493         break;
494     case NET_ACCESS:
495         switch( i_net_type )
496         {
497         case 0:
498             if( net_ports[0]->GetValue() !=
499                 config_GetInt( p_intf, "server-port" ) )
500             {
501                 mrl = "udp" + demux +
502                        wxString::Format( "://@:%d", net_ports[0]->GetValue() );
503             }
504             else
505             {
506                 mrl = "udp" + demux + "://";
507             }
508             break;
509
510         case 1:
511             mrl = "udp" + demux + "://@" + net_addrs[1]->GetLineText(0);
512             if( net_ports[1]->GetValue() !=
513                 config_GetInt( p_intf, "server-port" ) )
514             {
515                 mrl = mrl + wxString::Format( ":%d",
516                                               net_ports[1]->GetValue() );
517             }
518             break;
519
520         case 2:
521             mrl = "udp" + demux + "://";
522             break;
523
524         case 3:
525             /* http access */     
526             mrl = "http" + demux + "://" + net_addrs[3]->GetLineText(0);
527             break;
528         }
529         break;
530     case SAT_ACCESS:
531         mrl = "satellite" + demux + "://";
532         break;
533     default:
534         break;
535     }
536
537     mrl_combo->SetValue( mrl );
538 }
539
540 /*****************************************************************************
541  * Events methods.
542  *****************************************************************************/
543 void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
544 {
545     EndModal( wxID_OK );
546 }
547
548 void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
549 {
550     EndModal( wxID_CANCEL );
551 }
552
553 void OpenDialog::OnPageChange( wxNotebookEvent& event )
554 {
555     UpdateMRL( event.GetSelection() );
556 }
557
558 void OpenDialog::OnMRLChange( wxCommandEvent& event )
559 {
560     mrl = event.GetString();
561 }
562
563 /*****************************************************************************
564  * File panel event methods.
565  *****************************************************************************/
566 void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
567 {
568     UpdateMRL( FILE_ACCESS );
569 }
570
571 void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
572 {
573     wxFileDialog dialog( this, _("Open file"), "", "", "*.*",
574                          wxOPEN );
575
576     if( dialog.ShowModal() == wxID_OK )
577     {
578         file_combo->SetValue( dialog.GetPath() );      
579         UpdateMRL( FILE_ACCESS );
580     }
581 }
582
583 /*****************************************************************************
584  * Disc panel event methods.
585  *****************************************************************************/
586 void OpenDialog::OnDiscPanelChange( wxCommandEvent& WXUNUSED(event) )
587 {
588     UpdateMRL( DISC_ACCESS );
589 }
590
591 void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
592 {
593     char *psz_device;
594
595     switch( disc_type->GetSelection() )
596     {
597     case 2:
598         psz_device = config_GetPsz( p_intf, "vcd" );
599         disc_device->SetValue( psz_device ? psz_device : "" );
600         break;
601
602     default:
603         psz_device = config_GetPsz( p_intf, "dvd" );
604         disc_device->SetValue( psz_device ? psz_device : "" );
605         break;
606     }
607
608     if( psz_device ) free( psz_device );
609
610     switch( disc_type->GetSelection() )
611     {
612     case 1:
613         disc_title->SetRange( 0, 255 );
614         disc_title->SetValue( 0 );
615         break;
616
617     default:
618         disc_title->SetRange( 1, 255 );
619         disc_title->SetValue( 1 );
620         break;
621     }
622
623     disc_chapter->SetRange( 1, 255 );
624     disc_chapter->SetValue( 1 );
625
626     UpdateMRL( DISC_ACCESS );
627 }
628
629 /*****************************************************************************
630  * Net panel event methods.
631  *****************************************************************************/
632 void OpenDialog::OnNetPanelChange( wxCommandEvent& WXUNUSED(event) )
633 {
634     UpdateMRL( NET_ACCESS );
635 }
636
637 void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
638 {
639     int i;
640
641     i_net_type = event.GetId() - NetRadio1_Event;
642
643     for(i=0; i<4; i++)
644     {
645         net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
646         net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
647     }
648
649     UpdateMRL( NET_ACCESS );
650 }
651
652 /*****************************************************************************
653  * Stream output event methods.
654  *****************************************************************************/
655 void OpenDialog::OnSoutEnable( wxCommandEvent& event )
656 {
657     sout_button->Enable( event.GetInt() != 0 );
658     if( !event.GetInt() )
659     {
660         config_PutPsz( p_intf, "sout", "" );
661     }
662     else
663     {
664         demuxdump_checkbox->SetValue( 0 );
665         wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
666         event.SetInt( 0 );
667         OnDemuxDumpEnable( event );
668     }
669 }
670
671 void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
672 {
673     /* Show/hide the open dialog */
674     SoutDialog dialog( p_intf, p_main_interface );
675
676     if( dialog.ShowModal() == wxID_OK )
677     {
678         config_PutPsz( p_intf, "sout", (char *)dialog.mrl.c_str() );
679     }
680 }
681
682 /*****************************************************************************
683  * Demux dump event methods.
684  *****************************************************************************/
685 void OpenDialog::OnDemuxDumpEnable( wxCommandEvent& event )
686 {
687     demuxdump_textctrl->Enable( event.GetInt() != 0 );
688     demuxdump_button->Enable( event.GetInt() != 0 );
689
690     if( event.GetInt() )
691     {
692         sout_checkbox->SetValue( 0 );
693         wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
694         event.SetInt( 0 );
695         OnSoutEnable( event );
696     }
697
698     UpdateMRL( i_current_access_method );
699 }
700
701 void OpenDialog::OnDemuxDumpBrowse( wxCommandEvent& WXUNUSED(event) )
702 {
703     wxFileDialog dialog( this, _("Save file"), "", "", "*.*", wxSAVE );
704
705     if( dialog.ShowModal() == wxID_OK )
706     {
707         demuxdump_textctrl->SetValue( dialog.GetPath() );
708         wxCommandEvent event = wxCommandEvent( wxEVT_NULL );
709         OnDemuxDumpChange( event );
710     }
711 }
712
713 void OpenDialog::OnDemuxDumpChange( wxCommandEvent& WXUNUSED(event) )
714 {
715     config_PutPsz( p_intf, "demuxdump-file",
716                    demuxdump_textctrl->GetValue() );
717 }