summaryrefslogtreecommitdiff
path: root/src/sync
diff options
context:
space:
mode:
Diffstat (limited to 'src/sync')
-rw-r--r--src/sync/operasynchandler.cpp62
-rw-r--r--src/sync/synccheckwidget.cpp22
-rw-r--r--src/sync/syncdatawidget.cpp8
-rw-r--r--src/sync/synchosttypewidget.cpp14
-rw-r--r--src/sync/syncmanager.cpp9
-rw-r--r--src/sync/syncoperasettingswidget.cpp27
-rw-r--r--src/sync/syncoperasettingswidget.h4
7 files changed, 96 insertions, 50 deletions
diff --git a/src/sync/operasynchandler.cpp b/src/sync/operasynchandler.cpp
index 25656b10..50d671f8 100644
--- a/src/sync/operasynchandler.cpp
+++ b/src/sync/operasynchandler.cpp
@@ -183,7 +183,7 @@ void OperaSyncHandler::startLogin()
kDebug() << QUrl("https://auth.opera.com/service/oauth/authorize?oauth_token=" + QString(_requestToken) + "&oauth_callback=oob");
- _webPage.mainFrame()->load(QUrl("https://auth.opera.com/service/oauth/authorize?oauth_token=" + QString(_requestToken) + "&oauth_callback=oob" ));
+ _webPage.mainFrame()->load(QUrl("https://auth.opera.com/service/oauth/authorize?oauth_token=" + QString(_requestToken) + "&oauth_callback=oob"));
}
else
{
@@ -199,7 +199,7 @@ void OperaSyncHandler::loadFinished(bool ok)
if (!ok)
{
kDebug() << "Error loading: " << _webPage.mainFrame()->url();
- emit syncStatus(Rekonq::Bookmarks, false, i18n( "Error loading: " + _webPage.mainFrame()->url().toEncoded()));
+ emit syncStatus(Rekonq::Bookmarks, false, i18n("Error loading: " + _webPage.mainFrame()->url().toEncoded()));
_isSyncing = false;
return;
@@ -350,7 +350,7 @@ void OperaSyncHandler::fetchBookmarksResultSlot(KJob* job)
QDomElement item = responseList.at(0).toElement();
KBookmark current = root.first();
- while(!current.isNull())
+ while (!current.isNull())
{
if (current.isGroup())
{
@@ -377,7 +377,8 @@ void OperaSyncHandler::fetchBookmarksResultSlot(KJob* job)
kDebug() << "Grand child is null";
handleLocalGroup(current.toGroup(), grandChild, id);
}
- else{
+ else
+ {
handleLocalGroup(current.toGroup(), grandChild, id);
}
}
@@ -395,11 +396,11 @@ void OperaSyncHandler::fetchBookmarksResultSlot(KJob* job)
kDebug() << "Add bookmark :" << url;
addBookmarkOnServer(current.fullText(), current.url().url());
}
-/* else
- {
- kDebug() << "Bookmark exists :" << url;
- }
-*/
+ /* else
+ {
+ kDebug() << "Bookmark exists :" << url;
+ }
+ */
}
current = root.next(current);
@@ -591,7 +592,8 @@ void OperaSyncHandler::handleResponse(const QDomNodeList &responseList, KBookmar
{
handleResource(item, root);
item = item.nextSibling();
- }while (!item.isNull());
+ }
+ while (!item.isNull());
}
}
@@ -600,7 +602,7 @@ void OperaSyncHandler::handleLocalGroup(const KBookmarkGroup &root, const QDomEl
{
KBookmark current = root.first();
- while(!current.isNull())
+ while (!current.isNull())
{
if (current.isGroup())
{
@@ -641,11 +643,11 @@ void OperaSyncHandler::handleLocalGroup(const KBookmarkGroup &root, const QDomEl
addBookmarkOnServer(current.fullText(), current.url().url(), parentId);
}
-/* else
- {
- kDebug() << "Bookmark exists :" << url;
- }
-*/
+ /* else
+ {
+ kDebug() << "Bookmark exists :" << url;
+ }
+ */
}
current = root.next(current);
@@ -657,8 +659,8 @@ void OperaSyncHandler::addBookmarkOnServer(QString title, QString url, QString p
{
QOAuth::ParamMap requestMap;
requestMap.insert("api_output", "xml");
- requestMap.insert("api_method","create");
- requestMap.insert("item_type","bookmark");
+ requestMap.insert("api_method", "create");
+ requestMap.insert("item_type", "bookmark");
requestMap.insert("title", QUrl::toPercentEncoding(title.toUtf8()));
requestMap.insert("uri", QUrl::toPercentEncoding(url.toUtf8()));
@@ -671,8 +673,8 @@ void OperaSyncHandler::addBookmarkOnServer(QString title, QString url, QString p
QByteArray postData = _qoauth.createParametersString(requestUrl, QOAuth::POST, _authToken, _authTokenSecret, QOAuth::HMAC_SHA1, requestMap, QOAuth::ParseForRequestContent);
- KIO::TransferJob *job = KIO::http_post( KUrl(requestUrl), postData, KIO::HideProgressInfo );
- job->addMetaData("Content-Type", "application/x-www-form-urlencoded" );
+ KIO::TransferJob *job = KIO::http_post(KUrl(requestUrl), postData, KIO::HideProgressInfo);
+ job->addMetaData("Content-Type", "application/x-www-form-urlencoded");
connect(job, SIGNAL(result(KJob*)), this, SLOT(createBookmarkResultSlot(KJob*)));
connect(job, SIGNAL(data(KIO::Job*, QByteArray)), this, SLOT(createBookmarkDataSlot(KIO::Job*, QByteArray)));
@@ -685,8 +687,8 @@ KJob *OperaSyncHandler::addBookmarkFolderOnServer(QString title, QString parent)
{
QOAuth::ParamMap requestMap;
requestMap.insert("api_output", "xml");
- requestMap.insert("api_method","create");
- requestMap.insert("item_type","bookmark_folder");
+ requestMap.insert("api_method", "create");
+ requestMap.insert("item_type", "bookmark_folder");
requestMap.insert("title", QUrl::toPercentEncoding(title.toUtf8()));
QByteArray requestUrl = "https://link.api.opera.com/rest/bookmark/";
@@ -697,8 +699,8 @@ KJob *OperaSyncHandler::addBookmarkFolderOnServer(QString title, QString parent)
QByteArray postData = _qoauth.createParametersString(requestUrl, QOAuth::POST, _authToken, _authTokenSecret, QOAuth::HMAC_SHA1, requestMap, QOAuth::ParseForRequestContent);
- KIO::TransferJob *job = KIO::http_post( KUrl(requestUrl), postData, KIO::HideProgressInfo );
- job->addMetaData("Content-Type", "application/x-www-form-urlencoded" );
+ KIO::TransferJob *job = KIO::http_post(KUrl(requestUrl), postData, KIO::HideProgressInfo);
+ job->addMetaData("Content-Type", "application/x-www-form-urlencoded");
_jobToResponseMap.insert(job, "");
connect(job, SIGNAL(result(KJob*)), this, SLOT(createBookmarkFolderResultSlot(KJob*)));
@@ -712,7 +714,7 @@ KJob *OperaSyncHandler::addBookmarkFolderOnServer(QString title, QString parent)
void OperaSyncHandler::deleteResourceOnServer(QString id)
{
QOAuth::ParamMap requestMap;
- requestMap.insert("api_method","delete");
+ requestMap.insert("api_method", "delete");
QByteArray requestUrl = "https://link.api.opera.com/rest/bookmark/";
@@ -727,8 +729,8 @@ void OperaSyncHandler::deleteResourceOnServer(QString id)
kDebug() << "Deleting Resource : " << id;
- KIO::TransferJob *job = KIO::http_post( KUrl(requestUrl), postData, KIO::HideProgressInfo );
- job->addMetaData("Content-Type", "application/x-www-form-urlencoded" );
+ KIO::TransferJob *job = KIO::http_post(KUrl(requestUrl), postData, KIO::HideProgressInfo);
+ job->addMetaData("Content-Type", "application/x-www-form-urlencoded");
connect(job, SIGNAL(result(KJob*)), this, SLOT(deleteResourceResultSlot(KJob*)));
connect(job, SIGNAL(data(KIO::Job*, QByteArray)), this, SLOT(deleteResourceDataSlot(KIO::Job*, QByteArray)));
@@ -791,7 +793,7 @@ QString OperaSyncHandler::getChildString(const QDomNode &node, const QString &na
{
QDomNodeList nodes = node.childNodes();
- for (int j=0; j<nodes.size(); ++j)
+ for (int j = 0; j < nodes.size(); ++j)
{
QDomElement element = nodes.at(j).toElement();
@@ -808,7 +810,7 @@ QDomElement OperaSyncHandler::getChildElement(const QDomNode &node, const QStrin
{
QDomNodeList nodes = node.childNodes();
- for (int j=0; j<nodes.size(); ++j)
+ for (int j = 0; j < nodes.size(); ++j)
{
QDomElement element = nodes.at(j).toElement();
@@ -874,7 +876,7 @@ QDomElement OperaSyncHandler::findOperaBookmark(const QDomElement &root, const K
{
QDomElement current = root.firstChild().toElement();
- while (!current.isNull() )
+ while (!current.isNull())
{
if ((getChildString(current, "item_type") == "bookmark") && KUrl(getUrlFromResourceProperties(current)) == url)
break;
diff --git a/src/sync/synccheckwidget.cpp b/src/sync/synccheckwidget.cpp
index 7d44c580..4874377f 100644
--- a/src/sync/synccheckwidget.cpp
+++ b/src/sync/synccheckwidget.cpp
@@ -92,6 +92,22 @@ void SyncCheckWidget::initializePage()
QString loadingGitPath = KStandardDirs::locate("appdata" , "pics/loading.mng");
+ // Now, load syncManager settings...
+ rApp->syncManager()->loadSettings();
+
+ SyncHandler *h = rApp->syncManager()->handler();
+
+ if (!h)
+ {
+ bkLabel->setPixmap(notSyncedIcon.pixmap(16));
+ hsLabel->setPixmap(notSyncedIcon.pixmap(16));
+ psLabel->setPixmap(notSyncedIcon.pixmap(16));
+ return;
+ }
+
+ connect(h, SIGNAL(syncStatus(Rekonq::SyncData, bool, QString)), this, SLOT(updateWidget(Rekonq::SyncData, bool, QString)));
+
+
// bookmarks
if (ReKonfig::syncBookmarks())
{
@@ -130,12 +146,6 @@ void SyncCheckWidget::initializePage()
{
psLabel->setPixmap(notSyncedIcon.pixmap(16));
}
-
- // Now, load syncManager settings...
- rApp->syncManager()->loadSettings();
-
- SyncHandler *h = rApp->syncManager()->handler();
- connect(h, SIGNAL(syncStatus(Rekonq::SyncData, bool, QString)), this, SLOT(updateWidget(Rekonq::SyncData, bool, QString)));
}
diff --git a/src/sync/syncdatawidget.cpp b/src/sync/syncdatawidget.cpp
index 9b415ad2..635c6239 100644
--- a/src/sync/syncdatawidget.cpp
+++ b/src/sync/syncdatawidget.cpp
@@ -49,17 +49,17 @@ void SyncDataWidget::initializePage()
kcfg_syncHistory->setDisabled(true);
kcfg_syncPasswords->setDisabled(true);
- switch(ReKonfig::syncType())
+ switch (ReKonfig::syncType())
{
- //Ftp Sync Handler
+ //Ftp Sync Handler
case 0:
kcfg_syncBookmarks->setEnabled(true);
kcfg_syncHistory->setEnabled(true);
kcfg_syncPasswords->setEnabled(true);
break;
- //Google Sync Handler
+ //Google Sync Handler
case 1:
- //Opera Sync Handler
+ //Opera Sync Handler
case 2:
kcfg_syncBookmarks->setEnabled(true);
break;
diff --git a/src/sync/synchosttypewidget.cpp b/src/sync/synchosttypewidget.cpp
index cece6e2c..289f5e5e 100644
--- a/src/sync/synchosttypewidget.cpp
+++ b/src/sync/synchosttypewidget.cpp
@@ -45,9 +45,9 @@ SyncHostTypeWidget::SyncHostTypeWidget(QWidget *parent)
kcfg_syncEnabled->setChecked(ReKonfig::syncEnabled());
if (ReKonfig::syncType() == 0)
ftpRadioButton->setChecked(true);
- else if(ReKonfig::syncType() == 1)
+ else if (ReKonfig::syncType() == 1)
googleRadioButton->setChecked(true);
- else if(ReKonfig::syncType() == 2)
+ else if (ReKonfig::syncType() == 2)
operaRadioButton->setChecked(true);
else
nullRadioButton->setChecked(true);
@@ -83,11 +83,11 @@ int SyncHostTypeWidget::nextId() const
ReKonfig::setSyncType(0);
return SyncAssistant::Page_FTP_Settings;
}
- else if (googleRadioButton->isChecked())
- {
- ReKonfig::setSyncType(1);
- return SyncAssistant::Page_Google_Settings;
- }
+ else if (googleRadioButton->isChecked())
+ {
+ ReKonfig::setSyncType(1);
+ return SyncAssistant::Page_Google_Settings;
+ }
else if (operaRadioButton->isChecked())
{
ReKonfig::setSyncType(2);
diff --git a/src/sync/syncmanager.cpp b/src/sync/syncmanager.cpp
index 67b23054..78cc4b4e 100644
--- a/src/sync/syncmanager.cpp
+++ b/src/sync/syncmanager.cpp
@@ -31,6 +31,10 @@
// Auto Includes
#include "rekonq.h"
+// Config Includes
+#include "config-qca2.h"
+#include "config-qtoauth.h"
+
// Local Includes
#include "application.h"
#include "bookmarkmanager.h"
@@ -39,7 +43,10 @@
#include "syncassistant.h"
#include "ftpsynchandler.h"
#include "googlesynchandler.h"
+
+#if (defined HAVE_QCA2 && defined HAVE_QTOAUTH)
#include "operasynchandler.h"
+#endif
// KDE Includes
#include <klocalizedstring.h>
@@ -84,9 +91,11 @@ void SyncManager::loadSettings()
case 1:
_syncImplementation = new GoogleSyncHandler(this);
break;
+#if (defined HAVE_QCA2 && defined HAVE_QTOAUTH)
case 2:
_syncImplementation = new OperaSyncHandler(this);
break;
+#endif
default:
kDebug() << "/dev/null";
return;
diff --git a/src/sync/syncoperasettingswidget.cpp b/src/sync/syncoperasettingswidget.cpp
index 7cef9e24..a45ae70c 100644
--- a/src/sync/syncoperasettingswidget.cpp
+++ b/src/sync/syncoperasettingswidget.cpp
@@ -1,8 +1,9 @@
/* ============================================================
*
* This file is a part of the rekonq project
+*
* Copyright (C) 2012 by Siteshwar Vashisht <siteshwar at gmail dot com>
-* Copyright (C) 2011 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2011-2012 by Andrea Diamantini <adjam7 at gmail dot com>
*
*
* This program is free software; you can redistribute it and/or
@@ -31,6 +32,10 @@
// Auto Includes
#include "rekonq.h"
+// Config Includes
+#include "config-qca2.h"
+#include "config-qtoauth.h"
+
// Local Includes
#include "syncassistant.h"
@@ -39,15 +44,29 @@ SyncOperaSettingsWidget::SyncOperaSettingsWidget(QWidget *parent)
: QWizardPage(parent)
{
setupUi(this);
+
+#if (defined HAVE_QCA2 && defined HAVE_QTOAUTH)
+
kcfg_syncUser->setText(ReKonfig::syncUser());
kcfg_syncPass->setText(ReKonfig::syncPass());
kcfg_syncPass->setPasswordMode(true);
+
+#else
+
+ kcfg_syncUser->setEnabled(false);
+ kcfg_syncPass->setEnabled(false);
+
+ infoLabel->setText(i18n("Rekonq has been compiled without support for Opera Sync"));
+
+#endif
}
int SyncOperaSettingsWidget::nextId() const
{
+#if (defined HAVE_QCA2 && defined HAVE_QTOAUTH)
+
// save
ReKonfig::setSyncHost("http://link.opera.com/");
ReKonfig::setSyncUser(kcfg_syncUser->text());
@@ -57,4 +76,10 @@ int SyncOperaSettingsWidget::nextId() const
ReKonfig::setSyncPasswords(false);
return SyncAssistant::Page_Data;
+
+#else
+
+ return SyncAssistant::Page_Check;
+
+#endif
}
diff --git a/src/sync/syncoperasettingswidget.h b/src/sync/syncoperasettingswidget.h
index 5eb608d3..53e95699 100644
--- a/src/sync/syncoperasettingswidget.h
+++ b/src/sync/syncoperasettingswidget.h
@@ -2,8 +2,8 @@
*
* This file is a part of the rekonq project
*
-* Copyright (C) 2011 by Siteshwar Vashisht <siteshwar AT gmail.com>
-* Copyright (C) 2011 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2011-2012 by Siteshwar Vashisht <siteshwar AT gmail.com>
+* Copyright (C) 2011-2012 by Andrea Diamantini <adjam7 at gmail dot com>
*
*
* This program is free software; you can redistribute it and/or