open.cpp 45.8 KB
Newer Older
gbazin's avatar
   
gbazin committed
1
2
3
/*****************************************************************************
 * open.cpp : wxWindows plugin for vlc
 *****************************************************************************
hartman's avatar
hartman committed
4
 * Copyright (C) 2000-2004 VideoLAN
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
33
34
 *
 * 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>

#include <wx/combobox.h>
gbazin's avatar
   
gbazin committed
35
#include <wx/statline.h>
gbazin's avatar
   
gbazin committed
36
#include <wx/tokenzr.h>
gbazin's avatar
   
gbazin committed
37
38
39

#include <vlc/intf.h>

gbazin's avatar
   
gbazin committed
40
#include "wxwindows.h"
gbazin's avatar
   
gbazin committed
41
42
#include "preferences_widgets.h"

43
#ifndef wxRB_SINGLE
gbazin's avatar
   
gbazin committed
44
#   define wxRB_SINGLE 0
45
46
#endif

gbazin's avatar
   
gbazin committed
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*****************************************************************************
 * Event Table.
 *****************************************************************************/

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

    FileBrowse_Event,
    FileName_Event,

    DiscType_Event,
    DiscDevice_Event,
    DiscTitle_Event,
    DiscChapter_Event,

    NetType_Event,
66
    NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
gbazin's avatar
   
gbazin committed
67
    NetPort1_Event, NetPort2_Event, NetPort3_Event,
68
    NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
69
    NetForceIPv6_Event,
gbazin's avatar
   
gbazin committed
70

gbazin's avatar
   
gbazin committed
71
72
73
    SubsFileEnable_Event,
    SubsFileSettings_Event,

gbazin's avatar
   
gbazin committed
74
75
    SoutEnable_Event,
    SoutSettings_Event,
76
77

    AdvancedOptions_Event
gbazin's avatar
   
gbazin committed
78
79
};

80
BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
gbazin's avatar
   
gbazin committed
81
82
83
84
85
86
    /* Button events */
    EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
    EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)

    EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)

87
    EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
gbazin's avatar
   
gbazin committed
88
89
90

    /* Events generated by the file panel */
    EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
gbazin's avatar
   
gbazin committed
91
    EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
gbazin's avatar
   
gbazin committed
92
93
94

    /* Events generated by the disc panel */
    EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
yoann's avatar
yoann committed
95
    EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscDeviceChange)
gbazin's avatar
   
gbazin committed
96
97
98
99
100
101
102
103
104
105
    EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
    EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
    EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
    EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
    EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChange)

    /* Events generated by the net panel */
    EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
    EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
    EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
106
    EVT_RADIOBUTTON(NetRadio4_Event, OpenDialog::OnNetTypeChange)
gbazin's avatar
   
gbazin committed
107
108
109
110
111
112
113
114
    EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
    EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChange)
    EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
    EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChange)
    EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
    EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChange)
    EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
    EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
115
    EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange)
116
    EVT_CHECKBOX(NetForceIPv6_Event, OpenDialog::OnNetPanelChange)
gbazin's avatar
   
gbazin committed
117

gbazin's avatar
   
gbazin committed
118
119
120
121
    /* Events generated by the subtitle file buttons */
    EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
    EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)

gbazin's avatar
   
gbazin committed
122
123
124
    /* Events generated by the stream output buttons */
    EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
    EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
gbazin's avatar
   
gbazin committed
125

gbazin's avatar
   
gbazin committed
126
127
128
    /* Hide the window when the user closes the window */
    EVT_CLOSE(OpenDialog::OnCancel)

gbazin's avatar
   
gbazin committed
129
130
END_EVENT_TABLE()

131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*****************************************************************************
 * AutoBuiltPanel.
 *****************************************************************************/
WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);

class AutoBuiltPanel : public wxPanel
{
public:

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

    virtual ~AutoBuiltPanel() {}

146
147
    void UpdateAdvancedMRL();

148
149
    wxString name;
    ArrayOfConfigControls config_array;
150
151
    ArrayOfConfigControls advanced_config_array;
    wxComboBox *p_advanced_mrl_combo;
152
153
154

private:
    intf_thread_t *p_intf;
155
156
157
158
159
160
    OpenDialog *p_open_dialog;

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

    DECLARE_EVENT_TABLE();
161
162
};

163
164
165
166
167
BEGIN_EVENT_TABLE(AutoBuiltPanel, wxPanel)
    EVT_BUTTON(AdvancedOptions_Event, AutoBuiltPanel::OnAdvanced)
END_EVENT_TABLE()

static void AutoBuildCallback( void *p_data )
168
169
170
171
{
    ((OpenDialog *)p_data)->UpdateMRL();
}

172
173
174
175
176
static void AutoBuildAdvancedCallback( void *p_data )
{
    ((AutoBuiltPanel *)p_data)->UpdateAdvancedMRL();
}

177
178
179
AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
                                intf_thread_t *_p_intf,
                                const module_t *p_module )
180
181
182
183
  : 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 )
184
185
186
{
    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
    module_config_t *p_item = p_module->p_config;
187
    bool b_advanced = false;
188
189
190

    if( p_item ) do
    {
191
192
193
        if( !(p_item->i_type & CONFIG_HINT) && p_item->b_advanced )
            b_advanced = true;

194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
        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++ );

211
212
213
214
215
216
217
218
219
220
221
222
    if( b_advanced )
    {
        wxPanel *dummy_panel = new wxPanel( this, -1 );
        sizer->Add( dummy_panel, 1 );

        wxButton *button =
            new wxButton( this, AdvancedOptions_Event,
                          wxU(_("Advanced options...")) );
        sizer->Add( button, 0, wxALL, 5 );

        /* Build the advanced dialog */
        p_advanced_dialog =
223
224
            new wxDialog( this, -1, ((wxString)wxU(_("Advanced options"))) +
                          wxT(" (") + wxU( p_module->psz_longname ) + wxT(")"),
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
                          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 */
        dummy_panel = new wxPanel( p_advanced_dialog, -1 );
        sizer->Add( dummy_panel, 1 );
        wxStaticLine *static_line =
            new wxStaticLine( p_advanced_dialog, wxID_OK );
        sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );

277
        /* Create buttons */
278
279
280
        wxButton *ok_button =
            new wxButton( p_advanced_dialog, wxID_OK, wxU(_("OK")) );
        ok_button->SetDefault();
281
282
283
284
285
286
287
        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 );
288
289
290
291
292

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

293
294
295
    this->SetSizerAndFit( sizer );
}

296
297
void AutoBuiltPanel::OnAdvanced( wxCommandEvent& event )
{
298
299
300
301
302
    if( p_advanced_dialog->ShowModal() == wxID_OK )
    {
        UpdateAdvancedMRL();
        p_open_dialog->UpdateMRL();
    }
303
304
305
306
307
308
309
310
311
312
}

void AutoBuiltPanel::UpdateAdvancedMRL()
{
    wxString mrltemp;

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

313
        mrltemp += (i ? wxT(" :") : wxT(":"));
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341

        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
342
343
344
/*****************************************************************************
 * Constructor.
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
345
OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
gbazin's avatar
   
gbazin committed
346
                        int i_access_method, int i_arg ):
347
      wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
gbazin's avatar
   
gbazin committed
348
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
zorglub's avatar
zorglub committed
349
350
351
352
353
354
{
    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 ):
355
      wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
zorglub's avatar
zorglub committed
356
             wxDefaultSize, wxDEFAULT_FRAME_STYLE )
gbazin's avatar
   
gbazin committed
357
358
{
    /* Initializations */
zorglub's avatar
zorglub committed
359
    i_method = _i_method;
gbazin's avatar
   
gbazin committed
360
    p_intf = _p_intf;
gbazin's avatar
   
gbazin committed
361
    p_parent = _p_parent;
gbazin's avatar
   
gbazin committed
362
    SetIcon( *p_intf->p_sys->p_icon );
gbazin's avatar
   
gbazin committed
363
    file_dialog = NULL;
364
    i_disc_type_selection = 0;
gbazin's avatar
   
gbazin committed
365
    i_open_arg = i_arg;
Sam Hocevar's avatar
Sam Hocevar committed
366

gbazin's avatar
   
gbazin committed
367
368
    sout_dialog = NULL;
    subsfile_dialog = NULL;
yoann's avatar
yoann committed
369
    b_disc_device_changed = false;
gbazin's avatar
   
gbazin committed
370
371
372
373
374
375
376
377

    /* 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
378
                               wxU(_("Media Resource Locator (MRL)")) );
gbazin's avatar
   
gbazin committed
379
380
381
    wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
                                                        wxHORIZONTAL );
    wxStaticText *mrl_label = new wxStaticText( panel, -1,
Carlo Calabrò's avatar
Carlo Calabrò committed
382
                                                wxU(_("Open:")) );
gbazin's avatar
   
gbazin committed
383
    mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
gbazin's avatar
   
gbazin committed
384
385
                                wxPoint(20,25), wxSize(120, -1),
                                0, NULL );
gbazin's avatar
   
gbazin committed
386
387
    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
388
        "filled automatically when you use the controls below.")) );
gbazin's avatar
   
gbazin committed
389

gbazin's avatar
   
gbazin committed
390
391
    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
392
393
394
395
396
    mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );


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

zorglub's avatar
zorglub committed
400
401
402
403
    wxFlexGridSizer *sout_sizer = NULL;
    wxStaticLine *static_line = NULL;

    if( i_method == OPEN_NORMAL )
gbazin's avatar
   
gbazin committed
404
    {
zorglub's avatar
zorglub committed
405
406
        /* Create Stream Output checkox */
        sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
gbazin's avatar
   
gbazin committed
407
408


zorglub's avatar
zorglub committed
409
410
        sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
                                         wxU(_("Stream output")) );
hartman's avatar
hartman committed
411
        sout_checkbox->SetToolTip( wxU(_("Use VLC as a server of streams")) );
zorglub's avatar
zorglub committed
412
413
414
415
        sout_sizer->Add( sout_checkbox, 0,
                         wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
        sout_button = new wxButton( panel, SoutSettings_Event,
                                    wxU(_("Settings...")) );
yoann's avatar
yoann committed
416
        sout_button->Disable();
zorglub's avatar
zorglub committed
417
418
419
420
421
422

        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
423
            subsfile_mrl.Add( wxString(wxT("sout=")) + wxL2U(psz_sout) );
zorglub's avatar
zorglub committed
424
425
426
427
428
429
430
431
432
        }
        if( psz_sout ) free( psz_sout );

        sout_sizer->Add( sout_button, 1, wxALIGN_LEFT |
                         wxALIGN_CENTER_VERTICAL );

        /* Separation */
        static_line = new wxStaticLine( panel, wxID_OK );
    }
gbazin's avatar
   
gbazin committed
433

gbazin's avatar
   
gbazin committed
434
    /* Create the buttons */
gbazin's avatar
   
gbazin committed
435
    wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
gbazin's avatar
   
gbazin committed
436
    ok_button->SetDefault();
gbazin's avatar
   
gbazin committed
437
438
    wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
                                            wxU(_("Cancel")) );
gbazin's avatar
   
gbazin committed
439

gbazin's avatar
   
gbazin committed
440
    /* Create notebook */
gbazin's avatar
   
gbazin committed
441
    notebook = new wxNotebook( panel, Notebook_Event );
gbazin's avatar
   
gbazin committed
442
443
    wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );

gbazin's avatar
   
gbazin committed
444
    notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
gbazin's avatar
   
gbazin committed
445
                       i_access_method == FILE_ACCESS );
gbazin's avatar
   
gbazin committed
446
    notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
gbazin's avatar
   
gbazin committed
447
                       i_access_method == DISC_ACCESS );
gbazin's avatar
   
gbazin committed
448
    notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
gbazin's avatar
   
gbazin committed
449
                       i_access_method == NET_ACCESS );
450

451
452
453
454
455
456
    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 );
457
        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ),
458
459
460
461
462
463
464
465
466
                           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 );
467
468
469
470
471
472
473
474
475
476
477
        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ),
                           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 );
        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ),
478
479
480
481
                           i_access_method == CAPTURE_ACCESS );
    }

    p_module = config_FindModule( VLC_OBJECT(p_intf), "dshow" );
gbazin's avatar
   
gbazin committed
482
483
    if( p_module )
    {
484
485
486
        AutoBuiltPanel *autopanel =
            new AutoBuiltPanel( notebook, this, p_intf, p_module );
        input_tab_array.Add( autopanel );
487
        notebook->AddPage( autopanel, wxU( p_module->psz_shortname ),
gbazin's avatar
gbazin committed
488
                           i_access_method == CAPTURE_ACCESS );
gbazin's avatar
   
gbazin committed
489
490
    }

gbazin's avatar
   
gbazin committed
491
492
493
494
    /* Update Disc panel */
    wxCommandEvent dummy_event;
    OnDiscTypeChange( dummy_event );

gbazin's avatar
   
gbazin committed
495
496
497
498
    /* Update Net panel */
    dummy_event.SetId( NetRadio1_Event );
    OnNetTypeChange( dummy_event );

gbazin's avatar
   
gbazin committed
499
    /* Update MRL */
500
    wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
gbazin's avatar
   
gbazin committed
501
502
503
504
505
506
507
508
509
510
511
    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 );
gbazin's avatar
   
gbazin committed
512
    panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
zorglub's avatar
zorglub committed
513
514
515
516
517
    if( i_method == OPEN_NORMAL)
    {
        panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
        panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
    }
gbazin's avatar
   
gbazin committed
518
    panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
gbazin's avatar
   
gbazin committed
519
520
521
522
523
524
525
526
527
    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
528
529
530
531
    /* 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
532
533
}

gbazin's avatar
   
gbazin committed
534
int OpenDialog::Show( int i_access_method, int i_arg )
gbazin's avatar
   
gbazin committed
535
536
{
    notebook->SetSelection( i_access_method );
537
    int i_ret = wxDialog::Show();
gbazin's avatar
   
gbazin committed
538
539
    Raise();
    SetFocus();
gbazin's avatar
   
gbazin committed
540
    i_open_arg = i_arg;
gbazin's avatar
   
gbazin committed
541
    return i_ret;
gbazin's avatar
   
gbazin committed
542
543
}

gbazin's avatar
   
gbazin committed
544
int OpenDialog::Show()
gbazin's avatar
   
gbazin committed
545
{
546
    int i_ret = wxDialog::Show();
gbazin's avatar
   
gbazin committed
547
548
549
    Raise();
    SetFocus();
    return i_ret;
gbazin's avatar
   
gbazin committed
550
551
}

gbazin's avatar
   
gbazin committed
552
553
554
555
556
557
558
559
/*****************************************************************************
 * Private methods.
 *****************************************************************************/
wxPanel *OpenDialog::FilePanel( wxWindow* parent )
{
    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
                                  wxSize(200, 200) );

gbazin's avatar
   
gbazin committed
560
561
562
563
    wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );

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

gbazin's avatar
   
gbazin committed
565
    file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
gbazin's avatar
   
gbazin committed
566
567
                                 wxPoint(20,25), wxSize(200, -1), 0, NULL );
    wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
gbazin's avatar
   
gbazin committed
568
                                            wxU(_("Browse...")) );
gbazin's avatar
   
gbazin committed
569
570
571
572
573
574
    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
575
                                        wxU(_("Subtitle options")) );
Carlo Calabrò's avatar
Carlo Calabrò committed
576
    subsfile_checkbox->SetToolTip( wxU(_("Force options for separate subtitle files.")) );
gbazin's avatar
   
gbazin committed
577
578
579
580
581
582
583
584
585
586
587
    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
588
        subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxL2U(psz_subsfile) );
gbazin's avatar
   
gbazin committed
589
590
591
592
593
    }
    if( psz_subsfile ) free( psz_subsfile );

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

gbazin's avatar
   
gbazin committed
595
596
    sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
    sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 );
gbazin's avatar
   
gbazin committed
597
598
599
600
601
602
603
604
605
606
607
608
609
610
    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[] =
    {
611
        wxU(_("DVD (menus)")),
gbazin's avatar
   
gbazin committed
612
613
        wxU(_("DVD")),
        wxU(_("VCD")),
614
        wxU(_("Audio CD")),
615
        wxU(_("DVD (test)"))
gbazin's avatar
   
gbazin committed
616
617
    };

gbazin's avatar
   
gbazin committed
618
    disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
gbazin's avatar
   
gbazin committed
619
620
621
                                wxDefaultPosition, wxDefaultSize,
                                WXSIZEOF(disc_type_array), disc_type_array,
                                WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
Sam Hocevar's avatar
Sam Hocevar committed
622

623
    sizer_row->Add( disc_type, i_disc_type_selection, wxEXPAND | wxALL, 5 );
gbazin's avatar
   
gbazin committed
624

gbazin's avatar
   
gbazin committed
625
626
    wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
    disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
gbazin's avatar
   
gbazin committed
627
628
629
630
631
632
                                  wxDefaultPosition, wxDefaultSize,
                                  wxTE_PROCESS_ENTER);

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

633
    disc_title_label = new wxStaticText( panel, -1, wxU(_("Title")) );
gbazin's avatar
   
gbazin committed
634
    disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
gbazin's avatar
   
gbazin committed
635

636
    sizer->Add( disc_title_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
   
gbazin committed
637
638
    sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );

639
    disc_chapter_label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
gbazin's avatar
   
gbazin committed
640
    disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
Sam Hocevar's avatar
Sam Hocevar committed
641
642
    sizer->Add( disc_chapter_label, 0,
                wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
gbazin's avatar
   
gbazin committed
643
644
645
646
647
648
649
650
651
652
653
654
655
656
    sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
    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 );
657
    wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
gbazin's avatar
   
gbazin committed
658
659
660

    static const wxString net_type_array[] =
    {
gbazin's avatar
   
gbazin committed
661
662
        wxU(_("UDP/RTP")),
        wxU(_("UDP/RTP Multicast")),
663
664
        wxU(_("HTTP/FTP/MMS")),
        wxU(_("RTSP"))
gbazin's avatar
   
gbazin committed
665
666
    };

667
    for( i=0; i<4; i++ )
gbazin's avatar
   
gbazin committed
668
669
670
671
672
673
674
675
676
677
678
679
680
    {
        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 );
    }

    /* UDP/RTP row */
    wxFlexGridSizer *subpanel_sizer;
    wxStaticText *label;
gbazin's avatar
   
gbazin committed
681
    i_net_ports[0] = config_GetInt( p_intf, "server-port" );
682
    subpanel_sizer = new wxFlexGridSizer( 3, 1, 20 );
gbazin's avatar
   
gbazin committed
683
    label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
gbazin's avatar
   
gbazin committed
684
    net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
gbazin's avatar
   
gbazin committed
685
                                   wxString::Format(wxT("%d"), i_net_ports[0]),
gbazin's avatar
   
gbazin committed
686
687
                                   wxDefaultPosition, wxDefaultSize,
                                   wxSP_ARROW_KEYS,
gbazin's avatar
   
gbazin committed
688
                                   0, 16000, i_net_ports[0] );
gbazin's avatar
   
gbazin committed
689
690
691
692

    subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
    subpanel_sizer->Add( net_ports[0], 1,
                         wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
693
694
695
696
    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
697
    net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
gbazin's avatar
   
gbazin committed
698
    net_radios[0]->SetValue( TRUE );
gbazin's avatar
   
gbazin committed
699
700
701

    /* UDP/RTP Multicast row */
    subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
gbazin's avatar
   
gbazin committed
702
703
    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
704
705
706
707
708
709
                                   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
710
    label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
gbazin's avatar
   
gbazin committed
711
    i_net_ports[1] = i_net_ports[0];
gbazin's avatar
   
gbazin committed
712
    net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
gbazin's avatar
   
gbazin committed
713
                                   wxString::Format(wxT("%d"), i_net_ports[1]),
gbazin's avatar
   
gbazin committed
714
715
                                   wxDefaultPosition, wxDefaultSize,
                                   wxSP_ARROW_KEYS,
gbazin's avatar
   
gbazin committed
716
                                   0, 16000, i_net_ports[1] );
gbazin's avatar
   
gbazin committed
717
718
719
720
721
722

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

723
724
725
726
727
728
    /* 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
729
                                       (i == 2) ? wxT("") : wxT("rtsp://"),
730
731
732
733
734
735
736
                                       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
737
738

    /* Stuff everything into the main panel */
739
    for( i=0; i<4; i++ )
gbazin's avatar
   
gbazin committed
740
    {
gbazin's avatar
   
gbazin committed
741
742
743
744
        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
745
746
747
748
749
750
751
752
    }

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

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

753
void OpenDialog::UpdateMRL()
gbazin's avatar
   
gbazin committed
754
{
755
    UpdateMRL( i_current_access_method );
gbazin's avatar
   
gbazin committed
756
757
758
759
}

void OpenDialog::UpdateMRL( int i_access_method )
{
gbazin's avatar
   
gbazin committed
760
    wxString demux, mrltemp;
gbazin's avatar
   
gbazin committed
761
762
763

    i_current_access_method = i_access_method;

gbazin's avatar
   
gbazin committed
764
765
766
    switch( i_access_method )
    {
    case FILE_ACCESS:
gbazin's avatar
   
gbazin committed
767
768
        //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
        mrltemp = file_combo->GetValue();
gbazin's avatar
   
gbazin committed
769
770
        break;
    case DISC_ACCESS:
771
772
      i_disc_type_selection = disc_type->GetSelection();

773
      switch ( i_disc_type_selection )
Sam Hocevar's avatar
Sam Hocevar committed
774
        {
775
        case 0: /* DVD with menues */
Sam Hocevar's avatar
Sam Hocevar committed
776
777
          disc_chapter->Enable();
          disc_chapter_label->Enable();
778
          mrltemp = wxT("dvd://")
yoann's avatar
yoann committed
779
                  + disc_device->GetValue()
gbazin's avatar
   
gbazin committed
780
                  + wxString::Format( wxT("@%d:%d"),
gbazin's avatar
   
gbazin committed
781
782
                                      disc_title->GetValue(),
                                      disc_chapter->GetValue() );
Sam Hocevar's avatar
Sam Hocevar committed
783
          break;
784

785
        case 1: /* DVD of some sort */
Sam Hocevar's avatar
Sam Hocevar committed
786
787
788
          disc_chapter->Enable();
          disc_chapter_label->Enable();
          mrltemp = wxT("dvdsimple://")
Rocky Bernstein's avatar
Rocky Bernstein committed
789
790
791
792
                  + disc_device->GetValue()
                  + wxString::Format( wxT("@%d:%d"),
                                      disc_title->GetValue(),
                                      disc_chapter->GetValue() );
Sam Hocevar's avatar
Sam Hocevar committed
793
          break;
794

795
796
797
        case 2:  /* VCD of some sort */
          {
            /* The chapter object is used for subtitles */
798

799
800
801
802
803
            int i_subtitle = disc_chapter->GetValue();
            config_PutInt( p_intf, "spu-channel", i_subtitle );
            
            disc_chapter->Enable();
            disc_chapter_label->Enable();
Rocky Bernstein's avatar
Rocky Bernstein committed
804
#ifdef HAVE_VCDX
Sam Hocevar's avatar
Sam Hocevar committed
805
806
807
808
809
810
811
812
813
814
          if ( disc_title->GetValue() )
            mrltemp = wxT("vcdx://")
              + disc_device->GetValue()
              + wxString::Format( wxT("@%c%d"),
                                  config_GetInt( p_intf, "vcdx-PBC"  )
                                  ? 'P' : 'E',
                                  disc_title->GetValue()
                                  );
          else
            mrltemp = wxT("vcdx://")
815
              + disc_device->GetValue();
Rocky Bernstein's avatar
Rocky Bernstein committed
816
#else
Sam Hocevar's avatar
Sam Hocevar committed
817
          mrltemp = wxT("vcd://")
818
819
820
            + disc_device->GetValue()
            + wxString::Format( wxT("@%d"),
                                disc_title->GetValue() );
Rocky Bernstein's avatar
Rocky Bernstein committed
821
#endif
Sam Hocevar's avatar
Sam Hocevar committed
822
          break;
823
824
          }
          
825

826
        case 3: /* CD-DA */
Sam Hocevar's avatar
Sam Hocevar committed
827
828
          disc_chapter->Disable();
          disc_chapter_label->Disable();
Rocky Bernstein's avatar
Rocky Bernstein committed
829
#ifdef HAVE_CDDAX
Sam Hocevar's avatar
Sam Hocevar committed
830
831
832
          if ( disc_title->GetValue() )
            mrltemp =  wxT("cddax://")
                  + disc_device->GetValue()
833
834
                  + wxString::Format( wxT("@T%d"),
                                      disc_title->GetValue() );
Sam Hocevar's avatar
Sam Hocevar committed
835
836
837
          else
            mrltemp = wxT("cddax://")
                  + disc_device->GetValue();
838

Rocky Bernstein's avatar
Rocky Bernstein committed
839
#else
Sam Hocevar's avatar
Sam Hocevar committed
840
          mrltemp =  wxT("cdda://")
Rocky Bernstein's avatar
Rocky Bernstein committed
841
842
843
844
                  + disc_device->GetValue()
                  + wxString::Format( wxT("@%d"),
                                      disc_title->GetValue() );
#endif
Sam Hocevar's avatar
Sam Hocevar committed
845
          break;
846
847
848
849
850
851
852
853
854
855
856

        case 4: /* DVD of some sort */
          disc_chapter->Enable();
          disc_chapter_label->Enable();
          mrltemp = wxT("dvdnav://")
                  + disc_device->GetValue()
                  + wxString::Format( wxT("@%d:%d"),
                                      disc_title->GetValue(),
                                      disc_chapter->GetValue() );
          break;

Sam Hocevar's avatar
Sam Hocevar committed
857
858
859
860
        default: ;
          msg_Err( p_intf, "invalid selection (%d)",
                   disc_type->GetSelection() );
        }
861

gbazin's avatar
   
gbazin committed
862
863
864
865
866
        break;
    case NET_ACCESS:
        switch( i_net_type )
        {
        case 0:
867
            mrltemp = wxT("udp") + demux + wxT("://");
868
869
870
871
            if ( net_ipv6->GetValue() )
            {
                mrltemp += wxT("@[::]");
            }
gbazin's avatar
   
gbazin committed
872
            if( i_net_ports[0] !=
gbazin's avatar
   
gbazin committed
873
874
                config_GetInt( p_intf, "server-port" ) )
            {
875
                mrltemp += wxString::Format( wxT("@:%d"), i_net_ports[0] );
gbazin's avatar
   
gbazin committed
876
877
878
879
            }
            break;

        case 1:
880
881
882
883
884
885
886
887
888
889
890
891
892
            mrltemp = wxT("udp") + demux + wxT("://@");
            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
893
            {
894
                mrltemp += wxString::Format( wxT(":%d"), i_net_ports[1] );
gbazin's avatar
   
gbazin committed
895
896
897
898
            }
            break;

        case 2:
899
            /* http access */
gbazin's avatar
   
gbazin committed
900
            if( net_addrs[2]->GetLineText(0).Find(wxT("http://")) )
901
902
903
            {
                mrltemp = wxT("http") + demux + wxT("://");
            }
904
905
906
907
908
            mrltemp += net_addrs[2]->GetLineText(0);
            break;

        case 3:
            /* RTSP access */
909
            if( net_addrs[3]->GetLineText(0).Find(wxT("rtsp://")) != 0 )
910
911
912
913
            {
                mrltemp = wxT("rtsp") + demux + wxT("://");
            }
            mrltemp += net_addrs[3]->GetLineText(0);
gbazin's avatar
   
gbazin committed
914
915
916
            break;
        }
        break;
917

gbazin's avatar
   
gbazin committed
918
    default:
919
920
921
922
923
924
925
926
927
928
929
930
931
        {
            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);
932
933
934
935
936
937
938

                mrltemp += wxT(" :");

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

                mrltemp += control->GetName();
939
940
941
942
943
944
945

                switch( control->GetType() )
                {
                case CONFIG_ITEM_STRING:
                case CONFIG_ITEM_FILE:
                case CONFIG_ITEM_DIRECTORY:
                case CONFIG_ITEM_MODULE:
946
                    mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
947
948
949
                    break;
                case CONFIG_ITEM_INTEGER:
                    mrltemp +=
950
                        wxString::Format( wxT("=%i"), control->GetIntValue() );
951
952
953
                    break;
                case CONFIG_ITEM_FLOAT:
                    mrltemp +=
954
                        wxString::Format(wxT("=%f"), control->GetFloatValue());
955
956
957
                    break;
                }
            }
958
959
960
961
962
963
964

            if( input_panel->p_advanced_mrl_combo &&
                input_panel->p_advanced_mrl_combo->GetValue() )
            {
                mrltemp += wxT(" ") +
                    input_panel->p_advanced_mrl_combo->GetValue();
            }
965
        }
gbazin's avatar
   
gbazin committed
966
967
968
        break;
    }

gbazin's avatar
   
gbazin committed
969
970
971
    mrl_combo->SetValue( mrltemp );
}

gbazin's avatar
   
gbazin committed
972
973
974
975
976
/*****************************************************************************
 * Events methods.
 *****************************************************************************/
void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
{
gbazin's avatar
   
gbazin committed
977
    mrl = SeparateEntries( mrl_combo->GetValue() );
gbazin's avatar
   
gbazin committed
978
979
980
    mrl_combo->Append( mrl_combo->GetValue() );
    if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 );
    mrl_combo->SetSelection( mrl_combo->GetCount() - 1 );
gbazin's avatar
   
gbazin committed
981

zorglub's avatar
zorglub committed
982
983
984
    if( i_method == OPEN_STREAM )
    {
        Hide();
985
        if( IsModal() ) EndModal( wxID_OK );
zorglub's avatar
zorglub committed
986
987
988
        return;
    }

gbazin's avatar
   
gbazin committed
989
990
991
    /* Update the playlist */
    playlist_t *p_playlist =
        (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
992
                                       FIND_ANYWHERE );
993
    if( p_playlist == NULL ) return;
gbazin's avatar
   
gbazin committed
994

995
    for( int i = 0; i < (int)mrl.GetCount(); i++ )
gbazin's avatar
   
gbazin committed
996
    {
gbazin's avatar
   
gbazin committed
997
        vlc_bool_t b_start = !i && i_open_arg;
998
        playlist_item_t *p_item =
gbazin's avatar
   
gbazin committed
999
1000
            playlist_ItemNew( p_intf, (const char*)mrl[i].mb_str(),
                              (const char *)mrl[i].mb_str() );
1001

1002
        /* Insert options */
gbazin's avatar
   
gbazin committed
1003
1004
        while( i + 1 < (int)mrl.GetCount() &&
               ((const char *)mrl[i + 1].mb_str())[0] == ':' )
1005
        {
gbazin's avatar
   
gbazin committed
1006
1007
            playlist_ItemAddOption( p_item, mrl[i + 1].mb_str() );
            i++;
1008
1009
1010
1011
1012
1013
1014
        }

        /* Get the options from the subtitles dialog */
        if( subsfile_checkbox->IsChecked() && subsfile_mrl.GetCount() )
        {
            for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ )
            {
1015
                playlist_ItemAddOption( p_item, subsfile_mrl[j].mb_str() );
1016
1017
1018
1019
1020
1021
1022
1023
            }
        }

        /* Get the options from the stream output dialog */
        if( sout_checkbox->IsChecked() && sout_mrl.GetCount() )
        {
            for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
            {
1024
                playlist_ItemAddOption( p_item, sout_mrl[j].mb_str() );
1025
1026
            }
        }
gbazin's avatar
   
gbazin committed
1027

gbazin's avatar
   
gbazin committed
1028
1029
        int i_id = playlist_AddItem( p_playlist, p_item,
                                     PLAYLIST_APPEND, PLAYLIST_END );
1030

gbazin's avatar
   
gbazin committed
1031
        if( b_start )
gbazin's avatar
   
gbazin committed
1032
1033
1034
1035
        {
            int i_pos = playlist_GetPositionById( p_playlist , i_id );
            playlist_Command( p_playlist, PLAYLIST_GOTO, i_pos );
        }
1036
    }
gbazin's avatar
   
gbazin committed
1037
1038
1039
1040

    vlc_object_release( p_playlist );

    Hide();
1041

1042
    if( IsModal() ) EndModal( wxID_OK );
gbazin's avatar
   
gbazin committed
1043
1044
1045
1046
}

void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
{
gbazin's avatar
   
gbazin committed
1047
    Hide();
1048

1049
    if( IsModal() ) EndModal( wxID_CANCEL );
gbazin's avatar
   
gbazin committed
1050
1051
1052
1053
1054
1055
1056
1057
1058
}

void OpenDialog::OnPageChange( wxNotebookEvent& event )
{
    UpdateMRL( event.GetSelection() );
}

void OpenDialog::OnMRLChange( wxCommandEvent& event )
{
gbazin's avatar
   
gbazin committed
1059
    //mrl = SeparateEntries( event.GetString() );
gbazin's avatar
   
gbazin committed
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
}

/*****************************************************************************
 * File panel event methods.
 *****************************************************************************/
void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
{
    UpdateMRL( FILE_ACCESS );
}

void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
{
gbazin's avatar
   
gbazin committed
1072
    if( file_dialog == NULL )
hartman's avatar
hartman committed
1073
        file_dialog = new wxFileDialog( this, wxU(_("Open File")),
gbazin's avatar
   
gbazin committed
1074
            wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
gbazin's avatar
   
gbazin committed
1075

gbazin's avatar
   
gbazin committed
1076
    if( file_dialog && file_dialog->ShowModal() == wxID_OK )
gbazin's avatar
   
gbazin committed
1077
    {
gbazin's avatar
   
gbazin committed
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
        wxArrayString paths;
        wxString path;

        file_dialog->GetPaths( paths );

        for( size_t i = 0; i < paths.GetCount(); i++ )
        {
            if( paths[i].Find( wxT(' ') ) >= 0 )
                path += wxT("\"") + paths[i] + wxT("\" ");
            else
                path += paths[i] + wxT(" ");
        }

        file_combo->SetValue( path );
        file_combo->Append( path );
gbazin's avatar
   
gbazin committed
1093
        if( file_combo->GetCount() > 10 ) file_combo->Delete( 0 );
gbazin's avatar
   
gbazin committed
1094
1095
1096
1097
1098
1099
1100
        UpdateMRL( FILE_ACCESS );
    }
}

/*****************************************************************************
 * Disc panel event methods.
 *****************************************************************************/
gbazin's avatar
   
gbazin committed
1101
void OpenDialog::OnDiscPanelChange( wxCommandEvent& event )
gbazin's avatar
   
gbazin committed
1102
1103
1104
1105
{
    UpdateMRL( DISC_ACCESS );
}

yoann's avatar
yoann committed
1106
1107
1108
1109
1110
1111
1112
1113
1114
void OpenDialog::OnDiscDeviceChange( wxCommandEvent& event )
{
    char *psz_device;

    switch( disc_type->GetSelection() )
    {
        case 3:
            psz_device = config_GetPsz( p_intf, "cd-audio" );
            break;
1115

yoann's avatar
yoann committed
1116
1117
1118
        case 2:
            psz_device = config_GetPsz( p_intf, "vcd" );
            break;
1119

yoann's avatar
yoann committed
1120
1121
1122
1123
        default:
            psz_device = config_GetPsz( p_intf, "dvd" );
            break;
    }
Sam Hocevar's avatar
Sam Hocevar committed
1124

1125
    if ( !psz_device ) psz_device = "";
yoann's avatar
yoann committed
1126

gbazin's avatar
   
gbazin committed
1127
    if( disc_device->GetValue().Cmp( wxL2U( psz_device ) ) )
yoann's avatar
yoann committed
1128
1129
1130
1131
1132
1133
1134
    {
        b_disc_device_changed = true;
    }

    UpdateMRL( DISC_ACCESS );
}

gbazin's avatar
   
gbazin committed
1135
1136
void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
{
1137
1138
    char *psz_device = NULL;
    int  i_selection = 1; /* Default Title/Track selection number*/
gbazin's avatar
   
gbazin committed
1139
1140
1141

    switch( disc_type->GetSelection() )
    {
yoann's avatar
yoann committed
1142

1143
1144
1145
1146
    case 0: /* DVD with menus */
    case 4: /* DVD with menus (dvdnav) */
        i_selection=0;
        /* Fall through... */
gbazin's avatar
   
gbazin committed
1147

1148
    case 1: /* DVD of some sort */
gbazin's avatar
   
gbazin committed
1149
        psz_device = config_GetPsz( p_intf, "dvd" );
yoann's avatar
yoann committed
1150
1151
        if( !b_disc_device_changed )
        {
gbazin's avatar
   
gbazin committed
1152
1153
1154
1155
1156
            if( psz_device )
                disc_device->SetValue( wxL2U(psz_device) );
            else
                disc_device->SetValue( wxT("") );

hartman's avatar
hartman committed
1157
            disc_title_label->SetLabel ( wxU(_("Title")) );
Sam Hocevar's avatar
Sam Hocevar committed
1158
1159
1160
        }
        disc_title->SetRange( i_selection, 255 );
        disc_title->SetValue( i_selection );