Work on ownCloud plugin.
This commit is contained in:
parent
d6ba170efd
commit
8488be7441
@ -90,7 +90,6 @@ FormMain::FormMain(QWidget *parent, Qt::WindowFlags f)
|
||||
|
||||
OwnCloudNetworkFactory fac;
|
||||
|
||||
fac.setAuthIsUsed(true);
|
||||
fac.setUrl("https://cloud.yarpen.cz");
|
||||
fac.setAuthPassword("rssguard135");
|
||||
fac.setAuthUsername("rssguard");
|
||||
|
@ -86,7 +86,7 @@ void FormUpdate::checkForUpdates() {
|
||||
|
||||
const bool is_self_update_for_this_system = isUpdateForThisSystem() && isSelfUpdateSupported();
|
||||
|
||||
if (SystemFactory::isUpdateNewer(update.first.m_availableVersion, APP_VERSION)) {
|
||||
if (SystemFactory::isVersionNewer(update.first.m_availableVersion, APP_VERSION)) {
|
||||
m_ui->m_lblStatus->setStatus(WidgetWithStatus::Ok,
|
||||
tr("New release available."),
|
||||
tr("This is new version which can be\ndownloaded and installed."));
|
||||
|
@ -206,7 +206,7 @@ QPair<UpdateInfo, QNetworkReply::NetworkError> SystemFactory::checkForUpdates()
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SystemFactory::isUpdateNewer(const QString &new_version, const QString &base_version) {
|
||||
bool SystemFactory::isVersionNewer(const QString &new_version, const QString &base_version) {
|
||||
QStringList base_version_tkn = base_version.split(QL1C('.'));
|
||||
QStringList new_version_tkn = new_version.split(QL1C('.'));
|
||||
|
||||
@ -238,6 +238,10 @@ bool SystemFactory::isUpdateNewer(const QString &new_version, const QString &bas
|
||||
}
|
||||
}
|
||||
|
||||
bool SystemFactory::isVersionEqualOrNewer(const QString &new_version, const QString &base_version) {
|
||||
return new_version == base_version || isVersionNewer(new_version, base_version);
|
||||
}
|
||||
|
||||
UpdateInfo SystemFactory::parseUpdatesFile(const QByteArray &updates_file, const QByteArray &changelog) const {
|
||||
UpdateInfo update;
|
||||
QDomDocument document; document.setContent(updates_file, false);
|
||||
@ -273,7 +277,7 @@ UpdateInfo SystemFactory::parseUpdatesFile(const QByteArray &updates_file, const
|
||||
void SystemFactory::checkForUpdatesOnStartup() {
|
||||
const UpdateCheck updates = checkForUpdates();
|
||||
|
||||
if (updates.second == QNetworkReply::NoError && isUpdateNewer(updates.first.m_availableVersion,
|
||||
if (updates.second == QNetworkReply::NoError && isVersionNewer(updates.first.m_availableVersion,
|
||||
APP_VERSION)) {
|
||||
qApp->showGuiMessage(tr("New version available"),
|
||||
tr("Click the bubble for more information."),
|
||||
|
@ -87,7 +87,8 @@ class SystemFactory : public QObject {
|
||||
QPair<UpdateInfo, QNetworkReply::NetworkError> checkForUpdates() const;
|
||||
|
||||
// Checks if update is newer than current application version.
|
||||
static bool isUpdateNewer(const QString &new_version, const QString &base_version);
|
||||
static bool isVersionNewer(const QString &new_version, const QString &base_version);
|
||||
static bool isVersionEqualOrNewer(const QString &new_version, const QString &base_version);
|
||||
|
||||
public slots:
|
||||
void checkForUpdatesOnStartup();
|
||||
|
@ -81,12 +81,11 @@ void FormEditOwnCloudAccount::execForEdit(OwnCloudServiceRoot *existing_root) {
|
||||
setWindowTitle(tr("Edit existing Tiny Tiny RSS account"));
|
||||
m_editableRoot = existing_root;
|
||||
|
||||
// TODO: todo
|
||||
/* m_ui->m_txtUsername->lineEdit()->setText(existing_root->network()->username());
|
||||
m_ui->m_txtPassword->lineEdit()->setText(existing_root->network()->password());
|
||||
m_ui->m_txtUsername->lineEdit()->setText(existing_root->network()->authUsername());
|
||||
m_ui->m_txtPassword->lineEdit()->setText(existing_root->network()->authPassword());
|
||||
m_ui->m_txtUrl->lineEdit()->setText(existing_root->network()->url());
|
||||
m_ui->m_checkServerSideUpdate->setChecked(existing_root->network()->forceServerSideUpdate());
|
||||
*/
|
||||
|
||||
exec();
|
||||
}
|
||||
|
||||
@ -95,62 +94,39 @@ void FormEditOwnCloudAccount::displayPassword(bool display) {
|
||||
}
|
||||
|
||||
void FormEditOwnCloudAccount::performTest() {
|
||||
// TODO: todo
|
||||
/*TtRssNetworkFactory factory;
|
||||
OwnCloudNetworkFactory factory;
|
||||
|
||||
factory.setUsername(m_ui->m_txtUsername->lineEdit()->text());
|
||||
factory.setPassword(m_ui->m_txtPassword->lineEdit()->text());
|
||||
factory.setAuthUsername(m_ui->m_txtUsername->lineEdit()->text());
|
||||
factory.setAuthPassword(m_ui->m_txtPassword->lineEdit()->text());
|
||||
factory.setUrl(m_ui->m_txtUrl->lineEdit()->text());
|
||||
factory.setAuthIsUsed(m_ui->m_gbHttpAuthentication->isChecked());
|
||||
factory.setAuthUsername(m_ui->m_txtHttpUsername->lineEdit()->text());
|
||||
factory.setAuthPassword(m_ui->m_txtHttpPassword->lineEdit()->text());
|
||||
factory.setForceServerSideUpdate(m_ui->m_checkServerSideUpdate->isChecked());
|
||||
|
||||
TtRssLoginResponse result = factory.login();
|
||||
OwnCloudStatusResponse result = factory.status();
|
||||
|
||||
if (result.isLoaded()) {
|
||||
if (result.hasError()) {
|
||||
QString error = result.error();
|
||||
|
||||
if (error == API_DISABLED) {
|
||||
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
|
||||
tr("API access on selected server is not enabled."),
|
||||
tr("API access on selected server is not enabled."));
|
||||
}
|
||||
else if (error == LOGIN_ERROR) {
|
||||
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
|
||||
tr("Entered credentials are incorrect."),
|
||||
tr("Entered credentials are incorrect."));
|
||||
}
|
||||
else {
|
||||
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
|
||||
tr("Other error occurred, contact developers."),
|
||||
tr("Other error occurred, contact developers."));
|
||||
}
|
||||
}
|
||||
else if (result.apiLevel() < MINIMAL_API_LEVEL) {
|
||||
if (SystemFactory::isVersionEqualOrNewer(result.version(), MINIMAL_OC_VERSION)) {
|
||||
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
|
||||
tr("Selected Tiny Tiny RSS server is running unsupported version of API (%1). At least API level %2 is required.").arg(QString::number(result.apiLevel()),
|
||||
QString::number(MINIMAL_API_LEVEL)),
|
||||
tr("Selected Tiny Tiny RSS server is running unsupported version of API."));
|
||||
tr("Selected ownCloud News server is running unsupported version (%1). At least version %2 is required.").arg(result.version(),
|
||||
MINIMAL_OC_VERSION),
|
||||
tr("Selected ownCloud News server is running unsupported version."));
|
||||
}
|
||||
else {
|
||||
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Ok,
|
||||
tr("Tiny Tiny RSS server is okay, running with API level %1, while at least API level %2 is required.").arg(QString::number(result.apiLevel()),
|
||||
QString::number(MINIMAL_API_LEVEL)),
|
||||
tr("Tiny Tiny RSS server is okay."));
|
||||
tr("OwnCloud News server is okay, running with version %1, while at least version %2 is required.").arg(result.version(),
|
||||
MINIMAL_OC_VERSION),
|
||||
tr("OwnCloud News server is okay."));
|
||||
}
|
||||
}
|
||||
else if (factory.lastError() != QNetworkReply::NoError ) {
|
||||
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
|
||||
tr("Network error: '%1'.").arg(NetworkFactory::networkErrorText(factory.lastError())),
|
||||
tr("Network error, have you entered correct Tiny Tiny RSS API endpoint and password?"));
|
||||
tr("Network error, have you entered correct ownCloud endpoint and password?"));
|
||||
}
|
||||
else {
|
||||
m_ui->m_lblTestResult->setStatus(WidgetWithStatus::Error,
|
||||
tr("Unspecified error, did you enter correct URL?"),
|
||||
tr("Unspecified error, did you enter correct URL?"));
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
void FormEditOwnCloudAccount::onClickedOk() {
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
|
||||
OwnCloudNetworkFactory::OwnCloudNetworkFactory()
|
||||
: m_url(QString()), m_forceServerSideUpdate(false), m_authIsUsed(false),
|
||||
: m_url(QString()), m_forceServerSideUpdate(false),
|
||||
m_authUsername(QString()), m_authPassword(QString()), m_urlUser(QString()), m_urlStatus(QString()) {
|
||||
}
|
||||
|
||||
@ -58,14 +58,6 @@ void OwnCloudNetworkFactory::setForceServerSideUpdate(bool force_update) {
|
||||
m_forceServerSideUpdate = force_update;
|
||||
}
|
||||
|
||||
bool OwnCloudNetworkFactory::authIsUsed() const {
|
||||
return m_authIsUsed;
|
||||
}
|
||||
|
||||
void OwnCloudNetworkFactory::setAuthIsUsed(bool authIsUsed) {
|
||||
m_authIsUsed = authIsUsed;
|
||||
}
|
||||
|
||||
QString OwnCloudNetworkFactory::authUsername() const {
|
||||
return m_authUsername;
|
||||
}
|
||||
@ -92,7 +84,7 @@ OwnCloudUserResponse OwnCloudNetworkFactory::userInfo() {
|
||||
qApp->settings()->value(GROUP(Feeds),
|
||||
SETTING(Feeds::UpdateTimeout)).toInt(),
|
||||
result_raw,
|
||||
m_authIsUsed, m_authUsername, m_authPassword,
|
||||
true, m_authUsername, m_authPassword,
|
||||
true);
|
||||
OwnCloudUserResponse user_response(QString::fromUtf8(result_raw));
|
||||
|
||||
@ -110,7 +102,7 @@ OwnCloudStatusResponse OwnCloudNetworkFactory::status() {
|
||||
qApp->settings()->value(GROUP(Feeds),
|
||||
SETTING(Feeds::UpdateTimeout)).toInt(),
|
||||
result_raw,
|
||||
m_authIsUsed, m_authUsername, m_authPassword,
|
||||
true, m_authUsername, m_authPassword,
|
||||
true);
|
||||
OwnCloudStatusResponse status_response(QString::fromUtf8(result_raw));
|
||||
|
||||
|
@ -69,9 +69,6 @@ class OwnCloudNetworkFactory {
|
||||
bool forceServerSideUpdate() const;
|
||||
void setForceServerSideUpdate(bool force_update);
|
||||
|
||||
bool authIsUsed() const;
|
||||
void setAuthIsUsed(bool authIsUsed);
|
||||
|
||||
QString authUsername() const;
|
||||
void setAuthUsername(const QString &auth_username);
|
||||
|
||||
@ -91,7 +88,6 @@ class OwnCloudNetworkFactory {
|
||||
private:
|
||||
QString m_url;
|
||||
bool m_forceServerSideUpdate;
|
||||
bool m_authIsUsed;
|
||||
QString m_authUsername;
|
||||
QString m_authPassword;
|
||||
QNetworkReply::NetworkError m_lastError;
|
||||
|
@ -18,12 +18,14 @@
|
||||
#include "services/owncloud/owncloudserviceroot.h"
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "services/owncloud/network/owncloudnetworkfactory.h"
|
||||
|
||||
|
||||
OwnCloudServiceRoot::OwnCloudServiceRoot(RootItem *parent) : ServiceRoot(parent) {
|
||||
OwnCloudServiceRoot::OwnCloudServiceRoot(RootItem *parent) : ServiceRoot(parent), m_network(new OwnCloudNetworkFactory()) {
|
||||
}
|
||||
|
||||
OwnCloudServiceRoot::~OwnCloudServiceRoot() {
|
||||
delete m_network;
|
||||
}
|
||||
|
||||
bool OwnCloudServiceRoot::canBeEdited() const {
|
||||
@ -84,6 +86,10 @@ bool OwnCloudServiceRoot::loadMessagesForItem(RootItem *item, QSqlTableModel *mo
|
||||
return false;
|
||||
}
|
||||
|
||||
OwnCloudNetworkFactory *OwnCloudServiceRoot::network() const {
|
||||
return m_network;
|
||||
}
|
||||
|
||||
void OwnCloudServiceRoot::addNewFeed(const QString &url) {
|
||||
// TODO: TODO
|
||||
}
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "services/abstract/serviceroot.h"
|
||||
|
||||
|
||||
class OwnCloudNetworkFactory;
|
||||
|
||||
class OwnCloudServiceRoot : public ServiceRoot {
|
||||
Q_OBJECT
|
||||
|
||||
@ -48,9 +50,14 @@ class OwnCloudServiceRoot : public ServiceRoot {
|
||||
|
||||
bool loadMessagesForItem(RootItem *item, QSqlTableModel *model);
|
||||
|
||||
OwnCloudNetworkFactory *network() const;
|
||||
|
||||
public slots:
|
||||
void addNewFeed(const QString &url);
|
||||
void addNewCategory();
|
||||
|
||||
private:
|
||||
OwnCloudNetworkFactory *m_network;
|
||||
};
|
||||
|
||||
#endif // OWNCLOUDSERVICEROOT_H
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
TtRssServiceRoot::TtRssServiceRoot(RootItem *parent)
|
||||
: ServiceRoot(parent), m_recycleBin(new TtRssRecycleBin(this)),
|
||||
m_actionSyncIn(NULL), m_serviceMenu(QList<QAction*>()), m_network(new TtRssNetworkFactory) {
|
||||
m_actionSyncIn(NULL), m_serviceMenu(QList<QAction*>()), m_network(new TtRssNetworkFactory()) {
|
||||
setIcon(TtRssServiceEntryPoint().icon());
|
||||
setCreationDate(QDateTime::currentDateTime());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user