Skip to content

Commit

Permalink
Merge branch 'jb40089' into 'master'
Browse files Browse the repository at this point in the history
Expose SSL/TLS security info

See merge request mer-core/qtmozembed!49
  • Loading branch information
llewelld committed Sep 24, 2019
2 parents 0b191f0 + 07a6884 commit ddcf97d
Show file tree
Hide file tree
Showing 21 changed files with 781 additions and 102 deletions.
5 changes: 5 additions & 0 deletions qmlplugin5/main.cpp
@@ -1,4 +1,7 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (c) 2013 - 2019 Jolla Ltd.
* Copyright (c) 2019 Open Mobile Platform LLC.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand All @@ -10,6 +13,7 @@
#include "qmozcontext.h"
#include "qmozscrolldecorator.h"
#include "qmlmozcontext.h"
#include "qmozsecurity.h"

class QtMozEmbedPlugin : public QQmlExtensionPlugin
{
Expand All @@ -24,6 +28,7 @@ class QtMozEmbedPlugin : public QQmlExtensionPlugin
qmlRegisterType<QmlMozContext>("Qt5Mozilla", 1, 0, "QmlMozContext");
qmlRegisterUncreatableType<QMozScrollDecorator>("Qt5Mozilla", 1, 0, "QmlMozScrollDecorator", "");
qmlRegisterUncreatableType<QMozReturnValue>("Qt5Mozilla", 1, 0, "QMozReturnValue", "");
qmlRegisterType<QMozSecurity>("Qt5Mozilla", 1, 0, "QMozSecurity");
setenv("EMBED_COMPONENTS_PATH", DEFAULT_COMPONENTS_PATH, 1);
}
};
Expand Down
2 changes: 2 additions & 0 deletions qtmozembed.pro
Expand Up @@ -7,3 +7,5 @@ qmlplugin5.depends = src
isEmpty(NO_TESTS) {
SUBDIRS += tests
}

OTHER_FILES += rpm/qtmozembed-qt5.spec
2 changes: 2 additions & 0 deletions rpm/qtmozembed-qt5.spec
Expand Up @@ -27,7 +27,9 @@ BuildRequires: pkgconfig(pixman-1) >= 0.19.2
BuildRequires: xulrunner-qt5-devel >= %{min_xulrunner_version}
BuildRequires: qt5-default
BuildRequires: qt5-qttools
BuildRequires: pkgconfig(systemsettings) >= 0.5.25
Requires: xulrunner-qt5 >= %{min_xulrunner_version}
Requires: nemo-qml-plugin-systemsettings >= 0.5.25

%{!?qtc_qmake5:%define qtc_qmake5 %qmake5}
%{!?qtc_make:%define qtc_make make}
Expand Down
35 changes: 23 additions & 12 deletions src/qmozcontext.cpp
@@ -1,5 +1,9 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-*/
/* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (c) 2013 - 2019 Jolla Ltd.
* Copyright (c) 2019 Open Mobile Platform LLC.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

Expand All @@ -26,6 +30,8 @@
#include "mozilla/embedlite/EmbedLiteView.h"
#include "mozilla/embedlite/EmbedInitGlue.h"

Q_LOGGING_CATEGORY(lcEmbedLiteExt, "org.sailfishos.embedliteext", QtWarningMsg)

using namespace mozilla::embedlite;

Q_GLOBAL_STATIC(QMozContext, mozContextInstance)
Expand All @@ -47,7 +53,7 @@ QMozContextPrivate::QMozContextPrivate(QObject *parent)
, mViewCreator(NULL)
, mMozWindow(NULL)
{
LOGT("Create new Context: %p, parent:%p", (void *)this, (void *)parent);
qCDebug(lcEmbedLiteExt) << "Create new Context:" << (void *)this << ", parent:" << (void *)parent;
setenv("BUILD_GRE_HOME", BUILD_GRE_HOME, 1);
LoadEmbedLite();
mApp = XRE_GetEmbedLite();
Expand All @@ -65,7 +71,7 @@ QMozContextPrivate::~QMozContextPrivate()
bool QMozContextPrivate::ExecuteChildThread()
{
if (!getenv("GECKO_THREAD")) {
LOGT("Execute in child Native thread: %p", (void *)mThread);
qCDebug(lcEmbedLiteExt) << "Execute in child Native thread:" << (void *)mThread;
GeckoWorker *worker = new GeckoWorker(mApp);

connect(mThread, SIGNAL(started()), worker, SLOT(doWork()));
Expand All @@ -83,7 +89,7 @@ bool QMozContextPrivate::ExecuteChildThread()
bool QMozContextPrivate::StopChildThread()
{
if (mThread && !mThread->isFinished()) {
LOGT("Stop Native thread: %p", (void *)mThread);
qCDebug(lcEmbedLiteExt) << "Stop Native thread:" << (void *)mThread;
mThread->exit(0);
mThread->wait();
return true;
Expand Down Expand Up @@ -114,7 +120,9 @@ void QMozContextPrivate::Initialized()
// App Destroyed, and ready to delete and program exit
void QMozContextPrivate::Destroyed()
{
LOGT("");
#ifdef DEVELOPMENT_BUILD
qCInfo(lcEmbedLiteExt);
#endif
mApp->SetListener(nullptr);

if (!mThread->isFinished()) {
Expand All @@ -130,7 +138,7 @@ void QMozContextPrivate::Destroyed()

void QMozContextPrivate::OnObserve(const char *aTopic, const char16_t *aData)
{
// LOGT("aTopic: %s, data: %s", aTopic, NS_ConvertUTF16toUTF8(aData).get());
//qCDebug(lcEmbedLiteExt) << "aTopic:" << aTopic << ", data:" << NS_ConvertUTF16toUTF8(aData).get();
QString data((QChar *)aData);
if (!data.startsWith('{') && !data.startsWith('[') && !data.startsWith('"')) {
QVariant vdata = QVariant::fromValue(data);
Expand All @@ -143,10 +151,13 @@ void QMozContextPrivate::OnObserve(const char *aTopic, const char16_t *aData)
ok = error.error == QJsonParseError::NoError;
QVariant vdata = doc.toVariant();
if (ok) {
// LOGT("mesg:%s, data:%s", aTopic, data.toUtf8().data());
//qCDebug(lcEmbedLiteExt) << "mesg:" << aTopic << ", data:" << data.toUtf8().data();
Q_EMIT recvObserve(aTopic, vdata);
} else {
LOGT("parse: s:'%s', err:%s, errLine:%i", data.toUtf8().data(), error.errorString().toUtf8().data(), error.offset);
qCDebug(lcEmbedLiteExt) << "JSON parse error:" << error.errorString().toUtf8().data();
#ifdef DEVELOPMENT_BUILD
qCDebug(lcEmbedLiteExt) << "parse: s:'" << data.toUtf8().data() << "', errLine:" << error.offset;
#endif
}
}

Expand All @@ -168,7 +179,7 @@ bool QMozContextPrivate::IsInitialized()
uint32_t QMozContextPrivate::CreateNewWindowRequested(const uint32_t &chromeFlags, const char *uri, const uint32_t &contextFlags,
EmbedLiteView *aParentView)
{
LOGT("QtMozEmbedContext new Window requested: parent:%p", (void *)aParentView);
qCDebug(lcEmbedLiteExt) << "QtMozEmbedContext new Window requested: parent:" << (void *)aParentView;
uint32_t viewId = QMozContext::instance()->createView(QString(uri), aParentView ? aParentView->GetUniqueID() : 0);
return viewId;
}
Expand Down Expand Up @@ -334,13 +345,13 @@ QMozContext::GetApp()

void QMozContext::setPixelRatio(float ratio)
{
qDebug() << "QMozContext::setPixelRatio is deprecated and will be removed 1st of December 2016. Use QMozEngineSettings::setPixelRatio instead.";
qCWarning(lcEmbedLiteExt) << "QMozContext::setPixelRatio is deprecated and will be removed 1st of December 2016. Use QMozEngineSettings::setPixelRatio instead.";
QMozEngineSettings::instance()->setPixelRatio(ratio);
}

float QMozContext::pixelRatio() const
{
qDebug() << "QMozContext::pixelRatio is deprecated and will be removed 1st of December 2016. Use QMozEngineSettings::pixelRatio instead.";
qCWarning(lcEmbedLiteExt) << "QMozContext::pixelRatio is deprecated and will be removed 1st of December 2016. Use QMozEngineSettings::pixelRatio instead.";
return QMozEngineSettings::instance()->pixelRatio();
}

Expand Down
2 changes: 1 addition & 1 deletion src/qmozembed.pri
Expand Up @@ -33,7 +33,7 @@ contains(CONFIG, with-system-nspr) {

LIBS += -L$$GECKO_LIB_DIR -lxpcomglue -Wl,--whole-archive -lmozglue -lmemory
LIBS += -Wl,--no-whole-archive -rdynamic -ldl
PKGCONFIG += nspr pixman-1
PKGCONFIG += nspr pixman-1 systemsettings

DEFINES += BUILD_GRE_HOME=\"\\\"$$BIN_DIR\\\"\"

Expand Down
26 changes: 9 additions & 17 deletions src/qmozembedlog.h
@@ -1,28 +1,20 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (c) 2013 - 2019 Jolla Ltd.
* Copyright (c) 2019 Open Mobile Platform LLC.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef QMOZ_EMBED_LOG_H
#define QMOZ_EMBED_LOG_H

#include <stdio.h>
#include <QDebug>
#include <QLoggingCategory>

#ifdef Q_DEBUG_LOG
//#define DEVELOPMENT_BUILD (1)

#ifdef LOG_COMPONENT
#define LOGT(FMT, ...) fprintf(stderr, \
"EmbedLiteExt %s:%s:%d: " FMT "\n", LOG_COMPONENT, __FUNCTION__, __LINE__, ##__VA_ARGS__)
#else // LOG_COMPONENT
#define LOGT(FMT, ...) fprintf(stderr, \
"EmbedLiteExt %s:%d: " FMT "\n", __FUNCTION__, __LINE__, ##__VA_ARGS__)
#endif // LOG_COMPONENT

#else // Q_DEBUG_LOG

#define LOGT(...) do {} while (0)

#endif // Q_DEBUG_LOG
Q_DECLARE_LOGGING_CATEGORY(lcEmbedLiteExt)

#endif // QMOZ_EMBED_LOG_H
20 changes: 9 additions & 11 deletions src/qmozenginesettings.cpp
@@ -1,11 +1,9 @@
/****************************************************************************
**
** Copyright (C) 2016 Jolla Ltd.
** Contact: Raine Makelainen <raine.makelainen@jolla.com>
**
****************************************************************************/
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-*/
/* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (c) 2016 - 2019 Jolla Ltd.
* Copyright (c) 2019 Open Mobile Platform LLC.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

Expand Down Expand Up @@ -118,10 +116,10 @@ void QMozEngineSettingsPrivate::enableLowPrecisionBuffers(bool enabled)

void QMozEngineSettingsPrivate::setPreference(const QString &key, const QVariant &value)
{
LOGT("name:%s, type:%i", key.toUtf8().data(), value.type());
qCDebug(lcEmbedLiteExt) << "name:" << key.toUtf8().data() << ", type:" << value.type();

if (!isInitialized()) {
LOGT("Error: context not yet initialized");
qCDebug(lcEmbedLiteExt) << "Error: context not yet initialized";
mPreferences.insert(key, value);
return;
}
Expand Down Expand Up @@ -149,7 +147,7 @@ void QMozEngineSettingsPrivate::setPreference(const QString &key, const QVariant
}
break;
default:
LOGT("Unknown pref type: %i", value.type());
qCWarning(lcEmbedLiteExt) << "Unknown pref type:" << value.type();
}
}

Expand Down
10 changes: 7 additions & 3 deletions src/qmozgrabresult.cpp
@@ -1,14 +1,18 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (c) 2015 - 2019 Jolla Ltd.
* Copyright (c) 2019 Open Mobile Platform LLC.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "qmozembedlog.h"
#include "qopenglwebpage.h"
#include "qmozgrabresult.h"
#include "qmozwindow.h"

#include <QCoreApplication>
#include <QDebug>
#if defined(QT_OPENGL_ES_2)
#include <QOpenGLFunctions_ES2>
#else
Expand Down

0 comments on commit ddcf97d

Please sign in to comment.