Work on ownCloud syncing.
This commit is contained in:
parent
358675bb0c
commit
93bc60be9f
8 changed files with 90 additions and 37 deletions
|
@ -85,20 +85,6 @@ FormMain::FormMain(QWidget *parent, Qt::WindowFlags f)
|
|||
|
||||
// Initialize the web factory.
|
||||
WebFactory::instance()->loadState();
|
||||
|
||||
|
||||
|
||||
OwnCloudNetworkFactory fac;
|
||||
|
||||
fac.setUrl("https://cloud.yarpen.cz");
|
||||
fac.setAuthPassword("rssguard135");
|
||||
fac.setAuthUsername("rssguard");
|
||||
|
||||
OwnCloudStatusResponse user = fac.status();
|
||||
|
||||
QString ver = user.version();
|
||||
|
||||
int aaaa = 0;
|
||||
}
|
||||
|
||||
FormMain::~FormMain() {
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
#include "network-web/networkfactory.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/settings.h"
|
||||
#include "services/abstract/rootitem.h"
|
||||
#include "services/owncloud/owncloudcategory.h"
|
||||
#include "services/owncloud/owncloudfeed.h"
|
||||
|
||||
#include <QPixmap>
|
||||
|
||||
|
@ -179,7 +182,6 @@ QString OwnCloudResponse::toString() const {
|
|||
return QtJson::serializeStr(m_rawContent);
|
||||
}
|
||||
|
||||
|
||||
OwnCloudUserResponse::OwnCloudUserResponse(const QString &raw_content) : OwnCloudResponse(raw_content) {
|
||||
}
|
||||
|
||||
|
@ -255,13 +257,58 @@ bool OwnCloudStatusResponse::misconfiguredCron() const {
|
|||
|
||||
OwnCloudGetFeedsCategoriesResponse::OwnCloudGetFeedsCategoriesResponse(const QString &raw_categories,
|
||||
const QString &raw_feeds)
|
||||
: m_contentCategories(QString()), m_contentFeeds(QString()) {
|
||||
: m_contentCategories(raw_categories), m_contentFeeds(raw_feeds) {
|
||||
}
|
||||
|
||||
OwnCloudGetFeedsCategoriesResponse::~OwnCloudGetFeedsCategoriesResponse() {
|
||||
}
|
||||
|
||||
RootItem *OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons) const {
|
||||
// TODO: TODO
|
||||
return NULL;
|
||||
RootItem *parent = new RootItem();
|
||||
QMap<int,RootItem*> cats;
|
||||
|
||||
cats.insert(0, parent);
|
||||
|
||||
// Process categories first, then process feeds.
|
||||
foreach (QVariant cat, QtJson::parse(m_contentCategories).toMap()["folders"].toList()) {
|
||||
QMap<QString,QVariant> item = cat.toMap();
|
||||
OwnCloudCategory *category = new OwnCloudCategory();
|
||||
|
||||
category->setTitle(item["name"].toString());
|
||||
category->setCustomId(item["id"].toInt());
|
||||
|
||||
cats.insert(category->customId(), category);
|
||||
|
||||
// All categories in ownCloud are top-level.
|
||||
parent->appendChild(category);
|
||||
}
|
||||
|
||||
// We have categories added, now add all feeds.
|
||||
foreach (QVariant fed, QtJson::parse(m_contentFeeds).toMap()["feeds"].toList()) {
|
||||
QMap<QString,QVariant> item = fed.toMap();
|
||||
OwnCloudFeed *feed = new OwnCloudFeed();
|
||||
|
||||
if (obtain_icons) {
|
||||
QString icon_path = item["faviconLink"].toString();
|
||||
|
||||
if (!icon_path.isEmpty()) {
|
||||
QByteArray icon_data;
|
||||
|
||||
if (NetworkFactory::downloadFile(icon_path, DOWNLOAD_TIMEOUT, icon_data).first == QNetworkReply::NoError) {
|
||||
// Icon downloaded, set it up.
|
||||
QPixmap icon_pixmap;
|
||||
icon_pixmap.loadFromData(icon_data);
|
||||
feed->setIcon(QIcon(icon_pixmap));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
feed->setUrl(item["link"].toString());
|
||||
feed->setTitle(item["title"].toString());
|
||||
feed->setCustomId(item["id"].toInt());
|
||||
|
||||
cats.value(item["folderId"].toInt())->appendChild(feed);
|
||||
}
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
#include "miscellaneous/iconfactory.h"
|
||||
|
||||
|
||||
OwnCloudServiceCategory::OwnCloudServiceCategory(RootItem *parent) : Category(parent) {
|
||||
OwnCloudCategory::OwnCloudCategory(RootItem *parent) : Category(parent) {
|
||||
// Categories in ownCloud have now icons etc. They just have titles.
|
||||
setIcon(qApp->icons()->fromTheme(QSL("folder-category")));
|
||||
}
|
||||
|
||||
OwnCloudServiceCategory::~OwnCloudServiceCategory() {
|
||||
OwnCloudCategory::~OwnCloudCategory() {
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@
|
|||
#include "services/abstract/category.h"
|
||||
|
||||
|
||||
class OwnCloudServiceCategory : public Category {
|
||||
class OwnCloudCategory : public Category {
|
||||
public:
|
||||
explicit OwnCloudServiceCategory(RootItem *parent = NULL);
|
||||
virtual ~OwnCloudServiceCategory();
|
||||
explicit OwnCloudCategory(RootItem *parent = NULL);
|
||||
virtual ~OwnCloudCategory();
|
||||
};
|
||||
|
||||
#endif // OWNCLOUDSERVICECATEGORY_H
|
||||
|
|
|
@ -23,3 +23,12 @@ OwnCloudFeed::OwnCloudFeed(RootItem *parent) : Feed(parent) {
|
|||
|
||||
OwnCloudFeed::~OwnCloudFeed() {
|
||||
}
|
||||
|
||||
int OwnCloudFeed::update() {
|
||||
// TODO: TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OwnCloudFeed::messageForeignKeyId() const {
|
||||
return customId();
|
||||
}
|
||||
|
|
|
@ -25,6 +25,9 @@ class OwnCloudFeed : public Feed {
|
|||
public:
|
||||
explicit OwnCloudFeed(RootItem *parent = NULL);
|
||||
virtual ~OwnCloudFeed();
|
||||
|
||||
int update();
|
||||
int messageForeignKeyId() const;
|
||||
};
|
||||
|
||||
#endif // OWNCLOUDFEED_H
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
|
||||
|
||||
OwnCloudServiceRoot::OwnCloudServiceRoot(RootItem *parent)
|
||||
: ServiceRoot(parent), m_recycleBin(new OwnCloudRecycleBin(this)), m_network(new OwnCloudNetworkFactory()) {
|
||||
: ServiceRoot(parent), m_recycleBin(new OwnCloudRecycleBin(this)),
|
||||
m_actionSyncIn(NULL), m_serviceMenu(QList<QAction*>()), m_network(new OwnCloudNetworkFactory()) {
|
||||
setIcon(OwnCloudServiceEntryPoint().icon());
|
||||
}
|
||||
|
||||
|
@ -65,24 +66,23 @@ bool OwnCloudServiceRoot::supportsCategoryAdding() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
QList<QAction*> OwnCloudServiceRoot::addItemMenu() {
|
||||
// TODO: TODO
|
||||
return QList<QAction*>();
|
||||
}
|
||||
|
||||
QList<QAction*> OwnCloudServiceRoot::serviceMenu() {
|
||||
// TODO: TODO
|
||||
return QList<QAction*>();
|
||||
if (m_serviceMenu.isEmpty()) {
|
||||
m_actionSyncIn = new QAction(qApp->icons()->fromTheme(QSL("item-sync")), tr("Sync in"), this);
|
||||
|
||||
connect(m_actionSyncIn, SIGNAL(triggered()), this, SLOT(syncIn()));
|
||||
m_serviceMenu.append(m_actionSyncIn);
|
||||
}
|
||||
|
||||
return m_serviceMenu;
|
||||
}
|
||||
|
||||
RecycleBin *OwnCloudServiceRoot::recycleBin() const {
|
||||
// TODO: TODO
|
||||
return NULL;
|
||||
return m_recycleBin;
|
||||
}
|
||||
|
||||
void OwnCloudServiceRoot::start(bool freshly_activated) {
|
||||
// TODO: TODO
|
||||
//loadFromDatabase();
|
||||
loadFromDatabase();
|
||||
|
||||
if (childCount() == 1 && child(0)->kind() == RootItemKind::Bin) {
|
||||
syncIn();
|
||||
|
@ -244,3 +244,9 @@ void OwnCloudServiceRoot::syncIn() {
|
|||
setIcon(original_icon);
|
||||
itemChanged(QList<RootItem*>() << this);
|
||||
}
|
||||
|
||||
void OwnCloudServiceRoot::loadFromDatabase() {
|
||||
// As the last item, add recycle bin, which is needed.
|
||||
appendChild(m_recycleBin);
|
||||
m_recycleBin->updateCounts(true);
|
||||
}
|
||||
|
|
|
@ -38,8 +38,6 @@ class OwnCloudServiceRoot : public ServiceRoot {
|
|||
|
||||
bool supportsFeedAdding() const;
|
||||
bool supportsCategoryAdding() const;
|
||||
|
||||
QList<QAction*> addItemMenu();
|
||||
QList<QAction*> serviceMenu();
|
||||
|
||||
RecycleBin *recycleBin() const;
|
||||
|
@ -62,7 +60,11 @@ class OwnCloudServiceRoot : public ServiceRoot {
|
|||
void syncIn();
|
||||
|
||||
private:
|
||||
void loadFromDatabase();
|
||||
|
||||
OwnCloudRecycleBin *m_recycleBin;
|
||||
QAction *m_actionSyncIn;
|
||||
QList<QAction*> m_serviceMenu;
|
||||
OwnCloudNetworkFactory *m_network;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue