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