Changeset 5dc722b5545a43b46db156ab1031da89c512e4ab

Show
Ignore:
Timestamp:
11/01/04 01:45:06 (5 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1073781906 +0000
git-parent:

[0bbccbb10fc81f28af8ff7ccb8a402e03a5119c2]

git-author:
Clément Stenac <zorglub@videolan.org> 1073781906 +0000
Message:

* configure.ac : Added new folders

* New playlist import/export system:

-export plugin in misc/playlist (contains one module for each file type)
-open plugin = special demuxer2, that can be opened from the command

line or the graphical interface.

NB: the demuxer "playlist" is forced to earn speed, but this does not
work yet, as we have a demux2

* modules/gui/wxwindows: use the new import/export.

* src/playlist/group.c : fixed boundary check

* src/playlist/item-ext.c: correctly reset stuff when clearing the playlist

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • configure.ac

    r88066e9 r5dc722b  
    11dnl Autoconf settings for vlc 
    2 dnl $Id: configure.ac,v 1.148 2004/01/09 18:32:03 gbazin Exp $ 
     2dnl $Id: configure.ac,v 1.149 2004/01/11 00:45:06 zorglub Exp $ 
    33 
    44AC_INIT(vlc,0.7.1-cvs) 
     
    35873587  modules/demux/mp4/Makefile 
    35883588  modules/demux/mpeg/Makefile 
     3589  modules/demux/playlist/Makefile 
    35893590  modules/demux/util/Makefile 
    35903591  modules/gui/Makefile 
     
    36073608  modules/misc/network/Makefile 
    36083609  modules/misc/testsuite/Makefile 
     3610  modules/misc/playlist/Makefile 
    36093611  modules/mux/Makefile 
    36103612  modules/mux/mpeg/Makefile 
  • include/vlc_common.h

    r88066e9 r5dc722b  
    44 ***************************************************************************** 
    55 * Copyright (C) 1998, 1999, 2000 VideoLAN 
    6  * $Id: vlc_common.h,v 1.101 2004/01/09 18:32:03 gbazin Exp $ 
     6 * $Id: vlc_common.h,v 1.102 2004/01/11 00:45:06 zorglub Exp $ 
    77 * 
    88 * Authors: Samuel Hocevar <sam@via.ecp.fr> 
     
    193193typedef struct item_info_t item_info_t; 
    194194typedef struct item_info_category_t item_info_category_t; 
     195typedef struct playlist_export_t playlist_export_t; 
    195196 
    196197/* Modules */ 
  • include/vlc_playlist.h

    r7678195 r5dc722b  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2004 VideoLAN 
    5  * $Id: vlc_playlist.h,v 1.23 2004/01/10 14:24:33 hartman Exp $ 
     5 * $Id: vlc_playlist.h,v 1.24 2004/01/11 00:45:06 zorglub Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    5555    int i_infos;                /**< Number of infos in the category */ 
    5656    item_info_t **pp_infos;     /**< Pointer to an array of infos */ 
     57}; 
     58 
     59/** 
     60 * playlist export helper structure 
     61 */ 
     62struct playlist_export_t 
     63{ 
     64    char *psz_filename; 
     65    FILE *p_file; 
    5766}; 
    5867 
     
    210219 
    211220/* Load/Save */ 
    212 VLC_EXPORT( int,  playlist_LoadFile, ( playlist_t *, const char * ) ); 
    213 VLC_EXPORT( int,  playlist_SaveFile, ( playlist_t *, const char * ) ); 
     221VLC_EXPORT( int,  playlist_Import, ( playlist_t *, const char * ) ); 
     222VLC_EXPORT( int,  playlist_Export, ( playlist_t *, const char *, const char * ) ); 
    214223 
    215224/** 
  • modules/gui/wxwindows/playlist.cpp

    r0ce68cc r5dc722b  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000-2004 VideoLAN 
    5  * $Id: playlist.cpp,v 1.35 2004/01/10 03:36:03 hartman Exp $ 
     5 * $Id: playlist.cpp,v 1.36 2004/01/11 00:45:06 zorglub Exp $ 
    66 * 
    77 * Authors: Olivier Teuli� <ipkiss@via.ecp.fr> 
     
    8787 
    8888    /* controls */ 
    89     ListView_Event 
     89    ListView_Event, 
     90 
     91    Browse_Event,  /* For export playlist */ 
    9092}; 
    9193 
     
    153155    EVT_BUTTON( wxID_OK, NewGroup::OnOk) 
    154156    EVT_BUTTON( wxID_CANCEL, NewGroup::OnCancel) 
     157END_EVENT_TABLE() 
     158 
     159 
     160/* Event Table for the ExportPlaylist class */ 
     161BEGIN_EVENT_TABLE(ExportPlaylist, wxDialog) 
     162    EVT_BUTTON( wxID_OK, ExportPlaylist::OnOk) 
     163    EVT_BUTTON( wxID_CANCEL, ExportPlaylist::OnCancel) 
     164    EVT_BUTTON( Browse_Event, ExportPlaylist::OnBrowse) 
    155165END_EVENT_TABLE() 
    156166 
     
    409419        return; 
    410420    } 
    411     if( i < 0 || i > p_playlist->i_size
     421    if( i < 0 || i >= p_playlist->i_size || !p_playlist->pp_items[i]
    412422    { 
    413423        vlc_object_release(p_playlist); 
     
    416426    listview->SetItem( i, 0, wxL2U(p_playlist->pp_items[i]->psz_name) ); 
    417427    listview->SetItem( i, 1, wxL2U( playlist_GetInfo( p_playlist, i, 
    418                                        "General" , "Author" ) ) ); 
     428                                       _("General") , _("Author") ) ) ); 
     429    char *psz_group = playlist_FindGroup(p_playlist,p_playlist-> 
     430                                    pp_items[i]->i_group); 
    419431    listview->SetItem( i, 2, 
    420              wxL2U(playlist_FindGroup(p_playlist,p_playlist-> 
    421                                     pp_items[i]->i_group) ) ); 
     432             wxL2U( psz_group ? psz_group : _("Normal") ) ); 
    422433 
    423434    if( p_playlist->pp_items[i]->b_enabled == VLC_FALSE ) 
     
    578589void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) ) 
    579590{ 
    580     playlist_t *p_playlist = 
    581         (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
    582                                        FIND_ANYWHERE ); 
    583     if( p_playlist == NULL ) 
    584     { 
    585         return; 
    586     } 
    587  
    588     wxFileDialog dialog( this, wxU(_("Save playlist")), 
    589                          wxT(""), wxT(""), wxT("*"), wxSAVE ); 
    590  
    591     if( dialog.ShowModal() == wxID_OK ) 
    592     { 
    593         playlist_SaveFile( p_playlist, dialog.GetPath().mb_str() ); 
    594     } 
    595  
    596     vlc_object_release( p_playlist ); 
     591    ExportPlaylist *exp_pl = new ExportPlaylist( p_intf, this); 
     592    exp_pl->ShowModal(); 
     593    delete exp_pl; 
    597594} 
    598595 
     
    612609    if( dialog.ShowModal() == wxID_OK ) 
    613610    { 
    614         playlist_LoadFile( p_playlist, dialog.GetPath().mb_str() ); 
     611        playlist_Import( p_playlist, dialog.GetPath().mb_str() ); 
    615612    } 
    616613 
     
    11541151 
    11551152/*************************************************************************** 
    1156  * NewGroup 
     1153 * NewGroup Class 
    11571154 ***************************************************************************/ 
    11581155NewGroup::NewGroup( intf_thread_t *_p_intf, wxWindow *_p_parent ): 
     
    12191216            psz_name = NULL; 
    12201217        } 
    1221     } 
    1222  
    1223     vlc_object_release( p_playlist ); 
     1218        vlc_object_release( p_playlist ); 
     1219    } 
     1220 
    12241221    EndModal( wxID_OK ); 
    12251222} 
     
    12291226    EndModal( wxID_CANCEL ); 
    12301227} 
     1228 
     1229 
     1230 
     1231/*************************************************************************** 
     1232 * Export playlist class 
     1233 ***************************************************************************/ 
     1234ExportPlaylist::ExportPlaylist( intf_thread_t *_p_intf, wxWindow *_p_parent ): 
     1235    wxDialog( _p_parent, -1, wxU(_("Export playlist")), wxDefaultPosition, 
     1236             wxDefaultSize, wxDEFAULT_FRAME_STYLE ) 
     1237{ 
     1238    vlc_list_t *p_list; 
     1239    module_t *p_module; 
     1240 
     1241    /* Initializations */ 
     1242    p_intf = _p_intf; 
     1243    SetIcon( *p_intf->p_sys->p_icon ); 
     1244 
     1245    /* Create a panel to put everything in*/ 
     1246    wxPanel *panel = new wxPanel( this, -1 ); 
     1247    panel->SetAutoLayout( TRUE ); 
     1248 
     1249    /* Create the file box */ 
     1250    wxStaticBox *file_box = new wxStaticBox( panel, -1, 
     1251                                             wxU(_("File to save to")) ); 
     1252    wxStaticBoxSizer *file_sizer = new wxStaticBoxSizer( file_box, 
     1253                                                        wxHORIZONTAL ); 
     1254 
     1255    file_text = new wxTextCtrl(panel, -1, wxU(""),wxDefaultPosition, 
     1256                               wxSize(250,-1),wxTE_PROCESS_ENTER); 
     1257 
     1258    file_text->SetToolTip( wxU(_("Enter the name of the file to export " 
     1259                                 "the playlist to.")) ); 
     1260 
     1261    wxButton *file_button = new wxButton( panel, Browse_Event, 
     1262                                          wxU(_("Browse")) ); 
     1263 
     1264    file_sizer->Add( file_text, 0, wxALL | wxALIGN_CENTER , 5 ); 
     1265    file_sizer->Add( file_button, 0, wxALL | wxALIGN_CENTER , 5 ); 
     1266 
     1267    /* Create the type box */ 
     1268    wxStaticBox *type_box = new wxStaticBox( panel, -1, 
     1269                                             wxU(_("Select export type")) ); 
     1270 
     1271    wxStaticBoxSizer *type_sizer = new wxStaticBoxSizer( type_box, 
     1272                                                        wxHORIZONTAL ); 
     1273 
     1274    type_combo = new wxComboBox( panel, -1, wxT(""), wxDefaultPosition, 
     1275                                 wxSize(250, -1), 0, NULL ); 
     1276 
     1277    type_sizer->Add( type_combo, 0, wxALL | wxALIGN_CENTER, 5 ); 
     1278    type_sizer->Layout(); 
     1279 
     1280 
     1281 
     1282    wxButton *ok_button = new wxButton(panel, wxID_OK, wxU(_("OK")) ); 
     1283    ok_button->SetDefault(); 
     1284    wxButton *cancel_button = new wxButton( panel, wxID_CANCEL, 
     1285                                            wxU(_("Cancel")) ); 
     1286 
     1287    wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL ); 
     1288 
     1289    button_sizer->Add( ok_button, 0, wxALL, 5 ); 
     1290    button_sizer->Add( cancel_button, 0, wxALL, 5 ); 
     1291    button_sizer->Layout(); 
     1292 
     1293    wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL ); 
     1294    panel_sizer->Add( file_sizer, 0, wxEXPAND | wxALL, 5 ); 
     1295    panel_sizer->Add( type_sizer, 0, wxEXPAND | wxALL, 5 ); 
     1296    panel_sizer->Add( button_sizer, 0, wxEXPAND | wxALL, 5 ); 
     1297    panel_sizer->Layout(); 
     1298 
     1299    panel->SetSizerAndFit( panel_sizer ); 
     1300 
     1301    wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL ); 
     1302    main_sizer->Add( panel, 1, wxEXPAND, 0 ); 
     1303    main_sizer->Layout(); 
     1304    SetSizerAndFit( main_sizer ); 
     1305 
     1306    /* build a list of available modules */ 
     1307    p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE ); 
     1308    for( int i_index = 0; i_index < p_list->i_count; i_index++ ) 
     1309    { 
     1310        p_module = (module_t *)p_list->p_values[i_index].p_object ; 
     1311        if( !strcmp( p_module->psz_capability, "playlist export" ) ) 
     1312        { 
     1313            type_combo->Append( wxU(p_module->psz_longname), 
     1314                                p_module->pp_shortcuts[1] ? 
     1315                                p_module->pp_shortcuts[1] : 
     1316                                p_module->psz_object_name ); 
     1317        } 
     1318    } 
     1319    vlc_list_release( p_list ); 
     1320} 
     1321 
     1322 
     1323ExportPlaylist::~ExportPlaylist() 
     1324{ 
     1325} 
     1326 
     1327void ExportPlaylist::OnOk( wxCommandEvent& WXUNUSED(event) ) 
     1328{ 
     1329    playlist_t * p_playlist = 
     1330          (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, 
     1331                                       FIND_ANYWHERE ); 
     1332 
     1333    if( p_playlist ) 
     1334    { 
     1335        char *psz_type = (char *)type_combo->GetClientData( 
     1336                                             type_combo->GetSelection() ); 
     1337        if( file_text->GetValue().mb_str() && psz_type ) 
     1338        { 
     1339            playlist_Export( p_playlist, file_text->GetValue().mb_str(), 
     1340                             psz_type ); 
     1341        } 
     1342    } 
     1343 
     1344    vlc_object_release( p_playlist ); 
     1345    EndModal( wxID_OK ); 
     1346} 
     1347 
     1348void ExportPlaylist::OnCancel( wxCommandEvent& WXUNUSED(event) ) 
     1349{ 
     1350    EndModal( wxID_CANCEL ); 
     1351} 
     1352 
     1353void ExportPlaylist::OnBrowse( wxCommandEvent& WXUNUSED(event) ) 
     1354{ 
     1355    wxFileDialog dialog( this, wxU(_("Save playlist")), 
     1356                         wxT(""), wxT(""), wxT("*"), wxSAVE ); 
     1357 
     1358    if( dialog.ShowModal() == wxID_OK ) 
     1359    { 
     1360        file_text->SetValue( dialog.GetPath() ); 
     1361    } 
     1362} 
  • modules/gui/wxwindows/preferences.cpp

    r4219568 r5dc722b  
    33 ***************************************************************************** 
    44 * Copyright (C) 2000-2001 VideoLAN 
    5  * $Id: preferences.cpp,v 1.44 2003/12/22 02:24:52 sam Exp $ 
     5 * $Id: preferences.cpp,v 1.45 2004/01/11 00:45:06 zorglub Exp $ 
    66 * 
    77 * Authors: Gildas Bazin <gbazin@netcourrier.com> 
     
    329329        return i_type == 1 ? VIDEO_FILTER_TITLE : VIDEO_FILTER_HELP; 
    330330 
    331     return ""; 
     331    return " "; 
    332332} 
    333333 
  • modules/gui/wxwindows/wxwindows.h

    r1595dc2 r5dc722b  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999, 2000 VideoLAN 
    5  * $Id: wxwindows.h,v 1.83 2004/01/05 13:00:39 zorglub Exp $ 
     5 * $Id: wxwindows.h,v 1.84 2004/01/11 00:45:06 zorglub Exp $ 
    66 * 
    77 * Authors: Gildas Bazin <gbazin@netcourrier.com> 
     
    741741class ItemInfoDialog; 
    742742class NewGroup; 
     743class ExportPlaylist; 
    743744class Playlist: public wxFrame 
    744745{ 
     
    842843}; 
    843844 
     845class ExportPlaylist: public wxDialog 
     846{ 
     847public: 
     848    /* Constructor */ 
     849    ExportPlaylist(intf_thread_t *p_intf, wxWindow *p_parent ); 
     850    virtual ~ExportPlaylist(); 
     851 
     852private: 
     853    /* Event handlers (these functions should _not_ be virtual) */ 
     854    void OnOk( wxCommandEvent& event ); 
     855    void OnCancel( wxCommandEvent& event ); 
     856    void OnBrowse( wxCommandEvent& event ); 
     857 
     858    DECLARE_EVENT_TABLE(); 
     859    intf_thread_t *p_intf; 
     860    wxTextCtrl *file_text; 
     861    wxComboBox *type_combo; 
     862}; 
    844863 
    845864/* ItemInfo Dialog */ 
  • src/playlist/group.c

    r982c016 r5dc722b  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2004 VideoLAN 
    5  * $Id: group.c,v 1.6 2004/01/06 08:50:20 zorglub Exp $ 
     5 * $Id: group.c,v 1.7 2004/01/11 00:45:06 zorglub Exp $ 
    66 * 
    77 * Authors: Cl�nt Stenac <zorglub@videolan.org> 
     
    120120{ 
    121121    int i; 
    122     for( i=0 ; i<= p_playlist->i_groups; i++ ) 
     122    for( i=0 ; i< p_playlist->i_groups; i++ ) 
    123123    { 
    124124        if( p_playlist->pp_groups[i]->i_id == i_id ) 
  • src/playlist/item-ext.c

    r7678195 r5dc722b  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2004 VideoLAN 
    5  * $Id: item-ext.c,v 1.7 2004/01/10 14:24:33 hartman Exp $ 
     5 * $Id: item-ext.c,v 1.8 2004/01/11 00:45:06 zorglub Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    388388        playlist_Delete( p_playlist, 0 ); 
    389389    } 
     390 
     391    p_playlist->i_index = -1; 
     392    p_playlist->i_size = 0; 
     393    p_playlist->pp_items = NULL; 
     394 
     395    p_playlist->i_groups = 0; 
     396    p_playlist->pp_groups = NULL; 
     397 
    390398    return 0; 
    391399} 
  • src/playlist/loadsave.c

    r982c016 r5dc722b  
    33 ***************************************************************************** 
    44 * Copyright (C) 1999-2004 VideoLAN 
    5  * $Id: loadsave.c,v 1.3 2004/01/06 08:50:20 zorglub Exp $ 
     5 * $Id: loadsave.c,v 1.4 2004/01/11 00:45:06 zorglub Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    3434#include "vlc_playlist.h" 
    3535 
    36 #define PLAYLIST_FILE_HEADER_0_5  "# vlc playlist file version 0.5" 
    37 #define PLAYLIST_FILE_HEADER_0_6  "# vlc playlist file version 0.6" 
     36#define PLAYLIST_FILE_HEADER  "# vlc playlist file version 0.5" 
    3837 
    3938 
    4039/***************************************************************************** 
    41  * playlist_LoadFile: load a playlist file. 
     40 * playlist_Import: load a playlist file. 
    4241 ****************************************************************************/ 
    43 int playlist_LoadFile( playlist_t * p_playlist, const char *psz_filename ) 
     42int playlist_Import( playlist_t * p_playlist, const char *psz_filename ) 
    4443{ 
    45     FILE *file; 
    46     char line[1024]; 
    47     int i_current_status; 
    48     int i_format; 
    49     int i; 
     44    playlist_item_t *p_item; 
     45    char *psz_uri; 
     46    int i_id; 
    5047 
    51     msg_Dbg( p_playlist, "opening playlist file %s", psz_filename ); 
     48    msg_Dbg( p_playlist, "clearing playlist"); 
    5249 
    53     file = fopen( psz_filename, "rt" ); 
    54     if( !file ) 
     50    /* Create our "fake" playlist item */ 
     51    playlist_Clear( p_playlist ); 
     52 
     53 
     54    psz_uri = (char *)malloc(sizeof(char)*strlen(psz_filename) + 17 ); 
     55    sprintf( psz_uri, "file/playlist://%s", psz_filename); 
     56 
     57    i_id = playlist_Add( p_playlist, psz_uri, psz_uri, 
     58                  PLAYLIST_INSERT | PLAYLIST_GO , PLAYLIST_END); 
     59 
     60    p_item = playlist_GetItemById( p_playlist, i_id ); 
     61    p_item->b_autodeletion = VLC_TRUE; 
     62 
     63    //p_playlist->i_index = 0; 
     64 
     65/* 
     66 *     if( p_item ) 
    5567    { 
    56         msg_Err( p_playlist, "playlist file %s does not exist", psz_filename ); 
    57         return -1; 
     68        p_playlist->p_input = input_CreateThread( p_playlist, p_item ); 
    5869    } 
    59     fseek( file, 0L, SEEK_SET ); 
     70    */ 
    6071 
    61     /* check the file is not empty */ 
    62     if ( ! fgets( line, 1024, file ) ) 
    63     { 
    64         msg_Err( p_playlist, "playlist file %s is empty", psz_filename ); 
    65         fclose( file ); 
    66         return -1; 
    67     } 
    68  
    69     /* get rid of line feed */ 
    70     if( line[strlen(line)-1] == '\n' || line[strlen(line)-1] == '\r' ) 
    71     { 
    72        line[strlen(line)-1] = (char)0; 
    73        if( line[strlen(line)-1] == '\r' ) line[strlen(line)-1] = (char)0; 
    74     } 
    75     /* check the file format is valid */ 
    76     if ( !strcmp ( line , PLAYLIST_FILE_HEADER_0_5 ) ) 
    77     { 
    78        i_format = 5; 
    79     } 
    80     else if( !strcmp ( line , PLAYLIST_FILE_HEADER_0_6 ) ) 
    81     { 
    82        i_format = 6; 
    83     } 
    84     else 
    85     { 
    86         msg_Err( p_playlist, "playlist file %s format is unsupported" 
    87                 , psz_filename ); 
    88         fclose( file ); 
    89         return -1; 
    90     } 
    91  
    92     /* stop playing */ 
    93     i_current_status = p_playlist->i_status; 
    94     if ( p_playlist->i_status != PLAYLIST_STOPPED ) 
    95     { 
    96         playlist_Stop ( p_playlist ); 
    97     } 
    98  
    99     /* delete current content of the playlist */ 
    100     for( i = p_playlist->i_size - 1; i >= 0; i-- ) 
    101     { 
    102         playlist_Delete ( p_playlist , i ); 
    103     } 
    104  
    105     /* simply add each line */ 
    106     while( fgets( line, 1024, file ) ) 
    107     { 
    108        /* ignore comments or empty lines */ 
    109        if( (line[0] == '#') || (line[0] == '\r') || (line[0] == '\n') 
    110                || (line[0] == (char)0) ) 
    111            continue; 
    112  
    113        /* get rid of line feed */ 
    114        if( line[strlen(line)-1] == '\n' || line[strlen(line)-1] == '\r' ) 
    115        { 
    116            line[strlen(line)-1] = (char)0; 
    117            if( line[strlen(line)-1] == '\r' ) line[strlen(line)-1] = (char)0; 
    118        } 
    119        if( i_format == 5 ) 
    120        { 
    121            playlist_Add ( p_playlist , (char *)&line , (char *)&line, 
    122                          PLAYLIST_APPEND , PLAYLIST_END ); 
    123        } 
    124        else 
    125        { 
    126            msg_Warn( p_playlist, "Not supported yet"); 
    127        } 
    128     } 
    129  
    130     /* start playing */ 
    131     if ( i_current_status != PLAYLIST_STOPPED ) 
    132     { 
    133         playlist_Play ( p_playlist ); 
    134     } 
    135  
    136     fclose( file ); 
    137  
    138     return 0; 
     72    return VLC_SUCCESS; 
    13973} 
    14074 
     
    14276 * playlist_SaveFile: Save a playlist in a file. 
    14377 *****************************************************************************/ 
    144 int playlist_SaveFile( playlist_t * p_playlist, const char * psz_filename ) 
     78int playlist_Export( playlist_t * p_playlist, const char *psz_filename , 
     79                     const char *psz_type) 
    14580{ 
    146     FILE *file; 
    147     int i; 
     81    extern int errno; 
     82    module_t *p_module; 
     83    playlist_export_t *p_export; 
    14884 
     85    msg_Info( p_playlist, "Saving playlist to file %s", psz_filename ); 
     86 
     87    /* Prepare the playlist_export_t structure */ 
     88    p_export = (playlist_export_t *)malloc( sizeof(playlist_export_t) ); 
     89    if( !p_export) 
     90    { 
     91        msg_Err( p_playlist, "Out of memory"); 
     92        return VLC_ENOMEM; 
     93    } 
     94    p_export->p_file = fopen( psz_filename, "wt" ); 
     95    if( !p_export->p_file ) 
     96    { 
     97        msg_Err( p_playlist , "Could not create playlist file %s (%s)" 
     98                , psz_filename, strerror(errno) ); 
     99        return -1; 
     100    } 
     101 
     102    p_playlist->p_private = (void *)p_export; 
     103    /* Lock the playlist */ 
    149104    vlc_mutex_lock( &p_playlist->object_lock ); 
    150105 
    151     msg_Dbg( p_playlist, "saving playlist file %s", psz_filename ); 
     106    /* And call the module ! All work is done now */ 
     107    p_module = module_Need( p_playlist, "playlist export",  psz_type); 
     108    if( !p_module ) 
     109    { 
     110        msg_Warn( p_playlist, "Failed to export playlist" ); 
     111        vlc_mutex_unlock( &p_playlist->object_lock ); 
     112        return VLC_ENOOBJ; 
     113    } 
     114    module_Unneed( p_playlist , p_module ); 
    152115 
    153     file = fopen( psz_filename, "wt" ); 
    154     if( !file ) 
    155     { 
    156         msg_Err( p_playlist , "could not create playlist file %s" 
    157                 , psz_filename ); 
    158         return -1; 
    159     } 
    160     /* Save is done in 0_5 mode at the moment*/ 
    161  
    162     fprintf( file , PLAYLIST_FILE_HEADER_0_5 "\n" ); 
    163  
    164     for ( i = 0 ; i < p_playlist->i_size ; i++ ) 
    165     { 
    166         fprintf( file , p_playlist->pp_items[i]->psz_uri ); 
    167         fprintf( file , "\n" ); 
    168     } 
    169 #if 0 
    170     fprintf( file, PLAYLIST_FILE_HEADER_0_6 "\n" ); 
    171  
    172     for ( i=0 ; i< p_playlist->i_size ; i++ ) 
    173     { 
    174         fprintf( file, p_playlist->pp_items[i]->psz_uri ); 
    175         fprintf( file, "||" ); 
    176         fprintf( file, p_playlist->pp_items[i]->psz_name ); 
    177         fprintf( file, "||" ); 
    178         fprintf( file, "%i",p_playlist->pp_items[i]->b_enabled = VLC_TRUE ? 
    179                        1:0 ); 
    180         fprintf( file, "||" ); 
    181         fprintf( file, "%i", p_playlist->pp_items[i]->i_group ); 
    182         fprintf( file, "||" ); 
    183         fprintf( file, p_playlist->pp_items[i]->psz_author ); 
    184         fprintf( file , "\n" ); 
    185     } 
    186 #endif 
    187     fclose( file ); 
     116    fclose( p_export->p_file ); 
    188117 
    189118    vlc_mutex_unlock( &p_playlist->object_lock ); 
    190119 
    191     return 0
     120    return VLC_SUCCESS
    192121}