]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/vlm.cpp
Qt4 - Fix the VLM Input selection
[vlc] / modules / gui / qt4 / dialogs / vlm.cpp
1 /*****************************************************************************
2  * vlm.cpp : VLM Management
3  ****************************************************************************
4  * Copyright © 2008 the VideoLAN team
5  * $Id: sout.cpp 21875 2007-09-08 16:01:33Z jb $
6  *
7  * Authors: Jean-Baptiste Kempf <jb@videolan.org>
8  *          Jean-François Massol <jf.massol -at- gmail.com>
9  *          Clément Sténac <zorglub@videolan.org>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * ( at your option ) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #include "dialogs/vlm.hpp"
31
32 #ifdef ENABLE_VLM
33 #include "dialogs/open.hpp"
34 #include "dialogs/sout.hpp"
35
36 #include <QString>
37 #include <QComboBox>
38 #include <QVBoxLayout>
39 #include <QStackedWidget>
40 #include <QLabel>
41 #include <QWidget>
42 #include <QGridLayout>
43 #include <QLineEdit>
44 #include <QCheckBox>
45 #include <QToolButton>
46 #include <QGroupBox>
47 #include <QPushButton>
48 #include <QHBoxLayout>
49 #include <QDateTimeEdit>
50 #include <QDateTime>
51 #include <QSpinBox>
52 #include <QHeaderView>
53 #include <QScrollArea>
54 #include <QFileDialog>
55
56 static const char *psz_type[] = { "Broadcast", "Schedule", "VOD" };
57
58 VLMDialog *VLMDialog::instance = NULL;
59
60 VLMDialog::VLMDialog( QWidget *parent, intf_thread_t *_p_intf ) : QVLCDialog( parent, _p_intf )
61 {
62     p_vlm = vlm_New( p_intf );
63
64     if( !p_vlm )
65     {
66         msg_Warn( p_intf, "Couldn't build VLM object ");
67         return;
68     }
69     vlmWrapper = new VLMWrapper( p_vlm );
70
71     // UI stuff
72     ui.setupUi( this );
73     ui.saveButton->hide();
74
75 #define ADDMEDIATYPES( str, type ) ui.mediaType->addItem( qtr( str ), QVariant( type ) );
76     ADDMEDIATYPES( "Broadcast", QVLM_Broadcast );
77     ADDMEDIATYPES( "Schedule", QVLM_Schedule );
78     ADDMEDIATYPES( "Video On Demand ( VOD )", QVLM_VOD );
79 #undef ADDMEDIATYPES
80
81     /* Schedule Stuffs */
82     QGridLayout *schetimelayout = new QGridLayout( ui.schedBox );
83     QLabel *schetimelabel = new QLabel( qtr( "Hours/Minutes/Seconds:" ) );
84     schetimelayout->addWidget( schetimelabel, 0, 0 );
85     QLabel *schedatelabel = new QLabel( qtr( "Day Month Year:" ) );
86     schetimelayout->addWidget( schedatelabel, 1, 0 );
87     QLabel *scherepeatLabel = new QLabel( qtr( "Repeat:" ) );
88     schetimelayout->addWidget( scherepeatLabel, 2, 0 );
89     QLabel *scherepeatTimeLabel = new QLabel( qtr( "Repeat delay:" ) );
90     schetimelayout->addWidget( scherepeatTimeLabel, 3, 0 );
91
92     time = new QDateTimeEdit( QTime::currentTime() );
93     time->setAlignment( Qt::AlignRight );
94     time->setDisplayFormat( "hh:mm:ss" );
95     schetimelayout->addWidget( time, 0, 1, 1, 3 );
96
97     date = new QDateTimeEdit( QDate::currentDate() );
98     date->setAlignment( Qt::AlignRight );
99     date->setCalendarPopup( true );
100 #ifdef WIN32
101     date->setDisplayFormat( "dd MM yyyy" );
102 #else
103     date->setDisplayFormat( "dd MMMM yyyy" );
104 #endif
105     schetimelayout->addWidget( date, 1, 1, 1, 3 );
106
107     scherepeatnumber = new QSpinBox;
108     scherepeatnumber->setAlignment( Qt::AlignRight );
109     schetimelayout->addWidget( scherepeatnumber, 2, 1, 1, 3 );
110
111     repeatDays = new QSpinBox;
112     repeatDays->setAlignment( Qt::AlignRight );
113     schetimelayout->addWidget( repeatDays, 3, 1, 1, 1 );
114     repeatDays->setSuffix( qtr(" days") );
115
116     repeatTime = new QDateTimeEdit;
117     repeatTime->setAlignment( Qt::AlignRight );
118     schetimelayout->addWidget( repeatTime, 3, 2, 1, 2 );
119     repeatTime->setDisplayFormat( "hh:mm:ss" );
120
121     /* scrollArea */
122     ui.vlmItemScroll->setFrameStyle( QFrame::NoFrame );
123     ui.vlmItemScroll->setWidgetResizable( true );
124     vlmItemWidget = new QWidget;
125     vlmItemLayout = new QVBoxLayout( vlmItemWidget );
126     vlmItemWidget->setLayout( vlmItemLayout );
127     ui.vlmItemScroll->setWidget( vlmItemWidget );
128
129     QSpacerItem *spacer =
130         new QSpacerItem( 10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding);
131     vlmItemLayout->addItem( spacer );
132
133     QPushButton *exportButton = new QPushButton( qtr( "Export" ) );
134     ui.buttonBox->addButton( exportButton, QDialogButtonBox::ActionRole );
135
136     QPushButton *closeButton = new QPushButton( qtr( "Close" ) );
137     ui.buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
138
139
140     showScheduleWidget( QVLM_Broadcast );
141
142     /* Connect the comboBox to show the right Widgets */
143     CONNECT( ui.mediaType, currentIndexChanged( int ),
144              this, showScheduleWidget( int ) );
145
146     /* Connect the leftList to show the good VLMItem */
147     CONNECT( ui.vlmListItem, currentRowChanged( int ),
148              this, selectVLMItem( int ) );
149
150     BUTTONACT( closeButton, close() );
151     BUTTONACT( exportButton, exportVLMConf() );
152     BUTTONACT( ui.addButton, addVLMItem() );
153     BUTTONACT( ui.clearButton, clearWidgets() );
154     BUTTONACT( ui.saveButton, saveModifications() );
155     BUTTONACT( ui.inputButton, selectInput() );
156     BUTTONACT( ui.outputButton, selectOutput() );
157 }
158
159 VLMDialog::~VLMDialog()
160 {
161    /* FIXME :you have to destroy vlm here to close
162     * but we shouldn't destroy vlm here in case somebody else wants it */
163     if( p_vlm )
164         vlm_Delete( p_vlm );
165 }
166
167 void VLMDialog::showScheduleWidget( int i )
168 {
169     ui.schedBox->setVisible( ( i == QVLM_Schedule ) );
170     ui.loopBCast->setVisible( ( i == QVLM_Broadcast ) );
171     ui.vodBox->setVisible( ( i == QVLM_VOD ) );
172 }
173
174 void VLMDialog::selectVLMItem( int i )
175 {
176     if( i >= 0 )
177         ui.vlmItemScroll->ensureWidgetVisible( vlmItems.at( i ) );
178 }
179
180 bool VLMDialog::isNameGenuine( QString name )
181 {
182     for( int i = 0; i < vlmItems.size(); i++ )
183     {
184         if( vlmItems.at( i )->name == name )
185             return false;
186     }
187     return true;
188 }
189
190 void VLMDialog::addVLMItem()
191 {
192     int vlmItemCount = vlmItems.size();
193
194     /* Take the name and Check it */
195     QString name = ui.nameLedit->text();
196     if( name.isEmpty() || !isNameGenuine( name ) )
197     {
198         msg_Dbg( p_intf, "VLM Name is empty or already exists, I can't do it" );
199         return;
200     }
201
202     int type = ui.mediaType->itemData( ui.mediaType->currentIndex() ).toInt();
203
204     QString typeShortName;
205     QString inputText = ui.inputLedit->text();
206     QString outputText = ui.outputLedit->text();
207     bool b_checked = ui.enableCheck->isChecked();
208     bool b_looped = ui.loopBCast->isChecked();
209     QDateTime schetime = time->dateTime();
210     QDateTime schedate = date->dateTime();
211     int repeatnum = scherepeatnumber->value();
212     int repeatdays = repeatDays->value();
213     VLMAWidget * vlmAwidget;
214
215     switch( type )
216     {
217     case QVLM_Broadcast:
218         typeShortName = "Bcast";
219         vlmAwidget = new VLMBroadcast( name, inputText, outputText,
220                                        b_checked, b_looped, this );
221         VLMWrapper::AddBroadcast( name, inputText, outputText, b_checked,
222                                   b_looped );
223     break;
224     case QVLM_VOD:
225         typeShortName = "VOD";
226         vlmAwidget = new VLMVod( name, inputText, outputText,
227                                  b_checked, ui.muxLedit->text(), this );
228         VLMWrapper::AddVod( name, inputText, outputText, b_checked );
229         break;
230     case QVLM_Schedule:
231         typeShortName = "Sched";
232         vlmAwidget = new VLMSchedule( name, inputText, outputText,
233                                       schetime, schedate, repeatnum,
234                                       repeatdays, b_checked, this );
235         VLMWrapper::AddSchedule( name, inputText, outputText, schetime,
236                                  schedate, repeatnum, repeatdays, b_checked);
237         break;
238     default:
239         msg_Warn( p_intf, "Something bad happened" );
240         return;
241     }
242
243     /* Add an Item of the Side List */
244     ui.vlmListItem->addItem( typeShortName + " : " + name );
245     ui.vlmListItem->setCurrentRow( vlmItemCount - 1 );
246
247     /* Add a new VLMAWidget on the main List */
248
249     vlmItemLayout->insertWidget( vlmItemCount, vlmAwidget );
250     vlmItems.append( vlmAwidget );
251     clearWidgets();
252 }
253
254 // FIXME : VOD are not exported to the file
255 bool VLMDialog::exportVLMConf()
256 {
257     QString saveVLMConfFileName = QFileDialog::getSaveFileName(
258             this, qtr( "Choose a filename to save the VLM configuration..." ),
259             qfu( p_intf->p_libvlc->psz_homedir ),
260             qtr( "VLM conf (*.vlm) ;; All (*.*)" ) );
261
262     if( !saveVLMConfFileName.isEmpty() )
263     {
264         vlm_message_t *message;
265         QString command = "save \"" + saveVLMConfFileName + "\"";
266         vlm_ExecuteCommand( p_vlm , qtu( command ) , &message );
267         vlm_MessageDelete( message );
268         return true;
269     }
270     return false;
271 }
272
273 // TODO : import configuration file
274 bool VLMDialog::importVLMConf()
275 {
276 }
277
278 void VLMDialog::clearWidgets()
279 {
280     ui.nameLedit->clear();
281     ui.inputLedit->clear();
282     ui.outputLedit->clear();
283     time->setTime( QTime::currentTime() );
284     date->setDate( QDate::currentDate() );
285     ui.enableCheck->setChecked( true );
286     ui.nameLedit->setReadOnly( false );
287     ui.loopBCast->setChecked( false );
288     ui.muxLedit->clear();
289     ui.saveButton->hide();
290     ui.addButton->show();
291 }
292
293 void VLMDialog::selectInput()
294 {
295     OpenDialog *o = OpenDialog::getInstance( this, p_intf, SELECT, true );
296     o->exec();
297     ui.inputLedit->setText( o->getMRL() );
298 }
299
300 void VLMDialog::selectOutput()
301 {
302     SoutDialog *s = SoutDialog::getInstance( this, p_intf, false );
303     if( s->exec() == QDialog::Accepted )
304         ui.outputLedit->setText( s->getMrl() );
305 }
306
307 /* Object Modification */
308 void VLMDialog::removeVLMItem( VLMAWidget *vlmObj )
309 {
310     int index = vlmItems.indexOf( vlmObj );
311     if( index < 0 ) return;
312     delete ui.vlmListItem->takeItem( index );
313     vlmItems.removeAt( index );
314     delete vlmObj;
315
316     /* HERE BE DRAGONS VLM REQUEST */
317 }
318
319 void VLMDialog::startModifyVLMItem( VLMAWidget *vlmObj )
320 {
321     currentIndex = vlmItems.indexOf( vlmObj );
322     if( currentIndex < 0 ) return;
323
324     msg_Dbg( p_intf, "Type: %i", vlmObj->type );
325     ui.vlmListItem->setCurrentRow( currentIndex );
326     ui.nameLedit->setText( vlmObj->name );
327     ui.inputLedit->setText( vlmObj->input );
328     ui.outputLedit->setText( vlmObj->output );
329     ui.enableCheck->setChecked( vlmObj->b_enabled );
330
331     switch( vlmObj->type )
332     {
333     case QVLM_Broadcast:
334         ui.loopBCast->setChecked( (qobject_cast<VLMBroadcast *>(vlmObj))->b_looped );
335         break;
336     case QVLM_VOD:
337         ui.muxLedit->setText( (qobject_cast<VLMVod *>(vlmObj))->mux );
338         break;
339     case QVLM_Schedule:
340         time->setDateTime( ( qobject_cast<VLMSchedule *>(vlmObj))->schetime );
341         date->setDateTime( ( qobject_cast<VLMSchedule *>(vlmObj))->schedate );
342         break;
343     }
344
345     ui.nameLedit->setReadOnly( true );
346     ui.addButton->hide();
347     ui.saveButton->show();
348 }
349
350 void VLMDialog::saveModifications()
351 {
352     VLMAWidget *vlmObj = vlmItems.at( currentIndex );
353     if( vlmObj )
354     {
355         vlmObj->input = ui.inputLedit->text();
356         vlmObj->output = ui.outputLedit->text();
357         vlmObj->setChecked( ui.enableCheck->isChecked() );
358         vlmObj->b_enabled = ui.enableCheck->isChecked();
359         switch( vlmObj->type )
360         {
361         case QVLM_Broadcast:
362             (qobject_cast<VLMBroadcast *>(vlmObj))->b_looped = ui.loopBCast->isChecked();
363             break;
364         case QVLM_VOD:
365             (qobject_cast<VLMVod *>(vlmObj))->mux = ui.muxLedit->text();
366             break;
367         case QVLM_Schedule:
368             (qobject_cast<VLMSchedule *>(vlmObj))->schetime = time->dateTime();
369             (qobject_cast<VLMSchedule *>(vlmObj))->schedate = date->dateTime();
370             (qobject_cast<VLMSchedule *>(vlmObj))->rNumber = scherepeatnumber->value();
371             (qobject_cast<VLMSchedule *>(vlmObj))->rDays = repeatDays->value();
372             break;
373            //           vlmObj->
374         }
375         vlmObj->update(); /* It should call the correct function is VLMAWidget
376                              is abstract, but I am far from sure... FIXME ? */
377     }
378     clearWidgets();
379 }
380
381 /*********************************
382  * VLMAWidget - Abstract class
383  ********************************/
384
385 VLMAWidget::VLMAWidget( QString _name,
386                         QString _input,
387                         QString _output,
388                         bool _enabled,
389                         VLMDialog *_parent,
390                         int _type )
391                       : QGroupBox( _name, _parent )
392 {
393     parent = _parent;
394     name = _name;
395     input = _input;
396     output = _output;
397     b_enabled = _enabled;
398     type = _type;
399
400     setCheckable( true );
401     setChecked( b_enabled );
402
403     objLayout = new QGridLayout( this );
404     setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
405
406     nameLabel = new QLabel;
407     objLayout->addWidget( nameLabel, 0, 0, 1, 4 );
408
409     /*QLabel *time = new QLabel( "--:--/--:--" );
410     objLayout->addWidget( time, 1, 3, 1, 2 );*/
411
412     QToolButton *modifyButton = new QToolButton;
413     modifyButton->setIcon( QIcon( QPixmap( ":/pixmaps/menus_settings_16px.png" ) ) );
414     objLayout->addWidget( modifyButton, 0, 5 );
415
416     QToolButton *deleteButton = new QToolButton;
417     deleteButton->setIcon( QIcon( QPixmap( ":/pixmaps/menus_quit_16px.png" ) ) );
418     objLayout->addWidget( deleteButton, 0, 6 );
419
420     BUTTONACT( modifyButton, modify() );
421     BUTTONACT( deleteButton, del() );
422     CONNECT( this, clicked( bool ), this, toggleEnabled( bool ) );
423 }
424
425 void VLMAWidget::modify()
426 {
427     parent->startModifyVLMItem( this );
428 }
429
430 void VLMAWidget::del()
431 {
432     parent->removeVLMItem( this );
433 }
434
435 //FIXME, remove me before release
436 void VLMAWidget::enterEvent( QEvent *event )
437 {
438     printf( "test" );
439 }
440
441 void VLMAWidget::toggleEnabled( bool b_enable )
442 {
443     VLMWrapper::EnableItem( name, b_enable );
444 }
445
446 /****************
447  * VLMBroadcast
448  ****************/
449 VLMBroadcast::VLMBroadcast( QString _name, QString _input, QString _output,
450                             bool _enabled, bool _looped, VLMDialog *_parent)
451                           : VLMAWidget( _name, _input, _output,
452                                         _enabled, _parent, QVLM_Broadcast )
453 {
454     nameLabel->setText( "Broadcast: " + name );
455     type = QVLM_Broadcast;
456     b_looped = _looped;
457
458     playButton = new QToolButton;
459     playButton->setIcon( QIcon( QPixmap( ":/pixmaps/play_16px.png" ) ) );
460     objLayout->addWidget( playButton, 1, 0 );
461     b_playing = true;
462
463     QToolButton *stopButton = new QToolButton;
464     stopButton->setIcon( QIcon( QPixmap( ":/pixmaps/stop_16px.png" ) ) );
465     objLayout->addWidget( stopButton, 1, 1 );
466
467     loopButton = new QToolButton;
468     objLayout->addWidget( loopButton, 1, 2 );
469
470     BUTTONACT( playButton, togglePlayPause() );
471     BUTTONACT( stopButton, stop() );
472     BUTTONACT( loopButton, toggleLoop() );
473
474     update();
475 }
476
477 void VLMBroadcast::update()
478 {
479     VLMWrapper::EditBroadcast( name, input, output, b_enabled, b_looped );
480     if( b_looped )
481         loopButton->setIcon( QIcon( QPixmap( ":/pixmaps/playlist_repeat_all.png" ) ) );
482     else
483         loopButton->setIcon( QIcon( QPixmap( ":/pixmaps/playlist_repeat_off.png" ) ) );
484 }
485
486 void VLMBroadcast::togglePlayPause()
487 {
488     if( b_playing = true )
489     {
490         VLMWrapper::ControlBroadcast( name, ControlBroadcastPause );
491         playButton->setIcon( QIcon( QPixmap( ":/pixmaps/pause_16px.png" ) ) );
492     }
493     else
494     {
495         VLMWrapper::ControlBroadcast( name, ControlBroadcastPlay );
496         playButton->setIcon( QIcon( QPixmap( ":/pixmaps/play_16px.png" ) ) );
497     }
498     b_playing = !b_playing;
499 }
500
501 void VLMBroadcast::toggleLoop()
502 {
503     b_enabled = !b_enabled;
504     update();
505 }
506
507 void VLMBroadcast::stop()
508 {
509     VLMWrapper::ControlBroadcast( name, ControlBroadcastStop );
510     playButton->setIcon( QIcon( QPixmap( ":/pixmaps/play_16px.png" ) ) );
511 }
512
513 /****************
514  * VLMSchedule
515  ****************/
516 VLMSchedule::VLMSchedule( QString name, QString input, QString output,
517                           QDateTime _schetime, QDateTime _schedate,
518                           int _scherepeatnumber, int _repeatDays,
519                           bool enabled, VLMDialog *parent )
520             : VLMAWidget( name, input, output, enabled, parent, QVLM_Schedule )
521 {
522     nameLabel->setText( "Schedule: " + name );
523     schetime = _schetime;
524     schedate = _schedate;
525     rNumber = _scherepeatnumber;
526     rDays = _repeatDays;
527     type = QVLM_Schedule;
528     update();
529 }
530
531 void VLMSchedule::update()
532 {
533    VLMWrapper::EditSchedule( name, input, output, schetime, schedate,
534                              rNumber, rDays, b_enabled);
535 }
536
537 /****************
538  * VLMVOD
539  ****************/
540 VLMVod::VLMVod( QString name, QString input, QString output,
541                 bool enabled, QString _mux, VLMDialog *parent)
542        : VLMAWidget( name, input, output, enabled, parent, QVLM_VOD )
543 {
544     nameLabel->setText( "VOD:" + name );
545
546     mux = _mux;
547     muxLabel = new QLabel;
548     objLayout->addWidget( muxLabel, 1, 0 );
549
550     update();
551 }
552
553 void VLMVod::update()
554 {
555     muxLabel->setText( mux );
556     VLMWrapper::EditVod( name, input, output, b_enabled, mux );
557 }
558
559
560 /*******************
561  * VLMWrapper
562  *******************/
563 vlm_t * VLMWrapper::p_vlm = NULL;
564
565 VLMWrapper::VLMWrapper( vlm_t *_p_vlm )
566 {
567     p_vlm = _p_vlm;
568 }
569
570 VLMWrapper::~VLMWrapper()
571 {}
572
573 void VLMWrapper::AddBroadcast( const QString name, QString input,
574                                QString output,
575                                bool b_enabled, bool b_loop  )
576 {
577     vlm_message_t *message;
578     QString command = "new \"" + name + "\" broadcast";
579     vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
580     vlm_MessageDelete( message );
581     EditBroadcast( name, input, output, b_enabled, b_loop );
582 }
583
584 void VLMWrapper::EditBroadcast( const QString name, const QString input,
585                                 const QString output,
586                                 bool b_enabled, bool b_loop  )
587 {
588     vlm_message_t *message;
589     QString command;
590
591     command = "setup \"" + name + "\" inputdel all";
592     vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
593     vlm_MessageDelete( message );
594     command = "setup \"" + name + "\" input \"" + input + "\"";
595     vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
596     vlm_MessageDelete( message );
597     if( !output.isEmpty() )
598     {
599         command = "setup \"" + name + "\" output \"" + output + "\"";
600         vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
601         vlm_MessageDelete( message );
602     }
603     if( b_enabled )
604     {
605         command = "setup \"" + name + "\" enabled";
606         vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
607         vlm_MessageDelete( message );
608     }
609     if( b_loop )
610     {
611         command = "setup \"" + name + "\" loop";
612         vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
613         vlm_MessageDelete( message );
614     }
615 }
616
617 void VLMWrapper::EnableItem( const QString name, bool b_enable )
618 {
619     vlm_message_t *message;
620     QString command = "setup \"" + name + ( b_enable ? " enable" : " disable" );
621 }
622
623 void VLMWrapper::ControlBroadcast( const QString name, int BroadcastStatus,
624                                    unsigned int seek )
625 {
626     vlm_message_t *message;
627
628     QString command = "control \"" + name;
629     switch( BroadcastStatus )
630     {
631     case ControlBroadcastPlay:
632         command += " play";
633         break;
634     case ControlBroadcastPause:
635         command += " pause";
636         break;
637     case ControlBroadcastStop:
638         command += " stop";
639         break;
640     case ControlBroadcastSeek:
641         command += " seek" + seek;
642         break;
643     }
644     vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
645     vlm_MessageDelete( message );
646 }
647
648 void VLMWrapper::AddVod( const QString name, const QString input,
649                          const QString output,
650                          bool b_enabled, const QString mux )
651 {
652     vlm_message_t *message;
653     QString command = "new \"" + name + "\" vod";
654     vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
655     vlm_MessageDelete( message );
656     EditVod(  name, input, output, b_enabled, mux );
657 }
658
659 void VLMWrapper::EditVod( const QString name, const QString input,
660                           const QString output,
661                           bool b_enabled,
662                           const QString mux )
663 {
664     vlm_message_t *message;
665     QString command = "setup \"" + name + "\" input \"" + input + "\"";
666     vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
667     vlm_MessageDelete( message );
668     if( !output.isEmpty() )
669     {
670         command = "setup \"" + name + "\" output \"" + output + "\"";
671         vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
672         vlm_MessageDelete( message );
673     }
674     if( b_enabled )
675     {
676         command = "setup \"" + name + "\" enabled";
677         vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
678         vlm_MessageDelete( message );
679     }
680     if( !mux.isEmpty() )
681     {
682         command = "setup \"" + name + "\" mux \"" + mux + "\"";
683         vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
684         vlm_MessageDelete( message );
685     }
686 }
687
688 void VLMWrapper::AddSchedule( const QString name, const QString input,
689                               const QString output, QDateTime _schetime,
690                               QDateTime _schedate,
691                               int _scherepeatnumber, int _repeatDays,
692                               bool b_enabled, const QString mux )
693 {
694     vlm_message_t *message;
695     QString command = "new \"" + name + "\" schedule";
696     vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
697     vlm_MessageDelete( message );
698     EditSchedule(  name, input, output, _schetime, _schedate,
699             _scherepeatnumber, _repeatDays, b_enabled, mux );
700 }
701
702 void VLMWrapper::EditSchedule( const QString name, const QString input,
703                           const QString output, QDateTime _schetime,
704                           QDateTime _schedate, int _scherepeatnumber,
705                           int _repeatDays, bool b_enabled,
706                           const QString mux )
707 {
708     vlm_message_t *message;
709     QString command = "setup \"" + name + "\" input \"" + input + "\"";
710     vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
711     vlm_MessageDelete( message );
712
713     if( !output.isEmpty() )
714     {
715         command = "setup \"" + name + "\" output \"" + output + "\"";
716         vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
717         vlm_MessageDelete( message );
718     }
719
720     if( b_enabled )
721     {
722         command = "setup \"" + name + "\" enabled";
723         vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
724         vlm_MessageDelete( message );
725     }
726
727     if( !mux.isEmpty() )
728     {
729         command = "setup \"" + name + "\" mux \"" + mux + "\"";
730         vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
731         vlm_MessageDelete( message );
732     }
733
734     command = "setup \"" + name + "\" date \"" +
735         _schedate.toString( "yyyy/MM/dd" )+ "-" +
736         _schetime.toString( "hh:mm:ss" ) + "\"";
737     vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
738     vlm_MessageDelete( message );
739     if( _scherepeatnumber > 0 )
740     {
741        command = "setup \"" + name + "\" repeat \"" + _scherepeatnumber + "\"";
742        vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
743        vlm_MessageDelete( message );
744     }
745 }
746
747
748 #endif