]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs_provider.cpp
Qt: fix a forgotten deletion
[vlc] / modules / gui / qt4 / dialogs_provider.cpp
1 /*****************************************************************************
2  * dialogs_provider.cpp : Dialog Provider
3  *****************************************************************************
4  * Copyright (C) 2006-2009 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include <vlc_intf_strings.h>
30
31 #include "qt4.hpp"
32 #include "dialogs_provider.hpp"
33 #include "input_manager.hpp" /* Load Subtitles */
34 #include "menus.hpp"
35 #include "recents.hpp"
36 #include "util/qt_dirs.hpp"
37
38 /* The dialogs */
39 #include "dialogs/playlist.hpp"
40 #include "dialogs/bookmarks.hpp"
41 #include "dialogs/preferences.hpp"
42 #include "dialogs/mediainfo.hpp"
43 #include "dialogs/messages.hpp"
44 #include "dialogs/extended.hpp"
45 #include "dialogs/vlm.hpp"
46 #include "dialogs/sout.hpp"
47 #include "dialogs/convert.hpp"
48 #include "dialogs/open.hpp"
49 #include "dialogs/openurl.hpp"
50 #include "dialogs/help.hpp"
51 #include "dialogs/gototime.hpp"
52 #include "dialogs/podcast_configuration.hpp"
53 #include "dialogs/toolbar.hpp"
54 #include "dialogs/plugins.hpp"
55 #include "dialogs/external.hpp"
56 #include "dialogs/errors.hpp"
57 #include "dialogs/epg.hpp"
58
59 #include <QEvent>
60 #include <QApplication>
61 #include <QSignalMapper>
62 #include <QFileDialog>
63
64
65 DialogsProvider* DialogsProvider::instance = NULL;
66
67 DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
68                                   QObject( NULL ), p_intf( _p_intf )
69 {
70     b_isDying = false;
71
72     /* Various signal mappers for the menus */
73     menusMapper = new QSignalMapper();
74     CONNECT( menusMapper, mapped(QObject *), this, menuAction( QObject *) );
75
76     menusUpdateMapper = new QSignalMapper();
77     CONNECT( menusUpdateMapper, mapped(QObject *),
78              this, menuUpdateAction( QObject *) );
79
80     SDMapper = new QSignalMapper();
81     CONNECT( SDMapper, mapped (QString), this, SDMenuAction( QString ) );
82
83     new DialogHandler (p_intf, this );
84 }
85
86 DialogsProvider::~DialogsProvider()
87 {
88     PlaylistDialog::killInstance();
89     MediaInfoDialog::killInstance();
90     MessagesDialog::killInstance();
91     ExtendedDialog::killInstance();
92     BookmarksDialog::killInstance();
93     HelpDialog::killInstance();
94 #ifdef UPDATE_CHECK
95     UpdateDialog::killInstance();
96 #endif
97     PluginDialog::killInstance();
98
99     delete menusMapper;
100     delete menusUpdateMapper;
101     delete SDMapper;
102 }
103
104 void DialogsProvider::quit()
105 {
106     b_isDying = true;
107     libvlc_Quit( p_intf->p_libvlc );
108 }
109
110 void DialogsProvider::customEvent( QEvent *event )
111 {
112     if( event->type() == (int)DialogEvent_Type )
113     {
114         DialogEvent *de = static_cast<DialogEvent*>(event);
115         switch( de->i_dialog )
116         {
117         case INTF_DIALOG_FILE_SIMPLE:
118         case INTF_DIALOG_FILE:
119             openDialog(); break;
120         case INTF_DIALOG_FILE_GENERIC:
121             openFileGenericDialog( de->p_arg ); break;
122         case INTF_DIALOG_DISC:
123             openDiscDialog(); break;
124         case INTF_DIALOG_NET:
125             openNetDialog(); break;
126         case INTF_DIALOG_SAT:
127         case INTF_DIALOG_CAPTURE:
128             openCaptureDialog(); break;
129         case INTF_DIALOG_DIRECTORY:
130             PLAppendDir(); break;
131         case INTF_DIALOG_PLAYLIST:
132             playlistDialog(); break;
133         case INTF_DIALOG_MESSAGES:
134             messagesDialog(); break;
135         case INTF_DIALOG_FILEINFO:
136            mediaInfoDialog(); break;
137         case INTF_DIALOG_PREFS:
138            prefsDialog(); break;
139         case INTF_DIALOG_BOOKMARKS:
140            bookmarksDialog(); break;
141         case INTF_DIALOG_EXTENDED:
142            extendedDialog(); break;
143 #ifdef ENABLE_VLM
144         case INTF_DIALOG_VLM:
145            vlmDialog(); break;
146 #endif
147         case INTF_DIALOG_POPUPMENU:
148            QVLCMenu::PopupMenu( p_intf, (de->i_arg != 0) ); break;
149         case INTF_DIALOG_AUDIOPOPUPMENU:
150            QVLCMenu::AudioPopupMenu( p_intf ); break;
151         case INTF_DIALOG_VIDEOPOPUPMENU:
152            QVLCMenu::VideoPopupMenu( p_intf ); break;
153         case INTF_DIALOG_MISCPOPUPMENU:
154            QVLCMenu::MiscPopupMenu( p_intf ); break;
155         case INTF_DIALOG_WIZARD:
156         case INTF_DIALOG_STREAMWIZARD:
157             openAndStreamingDialogs(); break;
158 #ifdef UPDATE_CHECK
159         case INTF_DIALOG_UPDATEVLC:
160             updateDialog(); break;
161 #endif
162         case INTF_DIALOG_EXIT:
163             quit(); break;
164         default:
165            msg_Warn( p_intf, "unimplemented dialog" );
166         }
167     }
168 }
169
170 /****************************************************************************
171  * Individual simple dialogs
172  ****************************************************************************/
173 void DialogsProvider::playlistDialog()
174 {
175     PlaylistDialog::getInstance( p_intf )->toggleVisible();
176 }
177
178 void DialogsProvider::prefsDialog()
179 {
180     PrefsDialog *p = new PrefsDialog( (QWidget *)p_intf->p_sys->p_mi, p_intf );
181     p->toggleVisible();
182 }
183
184 void DialogsProvider::extendedDialog()
185 {
186     if( !ExtendedDialog::getInstance( p_intf )->isVisible() || /* Hidden */
187         ExtendedDialog::getInstance( p_intf )->currentTab() != 0 )  /* wrong tab */
188         ExtendedDialog::getInstance( p_intf )->showTab( 0 );
189     else
190         ExtendedDialog::getInstance( p_intf )->hide();
191 }
192
193 void DialogsProvider::synchroDialog()
194 {
195     if( !ExtendedDialog::getInstance( p_intf )->isVisible() || /* Hidden */
196         ExtendedDialog::getInstance( p_intf )->currentTab() != 2 )  /* wrong tab */
197         ExtendedDialog::getInstance( p_intf )->showTab( 2 );
198     else
199         ExtendedDialog::getInstance( p_intf )->hide();
200 }
201
202 void DialogsProvider::messagesDialog()
203 {
204     MessagesDialog::getInstance( p_intf )->toggleVisible();
205 }
206
207 void DialogsProvider::gotoTimeDialog()
208 {
209     GotoTimeDialog::getInstance( p_intf )->toggleVisible();
210 }
211
212 #ifdef ENABLE_VLM
213 void DialogsProvider::vlmDialog()
214 {
215     VLMDialog::getInstance( p_intf )->toggleVisible();
216 }
217 #endif
218
219 void DialogsProvider::helpDialog()
220 {
221     HelpDialog::getInstance( p_intf )->toggleVisible();
222 }
223
224 #ifdef UPDATE_CHECK
225 void DialogsProvider::updateDialog()
226 {
227     UpdateDialog::getInstance( p_intf )->toggleVisible();
228 }
229 #endif
230
231 void DialogsProvider::aboutDialog()
232 {
233     AboutDialog::getInstance( p_intf )->toggleVisible();
234 }
235
236 void DialogsProvider::mediaInfoDialog()
237 {
238     MediaInfoDialog::getInstance( p_intf )->showTab( 0 );
239 }
240
241 void DialogsProvider::mediaCodecDialog()
242 {
243     MediaInfoDialog::getInstance( p_intf )->showTab( 2 );
244 }
245
246 void DialogsProvider::bookmarksDialog()
247 {
248     BookmarksDialog::getInstance( p_intf )->toggleVisible();
249 }
250
251 void DialogsProvider::podcastConfigureDialog()
252 {
253     PodcastConfigDialog::getInstance( p_intf )->toggleVisible();
254 }
255
256 void DialogsProvider::toolbarDialog()
257 {
258     ToolbarEditDialog *toolbarEditor = new ToolbarEditDialog( (QWidget *)p_intf->p_sys->p_mi, p_intf );
259     if( toolbarEditor->exec() == QDialog::Accepted )
260         emit toolBarConfUpdated();
261 }
262
263 void DialogsProvider::pluginDialog()
264 {
265     PluginDialog::getInstance( p_intf )->toggleVisible();
266 }
267
268 void DialogsProvider::epgDialog()
269 {
270     EpgDialog::getInstance( p_intf )->toggleVisible();
271 }
272
273 /* Generic open file */
274 void DialogsProvider::openFileGenericDialog( intf_dialog_args_t *p_arg )
275 {
276     if( p_arg == NULL )
277     {
278         msg_Warn( p_intf, "openFileGenericDialog() called with NULL arg" );
279         return;
280     }
281
282     /* Replace the extensions to a Qt format */
283     int i = 0;
284     QString extensions = qfu( p_arg->psz_extensions );
285     while ( ( i = extensions.indexOf( "|", i ) ) != -1 )
286     {
287         if( ( extensions.count( "|" ) % 2 ) == 0 )
288             extensions.replace( i, 1, ");;" );
289         else
290             extensions.replace( i, 1, "(" );
291     }
292     extensions.replace( ";*", " *" );
293     extensions.append( ")" );
294
295     /* Save */
296     if( p_arg->b_save )
297     {
298         QString file = QFileDialog::getSaveFileName( NULL, p_arg->psz_title,
299                                         p_intf->p_sys->filepath, extensions );
300         if( !file.isEmpty() )
301         {
302             p_arg->i_results = 1;
303             p_arg->psz_results = (char **)malloc( p_arg->i_results * sizeof( char * ) );
304             p_arg->psz_results[0] = strdup( qtu( toNativeSepNoSlash( file ) ) );
305         }
306         else
307             p_arg->i_results = 0;
308     }
309     else /* non-save mode */
310     {
311         QStringList files = QFileDialog::getOpenFileNames( NULL,
312                 p_arg->psz_title, p_intf->p_sys->filepath,
313                 extensions );
314         p_arg->i_results = files.count();
315         p_arg->psz_results = (char **)malloc( p_arg->i_results * sizeof( char * ) );
316         i = 0;
317         foreach( const QString &file, files )
318             p_arg->psz_results[i++] = strdup( qtu( toNativeSepNoSlash( file ) ) );
319         if(i == 0)
320             p_intf->p_sys->filepath = QString::fromAscii("");
321         else
322             p_intf->p_sys->filepath = qfu( p_arg->psz_results[i-1] );
323     }
324
325     /* Callback */
326     if( p_arg->pf_callback )
327         p_arg->pf_callback( p_arg );
328
329     /* Clean afterwards */
330     if( p_arg->psz_results )
331     {
332         for( i = 0; i < p_arg->i_results; i++ )
333             free( p_arg->psz_results[i] );
334         free( p_arg->psz_results );
335     }
336     free( p_arg->psz_title );
337     free( p_arg->psz_extensions );
338     free( p_arg );
339 }
340 /****************************************************************************
341  * All the open/add stuff
342  * Open Dialog first - Simple Open then
343  ****************************************************************************/
344
345 void DialogsProvider::openDialog( int i_tab )
346 {
347     OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf )->showTab( i_tab );
348 }
349 void DialogsProvider::openDialog()
350 {
351     openDialog( OPEN_FILE_TAB );
352 }
353 void DialogsProvider::openFileDialog()
354 {
355     openDialog( OPEN_FILE_TAB );
356 }
357 void DialogsProvider::openDiscDialog()
358 {
359     openDialog( OPEN_DISC_TAB );
360 }
361 void DialogsProvider::openNetDialog()
362 {
363     openDialog( OPEN_NETWORK_TAB );
364 }
365 void DialogsProvider::openCaptureDialog()
366 {
367     openDialog( OPEN_CAPTURE_TAB );
368 }
369
370 /* Same as the open one, but force the enqueue */
371 void DialogsProvider::PLAppendDialog( int tab )
372 {
373     OpenDialog::getInstance( p_intf->p_sys->p_mi, p_intf, false,
374                              OPEN_AND_ENQUEUE )->showTab( tab );
375 }
376
377 void DialogsProvider::MLAppendDialog( int tab )
378 {
379     OpenDialog::getInstance( p_intf->p_sys->p_mi, p_intf, false,
380                             OPEN_AND_ENQUEUE, false, false )
381                                     ->showTab( tab );
382 }
383
384 /**
385  * Simple open
386  ***/
387 QStringList DialogsProvider::showSimpleOpen( const QString& help,
388                                              int filters,
389                                              const QString& path )
390 {
391     QString fileTypes = "";
392     if( filters & EXT_FILTER_MEDIA ) {
393         ADD_FILTER_MEDIA( fileTypes );
394     }
395     if( filters & EXT_FILTER_VIDEO ) {
396         ADD_FILTER_VIDEO( fileTypes );
397     }
398     if( filters & EXT_FILTER_AUDIO ) {
399         ADD_FILTER_AUDIO( fileTypes );
400     }
401     if( filters & EXT_FILTER_PLAYLIST ) {
402         ADD_FILTER_PLAYLIST( fileTypes );
403     }
404     if( filters & EXT_FILTER_SUBTITLE ) {
405         ADD_FILTER_SUBTITLE( fileTypes );
406     }
407     ADD_FILTER_ALL( fileTypes );
408     fileTypes.replace( ";*", " *");
409
410     QStringList files = QFileDialog::getOpenFileNames( NULL,
411         help.isEmpty() ? qtr(I_OP_SEL_FILES ) : help,
412         path.isEmpty() ? p_intf->p_sys->filepath : path,
413         fileTypes );
414
415     if( !files.isEmpty() ) savedirpathFromFile( files.last() );
416
417     return files;
418 }
419
420 /**
421  * Open a file,
422  * pl helps you to choose from playlist or media library,
423  * go to start or enqueue
424  **/
425 void DialogsProvider::addFromSimple( bool pl, bool go)
426 {
427     QStringList files = DialogsProvider::showSimpleOpen();
428     int i = 0;
429     files.sort();
430     foreach( const QString &file, files )
431     {
432         char* psz_uri = make_URI( qtu( toNativeSeparators(file) ) );
433         playlist_Add( THEPL, psz_uri, NULL,
434                       go ? ( PLAYLIST_APPEND | ( i ? PLAYLIST_PREPARSE : PLAYLIST_GO ) )
435                          : ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ),
436                       PLAYLIST_END, pl, pl_Unlocked );
437         free( psz_uri );
438         RecentsMRL::getInstance( p_intf )->addRecent(
439                 toNativeSeparators( file ) );
440         i++;
441     }
442 }
443
444 void DialogsProvider::simpleOpenDialog()
445 {
446     addFromSimple( true, true ); /* Playlist and Go */
447 }
448
449 void DialogsProvider::simplePLAppendDialog()
450 {
451     addFromSimple( true, false );
452 }
453
454 void DialogsProvider::simpleMLAppendDialog()
455 {
456     addFromSimple( false, false );
457 }
458
459 /* Url & Clipboard */
460 /**
461  * Open a MRL.
462  * If the clipboard contains URLs, the first is automatically 'preselected'.
463  **/
464 void DialogsProvider::openUrlDialog()
465 {
466     OpenUrlDialog *oud = OpenUrlDialog::getInstance( p_intf );
467     if( oud->exec() == QDialog::Accepted )
468     {
469         QString url = oud->url();
470         if( !url.isEmpty() )
471         {
472             playlist_Add( THEPL, qtu( url ),
473                           NULL, !oud->shouldEnqueue() ?
474                                   ( PLAYLIST_APPEND | PLAYLIST_GO )
475                                 : ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ),
476                           PLAYLIST_END, true, false );
477             RecentsMRL::getInstance( p_intf )->addRecent( url );
478         }
479     }
480 }
481
482 /* Directory */
483 /**
484  * Open a directory,
485  * pl helps you to choose from playlist or media library,
486  * go to start or enqueue
487  **/
488 static void openDirectory( intf_thread_t *p_intf, bool pl, bool go )
489 {
490     QString dir = QFileDialog::getExistingDirectory( NULL, qtr("Open Directory"), p_intf->p_sys->filepath );
491
492     if (!dir.isEmpty() )
493     {
494         QString mrl = (dir.endsWith( "VIDEO_TS", Qt::CaseInsensitive ) ?
495                        "dvd://" : "directory://")
496                     + toNativeSeparators( dir );
497         input_item_t *p_input = input_item_New( THEPL, qtu( mrl ), NULL );
498
499         /* FIXME: playlist_AddInput() can fail */
500         playlist_AddInput( THEPL, p_input,
501                        go ? ( PLAYLIST_APPEND | PLAYLIST_GO ) : PLAYLIST_APPEND,
502                        PLAYLIST_END, pl, pl_Unlocked );
503         RecentsMRL::getInstance( p_intf )->addRecent( mrl );
504         if( !go )
505             input_Read( THEPL, p_input );
506         vlc_gc_decref( p_input );
507     }
508 }
509
510 void DialogsProvider::PLOpenDir()
511 {
512     openDirectory( p_intf, true, true );
513 }
514
515 void DialogsProvider::PLAppendDir()
516 {
517     openDirectory( p_intf, true, false );
518 }
519
520 void DialogsProvider::MLAppendDir()
521 {
522     openDirectory( p_intf, false , false );
523 }
524
525 /****************
526  * Playlist     *
527  ****************/
528 void DialogsProvider::openAPlaylist()
529 {
530     QStringList files = showSimpleOpen( qtr( "Open playlist..." ),
531                                         EXT_FILTER_PLAYLIST );
532     foreach( const QString &file, files )
533     {
534         playlist_Import( THEPL, qtu( toNativeSeparators( file ) ) );
535     }
536 }
537
538 void DialogsProvider::saveAPlaylist()
539 {
540     static const struct
541     {
542         char filter[24];
543         char module[12];
544     } types[] = {
545         { N_("XSPF playlist (*.xspf)"), "export-xspf", },
546         { N_("M3U8 playlist (*.m3u)"), "export-m3u8", },
547         { N_("M3U playlist (*.m3u)"), "export-m3u", },
548         { N_("HTML playlist (*.html)"), "export-html", },
549     };
550     QString filters, selected;
551
552     for( size_t i = 0; i < sizeof (types) / sizeof (types[0]); i++ )
553     {
554         if( !filters.isEmpty() )
555             filters += ";;";
556         filters += qfu( vlc_gettext( types[i].filter ) );
557     }
558
559     QString file = QFileDialog::getSaveFileName( NULL,
560                                   qtr( "Save playlist as..." ),
561                                   p_intf->p_sys->filepath, filters, &selected );
562     if( file.isEmpty() )
563         return;
564
565     for( size_t i = 0; i < sizeof (types) / sizeof (types[0]); i++)
566         if( selected == qfu( vlc_gettext( types[i].filter ) ) )
567         {
568             playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
569                              THEPL->p_playing, types[i].module );
570             break;
571         }
572 }
573
574 /****************************************************************************
575  * Sout emulation
576  ****************************************************************************/
577
578 void DialogsProvider::streamingDialog( QWidget *parent,
579                                        const QString& mrl,
580                                        bool b_transcode_only,
581                                        QStringList options )
582 {
583     QString soutoption;
584
585     /* Stream */
586     if( !b_transcode_only )
587     {
588         SoutDialog *s = new SoutDialog( parent, p_intf, mrl );
589         if( s->exec() == QDialog::Accepted )
590         {
591             soutoption = s->getMrl();
592             delete s;
593         }
594         else
595         {
596             delete s; return;
597         }
598     } else {
599     /* Convert */
600         ConvertDialog *s = new ConvertDialog( parent, p_intf, mrl );
601         if( s->exec() == QDialog::Accepted )
602         {
603             soutoption = s->getMrl();
604             delete s;
605         }
606         else
607         {
608             delete s; return;
609         }
610     }
611
612     /* Get SoutMRL */
613     if( !soutoption.isEmpty() )
614     {
615         options += soutoption.split( " :");
616
617         /* Create Input */
618         input_item_t *p_input;
619         p_input = input_item_New( p_intf, qtu( mrl ), _("Streaming") );
620
621         /* Add normal Options */
622         for( int j = 0; j < options.size(); j++ )
623         {
624             QString qs = colon_unescape( options[j] );
625             if( !qs.isEmpty() )
626             {
627                 input_item_AddOption( p_input, qtu( qs ),
628                         VLC_INPUT_OPTION_TRUSTED );
629                 msg_Dbg( p_intf, "Adding option: %s", qtu( qs ) );
630             }
631         }
632
633         /* Switch between enqueuing and starting the item */
634         /* FIXME: playlist_AddInput() can fail */
635         playlist_AddInput( THEPL, p_input,
636                 PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true, pl_Unlocked );
637         vlc_gc_decref( p_input );
638
639         RecentsMRL::getInstance( p_intf )->addRecent( mrl );
640     }
641 }
642
643 void DialogsProvider::openAndStreamingDialogs()
644 {
645     OpenDialog::getInstance( p_intf->p_sys->p_mi, p_intf, false, OPEN_AND_STREAM )
646                                 ->showTab( OPEN_FILE_TAB );
647 }
648
649 void DialogsProvider::openAndTranscodingDialogs()
650 {
651     OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf, false, OPEN_AND_SAVE )
652                                 ->showTab( OPEN_FILE_TAB );
653 }
654
655 void DialogsProvider::loadSubtitlesFile()
656 {
657     input_thread_t *p_input = THEMIM->getInput();
658     if( !p_input ) return;
659
660     input_item_t *p_item = input_GetItem( p_input );
661     if( !p_item ) return;
662
663     char *path = input_item_GetURI( p_item );
664     if( !path ) path = strdup( "" );
665
666     char *sep = strrchr( path, DIR_SEP_CHAR );
667     if( sep ) *sep = '\0';
668
669     QStringList qsl = showSimpleOpen( qtr( "Open subtitles..." ),
670                                       EXT_FILTER_SUBTITLE,
671                                       qfu( path ) );
672     free( path );
673     foreach( const QString &qsFile, qsl )
674     {
675         if( input_AddSubtitle( p_input, qtu( toNativeSeparators( qsFile ) ),
676                     true ) )
677             msg_Warn( p_intf, "unable to load subtitles from '%s'",
678                       qtu( qsFile ) );
679     }
680 }
681
682
683 /****************************************************************************
684  * Menus
685  ****************************************************************************/
686
687 void DialogsProvider::menuAction( QObject *data )
688 {
689     QVLCMenu::DoAction( data );
690 }
691
692 void DialogsProvider::menuUpdateAction( QObject *data )
693 {
694     MenuFunc *func = qobject_cast<MenuFunc *>(data);
695     assert( func );
696     func->doFunc( p_intf );
697 }
698
699 void DialogsProvider::SDMenuAction( const QString& data )
700 {
701     char *psz_sd = strdup( qtu( data ) );
702     if( !playlist_IsServicesDiscoveryLoaded( THEPL, psz_sd ) )
703         playlist_ServicesDiscoveryAdd( THEPL, psz_sd );
704     else
705         playlist_ServicesDiscoveryRemove( THEPL, psz_sd );
706     free( psz_sd );
707 }
708
709 /**
710  * Play the MRL contained in the Recently played menu.
711  **/
712 void DialogsProvider::playMRL( const QString &mrl )
713 {
714     char* psz_uri = make_URI( qtu(mrl) );
715     playlist_Add( THEPL, psz_uri, NULL,
716            PLAYLIST_APPEND | PLAYLIST_GO , PLAYLIST_END, true, false );
717     free( psz_uri );
718
719     RecentsMRL::getInstance( p_intf )->addRecent( mrl );
720 }