Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[messagingframework] Update upstream to current master. Contributes t…
…o JB#40471 Rebased our changes against current master and exported as patch files. Not necessarily the most convenient to work with, but maintaining our changes doesn't get a mess of local changes, upstream merge and local changes on top of that. Can be converted into other format at will, e.g. rebooted git subtree. Bunch of local changes were already upstreamed so no longer needed. Rest of the commits reordered so that more easily upstreamable are first and accounts-q/nemo-keepalive are later. Bunch of the commits got squashed now, moreso in accounts-qt which had changes back and forth during the early development. More squashing could be still done. Commits were modified to be compatible with upstream changes, which included e.g. - Qt4 support removed - QT_NO_OPENSSL was changed into QT_NO_SSL - Upstream now building Qt modules which had effect here and there - Documentation is not built anymore. Removed -doc package - Because of Qt module, the tests are no longer installed. Left test package commented out in the hope of getting it back later.
- Loading branch information
Showing
22 changed files
with
13,241 additions
and
40 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
rpm/0001-Stop-_incomingDataTimer-when-imapprotocol-object-is-.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
From 41b5c72eac16e52509783b97add23e51f81203d7 Mon Sep 17 00:00:00 2001 | ||
From: =?UTF-8?q?Val=C3=A9rio=20Val=C3=A9rio?= <valerio.valerio@jolla.com> | ||
Date: Mon, 23 Feb 2015 13:08:24 +0200 | ||
Subject: [PATCH 01/20] Stop _incomingDataTimer when imapprotocol object is | ||
destroyed. | ||
|
||
A crash occurs in case the timer is active and the object is destroyed. | ||
--- | ||
src/plugins/messageservices/imap/imapprotocol.cpp | 3 +++ | ||
1 file changed, 3 insertions(+) | ||
|
||
diff --git a/src/plugins/messageservices/imap/imapprotocol.cpp b/src/plugins/messageservices/imap/imapprotocol.cpp | ||
index b37d990d..df5da7f2 100644 | ||
--- a/src/plugins/messageservices/imap/imapprotocol.cpp | ||
+++ b/src/plugins/messageservices/imap/imapprotocol.cpp | ||
@@ -2995,6 +2995,9 @@ ImapProtocol::ImapProtocol() | ||
|
||
ImapProtocol::~ImapProtocol() | ||
{ | ||
+ // FIXME: does this have any effect or can it be removed? shouldn't be able to trigger | ||
+ // before it's automatically stopped at the end of this function | ||
+ _incomingDataTimer.stop(); | ||
delete _transport; | ||
delete _fsm; | ||
} | ||
-- | ||
2.17.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
From f46ad61fbb6f94b2d7c5b329694bec9850cfa564 Mon Sep 17 00:00:00 2001 | ||
From: =?UTF-8?q?Val=C3=A9rio=20Val=C3=A9rio?= <valerio.valerio@jolla.com> | ||
Date: Tue, 17 Mar 2015 12:35:34 +0200 | ||
Subject: [PATCH 02/20] Use QTextDocument to parse html. | ||
|
||
Regular expression are not appropriated tool to parse a none regular language | ||
like html, a proper parse should be used. | ||
This commit introduces a dependency on QtGui making the messageserver | ||
binary marginally bigger in size. Usage of Html parse is optional | ||
can be defined via USE_HTML_PARSER compile flag. | ||
|
||
Squashed: | ||
Avoid unnecessary Wayland connection. Contributes to JB#34345 | ||
--- | ||
src/libraries/qmfclient/qmailmessage.cpp | 57 +++++++++++++++-------- | ||
src/libraries/qmfclient/qmailmessage.h | 3 ++ | ||
src/libraries/qmfclient/qmfclient.pro | 5 ++ | ||
src/tools/messageserver/main.cpp | 14 ++++++ | ||
src/tools/messageserver/messageserver.pro | 4 ++ | ||
5 files changed, 64 insertions(+), 19 deletions(-) | ||
|
||
diff --git a/src/libraries/qmfclient/qmailmessage.cpp b/src/libraries/qmfclient/qmailmessage.cpp | ||
index 98108179..f06927ed 100644 | ||
--- a/src/libraries/qmfclient/qmailmessage.cpp | ||
+++ b/src/libraries/qmfclient/qmailmessage.cpp | ||
@@ -54,6 +54,9 @@ | ||
#include <qtextcodec.h> | ||
#include <QTextCodec> | ||
#include <QtDebug> | ||
+#ifdef USE_HTML_PARSER | ||
+#include <QTextDocument> | ||
+#endif | ||
|
||
#include <stdlib.h> | ||
#include <limits.h> | ||
@@ -8596,51 +8599,67 @@ void QMailMessage::refreshPreview() | ||
{ | ||
const int maxPreviewLength = 280; | ||
// TODO: don't load entire body into memory | ||
- // TODO: parse html correctly, e.g. closing brackets in quotes in tags | ||
QMailMessagePartContainer *htmlPart= findHtmlContainer(); | ||
QMailMessagePartContainer *plainTextPart= findPlainTextContainer(); | ||
+ QString plainText; | ||
|
||
if (multipartType() == MultipartRelated && htmlPart) // force taking the html in this case | ||
plainTextPart=0; | ||
|
||
if ( plainTextPart && plainTextPart->hasBody()) { | ||
- QString plaintext(plainTextPart->body().data()); | ||
- plaintext.remove(QRegExp(QLatin1String("\\[(image|cid):[^\\]]*\\]"), Qt::CaseInsensitive)); | ||
- metaDataImpl()->setPreview(plaintext.left(maxPreviewLength)); | ||
+ plainText = plainTextPart->body().data(); | ||
+ // These are not valid html, so remove them before | ||
+ plainText.remove(QRegExp(QLatin1String("\\[(image|cid):[^\\]]*\\]"), Qt::CaseInsensitive)); | ||
} else if (htmlPart && ( multipartType() == MultipartRelated || htmlPart->hasBody())) { | ||
- QString markup = htmlPart->body().data(); | ||
- markup.remove(QRegExp(QLatin1String("<\\s*(style|head|form|script)[^<]*<\\s*/\\s*\\1\\s*>"), Qt::CaseInsensitive)); | ||
- markup.remove(QRegExp(QLatin1String("<(.)[^>]*>"))); | ||
- markup.replace(QLatin1String("""), QLatin1String("\""), Qt::CaseInsensitive); | ||
- markup.replace(QLatin1String(" "), QLatin1String(" "), Qt::CaseInsensitive); | ||
- markup.replace(QLatin1String("&"), QLatin1String("&"), Qt::CaseInsensitive); | ||
- markup.replace(QLatin1String("<"), QLatin1String("<"), Qt::CaseInsensitive); | ||
- markup.replace(QLatin1String(">"), QLatin1String(">"), Qt::CaseInsensitive); | ||
+ plainText = htmlPart->body().data(); | ||
+ | ||
+#ifndef USE_HTML_PARSER | ||
+ plainText.remove(QRegExp(QLatin1String("<\\s*(style|head|form|script)[^<]*<\\s*/\\s*\\1\\s*>"), Qt::CaseInsensitive)); | ||
+ plainText.remove(QRegExp(QLatin1String("<(.)[^>]*>"))); | ||
+ plainText.replace(QLatin1String("""), QLatin1String("\""), Qt::CaseInsensitive); | ||
+ plainText.replace(QLatin1String(" "), QLatin1String(" "), Qt::CaseInsensitive); | ||
+ plainText.replace(QLatin1String("&"), QLatin1String("&"), Qt::CaseInsensitive); | ||
+ plainText.replace(QLatin1String("<"), QLatin1String("<"), Qt::CaseInsensitive); | ||
+ plainText.replace(QLatin1String(">"), QLatin1String(">"), Qt::CaseInsensitive); | ||
|
||
// now replace stuff like "м" | ||
for (int pos = 0; ; ) { | ||
- pos = markup.indexOf(QLatin1String("&#"), pos); | ||
+ pos = plainText.indexOf(QLatin1String("&#"), pos); | ||
if (pos < 0) | ||
break; | ||
- int semicolon = markup.indexOf(';', pos+2); | ||
+ int semicolon = plainText.indexOf(';', pos+2); | ||
if (semicolon < 0) { | ||
++pos; | ||
continue; | ||
} | ||
- int code = (markup.mid(pos+2, semicolon-pos-2)).toInt(); | ||
+ int code = (plainText.mid(pos+2, semicolon-pos-2)).toInt(); | ||
if (code == 0) { | ||
++pos; | ||
continue; | ||
} | ||
- markup.replace(pos, semicolon-pos+1, QChar(code)); | ||
+ plainText.replace(pos, semicolon-pos+1, QChar(code)); | ||
} | ||
- | ||
- metaDataImpl()->setPreview(markup.simplified().left(maxPreviewLength)); | ||
+#endif | ||
} | ||
- | ||
+#ifdef USE_HTML_PARSER | ||
+ metaDataImpl()->setPreview(htmlToPlainText(plainText).left(maxPreviewLength)); | ||
+#else | ||
+ metaDataImpl()->setPreview(plainText.left(maxPreviewLength)); | ||
+#endif | ||
partContainerImpl()->setPreviewDirty(false); | ||
} | ||
|
||
+#ifdef USE_HTML_PARSER | ||
+QString QMailMessage::htmlToPlainText(const QString &html) | ||
+{ | ||
+ QTextDocument doc; | ||
+ doc.setHtml(html); | ||
+ // Parse text a second time to prevent html injection via pre-hidden tags(e.g: < img src="cenas.png" >) | ||
+ doc.setHtml(doc.toPlainText()); | ||
+ return doc.toPlainText(); | ||
+} | ||
+#endif | ||
+ | ||
/*! \internal */ | ||
QMailMessage QMailMessage::fromRfc2822(LongString& ls) | ||
{ | ||
diff --git a/src/libraries/qmfclient/qmailmessage.h b/src/libraries/qmfclient/qmailmessage.h | ||
index 6d73f75a..c846b434 100644 | ||
--- a/src/libraries/qmfclient/qmailmessage.h | ||
+++ b/src/libraries/qmfclient/qmailmessage.h | ||
@@ -808,6 +808,9 @@ private: | ||
|
||
static QMailMessage fromRfc2822(LongString& ls); | ||
void refreshPreview(); | ||
+#ifdef USE_HTML_PARSER | ||
+ static QString htmlToPlainText(const QString &html); | ||
+#endif | ||
|
||
public: | ||
virtual QString preview() const; | ||
diff --git a/src/libraries/qmfclient/qmfclient.pro b/src/libraries/qmfclient/qmfclient.pro | ||
index f643c4d1..665aba1b 100644 | ||
--- a/src/libraries/qmfclient/qmfclient.pro | ||
+++ b/src/libraries/qmfclient/qmfclient.pro | ||
@@ -16,6 +16,11 @@ DEFINES += QMF_INSTALL_ROOT=\\\"$$QMF_INSTALL_ROOT\\\" | ||
#DEPENDPATH += . | ||
INCLUDEPATH += support | ||
|
||
+contains(DEFINES, USE_HTML_PARSER) { | ||
+ QT += gui | ||
+} | ||
+ | ||
+ | ||
HEADERS += \ | ||
qmailaccount.h \ | ||
qmailaccountconfiguration.h \ | ||
diff --git a/src/tools/messageserver/main.cpp b/src/tools/messageserver/main.cpp | ||
index c6f0edc9..cb10d301 100644 | ||
--- a/src/tools/messageserver/main.cpp | ||
+++ b/src/tools/messageserver/main.cpp | ||
@@ -37,13 +37,21 @@ | ||
#include <qmaillog.h> | ||
#include <qloggers.h> | ||
#include <signal.h> | ||
+#include <stdlib.h> | ||
+#ifdef USE_HTML_PARSER | ||
+#include <QtGui> | ||
+#endif | ||
|
||
#if !defined(NO_SHUTDOWN_SIGNAL_HANDLING) && defined(Q_OS_UNIX) | ||
|
||
static void shutdown(int n) | ||
{ | ||
qMailLog(Messaging) << "Received signal" << n << ", shutting down."; | ||
+#ifdef USE_HTML_PARSER | ||
+ QGuiApplication::exit(); | ||
+#else | ||
QCoreApplication::exit(); | ||
+#endif | ||
} | ||
#endif | ||
|
||
@@ -58,7 +66,13 @@ static void recreateLoggers(int n) | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
+#ifdef USE_HTML_PARSER | ||
+ // Need for html parsing by <QTextdocument> in qmailmessage.cpp, but don't need real UI | ||
+ setenv("QT_QPA_PLATFORM", "minimal", 1); | ||
+ QGuiApplication app(argc, argv); | ||
+#else | ||
QCoreApplication app(argc, argv); | ||
+#endif | ||
|
||
// This is ~/.config/QtProject/Messageserver.conf | ||
qMailLoggersRecreate("QtProject", "Messageserver", "Msgsrv"); | ||
diff --git a/src/tools/messageserver/messageserver.pro b/src/tools/messageserver/messageserver.pro | ||
index a70edfe4..f7d92931 100644 | ||
--- a/src/tools/messageserver/messageserver.pro | ||
+++ b/src/tools/messageserver/messageserver.pro | ||
@@ -9,6 +9,10 @@ SERVER_AS_DLL: { | ||
TARGET = messageserver5 | ||
QT = core qmfclient qmfclient-private qmfmessageserver | ||
|
||
+contains(DEFINES, USE_HTML_PARSER) { | ||
+ QT += gui | ||
+} | ||
+ | ||
!contains(DEFINES,QMF_NO_WIDGETS) { | ||
QT += gui widgets | ||
} | ||
-- | ||
2.17.1 | ||
|
Oops, something went wrong.