/*****************************************************************************
* vlm.cpp : VLM Management
****************************************************************************
- * Copyright ( C ) 2006 the VideoLAN team
- * $Id: sout.cpp 21875 2007-09-08 16:01:33Z jb $
+ * Copyright © 2008 the VideoLAN team
+ * $Id$
*
* Authors: Jean-Baptiste Kempf <jb@videolan.org>
* Jean-François Massol <jf.massol -at- gmail.com>
* Foundation, Inc., 51 Franklin street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include "dialogs/vlm.hpp"
#ifdef ENABLE_VLM
#include <QPushButton>
#include <QHBoxLayout>
#include <QDateTimeEdit>
+#include <QDateTime>
#include <QSpinBox>
#include <QHeaderView>
#include <QScrollArea>
+#include <QFileDialog>
static const char *psz_type[] = { "Broadcast", "Schedule", "VOD" };
time = new QDateTimeEdit( QTime::currentTime() );
time->setAlignment( Qt::AlignRight );
+ time->setDisplayFormat( "hh:mm:ss" );
schetimelayout->addWidget( time, 0, 1, 1, 3 );
date = new QDateTimeEdit( QDate::currentDate() );
new QSpacerItem( 10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding);
vlmItemLayout->addItem( spacer );
+ QPushButton *importButton = new QPushButton( qtr( "Import" ) );
+ ui.buttonBox->addButton( importButton, QDialogButtonBox::ActionRole );
+
+ QPushButton *exportButton = new QPushButton( qtr( "Export" ) );
+ ui.buttonBox->addButton( exportButton, QDialogButtonBox::ActionRole );
+
QPushButton *closeButton = new QPushButton( qtr( "Close" ) );
ui.buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
+
showScheduleWidget( QVLM_Broadcast );
/* Connect the comboBox to show the right Widgets */
this, selectVLMItem( int ) );
BUTTONACT( closeButton, close() );
+ BUTTONACT( exportButton, exportVLMConf() );
+ BUTTONACT( importButton, importVLMConf() );
BUTTONACT( ui.addButton, addVLMItem() );
BUTTONACT( ui.clearButton, clearWidgets() );
BUTTONACT( ui.saveButton, saveModifications() );
{
/* FIXME :you have to destroy vlm here to close
* but we shouldn't destroy vlm here in case somebody else wants it */
+ msg_Dbg( p_intf, "Destroying VLM Dialog" );
if( p_vlm )
vlm_Delete( p_vlm );
}
QString outputText = ui.outputLedit->text();
bool b_checked = ui.enableCheck->isChecked();
bool b_looped = ui.loopBCast->isChecked();
-
+ QDateTime schetime = time->dateTime();
+ QDateTime schedate = date->dateTime();
+ int repeatnum = scherepeatnumber->value();
+ int repeatdays = repeatDays->value();
VLMAWidget * vlmAwidget;
switch( type )
case QVLM_Broadcast:
typeShortName = "Bcast";
vlmAwidget = new VLMBroadcast( name, inputText, outputText,
- b_checked, b_looped, this );
- VLMWrapper::AddBroadcast( name, inputText, outputText, b_checked, b_looped );
+ b_checked, b_looped, this );
+ VLMWrapper::AddBroadcast( name, inputText, outputText, b_checked,
+ b_looped );
break;
case QVLM_VOD:
typeShortName = "VOD";
case QVLM_Schedule:
typeShortName = "Sched";
vlmAwidget = new VLMSchedule( name, inputText, outputText,
- b_checked, this );
+ schetime, schedate, repeatnum,
+ repeatdays, b_checked, this );
+ VLMWrapper::AddSchedule( name, inputText, outputText, schetime,
+ schedate, repeatnum, repeatdays, b_checked);
break;
default:
msg_Warn( p_intf, "Something bad happened" );
clearWidgets();
}
+// FIXME : VOD are not exported to the file
+bool VLMDialog::exportVLMConf()
+{
+ QString saveVLMConfFileName = QFileDialog::getSaveFileName(
+ this, qtr( "Choose a filename to save the VLM configuration..." ),
+ qfu( p_intf->p_libvlc->psz_homedir ),
+ qtr( "VLM conf (*.vlm) ;; All (*.*)" ) );
+
+ if( !saveVLMConfFileName.isEmpty() )
+ {
+ vlm_message_t *message;
+ QString command = "save \"" + saveVLMConfFileName + "\"";
+ vlm_ExecuteCommand( p_vlm , qtu( command ) , &message );
+ vlm_MessageDelete( message );
+ return true;
+ }
+ return false;
+}
+
+
+bool VLMDialog::importVLMConf()
+{
+ QString openVLMConfFileName = QFileDialog::getOpenFileName(
+ this, qtr( "Choose a VLM configuration file to open..." ),
+ qfu( p_intf->p_libvlc->psz_homedir ),
+ qtr( "VLM conf (*.vlm) ;; All (*.*)" ) );
+
+ if( !openVLMConfFileName.isEmpty() )
+ {
+ vlm_message_t *message;
+ QString command = "load \"" + openVLMConfFileName + "\"";
+ vlm_ExecuteCommand( p_vlm, qtu( command ) , &message );
+ vlm_MessageDelete( message );
+ return true;
+ }
+ return false;
+}
+
void VLMDialog::clearWidgets()
{
ui.nameLedit->clear();
void VLMDialog::selectInput()
{
- OpenDialog *o = OpenDialog::getInstance( this, p_intf, 0, true );
+ OpenDialog *o = OpenDialog::getInstance( this, p_intf, SELECT, true );
o->exec();
ui.inputLedit->setText( o->getMRL() );
}
{
int index = vlmItems.indexOf( vlmObj );
if( index < 0 ) return;
-
delete ui.vlmListItem->takeItem( index );
vlmItems.removeAt( index );
delete vlmObj;
ui.muxLedit->setText( (qobject_cast<VLMVod *>(vlmObj))->mux );
break;
case QVLM_Schedule:
- //(qobject_cast<VLMSchedule *>)
+ time->setDateTime( ( qobject_cast<VLMSchedule *>(vlmObj))->schetime );
+ date->setDateTime( ( qobject_cast<VLMSchedule *>(vlmObj))->schedate );
break;
}
(qobject_cast<VLMVod *>(vlmObj))->mux = ui.muxLedit->text();
break;
case QVLM_Schedule:
+ (qobject_cast<VLMSchedule *>(vlmObj))->schetime = time->dateTime();
+ (qobject_cast<VLMSchedule *>(vlmObj))->schedate = date->dateTime();
+ (qobject_cast<VLMSchedule *>(vlmObj))->rNumber = scherepeatnumber->value();
+ (qobject_cast<VLMSchedule *>(vlmObj))->rDays = repeatDays->value();
break;
// vlmObj->
}
* VLMSchedule
****************/
VLMSchedule::VLMSchedule( QString name, QString input, QString output,
- bool enabled, VLMDialog *parent)
+ QDateTime _schetime, QDateTime _schedate,
+ int _scherepeatnumber, int _repeatDays,
+ bool enabled, VLMDialog *parent )
: VLMAWidget( name, input, output, enabled, parent, QVLM_Schedule )
{
nameLabel->setText( "Schedule: " + name );
+ schetime = _schetime;
+ schedate = _schedate;
+ rNumber = _scherepeatnumber;
+ rDays = _repeatDays;
+ type = QVLM_Schedule;
+ update();
}
void VLMSchedule::update()
{
+ VLMWrapper::EditSchedule( name, input, output, schetime, schedate,
+ rNumber, rDays, b_enabled);
}
/****************
vlm_MessageDelete( message );
}
}
+
+void VLMWrapper::AddSchedule( const QString name, const QString input,
+ const QString output, QDateTime _schetime,
+ QDateTime _schedate,
+ int _scherepeatnumber, int _repeatDays,
+ bool b_enabled, const QString mux )
+{
+ vlm_message_t *message;
+ QString command = "new \"" + name + "\" schedule";
+ vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
+ vlm_MessageDelete( message );
+ EditSchedule( name, input, output, _schetime, _schedate,
+ _scherepeatnumber, _repeatDays, b_enabled, mux );
+}
+
+void VLMWrapper::EditSchedule( const QString name, const QString input,
+ const QString output, QDateTime _schetime,
+ QDateTime _schedate, int _scherepeatnumber,
+ int _repeatDays, bool b_enabled,
+ const QString mux )
+{
+ vlm_message_t *message;
+ QString command = "setup \"" + name + "\" input \"" + input + "\"";
+ vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
+ vlm_MessageDelete( message );
+
+ if( !output.isEmpty() )
+ {
+ command = "setup \"" + name + "\" output \"" + output + "\"";
+ vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
+ vlm_MessageDelete( message );
+ }
+
+ if( b_enabled )
+ {
+ command = "setup \"" + name + "\" enabled";
+ vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
+ vlm_MessageDelete( message );
+ }
+
+ if( !mux.isEmpty() )
+ {
+ command = "setup \"" + name + "\" mux \"" + mux + "\"";
+ vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
+ vlm_MessageDelete( message );
+ }
+
+ command = "setup \"" + name + "\" date \"" +
+ _schedate.toString( "yyyy/MM/dd" )+ "-" +
+ _schetime.toString( "hh:mm:ss" ) + "\"";
+ vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
+ vlm_MessageDelete( message );
+ if( _scherepeatnumber > 0 )
+ {
+ command = "setup \"" + name + "\" repeat \"" + _scherepeatnumber + "\"";
+ vlm_ExecuteCommand( p_vlm, qtu( command ), &message );
+ vlm_MessageDelete( message );
+ }
+}
+
+
#endif