Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

open.cpp

00001 /*****************************************************************************
00002  * open.cpp : wxWindows plugin for vlc
00003  *****************************************************************************
00004  * Copyright (C) 2000-2005 the VideoLAN team
00005  * $Id: open.cpp 13180 2005-11-10 18:43:42Z gbazin $
00006  *
00007  * Authors: Gildas Bazin <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 /*****************************************************************************
00025  * Preamble
00026  *****************************************************************************/
00027 
00028 #include <stdlib.h>                                      /* malloc(), free() */
00029 #include <errno.h>                                                 /* ENOMEM */
00030 #include <string.h>                                            /* strerror() */
00031 #include <stdio.h>
00032 
00033 #include <vlc/vlc.h>
00034 #include "charset.h"
00035 
00036 #ifdef HAVE_LIBCDIO
00037 #include <cdio/cdio.h>
00038 #include <cdio/cd_types.h>
00039 #include <cdio/logging.h>
00040 #endif /* HAVE_LIBCDIO */
00041 
00042 #ifdef HAVE_VCDINFO
00043 #include <libvcd/version.h>
00044 /* There was a bug in libvcdinfo <= 23 which prevented C++ compilation */
00045 #if LIBVCD_VERSION_NUM > 23
00046 #include <libvcd/info.h>
00047 #endif /* LIBVCD_VERSION_NUM > 23 */
00048 #endif /* HAVE_VCDINFO */
00049 
00050 #include <wx/combobox.h>
00051 #include <wx/statline.h>
00052 #include <wx/tokenzr.h>
00053 
00054 #include <vlc/intf.h>
00055 
00056 #include <vector>
00057 
00058 #include "wxwidgets.h"
00059 #include "preferences_widgets.h"
00060 
00061 #ifndef wxRB_SINGLE
00062 #   define wxRB_SINGLE 0
00063 #endif
00064 
00065 #define SELECTION_DISC_TYPE_DVD_MENUS 0
00066 #define SELECTION_DISC_TYPE_DVD       1
00067 #define SELECTION_DISC_TYPE_VCD       2
00068 #define SELECTION_DISC_TYPE_CDDA      3
00069 
00070 /*****************************************************************************
00071  * Event Table.
00072  *****************************************************************************/
00073 
00074 /* IDs for the controls and the menu commands */
00075 enum
00076 {
00077     Notebook_Event = wxID_HIGHEST,
00078     MRL_Event,
00079 
00080     FileBrowse_Event,
00081     FileName_Event,
00082 
00083     DiscType_Event,
00084 #ifdef HAVE_LIBCDIO
00085     DiscProbe_Event,
00086 #endif
00087     DiscDevice_Event,
00088     DiscTitle_Event,
00089     DiscChapter_Event,
00090     DiscSub_Event,
00091     DiscAudio_Event,
00092 
00093     NetType_Event,
00094     NetRadio1_Event, NetRadio2_Event, NetRadio3_Event, NetRadio4_Event,
00095     NetPort1_Event, NetPort2_Event, NetPort3_Event,
00096     NetAddr1_Event, NetAddr2_Event, NetAddr3_Event, NetAddr4_Event,
00097     NetForceIPv6_Event, NetTimeshift_Event,
00098 
00099     SubsFileEnable_Event,
00100     SubsFileSettings_Event,
00101 
00102     SoutEnable_Event,
00103     SoutSettings_Event,
00104 
00105     CachingEnable_Event,
00106     CachingChange_Event,
00107 
00108     AdvancedOptions_Event
00109 };
00110 
00111 BEGIN_EVENT_TABLE(OpenDialog, wxDialog)
00112     /* Button events */
00113     EVT_BUTTON(wxID_OK, OpenDialog::OnOk)
00114     EVT_BUTTON(wxID_CANCEL, OpenDialog::OnCancel)
00115 
00116     EVT_NOTEBOOK_PAGE_CHANGED(Notebook_Event, OpenDialog::OnPageChange)
00117 
00118     EVT_TEXT(MRL_Event, OpenDialog::OnMRLChange)
00119 
00120     /* Events generated by the file panel */
00121     EVT_TEXT(FileName_Event, OpenDialog::OnFilePanelChange)
00122     EVT_BUTTON(FileBrowse_Event, OpenDialog::OnFileBrowse)
00123 
00124     /* Events generated by the disc panel */
00125     EVT_RADIOBOX(DiscType_Event, OpenDialog::OnDiscTypeChange)
00126 #ifdef HAVE_LIBCDIO
00127     EVT_CHECKBOX(DiscProbe_Event, OpenDialog::OnDiscProbe)
00128 #endif
00129     EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscDeviceChange)
00130     EVT_TEXT(DiscDevice_Event, OpenDialog::OnDiscPanelChange)
00131     EVT_TEXT(DiscTitle_Event, OpenDialog::OnDiscPanelChange)
00132     EVT_SPINCTRL(DiscTitle_Event, OpenDialog::OnDiscPanelChangeSpin)
00133     EVT_TEXT(DiscChapter_Event, OpenDialog::OnDiscPanelChange)
00134     EVT_SPINCTRL(DiscChapter_Event, OpenDialog::OnDiscPanelChangeSpin)
00135     EVT_TEXT(DiscSub_Event, OpenDialog::OnDiscPanelChange)
00136     EVT_TEXT(DiscAudio_Event, OpenDialog::OnDiscPanelChange)
00137     EVT_SPINCTRL(DiscSub_Event, OpenDialog::OnDiscPanelChangeSpin)
00138 
00139     /* Events generated by the net panel */
00140     EVT_RADIOBUTTON(NetRadio1_Event, OpenDialog::OnNetTypeChange)
00141     EVT_RADIOBUTTON(NetRadio2_Event, OpenDialog::OnNetTypeChange)
00142     EVT_RADIOBUTTON(NetRadio3_Event, OpenDialog::OnNetTypeChange)
00143     EVT_RADIOBUTTON(NetRadio4_Event, OpenDialog::OnNetTypeChange)
00144     EVT_TEXT(NetPort1_Event, OpenDialog::OnNetPanelChange)
00145     EVT_SPINCTRL(NetPort1_Event, OpenDialog::OnNetPanelChangeSpin)
00146     EVT_TEXT(NetPort2_Event, OpenDialog::OnNetPanelChange)
00147     EVT_SPINCTRL(NetPort2_Event, OpenDialog::OnNetPanelChangeSpin)
00148     EVT_TEXT(NetPort3_Event, OpenDialog::OnNetPanelChange)
00149     EVT_SPINCTRL(NetPort3_Event, OpenDialog::OnNetPanelChangeSpin)
00150     EVT_TEXT(NetAddr2_Event, OpenDialog::OnNetPanelChange)
00151     EVT_TEXT(NetAddr3_Event, OpenDialog::OnNetPanelChange)
00152     EVT_TEXT(NetAddr4_Event, OpenDialog::OnNetPanelChange)
00153     EVT_CHECKBOX(NetForceIPv6_Event, OpenDialog::OnNetPanelChange)
00154     EVT_CHECKBOX(NetTimeshift_Event, OpenDialog::OnNetPanelChange)
00155 
00156     /* Events generated by the subtitle file buttons */
00157     EVT_CHECKBOX(SubsFileEnable_Event, OpenDialog::OnSubsFileEnable)
00158     EVT_BUTTON(SubsFileSettings_Event, OpenDialog::OnSubsFileSettings)
00159 
00160     /* Events generated by the stream output buttons */
00161     EVT_CHECKBOX(SoutEnable_Event, OpenDialog::OnSoutEnable)
00162     EVT_BUTTON(SoutSettings_Event, OpenDialog::OnSoutSettings)
00163 
00164     /* Events generated by the caching button */
00165     EVT_CHECKBOX(CachingEnable_Event, OpenDialog::OnCachingEnable)
00166     EVT_TEXT(CachingChange_Event, OpenDialog::OnCachingChange)
00167     EVT_SPINCTRL(CachingChange_Event, OpenDialog::OnCachingChangeSpin)
00168 
00169     /* Hide the window when the user closes the window */
00170     EVT_CLOSE(OpenDialog::OnClose)
00171 
00172 END_EVENT_TABLE()
00173 
00174 #if 0
00175 /* Perhaps someday we'll figure out how to add media information to
00176    "Stream-and-Media info" when no input thread hasn't been initialized.
00177 */
00178 extern void MediaInsertCDDA( intf_thread_t *_p_intf,  CdIo_t *p_cdio,
00179                  track_t i_last_track );
00180 #endif
00181 
00182 /*****************************************************************************
00183  * AutoBuiltPanel.
00184  *****************************************************************************/
00185 WX_DEFINE_ARRAY(ConfigControl *, ArrayOfConfigControls);
00186 
00187 class AutoBuiltPanel : public wxPanel
00188 {
00189 public:
00190 
00191     AutoBuiltPanel() { }
00192     AutoBuiltPanel( wxWindow *, OpenDialog *, intf_thread_t *,
00193                     const module_t * );
00194 
00195     virtual ~AutoBuiltPanel() {}
00196 
00197     void UpdateAdvancedMRL();
00198 
00199     wxString name;
00200     ArrayOfConfigControls config_array;
00201     ArrayOfConfigControls advanced_config_array;
00202     wxComboBox *p_advanced_mrl_combo;
00203 
00204 private:
00205     intf_thread_t *p_intf;
00206     OpenDialog *p_open_dialog;
00207 
00208     void OnAdvanced( wxCommandEvent& event );
00209     wxDialog *p_advanced_dialog;
00210 
00211     DECLARE_EVENT_TABLE();
00212 };
00213 
00214 BEGIN_EVENT_TABLE(AutoBuiltPanel, wxPanel)
00215     EVT_BUTTON(AdvancedOptions_Event, AutoBuiltPanel::OnAdvanced)
00216 END_EVENT_TABLE()
00217 
00218 static void AutoBuildCallback( void *p_data )
00219 {
00220     ((OpenDialog *)p_data)->UpdateMRL();
00221 }
00222 
00223 static void AutoBuildAdvancedCallback( void *p_data )
00224 {
00225     ((AutoBuiltPanel *)p_data)->UpdateAdvancedMRL();
00226 }
00227 
00228 AutoBuiltPanel::AutoBuiltPanel( wxWindow *parent, OpenDialog *dialog,
00229                                 intf_thread_t *_p_intf,
00230                                 const module_t *p_module )
00231   : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize ),
00232     name( wxU(p_module->psz_object_name) ),
00233     p_advanced_mrl_combo( NULL ),
00234     p_intf( _p_intf ), p_open_dialog( dialog ), p_advanced_dialog( NULL )
00235 {
00236     wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
00237     module_config_t *p_item = p_module->p_config;
00238     bool b_advanced = false;
00239 
00240     if( p_item ) do
00241     {
00242         if( !(p_item->i_type & CONFIG_HINT) && p_item->b_advanced )
00243             b_advanced = true;
00244 
00245         if( p_item->i_type & CONFIG_HINT || p_item->b_advanced )
00246             continue;
00247 
00248         ConfigControl *control =
00249             CreateConfigControl( VLC_OBJECT(p_intf), p_item, this );
00250 
00251         config_array.Add( control );
00252 
00253         /* Don't add items that were not recognized */
00254         if( control == NULL ) continue;
00255 
00256         control->SetUpdateCallback( AutoBuildCallback, (void *)dialog );
00257 
00258         sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
00259     }
00260     while( p_item->i_type != CONFIG_HINT_END && p_item++ );
00261 
00262     if( b_advanced )
00263     {
00264         wxButton *button =
00265             new wxButton( this, AdvancedOptions_Event,
00266                           wxU(_("Advanced options...")) );
00267         sizer->Add( button, 0, wxALL, 5 );
00268 
00269         /* Build the advanced dialog */
00270         p_advanced_dialog =
00271             new wxDialog( this, -1, ((wxString)wxU(_("Advanced options"))) +
00272                           wxT(" (") + wxU( p_module->psz_longname ) + wxT(")"),
00273                           wxDefaultPosition, wxDefaultSize,
00274                           wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
00275 
00276         wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
00277 
00278         /* Create MRL combobox */
00279         wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
00280         wxStaticBox *mrl_box =
00281             new wxStaticBox( p_advanced_dialog, -1,
00282                              wxU(_("Advanced options")) );
00283         wxStaticBoxSizer *mrl_sizer =
00284             new wxStaticBoxSizer( mrl_box, wxHORIZONTAL );
00285         wxStaticText *mrl_label =
00286             new wxStaticText( p_advanced_dialog, -1, wxU(_("Options:")) );
00287         p_advanced_mrl_combo =
00288             new wxComboBox( p_advanced_dialog, MRL_Event, wxT(""),
00289                             wxDefaultPosition, wxDefaultSize );
00290         mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
00291         mrl_sizer->Add( p_advanced_mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
00292         mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
00293         sizer->Add( mrl_sizer_sizer, 0, wxEXPAND | wxALL, 2 );
00294 
00295         /* Add advanced options to panel */
00296         module_config_t *p_item = p_module->p_config;
00297         if( p_item ) do
00298         {
00299             if( p_item->i_type & CONFIG_HINT || !p_item->b_advanced )
00300                 continue;
00301 
00302             ConfigControl *control =
00303                 CreateConfigControl( VLC_OBJECT(p_intf), p_item,
00304                                      p_advanced_dialog );
00305 
00306             advanced_config_array.Add( control );
00307 
00308             /* Don't add items that were not recognized */
00309             if( control == NULL ) continue;
00310 
00311             control->SetUpdateCallback( AutoBuildAdvancedCallback,
00312                                         (void *)this );
00313 
00314             sizer->Add( control, 0, wxEXPAND | wxALL, 2 );
00315         }
00316         while( p_item->i_type != CONFIG_HINT_END && p_item++ );
00317 
00318         /* Separation */
00319         wxPanel *dummy_panel = new wxPanel( p_advanced_dialog, -1 );
00320         sizer->Add( dummy_panel, 1 );
00321         wxStaticLine *static_line =
00322             new wxStaticLine( p_advanced_dialog, wxID_OK );
00323         sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
00324 
00325         /* Create buttons */
00326         wxButton *ok_button =
00327             new wxButton( p_advanced_dialog, wxID_OK, wxU(_("OK")) );
00328         ok_button->SetDefault();
00329         wxButton *cancel_button =
00330             new wxButton( p_advanced_dialog, wxID_CANCEL, wxU(_("Cancel")) );
00331         wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
00332         button_sizer->Add( ok_button, 0, wxALL, 5 );
00333         button_sizer->Add( cancel_button, 0, wxALL, 5 );
00334         button_sizer->Layout();
00335         sizer->Add( button_sizer, 0, wxALL, 0 );
00336 
00337         sizer->SetMinSize( 400, -1 );
00338         p_advanced_dialog->SetSizerAndFit( sizer );
00339     }
00340 
00341     this->SetSizerAndFit( sizer );
00342 }
00343 
00344 void AutoBuiltPanel::OnAdvanced( wxCommandEvent& event )
00345 {
00346     if( p_advanced_dialog->ShowModal() == wxID_OK )
00347     {
00348         UpdateAdvancedMRL();
00349         p_open_dialog->UpdateMRL();
00350     }
00351 }
00352 
00353 void AutoBuiltPanel::UpdateAdvancedMRL()
00354 {
00355     wxString mrltemp;
00356 
00357     for( int i = 0; i < (int)advanced_config_array.GetCount(); i++ )
00358     {
00359         ConfigControl *control = advanced_config_array.Item(i);
00360 
00361         mrltemp += (i ? wxT(" :") : wxT(":"));
00362 
00363         if( control->GetType() == CONFIG_ITEM_BOOL &&
00364             !control->GetIntValue() ) mrltemp += wxT("no-");
00365 
00366         mrltemp += control->GetName();
00367 
00368         switch( control->GetType() )
00369         {
00370         case CONFIG_ITEM_STRING:
00371         case CONFIG_ITEM_FILE:
00372         case CONFIG_ITEM_DIRECTORY:
00373         case CONFIG_ITEM_MODULE:
00374             mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
00375             break;
00376         case CONFIG_ITEM_INTEGER:
00377             mrltemp +=
00378                 wxString::Format( wxT("=%i"), control->GetIntValue() );
00379             break;
00380         case CONFIG_ITEM_FLOAT:
00381             mrltemp +=
00382                 wxString::Format(wxT("=%f"), control->GetFloatValue());
00383             break;
00384         }
00385     }
00386 
00387     p_advanced_mrl_combo->SetValue( mrltemp );
00388 }
00389 
00390 /*****************************************************************************
00391  * Constructor.
00392  *****************************************************************************/
00393 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
00394                         int i_access_method, int i_arg ):
00395       wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
00396              wxDefaultSize, wxDEFAULT_FRAME_STYLE )
00397 {
00398     OpenDialog( _p_intf, _p_parent, i_access_method, i_arg, OPEN_NORMAL );
00399 }
00400 
00401 OpenDialog::OpenDialog( intf_thread_t *_p_intf, wxWindow *_p_parent,
00402                         int i_access_method, int i_arg, int _i_method ):
00403       wxDialog( _p_parent, -1, wxU(_("Open...")), wxDefaultPosition,
00404              wxDefaultSize, wxDEFAULT_FRAME_STYLE )
00405 {
00406     /* Initializations */
00407     i_method = _i_method;
00408     p_intf = _p_intf;
00409     p_parent = _p_parent;
00410     SetIcon( *p_intf->p_sys->p_icon );
00411     file_dialog = NULL;
00412     i_disc_type_selection = 0;
00413     i_disc_title = 0;
00414     i_open_arg = i_arg;
00415 
00416     sout_dialog = NULL;
00417     subsfile_dialog = NULL;
00418     b_disc_device_changed = false;
00419 
00420     /* Create a panel to put everything in */
00421     wxPanel *panel = new wxPanel( this, -1 );
00422     panel->SetAutoLayout( TRUE );
00423 
00424     /* Create MRL combobox */
00425     wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL );
00426     wxStaticBox *mrl_box = new wxStaticBox( panel, -1,
00427                                wxU(_("Media Resource Locator (MRL)")) );
00428     wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box,
00429                                                         wxHORIZONTAL );
00430     wxStaticText *mrl_label = new wxStaticText( panel, -1,
00431                                                 wxU(_("Open:")) );
00432     mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""),
00433                                 wxPoint(20,25), wxSize(120, -1) );
00434     mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing "
00435         "the full MRL you want to open.\n""Alternatively, the field will be "
00436         "filled automatically when you use the controls below.")) );
00437 
00438     mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 );
00439     mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 );
00440     mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 );
00441 
00442 
00443     /* Create Static Text */
00444     wxStaticText *label = new wxStaticText( panel, -1,
00445         wxU(_("Alternatively, you can build an MRL using one of the "
00446               "following predefined targets:")) );
00447 
00448     wxFlexGridSizer *common_opt_sizer = new wxFlexGridSizer( 5, 1, 20 );
00449 
00450     if( i_method == OPEN_NORMAL )
00451     {
00452         /* Create Stream Output checkox */
00453         sout_checkbox = new wxCheckBox( panel, SoutEnable_Event,
00454                                          wxU(_("Stream output")) );
00455         sout_checkbox->SetToolTip( wxU(_("Use VLC as a server of streams")) );
00456         common_opt_sizer->Add( sout_checkbox, 0,
00457                                wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
00458 
00459         sout_button = new wxButton( panel, SoutSettings_Event,
00460                                     wxU(_("Settings...")) );
00461         sout_button->Disable();
00462 
00463         char *psz_sout = config_GetPsz( p_intf, "sout" );
00464         if( psz_sout && *psz_sout )
00465         {
00466             sout_checkbox->SetValue(TRUE);
00467             sout_button->Enable();
00468             subsfile_mrl.Add( wxString(wxT("sout=")) + wxL2U(psz_sout) );
00469         }
00470         if( psz_sout ) free( psz_sout );
00471 
00472         common_opt_sizer->Add( sout_button, 1, wxALIGN_LEFT |
00473                                wxALIGN_CENTER_VERTICAL );
00474 
00475         common_opt_sizer->Add( new wxPanel( this, -1 ), 1,
00476                                wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
00477     }
00478 
00479     /* Create caching options */
00480     caching_checkbox = new wxCheckBox( panel, CachingEnable_Event,
00481                                        wxU(_("Caching")) );
00482     caching_checkbox->SetToolTip( wxU(_("Change the default caching value "
00483                                         "(in milliseconds)")) );
00484     common_opt_sizer->Add( caching_checkbox, 0,
00485                            wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
00486     caching_value = new wxSpinCtrl( panel, CachingChange_Event );
00487     caching_value->SetRange( 0, 1000000 );
00488     caching_value->Disable();
00489     common_opt_sizer->Add( caching_value, 0,
00490                            wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
00491 
00492     /* Separation */
00493     wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
00494 
00495     /* Create the buttons */
00496     wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) );
00497     ok_button->SetDefault();
00498     wxButton *cancel_button = new wxButton( panel, wxID_CANCEL,
00499                                             wxU(_("Cancel")) );
00500 
00501     /* Create notebook */
00502     notebook = new wxNotebook( panel, Notebook_Event );
00503 
00504 #if (!wxCHECK_VERSION(2,5,2))
00505     wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
00506 #endif
00507 
00508     notebook->AddPage( FilePanel( notebook ), wxU(_("File")),
00509                        i_access_method == FILE_ACCESS );
00510     notebook->AddPage( DiscPanel( notebook ), wxU(_("Disc")),
00511                        i_access_method == DISC_ACCESS );
00512     notebook->AddPage( NetPanel( notebook ), wxU(_("Network")),
00513                        i_access_method == NET_ACCESS );
00514 
00515     module_t *p_module = config_FindModule( VLC_OBJECT(p_intf), "v4l" );
00516     if( p_module )
00517     {
00518         AutoBuiltPanel *autopanel =
00519             new AutoBuiltPanel( notebook, this, p_intf, p_module );
00520         input_tab_array.Add( autopanel );
00521         notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
00522                         p_module->psz_shortname : p_module->psz_object_name ),
00523                            i_access_method == CAPTURE_ACCESS );
00524     }
00525 
00526     p_module = config_FindModule( VLC_OBJECT(p_intf), "pvr" );
00527     if( p_module )
00528     {
00529         AutoBuiltPanel *autopanel =
00530             new AutoBuiltPanel( notebook, this, p_intf, p_module );
00531         input_tab_array.Add( autopanel );
00532         notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
00533                         p_module->psz_shortname : p_module->psz_object_name ),
00534                            i_access_method == CAPTURE_ACCESS );
00535     }
00536 
00537     p_module = config_FindModule( VLC_OBJECT(p_intf), "dvb" );
00538     if( p_module )
00539     {
00540         AutoBuiltPanel *autopanel =
00541             new AutoBuiltPanel( notebook, this, p_intf, p_module );
00542         input_tab_array.Add( autopanel );
00543         notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
00544                         p_module->psz_shortname : p_module->psz_object_name ),
00545                            i_access_method == CAPTURE_ACCESS );
00546     }
00547 
00548     p_module = config_FindModule( VLC_OBJECT(p_intf), "dshow" );
00549     if( p_module )
00550     {
00551         AutoBuiltPanel *autopanel =
00552             new AutoBuiltPanel( notebook, this, p_intf, p_module );
00553         input_tab_array.Add( autopanel );
00554         notebook->AddPage( autopanel, wxU( p_module->psz_shortname ?
00555                         p_module->psz_shortname : p_module->psz_object_name ),
00556                            i_access_method == CAPTURE_ACCESS );
00557     }
00558 
00559     /* Update Disc panel */
00560     wxCommandEvent dummy_event;
00561     OnDiscTypeChange( dummy_event );
00562 
00563     /* Update Net panel */
00564     dummy_event.SetId( NetRadio1_Event );
00565     OnNetTypeChange( dummy_event );
00566 
00567     /* Update MRL */
00568     wxNotebookEvent event( wxEVT_NULL, 0, i_access_method );
00569     OnPageChange( event );
00570 
00571     /* Place everything in sizers */
00572     wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
00573     button_sizer->Add( ok_button, 0, wxALL, 5 );
00574     button_sizer->Add( cancel_button, 0, wxALL, 5 );
00575     button_sizer->Layout();
00576     wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
00577     wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
00578     panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 );
00579     panel_sizer->Add( label, 0, wxEXPAND | wxALL, 5 );
00580 #if (!wxCHECK_VERSION(2,5,2))
00581     panel_sizer->Add( notebook_sizer, 1, wxEXPAND | wxALL, 5 );
00582 #else
00583     panel_sizer->Add( notebook, 1, wxEXPAND | wxALL, 5 );
00584 #endif
00585     panel_sizer->Add( common_opt_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
00586     panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 );
00587     panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALL, 5 );
00588     panel_sizer->Layout();
00589     panel->SetSizerAndFit( panel_sizer );
00590     main_sizer->Add( panel, 1, wxGROW, 0 );
00591     main_sizer->Layout();
00592     SetSizerAndFit( main_sizer );
00593 }
00594 
00595 OpenDialog::~OpenDialog()
00596 {
00597     /* Clean up */
00598     if( file_dialog ) delete file_dialog;
00599     if( sout_dialog ) delete sout_dialog;
00600     if( subsfile_dialog ) delete subsfile_dialog;
00601 }
00602 
00603 int OpenDialog::Show( int i_access_method, int i_arg )
00604 {
00605     notebook->SetSelection( i_access_method );
00606     int i_ret = wxDialog::Show();
00607     Raise();
00608     SetFocus();
00609     i_open_arg = i_arg;
00610     return i_ret;
00611 }
00612 
00613 int OpenDialog::Show()
00614 {
00615     int i_ret = wxDialog::Show();
00616     Raise();
00617     SetFocus();
00618     return i_ret;
00619 }
00620 
00621 /*****************************************************************************
00622  * Private methods.
00623  *****************************************************************************/
00624 wxPanel *OpenDialog::FilePanel( wxWindow* parent )
00625 {
00626     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
00627                                   wxSize(200, 200) );
00628 
00629     wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
00630 
00631     /* Create browse file line */
00632     wxBoxSizer *file_sizer = new wxBoxSizer( wxHORIZONTAL );
00633 
00634     file_combo = new wxComboBox( panel, FileName_Event, wxT(""),
00635                                  wxPoint(20,25), wxSize(200, -1) );
00636     wxButton *browse_button = new wxButton( panel, FileBrowse_Event,
00637                                             wxU(_("Browse...")) );
00638     file_sizer->Add( file_combo, 1, wxALL, 5 );
00639     file_sizer->Add( browse_button, 0, wxALL, 5 );
00640 
00641     /* Create Subtitles File checkox */
00642     wxFlexGridSizer *subsfile_sizer = new wxFlexGridSizer( 2, 1, 20 );
00643     subsfile_checkbox = new wxCheckBox( panel, SubsFileEnable_Event,
00644                                         wxU(_("Subtitle options")) );
00645     subsfile_checkbox->SetToolTip( wxU(_("Force options for separate subtitle files.")) );
00646     subsfile_sizer->Add( subsfile_checkbox, 0,
00647                          wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
00648     subsfile_button = new wxButton( panel, SubsFileSettings_Event,
00649                                     wxU(_("Settings...")) );
00650     subsfile_button->Disable();
00651 
00652     char *psz_subsfile = config_GetPsz( p_intf, "sub-file" );
00653     if( psz_subsfile && *psz_subsfile )
00654     {
00655         subsfile_checkbox->SetValue(TRUE);
00656         subsfile_button->Enable();
00657         subsfile_mrl.Add( wxString(wxT("sub-file=")) + wxL2U(psz_subsfile) );
00658     }
00659     if( psz_subsfile ) free( psz_subsfile );
00660 
00661     subsfile_sizer->Add( subsfile_button, 1,
00662                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
00663 
00664     sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 );
00665     sizer->Add( subsfile_sizer, 0, wxEXPAND | wxALL, 5 );
00666     panel->SetSizerAndFit( sizer );
00667     return panel;
00668 }
00669 
00670 wxPanel *OpenDialog::DiscPanel( wxWindow* parent )
00671 {
00672     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
00673                                   wxSize(200, 200) );
00674 
00675     wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
00676     wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 3, 20 );
00677 
00678     static const wxString disc_type_array[] =
00679     {
00680         wxU(_("DVD (menus)")),
00681         wxU(_("DVD")),
00682         wxU(_("VCD")),
00683         wxU(_("Audio CD")),
00684     };
00685 
00686     disc_type = new wxRadioBox( panel, DiscType_Event, wxU(_("Disc type")),
00687                                 wxDefaultPosition, wxDefaultSize,
00688                                 WXSIZEOF(disc_type_array), disc_type_array,
00689                                 WXSIZEOF(disc_type_array), wxRA_SPECIFY_COLS );
00690 
00691 #ifdef HAVE_LIBCDIO
00692     disc_probe = new wxCheckBox( panel, DiscProbe_Event,
00693                                  wxU(_("Probe Disc(s)")) );
00694     disc_probe->SetToolTip( wxU(_("Probe for a DVD, VCD or audio CD. "
00695 "First try the Device name entered for the selected Disc type "
00696 "(DVD, DVD Menu, VCD, audio CD). If that doesn't find media, try any device "
00697 "for the Disc type.  If that doesn't work, then try looking for CD-ROMs or "
00698 "DVD drives. The Disc type, Device name, and some parameter ranges are set "
00699 "based on media we find.")) );
00700 #endif
00701 
00702     sizer_row->Add( disc_type, i_disc_type_selection, wxEXPAND | wxALL, 5 );
00703 #ifdef HAVE_LIBCDIO
00704     sizer_row->Add( disc_probe, 0, wxEXPAND | wxALL );
00705 #endif
00706 
00707     wxStaticText *label = new wxStaticText( panel, -1, wxU(_("Device name")) );
00708     disc_device = new wxTextCtrl( panel, DiscDevice_Event, wxT(""),
00709                                   wxDefaultPosition, wxDefaultSize,
00710                                   wxTE_PROCESS_ENTER);
00711 
00712 #ifdef WIN32
00713     char psz_default_device[3] = {0};
00714 
00715     /* find the drive_name for the first cdrom drive,
00716      * which is probably "D:" and put the drive_name into
00717      * psz_default_device... */
00718     for( char drive_letter = 'A'; drive_letter <= 'Z'; ++drive_letter )
00719     {
00720         char drive_name[3] = {drive_letter, ':', 0};
00721         UINT type = GetDriveTypeA( drive_name );
00722         if( type == DRIVE_CDROM )
00723         {
00724             psz_default_device[0] = drive_letter;
00725             psz_default_device[1] = ':';
00726             break;
00727         }
00728     }
00729 
00730 
00731     if( strlen(psz_default_device) > 0 )
00732     {
00733         if(disc_device)
00734             disc_device->SetValue( wxL2U(psz_default_device) );
00735     }
00736 #endif
00737 
00738     sizer->Add( label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
00739     sizer->Add( disc_device, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
00740 
00741     disc_title_label = new wxStaticText( panel, -1, wxU(_("Title")) );
00742     disc_title = new wxSpinCtrl( panel, DiscTitle_Event );
00743     sizer->Add( disc_title_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
00744     sizer->Add( disc_title, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
00745 
00746     disc_chapter_label = new wxStaticText( panel, -1, wxU(_("Chapter")) );
00747     disc_chapter = new wxSpinCtrl( panel, DiscChapter_Event );
00748     sizer->Add( disc_chapter_label, 0,
00749                 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
00750     sizer->Add( disc_chapter, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
00751 
00752     disc_sub_label = new wxStaticText( panel, -1, wxU(_("Subtitles track")) );
00753     disc_sub = new wxSpinCtrl( panel, DiscSub_Event );
00754     sizer->Add( disc_sub_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
00755     sizer->Add( disc_sub, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
00756     disc_sub->SetRange( -1, 255 );
00757     i_disc_sub = config_GetInt( p_intf, "sub-track" );
00758     disc_sub->SetValue( i_disc_sub );
00759 
00760     disc_audio_label = new wxStaticText( panel, -1, wxU(_("Audio track")) );
00761     disc_audio = new wxSpinCtrl( panel, DiscAudio_Event );
00762     sizer->Add( disc_audio_label, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
00763     sizer->Add( disc_audio, 1, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
00764     disc_audio->SetRange( -1, 255 );
00765     i_disc_audio = config_GetInt( p_intf, "audio-track" );
00766     disc_audio->SetValue( i_disc_audio );
00767 
00768     sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
00769 
00770     panel->SetSizerAndFit( sizer_row );
00771     return panel;
00772 }
00773 
00774 wxPanel *OpenDialog::NetPanel( wxWindow* parent )
00775 {
00776     int i;
00777     wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
00778                                   wxSize(200, 200) );
00779 
00780     wxBoxSizer *sizer_row = new wxBoxSizer( wxVERTICAL );
00781     wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 4, 20 );
00782 
00783     static const wxString net_type_array[] =
00784     {
00785         wxU(_("UDP/RTP")),
00786         wxU(_("UDP/RTP Multicast")),
00787         wxU(_("HTTP/HTTPS/FTP/MMS")),
00788         wxU(_("RTSP"))
00789     };
00790 
00791     for( i=0; i<4; i++ )
00792     {
00793         net_radios[i] = new wxRadioButton( panel, NetRadio1_Event + i,
00794                                            net_type_array[i],
00795                                            wxDefaultPosition, wxDefaultSize,
00796                                            wxRB_SINGLE );
00797 
00798         net_subpanels[i] = new wxPanel( panel, -1,
00799                                         wxDefaultPosition, wxDefaultSize );
00800     }
00801 
00802     /* Timeshift */
00803     net_timeshift  = new wxCheckBox( panel, NetTimeshift_Event,
00804                                      wxU(_("Allow timeshifting")) );
00805 
00806     /* UDP/RTP row */
00807     wxFlexGridSizer *subpanel_sizer;
00808     wxStaticText *label;
00809     i_net_ports[0] = config_GetInt( p_intf, "server-port" );
00810     subpanel_sizer = new wxFlexGridSizer( 3, 1, 20 );
00811     label = new wxStaticText( net_subpanels[0], -1, wxU(_("Port")) );
00812     net_ports[0] = new wxSpinCtrl( net_subpanels[0], NetPort1_Event,
00813                                    wxString::Format(wxT("%d"), i_net_ports[0]),
00814                                    wxDefaultPosition, wxDefaultSize,
00815                                    wxSP_ARROW_KEYS,
00816                                    0, 65535, i_net_ports[0] );
00817 
00818     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
00819     subpanel_sizer->Add( net_ports[0], 1,
00820                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
00821     net_ipv6 = new wxCheckBox( net_subpanels[0], NetForceIPv6_Event,
00822                                wxU(_("Force IPv6")));
00823     subpanel_sizer->Add( net_ipv6, 0,
00824                          wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
00825     net_subpanels[0]->SetSizerAndFit( subpanel_sizer );
00826     net_radios[0]->SetValue( TRUE );
00827 
00828     /* UDP/RTP Multicast row */
00829     subpanel_sizer = new wxFlexGridSizer( 4, 1, 20 );
00830     label = new wxStaticText( net_subpanels[1], -1, wxU(_("Address")) );
00831     net_addrs[1] = new wxTextCtrl( net_subpanels[1], NetAddr2_Event, wxT(""),
00832                                    wxDefaultPosition, wxDefaultSize,
00833                                    wxTE_PROCESS_ENTER);
00834     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
00835     subpanel_sizer->Add( net_addrs[1], 1,
00836                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
00837 
00838     label = new wxStaticText( net_subpanels[1], -1, wxU(_("Port")) );
00839     i_net_ports[1] = i_net_ports[0];
00840     net_ports[1] = new wxSpinCtrl( net_subpanels[1], NetPort2_Event,
00841                                    wxString::Format(wxT("%d"), i_net_ports[1]),
00842                                    wxDefaultPosition, wxDefaultSize,
00843                                    wxSP_ARROW_KEYS,
00844                                    0, 65535, i_net_ports[1] );
00845 
00846     subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
00847     subpanel_sizer->Add( net_ports[1], 1,
00848                          wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
00849     net_subpanels[1]->SetSizerAndFit( subpanel_sizer );
00850 
00851     /* HTTP and RTSP rows */
00852     for( i=2; i<4; i++ )
00853     {
00854         subpanel_sizer = new wxFlexGridSizer( 2, 1, 20 );
00855         label = new wxStaticText( net_subpanels[i], -1, wxU(_("URL")) );
00856         net_addrs[i] = new wxTextCtrl( net_subpanels[i], NetAddr1_Event + i,
00857                                        (i == 2) ? wxT("") : wxT("rtsp://"),
00858                                        wxDefaultPosition, wxSize( 200, -1 ),
00859                                        wxTE_PROCESS_ENTER);
00860         subpanel_sizer->Add( label, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL );
00861         subpanel_sizer->Add( net_addrs[i], 1,
00862                              wxEXPAND | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL );
00863         net_subpanels[i]->SetSizerAndFit( subpanel_sizer );
00864     }
00865 
00866     /* Stuff everything into the main panel */
00867     for( i=0; i<4; i++ )
00868     {
00869         sizer->Add( net_radios[i], 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
00870                     wxALL, 5 );
00871         sizer->Add( net_subpanels[i], 1, wxEXPAND | wxALIGN_LEFT |
00872                     wxALIGN_CENTER_VERTICAL | wxALL, 5  );
00873     }
00874     sizer->Add( net_timeshift, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL |
00875                 wxALL, 5 );
00876 
00877     sizer_row->Add( sizer, 0, wxEXPAND | wxALL, 5 );
00878 
00879     panel->SetSizerAndFit( sizer_row );
00880     return panel;
00881 }
00882 
00883 void OpenDialog::UpdateMRL()
00884 {
00885     UpdateMRL( i_current_access_method );
00886 }
00887 
00888 void OpenDialog::UpdateMRL( int i_access_method )
00889 {
00890     wxString mrltemp, caching_name;
00891 
00892     i_current_access_method = i_access_method;
00893 
00894     switch( i_access_method )
00895     {
00896     case FILE_ACCESS:
00897         mrltemp = file_combo->GetValue();
00898         caching_name = wxT("file-caching");
00899         break;
00900 
00901     case DISC_ACCESS:
00902         i_disc_type_selection = disc_type->GetSelection();
00903 
00904         switch ( i_disc_type_selection )
00905         {
00906         case 0: /* DVD with menus */
00907         case 1: /* DVD without menus */
00908             disc_device->SetToolTip( wxU(_("Name of DVD device "
00909             "to read from.")) );
00910             if( i_disc_type_selection == 0 )
00911             {
00912                 mrltemp = wxT("dvd://") + disc_device->GetValue();
00913                 caching_name = wxT("dvdnav-caching");
00914             }
00915             else
00916             {
00917                 mrltemp = wxT("dvdsimple://") + disc_device->GetValue();
00918                 caching_name = wxT("dvdread-caching");
00919             }
00920 
00921             if( i_disc_title > 0 )
00922             {
00923                 mrltemp += wxString::Format( wxT("@%d"), i_disc_title );
00924 
00925                 if( i_disc_chapter > 0 )
00926                     mrltemp += wxString::Format( wxT(":%d"), i_disc_chapter );
00927             }
00928 
00929             if( i_disc_sub >= 0 )
00930                 mrltemp += wxString::Format( wxT("  :sub-track=%d"),
00931                                              i_disc_sub );
00932             if( i_disc_audio >= 0 )
00933                 mrltemp += wxString::Format( wxT("  :audio-track=%d"),
00934                                              i_disc_audio );
00935             break;
00936 
00937         case 2:  /* VCD of some sort */
00938 #ifdef HAVE_VCDX
00939             disc_device->SetToolTip( wxU(_("Name of CD-ROM device "
00940             "to read Video CD from. If this field is left empty, we will scan "
00941             "for a CD-ROM with a VCD in it.")) );
00942             mrltemp = wxT("vcdx://") + disc_device->GetValue();
00943             if( i_disc_title > 0 )
00944                 mrltemp += wxString::Format( wxT("@%c%d"),
00945                                   config_GetInt( p_intf, "vcdx-PBC"  )
00946                                   ? 'P' : 'E', i_disc_title );
00947 #else
00948             disc_device->SetToolTip( wxU(_("Name of CD-ROM device "
00949             "to read Video CD from.")) );
00950             mrltemp = wxT("vcd://") + disc_device->GetValue();
00951             if( i_disc_title > 0 )
00952                 mrltemp += wxString::Format( wxT("@%d"), i_disc_title );
00953 #endif
00954 
00955             if( i_disc_sub >= 0 )
00956                 mrltemp += wxString::Format( wxT("  :sub-track=%d"),
00957                                              i_disc_sub );
00958 
00959             if( i_disc_audio >= 0 )
00960                 mrltemp += wxString::Format( wxT("  :audio-track=%d"),
00961                                              i_disc_audio );
00962             caching_name = wxT("vcd-caching");
00963             break;
00964 
00965         case 3: /* CD-DA */
00966 #ifdef HAVE_CDDAX
00967             disc_device->SetToolTip( wxU(_("Name of CD-ROM device "
00968             "to read audio CD from. If this field is left empty, we will scan "
00969             "for a CD-ROM with an audio CD in it." )) );
00970             mrltemp = wxT("cddax://")
00971 #else
00972             disc_device->SetToolTip( wxU(_("Name of CD-ROM device "
00973             "to read audio CD from." )) );
00974             mrltemp = wxT("cdda://")
00975 #endif
00976               + disc_device->GetValue();
00977             if( i_disc_title > 0 )
00978                 mrltemp += wxString::Format( wxT("@%d"), i_disc_title );
00979 
00980             caching_name = wxT("cdda-caching");
00981             break;
00982 
00983         default:
00984             msg_Err( p_intf, "invalid selection (%d)",
00985                      disc_type->GetSelection() );
00986         }
00987 
00988         break;
00989 
00990     case NET_ACCESS:
00991         switch( i_net_type )
00992         {
00993         case 0:
00994             mrltemp = wxT("udp://@");
00995             if ( net_ipv6->GetValue() )
00996             {
00997                 mrltemp += wxT("[::]");
00998             }
00999             if( i_net_ports[0] !=
01000                 config_GetInt( p_intf, "server-port" ) )
01001             {
01002                 mrltemp += wxString::Format( wxT(":%d"), i_net_ports[0] );
01003             }
01004 
01005             caching_name = wxT("udp-caching");
01006             break;
01007 
01008         case 1:
01009             mrltemp = wxT("udp://@");
01010             if ((net_addrs[1]->GetLineText(0).Find (':') != -1)
01011                 && (net_addrs[1]->GetLineText(0)[0u] != '['))
01012             {
01013                 /* automatically adds '[' and ']' to IPv6 addresses */
01014                 mrltemp += wxT("[") + net_addrs[1]->GetLineText(0)
01015                          + wxT("]");
01016             }
01017             else
01018             {
01019                 mrltemp += net_addrs[1]->GetLineText(0);
01020             }
01021             if( i_net_ports[1] != config_GetInt( p_intf, "server-port" ) )
01022             {
01023                 mrltemp += wxString::Format( wxT(":%d"), i_net_ports[1] );
01024             }
01025 
01026             caching_name = wxT("udp-caching");
01027             break;
01028 
01029         case 2:
01030             /* http access */
01031             if( net_addrs[2]->GetLineText(0).Find(wxT("://")) == -1 )
01032                 mrltemp = wxT("http://");
01033 
01034             mrltemp += net_addrs[2]->GetLineText(0);
01035 
01036             caching_name = wxT("http-caching");
01037             break;
01038 
01039         case 3:
01040             /* RTSP access */
01041             if( net_addrs[3]->GetLineText(0).Find(wxT("rtsp://")) != 0 )
01042             {
01043                 mrltemp = wxT("rtsp://");
01044             }
01045             mrltemp += net_addrs[3]->GetLineText(0);
01046 
01047             caching_name = wxT("rtsp-caching");
01048             break;
01049         }
01050         if( net_timeshift->IsEnabled() && net_timeshift->IsChecked() )
01051             mrltemp += wxT(" :access-filter=timeshift");
01052         break;
01053 
01054     default:
01055         {
01056             int i_item = i_access_method - MAX_ACCESS;
01057 
01058             if( i_item < 0 || i_item >= (int)input_tab_array.GetCount() )
01059                 break;
01060 
01061             AutoBuiltPanel *input_panel = input_tab_array.Item( i_item );
01062 
01063             mrltemp = input_panel->name + wxT("://");
01064 
01065             for( int i=0; i < (int)input_panel->config_array.GetCount(); i++ )
01066             {
01067                 ConfigControl *control = input_panel->config_array.Item(i);
01068 
01069                 mrltemp += wxT(" :");
01070 
01071                 if( control->GetType() == CONFIG_ITEM_BOOL &&
01072                     !control->GetIntValue() ) mrltemp += wxT("no-");
01073 
01074                 mrltemp += control->GetName();
01075 
01076                 switch( control->GetType() )
01077                 {
01078                 case CONFIG_ITEM_STRING:
01079                 case CONFIG_ITEM_FILE:
01080                 case CONFIG_ITEM_DIRECTORY:
01081                 case CONFIG_ITEM_MODULE:
01082                     mrltemp += wxT("=\"") + control->GetPszValue() + wxT("\"");
01083                     break;
01084                 case CONFIG_ITEM_INTEGER:
01085                     mrltemp +=
01086                         wxString::Format( wxT("=%i"), control->GetIntValue() );
01087                     break;
01088                 case CONFIG_ITEM_FLOAT:
01089                     mrltemp +=
01090                         wxString::Format(wxT("=%f"), control->GetFloatValue());
01091                     break;
01092                 }
01093             }
01094 
01095             if( input_panel->p_advanced_mrl_combo &&
01096                 input_panel->p_advanced_mrl_combo->GetValue() )
01097             {
01098                 mrltemp += wxT(" ") +
01099                     input_panel->p_advanced_mrl_combo->GetValue();
01100             }
01101         }
01102         break;
01103     }
01104 
01105     if( caching_name.size() )
01106     {
01107         if( caching_value->IsEnabled() )
01108         {
01109             mrltemp += wxT("  :") + caching_name +
01110                 wxString::Format( wxT("=%d"), i_caching );
01111         }
01112         else
01113         {
01114             int i_value = config_GetInt( p_intf, caching_name.mb_str() );
01115             caching_value->SetValue( i_value );
01116         }
01117     }
01118 
01119     mrl_combo->SetValue( mrltemp );
01120 }
01121 
01122 /*****************************************************************************
01123  * Events methods.
01124  *****************************************************************************/
01125 void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
01126 {
01127     mrl = SeparateEntries( mrl_combo->GetValue() );
01128     mrl_combo->Append( mrl_combo->GetValue() );
01129     if( mrl_combo->GetCount() > 10 ) mrl_combo->Delete( 0 );
01130     mrl_combo->SetSelection( mrl_combo->GetCount() - 1 );
01131 
01132     if( i_method == OPEN_STREAM )
01133     {
01134         if( IsModal() ) EndModal( wxID_OK );
01135         Hide();
01136         return;
01137     }
01138 
01139     /* Update the playlist */
01140     playlist_t *p_playlist =
01141         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
01142                                        FIND_ANYWHERE );
01143     if( p_playlist == NULL ) return;
01144 
01145     for( int i = 0; i < (int)mrl.GetCount(); i++ )
01146     {
01147         vlc_bool_t b_start = !i && i_open_arg;
01148         playlist_item_t *p_item;
01149         char *psz_utf8;
01150 
01151         psz_utf8 = wxFromLocale( mrl[i] );
01152         p_item = playlist_ItemNew( p_intf, psz_utf8, psz_utf8 );
01153         wxLocaleFree( psz_utf8 );
01154 
01155         /* Insert options */
01156         while( i + 1 < (int)mrl.GetCount() &&
01157                ((const char *)mrl[i + 1].mb_str())[0] == ':' )
01158         {
01159             psz_utf8 = wxFromLocale( mrl[i + 1] );
01160             playlist_ItemAddOption( p_item, psz_utf8 );
01161             wxLocaleFree( psz_utf8 );
01162             i++;
01163         }
01164 
01165         /* Get the options from the subtitles dialog */
01166         if( subsfile_checkbox->IsChecked() && subsfile_mrl.GetCount() )
01167         {
01168             for( int j = 0; j < (int)subsfile_mrl.GetCount(); j++ )
01169             {
01170                 psz_utf8 = wxFromLocale( subsfile_mrl[j] );
01171                 playlist_ItemAddOption( p_item, psz_utf8 );
01172                 wxLocaleFree( psz_utf8 );
01173             }
01174         }
01175 
01176         /* Get the options from the stream output dialog */
01177         if( sout_checkbox->IsChecked() && sout_mrl.GetCount() )
01178         {
01179             for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
01180             {
01181                 psz_utf8 = wxFromLocale( sout_mrl[j] );
01182                 playlist_ItemAddOption( p_item, psz_utf8 );
01183                 wxLocaleFree( psz_utf8 );
01184             }
01185         }
01186 
01187         playlist_AddItem( p_playlist, p_item, PLAYLIST_APPEND, PLAYLIST_END );
01188 
01189         if( b_start )
01190         {
01191             playlist_Control( p_playlist, PLAYLIST_ITEMPLAY, p_item );
01192         }
01193     }
01194 
01195     vlc_object_release( p_playlist );
01196 
01197     Hide();
01198 
01199     if( IsModal() ) EndModal( wxID_OK );
01200 }
01201 
01202 void OpenDialog::OnCancel( wxCommandEvent& WXUNUSED(event) )
01203 {
01204     wxCloseEvent cevent;
01205     OnClose(cevent);
01206 }
01207 
01208 void OpenDialog::OnClose( wxCloseEvent& WXUNUSED(event) )
01209 {
01210     Hide();
01211 
01212     if( IsModal() ) EndModal( wxID_CANCEL );
01213 }
01214 
01215 void OpenDialog::OnPageChange( wxNotebookEvent& event )
01216 {
01217     UpdateMRL( event.GetSelection() );
01218 }
01219 
01220 void OpenDialog::OnMRLChange( wxCommandEvent& event )
01221 {
01222     //mrl = SeparateEntries( event.GetString() );
01223 }
01224 
01225 /*****************************************************************************
01226  * File panel event methods.
01227  *****************************************************************************/
01228 void OpenDialog::OnFilePanelChange( wxCommandEvent& WXUNUSED(event) )
01229 {
01230     UpdateMRL( FILE_ACCESS );
01231 }
01232 
01233 void OpenDialog::OnFileBrowse( wxCommandEvent& WXUNUSED(event) )
01234 {
01235     if( file_dialog == NULL )
01236         file_dialog = new wxFileDialog( this, wxU(_("Open File")),
01237             wxT(""), wxT(""), wxT("*"), wxOPEN | wxMULTIPLE );
01238 
01239     if( file_dialog && file_dialog->ShowModal() == wxID_OK )
01240     {
01241         wxArrayString paths;
01242         wxString path;
01243 
01244         file_dialog->GetPaths( paths );
01245 
01246         for( size_t i = 0; i < paths.GetCount(); i++ )
01247         {
01248             if( paths[i].Find( wxT(' ') ) >= 0 )
01249                 path += wxT("\"") + paths[i] + wxT("\" ");
01250             else
01251                 path += paths[i] + wxT(" ");
01252         }
01253 
01254         file_combo->SetValue( path );
01255         file_combo->Append( path );
01256         if( file_combo->GetCount() > 10 ) file_combo->Delete( 0 );
01257         UpdateMRL( FILE_ACCESS );
01258     }
01259 }
01260 
01261 /*****************************************************************************
01262  * Disc panel event methods.
01263  *****************************************************************************/
01264 void OpenDialog::OnDiscPanelChangeSpin( wxSpinEvent& event )
01265 {
01266     wxCommandEvent cevent;
01267     cevent.SetId(event.GetId());
01268     cevent.SetInt(event.GetPosition());
01269     OnDiscPanelChange(cevent);
01270 }
01271 
01272 void OpenDialog::OnDiscPanelChange( wxCommandEvent& event )
01273 {
01274     if( event.GetId() == DiscTitle_Event ) i_disc_title = event.GetInt();
01275     if( event.GetId() == DiscChapter_Event ) i_disc_chapter = event.GetInt();
01276     if( event.GetId() == DiscSub_Event ) i_disc_sub = event.GetInt();
01277     if( event.GetId() == DiscAudio_Event ) i_disc_audio = event.GetInt();
01278 
01279     UpdateMRL( DISC_ACCESS );
01280 }
01281 
01282 void OpenDialog::OnDiscDeviceChange( wxCommandEvent& event )
01283 {
01284     char *psz_device;
01285 
01286     switch( disc_type->GetSelection() )
01287     {
01288         case 3:
01289             psz_device = config_GetPsz( p_intf, "cd-audio" );
01290             break;
01291 
01292         case 2:
01293             psz_device = config_GetPsz( p_intf, "vcd" );
01294             break;
01295 
01296         default:
01297             psz_device = config_GetPsz( p_intf, "dvd" );
01298             break;
01299     }
01300 
01301     if ( !psz_device ) psz_device = "";
01302 
01303     if( disc_device->GetValue().Cmp( wxL2U( psz_device ) ) )
01304     {
01305         b_disc_device_changed = true;
01306     }
01307 
01308     UpdateMRL( DISC_ACCESS );
01309 }
01310 
01311 #ifdef HAVE_LIBCDIO
01312 
01313 /* Return true if *psz_drive is a drive with a DVD in it. A more complete
01314    check would see if the media looks like a *playable* DVD. This should
01315    go into libcdio.
01316  */
01317 static bool IsDVD(const char *psz_drive)
01318 {
01319   CdIo_t *p_cdio = cdio_open (psz_drive, DRIVER_UNKNOWN);
01320   if (p_cdio)
01321   {
01322       discmode_t discmode = cdio_get_discmode(p_cdio);
01323       cdio_destroy(p_cdio);
01324       return cdio_is_discmode_dvd(discmode);
01325   }
01326   return false;
01327 }
01328 
01329 
01330 /* Return a device that has a DVD in it. The caller needs to free
01331    the returned string.
01332 */
01333 static char * ProbeDVD(const wxChar *device)
01334 {
01335   char **ppsz_cd_drives;
01336   const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(device);
01337   char *psz_device = const_cast<char *>(tmp_buf.data());
01338 
01339   if( IsDVD(psz_device) )
01340   {
01341       return strdup(psz_device);
01342   }
01343 
01344   ppsz_cd_drives = cdio_get_devices(DRIVER_DEVICE);
01345   if( ppsz_cd_drives )
01346   {
01347       char **c;
01348       for( c = ppsz_cd_drives; *c != NULL; c++ )
01349       {
01350       if( IsDVD(*c) )
01351       {
01352           char *psz_drive = strdup(*c);
01353           cdio_free_device_list(ppsz_cd_drives);
01354           return strdup(psz_drive);
01355           }
01356       }
01357       cdio_free_device_list(ppsz_cd_drives);
01358   }
01359   return NULL;
01360 }
01361 
01362 
01363 static char * ProbeDevice(char **ppsz_search_devices, cdio_fs_anal_t mask,
01364               bool b_any)
01365 {
01366     char **ppsz_devices;
01367 
01368     if( ppsz_search_devices && !ppsz_search_devices[0] )
01369         ppsz_search_devices = NULL;
01370 
01371     /* Start out trying the device that has been entered so far. */
01372     ppsz_devices = cdio_get_devices_with_cap(ppsz_search_devices, mask,
01373                          b_any);
01374 
01375     if (ppsz_devices && *ppsz_devices)
01376     {
01377         char *psz_device = strdup(*ppsz_devices);
01378         cdio_free_device_list(ppsz_devices);
01379         return psz_device;
01380     }
01381 
01382     /* If there was no device specified on the first try, then give up
01383        now. Otherwise accept any CD-ROM in the class (e.g. VCD or DVD).
01384     */
01385     if( !ppsz_search_devices ) return NULL;
01386 
01387     ppsz_devices = cdio_get_devices_with_cap(NULL, mask, true);
01388 
01389     if (ppsz_devices && *ppsz_devices)
01390     {
01391         char *psz_device = strdup(*ppsz_devices);
01392         cdio_free_device_list(ppsz_devices);
01393         return psz_device;
01394     }
01395 
01396     return NULL;
01397 }
01398 
01399 
01400 /* Return a device that has a CD-DA in it. The caller needs to free
01401    the returned string.
01402 */
01403 static char * ProbeCDDA(const wxChar *device)
01404 {
01405    char *ppsz_device[2];
01406    const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(device);
01407    char *psz_device = const_cast<char *>(tmp_buf.data());
01408    ppsz_device[0] = (device && *device) ? psz_device : NULL;
01409    ppsz_device[1] = NULL;
01410    return ProbeDevice(ppsz_device, CDIO_FS_AUDIO, false);
01411 }
01412 
01413 /* Return a device that has a VCD in it. The caller needs to free
01414    the returned string.
01415 */
01416 static char * ProbeVCD(const wxChar *device)
01417 {
01418    char *ppsz_device[2];
01419    const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(device);
01420    char *psz_device = const_cast<char *>(tmp_buf.data());
01421    ppsz_device[0] = (device && *device) ? psz_device : NULL;
01422    ppsz_device[1] = NULL;
01423    return ProbeDevice(ppsz_device,
01424                       (CDIO_FS_ANAL_SVCD|CDIO_FS_ANAL_CVD|CDIO_FS_ANAL_VIDEOCD
01425                        |CDIO_FS_UNKNOWN), true);
01426 }
01427 
01428 
01429 /*
01430    Probe (find anywhere) a CD-DA, VCD, or a DVD.
01431    First try the device name that may have been entered for the "disc type"
01432    selected. If that doesn't work we try any device for the disc type.
01433    If that doesn't work, try looking for CD-ROMs or DVD drives. the
01434    disc type, device name and paramter ranges are set to whatever we find.
01435 */
01436 void OpenDialog::OnDiscProbe( wxCommandEvent& WXUNUSED(event) )
01437 {
01438     wxCommandEvent dummy_event;
01439     char *psz_device = NULL;
01440     bool b_probed_DVD = false;
01441     bool b_probed_VCD = false;
01442     const int i_selection = disc_type->GetSelection();
01443 
01444     /* Reduce verbosity of cdio errors. */
01445     cdio_loglevel_default = CDIO_LOG_ERROR;
01446 
01447  retry:
01448     switch( disc_type->GetSelection() )
01449     {
01450 
01451     case SELECTION_DISC_TYPE_DVD_MENUS:
01452     case SELECTION_DISC_TYPE_DVD:
01453       /* If not a DVD then try for a VCD. If VCD fails it will
01454          try for a CD-DA. */
01455       if (!psz_device) psz_device = ProbeDVD(disc_device->GetValue());
01456       if (!psz_device)
01457       {
01458           b_probed_DVD = true;
01459           disc_type->SetSelection(SELECTION_DISC_TYPE_VCD);
01460           OnDiscTypeChange( dummy_event );
01461           goto retry;
01462       }
01463       disc_device->SetValue( wxL2U(psz_device) );
01464       break;
01465 
01466     case SELECTION_DISC_TYPE_VCD:  /* VCD probe of some sort */
01467       if(!psz_device) psz_device = ProbeVCD(disc_device->GetValue());
01468       if( psz_device  )
01469       {
01470 #ifdef HAVE_VCDX
01471 #if LIBVCD_VERSION_NUM > 23
01472       vcdinfo_obj_t *p_vcdinfo;
01473 
01474           /* Set LID or entry range accurately if possible. */
01475       if( vcdinfo_open(&p_vcdinfo, &psz_device, DRIVER_DEVICE,
01476                 NULL) == VCDINFO_OPEN_VCD)
01477       {
01478           if (config_GetInt( p_intf, "vcdx-PBC"  ))
01479           {
01480           /* Set largest LID. */;
01481           disc_title->SetRange( 0, vcdinfo_get_num_LIDs(p_vcdinfo) );
01482 
01483           }
01484           else
01485           {
01486           /* Set largest Entry */
01487           disc_title->SetRange( 0,
01488                     vcdinfo_get_num_entries(p_vcdinfo)-1 );
01489           }
01490           vcdinfo_close(p_vcdinfo);
01491       }
01492 #endif /* LIBVCD_VERSION_NUM > 23 */
01493           disc_device->SetValue( wxL2U(psz_device) );
01494 #else
01495           CdIo_t *p_cdio = cdio_open (psz_device, DRIVER_UNKNOWN);
01496           disc_device->SetValue( wxL2U(psz_device) );
01497 
01498           /* Set track range accurately if possible. */
01499           if (p_cdio)
01500           {
01501               track_t i_last_track = cdio_get_last_track_num(p_cdio);
01502               disc_title->SetRange( 0, i_last_track-1 );
01503           }
01504           cdio_destroy(p_cdio);
01505 #endif
01506           break;
01507       }
01508 
01509       b_probed_VCD = true;
01510 
01511       /* Not a VCD. Try for a DVD unless we've been there before. */
01512       if( !b_probed_DVD && (psz_device = ProbeDVD(disc_device->GetValue())) )
01513       {
01514           disc_type->SetSelection(SELECTION_DISC_TYPE_DVD_MENUS);
01515           OnDiscTypeChange( dummy_event );
01516           goto retry;
01517       }
01518       b_probed_DVD = true;
01519 
01520       /* Couldn't find a VCD or DVD. See if we can find a CD-DA. */
01521       psz_device = ProbeCDDA(disc_device->GetValue());
01522       if( psz_device  )
01523       {
01524           disc_type->SetSelection(SELECTION_DISC_TYPE_CDDA);
01525           OnDiscTypeChange( dummy_event );
01526           goto retry;
01527       }
01528 
01529       /* Couldn't find a VCD, DVD or CD-DA. Null out the Device name and
01530      set to original selection.
01531        */
01532       disc_device->SetValue( wxL2U("") );
01533       disc_type->SetSelection(i_selection);
01534       OnDiscTypeChange( dummy_event );
01535       break;
01536 
01537     case SELECTION_DISC_TYPE_CDDA:
01538       if(!psz_device) psz_device = ProbeCDDA(disc_device->GetValue());
01539       if( psz_device  )
01540       {
01541           CdIo_t *p_cdio = cdio_open (psz_device, DRIVER_UNKNOWN);
01542           disc_device->SetValue( wxL2U(psz_device) );
01543           if (p_cdio)
01544           {
01545               track_t i_last_track = cdio_get_last_track_num(p_cdio);
01546               disc_title->SetRange( 0, i_last_track );
01547 #if 0
01548           MediaInsertCDDA( p_intf,  p_cdio, i_last_track );
01549 #endif
01550           }
01551           cdio_destroy(p_cdio);
01552           break;
01553       }
01554 
01555       /* Not a CD-DA. Try for a DVD unless we've been there before. */
01556       if( !b_probed_DVD && (psz_device = ProbeDVD(disc_device->GetValue())) )
01557       {
01558           disc_type->SetSelection(SELECTION_DISC_TYPE_DVD_MENUS);
01559           OnDiscTypeChange( dummy_event );
01560           goto retry;
01561       }
01562 
01563       /* Couldn't find a CD-DA or DVD. See if we can find a VCD, unless
01564          we've tried that before. */
01565       if (!b_probed_VCD) psz_device = ProbeVCD(disc_device->GetValue());
01566       if( psz_device  )
01567       {
01568           disc_type->SetSelection(SELECTION_DISC_TYPE_VCD);
01569           OnDiscTypeChange( dummy_event );
01570           goto retry;
01571       }
01572       disc_device->SetValue( wxL2U("") );
01573       break;
01574 
01575     default:
01576         msg_Err( p_intf, "invalid Disc type selection (%d)",
01577                  disc_type->GetSelection() );
01578         break;
01579     }
01580 
01581     free(psz_device);
01582     disc_probe->SetValue(FALSE);
01583 
01584     UpdateMRL( DISC_ACCESS );
01585 }
01586 #endif /* HAVE_LIBCDIO */
01587 
01588 void OpenDialog::OnDiscTypeChange( wxCommandEvent& WXUNUSED(event) )
01589 {
01590     char *psz_device = NULL;
01591 
01592     switch( disc_type->GetSelection() )
01593     {
01594 
01595     case SELECTION_DISC_TYPE_DVD_MENUS:
01596     case SELECTION_DISC_TYPE_DVD:
01597         disc_sub->Enable(); disc_sub_label->Enable();
01598         disc_audio->Enable(); disc_audio_label->Enable();
01599         disc_chapter->Enable(); disc_chapter_label->Enable();
01600         disc_title_label->SetLabel ( wxU(_("Title")) );
01601         psz_device = config_GetPsz( p_intf, "dvd" );
01602         if( !b_disc_device_changed )
01603         {
01604             if( psz_device ) disc_device->SetValue( wxL2U(psz_device) );
01605             else disc_device->SetValue( wxT("") );
01606         }
01607         disc_title->SetRange( 0, 255 );
01608         disc_sub->SetRange( -1, 31 );  // up to 32 subtitles -1: no subtitle
01609         disc_audio->SetRange( 0, 7 );  // up to 8 audio channels
01610         disc_chapter->SetRange( 0, 255 );
01611         disc_title->SetToolTip( wxU(_("Title number.")) );
01612         disc_sub->SetToolTip( wxU(_(
01613           "DVD's can have up to 32 subtitles numbered 0..31. "
01614           "Note this is not the same thing as a subtitle name e.g. 'en'. "
01615           "If a value -1 is used, no subtitle will be shown." )) );
01616         disc_audio->SetToolTip( wxU(_("Audio track number. "
01617           "DVD's can have up to 8 audio tracks numbered 0..7."
01618         )) );
01619         break;
01620 
01621     case SELECTION_DISC_TYPE_VCD:
01622         disc_sub->Enable(); disc_sub_label->Enable();
01623         disc_audio->Enable(); disc_audio_label->Enable();
01624         disc_chapter->Disable(); disc_chapter_label->Disable();
01625         psz_device = config_GetPsz( p_intf, "vcd" );
01626         if( !b_disc_device_changed )
01627         {
01628             if( psz_device ) disc_device->SetValue( wxL2U(psz_device) );
01629             else disc_device->SetValue( wxT("") );
01630         }
01631 
01632 #ifdef HAVE_VCDX
01633         if (config_GetInt( p_intf, "vcdx-PBC"  ))
01634         {
01635           disc_title_label->SetLabel ( wxT("Playback LID") );
01636           disc_title->SetToolTip( wxU(_(
01637           "Playback control (PBC) usually starts with number 1." )) );
01638         }
01639         else
01640         {
01641           disc_title_label->SetLabel ( wxT("Entry") );
01642           disc_title->SetToolTip( wxU(_(
01643           "The first entry (the beginning of the first MPEG track) is 0." )) );
01644         }
01645 
01646 #else
01647         disc_title_label->SetLabel ( wxU(_("Track")) );
01648         disc_title->SetToolTip( wxU(_("Track number.")) );
01649 #endif
01650         disc_title->SetRange( 0, 99 );  // only 100 tracks allowed on VCDs
01651         disc_sub->SetRange( -1, 3 );    // up to 4 subtitles -1 = no subtitle
01652         disc_audio->SetRange( 0, 1 );   // up to 2 audio tracks
01653         disc_sub->SetToolTip( wxU(_(
01654           "SVCD's can have up to 4 subtitles numbered 0..3. "
01655           "If a value -1 is used, no subtitle will be shown." )) );
01656         disc_audio->SetToolTip( wxU(_("Audio track number. "
01657           "VCD's can have up to 2 audio tracks numbered 0 or 1. "
01658         )) );
01659         break;
01660 
01661     case SELECTION_DISC_TYPE_CDDA:
01662         disc_sub->Disable(); disc_sub_label->Disable();
01663         disc_chapter->Disable(); disc_chapter_label->Disable();
01664         disc_audio->Disable(); disc_audio_label->Disable();
01665         disc_title_label->SetLabel ( wxU(_("Track")) );
01666 #ifdef HAVE_CDDAX
01667         disc_title->SetToolTip( wxU(_(
01668         "Audio CDs can have up to 100 tracks, the first track is usually 1. "
01669         "If 0 is given, then all tracks are played.")) );
01670 #else
01671         disc_title->SetToolTip( wxU(_(
01672         "Audio CDs can have up to 100 tracks, the first track is usually 1."
01673         )) );
01674 #endif
01675         psz_device = config_GetPsz( p_intf, "cd-audio" );
01676         if( !b_disc_device_changed )
01677         {
01678             if( psz_device ) disc_device->SetValue( wxL2U(psz_device) );
01679             else disc_device->SetValue( wxT("") );
01680         }
01681 
01682         /* There are at most 100 tracks in a CD-DA */
01683         disc_title->SetRange( 0, 100 );
01684         break;
01685 
01686     default:
01687         msg_Err( p_intf, "invalid Disc type selection (%d)",
01688                  disc_type->GetSelection() );
01689         break;
01690     }
01691 
01692     disc_title->SetValue( 0 ); i_disc_title = 0;
01693     disc_chapter->SetValue( 0 ); i_disc_chapter = 0;
01694 
01695     if( psz_device ) free( psz_device );
01696 
01697     UpdateMRL( DISC_ACCESS );
01698 }
01699 
01700 /*****************************************************************************
01701  * Net panel event methods.
01702  *****************************************************************************/
01703 void OpenDialog::OnNetPanelChangeSpin( wxSpinEvent& event )
01704 {
01705     wxCommandEvent cevent;
01706     cevent.SetId(event.GetId());
01707     cevent.SetInt(event.GetPosition());
01708     OnNetPanelChange(cevent);
01709 }
01710 
01711 void OpenDialog::OnNetPanelChange( wxCommandEvent& event )
01712 {
01713     if( event.GetId() >= NetPort1_Event && event.GetId() <= NetPort3_Event )
01714     {
01715         i_net_ports[event.GetId() - NetPort1_Event] = event.GetInt();
01716     }
01717 
01718     UpdateMRL( NET_ACCESS );
01719 }
01720 
01721 void OpenDialog::OnNetTypeChange( wxCommandEvent& event )
01722 {
01723     int i;
01724 
01725     i_net_type = event.GetId() - NetRadio1_Event;
01726 
01727     for(i=0; i<4; i++)
01728     {
01729         net_radios[i]->SetValue( event.GetId() == (NetRadio1_Event+i) );
01730         net_subpanels[i]->Enable( event.GetId() == (NetRadio1_Event+i) );
01731     }
01732     /* UDP Unicast or multicast -> timeshift */
01733     if( i_net_type == 0 || i_net_type == 1 )
01734         net_timeshift->Enable();
01735     else
01736         net_timeshift->Disable();
01737 
01738     UpdateMRL( NET_ACCESS );
01739 }
01740 
01741 /*****************************************************************************
01742  * Subtitles file event methods.
01743  *****************************************************************************/
01744 void OpenDialog::OnSubsFileEnable( wxCommandEvent& event )
01745 {
01746     subsfile_button->Enable( event.GetInt() != 0 );
01747 }
01748 
01749 void OpenDialog::OnSubsFileSettings( wxCommandEvent& WXUNUSED(event) )
01750 {
01751     /* Show/hide the open dialog */
01752     if( subsfile_dialog == NULL )
01753         subsfile_dialog = new SubsFileDialog( p_intf, this );
01754 
01755     if( subsfile_dialog && subsfile_dialog->ShowModal() == wxID_OK )
01756     {
01757         subsfile_mrl.Empty();
01758         subsfile_mrl.Add( wxString(wxT("sub-file=")) +
01759                           subsfile_dialog->file_combo->GetValue() );
01760         if( subsfile_dialog->encoding_combo )
01761         {
01762             subsfile_mrl.Add( wxString(wxT("subsdec-encoding=")) +
01763                               subsfile_dialog->encoding_combo->GetValue() );
01764         }
01765         if( subsfile_dialog->align_combo )
01766         {
01767             subsfile_mrl.Add( wxString::Format(wxT("subsdec-align=%i"),
01768                               (int)subsfile_dialog->align_combo->GetClientData(
01769                               subsfile_dialog->align_combo->GetSelection()) ) );
01770         }
01771         if( subsfile_dialog->size_combo )
01772         {
01773             subsfile_mrl.Add( wxString::Format( wxT("freetype-rel-fontsize=%i"),
01774                               (int)subsfile_dialog->size_combo->GetClientData(
01775                               subsfile_dialog->size_combo->GetSelection()) ) );
01776         }
01777         subsfile_mrl.Add( wxString::Format( wxT("sub-fps=%i"),
01778                           subsfile_dialog->fps_spinctrl->GetValue() ) );
01779         subsfile_mrl.Add( wxString::Format( wxT("sub-delay=%i"),
01780                           subsfile_dialog->delay_spinctrl->GetValue() ) );
01781     }
01782 }
01783 
01784 /*****************************************************************************
01785  * Stream output event methods.
01786  *****************************************************************************/
01787 void OpenDialog::OnSoutEnable( wxCommandEvent& event )
01788 {
01789     sout_button->Enable( event.GetInt() != 0 );
01790 }
01791 
01792 void OpenDialog::OnSoutSettings( wxCommandEvent& WXUNUSED(event) )
01793 {
01794     /* Show/hide the open dialog */
01795     if( sout_dialog == NULL )
01796         sout_dialog = new SoutDialog( p_intf, this );
01797 
01798     if( sout_dialog && sout_dialog->ShowModal() == wxID_OK )
01799     {
01800         sout_mrl = sout_dialog->GetOptions();
01801     }
01802 }
01803 
01804 /*****************************************************************************
01805  * Caching event methods.
01806  *****************************************************************************/
01807 void OpenDialog::OnCachingEnable( wxCommandEvent& event )
01808 {
01809     caching_value->Enable( event.GetInt() != 0 );
01810     i_caching = caching_value->GetValue();
01811     UpdateMRL();
01812 }
01813 
01814 void OpenDialog::OnCachingChangeSpin( wxSpinEvent& event )
01815 {
01816     wxCommandEvent cevent;
01817     OnCachingChange(cevent);
01818 }
01819 
01820 void OpenDialog::OnCachingChange( wxCommandEvent& event )
01821 {
01822     i_caching = event.GetInt();
01823     UpdateMRL();
01824 }
01825 
01826 /*****************************************************************************
01827  * Utility functions.
01828  *****************************************************************************/
01829 wxArrayString SeparateEntries( wxString entries )
01830 {
01831     vlc_bool_t b_quotes_mode = VLC_FALSE;
01832 
01833     wxArrayString entries_array;
01834     wxString entry;
01835 
01836     wxStringTokenizer token( entries, wxT(" \t\r\n\""), wxTOKEN_RET_DELIMS );
01837 
01838     while( token.HasMoreTokens() )
01839     {
01840         entry += token.GetNextToken();
01841 
01842         if( entry.IsEmpty() ) continue;
01843 
01844         if( !b_quotes_mode && entry.Last() == wxT('\"') )
01845         {
01846             /* Enters quotes mode */
01847             entry.RemoveLast();
01848             b_quotes_mode = VLC_TRUE;
01849         }
01850         else if( b_quotes_mode && entry.Last() == wxT('\"') )
01851         {
01852             /* Finished the quotes mode */
01853             entry.RemoveLast();
01854             b_quotes_mode = VLC_FALSE;
01855         }
01856         else if( !b_quotes_mode && entry.Last() != wxT('\"') )
01857         {
01858             /* we found a non-quoted standalone string */
01859             if( token.HasMoreTokens() ||
01860                 entry.Last() == wxT(' ') || entry.Last() == wxT('\t') ||
01861                 entry.Last() == wxT('\r') || entry.Last() == wxT('\n') )
01862                 entry.RemoveLast();
01863             if( !entry.IsEmpty() ) entries_array.Add( entry );
01864             entry.Empty();
01865         }
01866         else
01867         {;}
01868     }
01869 
01870     if( !entry.IsEmpty() ) entries_array.Add( entry );
01871 
01872     return entries_array;
01873 }

Generated on Tue Dec 20 10:14:45 2005 for vlc-0.8.4a by  doxygen 1.4.2