summaryrefslogtreecommitdiff
path: root/src/sync
diff options
context:
space:
mode:
authorRadu Andries <admiral0@tuxfamily.org>2013-07-09 16:55:13 +0200
committerAndrea Diamantini <adjam7@gmail.com>2013-07-09 16:58:01 +0200
commitd71d059a6c537bc1857d521b228de5cd08409c62 (patch)
tree40b6db4eed05e508c7c8625fb2e649bd370d23c8 /src/sync
parentGet sure WebIcon is deleted when done (diff)
downloadrekonq-d71d059a6c537bc1857d521b228de5cd08409c62.tar.xz
Add a simple ssh sync handler
CCMAIL: admiral0@tuxfamily.org REVIEWED-BY: adjam Many thanks, Radu! And sorry for the late merge ;)
Diffstat (limited to 'src/sync')
-rw-r--r--src/sync/sshsynchandler.cpp290
-rw-r--r--src/sync/sshsynchandler.h83
-rw-r--r--src/sync/sync_host_type.ui7
-rw-r--r--src/sync/sync_ssh_settings.ui112
-rw-r--r--src/sync/syncassistant.cpp2
-rw-r--r--src/sync/syncassistant.h1
-rw-r--r--src/sync/synccheckwidget.cpp5
-rw-r--r--src/sync/syncdatawidget.cpp6
-rw-r--r--src/sync/syncftpsettingswidget.cpp9
-rw-r--r--src/sync/synchosttypewidget.cpp9
-rw-r--r--src/sync/syncmanager.cpp4
-rw-r--r--src/sync/syncsshsettingswidget.cpp83
-rw-r--r--src/sync/syncsshsettingswidget.h45
13 files changed, 653 insertions, 3 deletions
diff --git a/src/sync/sshsynchandler.cpp b/src/sync/sshsynchandler.cpp
new file mode 100644
index 00000000..06c06861
--- /dev/null
+++ b/src/sync/sshsynchandler.cpp
@@ -0,0 +1,290 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2011 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2013 by Radu Andries <admiral0 at tuxfamily dot org>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* published by the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* 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 General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+
+// Self Includes
+#include "sshsynchandler.h"
+#include "sshsynchandler.moc"
+
+// Auto Includes
+#include "rekonq.h"
+
+// KDE Includes
+#include <KStandardDirs>
+#include <klocalizedstring.h>
+
+#include <KIO/Job>
+
+
+SSHSyncHandler::SSHSyncHandler(QObject *parent)
+ : SyncHandler(parent)
+{
+ kDebug() << "creating SSH handler...";
+}
+
+
+void SSHSyncHandler::initialLoadAndCheck()
+{
+ if (!ReKonfig::syncEnabled())
+ {
+ _firstTimeSynced = false;
+ return;
+ }
+
+ // Bookmarks
+ if (ReKonfig::syncBookmarks())
+ {
+ _remoteBookmarksUrl = QUrl();
+ _remoteBookmarksUrl.setHost(ReKonfig::syncHost());
+ _remoteBookmarksUrl.setScheme("fish");
+ _remoteBookmarksUrl.setUserName(ReKonfig::syncUser());
+ _remoteBookmarksUrl.setPassword(ReKonfig::syncPass());
+ _remoteBookmarksUrl.setPort(ReKonfig::syncPort());
+ _remoteBookmarksUrl.setPath(ReKonfig::syncPath() + QL1S("/bookmarks.xml"));
+
+ const QString bookmarksFilePath = KStandardDirs::locateLocal("data", QL1S("konqueror/bookmarks.xml"));
+ _localBookmarksUrl = KUrl(bookmarksFilePath);
+
+ KIO::StatJob *job = KIO::stat(_remoteBookmarksUrl, KIO::StatJob::DestinationSide, 0, KIO::HideProgressInfo);
+ connect(job, SIGNAL(finished(KJob*)), this, SLOT(onBookmarksStatFinished(KJob*)));
+ }
+
+ // History
+ if (ReKonfig::syncHistory())
+ {
+ _remoteHistoryUrl = QUrl();
+ _remoteHistoryUrl.setHost(ReKonfig::syncHost());
+ _remoteHistoryUrl.setScheme("fish");
+ _remoteHistoryUrl.setUserName(ReKonfig::syncUser());
+ _remoteHistoryUrl.setPassword(ReKonfig::syncPass());
+ _remoteHistoryUrl.setPort(ReKonfig::syncPort());
+ _remoteHistoryUrl.setPath(ReKonfig::syncPath() + QL1S("/history"));
+
+ const QString historyFilePath = KStandardDirs::locateLocal("appdata", "history");
+ _localHistoryUrl = KUrl(historyFilePath);
+
+ KIO::StatJob *job = KIO::stat(_remoteHistoryUrl, KIO::StatJob::DestinationSide, 0, KIO::HideProgressInfo);
+ connect(job, SIGNAL(finished(KJob*)), this, SLOT(onHistoryStatFinished(KJob*)));
+ }
+
+ // Passwords
+ if (ReKonfig::syncPasswords())
+ {
+ _remotePasswordsUrl = QUrl();
+ _remotePasswordsUrl.setHost(ReKonfig::syncHost());
+ _remotePasswordsUrl.setScheme("fish");
+ _remotePasswordsUrl.setUserName(ReKonfig::syncUser());
+ _remotePasswordsUrl.setPassword(ReKonfig::syncPass());
+ _remotePasswordsUrl.setPort(ReKonfig::syncPort());
+ _remotePasswordsUrl.setPath(ReKonfig::syncPath() + QL1S("/kdewallet.kwl"));
+
+ const QString passwordsFilePath = KStandardDirs::locateLocal("data", QL1S("kwallet/kdewallet.kwl"));
+ _localPasswordsUrl = KUrl(passwordsFilePath);
+
+ KIO::StatJob *job = KIO::stat(_remotePasswordsUrl, KIO::StatJob::DestinationSide, 0, KIO::HideProgressInfo);
+ connect(job, SIGNAL(finished(KJob*)), this, SLOT(onPasswordsStatFinished(KJob*)));
+ }
+}
+
+
+bool SSHSyncHandler::syncRelativeEnabled(bool check)
+{
+ if (!ReKonfig::syncEnabled())
+ return false;
+
+ if (!_firstTimeSynced)
+ return false;
+
+ return check;
+}
+
+
+// ---------------------------------------------------------------------------------------
+
+
+void SSHSyncHandler::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 SSHSyncHandler::onBookmarksStatFinished(KJob *job)
+{
+ if (job->error())
+ {
+ if (job->error() == KIO::ERR_DOES_NOT_EXIST)
+ {
+ KIO::Job *job = KIO::file_copy(_localBookmarksUrl, _remoteBookmarksUrl, -1, KIO::HideProgressInfo | KIO::Overwrite);
+ connect(job, SIGNAL(finished(KJob*)), this, SLOT(onBookmarksSyncFinished(KJob*)));
+
+ emit syncStatus(Rekonq::Bookmarks, true, i18n("Remote bookmarks file does not exists. Exporting local copy..."));
+ _firstTimeSynced = true;
+ }
+ else
+ {
+ emit syncStatus(Rekonq::Bookmarks, false, job->errorString());
+ }
+ }
+ else
+ {
+ KIO::Job *job = KIO::file_copy(_remoteBookmarksUrl, _localBookmarksUrl, -1, KIO::HideProgressInfo | KIO::Overwrite);
+ connect(job, SIGNAL(finished(KJob*)), this, SLOT(onBookmarksSyncFinished(KJob*)));
+
+ emit syncStatus(Rekonq::Bookmarks, true, i18n("Remote bookmarks file exists. Syncing local copy..."));
+ _firstTimeSynced = true;
+ }
+}
+
+
+void SSHSyncHandler::onBookmarksSyncFinished(KJob *job)
+{
+ if (job->error())
+ {
+ emit syncStatus(Rekonq::Bookmarks, false, job->errorString());
+ emit syncBookmarksFinished(false);
+ return;
+ }
+
+ emit syncBookmarksFinished(true);
+}
+
+
+// ---------------------------------------------------------------------------------------
+
+
+void SSHSyncHandler::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 SSHSyncHandler::onHistoryStatFinished(KJob *job)
+{
+ if (job->error())
+ {
+ if (job->error() == KIO::ERR_DOES_NOT_EXIST)
+ {
+ KIO::Job *job = KIO::file_copy(_localHistoryUrl, _remoteHistoryUrl, -1, KIO::HideProgressInfo | KIO::Overwrite);
+ connect(job, SIGNAL(finished(KJob*)), this, SLOT(onHistorySyncFinished(KJob*)));
+
+ emit syncStatus(Rekonq::History, true, i18n("Remote history file does not exists. Exporting local copy..."));
+ _firstTimeSynced = true;
+ }
+ else
+ {
+ emit syncStatus(Rekonq::History, false, job->errorString());
+ }
+ }
+ else
+ {
+ KIO::Job *job = KIO::file_copy(_remoteHistoryUrl, _localHistoryUrl, -1, KIO::HideProgressInfo | KIO::Overwrite);
+ connect(job, SIGNAL(finished(KJob*)), this, SLOT(onHistorySyncFinished(KJob*)));
+
+ emit syncStatus(Rekonq::History, true, i18n("Remote history file exists. Syncing local copy..."));
+ _firstTimeSynced = true;
+ }
+}
+
+
+void SSHSyncHandler::onHistorySyncFinished(KJob *job)
+{
+ if (job->error())
+ {
+ emit syncStatus(Rekonq::History, false, job->errorString());
+ emit syncHistoryFinished(false);
+ return;
+ }
+
+ emit syncHistoryFinished(true);
+}
+
+
+// ---------------------------------------------------------------------------------------
+
+
+void SSHSyncHandler::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 SSHSyncHandler::onPasswordsStatFinished(KJob *job)
+{
+ if (job->error())
+ {
+ if (job->error() == KIO::ERR_DOES_NOT_EXIST)
+ {
+ KIO::Job *job = KIO::file_copy(_localPasswordsUrl, _remotePasswordsUrl, -1, KIO::HideProgressInfo | KIO::Overwrite);
+ connect(job, SIGNAL(finished(KJob*)), this, SLOT(onPasswordsSyncFinished(KJob*)));
+
+ emit syncStatus(Rekonq::Passwords, true, i18n("Remote passwords file does not exists. Exporting local copy..."));
+ _firstTimeSynced = true;
+ }
+ else
+ {
+ emit syncStatus(Rekonq::Passwords, false, job->errorString());
+ }
+ }
+ else
+ {
+ KIO::Job *job = KIO::file_copy(_remotePasswordsUrl, _localPasswordsUrl, -1, KIO::HideProgressInfo | KIO::Overwrite);
+ connect(job, SIGNAL(finished(KJob*)), this, SLOT(onPasswordsSyncFinished(KJob*)));
+
+ emit syncStatus(Rekonq::Passwords, true, i18n("Remote passwords file exists. Syncing local copy..."));
+ _firstTimeSynced = true;
+ }
+}
+
+
+void SSHSyncHandler::onPasswordsSyncFinished(KJob *job)
+{
+ if (job->error())
+ {
+ emit syncStatus(Rekonq::Passwords, false, job->errorString());
+ emit syncPasswordsFinished(false);
+ return;
+ }
+
+ emit syncPasswordsFinished(true);
+}
diff --git a/src/sync/sshsynchandler.h b/src/sync/sshsynchandler.h
new file mode 100644
index 00000000..4c1718d9
--- /dev/null
+++ b/src/sync/sshsynchandler.h
@@ -0,0 +1,83 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2011 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2013 by Radu Andries <admiral0 at tuxfamily dot org>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* published by the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* 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 General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+#ifndef SSHSYNCHANDLER_H
+#define SSHSYNCHANDLER_H
+
+// Local includes
+#include "synchandler.h"
+
+// KDE Includes
+#include <KUrl>
+
+// Forward Declarations
+class KJob;
+
+class KJob;
+
+class SSHSyncHandler : public SyncHandler
+{
+ Q_OBJECT
+
+public:
+ explicit SSHSyncHandler(QObject *parent = 0);
+
+ void syncHistory();
+ void syncBookmarks();
+ void syncPasswords();
+
+ void initialLoadAndCheck();
+
+private Q_SLOTS:
+ void onBookmarksSyncFinished(KJob *);
+ void onBookmarksStatFinished(KJob *);
+
+ void onHistorySyncFinished(KJob *);
+ void onHistoryStatFinished(KJob *);
+
+ void onPasswordsSyncFinished(KJob *);
+ void onPasswordsStatFinished(KJob *);
+
+Q_SIGNALS:
+ void syncBookmarksFinished(bool);
+ void syncHistoryFinished(bool);
+ void syncPasswordsFinished(bool);
+
+private:
+ bool syncRelativeEnabled(bool);
+
+ QUrl _remoteBookmarksUrl;
+ KUrl _localBookmarksUrl;
+
+ QUrl _remoteHistoryUrl;
+ KUrl _localHistoryUrl;
+
+ QUrl _remotePasswordsUrl;
+ KUrl _localPasswordsUrl;
+
+};
+
+#endif // SSHSYNCHANDLER_H
diff --git a/src/sync/sync_host_type.ui b/src/sync/sync_host_type.ui
index 676e0052..f3f82117 100644
--- a/src/sync/sync_host_type.ui
+++ b/src/sync/sync_host_type.ui
@@ -32,6 +32,13 @@
</widget>
</item>
<item>
+ <widget class="QRadioButton" name="sshRadioButton">
+ <property name="text">
+ <string>SSH</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QRadioButton" name="googleRadioButton">
<property name="text">
<string>Google Sync</string>
diff --git a/src/sync/sync_ssh_settings.ui b/src/sync/sync_ssh_settings.ui
new file mode 100644
index 00000000..3ce8c662
--- /dev/null
+++ b/src/sync/sync_ssh_settings.ui
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SyncSSHSettings</class>
+ <widget class="QWidget" name="SyncSSHSettings">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="sshGroupBox">
+ <property name="title">
+ <string>SSH Host Settings</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::ExpandingFieldsGrow</enum>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Server:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="KLineEdit" name="kcfg_syncHost"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Username:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="KLineEdit" name="kcfg_syncUser"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Password:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="KLineEdit" name="kcfg_syncPass"/>
+ </item>
+ <item row="3" column="1">
+ <widget class="QCheckBox" name="syncWithSSHKeys">
+ <property name="text">
+ <string>Use system ssh keys to login</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Path:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="KLineEdit" name="kcfg_syncPath"/>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Port:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="KIntNumInput" name="kcfg_syncPort"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>124</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>KLineEdit</class>
+ <extends>QLineEdit</extends>
+ <header>klineedit.h</header>
+ </customwidget>
+ <customwidget>
+ <class>KIntNumInput</class>
+ <extends>QWidget</extends>
+ <header>knuminput.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/sync/syncassistant.cpp b/src/sync/syncassistant.cpp
index 35fcbddb..dcad5397 100644
--- a/src/sync/syncassistant.cpp
+++ b/src/sync/syncassistant.cpp
@@ -36,6 +36,7 @@
#include "syncftpsettingswidget.h"
#include "syncgooglesettingswidget.h"
#include "syncoperasettingswidget.h"
+#include "syncsshsettingswidget.h"
SyncAssistant::SyncAssistant(QWidget *parent)
@@ -47,6 +48,7 @@ SyncAssistant::SyncAssistant(QWidget *parent)
setPage(Page_FTP_Settings, new SyncFTPSettingsWidget(this));
setPage(Page_Google_Settings, new SyncGoogleSettingsWidget(this));
setPage(Page_Opera_Settings, new SyncOperaSettingsWidget(this));
+ setPage(Page_SSH_Settings, new SyncSSHSettingsWidget(this));
setPage(Page_Data, new SyncDataWidget(this));
setPage(Page_Check, new SyncCheckWidget(this));
}
diff --git a/src/sync/syncassistant.h b/src/sync/syncassistant.h
index f373a5f8..d76df5e1 100644
--- a/src/sync/syncassistant.h
+++ b/src/sync/syncassistant.h
@@ -43,6 +43,7 @@ public:
Page_FTP_Settings,
Page_Google_Settings,
Page_Opera_Settings,
+ Page_SSH_Settings,
Page_Data,
Page_Check
};
diff --git a/src/sync/synccheckwidget.cpp b/src/sync/synccheckwidget.cpp
index 913ccafe..d7748caa 100644
--- a/src/sync/synccheckwidget.cpp
+++ b/src/sync/synccheckwidget.cpp
@@ -68,6 +68,11 @@ void SyncCheckWidget::initializePage()
syncLabel->setText(i18n("Opera"));
hostLabel->setText(ReKonfig::syncHost());
}
+ else if (ReKonfig::syncType() == 3)
+ {
+ syncLabel->setText(i18n("SSH"));
+ hostLabel->setText(ReKonfig::syncHost());
+ }
else
{
syncLabel->setText(i18n("No sync"));
diff --git a/src/sync/syncdatawidget.cpp b/src/sync/syncdatawidget.cpp
index 635c6239..5624c45f 100644
--- a/src/sync/syncdatawidget.cpp
+++ b/src/sync/syncdatawidget.cpp
@@ -63,6 +63,12 @@ void SyncDataWidget::initializePage()
case 2:
kcfg_syncBookmarks->setEnabled(true);
break;
+ case 3:
+ //SSH sync handler
+ kcfg_syncBookmarks->setEnabled(true);
+ kcfg_syncHistory->setEnabled(true);
+ kcfg_syncPasswords->setEnabled(true);
+ break;
default:
kDebug() << "Unknown sync type!";
}
diff --git a/src/sync/syncftpsettingswidget.cpp b/src/sync/syncftpsettingswidget.cpp
index 5eb6bfdc..14924f38 100644
--- a/src/sync/syncftpsettingswidget.cpp
+++ b/src/sync/syncftpsettingswidget.cpp
@@ -39,12 +39,17 @@ SyncFTPSettingsWidget::SyncFTPSettingsWidget(QWidget *parent)
: QWizardPage(parent)
{
setupUi(this);
-
+
+ int port = ReKonfig::syncPort();
+ if(port == -1){
+ port=21;
+ }
+
kcfg_syncHost->setText(ReKonfig::syncHost());
kcfg_syncUser->setText(ReKonfig::syncUser());
kcfg_syncPass->setText(ReKonfig::syncPass());
kcfg_syncPath->setText(ReKonfig::syncPath());
- kcfg_syncPort->setValue(ReKonfig::syncPort());
+ kcfg_syncPort->setValue(port);
kcfg_syncPass->setPasswordMode(true);
}
diff --git a/src/sync/synchosttypewidget.cpp b/src/sync/synchosttypewidget.cpp
index 289f5e5e..373b6a6a 100644
--- a/src/sync/synchosttypewidget.cpp
+++ b/src/sync/synchosttypewidget.cpp
@@ -49,6 +49,8 @@ SyncHostTypeWidget::SyncHostTypeWidget(QWidget *parent)
googleRadioButton->setChecked(true);
else if (ReKonfig::syncType() == 2)
operaRadioButton->setChecked(true);
+ if (ReKonfig::syncType() == 3)
+ sshRadioButton->setChecked(true);
else
nullRadioButton->setChecked(true);
@@ -93,9 +95,14 @@ int SyncHostTypeWidget::nextId() const
ReKonfig::setSyncType(2);
return SyncAssistant::Page_Opera_Settings;
}
- else
+ else if (sshRadioButton->isChecked())
{
ReKonfig::setSyncType(3);
+ return SyncAssistant::Page_SSH_Settings;
+ }
+ else
+ {
+ ReKonfig::setSyncType(4);
return SyncAssistant::Page_Check;
}
diff --git a/src/sync/syncmanager.cpp b/src/sync/syncmanager.cpp
index 7a1cb782..20d2a4a5 100644
--- a/src/sync/syncmanager.cpp
+++ b/src/sync/syncmanager.cpp
@@ -43,6 +43,7 @@
#include "syncassistant.h"
#include "ftpsynchandler.h"
#include "googlesynchandler.h"
+#include "sshsynchandler.h"
#if (defined HAVE_QCA2 && defined HAVE_QTOAUTH)
#include "operasynchandler.h"
@@ -112,6 +113,9 @@ void SyncManager::loadSettings()
_syncImplementation = new OperaSyncHandler(this);
break;
#endif
+ case 3:
+ _syncImplementation = new SSHSyncHandler(this);
+ break;
default:
kDebug() << "/dev/null";
return;
diff --git a/src/sync/syncsshsettingswidget.cpp b/src/sync/syncsshsettingswidget.cpp
new file mode 100644
index 00000000..cd89193d
--- /dev/null
+++ b/src/sync/syncsshsettingswidget.cpp
@@ -0,0 +1,83 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2013 by Radu Andries <admiral0 at tuxfamily dot org>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* published by the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* 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 General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+
+#include "syncsshsettingswidget.h"
+
+// Auto Includes
+#include "rekonq.h"
+
+#include <config-qca2.h>
+
+// Local Includes
+#include "syncassistant.h"
+
+int SyncSSHSettingsWidget::nextId() const
+{
+ // save
+ ReKonfig::setSyncHost(kcfg_syncHost->text());
+ ReKonfig::setSyncUser(kcfg_syncUser->text());
+ ReKonfig::setSyncPass(kcfg_syncPass->text());
+ ReKonfig::setSyncPath(kcfg_syncPath->text());
+ ReKonfig::setSyncPort(kcfg_syncPort->value());
+
+ return SyncAssistant::Page_Data;
+}
+
+SyncSSHSettingsWidget::SyncSSHSettingsWidget(QWidget* parent): QWizardPage(parent)
+{
+ setupUi(this);
+
+ int port = ReKonfig::syncPort();
+ if(port == -1){
+ port=22;
+ }
+
+ kcfg_syncHost->setText(ReKonfig::syncHost());
+ kcfg_syncUser->setText(ReKonfig::syncUser());
+ kcfg_syncPass->setText(ReKonfig::syncPass());
+ kcfg_syncPath->setText(ReKonfig::syncPath());
+ kcfg_syncPort->setValue(port);
+
+ if(kcfg_syncPass->text().isEmpty()){
+ syncWithSSHKeys->setChecked(true);
+ toggleUserPass(true);
+ }
+
+ kcfg_syncPass->setPasswordMode(true);
+
+ connect(syncWithSSHKeys,SIGNAL(toggled(bool)),SLOT(toggleUserPass(bool)));
+}
+
+void SyncSSHSettingsWidget::toggleUserPass(bool enabled)
+{
+ if(enabled){
+ kcfg_syncPass->setText("");
+ kcfg_syncPass->setEnabled(false);
+ }else{
+ kcfg_syncPass->setEnabled(true);
+ }
+}
+
+
diff --git a/src/sync/syncsshsettingswidget.h b/src/sync/syncsshsettingswidget.h
new file mode 100644
index 00000000..051be78e
--- /dev/null
+++ b/src/sync/syncsshsettingswidget.h
@@ -0,0 +1,45 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2013 by Radu Andries <admiral0 at tuxfamily dot org>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* published by the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* 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 General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
+#ifndef SYNCSSHSETTINGSWIDGET_H
+#define SYNCSSHSETTINGSWIDGET_H
+
+#include <QWizardPage>
+
+#include "ui_sync_ssh_settings.h"
+
+class SyncSSHSettingsWidget : public QWizardPage, private Ui::SyncSSHSettings
+{
+ Q_OBJECT
+public:
+
+ explicit SyncSSHSettingsWidget(QWidget *parent = 0);
+
+ int nextId() const;
+
+private slots:
+ void toggleUserPass(bool enabled);
+};
+
+#endif // SYNCSSHSETTINGSWIDGET_H