2020-08-08 Fred Gleason <fredg@paravelsystems.com>

* Implemented multicast notifications for RSS feed items.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2020-08-08 17:38:16 -04:00
parent 9a428ad855
commit b4cd2117ec
7 changed files with 113 additions and 3 deletions

View File

@@ -20178,3 +20178,5 @@
dialog in rdcastmanager(1).
* Added a 'Posted By' column to the 'Podcast Item List' dialog in
rdcastmanager(1).
2020-08-08 Fred Gleason <fredg@paravelsystems.com>
* Implemented multicast notifications for RSS feed items.

View File

@@ -2,7 +2,7 @@
//
// A container class for a Rivendell Notification message.
//
// (C) Copyright 2018-2019 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2018-2020 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
@@ -115,6 +115,10 @@ bool RDNotification::read(const QString &str)
notify_id=QVariant(args[3].toUInt());
break;
case RDNotification::FeedItemType:
notify_id=QVariant(args[3].toUInt());
break;
case RDNotification::NullType:
case RDNotification::LastType:
break;
@@ -166,6 +170,10 @@ QString RDNotification::write() const
ret+=QString().sprintf("%u",notify_id.toUInt());
break;
case RDNotification::FeedItemType:
ret+=QString().sprintf("%u",notify_id.toUInt());
break;
case RDNotification::NullType:
case RDNotification::LastType:
break;
@@ -199,6 +207,10 @@ QString RDNotification::typeString(RDNotification::Type type)
ret="CATCH_EVENT";
break;
case RDNotification::FeedItemType:
ret="FEED_ITEM";
break;
case RDNotification::NullType:
case RDNotification::LastType:
break;

View File

@@ -2,7 +2,7 @@
//
// A container class for a Rivendell Notification message.
//
// (C) Copyright 2018-2019 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2018-2020 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
@@ -28,7 +28,7 @@ class RDNotification
{
public:
enum Type {NullType=0,CartType=1,LogType=2,PypadType=3,DropboxType=4,
CatchEventType=5,LastType=6};
CatchEventType=5,FeedItemType=6,LastType=7};
enum Action {NoAction=0,AddAction=1,DeleteAction=2,ModifyAction=3,
LastAction=4};
RDNotification(Type type,Action action,const QVariant &id);

View File

@@ -356,6 +356,11 @@ void EditCast::okData()
if(!cast_feed->postXmlConditional("RDCastManager",this)) {
return;
}
RDNotification *notify=new RDNotification(RDNotification::FeedItemType,
RDNotification::ModifyAction,
cast_cast->id());
rda->ripc()->sendNotification(*notify);
delete notify;
done(0);
}

View File

@@ -27,6 +27,7 @@
#include <rdcut_dialog.h>
#include <rdescape_string.h>
#include <rdlist_logs.h>
#include <rdpodcast.h>
#include "edit_cast.h"
#include "globals.h"
@@ -60,6 +61,12 @@ ListCasts::ListCasts(unsigned feed_id,bool is_super,QWidget *parent)
list_redball_map=new QPixmap(redball_xpm);
list_whiteball_map=new QPixmap(whiteball_xpm);
//
// Notifications
//
connect(rda->ripc(),SIGNAL(notificationReceived(RDNotification *)),
this,SLOT(notificationReceivedData(RDNotification *)));
//
// The Feed
//
@@ -247,6 +254,11 @@ void ListCasts::addCartData()
list_casts_view->setSelected(item,true);
list_casts_view->ensureItemVisible(item);
delete edit_cast;
RDNotification *notify=new RDNotification(RDNotification::FeedItemType,
RDNotification::AddAction,cast_id);
rda->ripc()->sendNotification(*notify);
delete notify;
}
@@ -272,6 +284,11 @@ void ListCasts::addFileData()
list_casts_view->setSelected(item,true);
list_casts_view->ensureItemVisible(item);
delete edit_cast;
RDNotification *notify=new RDNotification(RDNotification::FeedItemType,
RDNotification::AddAction,cast_id);
rda->ripc()->sendNotification(*notify);
delete notify;
}
@@ -317,6 +334,11 @@ void ListCasts::addLogData()
}
}
delete d;
RDNotification *notify=new RDNotification(RDNotification::FeedItemType,
RDNotification::AddAction,cast_id);
rda->ripc()->sendNotification(*notify);
delete notify;
}
@@ -344,6 +366,7 @@ void ListCasts::deleteData()
if(item==NULL) {
return;
}
unsigned cast_id=item->id();
if(QMessageBox::question(this,"RDCastManager - "+tr("Delete Podcast"),
tr("Are you sure you want to delete this podcast?"),
QMessageBox::Yes,QMessageBox::No)==
@@ -394,6 +417,11 @@ void ListCasts::deleteData()
delete pd;
delete cast;
delete item;
RDNotification *notify=new RDNotification(RDNotification::FeedItemType,
RDNotification::DeleteAction,cast_id);
rda->ripc()->sendNotification(*notify);
delete notify;
}
@@ -470,6 +498,57 @@ void ListCasts::resizeEvent(QResizeEvent *e)
}
void ListCasts::notificationReceivedData(RDNotification *notify)
{
unsigned cast_id=0;
RDListViewItem *item=NULL;
RDPodcast *cast=NULL;
if(notify->type()==RDNotification::FeedItemType) {
cast_id=notify->id().toUInt();
switch(notify->action()) {
case RDNotification::AddAction:
cast=new RDPodcast(rda->config(),cast_id);
if(cast->keyName()==list_feed->keyName()) {
item=new RDListViewItem(list_casts_view);
item->setId(cast_id);
RefreshItem(item);
delete cast;
return;
}
delete cast;
break;
case RDNotification::DeleteAction:
item=(RDListViewItem *)list_casts_view->firstChild();
while(item!=NULL) {
if(item->id()==(int)cast_id) {
delete item;
return;
}
item=(RDListViewItem *)item->nextSibling();
}
break;
case RDNotification::ModifyAction:
item=(RDListViewItem *)list_casts_view->firstChild();
while(item!=NULL) {
if(item->id()==(int)cast_id) {
RefreshItem(item);
}
item=(RDListViewItem *)item->nextSibling();
}
break;
case RDNotification::LastAction:
case RDNotification::NoAction:
break;
}
}
}
void ListCasts::RefreshList()
{
QString sql;

View File

@@ -52,6 +52,7 @@ class ListCasts : public RDDialog
void activeToggledData(bool state);
void postProgressChangedData(int step);
void closeData();
void notificationReceivedData(RDNotification *notify);
protected:
void resizeEvent(QResizeEvent *e);

View File

@@ -84,6 +84,12 @@ MainObject::MainObject(QObject *parent)
}
}
//
// Connect to ripcd(8)
//
rda->ripc()->
connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
//
// Scan Timer
//
@@ -157,6 +163,11 @@ void MainObject::ProcessFeed(const QString &key_name)
q->value(0).toUInt(),cast->itemTitle().toUtf8().constData(),
feed->keyName().toUtf8().constData());
delete cast;
RDNotification *notify=new RDNotification(RDNotification::FeedItemType,
RDNotification::DeleteAction,
q->value(0).toUInt());
rda->ripc()->sendNotification(*notify);
delete notify;
}
if(feed->postXml(&err_msg)) {
rda->syslog(LOG_DEBUG,