]> git.sesse.net Git - vlc/blob - modules/gui/wxwindows/open.cpp
Added "Force IPv6" check box to UDP Unicast in open dialog
[vlc] / modules / gui / wxwindows / open.cpp
1 /*****************************************************************************
2  * open.cpp : wxWindows plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2000-2001 VideoLAN
5  * $Id: open.cpp,v 1.49 2003/12/10 21:54:16 courmisch Exp $
6  *
7  * Authors: Gildas Bazin <gbazin@netcourrier.com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <stdlib.h>                                      /* malloc(), free() */
28 #include <errno.h>                                                 /* ENOMEM */
29 #include <string.h>                                            /* strerror() */
30 #include <stdio.h>
31
32 #include <vlc/vlc.h>
33
34 #ifdef WIN32                                                 /* mingw32 hack */
35 #undef Yield
36 #undef CreateDialog
37 #endif
38
39 /* Let vlc take care of the i18n stuff */
40 #define WXINTL_NO_GETTEXT_MACRO
41
42 #include <wx/wxprec.h>
43 #include <wx/wx.h>
44 #include <wx/notebook.h>
45 #include <wx/textctrl.h>
46 #include <wx/combobox.h>
47 #include <wx/spinctrl.h>
48 #include <wx/statline.h>
49 #include <wx/tokenzr.h>
50
51 #include <vlc/intf.h>
52
53 #include "wxwindows.h"
54
55 #include "preferences_widgets.h"
56
57 #ifndef wxRB_SINGLE
58 #   define wxRB_SINGLE 0
59 #endif
60
61 /*****************************************************************************
62  * Event Table.
63  *****************************************************************************/
64
65 /* IDs for the controls and the menu commands */
66 enum
67 {
68     Notebook_Event = wxID_HIGHEST,
69     MRL_Event,
70
71     FileBrowse_Event,
72     FileName_Event,
73
74     DiscType_Event,
75     DiscDevice_Event,
76     DiscTitle_Event,
77     DiscChapter_Event,
78
79     NetType_Event,
80     NetRadio1_Event, NetRadio2_Event, NetRadio3_Event,
81     NetPort1_Event, NetPort2_Event, NetPort3_Event,
82     NetAddr1_Event, NetAddr2_Event, NetAddr3_Event,
83     NetForceIPv6_Event,
84
85 #ifndef WIN32
86     VideoType_Event,
87     VideoDevice_Event,
88     VideoChannel_Event,
89     V4LSettings_Event,
90 #endif
91
92     SubsFileEnable_Event,
93     SubsFileSettings_Event,
94
95     SoutEnable_Event,
96     SoutSettings_Event,
97 };
98
99 BEGIN_EVENT_TABLE(OpenDialog, wxFrame)
100     /* Button events */
101     EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
102     EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
103
104     EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)
105
106     EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
107
108     /* Events generated by the file panel */
109     EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
110     EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
111
112     /* Events generated by the disc panel */
113     EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
114     EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscDeviceChange)
115     EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
116     EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
117     EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
118     EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
119     EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
120
121     /* Events generated by the net panel */
122     EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
123     EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
124     EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
125     EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
126     EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChange)
127     EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
128     EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChange)
129     EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
130     EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChange)
131     EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
132     EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
133     EVT_CHECKBOX(NetForceIPv6_Event, OpenDialog::OnNetPanelChange)
134
135 #ifndef WIN32
136     /* Events generated by the v4l panel */
137     EVT_RADIOBOX(VideoType_Event, OpenDialog::OnV4LTypeChange)
138     EVT_TEXT(VideoDevice_Event, OpenDialog::OnV4LPanelChange)
139     EVT_SPINCTRL(VideoChannel_Event, OpenDialog::OnV4LPanelChange)
140     EVT_BUTTON(V4LSettings_Event, OpenDialog::OnV4LSettingsChange)
141 #endif
142
143     /* Events generated by the subtitle file buttons */
144     EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
145     EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)
146
147     /* Events generated by the stream output buttons */
148     EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
149     EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
150
151     /* Hide the window when the user closes the window */
152     EVT_CLOSE(OpenDialog::OnCancel)
153
154 END_EVENT_TABLE()
155
156 /*****************************************************************************
157  * AutoBuiltPanel.
158  *****************************************************************************/
159 WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);
160
161 class AutoBuiltPanel : public wxPanel
162 {
163 public:
164
165     AutoBuiltPanel() { }
166     AutoBuiltPanel( wxWindow *, OpenDialog *, intf_thread_t *,
167                     const module_t * );
168
169     virtual ~AutoBuiltPanel() {}
170
171     wxString name;
172     ArrayOfConfigControls config_array;
173
174 private:
175     intf_thread_t *p_intf;
176 };
177
178 void AutoBuildCallback( void *p_data )
179 {
180     ((OpenDialog *)p_data)->UpdateMRL();
181 }
182
183 AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
184                                 intf_thread_t *_p_intf,
185                                 const module_t *p_module )
186   : wxPanel( parent, -1, wxDefaultPosition, wxSize(200, 200) ),
187     name( wxU(p_module->psz_object_name) ), p_intf( _p_intf )
188 {
189     wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
190
191     module_config_t *p_item = p_module->p_config;
192
193     if( p_item ) do
194     {
195         if( p_item->i_type & CONFIG_HINT || p_item->b_advanced )
196             continue;
197
198         ConfigControl *control =
199             CreateConfigControl( VLC_OBJECT(p_intf), p_item, this );
200
201         config_array.Add( control );
202
203         /* Don't add items that were not recognized */
204         if( control == NULL ) continue;
205
206         control->SetUpdateCallback( AutoBuildCallback, (void *)dialog );
207
208         sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
209     }
210     while( p_item->i_type != CONFIG_HINT_END && p_item++ );
211
212     this->SetSizerAndFit( sizer );
213 }
214
215 /*****************************************************************************
216  * Constructor.
217  *****************************************************************************/
218 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
219                         int i_access_method, int i_arg ):
220     wxFrame( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition,
221              wxDefaultSize, wxDEFAULT_FRAME_STYLE )
222 {
223     OpenDialog( _p_intf, _p_parent, i_access_method, i_arg, OPEN_NORMAL );
224 }
225
226 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
227                         int i_access_method, int i_arg, int _i_method ):
228     wxFrame( _p_parent, -1, wxU(_("Open Target")), wxDefaultPosition,
229              wxDefaultSize, wxDEFAULT_FRAME_STYLE )
230 {
231     /* Initializations */
232     i_method = _i_method;
233     p_intf = _p_intf;
234     p_parent = _p_parent;
235     SetIcon( *p_intf->p_sys->p_icon );
236     file_dialog = NULL;
237 #ifndef WIN32
238     v4l_dialog = NULL;
239 #endif
240     sout_dialog = NULL;
241     subsfile_dialog = NULL;
242     b_disc_device_changed = false;
243
244     /* Create a panel to put everything in */
245     wxPanel *panel = new wxPanel( this, -1 );
246     panel->SetAutoLayout( TRUE );
247
248     /* Create MRL combobox */
249     wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
250     wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
251                                wxU(_("Media Resource Locator (MRL)")) );
252     wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
253                                                         wxHORIZONTAL );
254     wxStaticText *mrl_label = new wxStaticText( panel, -1,
255                                                 wxU(_("Open Target:")) );
256     mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
257                                 wxPoint(20,25), wxSize(120, -1),
258                                 0, NULL );
259     mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
260         "the full MRL you want to open.\n""Alternatively, the field will be "
261         "filled automatically when you use the controls below.")) );
262
263     mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
264     mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
265     mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
266
267
268     /* Create Static Text */
269     wxStaticText *label = new wxStaticText( panel, -1,
270         wxU(_("Alternatively, you can build an MRL using one of the "
271               "following predefined targets:")) );
272
273     wxFlexGridSizer *sout_sizer = NULL;
274     wxStaticLine *static_line = NULL;
275
276     if( i_method == OPEN_NORMAL )
277     {
278         /* Create Stream Output checkox */
279         sout_sizer = new wxFlexGridSizer( 2, 1, 20 );
280
281
282         sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
283                                          wxU(_("Stream output")) );
284         sout_checkbox->SetToolTip( wxU(_("Use VLC as a stream server")) );
285         sout_sizer->Add( sout_checkbox, 0,
286                          wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
287         sout_button = new wxButton( panel, SoutSettings_Event,
288                                     wxU(_("Settings...")) );
289         sout_button->Disable();
290
291         char *psz_sout = config_GetPsz( p_intf, "sout" );
292         if( psz_sout && *psz_sout )
293         {
294             sout_checkbox->SetValue(TRUE);
295             sout_button->Enable();
296             subsfile_mrl.Add( wxString(wxT("sout=")) + wxU(psz_sout) );
297         }
298         if( psz_sout ) free( psz_sout );
299
300         sout_sizer->Add( sout_button, 1, wxALIGN_LEFT |
301                          wxALIGN_CENTER_VERTICAL );
302
303         /* Separation */
304         static_line = new wxStaticLine( panel, wxID_OK );
305     }
306
307     /* Create the buttons */
308     wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
309     ok_button->SetDefault();
310     wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
311                                             wxU(_("Cancel")) );
312
313     /* Create notebook */
314     notebook = new wxNotebook( panel, Notebook_Event );
315     wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
316
317     notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
318                        i_access_method == FILE_ACCESS );
319     notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
320                        i_access_method == DISC_ACCESS );
321     notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
322                        i_access_method == NET_ACCESS );
323 #ifndef WIN32
324     notebook->AddPage( V4LPanel( notebook ), wxU(_("Video For Linux")),
325                        i_access_method == V4L_ACCESS );
326 #endif
327
328     module_t *p_module = config_FindModule( VLC_OBJECT(p_intf), "dshow" );
329     if( p_module )
330     {
331         AutoBuiltPanel *autopanel =
332             new AutoBuiltPanel( notebook, this, p_intf, p_module );
333         input_tab_array.Add( autopanel );
334         notebook->AddPage( autopanel, wxU( p_module->psz_longname ) );
335     }
336
337     /* Update Disc panel */
338     wxCommandEvent dummy_event;
339     OnDiscTypeChange( dummy_event );
340
341     /* Update Net panel */
342     dummy_event.SetId( NetRadio1_Event );
343     OnNetTypeChange( dummy_event );
344
345 #ifndef WIN32
346     /* Update v4l panel */
347     dummy_event.SetId( VideoType_Event );
348     OnV4LTypeChange( dummy_event );
349 #endif
350
351     /* Update MRL */
352     wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
353     OnPageChange( event );
354
355     /* Place everything in sizers */
356     wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
357     button_sizer->Add( ok_button, 0, wxALL, 5 );
358     button_sizer->Add( cancel_button, 0, wxALL, 5 );
359     button_sizer->Layout();
360     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
361     wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
362     panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
363     panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
364     panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
365     if( i_method == OPEN_NORMAL)
366     {
367         panel_sizer->Add( sout_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
368         panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
369     }
370     panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
371     panel_sizer->Layout();
372     panel->SetSizerAndFit( panel_sizer );
373     main_sizer->Add( panel, 1, wxGROW, 0 );
374     main_sizer->Layout();
375     SetSizerAndFit( main_sizer );
376 }
377
378 OpenDialog::~OpenDialog()
379 {
380     /* Clean up */
381     if( file_dialog ) delete file_dialog;
382 #ifndef WIN32
383     if( v4l_dialog ) delete v4l_dialog;
384 #endif
385     if( sout_dialog ) delete sout_dialog;
386     if( subsfile_dialog ) delete subsfile_dialog;
387 }
388
389 int OpenDialog::Show( int i_access_method, int i_arg )
390 {
391     int i_ret;
392     notebook->SetSelection( i_access_method );
393     i_ret = wxFrame::Show();
394     Raise();
395     SetFocus();
396     return i_ret;
397 }
398
399 int OpenDialog::Show()
400 {
401     int i_ret;
402     i_ret = wxFrame::Show();
403     Raise();
404     SetFocus();
405     return i_ret;
406 }
407
408 /*****************************************************************************
409  * Private methods.
410  *****************************************************************************/
411 wxPanel *OpenDialog::FilePanel( wxWindow* parent )
412 {
413     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
414                                   wxSize(200, 200) );
415
416     wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
417
418     /* Create browse file line */
419     wxBoxSizer *file_sizer = new wxBoxSizer( wxHORIZONTAL );
420
421     file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
422                                  wxPoint(20,25), wxSize(200, -1), 0, NULL );
423     wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
424                                             wxU(_("Browse...")) );
425     file_sizer->Add( file_combo, 1, wxALL, 5 );
426     file_sizer->Add( browse_button, 0, wxALL, 5 );
427
428     /* Create Subtitles File checkox */
429     wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
430     subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
431                                         wxU(_("Subtitles file")) );
432     subsfile_checkbox->SetToolTip( wxU(_("Load an additional subtitles file. "
433                                    "Currently only works with AVI files.")) );
434     subsfile_sizer->Add( subsfile_checkbox, 0,
435                          wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
436     subsfile_button = new wxButton( panel, SubsFileSettings_Event,
437                                     wxU(_("Settings...")) );
438     subsfile_button->Disable();
439
440     char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
441     if( psz_subsfile && *psz_subsfile )
442     {
443         subsfile_checkbox->SetValue(TRUE);
444         subsfile_button->Enable();
445         subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxU(psz_subsfile) );
446     }
447     if( psz_subsfile ) free( psz_subsfile );
448
449     subsfile_sizer->Add( subsfile_button, 1,
450                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
451
452     sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
453     sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 );
454     panel->SetSizerAndFit( sizer );
455     return panel;
456 }
457
458 wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
459 {
460     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
461                                   wxSize(200, 200) );
462
463     wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
464     wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
465
466     static const wxString disc_type_array[] =
467     {
468         wxU(_("DVD (menus support)")),
469         wxU(_("DVD")),
470         wxU(_("VCD")),
471         wxU(_("CD Audio"))
472
473     };
474
475     disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
476                                 wxDefaultPosition, wxDefaultSize,
477                                 WXSIZEOF(disc_type_array), disc_type_array,
478                                 WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
479     sizer_row->Add( disc_type, 0, wxEXPAND | wxALL, 5 );
480
481     wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
482     disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
483                                   wxDefaultPosition, wxDefaultSize,
484                                   wxTE_PROCESS_ENTER);
485
486     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
487     sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
488
489     label = new wxStaticText( panel, -1, wxU(_("Title")) );
490     disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
491
492     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
493     sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
494
495     label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
496     disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
497     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
498     sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
499     sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
500
501     panel->SetSizerAndFit( sizer_row );
502     return panel;
503 }
504
505 wxPanel *OpenDialog::NetPanel( wxWindow* parent )
506 {
507     int i;
508     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
509                                   wxSize(200, 200) );
510
511     wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
512     wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
513
514     static const wxString net_type_array[] =
515     {
516         wxU(_("UDP/RTP")),
517         wxU(_("UDP/RTP Multicast")),
518         wxU(_("HTTP/FTP/MMS"))
519     };
520
521     for( i=0; i<3; i++ )
522     {
523         net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
524                                            net_type_array[i],
525                                            wxDefaultPosition, wxDefaultSize,
526                                            wxRB_SINGLE );
527
528         net_subpanels[i] = new wxPanel( panel, -1,
529                                         wxDefaultPosition, wxDefaultSize );
530     }
531
532     /* UDP/RTP row */
533     wxFlexGridSizer *subpanel_sizer;
534     wxStaticText *label;
535     i_net_ports[0] = config_GetInt( p_intf, "server-port" );
536     subpanel_sizer = new wxFlexGridSizer( 3, 1, 20 );
537     label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
538     net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
539                                    wxString::Format(wxT("%d"), i_net_ports[0]),
540                                    wxDefaultPosition, wxDefaultSize,
541                                    wxSP_ARROW_KEYS,
542                                    0, 16000, i_net_ports[0] );
543
544     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
545     subpanel_sizer->Add( net_ports[0], 1,
546                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
547     net_ipv6 = new wxCheckBox( net_subpanels[0], NetForceIPv6_Event,
548                                wxU(_("Force IPv6")));
549     subpanel_sizer->Add( net_ipv6, 0,
550                          wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
551     net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
552     net_radios[0]->SetValue( TRUE );
553
554     /* UDP/RTP Multicast row */
555     subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
556     label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
557     net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
558                                    wxDefaultPosition, wxDefaultSize,
559                                    wxTE_PROCESS_ENTER);
560     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
561     subpanel_sizer->Add( net_addrs[1], 1,
562                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
563
564     label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
565     i_net_ports[1] = i_net_ports[0];
566     net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
567                                    wxString::Format(wxT("%d"), i_net_ports[1]),
568                                    wxDefaultPosition, wxDefaultSize,
569                                    wxSP_ARROW_KEYS,
570                                    0, 16000, i_net_ports[1] );
571
572     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
573     subpanel_sizer->Add( net_ports[1], 1,
574                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
575     net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
576
577     /* HTTP row */
578     subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
579     label = new wxStaticText( net_subpanels[2], -1, wxU(_("URL")) );
580     net_addrs[2] = new wxTextCtrl( net_subpanels[2], NetAddr3_Event, wxT(""),
581                                    wxDefaultPosition, wxSize( 200, -1 ),
582                                    wxTE_PROCESS_ENTER);
583     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
584     subpanel_sizer->Add( net_addrs[2], 1,
585                          wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
586     net_subpanels[2]->SetSizerAndFit( subpanel_sizer );
587
588     /* Stuff everything into the main panel */
589     for( i=0; i<3; i++ )
590     {
591         sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
592                     wxALL, 5 );
593         sizer->Add( net_subpanels[i], 1, wxEXPAND | wxALIGN_LEFT |
594                     wxALIGN_CENTER_VERTICAL | wxALL, 5  );
595     }
596
597     sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
598
599     panel->SetSizerAndFit( sizer_row );
600     return panel;
601 }
602
603 #ifndef WIN32
604 wxPanel *OpenDialog::V4LPanel( wxWindow* parent )
605 {
606     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
607                                   wxSize(200, 200) );
608
609     wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
610     wxFlexGridSizer *sizer = new wxFlexGridSizer( 1, 4, 20 );
611
612     static const wxString video_type_array[] =
613     {
614         wxU(_("WebCam")),
615         wxU(_("TV Card")),
616         wxU(_("PVR")),
617         wxU(_("Kfir")),
618     };
619
620     video_type = new wxRadioBox( panel, VideoType_Event,
621             wxU(_("Video Device Type")),
622             wxDefaultPosition, wxDefaultSize,
623             WXSIZEOF(video_type_array), video_type_array,
624             WXSIZEOF(video_type_array), wxRA_SPECIFY_COLS );
625
626     sizer_row->Add( video_type, 0, wxEXPAND | wxALL, 5 );
627
628
629     /* Video Options */
630     wxFlexGridSizer *video_sizer = new wxFlexGridSizer( 4, 2, 20 );
631     wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Video Device")) );
632     video_device = new wxTextCtrl( panel, VideoDevice_Event, wxT(""),
633                                   wxDefaultPosition, wxDefaultSize,
634                                   wxTE_PROCESS_ENTER);
635     video_device->SetToolTip( wxU(_("Device corresponding to your acquisition "
636                                     "card or your webcam")) );
637     video_sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
638     video_sizer->Add( video_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
639
640     label = new wxStaticText( panel, -1, wxU(_("Channel")) );
641     video_channel = new wxSpinCtrl( panel, VideoChannel_Event, wxT("0") );
642     video_channel->SetToolTip( wxU(_("Usually 0 is for tuner, 1 for composite "
643                                      "and 2 for svideo")) );
644     video_sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_HORIZONTAL );
645     video_sizer->Add( video_channel, 1, wxALIGN_LEFT | wxALIGN_CENTER_HORIZONTAL );
646     sizer->Add( video_sizer, 0, wxEXPAND | wxALL, 5 );
647
648     wxBoxSizer *v4lbutton_sizer = new wxBoxSizer( wxHORIZONTAL );
649     v4l_button = new wxButton( panel, V4LSettings_Event,
650                             wxU(_("Advanced Settings...")) );
651
652     v4lbutton_sizer->Add( v4l_button, 0, wxALIGN_RIGHT, 5 );
653
654     sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
655     sizer_row->Add( v4lbutton_sizer, 0, wxEXPAND | wxALL, 5 );
656
657     panel->SetSizerAndFit( sizer_row );
658     return panel;
659 }
660 #endif
661
662 void OpenDialog::UpdateMRL()
663 {
664     UpdateMRL( i_current_access_method );
665 }
666
667 void OpenDialog::UpdateMRL( int i_access_method )
668 {
669     wxString demux, mrltemp;
670
671     i_current_access_method = i_access_method;
672
673     switch( i_access_method )
674     {
675     case FILE_ACCESS:
676         //mrltemp = wxT("file") + demux + wxT(":") + file_combo->GetValue();
677         mrltemp = file_combo->GetValue();
678         break;
679     case DISC_ACCESS:
680         mrltemp = ( disc_type->GetSelection() == 0 ? wxT("dvd") :
681                 disc_type->GetSelection() == 1 ? wxT("dvdsimple") :
682                 disc_type->GetSelection() == 2 ? wxT("vcd") : wxT("cdda") )
683                   + demux + wxT(":")
684 //                  + disc_device->GetLineText(0)
685                   + disc_device->GetValue()
686                   + wxString::Format( wxT("@%d:%d"),
687                                       disc_title->GetValue(),
688                                       disc_chapter->GetValue() );
689         break;
690     case NET_ACCESS:
691         switch( i_net_type )
692         {
693         case 0:
694             mrltemp = wxT("udp") + demux + wxT("://");
695             if ( net_ipv6->GetValue() )
696             {
697                 mrltemp += wxT("@[::]");
698             }
699             if( i_net_ports[0] !=
700                 config_GetInt( p_intf, "server-port" ) )
701             {
702                 mrltemp += wxString::Format( wxT("@:%d"), i_net_ports[0] );
703             }
704             break;
705
706         case 1:
707             mrltemp = wxT("udp") + demux + wxT("://@");
708             if ((net_addrs[1]->GetLineText(0).Find (':') != -1)
709                 && (net_addrs[1]->GetLineText(0)[0u] != '['))
710             {
711                 /* automatically adds '[' and ']' to IPv6 addresses */
712                 mrltemp += wxT("[") + net_addrs[1]->GetLineText(0)
713                          + wxT("]");
714             }
715             else
716             {
717                 mrltemp += net_addrs[1]->GetLineText(0);
718             }
719             if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
720             {
721                 mrltemp += wxString::Format( wxT(":%d"), i_net_ports[1] );
722             }
723             break;
724
725         case 2:
726             /* http access */
727             mrltemp = wxT("http") + demux + wxT("://") +
728                       net_addrs[2]->GetLineText(0);
729             break;
730         }
731         break;
732
733 #ifndef WIN32
734     case V4L_ACCESS:
735         mrltemp = ( video_type->GetSelection() == 0 ? wxT("v4l") :
736                     video_type->GetSelection() == 1 ? wxT("v4l") :
737                     video_type->GetSelection() == 2 ? wxT("pvr") :
738                                                       wxT("kfir") )
739             + demux + wxT(":")
740             + video_device->GetLineText( 0 );
741
742         if( video_type->GetSelection() == 1 )
743         {
744             mrltemp += wxString::Format( wxT(":channel=%d"),
745                                          video_channel->GetValue() );
746         }
747
748         if ( /* v4l_dialog != NULL && */ !v4l_mrl.IsEmpty() )
749         {
750             mrltemp += v4l_mrl[0];
751         }
752
753         break;
754 #endif
755
756     default:
757         {
758             int i_item = i_access_method - MAX_ACCESS;
759
760             if( i_item < 0 || i_item >= (int)input_tab_array.GetCount() )
761                 break;
762
763             AutoBuiltPanel *input_panel = input_tab_array.Item( i_item );
764
765             mrltemp = input_panel->name + wxT("://");
766
767             for( int i=0; i < (int)input_panel->config_array.GetCount(); i++ )
768             {
769                 ConfigControl *control = input_panel->config_array.Item(i);
770                 mrltemp += wxT(" :") + control->GetName() + wxT("=");
771
772                 switch( control->GetType() )
773                 {
774                 case CONFIG_ITEM_STRING:
775                 case CONFIG_ITEM_FILE:
776                 case CONFIG_ITEM_DIRECTORY:
777                 case CONFIG_ITEM_MODULE:
778                     mrltemp += wxT("\"") + control->GetPszValue() + wxT("\"");
779                     break;
780                 case CONFIG_ITEM_INTEGER:
781                 case CONFIG_ITEM_BOOL:
782                     mrltemp +=
783                         wxString::Format( wxT("%i"), control->GetIntValue() );
784                     break;
785                 case CONFIG_ITEM_FLOAT:
786                     mrltemp +=
787                         wxString::Format( wxT("%f"), control->GetFloatValue());
788                     break;
789                 }
790             }
791         }
792         break;
793     }
794
795     mrl_combo->SetValue( mrltemp );
796 }
797
798 /*****************************************************************************
799  * Events methods.
800  *****************************************************************************/
801 void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
802 {
803     mrl = SeparateEntries( mrl_combo->GetValue() );
804     mrl_combo->Append( mrl_combo->GetValue() );
805     if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 );
806     mrl_combo->SetSelection( mrl_combo->GetCount() - 1 );
807
808     if( i_method == OPEN_STREAM )
809     {
810         Hide();
811         return;
812     }
813
814     /* Update the playlist */
815     playlist_t *p_playlist =
816         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
817                                        FIND_ANYWHERE );
818     if( p_playlist == NULL ) return;
819
820     for( int i = 0; i < (int)mrl.GetCount(); i++ )
821     {
822         int i_options = 0, i_total_options;
823         char **ppsz_options = NULL;
824
825         /* Count the input options */
826         while( i + i_options + 1 < (int)mrl.GetCount() &&
827                ((const char *)mrl[i + i_options + 1].mb_str())[0] == ':' )
828         {
829             i_options++;
830         }
831
832         /* Allocate ppsz_options */
833         for( int j = 0; j < i_options; j++ )
834         {
835             if( !ppsz_options )
836                 ppsz_options = (char **)malloc( sizeof(char *) * i_options );
837
838             ppsz_options[j] = strdup( mrl[i + j  + 1].mb_str() );
839         }
840
841         i_total_options = i_options;
842
843         /* Get the options from the subtitles dialog */
844         if( subsfile_checkbox->IsChecked() && subsfile_mrl.GetCount() )
845         {
846             ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
847                                (i_total_options + subsfile_mrl.GetCount()) );
848
849             for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ )
850             {
851                 ppsz_options[i_total_options + j] =
852                     strdup( subsfile_mrl[j].mb_str() );
853             }
854
855             i_total_options += subsfile_mrl.GetCount();
856         }
857
858         /* Get the options from the stream output dialog */
859         if( sout_checkbox->IsChecked() && sout_mrl.GetCount() )
860         {
861             ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
862                                (i_total_options + sout_mrl.GetCount()) );
863
864             for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
865             {
866                 ppsz_options[i_total_options + j] =
867                     strdup( sout_mrl[j].mb_str() );
868             }
869
870             i_total_options += sout_mrl.GetCount();
871
872         }
873
874         playlist_Add( p_playlist, (const char *)mrl[i].mb_str(),
875                       (const char **)ppsz_options, i_total_options,
876                       PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
877
878         /* clean up */
879         for( int j = 0; j < i_total_options; j++ )
880             free( ppsz_options[j] );
881         if( ppsz_options ) free( ppsz_options );
882
883         i += i_options;
884     }
885
886     //TogglePlayButton( PLAYING_S );
887
888     vlc_object_release( p_playlist );
889
890     Hide();
891 }
892
893 void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
894 {
895     Hide();
896 }
897
898 void OpenDialog::OnPageChange( wxNotebookEvent& event )
899 {
900     UpdateMRL( event.GetSelection() );
901 }
902
903 void OpenDialog::OnMRLChange( wxCommandEvent& event )
904 {
905     //mrl = SeparateEntries( event.GetString() );
906 }
907
908 /*****************************************************************************
909  * File panel event methods.
910  *****************************************************************************/
911 void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
912 {
913     UpdateMRL( FILE_ACCESS );
914 }
915
916 void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
917 {
918     if( file_dialog == NULL )
919         file_dialog = new wxFileDialog( this, wxU(_("Open file")),
920             wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
921
922     if( file_dialog && file_dialog->ShowModal() == wxID_OK )
923     {
924         wxArrayString paths;
925         wxString path;
926
927         file_dialog->GetPaths( paths );
928
929         for( size_t i = 0; i < paths.GetCount(); i++ )
930         {
931             if( paths[i].Find( wxT(' ') ) >= 0 )
932                 path += wxT("\"") + paths[i] + wxT("\" ");
933             else
934                 path += paths[i] + wxT(" ");
935         }
936
937         file_combo->SetValue( path );
938         file_combo->Append( path );
939         if( file_combo->GetCount() > 10 ) file_combo->Delete( 0 );
940         UpdateMRL( FILE_ACCESS );
941     }
942 }
943
944 /*****************************************************************************
945  * Disc panel event methods.
946  *****************************************************************************/
947 void OpenDialog::OnDiscPanelChange( wxCommandEvent& event )
948 {
949     UpdateMRL( DISC_ACCESS );
950 }
951
952 void OpenDialog::OnDiscDeviceChange( wxCommandEvent& event )
953 {
954     char *psz_device;
955
956     switch( disc_type->GetSelection() )
957     {
958         case 3:
959             psz_device = config_GetPsz( p_intf, "cd-audio" );
960             break;
961                                                                                                                            
962         case 2:
963             psz_device = config_GetPsz( p_intf, "vcd" );
964             break;
965                                                                                                                             
966         default:
967             psz_device = config_GetPsz( p_intf, "dvd" );
968             break;
969     }
970
971     if( disc_device->GetValue().Cmp( wxU( psz_device ) ) )
972     {
973         b_disc_device_changed = true;
974     }
975
976     UpdateMRL( DISC_ACCESS );
977 }
978
979 void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
980 {
981     char *psz_device;
982
983     switch( disc_type->GetSelection() )
984     {
985     case 3:
986         psz_device = config_GetPsz( p_intf, "cd-audio" );
987         if( !b_disc_device_changed )
988         {
989             disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
990         }
991         break;
992
993     case 2:
994         psz_device = config_GetPsz( p_intf, "vcd" );
995         if( !b_disc_device_changed )
996         {
997             disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
998         }
999         break;
1000
1001     default:
1002         psz_device = config_GetPsz( p_intf, "dvd" );
1003         if( !b_disc_device_changed )
1004         {
1005             disc_device->SetValue( psz_device ? wxU(psz_device) : wxT("") );
1006         }
1007         break;
1008     }
1009
1010     if( psz_device ) free( psz_device );
1011
1012     switch( disc_type->GetSelection() )
1013     {
1014     case 0:
1015         disc_title->SetRange( 0, 255 );
1016         disc_title->SetValue( 0 );
1017         break;
1018
1019     default:
1020         disc_title->SetRange( 1, 255 );
1021         disc_title->SetValue( 1 );
1022         break;
1023     }
1024
1025     disc_chapter->SetRange( 1, 255 );
1026     disc_chapter->SetValue( 1 );
1027
1028     UpdateMRL( DISC_ACCESS );
1029 }
1030
1031 /*****************************************************************************
1032  * Net panel event methods.
1033  *****************************************************************************/
1034 void OpenDialog::OnNetPanelChange( wxCommandEvent& event )
1035 {
1036     if( event.GetId() >= NetPort1_Event && event.GetId() <= NetPort3_Event )
1037     {
1038         i_net_ports[event.GetId() - NetPort1_Event] = event.GetInt();
1039     }
1040
1041     UpdateMRL( NET_ACCESS );
1042 }
1043
1044 void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
1045 {
1046     int i;
1047
1048     i_net_type = event.GetId() - NetRadio1_Event;
1049
1050     for(i=0; i<3; i++)
1051     {
1052         net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
1053         net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
1054     }
1055
1056     UpdateMRL( NET_ACCESS );
1057 }
1058
1059 #ifndef WIN32
1060 /*****************************************************************************
1061  * v4l panel event methods.
1062  *****************************************************************************/
1063 void OpenDialog::OnV4LPanelChange( wxCommandEvent& WXUNUSED(event) )
1064 {
1065     UpdateMRL( V4L_ACCESS );
1066 }
1067
1068 void OpenDialog::OnV4LTypeChange( wxCommandEvent& WXUNUSED(event) )
1069 {
1070     video_device->SetValue( wxU( "/dev/video" ) );
1071
1072     v4l_button->Enable();
1073     video_channel->Disable();
1074
1075     switch( video_type->GetSelection() )
1076     {
1077         case 1:
1078             video_channel->Enable();
1079             video_channel->SetRange( 0, 255 );
1080            break;
1081         case 3:
1082             v4l_button->Disable();
1083             break;
1084         default:
1085             break;
1086     }
1087
1088     UpdateMRL( V4L_ACCESS );
1089 }
1090
1091 void OpenDialog::OnV4LSettingsChange( wxCommandEvent& WXUNUSED(event) )
1092 {
1093     /* Show/hide the open dialog */
1094     if( v4l_dialog == NULL )
1095         v4l_dialog = new V4LDialog( p_intf, this );
1096
1097     if( v4l_dialog && v4l_dialog->ShowModal() == wxID_OK )
1098     {
1099         v4l_mrl = v4l_dialog->GetOptions();
1100     }
1101
1102     UpdateMRL( V4L_ACCESS );
1103 }
1104 #endif
1105
1106 /*****************************************************************************
1107  * Subtitles file event methods.
1108  *****************************************************************************/
1109 void OpenDialog::OnSubsFileEnable( wxCommandEvent& event )
1110 {
1111     subsfile_button->Enable( event.GetInt() != 0 );
1112 }
1113
1114 void OpenDialog::OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) )
1115 {
1116     /* Show/hide the open dialog */
1117     if( subsfile_dialog == NULL )
1118         subsfile_dialog = new SubsFileDialog( p_intf, this );
1119
1120     if( subsfile_dialog && subsfile_dialog->ShowModal() == wxID_OK )
1121     {
1122         subsfile_mrl.Empty();
1123         subsfile_mrl.Add( wxString(wxT("sub-file=")) +
1124                           subsfile_dialog->file_combo->GetValue() );
1125         if( subsfile_dialog->encoding_combo )
1126             subsfile_mrl.Add( wxString(wxT("subsdec-encoding=")) +
1127                               subsfile_dialog->encoding_combo->GetValue() );
1128         subsfile_mrl.Add( wxString::Format( wxT("sub-delay=%i"),
1129                           subsfile_dialog->delay_spinctrl->GetValue() ) );
1130         subsfile_mrl.Add( wxString::Format( wxT("sub-fps=%i"),
1131                           subsfile_dialog->fps_spinctrl->GetValue() ) );
1132     }
1133 }
1134
1135 /*****************************************************************************
1136  * Stream output event methods.
1137  *****************************************************************************/
1138 void OpenDialog::OnSoutEnable( wxCommandEvent& event )
1139 {
1140     sout_button->Enable( event.GetInt() != 0 );
1141 }
1142
1143 void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
1144 {
1145     /* Show/hide the open dialog */
1146     if( sout_dialog == NULL )
1147         sout_dialog = new SoutDialog( p_intf, this );
1148
1149     if( sout_dialog && sout_dialog->ShowModal() == wxID_OK )
1150     {
1151         sout_mrl = sout_dialog->GetOptions();
1152     }
1153 }
1154
1155 /*****************************************************************************
1156  * Utility functions.
1157  *****************************************************************************/
1158 wxArrayString SeparateEntries( wxString entries )
1159 {
1160     vlc_bool_t b_quotes_mode = VLC_FALSE;
1161
1162     wxArrayString entries_array;
1163     wxString entry;
1164
1165     wxStringTokenizer token( entries, wxT(" \t\r\n\""), wxTOKEN_RET_DELIMS );
1166
1167     while( token.HasMoreTokens() )
1168     {
1169         entry += token.GetNextToken();
1170
1171         if( entry.IsEmpty() ) continue;
1172
1173         if( !b_quotes_mode && entry.Last() == wxT('\"') )
1174         {
1175             /* Enters quotes mode */
1176             entry.RemoveLast();
1177             b_quotes_mode = VLC_TRUE;
1178         }
1179         else if( b_quotes_mode && entry.Last() == wxT('\"') )
1180         {
1181             /* Finished the quotes mode */
1182             entry.RemoveLast();
1183             if( !entry.IsEmpty() ) entries_array.Add( entry );
1184             entry.Empty();
1185             b_quotes_mode = VLC_FALSE;
1186         }
1187         else if( !b_quotes_mode && entry.Last() != wxT('\"') )
1188         {
1189             /* we found a non-quoted standalone string */
1190             if( token.HasMoreTokens() ||
1191                 entry.Last() == wxT(' ') || entry.Last() == wxT('\t') ||
1192                 entry.Last() == wxT('\r') || entry.Last() == wxT('\n') )
1193                 entry.RemoveLast();
1194             if( !entry.IsEmpty() ) entries_array.Add( entry );
1195             entry.Empty();
1196         }
1197         else
1198         {;}
1199     }
1200
1201     if( !entry.IsEmpty() ) entries_array.Add( entry );
1202
1203     return entries_array;
1204 }