From 7ce4b2ff10ea4d70f2368971e9ba5c36f59622ad Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Sun, 11 Mar 2018 20:24:39 -0400 Subject: [PATCH] 2018-03-11 Fred Gleason * Converted ripcd(8) to use RDApplication. * Documented a 'Notification' message type in 'docs/apis/notification.xml'. * Added an 'RDMulticaster' class. * Added an 'mcast_recv_test' program in 'tests/'. * Added a 'SYSTEM.NOTIFICATION_ADDRESS' field to the database. * Incremented the database version to 276. * Added an 'Mcast Address for Notifications' control to the 'System-Wide Settings' dialog in rdadmin(1). * Implemented the 'Process Notification' ['ON'] command in ripcd(8). * Added an 'RDRipc::sendNotification()' method. * Added an 'RDRipc::notificationReceived()' signal. --- .gitignore | 1 + ChangeLog | 14 +++ docs/apis/Makefile.am | 5 ++ docs/apis/notification.xml | 133 ++++++++++++++++++++++++++++ docs/apis/ripc.xml | 20 +++++ docs/tables/system.txt | 1 + lib/Makefile.am | 5 +- lib/dbversion.h | 2 +- lib/lib.pro | 2 + lib/rd.h | 10 +++ lib/rdmulticaster.cpp | 142 +++++++++++++++++++++++++++++ lib/rdmulticaster.h | 60 +++++++++++++ lib/rdnotification.cpp | 166 ++++++++++++++++++++++++++++++++++ lib/rdnotification.h | 53 +++++++++++ lib/rdripc.cpp | 24 +++++ lib/rdripc.h | 8 +- lib/rdsystem.cpp | 12 +++ lib/rdsystem.h | 3 + rdadmin/createdb.cpp | 11 ++- rdadmin/edit_settings.cpp | 42 ++++++--- rdadmin/edit_settings.h | 1 + rdadmin/rdadmin_cs.ts | 4 + rdadmin/rdadmin_de.ts | 4 + rdadmin/rdadmin_es.ts | 4 + rdadmin/rdadmin_fr.ts | 4 + rdadmin/rdadmin_nb.ts | 4 + rdadmin/rdadmin_nn.ts | 4 + rdadmin/rdadmin_pt_BR.ts | 4 + ripcd/acu1p.cpp | 4 +- ripcd/bt10x1.cpp | 9 +- ripcd/bt16x1.cpp | 10 ++- ripcd/bt16x2.cpp | 14 +-- ripcd/bt8x2.cpp | 10 ++- ripcd/btacs82.cpp | 14 +-- ripcd/btadms4422.cpp | 18 ++-- ripcd/btgpi16.cpp | 14 +-- ripcd/btsentinel4web.cpp | 13 +-- ripcd/btsrc16.cpp | 14 +-- ripcd/btsrc8iii.cpp | 13 +-- ripcd/btss124.cpp | 14 +-- ripcd/btss164.cpp | 14 +-- ripcd/btss41mlr.cpp | 13 +-- ripcd/btss42.cpp | 14 +-- ripcd/btss44.cpp | 14 +-- ripcd/btss82.cpp | 14 +-- ripcd/globals.h | 7 +- ripcd/livewire_lwrpaudio.cpp | 11 ++- ripcd/livewire_mcastgpio.cpp | 13 +-- ripcd/loaddrivers.cpp | 94 ++++++++++---------- ripcd/local_audio.cpp | 21 ++--- ripcd/local_macros.cpp | 48 +++++----- ripcd/modemlines.cpp | 18 ++-- ripcd/quartz1.cpp | 10 ++- ripcd/ripcd.cpp | 167 ++++++++++++++++++----------------- ripcd/ripcd.h | 5 +- ripcd/rossnkscp.cpp | 9 +- ripcd/sas16000.cpp | 11 ++- ripcd/sas32000.cpp | 10 ++- ripcd/sas64000.cpp | 10 ++- ripcd/sas64000gpi.cpp | 9 +- ripcd/sasusi.cpp | 27 +++--- ripcd/starguide3.cpp | 14 +-- ripcd/swauthority.cpp | 29 +++--- ripcd/switcher.cpp | 3 +- ripcd/unity4000.cpp | 11 +-- ripcd/vguest.cpp | 12 +-- tests/Makefile.am | 5 ++ tests/mcast_recv_test.cpp | 104 ++++++++++++++++++++++ tests/mcast_recv_test.h | 44 +++++++++ utils/rdrevert/rdrevert.cpp | 18 ++++ utils/rdrevert/rdrevert.h | 1 + 71 files changed, 1302 insertions(+), 368 deletions(-) create mode 100644 docs/apis/notification.xml create mode 100644 lib/rdmulticaster.cpp create mode 100644 lib/rdmulticaster.h create mode 100644 lib/rdnotification.cpp create mode 100644 lib/rdnotification.h create mode 100644 tests/mcast_recv_test.cpp create mode 100644 tests/mcast_recv_test.h diff --git a/.gitignore b/.gitignore index 929af3c9..b6f4e662 100644 --- a/.gitignore +++ b/.gitignore @@ -89,6 +89,7 @@ tests/audio_import_test tests/audio_peaks_test tests/datedecode_test tests/log_unlink_test +tests/mcast_recv_test tests/rdxml_parse_test tests/reserve_carts_test tests/sas_switch_torture diff --git a/ChangeLog b/ChangeLog index 4e1c0fb7..5f2eaecb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16709,3 +16709,17 @@ * Refactored the RDSoundPanel class to use RDApplication. 2018-02-24 Fred Gleason * Refactored the RDUpload class to use RDApplication. +2018-03-11 Fred Gleason + * Converted ripcd(8) to use RDApplication. + * Documented a 'Notification' message type in + 'docs/apis/notification.xml'. + * Added an 'RDMulticaster' class. + * Added an 'mcast_recv_test' program in 'tests/'. + * Added a 'SYSTEM.NOTIFICATION_ADDRESS' field to the database. + * Incremented the database version to 276. + * Added an 'Mcast Address for Notifications' control to the + 'System-Wide Settings' dialog in rdadmin(1). + * Implemented the 'Process Notification' ['ON'] command in + ripcd(8). + * Added an 'RDRipc::sendNotification()' method. + * Added an 'RDRipc::notificationReceived()' signal. diff --git a/docs/apis/Makefile.am b/docs/apis/Makefile.am index 6bf6073c..f0ec062f 100644 --- a/docs/apis/Makefile.am +++ b/docs/apis/Makefile.am @@ -35,6 +35,8 @@ all-local: cae.html\ cae.pdf\ catchd.html\ catchd.pdf\ + notification.html\ + notification.pdf\ ripc.html\ ripc.pdf\ web_api.html\ @@ -46,6 +48,9 @@ EXTRA_DIST = cae.html\ catchd.html\ catchd.pdf\ catchd.xml\ + notifcation.html\ + notifcation.pdf\ + notifcation.xml\ ripc.html\ ripc.pdf\ ripc.xml\ diff --git a/docs/apis/notification.xml b/docs/apis/notification.xml new file mode 100644 index 00000000..cd30e96f --- /dev/null +++ b/docs/apis/notification.xml @@ -0,0 +1,133 @@ + +
+ + Rivendell Notification Protocol + + + Fred + Gleason + fredg@paravelsystems.com + + + + + + Overview + + This defines the IP protocol used to notify Rivendell components of + changes to the state of database objects. Messages are send by means + of multicast UDP packets to port 20539. + + + The format of a message is as follows: + + + NOTIFY obj-type + action + id + [args] + + + + + obj-type + + + + The object type to which the message pertains. + + + + + + action + + + + The action being reported. The following actions are defined: + + + + + ADD + + + + The referenced object has just been added to the database. + + + + + + DELETE + + + + The referenced object has just been deleted from the database. + + + + + + MODIFY + + + + The reference object has just been modified in the database. + + + + + + + + + id + + + + Unique id of the object. + + + + + + args + + + + Zero or more additional arguments. Varies by + obj-type. + + + + + + + + Object Types + + The following object types are defined: + + + Carts + + CART + + + Cart Fields + + + + + FieldValue + obj-typeCART + idCart number + + +
+
+ +
+ +
diff --git a/docs/apis/ripc.xml b/docs/apis/ripc.xml index 01822440..77ee4a23 100644 --- a/docs/apis/ripc.xml +++ b/docs/apis/ripc.xml @@ -608,6 +608,26 @@ + + Process Notification + + Send or Receive an Object Notification + + + ON notify! + + + Send the notify to all other active + Rivendell modules. + + + + See the Rivendell Notification Protocol API document for a description + of the contents of notify. + + + + diff --git a/docs/tables/system.txt b/docs/tables/system.txt index e108d703..ff0ef5c2 100644 --- a/docs/tables/system.txt +++ b/docs/tables/system.txt @@ -12,3 +12,4 @@ MAX_POST_LENGTH int(10) unsigned ISCI_XREFERENCE_PATH char(255) TEMP_CART_GROUP char(10) From 'GROUPS.NAME' SHOW_USER_LIST enum('N','Y') +NOTIFICATION_ADDRESS char(15) diff --git a/lib/Makefile.am b/lib/Makefile.am index 9691a191..ba740822 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -2,7 +2,7 @@ ## ## Automake.am for rivendell/lib ## -## (C) Copyright 2002-2016 Fred Gleason +## (C) Copyright 2002-2018 Fred Gleason ## ## 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 @@ -182,6 +182,8 @@ dist_librd_la_SOURCES = dbversion.h\ rdmixer.cpp rdmixer.h\ rdmonitor_config.cpp rdmonitor_config.h\ rdmp4.cpp rdmp4.h\ + rdmulticaster.cpp rdmulticaster.h\ + rdnotification.cpp rdnotification.h\ rdnownext.cpp rdnownext.h\ rdoneshot.cpp rdoneshot.h\ rdpam.cpp rdpam.h\ @@ -309,6 +311,7 @@ nodist_librd_la_SOURCES = moc_rdadd_cart.cpp\ moc_rdmacro_event.cpp\ moc_rdmarker_bar.cpp\ moc_rdmarker_edit.cpp\ + moc_rdmulticaster.cpp\ moc_rdoneshot.cpp\ moc_rdpanel_button.cpp\ moc_rdpasswd.cpp\ diff --git a/lib/dbversion.h b/lib/dbversion.h index 193461ca..5c8ba5d7 100644 --- a/lib/dbversion.h +++ b/lib/dbversion.h @@ -24,7 +24,7 @@ /* * Current Database Version */ -#define RD_VERSION_DATABASE 275 +#define RD_VERSION_DATABASE 276 #endif // DBVERSION_H diff --git a/lib/lib.pro b/lib/lib.pro index 014248fd..2b709f7a 100644 --- a/lib/lib.pro +++ b/lib/lib.pro @@ -94,6 +94,7 @@ SOURCES += rdlogfilter.cpp SOURCES += rdloglock.cpp SOURCES += rdmacro.cpp SOURCES += rdmacro_event.cpp +SOURCES += rdnotification.cpp SOURCES += rdoneshot.cpp SOURCES += rdplaymeter.cpp SOURCES += rdprofile.cpp @@ -237,6 +238,7 @@ HEADERS += rdlogfilter.h HEADERS += rdloglock.h HEADERS += rdmacro.h HEADERS += rdmacro_event.h +HEADERS += rdnotification.h HEADERS += rdoneshot.h HEADERS += rdplaymeter.h HEADERS += rdprofile.h diff --git a/lib/rd.h b/lib/rd.h index 5adf8c1d..cf024552 100644 --- a/lib/rd.h +++ b/lib/rd.h @@ -572,5 +572,15 @@ */ #define RD_LOG_LOCK_TIMEOUT 30000 +/* + * Default multicast address for sending state updates + */ +#define RD_NOTIFICATION_ADDRESS "239.192.255.72" + +/* + * UDP port for sending state updates + */ +#define RD_NOTIFICATION_PORT 20539 + #endif // RD_H diff --git a/lib/rdmulticaster.cpp b/lib/rdmulticaster.cpp new file mode 100644 index 00000000..1932a5af --- /dev/null +++ b/lib/rdmulticaster.cpp @@ -0,0 +1,142 @@ +// rdmulticaster.cpp +// +// Multi-interface multicast transciever +// +// (C) Copyright 2018 Fred Gleason +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library 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 +#include +#include +#include +#include +#include + +#include "rdmulticaster.h" + +RDMulticaster::RDMulticaster(QObject *parent) + : QObject(parent) +{ + multi_socket=new QSocketDevice(QSocketDevice::Datagram); + multi_notifier=new QSocketNotifier(multi_socket->socket(), + QSocketNotifier::Read,this); + connect(multi_notifier,SIGNAL(activated(int)),this,SLOT(activatedData(int))); + + GetInterfaces(); +} + + +bool RDMulticaster::bind(uint16_t port) +{ + return multi_socket->bind(QHostAddress("0.0.0.0"),port); +} + + +void RDMulticaster::enableLoopback(bool state) +{ + int var=state; + + setsockopt(multi_socket->socket(),IPPROTO_IP,IP_MULTICAST_LOOP, + &var,sizeof(var)); +} + + +void RDMulticaster::subscribe(const QHostAddress &addr) +{ + struct ip_mreqn mreq; + + for(unsigned i=0;isocket(),IPPROTO_IP,IP_ADD_MEMBERSHIP, + &mreq,sizeof(mreq))<0) { + fprintf(stderr,tr("Unable to subscribe to multicast address")+" \""+ + addr.toString()+"\" ["+strerror(errno)+"]"); + } + } +} + + +void RDMulticaster::unsubscribe(const QHostAddress &addr) +{ + struct ip_mreqn mreq; + + for(unsigned i=0;isocket(),IPPROTO_IP,IP_DROP_MEMBERSHIP, + &mreq,sizeof(mreq))<0) { + fprintf(stderr,tr("Unable to subscribe to multicast address")+" \""+ + addr.toString()+"\" ["+strerror(errno)+"]"); + } + } +} + + +void RDMulticaster::send(const QString &msg,const QHostAddress &m_addr, + uint16_t port) +{ + multi_socket->writeBlock(msg.utf8(),msg.utf8().length(),m_addr,port); +} + + +void RDMulticaster::activatedData(int sock) +{ + struct sockaddr_in sa; + socklen_t sa_len=sizeof(struct sockaddr_in); + char data[1501]; + int n; + + memset(&sa,0,sizeof(sa)); + while((n=recvfrom(multi_socket->socket(),data,1500,MSG_DONTWAIT,(sockaddr *)&sa,&sa_len))>0) { + data[n]=0; + QString msg(data); + emit received(msg,QHostAddress(ntohl(sa.sin_addr.s_addr))); + sa_len=sizeof(struct sockaddr_in); + } +} + + +void RDMulticaster::GetInterfaces() +{ + int fd; + struct ifreq ifr; + int index=0; + sockaddr_in *sa=NULL; + + if((fd=socket(PF_INET,SOCK_DGRAM,IPPROTO_IP))<0) { + return; + } + + memset(&ifr,0,sizeof(ifr)); + index=1; + ifr.ifr_ifindex=index; + while(ioctl(fd,SIOCGIFNAME,&ifr)==0) { + if(ioctl(fd,SIOCGIFADDR,&ifr)==0) { + sa=(struct sockaddr_in *)(&(ifr.ifr_addr)); + if((ntohl(sa->sin_addr.s_addr)&0xFF000000)!=0x7F000000) { + multi_iface_addresses.push_back(QHostAddress()); + multi_iface_addresses.back().setAddress(ntohl(sa->sin_addr.s_addr)); + } + } + ifr.ifr_ifindex=++index; + } + ::close(fd); +} diff --git a/lib/rdmulticaster.h b/lib/rdmulticaster.h new file mode 100644 index 00000000..c3e6c32d --- /dev/null +++ b/lib/rdmulticaster.h @@ -0,0 +1,60 @@ +// rdmulticaster.h +// +// Multi-interface multicast transciever +// +// (C) Copyright 2018 Fred Gleason +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library 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 RDMULTICASTER_H +#define RDMULTICASTER_H + +#include + +#include + +#include +#include +#include +#include + +class RDMulticaster : public QObject +{ + Q_OBJECT + public: + RDMulticaster(QObject *parent=0); + bool bind(uint16_t port); + void enableLoopback(bool state); + void subscribe(const QHostAddress &addr); + void unsubscribe(const QHostAddress &addr); + + signals: + void received(const QString &msg,const QHostAddress &src_addr); + + public slots: + void send(const QString &msg,const QHostAddress &m_addr,uint16_t port); + + private slots: + void activatedData(int sock); + + private: + void GetInterfaces(); + QSocketDevice *multi_socket; + QSocketNotifier *multi_notifier; + std::vector multi_iface_addresses; +}; + + +#endif // RDMULTICASTER_H diff --git a/lib/rdnotification.cpp b/lib/rdnotification.cpp new file mode 100644 index 00000000..a1540b6c --- /dev/null +++ b/lib/rdnotification.cpp @@ -0,0 +1,166 @@ +// rdnotification.cpp +// +// A container class for a Rivendell Notification message. +// +// (C) Copyright 2018 Fred Gleason +// +// 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 "rdnotification.h" + +RDNotification::RDNotification() +{ + notify_type=RDNotification::NullType; + notify_action=RDNotification::NoAction; +} + + +RDNotification::Type RDNotification::type() const +{ + return notify_type; +} + + +void RDNotification::setType(RDNotification::Type type) +{ + notify_type=type; +} + + +RDNotification::Action RDNotification::action() const +{ + return notify_action; +} + + +void RDNotification::setAction(RDNotification::Action action) +{ + notify_action=action; +} + + +QVariant RDNotification::id() const +{ + return notify_id; +} + + +void RDNotification::setId(const QVariant id) +{ + notify_id=id; +} + + +bool RDNotification::isValid() const +{ + return true; +} + + +bool RDNotification::read(const QString &str) +{ + notify_type=RDNotification::NullType; + notify_action=RDNotification::NoAction; + notify_id=QVariant(); + + QStringList args=args.split(" ",str); + if(args.size()==4) { + if(args[0]!="NOTIFY") { + return false; + } + for(int i=0;i +// +// 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 RDNOTIFICATION_H +#define RDNOTIFICATION_H + +#include +#include + +class RDNotification +{ + public: + enum Type {NullType=0,CartType=1,LastType=2}; + enum Action {NoAction=0,AddAction=1,DeleteAction=2,ModifyAction=3, + LastAction=4}; + RDNotification(); + Type type() const; + void setType(Type type); + Action action() const; + void setAction(Action action); + QVariant id() const; + void setId(const QVariant id); + bool isValid() const; + bool read(const QString &str); + QString write() const; + static QString typeString(Type type); + static QString actionString(Action action); + + private: + Type notify_type; + Action notify_action; + QVariant notify_id; +}; + + +#endif // RDNOTIFICATION_H diff --git a/lib/rdripc.cpp b/lib/rdripc.cpp index 073108aa..43e93a73 100644 --- a/lib/rdripc.cpp +++ b/lib/rdripc.cpp @@ -137,6 +137,12 @@ void RDRipc::sendGpoCart(int matrix) } +void RDRipc::sendNotification(const RDNotification ¬ify) +{ + SendCommand("ON "+notify.write()+"!"); +} + + void RDRipc::sendOnairFlag() { SendCommand("TA!"); @@ -425,4 +431,22 @@ void RDRipc::DispatchCommand() ripc_onair_flag=args[1][0]=='1'; emit onairFlagChanged(ripc_onair_flag); } + + if(!strcmp(args[0],"ON")) { // Notification Received + if(argnum<4) { + return; + } + QString msg; + for(int i=1;iread(msg)) { + delete notify; + return; + } + emit notificationReceived(notify); + delete notify; + } } diff --git a/lib/rdripc.h b/lib/rdripc.h index 6d7de806..f6c77ab9 100644 --- a/lib/rdripc.h +++ b/lib/rdripc.h @@ -2,7 +2,7 @@ // // Connection to the Rivendell Interprocess Communication Daemon // -// (C) Copyright 2002-2004,2016 Fred Gleason +// (C) Copyright 2002-2004,2016-2018 Fred Gleason // // 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 @@ -27,6 +27,7 @@ #include #include +#include #include #ifndef RDRIPC_H @@ -40,8 +41,7 @@ class RDRipc : public QObject { Q_OBJECT public: - // RDRipc(QString stationname,QObject *parent=0); - RDRipc(RDStation *station,RDConfig *config,QObject *parent=0); + RDRipc(RDStation *station,RDConfig *config,QObject *parent=0); ~RDRipc(); QString user() const; QString station() const; @@ -55,6 +55,7 @@ class RDRipc : public QObject void sendGpoMask(int matrix); void sendGpiCart(int matrix); void sendGpoCart(int matrix); + void sendNotification(const RDNotification ¬ify); void sendOnairFlag(); void sendRml(RDMacro *macro); void reloadHeartbeat(); @@ -68,6 +69,7 @@ class RDRipc : public QObject void gpoMaskChanged(int matrix,int line,bool state); void gpiCartChanged(int matrix,int line,int off_cartnum,int on_cartnum); void gpoCartChanged(int matrix,int line,int off_cartnum,int on_cartnum); + void notificationReceived(RDNotification *notify); void onairFlagChanged(bool state); void rmlReceived(RDMacro *rml); diff --git a/lib/rdsystem.cpp b/lib/rdsystem.cpp index 4e670d81..9c17588a 100644 --- a/lib/rdsystem.cpp +++ b/lib/rdsystem.cpp @@ -174,6 +174,18 @@ void RDSystem::setShowUserList(bool state) const } +QHostAddress RDSystem::notificationAddress() const +{ + return QHostAddress(GetValue("NOTIFICATION_ADDRESS").toString()); +} + + +void RDSystem::setNotificationAddress(const QHostAddress &addr) +{ + SetRow("NOTIFICATION_ADDRESS",addr.toString()); +} + + QString RDSystem::xml() const { QString xml="\n"; diff --git a/lib/rdsystem.h b/lib/rdsystem.h index 4c7795ba..e49aa7f7 100644 --- a/lib/rdsystem.h +++ b/lib/rdsystem.h @@ -21,6 +21,7 @@ #ifndef RDSYSTEM_H #define RDSYSTEM_H +#include #include class RDSystem @@ -41,6 +42,8 @@ class RDSystem void setTempCartGroup(const QString &str) const; bool showUserList() const; void setShowUserList(bool state) const; + QHostAddress notificationAddress() const; + void setNotificationAddress(const QHostAddress &addr); QString xml() const; private: diff --git a/rdadmin/createdb.cpp b/rdadmin/createdb.cpp index 585afaf1..fc2708e3 100644 --- a/rdadmin/createdb.cpp +++ b/rdadmin/createdb.cpp @@ -1916,7 +1916,8 @@ bool CreateDb(QString name,QString pwd,RDConfig *config) RD_DEFAULT_MAX_POST_LENGTH)+ "ISCI_XREFERENCE_PATH char(255),"+ "TEMP_CART_GROUP char(10),"+ - "SHOW_USER_LIST enum('N','Y') not null default 'Y')"+ + "SHOW_USER_LIST enum('N','Y') not null default 'Y',"+ + "NOTIFICATION_ADDRESS char(15) default \""+RD_NOTIFICATION_ADDRESS+"\")"+ config->createTablePostfix(); if(!RunQuery(sql)) { return false; @@ -8025,6 +8026,14 @@ int UpdateDb(int ver,RDConfig *config) delete q; } + if(ver<276) { + sql=QString("alter table SYSTEM ")+ + "add column NOTIFICATION_ADDRESS char(15) default \""+ + RD_NOTIFICATION_ADDRESS+"\" after SHOW_USER_LIST"; + q=new RDSqlQuery(sql,false); + delete q; + } + // // Maintainer's Note: diff --git a/rdadmin/edit_settings.cpp b/rdadmin/edit_settings.cpp index 03c0f7e2..ee87d0c6 100644 --- a/rdadmin/edit_settings.cpp +++ b/rdadmin/edit_settings.cpp @@ -118,17 +118,27 @@ EditSettings::EditSettings(QWidget *parent) label->setAlignment(AlignRight|AlignVCenter|ShowPrefix); // - // Maximum POST Size + // Notification Address // - edit_maxpost_spin=new QSpinBox(this); - edit_maxpost_spin->setGeometry(200,98,60,20); - edit_maxpost_spin->setRange(1,1000); - label=new QLabel(edit_maxpost_spin,tr("Maximum Remote Post Length:"),this); + edit_notification_address_edit=new QLineEdit(this); + edit_notification_address_edit->setGeometry(200,98,150,20); + label=new QLabel(edit_notification_address_edit,tr("Mcast Address for Notifications"),this); label->setGeometry(10,98,185,20); label->setFont(font); label->setAlignment(AlignRight|AlignVCenter|ShowPrefix); + + // + // Maximum POST Size + // + edit_maxpost_spin=new QSpinBox(this); + edit_maxpost_spin->setGeometry(200,120,60,20); + edit_maxpost_spin->setRange(1,1000); + label=new QLabel(edit_maxpost_spin,tr("Maximum Remote Post Length:"),this); + label->setGeometry(10,120,185,20); + label->setFont(font); + label->setAlignment(AlignRight|AlignVCenter|ShowPrefix); label=new QLabel(tr("Mbytes"),this); - label->setGeometry(265,98,60,20); + label->setGeometry(265,120,60,20); label->setFont(font); label->setAlignment(AlignLeft|AlignVCenter|ShowPrefix); @@ -136,7 +146,7 @@ EditSettings::EditSettings(QWidget *parent) // Temporary Cart Group // edit_temp_cart_group_box=new QComboBox(this); - edit_temp_cart_group_box->setGeometry(200,119,100,20); + edit_temp_cart_group_box->setGeometry(200,141,100,20); sql="select NAME from GROUPS order by NAME"; q=new RDSqlQuery(sql); while(q->next()) { @@ -144,7 +154,7 @@ EditSettings::EditSettings(QWidget *parent) } delete q; label=new QLabel(edit_temp_cart_group_box,tr("Temporary Cart Group:"),this); - label->setGeometry(10,119,185,20); + label->setGeometry(10,141,185,20); label->setFont(font); label->setAlignment(AlignRight|AlignVCenter|ShowPrefix); @@ -152,12 +162,12 @@ EditSettings::EditSettings(QWidget *parent) // Show User List // edit_show_user_list_box=new QCheckBox(this); - edit_show_user_list_box->setGeometry(20,143,15,15); + edit_show_user_list_box->setGeometry(20,165,15,15); connect(edit_show_user_list_box,SIGNAL(toggled(bool)), this,SLOT(duplicatesCheckedData(bool))); label= new QLabel(edit_show_user_list_box,tr("Show User List in RDLogin"),this); - label->setGeometry(40,141,sizeHint().width()-50,20); + label->setGeometry(40,163,sizeHint().width()-50,20); label->setFont(font); label->setAlignment(AlignLeft|AlignVCenter|ShowPrefix); @@ -167,11 +177,11 @@ EditSettings::EditSettings(QWidget *parent) edit_duplicate_label=new RDLabel(this); edit_duplicate_label->setText(tr("The following duplicate titles must be corrected before \"Allow Duplicate Values\" can be turned off.")); edit_duplicate_label->setWordWrapEnabled(true); - edit_duplicate_label->setGeometry(15,164,sizeHint().width()-30,50); + edit_duplicate_label->setGeometry(15,186,sizeHint().width()-30,50); edit_duplicate_label->setFont(normal_font); edit_duplicate_label->hide(); edit_duplicate_list=new QListView(this); - edit_duplicate_list->setGeometry(10,187,sizeHint().width()-20,200); + edit_duplicate_list->setGeometry(10,209,sizeHint().width()-20,200); edit_duplicate_list->setItemMargin(5); edit_duplicate_list->setAllColumnsShowFocus(true); edit_duplicate_list->addColumn(tr("CART")); @@ -181,7 +191,7 @@ EditSettings::EditSettings(QWidget *parent) edit_duplicate_list->hide(); edit_save_button=new QPushButton(this); edit_save_button-> - setGeometry(sizeHint().width()-85,392,70,25); + setGeometry(sizeHint().width()-85,414,70,25); edit_save_button->setFont(normal_font); edit_save_button->setText(tr("&Save List")); connect(edit_save_button,SIGNAL(clicked()),this,SLOT(saveData())); @@ -213,6 +223,8 @@ EditSettings::EditSettings(QWidget *parent) duplicatesCheckedData(edit_system->allowDuplicateCartTitles()); edit_maxpost_spin->setValue(edit_system->maxPostLength()/1000000); edit_isci_path_edit->setText(edit_system->isciXreferencePath()); + edit_notification_address_edit-> + setText(edit_system->notificationAddress().toString()); edit_show_user_list_box->setChecked(edit_system->showUserList()); for(int i=0;icount();i++) { @@ -239,7 +251,7 @@ EditSettings::~EditSettings() QSize EditSettings::sizeHint() const { - return QSize(500,240+y_pos); + return QSize(500,262+y_pos); } @@ -398,6 +410,8 @@ void EditSettings::okData() edit_system->setSampleRate(edit_sample_rate_box->currentText().toUInt()); edit_system->setMaxPostLength(edit_maxpost_spin->value()*1000000); edit_system->setIsciXreferencePath(edit_isci_path_edit->text()); + edit_system-> + setNotificationAddress(QHostAddress(edit_notification_address_edit->text())); edit_system->setTempCartGroup(edit_temp_cart_group_box->currentText()); edit_system->setShowUserList(edit_show_user_list_box->isChecked()); diff --git a/rdadmin/edit_settings.h b/rdadmin/edit_settings.h index 7ebc29d5..e1036824 100644 --- a/rdadmin/edit_settings.h +++ b/rdadmin/edit_settings.h @@ -62,6 +62,7 @@ class EditSettings : public QDialog QComboBox *edit_temp_cart_group_box; QCheckBox *edit_show_user_list_box; QListView *edit_duplicate_list; + QLineEdit *edit_notification_address_edit; QPushButton *edit_settings_button; QPushButton *edit_save_button; QPushButton *edit_ok_button; diff --git a/rdadmin/rdadmin_cs.ts b/rdadmin/rdadmin_cs.ts index 5fefc2a7..9e2390f7 100644 --- a/rdadmin/rdadmin_cs.ts +++ b/rdadmin/rdadmin_cs.ts @@ -3548,6 +3548,10 @@ PÅ™epsat? Show User List in RDLogin + + Mcast Address for Notifications + + EditStation diff --git a/rdadmin/rdadmin_de.ts b/rdadmin/rdadmin_de.ts index 4706ee01..dd052611 100644 --- a/rdadmin/rdadmin_de.ts +++ b/rdadmin/rdadmin_de.ts @@ -3500,6 +3500,10 @@ Overwrite? Show User List in RDLogin + + Mcast Address for Notifications + + EditStation diff --git a/rdadmin/rdadmin_es.ts b/rdadmin/rdadmin_es.ts index 4195363d..a94f4a59 100644 --- a/rdadmin/rdadmin_es.ts +++ b/rdadmin/rdadmin_es.ts @@ -3547,6 +3547,10 @@ Overwrite? Show User List in RDLogin + + Mcast Address for Notifications + + EditStation diff --git a/rdadmin/rdadmin_fr.ts b/rdadmin/rdadmin_fr.ts index d3f4f32a..6c649c60 100644 --- a/rdadmin/rdadmin_fr.ts +++ b/rdadmin/rdadmin_fr.ts @@ -3160,6 +3160,10 @@ Overwrite? Show User List in RDLogin + + Mcast Address for Notifications + + EditStation diff --git a/rdadmin/rdadmin_nb.ts b/rdadmin/rdadmin_nb.ts index e1e91972..ca06fd7f 100644 --- a/rdadmin/rdadmin_nb.ts +++ b/rdadmin/rdadmin_nb.ts @@ -3499,6 +3499,10 @@ Overwrite? Show User List in RDLogin + + Mcast Address for Notifications + + EditStation diff --git a/rdadmin/rdadmin_nn.ts b/rdadmin/rdadmin_nn.ts index e1e91972..ca06fd7f 100644 --- a/rdadmin/rdadmin_nn.ts +++ b/rdadmin/rdadmin_nn.ts @@ -3499,6 +3499,10 @@ Overwrite? Show User List in RDLogin + + Mcast Address for Notifications + + EditStation diff --git a/rdadmin/rdadmin_pt_BR.ts b/rdadmin/rdadmin_pt_BR.ts index 589f28b5..62266c04 100644 --- a/rdadmin/rdadmin_pt_BR.ts +++ b/rdadmin/rdadmin_pt_BR.ts @@ -3492,6 +3492,10 @@ Overwrite? Show User List in RDLogin + + Mcast Address for Notifications + + EditStation diff --git a/ripcd/acu1p.cpp b/ripcd/acu1p.cpp index 776d692c..869f9249 100644 --- a/ripcd/acu1p.cpp +++ b/ripcd/acu1p.cpp @@ -20,6 +20,8 @@ #include +#include + #include #include @@ -40,7 +42,7 @@ Acu1p::Acu1p(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); bt_device=new RDTTYDevice(); if(tty->active()) { bt_device->setName(tty->port()); diff --git a/ripcd/bt10x1.cpp b/ripcd/bt10x1.cpp index f3e7530d..f54003e2 100644 --- a/ripcd/bt10x1.cpp +++ b/ripcd/bt10x1.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the BroadcastTools 10x1 // -// (C) Copyright 2002-2003,2016 Fred Gleason +// (C) Copyright 2002-2003,2016-2018 Fred Gleason // // 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 @@ -20,9 +20,10 @@ #include -#include -#include +#include +#include "bt10x1.h" +#include "globals.h" Bt10x1::Bt10x1(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -36,7 +37,7 @@ Bt10x1::Bt10x1(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); bt_device=new RDTTYDevice(); if(tty->active()) { bt_device->setName(tty->port()); diff --git a/ripcd/bt16x1.cpp b/ripcd/bt16x1.cpp index 40fc8ec5..426d710e 100644 --- a/ripcd/bt16x1.cpp +++ b/ripcd/bt16x1.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the BroadcastTools 16x1 // -// (C) Copyright 2002-2004,2016 Fred Gleason +// (C) Copyright 2002-2004,2016-2018 Fred Gleason // // 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 @@ -20,8 +20,10 @@ #include -#include -#include +#include + +#include "bt16x1.h" +#include "globals.h" Bt16x1::Bt16x1(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -35,7 +37,7 @@ Bt16x1::Bt16x1(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); bt_device=new RDTTYDevice(); if(tty->active()) { bt_device->setName(tty->port()); diff --git a/ripcd/bt16x2.cpp b/ripcd/bt16x2.cpp index 626d8ec4..8c2d4b37 100644 --- a/ripcd/bt16x2.cpp +++ b/ripcd/bt16x2.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the BroadcastTools 16x2 // -// (C) Copyright 2002-2004,2016 Fred Gleason +// (C) Copyright 2002-2004,2016-2018 Fred Gleason // // 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 @@ -18,12 +18,14 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include - #include -#include -#include +#include + +#include + +#include "bt16x2.h" +#include "globals.h" Bt16x2::Bt16x2(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -49,7 +51,7 @@ Bt16x2::Bt16x2(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); bt_device=new RDTTYDevice(); if(tty->active()) { bt_device->setName(tty->port()); diff --git a/ripcd/bt8x2.cpp b/ripcd/bt8x2.cpp index bbb4f747..9fc2afa2 100644 --- a/ripcd/bt8x2.cpp +++ b/ripcd/bt8x2.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the BroadcastTools 8x2 // -// (C) Copyright 2002-2004,2016 Fred Gleason +// (C) Copyright 2002-2004,2016-2018 Fred Gleason // // 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 @@ -20,8 +20,10 @@ #include -#include -#include +#include + +#include "bt8x2.h" +#include "globals.h" Bt8x2::Bt8x2(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -35,7 +37,7 @@ Bt8x2::Bt8x2(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); bt_device=new RDTTYDevice(); if(tty->active()) { bt_device->setName(tty->port()); diff --git a/ripcd/btacs82.cpp b/ripcd/btacs82.cpp index 3e440b2a..0e0145c9 100644 --- a/ripcd/btacs82.cpp +++ b/ripcd/btacs82.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the BroadcastTools ACS 8.2 // -// (C) Copyright 2002-2004,2016 Fred Gleason +// (C) Copyright 2002-2004,2016-2018 Fred Gleason // // 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 @@ -18,12 +18,14 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include - #include -#include -#include +#include + +#include + +#include "btacs82.h" +#include "globals.h" BtAcs82::BtAcs82(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -49,7 +51,7 @@ BtAcs82::BtAcs82(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); bt_device=new RDTTYDevice(); if(tty->active()) { bt_device->setName(tty->port()); diff --git a/ripcd/btadms4422.cpp b/ripcd/btadms4422.cpp index 586b8e0e..d4bed828 100644 --- a/ripcd/btadms4422.cpp +++ b/ripcd/btadms4422.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the BroadcastTools ADMS 44.22 // -// (C) Copyright 2002-2016 Fred Gleason +// (C) Copyright 2002-2018 Fred Gleason // // 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 @@ -18,12 +18,14 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include - #include -#include -#include +#include + +#include + +#include "btadms4422.h" +#include "globals.h" BtAdms4422::BtAdms4422(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -49,7 +51,7 @@ BtAdms4422::BtAdms4422(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); bt_device=new RDTTYDevice(); if(tty->active()) { bt_device->setName(tty->port()); @@ -62,8 +64,8 @@ BtAdms4422::BtAdms4422(RDMatrix *matrix,QObject *parent) writeBlock(QString().sprintf("*%uUM0\r\n",BTADMS4422_UNIT_ID),7); } else { - ripcd_config->log("ripcd",RDConfig::LogWarning, - "failed to open port \""+tty->port()+"\""); + rda->config()->log("ripcd",RDConfig::LogWarning, + "failed to open port \""+tty->port()+"\""); } } delete tty; diff --git a/ripcd/btgpi16.cpp b/ripcd/btgpi16.cpp index abd4b2f3..5cd6a5f1 100644 --- a/ripcd/btgpi16.cpp +++ b/ripcd/btgpi16.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the BroadcastTools GPI-16 // -// (C) Copyright 2002-2005,2010,2016 Fred Gleason +// (C) Copyright 2002-2005,2010,2016-2018 Fred Gleason // // 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 @@ -18,12 +18,14 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include - #include -#include -#include +#include + +#include + +#include "btgpi16.h" +#include "globals.h" BtGpi16::BtGpi16(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -46,7 +48,7 @@ BtGpi16::BtGpi16(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); bt_device=new RDTTYDevice(); if(tty->active()) { bt_device->setName(tty->port()); diff --git a/ripcd/btsentinel4web.cpp b/ripcd/btsentinel4web.cpp index d30bad76..4ac001c5 100644 --- a/ripcd/btsentinel4web.cpp +++ b/ripcd/btsentinel4web.cpp @@ -2,7 +2,7 @@ // // Rivendell switcher driver for the BroadcastTools Sentinel4Web AES switcher // -// (C) Copyright 2002-2013,2016 Fred Gleason +// (C) Copyright 2002-2013,2016-2018 Fred Gleason // // 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 @@ -19,9 +19,12 @@ // #include + +#include #include -#include -#include + +#include "btsentinel4web.h" +#include "globals.h" BtSentinel4Web::BtSentinel4Web(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -130,7 +133,7 @@ void BtSentinel4Web::processCommand(RDMacro *cmd) void BtSentinel4Web::connectedData() { bt_socket->writeBlock("*0U",3); - ripcd_config->log("ripcd",RDConfig::LogInfo,"connected to BT Sentinel4Web device at "+ + rda->config()->log("ripcd",RDConfig::LogInfo,"connected to BT Sentinel4Web device at "+ bt_socket->peerAddress().toString()); } @@ -154,7 +157,7 @@ void BtSentinel4Web::readyReadData() void BtSentinel4Web::watchdogData() { - ripcd_config->log("ripcd",RDConfig::LogWarning,"lost connection to BT Sentinel4Web device at "+ + rda->config()->log("ripcd",RDConfig::LogWarning,"lost connection to BT Sentinel4Web device at "+ bt_socket->peerAddress().toString()); bt_watchdog_reset_timer->start(BTSENTINEL4WEB_WATCHDOG_INTERVAL,true); } diff --git a/ripcd/btsrc16.cpp b/ripcd/btsrc16.cpp index 41a59399..75724826 100644 --- a/ripcd/btsrc16.cpp +++ b/ripcd/btsrc16.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the BroadcastTools SRC-16 // -// (C) Copyright 2002-2005,2010,2016 Fred Gleason +// (C) Copyright 2002-2005,2010,2016-2018 Fred Gleason // // 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 @@ -18,12 +18,14 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include - #include -#include -#include +#include + +#include + +#include "btsrc16.h" +#include "globals.h" BtSrc16::BtSrc16(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -47,7 +49,7 @@ BtSrc16::BtSrc16(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); bt_device=new RDTTYDevice(); if(tty->active()) { bt_device->setName(tty->port()); diff --git a/ripcd/btsrc8iii.cpp b/ripcd/btsrc8iii.cpp index 80625285..672b3960 100644 --- a/ripcd/btsrc8iii.cpp +++ b/ripcd/btsrc8iii.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the BroadcastTools SRC-8 III // -// (C) Copyright 2002-2005,2010,2016 Fred Gleason +// (C) Copyright 2002-2005,2010,2016-2018 Fred Gleason // // 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 @@ -18,13 +18,14 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include - #include -#include -#include +#include +#include + +#include "btsrc8iii.h" +#include "globals.h" BtSrc8Iii::BtSrc8Iii(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -48,7 +49,7 @@ BtSrc8Iii::BtSrc8Iii(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); bt_device=new RDTTYDevice(); if(tty->active()) { bt_device->setName(tty->port()); diff --git a/ripcd/btss124.cpp b/ripcd/btss124.cpp index f9451e62..6356fa44 100644 --- a/ripcd/btss124.cpp +++ b/ripcd/btss124.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the BroadcastTools SS 12.4 // -// (C) Copyright 2002-2004,2016 Fred Gleason +// (C) Copyright 2002-2004,2016-2018 Fred Gleason // // 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 @@ -18,12 +18,14 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include - #include -#include -#include +#include + +#include + +#include "btss124.h" +#include "globals.h" BtSs124::BtSs124(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -38,7 +40,7 @@ BtSs124::BtSs124(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); bt_device=new RDTTYDevice(); if(tty->active()) { bt_device->setName(tty->port()); diff --git a/ripcd/btss164.cpp b/ripcd/btss164.cpp index 89568050..38a3cd92 100644 --- a/ripcd/btss164.cpp +++ b/ripcd/btss164.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the BroadcastTools SS 16.4 // -// (C) Copyright 2002-2005,2016 Fred Gleason +// (C) Copyright 2002-2005,2016-2018 Fred Gleason // // 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 @@ -18,12 +18,14 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include - #include -#include -#include +#include + +#include + +#include "btss164.h" +#include "globals.h" BtSs164::BtSs164(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -49,7 +51,7 @@ BtSs164::BtSs164(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); bt_device=new RDTTYDevice(); if(tty->active()) { bt_device->setName(tty->port()); diff --git a/ripcd/btss41mlr.cpp b/ripcd/btss41mlr.cpp index a6d7c598..4deff7bf 100644 --- a/ripcd/btss41mlr.cpp +++ b/ripcd/btss41mlr.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the BroadcastTools SS 4.1 MLR // -// (C) Copyright 2002-2016 Fred Gleason +// (C) Copyright 2002-2018 Fred Gleason // // 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 @@ -18,14 +18,15 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // +#include + #include #include -#include - -#include -#include +#include +#include "btss41mlr.h" +#include "globals.h" BtSs41Mlr::BtSs41Mlr(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -51,7 +52,7 @@ BtSs41Mlr::BtSs41Mlr(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); bt_device=new RDTTYDevice(); if(tty->active()) { bt_device->setName(tty->port()); diff --git a/ripcd/btss42.cpp b/ripcd/btss42.cpp index ce5ea342..1292c47b 100644 --- a/ripcd/btss42.cpp +++ b/ripcd/btss42.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the BroadcastTools SS 4.2 // -// (C) Copyright 2002-2005,2016 Fred Gleason +// (C) Copyright 2002-2005,2016-2018 Fred Gleason // // 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 @@ -18,12 +18,14 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include - #include -#include -#include +#include + +#include + +#include "btss42.h" +#include "globals.h" BtSs42::BtSs42(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -49,7 +51,7 @@ BtSs42::BtSs42(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); bt_device=new RDTTYDevice(); if(tty->active()) { bt_device->setName(tty->port()); diff --git a/ripcd/btss44.cpp b/ripcd/btss44.cpp index d30144dd..ebdb0b3b 100644 --- a/ripcd/btss44.cpp +++ b/ripcd/btss44.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the BroadcastTools SS 4.4 // -// (C) Copyright 2002-2005,2009,2016 Fred Gleason +// (C) Copyright 2002-2005,2009,2016-2018 Fred Gleason // // 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 @@ -18,12 +18,14 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include - #include -#include -#include +#include + +#include + +#include "btss44.h" +#include "globals.h" BtSs44::BtSs44(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -49,7 +51,7 @@ BtSs44::BtSs44(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); bt_device=new RDTTYDevice(); if(tty->active()) { bt_device->setName(tty->port()); diff --git a/ripcd/btss82.cpp b/ripcd/btss82.cpp index ab93adc3..0172bdaf 100644 --- a/ripcd/btss82.cpp +++ b/ripcd/btss82.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the BroadcastTools SS 8.2 // -// (C) Copyright 2002-2004,2016 Fred Gleason +// (C) Copyright 2002-2004,2016-2018 Fred Gleason // // 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 @@ -18,12 +18,14 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include - #include -#include -#include +#include + +#include + +#include "btss82.h" +#include "globals.h" BtSs82::BtSs82(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -49,7 +51,7 @@ BtSs82::BtSs82(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); bt_device=new RDTTYDevice(); if(tty->active()) { bt_device->setName(tty->port()); diff --git a/ripcd/globals.h b/ripcd/globals.h index 5d60db5a..47f3c8f1 100644 --- a/ripcd/globals.h +++ b/ripcd/globals.h @@ -21,17 +21,14 @@ #ifndef GLOBALS_H #define GLOBALS_H -#include -#include +#include + #include #include // // Global Objects // -extern RDConfig *ripcd_config; -extern RDCae *rdcae; -extern RDStation *rdstation; extern QString ripcd_active_locks[MAX_MATRICES]; extern void LogLine(RDConfig::LogPriority prio,const QString &line); diff --git a/ripcd/livewire_lwrpaudio.cpp b/ripcd/livewire_lwrpaudio.cpp index 5e2a8307..a4045b1c 100644 --- a/ripcd/livewire_lwrpaudio.cpp +++ b/ripcd/livewire_lwrpaudio.cpp @@ -2,7 +2,7 @@ // // A Rivendell LWRP audio switcher driver for LiveWire networks. // -// (C) Copyright 2002-2013,2016 Fred Gleason +// (C) Copyright 2002-2013,2016-2018 Fred Gleason // // 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 @@ -19,9 +19,12 @@ // #include + +#include #include -#include -#include + +#include "globals.h" +#include "livewire_lwrpaudio.h" LiveWireLwrpAudio::LiveWireLwrpAudio(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -32,7 +35,7 @@ LiveWireLwrpAudio::LiveWireLwrpAudio(RDMatrix *matrix,QObject *parent) // // Get Matrix Parameters // - livewire_stationname=rdstation->name(); + livewire_stationname=rda->station()->name(); livewire_matrix=matrix->matrix(); // diff --git a/ripcd/livewire_mcastgpio.cpp b/ripcd/livewire_mcastgpio.cpp index 8f82c7c9..f1014097 100644 --- a/ripcd/livewire_mcastgpio.cpp +++ b/ripcd/livewire_mcastgpio.cpp @@ -2,7 +2,7 @@ // // A Rivendell multicast GPIO driver for LiveWire networks. // -// (C) Copyright 2013,2016 Fred Gleason +// (C) Copyright 2013,2016-2018 Fred Gleason // // 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 @@ -18,19 +18,20 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // -#include -#include #include #include +#include +#include #include #include #include +#include #include #include -#include -#include +#include "globals.h" +#include "livewire_mcastgpio.h" LiveWireMcastGpio::LiveWireMcastGpio(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -45,7 +46,7 @@ LiveWireMcastGpio::LiveWireMcastGpio(RDMatrix *matrix,QObject *parent) // // Get Matrix Parameters // - livewire_stationname=rdstation->name(); + livewire_stationname=rda->station()->name(); livewire_matrix=matrix->matrix(); livewire_gpios=matrix->gpis(); livewire_interface_addr=matrix->ipAddress(RDMatrix::Primary); diff --git a/ripcd/loaddrivers.cpp b/ripcd/loaddrivers.cpp index 084da9f2..73921484 100644 --- a/ripcd/loaddrivers.cpp +++ b/ripcd/loaddrivers.cpp @@ -2,7 +2,7 @@ // // Load Switcher drivers for ripcd(8) // -// (C) Copyright 2002-2017 Fred Gleason +// (C) Copyright 2002-2018 Fred Gleason // // 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 @@ -20,54 +20,56 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include "ripcd.h" +#include "switcher.h" +#include "globals.h" +#include "acu1p.h" +#include "am16.h" +#include "bt10x1.h" +#include "bt16x1.h" +#include "bt16x2.h" +#include "bt8x2.h" +#include "btacs82.h" +#include "btadms4422.h" +#include "btgpi16.h" +#include "btsentinel4web.h" +#include "btsrc16.h" +#include "btsrc8iii.h" +#include "btss124.h" +#include "btss164.h" +#include "btss41mlr.h" +#include "btss42.h" +#include "btss44.h" +#include "btss82.h" +#include "btu41mlrweb.h" +#include "harlond.h" +#include "kernelgpio.h" +#include "livewire_lwrpaudio.h" +#include "livewire_lwrpgpio.h" +#include "livewire_mcastgpio.h" +#include "local_audio.h" +#include "local_gpio.h" +#include "modbus.h" +#include "modemlines.h" +#include "quartz1.h" +#include "rossnkscp.h" +#include "sas16000.h" +#include "sas32000.h" +#include "sas64000.h" +#include "sas64000gpi.h" +#include "sasusi.h" +#include "starguide3.h" +#include "swauthority.h" +#include "unity4000.h" +#include "vguest.h" +#include "wheatnet_lio.h" +#include "wheatnet_slio.h" bool MainObject::LoadSwitchDriver(int matrix_num) { - RDMatrix *matrix=new RDMatrix(rdstation->name(),matrix_num); + RDMatrix *matrix=new RDMatrix(rda->station()->name(),matrix_num); switch(matrix->type()) { case RDMatrix::Acu1p: diff --git a/ripcd/local_audio.cpp b/ripcd/local_audio.cpp index 7723749d..e8c77409 100644 --- a/ripcd/local_audio.cpp +++ b/ripcd/local_audio.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the BroadcastTools 10x1 // -// (C) Copyright 2002-2003,2016 Fred Gleason +// (C) Copyright 2002-2003,2016-2018 Fred Gleason // // 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,9 +21,10 @@ #include #include +#include -#include -#include +#include "globals.h" +#include "local_audio.h" LocalAudio::LocalAudio(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -84,19 +85,19 @@ void LocalAudio::processCommand(RDMacro *cmd) } if(cmd->arg(1).toInt()==0) { for(int i=0;i + rda->cae()-> setPassthroughVolume(bt_card,i,cmd->arg(2).toInt()-1,-10000); } } else { - rdcae->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1, + rda->cae()->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1, cmd->arg(2).toInt()-1,0); for(int i=0;i<(cmd->arg(1).toInt()-1);i++) { - rdcae-> + rda->cae()-> setPassthroughVolume(bt_card,i,cmd->arg(2).toInt()-1,-10000); } for(int i=cmd->arg(1).toInt();i + rda->cae()-> setPassthroughVolume(bt_card,i,cmd->arg(2).toInt()-1,-10000); } } @@ -111,7 +112,7 @@ void LocalAudio::processCommand(RDMacro *cmd) emit rmlEcho(cmd); return; } - rdcae->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1, + rda->cae()->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1, cmd->arg(2).toInt()-1,0); cmd->acknowledge(true); emit rmlEcho(cmd); @@ -124,7 +125,7 @@ void LocalAudio::processCommand(RDMacro *cmd) emit rmlEcho(cmd); return; } - rdcae->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1, + rda->cae()->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1, cmd->arg(2).toInt()-1,RD_MUTE_DEPTH); cmd->acknowledge(true); emit rmlEcho(cmd); @@ -138,7 +139,7 @@ void LocalAudio::processCommand(RDMacro *cmd) emit rmlEcho(cmd); return; } - rdcae->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1, + rda->cae()->setPassthroughVolume(bt_card,cmd->arg(1).toInt()-1, cmd->arg(2).toInt()-1,cmd->arg(3).toInt()); cmd->acknowledge(true); emit rmlEcho(cmd); diff --git a/ripcd/local_macros.cpp b/ripcd/local_macros.cpp index f4c8b362..3804c257 100644 --- a/ripcd/local_macros.cpp +++ b/ripcd/local_macros.cpp @@ -2,7 +2,7 @@ // // Local RML Macros for the Rivendell Interprocess Communication Daemon // -// (C) Copyright 2002-2004,2016 Fred Gleason +// (C) Copyright 2002-2004,2016-2018 Fred Gleason // // 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 @@ -23,13 +23,13 @@ #include #include +#include #include +#include #include #include -#include -#include -#include -#include + +#include "ripcd.h" void MainObject::gpiChangedData(int matrix,int line,bool state) { @@ -117,7 +117,7 @@ void MainObject::ExecCart(int cartnum) RDMacro rml; rml.setRole(RDMacro::Cmd); rml.setCommand(RDMacro::EX); - rml.setAddress(rdstation->address()); + rml.setAddress(rda->station()->address()); rml.setEchoRequested(false); rml.setArgQuantity(1); rml.setArg(0,cartnum); @@ -132,7 +132,7 @@ void MainObject::LogGpioEvent(int matrix,int line,RDMatrix::GpioType type, RDSqlQuery *q; sql=QString("insert into GPIO_EVENTS set ")+ - "STATION_NAME=\""+RDEscapeString(rdstation->name())+"\","+ + "STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\","+ QString().sprintf("MATRIX=%d,",matrix)+ QString().sprintf("NUMBER=%d,",line+1)+ QString().sprintf("TYPE=%d,",type)+ @@ -163,7 +163,7 @@ void MainObject::LoadLocalMacros() // sql=QString().sprintf("select MATRIX,TYPE,PORT,INPUTS,OUTPUTS from MATRICES \ where STATION_NAME=\"%s\"", - (const char *)rdstation->name()); + (const char *)rda->station()->name()); q=new RDSqlQuery(sql); while(q->next()) { if(!LoadSwitchDriver(q->value(0).toInt())) { @@ -180,7 +180,7 @@ void MainObject::LoadLocalMacros() sql=QString().sprintf("select PORT_ID,PORT,BAUD_RATE,DATA_BITS,PARITY,\ TERMINATION from TTYS where (STATION_NAME=\"%s\")&&\ (ACTIVE=\"Y\")", - (const char *)rdstation->name()); + (const char *)rda->station()->name()); q=new RDSqlQuery(sql); while(q->next()) { tty_port=q->value(0).toUInt(); @@ -270,9 +270,9 @@ void MainObject::RunLocalMacros(RDMacro *rml) } if(fork()==0) { cmd=QString().sprintf("mysqldump -c Rivendell -h %s -u %s -p%s > %s", - (const char *)ripcd_config->mysqlHostname(), - (const char *)ripcd_config->mysqlUsername(), - (const char *)ripcd_config->mysqlPassword(), + (const char *)rda->config()->mysqlHostname(), + (const char *)rda->config()->mysqlUsername(), + (const char *)rda->config()->mysqlPassword(), (const char *)rml->arg(0).toString()); system((const char *)cmd); exit(0); @@ -416,7 +416,7 @@ void MainObject::RunLocalMacros(RDMacro *rml) } return; } - rdcae->connectJackPorts(rml->arg(0).toString(),rml->arg(1).toString()); + rda->cae()->connectJackPorts(rml->arg(0).toString(),rml->arg(1).toString()); if(rml->echoRequested()) { rml->acknowledge(true); sendRml(rml); @@ -431,7 +431,7 @@ void MainObject::RunLocalMacros(RDMacro *rml) } return; } - rdcae->disconnectJackPorts(rml->arg(0).toString(),rml->arg(1).toString()); + rda->cae()->disconnectJackPorts(rml->arg(0).toString(),rml->arg(1).toString()); if(rml->echoRequested()) { rml->acknowledge(true); sendRml(rml); @@ -447,7 +447,7 @@ void MainObject::RunLocalMacros(RDMacro *rml) return; } if(rml->argQuantity()==0) { - rduser=new RDUser(rdstation->defaultName()); + rduser=new RDUser(rda->station()->defaultName()); } else { rduser=new RDUser(rml->arg(0).toString()); @@ -494,19 +494,19 @@ void MainObject::RunLocalMacros(RDMacro *rml) } if(fork()==0) { if(getuid()==0) { - if(setegid(ripcd_config->gid())<0) { + if(setegid(rda->config()->gid())<0) { LogLine(RDConfig::LogWarning,QString(). sprintf("unable to set group id %d for RDPopup", - ripcd_config->gid())); + rda->config()->gid())); if(rml->echoRequested()) { rml->acknowledge(false); sendRml(rml); } } - if(seteuid(ripcd_config->uid())<0) { + if(seteuid(rda->config()->uid())<0) { LogLine(RDConfig::LogWarning,QString(). sprintf("unable to set user id %d for RDPopup", - ripcd_config->uid())); + rda->config()->uid())); if(rml->echoRequested()) { rml->acknowledge(false); sendRml(rml); @@ -579,19 +579,19 @@ void MainObject::RunLocalMacros(RDMacro *rml) cmd+=" "+rml->arg(i).toString(); } if(getuid()==0) { - if(setgid(ripcd_config->gid())<0) { + if(setgid(rda->config()->gid())<0) { LogLine(RDConfig::LogWarning,QString(). sprintf("unable to set group id %d for RN", - ripcd_config->gid())); + rda->config()->gid())); if(rml->echoRequested()) { rml->acknowledge(false); sendRml(rml); } } - if(setuid(ripcd_config->uid())<0) { + if(setuid(rda->config()->uid())<0) { LogLine(RDConfig::LogWarning,QString(). sprintf("unable to set user id %d for RN", - ripcd_config->uid())); + rda->config()->uid())); if(rml->echoRequested()) { rml->acknowledge(false); sendRml(rml); @@ -781,7 +781,7 @@ void MainObject::RunLocalMacros(RDMacro *rml) sql=QString().sprintf("select PORT_ID,PORT,BAUD_RATE,DATA_BITS,PARITY,\ TERMINATION from TTYS where (STATION_NAME=\"%s\")&& \ (ACTIVE=\"Y\")&&(PORT_ID=%d)", - (const char *)rdstation->name(),tty_port); + (const char *)rda->station()->name(),tty_port); q=new RDSqlQuery(sql); if(q->first()) { if(!ripcd_tty_inuse[tty_port]) { diff --git a/ripcd/modemlines.cpp b/ripcd/modemlines.cpp index 5535c31c..43333df4 100644 --- a/ripcd/modemlines.cpp +++ b/ripcd/modemlines.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for using TTY modem lines for GPIO // -// (C) Copyright 2015-2016 Fred Gleason +// (C) Copyright 2015-2018 Fred Gleason // // 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 @@ -18,15 +18,17 @@ // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include +#include + +#include "globals.h" +#include "modemlines.h" ModemLines::ModemLines(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -54,7 +56,7 @@ ModemLines::ModemLines(RDMatrix *matrix,QObject *parent) // // Open TTY // - gpio_tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + gpio_tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); if((gpio_fd=open(gpio_tty->port(),O_RDONLY))<0) { syslog(LOG_ERR,"unable to open tty \"%s\"",(const char *)gpio_tty->port()); return; diff --git a/ripcd/quartz1.cpp b/ripcd/quartz1.cpp index 881140c1..0f522f8b 100644 --- a/ripcd/quartz1.cpp +++ b/ripcd/quartz1.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the Quartz Type 1 Switcher Protocol // -// (C) Copyright 2002-2004,2008,2016 Fred Gleason +// (C) Copyright 2002-2004,2008,2016-2018 Fred Gleason // // 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 @@ -22,9 +22,11 @@ #include +#include #include -#include -#include + +#include "globals.h" +#include "quartz1.h" Quartz1::Quartz1(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -71,7 +73,7 @@ Quartz1::Quartz1(RDMatrix *matrix,QObject *parent) for(int i=0;i<2;i++) { switch(sas_porttype[i]) { case RDMatrix::TtyPort: - tty=new RDTty(rdstation->name(),sas_port[i]); + tty=new RDTty(rda->station()->name(),sas_port[i]); sas_device[i]=new RDTTYDevice(); if(tty->active()) { sas_device[i]->setName(tty->port()); diff --git a/ripcd/ripcd.cpp b/ripcd/ripcd.cpp index 759fdb56..e364f5d5 100644 --- a/ripcd/ripcd.cpp +++ b/ripcd/ripcd.cpp @@ -38,24 +38,15 @@ #include #include -#include +#include #include -#include #include -#include -#include -#include +#include -#include -#include -#include +#include "globals.h" +#include "ripcd_socket.h" +#include "ripcd.h" -// -// Global Objects -// -RDConfig *ripcd_config; -RDCae *rdcae; -RDStation *rdstation; bool global_exiting=false; void SigHandler(int signo) @@ -84,26 +75,13 @@ void SigHandler(int signo) MainObject::MainObject(QObject *parent) :QObject(parent) { - bool skip_db_check=false; + QString err_msg; - // - // Read Command Options - // - RDCmdSwitch *cmd= - new RDCmdSwitch(qApp->argc(),qApp->argv(),"ripcd",RIPCD_USAGE); - for(unsigned i=0;ikeys();i++) { - if(cmd->key(i)=="--skip-db-check") { - skip_db_check=true; - } + rda=new RDApplication("ripcd","ripcd",RIPCD_USAGE,this); + if(!rda->open(&err_msg)) { + fprintf(stderr,"ripcd: %s\n",(const char *)err_msg); + exit(1); } - delete cmd; - - // - // Load Local Configs - // - ripcd_config=new RDConfig(RD_CONF_FILE); - ripcd_config->load(); - ripcd_config->setModuleName("ripcd"); // // Make sure we're the only instance running @@ -145,39 +123,15 @@ MainObject::MainObject(QObject *parent) connect(ripc_macro_timer[i],SIGNAL(timeout()),mapper,SLOT(map())); } - // - // Open Database - // - unsigned schema=0; - QString err (tr("ripcd: ")); - ripcd_db = RDInitDb (&schema,&err); - if(!ripcd_db) { - printf ("%s\n",err.ascii()); - exit (1); - } - if((schema!=RD_VERSION_DATABASE)&&(!skip_db_check)) { - fprintf(stderr,"database version mismatch, should be %u, is %u", - RD_VERSION_DATABASE,schema); - exit(256); - } - connect (RDDbStatus(),SIGNAL(logText(RDConfig::LogPriority,const QString &)), - this,SLOT(log(RDConfig::LogPriority,const QString &))); - - // - // Station - // - rdstation=new RDStation(ripcd_config->stationName()); - rdstation->setUserName(rdstation->defaultName()); - ripcd_host_addr=rdstation->address(); + ripcd_host_addr=rda->station()->address(); // // CAE Connection // - rdcae=new RDCae(rdstation,ripcd_config,parent); - rdcae->connectHost(); + rda->cae()->connectHost(); if(qApp->argc()==1) { - RDDetach(ripcd_config->logCoreDumpDirectory()); + RDDetach(rda->config()->logCoreDumpDirectory()); } else { debug=true; @@ -185,7 +139,7 @@ MainObject::MainObject(QObject *parent) ::signal(SIGCHLD,SigHandler); ::signal(SIGTERM,SigHandler); ::signal(SIGINT,SigHandler); - if(!RDWritePid(RD_PID_DIR,"ripcd.pid",ripcd_config->uid())) { + if(!RDWritePid(RD_PID_DIR,"ripcd.pid",rda->config()->uid())) { printf("ripcd: can't write pid file\n"); exit(1); } @@ -214,6 +168,18 @@ MainObject::MainObject(QObject *parent) // LoadLocalMacros(); + // + // Initialize Notifications + // + ripcd_notification_mcaster=new RDMulticaster(this); + ripcd_notification_mcaster->enableLoopback(false); + connect(ripcd_notification_mcaster, + SIGNAL(received(const QString &,const QHostAddress &)), + this, + SLOT(notificationReceivedData(const QString &,const QHostAddress &))); + ripcd_notification_mcaster->bind(RD_NOTIFICATION_PORT); + ripcd_notification_mcaster->subscribe(rda->system()->notificationAddress()); + // // Start RML Polling // @@ -237,7 +203,7 @@ MainObject::MainObject(QObject *parent) ripcd_maint_timer=new QTimer(this); connect(ripcd_maint_timer,SIGNAL(timeout()),this,SLOT(checkMaintData())); int interval=GetMaintInterval(); - if(!ripcd_config->disableMaintChecks()) { + if(!rda->config()->disableMaintChecks()) { ripcd_maint_timer->start(interval); } else { @@ -287,6 +253,21 @@ void MainObject::newConnection(int fd) } +void MainObject::notificationReceivedData(const QString &msg, + const QHostAddress &addr) +{ + RDNotification *notify=new RDNotification(); + if(!notify->read(msg)) { + LogLine(RDConfig::LogWarning, + "Invalid notification received from "+addr.toString()); + delete notify; + return; + } + BroadcastCommand("ON "+msg+"!"); + delete notify; +} + + void MainObject::sendRml(RDMacro *rml) { char buf[RD_RML_MAX_LENGTH]; @@ -327,20 +308,20 @@ void MainObject::databaseBackup() QDateTime datetime=QDateTime::currentDateTime(); int life; - if((life=rdstation->backupLife())<=0) { + if((life=rda->station()->backupLife())<=0) { return; } if(fork()==0) { cmd=QString().sprintf("find %s -name *.sql -ctime +%d -exec rm \\{\\} \\;", - (const char *)rdstation->backupPath(), - rdstation->backupLife()); + (const char *)rda->station()->backupPath(), + rda->station()->backupLife()); system((const char *)cmd); cmd=QString(). sprintf("mysqldump -c Rivendell -h %s -u %s -p%s > %s/%s.sql", - (const char *)ripcd_config->mysqlHostname(), - (const char *)ripcd_config->mysqlUsername(), - (const char *)ripcd_config->mysqlPassword(), - (const char *)rdstation->backupPath(), + (const char *)rda->config()->mysqlHostname(), + (const char *)rda->config()->mysqlUsername(), + (const char *)rda->config()->mysqlPassword(), + (const char *)rda->station()->backupPath(), (const char *)datetime.date().toString("yyyyMMdd")); system((const char *)cmd); exit(0); @@ -373,7 +354,7 @@ void MainObject::checkMaintData() // // Should we try to run system maintenance? // - if(!rdstation->systemMaint()) { + if(!rda->station()->systemMaint()) { return; } @@ -427,7 +408,7 @@ void MainObject::exitTimerData() void MainObject::SetUser(QString username) { - rdstation->setUserName(username); + rda->station()->setUserName(username); BroadcastCommand(QString().sprintf("RU %s!",(const char *)username)); } @@ -500,7 +481,7 @@ void MainObject::DispatchCommand(int ch) return; } if(!strcmp(conn->args[0],"PW")) { // Password Authenticate - if(!strcmp(conn->args[1],ripcd_config->password())) { + if(!strcmp(conn->args[1],rda->config()->password())) { conn->auth=true; EchoCommand(ch,"PW +!"); return; @@ -523,7 +504,7 @@ void MainObject::DispatchCommand(int ch) if(!strcmp(conn->args[0],"RU")) { // Request User EchoCommand(ch,(const char *)QString(). - sprintf("RU %s!",(const char *)rdstation->userName())); + sprintf("RU %s!",(const char *)rda->station()->userName())); return; } @@ -556,7 +537,7 @@ void MainObject::DispatchCommand(int ch) */ if(!macro.address().isNull()) { - if(macro.address()==rdstation->address()&& + if(macro.address()==rda->station()->address()&& ((macro.port()==RD_RML_ECHO_PORT)|| (macro.port()==RD_RML_NOECHO_PORT))) { // Local Loopback macro.generateString(buffer,RD_RML_MAX_LENGTH); @@ -590,7 +571,7 @@ void MainObject::DispatchCommand(int ch) addr.setAddress(conn->args[1]); macro.setAddress(addr); macro.setRole(RDMacro::Reply); - if(macro.address()==rdstation->address()) { // Local Loopback + if(macro.address()==rda->station()->address()) { // Local Loopback macro.generateString(buffer,RD_RML_MAX_LENGTH); sprintf(cmd,"ME %s 0 %s",(const char *)macro.address().toString(), buffer); @@ -641,6 +622,24 @@ void MainObject::DispatchCommand(int ch) SendGpoCart(ch,matrix); } + if(!strcmp(conn->args[0],"ON")) { // Send Notification + QString msg; + for(int i=1;iargnum;i++) { + msg+=QString(conn->args[i])+" "; + } + msg=msg.left(msg.length()-1); + RDNotification *notify=new RDNotification(); + if(!notify->read(msg)) { + LogLine(RDConfig::LogWarning,"invalid notification processed"); + delete notify; + return; + } + BroadcastCommand("ON "+msg+"!",ch); + ripcd_notification_mcaster-> + send(msg,rda->system()->notificationAddress(),RD_NOTIFICATION_PORT); + delete notify; + } + if(!strcmp(conn->args[0],"TA")) { // Send Onair Flag State EchoCommand(ch,QString().sprintf("TA %d!",ripc_onair_flag)); } @@ -662,11 +661,13 @@ void MainObject::EchoCommand(int ch,const char *command) } -void MainObject::BroadcastCommand(const char *command) +void MainObject::BroadcastCommand(const char *command,int except_ch) { for(unsigned i=0;istationName()); + (const char *)rda->config()->stationName()); RDSqlQuery *q=new RDSqlQuery(sql); while(q->next()) { ripcd_gpi_macro[q->value(0).toInt()][q->value(1).toInt()-1][0]= @@ -786,7 +787,7 @@ void MainObject::LoadGpiTable() sql=QString().sprintf("select MATRIX,NUMBER,OFF_MACRO_CART,MACRO_CART \ from GPOS where STATION_NAME=\"%s\"", - (const char *)ripcd_config->stationName()); + (const char *)rda->config()->stationName()); q=new RDSqlQuery(sql); while(q->next()) { ripcd_gpo_macro[q->value(0).toInt()][q->value(1).toInt()-1][0]= @@ -878,18 +879,18 @@ void LogLine(RDConfig::LogPriority prio,const QString &line) { FILE *logfile; - ripcd_config->log("ripcd",prio,line); + rda->config()->log("ripcd",prio,line); - if((!ripcd_config) || ripcd_config->ripcdLogname().isEmpty()) { + if((!rda->config()) || rda->config()->ripcdLogname().isEmpty()) { return; } QDateTime current=QDateTime::currentDateTime(); - logfile=fopen(ripcd_config->ripcdLogname(),"a"); + logfile=fopen(rda->config()->ripcdLogname(),"a"); if(logfile==NULL) { return; } - chmod(ripcd_config->ripcdLogname(),S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH); + chmod(rda->config()->ripcdLogname(),S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH); fprintf(logfile,"%02d/%02d/%4d - %02d:%02d:%02d.%03d : %s\n", current.date().month(), current.date().day(), diff --git a/ripcd/ripcd.h b/ripcd/ripcd.h index d6aee281..037b7749 100644 --- a/ripcd/ripcd.h +++ b/ripcd/ripcd.h @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -63,6 +64,7 @@ class MainObject : public QObject void newConnection(int fd); private slots: + void notificationReceivedData(const QString &msg,const QHostAddress &addr); void log(RDConfig::LogPriority prio,const QString &msg); void sendRml(RDMacro *rml); void readRml(); @@ -87,7 +89,7 @@ class MainObject : public QObject void DispatchCommand(int); void KillSocket(int); void EchoCommand(int,const char *); - void BroadcastCommand(const char *); + void BroadcastCommand(const char *,int except_ch=-1); void EchoArgs(int,const char); void ReadRmlSocket(QSocketDevice *dev,RDMacro::Role role,bool echo); QString StripPoint(QString); @@ -132,6 +134,7 @@ class MainObject : public QObject QTimer *ripc_macro_timer[RD_MAX_MACRO_TIMERS]; unsigned ripc_macro_cart[RD_MAX_MACRO_TIMERS]; QTimer *ripcd_maint_timer; + RDMulticaster *ripcd_notification_mcaster; }; diff --git a/ripcd/rossnkscp.cpp b/ripcd/rossnkscp.cpp index bc508aab..34accefe 100644 --- a/ripcd/rossnkscp.cpp +++ b/ripcd/rossnkscp.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the Ross NK switchers via the SCP/A // -// (C) Copyright 2002-2016 Fred Gleason +// (C) Copyright 2002-2018 Fred Gleason // // 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 @@ -20,9 +20,10 @@ #include -#include -#include +#include +#include "globals.h" +#include "rossnkscp.h" RossNkScp::RossNkScp(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -37,7 +38,7 @@ RossNkScp::RossNkScp(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); ross_device=new RDTTYDevice(); if(tty->active()) { ross_device->setName(tty->port()); diff --git a/ripcd/sas16000.cpp b/ripcd/sas16000.cpp index 592c2e31..8601f64e 100644 --- a/ripcd/sas16000.cpp +++ b/ripcd/sas16000.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the SAS USI Protocol (2 digit) // -// (C) Copyright 2002-2016 Fred Gleason +// (C) Copyright 2002-2018 Fred Gleason // // 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 @@ -19,9 +19,12 @@ // #include + +#include #include -#include -#include + +#include "globals.h" +#include "sas16000.h" Sas16000::Sas16000(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -41,7 +44,7 @@ Sas16000::Sas16000(RDMatrix *matrix,QObject *parent) // // Initialize the connection // - tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); sas_device=new RDTTYDevice(); if(tty->active()) { sas_device->setName(tty->port()); diff --git a/ripcd/sas32000.cpp b/ripcd/sas32000.cpp index 6963334c..c0bc2078 100644 --- a/ripcd/sas32000.cpp +++ b/ripcd/sas32000.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the SAS32000 // -// (C) Copyright 2002-2004,2016 Fred Gleason +// (C) Copyright 2002-2004,2016-2018 Fred Gleason // // 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 @@ -20,8 +20,10 @@ #include -#include -#include +#include + +#include "globals.h" +#include "sas32000.h" Sas32000::Sas32000(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -35,7 +37,7 @@ Sas32000::Sas32000(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); sas_device=new RDTTYDevice(); if(tty->active()) { sas_device->setName(tty->port()); diff --git a/ripcd/sas64000.cpp b/ripcd/sas64000.cpp index d2cf322c..c260183d 100644 --- a/ripcd/sas64000.cpp +++ b/ripcd/sas64000.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the SAS64000 // -// (C) Copyright 2002-2004,2016 Fred Gleason +// (C) Copyright 2002-2004,2016-2018 Fred Gleason // // 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 @@ -20,8 +20,10 @@ #include -#include -#include +#include + +#include "globals.h" +#include "sas64000.h" Sas64000::Sas64000(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -35,7 +37,7 @@ Sas64000::Sas64000(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); sas_device=new RDTTYDevice(); if(tty->active()) { sas_device->setName(tty->port()); diff --git a/ripcd/sas64000gpi.cpp b/ripcd/sas64000gpi.cpp index 3e8cb29f..0af069e9 100644 --- a/ripcd/sas64000gpi.cpp +++ b/ripcd/sas64000gpi.cpp @@ -3,7 +3,7 @@ // A Rivendell switcher driver for the SAS64000 connected via // a GPI-1600 // -// (C) Copyright 2002-2004,2016 Fred Gleason +// (C) Copyright 2002-2004,2016-2018 Fred Gleason // // 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,9 +21,10 @@ #include -#include -#include +#include +#include "globals.h" +#include "sas64000gpi.h" Sas64000Gpi::Sas64000Gpi(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -40,7 +41,7 @@ Sas64000Gpi::Sas64000Gpi(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); sas_device=new RDTTYDevice(); if(tty->active()) { sas_device->setName(tty->port()); diff --git a/ripcd/sasusi.cpp b/ripcd/sasusi.cpp index 03abc204..7a08ce47 100644 --- a/ripcd/sasusi.cpp +++ b/ripcd/sasusi.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the SAS USI Protocol // -// (C) Copyright 2002-2016 Fred Gleason +// (C) Copyright 2002-2018 Fred Gleason // // 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 @@ -19,9 +19,12 @@ // #include + +#include #include -#include -#include + +#include "globals.h" +#include "sasusi.h" SasUsi::SasUsi(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -53,7 +56,7 @@ SasUsi::SasUsi(RDMatrix *matrix,QObject *parent) sprintf("select ENGINE_NUM,DEVICE_NUM,RELAY_NUM \ from VGUEST_RESOURCES where (STATION_NAME=\"%s\")&&\ (MATRIX_NUM=%d) order by NUMBER", - (const char *)ripcd_config->stationName(), + (const char *)rda->config()->stationName(), matrix->matrix()); q=new RDSqlQuery(sql); while(q->next()) { @@ -74,7 +77,7 @@ SasUsi::SasUsi(RDMatrix *matrix,QObject *parent) // switch(sas_porttype) { case RDMatrix::TtyPort: - tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); sas_device=new RDTTYDevice(); if(tty->active()) { sas_device->setName(tty->port()); @@ -486,7 +489,7 @@ void SasUsi::DispatchCommand() sql=QString().sprintf("select NUMBER from INPUTS where \ (STATION_NAME=\"%s\")&& \ (MATRIX=%d)&&(NUMBER=%d)", - (const char *)rdstation->name(), + (const char *)rda->station()->name(), sas_matrix,input); q=new RDSqlQuery(sql); if(q->first()) { @@ -494,14 +497,14 @@ void SasUsi::DispatchCommand() (STATION_NAME=\"%s\")&&\ (MATRIX=%d)&&(NUMBER=%d)", (const char *)label, - (const char *)rdstation->name(), + (const char *)rda->station()->name(), sas_matrix,input); } else { sql=QString().sprintf("insert into INPUTS set NAME=\"%s\",\ STATION_NAME=\"%s\",MATRIX=%d,NUMBER=%d", (const char *)label, - (const char *)rdstation->name(), + (const char *)rda->station()->name(), sas_matrix,input); } delete q; @@ -521,7 +524,7 @@ void SasUsi::DispatchCommand() sql=QString().sprintf("select NUMBER from OUTPUTS where \ (STATION_NAME=\"%s\")&&\ (MATRIX=%d)&&(NUMBER=%d)", - (const char *)rdstation->name(), + (const char *)rda->station()->name(), sas_matrix,output); q=new RDSqlQuery(sql); if(q->first()) { @@ -529,14 +532,14 @@ void SasUsi::DispatchCommand() (STATION_NAME=\"%s\")&&\ (MATRIX=%d)&&(NUMBER=%d)", (const char *)label, - (const char *)rdstation->name(), + (const char *)rda->station()->name(), sas_matrix,output); } else { sql=QString().sprintf("insert into OUTPUTS set NAME=\"%s\",\ STATION_NAME=\"%s\",MATRIX=%d,NUMBER=%d", (const char *)label, - (const char *)rdstation->name(), + (const char *)rda->station()->name(), sas_matrix,output); } delete q; @@ -619,7 +622,7 @@ void SasUsi::ExecuteMacroCart(unsigned cartnum) RDMacro rml; rml.setRole(RDMacro::Cmd); rml.setCommand(RDMacro::EX); - rml.setAddress(rdstation->address()); + rml.setAddress(rda->station()->address()); rml.setEchoRequested(false); rml.setArgQuantity(1); rml.setArg(0,cartnum); diff --git a/ripcd/starguide3.cpp b/ripcd/starguide3.cpp index 27388b0a..c65e8fd1 100644 --- a/ripcd/starguide3.cpp +++ b/ripcd/starguide3.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the StarGuide III Satellite Receiver // -// (C) Copyright 2002-2005,2016 Fred Gleason +// (C) Copyright 2002-2005,2016-2018 Fred Gleason // // 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 @@ -20,10 +20,10 @@ #include -#include -#include -#include -#include +#include + +#include "globals.h" +#include "starguide3.h" StarGuide3::StarGuide3(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -43,7 +43,7 @@ StarGuide3::StarGuide3(RDMatrix *matrix,QObject *parent) sql=QString().sprintf("select NUMBER,ENGINE_NUM,DEVICE_NUM,CHANNEL_MODE\ from INPUTS where STATION_NAME=\"%s\" && MATRIX=%d \ order by NUMBER", - (const char *)rdstation->name(), + (const char *)rda->station()->name(), matrix->matrix()); q=new RDSqlQuery(sql); q->first(); @@ -61,7 +61,7 @@ StarGuide3::StarGuide3(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); sg_device=new RDTTYDevice(); if(tty->active()) { sg_device->setName(tty->port()); diff --git a/ripcd/swauthority.cpp b/ripcd/swauthority.cpp index 156f51c7..ad52fdaa 100644 --- a/ripcd/swauthority.cpp +++ b/ripcd/swauthority.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for systems using Software Authority Protocol // -// (C) Copyright 2002-2016 Fred Gleason +// (C) Copyright 2002-2018 Fred Gleason // // 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 @@ -22,10 +22,11 @@ #include +#include #include -#include -#include -#include + +#include "globals.h" +#include "swauthority.h" SoftwareAuthority::SoftwareAuthority(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -297,7 +298,7 @@ void SoftwareAuthority::DispatchCommand() swa_istate=0; sql=QString("update MATRICES set ")+ QString().sprintf("INPUTS=%d ",swa_inputs)+ - "where (STATION_NAME=\""+RDEscapeString(rdstation->name())+"\")&&"+ + "where (STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+ QString().sprintf("(MATRIX=%d)",swa_matrix); q=new RDSqlQuery(sql); delete q; @@ -312,7 +313,7 @@ void SoftwareAuthority::DispatchCommand() sql=QString().sprintf("select NUMBER from INPUTS where \ (STATION_NAME=\"%s\")&& \ (MATRIX=%d)&&(NUMBER=%d)", - (const char *)rdstation->name(), + (const char *)rda->station()->name(), swa_matrix,f0[0].toInt()); q=new RDSqlQuery(sql); if(q->first()) { @@ -320,14 +321,14 @@ void SoftwareAuthority::DispatchCommand() (STATION_NAME=\"%s\")&&\ (MATRIX=%d)&&(NUMBER=%d)", (const char *)name, - (const char *)rdstation->name(), + (const char *)rda->station()->name(), swa_matrix,f0[0].toInt()); } else { sql=QString().sprintf("insert into INPUTS set NAME=\"%s\",\ STATION_NAME=\"%s\",MATRIX=%d,NUMBER=%d", (const char *)name, - (const char *)rdstation->name(), + (const char *)rda->station()->name(), swa_matrix,f0[0].toInt()); } delete q; @@ -343,7 +344,7 @@ void SoftwareAuthority::DispatchCommand() swa_istate=0; sql=QString("update MATRICES set ")+ QString().sprintf("OUTPUTS=%d ",swa_outputs)+ - "where (STATION_NAME=\""+RDEscapeString(rdstation->name())+"\")&&"+ + "where (STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+ QString().sprintf("(MATRIX=%d)",swa_matrix); q=new RDSqlQuery(sql); delete q; @@ -366,7 +367,7 @@ void SoftwareAuthority::DispatchCommand() sql=QString().sprintf("select NUMBER from OUTPUTS where \ (STATION_NAME=\"%s\")&&\ (MATRIX=%d)&&(NUMBER=%d)", - (const char *)rdstation->name(), + (const char *)rda->station()->name(), swa_matrix,f0[0].toInt()); q=new RDSqlQuery(sql); if(q->first()) { @@ -374,14 +375,14 @@ void SoftwareAuthority::DispatchCommand() (STATION_NAME=\"%s\")&&\ (MATRIX=%d)&&(NUMBER=%d)", (const char *)name, - (const char *)rdstation->name(), + (const char *)rda->station()->name(), swa_matrix,f0[0].toInt()); } else { sql=QString().sprintf("insert into OUTPUTS set NAME=\"%s\",\ STATION_NAME=\"%s\",MATRIX=%d,NUMBER=%d", (const char *)name, - (const char *)rdstation->name(), + (const char *)rda->station()->name(), swa_matrix,f0[0].toInt()); } delete q; @@ -393,7 +394,7 @@ void SoftwareAuthority::DispatchCommand() // sql=QString("update MATRICES set ")+ QString().sprintf("GPIS=%d,GPOS=%d where ",swa_gpis,swa_gpos)+ - "(STATION_NAME=\""+RDEscapeString(rdstation->name())+"\")&&"+ + "(STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+ QString().sprintf("(MATRIX=%d)",swa_matrix); q=new RDSqlQuery(sql); delete q; @@ -446,7 +447,7 @@ void SoftwareAuthority::ExecuteMacroCart(unsigned cartnum) RDMacro rml; rml.setRole(RDMacro::Cmd); rml.setCommand(RDMacro::EX); - rml.setAddress(rdstation->address()); + rml.setAddress(rda->station()->address()); rml.setEchoRequested(false); rml.setArgQuantity(1); rml.setArg(0,cartnum); diff --git a/ripcd/switcher.cpp b/ripcd/switcher.cpp index 14253b79..ae2ca195 100644 --- a/ripcd/switcher.cpp +++ b/ripcd/switcher.cpp @@ -20,6 +20,7 @@ #include +#include #include #include @@ -67,7 +68,7 @@ void Switcher::executeMacroCart(unsigned cartnum) RDMacro rml; rml.setRole(RDMacro::Cmd); rml.setCommand(RDMacro::EX); - rml.setAddress(rdstation->address()); + rml.setAddress(rda->station()->address()); rml.setEchoRequested(false); rml.setArgQuantity(1); rml.setArg(0,cartnum); diff --git a/ripcd/unity4000.cpp b/ripcd/unity4000.cpp index c89ea030..a0697fe5 100644 --- a/ripcd/unity4000.cpp +++ b/ripcd/unity4000.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the UNITY4000 // -// (C) Copyright 2002-2003,2016 Fred Gleason +// (C) Copyright 2002-2003,2016-2018 Fred Gleason // // 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 @@ -20,10 +20,11 @@ #include +#include #include -#include -#include +#include "globals.h" +#include "unity4000.h" Unity4000::Unity4000(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -43,7 +44,7 @@ Unity4000::Unity4000(RDMatrix *matrix,QObject *parent) sql=QString().sprintf("select NUMBER,FEED_NAME,CHANNEL_MODE from INPUTS \ where STATION_NAME=\"%s\" && MATRIX=%d \ order by NUMBER", - (const char *)rdstation->name(), + (const char *)rda->station()->name(), matrix->matrix()); q=new RDSqlQuery(sql); q->first(); @@ -60,7 +61,7 @@ Unity4000::Unity4000(RDMatrix *matrix,QObject *parent) // // Initialize the TTY Port // - RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary)); + RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary)); unity_device=new RDTTYDevice(); if(tty->active()) { unity_device->setName(tty->port()); diff --git a/ripcd/vguest.cpp b/ripcd/vguest.cpp index 118a44b4..dc039132 100644 --- a/ripcd/vguest.cpp +++ b/ripcd/vguest.cpp @@ -2,7 +2,7 @@ // // A Rivendell switcher driver for the Logitek vGuest Protocol // -// (C) Copyright 2002-2005,2016 Fred Gleason +// (C) Copyright 2002-2005,2016-2018 Fred Gleason // // 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 @@ -22,10 +22,10 @@ #include -#include -#include -#include +#include +#include "globals.h" +#include "vguest.h" VGuest::VGuest(RDMatrix *matrix,QObject *parent) : Switcher(matrix,parent) @@ -208,7 +208,7 @@ VGuest::VGuest(RDMatrix *matrix,QObject *parent) // for(int i=0;i<2;i++) { if(vguest_porttype[i]==RDMatrix::TtyPort) { - tty=new RDTty(rdstation->name(),matrix->port((RDMatrix::Role)i)); + tty=new RDTty(rda->station()->name(),matrix->port((RDMatrix::Role)i)); vguest_device[i]=new RDTTYDevice(); if(tty->active()) { vguest_device[i]->setName(tty->port()); @@ -806,7 +806,7 @@ void VGuest::ExecuteMacroCart(unsigned cartnum) RDMacro rml; rml.setRole(RDMacro::Cmd); rml.setCommand(RDMacro::EX); - rml.setAddress(rdstation->address()); + rml.setAddress(rda->station()->address()); rml.setEchoRequested(false); rml.setArgQuantity(1); rml.setArg(0,cartnum); diff --git a/tests/Makefile.am b/tests/Makefile.am index 92ee1b47..2ef729af 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -34,6 +34,7 @@ noinst_PROGRAMS = audio_convert_test\ audio_peaks_test\ datedecode_test\ log_unlink_test\ + mcast_recv_test\ rdxml_parse_test\ reserve_carts_test\ sas_switch_torture\ @@ -64,6 +65,10 @@ dist_log_unlink_test_SOURCES = log_unlink_test.cpp log_unlink_test.h nodist_log_unlink_test_SOURCES = moc_log_unlink_test.cpp log_unlink_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ +dist_mcast_recv_test_SOURCES = mcast_recv_test.cpp mcast_recv_test.h +nodist_mcast_recv_test_SOURCES = moc_mcast_recv_test.cpp +mcast_recv_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ + dist_rdxml_parse_test_SOURCES = rdxml_parse_test.cpp rdxml_parse_test.h rdxml_parse_test_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ diff --git a/tests/mcast_recv_test.cpp b/tests/mcast_recv_test.cpp new file mode 100644 index 00000000..9f34b2f2 --- /dev/null +++ b/tests/mcast_recv_test.cpp @@ -0,0 +1,104 @@ +// mcast_recv_test.cpp +// +// Test the Rivendell multicast receiver routines +// +// (C) Copyright 2018 Fred Gleason +// +// 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 +#include + +#include +#include +#include + +#include + +#include "mcast_recv_test.h" + +MainObject::MainObject(QObject *parent) + : QObject(parent) +{ + QHostAddress from_addr; + unsigned from_port=0; + bool ok=false; + + RDCmdSwitch *cmd= + new RDCmdSwitch(qApp->argc(),qApp->argv(),"mcast_recv_test", + MCAST_RECV_TEST_USAGE); + for(unsigned i=0;ikeys();i++) { + if(cmd->key(i)=="--from") { + QStringList f0=f0.split(":",cmd->value(i)); + if(f0.size()!=2) { + fprintf(stderr,"mcast_recv_test: invalid argument to \"--from\"\n"); + exit(1); + } + if(!from_addr.setAddress(f0[0])) { + fprintf(stderr,"mcast_recv_test: invalid address in \"--from\"\n"); + exit(1); + } + from_port=f0[1].toUInt(&ok); + if(!ok) { + fprintf(stderr,"mcast_recv_test: invalid port in \"--from\"\n"); + exit(1); + } + if((from_port==0)||(from_port>=65536)) { + fprintf(stderr,"mcast_recv_test: invalid port in \"--from\"\n"); + exit(1); + } + cmd->setProcessed(i,true); + } + if(!cmd->processed(i)) { + fprintf(stderr,"mcast_recv_test: unknown option \"%s\"\n", + (const char *)cmd->value(i)); + exit(256); + } + } + if(from_addr.isNull()) { + fprintf(stderr,"mcast_recv_test: you must specify a multicast address in \"--from\"\n"); + exit(1); + } + if(from_port==0) { + fprintf(stderr,"mcast_recv_test: you must specify a UDP port in \"--from\"\n"); + exit(1); + } + mcast_multicaster=new RDMulticaster(this); + connect(mcast_multicaster, + SIGNAL(received(const QString &,const QHostAddress &)), + this,SLOT(receivedData(const QString &,const QHostAddress &))); + if(!mcast_multicaster->bind(from_port)) { + fprintf(stderr,"mcast_recv_test: unable to bind port\n"); + exit(1); + } + mcast_multicaster->subscribe(from_addr); + printf("listening for %s at %u\n",(const char *)from_addr.toString(), + 0xFFFF&from_port); +} + + +void MainObject::receivedData(const QString &msg,const QHostAddress &src_addr) +{ + printf("%15s: %s\n",(const char *)src_addr.toString(), + (const char *)msg); +} + + +int main(int argc,char *argv[]) +{ + QApplication a(argc,argv,false); + new MainObject(); + return a.exec(); +} diff --git a/tests/mcast_recv_test.h b/tests/mcast_recv_test.h new file mode 100644 index 00000000..c15f0749 --- /dev/null +++ b/tests/mcast_recv_test.h @@ -0,0 +1,44 @@ +// mcast_recv_test.h +// +// Test the Rivendell multicast receiver routines +// +// (C) Copyright 2018 Fred Gleason +// +// 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 MCAST_RECV_TEST_H +#define MCAST_RECV_TEST_H + +#include + +#include + +#define MCAST_RECV_TEST_USAGE "[options]\n\nTest the Rivendell multicast receiver routines\n\nOptions are:\n--from=:\n Subscribe to and listen on .\n\n" + +class MainObject : public QObject +{ + Q_OBJECT; + public: + MainObject(QObject *parent=0); + + private slots: + void receivedData(const QString &msg,const QHostAddress &src_addr); + + private: + RDMulticaster *mcast_multicaster; +}; + + +#endif // MCAST_RECV_TEST_H diff --git a/utils/rdrevert/rdrevert.cpp b/utils/rdrevert/rdrevert.cpp index 7ed52826..81682246 100644 --- a/utils/rdrevert/rdrevert.cpp +++ b/utils/rdrevert/rdrevert.cpp @@ -259,6 +259,10 @@ void MainObject::Revert(int schema) const case 275: Revert275(); break; + + case 276: + Revert276(); + break; } } @@ -825,6 +829,19 @@ void MainObject::Revert275() const } +void MainObject::Revert276() const +{ + QString sql; + RDSqlQuery *q; + + sql=QString("alter table SYSTEM drop column NOTIFICATION_ADDRESS"); + q=new RDSqlQuery(sql,false); + delete q; + + SetVersion(275); +} + + int MainObject::GetVersion() const { QString sql; @@ -871,6 +888,7 @@ int MainObject::MapSchema(const QString &ver) version_map["2.17"]=268; version_map["2.18"]=272; version_map["2.19"]=275; + version_map["2.20"]=276; // // Normalize String diff --git a/utils/rdrevert/rdrevert.h b/utils/rdrevert/rdrevert.h index fef42872..dfe1e7cd 100644 --- a/utils/rdrevert/rdrevert.h +++ b/utils/rdrevert/rdrevert.h @@ -71,6 +71,7 @@ class MainObject : public QObject void Revert273() const; void Revert274() const; void Revert275() const; + void Revert276() const; int GetVersion() const; void SetVersion(int schema) const; int MapSchema(const QString &ver);