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
, inputOptions
, outputText
,
229 b_checked
, b_looped
, this );
230 VLMWrapper::AddBroadcast( name
, inputText
, inputOptions
, outputText
, b_checked
,
234 typeShortName
= "VOD";
235 vlmAwidget
= new VLMVod( name
, inputText
, inputOptions
, outputText
,
236 b_checked
, ui
.muxLedit
->text(), this );
237 VLMWrapper::AddVod( name
, inputText
, inputOptions
, outputText
, b_checked
);
240 typeShortName
= "Sched";
241 vlmAwidget
= new VLMSchedule( name
, inputText
, inputOptions
, outputText
,
242 schetime
, schedate
, repeatnum
,
243 repeatdays
, b_checked
, this );
244 VLMWrapper::AddSchedule( name
, inputText
, inputOptions
, 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 information 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 information */
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
, inputOptions
,
314 outputText
, (*ppp_dsc
)[i
]->b_enabled
,
319 typeShortName
= "Bcast";
320 vlmAwidget
= new VLMBroadcast( mediaName
, inputText
, inputOptions
,
321 outputText
, (*ppp_dsc
)[i
]->b_enabled
,
322 (*ppp_dsc
)[i
]->broadcast
.b_loop
, this );
324 /* Add an Item of the Side List */
325 ui
.vlmListItem
->addItem( typeShortName
+ " : " + mediaName
);
326 ui
.vlmListItem
->setCurrentRow( vlmItemCount
- 1 );
328 /* Add a new VLMAWidget on the main List */
329 vlmItemLayout
->insertWidget( vlmItemCount
, vlmAwidget
);
330 vlmItems
.append( vlmAwidget
);
337 bool VLMDialog::importVLMConf()
339 QString openVLMConfFileName
= toNativeSeparators(
340 QFileDialog::getOpenFileName(
341 this, qtr( "Open VLM configuration..." ),
342 QVLCUserDir( VLC_DOCUMENTS_DIR
),
343 qtr( "VLM conf (*.vlm);;All (*)" ) ) );
345 if( !openVLMConfFileName
.isEmpty() )
347 vlm_message_t
*message
;
349 QString command
= "load \"" + openVLMConfFileName
+ "\"";
350 status
= vlm_ExecuteCommand( p_vlm
, qtu( command
) , &message
);
351 vlm_MessageDelete( message
);
358 msg_Warn( p_intf
, "Failed to import vlm configuration file : %s", qtu( command
) );
366 void VLMDialog::clearWidgets()
368 ui
.nameLedit
->clear();
369 ui
.inputLedit
->clear();
370 inputOptions
.clear();
371 ui
.outputLedit
->clear();
372 time
->setTime( QTime::currentTime() );
373 date
->setDate( QDate::currentDate() );
374 ui
.enableCheck
->setChecked( true );
375 ui
.nameLedit
->setReadOnly( false );
376 ui
.loopBCast
->setChecked( false );
377 ui
.muxLedit
->clear();
378 ui
.saveButton
->hide();
379 ui
.addButton
->show();
382 void VLMDialog::selectInput()
384 OpenDialog
*o
= OpenDialog::getInstance( this, p_intf
, false, SELECT
, true );
386 ui
.inputLedit
->setText( o
->getMRL( false ) );
387 inputOptions
= o
->getOptions();
390 void VLMDialog::selectOutput()
392 SoutDialog
*s
= new SoutDialog( this, p_intf
);
393 if( s
->exec() == QDialog::Accepted
)
394 ui
.outputLedit
->setText( s
->getMrl() );
397 /* Object Modification */
398 void VLMDialog::removeVLMItem( VLMAWidget
*vlmObj
)
400 int index
= vlmItems
.indexOf( vlmObj
);
401 if( index
< 0 ) return;
402 delete ui
.vlmListItem
->takeItem( index
);
403 vlmItems
.removeAt( index
);
406 /* HERE BE DRAGONS VLM REQUEST */
409 void VLMDialog::startModifyVLMItem( VLMAWidget
*vlmObj
)
411 currentIndex
= vlmItems
.indexOf( vlmObj
);
412 if( currentIndex
< 0 ) return;
414 ui
.vlmListItem
->setCurrentRow( currentIndex
);
415 ui
.nameLedit
->setText( vlmObj
->name
);
416 ui
.inputLedit
->setText( vlmObj
->input
);
417 ui
.outputLedit
->setText( vlmObj
->output
);
418 ui
.enableCheck
->setChecked( vlmObj
->b_enabled
);
420 switch( vlmObj
->type
)
423 ui
.loopBCast
->setChecked( (qobject_cast
<VLMBroadcast
*>(vlmObj
))->b_looped
);
426 ui
.muxLedit
->setText( (qobject_cast
<VLMVod
*>(vlmObj
))->mux
);
429 time
->setDateTime( ( qobject_cast
<VLMSchedule
*>(vlmObj
))->schetime
);
430 date
->setDateTime( ( qobject_cast
<VLMSchedule
*>(vlmObj
))->schedate
);
434 ui
.nameLedit
->setReadOnly( true );
435 ui
.addButton
->hide();
436 ui
.saveButton
->show();
439 void VLMDialog::saveModifications()
441 VLMAWidget
*vlmObj
= vlmItems
.at( currentIndex
);
444 vlmObj
->input
= ui
.inputLedit
->text();
445 vlmObj
->output
= ui
.outputLedit
->text().remove( ":sout=" );
446 vlmObj
->setChecked( ui
.enableCheck
->isChecked() );
447 vlmObj
->b_enabled
= ui
.enableCheck
->isChecked();
448 switch( vlmObj
->type
)
451 (qobject_cast
<VLMBroadcast
*>(vlmObj
))->b_looped
= ui
.loopBCast
->isChecked();
454 (qobject_cast
<VLMVod
*>(vlmObj
))->mux
= ui
.muxLedit
->text();
457 (qobject_cast
<VLMSchedule
*>(vlmObj
))->schetime
= time
->dateTime();
458 (qobject_cast
<VLMSchedule
*>(vlmObj
))->schedate
= date
->dateTime();
459 (qobject_cast
<VLMSchedule
*>(vlmObj
))->rNumber
= scherepeatnumber
->value();
460 (qobject_cast
<VLMSchedule
*>(vlmObj
))->rDays
= repeatDays
->value();
469 /*********************************
470 * VLMAWidget - Abstract class
471 ********************************/
473 VLMAWidget::VLMAWidget( const QString
& _name
, const QString
& _input
,
474 const QString
& _inputOptions
, const QString
& _output
,
475 bool _enabled
, VLMDialog
*_parent
, int _type
)
476 : QGroupBox( _name
, _parent
)
481 inputOptions
= _inputOptions
;
483 b_enabled
= _enabled
;
486 setCheckable( true );
487 setChecked( b_enabled
);
489 objLayout
= new QGridLayout( this );
490 setSizePolicy( QSizePolicy::Preferred
, QSizePolicy::Maximum
);
492 nameLabel
= new QLabel
;
493 objLayout
->addWidget( nameLabel
, 0, 0, 1, 4 );
495 /*QLabel *time = new QLabel( "--:--/--:--" );
496 objLayout->addWidget( time, 1, 3, 1, 2 );*/
498 QToolButton
*modifyButton
= new QToolButton
;
499 modifyButton
->setIcon( QIcon( ":/menu/settings" ) );
500 objLayout
->addWidget( modifyButton
, 0, 5 );
502 QToolButton
*deleteButton
= new QToolButton
;
503 deleteButton
->setIcon( QIcon( ":/menu/quit" ) );
504 objLayout
->addWidget( deleteButton
, 0, 6 );
506 BUTTONACT( modifyButton
, modify() );
507 BUTTONACT( deleteButton
, del() );
508 CONNECT( this, clicked( bool ), this, toggleEnabled( bool ) );
511 void VLMAWidget::modify()
513 parent
->startModifyVLMItem( this );
516 void VLMAWidget::del()
518 parent
->removeVLMItem( this );
521 void VLMAWidget::toggleEnabled( bool b_enable
)
523 VLMWrapper::EnableItem( name
, b_enable
);
529 VLMBroadcast::VLMBroadcast( const QString
& _name
, const QString
& _input
,
530 const QString
& _inputOptions
,
531 const QString
& _output
, bool _enabled
,
532 bool _looped
, VLMDialog
*_parent
)
533 : VLMAWidget( _name
, _input
, _inputOptions
, _output
,
534 _enabled
, _parent
, QVLM_Broadcast
)
536 nameLabel
->setText( qtr("Broadcast: ") + name
);
537 type
= QVLM_Broadcast
;
540 playButton
= new QToolButton
;
541 playButton
->setIcon( QIcon( ":/menu/play" ) );
542 objLayout
->addWidget( playButton
, 1, 0 );
545 QToolButton
*stopButton
= new QToolButton
;
546 stopButton
->setIcon( QIcon( ":/toolbar/stop_b" ) );
547 objLayout
->addWidget( stopButton
, 1, 1 );
549 loopButton
= new QToolButton
;
550 objLayout
->addWidget( loopButton
, 1, 2 );
552 BUTTONACT( playButton
, togglePlayPause() );
553 BUTTONACT( stopButton
, stop() );
554 BUTTONACT( loopButton
, toggleLoop() );
559 void VLMBroadcast::update()
561 VLMWrapper::EditBroadcast( name
, input
, inputOptions
, output
, b_enabled
, b_looped
);
563 loopButton
->setIcon( QIcon( ":/buttons/playlist/repeat_all" ) );
565 loopButton
->setIcon( QIcon( ":/buttons/playlist/repeat_off" ) );
568 void VLMBroadcast::togglePlayPause()
572 VLMWrapper::ControlBroadcast( name
, ControlBroadcastPause
);
573 playButton
->setIcon( QIcon( ":/menu/pause" ) );
577 VLMWrapper::ControlBroadcast( name
, ControlBroadcastPlay
);
578 playButton
->setIcon( QIcon( ":/menu/play" ) );
580 b_playing
= !b_playing
;
583 void VLMBroadcast::toggleLoop()
585 b_enabled
= !b_enabled
;
589 void VLMBroadcast::stop()
591 VLMWrapper::ControlBroadcast( name
, ControlBroadcastStop
);
592 playButton
->setIcon( QIcon( ":/menu/play" ) );
598 VLMSchedule::VLMSchedule( const QString
& name
, const QString
& input
,
599 const QString
& inputOptions
,
600 const QString
& output
, QDateTime _schetime
,
601 QDateTime _schedate
, int _scherepeatnumber
,
602 int _repeatDays
, bool enabled
, VLMDialog
*parent
)
603 : VLMAWidget( name
, input
, inputOptions
, output
, enabled
, parent
,
606 nameLabel
->setText( qtr("Schedule: ") + name
);
607 schetime
= _schetime
;
608 schedate
= _schedate
;
609 rNumber
= _scherepeatnumber
;
611 type
= QVLM_Schedule
;
615 void VLMSchedule::update()
617 VLMWrapper::EditSchedule( name
, input
, inputOptions
, output
, schetime
, schedate
,
618 rNumber
, rDays
, b_enabled
);
624 VLMVod::VLMVod( const QString
& name
, const QString
& input
,
625 const QString
& inputOptions
, const QString
& output
,
626 bool enabled
, const QString
& _mux
, VLMDialog
*parent
)
627 : VLMAWidget( name
, input
, inputOptions
, output
, enabled
, parent
,
630 nameLabel
->setText( qtr("VOD: ") + name
);
633 muxLabel
= new QLabel
;
634 objLayout
->addWidget( muxLabel
, 1, 0 );
639 void VLMVod::update()
641 muxLabel
->setText( mux
);
642 VLMWrapper::EditVod( name
, input
, inputOptions
, output
, b_enabled
, mux
);
649 vlm_t
* VLMWrapper::p_vlm
= NULL
;
651 VLMWrapper::VLMWrapper( vlm_t
*_p_vlm
)
656 VLMWrapper::~VLMWrapper()
661 void VLMWrapper::AddBroadcast( const QString
& name
, const QString
& input
,
662 const QString
& inputOptions
, const QString
& output
,
663 bool b_enabled
, bool b_loop
)
665 vlm_message_t
*message
;
666 QString command
= "new \"" + name
+ "\" broadcast";
667 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
668 vlm_MessageDelete( message
);
669 EditBroadcast( name
, input
, inputOptions
, output
, b_enabled
, b_loop
);
672 void VLMWrapper::EditBroadcast( 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
;
679 command
= "setup \"" + name
+ "\" inputdel all";
680 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
681 vlm_MessageDelete( message
);
683 if( !input
.isEmpty() )
685 command
= "setup \"" + name
+ "\" input \"" + input
+ "\"";
686 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
687 vlm_MessageDelete( message
);
689 QStringList options
= inputOptions
.split( " :", QString::SkipEmptyParts
);
690 for( int i
= 0; i
< options
.size(); i
++ )
692 command
= "setup \"" + name
+ "\" option \"" + options
[i
].trimmed() + "\"";
693 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
694 vlm_MessageDelete( message
);
698 if( !output
.isEmpty() )
700 command
= "setup \"" + name
+ "\" output \"" + output
+ "\"";
701 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
702 vlm_MessageDelete( message
);
706 command
= "setup \"" + name
+ "\" enabled";
707 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
708 vlm_MessageDelete( message
);
712 command
= "setup \"" + name
+ "\" loop";
713 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
714 vlm_MessageDelete( message
);
718 void VLMWrapper::EnableItem( const QString
& name
, bool b_enable
)
720 vlm_message_t
*message
;
721 QString command
= "setup \"" + name
+ ( b_enable
? " enable" : " disable" );
722 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
723 vlm_MessageDelete( message
);
726 void VLMWrapper::ControlBroadcast( const QString
& name
, int BroadcastStatus
,
729 vlm_message_t
*message
;
731 QString command
= "control \"" + name
+ "\"";
732 switch( BroadcastStatus
)
734 case ControlBroadcastPlay
:
737 case ControlBroadcastPause
:
740 case ControlBroadcastStop
:
743 case ControlBroadcastSeek
:
744 command
+= " seek" + seek
;
747 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
748 vlm_MessageDelete( message
);
751 void VLMWrapper::AddVod( const QString
& name
, const QString
& input
,
752 const QString
& inputOptions
, const QString
& output
,
753 bool b_enabled
, const QString
& mux
)
755 vlm_message_t
*message
;
756 QString command
= "new \"" + name
+ "\" vod";
757 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
758 vlm_MessageDelete( message
);
759 EditVod( name
, input
, inputOptions
, output
, b_enabled
, mux
);
762 void VLMWrapper::EditVod( const QString
& name
, const QString
& input
,
763 const QString
& inputOptions
, const QString
& output
,
767 vlm_message_t
*message
;
770 if( !input
.isEmpty() )
772 command
= "setup \"" + name
+ "\" input \"" + input
+ "\"";
773 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
774 vlm_MessageDelete( message
);
776 QStringList options
= inputOptions
.split( " :", QString::SkipEmptyParts
);
777 for( int i
= 0; i
< options
.size(); i
++ )
779 command
= "setup \"" + name
+ "\" option \"" + options
[i
].trimmed() + "\"";
780 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
781 vlm_MessageDelete( message
);
785 if( !output
.isEmpty() )
787 command
= "setup \"" + name
+ "\" output \"" + output
+ "\"";
788 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
789 vlm_MessageDelete( message
);
794 command
= "setup \"" + name
+ "\" enabled";
795 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
796 vlm_MessageDelete( message
);
800 command
= "setup \"" + name
+ "\" mux \"" + mux
+ "\"";
801 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
802 vlm_MessageDelete( message
);
806 void VLMWrapper::AddSchedule( const QString
& name
, const QString
& input
,
807 const QString
& inputOptions
, const QString
& output
,
808 QDateTime _schetime
, QDateTime _schedate
,
809 int _scherepeatnumber
, int _repeatDays
,
810 bool b_enabled
, const QString
& mux
)
812 vlm_message_t
*message
;
813 QString command
= "new \"" + name
+ "\" schedule";
814 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
815 vlm_MessageDelete( message
);
816 EditSchedule( name
, input
, inputOptions
, output
, _schetime
, _schedate
,
817 _scherepeatnumber
, _repeatDays
, b_enabled
, mux
);
820 void VLMWrapper::EditSchedule( const QString
& name
, const QString
& input
,
821 const QString
& inputOptions
, const QString
& output
,
822 QDateTime _schetime
, QDateTime _schedate
,
823 int _scherepeatnumber
, int _repeatDays
,
824 bool b_enabled
, const QString
& mux
)
826 vlm_message_t
*message
;
829 if( !input
.isEmpty() )
831 command
= "setup \"" + name
+ "\" input \"" + input
+ "\"";
832 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
833 vlm_MessageDelete( message
);
835 QStringList options
= inputOptions
.split( " :", QString::SkipEmptyParts
);
836 for( int i
= 0; i
< options
.size(); i
++ )
838 command
= "setup \"" + name
+ "\" option \"" + options
[i
].trimmed() + "\"";
839 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
840 vlm_MessageDelete( message
);
844 if( !output
.isEmpty() )
846 command
= "setup \"" + name
+ "\" output \"" + output
+ "\"";
847 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
848 vlm_MessageDelete( message
);
853 command
= "setup \"" + name
+ "\" enabled";
854 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
855 vlm_MessageDelete( message
);
860 command
= "setup \"" + name
+ "\" mux \"" + mux
+ "\"";
861 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
862 vlm_MessageDelete( message
);
865 command
= "setup \"" + name
+ "\" date \"" +
866 _schedate
.toString( "yyyy/MM/dd" )+ "-" +
867 _schetime
.toString( "hh:mm:ss" ) + "\"";
868 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
869 vlm_MessageDelete( message
);
871 if( _scherepeatnumber
> 0 )
873 command
= "setup \"" + name
+ "\" repeat \"" + _scherepeatnumber
+ "\"";
874 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
875 vlm_MessageDelete( message
);
878 if( _repeatDays
> 0 )
880 command
= "setup \"" + name
+ "\" period \"" + _repeatDays
+ "\"";
881 vlm_ExecuteCommand( p_vlm
, qtu( command
), &message
);
882 vlm_MessageDelete( message
);
886 void VLMDialog::toggleVisible()
888 QList
<VLMAWidget
*>::iterator it
;
889 for( it
= vlmItems
.begin(); it
!= vlmItems
.end(); it
++ )
891 VLMAWidget
*item
= *it
;
896 ui
.vlmListItem
->clear();
898 QVLCDialog::toggleVisible();