open.cpp 58.5 KB
Newer Older
gbazin's avatar
 
gbazin committed
1
2
3
/*****************************************************************************
 * open.cpp : wxWindows plugin for vlc
 *****************************************************************************
4
 * Copyright (C) 2000-2005 the VideoLAN team
Carlo Calabrò's avatar
Carlo Calabrò committed
5
 * $Id$
gbazin's avatar
 
gbazin committed
6
 *
7
 * Authors: Gildas Bazin <gbazin@videolan.org>
gbazin's avatar
 
gbazin committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 *
 * 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
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#include <stdlib.h>                                      /* malloc(), free() */
#include <errno.h>                                                 /* ENOMEM */
#include <string.h>                                            /* strerror() */
#include <stdio.h>

#include <vlc/vlc.h>
33
34
35
36
#ifdef HAVE_LIBCDIO
#include <cdio/cdio.h>
#include <cdio/cd_types.h>
#endif /* HAVE_LIBCDIO */
gbazin's avatar
 
gbazin committed
37
38

#include <wx/combobox.h>
gbazin's avatar
   
gbazin committed
39
#include <wx/statline.h>
gbazin's avatar
   
gbazin committed
40
#include <wx/tokenzr.h>
gbazin's avatar
 
gbazin committed
41
42
43

#include <vlc/intf.h>

zorglub's avatar
zorglub committed
44
45
#include <vector>

gbazin's avatar
   
gbazin committed
46
#include "wxwindows.h"
gbazin's avatar
   
gbazin committed
47
48
#include "preferences_widgets.h"

49
#ifndef wxRB_SINGLE
gbazin's avatar
   
gbazin committed
50
#   define wxRB_SINGLE 0
51
52
#endif

gbazin's avatar
 
gbazin committed
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*****************************************************************************
 * Event Table.
 *****************************************************************************/

/* IDs for the controls and the menu commands */
enum
{
    Notebook_Event = wxID_HIGHEST,
    MRL_Event,

    FileBrowse_Event,
    FileName_Event,

    DiscType_Event,
67
68
69
#ifdef HAVE_LIBCDIO
    DiscProbe_Event,
#endif
gbazin's avatar
 
gbazin committed
70
71
72
    DiscDevice_Event,
    DiscTitle_Event,
    DiscChapter_Event,
73
    DiscSub_Event,
74
    DiscAudio_Event,
gbazin's avatar
 
gbazin committed
75
76

    NetType_Event,
77
    NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
gbazin's avatar
   
gbazin committed
78
    NetPort1_Event, NetPort2_Event, NetPort3_Event,
79
    NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
zorglub's avatar
zorglub committed
80
    NetForceIPv6_Event, NetTimeshift_Event,
gbazin's avatar
   
gbazin committed
81

gbazin's avatar
   
gbazin committed
82
83
84
    SubsFileEnable_Event,
    SubsFileSettings_Event,

gbazin's avatar
   
gbazin committed
85
86
    SoutEnable_Event,
    SoutSettings_Event,
87

88
89
90
    CachingEnable_Event,
    CachingChange_Event,

91
    AdvancedOptions_Event
gbazin's avatar
 
gbazin committed
92
93
};

94
BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
gbazin's avatar
 
gbazin committed
95
96
97
98
99
100
    /* Button events */
    EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
    EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)

    EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)

101
    EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
gbazin's avatar
 
gbazin committed
102
103
104

    /* Events generated by the file panel */
    EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
gbazin's avatar
   
gbazin committed
105
    EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
gbazin's avatar
 
gbazin committed
106
107
108

    /* Events generated by the disc panel */
    EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
109
110
111
#ifdef HAVE_LIBCDIO
    EVT_CHECKBOX(DiscProbe_Event, OpenDialog::OnDiscProbe)
#endif
yoann's avatar
yoann committed
112
    EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscDeviceChange)
gbazin's avatar
 
gbazin committed
113
114
    EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
    EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
115
    EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChangeSpin)
gbazin's avatar
 
gbazin committed
116
    EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
117
    EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChangeSpin)
118
    EVT_TEXT(DiscSub_Event, OpenDialog::OnDiscPanelChange)
119
    EVT_TEXT(DiscAudio_Event, OpenDialog::OnDiscPanelChange)
120
    EVT_SPINCTRL(DiscSub_Event, OpenDialog::OnDiscPanelChangeSpin)
gbazin's avatar
 
gbazin committed
121
122
123
124
125

    /* Events generated by the net panel */
    EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
    EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
    EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
126
    EVT_RADIOBUTTON(NetRadio4_Event, OpenDialog::OnNetTypeChange)
gbazin's avatar
 
gbazin committed
127
    EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
128
    EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChangeSpin)
gbazin's avatar
 
gbazin committed
129
    EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
130
    EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChangeSpin)
gbazin's avatar
 
gbazin committed
131
    EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
132
    EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChangeSpin)
gbazin's avatar
 
gbazin committed
133
134
    EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
    EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
135
    EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange)
136
    EVT_CHECKBOX(NetForceIPv6_Event, OpenDialog::OnNetPanelChange)
zorglub's avatar
zorglub committed
137
    EVT_CHECKBOX(NetTimeshift_Event, OpenDialog::OnNetPanelChange)
gbazin's avatar
 
gbazin committed
138

gbazin's avatar
   
gbazin committed
139
140
141
142
    /* Events generated by the subtitle file buttons */
    EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
    EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)

gbazin's avatar
   
gbazin committed
143
144
145
    /* Events generated by the stream output buttons */
    EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
    EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
gbazin's avatar
   
gbazin committed
146

147
148
149
    /* Events generated by the caching button */
    EVT_CHECKBOX(CachingEnable_Event, OpenDialog::OnCachingEnable)
    EVT_TEXT(CachingChange_Event, OpenDialog::OnCachingChange)
150
    EVT_SPINCTRL(CachingChange_Event, OpenDialog::OnCachingChangeSpin)
151

gbazin's avatar
   
gbazin committed
152
    /* Hide the window when the user closes the window */
153
    EVT_CLOSE(OpenDialog::OnClose)
gbazin's avatar
   
gbazin committed
154

gbazin's avatar
 
gbazin committed
155
156
END_EVENT_TABLE()

157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*****************************************************************************
 * AutoBuiltPanel.
 *****************************************************************************/
WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);

class AutoBuiltPanel : public wxPanel
{
public:

    AutoBuiltPanel() { }
    AutoBuiltPanel( wxWindow *, OpenDialog *, intf_thread_t *,
                    const module_t * );

    virtual ~AutoBuiltPanel() {}

172
173
    void UpdateAdvancedMRL();

174
175
    wxString name;
    ArrayOfConfigControls config_array;
176
177
    ArrayOfConfigControls advanced_config_array;
    wxComboBox *p_advanced_mrl_combo;
178
179
180

private:
    intf_thread_t *p_intf;
181
182
183
184
185
186
    OpenDialog *p_open_dialog;

    void OnAdvanced( wxCommandEvent& event );
    wxDialog *p_advanced_dialog;

    DECLARE_EVENT_TABLE();
187
188
};

189
190
191
192
193
BEGIN_EVENT_TABLE(AutoBuiltPanel, wxPanel)
    EVT_BUTTON(AdvancedOptions_Event, AutoBuiltPanel::OnAdvanced)
END_EVENT_TABLE()

static void AutoBuildCallback( void *p_data )
194
195
196
197
{
    ((OpenDialog *)p_data)->UpdateMRL();
}

198
199
200
201
202
static void AutoBuildAdvancedCallback( void *p_data )
{
    ((AutoBuiltPanel *)p_data)->UpdateAdvancedMRL();
}

203
204
205
AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
                                intf_thread_t *_p_intf,
                                const module_t *p_module )
206
207
208
209
  : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize ),
    name( wxU(p_module->psz_object_name) ),
    p_advanced_mrl_combo( NULL ),
    p_intf( _p_intf ), p_open_dialog( dialog ), p_advanced_dialog( NULL )
210
211
212
{
    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
    module_config_t *p_item = p_module->p_config;
213
    bool b_advanced = false;
214
215
216

    if( p_item ) do
    {
217
218
219
        if( !(p_item->i_type & CONFIG_HINT) && p_item->b_advanced )
            b_advanced = true;

220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
        if( p_item->i_type & CONFIG_HINT || p_item->b_advanced )
            continue;

        ConfigControl *control =
            CreateConfigControl( VLC_OBJECT(p_intf), p_item, this );

        config_array.Add( control );

        /* Don't add items that were not recognized */
        if( control == NULL ) continue;

        control->SetUpdateCallback( AutoBuildCallback, (void *)dialog );

        sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
    }
    while( p_item->i_type != CONFIG_HINT_END && p_item++ );

237
238
239
240
241
242
243
244
245
    if( b_advanced )
    {
        wxButton *button =
            new wxButton( this, AdvancedOptions_Event,
                          wxU(_("Advanced options...")) );
        sizer->Add( button, 0, wxALL, 5 );

        /* Build the advanced dialog */
        p_advanced_dialog =
246
247
            new wxDialog( this, -1, ((wxString)wxU(_("Advanced options"))) +
                          wxT(" (") + wxU( p_module->psz_longname ) + wxT(")"),
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
                          wxDefaultPosition, wxDefaultSize,
                          wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );

        wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );

        /* Create MRL combobox */
        wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
        wxStaticBox *mrl_box =
            new wxStaticBox( p_advanced_dialog, -1,
                             wxU(_("Advanced options")) );
        wxStaticBoxSizer *mrl_sizer =
            new wxStaticBoxSizer( mrl_box, wxHORIZONTAL );
        wxStaticText *mrl_label =
            new wxStaticText( p_advanced_dialog, -1, wxU(_("Options:")) );
        p_advanced_mrl_combo =
            new wxComboBox( p_advanced_dialog, MRL_Event, wxT(""),
                            wxDefaultPosition, wxDefaultSize );
        mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
        mrl_sizer->Add( p_advanced_mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
        mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
        sizer->Add( mrl_sizer_sizer, 0, wxEXPAND | wxALL, 2 );

        /* Add advanced options to panel */
        module_config_t *p_item = p_module->p_config;
        if( p_item ) do
        {
            if( p_item->i_type & CONFIG_HINT || !p_item->b_advanced )
                continue;

            ConfigControl *control =
                CreateConfigControl( VLC_OBJECT(p_intf), p_item,
                                     p_advanced_dialog );

            advanced_config_array.Add( control );

            /* Don't add items that were not recognized */
            if( control == NULL ) continue;

            control->SetUpdateCallback( AutoBuildAdvancedCallback,
                                        (void *)this );

            sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
        }
        while( p_item->i_type != CONFIG_HINT_END && p_item++ );

        /* Separation */
294
        wxPanel *dummy_panel = new wxPanel( p_advanced_dialog, -1 );
295
296
297
298
299
        sizer->Add( dummy_panel, 1 );
        wxStaticLine *static_line =
            new wxStaticLine( p_advanced_dialog, wxID_OK );
        sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );

300
        /* Create buttons */
301
302
303
        wxButton *ok_button =
            new wxButton( p_advanced_dialog, wxID_OK, wxU(_("OK")) );
        ok_button->SetDefault();
304
305
306
307
308
309
310
        wxButton *cancel_button =
            new wxButton( p_advanced_dialog, wxID_CANCEL, wxU(_("Cancel")) );
        wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
        button_sizer->Add( ok_button, 0, wxALL, 5 );
        button_sizer->Add( cancel_button, 0, wxALL, 5 );
        button_sizer->Layout();
        sizer->Add( button_sizer, 0, wxALL, 0 );
311
312
313
314
315

        sizer->SetMinSize( 400, -1 );
        p_advanced_dialog->SetSizerAndFit( sizer );
    }

316
317
318
    this->SetSizerAndFit( sizer );
}

319
320
void AutoBuiltPanel::OnAdvanced( wxCommandEvent& event )
{
321
322
323
324
325
    if( p_advanced_dialog->ShowModal() == wxID_OK )
    {
        UpdateAdvancedMRL();
        p_open_dialog->UpdateMRL();
    }
326
327
328
329
330
331
332
333
334
335
}

void AutoBuiltPanel::UpdateAdvancedMRL()
{
    wxString mrltemp;

    for( int i = 0; i < (int)advanced_config_array.GetCount(); i++ )
    {
        ConfigControl *control = advanced_config_array.Item(i);

336
        mrltemp += (i ? wxT(" :") : wxT(":"));
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364

        if( control->GetType() == CONFIG_ITEM_BOOL &&
            !control->GetIntValue() ) mrltemp += wxT("no-");

        mrltemp += control->GetName();

        switch( control->GetType() )
        {
        case CONFIG_ITEM_STRING:
        case CONFIG_ITEM_FILE:
        case CONFIG_ITEM_DIRECTORY:
        case CONFIG_ITEM_MODULE:
            mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
            break;
        case CONFIG_ITEM_INTEGER:
            mrltemp +=
                wxString::Format( wxT("=%i"), control->GetIntValue() );
            break;
        case CONFIG_ITEM_FLOAT:
            mrltemp +=
                wxString::Format(wxT("=%f"), control->GetFloatValue());
            break;
        }
    }

    p_advanced_mrl_combo->SetValue( mrltemp );
}

gbazin's avatar
 
gbazin committed
365
366
367
/*****************************************************************************
 * Constructor.
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
368
OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
gbazin's avatar
   
gbazin committed
369
                        int i_access_method, int i_arg ):
370
      wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
gbazin's avatar
 
gbazin committed
371
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
zorglub's avatar
zorglub committed
372
373
374
375
376
377
{
    OpenDialog( _p_intf, _p_parent, i_access_method, i_arg, OPEN_NORMAL );
}

OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
                        int i_access_method, int i_arg, int _i_method ):
378
      wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
zorglub's avatar
zorglub committed
379
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
gbazin's avatar
 
gbazin committed
380
381
{
    /* Initializations */
zorglub's avatar
zorglub committed
382
    i_method = _i_method;
gbazin's avatar
 
gbazin committed
383
    p_intf = _p_intf;
gbazin's avatar
   
gbazin committed
384
    p_parent = _p_parent;
gbazin's avatar
   
gbazin committed
385
    SetIcon( *p_intf->p_sys->p_icon );
gbazin's avatar
   
gbazin committed
386
    file_dialog = NULL;
387
    i_disc_type_selection = 0;
zorglub's avatar
zorglub committed
388
    i_disc_title = 0;
gbazin's avatar
   
gbazin committed
389
    i_open_arg = i_arg;
Sam Hocevar's avatar
Sam Hocevar committed
390

gbazin's avatar
   
gbazin committed
391
392
    sout_dialog = NULL;
    subsfile_dialog = NULL;
yoann's avatar
yoann committed
393
    b_disc_device_changed = false;
gbazin's avatar
 
gbazin committed
394
395
396
397
398
399
400
401

    /* Create a panel to put everything in */
    wxPanel *panel = new wxPanel( this, -1 );
    panel->SetAutoLayout( TRUE );

    /* Create MRL combobox */
    wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
    wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
gbazin's avatar
   
gbazin committed
402
                               wxU(_("Media Resource Locator (MRL)")) );
gbazin's avatar
 
gbazin committed
403
404
405
    wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
                                                        wxHORIZONTAL );
    wxStaticText *mrl_label = new wxStaticText( panel, -1,
Carlo Calabrò's avatar
Carlo Calabrò committed
406
                                                wxU(_("Open:")) );
gbazin's avatar
   
gbazin committed
407
    mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
408
                                wxPoint(20,25), wxSize(120, -1) );
gbazin's avatar
   
gbazin committed
409
410
    mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
        "the full MRL you want to open.\n""Alternatively, the field will be "
gbazin's avatar
   
gbazin committed
411
        "filled automatically when you use the controls below.")) );
gbazin's avatar
   
gbazin committed
412

gbazin's avatar
   
gbazin committed
413
414
    mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
    mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
gbazin's avatar
 
gbazin committed
415
416
417
418
419
    mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );


    /* Create Static Text */
    wxStaticText *label = new wxStaticText( panel, -1,
gbazin's avatar
   
gbazin committed
420
421
        wxU(_("Alternatively, you can build an MRL using one of the "
              "following predefined targets:")) );
gbazin's avatar
 
gbazin committed
422

423
    wxFlexGridSizer *common_opt_sizer = new wxFlexGridSizer( 5, 1, 20 );
zorglub's avatar
zorglub committed
424
425

    if( i_method == OPEN_NORMAL )
gbazin's avatar
   
gbazin committed
426
    {
zorglub's avatar
zorglub committed
427
428
429
        /* Create Stream Output checkox */
        sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
                                         wxU(_("Stream output")) );
hartman's avatar
hartman committed
430
        sout_checkbox->SetToolTip( wxU(_("Use VLC as a server of streams")) );
431
432
433
        common_opt_sizer->Add( sout_checkbox, 0,
                               wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );

zorglub's avatar
zorglub committed
434
435
        sout_button = new wxButton( panel, SoutSettings_Event,
                                    wxU(_("Settings...")) );
yoann's avatar
yoann committed
436
        sout_button->Disable();
zorglub's avatar
zorglub committed
437
438
439
440
441
442

        char *psz_sout = config_GetPsz( p_intf, "sout" );
        if( psz_sout && *psz_sout )
        {
            sout_checkbox->SetValue(TRUE);
            sout_button->Enable();
gbazin's avatar
   
gbazin committed
443
            subsfile_mrl.Add( wxString(wxT("sout=")) + wxL2U(psz_sout) );
zorglub's avatar
zorglub committed
444
445
446
        }
        if( psz_sout ) free( psz_sout );

447
448
        common_opt_sizer->Add( sout_button, 1, wxALIGN_LEFT |
                               wxALIGN_CENTER_VERTICAL );
zorglub's avatar
zorglub committed
449

450
451
        common_opt_sizer->Add( new wxPanel( this, -1 ), 1,
                               wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
zorglub's avatar
zorglub committed
452
    }
gbazin's avatar
   
gbazin committed
453

454
455
456
457
    /* Create caching options */
    caching_checkbox = new wxCheckBox( panel, CachingEnable_Event,
                                       wxU(_("Caching")) );
    caching_checkbox->SetToolTip( wxU(_("Change the default caching value "
458
                                        "(in milliseconds)")) );
459
460
461
462
463
464
465
466
467
468
469
    common_opt_sizer->Add( caching_checkbox, 0,
                           wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
    caching_value = new wxSpinCtrl( panel, CachingChange_Event );
    caching_value->SetRange( 0, 1000000 );
    caching_value->Disable();
    common_opt_sizer->Add( caching_value, 0,
                           wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );

    /* Separation */
    wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );

gbazin's avatar
 
gbazin committed
470
    /* Create the buttons */
gbazin's avatar
   
gbazin committed
471
    wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
gbazin's avatar
 
gbazin committed
472
    ok_button->SetDefault();
gbazin's avatar
   
gbazin committed
473
474
    wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
                                            wxU(_("Cancel")) );
gbazin's avatar
 
gbazin committed
475

gbazin's avatar
   
gbazin committed
476
    /* Create notebook */
gbazin's avatar
   
gbazin committed
477
    notebook = new wxNotebook( panel, Notebook_Event );
478

zorglub's avatar
zorglub committed
479
#if (!wxCHECK_VERSION(2,5,0))
gbazin's avatar
   
gbazin committed
480
    wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
zorglub's avatar
zorglub committed
481
#endif
gbazin's avatar
   
gbazin committed
482

gbazin's avatar
   
gbazin committed
483
    notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
gbazin's avatar
   
gbazin committed
484
                       i_access_method == FILE_ACCESS );
gbazin's avatar
   
gbazin committed
485
    notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
gbazin's avatar
   
gbazin committed
486
                       i_access_method == DISC_ACCESS );
gbazin's avatar
   
gbazin committed
487
    notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
gbazin's avatar
   
gbazin committed
488
                       i_access_method == NET_ACCESS );
489

490
491
492
493
494
495
    module_t *p_module = config_FindModule( VLC_OBJECT(p_intf), "v4l" );
    if( p_module )
    {
        AutoBuiltPanel *autopanel =
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
        input_tab_array.Add( autopanel );
zorglub's avatar
zorglub committed
496
497
        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
                        p_module->psz_shortname : p_module->psz_object_name ),
498
499
500
501
502
503
504
505
506
                           i_access_method == CAPTURE_ACCESS );
    }

    p_module = config_FindModule( VLC_OBJECT(p_intf), "pvr" );
    if( p_module )
    {
        AutoBuiltPanel *autopanel =
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
        input_tab_array.Add( autopanel );
zorglub's avatar
zorglub committed
507
508
        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
                        p_module->psz_shortname : p_module->psz_object_name ),
509
510
511
512
513
514
515
516
517
                           i_access_method == CAPTURE_ACCESS );
    }

    p_module = config_FindModule( VLC_OBJECT(p_intf), "dvb" );
    if( p_module )
    {
        AutoBuiltPanel *autopanel =
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
        input_tab_array.Add( autopanel );
zorglub's avatar
zorglub committed
518
519
        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
                        p_module->psz_shortname : p_module->psz_object_name ),
520
521
522
523
                           i_access_method == CAPTURE_ACCESS );
    }

    p_module = config_FindModule( VLC_OBJECT(p_intf), "dshow" );
gbazin's avatar
   
gbazin committed
524
525
    if( p_module )
    {
526
527
528
        AutoBuiltPanel *autopanel =
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
        input_tab_array.Add( autopanel );
zorglub's avatar
zorglub committed
529
530
        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
                        p_module->psz_shortname : p_module->psz_object_name ),
gbazin's avatar
gbazin committed
531
                           i_access_method == CAPTURE_ACCESS );
gbazin's avatar
   
gbazin committed
532
533
    }

gbazin's avatar
   
gbazin committed
534
535
536
537
    /* Update Disc panel */
    wxCommandEvent dummy_event;
    OnDiscTypeChange( dummy_event );

gbazin's avatar
   
gbazin committed
538
539
540
541
    /* Update Net panel */
    dummy_event.SetId( NetRadio1_Event );
    OnNetTypeChange( dummy_event );

gbazin's avatar
 
gbazin committed
542
    /* Update MRL */
543
    wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
gbazin's avatar
 
gbazin committed
544
545
546
547
548
549
550
551
552
553
554
    OnPageChange( event );

    /* Place everything in sizers */
    wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
    button_sizer->Add( ok_button, 0, wxALL, 5 );
    button_sizer->Add( cancel_button, 0, wxALL, 5 );
    button_sizer->Layout();
    wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
    wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
    panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
    panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
zorglub's avatar
zorglub committed
555
#if (!wxCHECK_VERSION(2,5,0))
gbazin's avatar
   
gbazin committed
556
    panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
zorglub's avatar
zorglub committed
557
558
#else
    panel_sizer->Add( notebook, 1, wxEXPAND | wxALL, 5 );
zorglub's avatar
zorglub committed
559
#endif
560
561
    panel_sizer->Add( common_opt_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
    panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
gbazin's avatar
   
gbazin committed
562
    panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
gbazin's avatar
 
gbazin committed
563
564
565
566
567
568
569
570
571
    panel_sizer->Layout();
    panel->SetSizerAndFit( panel_sizer );
    main_sizer->Add( panel, 1, wxGROW, 0 );
    main_sizer->Layout();
    SetSizerAndFit( main_sizer );
}

OpenDialog::~OpenDialog()
{
gbazin's avatar
   
gbazin committed
572
573
574
575
    /* Clean up */
    if( file_dialog ) delete file_dialog;
    if( sout_dialog ) delete sout_dialog;
    if( subsfile_dialog ) delete subsfile_dialog;
gbazin's avatar
 
gbazin committed
576
577
}

gbazin's avatar
   
gbazin committed
578
int OpenDialog::Show( int i_access_method, int i_arg )
gbazin's avatar
   
gbazin committed
579
580
{
    notebook->SetSelection( i_access_method );
581
    int i_ret = wxDialog::Show();
gbazin's avatar
   
gbazin committed
582
583
    Raise();
    SetFocus();
gbazin's avatar
   
gbazin committed
584
    i_open_arg = i_arg;
gbazin's avatar
   
gbazin committed
585
    return i_ret;
gbazin's avatar
   
gbazin committed
586
587
}

gbazin's avatar
   
gbazin committed
588
int OpenDialog::Show()
gbazin's avatar
   
gbazin committed
589
{
590
    int i_ret = wxDialog::Show();
gbazin's avatar
   
gbazin committed
591
592
593
    Raise();
    SetFocus();
    return i_ret;
gbazin's avatar
   
gbazin committed
594
595
}

gbazin's avatar
 
gbazin committed
596
597
598
599
600
601
602
603
/*****************************************************************************
 * Private methods.
 *****************************************************************************/
wxPanel *OpenDialog::FilePanel( wxWindow* parent )
{
    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
                                  wxSize(200, 200) );

gbazin's avatar
   
gbazin committed
604
605
606
607
    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );

    /* Create browse file line */
    wxBoxSizer *file_sizer = new wxBoxSizer( wxHORIZONTAL );
gbazin's avatar
 
gbazin committed
608

gbazin's avatar
   
gbazin committed
609
    file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
610
                                 wxPoint(20,25), wxSize(200, -1) );
gbazin's avatar
 
gbazin committed
611
    wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
gbazin's avatar
   
gbazin committed
612
                                            wxU(_("Browse...")) );
gbazin's avatar
   
gbazin committed
613
614
615
616
617
618
    file_sizer->Add( file_combo, 1, wxALL, 5 );
    file_sizer->Add( browse_button, 0, wxALL, 5 );

    /* Create Subtitles File checkox */
    wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
    subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
hartman's avatar
hartman committed
619
                                        wxU(_("Subtitle options")) );
Carlo Calabrò's avatar
Carlo Calabrò committed
620
    subsfile_checkbox->SetToolTip( wxU(_("Force options for separate subtitle files.")) );
gbazin's avatar
   
gbazin committed
621
622
623
624
625
626
627
628
629
630
631
    subsfile_sizer->Add( subsfile_checkbox, 0,
                         wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
    subsfile_button = new wxButton( panel, SubsFileSettings_Event,
                                    wxU(_("Settings...")) );
    subsfile_button->Disable();

    char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
    if( psz_subsfile && *psz_subsfile )
    {
        subsfile_checkbox->SetValue(TRUE);
        subsfile_button->Enable();
gbazin's avatar
   
gbazin committed
632
        subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxL2U(psz_subsfile) );
gbazin's avatar
   
gbazin committed
633
634
635
636
637
    }
    if( psz_subsfile ) free( psz_subsfile );

    subsfile_sizer->Add( subsfile_button, 1,
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
 
gbazin committed
638

gbazin's avatar
   
gbazin committed
639
640
    sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
    sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 );
gbazin's avatar
 
gbazin committed
641
642
643
644
645
646
647
648
649
650
651
652
653
654
    panel->SetSizerAndFit( sizer );
    return panel;
}

wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
{
    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
                                  wxSize(200, 200) );

    wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
    wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );

    static const wxString disc_type_array[] =
    {
655
        wxU(_("DVD (menus)")),
gbazin's avatar
   
gbazin committed
656
657
        wxU(_("DVD")),
        wxU(_("VCD")),
658
        wxU(_("Audio CD")),
gbazin's avatar
 
gbazin committed
659
660
    };

gbazin's avatar
   
gbazin committed
661
    disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
gbazin's avatar
 
gbazin committed
662
663
664
                                wxDefaultPosition, wxDefaultSize,
                                WXSIZEOF(disc_type_array), disc_type_array,
                                WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
Sam Hocevar's avatar
Sam Hocevar committed
665

666
667
668
669
670
#ifdef HAVE_LIBCDIO
    disc_probe = new wxCheckBox( panel, DiscProbe_Event, 
				 wxU(_("Probe Disc")) );
#endif

671
    sizer_row->Add( disc_type, i_disc_type_selection, wxEXPAND | wxALL, 5 );
672
    sizer_row->Add( disc_probe, 0, wxEXPAND | wxALL );
gbazin's avatar
 
gbazin committed
673

gbazin's avatar
   
gbazin committed
674
675
    wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
    disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
gbazin's avatar
 
gbazin committed
676
677
678
679
680
681
                                  wxDefaultPosition, wxDefaultSize,
                                  wxTE_PROCESS_ENTER);

    sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );

682
    disc_title_label = new wxStaticText( panel, -1, wxU(_("Title")) );
gbazin's avatar
   
gbazin committed
683
    disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
684
    sizer->Add( disc_title_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
 
gbazin committed
685
686
    sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );

687
    disc_chapter_label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
gbazin's avatar
   
gbazin committed
688
    disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
Sam Hocevar's avatar
Sam Hocevar committed
689
690
    sizer->Add( disc_chapter_label, 0,
                wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
 
gbazin committed
691
    sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
692
693
694
695
696
697

    disc_sub_label = new wxStaticText( panel, -1, wxU(_("Subtitles track")) );
    disc_sub = new wxSpinCtrl( panel, DiscSub_Event );
    sizer->Add( disc_sub_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    sizer->Add( disc_sub, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    disc_sub->SetRange( -1, 255 );
hartman's avatar
hartman committed
698
    i_disc_sub = config_GetInt( p_intf, "sub-track" );
699
700
    disc_sub->SetValue( i_disc_sub );

701
702
703
704
705
706
707
708
    disc_audio_label = new wxStaticText( panel, -1, wxU(_("Audio track")) );
    disc_audio = new wxSpinCtrl( panel, DiscAudio_Event );
    sizer->Add( disc_audio_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    sizer->Add( disc_audio, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    disc_audio->SetRange( -1, 255 );
    i_disc_audio = config_GetInt( p_intf, "audio-track" );
    disc_audio->SetValue( i_disc_audio );

gbazin's avatar
 
gbazin committed
709
710
711
712
713
714
715
716
717
718
719
720
721
    sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );

    panel->SetSizerAndFit( sizer_row );
    return panel;
}

wxPanel *OpenDialog::NetPanel( wxWindow* parent )
{
    int i;
    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
                                  wxSize(200, 200) );

    wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
722
    wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
gbazin's avatar
 
gbazin committed
723
724
725

    static const wxString net_type_array[] =
    {
gbazin's avatar
   
gbazin committed
726
727
        wxU(_("UDP/RTP")),
        wxU(_("UDP/RTP Multicast")),
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
728
        wxU(_("HTTP/HTTPS/FTP/MMS")),
729
        wxU(_("RTSP"))
gbazin's avatar
 
gbazin committed
730
731
    };

732
    for( i=0; i<4; i++ )
gbazin's avatar
 
gbazin committed
733
734
735
736
737
738
739
740
741
742
    {
        net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
                                           net_type_array[i],
                                           wxDefaultPosition, wxDefaultSize,
                                           wxRB_SINGLE );

        net_subpanels[i] = new wxPanel( panel, -1,
                                        wxDefaultPosition, wxDefaultSize );
    }

743
744
745
746
    /* Timeshift */
    net_timeshift  = new wxCheckBox( panel, NetTimeshift_Event,
                                     wxU(_("Allow timeshifting")) );

gbazin's avatar
 
gbazin committed
747
748
749
    /* UDP/RTP row */
    wxFlexGridSizer *subpanel_sizer;
    wxStaticText *label;
gbazin's avatar
   
gbazin committed
750
    i_net_ports[0] = config_GetInt( p_intf, "server-port" );
751
    subpanel_sizer = new wxFlexGridSizer( 3, 1, 20 );
gbazin's avatar
   
gbazin committed
752
    label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
gbazin's avatar
 
gbazin committed
753
    net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
gbazin's avatar
   
gbazin committed
754
                                   wxString::Format(wxT("%d"), i_net_ports[0]),
gbazin's avatar
 
gbazin committed
755
756
                                   wxDefaultPosition, wxDefaultSize,
                                   wxSP_ARROW_KEYS,
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
757
                                   0, 65535, i_net_ports[0] );
gbazin's avatar
 
gbazin committed
758
759
760
761

    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
    subpanel_sizer->Add( net_ports[0], 1,
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
762
763
764
765
    net_ipv6 = new wxCheckBox( net_subpanels[0], NetForceIPv6_Event,
                               wxU(_("Force IPv6")));
    subpanel_sizer->Add( net_ipv6, 0,
                         wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
 
gbazin committed
766
    net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
gbazin's avatar
   
gbazin committed
767
    net_radios[0]->SetValue( TRUE );
gbazin's avatar
 
gbazin committed
768
769
770

    /* UDP/RTP Multicast row */
    subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
gbazin's avatar
   
gbazin committed
771
772
    label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
    net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
gbazin's avatar
 
gbazin committed
773
774
775
776
777
778
                                   wxDefaultPosition, wxDefaultSize,
                                   wxTE_PROCESS_ENTER);
    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
    subpanel_sizer->Add( net_addrs[1], 1,
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );

gbazin's avatar
   
gbazin committed
779
    label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
gbazin's avatar
   
gbazin committed
780
    i_net_ports[1] = i_net_ports[0];
gbazin's avatar
 
gbazin committed
781
    net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
gbazin's avatar
   
gbazin committed
782
                                   wxString::Format(wxT("%d"), i_net_ports[1]),
gbazin's avatar
 
gbazin committed
783
784
                                   wxDefaultPosition, wxDefaultSize,
                                   wxSP_ARROW_KEYS,
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
785
                                   0, 65535, i_net_ports[1] );
gbazin's avatar
 
gbazin committed
786
787
788
789
790
791

    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
    subpanel_sizer->Add( net_ports[1], 1,
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    net_subpanels[1]->SetSizerAndFit( subpanel_sizer );

792
793
794
795
796
797
    /* HTTP and RTSP rows */
    for( i=2; i<4; i++ )
    {
        subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
        label = new wxStaticText( net_subpanels[i], -1, wxU(_("URL")) );
        net_addrs[i] = new wxTextCtrl( net_subpanels[i], NetAddr1_Event + i,
gbazin's avatar
   
gbazin committed
798
                                       (i == 2) ? wxT("") : wxT("rtsp://"),
799
800
801
802
803
804
805
                                       wxDefaultPosition, wxSize( 200, -1 ),
                                       wxTE_PROCESS_ENTER);
        subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
        subpanel_sizer->Add( net_addrs[i], 1,
                             wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
        net_subpanels[i]->SetSizerAndFit( subpanel_sizer );
    }
gbazin's avatar
 
gbazin committed
806
807

    /* Stuff everything into the main panel */
808
    for( i=0; i<4; i++ )
gbazin's avatar
 
gbazin committed
809
    {
gbazin's avatar
   
gbazin committed
810
811
812
813
        sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
                    wxALL, 5 );
        sizer->Add( net_subpanels[i], 1, wxEXPAND | wxALIGN_LEFT |
                    wxALIGN_CENTER_VERTICAL | wxALL, 5  );
gbazin's avatar
 
gbazin committed
814
    }
815
816
    sizer->Add( net_timeshift, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
                wxALL, 5 );
gbazin's avatar
 
gbazin committed
817
818
819
820
821
822
823

    sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );

    panel->SetSizerAndFit( sizer_row );
    return panel;
}

824
void OpenDialog::UpdateMRL()
gbazin's avatar
 
gbazin committed
825
{
826
    UpdateMRL( i_current_access_method );
gbazin's avatar
 
gbazin committed
827
828
829
830
}

void OpenDialog::UpdateMRL( int i_access_method )
{
831
    wxString mrltemp, caching_name;
gbazin's avatar
   
gbazin committed
832
833
834

    i_current_access_method = i_access_method;

gbazin's avatar
 
gbazin committed
835
836
837
    switch( i_access_method )
    {
    case FILE_ACCESS:
gbazin's avatar
   
gbazin committed
838
        mrltemp = file_combo->GetValue();
839
        caching_name = wxT("file-caching");
gbazin's avatar
 
gbazin committed
840
        break;
841

gbazin's avatar
 
gbazin committed
842
    case DISC_ACCESS:
843
        i_disc_type_selection = disc_type->GetSelection();
844

845
        switch ( i_disc_type_selection )
Sam Hocevar's avatar
Sam Hocevar committed
846
        {
847
848
        case 0: /* DVD with menus */
        case 1: /* DVD without menus */
849
850
	    disc_device->SetToolTip( wxU(_("Name of DVD device "
	    "to read from.")) );
851
            if( i_disc_type_selection == 0 )
852
            {
853
                mrltemp = wxT("dvd://") + disc_device->GetValue();
854
                caching_name = wxT("dvdnav-caching");
855
            }
856
            else
857
            {
858
                mrltemp = wxT("dvdsimple://") + disc_device->GetValue();
859
                caching_name = wxT("dvdread-caching");
860
            }
861
862
863
864
865
866
867
868
869
870

            if( i_disc_title > 0 )
            {
                mrltemp += wxString::Format( wxT("@%d"), i_disc_title );

                if( i_disc_chapter > 0 )
                    mrltemp += wxString::Format( wxT(":%d"), i_disc_chapter );
            }

            if( i_disc_sub >= 0 )
hartman's avatar
hartman committed
871
                mrltemp += wxString::Format( wxT("  :sub-track=%d"),
872
                                             i_disc_sub );
873
874
875
            if( i_disc_audio >= 0 )
                mrltemp += wxString::Format( wxT("  :audio-track=%d"),
                                             i_disc_audio );
876
            break;
877

878
        case 2:  /* VCD of some sort */
Rocky Bernstein's avatar
Rocky Bernstein committed
879
#ifdef HAVE_VCDX
880
881
882
	    disc_device->SetToolTip( wxU(_("Name of CD-ROM device "
	    "to read Video CD from. If this field is left empty, we will scan "
	    "for a CD-ROM with a VCD in it.")) );
883
884
885
            mrltemp = wxT("vcdx://") + disc_device->GetValue();
            if( i_disc_title > 0 )
                mrltemp += wxString::Format( wxT("@%c%d"),
Sam Hocevar's avatar
Sam Hocevar committed
886
                                  config_GetInt( p_intf, "vcdx-PBC"  )
887
                                  ? 'P' : 'E', i_disc_title );
Rocky Bernstein's avatar
Rocky Bernstein committed
888
#else
889
890
	    disc_device->SetToolTip( wxU(_("Name of CD-ROM device "
	    "to read Video CD from.")) );
891
892
893
            mrltemp = wxT("vcd://") + disc_device->GetValue();
            if( i_disc_title > 0 )
                mrltemp += wxString::Format( wxT("@%d"), i_disc_title );
Rocky Bernstein's avatar
Rocky Bernstein committed
894
#endif
895

896
            if( i_disc_sub >= 0 )
hartman's avatar
hartman committed
897
                mrltemp += wxString::Format( wxT("  :sub-track=%d"),
898
                                             i_disc_sub );
899

900
901
902
            if( i_disc_audio >= 0 )
                mrltemp += wxString::Format( wxT("  :audio-track=%d"),
                                             i_disc_audio );
903
            caching_name = wxT("vcd-caching");
904
            break;
905

906
        case 3: /* CD-DA */
907
#ifdef HAVE_CDDAX
908
909
910
911
	    disc_device->SetToolTip( wxU(_("Name of CD-ROM device "
	    "to read audio CD from. If this field is left empty, we will scan "
	    "for a CD-ROM with an audio CD in it." )) );
            mrltemp = wxT("cddax://") 
912
#else
913
914
915
	    disc_device->SetToolTip( wxU(_("Name of CD-ROM device "
	    "to read audio CD from." )) );
            mrltemp = wxT("cdda://") 
916
#endif
917
              + disc_device->GetValue();
918
919
            if( i_disc_title > 0 )
                mrltemp += wxString::Format( wxT("@%d"), i_disc_title );
920

921
            caching_name = wxT("cdda-caching");
922
            break;
923

924
925
926
        default:
            msg_Err( p_intf, "invalid selection (%d)",
                     disc_type->GetSelection() );
Sam Hocevar's avatar
Sam Hocevar committed
927
        }
928

gbazin's avatar
 
gbazin committed
929
        break;
930

gbazin's avatar
 
gbazin committed
931
932
933
934
    case NET_ACCESS:
        switch( i_net_type )
        {
        case 0:
935
            mrltemp = wxT("udp://@");
936
937
            if ( net_ipv6->GetValue() )
            {
938
                mrltemp += wxT("[::]");
939
            }
gbazin's avatar
   
gbazin committed
940
            if( i_net_ports[0] !=
gbazin's avatar
 
gbazin committed
941
942
                config_GetInt( p_intf, "server-port" ) )
            {
943
                mrltemp += wxString::Format( wxT(":%d"), i_net_ports[0] );
gbazin's avatar
 
gbazin committed
944
            }
945

946
            caching_name = wxT("udp-caching");
gbazin's avatar
 
gbazin committed
947
948
949
            break;

        case 1:
950
            mrltemp = wxT("udp://@");
951
952
953
954
955
956
957
958
959
960
961
962
            if ((net_addrs[1]->GetLineText(0).Find (':') != -1)
                && (net_addrs[1]->GetLineText(0)[0u] != '['))
            {
                /* automatically adds '[' and ']' to IPv6 addresses */
                mrltemp += wxT("[") + net_addrs[1]->GetLineText(0)
                         + wxT("]");
            }
            else
            {
                mrltemp += net_addrs[1]->GetLineText(0);
            }
            if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
gbazin's avatar
 
gbazin committed
963
            {
964
                mrltemp += wxString::Format( wxT(":%d"), i_net_ports[1] );
gbazin's avatar
 
gbazin committed
965
            }
966

967
            caching_name = wxT("udp-caching");
gbazin's avatar
 
gbazin committed
968
969
970
            break;

        case 2:
971
            /* http access */
972
973
974
            if( net_addrs[2]->GetLineText(0).Find(wxT("://")) == -1 )
                mrltemp = wxT("http://");

975
            mrltemp += net_addrs[2]->GetLineText(0);
976

977
            caching_name = wxT("http-caching");
978
979
980
981
            break;

        case 3:
            /* RTSP access */
982
            if( net_addrs[3]->GetLineText(0).Find(wxT("rtsp://")) != 0 )
983
            {
984
                mrltemp = wxT("rtsp://");
985
986
            }
            mrltemp += net_addrs[3]->GetLineText(0);
987

988
            caching_name = wxT("rtsp-caching");
gbazin's avatar
 
gbazin committed
989
990
            break;
        }
zorglub's avatar
zorglub committed
991
992
        if( net_timeshift->IsEnabled() && net_timeshift->IsChecked() )
            mrltemp += wxT(" :access-filter=timeshift");
gbazin's avatar
 
gbazin committed
993
        break;
994

gbazin's avatar
 
gbazin committed
995
    default:
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
        {
            int i_item = i_access_method - MAX_ACCESS;

            if( i_item < 0 || i_item >= (int)input_tab_array.GetCount() )
                break;

            AutoBuiltPanel *input_panel = input_tab_array.Item( i_item );

            mrltemp = input_panel->name + wxT("://");

            for( int i=0; i < (int)input_panel->config_array.GetCount(); i++ )
            {
                ConfigControl *control = input_panel->config_array.Item(i);
1009
1010
1011
1012
1013
1014
1015

                mrltemp += wxT(" :");

                if( control->GetType() == CONFIG_ITEM_BOOL &&
                    !control->GetIntValue() ) mrltemp += wxT("no-");

                mrltemp += control->GetName();
1016
1017
1018
1019
1020
1021
1022

                switch( control->GetType() )
                {
                case CONFIG_ITEM_STRING:
                case CONFIG_ITEM_FILE:
                case CONFIG_ITEM_DIRECTORY:
                case CONFIG_ITEM_MODULE:
1023
                    mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
1024
1025
1026
                    break;
                case CONFIG_ITEM_INTEGER:
                    mrltemp +=
1027
                        wxString::Format( wxT("=%i"), control->GetIntValue() );
1028
1029
1030
                    break;
                case CONFIG_ITEM_FLOAT:
                    mrltemp +=
1031
                        wxString::Format(wxT("=%f"), control->GetFloatValue());
1032
1033
1034
                    break;
                }
            }
1035
1036
1037
1038
1039
1040
1041

            if( input_panel->p_advanced_mrl_combo &&
                input_panel->p_advanced_mrl_combo->GetValue() )
            {
                mrltemp += wxT(" ") +
                    input_panel->p_advanced_mrl_combo->GetValue();
            }
1042
        }
gbazin's avatar
 
gbazin committed
1043
1044
1045
        break;
    }

1046
1047
1048
1049
    if( caching_name.size() )
    {
        if( caching_value->IsEnabled() )
        {
1050
1051
            mrltemp += wxT("  :") + caching_name +
                wxString::Format( wxT("=%d"), i_caching );
1052
1053
1054
1055
1056
1057
1058
1059
        }
        else
        {
            int i_value = config_GetInt( p_intf, caching_name.mb_str() );
            caching_value->SetValue( i_value );
        }
    }

gbazin's avatar
   
gbazin committed
1060
1061
1062
    mrl_combo->SetValue( mrltemp );
}

gbazin's avatar
 
gbazin committed
1063
1064
1065
1066
1067
/*****************************************************************************
 * Events methods.
 *****************************************************************************/
void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
{
gbazin's avatar
   
gbazin committed
1068
    mrl = SeparateEntries( mrl_combo->GetValue() );
gbazin's avatar
   
gbazin committed
1069
1070
1071
    mrl_combo->Append( mrl_combo->GetValue() );
    if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 );
    mrl_combo->SetSelection( mrl_combo->GetCount() - 1 );
gbazin's avatar
   
gbazin committed
1072

zorglub's avatar
zorglub committed
1073
1074
    if( i_method == OPEN_STREAM )
    {
1075
        if( IsModal() ) EndModal( wxID_OK );
1076
        Hide();
zorglub's avatar
zorglub committed
1077
1078
1079
        return;</