2018-11-04 09:48:33 -05:00
|
|
|
/*******************************************************************************
|
|
|
|
* plugins/FeedReader/gui/FeedReaderStringDefs.cpp *
|
|
|
|
* *
|
|
|
|
* Copyright (C) 2012 by Thunder <retroshare.project@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* 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 Affero General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2012-08-13 17:35:11 -04:00
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
|
|
#include "FeedReaderStringDefs.h"
|
|
|
|
|
|
|
|
bool FeedReaderStringDefs::showError(QWidget *parent, RsFeedAddResult result, const QString &title, const QString &text)
|
|
|
|
{
|
|
|
|
QString error;
|
|
|
|
|
|
|
|
switch (result) {
|
|
|
|
case RS_FEED_ADD_RESULT_SUCCESS:
|
|
|
|
/* no error */
|
|
|
|
return false;
|
|
|
|
case RS_FEED_ADD_RESULT_FEED_NOT_FOUND:
|
|
|
|
error = QApplication::translate("FeedReaderStringDefs", "Feed not found.");
|
|
|
|
break;
|
|
|
|
case RS_FEED_ADD_RESULT_PARENT_NOT_FOUND:
|
|
|
|
error = QApplication::translate("FeedReaderStringDefs", "Parent not found.");
|
|
|
|
break;
|
|
|
|
case RS_FEED_ADD_RESULT_PARENT_IS_NO_FOLDER:
|
|
|
|
error = QApplication::translate("FeedReaderStringDefs", "Parent is no folder.");
|
|
|
|
break;
|
|
|
|
case RS_FEED_ADD_RESULT_FEED_IS_FOLDER:
|
|
|
|
error = QApplication::translate("FeedReaderStringDefs", "Feed is a folder.");
|
|
|
|
break;
|
|
|
|
case RS_FEED_ADD_RESULT_FEED_IS_NO_FOLDER:
|
|
|
|
error = QApplication::translate("FeedReaderStringDefs", "Feed is no folder.");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = QApplication::translate("FeedReaderStringDefs", "Unknown error occured.");
|
|
|
|
}
|
|
|
|
|
|
|
|
QMessageBox::critical(parent, title, text + "\n" + error);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString FeedReaderStringDefs::workState(FeedInfo::WorkState state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
case FeedInfo::WAITING:
|
|
|
|
return "";
|
|
|
|
case FeedInfo::WAITING_TO_DOWNLOAD:
|
|
|
|
return QApplication::translate("FeedReaderStringDefs", "Waiting for download");
|
|
|
|
case FeedInfo::DOWNLOADING:
|
|
|
|
return QApplication::translate("FeedReaderStringDefs", "Downloading");
|
|
|
|
case FeedInfo::WAITING_TO_PROCESS:
|
|
|
|
return QApplication::translate("FeedReaderStringDefs", "Waiting for process");
|
|
|
|
case FeedInfo::PROCESSING:
|
|
|
|
return QApplication::translate("FeedReaderStringDefs", "Processing");
|
|
|
|
}
|
|
|
|
|
2013-01-21 19:11:43 -05:00
|
|
|
return QApplication::translate("FeedReaderStringDefs", "Unknown");
|
2012-08-13 17:35:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
QString FeedReaderStringDefs::errorString(const FeedInfo &feedInfo)
|
|
|
|
{
|
2012-09-04 19:53:04 -04:00
|
|
|
return errorString(feedInfo.errorState, feedInfo.errorString);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString FeedReaderStringDefs::errorString(RsFeedReaderErrorState errorState, const std::string &errorString)
|
|
|
|
{
|
|
|
|
QString errorText;
|
|
|
|
switch (errorState) {
|
2012-08-13 17:35:11 -04:00
|
|
|
case RS_FEED_ERRORSTATE_OK:
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* download */
|
|
|
|
case RS_FEED_ERRORSTATE_DOWNLOAD_INTERNAL_ERROR:
|
2012-09-04 19:53:04 -04:00
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "Internal download error");
|
2012-08-13 17:35:11 -04:00
|
|
|
break;
|
|
|
|
case RS_FEED_ERRORSTATE_DOWNLOAD_ERROR:
|
2012-09-04 19:53:04 -04:00
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "Download error");
|
2012-08-13 17:35:11 -04:00
|
|
|
break;
|
|
|
|
case RS_FEED_ERRORSTATE_DOWNLOAD_UNKNOWN_CONTENT_TYPE:
|
2012-09-04 19:53:04 -04:00
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "Unknown content type");
|
2012-08-13 17:35:11 -04:00
|
|
|
break;
|
|
|
|
case RS_FEED_ERRORSTATE_DOWNLOAD_NOT_FOUND:
|
2012-09-04 19:53:04 -04:00
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "Download not found");
|
2012-08-13 17:35:11 -04:00
|
|
|
break;
|
|
|
|
case RS_FEED_ERRORSTATE_DOWNLOAD_UNKOWN_RESPONSE_CODE:
|
2012-09-04 19:53:04 -04:00
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "Unknown response code");
|
2012-08-13 17:35:11 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* process */
|
|
|
|
case RS_FEED_ERRORSTATE_PROCESS_INTERNAL_ERROR:
|
2012-09-04 19:53:04 -04:00
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "Internal process error");
|
2012-08-13 17:35:11 -04:00
|
|
|
break;
|
|
|
|
case RS_FEED_ERRORSTATE_PROCESS_UNKNOWN_FORMAT:
|
2012-09-04 19:53:04 -04:00
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "Unknown XML format");
|
2012-08-13 17:35:11 -04:00
|
|
|
break;
|
|
|
|
case RS_FEED_ERRORSTATE_PROCESS_FORUM_CREATE:
|
2012-09-04 19:53:04 -04:00
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "Can't create forum");
|
2012-08-13 17:35:11 -04:00
|
|
|
break;
|
|
|
|
case RS_FEED_ERRORSTATE_PROCESS_FORUM_NOT_FOUND:
|
2012-09-04 19:53:04 -04:00
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "Forum not found");
|
2012-08-13 17:35:11 -04:00
|
|
|
break;
|
|
|
|
case RS_FEED_ERRORSTATE_PROCESS_FORUM_NO_ADMIN:
|
2012-09-04 19:53:04 -04:00
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "You are not admin of the forum");
|
2012-08-13 17:35:11 -04:00
|
|
|
break;
|
2015-06-09 14:03:09 -04:00
|
|
|
case RS_FEED_ERRORSTATE_PROCESS_FORUM_NO_AUTHOR:
|
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "Forum has no author");
|
|
|
|
break;
|
2012-09-04 19:53:04 -04:00
|
|
|
|
|
|
|
case RS_FEED_ERRORSTATE_PROCESS_HTML_ERROR:
|
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "Can't read html");
|
|
|
|
break;
|
|
|
|
case RS_FEED_ERRORSTATE_PROCESS_XPATH_INTERNAL_ERROR:
|
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "Internal XPath error");
|
|
|
|
break;
|
|
|
|
case RS_FEED_ERRORSTATE_PROCESS_XPATH_WRONG_EXPRESSION:
|
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "Wrong XPath expression");
|
|
|
|
break;
|
|
|
|
case RS_FEED_ERRORSTATE_PROCESS_XPATH_NO_RESULT:
|
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "Empty XPath result");
|
2012-08-13 17:35:11 -04:00
|
|
|
break;
|
2013-01-21 19:11:43 -05:00
|
|
|
case RS_FEED_ERRORSTATE_PROCESS_XSLT_FORMAT_ERROR:
|
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "XSLT format error");
|
|
|
|
break;
|
|
|
|
case RS_FEED_ERRORSTATE_PROCESS_XSLT_TRANSFORM_ERROR:
|
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "XSLT transformation error");
|
|
|
|
break;
|
|
|
|
case RS_FEED_ERRORSTATE_PROCESS_XSLT_NO_RESULT:
|
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "Empty XSLT result");
|
|
|
|
break;
|
2012-08-13 17:35:11 -04:00
|
|
|
|
|
|
|
default:
|
2012-09-04 19:53:04 -04:00
|
|
|
errorText = QApplication::translate("FeedReaderStringDefs", "Unknown error");
|
2012-08-13 17:35:11 -04:00
|
|
|
}
|
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
if (!errorString.empty()) {
|
|
|
|
errorText += QString(" (%1)").arg(QString::fromUtf8(errorString.c_str()));
|
2012-08-13 17:35:11 -04:00
|
|
|
}
|
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
return errorText;
|
2012-08-13 17:35:11 -04:00
|
|
|
}
|
2013-01-21 19:11:43 -05:00
|
|
|
|
|
|
|
QString FeedReaderStringDefs::transforationTypeString(RsFeedTransformationType transformationType)
|
|
|
|
{
|
|
|
|
switch (transformationType) {
|
|
|
|
case RS_FEED_TRANSFORMATION_TYPE_NONE:
|
|
|
|
return QApplication::translate("FeedReaderStringDefs", "No transformation");
|
|
|
|
case RS_FEED_TRANSFORMATION_TYPE_XPATH:
|
|
|
|
return QApplication::translate("FeedReaderStringDefs", "XPath");
|
|
|
|
case RS_FEED_TRANSFORMATION_TYPE_XSLT:
|
|
|
|
return QApplication::translate("FeedReaderStringDefs", "XSLT");
|
|
|
|
}
|
|
|
|
|
|
|
|
return QApplication::translate("FeedReaderStringDefs", "Unknown");
|
|
|
|
}
|