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