2022-11-03 Fred Gleason <fredg@paravelsystems.com>

* Removed vestigal code for RDCatch control via TCP connection.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2022-11-03 12:44:29 -04:00
parent ae3542f9a4
commit 9161d9014e
22 changed files with 110 additions and 1325 deletions

View File

@@ -23608,3 +23608,5 @@
* Refactored rdcatch(1) and rdcatchd(8) to use the notification
mechanism instead for distributing meter updates instead of the
'Enable Metering' catch command.
2022-11-03 Fred Gleason <fredg@paravelsystems.com>
* Removed vestigal code for RDCatch control via TCP connection.

View File

@@ -33,8 +33,6 @@
all-local: cae.html\
cae.pdf\
catchd.html\
catchd.pdf\
fonts.html\
fonts.rdcastmanager.list_carts.png\
fonts.pdf\
@@ -54,9 +52,6 @@ all-local: cae.html\
EXTRA_DIST = cae.html\
cae.pdf\
cae.xml\
catchd.html\
catchd.pdf\
catchd.xml\
fonts.html\
fonts.pdf\
fonts.xml\

View File

@@ -1,137 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<article xmlns="http://docbook.org/ns/docbook" version="5.0">
<info>
<title>Rivendell RDCatch Monitor Protocol</title>
<author>
<personname>
<firstname>Fred</firstname>
<surname>Gleason</surname>
<email>fredg@paravelsystems.com</email>
</personname>
</author>
</info>
<sect1 xml:id="overview">
<title>Overview</title>
<para>
This defines the IP protocol used for communication between different
modules of Rivendell and the
<command>rdcatchd</command><manvolnum>8</manvolnum> daemon.
</para>
<para>
Connection to ripcd is by means of a TCP SOCK_STREAM connection to TCP
port <userinput>6006</userinput>. The format of a message is as follows:
</para>
<para>
<replaceable>cmd-code</replaceable> [<replaceable>arg</replaceable>] [<replaceable>...</replaceable>]!
</para>
<variablelist>
<varlistentry>
<term>
<replaceable>cmd-code</replaceable>
</term>
<listitem>
<para>
A two letter command code, describing the generic action to be
performed
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<replaceable>arg</replaceable>
</term>
<listitem>
<para>
Zero or more arguments, delimited by spaces or, if the last
argument, by ! (see below)
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
!
</term>
<listitem>
<para>
The ASCII character 33, indicating the end of the command sequence.
</para>
</listitem>
</varlistentry>
</variablelist>
</sect1>
<sect1 xml:id="sect.unprivileged_commands">
<title>Unprivileged Commands</title>
<para>
No authentication is required to execute these.
</para>
</sect1>
<sect1 xml:id="sect.privileged_commands">
<title>Privileged Commands</title>
<para>
A connection must be authenticated before these can be executed.
</para>
<sect2 xml:id="sect.privileged_commands.enable_metering">
<title>Enable Metering</title>
<para>
Enable/Disable Audio Metering
</para>
<para>
<userinput>RM <replaceable>state</replaceable>!</userinput>
</para>
<variablelist>
<varlistentry>
<term><replaceable>state</replaceable></term>
<listitem>
<para>
<computeroutput>1</computeroutput> = Enabled,
<computeroutput>0</computeroutput> = Disabled.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
When metering is active, meter data packets will be periodically sent,
as follows:
</para>
<para>
<computeroutput>RM <replaceable>deck</replaceable>
<replaceable>chan</replaceable>
<replaceable>level</replaceable>!</computeroutput>
</para>
<variablelist>
<varlistentry>
<term><replaceable>deck</replaceable></term>
<listitem>
<para>
Deck number
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>chan</replaceable></term>
<listitem>
<para>
Channel, <computeroutput>0</computeroutput> = Left,
<computeroutput>1</computeroutput> = Right
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>level</replaceable></term>
<listitem>
<para>
Left audio level, in 1/100 of dbFS
</para>
</listitem>
</varlistentry>
</variablelist>
</sect2>
</sect1>
</article>

View File

@@ -2,7 +2,7 @@
//
// An RDCatch event copier.
//
// (C) Copyright 2002-2005,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@@ -21,13 +21,11 @@
#ifndef RDCATCH_COPY_H
#define RDCATCH_COPY_H
#include <qobject.h>
#include <qapplication.h>
#include <qsqldatabase.h>
#include <QObject>
#include <QApplication>
#include <rdstation.h>
#include <rdripc.h>
#include <rdcatch_connect.h>
#include <rdstation.h>
#include <rdconfig.h>

View File

@@ -2,7 +2,7 @@
//
// A Library import filter for the Crown Wings system
//
// (C) Copyright 2002-2005,2018 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
//
// 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
@@ -25,7 +25,6 @@
#include <qobject.h>
#include <rdcatch_connect.h>
#include <rdgroup.h>
#include <rdwavefile.h>

View File

@@ -82,7 +82,6 @@ dist_librd_la_SOURCES = dbversion.h\
rdcartslot.cpp rdcartslot.h\
rdcastsearch.cpp rdcastsearch.h\
rdcatch_conf.cpp rdcatch_conf.h\
rdcatch_connect.cpp rdcatch_connect.h\
rdcatchevent.cpp rdcatchevent.h\
rdcutlistmodel.cpp rdcutlistmodel.h\
rdcddblookup.cpp rdcddblookup.h\
@@ -315,7 +314,6 @@ nodist_librd_la_SOURCES = moc_rdadd_cart.cpp\
moc_rdcart_dialog.cpp\
moc_rdcartfilter.cpp\
moc_rdcartslot.cpp\
moc_rdcatch_connect.cpp\
moc_rdcddblookup.cpp\
moc_rdcdplayer.cpp\
moc_rdcdripper.cpp\

View File

@@ -56,7 +56,6 @@ SOURCES += rdcart_dialog.cpp
SOURCES += rdcart_search_text.cpp
SOURCES += rdcartdrag.cpp
SOURCES += rdcartfilter.cpp
SOURCES += rdcatch_connect.cpp
SOURCES += rdcatchevent.cpp
SOURCES += rdcddblookup.cpp
SOURCES += rdcdplayer.cpp
@@ -246,7 +245,6 @@ HEADERS += rdcart_dialog.h
HEADERS += rdcart_search_text.h
HEADERS += rdcartdrag.h
HEADERS += rdcartfilter.h
HEADERS += rdcatch_connect.h
HEADERS += rdcatchevent.h
HEADERS += rdcddblookup.h
HEADERS += rdcdplayer.h

View File

@@ -1,272 +0,0 @@
// catch_connect.cpp
//
// Connect to the Rivendell Netcatcher Daemon.
//
// (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
//
// 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 <ctype.h>
#include <qobject.h>
#include <rdcatch_connect.h>
RDCatchConnect::RDCatchConnect(int serial,QObject *parent)
: QObject(parent)
{
cc_serial=serial;
cc_connected=false;
argnum=0;
argptr=0;
for(int i=0;i<MAX_DECKS;i++) {
cc_monitor_state[i]=false;
}
//
// TCP Connection
//
cc_socket=new QTcpSocket(this);
connect(cc_socket,SIGNAL(connected()),this,SLOT(connectedData()));
connect(cc_socket,SIGNAL(readyRead()),this,SLOT(readyData()));
}
RDCatchConnect::~RDCatchConnect()
{
// printf("Destroying RDCatchConnect\n");
}
void RDCatchConnect::connectHost(QString hostname,uint16_t hostport,
QString password)
{
cc_password=password;
cc_socket->connectToHost(hostname,hostport);
}
RDDeck::Status RDCatchConnect::status(unsigned chan) const
{
if(chan<=MAX_DECKS) {
return cc_record_deck_status[chan-1];
}
return cc_play_deck_status[chan-128];
}
int RDCatchConnect::currentId(unsigned chan) const
{
if(chan<=MAX_DECKS) {
return cc_record_id[chan-1];
}
return cc_play_id[chan-129];
}
void RDCatchConnect::enableMetering(bool state)
{
SendCommand(QString::asprintf("RM %d!",state));
}
void RDCatchConnect::reloadDropboxes()
{
SendCommand("RX!");
}
void RDCatchConnect::connectedData()
{
SendCommand(QString("PW ")+cc_password+"!");
}
void RDCatchConnect::readyData()
{
char buf[1024];
int c;
while((c=cc_socket->read(buf,254))>0) {
buf[c]=0;
// printf("readyData: %s\n",buf);
for(int i=0;i<c;i++) {
if(buf[i]==' ') {
if(argnum<CC_MAX_ARGS) {
args[argnum][argptr]=0;
argnum++;
argptr=0;
}
else {
if(debug) {
printf("Argument list truncated!\n");
}
}
}
if(buf[i]=='!') {
args[argnum++][argptr]=0;
DispatchCommand();
argnum=0;
argptr=0;
if(cc_socket==NULL) {
return;
}
}
if((isgraph(buf[i]))&&(buf[i]!='!')) {
if(argptr<CC_MAX_LENGTH) {
args[argnum][argptr]=buf[i];
argptr++;
}
else {
if(debug) {
printf("WARNING: argument truncated!\n");
}
}
}
}
}
}
void RDCatchConnect::SendCommand(QString cmd)
{
// printf("SendCommand(%s)\n",(const char *)cmd);
cc_socket->write(cmd.toUtf8());
}
void RDCatchConnect::DispatchCommand()
{
int deck;
int channel;
int level;
// unsigned chan;
// int status;
int id;
// int number;
if(!strcmp(args[0],"PW")) { // Password Response
if(args[1][0]=='+') {
emit connected(cc_serial,true);
SendCommand("RE 0!");
}
else {
emit connected(cc_serial,false);
}
}
/*
if(!strcmp(args[0],"DE")) { // Deck Event
if(sscanf(args[1],"%d",&deck)!=1) {
return;
}
if(sscanf(args[2],"%d",&number)!=1) {
return;
}
emit deckEventSent(cc_serial,deck,number);
}
if(!strcmp(args[0],"RE")) { // Channel Status
if(sscanf(args[1],"%u",&chan)!=1){
return;
}
if((chan<0)||((chan>(MAX_DECKS+1))&&(chan<(129)))||
(chan>(MAX_DECKS+129))) {
return;
}
if(sscanf(args[2],"%d",&status)!=1) {
return;
}
if(sscanf(args[3],"%d",&id)!=1) {
return;
}
if(chan==0) {
emit statusChanged(cc_serial,chan,(RDDeck::Status)status,id,"");
return;
}
chan--;
if(chan<=MAX_DECKS) {
if((status!=cc_record_deck_status[chan])||(id!=cc_record_id[chan])) {
cc_record_deck_status[chan]=(RDDeck::Status)status;
cc_record_id[chan]=id;
emit statusChanged(cc_serial,chan+1,cc_record_deck_status[chan],
cc_record_id[chan],args[4]);
}
}
if((chan>=128)&&(chan<MAX_DECKS+128)) {
if((status!=cc_play_deck_status[chan-128])||(id!=cc_play_id[chan-128])) {
cc_play_deck_status[chan-128]=(RDDeck::Status)status;
cc_play_id[chan-128]=id;
emit statusChanged(cc_serial,chan+1,cc_play_deck_status[chan-128],
cc_play_id[chan-128],args[4]);
}
}
return;
}
*/
if(!strcmp(args[0],"RM")) { // Meter Level
if(sscanf(args[1],"%d",&deck)!=1) {
return;
}
if(sscanf(args[2],"%d",&channel)!=1) {
return;
}
if(sscanf(args[3],"%d",&level)!=1) {
return;
}
emit meterLevel(cc_serial,deck,channel,level);
return;
}
if(!strcmp(args[0],"RU")) { // Update Event
if(sscanf(args[1],"%d",&id)!=1) {
return;
}
emit eventUpdated(id);
}
/*
if(!strcmp(args[0],"PE")) { // Purge Event
if(sscanf(args[1],"%d",&id)!=1) {
return;
}
emit eventPurged(id);
}
*/
/*
if(!strcmp(args[0],"HB")) { // Heartbeat
cc_heartbeat_timer->stop();
cc_heartbeat_timer->start(CC_HEARTBEAT_INTERVAL);
}
*/
/*
if(!strcmp(args[0],"MN")) { // Monitor State
if(sscanf(args[1],"%d",&deck)!=1) {
return;
}
if(args[2][0]=='1') {
cc_monitor_state[deck-1]=true;
emit monitorChanged(cc_serial,deck,true);
}
else {
cc_monitor_state[deck-1]=false;
emit monitorChanged(cc_serial,deck,false);
}
}
*/
}

View File

@@ -1,83 +0,0 @@
// rdcatch_connect.h
//
// Connect to the Rivendell Netcatcher Daemon.
//
// (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
//
// 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 <stdint.h>
#include <QLabel>
#include <QObject>
#include <QString>
#include <QTcpSocket>
#include <rd.h>
#include <rddeck.h>
#include <rdrecording.h>
#ifndef RDCATCH_CONNECT_H
#define RDCATCH_CONNECT_H
#define CC_MAX_ARGS 10
#define CC_MAX_LENGTH 256
#define CC_HEARTBEAT_INTERVAL 15000
class RDCatchConnect : public QObject
{
Q_OBJECT;
public:
RDCatchConnect(int serial,QObject *parent=0);
~RDCatchConnect();
void connectHost(QString hostname,uint16_t hostport,QString password);
RDDeck::Status status(unsigned chan) const;
int currentId(unsigned chan) const;
void enableMetering(bool state);
void reloadDropboxes();
signals:
void connected(int serial,bool state);
void statusChanged(int serial,unsigned channel,RDDeck::Status status,
int id,const QString &cutname);
void meterLevel(int serial,int deck,int chan,int level);
void eventUpdated(int id);
void eventPurged(int id);
private slots:
void connectedData();
void readyData();
private:
void SendCommand(QString cmd);
void DispatchCommand();
QTcpSocket *cc_socket;
QString cc_password;
bool debug;
char args[CC_MAX_ARGS][CC_MAX_LENGTH];
int argnum;
int argptr;
bool cc_connected;
RDDeck::Status cc_record_deck_status[MAX_DECKS];
RDDeck::Status cc_play_deck_status[MAX_DECKS];
int cc_record_id[MAX_DECKS];
int cc_play_id[MAX_DECKS];
int cc_serial;
bool cc_heartbeat_valid;
bool cc_monitor_state[MAX_DECKS];
};
#endif // RDCATCH_CONNECT_H

View File

@@ -21,7 +21,6 @@
#include <QMessageBox>
#include <rdapplication.h>
#include <rdcatch_connect.h>
#include <rdcart_dialog.h>
#include <rdconf.h>
#include <rddb.h>
@@ -62,9 +61,6 @@ EditStation::EditStation(QString sname,QWidget *parent)
setWindowTitle("RDAdmin - "+tr("Host: ")+sname);
GetPrivateProfileString(RD_CONF_FILE,"Identity","Password",temp,"",255);
station_catch_connect=new RDCatchConnect(0,this);
station_catch_connect->connectHost(station_station->address().toString(),
RDCATCHD_TCP_PORT,temp);
//
// Validators
@@ -811,7 +807,9 @@ void EditStation::editDropboxesData()
{
ListDropboxes *list_conf=new ListDropboxes(station_station->name(),this);
list_conf->exec();
station_catch_connect->reloadDropboxes();
//
// FIXME: reload the dropbox!
//
delete list_conf;
}

View File

@@ -31,7 +31,6 @@
#include <rddialog.h>
#include <rdcardselector.h>
#include <rdcatch_connect.h>
#include <rdcombobox.h>
#include <rdripc.h>
#include <rdstation.h>
@@ -80,7 +79,6 @@ class EditStation : public RDDialog
QString HostPart(QString);
RDStation *station_station;
RDStation *station_cae_station;
RDCatchConnect *station_catch_connect;
QLabel *station_name_label;
QLineEdit *station_name_edit;
QLabel *station_short_name_label;

View File

@@ -2,7 +2,7 @@
##
## Automake.am for rivendell/rdcatch
##
## (C) Copyright 2002-2021 Fred Gleason <fredg@paravelsystems.com>
## (C) Copyright 2002-2022 Fred Gleason <fredg@paravelsystems.com>
##
## 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
@@ -41,7 +41,6 @@ all:
bin_PROGRAMS = rdcatch
dist_rdcatch_SOURCES = add_recording.cpp add_recording.h\
catch_monitor.cpp catch_monitor.h\
catchtableview.cpp catchtableview.h\
colors.h\
deckmon.cpp deckmon.h\

View File

@@ -1,72 +0,0 @@
// catch_monitor.cpp
//
// A container class for RDCatch deck monitors and assorted metadata.
//
// (C) Copyright 2002-2018 Fred Gleason <fredg@paravelsystems.com>
//
// 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 <catch_monitor.h>
CatchMonitor::CatchMonitor()
{
catch_deck_mon=NULL;
catch_serial_number=-1;
catch_channel_number=-1;
}
CatchMonitor::CatchMonitor(DeckMon *mon,int serial,int channel)
{
catch_deck_mon=mon;
catch_serial_number=serial;
catch_channel_number=channel;
}
DeckMon *CatchMonitor::deckMon() const
{
return catch_deck_mon;
}
void CatchMonitor::setDeckMon(DeckMon *mon)
{
catch_deck_mon=mon;
}
int CatchMonitor::serialNumber() const
{
return catch_serial_number;
}
void CatchMonitor::setSerialNumber(int num)
{
catch_serial_number=num;
}
int CatchMonitor::channelNumber() const
{
return catch_channel_number;
}
void CatchMonitor::setChannelNumber(int num)
{
catch_channel_number=num;
}

View File

@@ -1,46 +0,0 @@
// catch_monitor.h
//
// A container class for RDCatch deck monitors and assorted metadata.
//
// (C) Copyright 2002-2018 Fred Gleason <fredg@paravelsystems.com>
//
// 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 CATCH_MONITOR_H
#define CATCH_MONITOR_H
#include <deckmon.h>
class CatchMonitor
{
public:
CatchMonitor();
CatchMonitor(DeckMon *mon,int serial,int channel);
DeckMon *deckMon() const;
void setDeckMon(DeckMon *mon);
int serialNumber() const;
void setSerialNumber(int num);
int channelNumber() const;
void setChannelNumber(int num);
private:
DeckMon *catch_deck_mon;
int catch_serial_number;
int catch_channel_number;
};
#endif // CATCH_MONITOR_H

View File

@@ -140,84 +140,6 @@ void DeckMon::enableMonitorButton(bool state)
}
void DeckMon::setStatus(RDDeck::Status status,int id,const QString &cutname)
{
if(id==0) {
mon_status_label->setText(tr("IDLE"));
SetCutInfo(0,"");
mon_left_meter->setPeakBar(-10000);
mon_right_meter->setPeakBar(-10000);
mon_abort_button->setDisabled(true);
mon_event_light->setDisabled(true);
return;
}
switch(status) {
case RDDeck::Offline:
mon_status_label->setText(tr("OFFLINE"));
SetCutInfo(0,"");
mon_left_meter->setPeakBar(-10000);
mon_right_meter->setPeakBar(-10000);
mon_abort_button->setDisabled(true);
mon_event_light->setDisabled(true);
break;
case RDDeck::Idle:
mon_status_label->setText(tr("IDLE"));
SetCutInfo(0,"");
mon_left_meter->setPeakBar(-10000);
mon_right_meter->setPeakBar(-10000);
mon_abort_button->setDisabled(true);
mon_event_light->setDisabled(true);
break;
case RDDeck::Ready:
mon_status_label->setText(tr("READY"));
SetCutInfo(id,"");
mon_left_meter->setPeakBar(-10000);
mon_right_meter->setPeakBar(-10000);
mon_abort_button->setEnabled(true);
mon_event_light->setDisabled(true);
break;
case RDDeck::Waiting:
mon_status_label->setText(tr("WAITING"));
SetCutInfo(id,"");
mon_left_meter->setPeakBar(-10000);
mon_right_meter->setPeakBar(-10000);
mon_abort_button->setEnabled(true);
mon_event_light->setDisabled(true);
break;
case RDDeck::Recording:
if((mon_channel>0)&&(mon_channel<(MAX_DECKS+1))) {
mon_status_label->setText(tr("RECORDING"));
}
if((mon_channel>128)&&(mon_channel<(MAX_DECKS+129))) {
mon_status_label->setText(tr("PLAYING"));
}
SetCutInfo(id,cutname);
mon_abort_button->setEnabled(true);
mon_event_light->setEnabled(true);
break;
case RDDeck::LastStatus:
break;
}
}
/*
void DeckMon::setLeftMeter(int level)
{
mon_left_meter->setPeakBar(level);
}
void DeckMon::setRightMeter(int level)
{
mon_right_meter->setPeakBar(level);
}
*/
void DeckMon::processCatchEvent(RDCatchEvent *evt)
{
// printf("processCatchEvent(): %s\n",evt->dump().toUtf8().constData());
@@ -234,7 +156,7 @@ void DeckMon::processCatchEvent(RDCatchEvent *evt)
case RDCatchEvent::DeckStatusResponseOp:
if(evt->deckChannel()==mon_channel) {
setStatus(evt->deckStatus(),evt->eventId(),
SetStatus(evt->deckStatus(),evt->eventId(),
RDCut::cutName(evt->cartNumber(),evt->cutNumber()));
}
break;
@@ -303,7 +225,72 @@ void DeckMon::abortButtonData()
rda->ripc()->sendCatchEvent(evt);
delete evt;
// emit abortClicked();
}
void DeckMon::SetStatus(RDDeck::Status status,int id,const QString &cutname)
{
if(id==0) {
mon_status_label->setText(tr("IDLE"));
SetCutInfo(0,"");
mon_left_meter->setPeakBar(-10000);
mon_right_meter->setPeakBar(-10000);
mon_abort_button->setDisabled(true);
mon_event_light->setDisabled(true);
return;
}
switch(status) {
case RDDeck::Offline:
mon_status_label->setText(tr("OFFLINE"));
SetCutInfo(0,"");
mon_left_meter->setPeakBar(-10000);
mon_right_meter->setPeakBar(-10000);
mon_abort_button->setDisabled(true);
mon_event_light->setDisabled(true);
break;
case RDDeck::Idle:
mon_status_label->setText(tr("IDLE"));
SetCutInfo(0,"");
mon_left_meter->setPeakBar(-10000);
mon_right_meter->setPeakBar(-10000);
mon_abort_button->setDisabled(true);
mon_event_light->setDisabled(true);
break;
case RDDeck::Ready:
mon_status_label->setText(tr("READY"));
SetCutInfo(id,"");
mon_left_meter->setPeakBar(-10000);
mon_right_meter->setPeakBar(-10000);
mon_abort_button->setEnabled(true);
mon_event_light->setDisabled(true);
break;
case RDDeck::Waiting:
mon_status_label->setText(tr("WAITING"));
SetCutInfo(id,"");
mon_left_meter->setPeakBar(-10000);
mon_right_meter->setPeakBar(-10000);
mon_abort_button->setEnabled(true);
mon_event_light->setDisabled(true);
break;
case RDDeck::Recording:
if((mon_channel>0)&&(mon_channel<(MAX_DECKS+1))) {
mon_status_label->setText(tr("RECORDING"));
}
if((mon_channel>128)&&(mon_channel<(MAX_DECKS+129))) {
mon_status_label->setText(tr("PLAYING"));
}
SetCutInfo(id,cutname);
mon_abort_button->setEnabled(true);
mon_event_light->setEnabled(true);
break;
case RDDeck::LastStatus:
break;
}
}

View File

@@ -21,8 +21,8 @@
#ifndef DECKMON_H
#define DECKMON_H
#include <qlabel.h>
#include <qpushbutton.h>
#include <QLabel>
#include <QPushButton>
#include <rddeck.h>
#include <rdframe.h>
@@ -42,9 +42,6 @@ class DeckMon : public RDFrame
void enableMonitorButton(bool state);
public slots:
void setStatus(RDDeck::Status status,int id,const QString &cutname);
// void setLeftMeter(int level);
// void setRightMeter(int level);
void processCatchEvent(RDCatchEvent *evt);
protected:
@@ -55,6 +52,7 @@ class DeckMon : public RDFrame
void abortButtonData();
private:
void SetStatus(RDDeck::Status status,int id,const QString &cutname);
void SetCutInfo(int id,const QString &cutname);
QLabel *mon_station_label;
QLabel *mon_cut_label;

View File

@@ -52,27 +52,6 @@ EditUpload *catch_editupload_dialog;
int catch_audition_card=-1;
int catch_audition_port=-1;
CatchConnector::CatchConnector(RDCatchConnect *conn,const QString &station_name)
{
catch_connect=conn;
catch_station_name=station_name;
}
RDCatchConnect *CatchConnector::connector() const
{
return catch_connect;
}
QString CatchConnector::stationName()
{
return catch_station_name;
}
MainWidget::MainWidget(RDConfig *c,QWidget *parent)
: RDMainWindow("rdcatch",c)
{
@@ -187,22 +166,6 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
"`NAME`!='DEFAULT'";
RDSqlQuery *q=new RDSqlQuery(sql);
while(q->next()) {
catch_connect.push_back(new CatchConnector(new RDCatchConnect(catch_connect.size(),this),q->value(0).toString().toLower()));
connect(catch_connect.back()->connector(),
SIGNAL(statusChanged(int,unsigned,RDDeck::Status,int,const QString &)),
this,
SLOT(statusChangedData(int,unsigned,RDDeck::Status,int,const QString &)));
connect(catch_connect.back()->connector(),
SIGNAL(connected(int,bool)),
this,SLOT(connectedData(int,bool)));
/*
connect(catch_connect.back()->connector(),
SIGNAL(meterLevel(int,int,int,int)),
this,SLOT(meterLevelData(int,int,int,int)));
*/
catch_connect.back()->connector()->
connectHost(q->value(1).toString(),RDCATCHD_TCP_PORT,
rda->config()->password());
sql=QString("select ")+
"`CHANNEL`,"+ // 00
"`MON_PORT_NUMBER` "+ // 01
@@ -213,29 +176,18 @@ MainWidget::MainWidget(RDConfig *c,QWidget *parent)
"order by `CHANNEL`";
q1=new RDSqlQuery(sql);
while(q1->next()) {
catch_connect.back()->chan.push_back(q1->value(0).toUInt());
catch_connect.back()->mon_id.push_back(catch_monitor.size());
DeckMon *mon=new DeckMon(q->value(0).toString(),q1->value(0).toUInt(),
catch_monitor_vbox);
catch_deck_monitors.
push_back(new DeckMon(q->value(0).toString(),q1->value(0).toUInt(),
catch_monitor_vbox));
connect(rda->ripc(),SIGNAL(catchEventReceived(RDCatchEvent *)),
mon,SLOT(processCatchEvent(RDCatchEvent *)));
catch_monitor.push_back(new CatchMonitor());
catch_monitor.back()->setDeckMon(mon);
catch_monitor.back()->setSerialNumber(catch_connect.size()-1);
catch_monitor.back()->setChannelNumber(q1->value(0).toUInt());
catch_monitor_vbox->addWidget(catch_monitor.back()->deckMon());
catch_monitor.back()->deckMon()->
enableMonitorButton((q1->value(1).toInt()>=0)&&
(rda->config()->stationName().toLower()==
q->value(0).toString().toLower()));
catch_monitor.back()->deckMon()->show();
catch_deck_monitors.back(),
SLOT(processCatchEvent(RDCatchEvent *)));
catch_monitor_vbox->addWidget(catch_deck_monitors.back());
}
delete q1;
}
delete q;
if(catch_monitor.size()==0) {
if(catch_deck_monitors.size()==0) {
catch_monitor_area->hide();
}
@@ -493,14 +445,6 @@ QSizePolicy MainWidget::sizePolicy() const
}
void MainWidget::connectedData(int serial,bool state)
{
if(state) {
catch_connect[serial]->connector()->enableMetering(true);
}
}
void MainWidget::nextEventData()
{
QTime next_time;
@@ -547,7 +491,6 @@ void MainWidget::nextEventData()
void MainWidget::addData()
{
int conn;
RDNotification *notify=NULL;
QModelIndex row;
RDRecording::Type type=RDRecording::Recording;
@@ -566,11 +509,6 @@ void MainWidget::addData()
if(row.isValid()) {
catch_recordings_view->selectRow(row.row());
}
conn=GetConnection(catch_recordings_model->hostName(row));
if(conn<0) {
fprintf(stderr,"rdcatch: invalid connection index!\n");
return;
}
nextEventData();
}
}
@@ -648,7 +586,6 @@ void MainWidget::deleteData()
{
QString warning;
QString filename;
int conn;
QString sql;
QModelIndexList rows=catch_recordings_view->selectionModel()->selectedRows();
@@ -665,11 +602,6 @@ void MainWidget::deleteData()
QMessageBox::Yes) {
return;
}
conn=GetConnection(catch_recordings_model->hostName(rows.first()));
if(conn<0) {
fprintf(stderr,"rdcatch: invalid connection index!\n");
return;
}
sql=QString("delete from `RECORDINGS` where ")+
QString::asprintf("`ID`=%u",catch_recordings_model->recordId(rows.first()));
RDSqlQuery::apply(sql);
@@ -719,36 +651,6 @@ void MainWidget::ripcUserData()
}
void MainWidget::statusChangedData(int serial,unsigned chan,
RDDeck::Status status,int id,
const QString &cutname)
{
// printf("statusChangedData(%d,%u,%d,%d)\n",serial,chan,status,id);
int mon=GetMonitor(serial,chan);
catch_recordings_model->setRecordStatus(id,status);
if(mon>=0) {
int waiting_count=0;
int active_count=0;
unsigned waiting_id=0;
catch_recordings_model->
channelCounts(chan,&waiting_count,&active_count,&waiting_id);
if(waiting_count>1) {
catch_monitor[mon]->deckMon()->setStatus(status,-1,cutname);
}
else {
if((active_count==0)||(status!=RDDeck::Idle)) {
catch_monitor[mon]->deckMon()->setStatus(status,id,cutname);
}
else {
catch_monitor[mon]->deckMon()->
setStatus(RDDeck::Waiting,waiting_id,cutname);
}
}
}
nextEventData();
}
void MainWidget::catchEventReceivedData(RDCatchEvent *evt)
{
// printf("catchEventReceivedData()\n");
@@ -756,7 +658,6 @@ void MainWidget::catchEventReceivedData(RDCatchEvent *evt)
switch(evt->operation()) {
case RDCatchEvent::DeckStatusResponseOp:
printf("catchEventReceivedData(): %s\n",evt->dump().toUtf8().constData());
if(evt->eventId()>0) {
if(!catch_recordings_model->refresh(evt->eventId())) {
catch_recordings_model->addRecord(evt->eventId());
@@ -813,8 +714,10 @@ void MainWidget::headButtonData()
RDSetMixerOutputPort(rda->cae(),catch_audition_card,catch_audition_stream,
catch_audition_port);
rda->cae()->positionPlay(catch_play_handle,cut->startPoint());
rda->cae()->setPlayPortActive(catch_audition_card,catch_audition_port,catch_audition_stream);
rda->cae()->setOutputVolume(catch_audition_card,catch_audition_stream,catch_audition_port,
rda->cae()->setPlayPortActive(catch_audition_card,catch_audition_port,
catch_audition_stream);
rda->cae()->setOutputVolume(catch_audition_card,catch_audition_stream,
catch_audition_port,
0+cut->playGain());
rda->cae()->play(catch_play_handle,RDCATCH_AUDITION_LENGTH,
RD_TIMESCALE_DIVISOR,false);
@@ -905,25 +808,6 @@ void MainWidget::playStoppedData(int handle)
rda->cae()->unloadPlay(catch_play_handle);
}
/*
void MainWidget::meterLevelData(int serial,int deck,int l_r,int level)
{
DeckMon *monitor;
for(unsigned i=0;i<catch_connect[serial]->chan.size();i++) {
if(catch_connect[serial]->chan[i]==(unsigned)deck) {
monitor=catch_monitor[catch_connect[serial]->mon_id[i]]->deckMon();
if(l_r==0) {
monitor->setLeftMeter(level);
}
if(l_r==1) {
monitor->setRightMeter(level);
}
return;
}
}
}
*/
void MainWidget::selectionChangedData(const QItemSelection &before,
const QItemSelection &after)
@@ -1126,11 +1010,11 @@ void MainWidget::resizeEvent(QResizeEvent *e)
{
assert(e);
assert(catch_monitor_area);
if(catch_monitor.size()<=RDCATCH_MAX_VISIBLE_MONITORS) {
if(catch_deck_monitors.size()<=RDCATCH_MAX_VISIBLE_MONITORS) {
catch_monitor_area->
setGeometry(10,10,e->size().width()-20,32*catch_monitor.size()+4);
setGeometry(10,10,e->size().width()-20,32*catch_deck_monitors.size()+4);
catch_monitor_vbox->
setGeometry(0,0,e->size().width()-25,32*catch_monitor.size());
setGeometry(0,0,e->size().width()-25,32*catch_deck_monitors.size());
}
else {
catch_monitor_area->
@@ -1139,17 +1023,16 @@ void MainWidget::resizeEvent(QResizeEvent *e)
// This depends on the width of the scrollbar. How to reliably
// determine such on various desktops?
//
// (catch_monitor_area->verticalScrollBar()->geometry().width() is not
// always accurate!)
// N.B. catch_monitor_area->verticalScrollBar()->geometry().width() is not
// always accurate!
//
catch_monitor_vbox->
setGeometry(0,
0,
setGeometry(0,0,
e->size().width()-40, // Works on XFCE, what about others?
32*catch_monitor.size());
32*catch_deck_monitors.size());
}
int deck_height=0;
if (catch_monitor.size()>0){
if (catch_deck_monitors.size()>0){
deck_height=catch_monitor_area->geometry().y()+
catch_monitor_area->geometry().height();
}
@@ -1277,37 +1160,6 @@ void MainWidget::UpdateScroll()
}
int MainWidget::GetMonitor(int serial,int chan)
{
for(unsigned i=0;i<catch_monitor.size();i++) {
if((catch_monitor[i]->serialNumber()==serial)&&
(catch_monitor[i]->channelNumber()==chan)) {
return i;
}
}
return -1;
}
int MainWidget::GetConnection(QString station,unsigned chan)
{
for(unsigned i=0;i<catch_connect.size();i++) {
if(catch_connect[i]->stationName()==station.toLower()) {
if(chan==0) {
return i;
}
for(unsigned j=0;j<catch_connect[i]->chan.size();j++) {
if(catch_connect[i]->chan[j]==chan) {
return i;
}
}
return -1;
}
}
printf(" No connection found!\n");
return -1;
}
QString MainWidget::GeometryFile() {
bool home_found = false;
QString home = RDGetHomeDir(&home_found);

View File

@@ -23,10 +23,10 @@
#include <QCheckBox>
#include <QComboBox>
#include <QList>
#include <QScrollArea>
#include <rdcart_dialog.h>
#include <rdcatch_connect.h>
#include <rdcut_dialog.h>
#include <rdmainwindow.h>
#include <rdtableview.h>
@@ -34,7 +34,6 @@
#include <rdwidget.h>
#include "add_recording.h"
#include "catch_monitor.h"
#include "catchtableview.h"
#include "deckmon.h"
#include "recordlistmodel.h"
@@ -48,21 +47,6 @@
#define RDCATCH_MAX_VISIBLE_MONITORS 8
#define RDCATCH_USAGE "[--offline-host-warnings=yes|no]\n"
class CatchConnector
{
public:
CatchConnector(RDCatchConnect *conn,const QString &station_name);
RDCatchConnect *connector() const;
QString stationName();
std::vector<unsigned> chan;
std::vector<unsigned> mon_id;
private:
RDCatchConnect *catch_connect;
QString catch_station_name;
};
class MainWidget : public RDMainWindow
{
Q_OBJECT
@@ -72,15 +56,12 @@ class MainWidget : public RDMainWindow
QSizePolicy sizePolicy() const;
private slots:
void connectedData(int serial,bool state);
void nextEventData();
void addData();
void editData();
void deleteData();
void ripcConnectedData(bool);
void ripcUserData();
void statusChangedData(int,unsigned,RDDeck::Status,int,
const QString &cutname);
void catchEventReceivedData(RDCatchEvent *evt);
void scrollButtonData();
void reportsButtonData();
@@ -90,7 +71,6 @@ class MainWidget : public RDMainWindow
void initData(bool);
void playedData(int);
void playStoppedData(int);
// void meterLevelData(int,int,int,int);
void selectionChangedData(const QItemSelection &before,
const QItemSelection &after);
void doubleClickedData(const QModelIndex &index);
@@ -110,13 +90,9 @@ class MainWidget : public RDMainWindow
void ProcessNewRecords(std::vector<int> *adds);
void EnableScroll(bool state);
void UpdateScroll();
int GetMonitor(int serial,int chan);
int GetConnection(QString station,unsigned chan=0);
QString GeometryFile();
std::vector<CatchMonitor *> catch_monitor;
QScrollArea *catch_monitor_area;
VBox *catch_monitor_vbox;
std::vector<CatchConnector *> catch_connect;
QSqlDatabase *catch_db;
int catch_audition_stream;
int catch_play_handle;
@@ -154,6 +130,7 @@ class MainWidget : public RDMainWindow
int catch_time_offset;
bool catch_host_warnings;
AddRecording *catch_add_recording_dialog;
QList<DeckMon *> catch_deck_monitors;
};

View File

@@ -32,8 +32,8 @@ x11 {
SOURCES += edit_upload.cpp
SOURCES += eventlight.cpp
SOURCES += eventwidget.cpp
SOURCES += rdcatch.cpp
SOURCES += list_reports.cpp
SOURCES += rdcatch.cpp
SOURCES += recordlistmodel.cpp
}
@@ -50,8 +50,8 @@ x11 {
HEADERS += edit_upload.h
HEADERS += eventlight.h
HEADERS += eventwidget.h
HEADERS += rdcatch.h
HEADERS += list_reports.h
HEADERS += rdcatch.h
HEADERS += recordlistmodel.h
}

View File

@@ -55,21 +55,10 @@
#include "rdcatchd.h"
void MainObject::catchConnectedData(int serial,bool state)
{
if(!state) {
rda->syslog(LOG_ERR,"unable to connect to rdcatchd(8) daemon");
exit(256);
}
connect(rda,SIGNAL(userChanged()),this,SLOT(userChangedData()));
rda->ripc()->
connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
}
void MainObject::userChangedData()
{
disconnect(rda,SIGNAL(userChanged()),this,SLOT(userChangedData()));
//
// Dispatch Handler
//
@@ -160,13 +149,11 @@ void MainObject::RunBatch(RDCmdSwitch *cmd)
delete q;
//
// Open Status Connection
// Connect to ripcd(8)
//
catch_connect=new RDCatchConnect(0,this);
connect(catch_connect,SIGNAL(connected(int,bool)),
this,SLOT(catchConnectedData(int,bool)));
catch_connect->
connectHost("localhost",RDCATCHD_TCP_PORT,rda->config()->password());
connect(rda,SIGNAL(userChanged()),this,SLOT(userChangedData()));
rda->ripc()->
connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
}

View File

@@ -35,8 +35,6 @@
#include <sched.h>
#include <sys/mman.h>
#include <vector>
#include <QApplication>
#include <rdapplication.h>
@@ -80,73 +78,6 @@ void SigHandler(int signum)
}
ServerConnection::ServerConnection(int id,QTcpSocket *sock)
{
conn_id=id;
conn_socket=sock;
conn_authenticated=false;
conn_meter_enabled=false;
conn_is_closing=false;
accum="";
}
ServerConnection::~ServerConnection()
{
delete conn_socket;
}
int ServerConnection::id() const
{
return conn_id;
}
bool ServerConnection::isAuthenticated() const
{
return conn_authenticated;
}
void ServerConnection::setAuthenticated(bool state)
{
conn_authenticated=state;
}
bool ServerConnection::meterEnabled() const
{
return conn_meter_enabled;
}
void ServerConnection::setMeterEnabled(bool state)
{
conn_meter_enabled=state;
}
QTcpSocket *ServerConnection::socket()
{
return conn_socket;
}
bool ServerConnection::isClosing() const
{
return conn_is_closing;
}
void ServerConnection::close()
{
conn_is_closing=true;
}
MainObject::MainObject(QObject *parent)
:QObject(parent)
{
@@ -241,23 +172,6 @@ MainObject::MainObject(QObject *parent)
connect(timer,SIGNAL(timeout()),this,SLOT(freeEventsData()));
timer->start(RDCATCHD_FREE_EVENTS_INTERVAL);
//
// Command Server
//
server=new QTcpServer(this);
if(!server->listen(QHostAddress::Any,RDCATCHD_TCP_PORT)) {
fprintf(stderr,"rdcatchd: aborting - couldn't bind socket");
exit(1);
}
connect(server,SIGNAL(newConnection()),this,SLOT(newConnectionData()));
catch_ready_mapper=new QSignalMapper(this);
connect(catch_ready_mapper,SIGNAL(mapped(int)),this,SLOT(socketReadyReadData(int)));
catch_kill_mapper=new QSignalMapper(this);
connect(catch_kill_mapper,SIGNAL(mapped(int)),this,SLOT(socketKillData(int)));
catch_garbage_timer=new QTimer(this);
catch_garbage_timer->setSingleShot(true);
connect(catch_garbage_timer,SIGNAL(timeout()),this,SLOT(garbageData()));
//
// Create RDCatchConf
//
@@ -535,28 +449,6 @@ void MainObject::catchEventReceivedData(RDCatchEvent *evt)
}
}
void MainObject::newConnectionData()
{
int i=0;
QTcpSocket *sock=server->nextPendingConnection();
while((i<catch_connections.size())&&(catch_connections[i]!=NULL)) {
i++;
}
if(i==catch_connections.size()) { // Table full, create a new slot
catch_connections.push_back(new ServerConnection(i,sock));
}
else {
catch_connections[i]=new ServerConnection(i,sock);
}
connect(sock,SIGNAL(readyRead()),catch_ready_mapper,SLOT(map()));
catch_ready_mapper->setMapping(sock,i);
connect(sock,SIGNAL(disconnected()),catch_kill_mapper,SLOT(map()));
catch_kill_mapper->setMapping(sock,i);
rda->syslog(LOG_DEBUG,"created connection %d",i);
}
void MainObject::rmlReceivedData(RDMacro *rml)
{
if(rml->role()!=RDMacro::Cmd) {
@@ -903,58 +795,6 @@ void MainObject::engineData(int id)
}
void MainObject::socketReadyReadData(int ch)
{
ParseCommand(ch);
}
void MainObject::socketKillData(int conn_id)
{
if(catch_connections[conn_id]!=NULL) {
catch_connections[conn_id]->close();
catch_garbage_timer->start(1);
}
}
void MainObject::garbageData()
{
for(int i=0;i<catch_connections.size();i++) {
if(catch_connections.at(i)!=NULL) {
if(catch_connections.at(i)->isClosing()) {
delete catch_connections.at(i);
catch_connections[i]=NULL;
rda->syslog(LOG_DEBUG,"closed connection %d",i);
}
}
}
}
void MainObject::isConnectedData(bool state)
{
if(state) {
QList<int> cards;
QString sql=QString("select `CARD_NUMBER` from `DECKS` where ")+
"`STATION_NAME`='"+RDEscapeString(rda->station()->name())+"' && "+
"`CARD_NUMBER`>=0";
RDSqlQuery *q=new RDSqlQuery(sql);
while(q->next()) {
if(!cards.contains(q->value(0).toInt())) {
cards.push_back(q->value(0).toInt());
}
}
delete q;
rda->cae()->enableMetering(&cards);
}
if(!state) {
rda->syslog(LOG_ERR,"aborting - unable to connect to Core AudioEngine");
exit(1);
}
}
void MainObject::recordLoadedData(int card,int stream)
{
int deck=GetRecordDeck(card,stream);
@@ -988,13 +828,11 @@ void MainObject::recordingData(int card,int stream)
void MainObject::recordStoppedData(int card,int stream)
{
int deck=GetRecordDeck(card,stream);
short levels[2]={-10000,-10000};
catch_record_status[deck-1]=false;
if(debug) {
printf("Stopped - Card: %d Stream: %d\n",card,stream);
}
SendMeterLevel(deck-1,levels);
rda->cae()->unloadRecord(card,stream);
}
@@ -1099,7 +937,6 @@ void MainObject::playingData(int handle)
void MainObject::playStoppedData(int handle)
{
int deck=GetPlayoutDeck(handle);
short levels[2]={-10000,-10000};
catch_playout_status[deck-129]=false;
catch_playout_event_player[deck-129]->stop();
@@ -1110,7 +947,6 @@ void MainObject::playStoppedData(int handle)
catch_playout_card[deck-129],
catch_playout_stream[deck-129]);
}
SendMeterLevel(deck,levels);
rda->cae()->unloadPlay(handle);
}
@@ -1174,22 +1010,6 @@ void MainObject::meterData()
rda->ripc()->sendCatchEvent(evt);
delete evt;
}
/*
for(int i=0;i<MAX_DECKS;i++) {
if(catch_record_deck_status[i]==RDDeck::Recording) {
rda->cae()->inputMeterUpdate(catch_record_card[i],catch_record_stream[i],
levels);
SendMeterLevel(i+1,levels);
}
if(catch_playout_deck_status[i]==RDDeck::Recording) {
rda->cae()->
outputMeterUpdate(catch_playout_card[i],catch_playout_port[i],
levels);
SendMeterLevel(i+129,levels);
}
}
*/
}
@@ -1689,23 +1509,8 @@ void MainObject::SendFullEventResponse(const QHostAddress &addr)
}
void MainObject::SendMeterLevel(int deck,short levels[2])
{
for(int i=0;i<catch_connections.size();i++) {
if(catch_connections.at(i)!=NULL) {
if(catch_connections.at(i)->meterEnabled()) {
EchoCommand(i,QString::asprintf("RM %d 0 %d!",deck,(int)levels[0]));
EchoCommand(i,QString::asprintf("RM %d 1 %d!",deck,(int)levels[1]));
}
}
}
}
void MainObject::SendDeckEvent(int deck,int number)
{
BroadcastCommand(QString::asprintf("DE %d %d!",deck,number));
RDCatchEvent *evt=new RDCatchEvent();
evt->setOperation(RDCatchEvent::DeckEventProcessedOp);
evt->setDeckChannel(deck);
@@ -1715,155 +1520,6 @@ void MainObject::SendDeckEvent(int deck,int number)
}
void MainObject::ParseCommand(int ch)
{
char data[1501];
int n;
ServerConnection *conn=catch_connections.at(ch);
if(conn!=NULL) {
while((n=conn->socket()->read(data,1500))>0) {
data[n]=0;
QString line=QString::fromUtf8(data);
for(int i=0;i<line.length();i++) {
QChar c=line.at(i);
bool modified=false;
if(c==QChar('!')) {
DispatchCommand(conn);
conn->accum="";
modified=true;
}
if((!modified)&&(c!=QChar('\r'))&&(c!=QChar('\n'))) {
conn->accum+=c;
}
}
}
}
}
void MainObject::DispatchCommand(ServerConnection *conn)
{
// int chan;
// int id;
// int event;
// int code;
QString str;
// bool ok=false;
QStringList cmds=conn->accum.split(" ");
//
// Common Commands
// Authentication not required to execute these!
//
if(cmds.at(0)=="DC") { // Drop Connection
socketKillData(conn->id());
return;
}
if((cmds.at(0)=="PW")&&(cmds.size()==2)) { // Password Authenticate
if(cmds.at(1)==rda->config()->password()) {
conn->setAuthenticated(true);
EchoCommand(conn->id(),"PW +!");
return;
}
else {
conn->setAuthenticated(false);
EchoCommand(conn->id(),"PW -!");
return;
}
}
//
// Priviledged Commands
// Authentication required to execute these!
//
if(!conn->isAuthenticated()) {
EchoArgs(conn->id(),'-');
return;
}
if(cmds.at(0)=="RS") { // Reset
EchoArgs(conn->id(),'+');
LoadEngine();
}
if(cmds.at(0)=="RD") { // Load Deck List
EchoArgs(conn->id(),'+');
LoadDeckList();
}
if((cmds.at(0)=="RM")&&(cmds.size()==2)) { // Enable/Disable Metering
conn->setMeterEnabled(cmds.at(1).trimmed()!="0");
}
/*
if((cmds.at(0)=="SC")&&(cmds.size()>=4)) { // Set Exit Code
id=cmds.at(1).toInt(&ok);
if(!ok) {
return;
}
code=cmds.at(2).toInt(&ok);
if(!ok) {
return;
}
str="";
for(int i=3;i<cmds.size();i++) {
str+=cmds.at(i)+" ";
str=str.left(str.length()-1);
}
if((event=GetEvent(id))<0) {
return;
}
WriteExitCode(event,(RDRecording::ExitCode)code,str);
SendEventResponse(0,RDDeck::Idle,id,"");
// BroadcastCommand(QString::asprintf("RE 0 %d %d!",RDDeck::Idle,id));
if((RDRecording::ExitCode)code==RDRecording::Ok) {
SendEventResponse(0,RDDeck::Idle,id,"");
// BroadcastCommand(QString::asprintf("RE 0 %d %d!",RDDeck::Idle,id));
}
else {
SendEventResponse(0,RDDeck::Offline,id,"");
// BroadcastCommand(QString::asprintf("RE 0 %d %d!",RDDeck::Offline,id));
}
}
*/
}
void MainObject::EchoCommand(int ch,const QString &cmd)
{
// LogLine(RDConfig::LogDebug,QString::asprintf("rdcatchd: EchoCommand(%d,%s)",ch,command));
ServerConnection *conn=catch_connections.at(ch);
if(conn->socket()->state()==QAbstractSocket::ConnectedState) {
conn->socket()->write(cmd.toUtf8());
}
}
void MainObject::BroadcastCommand(const QString &cmd,int except_ch)
{
// LogLine(RDConfig::LogDebug,QString::asprintf("rdcatchd: BroadcastCommand(%s)",command));
for(int i=0;i<catch_connections.size();i++) {
if(catch_connections.at(i)!=NULL) {
if(i!=except_ch) {
EchoCommand(i,cmd);
}
}
}
}
void MainObject::EchoArgs(int ch,const char append)
{
ServerConnection *conn=catch_connections.at(ch);
if(conn!=NULL) {
QString cmd=conn->accum+append+"!";
EchoCommand(ch,cmd);
}
}
void MainObject::LoadEngine(bool adv_day)
{
RDSqlQuery *q;
@@ -2468,13 +2124,6 @@ QString MainObject::GetFileExtension(QString filename)
return QString();
}
/* This is an overloaded virtual function to tell a session manager not to restart this daemon. */
/*
void QApplication::saveState(QSessionManager &sm) {
sm.setRestartHint(QSessionManager::RestartNever);
return;
};
*/
bool MainObject::ExecuteErrorRml(CatchEvent *event,const QString &err_desc,
QString rml)

View File

@@ -29,7 +29,6 @@
#include <rd.h>
#include <rdcart.h>
#include <rdcatch_conf.h>
#include <rdcatch_connect.h>
#include <rdcatchevent.h>
#include <rdcmd_switch.h>
#include <rddeck.h>
@@ -51,32 +50,6 @@
#define RDCATCHD_HEARTBEAT_INTERVAL 10000
#define RDCATCHD_ERROR_ID_OFFSET 1000000
class ServerConnection
{
public:
ServerConnection(int id,QTcpSocket *sock);
~ServerConnection();
int id() const;
bool isAuthenticated() const;
void setAuthenticated(bool state);
bool meterEnabled() const;
void setMeterEnabled(bool state);
QTcpSocket *socket();
bool isClosing() const;
void close();
QString accum;
private:
int conn_id;
bool conn_authenticated;
bool conn_meter_enabled;
QTcpSocket *conn_socket;
bool conn_is_closing;
};
class MainObject : public QObject
{
Q_OBJECT
@@ -87,16 +60,11 @@ class MainObject : public QObject
//
// rdcatchd.cpp
//
void newConnectionData();
void rmlReceivedData(RDMacro *rml);
void gpiStateChangedData(int matrix,int line,bool state);
void startTimerData(int id);
void offsetTimerData(int id);
void engineData(int);
void socketReadyReadData(int conn_id);
void socketKillData(int conn_id);
void garbageData();
void isConnectedData(bool state);
void recordLoadedData(int card,int stream);
void recordingData(int card,int stream);
void recordStoppedData(int card,int stream);
@@ -117,7 +85,7 @@ class MainObject : public QObject
//
// batch.cpp
//
void catchConnectedData(int serial,bool state);
// void catchConnectedData(int serial,bool state);
void userChangedData();
void exitData();
@@ -148,13 +116,7 @@ class MainObject : public QObject
void SendEventResponse(int chan,RDDeck::Status status,int id,
const QString &cutname);
void SendFullEventResponse(const QHostAddress &addr);
void SendMeterLevel(int deck,short levels[2]);
void SendDeckEvent(int deck,int number);
void ParseCommand(int);
void DispatchCommand(ServerConnection *conn);
void EchoCommand(int,const QString &cmd);
void BroadcastCommand(const QString &cmd,int except_ch=-1);
void EchoArgs(int,const char);
void LoadEngine(bool adv_day=false);
QString LoadEventSql();
void LoadEvent(RDSqlQuery *q,CatchEvent *e,bool add);
@@ -195,8 +157,6 @@ class MainObject : public QObject
RDTimeEngine *catch_engine;
int16_t tcp_port;
QTcpServer *server;
RDCatchConnect *catch_connect;
QList<ServerConnection *> catch_connections;
QSignalMapper *catch_ready_mapper;
QSignalMapper *catch_kill_mapper;
QTimer *catch_garbage_timer;