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