1 /*****************************************************************************
2 * vlm.cpp : VLM Management
3 ****************************************************************************
4 * Copyright © 2008 the VideoLAN team
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>
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.
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.
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 *****************************************************************************/
30 #include "dialogs/vlm.hpp"
33 #include "dialogs/open.hpp"
34 #include "dialogs/sout.hpp"
35 #include "util/qt_dirs.hpp"
39 #include <QVBoxLayout>
40 #include <QStackedWidget>
43 #include <QGridLayout>
46 #include <QToolButton>
48 #include <QPushButton>
49 #include <QHBoxLayout>
50 #include <QDateTimeEdit>
53 #include <QScrollArea>
54 #include <QFileDialog>
57 VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCDialog( (QWidget*)_p_intf->p_sys->p_mi, _p_intf )
59 p_vlm = vlm_New( p_intf );
63 msg_Warn( p_intf, "Couldn't build VLM object ");
66 vlmWrapper = new VLMWrapper( p_vlm );
70 ui.saveButton->hide();
72 #define ADDMEDIATYPES( str, type ) ui.mediaType->addItem( qtr( str ), QVariant( type ) );
73 ADDMEDIATYPES( N_("Broadcast"), QVLM_Broadcast );
74 ADDMEDIATYPES( N_("Schedule"), QVLM_Schedule );
75 ADDMEDIATYPES( N_("Video On Demand ( VOD )"), QVLM_VOD );
79 QGridLayout *schetimelayout = new QGridLayout( ui.schedBox );
80 QLabel *schetimelabel = new QLabel( qtr( "Hours / Minutes / Seconds:" ) );
81 schetimelayout->addWidget( schetimelabel, 0, 0 );
82 QLabel *schedatelabel = new QLabel( qtr( "Day / Month / Year:" ) );
83 schetimelayout->addWidget( schedatelabel, 1, 0 );
84 QLabel *scherepeatLabel = new QLabel( qtr( "Repeat:" ) );
85 schetimelayout->addWidget( scherepeatLabel, 2, 0 );
86 QLabel *scherepeatTimeLabel = new QLabel( qtr( "Repeat delay:" ) );
87 schetimelayout->addWidget( scherepeatTimeLabel, 3, 0 );
89 time = new QDateTimeEdit( QTime::currentTime() );
90 time->setAlignment( Qt::AlignRight );
91 time->setDisplayFormat( "hh:mm:ss" );
92 schetimelayout->addWidget( time, 0, 1, 1, 3 );
94 date = new QDateTimeEdit( QDate::currentDate() );
95 date->setAlignment( Qt::AlignRight );
96 date->setCalendarPopup( true );
98 date->setDisplayFormat( "dd MM yyyy" );
100 date->setDisplayFormat( "dd MMMM yyyy" );
102 schetimelayout->addWidget( date, 1, 1, 1, 3 );
104 scherepeatnumber = new QSpinBox;
105 scherepeatnumber->setAlignment( Qt::AlignRight );
106 schetimelayout->addWidget( scherepeatnumber, 2, 1, 1, 3 );
108 repeatDays = new QSpinBox;
109 repeatDays->setAlignment( Qt::AlignRight );
110 schetimelayout->addWidget( repeatDays, 3, 1, 1, 1 );
111 repeatDays->setSuffix( qtr(" days") );
113 repeatTime = new QDateTimeEdit;
114 repeatTime->setAlignment( Qt::AlignRight );
115 schetimelayout->addWidget( repeatTime, 3, 2, 1, 2 );
116 repeatTime->setDisplayFormat( "hh:mm:ss" );
119 ui.vlmItemScroll->setFrameStyle( QFrame::NoFrame );
120 ui.vlmItemScroll->setWidgetResizable( true );
121 vlmItemWidget = new QWidget;
122 vlmItemLayout = new QVBoxLayout( vlmItemWidget );
123 vlmItemWidget->setLayout( vlmItemLayout );
124 ui.vlmItemScroll->setWidget( vlmItemWidget );
126 QSpacerItem *spacer =
127 new QSpacerItem( 10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding);
128 vlmItemLayout->addItem( spacer );
130 QPushButton *importButton = new QPushButton( qtr( "I&mport" ) );
131 ui.buttonBox->addButton( importButton, QDialogButtonBox::ActionRole );
133 QPushButton *exportButton = new QPushButton( qtr( "E&xport" ) );
134 ui.buttonBox->addButton( exportButton, QDialogButtonBox::ActionRole );
136 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
137 ui.buttonBox->addButton( closeButton, QDialogButtonBox::RejectRole );
140 showScheduleWidget( QVLM_Broadcast );
142 /* Connect the comboBox to show the right Widgets */
143 CONNECT( ui.mediaType, currentIndexChanged( int ),
144 this, showScheduleWidget( int ) );
146 /* Connect the leftList to show the good VLMItem */
147 CONNECT( ui.vlmListItem, currentRowChanged( int ),
148 this, selectVLMItem( int ) );
150 BUTTONACT( closeButton, close() );
151 BUTTONACT( exportButton, exportVLMConf() );
152 BUTTONACT( importButton, importVLMConf() );
153 BUTTONACT( ui.addButton, addVLMItem() );
154 BUTTONACT( ui.clearButton, clearWidgets() );
155 BUTTONACT( ui.saveButton, saveModifications() );
156 BUTTONACT( ui.inputButton, selectInput() );
157 BUTTONACT( ui.outputButton, selectOutput() );
159 if( !restoreGeometry( getSettings()->value("VLM/geometry").toByteArray() ) )
161 resize( QSize( 700, 500 ) );
165 VLMDialog::~VLMDialog()
169 getSettings()->setValue("VLM/geometry", saveGeometry());
170 /* TODO :you have to destroy vlm here to close
171 * but we shouldn't destroy vlm here in case somebody else wants it */
178 void VLMDialog::showScheduleWidget( int i )
180 ui.schedBox->setVisible( ( i == QVLM_Schedule ) );
181 ui.loopBCast->setVisible( ( i == QVLM_Broadcast ) );
182 ui.vodBox->setVisible( ( i == QVLM_VOD ) );
185 void VLMDialog::selectVLMItem( int i )
188 ui.vlmItemScroll->ensureWidgetVisible( vlmItems.at( i ) );
191 bool VLMDialog::isNameGenuine( const QString& name )
193 for( int i = 0; i < vlmItems.count(); i++ )
195 if( vlmItems.at( i )->name == name )
201 void VLMDialog::addVLMItem()
203 int vlmItemCount = vlmItems.count();
205 /* Take the name and Check it */
206 QString name = ui.nameLedit->text();
207 if( name.isEmpty() || !isNameGenuine( name ) )
209 msg_Err( p_intf, "VLM Name is empty or already exists, I can't do it" );
213 int type = ui.mediaType->itemData( ui.mediaType->currentIndex() ).toInt();
215 QString typeShortName;
216 QString inputText = ui.inputLedit->text();
217 QString outputText = ui.outputLedit->text();
218 bool b_checked = ui.enableCheck->isChecked();
219 bool b_looped = ui.loopBCast->isChecked();
220 QDateTime schetime = time->dateTime();
221 QDateTime schedate = date->dateTime();
222 int repeatnum = scherepeatnumber->value();
223 int repeatdays = repeatDays->value();
224 VLMAWidget * vlmAwidget;
225 outputText.remove( ":sout=" );
230 typeShortName = "Bcast";
231 vlmAwidget = new VLMBroadcast( name, inputText, inputOptions, outputText,
232 b_checked, b_looped, this );
233 VLMWrapper::AddBroadcast( name, inputText, inputOptions, outputText, b_checked,
237 typeShortName = "VOD";
238 vlmAwidget = new VLMVod( name, inputText, inputOptions, outputText,
239 b_checked, ui.muxLedit->text(), this );
240 VLMWrapper::AddVod( name, inputText, inputOptions, outputText, b_checked );
243 typeShortName = "Sched";
244 vlmAwidget = new VLMSchedule( name, inputText, inputOptions, outputText,
245 schetime, schedate, repeatnum,
246 repeatdays, b_checked, this );
247 VLMWrapper::AddSchedule( name, inputText, inputOptions, outputText, schetime,
248 schedate, repeatnum, repeatdays, b_checked);
251 msg_Warn( p_intf, "Something bad happened" );
255 /* Add an Item of the Side List */
256 ui.vlmListItem->addItem( typeShortName + " : " + name );
257 ui.vlmListItem->setCurrentRow( vlmItemCount - 1 );
259 /* Add a new VLMAWidget on the main List */
261 vlmItemLayout->insertWidget( vlmItemCount, vlmAwidget );
262 vlmItems.append( vlmAwidget );
266 /* TODO : VOD are not exported to the file */
267 bool VLMDialog::exportVLMConf()
269 QString saveVLMConfFileName = QFileDialog::getSaveFileName( this,
270 qtr( "Save VLM configuration as..." ),
271 QVLCUserDir( VLC_DOCUMENTS_DIR ),
272 qtr( "VLM conf (*.vlm);;All (*)" ) );
274 if( !saveVLMConfFileName.isEmpty() )
276 vlm_message_t *message;
277 QString command = "save \"" + saveVLMConfFileName + "\"";
278 vlm_ExecuteCommand( p_vlm , qtu( command ) , &message );
279 vlm_MessageDelete( message );
286 void VLMDialog::mediasPopulator()
291 QString typeShortName;
293 vlm_media_t ***ppp_dsc = (vlm_media_t ***)malloc( sizeof( vlm_media_t** ) );
295 /* Get medias information and numbers */
296 vlm_Control( p_vlm, VLM_GET_MEDIAS, ppp_dsc, &i_nMedias );
298 /* Loop on all of them */
299 for( int i = 0; i < i_nMedias; i++ )
301 VLMAWidget * vlmAwidget;
302 vlmItemCount = vlmItems.count();
304 QString mediaName = qfu( (*ppp_dsc)[i]->psz_name );
305 /* It may have several inputs, we take the first one by default
306 - an evolution will be to manage these inputs in the gui */
307 QString inputText = qfu( (*ppp_dsc)[i]->ppsz_input[0] );
309 QString outputText = qfu( (*ppp_dsc)[i]->psz_output );
311 /* Schedule media is a quite especial, maybe there is another way to grab information */
312 if( (*ppp_dsc)[i]->b_vod )
314 typeShortName = "VOD";
315 QString mux = qfu( (*ppp_dsc)[i]->vod.psz_mux );
316 vlmAwidget = new VLMVod( mediaName, inputText, inputOptions,
317 outputText, (*ppp_dsc)[i]->b_enabled,
322 typeShortName = "Bcast";
323 vlmAwidget = new VLMBroadcast( mediaName, inputText, inputOptions,
324 outputText, (*ppp_dsc)[i]->b_enabled,
325 (*ppp_dsc)[i]->broadcast.b_loop, this );
327 /* Add an Item of the Side List */
328 ui.vlmListItem->addItem( typeShortName + " : " + mediaName );
329 ui.vlmListItem->setCurrentRow( vlmItemCount - 1 );
331 /* Add a new VLMAWidget on the main List */
332 vlmItemLayout->insertWidget( vlmItemCount, vlmAwidget );
333 vlmItems.append( vlmAwidget );
340 bool VLMDialog::importVLMConf()
342 QString openVLMConfFileName = toNativeSeparators(
343 QFileDialog::getOpenFileName(
344 this, qtr( "Open VLM configuration..." ),
345 QVLCUserDir( VLC_DOCUMENTS_DIR ),
346 qtr( "VLM conf (*.vlm);;All (*)" ) ) );
348 if( !openVLMConfFileName.isEmpty() )
350 vlm_message_t *message;
352 QString command = "load \"" + openVLMConfFileName + "\"";
353 status = vlm_ExecuteCommand( p_vlm, qtu( command ) , &message );
354 vlm_MessageDelete( message );
361 msg_Warn( p_intf, "Failed to import vlm configuration file : %s", qtu( command ) );
369 void VLMDialog::clearWidgets()
371 ui.nameLedit->clear();
372 ui.inputLedit->clear();
373 inputOptions.clear();
374 ui.outputLedit->clear();
375 time->setTime( QTime::currentTime() );
376 date->setDate( QDate::currentDate() );
377 ui.enableCheck->setChecked( true );
378 ui.nameLedit->setReadOnly( false );
379 ui.loopBCast->setChecked( false );
380 ui.muxLedit->clear();
381 ui.saveButton->hide();
382 ui.addButton->show();
385 void VLMDialog::selectInput()
387 OpenDialog *o = OpenDialog::getInstance( this, p_intf, false, SELECT, true );
389 ui.inputLedit->setText( o->getMRL( false ) );
390 inputOptions = o->getOptions();
393 void VLMDialog::selectOutput()
395 SoutDialog *s = new SoutDialog( this, p_intf );
396 if( s->exec() == QDialog::Accepted )
398 int i = s->getMrl().indexOf( " " );
399 ui.outputLedit->setText( s->getMrl().left( i ) );
403 /* Object Modification */
404 void VLMDialog::removeVLMItem( VLMAWidget *vlmObj )
406 int index = vlmItems.indexOf( vlmObj );
407 if( index < 0 ) return;
408 delete ui.vlmListItem->takeItem( index );
409 vlmItems.removeAt( index );
412 /* HERE BE DRAGONS VLM REQUEST */
415 void VLMDialog::startModifyVLMItem( VLMAWidget *vlmObj )
417 currentIndex = vlmItems.indexOf( vlmObj );
418 if( currentIndex < 0 ) return;
420 ui.vlmListItem->setCurrentRow( currentIndex );
421 ui.nameLedit->setText( vlmObj->name );
422 ui.inputLedit->setText( vlmObj->input );
423 ui.outputLedit->setText( vlmObj->output );
424 ui.enableCheck->setChecked( vlmObj->b_enabled );
426 switch( vlmObj->type )
429 ui.loopBCast->setChecked( (qobject_cast<VLMBroadcast *>(vlmObj))->b_looped );
432 ui.muxLedit->setText( (qobject_cast<VLMVod *>(vlmObj))->mux );
435 time->setDateTime( ( qobject_cast<VLMSchedule *>(vlmObj))->schetime );
436 date->setDateTime( ( qobject_cast<VLMSchedule *>(vlmObj))->schedate );
440 ui.nameLedit->setReadOnly( true );
441 ui.addButton->hide();
442 ui.saveButton->show();
445 void VLMDialog::saveModifications()
447 VLMAWidget *vlmObj = vlmItems.at( currentIndex );
450 vlmObj->input = ui.inputLedit->text();
451 vlmObj->output = ui.outputLedit->text().remove( ":sout=" );
452 vlmObj->setChecked( ui.enableCheck->isChecked() );
453 vlmObj->b_enabled = ui.enableCheck->isChecked();
454 switch( vlmObj->type )
457 (qobject_cast<VLMBroadcast *>(vlmObj))->b_looped = ui.loopBCast->isChecked();
460 (qobject_cast<VLMVod *>(vlmObj))->mux = ui.muxLedit->text();
463 (qobject_cast<VLMSchedule *>(vlmObj))->schetime = time->dateTime();
464 (qobject_cast<VLMSchedule *>(vlmObj))->schedate = date->dateTime();
465 (qobject_cast<VLMSchedule *>(vlmObj))->rNumber = scherepeatnumber->value();
466 (qobject_cast<VLMSchedule *>(vlmObj))->rDays = repeatDays->value();
475 /*********************************
476 * VLMAWidget - Abstract class
477 ********************************/
479 VLMAWidget::VLMAWidget( const QString& _name, const QString& _input,
480 const QString& _inputOptions, const QString& _output,
481 bool _enabled, VLMDialog *_parent, int _type )
482 : QGroupBox( _name, _parent )
487 inputOptions = _inputOptions;
489 b_enabled = _enabled;
492 setCheckable( true );
493 setChecked( b_enabled );
495 objLayout = new QGridLayout( this );
496 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
498 nameLabel = new QLabel;
499 objLayout->addWidget( nameLabel, 0, 0, 1, 4 );
501 /*QLabel *time = new QLabel( "--:--/--:--" );
502 objLayout->addWidget( time, 1, 3, 1, 2 );*/
504 QToolButton *modifyButton = new QToolButton;
505 modifyButton->setIcon( QIcon( ":/menu/settings" ) );
506 modifyButton->setToolTip( qtr("Change") );
507 objLayout->addWidget( modifyButton, 0, 5 );
509 QToolButton *deleteButton = new QToolButton;
510 deleteButton->setIcon( QIcon( ":/menu/quit" ) );
511 deleteButton->setToolTip("Delete");
512 objLayout->addWidget( deleteButton, 0, 6 );
514 BUTTONACT( modifyButton, modify() );
515 BUTTONACT( deleteButton, del() );
516 CONNECT( this, clicked( bool ), this, toggleEnabled( bool ) );
519 void VLMAWidget::modify()
521 parent->startModifyVLMItem( this );
524 void VLMAWidget::del()
526 parent->removeVLMItem( this );
529 void VLMAWidget::toggleEnabled( bool b_enable )
531 VLMWrapper::EnableItem( name, b_enable );
537 VLMBroadcast::VLMBroadcast( const QString& _name, const QString& _input,
538 const QString& _inputOptions,
539 const QString& _output, bool _enabled,
540 bool _looped, VLMDialog *_parent )
541 : VLMAWidget( _name, _input, _inputOptions, _output,
542 _enabled, _parent, QVLM_Broadcast )
544 nameLabel->setText( qtr("Broadcast: ") + name );
545 type = QVLM_Broadcast;
548 playButton = new QToolButton;
549 playButton->setIcon( QIcon( ":/menu/play" ) );
550 playButton->setToolTip( qtr("Play") );
551 objLayout->addWidget( playButton, 1, 0 );
554 QToolButton *stopButton = new QToolButton;
555 stopButton->setIcon( QIcon( ":/toolbar/stop_b" ) );
556 stopButton->setToolTip( qtr("Stop") );
557 objLayout->addWidget( stopButton, 1, 1 );
559 loopButton = new QToolButton;
560 loopButton->setToolTip( qtr("Repeat") );
561 objLayout->addWidget( loopButton, 1, 2 );
563 BUTTONACT( playButton, togglePlayPause() );
564 BUTTONACT( stopButton, stop() );
565 BUTTONACT( loopButton, toggleLoop() );
570 void VLMBroadcast::update()
572 VLMWrapper::EditBroadcast( name, input, inputOptions, output, b_enabled, b_looped );
574 loopButton->setIcon( QIcon( ":/buttons/playlist/repeat_all" ) );
576 loopButton->setIcon( QIcon( ":/buttons/playlist/repeat_off" ) );
579 void VLMBroadcast::togglePlayPause()
583 VLMWrapper::ControlBroadcast( name, ControlBroadcastPause );
584 playButton->setIcon( QIcon( ":/menu/pause" ) );
588 VLMWrapper::ControlBroadcast( name, ControlBroadcastPlay );
589 playButton->setIcon( QIcon( ":/menu/play" ) );
591 b_playing = !b_playing;
594 void VLMBroadcast::toggleLoop()
596 b_enabled = !b_enabled;
600 void VLMBroadcast::stop()
602 VLMWrapper::ControlBroadcast( name, ControlBroadcastStop );
603 playButton->setIcon( QIcon( ":/menu/play" ) );
609 VLMSchedule::VLMSchedule( const QString& name_, const QString& input,
610 const QString& inputOptions,
611 const QString& output, QDateTime _schetime,
612 QDateTime _schedate, int _scherepeatnumber,
613 int _repeatDays, bool enabled, VLMDialog *parent )
614 : VLMAWidget( name_, input, inputOptions, output, enabled, parent,
617 nameLabel->setText( qtr("Schedule: ") + name );
618 schetime = _schetime;
619 schedate = _schedate;
620 rNumber = _scherepeatnumber;
622 type = QVLM_Schedule;
626 void VLMSchedule::update()
628 VLMWrapper::EditSchedule( name, input, inputOptions, output, schetime, schedate,
629 rNumber, rDays, b_enabled);
635 VLMVod::VLMVod( const QString& name_, const QString& input,
636 const QString& inputOptions, const QString& output,
637 bool enabled, const QString& _mux, VLMDialog *parent)
638 : VLMAWidget( name_, input, inputOptions, output, enabled, parent,
641 nameLabel->setText( qtr("VOD: ") + name );
644 muxLabel = new QLabel;
645 objLayout->addWidget( muxLabel, 1, 0 );
650 void VLMVod::update()
652 muxLabel->setText( mux );
653 VLMWrapper::EditVod( name, input, inputOptions, output, b_enabled, mux );
660 vlm_t * VLMWrapper::p_vlm = NULL;
662 VLMWrapper::VLMWrapper( vlm_t *_p_vlm )
667 VLMWrapper::~VLMWrapper()
672 void VLMWrapper::AddBroadcast( const QString& name, const QString& input,
673 const QString& inputOptions, const QString& output,
674 bool b_enabled, bool b_loop )
676 vlm_message_t *message;
677 QString command = "new \"" + name + "\" broadcast";
678 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
679 vlm_MessageDelete( message );
680 EditBroadcast( name, input, inputOptions, output, b_enabled, b_loop );
683 void VLMWrapper::EditBroadcast( const QString& name, const QString& input,
684 const QString& inputOptions, const QString& output,
685 bool b_enabled, bool b_loop )
687 vlm_message_t *message;
690 command = "setup \"" + name + "\" inputdel all";
691 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
692 vlm_MessageDelete( message );
694 if( !input.isEmpty() )
696 command = "setup \"" + name + "\" input \"" + input + "\"";
697 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
698 vlm_MessageDelete( message );
700 QStringList options = inputOptions.split( " :", QString::SkipEmptyParts );
701 for( int i = 0; i < options.count(); i++ )
703 command = "setup \"" + name + "\" option \"" + options[i].trimmed() + "\"";
704 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
705 vlm_MessageDelete( message );
709 if( !output.isEmpty() )
711 command = "setup \"" + name + "\" output \"" + output + "\"";
712 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
713 vlm_MessageDelete( message );
717 command = "setup \"" + name + "\" enabled";
718 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
719 vlm_MessageDelete( message );
723 command = "setup \"" + name + "\" loop";
724 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
725 vlm_MessageDelete( message );
729 void VLMWrapper::EnableItem( const QString& name, bool b_enable )
731 vlm_message_t *message;
732 QString command = "setup \"" + name + ( b_enable ? " enable" : " disable" );
733 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
734 vlm_MessageDelete( message );
737 void VLMWrapper::ControlBroadcast( const QString& name, int BroadcastStatus,
740 vlm_message_t *message;
742 QString command = "control \"" + name + "\"";
743 switch( BroadcastStatus )
745 case ControlBroadcastPlay:
748 case ControlBroadcastPause:
751 case ControlBroadcastStop:
754 case ControlBroadcastSeek:
755 command += " seek " + QString::number( seek );
758 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
759 vlm_MessageDelete( message );
762 void VLMWrapper::AddVod( const QString& name, const QString& input,
763 const QString& inputOptions, const QString& output,
764 bool b_enabled, const QString& mux )
766 vlm_message_t *message;
767 QString command = "new \"" + name + "\" vod";
768 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
769 vlm_MessageDelete( message );
770 EditVod( name, input, inputOptions, output, b_enabled, mux );
773 void VLMWrapper::EditVod( const QString& name, const QString& input,
774 const QString& inputOptions, const QString& output,
778 vlm_message_t *message;
781 if( !input.isEmpty() )
783 command = "setup \"" + name + "\" input \"" + input + "\"";
784 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
785 vlm_MessageDelete( message );
787 QStringList options = inputOptions.split( " :", QString::SkipEmptyParts );
788 for( int i = 0; i < options.count(); i++ )
790 command = "setup \"" + name + "\" option \"" + options[i].trimmed() + "\"";
791 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
792 vlm_MessageDelete( message );
796 if( !output.isEmpty() )
798 command = "setup \"" + name + "\" output \"" + output + "\"";
799 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
800 vlm_MessageDelete( message );
805 command = "setup \"" + name + "\" enabled";
806 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
807 vlm_MessageDelete( message );
811 command = "setup \"" + name + "\" mux \"" + mux + "\"";
812 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
813 vlm_MessageDelete( message );
817 void VLMWrapper::AddSchedule( const QString& name, const QString& input,
818 const QString& inputOptions, const QString& output,
819 QDateTime _schetime, QDateTime _schedate,
820 int _scherepeatnumber, int _repeatDays,
821 bool b_enabled, const QString& mux )
823 vlm_message_t *message;
824 QString command = "new \"" + name + "\" schedule";
825 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
826 vlm_MessageDelete( message );
827 EditSchedule( name, input, inputOptions, output, _schetime, _schedate,
828 _scherepeatnumber, _repeatDays, b_enabled, mux );
831 void VLMWrapper::EditSchedule( const QString& name, const QString& input,
832 const QString& inputOptions, const QString& output,
833 QDateTime _schetime, QDateTime _schedate,
834 int _scherepeatnumber, int _repeatDays,
835 bool b_enabled, const QString& mux )
837 vlm_message_t *message;
840 if( !input.isEmpty() )
842 command = "setup \"" + name + "\" input \"" + input + "\"";
843 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
844 vlm_MessageDelete( message );
846 QStringList options = inputOptions.split( " :", QString::SkipEmptyParts );
847 for( int i = 0; i < options.count(); i++ )
849 command = "setup \"" + name + "\" option \"" + options[i].trimmed() + "\"";
850 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
851 vlm_MessageDelete( message );
855 if( !output.isEmpty() )
857 command = "setup \"" + name + "\" output \"" + output + "\"";
858 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
859 vlm_MessageDelete( message );
864 command = "setup \"" + name + "\" enabled";
865 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
866 vlm_MessageDelete( message );
871 command = "setup \"" + name + "\" mux \"" + mux + "\"";
872 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
873 vlm_MessageDelete( message );
876 command = "setup \"" + name + "\" date \"" +
877 _schedate.toString( "yyyy/MM/dd" )+ "-" +
878 _schetime.toString( "hh:mm:ss" ) + "\"";
879 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
880 vlm_MessageDelete( message );
882 if( _scherepeatnumber > 0 )
884 command = "setup \"" + name + "\" repeat \"" + _scherepeatnumber + "\"";
885 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
886 vlm_MessageDelete( message );
889 if( _repeatDays > 0 )
891 command = "setup \"" + name + "\" period \"" + _repeatDays + "\"";
892 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
893 vlm_MessageDelete( message );
897 void VLMDialog::toggleVisible()
899 qDeleteAll( vlmItems );
902 ui.vlmListItem->clear();
904 QVLCDialog::toggleVisible();