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 <QHeaderView>
54 #include <QScrollArea>
55 #include <QFileDialog>
58 VLMDialog::VLMDialog( intf_thread_t *_p_intf ) : QVLCDialog( (QWidget*)_p_intf->p_sys->p_mi, _p_intf )
60 p_vlm = vlm_New( p_intf );
64 msg_Warn( p_intf, "Couldn't build VLM object ");
67 vlmWrapper = new VLMWrapper( p_vlm );
71 ui.saveButton->hide();
73 #define ADDMEDIATYPES( str, type ) ui.mediaType->addItem( qtr( str ), QVariant( type ) );
74 ADDMEDIATYPES( N_("Broadcast"), QVLM_Broadcast );
75 ADDMEDIATYPES( N_("Schedule"), QVLM_Schedule );
76 ADDMEDIATYPES( N_("Video On Demand ( VOD )"), QVLM_VOD );
80 QGridLayout *schetimelayout = new QGridLayout( ui.schedBox );
81 QLabel *schetimelabel = new QLabel( qtr( "Hours / Minutes / Seconds:" ) );
82 schetimelayout->addWidget( schetimelabel, 0, 0 );
83 QLabel *schedatelabel = new QLabel( qtr( "Day / Month / Year:" ) );
84 schetimelayout->addWidget( schedatelabel, 1, 0 );
85 QLabel *scherepeatLabel = new QLabel( qtr( "Repeat:" ) );
86 schetimelayout->addWidget( scherepeatLabel, 2, 0 );
87 QLabel *scherepeatTimeLabel = new QLabel( qtr( "Repeat delay:" ) );
88 schetimelayout->addWidget( scherepeatTimeLabel, 3, 0 );
90 time = new QDateTimeEdit( QTime::currentTime() );
91 time->setAlignment( Qt::AlignRight );
92 time->setDisplayFormat( "hh:mm:ss" );
93 schetimelayout->addWidget( time, 0, 1, 1, 3 );
95 date = new QDateTimeEdit( QDate::currentDate() );
96 date->setAlignment( Qt::AlignRight );
97 date->setCalendarPopup( true );
99 date->setDisplayFormat( "dd MM yyyy" );
101 date->setDisplayFormat( "dd MMMM yyyy" );
103 schetimelayout->addWidget( date, 1, 1, 1, 3 );
105 scherepeatnumber = new QSpinBox;
106 scherepeatnumber->setAlignment( Qt::AlignRight );
107 schetimelayout->addWidget( scherepeatnumber, 2, 1, 1, 3 );
109 repeatDays = new QSpinBox;
110 repeatDays->setAlignment( Qt::AlignRight );
111 schetimelayout->addWidget( repeatDays, 3, 1, 1, 1 );
112 repeatDays->setSuffix( qtr(" days") );
114 repeatTime = new QDateTimeEdit;
115 repeatTime->setAlignment( Qt::AlignRight );
116 schetimelayout->addWidget( repeatTime, 3, 2, 1, 2 );
117 repeatTime->setDisplayFormat( "hh:mm:ss" );
120 ui.vlmItemScroll->setFrameStyle( QFrame::NoFrame );
121 ui.vlmItemScroll->setWidgetResizable( true );
122 vlmItemWidget = new QWidget;
123 vlmItemLayout = new QVBoxLayout( vlmItemWidget );
124 vlmItemWidget->setLayout( vlmItemLayout );
125 ui.vlmItemScroll->setWidget( vlmItemWidget );
127 QSpacerItem *spacer =
128 new QSpacerItem( 10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding);
129 vlmItemLayout->addItem( spacer );
131 QPushButton *importButton = new QPushButton( qtr( "I&mport" ) );
132 ui.buttonBox->addButton( importButton, QDialogButtonBox::ActionRole );
134 QPushButton *exportButton = new QPushButton( qtr( "E&xport" ) );
135 ui.buttonBox->addButton( exportButton, QDialogButtonBox::ActionRole );
137 QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
138 ui.buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
141 showScheduleWidget( QVLM_Broadcast );
143 /* Connect the comboBox to show the right Widgets */
144 CONNECT( ui.mediaType, currentIndexChanged( int ),
145 this, showScheduleWidget( int ) );
147 /* Connect the leftList to show the good VLMItem */
148 CONNECT( ui.vlmListItem, currentRowChanged( int ),
149 this, selectVLMItem( int ) );
151 BUTTONACT( closeButton, close() );
152 BUTTONACT( exportButton, exportVLMConf() );
153 BUTTONACT( importButton, importVLMConf() );
154 BUTTONACT( ui.addButton, addVLMItem() );
155 BUTTONACT( ui.clearButton, clearWidgets() );
156 BUTTONACT( ui.saveButton, saveModifications() );
157 BUTTONACT( ui.inputButton, selectInput() );
158 BUTTONACT( ui.outputButton, selectOutput() );
159 //readSettings( "VLM", QSize( 700, 500 ) );
162 VLMDialog::~VLMDialog()
166 //writeSettings( "VLM" );
167 /* TODO :you have to destroy vlm here to close
168 * but we shouldn't destroy vlm here in case somebody else wants it */
175 void VLMDialog::showScheduleWidget( int i )
177 ui.schedBox->setVisible( ( i == QVLM_Schedule ) );
178 ui.loopBCast->setVisible( ( i == QVLM_Broadcast ) );
179 ui.vodBox->setVisible( ( i == QVLM_VOD ) );
182 void VLMDialog::selectVLMItem( int i )
185 ui.vlmItemScroll->ensureWidgetVisible( vlmItems.at( i ) );
188 bool VLMDialog::isNameGenuine( const QString& name )
190 for( int i = 0; i < vlmItems.size(); i++ )
192 if( vlmItems.at( i )->name == name )
198 void VLMDialog::addVLMItem()
200 int vlmItemCount = vlmItems.size();
202 /* Take the name and Check it */
203 QString name = ui.nameLedit->text();
204 if( name.isEmpty() || !isNameGenuine( name ) )
206 msg_Err( p_intf, "VLM Name is empty or already exists, I can't do it" );
210 int type = ui.mediaType->itemData( ui.mediaType->currentIndex() ).toInt();
212 QString typeShortName;
213 QString inputText = ui.inputLedit->text();
214 QString outputText = ui.outputLedit->text();
215 bool b_checked = ui.enableCheck->isChecked();
216 bool b_looped = ui.loopBCast->isChecked();
217 QDateTime schetime = time->dateTime();
218 QDateTime schedate = date->dateTime();
219 int repeatnum = scherepeatnumber->value();
220 int repeatdays = repeatDays->value();
221 VLMAWidget * vlmAwidget;
222 outputText.remove( ":sout=" );
227 typeShortName = "Bcast";
228 vlmAwidget = new VLMBroadcast( name, inputText, outputText,
229 b_checked, b_looped, this );
230 VLMWrapper::AddBroadcast( name, inputText, outputText, b_checked,
234 typeShortName = "VOD";
235 vlmAwidget = new VLMVod( name, inputText, outputText,
236 b_checked, ui.muxLedit->text(), this );
237 VLMWrapper::AddVod( name, inputText, outputText, b_checked );
240 typeShortName = "Sched";
241 vlmAwidget = new VLMSchedule( name, inputText, outputText,
242 schetime, schedate, repeatnum,
243 repeatdays, b_checked, this );
244 VLMWrapper::AddSchedule( name, inputText, outputText, schetime,
245 schedate, repeatnum, repeatdays, b_checked);
248 msg_Warn( p_intf, "Something bad happened" );
252 /* Add an Item of the Side List */
253 ui.vlmListItem->addItem( typeShortName + " : " + name );
254 ui.vlmListItem->setCurrentRow( vlmItemCount - 1 );
256 /* Add a new VLMAWidget on the main List */
258 vlmItemLayout->insertWidget( vlmItemCount, vlmAwidget );
259 vlmItems.append( vlmAwidget );
263 /* TODO : VOD are not exported to the file */
264 bool VLMDialog::exportVLMConf()
266 QString saveVLMConfFileName = QFileDialog::getSaveFileName( this,
267 qtr( "Save VLM configuration as..." ),
268 QVLCUserDir( VLC_DOCUMENTS_DIR ),
269 qtr( "VLM conf (*.vlm);;All (*)" ) );
271 if( !saveVLMConfFileName.isEmpty() )
273 vlm_message_t *message;
274 QString command = "save \"" + saveVLMConfFileName + "\"";
275 vlm_ExecuteCommand( p_vlm , qtu( command ) , &message );
276 vlm_MessageDelete( message );
283 void VLMDialog::mediasPopulator()
288 QString typeShortName;
290 vlm_media_t ***ppp_dsc = (vlm_media_t ***)malloc( sizeof( vlm_media_t ) );
292 /* Get medias informations and numbers */
293 vlm_Control( p_vlm, VLM_GET_MEDIAS, ppp_dsc, &i_nMedias );
295 /* Loop on all of them */
296 for( int i = 0; i < i_nMedias; i++ )
298 VLMAWidget * vlmAwidget;
299 vlmItemCount = vlmItems.size();
301 QString mediaName = qfu( (*ppp_dsc)[i]->psz_name );
302 /* It may have several inputs, we take the first one by default
303 - an evolution will be to manage these inputs in the gui */
304 QString inputText = qfu( (*ppp_dsc)[i]->ppsz_input[0] );
306 QString outputText = qfu( (*ppp_dsc)[i]->psz_output );
308 /* Schedule media is a quite especial, maybe there is another way to grab informations */
309 if( (*ppp_dsc)[i]->b_vod )
311 typeShortName = "VOD";
312 QString mux = qfu( (*ppp_dsc)[i]->vod.psz_mux );
313 vlmAwidget = new VLMVod( mediaName, inputText, outputText,
314 (*ppp_dsc)[i]->b_enabled, mux, this );
318 typeShortName = "Bcast";
319 vlmAwidget = new VLMBroadcast( mediaName, inputText, outputText,
320 (*ppp_dsc)[i]->b_enabled, (*ppp_dsc)[i]->broadcast.b_loop, this );
322 /* Add an Item of the Side List */
323 ui.vlmListItem->addItem( typeShortName + " : " + mediaName );
324 ui.vlmListItem->setCurrentRow( vlmItemCount - 1 );
326 /* Add a new VLMAWidget on the main List */
327 vlmItemLayout->insertWidget( vlmItemCount, vlmAwidget );
328 vlmItems.append( vlmAwidget );
335 bool VLMDialog::importVLMConf()
337 QString openVLMConfFileName = toNativeSeparators(
338 QFileDialog::getOpenFileName(
339 this, qtr( "Open VLM configuration..." ),
340 QVLCUserDir( VLC_DOCUMENTS_DIR ),
341 qtr( "VLM conf (*.vlm);;All (*)" ) ) );
343 if( !openVLMConfFileName.isEmpty() )
345 vlm_message_t *message;
347 QString command = "load \"" + openVLMConfFileName + "\"";
348 status = vlm_ExecuteCommand( p_vlm, qtu( command ) , &message );
349 vlm_MessageDelete( message );
356 msg_Warn( p_intf, "Failed to import vlm configuration file : %s", qtu( command ) );
364 void VLMDialog::clearWidgets()
366 ui.nameLedit->clear();
367 ui.inputLedit->clear();
368 ui.outputLedit->clear();
369 time->setTime( QTime::currentTime() );
370 date->setDate( QDate::currentDate() );
371 ui.enableCheck->setChecked( true );
372 ui.nameLedit->setReadOnly( false );
373 ui.loopBCast->setChecked( false );
374 ui.muxLedit->clear();
375 ui.saveButton->hide();
376 ui.addButton->show();
379 void VLMDialog::selectInput()
381 OpenDialog *o = OpenDialog::getInstance( this, p_intf, false, SELECT, true );
383 ui.inputLedit->setText( o->getMRL() );
386 void VLMDialog::selectOutput()
388 SoutDialog *s = new SoutDialog( this, p_intf );
389 if( s->exec() == QDialog::Accepted )
390 ui.outputLedit->setText( s->getMrl() );
393 /* Object Modification */
394 void VLMDialog::removeVLMItem( VLMAWidget *vlmObj )
396 int index = vlmItems.indexOf( vlmObj );
397 if( index < 0 ) return;
398 delete ui.vlmListItem->takeItem( index );
399 vlmItems.removeAt( index );
402 /* HERE BE DRAGONS VLM REQUEST */
405 void VLMDialog::startModifyVLMItem( VLMAWidget *vlmObj )
407 currentIndex = vlmItems.indexOf( vlmObj );
408 if( currentIndex < 0 ) return;
410 ui.vlmListItem->setCurrentRow( currentIndex );
411 ui.nameLedit->setText( vlmObj->name );
412 ui.inputLedit->setText( vlmObj->input );
413 ui.outputLedit->setText( vlmObj->output );
414 ui.enableCheck->setChecked( vlmObj->b_enabled );
416 switch( vlmObj->type )
419 ui.loopBCast->setChecked( (qobject_cast<VLMBroadcast *>(vlmObj))->b_looped );
422 ui.muxLedit->setText( (qobject_cast<VLMVod *>(vlmObj))->mux );
425 time->setDateTime( ( qobject_cast<VLMSchedule *>(vlmObj))->schetime );
426 date->setDateTime( ( qobject_cast<VLMSchedule *>(vlmObj))->schedate );
430 ui.nameLedit->setReadOnly( true );
431 ui.addButton->hide();
432 ui.saveButton->show();
435 void VLMDialog::saveModifications()
437 VLMAWidget *vlmObj = vlmItems.at( currentIndex );
440 vlmObj->input = ui.inputLedit->text();
441 vlmObj->output = ui.outputLedit->text().remove( ":sout=" );
442 vlmObj->setChecked( ui.enableCheck->isChecked() );
443 vlmObj->b_enabled = ui.enableCheck->isChecked();
444 switch( vlmObj->type )
447 (qobject_cast<VLMBroadcast *>(vlmObj))->b_looped = ui.loopBCast->isChecked();
450 (qobject_cast<VLMVod *>(vlmObj))->mux = ui.muxLedit->text();
453 (qobject_cast<VLMSchedule *>(vlmObj))->schetime = time->dateTime();
454 (qobject_cast<VLMSchedule *>(vlmObj))->schedate = date->dateTime();
455 (qobject_cast<VLMSchedule *>(vlmObj))->rNumber = scherepeatnumber->value();
456 (qobject_cast<VLMSchedule *>(vlmObj))->rDays = repeatDays->value();
465 /*********************************
466 * VLMAWidget - Abstract class
467 ********************************/
469 VLMAWidget::VLMAWidget( const QString& _name,
470 const QString& _input,
471 const QString& _output,
475 : QGroupBox( _name, _parent )
481 b_enabled = _enabled;
484 setCheckable( true );
485 setChecked( b_enabled );
487 objLayout = new QGridLayout( this );
488 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
490 nameLabel = new QLabel;
491 objLayout->addWidget( nameLabel, 0, 0, 1, 4 );
493 /*QLabel *time = new QLabel( "--:--/--:--" );
494 objLayout->addWidget( time, 1, 3, 1, 2 );*/
496 QToolButton *modifyButton = new QToolButton;
497 modifyButton->setIcon( QIcon( ":/menu/settings" ) );
498 objLayout->addWidget( modifyButton, 0, 5 );
500 QToolButton *deleteButton = new QToolButton;
501 deleteButton->setIcon( QIcon( ":/menu/quit" ) );
502 objLayout->addWidget( deleteButton, 0, 6 );
504 BUTTONACT( modifyButton, modify() );
505 BUTTONACT( deleteButton, del() );
506 CONNECT( this, clicked( bool ), this, toggleEnabled( bool ) );
509 void VLMAWidget::modify()
511 parent->startModifyVLMItem( this );
514 void VLMAWidget::del()
516 parent->removeVLMItem( this );
519 void VLMAWidget::toggleEnabled( bool b_enable )
521 VLMWrapper::EnableItem( name, b_enable );
527 VLMBroadcast::VLMBroadcast( const QString& _name, const QString& _input,
528 const QString& _output, bool _enabled,
529 bool _looped, VLMDialog *_parent )
530 : VLMAWidget( _name, _input, _output,
531 _enabled, _parent, QVLM_Broadcast )
533 nameLabel->setText( qtr("Broadcast: ") + name );
534 type = QVLM_Broadcast;
537 playButton = new QToolButton;
538 playButton->setIcon( QIcon( ":/menu/play" ) );
539 objLayout->addWidget( playButton, 1, 0 );
542 QToolButton *stopButton = new QToolButton;
543 stopButton->setIcon( QIcon( ":/toolbar/stop_b" ) );
544 objLayout->addWidget( stopButton, 1, 1 );
546 loopButton = new QToolButton;
547 objLayout->addWidget( loopButton, 1, 2 );
549 BUTTONACT( playButton, togglePlayPause() );
550 BUTTONACT( stopButton, stop() );
551 BUTTONACT( loopButton, toggleLoop() );
556 void VLMBroadcast::update()
558 VLMWrapper::EditBroadcast( name, input, output, b_enabled, b_looped );
560 loopButton->setIcon( QIcon( ":/buttons/playlist/repeat_all" ) );
562 loopButton->setIcon( QIcon( ":/buttons/playlist/repeat_off" ) );
565 void VLMBroadcast::togglePlayPause()
569 VLMWrapper::ControlBroadcast( name, ControlBroadcastPause );
570 playButton->setIcon( QIcon( ":/menu/pause" ) );
574 VLMWrapper::ControlBroadcast( name, ControlBroadcastPlay );
575 playButton->setIcon( QIcon( ":/menu/play" ) );
577 b_playing = !b_playing;
580 void VLMBroadcast::toggleLoop()
582 b_enabled = !b_enabled;
586 void VLMBroadcast::stop()
588 VLMWrapper::ControlBroadcast( name, ControlBroadcastStop );
589 playButton->setIcon( QIcon( ":/menu/play" ) );
595 VLMSchedule::VLMSchedule( const QString& name, const QString& input,
596 const QString& output, QDateTime _schetime,
597 QDateTime _schedate, int _scherepeatnumber,
598 int _repeatDays, bool enabled, VLMDialog *parent )
599 : VLMAWidget( name, input, output, enabled, parent, QVLM_Schedule )
601 nameLabel->setText( qtr("Schedule: ") + name );
602 schetime = _schetime;
603 schedate = _schedate;
604 rNumber = _scherepeatnumber;
606 type = QVLM_Schedule;
610 void VLMSchedule::update()
612 VLMWrapper::EditSchedule( name, input, output, schetime, schedate,
613 rNumber, rDays, b_enabled);
619 VLMVod::VLMVod( const QString& name, const QString& input, const QString& output,
620 bool enabled, const QString& _mux, VLMDialog *parent)
621 : VLMAWidget( name, input, output, enabled, parent, QVLM_VOD )
623 nameLabel->setText( qtr("VOD: ") + name );
626 muxLabel = new QLabel;
627 objLayout->addWidget( muxLabel, 1, 0 );
632 void VLMVod::update()
634 muxLabel->setText( mux );
635 VLMWrapper::EditVod( name, input, output, b_enabled, mux );
642 vlm_t * VLMWrapper::p_vlm = NULL;
644 VLMWrapper::VLMWrapper( vlm_t *_p_vlm )
649 VLMWrapper::~VLMWrapper()
654 void VLMWrapper::AddBroadcast( const QString& name, const QString& input,
655 const QString& output,
656 bool b_enabled, bool b_loop )
658 vlm_message_t *message;
659 QString command = "new \"" + name + "\" broadcast";
660 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
661 vlm_MessageDelete( message );
662 EditBroadcast( name, input, output, b_enabled, b_loop );
665 void VLMWrapper::EditBroadcast( const QString& name, const QString& input,
666 const QString& output,
667 bool b_enabled, bool b_loop )
669 vlm_message_t *message;
672 command = "setup \"" + name + "\" inputdel all";
673 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
674 vlm_MessageDelete( message );
678 QStringList inputs = input.split(":", QString::SkipEmptyParts);
680 command = "setup \"" + name + "\" input \"" + inputs[0].trimmed() + "\"";
681 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
682 vlm_MessageDelete( message );
684 for( int i = 1; i < inputs.size(); i++ )
686 command = "setup \"" + name + "\" option \"" + inputs[i].trimmed() + "\"";
687 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
688 vlm_MessageDelete( message );
692 if( !output.isEmpty() )
694 command = "setup \"" + name + "\" output \"" + output + "\"";
695 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
696 vlm_MessageDelete( message );
700 command = "setup \"" + name + "\" enabled";
701 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
702 vlm_MessageDelete( message );
706 command = "setup \"" + name + "\" loop";
707 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
708 vlm_MessageDelete( message );
712 void VLMWrapper::EnableItem( const QString& name, bool b_enable )
714 vlm_message_t *message;
715 QString command = "setup \"" + name + ( b_enable ? " enable" : " disable" );
716 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
717 vlm_MessageDelete( message );
720 void VLMWrapper::ControlBroadcast( const QString& name, int BroadcastStatus,
723 vlm_message_t *message;
725 QString command = "control \"" + name + "\"";
726 switch( BroadcastStatus )
728 case ControlBroadcastPlay:
731 case ControlBroadcastPause:
734 case ControlBroadcastStop:
737 case ControlBroadcastSeek:
738 command += " seek" + seek;
741 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
742 vlm_MessageDelete( message );
745 void VLMWrapper::AddVod( const QString& name, const QString& input,
746 const QString& output,
747 bool b_enabled, const QString& mux )
749 vlm_message_t *message;
750 QString command = "new \"" + name + "\" vod";
751 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
752 vlm_MessageDelete( message );
753 EditVod( name, input, output, b_enabled, mux );
756 void VLMWrapper::EditVod( const QString& name, const QString& input,
757 const QString& output,
761 vlm_message_t *message;
766 QStringList inputs = input.split(":", QString::SkipEmptyParts);
768 command = "setup \"" + name + "\" input \"" + inputs[0].trimmed() + "\"";
769 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
770 vlm_MessageDelete( message );
772 for( int i = 1; i < inputs.size(); i++ )
774 command = "setup \"" + name + "\" option \"" + inputs[i].trimmed() + "\"";
775 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
776 vlm_MessageDelete( message );
780 if( !output.isEmpty() )
782 command = "setup \"" + name + "\" output \"" + output + "\"";
783 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
784 vlm_MessageDelete( message );
789 command = "setup \"" + name + "\" enabled";
790 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
791 vlm_MessageDelete( message );
795 command = "setup \"" + name + "\" mux \"" + mux + "\"";
796 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
797 vlm_MessageDelete( message );
801 void VLMWrapper::AddSchedule( const QString& name, const QString& input,
802 const QString& output, QDateTime _schetime,
804 int _scherepeatnumber, int _repeatDays,
805 bool b_enabled, const QString& mux )
807 vlm_message_t *message;
808 QString command = "new \"" + name + "\" schedule";
809 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
810 vlm_MessageDelete( message );
811 EditSchedule( name, input, output, _schetime, _schedate,
812 _scherepeatnumber, _repeatDays, b_enabled, mux );
815 void VLMWrapper::EditSchedule( const QString& name, const QString& input,
816 const QString& output, QDateTime _schetime,
817 QDateTime _schedate, int _scherepeatnumber,
818 int _repeatDays, bool b_enabled,
821 vlm_message_t *message;
826 QStringList inputs = input.split(":", QString::SkipEmptyParts);
828 command = "setup \"" + name + "\" input \"" + inputs[0].trimmed() + "\"";
829 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
830 vlm_MessageDelete( message );
832 for( int i = 1; i < inputs.size(); i++ )
834 command = "setup \"" + name + "\" option \"" + inputs[i].trimmed() + "\"";
835 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
836 vlm_MessageDelete( message );
840 if( !output.isEmpty() )
842 command = "setup \"" + name + "\" output \"" + output + "\"";
843 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
844 vlm_MessageDelete( message );
849 command = "setup \"" + name + "\" enabled";
850 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
851 vlm_MessageDelete( message );
856 command = "setup \"" + name + "\" mux \"" + mux + "\"";
857 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
858 vlm_MessageDelete( message );
861 command = "setup \"" + name + "\" date \"" +
862 _schedate.toString( "yyyy/MM/dd" )+ "-" +
863 _schetime.toString( "hh:mm:ss" ) + "\"";
864 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
865 vlm_MessageDelete( message );
867 if( _scherepeatnumber > 0 )
869 command = "setup \"" + name + "\" repeat \"" + _scherepeatnumber + "\"";
870 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
871 vlm_MessageDelete( message );
874 if( _repeatDays > 0 )
876 command = "setup \"" + name + "\" period \"" + _repeatDays + "\"";
877 vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
878 vlm_MessageDelete( message );
882 void VLMDialog::toggleVisible()
884 QList<VLMAWidget *>::iterator it;
885 for( it = vlmItems.begin(); it != vlmItems.end(); it++ )
887 VLMAWidget *item = *it;
892 ui.vlmListItem->clear();
894 QVLCDialog::toggleVisible();