mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-28 14:42:34 +02:00
2018-03-21 Fred Gleason <fredg@paravelsystems.com>
* Added support for cart notifications to the RDXport service. * Added support for notifications to rdimport(1).
This commit is contained in:
parent
e3fb53d0cf
commit
471c6498fd
@ -16725,3 +16725,6 @@
|
||||
* Added an 'RDRipc::notificationReceived()' signal.
|
||||
2018-03-21 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added support for notifications to rdlibrary(1).
|
||||
2018-03-21 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added support for cart notifications to the RDXport service.
|
||||
* Added support for notifications to rdimport(1).
|
||||
|
@ -29,6 +29,14 @@ RDNotification::RDNotification(RDNotification::Type type,
|
||||
}
|
||||
|
||||
|
||||
RDNotification::RDNotification(Type type,Action action,const QVariant &id)
|
||||
{
|
||||
notify_type=type;
|
||||
notify_action=action;
|
||||
notify_id=id;
|
||||
}
|
||||
|
||||
|
||||
RDNotification::RDNotification()
|
||||
{
|
||||
notify_type=RDNotification::NullType;
|
||||
|
@ -31,6 +31,7 @@ class RDNotification
|
||||
enum Action {NoAction=0,AddAction=1,DeleteAction=2,ModifyAction=3,
|
||||
LastAction=4};
|
||||
RDNotification(Type type,Action action,unsigned cartnum);
|
||||
RDNotification(Type type,Action action,const QVariant &id);
|
||||
RDNotification();
|
||||
Type type() const;
|
||||
void setType(Type type);
|
||||
|
@ -1339,6 +1339,12 @@ MainObject::Result MainObject::ImportFile(const QString &filename,
|
||||
cut->setFadeupPoint(import_fadeup_marker->fadeValue(lo,hi));
|
||||
}
|
||||
cart->updateLength();
|
||||
if(cart_created) {
|
||||
SendNotification(RDNotification::AddAction,cart->number());
|
||||
}
|
||||
else {
|
||||
SendNotification(RDNotification::ModifyAction,cart->number());
|
||||
}
|
||||
delete settings;
|
||||
delete conv;
|
||||
delete cut;
|
||||
@ -2018,6 +2024,17 @@ void MainObject::ReadXmlFile(const QString &basename,RDWaveData *wavedata) const
|
||||
}
|
||||
|
||||
|
||||
void MainObject::SendNotification(RDNotification::Action action,
|
||||
unsigned cartnum)
|
||||
{
|
||||
RDNotification *notify=
|
||||
new RDNotification(RDNotification::CartType,action,QVariant(cartnum));
|
||||
rda->ripc()->sendNotification(*notify);
|
||||
qApp->processEvents();
|
||||
delete notify;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
QApplication a(argc,argv,false);
|
||||
|
@ -29,11 +29,12 @@
|
||||
#include <qfileinfo.h>
|
||||
#include <qdatetime.h>
|
||||
|
||||
#include <rdwavedata.h>
|
||||
#include <rdwavefile.h>
|
||||
#include <rdgroup.h>
|
||||
#include <rdcart.h>
|
||||
#include <rdcut.h>
|
||||
#include <rdgroup.h>
|
||||
#include <rdnotification.h>
|
||||
#include <rdwavedata.h>
|
||||
#include <rdwavefile.h>
|
||||
|
||||
#include "markerset.h"
|
||||
|
||||
@ -73,6 +74,7 @@ class MainObject : public QObject
|
||||
void WriteTimestampCache(const QString &filename,const QDateTime &dt);
|
||||
bool SchedulerCodeExists(const QString &code) const;
|
||||
void ReadXmlFile(const QString &basename,RDWaveData *wavedata) const;
|
||||
void SendNotification(RDNotification::Action action,unsigned cartnum);
|
||||
unsigned import_file_key;
|
||||
RDGroup *import_group;
|
||||
bool import_verbose;
|
||||
|
@ -23,6 +23,10 @@ AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -DQTDIR=\"@QT_DIR@\" @QT_CXXFLAGS@ -I
|
||||
LIBS = @QT_LIBS@ -L$(top_srcdir)/lib
|
||||
MOC = @QT_MOC@
|
||||
|
||||
# The dependency for qt's Meta Object Compiler (moc)
|
||||
moc_%.cpp: %.h
|
||||
$(MOC) $< -o $@
|
||||
|
||||
libexec_PROGRAMS = rdxport.cgi
|
||||
|
||||
install-exec-hook:
|
||||
@ -45,6 +49,8 @@ dist_rdxport_cgi_SOURCES = audioinfo.cpp\
|
||||
systemsettings.cpp\
|
||||
trimaudio.cpp
|
||||
|
||||
nodist_rdxport_cgi_SOURCES = moc_rdxport.cpp
|
||||
|
||||
rdxport_cgi_LDADD = @LIB_RDLIBS@ -lsndfile @LIBVORBIS@
|
||||
|
||||
EXTRA_DIST = rdxport.pro
|
||||
|
@ -108,6 +108,8 @@ void Xport::AddCart()
|
||||
printf("<cartAdd>\n");
|
||||
if(cart->exists()) {
|
||||
printf("%s",(const char *)cart->xml(false,true));
|
||||
SendNotification(RDNotification::CartType,RDNotification::AddAction,
|
||||
QVariant(cart->number()));
|
||||
}
|
||||
delete cart;
|
||||
printf("</cartAdd>\n");
|
||||
@ -394,6 +396,8 @@ void Xport::EditCart()
|
||||
printf("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
|
||||
printf("<cartList>\n");
|
||||
printf("%s",(const char *)cart->xml(include_cuts,true));
|
||||
SendNotification(RDNotification::CartType,RDNotification::ModifyAction,
|
||||
QVariant(cart->number()));
|
||||
delete cart;
|
||||
printf("</cartList>\n");
|
||||
|
||||
@ -435,6 +439,8 @@ void Xport::RemoveCart()
|
||||
delete cart;
|
||||
XmlExit("Unable to delete cart",500,"carts.cpp",LINE_NUMBER);
|
||||
}
|
||||
SendNotification(RDNotification::CartType,RDNotification::DeleteAction,
|
||||
QVariant(cart->number()));
|
||||
delete cart;
|
||||
XmlExit("OK",200,"carts.cpp",LINE_NUMBER);
|
||||
}
|
||||
@ -483,6 +489,8 @@ void Xport::AddCut()
|
||||
cut=new RDCut(cart_number,cut_number);
|
||||
if(cut->exists()) {
|
||||
printf("%s",(const char *)RDCart::cutXml(cart_number,cut_number,true));
|
||||
SendNotification(RDNotification::CartType,RDNotification::ModifyAction,
|
||||
QVariant(cart->number()));
|
||||
}
|
||||
delete cut;
|
||||
delete cart;
|
||||
@ -843,6 +851,8 @@ void Xport::EditCut()
|
||||
printf("<cutList>\n");
|
||||
printf("%s",(const char *)RDCart::cutXml(cart_number,cut_number,true));
|
||||
printf("</cutList>\n");
|
||||
SendNotification(RDNotification::CartType,RDNotification::ModifyAction,
|
||||
QVariant(cut->cartNumber()));
|
||||
delete cut;
|
||||
|
||||
Exit(0);
|
||||
@ -934,6 +944,8 @@ void Xport::RemoveCut()
|
||||
delete cart;
|
||||
XmlExit("No such cut",404);
|
||||
}
|
||||
SendNotification(RDNotification::CartType,RDNotification::ModifyAction,
|
||||
QVariant(cart->number()));
|
||||
delete cart;
|
||||
XmlExit("OK",200);
|
||||
}
|
||||
|
@ -77,5 +77,7 @@ void Xport::CopyAudio()
|
||||
RDCut::pathName(destination_cartnum,destination_cutnum))!=0) {
|
||||
XmlExit(strerror(errno),400,"copyaudio.cpp",LINE_NUMBER);
|
||||
}
|
||||
SendNotification(RDNotification::CartType,RDNotification::ModifyAction,
|
||||
QVariant(destination_cartnum));
|
||||
XmlExit("OK",200,"copyaudio.cpp",LINE_NUMBER);
|
||||
}
|
||||
|
@ -63,6 +63,8 @@ void Xport::DeleteAudio()
|
||||
"CUT_NAME=\""+RDCut::cutName(cartnum,cutnum)+"\"";
|
||||
RDSqlQuery *q=new RDSqlQuery(sql);
|
||||
delete q;
|
||||
SendNotification(RDNotification::CartType,RDNotification::ModifyAction,
|
||||
QVariant(cartnum));
|
||||
syslog(LOG_NOTICE,"unlink(%s): %s",(const char *)RDCut::pathName(cartnum,cutnum),strerror(errno));
|
||||
delete cut;
|
||||
XmlExit("OK",200,"deleteaudio.cpp",LINE_NUMBER);
|
||||
|
@ -154,6 +154,8 @@ void Xport::Import()
|
||||
XmlExit("Unable to create cart ["+err_msg+"]",500,"import.cpp",
|
||||
LINE_NUMBER);
|
||||
}
|
||||
SendNotification(RDNotification::CartType,RDNotification::AddAction,
|
||||
QVariant(cartnum));
|
||||
cutnum=1;
|
||||
cut=new RDCut(cartnum,cutnum,true);
|
||||
delete group;
|
||||
@ -267,6 +269,8 @@ void Xport::Import()
|
||||
printf(" <CartNumber>%d</CartNumber>\r\n",cartnum);
|
||||
printf(" <CutNumber>%d</CutNumber>\r\n",cutnum);
|
||||
printf("</RDWebResult>\r\n");
|
||||
SendNotification(RDNotification::CartType,RDNotification::ModifyAction,
|
||||
QVariant(cartnum));
|
||||
unlink(filename);
|
||||
rmdir(xport_post->tempDir());
|
||||
exit(0);
|
||||
|
@ -128,6 +128,23 @@ Xport::Xport(QObject *parent)
|
||||
XmlExit("Invalid User",403,"rdxport.cpp",LINE_NUMBER);
|
||||
}
|
||||
|
||||
//
|
||||
// Connect to ripcd(8)
|
||||
//
|
||||
connect(rda->ripc(),SIGNAL(connected(bool)),
|
||||
this,SLOT(ripcConnectedData(bool)));
|
||||
rda->ripc()->
|
||||
connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
|
||||
}
|
||||
|
||||
|
||||
void Xport::ripcConnectedData(bool state)
|
||||
{
|
||||
if(!state) {
|
||||
XmlExit("unable to connect to ripc service",500,"rdxport.cpp",LINE_NUMBER);
|
||||
Exit(0);
|
||||
}
|
||||
|
||||
//
|
||||
// Read Command Variable and Dispatch
|
||||
//
|
||||
@ -393,6 +410,16 @@ void Xport::TryCreateTicket(const QString &name)
|
||||
}
|
||||
|
||||
|
||||
void Xport::SendNotification(RDNotification::Type type,
|
||||
RDNotification::Action action,const QVariant &id)
|
||||
{
|
||||
RDNotification *notify=new RDNotification(type,action,id);
|
||||
rda->ripc()->sendNotification(*notify);
|
||||
qApp->processEvents();
|
||||
delete notify;
|
||||
}
|
||||
|
||||
|
||||
void Xport::Exit(int code)
|
||||
{
|
||||
if(xport_post!=NULL) {
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include <rdaudioconvert.h>
|
||||
#include <rdformpost.h>
|
||||
#include <rdnotification.h>
|
||||
#include <rdsvc.h>
|
||||
|
||||
#define RDXPORT_CGI_USAGE "\n"
|
||||
@ -34,10 +35,14 @@
|
||||
|
||||
class Xport : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
enum LockLogOperation {LockLogCreate=0,LockLogUpdate=1,LockLogClear=2};
|
||||
Xport(QObject *parent=0);
|
||||
|
||||
private slots:
|
||||
void ripcConnectedData(bool state);
|
||||
|
||||
private:
|
||||
bool Authenticate();
|
||||
void TryCreateTicket(const QString &name);
|
||||
@ -81,6 +86,8 @@ class Xport : public QObject
|
||||
QString LogLockXml(bool result,const QString &log_name,const QString &guid,
|
||||
const QString &username,const QString &stationname,
|
||||
const QHostAddress addr) const;
|
||||
void SendNotification(RDNotification::Type type,RDNotification::Action action,
|
||||
const QVariant &id);
|
||||
void Exit(int code);
|
||||
void XmlExit(const QString &msg,int code,
|
||||
const QString &srcfile="",int line=-1,
|
||||
|
@ -93,5 +93,7 @@ void Xport::TrimAudio()
|
||||
}
|
||||
printf(" <endTrimPoint>%d</endTrimPoint>\n",point);
|
||||
printf("</trimPoint>\n");
|
||||
SendNotification(RDNotification::CartType,RDNotification::ModifyAction,
|
||||
QVariant(cartnum));
|
||||
Exit(0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user