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