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::AcceptRole );
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() );
158 //readSettings( "VLM", QSize( 700, 500 ) );
161 VLMDialog::~VLMDialog()
165 //writeSettings( "VLM" );
166 /* TODO :you have to destroy vlm here to close
167 * but we shouldn't destroy vlm here in case somebody else wants it */
174 void VLMDialog::showScheduleWidget( int i )
176 ui.schedBox->setVisible( ( i == QVLM_Schedule ) );
177 ui.loopBCast->setVisible( ( i == QVLM_Broadcast ) );
178 ui.vodBox->setVisible( ( i == QVLM_VOD ) );
181 void VLMDialog::selectVLMItem( int i )
184 ui.vlmItemScroll->ensureWidgetVisible( vlmItems.at( i ) );
187 bool VLMDialog::isNameGenuine( const QString& name )
189 for( int i = 0; i < vlmItems.size(); i++ )
191 if( vlmItems.at( i )->name == name )
197 void VLMDialog::addVLMItem()
199 int vlmItemCount = vlmItems.size();
201 /* Take the name and Check it */
202 QString name = ui.nameLedit->text();
203 if( name.isEmpty() || !isNameGenuine( name ) )
205 msg_Err( p_intf, "VLM Name is empty or already exists, I can't do it" );
209 int type = ui.mediaType->itemData( ui.mediaType->currentIndex() ).toInt();
211 QString typeShortName;
212 QString inputText = ui.inputLedit->text();
213 QString outputText = ui.outputLedit->text();
214 bool b_checked = ui.enableCheck->isChecked();
215 bool b_looped = ui.loopBCast->isChecked();
216 QDateTime schetime = time->dateTime();
217 QDateTime schedate = date->dateTime();
218 int repeatnum = scherepeatnumber->value();
219 int repeatdays = repeatDays->value();
220 VLMAWidget * vlmAwidget;
221 outputText.remove( ":sout=" );
226 typeShortName = "Bcast";
227 vlmAwidget = new VLMBroadcast( name, inputText, inputOptions, outputText,
228 b_checked, b_looped, this );
229 VLMWrapper::AddBroadcast( name, inputText, inputOptions, outputText, b_checked,
233 typeShortName = "VOD";
234 vlmAwidget = new VLMVod( name, inputText, inputOptions, outputText,
235 b_checked, ui.muxLedit->text(), this );
236 VLMWrapper::AddVod( name, inputText, inputOptions, outputText, b_checked );
239 typeShortName = "Sched";
240 vlmAwidget = new VLMSchedule( name, inputText, inputOptions, outputText,
241 schetime, schedate, repeatnum,
242 repeatdays, b_checked, this );
243 VLMWrapper::AddSchedule( name, inputText, inputOptions, outputText, schetime,
244 schedate, repeatnum, repeatdays, b_checked);
247 msg_Warn( p_intf, "Something bad happened" );
251 /* Add an Item of the Side List */
252 ui.vlmListItem->addItem( typeShortName + " : " + name );
253 ui.vlmListItem->setCurrentRow( vlmItemCount - 1 );
255 /* Add a new VLMAWidget on the main List */
257 vlmItemLayout->insertWidget( vlmItemCount, vlmAwidget );
258 vlmItems.append( vlmAwidget );
262 /* TODO : VOD are not exported to the file */
263 bool VLMDialog::exportVLMConf()
265 QString saveVLMConfFileName = QFileDialog::getSaveFileName( this,
266 qtr( "Save VLM configuration as..." ),
267 QVLCUserDir( VLC_DOCUMENTS_DIR ),
268 qtr( "VLM conf (*.vlm);;All (*)" ) );
270 if( !saveVLMConfFileName.isEmpty() )
272 vlm_message_t *message;
273 QString command = "save \"" + saveVLMConfFileName + "\"";
274 vlm_ExecuteCommand( p_vlm , qtu( command ) , &message );
275 vlm_MessageDelete( message );
282 void VLMDialog::mediasPopulator()
287 QString typeShortName;
289 vlm_media_t ***ppp_dsc = (vlm_media_t ***)malloc( sizeof( vlm_media_t ) );
291 /* Get medias information and numbers */
292 vlm_Control( p_vlm, VLM_GET_MEDIAS, ppp_dsc, &i_nMedias );
294 /* Loop on all of them */
295 for( int i = 0; i < i_nMedias; i++ )
297 VLMAWidget * vlmAwidget;
298 vlmItemCount = vlmItems.size();
300 QString mediaName = qfu( (*ppp_dsc)[i]->psz_name );
301 /* It may have several inputs, we take the first one by default
302 - an evolution will be to manage these inputs in the gui */
303 QString inputText = qfu( (*ppp_dsc)[i]->ppsz_input[0] );
305 QString outputText = qfu( (*ppp_dsc)[i]->psz_output );
307 /* Schedule media is a quite especial, maybe there is another way to grab information */
308 if( (*ppp_dsc)[i]->b_vod )
310 typeShortName = "VOD";
311 QString mux = qfu( (*ppp_dsc)[i]->vod.psz_mux );
312 vlmAwidget = new VLMVod( mediaName, inputText, inputOptions,
313 outputText, (*ppp_dsc)[i]->b_enabled,
318 typeShortName = "Bcast";
319 vlmAwidget = new VLMBroadcast( mediaName, inputText, inputOptions,
320 outputText, (*ppp_dsc)[i]->b_enabled,
321 (*ppp_dsc)[i]->broadcast.b_loop, this );
323 /* Add an Item of the Side List */
324 ui.vlmListItem->addItem( typeShortName + " : " + mediaName );
325 ui.vlmListItem->setCurrentRow( vlmItemCount - 1 );
327 /* Add a new VLMAWidget on the main List */
328 vlmItemLayout->insertWidget( vlmItemCount, vlmAwidget );
329 vlmItems.append( vlmAwidget );
336 bool VLMDialog::importVLMConf()
338 QString openVLMConfFileName = toNativeSeparators(
339 QFileDialog::getOpenFileName(
340 this, qtr( "Open VLM configuration..." ),
341 QVLCUserDir( VLC_DOCUMENTS_DIR ),
342 qtr( "VLM conf (*.vlm);;All (*)" ) ) );
344 if( !openVLMConfFileName.isEmpty() )
346 vlm_message_t *message;
348 QString command = "load \"" + openVLMConfFileName + "\"";
349 status = vlm_ExecuteCommand( p_vlm, qtu( command ) , &message );
350 vlm_MessageDelete( message );
357 msg_Warn( p_intf, "Failed to import vlm configuration file : %s", qtu( command ) );
365 void VLMDialog::clearWidgets()
367 ui.nameLedit->clear();
368 ui.inputLedit->clear();
369 inputOptions.clear();
370 ui.outputLedit->clear();
371 time->setTime( QTime::currentTime() );
372 date->setDate( QDate::currentDate() );
373 ui.enableCheck->setChecked( true );
374 ui.nameLedit->setReadOnly( false );
375 ui.loopBCast->setChecked( false );
376 ui.muxLedit->clear();
377 ui.saveButton->hide();
378 ui.addButton->show();
381 void VLMDialog::selectInput()
383 OpenDialog *o = OpenDialog::getInstance( this, p_intf, false, SELECT, true );
385 ui.inputLedit->setText( o->getMRL( false ) );
386 inputOptions = o->getOptions();
389 void VLMDialog::selectOutput()
391 SoutDialog *s = new SoutDialog( this, p_intf );
392 if( s->exec() == QDialog::Accepted )
394 int i = s->getMrl().indexOf( " " );
395 ui.outputLedit->setText( s->getMrl().left( i ) );
399 /* Object Modification */
400 void VLMDialog::removeVLMItem( VLMAWidget *vlmObj )
402 int index = vlmItems.indexOf( vlmObj );
403 if( index < 0 ) return;
404 delete ui.vlmListItem->takeItem( index );
405 vlmItems.removeAt( index );
408 /* HERE BE DRAGONS VLM REQUEST */
411 void VLMDialog::startModifyVLMItem( VLMAWidget *vlmObj )
413 currentIndex = vlmItems.indexOf( vlmObj );
414 if( currentIndex < 0 ) return;
416 ui.vlmListItem->setCurrentRow( currentIndex );
417 ui.nameLedit->setText( vlmObj->name );
418 ui.inputLedit->setText( vlmObj->input );
419 ui.outputLedit->setText( vlmObj->output );
420 ui.enableCheck->setChecked( vlmObj->b_enabled );
422 switch( vlmObj->type )
425 ui.loopBCast->setChecked( (qobject_cast<VLMBroadcast *>(vlmObj))->b_looped );
428 ui.muxLedit->setText( (qobject_cast<VLMVod *>(vlmObj))->mux );
431 time->setDateTime( ( qobject_cast<VLMSchedule *>(vlmObj))->schetime );
432 date->setDateTime( ( qobject_cast<VLMSchedule *>(vlmObj))->schedate );
436 ui.nameLedit->setReadOnly( true );
437 ui.addButton->hide();
438 ui.saveButton->show();
441 void VLMDialog::saveModifications()
443 VLMAWidget *vlmObj = vlmItems.at( currentIndex );
446 vlmObj->input = ui.inputLedit->text();
447 vlmObj->output = ui.outputLedit->text().remove( ":sout=" );
448 vlmObj->setChecked( ui.enableCheck->isChecked() );
449 vlmObj->b_enabled = ui.enableCheck->isChecked();
450 switch( vlmObj->type )
453 (qobject_cast<VLMBroadcast *>(vlmObj))->b_looped = ui.loopBCast->isChecked();
456 (qobject_cast<VLMVod *>(vlmObj))->mux = ui.muxLedit->text();
459 (qobject_cast<VLMSchedule *>(vlmObj))->schetime = time->dateTime();
460 (qobject_cast<VLMSchedule *>(vlmObj))->schedate = date->dateTime();
461 (qobject_cast<VLMSchedule *>(vlmObj))->rNumber = scherepeatnumber->value();
462 (qobject_cast<VLMSchedule *>(vlmObj))->rDays = repeatDays->value();
471 /*********************************
472 * VLMAWidget - Abstract class
473 ********************************/
475 VLMAWidget::VLMAWidget( const QString& _name, const QString& _input,
476 const QString& _inputOptions, const QString& _output,
477 bool _enabled, VLMDialog *_parent, int _type )
478 : QGroupBox( _name, _parent )
483 inputOptions = _inputOptions;
485 b_enabled = _enabled;
488 setCheckable( true );
489 setChecked( b_enabled );
491 objLayout = new QGridLayout( this );
492 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
494 nameLabel = new QLabel;
495 objLayout->addWidget( nameLabel, 0, 0, 1, 4 );
497 /*QLabel *time = new QLabel( "--:--/--:--" );
498 objLayout->addWidget( time, 1, 3, 1, 2 );*/
500 QToolButton *modifyButton = new QToolButton;
501 modifyButton->setIcon( QIcon( ":/menu/settings" ) );
502 modifyButton->setToolTip( qtr("Change") );
503 objLayout->addWidget( modifyButton, 0, 5 );
505 QToolButton *deleteButton = new QToolButton;
506 deleteButton->setIcon( QIcon( ":/menu/quit" ) );
507 deleteButton->setToolTip("Delete");
508 objLayout->addWidget( deleteButton, 0, 6 );
510 BUTTONACT( modifyButton, modify() );
511 BUTTONACT( deleteButton, del() );
512 CONNECT( this, clicked( bool ), this, toggleEnabled( bool ) );
515 void VLMAWidget::modify()
517 parent->startModifyVLMItem( this );
520 void VLMAWidget::del()
522 parent->removeVLMItem( this );
525 void VLMAWidget::toggleEnabled( bool b_enable )
527 VLMWrapper::EnableItem( name, b_enable );
533 VLMBroadcast::VLMBroadcast( const QString& _name, const QString& _input,
534 const QString& _inputOptions,
535 const QString& _output, bool _enabled,
536 bool _looped, VLMDialog *_parent )
537 : VLMAWidget( _name, _input, _inputOptions, _output,
538 _enabled, _parent, QVLM_Broadcast )
540 nameLabel->setText( qtr("Broadcast: ") + name );
541 type = QVLM_Broadcast;
544 playButton = new QToolButton;
545 playButton->setIcon( QIcon( ":/menu/play" ) );
546 playButton->setToolTip( qtr("Play") );
547 objLayout->addWidget( playButton, 1, 0 );
550 QToolButton *stopButton = new QToolButton;
551 stopButton->setIcon( QIcon( ":/toolbar/stop_b" ) );
552 stopButton->setToolTip( qtr("Stop") );
553 objLayout->addWidget( stopButton, 1, 1 );
555 loopButton = new QToolButton;
556 loopButton->setToolTip( qtr("Repeat") );
557 objLayout->addWidget( loopButton, 1, 2 );
559 BUTTONACT( playButton, togglePlayPause() );
560 BUTTONACT( stopButton, stop() );
561 BUTTONACT( loopButton, toggleLoop() );
566 void VLMBroadcast::update()
568 VLMWrapper::EditBroadcast( name, input, inputOptions, output, b_enabled, b_looped );
570 loopButton->setIcon( QIcon( ":/buttons/playlist/repeat_all" ) );
572 loopButton->setIcon( QIcon( ":/buttons/playlist/repeat_off" ) );
575 void VLMBroadcast::togglePlayPause()
579 VLMWrapper::ControlBroadcast( name, ControlBroadcastPause );
580 playButton->setIcon( QIcon( ":/menu/pause" ) );
584 VLMWrapper::ControlBroadcast( name, ControlBroadcastPlay );
585 playButton->setIcon( QIcon( ":/menu/play" ) );
587 b_playing = !b_playing;
590 void VLMBroadcast::toggleLoop()
592 b_enabled = !b_enabled;
596 void VLMBroadcast::stop()
598 VLMWrapper::ControlBroadcast( name, ControlBroadcastStop );
599 playButton->setIcon( QIcon( ":/menu/play" ) );
605 VLMSchedule::VLMSchedule( const QString& name, const QString& input,
606 const QString& inputOptions,
607 const QString& output, QDateTime _schetime,
608 QDateTime _schedate, int _scherepeatnumber,
609 int _repeatDays, bool enabled, VLMDialog *parent )
610 : VLMAWidget( name, input, inputOptions, output, enabled, parent,
613 nameLabel->setText( qtr("Schedule: ") + name );
614 schetime = _schetime;
615 schedate = _schedate;
616 rNumber = _scherepeatnumber;
618 type = QVLM_Schedule;
622 void VLMSchedule::update()
624 VLMWrapper::EditSchedule( name, input, inputOptions, output, schetime, schedate,
625 rNumber, rDays, b_enabled);
631 VLMVod::VLMVod( const QString& name, const QString& input,
632 const QString& inputOptions, const QString& output,
633 bool enabled, const QString& _mux, VLMDialog *parent)
634 : VLMAWidget( name, input, inputOptions, output, enabled, parent,
637 nameLabel->setText( qtr("VOD: ") + name );
640 muxLabel = new QLabel;
641 objLayout->addWidget( muxLabel, 1, 0 );
646 void VLMVod::update()
648 muxLabel->setText( mux );
649 VLMWrapper::EditVod( name, input, inputOptions, output, b_enabled, mux );
656 vlm_t * VLMWrapper::p_vlm = NULL;
658 VLMWrapper::VLMWrapper( vlm_t *_p_vlm )
663 VLMWrapper::~VLMWrapper()
668 void VLMWrapper::AddBroadcast( const QString& name, const QString& input,
669 const QString& inputOptions, const QString& output,
670 bool b_enabled, bool b_loop )
672 vlm_message_t *message;
673 QString command = "new \"" + name + "\" broadcast";
674 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
675 vlm_MessageDelete( message );
676 EditBroadcast( name, input, inputOptions, output, b_enabled, b_loop );
679 void VLMWrapper::EditBroadcast( const QString& name, const QString& input,
680 const QString& inputOptions, const QString& output,
681 bool b_enabled, bool b_loop )
683 vlm_message_t *message;
686 command = "setup \"" + name + "\" inputdel all";
687 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
688 vlm_MessageDelete( message );
690 if( !input.isEmpty() )
692 command = "setup \"" + name + "\" input \"" + input + "\"";
693 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
694 vlm_MessageDelete( message );
696 QStringList options = inputOptions.split( " :", QString::SkipEmptyParts );
697 for( int i = 0; i < options.size(); i++ )
699 command = "setup \"" + name + "\" option \"" + options[i].trimmed() + "\"";
700 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
701 vlm_MessageDelete( message );
705 if( !output.isEmpty() )
707 command = "setup \"" + name + "\" output \"" + output + "\"";
708 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
709 vlm_MessageDelete( message );
713 command = "setup \"" + name + "\" enabled";
714 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
715 vlm_MessageDelete( message );
719 command = "setup \"" + name + "\" loop";
720 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
721 vlm_MessageDelete( message );
725 void VLMWrapper::EnableItem( const QString& name, bool b_enable )
727 vlm_message_t *message;
728 QString command = "setup \"" + name + ( b_enable ? " enable" : " disable" );
729 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
730 vlm_MessageDelete( message );
733 void VLMWrapper::ControlBroadcast( const QString& name, int BroadcastStatus,
736 vlm_message_t *message;
738 QString command = "control \"" + name + "\"";
739 switch( BroadcastStatus )
741 case ControlBroadcastPlay:
744 case ControlBroadcastPause:
747 case ControlBroadcastStop:
750 case ControlBroadcastSeek:
751 command += " seek" + seek;
754 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
755 vlm_MessageDelete( message );
758 void VLMWrapper::AddVod( const QString& name, const QString& input,
759 const QString& inputOptions, const QString& output,
760 bool b_enabled, const QString& mux )
762 vlm_message_t *message;
763 QString command = "new \"" + name + "\" vod";
764 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
765 vlm_MessageDelete( message );
766 EditVod( name, input, inputOptions, output, b_enabled, mux );
769 void VLMWrapper::EditVod( const QString& name, const QString& input,
770 const QString& inputOptions, const QString& output,
774 vlm_message_t *message;
777 if( !input.isEmpty() )
779 command = "setup \"" + name + "\" input \"" + input + "\"";
780 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
781 vlm_MessageDelete( message );
783 QStringList options = inputOptions.split( " :", QString::SkipEmptyParts );
784 for( int i = 0; i < options.size(); i++ )
786 command = "setup \"" + name + "\" option \"" + options[i].trimmed() + "\"";
787 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
788 vlm_MessageDelete( message );
792 if( !output.isEmpty() )
794 command = "setup \"" + name + "\" output \"" + output + "\"";
795 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
796 vlm_MessageDelete( message );
801 command = "setup \"" + name + "\" enabled";
802 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
803 vlm_MessageDelete( message );
807 command = "setup \"" + name + "\" mux \"" + mux + "\"";
808 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
809 vlm_MessageDelete( message );
813 void VLMWrapper::AddSchedule( const QString& name, const QString& input,
814 const QString& inputOptions, const QString& output,
815 QDateTime _schetime, QDateTime _schedate,
816 int _scherepeatnumber, int _repeatDays,
817 bool b_enabled, const QString& mux )
819 vlm_message_t *message;
820 QString command = "new \"" + name + "\" schedule";
821 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
822 vlm_MessageDelete( message );
823 EditSchedule( name, input, inputOptions, output, _schetime, _schedate,
824 _scherepeatnumber, _repeatDays, b_enabled, mux );
827 void VLMWrapper::EditSchedule( const QString& name, const QString& input,
828 const QString& inputOptions, const QString& output,
829 QDateTime _schetime, QDateTime _schedate,
830 int _scherepeatnumber, int _repeatDays,
831 bool b_enabled, const QString& mux )
833 vlm_message_t *message;
836 if( !input.isEmpty() )
838 command = "setup \"" + name + "\" input \"" + input + "\"";
839 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
840 vlm_MessageDelete( message );
842 QStringList options = inputOptions.split( " :", QString::SkipEmptyParts );
843 for( int i = 0; i < options.size(); i++ )
845 command = "setup \"" + name + "\" option \"" + options[i].trimmed() + "\"";
846 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
847 vlm_MessageDelete( message );
851 if( !output.isEmpty() )
853 command = "setup \"" + name + "\" output \"" + output + "\"";
854 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
855 vlm_MessageDelete( message );
860 command = "setup \"" + name + "\" enabled";
861 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
862 vlm_MessageDelete( message );
867 command = "setup \"" + name + "\" mux \"" + mux + "\"";
868 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
869 vlm_MessageDelete( message );
872 command = "setup \"" + name + "\" date \"" +
873 _schedate.toString( "yyyy/MM/dd" )+ "-" +
874 _schetime.toString( "hh:mm:ss" ) + "\"";
875 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
876 vlm_MessageDelete( message );
878 if( _scherepeatnumber > 0 )
880 command = "setup \"" + name + "\" repeat \"" + _scherepeatnumber + "\"";
881 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
882 vlm_MessageDelete( message );
885 if( _repeatDays > 0 )
887 command = "setup \"" + name + "\" period \"" + _repeatDays + "\"";
888 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
889 vlm_MessageDelete( message );
893 void VLMDialog::toggleVisible()
895 QList<VLMAWidget *>::iterator it;
896 for( it = vlmItems.begin(); it != vlmItems.end(); ++it )
898 VLMAWidget *item = *it;
903 ui.vlmListItem->clear();
905 QVLCDialog::toggleVisible();