mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2026-01-11 15:16:07 +01:00
2018-03-11 Fred Gleason <fredg@paravelsystems.com>
* 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.
This commit is contained in:
@@ -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@
|
||||
|
||||
|
||||
104
tests/mcast_recv_test.cpp
Normal file
104
tests/mcast_recv_test.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
// mcast_recv_test.cpp
|
||||
//
|
||||
// Test the Rivendell multicast receiver routines
|
||||
//
|
||||
// (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qhostaddress.h>
|
||||
#include <qstringlist.h>
|
||||
|
||||
#include <rdcmd_switch.h>
|
||||
|
||||
#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;i<cmd->keys();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();
|
||||
}
|
||||
44
tests/mcast_recv_test.h
Normal file
44
tests/mcast_recv_test.h
Normal file
@@ -0,0 +1,44 @@
|
||||
// mcast_recv_test.h
|
||||
//
|
||||
// Test the Rivendell multicast receiver routines
|
||||
//
|
||||
// (C) Copyright 2018 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#ifndef MCAST_RECV_TEST_H
|
||||
#define MCAST_RECV_TEST_H
|
||||
|
||||
#include <qobject.h>
|
||||
|
||||
#include <rdmulticaster.h>
|
||||
|
||||
#define MCAST_RECV_TEST_USAGE "[options]\n\nTest the Rivendell multicast receiver routines\n\nOptions are:\n--from=<mcast-addr>:<port>\n Subscribe to <mcast-addr> and listen on <port>.\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
|
||||
Reference in New Issue
Block a user