Bozze: salva in Drafts, riprendi, sostituisci per id (0.15.0)
Compose con Queue=0 scrive il messaggio senza metterlo in coda; la cartella e' Drafts (nuovo tipo 'draft' in folders()). Riprendendo una bozza il motore la sostituisce per id (Draft), non ne crea una seconda; dopo l'invio va nel cestino. Foglio di composizione estratto in foglioMessaggio(), usato da invio e bozza.
This commit is contained in:
1 parent
69f97d99b8
commit
d7549cedd0
6 files changed
+187
-22
No files matched your search
@@ -10,6 +10,7 @@ Page {
|
||||
|
||||
property string destinatario: ""
|
||||
property string copia: ""
|
||||
property string bcc: ""
|
||||
property string oggetto: ""
|
||||
property string corpo: ""
|
||||
property string mittente: ""
|
||||
@@ -19,6 +20,10 @@ Page {
|
||||
property var suggerimenti: []
|
||||
// Percorsi dei file da allegare: li legge il motore dal disco.
|
||||
property var allegati: []
|
||||
// Bozza che si sta riprendendo: cartella e riga; -1 = messaggio nuovo.
|
||||
property int bozzaCartella: -1
|
||||
property int bozzaRiga: -1
|
||||
property int bozzaId: -1
|
||||
|
||||
// Il "Da" si vede e si può correggere qui: se il campo in Account non è
|
||||
// stato salvato, l'invio non resta bloccato senza spiegazione.
|
||||
@@ -27,6 +32,31 @@ Page {
|
||||
page.mittente = account.mittente;
|
||||
else if (account.persona.indexOf("@") > 0)
|
||||
page.mittente = account.persona;
|
||||
if (page.bozzaRiga >= 0) page.riprendi();
|
||||
}
|
||||
|
||||
// Riprendere una bozza: i campi tornano come erano, allegati compresi.
|
||||
function riprendi() {
|
||||
var b = engine.bozza(page.bozzaCartella, page.bozzaRiga);
|
||||
page.destinatario = b.a;
|
||||
page.copia = b.cc;
|
||||
page.bcc = b.bcc;
|
||||
page.oggetto = b.oggetto;
|
||||
page.corpo = b.corpo;
|
||||
page.allegati = b.allegati ? b.allegati : [];
|
||||
if (b.da.length > 0) page.mittente = b.da;
|
||||
// L'id serve al motore per sostituire questa bozza invece di
|
||||
// crearne una seconda.
|
||||
page.bozzaId = engine.idOf(page.bozzaCartella, page.bozzaRiga);
|
||||
}
|
||||
|
||||
function salvaBozza() {
|
||||
page.errore = engine.salvaBozza(campoA.text, campoCc.text,
|
||||
campoBcc.text, campoDa.text,
|
||||
campoOggetto.text, campoCorpo.text,
|
||||
page.allegati, page.bozzaId);
|
||||
if (page.errore.length === 0)
|
||||
pageStack.pop();
|
||||
}
|
||||
|
||||
SilicaFlickable {
|
||||
@@ -113,6 +143,7 @@ Page {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
label: qsTr("Bcc")
|
||||
placeholderText: qsTr("destinatari nascosti, facoltativo")
|
||||
text: page.bcc
|
||||
inputMethodHints: Qt.ImhEmailCharactersOnly | Qt.ImhNoAutoUppercase
|
||||
EnterKey.enabled: true
|
||||
EnterKey.iconSource: "image://theme/icon-m-enter-next"
|
||||
@@ -172,6 +203,15 @@ Page {
|
||||
}
|
||||
}
|
||||
|
||||
Button {
|
||||
id: pulsanteBozza
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: qsTr("Salva bozza")
|
||||
preferredWidth: Theme.buttonWidthSmall
|
||||
enabled: !page.inviando
|
||||
onClicked: page.salvaBozza()
|
||||
}
|
||||
|
||||
Button {
|
||||
id: pulsanteInvia
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
@@ -284,6 +324,10 @@ Page {
|
||||
page.errore = motivo;
|
||||
return;
|
||||
}
|
||||
// Se il messaggio partiva da una bozza, la bozza ha finito il suo
|
||||
// lavoro: la si toglie di mezzo, altrimenti resta lì a confondere.
|
||||
if (page.bozzaRiga >= 0)
|
||||
engine.moveToTrash(page.bozzaCartella, page.bozzaRiga);
|
||||
page.inviando = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -255,6 +255,13 @@ Page {
|
||||
avvisoTimer.restart();
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr("Riprendi la bozza")
|
||||
visible: engine.folderType(page.cartella) === "draft"
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("ComposePage.qml"),
|
||||
{ "bozzaCartella": page.cartella,
|
||||
"bozzaRiga": page.riga })
|
||||
}
|
||||
MenuItem {
|
||||
text: page.mostraHtml ? qsTr("Vedi come testo")
|
||||
: qsTr("Vedi come HTML")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Name: harbour-grumpydove
|
||||
Summary: Eudora-style mail interface, mobile prototype
|
||||
Version: 0.14.0
|
||||
Version: 0.15.0
|
||||
Release: 1
|
||||
Group: Qt/Qt
|
||||
# Codice EUPL-1.2; le icone vengono dagli sprite di Eudora, BSD 3-Clause
|
||||
@@ -27,6 +27,11 @@ Icons come from the original project's Eudora bitmaps (BSD 3-Clause,
|
||||
Computer History Museum).
|
||||
|
||||
%changelog
|
||||
* Sat Nov 14 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.15.0-1
|
||||
- Bozze: "Salva bozza" scrive nella cartella Drafts (il motore con Queue=0 non
|
||||
la manda) e "Riprendi la bozza" riporta nel modulo destinatari, copie,
|
||||
oggetto, testo e allegati. Riprendendo, il motore sostituisce la bozza
|
||||
invece di crearne una seconda; dopo l'invio la bozza va nel cestino
|
||||
* Sat Nov 14 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.14.0-1
|
||||
- Controllo automatico della posta: ogni N minuti (0 = spento), impostato in
|
||||
Account. Quando arrivano messaggi nuovi compare una notifica di sistema, e
|
||||
|
||||
+113
-19
@@ -375,6 +375,12 @@ QString EngineBridge::headerOf(int folder, int row, const QString &name)
|
||||
return testoMotore(buf, qMin(n, int(sizeof buf) - 1)).trimmed();
|
||||
}
|
||||
|
||||
int EngineBridge::idOf(int folder, int row)
|
||||
{
|
||||
if (!s_id_of) return -1;
|
||||
return s_id_of(folder, row);
|
||||
}
|
||||
|
||||
// Una cella, come stringa UTF-8 letta dal motore.
|
||||
QString EngineBridge::cell(int folder, int row, int column)
|
||||
{
|
||||
@@ -444,6 +450,7 @@ QVariantList EngineBridge::folders()
|
||||
else if (e.nome == QLatin1String("INBOX") || e.nome == QLatin1String("In")) tipo = "in";
|
||||
else if (e.nome == QLatin1String("Sent") || e.nome == QLatin1String("Out")) tipo = "out";
|
||||
else if (e.nome == QLatin1String("Junk")) tipo = "junk";
|
||||
else if (e.nome == QLatin1String("Drafts")) tipo = "draft";
|
||||
else if (e.nome == QLatin1String("Trash")) tipo = "trash";
|
||||
|
||||
QVariantMap m;
|
||||
@@ -1045,6 +1052,110 @@ void EngineBridge::pollFiltri()
|
||||
emit ready();
|
||||
}
|
||||
|
||||
// Il foglio di composizione, nell'unico formato che Mail_Compose.Parse
|
||||
// conosce: campi "Nome: valore", riga vuota, corpo.
|
||||
QString EngineBridge::foglioMessaggio(const QString &to, const QString &cc,
|
||||
const QString &bcc, const QString &from,
|
||||
const QString &oggetto, const QString &corpo,
|
||||
const QStringList &allegati) const
|
||||
{
|
||||
QString foglio;
|
||||
foglio += QLatin1String("From: ") + from + QLatin1Char('\n');
|
||||
foglio += QLatin1String("To: ") + to.trimmed() + QLatin1Char('\n');
|
||||
if (!cc.trimmed().isEmpty())
|
||||
foglio += QLatin1String("Cc: ") + cc.trimmed() + QLatin1Char('\n');
|
||||
if (!bcc.trimmed().isEmpty())
|
||||
foglio += QLatin1String("Bcc: ") + bcc.trimmed() + QLatin1Char('\n');
|
||||
// Gli allegati: percorsi separati da punto e virgola, come li legge
|
||||
// Split_Paths di Mail_Compose. Un file che non si legge fa fallire la
|
||||
// composizione, quindi si scartano i percorsi vuoti.
|
||||
QStringList validi;
|
||||
for (int i = 0; i < allegati.size(); i++) {
|
||||
const QString p = allegati.at(i).trimmed();
|
||||
if (!p.isEmpty()) validi << p;
|
||||
}
|
||||
if (!validi.isEmpty())
|
||||
foglio += QLatin1String("Attached: ") + validi.join(QLatin1String("; "))
|
||||
+ QLatin1Char('\n');
|
||||
foglio += QLatin1String("Subject: ") + oggetto + QLatin1String("\n\n") + corpo;
|
||||
return foglio;
|
||||
}
|
||||
|
||||
// La cartella delle bozze: "Drafts" sul server; se non c'è, si ripiega su Out.
|
||||
int EngineBridge::folderDrafts()
|
||||
{
|
||||
const QVariantList tutte = folders();
|
||||
for (int i = 0; i < tutte.size(); i++) {
|
||||
const QVariantMap m = tutte.at(i).toMap();
|
||||
if (m.value(QStringLiteral("tipo")).toString() == QLatin1String("draft"))
|
||||
return m.value(QStringLiteral("folder")).toInt();
|
||||
}
|
||||
return folderOut();
|
||||
}
|
||||
|
||||
// Salvare una bozza: Queue = 0, così il messaggio non parte, e la cartella
|
||||
// di destinazione è Drafts. bozzaId >= 0 sostituisce quella ripresa.
|
||||
QString EngineBridge::salvaBozza(const QString &to, const QString &cc,
|
||||
const QString &bcc, const QString &da,
|
||||
const QString &oggetto, const QString &corpo,
|
||||
const QStringList &allegati, int bozzaId)
|
||||
{
|
||||
if (!s_compose) return tr("Il motore non è pronto");
|
||||
|
||||
const int drafts = folderDrafts();
|
||||
if (drafts < 0) {
|
||||
const QString m = tr("Manca la cartella delle bozze");
|
||||
logInvio("ERR bozza: " + m);
|
||||
return m;
|
||||
}
|
||||
|
||||
QString from = da.trimmed();
|
||||
if (from.isEmpty() && m_settings) from = m_settings->mittente().trimmed();
|
||||
|
||||
const QString foglio = foglioMessaggio(to, cc, bcc, from, oggetto, corpo,
|
||||
allegati);
|
||||
const QByteArray testo = foglio.toUtf8();
|
||||
const QByteArray nessunHtml;
|
||||
char stato[1024];
|
||||
stato[0] = '\0';
|
||||
const int id = s_compose(drafts, testo.constData(), testo.size(),
|
||||
nessunHtml.constData(), 0,
|
||||
0 /* non in coda */, 0 /* cifra */, 0 /* firma */,
|
||||
0 /* nuovo */, -1, -1, bozzaId, stato,
|
||||
int(sizeof stato) - 1);
|
||||
if (id < 0) {
|
||||
const QString m = QString::fromUtf8(stato, qMin(-id, int(sizeof stato) - 1));
|
||||
logInvio("ERR bozza: " + m);
|
||||
return m;
|
||||
}
|
||||
dropRows(drafts);
|
||||
logInvio(QString("bozza salvata: id %1 in %2").arg(id).arg(drafts));
|
||||
emit ready();
|
||||
return QString();
|
||||
}
|
||||
|
||||
// Rileggere una bozza per riprenderla: i campi del foglio e gli allegati.
|
||||
QVariantMap EngineBridge::bozza(int folder, int row)
|
||||
{
|
||||
QVariantMap m;
|
||||
m["a"] = headerOf(folder, row, QStringLiteral("To"));
|
||||
m["cc"] = headerOf(folder, row, QStringLiteral("Cc"));
|
||||
m["bcc"] = headerOf(folder, row, QStringLiteral("Bcc"));
|
||||
m["da"] = headerOf(folder, row, QStringLiteral("From"));
|
||||
m["oggetto"] = headerOf(folder, row, QStringLiteral("Subject"));
|
||||
m["corpo"] = body(folder, row);
|
||||
// I percorsi degli allegati li scrive il motore in questo header quando
|
||||
// il messaggio è una bozza (Mail_Compose.Draft_Attached).
|
||||
QStringList allegati;
|
||||
const QString attaccati =
|
||||
headerOf(folder, row, QStringLiteral("X-Grumpydove-Attached"));
|
||||
if (!attaccati.isEmpty())
|
||||
allegati = attaccati.split(QRegExp(QStringLiteral("\\s*;\\s*")),
|
||||
QString::SkipEmptyParts);
|
||||
m["allegati"] = allegati;
|
||||
return m;
|
||||
}
|
||||
|
||||
// Il giro dell'invio, come nell'originale: compose scrive il messaggio in Out
|
||||
// con il flag di coda, claim estrae quelli da mandare, send_start parla con il
|
||||
// server SMTP e send_poll riporta un messaggio per volta.
|
||||
@@ -1108,25 +1219,8 @@ QString EngineBridge::sendMessage(const QString &to, const QString &cc,
|
||||
|
||||
// Il foglio che il motore sa leggere: campi "Nome: valore", riga vuota,
|
||||
// poi il corpo (Mail_Compose.Parse).
|
||||
QString foglio;
|
||||
foglio += QLatin1String("From: ") + from + QLatin1Char('\n');
|
||||
foglio += QLatin1String("To: ") + to.trimmed() + QLatin1Char('\n');
|
||||
if (!cc.trimmed().isEmpty())
|
||||
foglio += QLatin1String("Cc: ") + cc.trimmed() + QLatin1Char('\n');
|
||||
if (!bcc.trimmed().isEmpty())
|
||||
foglio += QLatin1String("Bcc: ") + bcc.trimmed() + QLatin1Char('\n');
|
||||
// Gli allegati: percorsi separati da punto e virgola, come li legge
|
||||
// Split_Paths di Mail_Compose. Un file che non si legge fa fallire la
|
||||
// composizione, quindi si scartano i percorsi vuoti.
|
||||
QStringList validi;
|
||||
for (int i = 0; i < allegati.size(); i++) {
|
||||
const QString p = allegati.at(i).trimmed();
|
||||
if (!p.isEmpty()) validi << p;
|
||||
}
|
||||
if (!validi.isEmpty())
|
||||
foglio += QLatin1String("Attached: ") + validi.join(QLatin1String("; "))
|
||||
+ QLatin1Char('\n');
|
||||
foglio += QLatin1String("Subject: ") + oggetto + QLatin1String("\n\n") + corpo;
|
||||
const QString foglio = foglioMessaggio(to, cc, bcc, from, oggetto, corpo,
|
||||
allegati);
|
||||
|
||||
const QByteArray testo = foglio.toUtf8();
|
||||
const QByteArray nessunHtml;
|
||||
|
||||
@@ -75,6 +75,9 @@ public:
|
||||
// Per rispondere serve l'indirizzo, non solo il nome che sta in colonna.
|
||||
Q_INVOKABLE QString senderOf(int folder, int row);
|
||||
Q_INVOKABLE QString headerOf(int folder, int row, const QString &name);
|
||||
// L'id interno di un messaggio: serve alle bozze, che si sostituiscono
|
||||
// per id e non per riga.
|
||||
Q_INVOKABLE int idOf(int folder, int row);
|
||||
// "non letto" non e' "stato vuoto": la regola sta in un posto solo.
|
||||
Q_INVOKABLE bool isUnread(int folder, int row);
|
||||
Q_INVOKABLE QString folderType(int folder);
|
||||
@@ -112,6 +115,13 @@ public:
|
||||
const QString &bcc, const QString &da,
|
||||
const QString &oggetto, const QString &corpo,
|
||||
const QStringList &allegati);
|
||||
// Bozze: si salvano nella cartella Drafts; bozzaId >= 0 sostituisce quella
|
||||
// che si sta riprendendo (l'id, non la riga).
|
||||
Q_INVOKABLE QString salvaBozza(const QString &to, const QString &cc,
|
||||
const QString &bcc, const QString &da,
|
||||
const QString &oggetto, const QString &corpo,
|
||||
const QStringList &allegati, int bozzaId);
|
||||
Q_INVOKABLE QVariantMap bozza(int folder, int row);
|
||||
|
||||
signals:
|
||||
void ready();
|
||||
@@ -187,6 +197,11 @@ private:
|
||||
// Filtri: fase 1 impara dalle cartelle, fase 2 archivia i messaggi.
|
||||
void avviaFiltri(bool apprendimento);
|
||||
void pollFiltri();
|
||||
QString foglioMessaggio(const QString &to, const QString &cc,
|
||||
const QString &bcc, const QString &from,
|
||||
const QString &oggetto, const QString &corpo,
|
||||
const QStringList &allegati) const;
|
||||
int folderDrafts();
|
||||
QTimer *m_filtriTimer = nullptr;
|
||||
QString m_filtriImpara;
|
||||
QString m_filtriArchivia;
|
||||
|
||||
+2
-2
@@ -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.14.0"));
|
||||
app->setApplicationVersion(QStringLiteral("0.15.0"));
|
||||
|
||||
qDebug() << "harbour-grumpydove v0.14.0 build" << __DATE__ << __TIME__;
|
||||
qDebug() << "harbour-grumpydove v0.15.0 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
|
||||
|
||||
Reference in new issue
Block a user