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