From 634782a53772ac38f04aeb32f0f357839b899750 Mon Sep 17 00:00:00 2001 From: Carlo Baratto Date: Wed, 11 Nov 2026 16:19:58 +0100 Subject: [PATCH] Leggere i testi del motore con la loro lunghezza (0.6.6) Il motore restituisce la lunghezza, non un terminatore: fromUtf8(buf) leggeva i residui del testo precedente (In -> Incal, Out -> Outal). La coda Local/Sent non si trovava per questo. Corretti cartelle, mittente e header. --- rpm/harbour-grumpydove.spec | 8 +++++++- src/enginebridge.cpp | 40 ++++++++++++++++++++++--------------- src/main.cpp | 4 ++-- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/rpm/harbour-grumpydove.spec b/rpm/harbour-grumpydove.spec index ef64da7..238cfde 100644 --- a/rpm/harbour-grumpydove.spec +++ b/rpm/harbour-grumpydove.spec @@ -1,6 +1,6 @@ Name: harbour-grumpydove Summary: Eudora-style mail interface, mobile prototype -Version: 0.6.5 +Version: 0.6.6 Release: 1 Group: Qt/Qt # Codice EUPL-1.2; le icone vengono dagli sprite di Eudora, BSD 3-Clause @@ -27,6 +27,12 @@ Icons come from the original project's Eudora bitmaps (BSD 3-Clause, Computer History Museum). %changelog +* Wed Nov 11 2026 Carlo Baratto - 0.6.6-1 +- Nomi delle cartelle corrotti nel ponte: il motore restituisce la lunghezza + del testo, non un terminatore, e leggerlo fino al primo zero si portava + dietro i residui del precedente ("In" diventava "Incal", "Out" "Outal"). + Per questo la coda Local/Sent non si trovava e l'invio si fermava. Corretti + anche mittente e header, che avevano lo stesso difetto * Wed Nov 11 2026 Carlo Baratto - 0.6.5-1 - L'invio scrive nel log del motore ogni passaggio e ogni motivo di stop ("ERR send: ..."): prima, se si fermava nel ponte, non restava traccia e non diff --git a/src/enginebridge.cpp b/src/enginebridge.cpp index 022fc78..63b62c1 100644 --- a/src/enginebridge.cpp +++ b/src/enginebridge.cpp @@ -227,6 +227,15 @@ bool EngineBridge::moveToTrash(int folder, int row) return ok; } +// Il motore restituisce la lunghezza del testo, non un terminatore: leggere +// il buffer fino al primo zero si porta dietro i residui del testo precedente +// ("In" che diventa "Incal"). Si legge sempre con la lunghezza. +static QString testoMotore(const char *buf, int n) +{ + if (n <= 0) return QString(); + return QString::fromUtf8(buf, n); +} + // L'indirizzo di chi ha scritto: il motore da' "Nome\tindirizzo". QString EngineBridge::senderOf(int folder, int row) { @@ -236,8 +245,7 @@ QString EngineBridge::senderOf(int folder, int row) char buf[1024]; const int n = s_sender(folder, id, buf, int(sizeof buf) - 1); if (n <= 0) return QString(); - buf[qMin(n, int(sizeof buf) - 1)] = '\0'; - const QString tutto = QString::fromUtf8(buf); + const QString tutto = testoMotore(buf, qMin(n, int(sizeof buf) - 1)); const int tab = tutto.indexOf(QLatin1Char('\t')); const QString indirizzo = tab >= 0 ? tutto.mid(tab + 1) : tutto; return indirizzo.trimmed(); @@ -253,8 +261,7 @@ QString EngineBridge::headerOf(int folder, int row, const QString &name) const int n = s_header(folder, id, name.toUtf8().constData(), buf, int(sizeof buf) - 1); if (n <= 0) return QString(); - buf[qMin(n, int(sizeof buf) - 1)] = '\0'; - return QString::fromUtf8(buf).trimmed(); + return testoMotore(buf, qMin(n, int(sizeof buf) - 1)).trimmed(); } // Una cella, come stringa UTF-8 letta dal motore. @@ -374,9 +381,10 @@ int EngineBridge::folderNamed(const QString &nome) int depth = 0; for (int i = 0; i < 500; i++) { buf[0] = '\0'; - if (s_folder(i, &depth, buf, int(sizeof buf) - 1) < 0) break; - buf[sizeof buf - 1] = '\0'; - if (QString::fromUtf8(buf).compare(nome, Qt::CaseInsensitive) == 0) + const int n = s_folder(i, &depth, buf, int(sizeof buf) - 1); + if (n < 0) break; + if (testoMotore(buf, qMin(n, int(sizeof buf) - 1)) + .compare(nome, Qt::CaseInsensitive) == 0) return i; } return -1; @@ -395,16 +403,16 @@ int EngineBridge::folderOut() int depth = 0; for (int i = 0; i < 500; i++) { buf[0] = '\0'; - if (s_folder(i, &depth, buf, int(sizeof buf) - 1) < 0) break; - buf[sizeof buf - 1] = '\0'; - const QString nome = QString::fromUtf8(buf); + const int n = s_folder(i, &depth, buf, int(sizeof buf) - 1); + if (n < 0) break; + const QString nome = testoMotore(buf, qMin(n, int(sizeof buf) - 1)); if (s_place) { char dove[1024]; dove[0] = '\0'; - if (s_place(i, dove, int(sizeof dove) - 1) > 0) { - dove[sizeof dove - 1] = '\0'; - const QString posto = QString::fromUtf8(dove); + const int m = s_place(i, dove, int(sizeof dove) - 1); + if (m > 0) { + const QString posto = testoMotore(dove, qMin(m, int(sizeof dove) - 1)); if (posto.compare(QLatin1String("Local\tSent"), Qt::CaseInsensitive) == 0) return i; // la coda vera if (posto.endsWith(QLatin1String("\tSent"))) @@ -427,9 +435,9 @@ QString EngineBridge::cartelleViste() int depth = 0; for (int i = 0; i < 500; i++) { buf[0] = '\0'; - if (s_folder(i, &depth, buf, int(sizeof buf) - 1) < 0) break; - buf[sizeof buf - 1] = '\0'; - nomi << QString::fromUtf8(buf); + const int n = s_folder(i, &depth, buf, int(sizeof buf) - 1); + if (n < 0) break; + nomi << testoMotore(buf, qMin(n, int(sizeof buf) - 1)); } return nomi.join(QStringLiteral(", ")); } diff --git a/src/main.cpp b/src/main.cpp index e737ee9..19a21bd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,9 +24,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) app->setOrganizationName(QStringLiteral("harbour")); app->setApplicationName(QStringLiteral("grumpydove")); - app->setApplicationVersion(QStringLiteral("0.6.5")); + app->setApplicationVersion(QStringLiteral("0.6.6")); - qDebug() << "harbour-grumpydove v0.6.5 build" << __DATE__ << __TIME__; + qDebug() << "harbour-grumpydove v0.6.6 build" << __DATE__ << __TIME__; // La sandbox di Sailfish (SailJail) non lascia vedere ~/Mail, ma il motore // legge il percorso del Maildir da GRUMPYDOVE_MAIL: si punta alla cartella