3 #include <QDomDocument>
4 #include <QImageReader>
28 #define LOC QString("RSSEditor: ")
29 #define LOC_WARN QString("RSSEditor, Warning: ")
30 #define LOC_ERR QString("RSSEditor, Error: ")
34 const QString CEID_NEWIMAGE =
"image";
36 QStringList GetSupportedImageExtensionFilter()
40 QList<QByteArray> exts = QImageReader::supportedImageFormats();
41 for (
const auto & ext : qAsConst(exts))
42 ret.append(QString(
"*.").append(ext));
80 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'rsseditpopup'");
103 if (!thumb.isEmpty())
160 connect(
m_manager, &QNetworkAccessManager::finished,
this,
166 const QUrl& oldRedirectUrl)
169 if(!possibleRedirectUrl.isEmpty() && possibleRedirectUrl != oldRedirectUrl)
176 QVariant possibleRedirectUrl =
177 reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
179 QUrl urlRedirectedTo;
181 possibleRedirectUrl.toUrl(), urlRedirectedTo);
183 if (!urlRedirectedTo.isEmpty())
186 m_manager->get(QNetworkRequest(urlRedirectedTo));
193 reply->deleteLater();
198 QDomDocument document;
199 document.setContent(reply->read(reply->bytesAvailable()),
true);
201 QString text = document.toString();
208 LOG(VB_GENERAL, LOG_DEBUG, QString(
"Text to Parse: %1").arg(text));
210 QDomElement root = document.documentElement();
211 QDomElement channel = root.firstChildElement (
"channel");
212 if (!channel.isNull())
216 title = channel.firstChildElement(
"title").text().trimmed();
217 if (description.isEmpty())
218 description = channel.firstChildElement(
"description").text();
219 if (author.isEmpty())
221 if (author.isEmpty())
222 author = channel.firstChildElement(
"managingEditor").text();
223 if (author.isEmpty())
224 author = channel.firstChildElement(
"webMaster").text();
226 QString thumbnailURL =
227 channel.firstChildElement(
"image").attribute(
"url");
228 if (thumbnailURL.isEmpty())
230 QDomElement thumbElem = channel.firstChildElement(
"image");
231 if (!thumbElem.isNull())
232 thumbnailURL = thumbElem.firstChildElement(
"url").text();
234 if (thumbnailURL.isEmpty())
236 QDomNodeList nodes = channel.elementsByTagNameNS(
237 "http://www.itunes.com/dtds/podcast-1.0.dtd",
242 nodes.at(0).toElement().attributeNode(
"href").value();
243 if (thumbnailURL.isEmpty())
244 thumbnailURL = nodes.at(0).toElement().text();
253 else if (!thumbnailURL.isEmpty())
275 QObject &inst,
const QString &returnEvent)
280 fb->SetNameFilter(GetSupportedImageExtensionFilter());
283 fb->SetReturnEvent(&inst, returnEvent);
295 if ((dce !=
nullptr) && (dce->GetId() == CEID_NEWIMAGE))
306 QMutexLocker locker(&
m_lock);
314 QMutexLocker locker(&
m_lock);
336 LOG(VB_GENERAL, LOG_ERR,
"Cannot load screen 'rsseditor'");
393 for (
int i = 0; i < actions.size() && !handled; i++)
395 QString
action = actions[i];
419 QMutexLocker locker(&
m_lock);
423 for (
const auto & site : qAsConst(
m_siteList))
426 item->SetText(site->GetTitle(),
"title");
427 item->SetText(site->GetDescription(),
"description");
428 item->SetText(site->GetURL(),
"url");
429 item->SetText(site->GetAuthor(),
"author");
430 item->SetData(QVariant::fromValue(site));
431 item->SetImage(site->GetImage());
442 const QString& thumb = site->
GetImage();
446 if (!thumb.isEmpty())
465 QMutexLocker locker(&
m_lock);
468 tr(
"Are you sure you want to unsubscribe from this feed?");
475 if (confirmdialog->Create())
483 delete confirmdialog;
488 QMutexLocker locker(&
m_lock);
496 new RSSEditPopup(site->GetURL(),
true, mainStack,
"rsseditpopup");
498 if (rsseditpopup->Create())
511 QMutexLocker locker(&
m_lock);
515 auto *rsseditpopup =
new RSSEditPopup(
"",
false, mainStack,
"rsseditpopup");
517 if (rsseditpopup->Create())
529 QMutexLocker locker(&
m_lock);