Commit 4e72ae2d authored by Damien Caliste's avatar Damien Caliste

[qmf] Modify undecodedData functions to handle parts separately, prepare for IMAP support.

parent 1196bcd0
......@@ -6095,14 +6095,60 @@ bool QMailMessagePart::hasUndecodedData() const
return !impl(this)->undecodedData().isEmpty();
}
const QByteArray QMailMessagePart::undecodedData() const
const QByteArray QMailMessagePart::undecodedData(bool gatherAllParts) const
{
return impl(this)->undecodedData();
if (gatherAllParts && multipartType() != QMailMessagePartContainerFwd::MultipartNone) {
QByteArray undecodedData(impl(this)->undecodedData());
QByteArray bound = QByteArray(2, '-') + boundary();
int foot = undecodedData.indexOf(bound);
QByteArray head = undecodedData.left(foot);
for (unsigned int i = 0; i < partCount(); i++) {
head.append(bound);
head.append(QMailMessage::CRLF);
head.append(partAt(i).undecodedData(true));
head.append(QMailMessage::CRLF);
}
head.append(undecodedData.mid(foot));
return head;
} else {
return impl(this)->undecodedData();
}
}
void QMailMessagePart::setUndecodedData(const QByteArray &data)
void QMailMessagePart::setUndecodedData(const QByteArray &data, bool scatterByParts)
{
impl(this)->setUndecodedData(data);
if (scatterByParts && multipartType() != QMailMessagePartContainerFwd::MultipartNone) {
QByteArray bound = QByteArray(2, '-') + boundary();
int next = data.indexOf(bound);
if (next < 0) {
qWarning() << "wrong structured undecoded data, no boundary found.";
return;
}
QByteArray undecodedData = data.left(next);
unsigned int i = 0;
int from = 0;
while (next > 0) {
from = next + bound.length();
from += data.at(from + 1) == '\r' && data.at(from + 2) == '\n' ? 2 : 1;
next = data.indexOf(bound, from);
if (next > 0 && i < partCount()) {
int len = next - from;
len -= data.at(next - 2) == '\r' && data.at(next - 1) == '\n' ? 2 : 1;
partAt(i++).setUndecodedData(data.mid(from, len), true);
}
}
// Need to add the terminator here, because we need to save how many
// carriage returns are following.
undecodedData.append(bound);
undecodedData.append(QByteArray(2, '-'));
undecodedData.append(data.mid(from + 1));
impl(this)->setUndecodedData(undecodedData);
} else {
impl(this)->setUndecodedData(data);
}
}
/*!
......@@ -8815,7 +8861,7 @@ QMailMessage QMailMessage::fromRfc2822(LongString& ls, bool storeUndecodedData)
// CR, LF or CRLF.
len -= (ls.mid(body_stop - 1, 1).toQByteArray()[0] == '\n') ? 1 : 2;
QByteArray raw = QByteArray(ls.mid(body_start, len).toQByteArray().data(), len); /* Do a copy here because data from LongString are volatile. */
sign->partAt(0).setUndecodedData(raw);
sign->partAt(0).setUndecodedData(raw, true);
}
}
......
......@@ -493,8 +493,8 @@ public:
// Undecoded data handling:
bool hasUndecodedData() const;
const QByteArray undecodedData() const;
void setUndecodedData(const QByteArray &data);
const QByteArray undecodedData(bool gatherAllParts = false) const;
void setUndecodedData(const QByteArray &data, bool scatterByParts = false);
private:
friend class QMailMessagePrivate;
......
......@@ -172,7 +172,7 @@ QMailCryptoFwd::SignatureResult QMailCryptoGPG::verifySignature(const QMailMessa
!signature.contentAvailable())
return QMailCryptoFwd::UnknownError;
QByteArray undecodedData = body.undecodedData();
QByteArray undecodedData = body.undecodedData(true);
switch (gpgme_err_code(gpgme_verify(signature.body().data(QMailMessageBodyFwd::Decoded).data(),
undecodedData.data()))) {
......
Date: Mon, 2 Jan 2017 00:00:44 +0100
To: debian-science@lists.debian.org
Subject: Re: Please add ros packages to robotics tasks
Message-ID: <20170101230027.c5eaduapbf26womo@vis.informatik.uni-osnabrueck.de>
Mail-Followup-To: debian-science@lists.debian.org
References: <20161230221400.GB32172@an3as.eu>
<20161230223230.jbds7hvuv2u4nq44@vis.informatik.uni-osnabrueck.de>
<20170101222729.GO32172@an3as.eu>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
protocol="application/pgp-signature"; boundary="k6l3pg2inhdzciti"
Content-Disposition: inline
In-Reply-To: <20170101222729.GO32172@an3as.eu>
Organization: The Debian Project
User-Agent: NeoMutt/20161126 (1.7.1)
--k6l3pg2inhdzciti
Content-Type: multipart/mixed; boundary="qip6aqgh66xchxw6"
Content-Disposition: inline
--qip6aqgh66xchxw6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi Andreas,
* Andreas Tille <andreas@an3as.eu> [2017-01-01 23:27]:
> I added these metapackages as well as their first dependencies in the
> following patch:
[..]
Thanks a lot, I had just cloned the repo when I found your commit :).
> Any DD has commit permissions and those who are working
> actively on robotics packages should maintain this task themselves.
I tried to commit the attached patch, but all blends seem to belong to
the scm_blends group, which I'm not part of (I found other DDs not
being in that group, so I don't think any DD has access).
Could you either give apply the attached patch or give me access to the
repo?
> BTW, you might like to consider a robotics Blend which enables you to
> use Blends tools to maintain the metapackages you created manually.
That sounds interesting. Could we still be part of the debian-science
team with that?
Cheers Jochen
--qip6aqgh66xchxw6
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0001-Remove-old-ROS-dependencies.patch"
Content-Transfer-Encoding: quoted-printable
=46rom 3a1a3413d4c460becb8a3c479f04da3890afc983 Mon Sep 17 00:00:00 2001
=46rom: Jochen Sprickerhof <git@jochen.sprickerhof.de>
Date: Sun, 1 Jan 2017 23:51:01 +0100
Subject: [PATCH] Remove old ROS dependencies
---
tasks/robotics | 2 --
1 file changed, 2 deletions(-)
diff --git a/tasks/robotics b/tasks/robotics
index 8ad5cc8..a09b595 100644
--- a/tasks/robotics
+++ b/tasks/robotics
@@ -132,8 +132,6 @@ Pkg-Description: framework for inference in Dynamic Bay=
esian Networks
applications.
=20
=20
-Depends: ros-mk, rosbuild, roslang, rosbash, python-rosclean, python-roscr=
eate, python-rosmake, python-rosunit
-
Depends: ros-desktop-full,
ros-desktop,
ros-perception,
--=20
2.11.0
--qip6aqgh66xchxw6--
--k6l3pg2inhdzciti
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEc7KZy9TurdzAF+h6W//cwljmlDMFAlhpihwACgkQW//cwljm
lDMn2BAAjzM99/fCxV46IteHIzg/1K2mGzRoW5V6uwx5444QmLMQC4qH7m++EKhO
0OfqRb4eyt2PcH/OrTV3T/6c33aQTlcI5GT2Bg5IkpJoUIzijx8dOtXoC9RHgd19
yh//Mbzc7G5p9ZpKCK7zUvJ9RnCAxZm2Bu8+juiNoY2ubvwOUKCqrnc/cnIIuZp5
VAUlBWJCehs1BXhjtdbmCfdiIOcZNbg2SER2DsrB1g1Uf31d9uScbuCx5VX7ohSQ
1Q386Bn+CwPRHiJup7+TPpLgRmoOW5pknwJnBsPT8arz7D/ISx2CZBFsBwXHAj8U
+Q1sPV5BUVthFbXRGoGJ67UNnJtj8D/thrgj0MoUEsGEz1qPFP/xm9uL0isLzXir
vaEEFVWGV5lL7pv78QxnSpdl0FdgUogsrJ2Em6qQ22dVF92lNnwb8GPd9zdhpN9H
6j0G4JWGT5axT+zUyQ0XWBHXo+FI7clRSRPIdnuqK0/MUAa/+B2598baUT02MHQR
zk9qUT7IaM8W+N02uI6nVAIYi9M0Ps27i4Llef8y76KF7Wfn7mdG6UhCqRlia3Qn
QV0/yJse4huWOHIPmWGPP380p5/5qLalkTnxuoi6QacCMv7+iQO4RV9/t0u5Ysmr
es1YPrnIG5m3geOuyKEkqdjucPWoCPcIqhv/zyZQAjkrqIk8VW0=
=/5ZM
-----END PGP SIGNATURE-----
--k6l3pg2inhdzciti--
......@@ -48,6 +48,7 @@ public slots:
void cleanup();
private slots:
void setUndecoded();
void verify_data();
void verify();
void sign_data();
......@@ -197,6 +198,30 @@ void tst_Crypto::cleanup()
{
}
void tst_Crypto::setUndecoded()
{
QFile f(QStringLiteral("%1/%2").arg(QCoreApplication::applicationDirPath(),
"testdata/multipart"));
if (!f.open(QIODevice::ReadOnly)) {
QFAIL("Mail file does not exist or cannot be opened for reading!");
}
QMailMessage msg = QMailMessage::fromRfc2822File(QStringLiteral("%1/%2").arg(QCoreApplication::applicationDirPath(),
"testdata/multipart"));
QVERIFY(msg.partAt(0).undecodedData().startsWith("Content-Type: multipart/mixed;"));
QVERIFY(msg.partAt(0).undecodedData().endsWith("Content-Disposition: inline\n\n\n--qip6aqgh66xchxw6--\n"));
QVERIFY(msg.partAt(0).undecodedData(true).startsWith("Content-Type: multipart/mixed; boundary=\"qip6aqgh66xchxw6\"\nContent-Disposition: inline\n\n\n--qip6aqgh66xchxw6\r\nContent-Type: text/plain; charset=us-ascii\n"));
QVERIFY(msg.partAt(0).undecodedData(true).endsWith("2.11.0\n\n\r\n--qip6aqgh66xchxw6--\n"));
QVERIFY(msg.partAt(0).partAt(0).undecodedData().startsWith("Content-Type: text/plain; charset=us-ascii"));
QVERIFY(msg.partAt(0).partAt(0).undecodedData().endsWith("Cheers Jochen\n"));
QVERIFY(msg.partAt(0).partAt(1).undecodedData().startsWith("Content-Type: text/x-diff; charset=us-ascii"));
QVERIFY(msg.partAt(0).partAt(1).undecodedData().endsWith("2.11.0\n\n"));
}
void tst_Crypto::verify_data()
{
QTest::addColumn<QString>("rfc2822Filename");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment