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