open.cpp 60.1 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
#ifdef HAVE_VCDINFO
38
#include <libvcd/info.h>
39
#include <libvcd/version.h>
40
#endif /* HAVE_VCDINFO */
gbazin's avatar
   
gbazin committed
41
42

#include <wx/combobox.h>
gbazin's avatar
   
gbazin committed
43
#include <wx/statline.h>
gbazin's avatar
   
gbazin committed
44
#include <wx/tokenzr.h>
gbazin's avatar
   
gbazin committed
45
46
47

#include <vlc/intf.h>

zorglub's avatar
zorglub committed
48
49
#include <vector>

gbazin's avatar
   
gbazin committed
50
#include "wxwindows.h"
gbazin's avatar
   
gbazin committed
51
52
#include "preferences_widgets.h"

53
#ifndef wxRB_SINGLE
gbazin's avatar
   
gbazin committed
54
#   define wxRB_SINGLE 0
55
56
#endif

gbazin's avatar
   
gbazin committed
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*****************************************************************************
 * Event Table.
 *****************************************************************************/

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

    FileBrowse_Event,
    FileName_Event,

    DiscType_Event,
71
72
73
#ifdef HAVE_LIBCDIO
    DiscProbe_Event,
#endif
gbazin's avatar
   
gbazin committed
74
75
76
    DiscDevice_Event,
    DiscTitle_Event,
    DiscChapter_Event,
77
    DiscSub_Event,
78
    DiscAudio_Event,
gbazin's avatar
   
gbazin committed
79
80

    NetType_Event,
81
    NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
gbazin's avatar
   
gbazin committed
82
    NetPort1_Event, NetPort2_Event, NetPort3_Event,
83
    NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
zorglub's avatar
zorglub committed
84
    NetForceIPv6_Event, NetTimeshift_Event,
gbazin's avatar
   
gbazin committed
85

gbazin's avatar
   
gbazin committed
86
87
88
    SubsFileEnable_Event,
    SubsFileSettings_Event,

gbazin's avatar
   
gbazin committed
89
90
    SoutEnable_Event,
    SoutSettings_Event,
91

92
93
94
    CachingEnable_Event,
    CachingChange_Event,

95
    AdvancedOptions_Event
gbazin's avatar
   
gbazin committed
96
97
};

98
BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
gbazin's avatar
   
gbazin committed
99
100
101
102
103
104
    /* Button events */
    EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
    EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)

    EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)

105
    EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
gbazin's avatar
   
gbazin committed
106
107
108

    /* Events generated by the file panel */
    EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
gbazin's avatar
   
gbazin committed
109
    EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
gbazin's avatar
   
gbazin committed
110
111
112

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

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

gbazin's avatar
   
gbazin committed
143
144
145
146
    /* Events generated by the subtitle file buttons */
    EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
    EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)

gbazin's avatar
   
gbazin committed
147
148
149
    /* Events generated by the stream output buttons */
    EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
    EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
gbazin's avatar
   
gbazin committed
150

151
152
153
    /* Events generated by the caching button */
    EVT_CHECKBOX(CachingEnable_Event, OpenDialog::OnCachingEnable)
    EVT_TEXT(CachingChange_Event, OpenDialog::OnCachingChange)
154
    EVT_SPINCTRL(CachingChange_Event, OpenDialog::OnCachingChangeSpin)
155

gbazin's avatar
   
gbazin committed
156
    /* Hide the window when the user closes the window */
157
    EVT_CLOSE(OpenDialog::OnClose)
gbazin's avatar
   
gbazin committed
158

gbazin's avatar
   
gbazin committed
159
160
END_EVENT_TABLE()

161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*****************************************************************************
 * AutoBuiltPanel.
 *****************************************************************************/
WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);

class AutoBuiltPanel : public wxPanel
{
public:

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

    virtual ~AutoBuiltPanel() {}

176
177
    void UpdateAdvancedMRL();

178
179
    wxString name;
    ArrayOfConfigControls config_array;
180
181
    ArrayOfConfigControls advanced_config_array;
    wxComboBox *p_advanced_mrl_combo;
182
183
184

private:
    intf_thread_t *p_intf;
185
186
187
188
189
190
    OpenDialog *p_open_dialog;

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

    DECLARE_EVENT_TABLE();
191
192
};

193
194
195
196
197
BEGIN_EVENT_TABLE(AutoBuiltPanel, wxPanel)
    EVT_BUTTON(AdvancedOptions_Event, AutoBuiltPanel::OnAdvanced)
END_EVENT_TABLE()

static void AutoBuildCallback( void *p_data )
198
199
200
201
{
    ((OpenDialog *)p_data)->UpdateMRL();
}

202
203
204
205
206
static void AutoBuildAdvancedCallback( void *p_data )
{
    ((AutoBuiltPanel *)p_data)->UpdateAdvancedMRL();
}

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

    if( p_item ) do
    {
221
222
223
        if( !(p_item->i_type & CONFIG_HINT) && p_item->b_advanced )
            b_advanced = true;

224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
        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++ );

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

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

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

320
321
322
    this->SetSizerAndFit( sizer );
}

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

void AutoBuiltPanel::UpdateAdvancedMRL()
{
    wxString mrltemp;

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

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

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

gbazin's avatar
   
gbazin committed
395
396
    sout_dialog = NULL;
    subsfile_dialog = NULL;
yoann's avatar
yoann committed
397
    b_disc_device_changed = false;
gbazin's avatar
   
gbazin committed
398
399
400
401
402
403
404
405

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

gbazin's avatar
   
gbazin committed
417
418
    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
419
420
421
422
423
    mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );


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

427
    wxFlexGridSizer *common_opt_sizer = new wxFlexGridSizer( 5, 1, 20 );
zorglub's avatar
zorglub committed
428
429

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

zorglub's avatar
zorglub committed
438
439
        sout_button = new wxButton( panel, SoutSettings_Event,
                                    wxU(_("Settings...")) );
yoann's avatar
yoann committed
440
        sout_button->Disable();
zorglub's avatar
zorglub committed
441
442
443
444
445
446

        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
447
            subsfile_mrl.Add( wxString(wxT("sout=")) + wxL2U(psz_sout) );
zorglub's avatar
zorglub committed
448
449
450
        }
        if( psz_sout ) free( psz_sout );

451
452
        common_opt_sizer->Add( sout_button, 1, wxALIGN_LEFT |
                               wxALIGN_CENTER_VERTICAL );
zorglub's avatar
zorglub committed
453

454
455
        common_opt_sizer->Add( new wxPanel( this, -1 ), 1,
                               wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
zorglub's avatar
zorglub committed
456
    }
gbazin's avatar
   
gbazin committed
457

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

gbazin's avatar
   
gbazin committed
480
    /* Create notebook */
gbazin's avatar
   
gbazin committed
481
    notebook = new wxNotebook( panel, Notebook_Event );
482

zorglub's avatar
zorglub committed
483
#if (!wxCHECK_VERSION(2,5,0))
gbazin's avatar
   
gbazin committed
484
    wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
zorglub's avatar
zorglub committed
485
#endif
gbazin's avatar
   
gbazin committed
486

gbazin's avatar
   
gbazin committed
487
    notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
gbazin's avatar
   
gbazin committed
488
                       i_access_method == FILE_ACCESS );
gbazin's avatar
   
gbazin committed
489
    notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
gbazin's avatar
   
gbazin committed
490
                       i_access_method == DISC_ACCESS );
gbazin's avatar
   
gbazin committed
491
    notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
gbazin's avatar
   
gbazin committed
492
                       i_access_method == NET_ACCESS );
493

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

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

gbazin's avatar
   
gbazin committed
538
539
540
541
    /* Update Disc panel */
    wxCommandEvent dummy_event;
    OnDiscTypeChange( dummy_event );

gbazin's avatar
   
gbazin committed
542
543
544
545
    /* Update Net panel */
    dummy_event.SetId( NetRadio1_Event );
    OnNetTypeChange( dummy_event );

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

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

gbazin's avatar
   
gbazin committed
592
int OpenDialog::Show()
gbazin's avatar
   
gbazin committed
593
{
594
    int i_ret = wxDialog::Show();
gbazin's avatar
   
gbazin committed
595
596
597
    Raise();
    SetFocus();
    return i_ret;
gbazin's avatar
   
gbazin committed
598
599
}

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

gbazin's avatar
   
gbazin committed
608
609
610
611
    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );

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

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

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

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

gbazin's avatar
   
gbazin committed
665
    disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
gbazin's avatar
   
gbazin committed
666
667
668
                                wxDefaultPosition, wxDefaultSize,
                                WXSIZEOF(disc_type_array), disc_type_array,
                                WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
Sam Hocevar's avatar
Sam Hocevar committed
669

670
671
#ifdef HAVE_LIBCDIO
    disc_probe = new wxCheckBox( panel, DiscProbe_Event, 
672
                                 wxU(_("Probe Disc")) );
673
674
675
676
677
678
    disc_probe->SetToolTip( wxU(_("Probe for a DVD, VCD or audio CD. " 
"First try the device name entered for the selected disc type "
"(DVD, DVD Menu, VCD, CDDA). 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 "
"based on media we find.")) );
679
680
#endif

681
    sizer_row->Add( disc_type, i_disc_type_selection, wxEXPAND | wxALL, 5 );
682
    sizer_row->Add( disc_probe, 0, wxEXPAND | wxALL );
gbazin's avatar
   
gbazin committed
683

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

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

692
    disc_title_label = new wxStaticText( panel, -1, wxU(_("Title")) );
gbazin's avatar
   
gbazin committed
693
    disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
694
    sizer->Add( disc_title_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
   
gbazin committed
695
696
    sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );

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

    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
708
    i_disc_sub = config_GetInt( p_intf, "sub-track" );
709
710
    disc_sub->SetValue( i_disc_sub );

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

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

742
    for( i=0; i<4; i++ )
gbazin's avatar
   
gbazin committed
743
744
745
746
747
748
749
750
751
752
    {
        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 );
    }

753
754
755
756
    /* Timeshift */
    net_timeshift  = new wxCheckBox( panel, NetTimeshift_Event,
                                     wxU(_("Allow timeshifting")) );

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

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

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

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

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

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

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

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

834
void OpenDialog::UpdateMRL()
gbazin's avatar
   
gbazin committed
835
{
836
    UpdateMRL( i_current_access_method );
gbazin's avatar
   
gbazin committed
837
838
839
840
}

void OpenDialog::UpdateMRL( int i_access_method )
{
841
    wxString mrltemp, caching_name;
gbazin's avatar
   
gbazin committed
842
843
844

    i_current_access_method = i_access_method;

gbazin's avatar
   
gbazin committed
845
846
847
    switch( i_access_method )
    {
    case FILE_ACCESS:
gbazin's avatar
   
gbazin committed
848
        mrltemp = file_combo->GetValue();
849
        caching_name = wxT("file-caching");
gbazin's avatar
   
gbazin committed
850
        break;
851

gbazin's avatar
   
gbazin committed
852
    case DISC_ACCESS:
853
        i_disc_type_selection = disc_type->GetSelection();
854

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

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

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

906
            if( i_disc_sub >= 0 )
hartman's avatar
hartman committed
907
                mrltemp += wxString::Format( wxT("  :sub-track=%d"),
908
                                             i_disc_sub );
909

910
911
912
            if( i_disc_audio >= 0 )
                mrltemp += wxString::Format( wxT("  :audio-track=%d"),
                                             i_disc_audio );
913
            caching_name = wxT("vcd-caching");
914
            break;
915

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

931
            caching_name = wxT("cdda-caching");
932
            break;
933

934
935
936
        default:
            msg_Err( p_intf, "invalid selection (%d)",
                     disc_type->GetSelection() );
Sam Hocevar's avatar
Sam Hocevar committed
937
        }
938

gbazin's avatar
   
gbazin committed
939
        break;
940

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

956
            caching_name = wxT("udp-caching");
gbazin's avatar
   
gbazin committed
957
958
959
            break;

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

977
            caching_name = wxT("udp-caching");
gbazin's avatar
   
gbazin committed
978
979
980
            break;

        case 2:
981
            /* http access */
982
983
984
            if( net_addrs[2]->GetLineText(0).Find(wxT("://")) == -1 )
                mrltemp = wxT("http://");

985
            mrltemp += net_addrs[2]->GetLineText(0);
986

987
            caching_name = wxT("http-caching");
988
989
990
991
            break;

        case 3:
            /* RTSP access */
992
            if( net_addrs[3]->GetLineText(0).Find(wxT("rtsp://")) != 0 )
993
            {
994
                mrltemp = wxT("rtsp://");
995
996
            }
            mrltemp += net_addrs[3]->GetLineText(0);
997

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

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

                mrltemp += wxT(" :");

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

                mrltemp += control->GetName();
1026
1027
1028
1029
1030
1031
1032

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

            if( input_panel->p_advanced_mrl_combo &&
                input_panel->p_advanced_mrl_combo->GetValue() )
            {
                mrltemp += wxT(" ") +
                    input_panel->p_advanced_mrl_combo->GetValue();
            }
1052
        }
gbazin's avatar
   
gbazin committed
1053
1054
1055
        break;
    }

1056
1057
1058
1059
    if( caching_name.size() )
    {
        if( caching_value->IsEnabled() )
        {
1060
1061
            mrltemp += wxT("  :") + caching_name +
                wxString::Format( wxT("=%d"), i_caching );
1062
1063
1064
1065
1066
1067
1068
1069
        }
        else
        {
            int i_value = config_GetInt( p_intf, caching_name.mb_str() );
            caching_value->SetValue( i_value );
        }
    }

gbazin's avatar
   
gbazin committed
1070
1071
1072
    mrl_combo->SetValue( mrltemp );
}

gbazin's avatar
   
gbazin committed
1073
1074
1075
1076
1077
/*****************************************************************************
 * Events methods.
 *****************************************************************************/
void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
{
gbazin's avatar
   
gbazin committed
1078
    mrl = SeparateEntries( mrl_combo->GetValue() );
gbazin's avatar
   
gbazin committed
1079
1080
1081
    mrl_combo->Append( mrl_combo->GetValue() );