]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs_provider.cpp
815603999a423d7409b11ed91d8a72fb55e745e7
[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/epg.hpp"
57 #include "dialogs/errors.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 = new OpenUrlDialog( 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     delete oud;
481 }
482
483 /* Directory */
484 /**
485  * Open a directory,
486  * pl helps you to choose from playlist or media library,
487  * go to start or enqueue
488  **/
489 static void openDirectory( intf_thread_t *p_intf, bool pl, bool go )
490 {
491     QString dir = QFileDialog::getExistingDirectory( NULL, qtr("Open Directory"), p_intf->p_sys->filepath );
492
493     if (!dir.isEmpty() )
494     {
495         QString mrl = (dir.endsWith( "VIDEO_TS", Qt::CaseInsensitive ) ?
496                        "dvd://" : "directory://")
497                     + toNativeSeparators( dir );
498         input_item_t *p_input = input_item_New( THEPL, qtu( mrl ), NULL );
499
500         /* FIXME: playlist_AddInput() can fail */
501         playlist_AddInput( THEPL, p_input,
502                        go ? ( PLAYLIST_APPEND | PLAYLIST_GO ) : PLAYLIST_APPEND,
503                        PLAYLIST_END, pl, pl_Unlocked );
504         RecentsMRL::getInstance( p_intf )->addRecent( mrl );
505         if( !go )
506             input_Read( THEPL, p_input );
507         vlc_gc_decref( p_input );
508     }
509 }
510
511 void DialogsProvider::PLOpenDir()
512 {
513     openDirectory( p_intf, true, true );
514 }
515
516 void DialogsProvider::PLAppendDir()
517 {
518     openDirectory( p_intf, true, false );
519 }
520
521 void DialogsProvider::MLAppendDir()
522 {
523     openDirectory( p_intf, false , false );
524 }
525
526 /****************
527  * Playlist     *
528  ****************/
529 void DialogsProvider::openAPlaylist()
530 {
531     QStringList files = showSimpleOpen( qtr( "Open playlist..." ),
532                                         EXT_FILTER_PLAYLIST );
533     foreach( const QString &file, files )
534     {
535         playlist_Import( THEPL, qtu( toNativeSeparators( file ) ) );
536     }
537 }
538
539 void DialogsProvider::saveAPlaylist()
540 {
541     static const struct
542     {
543         char filter[24];
544         char module[12];
545     } types[] = {
546         { N_("XSPF playlist (*.xspf)"), "export-xspf", },
547         { N_("M3U8 playlist (*.m3u)"), "export-m3u8", },
548         { N_("M3U playlist (*.m3u)"), "export-m3u", },
549         { N_("HTML playlist (*.html)"), "export-html", },
550     };
551     QString filters, selected;
552
553     for( size_t i = 0; i < sizeof (types) / sizeof (types[0]); i++ )
554     {
555         if( !filters.isEmpty() )
556             filters += ";;";
557         filters += qfu( vlc_gettext( types[i].filter ) );
558     }
559
560     QString file = QFileDialog::getSaveFileName( NULL,
561                                   qtr( "Save playlist as..." ),
562                                   p_intf->p_sys->filepath, filters, &selected );
563     if( file.isEmpty() )
564         return;
565
566     for( size_t i = 0; i < sizeof (types) / sizeof (types[0]); i++)
567         if( selected == qfu( vlc_gettext( types[i].filter ) ) )
568         {
569             playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
570                              THEPL->p_playing, types[i].module );
571             break;
572         }
573 }
574
575 /****************************************************************************
576  * Sout emulation
577  ****************************************************************************/
578
579 void DialogsProvider::streamingDialog( QWidget *parent,
580                                        const QString& mrl,
581                                        bool b_transcode_only,
582                                        QStringList options )
583 {
584     QString soutoption;
585
586     /* Stream */
587     if( !b_transcode_only )
588     {
589         SoutDialog *s = new SoutDialog( parent, p_intf, mrl );
590         if( s->exec() == QDialog::Accepted )
591         {
592             soutoption = s->getMrl();
593             delete s;
594         }
595         else
596         {
597             delete s; return;
598         }
599     } else {
600     /* Convert */
601         ConvertDialog *s = new ConvertDialog( parent, p_intf, mrl );
602         if( s->exec() == QDialog::Accepted )
603         {
604             soutoption = s->getMrl();
605             delete s;
606         }
607         else
608         {
609             delete s; return;
610         }
611     }
612
613     /* Get SoutMRL */
614     if( !soutoption.isEmpty() )
615     {
616         options += soutoption.split( " :");
617
618         /* Create Input */
619         input_item_t *p_input;
620         p_input = input_item_New( p_intf, qtu( mrl ), _("Streaming") );
621
622         /* Add normal Options */
623         for( int j = 0; j < options.size(); j++ )
624         {
625             QString qs = colon_unescape( options[j] );
626             if( !qs.isEmpty() )
627             {
628                 input_item_AddOption( p_input, qtu( qs ),
629                         VLC_INPUT_OPTION_TRUSTED );
630                 msg_Dbg( p_intf, "Adding option: %s", qtu( qs ) );
631             }
632         }
633
634         /* Switch between enqueuing and starting the item */
635         /* FIXME: playlist_AddInput() can fail */
636         playlist_AddInput( THEPL, p_input,
637                 PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true, pl_Unlocked );
638         vlc_gc_decref( p_input );
639
640         RecentsMRL::getInstance( p_intf )->addRecent( mrl );
641     }
642 }
643
644 void DialogsProvider::openAndStreamingDialogs()
645 {
646     OpenDialog::getInstance( p_intf->p_sys->p_mi, p_intf, false, OPEN_AND_STREAM )
647                                 ->showTab( OPEN_FILE_TAB );
648 }
649
650 void DialogsProvider::openAndTranscodingDialogs()
651 {
652     OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf, false, OPEN_AND_SAVE )
653                                 ->showTab( OPEN_FILE_TAB );
654 }
655
656 void DialogsProvider::loadSubtitlesFile()
657 {
658     input_thread_t *p_input = THEMIM->getInput();
659     if( !p_input ) return;
660
661     input_item_t *p_item = input_GetItem( p_input );
662     if( !p_item ) return;
663
664     char *path = input_item_GetURI( p_item );
665     if( !path ) path = strdup( "" );
666
667     char *sep = strrchr( path, DIR_SEP_CHAR );
668     if( sep ) *sep = '\0';
669
670     QStringList qsl = showSimpleOpen( qtr( "Open subtitles..." ),
671                                       EXT_FILTER_SUBTITLE,
672                                       qfu( path ) );
673     free( path );
674     foreach( const QString &qsFile, qsl )
675     {
676         if( input_AddSubtitle( p_input, qtu( toNativeSeparators( qsFile ) ),
677                     true ) )
678             msg_Warn( p_intf, "unable to load subtitles from '%s'",
679                       qtu( qsFile ) );
680     }
681 }
682
683
684 /****************************************************************************
685  * Menus
686  ****************************************************************************/
687
688 void DialogsProvider::menuAction( QObject *data )
689 {
690     QVLCMenu::DoAction( data );
691 }
692
693 void DialogsProvider::menuUpdateAction( QObject *data )
694 {
695     MenuFunc *func = qobject_cast<MenuFunc *>(data);
696     assert( func );
697     func->doFunc( p_intf );
698 }
699
700 void DialogsProvider::SDMenuAction( const QString& data )
701 {
702     char *psz_sd = strdup( qtu( data ) );
703     if( !playlist_IsServicesDiscoveryLoaded( THEPL, psz_sd ) )
704         playlist_ServicesDiscoveryAdd( THEPL, psz_sd );
705     else
706         playlist_ServicesDiscoveryRemove( THEPL, psz_sd );
707     free( psz_sd );
708 }
709
710 /**
711  * Play the MRL contained in the Recently played menu.
712  **/
713 void DialogsProvider::playMRL( const QString &mrl )
714 {
715     char* psz_uri = make_URI( qtu(mrl) );
716     playlist_Add( THEPL, psz_uri, NULL,
717            PLAYLIST_APPEND | PLAYLIST_GO , PLAYLIST_END, true, false );
718     free( psz_uri );
719
720     RecentsMRL::getInstance( p_intf )->addRecent( mrl );
721 }