summaryrefslogtreecommitdiff
path: root/src/sync
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-11-18 15:40:21 +0100
committerAndrea Diamantini <adjam7@gmail.com>2011-12-12 16:40:28 +0100
commit984b65aa6da257c8d2ea79a9c2336d7e3ff484c2 (patch)
treed3695485aa8be48dc69d9b9d35483bc1b95063d6 /src/sync
parentBookmarkProvider --> BookmarkManager (diff)
downloadrekonq-984b65aa6da257c8d2ea79a9c2336d7e3ff484c2.tar.xz
On the road to the sync feature...
Diffstat (limited to 'src/sync')
-rw-r--r--src/sync/settings_sync.ui6
-rw-r--r--src/sync/syncmanager.cpp83
-rw-r--r--src/sync/syncmanager.h7
-rw-r--r--src/sync/syncwidget.cpp4
4 files changed, 56 insertions, 44 deletions
diff --git a/src/sync/settings_sync.ui b/src/sync/settings_sync.ui
index f45c8b6c..ec8f0ddb 100644
--- a/src/sync/settings_sync.ui
+++ b/src/sync/settings_sync.ui
@@ -57,18 +57,18 @@
<item>
<widget class="QGroupBox" name="ownCloudGroupBox">
<property name="title">
- <string>ownCloud settings</string>
+ <string>remote host settings</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
- <string>host:</string>
+ <string>URL:</string>
</property>
</widget>
</item>
<item row="0" column="1">
- <widget class="KLineEdit" name="kcfg_syncHost"/>
+ <widget class="KLineEdit" name="kcfg_syncUrl"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
diff --git a/src/sync/syncmanager.cpp b/src/sync/syncmanager.cpp
index fe4ffc43..e926e181 100644
--- a/src/sync/syncmanager.cpp
+++ b/src/sync/syncmanager.cpp
@@ -54,12 +54,6 @@ SyncManager::SyncManager(QObject *parent)
}
-SyncManager::~SyncManager()
-{
- sync();
-}
-
-
void SyncManager::loadSettings()
{
if (ReKonfig::syncEnabled())
@@ -68,8 +62,8 @@ void SyncManager::loadSettings()
// bookmarks
ReKonfig::syncBookmarks()
- ? connect(rApp->bookmarkManager(), SIGNAL(changed()), this, SLOT(syncBookmarks()))
- : disconnect(rApp->bookmarkManager(), SIGNAL(changed()), this, SLOT(syncBookmarks()))
+ ? connect(rApp->bookmarkManager(), SIGNAL(bookmarksUpdated()), this, SLOT(syncBookmarks()))
+ : disconnect(rApp->bookmarkManager(), SIGNAL(bookmarksUpdated()), this, SLOT(syncBookmarks()))
;
// history
@@ -81,7 +75,7 @@ void SyncManager::loadSettings()
else
{
// bookmarks
- disconnect(rApp->bookmarkManager(), SIGNAL(changed()), this, SLOT(syncBookmarks()));
+ disconnect(rApp->bookmarkManager(), SIGNAL(bookmarksUpdated()), this, SLOT(syncBookmarks()));
// history
disconnect(rApp->historyManager(), SIGNAL(historySaved()), this, SLOT(syncHistory()));
@@ -110,7 +104,7 @@ void SyncManager::firstTimeSync()
// Bookmarks
if (ReKonfig::syncBookmarks())
{
- _remoteBookmarksUrl = QUrl(ReKonfig::syncHost());
+ _remoteBookmarksUrl = QUrl::fromUserInput(ReKonfig::syncUrl());
_remoteBookmarksUrl.setUserName(ReKonfig::syncUser());
_remoteBookmarksUrl.setPassword(ReKonfig::syncPass());
_remoteBookmarksUrl.setPath(QL1S("/data/") + ReKonfig::syncUser() + QL1S("/files/bookmarks.xml"));
@@ -129,7 +123,7 @@ void SyncManager::firstTimeSync()
// History
if (ReKonfig::syncHistory())
{
- _remoteHistoryUrl = QUrl(ReKonfig::syncHost());
+ _remoteHistoryUrl = QUrl::fromUserInput(ReKonfig::syncUrl());
_remoteHistoryUrl.setUserName(ReKonfig::syncUser());
_remoteHistoryUrl.setPassword(ReKonfig::syncPass());
_remoteHistoryUrl.setPath(QL1S("/data/") + ReKonfig::syncUser() + QL1S("/files/history"));
@@ -148,7 +142,7 @@ void SyncManager::firstTimeSync()
// Passwords
if (ReKonfig::syncPasswords())
{
- _remotePasswordsUrl = QUrl(ReKonfig::syncHost());
+ _remotePasswordsUrl = QUrl::fromUserInput(ReKonfig::syncUrl());
_remotePasswordsUrl.setUserName(ReKonfig::syncUser());
_remotePasswordsUrl.setPassword(ReKonfig::syncPass());
_remotePasswordsUrl.setPath(QL1S("/data/") + ReKonfig::syncUser() + QL1S("/files/kdewallet.kwl"));
@@ -166,46 +160,37 @@ void SyncManager::firstTimeSync()
}
-void SyncManager::sync()
+bool SyncManager::syncRelativeEnabled(bool check)
{
- kDebug() << "syncing now...";
-
if (!ReKonfig::syncEnabled())
- return;
+ return false;
if (!_firstTimeSynced)
{
kDebug() << "need to sync for the first time...";
firstTimeSync();
- return;
- }
-
- // Bookmarks
- if (ReKonfig::syncBookmarks())
- {
- KIO::Job *job = KIO::file_copy(_localBookmarksUrl, _remoteBookmarksUrl, -1, KIO::HideProgressInfo | KIO::Overwrite);
- connect(job, SIGNAL(finished(KJob *)), this, SLOT(onBookmarksSyncFinished(KJob *)));
+ return false;
}
- // History
- if (ReKonfig::syncHistory())
- {
- KIO::Job *job = KIO::file_copy(_localHistoryUrl, _remoteHistoryUrl, -1, KIO::HideProgressInfo | KIO::Overwrite);
- connect(job, SIGNAL(finished(KJob *)), this, SLOT(onHistorySyncFinished(KJob *)));
- }
-
- // Passwords
- if (ReKonfig::syncPasswords())
- {
- KIO::Job *job = KIO::file_copy(_localPasswordsUrl, _remotePasswordsUrl, -1, KIO::HideProgressInfo | KIO::Overwrite);
- connect(job, SIGNAL(finished(KJob *)), this, SLOT(onPasswordsSyncFinished(KJob *)));
- }
+ return check;
}
// ---------------------------------------------------------------------------------------
+void SyncManager::syncBookmarks()
+{
+ kDebug() << "syncing now...";
+
+ if (!syncRelativeEnabled(ReKonfig::syncBookmarks()))
+ return;
+
+ KIO::Job *job = KIO::file_copy(_localBookmarksUrl, _remoteBookmarksUrl, -1, KIO::HideProgressInfo | KIO::Overwrite);
+ connect(job, SIGNAL(finished(KJob *)), this, SLOT(onBookmarksSyncFinished(KJob *)));
+}
+
+
void SyncManager::onBookmarksStatFinished(KJob *job)
{
if (job->error() ||
@@ -246,6 +231,18 @@ void SyncManager::onBookmarksSyncFinished(KJob *job)
// ---------------------------------------------------------------------------------------
+void SyncManager::syncHistory()
+{
+ kDebug() << "syncing now...";
+
+ if (!syncRelativeEnabled(ReKonfig::syncHistory()))
+ return;
+
+ KIO::Job *job = KIO::file_copy(_localHistoryUrl, _remoteHistoryUrl, -1, KIO::HideProgressInfo | KIO::Overwrite);
+ connect(job, SIGNAL(finished(KJob *)), this, SLOT(onHistorySyncFinished(KJob *)));
+}
+
+
void SyncManager::onHistoryStatFinished(KJob *job)
{
if (job->error() ||
@@ -286,6 +283,18 @@ void SyncManager::onHistorySyncFinished(KJob *job)
// ---------------------------------------------------------------------------------------
+void SyncManager::syncPasswords()
+{
+ kDebug() << "syncing now...";
+
+ if (!syncRelativeEnabled(ReKonfig::syncPasswords()))
+ return;
+
+ KIO::Job *job = KIO::file_copy(_localPasswordsUrl, _remotePasswordsUrl, -1, KIO::HideProgressInfo | KIO::Overwrite);
+ connect(job, SIGNAL(finished(KJob *)), this, SLOT(onPasswordsSyncFinished(KJob *)));
+}
+
+
void SyncManager::onPasswordsStatFinished(KJob *job)
{
if (job->error() ||
diff --git a/src/sync/syncmanager.h b/src/sync/syncmanager.h
index b87045a1..82fd3551 100644
--- a/src/sync/syncmanager.h
+++ b/src/sync/syncmanager.h
@@ -47,12 +47,13 @@ class REKONQ_TESTS_EXPORT SyncManager : public QObject
public:
SyncManager(QObject *parent = 0);
- ~SyncManager();
void firstTimeSync();
public Q_SLOTS:
- void sync();
+ void syncBookmarks();
+ void syncHistory();
+ void syncPasswords();
private Q_SLOTS:
void loadSettings();
@@ -73,6 +74,8 @@ Q_SIGNALS:
void syncPasswordsFinished(bool);
private:
+ bool syncRelativeEnabled(bool);
+
bool _firstTimeSynced;
QUrl _remoteBookmarksUrl;
diff --git a/src/sync/syncwidget.cpp b/src/sync/syncwidget.cpp
index b8e95753..c8fc1368 100644
--- a/src/sync/syncwidget.cpp
+++ b/src/sync/syncwidget.cpp
@@ -46,7 +46,7 @@ SyncWidget::SyncWidget(QWidget *parent)
kcfg_syncBookmarks->setChecked(ReKonfig::syncBookmarks());
kcfg_syncHistory->setChecked(ReKonfig::syncHistory());
kcfg_syncPasswords->setChecked(ReKonfig::syncPasswords());
- kcfg_syncHost->setText(ReKonfig::syncHost());
+ kcfg_syncUrl->setText(ReKonfig::syncUrl());
kcfg_syncUser->setText(ReKonfig::syncUser());
kcfg_syncPass->setText(ReKonfig::syncPass());
@@ -68,7 +68,7 @@ void SyncWidget::save()
ReKonfig::setSyncBookmarks(kcfg_syncBookmarks->isChecked());
ReKonfig::setSyncHistory(kcfg_syncHistory->isChecked());
ReKonfig::setSyncPasswords(kcfg_syncPasswords->isChecked());
- ReKonfig::setSyncHost(kcfg_syncHost->text());
+ ReKonfig::setSyncUrl(kcfg_syncUrl->text());
ReKonfig::setSyncUser(kcfg_syncUser->text());
ReKonfig::setSyncPass(kcfg_syncPass->text());