1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Add Sync tab in Preferences, Load FxA login & Add HKDF algorithm.

Add Sync tab in Prefernces.
Load Firefox Account Login page in Sync tab in Prefernces.
Add HKDF algorithm that will be used for key stretching during Sync
process.
This commit is contained in:
Prasenjit Kumar Shaw 2019-06-03 00:04:35 +05:30
parent 721d203366
commit 630a57edbc
12 changed files with 383 additions and 6 deletions

View File

@ -166,6 +166,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/src/lib/preferences
${CMAKE_SOURCE_DIR}/src/lib/session
${CMAKE_SOURCE_DIR}/src/lib/sidebar
${CMAKE_SOURCE_DIR}/src/lib/sync
${CMAKE_SOURCE_DIR}/src/lib/tabwidget
${CMAKE_SOURCE_DIR}/src/lib/tools
${CMAKE_SOURCE_DIR}/src/lib/webengine

View File

@ -32,6 +32,7 @@ include_directories(
preferences
session
sidebar
sync
tabwidget
tools
webengine
@ -204,6 +205,7 @@ set(SRCS ${SRCS}
preferences/pluginlistdelegate.cpp
preferences/pluginsmanager.cpp
preferences/preferences.cpp
preferences/syncoptions.cpp
preferences/thememanager.cpp
preferences/useragentdialog.cpp
session/recoveryjsobject.cpp
@ -213,6 +215,7 @@ set(SRCS ${SRCS}
sidebar/bookmarkssidebar.cpp
sidebar/historysidebar.cpp
sidebar/sidebar.cpp
sync/hkdf.cpp
tabwidget/combotabbar.cpp
tabwidget/tabbar.cpp
tabwidget/tabicon.cpp
@ -313,6 +316,7 @@ qt5_wrap_ui(SRCS
preferences/jsoptions.ui
preferences/pluginslist.ui
preferences/preferences.ui
preferences/syncoptions.ui
preferences/thememanager.ui
preferences/useragentdialog.ui
session/sessionmanagerdialog.ui

View File

@ -56,6 +56,7 @@
<file>icons/preferences/privacy.svg</file>
<file>icons/preferences/shortcuts.svg</file>
<file>icons/preferences/spellcheck.svg</file>
<file>icons/preferences/sync.svg</file>
<file>icons/preferences/tabs.svg</file>
<file>icons/menu/download.svg</file>
</qresource>

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="32"
height="32"
viewBox="0 0 320 320"
version="1.1"
id="svg4"
sodipodi:docname="combine-top-bottom.svg"
style="clip-rule:evenodd;fill-rule:evenodd;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision"
inkscape:version="0.92.3 (2405546, 2018-03-11)">
<metadata
id="metadata10">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs8" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1440"
inkscape:window-height="871"
id="namedview6"
showgrid="false"
inkscape:zoom="3.6875"
inkscape:cx="32"
inkscape:cy="32"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg4" />
<path
d="M 78.179501,3.1020669 2.711865,103.92457 l 48.576908,0.008 v 178.53258 h 53.792747 v -0.007 h 36.55743 l 1.05494,0.007 48.20595,-0.0145 -51.71229,-69.08377 -34.10603,0.007 V 103.94021 l 48.57151,-0.0145 z M 241.2677,316.22199 316.74124,215.3995 l -48.5828,-0.007 v -92.01018 l 0.005,-1.74948 V 36.858711 l -2.61969,-0.0076 H 199.523 l -59.79119,0.0076 v 10.808128 l 43.6275,58.275651 h 14.80748 l 1.36751,0.007 h 14.83052 v 109.43558 l -48.57152,0.0151 75.47353,100.82249 z"
id="path2"
inkscape:connector-curvature="0"
style="stroke-width:0.5560813;fill:#00c1b2;fill-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -48,6 +48,7 @@
#include "webscrollbarmanager.h"
#include "protocolhandlerdialog.h"
#include "../config.h"
#include "syncoptions.h"
#include <QSettings>
#include <QInputDialog>
@ -137,7 +138,8 @@ Preferences::Preferences(BrowserWindow* window)
setCategoryIcon(9, QIcon(":/icons/preferences/notifications.svg"));
setCategoryIcon(10, QIcon(":/icons/preferences/extensions.svg"));
setCategoryIcon(11, QIcon(":/icons/preferences/spellcheck.svg"));
setCategoryIcon(12, QIcon(":/icons/preferences/other.svg"));
setCategoryIcon(12, QIcon(":/icons/preferences/sync.svg"));
setCategoryIcon(13, QIcon(":/icons/preferences/other.svg"));
Settings settings;
//GENERAL URLs
@ -204,6 +206,10 @@ Preferences::Preferences(BrowserWindow* window)
ui->newTabUseCurrent->setEnabled(false);
}
// SYNC
m_syncOptions = new SyncOptions(this);
ui->syncFrame->addWidget(m_syncOptions);
// PROFILES
QString startingProfile = ProfileManager::startingProfile();
ui->activeProfile->setText("<b>" + ProfileManager::currentProfile() + "</b>");

View File

@ -37,6 +37,7 @@ class BrowserWindow;
class PluginsManager;
class DesktopNotification;
class ThemeManager;
class SyncOptions;
class FALKON_EXPORT Preferences : public QDialog
{
@ -97,6 +98,7 @@ private:
AutoFillManager* m_autoFillManager;
PluginsManager* m_pluginsList;
ThemeManager* m_themesManager;
SyncOptions* m_syncOptions;
QPointer<DesktopNotification> m_notification;
QUrl m_homepage;

View File

@ -115,6 +115,11 @@
<string>Spell Check</string>
</property>
</item>
<item>
<property name="text">
<string>Sync</string>
</property>
</item>
<item>
<property name="text">
<string>Other</string>
@ -145,8 +150,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>582</width>
<height>476</height>
<width>602</width>
<height>456</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
@ -168,7 +173,7 @@
<enum>Qt::NoFocus</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>12</number>
</property>
<widget class="QWidget" name="generalPage">
<layout class="QGridLayout" name="gridLayout_6">
@ -2400,8 +2405,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>560</width>
<height>80</height>
<width>96</width>
<height>30</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_14">
@ -2437,6 +2442,19 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="syncPage">
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>601</width>
<height>451</height>
</rect>
</property>
<layout class="QHBoxLayout" name="syncFrame"/>
</widget>
</widget>
<widget class="QWidget" name="otherPage">
<layout class="QGridLayout" name="gridLayout_13">
<item row="15" column="2">

View File

@ -0,0 +1,44 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2019 Prasenjit Kumar Shaw <shawprasenjit07@gmail.com>
*
* 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 3 of the License, or
* (at your option) any later version.
*
* 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 "syncoptions.h"
#include "ui_syncoptions.h"
#include <QWebEngineView>
#include <QWebEnginePage>
#include "syncoptions.h"
SyncOptions::SyncOptions(QWidget* parent)
: QWidget(parent)
, ui(new Ui::SyncOptions)
{
ui->setupUi(this);
QWebEnginePage *FxA_loginPage = new QWebEnginePage();
FxA_loginPage->load(FxALoginUrl);
ui->fxaLoginView->setPage(FxA_loginPage);
ui->fxaLoginView->show();
}
SyncOptions::~SyncOptions()
{
delete ui;
}

View File

@ -0,0 +1,47 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2019 Prasenjit Kumar Shaw <shawprasenjit07@gmail.com>
*
* 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 3 of the License, or
* (at your option) any later version.
*
* 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 SYNCOPTIONS_H
#define SYNCOPTIONS_H
#include <QWidget>
#include <QUrl>
#include "qzcommon.h"
namespace Ui
{
class SyncOptions;
}
class FALKON_EXPORT SyncOptions : public QWidget
{
Q_OBJECT
public:
explicit SyncOptions(QWidget* parent = 0);
~SyncOptions();
private:
const QUrl FxALoginUrl = QUrl("https://accounts.firefox.com/signin?service=sync&context=fx_desktop_v3");
Ui::SyncOptions *ui;
};
#endif // SYNCOPTIONS_H

View File

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SyncOptions</class>
<widget class="QWidget" name="SyncOptions">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>535</width>
<height>749</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<height>511</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWebEngineView" name="fxaLoginView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="url">
<url>
<string>about:blank</string>
</url>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="verticalLayoutWidget_2">
<property name="geometry">
<rect>
<x>0</x>
<y>530</y>
<width>531</width>
<height>211</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QWidget" name="options" native="true">
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<height>51</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Sync Interval :</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton">
<property name="text">
<string>5 minutes</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_3">
<property name="text">
<string>15 minutes</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_2">
<property name="text">
<string>30 minutes</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>QWebEngineView</class>
<extends>QWidget</extends>
<header location="global">QtWebEngineWidgets/QWebEngineView</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

52
src/lib/sync/hkdf.cpp Normal file
View File

@ -0,0 +1,52 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2019 Prasenjit Kumar Shaw <shawprasenjit07@gmail.com>
*
* 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 3 of the License, or
* (at your option) any later version.
*
* 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 "hkdf.h"
#include <openssl/evp.h>
#include <openssl/kdf.h>
#include <QByteArray>
HKDF::HKDF(const QByteArray key, const QByteArray salt)
{
pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF,NULL);
init(key, salt);
}
HKDF::~HKDF() {
;
}
void HKDF::init(const QByteArray key, const QByteArray salt)
{
size_t keylen = key.size();
size_t saltlen = salt.size();
EVP_PKEY_derive_init(pctx);
EVP_PKEY_CTX_set_hkdf_md(pctx, EVP_sha256());
EVP_PKEY_CTX_set1_hkdf_salt(pctx, (uchar *)salt.data(), saltlen);
EVP_PKEY_CTX_set1_hkdf_key(pctx, (uchar *)key.data(), keylen);
}
QByteArray HKDF::getKey(size_t outlen) {
QByteArray out;
EVP_PKEY_derive(pctx, (uchar *)out.data(), &outlen);
return out;
}

36
src/lib/sync/hkdf.h Normal file
View File

@ -0,0 +1,36 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2019 Prasenjit Kumar Shaw <shawprasenjit07@gmail.com>
*
* 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 3 of the License, or
* (at your option) any later version.
*
* 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/>.
* ============================================================ */
#pragma once
#include <openssl/evp.h>
#include <QByteArray>
class HKDF
{
public:
explicit HKDF(const QByteArray key, const QByteArray salt);
~HKDF();
QByteArray getKey(size_t outlen);
private:
void init(const QByteArray key, const QByteArray salt);
EVP_PKEY_CTX *pctx;
};