open.cpp 60.3 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 */
37

38
39
#ifdef HAVE_VCDINFO
#include <libvcd/version.h>
40
41
42
43
/* There was a bug in libvcdinfo <= 23 which prevented C++ compilation */
#if LIBVCD_VERSION_NUM > 23
#include <libvcd/info.h>
#endif /* LIBVCD_VERSION_NUM > 23 */
44
#endif /* HAVE_VCDINFO */
gbazin's avatar
 
gbazin committed
45
46

#include <wx/combobox.h>
gbazin's avatar
   
gbazin committed
47
#include <wx/statline.h>
gbazin's avatar
   
gbazin committed
48
#include <wx/tokenzr.h>
gbazin's avatar
 
gbazin committed
49
50
51

#include <vlc/intf.h>

zorglub's avatar
zorglub committed
52
53
#include <vector>

gbazin's avatar
   
gbazin committed
54
#include "wxwindows.h"
gbazin's avatar
   
gbazin committed
55
56
#include "preferences_widgets.h"

57
#ifndef wxRB_SINGLE
gbazin's avatar
   
gbazin committed
58
#   define wxRB_SINGLE 0
59
60
#endif

gbazin's avatar
 
gbazin committed
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*****************************************************************************
 * Event Table.
 *****************************************************************************/

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

    FileBrowse_Event,
    FileName_Event,

    DiscType_Event,
75
76
77
#ifdef HAVE_LIBCDIO
    DiscProbe_Event,
#endif
gbazin's avatar
 
gbazin committed
78
79
80
    DiscDevice_Event,
    DiscTitle_Event,
    DiscChapter_Event,
81
    DiscSub_Event,
82
    DiscAudio_Event,
gbazin's avatar
 
gbazin committed
83
84

    NetType_Event,
85
    NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
gbazin's avatar
   
gbazin committed
86
    NetPort1_Event, NetPort2_Event, NetPort3_Event,
87
    NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
zorglub's avatar
zorglub committed
88
    NetForceIPv6_Event, NetTimeshift_Event,
gbazin's avatar
   
gbazin committed
89

gbazin's avatar
   
gbazin committed
90
91
92
    SubsFileEnable_Event,
    SubsFileSettings_Event,

gbazin's avatar
   
gbazin committed
93
94
    SoutEnable_Event,
    SoutSettings_Event,
95

96
97
98
    CachingEnable_Event,
    CachingChange_Event,

99
    AdvancedOptions_Event
gbazin's avatar
 
gbazin committed
100
101
};

102
BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
gbazin's avatar
 
gbazin committed
103
104
105
106
107
108
    /* Button events */
    EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
    EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)

    EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)

109
    EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
gbazin's avatar
 
gbazin committed
110
111
112

    /* Events generated by the file panel */
    EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
gbazin's avatar
   
gbazin committed
113
    EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
gbazin's avatar
 
gbazin committed
114
115
116

    /* Events generated by the disc panel */
    EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
117
118
119
#ifdef HAVE_LIBCDIO
    EVT_CHECKBOX(DiscProbe_Event, OpenDialog::OnDiscProbe)
#endif
yoann's avatar
yoann committed
120
    EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscDeviceChange)
gbazin's avatar
 
gbazin committed
121
122
    EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
    EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
123
    EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChangeSpin)
gbazin's avatar
 
gbazin committed
124
    EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
125
    EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChangeSpin)
126
    EVT_TEXT(DiscSub_Event, OpenDialog::OnDiscPanelChange)
127
    EVT_TEXT(DiscAudio_Event, OpenDialog::OnDiscPanelChange)
128
    EVT_SPINCTRL(DiscSub_Event, OpenDialog::OnDiscPanelChangeSpin)
gbazin's avatar
 
gbazin committed
129
130
131
132
133

    /* Events generated by the net panel */
    EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
    EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
    EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
134
    EVT_RADIOBUTTON(NetRadio4_Event, OpenDialog::OnNetTypeChange)
gbazin's avatar
 
gbazin committed
135
    EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
136
    EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChangeSpin)
gbazin's avatar
 
gbazin committed
137
    EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
138
    EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChangeSpin)
gbazin's avatar
 
gbazin committed
139
    EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
140
    EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChangeSpin)
gbazin's avatar
 
gbazin committed
141
142
    EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
    EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
143
    EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange)
144
    EVT_CHECKBOX(NetForceIPv6_Event, OpenDialog::OnNetPanelChange)
zorglub's avatar
zorglub committed
145
    EVT_CHECKBOX(NetTimeshift_Event, OpenDialog::OnNetPanelChange)
gbazin's avatar
 
gbazin committed
146

gbazin's avatar
   
gbazin committed
147
148
149
150
    /* Events generated by the subtitle file buttons */
    EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
    EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)

gbazin's avatar
   
gbazin committed
151
152
153
    /* Events generated by the stream output buttons */
    EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
    EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
gbazin's avatar
   
gbazin committed
154

155
156
157
    /* Events generated by the caching button */
    EVT_CHECKBOX(CachingEnable_Event, OpenDialog::OnCachingEnable)
    EVT_TEXT(CachingChange_Event, OpenDialog::OnCachingChange)
158
    EVT_SPINCTRL(CachingChange_Event, OpenDialog::OnCachingChangeSpin)
159

gbazin's avatar
   
gbazin committed
160
    /* Hide the window when the user closes the window */
161
    EVT_CLOSE(OpenDialog::OnClose)
gbazin's avatar
   
gbazin committed
162

gbazin's avatar
 
gbazin committed
163
164
END_EVENT_TABLE()

165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*****************************************************************************
 * AutoBuiltPanel.
 *****************************************************************************/
WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);

class AutoBuiltPanel : public wxPanel
{
public:

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

    virtual ~AutoBuiltPanel() {}

180
181
    void UpdateAdvancedMRL();

182
183
    wxString name;
    ArrayOfConfigControls config_array;
184
185
    ArrayOfConfigControls advanced_config_array;
    wxComboBox *p_advanced_mrl_combo;
186
187
188

private:
    intf_thread_t *p_intf;
189
190
191
192
193
194
    OpenDialog *p_open_dialog;

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

    DECLARE_EVENT_TABLE();
195
196
};

197
198
199
200
201
BEGIN_EVENT_TABLE(AutoBuiltPanel, wxPanel)
    EVT_BUTTON(AdvancedOptions_Event, AutoBuiltPanel::OnAdvanced)
END_EVENT_TABLE()

static void AutoBuildCallback( void *p_data )
202
203
204
205
{
    ((OpenDialog *)p_data)->UpdateMRL();
}

206
207
208
209
210
static void AutoBuildAdvancedCallback( void *p_data )
{
    ((AutoBuiltPanel *)p_data)->UpdateAdvancedMRL();
}

211
212
213
AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
                                intf_thread_t *_p_intf,
                                const module_t *p_module )
214
215
216
217
  : 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 )
218
219
220
{
    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
    module_config_t *p_item = p_module->p_config;
221
    bool b_advanced = false;
222
223
224

    if( p_item ) do
    {
225
226
227
        if( !(p_item->i_type & CONFIG_HINT) && p_item->b_advanced )
            b_advanced = true;

228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
        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++ );

245
246
247
248
249
250
251
252
253
    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 =
254
255
            new wxDialog( this, -1, ((wxString)wxU(_("Advanced options"))) +
                          wxT(" (") + wxU( p_module->psz_longname ) + wxT(")"),
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
294
295
296
297
298
299
300
301
                          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 */
302
        wxPanel *dummy_panel = new wxPanel( p_advanced_dialog, -1 );
303
304
305
306
307
        sizer->Add( dummy_panel, 1 );
        wxStaticLine *static_line =
            new wxStaticLine( p_advanced_dialog, wxID_OK );
        sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );

308
        /* Create buttons */
309
310
311
        wxButton *ok_button =
            new wxButton( p_advanced_dialog, wxID_OK, wxU(_("OK")) );
        ok_button->SetDefault();
312
313
314
315
316
317
318
        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 );
319
320
321
322
323

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

324
325
326
    this->SetSizerAndFit( sizer );
}

327
328
void AutoBuiltPanel::OnAdvanced( wxCommandEvent& event )
{
329
330
331
332
333
    if( p_advanced_dialog->ShowModal() == wxID_OK )
    {
        UpdateAdvancedMRL();
        p_open_dialog->UpdateMRL();
    }
334
335
336
337
338
339
340
341
342
343
}

void AutoBuiltPanel::UpdateAdvancedMRL()
{
    wxString mrltemp;

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

344
        mrltemp += (i ? wxT(" :") : wxT(":"));
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372

        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
373
374
375
/*****************************************************************************
 * Constructor.
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
376
OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
gbazin's avatar
   
gbazin committed
377
                        int i_access_method, int i_arg ):
378
      wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
gbazin's avatar
 
gbazin committed
379
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
zorglub's avatar
zorglub committed
380
381
382
383
384
385
{
    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 ):
386
      wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
zorglub's avatar
zorglub committed
387
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
gbazin's avatar
 
gbazin committed
388
389
{
    /* Initializations */
zorglub's avatar
zorglub committed
390
    i_method = _i_method;
gbazin's avatar
 
gbazin committed
391
    p_intf = _p_intf;
gbazin's avatar
   
gbazin committed
392
    p_parent = _p_parent;
gbazin's avatar
   
gbazin committed
393
    SetIcon( *p_intf->p_sys->p_icon );
gbazin's avatar
   
gbazin committed
394
    file_dialog = NULL;
395
    i_disc_type_selection = 0;
zorglub's avatar
zorglub committed
396
    i_disc_title = 0;
gbazin's avatar
   
gbazin committed
397
    i_open_arg = i_arg;
Sam Hocevar's avatar
Sam Hocevar committed
398

gbazin's avatar
   
gbazin committed
399
400
    sout_dialog = NULL;
    subsfile_dialog = NULL;
yoann's avatar
yoann committed
401
    b_disc_device_changed = false;
gbazin's avatar
 
gbazin committed
402
403
404
405
406
407
408
409

    /* 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
410
                               wxU(_("Media Resource Locator (MRL)")) );
gbazin's avatar
 
gbazin committed
411
412
413
    wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
                                                        wxHORIZONTAL );
    wxStaticText *mrl_label = new wxStaticText( panel, -1,
Carlo Calabrò's avatar
Carlo Calabrò committed
414
                                                wxU(_("Open:")) );
gbazin's avatar
   
gbazin committed
415
    mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
416
                                wxPoint(20,25), wxSize(120, -1) );
gbazin's avatar
   
gbazin committed
417
418
    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
419
        "filled automatically when you use the controls below.")) );
gbazin's avatar
   
gbazin committed
420

gbazin's avatar
   
gbazin committed
421
422
    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
423
424
425
426
427
    mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );


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

431
    wxFlexGridSizer *common_opt_sizer = new wxFlexGridSizer( 5, 1, 20 );
zorglub's avatar
zorglub committed
432
433

    if( i_method == OPEN_NORMAL )
gbazin's avatar
   
gbazin committed
434
    {
zorglub's avatar
zorglub committed
435
436
437
        /* Create Stream Output checkox */
        sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
                                         wxU(_("Stream output")) );
hartman's avatar
hartman committed
438
        sout_checkbox->SetToolTip( wxU(_("Use VLC as a server of streams")) );
439
440
441
        common_opt_sizer->Add( sout_checkbox, 0,
                               wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );

zorglub's avatar
zorglub committed
442
443
        sout_button = new wxButton( panel, SoutSettings_Event,
                                    wxU(_("Settings...")) );
yoann's avatar
yoann committed
444
        sout_button->Disable();
zorglub's avatar
zorglub committed
445
446
447
448
449
450

        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
451
            subsfile_mrl.Add( wxString(wxT("sout=")) + wxL2U(psz_sout) );
zorglub's avatar
zorglub committed
452
453
454
        }
        if( psz_sout ) free( psz_sout );

455
456
        common_opt_sizer->Add( sout_button, 1, wxALIGN_LEFT |
                               wxALIGN_CENTER_VERTICAL );
zorglub's avatar
zorglub committed
457

458
459
        common_opt_sizer->Add( new wxPanel( this, -1 ), 1,
                               wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
zorglub's avatar
zorglub committed
460
    }
gbazin's avatar
   
gbazin committed
461

462
463
464
465
    /* Create caching options */
    caching_checkbox = new wxCheckBox( panel, CachingEnable_Event,
                                       wxU(_("Caching")) );
    caching_checkbox->SetToolTip( wxU(_("Change the default caching value "
466
                                        "(in milliseconds)")) );
467
468
469
470
471
472
473
474
475
476
477
    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
478
    /* Create the buttons */
gbazin's avatar
   
gbazin committed
479
    wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
gbazin's avatar
 
gbazin committed
480
    ok_button->SetDefault();
gbazin's avatar
   
gbazin committed
481
482
    wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
                                            wxU(_("Cancel")) );
gbazin's avatar
 
gbazin committed
483

gbazin's avatar
   
gbazin committed
484
    /* Create notebook */
gbazin's avatar
   
gbazin committed
485
    notebook = new wxNotebook( panel, Notebook_Event );
486

zorglub's avatar
zorglub committed
487
#if (!wxCHECK_VERSION(2,5,0))
gbazin's avatar
   
gbazin committed
488
    wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
zorglub's avatar
zorglub committed
489
#endif
gbazin's avatar
   
gbazin committed
490

gbazin's avatar
   
gbazin committed
491
    notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
gbazin's avatar
   
gbazin committed
492
                       i_access_method == FILE_ACCESS );
gbazin's avatar
   
gbazin committed
493
    notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
gbazin's avatar
   
gbazin committed
494
                       i_access_method == DISC_ACCESS );
gbazin's avatar
   
gbazin committed
495
    notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
gbazin's avatar
   
gbazin committed
496
                       i_access_method == NET_ACCESS );
497

498
499
500
501
502
503
    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
504
505
        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
                        p_module->psz_shortname : p_module->psz_object_name ),
506
507
508
509
510
511
512
513
514
                           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
515
516
        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
                        p_module->psz_shortname : p_module->psz_object_name ),
517
518
519
520
521
522
523
524
525
                           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
526
527
        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
                        p_module->psz_shortname : p_module->psz_object_name ),
528
529
530
531
                           i_access_method == CAPTURE_ACCESS );
    }

    p_module = config_FindModule( VLC_OBJECT(p_intf), "dshow" );
gbazin's avatar
   
gbazin committed
532
533
    if( p_module )
    {
534
535
536
        AutoBuiltPanel *autopanel =
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
        input_tab_array.Add( autopanel );
zorglub's avatar
zorglub committed
537
538
        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
                        p_module->psz_shortname : p_module->psz_object_name ),
gbazin's avatar
gbazin committed
539
                           i_access_method == CAPTURE_ACCESS );
gbazin's avatar
   
gbazin committed
540
541
    }

gbazin's avatar
   
gbazin committed
542
543
544
545
    /* Update Disc panel */
    wxCommandEvent dummy_event;
    OnDiscTypeChange( dummy_event );

gbazin's avatar
   
gbazin committed
546
547
548
549
    /* Update Net panel */
    dummy_event.SetId( NetRadio1_Event );
    OnNetTypeChange( dummy_event );

gbazin's avatar
 
gbazin committed
550
    /* Update MRL */
551
    wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
gbazin's avatar
 
gbazin committed
552
553
554
555
556
557
558
559
560
561
562
    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
563
#if (!wxCHECK_VERSION(2,5,0))
gbazin's avatar
   
gbazin committed
564
    panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
zorglub's avatar
zorglub committed
565
566
#else
    panel_sizer->Add( notebook, 1, wxEXPAND | wxALL, 5 );
zorglub's avatar
zorglub committed
567
#endif
568
569
    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
570
    panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
gbazin's avatar
 
gbazin committed
571
572
573
574
575
576
577
578
579
    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
580
581
582
583
    /* 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
584
585
}

gbazin's avatar
   
gbazin committed
586
int OpenDialog::Show( int i_access_method, int i_arg )
gbazin's avatar
   
gbazin committed
587
588
{
    notebook->SetSelection( i_access_method );
589
    int i_ret = wxDialog::Show();
gbazin's avatar
   
gbazin committed
590
591
    Raise();
    SetFocus();
gbazin's avatar
   
gbazin committed
592
    i_open_arg = i_arg;
gbazin's avatar
   
gbazin committed
593
    return i_ret;
gbazin's avatar
   
gbazin committed
594
595
}

gbazin's avatar
   
gbazin committed
596
int OpenDialog::Show()
gbazin's avatar
   
gbazin committed
597
{
598
    int i_ret = wxDialog::Show();
gbazin's avatar
   
gbazin committed
599
600
601
    Raise();
    SetFocus();
    return i_ret;
gbazin's avatar
   
gbazin committed
602
603
}

gbazin's avatar
 
gbazin committed
604
605
606
607
608
609
610
611
/*****************************************************************************
 * Private methods.
 *****************************************************************************/
wxPanel *OpenDialog::FilePanel( wxWindow* parent )
{
    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
                                  wxSize(200, 200) );

gbazin's avatar
   
gbazin committed
612
613
614
615
    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );

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

gbazin's avatar
   
gbazin committed
617
    file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
618
                                 wxPoint(20,25), wxSize(200, -1) );
gbazin's avatar
 
gbazin committed
619
    wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
gbazin's avatar
   
gbazin committed
620
                                            wxU(_("Browse...")) );
gbazin's avatar
   
gbazin committed
621
622
623
624
625
626
    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
627
                                        wxU(_("Subtitle options")) );
Carlo Calabrò's avatar
Carlo Calabrò committed
628
    subsfile_checkbox->SetToolTip( wxU(_("Force options for separate subtitle files.")) );
gbazin's avatar
   
gbazin committed
629
630
631
632
633
634
635
636
637
638
639
    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
640
        subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxL2U(psz_subsfile) );
gbazin's avatar
   
gbazin committed
641
642
643
644
645
    }
    if( psz_subsfile ) free( psz_subsfile );

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

gbazin's avatar
   
gbazin committed
647
648
    sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
    sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 );
gbazin's avatar
 
gbazin committed
649
650
651
652
653
654
655
656
657
658
659
660
661
662
    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[] =
    {
663
        wxU(_("DVD (menus)")),
gbazin's avatar
   
gbazin committed
664
665
        wxU(_("DVD")),
        wxU(_("VCD")),
666
        wxU(_("Audio CD")),
gbazin's avatar
 
gbazin committed
667
668
    };

gbazin's avatar
   
gbazin committed
669
    disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
gbazin's avatar
 
gbazin committed
670
671
672
                                wxDefaultPosition, wxDefaultSize,
                                WXSIZEOF(disc_type_array), disc_type_array,
                                WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
Sam Hocevar's avatar
Sam Hocevar committed
673

674
675
#ifdef HAVE_LIBCDIO
    disc_probe = new wxCheckBox( panel, DiscProbe_Event, 
676
                                 wxU(_("Probe Disc")) );
677
    disc_probe->SetToolTip( wxU(_("Probe for a DVD, VCD or audio CD. " 
678
679
680
681
"First try the Device name entered for the selected Disc type "
"(DVD, DVD Menu, VCD, audio CD). If that doesn't find media, try any device "
"for the Disc type.  If that doesn't work, then try looking for CD-ROMs or "
"DVD drives. The Disc type, Device name, and some parameter ranges are set "
682
"based on media we find.")) );
683
684
#endif

685
    sizer_row->Add( disc_type, i_disc_type_selection, wxEXPAND | wxALL, 5 );
686
    sizer_row->Add( disc_probe, 0, wxEXPAND | wxALL );
gbazin's avatar
 
gbazin committed
687

gbazin's avatar
   
gbazin committed
688
689
    wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
    disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
gbazin's avatar
 
gbazin committed
690
691
692
693
694
695
                                  wxDefaultPosition, wxDefaultSize,
                                  wxTE_PROCESS_ENTER);

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

696
    disc_title_label = new wxStaticText( panel, -1, wxU(_("Title")) );
gbazin's avatar
   
gbazin committed
697
    disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
698
    sizer->Add( disc_title_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
 
gbazin committed
699
700
    sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );

701
    disc_chapter_label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
gbazin's avatar
   
gbazin committed
702
    disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
Sam Hocevar's avatar
Sam Hocevar committed
703
704
    sizer->Add( disc_chapter_label, 0,
                wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
 
gbazin committed
705
    sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
706
707
708
709
710
711

    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
712
    i_disc_sub = config_GetInt( p_intf, "sub-track" );
713
714
    disc_sub->SetValue( i_disc_sub );

715
716
717
718
719
720
721
722
    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
723
724
725
726
727
728
729
730
731
732
733
734
735
    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 );
736
    wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
gbazin's avatar
 
gbazin committed
737
738
739

    static const wxString net_type_array[] =
    {
gbazin's avatar
   
gbazin committed
740
741
        wxU(_("UDP/RTP")),
        wxU(_("UDP/RTP Multicast")),
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
742
        wxU(_("HTTP/HTTPS/FTP/MMS")),
743
        wxU(_("RTSP"))
gbazin's avatar
 
gbazin committed
744
745
    };

746
    for( i=0; i<4; i++ )
gbazin's avatar
 
gbazin committed
747
748
749
750
751
752
753
754
755
756
    {
        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 );
    }

757
758
759
760
    /* Timeshift */
    net_timeshift  = new wxCheckBox( panel, NetTimeshift_Event,
                                     wxU(_("Allow timeshifting")) );

gbazin's avatar
 
gbazin committed
761
762
763
    /* UDP/RTP row */
    wxFlexGridSizer *subpanel_sizer;
    wxStaticText *label;
gbazin's avatar
   
gbazin committed
764
    i_net_ports[0] = config_GetInt( p_intf, "server-port" );
765
    subpanel_sizer = new wxFlexGridSizer( 3, 1, 20 );
gbazin's avatar
   
gbazin committed
766
    label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
gbazin's avatar
 
gbazin committed
767
    net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
gbazin's avatar
   
gbazin committed
768
                                   wxString::Format(wxT("%d"), i_net_ports[0]),
gbazin's avatar
 
gbazin committed
769
770
                                   wxDefaultPosition, wxDefaultSize,
                                   wxSP_ARROW_KEYS,
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
771
                                   0, 65535, i_net_ports[0] );
gbazin's avatar
 
gbazin committed
772
773
774
775

    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
    subpanel_sizer->Add( net_ports[0], 1,
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
776
777
778
779
    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
780
    net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
gbazin's avatar
   
gbazin committed
781
    net_radios[0]->SetValue( TRUE );
gbazin's avatar
 
gbazin committed
782
783
784

    /* UDP/RTP Multicast row */
    subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
gbazin's avatar
   
gbazin committed
785
786
    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
787
788
789
790
791
792
                                   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
793
    label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
gbazin's avatar
   
gbazin committed
794
    i_net_ports[1] = i_net_ports[0];
gbazin's avatar
 
gbazin committed
795
    net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
gbazin's avatar
   
gbazin committed
796
                                   wxString::Format(wxT("%d"), i_net_ports[1]),
gbazin's avatar
 
gbazin committed
797
798
                                   wxDefaultPosition, wxDefaultSize,
                                   wxSP_ARROW_KEYS,
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
799
                                   0, 65535, i_net_ports[1] );
gbazin's avatar
 
gbazin committed
800
801
802
803
804
805

    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 );

806
807
808
809
810
811
    /* 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
812
                                       (i == 2) ? wxT("") : wxT("rtsp://"),
813
814
815
816
817
818
819
                                       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
820
821

    /* Stuff everything into the main panel */
822
    for( i=0; i<4; i++ )
gbazin's avatar
 
gbazin committed
823
    {
gbazin's avatar
   
gbazin committed
824
825
826
827
        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
828
    }
829
830
    sizer->Add( net_timeshift, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
                wxALL, 5 );
gbazin's avatar
 
gbazin committed
831
832
833
834
835
836
837

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

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

838
void OpenDialog::UpdateMRL()
gbazin's avatar
 
gbazin committed
839
{
840
    UpdateMRL( i_current_access_method );
gbazin's avatar
 
gbazin committed
841
842
843
844
}

void OpenDialog::UpdateMRL( int i_access_method )
{
845
    wxString mrltemp, caching_name;
gbazin's avatar
   
gbazin committed
846
847
848

    i_current_access_method = i_access_method;

gbazin's avatar
 
gbazin committed
849
850
851
    switch( i_access_method )
    {
    case FILE_ACCESS:
gbazin's avatar
   
gbazin committed
852
        mrltemp = file_combo->GetValue();
853
        caching_name = wxT("file-caching");
gbazin's avatar
 
gbazin committed
854
        break;
855

gbazin's avatar
 
gbazin committed
856
    case DISC_ACCESS:
857
        i_disc_type_selection = disc_type->GetSelection();
858

859
        switch ( i_disc_type_selection )
Sam Hocevar's avatar
Sam Hocevar committed
860
        {
861
862
        case 0: /* DVD with menus */
        case 1: /* DVD without menus */
863
864
            disc_device->SetToolTip( wxU(_("Name of DVD device "
            "to read from.")) );
865
            if( i_disc_type_selection == 0 )
866
            {
867
                mrltemp = wxT("dvd://") + disc_device->GetValue();
868
                caching_name = wxT("dvdnav-caching");
869
            }
870
            else
871
            {
872
                mrltemp = wxT("dvdsimple://") + disc_device->GetValue();
873
                caching_name = wxT("dvdread-caching");
874
            }
875
876
877
878
879
880
881
882
883
884

            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
885
                mrltemp += wxString::Format( wxT("  :sub-track=%d"),
886
                                             i_disc_sub );
887
888
889
            if( i_disc_audio >= 0 )
                mrltemp += wxString::Format( wxT("  :audio-track=%d"),
                                             i_disc_audio );
890
            break;
891

892
        case 2:  /* VCD of some sort */
Rocky Bernstein's avatar
Rocky Bernstein committed
893
#ifdef HAVE_VCDX
894
895
896
            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.")) );
897
898
899
            mrltemp = wxT("vcdx://") + disc_device->GetValue();
            if( i_disc_title > 0 )
                mrltemp += wxString::Format( wxT("@%c%d"),
Sam Hocevar's avatar
Sam Hocevar committed
900
                                  config_GetInt( p_intf, "vcdx-PBC"  )
901
                                  ? 'P' : 'E', i_disc_title );
Rocky Bernstein's avatar
Rocky Bernstein committed
902
#else
903
904
            disc_device->SetToolTip( wxU(_("Name of CD-ROM device "
            "to read Video CD from.")) );
905
906
907
            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
908
#endif
909

910
            if( i_disc_sub >= 0 )
hartman's avatar
hartman committed
911
                mrltemp += wxString::Format( wxT("  :sub-track=%d"),
912
                                             i_disc_sub );
913

914
915
916
            if( i_disc_audio >= 0 )
                mrltemp += wxString::Format( wxT("  :audio-track=%d"),
                                             i_disc_audio );
917
            caching_name = wxT("vcd-caching");
918
            break;
919

920
        case 3: /* CD-DA */
921
#ifdef HAVE_CDDAX
922
923
924
            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." )) );
925
            mrltemp = wxT("cddax://") 
926
#else
927
928
            disc_device->SetToolTip( wxU(_("Name of CD-ROM device "
            "to read audio CD from." )) );
929
            mrltemp = wxT("cdda://") 
930
#endif
931
              + disc_device->GetValue();
932
933
            if( i_disc_title > 0 )
                mrltemp += wxString::Format( wxT("@%d"), i_disc_title );
934

935
            caching_name = wxT("cdda-caching");
936
            break;
937

938
939
940
        default:
            msg_Err( p_intf, "invalid selection (%d)",
                     disc_type->GetSelection() );
Sam Hocevar's avatar
Sam Hocevar committed
941
        }
942

gbazin's avatar
 
gbazin committed
943
        break;
944

gbazin's avatar
 
gbazin committed
945
946
947
948
    case NET_ACCESS:
        switch( i_net_type )
        {
        case 0:
949
            mrltemp = wxT("udp://@");
950
951
            if ( net_ipv6->GetValue() )
            {
952
                mrltemp += wxT("[::]");
953
            }
gbazin's avatar
   
gbazin committed
954
            if( i_net_ports[0] !=
gbazin's avatar
 
gbazin committed
955
956
                config_GetInt( p_intf, "server-port" ) )
            {
957
                mrltemp += wxString::Format( wxT(":%d"), i_net_ports[0] );
gbazin's avatar
 
gbazin committed
958
            }
959

960
            caching_name = wxT("udp-caching");
gbazin's avatar
 
gbazin committed
961
962
963
            break;

        case 1:
964
            mrltemp = wxT("udp://@");
965
966
967
968
969
970
971
972
973
974
975
976
            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
977
            {
978
                mrltemp += wxString::Format( wxT(":%d"), i_net_ports[1] );
gbazin's avatar
 
gbazin committed
979
            }
980

981
            caching_name = wxT("udp-caching");
gbazin's avatar
 
gbazin committed
982
983
984
            break;

        case 2:
985
            /* http access */
986
987
988
            if( net_addrs[2]->GetLineText(0).Find(wxT("://")) == -1 )
                mrltemp = wxT("http://");

989
            mrltemp += net_addrs[2]->GetLineText(0);
990

991
            caching_name = wxT("http-caching");
992
993
994
995
            break;

        case 3:
            /* RTSP access */
996
            if( net_addrs[3]->GetLineText(0).Find(wxT("rtsp://")) != 0 )
997
            {
998
                mrltemp = wxT("rtsp://");
999
1000
            }
            mrltemp += net_addrs[3]->GetLineText(0);
1001

1002
            caching_name = wxT("rtsp-caching");
gbazin's avatar
 
gbazin committed
1003
1004
            break;
        }
zorglub's avatar
zorglub committed
1005
1006
        if( net_timeshift->IsEnabled() && net_timeshift->IsChecked() )
            mrltemp += wxT(" :access-filter=timeshift");
gbazin's avatar
 
gbazin committed
1007
        break;
1008

gbazin's avatar
 
gbazin committed
1009
    default:
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
        {
            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);
1023
1024
1025
1026
1027
1028
1029

                mrltemp += wxT(" :");

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

                mrltemp += control->GetName();
1030
1031
1032
1033
1034
1035
1036

                switch( control->GetType() )
                {
                case CONFIG_ITEM_STRING:
                case CONFIG_ITEM_FILE:
                case CONFIG_ITEM_DIRECTORY:
                case CONFIG_ITEM_MODULE:
1037
                    mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
1038
1039
1040
                    break;
                case CONFIG_ITEM_INTEGER:
                    mrltemp +=
1041
                        wxString::Format( wxT("=%i"), control->GetIntValue() );
1042
1043
1044
                    break;
                case CONFIG_ITEM_FLOAT:
                    mrltemp +=
1045
                        wxString::Format(wxT("=%f"), control->GetFloatValue());
1046
1047
1048
                    break;
                }
            }
1049
1050
1051
1052
1053
1054
1055

            if( input_panel->p_advanced_mrl_combo &&
                input_panel->p_advanced_mrl_combo->GetValue() )
            {
                mrltemp += wxT(" ") +
                    input_panel->p_advanced_mrl_combo->GetValue();
            }
1056
        }
gbazin's avatar
 
gbazin committed
1057
1058
1059
        break;
    }

1060
1061
1062
1063
    if( caching_name.size() )
    {
        if( caching_value->IsEnabled() )
        {
1064
1065
            mrltemp += wxT("  :") + caching_name +
                wxString::Format( wxT("=%d"), i_caching );
1066
1067
1068
1069