Initial import of CVS-v2_8_branch

This commit is contained in:
Fred Gleason
2014-08-12 15:13:02 -04:00
commit afd67c7af8
1508 changed files with 405304 additions and 0 deletions

69
rdcartslots/Makefile.am Normal file
View File

@@ -0,0 +1,69 @@
## automake.am
##
## Automake.am for rivendell/rdcartslots
##
## (C) Copyright 2012 Fred Gleason <fredg@paravelsystems.com>
##
## $Id: Makefile.am,v 1.4.2.2 2012/11/16 18:10:40 cvs Exp $
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License version 2 as
## published by the Free Software Foundation.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public
## License along with this program; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
##
## Use automake to process this into a Makefile.in
AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -DQTDIR=\"@QT_DIR@\" @QT_CXXFLAGS@
INCLUDES = -I$(top_srcdir)/lib
LIBS = @QT_LIBS@ -L$(top_srcdir)/lib
MOC = @QT_MOC@
# The dependency for qt's Meta Object Compiler (moc)
moc_%.cpp: %.h
$(MOC) $< -o $@
# I18N Stuff
install-exec-local:
mkdir -p $(DESTDIR)$(prefix)/share/rivendell
cp rdcartslots_*.qm $(DESTDIR)$(prefix)/share/rivendell
uninstall:
rm -f $(DESTDIR)$(prefix)/share/rivendell/rdcartslots_*.qm
all:
lupdate rdcartslots.pro
lrelease rdcartslots.pro
bin_PROGRAMS = rdcartslots
dist_rdcartslots_SOURCES = local_macros.cpp\
rdcartslots.cpp rdcartslots.h
nodist_rdcartslots_SOURCES = moc_rdcartslots.cpp
rdcartslots_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
EXTRA_DIST = rdcartslots.pro\
rdcartslots_de.ts\
rdcartslots_es.ts\
rdcartslots_fr.ts\
rdcartslots_nb.ts\
rdcartslots_nn.ts\
rdcartslots_pt_BR.ts
CLEANFILES = *~\
moc_*\
*.qm
MAINTAINERCLEANFILES = *~\
Makefile.in\
moc_*

View File

@@ -0,0 +1,201 @@
// local_macros.cpp
//
// A Dedicated Cart Slot Utility for Rivendell.
//
// (C) Copyright 2012 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: local_macros.cpp,v 1.2.2.3 2012/11/28 21:44:08 cvs Exp $
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include "rdcartslots.h"
void MainWidget::RunLocalMacros(RDMacro *rml)
{
bool ok=false;
unsigned slotnum;
unsigned cartnum;
unsigned len;
if(rml->role()!=RDMacro::Cmd) {
return;
}
switch(rml->command()) {
case RDMacro::DL:
if(rml->argQuantity()!=2) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
slotnum=rml->arg(0).toUInt(&ok)-1;
if((!ok)||(slotnum>=panel_slots.size())) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
if(panel_slots[slotnum]->slotOptions()->mode()!=
RDSlotOptions::CartDeckMode) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
cartnum=rml->arg(1).toUInt(&ok);
if((!ok)||(cartnum>999999)) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
if(cartnum==0) {
panel_slots[slotnum]->unload();
}
else {
if(!panel_slots[slotnum]->load(cartnum)) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
}
if(rml->echoRequested()) {
rml->acknowledge(true);
panel_ripc->sendRml(rml);
}
break;
case RDMacro::DP:
if(rml->argQuantity()!=1) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
slotnum=rml->arg(0).toUInt(&ok)-1;
if((!ok)||(slotnum>=panel_slots.size())) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
if(panel_slots[slotnum]->slotOptions()->mode()!=
RDSlotOptions::CartDeckMode) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
if(!panel_slots[slotnum]->play()) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
if(rml->echoRequested()) {
rml->acknowledge(true);
panel_ripc->sendRml(rml);
}
break;
case RDMacro::DS:
if(rml->argQuantity()!=1) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
slotnum=rml->arg(0).toUInt(&ok)-1;
if((!ok)||(slotnum>=panel_slots.size())) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
if(panel_slots[slotnum]->slotOptions()->mode()!=
RDSlotOptions::CartDeckMode) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
if(!panel_slots[slotnum]->stop()) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
if(rml->echoRequested()) {
rml->acknowledge(true);
panel_ripc->sendRml(rml);
}
break;
case RDMacro::DX:
if(rml->argQuantity()!=2) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
slotnum=rml->arg(0).toUInt(&ok)-1;
if((!ok)||(slotnum>=panel_slots.size())) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
len=rml->arg(1).toUInt(&ok);
if(!ok) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
if(!panel_slots[slotnum]->breakAway(len)) {
if(rml->echoRequested()) {
rml->acknowledge(false);
panel_ripc->sendRml(rml);
}
return;
}
if(rml->echoRequested()) {
rml->acknowledge(true);
panel_ripc->sendRml(rml);
}
break;
default:
break;
}
}

291
rdcartslots/rdcartslots.cpp Normal file
View File

@@ -0,0 +1,291 @@
// rdcartslots.cpp
//
// A Dedicated Cart Slot Utility for Rivendell.
//
// (C) Copyright 2012 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: rdcartslots.cpp,v 1.8.2.13 2014/02/11 23:46:29 cvs Exp $
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <stdlib.h>
#include <math.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <qmessagebox.h>
#include <qapplication.h>
#include <qwindowsstyle.h>
#include <qtranslator.h>
#include <qtextcodec.h>
#include <qpainter.h>
#include <qpixmap.h>
#include <rdcartslots.h>
#include <rd.h>
#include <rdcheck_daemons.h>
#include <rddbheartbeat.h>
#include <rdcmd_switch.h>
#include <dbversion.h>
//
// Icons
//
#include "../icons/rivendell-22x22.xpm"
MainWidget::MainWidget(QWidget *parent)
:QWidget(parent)
{
bool skip_db_check=false;
unsigned schema=0;
//
// Force a reasonable default font.
//
QFont mfont("helvetica",12,QFont::Normal);
mfont.setPixelSize(12);
qApp->setFont(mfont);
//
// Load Local Configs
//
panel_config=new RDConfig();
panel_config->load();
//
// Load the command-line arguments
//
RDCmdSwitch *cmd=new RDCmdSwitch(qApp->argc(),qApp->argv(),"rdcartslots",
RDCARTSLOTS_USAGE);
for(unsigned i=0;i<cmd->keys();i++) {
if(cmd->key(i)=="--skip-db-check") {
skip_db_check=true;
}
}
//
// Create Icons
//
lib_rivendell_map=new QPixmap(rivendell_xpm);
setIcon(*lib_rivendell_map);
//
// Ensure that system daemons are running
//
RDInitializeDaemons();
//
// Open Database
//
QString err;
QSqlDatabase *db=RDInitDb(&schema,&err);
if(!db) {
QMessageBox::warning(this,tr("Can't Connect"),err);
exit(0);
}
if((schema!=RD_VERSION_DATABASE)&&(!skip_db_check)) {
fprintf(stderr,
"rdcastmanager: database version mismatch, should be %u, is %u\n",
RD_VERSION_DATABASE,schema);
exit(256);
}
new RDDbHeartbeat(panel_config->mysqlHeartbeatInterval(),this);
//
// Allocate Global Resources
//
panel_station=new RDStation(panel_config->stationName());
panel_system=new RDSystem();
//
// RDAirPlay Configuration
//
panel_airplay_conf=new RDAirPlayConf(panel_config->stationName(),"RDAIRPLAY");
//
// CAE Connection
//
panel_cae=new RDCae(panel_station,panel_config,parent);
panel_cae->connectHost();
//
// RIPC Connection
//
panel_ripc=new RDRipc(panel_config->stationName());
connect(panel_ripc,SIGNAL(userChanged()),this,SLOT(userData()));
connect(panel_ripc,SIGNAL(rmlReceived(RDMacro *)),
this,SLOT(rmlReceivedData(RDMacro *)));
//
// User
//
panel_user=NULL;
//
// Service Picker
//
panel_svcs_dialog=new RDListSvcs(tr("RDCartSlots"),this);
//
// Macro Player
//
panel_player=new RDEventPlayer(panel_ripc,this);
//
// Dialogs
//
panel_cart_dialog=new RDCartDialog(&panel_filter,&panel_group,
&panel_schedcode,panel_cae,panel_ripc,
panel_station,panel_system,panel_config,
this);
panel_slot_dialog=new RDSlotDialog(tr("RDCartSlots"),this);
panel_cue_dialog=new RDCueEditDialog(panel_cae,panel_station->cueCard(),
panel_station->cuePort(),
tr("RDCartSlots"),this);
//
// Cart Slots
//
QTimer *timer=new QTimer(this);
for(int i=0;i<panel_station->cartSlotColumns();i++) {
for(int j=0;j<panel_station->cartSlotRows();j++) {
panel_slots.
push_back(new RDCartSlot(panel_slots.size(),panel_ripc,panel_cae,
panel_station,panel_config,panel_svcs_dialog,
panel_slot_dialog,panel_cart_dialog,
panel_cue_dialog,tr("RDCartSlots"),
panel_airplay_conf,this));
panel_slots.back()->
setGeometry(10+i*(panel_slots.back()->sizeHint().width()+10),
10+j*(panel_slots.back()->sizeHint().height()+5),
panel_slots.back()->sizeHint().width(),
panel_slots.back()->sizeHint().height());
connect(timer,SIGNAL(timeout()),
panel_slots.back(),SLOT(updateMeters()));
}
}
timer->start(METER_INTERVAL);
panel_ripc->connectHost("localhost",RIPCD_TCP_PORT,panel_config->password());
//
// Fix the Window Size
//
#ifndef RESIZABLE
setMinimumWidth(sizeHint().width());
setMaximumWidth(sizeHint().width());
setMinimumHeight(sizeHint().height());
setMaximumHeight(sizeHint().height());
#endif // RESIZABLE
}
QSize MainWidget::sizeHint() const
{
return QSize(10+panel_station->cartSlotColumns()*
(10+panel_slots[0]->size().width()),
10+panel_station->cartSlotRows()*
(5+panel_slots[0]->size().height()));
}
void MainWidget::rmlReceivedData(RDMacro *rml)
{
RunLocalMacros(rml);
}
QSizePolicy MainWidget::sizePolicy() const
{
return QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
}
void MainWidget::userData()
{
if(panel_user!=NULL) {
delete panel_user;
}
panel_user=new RDUser(panel_ripc->user());
for(unsigned i=0;i<panel_slots.size();i++) {
panel_slots[i]->setUser(panel_user);
}
SetCaption();
panel_ripc->sendOnairFlag();
}
void MainWidget::paintEvent(QPaintEvent *e)
{
QPainter *p=new QPainter(this);
p->setPen(Qt::black);
p->setBrush(Qt::black);
for(int i=1;i<panel_station->cartSlotColumns();i++) {
p->fillRect(i*(panel_slots[0]->size().width()+10),10,
5,size().height()-15,Qt::black);
}
delete p;
}
void MainWidget::closeEvent(QCloseEvent *e)
{
for(unsigned i=0;i<panel_slots.size();i++) {
delete panel_slots[i]; // So temporary carts get cleaned up properly
}
exit(0);
}
void MainWidget::SetCaption()
{
QString service=tr("[None]");
setCaption(tr("RDCartSlots")+" v"+VERSION+" - "+tr("Station")+": "+
panel_config->stationName()+" "+tr("User")+": "+
panel_ripc->user());
}
int main(int argc,char *argv[])
{
QApplication a(argc,argv);
//
// Load Translations
//
QTranslator qt(0);
qt.load(QString(QTDIR)+QString("/translations/qt_")+QTextCodec::locale(),".");
a.installTranslator(&qt);
QTranslator rd(0);
rd.load(QString(PREFIX)+QString("/share/rivendell/librd_")+
QTextCodec::locale(),".");
a.installTranslator(&rd);
QTranslator rdhpi(0);
rdhpi.load(QString(PREFIX)+QString("/share/rivendell/librdhpi_")+
QTextCodec::locale(),".");
a.installTranslator(&rdhpi);
QTranslator tr(0);
tr.load(QString(PREFIX)+QString("/share/rivendell/rdcartslots_")+
QTextCodec::locale(),".");
a.installTranslator(&tr);
MainWidget *w=new MainWidget();
a.setMainWidget(w);
w->setGeometry(QRect(QPoint(0,0),w->sizeHint()));
w->show();
return a.exec();
}

92
rdcartslots/rdcartslots.h Normal file
View File

@@ -0,0 +1,92 @@
// rdcartslots.h
//
// A Dedicated Cart Slot Utility for Rivendell.
//
// (C) Copyright 2012 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: rdcartslots.h,v 1.5.2.6 2014/01/07 23:23:18 cvs Exp $
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#ifndef RDCARTSLOTS_H
#define RDCARTSLOTS_H
#include <vector>
#include <qwidget.h>
#include <qtimer.h>
#include <qpixmap.h>
#include <rdstereometer.h>
#include <rdcae.h>
#include <rdsystem.h>
#include <rdmacro.h>
#include <rdconfig.h>
#include <rdevent_player.h>
#include <rdcartslot.h>
#include <rdcart_dialog.h>
#include <rdslotdialog.h>
#include <rdcueeditdialog.h>
#include <rdlistsvcs.h>
#include <rdairplay_conf.h>
//
// Settings
//
#define MASTER_TIMER_INTERVAL 100
#define METER_INTERVAL 50
#define RDCARTSLOTS_USAGE "\n"
class MainWidget : public QWidget
{
Q_OBJECT
public:
MainWidget(QWidget *parent=0);
QSize sizeHint() const;
QSizePolicy sizePolicy() const;
private slots:
void userData();
void rmlReceivedData(RDMacro *rml);
protected:
void paintEvent(QPaintEvent *e);
void closeEvent(QCloseEvent *e);
private:
void RunLocalMacros(RDMacro *rml);
void SetCaption();
RDConfig *panel_config;
RDCae *panel_cae;
RDRipc *panel_ripc;
RDUser *panel_user;
RDStation *panel_station;
RDSystem *panel_system;
RDEventPlayer *panel_player;
QPixmap *lib_rivendell_map;
QString panel_filter;
QString panel_group;
QString panel_schedcode;
std::vector<RDCartSlot *> panel_slots;
RDCartDialog *panel_cart_dialog;
RDSlotDialog *panel_slot_dialog;
RDCueEditDialog *panel_cue_dialog;
RDListSvcs *panel_svcs_dialog;
RDAirPlayConf *panel_airplay_conf;
};
#endif // RDCARTSLOTS_H

View File

@@ -0,0 +1,37 @@
# rdcartslots.pro
#
# The QMake project file for RDCartSlots.
#
# (C) Copyright 2012 Fred Gleason <fredg@paravelsystems.com>
#
# $Id: rdcartslots.pro,v 1.1.2.2 2012/11/16 18:10:41 cvs Exp $
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
TEMPLATE = app
x11 {
SOURCES += rdcartslots.cpp
}
x11 {
HEADERS += rdcartslots.h
}
TRANSLATIONS += rdcartslots_de.ts
TRANSLATIONS += rdcartslots_es.ts
TRANSLATIONS += rdcartslots_fr.ts
TRANSLATIONS += rdcartslots_nb.ts
TRANSLATIONS += rdcartslots_nn.ts
TRANSLATIONS += rdcartslots_pt_BR.ts

View File

@@ -0,0 +1,25 @@
<!DOCTYPE TS><TS>
<context>
<name>MainWidget</name>
<message>
<source>RDCartSlots</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[None]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Station</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@@ -0,0 +1,25 @@
<!DOCTYPE TS><TS>
<context>
<name>MainWidget</name>
<message>
<source>RDCartSlots</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[None]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Station</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@@ -0,0 +1,25 @@
<!DOCTYPE TS><TS>
<context>
<name>MainWidget</name>
<message>
<source>RDCartSlots</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[None]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Station</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@@ -0,0 +1,25 @@
<!DOCTYPE TS><TS>
<context>
<name>MainWidget</name>
<message>
<source>RDCartSlots</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[None]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Station</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@@ -0,0 +1,25 @@
<!DOCTYPE TS><TS>
<context>
<name>MainWidget</name>
<message>
<source>RDCartSlots</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[None]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Station</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@@ -0,0 +1,25 @@
<!DOCTYPE TS><TS>
<context>
<name>MainWidget</name>
<message>
<source>RDCartSlots</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>[None]</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Station</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>User</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Can&apos;t Connect</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>