Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c23a9ee5b3 | ||
|
|
abbf5b4c5c | ||
|
|
ca7d4f66e4 | ||
|
|
634782a537 | ||
|
|
044d3f4b6d | ||
|
|
fb789ef823 | ||
|
|
30cb753648 | ||
|
|
148ac1cd20 | ||
|
|
91c64eb290 | ||
|
|
1c675bf3a3 | ||
|
|
655636e652 | ||
|
|
79eee96199 |
No files matched your search
@@ -21,16 +21,17 @@ mobile sono miei.
|
||||
|
||||
Il progetto originale è EUPL-1.2; anche questo porting resta EUPL-1.2.
|
||||
|
||||
## Stato: 0.5.2
|
||||
## Stato: 0.6.0
|
||||
|
||||
Installabile e usabile per leggere la posta. L'invio **non** è ancora collegato.
|
||||
Installabile e usabile: si legge e si manda la posta.
|
||||
|
||||
Funziona oggi:
|
||||
|
||||
- **Cartelle** dal motore, con conteggio dei non letti; account in cima e
|
||||
cartelle rientrate per profondità, come nell'albero di Eudora.
|
||||
- **Configurazione dell'account** dentro l'app (IMAP: server, porta,
|
||||
STARTTLS/TLS, utente, password, quanti messaggi tenere per cartella).
|
||||
STARTTLS/TLS, utente, password, quanti messaggi tenere per cartella;
|
||||
più l'**indirizzo del mittente**, che è il From dei messaggi in uscita).
|
||||
- **Scarico della posta** con avanzamento a schermo, cartella per cartella.
|
||||
- **Elenco messaggi** dal più nuovo al più vecchio, non letti in grassetto con
|
||||
barra a sinistra, filtro per i soli non letti.
|
||||
@@ -45,14 +46,14 @@ Funziona oggi:
|
||||
- **Rispondi** (con l'indirizzo vero del mittente, non solo il nome) e
|
||||
**Rispondi a tutti** (mittente, destinatari e copie, senza te e senza
|
||||
doppioni).
|
||||
- **Invio**: il messaggio entra nella coda del motore, parte con SMTP e la
|
||||
copia resta in Sent sul server. A, Cc, Oggetto, Testo; esiti a schermo.
|
||||
- **Copertina** con i non letti totali.
|
||||
- La posta resta dopo la chiusura: il Maildir vive nella cartella dati
|
||||
dell'app, non in `~/Mail` (vedi sotto).
|
||||
|
||||
## Cosa manca
|
||||
|
||||
- **Invio**: la pagina di composizione si compila ma non manda nulla. Serve
|
||||
collegare `gd_compose_fn` e la coda di invio del motore.
|
||||
- **HTML**: le mail arrivano come testo. L'originale ha una vista senza script
|
||||
né stili remoti, con le immagini remote solo su richiesta — va portata.
|
||||
- **Ricerca**, filtri, PGP/S-MIME, rubrica CardDAV, JMAP: il motore li ha, la
|
||||
|
||||
+82
-12
@@ -1,14 +1,28 @@
|
||||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
// Composizione. Nel prototipo l'invio e' finto: mostra la conferma e torna
|
||||
// indietro, per valutare il flusso dei campi su telefono.
|
||||
// Composizione e invio. Il motore mette il messaggio nella coda (Out), lo
|
||||
// manda con SMTP e lascia la copia in Sent; qui si segue l'esito.
|
||||
Page {
|
||||
id: page
|
||||
|
||||
property string destinatario: ""
|
||||
property string copia: ""
|
||||
property string oggetto: ""
|
||||
property string corpo: ""
|
||||
property string mittente: ""
|
||||
|
||||
property bool inviando: false
|
||||
property string errore: ""
|
||||
|
||||
// Il "Da" si vede e si può correggere qui: se il campo in Account non è
|
||||
// stato salvato, l'invio non resta bloccato senza spiegazione.
|
||||
Component.onCompleted: {
|
||||
if (account.mittente.length > 0)
|
||||
page.mittente = account.mittente;
|
||||
else if (account.persona.indexOf("@") > 0)
|
||||
page.mittente = account.persona;
|
||||
}
|
||||
|
||||
SilicaFlickable {
|
||||
anchors.fill: parent
|
||||
@@ -23,16 +37,42 @@ Page {
|
||||
width: parent.width
|
||||
spacing: Theme.paddingMedium
|
||||
|
||||
TextField {
|
||||
id: campoDa
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
label: qsTr("Da")
|
||||
placeholderText: qsTr("il tuo indirizzo")
|
||||
text: page.mittente
|
||||
inputMethodHints: Qt.ImhEmailCharactersOnly | Qt.ImhNoAutoUppercase
|
||||
EnterKey.enabled: true
|
||||
EnterKey.iconSource: "image://theme/icon-m-enter-next"
|
||||
EnterKey.onClicked: campoA.forceActiveFocus()
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: campoA
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
label: qsTr("A")
|
||||
placeholderText: qsTr("indirizzo")
|
||||
placeholderText: qsTr("indirizzo, anche piu' di uno")
|
||||
text: page.destinatario
|
||||
inputMethodHints: Qt.ImhEmailCharactersOnly | Qt.ImhNoAutoUppercase
|
||||
EnterKey.enabled: true
|
||||
EnterKey.iconSource: "image://theme/icon-m-enter-next"
|
||||
EnterKey.onClicked: campoCc.forceActiveFocus()
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: campoCc
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
label: qsTr("Cc")
|
||||
placeholderText: qsTr("facoltativo")
|
||||
text: page.copia
|
||||
inputMethodHints: Qt.ImhEmailCharactersOnly | Qt.ImhNoAutoUppercase
|
||||
EnterKey.enabled: true
|
||||
EnterKey.iconSource: "image://theme/icon-m-enter-next"
|
||||
EnterKey.onClicked: campoOggetto.forceActiveFocus()
|
||||
}
|
||||
|
||||
@@ -59,9 +99,11 @@ Page {
|
||||
}
|
||||
|
||||
Button {
|
||||
id: pulsanteInvia
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: qsTr("Invia")
|
||||
text: page.inviando ? qsTr("Invio in corso…") : qsTr("Invia")
|
||||
preferredWidth: Theme.buttonWidthSmall
|
||||
enabled: !page.inviando
|
||||
onClicked: page.invia()
|
||||
}
|
||||
|
||||
@@ -69,25 +111,53 @@ Page {
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: qsTr("Nel prototipo non parte nulla: i dati sono finti.")
|
||||
text: page.errore
|
||||
visible: page.errore.length > 0
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
color: Theme.secondaryColor
|
||||
color: Theme.highlightColor
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
Button {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: qsTr("Apri Account")
|
||||
preferredWidth: Theme.buttonWidthSmall
|
||||
visible: page.errore.indexOf("Account") >= 0
|
||||
|| page.errore.indexOf("SMTP") >= 0
|
||||
|| page.errore.indexOf("mittente") >= 0
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml"))
|
||||
}
|
||||
}
|
||||
|
||||
VerticalScrollDecorator { }
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: engine
|
||||
onSendFinished: {
|
||||
page.inviando = false;
|
||||
if (falliti === 0) {
|
||||
avviso.text = inviati === 1 ? qsTr("Messaggio inviato")
|
||||
: qsTr("%1 messaggi inviati").arg(inviati);
|
||||
avvisoTimer.restart();
|
||||
timerPop.restart();
|
||||
} else {
|
||||
page.errore = esito.length > 0 ? esito
|
||||
: qsTr("Invio non riuscito");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function invia() {
|
||||
if (campoA.text.length === 0) {
|
||||
avviso.text = qsTr("Manca il destinatario");
|
||||
avvisoTimer.restart();
|
||||
page.errore = "";
|
||||
const motivo = engine.sendMessage(campoA.text, campoCc.text, "",
|
||||
campoDa.text,
|
||||
campoOggetto.text, campoCorpo.text);
|
||||
if (motivo.length > 0) {
|
||||
page.errore = motivo;
|
||||
return;
|
||||
}
|
||||
avviso.text = qsTr("Messaggio inviato");
|
||||
avvisoTimer.restart();
|
||||
timerPop.restart();
|
||||
page.inviando = true;
|
||||
}
|
||||
|
||||
Label {
|
||||
|
||||
@@ -79,6 +79,12 @@ Page {
|
||||
text: page.soloNonLetti ? qsTr("Mostra tutti") : qsTr("Solo non letti")
|
||||
onClicked: { page.soloNonLetti = !page.soloNonLetti; page.carica() }
|
||||
}
|
||||
MenuItem {
|
||||
// Il cestino si svuota da qui, dove lo si sta guardando.
|
||||
text: qsTr("Svuota il cestino")
|
||||
visible: engine.folderType(page.cartella) === "trash"
|
||||
onClicked: page.chiediSvuota()
|
||||
}
|
||||
}
|
||||
|
||||
delegate: BackgroundItem {
|
||||
@@ -162,4 +168,14 @@ Page {
|
||||
color: Theme.secondaryColor
|
||||
}
|
||||
}
|
||||
|
||||
// Svuotare e' irreversibile: Sailfish da' qualche secondo per ripensarci.
|
||||
RemorseItem { id: remorse }
|
||||
|
||||
function chiediSvuota() {
|
||||
remorse.execute(qsTr("Svuoto il cestino"), function() {
|
||||
engine.emptyTrash(page.cartella);
|
||||
page.carica();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,16 @@ Page {
|
||||
onTextChanged: account.persona = text
|
||||
}
|
||||
|
||||
TextField {
|
||||
width: parent.width - 2 * Theme.horizontalPageMargin
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
label: qsTr("Indirizzo del mittente")
|
||||
placeholderText: qsTr("nome@example.org")
|
||||
inputMethodHints: Qt.ImhEmailCharactersOnly | Qt.ImhNoAutoUppercase
|
||||
text: account.mittente
|
||||
onTextChanged: account.mittente = text.trim()
|
||||
}
|
||||
|
||||
SectionHeader { text: qsTr("Posta in arrivo (IMAP)") }
|
||||
|
||||
TextField {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Name: harbour-grumpydove
|
||||
Summary: Eudora-style mail interface, mobile prototype
|
||||
Version: 0.5.4
|
||||
Version: 0.6.9
|
||||
Release: 1
|
||||
Group: Qt/Qt
|
||||
# Codice EUPL-1.2; le icone vengono dagli sprite di Eudora, BSD 3-Clause
|
||||
@@ -27,6 +27,55 @@ Icons come from the original project's Eudora bitmaps (BSD 3-Clause,
|
||||
Computer History Museum).
|
||||
|
||||
%changelog
|
||||
* Wed Nov 11 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.6.9-1
|
||||
- Svuota il cestino agiva sulla prima cartella chiamata "Trash", che con piu'
|
||||
account e' quella locale e vuota: i messaggi del cestino dell'account
|
||||
restavano. Ora svuota la cartella che si sta guardando
|
||||
* Wed Nov 11 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.6.8-1
|
||||
- Svuota il cestino: nel menu della cartella Trash, con la conferma che Sailfish
|
||||
da' alle azioni irreversibili (RemorseItem). Usa Empty del motore, come la
|
||||
vista originale
|
||||
* Wed Nov 11 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.6.7-1
|
||||
- Dopo l'invio il controllo posta parte da solo: e' quello che porta sul server
|
||||
la copia del messaggio (append). Prima restava solo nella coda locale
|
||||
Local/Sent, che e' l'"Out" di Eudora
|
||||
* Wed Nov 11 2026 Carlo Baratto <carlo@carlobaratto.it> - 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 <carlo@carlobaratto.it> - 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
|
||||
c'era modo di capire dall'esterno
|
||||
* Wed Nov 11 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.6.4-1
|
||||
- Il mittente (From) e' un campo della pagina di composizione, precompilato da
|
||||
Account: il salvataggio del campo in Account non arrivava al file, e l'invio
|
||||
si bloccava senza che si vedesse dove metterci le mani. Scritto una volta,
|
||||
resta per le volte dopo
|
||||
* Wed Nov 11 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.6.3-1
|
||||
- Se l'invio si ferma per mittente o SMTP, sotto l'errore compare "Apri
|
||||
Account": il messaggio del motore ("The From line has no address") non dice
|
||||
dove metterci le mani
|
||||
* Wed Nov 11 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.6.2-1
|
||||
- La coda di invio si cerca per posizione, non per nome: place da'
|
||||
"account<TAB>cartella" e la coda e' "Local<TAB>Sent". Cercarla come "Out" o
|
||||
"Sent" falliva perche' il nome mostrato non coincide sempre
|
||||
- Se la coda non si trova, il messaggio elenca le cartelle che il motore vede
|
||||
(per capire, non per indovinare)
|
||||
* Wed Nov 11 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.6.1-1
|
||||
- "Manca la cartella Out": la coda di invio e' Local/Sent, che il motore mostra
|
||||
come "Out" ma la vista nasconde quando e' vuota. Ora si chiede al motore
|
||||
direttamente (con la Sent di Local come ripiego)
|
||||
- Il From non veniva compilato: la configurazione non aveva un indirizzo per
|
||||
il mittente. Aggiunto "Indirizzo del mittente" in Account, usato nel foglio
|
||||
di composizione
|
||||
* Wed Nov 11 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.6.0-1
|
||||
- Invio: il messaggio va nella coda Out con il foglio che il motore sa
|
||||
leggere (To/Cc/Bcc/Subject, riga vuota, corpo), poi claim, send_start con la
|
||||
riga SMTP dell'account e send_poll fino alla fine; la copia in Sent la mette
|
||||
queue_sent. Esiti a schermo, e la lista delle cartelle si aggiorna
|
||||
* Wed Nov 11 2026 Carlo Baratto <carlo@carlobaratto.it> - 0.5.4-1
|
||||
- "Letto" era considerato "stato vuoto": il motore scrive invece uno spazio
|
||||
(U = non letto, ' ' = letto, piu' Q/D/Z/S/R/F). Il confronto con "" rendeva
|
||||
|
||||
@@ -26,6 +26,7 @@ void AccountSettings::load()
|
||||
{
|
||||
QSettings s(path(), QSettings::IniFormat);
|
||||
m_persona = s.value("account/persona").toString();
|
||||
m_mittente = s.value("account/mittente").toString();
|
||||
m_imapHost = s.value("account/imap_host").toString();
|
||||
m_imapPort = s.value("account/imap_port", 993).toInt();
|
||||
m_imapSecurity = s.value("account/imap_security", 2).toInt();
|
||||
@@ -43,6 +44,7 @@ void AccountSettings::save()
|
||||
{
|
||||
QSettings s(path(), QSettings::IniFormat);
|
||||
s.setValue("account/persona", m_persona);
|
||||
s.setValue("account/mittente", m_mittente);
|
||||
s.setValue("account/imap_host", m_imapHost);
|
||||
s.setValue("account/imap_port", m_imapPort);
|
||||
s.setValue("account/imap_security", m_imapSecurity);
|
||||
@@ -60,6 +62,7 @@ void AccountSettings::save()
|
||||
}
|
||||
|
||||
void AccountSettings::setPersona(const QString &v) { if (m_persona != v) { m_persona = v; emit changed(); } }
|
||||
void AccountSettings::setMittente(const QString &v) { if (m_mittente != v) { m_mittente = v; emit changed(); } }
|
||||
void AccountSettings::setImapHost(const QString &v) { if (m_imapHost != v) { m_imapHost = v; emit changed(); } }
|
||||
void AccountSettings::setImapPort(int v) { if (m_imapPort != v) { m_imapPort = v; emit changed(); } }
|
||||
void AccountSettings::setImapSecurity(int v) { if (m_imapSecurity != v) { m_imapSecurity = v; emit changed(); } }
|
||||
|
||||
@@ -12,6 +12,8 @@ class AccountSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString persona READ persona WRITE setPersona NOTIFY changed)
|
||||
// L'indirizzo che finisce nel From: senza, il messaggio non ha mittente.
|
||||
Q_PROPERTY(QString mittente READ mittente WRITE setMittente NOTIFY changed)
|
||||
Q_PROPERTY(QString imapHost READ imapHost WRITE setImapHost NOTIFY changed)
|
||||
Q_PROPERTY(int imapPort READ imapPort WRITE setImapPort NOTIFY changed)
|
||||
Q_PROPERTY(int imapSecurity READ imapSecurity WRITE setImapSecurity NOTIFY changed)
|
||||
@@ -26,6 +28,7 @@ public:
|
||||
explicit AccountSettings(QObject *parent = nullptr);
|
||||
|
||||
QString persona() const { return m_persona; }
|
||||
QString mittente() const { return m_mittente; }
|
||||
QString imapHost() const { return m_imapHost; }
|
||||
int imapPort() const { return m_imapPort; }
|
||||
int imapSecurity() const { return m_imapSecurity; }
|
||||
@@ -37,6 +40,7 @@ public:
|
||||
int keep() const { return m_keep; }
|
||||
|
||||
void setPersona(const QString &v);
|
||||
void setMittente(const QString &v);
|
||||
void setImapHost(const QString &v);
|
||||
void setImapPort(int v);
|
||||
void setImapSecurity(int v);
|
||||
@@ -62,7 +66,7 @@ private:
|
||||
static QString path();
|
||||
void load();
|
||||
|
||||
QString m_persona, m_imapHost, m_user, m_password;
|
||||
QString m_persona, m_mittente, m_imapHost, m_user, m_password;
|
||||
QString m_smtpHost, m_smtpPassword;
|
||||
int m_imapPort, m_imapSecurity, m_smtpPort, m_smtpSecurity, m_keep;
|
||||
};
|
||||
|
||||
+314
-5
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QRegularExpression>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QHash>
|
||||
@@ -33,6 +34,15 @@ gd_sort_fn EngineBridge::s_sort = nullptr;
|
||||
gd_absorb_fn EngineBridge::s_absorb = nullptr;
|
||||
gd_text_fn EngineBridge::s_sender = nullptr;
|
||||
gd_header_fn EngineBridge::s_header = nullptr;
|
||||
gd_compose_fn EngineBridge::s_compose = nullptr;
|
||||
gd_claim_fn EngineBridge::s_claim = nullptr;
|
||||
gd_send_start_fn EngineBridge::s_send_start = nullptr;
|
||||
gd_find_poll_fn EngineBridge::s_send_poll = nullptr;
|
||||
gd_send_done_fn EngineBridge::s_send_done = nullptr;
|
||||
gd_queue_sent_fn EngineBridge::s_queue_sent = nullptr;
|
||||
gd_place_fn EngineBridge::s_place = nullptr;
|
||||
gd_log_fn EngineBridge::s_log = nullptr;
|
||||
gd_empty_fn EngineBridge::s_empty = nullptr;
|
||||
|
||||
// Colonne del motore (enum Column di qt_shim.cpp)
|
||||
enum Column { Status, Priority, Attachment, Label, Who, Date, Size, Subject, Junk };
|
||||
@@ -58,7 +68,13 @@ void EngineBridge::keepCallbacks(gd_folder_fn folder, gd_open_fn open, gd_cell_f
|
||||
gd_find_start_fn imap_start, gd_find_poll_fn imap_poll,
|
||||
gd_rescan_fn rescan, gd_text_fn attachments,
|
||||
gd_sort_fn sort, gd_absorb_fn absorb,
|
||||
gd_text_fn sender, gd_header_fn header)
|
||||
gd_text_fn sender, gd_header_fn header,
|
||||
gd_compose_fn compose, gd_claim_fn claim,
|
||||
gd_send_start_fn send_start,
|
||||
gd_find_poll_fn send_poll,
|
||||
gd_send_done_fn send_done,
|
||||
gd_queue_sent_fn queue_sent, gd_place_fn place,
|
||||
gd_log_fn log, gd_empty_fn empty)
|
||||
{
|
||||
s_folder = folder;
|
||||
s_open = open;
|
||||
@@ -77,6 +93,15 @@ void EngineBridge::keepCallbacks(gd_folder_fn folder, gd_open_fn open, gd_cell_f
|
||||
s_absorb = absorb;
|
||||
s_sender = sender;
|
||||
s_header = header;
|
||||
s_compose = compose;
|
||||
s_claim = claim;
|
||||
s_send_start = send_start;
|
||||
s_send_poll = send_poll;
|
||||
s_send_done = send_done;
|
||||
s_queue_sent = queue_sent;
|
||||
s_place = place;
|
||||
s_log = log;
|
||||
s_empty = empty;
|
||||
if (s_instance) {
|
||||
emit s_instance->ready();
|
||||
}
|
||||
@@ -204,6 +229,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)
|
||||
{
|
||||
@@ -213,8 +247,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();
|
||||
@@ -230,8 +263,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.
|
||||
@@ -341,6 +373,283 @@ QString EngineBridge::folderType(int folder)
|
||||
return QString();
|
||||
}
|
||||
|
||||
// Una cartella per nome, chiesta direttamente al motore: folders() e' la
|
||||
// vista, che nasconde le cartelle locali vuote — e la coda di invio e' una di
|
||||
// quelle.
|
||||
int EngineBridge::folderNamed(const QString &nome)
|
||||
{
|
||||
if (!s_folder) return -1;
|
||||
char buf[512];
|
||||
int depth = 0;
|
||||
for (int i = 0; i < 500; i++) {
|
||||
buf[0] = '\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;
|
||||
}
|
||||
|
||||
// La coda di invio. Il nome mostrato non basta ("Out" o "Sent" a seconda dei
|
||||
// casi e delle lingue), quindi si chiede al motore la posizione: place da'
|
||||
// "account<TAB>cartella" e la coda e' "Local<TAB>Sent".
|
||||
int EngineBridge::folderOut()
|
||||
{
|
||||
if (!s_folder) return -1;
|
||||
|
||||
int perNome = -1;
|
||||
int sentAltrove = -1;
|
||||
char buf[512];
|
||||
int depth = 0;
|
||||
for (int i = 0; i < 500; i++) {
|
||||
buf[0] = '\0';
|
||||
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';
|
||||
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")))
|
||||
sentAltrove = i;
|
||||
}
|
||||
}
|
||||
if (nome.compare(QLatin1String("Out"), Qt::CaseInsensitive) == 0)
|
||||
perNome = i;
|
||||
}
|
||||
if (perNome >= 0) return perNome; // il nome che usa la vista
|
||||
return sentAltrove;
|
||||
}
|
||||
|
||||
// Per il messaggio d'errore: cosa il motore dice di avere, senza indovinare.
|
||||
QString EngineBridge::cartelleViste()
|
||||
{
|
||||
if (!s_folder) return QStringLiteral("(motore non pronto)");
|
||||
QStringList nomi;
|
||||
char buf[512];
|
||||
int depth = 0;
|
||||
for (int i = 0; i < 500; i++) {
|
||||
buf[0] = '\0';
|
||||
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(", "));
|
||||
}
|
||||
|
||||
void EngineBridge::logInvio(const QString &riga)
|
||||
{
|
||||
if (s_log) s_log(riga.toUtf8().constData());
|
||||
}
|
||||
|
||||
// Svuota il cestino, come fa la vista originale: la cartella "Trash" e la
|
||||
// funzione Empty del motore. Restituisce quanti messaggi sono spariti.
|
||||
int EngineBridge::emptyTrash(int folder)
|
||||
{
|
||||
if (!s_empty) return -1;
|
||||
// Il cestino che si sta guardando, non "il primo chiamato Trash": con piu'
|
||||
// account ce n'e' uno per account e si finiva su quello locale, vuoto.
|
||||
const int cestino = folder >= 0 ? folder : folderNamed(QStringLiteral("Trash"));
|
||||
if (cestino < 0) {
|
||||
logInvio("ERR trash: nessun cestino");
|
||||
return -1;
|
||||
}
|
||||
const int rimossi = s_empty(cestino);
|
||||
if (s_commit) s_commit(cestino);
|
||||
if (s_absorb) s_absorb(cestino);
|
||||
dropRows(cestino);
|
||||
if (s_rescan) s_rescan();
|
||||
logInvio(QString("trash: %1 messaggi rimossi").arg(rimossi));
|
||||
QTimer::singleShot(0, this, [this] { emit ready(); });
|
||||
return rimossi;
|
||||
}
|
||||
|
||||
// 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.
|
||||
QString EngineBridge::sendMessage(const QString &to, const QString &cc,
|
||||
const QString &bcc, const QString &da,
|
||||
const QString &oggetto, const QString &corpo)
|
||||
{
|
||||
if (!s_compose || !s_claim || !s_send_start || !s_send_poll) {
|
||||
const QString m = tr("Il motore non è pronto");
|
||||
logInvio("ERR send: " + m);
|
||||
return m;
|
||||
}
|
||||
|
||||
const int out = folderOut();
|
||||
if (out < 0) {
|
||||
const QString m = tr("Manca la cartella di uscita. Il motore vede: %1")
|
||||
.arg(cartelleViste());
|
||||
logInvio("ERR send: " + m);
|
||||
return m;
|
||||
}
|
||||
|
||||
const QString config = m_settings ? m_settings->smtpLine() : QString();
|
||||
if (config.isEmpty()) {
|
||||
const QString m = tr("SMTP non configurato: controlla l'account");
|
||||
logInvio("ERR send: " + m);
|
||||
return m;
|
||||
}
|
||||
|
||||
if (to.trimmed().isEmpty()) {
|
||||
const QString m = tr("Manca il destinatario");
|
||||
logInvio("ERR send: " + m);
|
||||
return m;
|
||||
}
|
||||
|
||||
// Il From: senza, il messaggio parte senza mittente e il motore non
|
||||
// trova nemmeno la personalità a cui appartiene. Arriva dalla pagina di
|
||||
// composizione, che lo mostra: cosi' non dipende dal fatto che il campo
|
||||
// in Account sia stato salvato.
|
||||
QString from = da.trimmed();
|
||||
if (from.isEmpty() && m_settings)
|
||||
from = m_settings->mittente().trimmed();
|
||||
if (from.isEmpty() && m_settings && m_settings->persona().contains(QLatin1Char('@')))
|
||||
from = m_settings->persona().trimmed();
|
||||
if (from.isEmpty()) {
|
||||
const QString m = tr("Manca l'indirizzo del mittente: scrivilo nel campo «Da»");
|
||||
logInvio("ERR send: " + m);
|
||||
return m;
|
||||
}
|
||||
if (from.indexOf(QLatin1Char('@')) < 1) {
|
||||
const QString m = tr("«%1» non è un indirizzo: manca la parte dopo la @").arg(from);
|
||||
logInvio("ERR send: " + m);
|
||||
return m;
|
||||
}
|
||||
|
||||
// Se l'hai scritto qui, vale anche per le prossime volte.
|
||||
if (m_settings && m_settings->mittente().compare(from, Qt::CaseInsensitive) != 0) {
|
||||
m_settings->setMittente(from);
|
||||
m_settings->save();
|
||||
}
|
||||
|
||||
// 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');
|
||||
foglio += QLatin1String("Subject: ") + oggetto + QLatin1String("\n\n") + corpo;
|
||||
|
||||
const QByteArray testo = foglio.toUtf8();
|
||||
const QByteArray nessunHtml;
|
||||
char stato[1024];
|
||||
stato[0] = '\0';
|
||||
const int salvato = s_compose(out, testo.constData(), testo.size(),
|
||||
nessunHtml.constData(), 0,
|
||||
1 /* in coda */, 0 /* cifra */, 0 /* firma */,
|
||||
0 /* nessun originale */, -1, -1, -1,
|
||||
stato, int(sizeof stato) - 1);
|
||||
if (salvato < 0) {
|
||||
const QString motivo = QString::fromUtf8(stato).trimmed();
|
||||
const QString m = motivo.isEmpty() ? tr("Il motore ha rifiutato il messaggio")
|
||||
: motivo;
|
||||
logInvio("ERR send: compose: " + m);
|
||||
return m;
|
||||
}
|
||||
|
||||
QByteArray coda(1 << 20, '\0');
|
||||
const int usati = s_claim(out, coda.data(), coda.size());
|
||||
if (usati <= 0) {
|
||||
const QString m = tr("Niente in coda da mandare");
|
||||
logInvio("ERR send: " + m);
|
||||
return m;
|
||||
}
|
||||
coda.truncate(usati);
|
||||
logInvio(QString("send: coda %1, %2 byte, da %3, a %4")
|
||||
.arg(out).arg(usati).arg(from).arg(to.trimmed()));
|
||||
|
||||
// Il nome della personalità serve alla copia in Sent sul server.
|
||||
QString persona = m_settings->persona().isEmpty() ? m_settings->user()
|
||||
: m_settings->persona();
|
||||
persona.replace(QRegularExpression(QStringLiteral("[^A-Za-z0-9._-]")),
|
||||
QStringLiteral("-"));
|
||||
|
||||
m_sendFolder = out;
|
||||
m_sendOk = 0;
|
||||
m_sendKo = 0;
|
||||
m_sendEsito.clear();
|
||||
m_sendPersona = persona;
|
||||
|
||||
if (!m_sendTimer) {
|
||||
m_sendTimer = new QTimer(this);
|
||||
m_sendTimer->setInterval(200);
|
||||
connect(m_sendTimer, &QTimer::timeout, this, &EngineBridge::pollSend);
|
||||
}
|
||||
const QByteArray cfg = config.toUtf8();
|
||||
s_send_start(cfg.constData(), cfg.size(), coda.constData(), coda.size());
|
||||
m_sendTimer->start();
|
||||
return QString();
|
||||
}
|
||||
|
||||
void EngineBridge::pollSend()
|
||||
{
|
||||
if (!s_send_poll) {
|
||||
if (m_sendTimer) m_sendTimer->stop();
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray buffer(64 * 1024, '\0');
|
||||
int ancora = 0;
|
||||
const int letti = s_send_poll(buffer.data(), buffer.size(), &ancora);
|
||||
const QList<QByteArray> righe = buffer.left(letti).split('\n');
|
||||
for (int i = 0; i < righe.size(); i++) {
|
||||
const QByteArray riga = righe.at(i);
|
||||
if (riga.isEmpty()) continue;
|
||||
if (riga.at(0) == '!') {
|
||||
m_sendEsito = QString::fromUtf8(riga.mid(2)).trimmed();
|
||||
continue;
|
||||
}
|
||||
const QList<QByteArray> celle = riga.split('\t');
|
||||
if (celle.size() < 2) continue;
|
||||
const int id = celle.at(1).toInt();
|
||||
const bool inviato = riga.at(0) == '+';
|
||||
if (inviato) {
|
||||
++m_sendOk;
|
||||
// La copia che resta sul server: la mette lui nel Sent della
|
||||
// personalità, se la conosce.
|
||||
if (s_queue_sent && !m_sendPersona.isEmpty()) {
|
||||
const QByteArray p = m_sendPersona.toUtf8();
|
||||
s_queue_sent(m_sendFolder, id, p.constData(), p.size());
|
||||
}
|
||||
} else {
|
||||
++m_sendKo;
|
||||
m_sendEsito = celle.size() > 2 ? QString::fromUtf8(celle.at(2)).trimmed()
|
||||
: tr("invio non riuscito");
|
||||
}
|
||||
if (s_send_done) s_send_done(m_sendFolder, id, inviato ? 1 : 0);
|
||||
}
|
||||
|
||||
if (ancora) return;
|
||||
|
||||
m_sendTimer->stop();
|
||||
if (s_absorb) s_absorb(m_sendFolder);
|
||||
dropAllRows(); // Out e Sent sono cambiate
|
||||
if (s_rescan) s_rescan();
|
||||
|
||||
// La copia sul server (l'append di queue_sent) parte col controllo posta:
|
||||
// l'originale lo fa subito dopo l'invio, altrimenti la posta inviata resta
|
||||
// solo nella coda locale.
|
||||
if (m_sendOk > 0 && m_settings && m_settings->configured()) {
|
||||
logInvio("send: avvio il controllo per portare la copia sul server");
|
||||
QTimer::singleShot(400, this, [this] { checkMail(); });
|
||||
}
|
||||
|
||||
emit sendFinished(m_sendOk, m_sendKo, m_sendEsito);
|
||||
QTimer::singleShot(0, this, [this] { emit ready(); });
|
||||
}
|
||||
|
||||
// Legge una cartella dal motore una volta sola e la tiene: una chiamata per
|
||||
// campo per riga, quindi rileggerla a ogni apertura era il costo vero.
|
||||
void EngineBridge::buildRows(int folder)
|
||||
|
||||
+37
-1
@@ -39,7 +39,13 @@ public:
|
||||
gd_find_start_fn imap_start, gd_find_poll_fn imap_poll,
|
||||
gd_rescan_fn rescan, gd_text_fn attachments,
|
||||
gd_sort_fn sort, gd_absorb_fn absorb,
|
||||
gd_text_fn sender, gd_header_fn header);
|
||||
gd_text_fn sender, gd_header_fn header,
|
||||
gd_compose_fn compose, gd_claim_fn claim,
|
||||
gd_send_start_fn send_start,
|
||||
gd_find_poll_fn send_poll,
|
||||
gd_send_done_fn send_done,
|
||||
gd_queue_sent_fn queue_sent, gd_place_fn place,
|
||||
gd_log_fn log, gd_empty_fn empty);
|
||||
|
||||
bool checking() const { return m_checking; }
|
||||
QString lastResult() const { return m_lastResult; }
|
||||
@@ -60,9 +66,18 @@ public:
|
||||
// "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);
|
||||
Q_INVOKABLE int folderNamed(const QString &nome);
|
||||
Q_INVOKABLE int folderOut();
|
||||
// Svuota il cestino indicato: quanti messaggi sono spariti, -1 se non c'e'.
|
||||
Q_INVOKABLE int emptyTrash(int folder);
|
||||
// Manda un messaggio: stringa vuota se e' partito, altrimenti il motivo.
|
||||
Q_INVOKABLE QString sendMessage(const QString &to, const QString &cc,
|
||||
const QString &bcc, const QString &da,
|
||||
const QString &oggetto, const QString &corpo);
|
||||
|
||||
signals:
|
||||
void ready();
|
||||
void sendFinished(int inviati, int falliti, const QString &esito);
|
||||
void checkingChanged();
|
||||
void mailChecked();
|
||||
// a ogni riga di avanzamento che il motore manda durante il controllo
|
||||
@@ -90,6 +105,27 @@ private:
|
||||
static gd_absorb_fn s_absorb;
|
||||
static gd_text_fn s_sender;
|
||||
static gd_header_fn s_header;
|
||||
static gd_compose_fn s_compose;
|
||||
static gd_claim_fn s_claim;
|
||||
static gd_send_start_fn s_send_start;
|
||||
static gd_find_poll_fn s_send_poll;
|
||||
static gd_send_done_fn s_send_done;
|
||||
static gd_queue_sent_fn s_queue_sent;
|
||||
static gd_place_fn s_place;
|
||||
static gd_log_fn s_log;
|
||||
static gd_empty_fn s_empty;
|
||||
// Un mio passaggio scritto nel log del motore: senza, quando l'invio si
|
||||
// ferma prima del motore non resta traccia di niente.
|
||||
void logInvio(const QString &riga);
|
||||
QString cartelleViste();
|
||||
|
||||
void pollSend();
|
||||
QTimer *m_sendTimer = nullptr;
|
||||
int m_sendFolder = -1;
|
||||
int m_sendOk = 0;
|
||||
int m_sendKo = 0;
|
||||
QString m_sendEsito;
|
||||
QString m_sendPersona;
|
||||
|
||||
AccountSettings *m_settings;
|
||||
QTimer *m_poll;
|
||||
|
||||
@@ -45,14 +45,13 @@ int gd_run(gd_folder_fn folder, gd_open_fn open, gd_cell_fn cell,
|
||||
gd_can_hold_fn unread)
|
||||
{
|
||||
(void)sort; (void)mark_read; (void)id_of; (void)row_of; (void)move;
|
||||
(void)commit; (void)empty; (void)log; (void)priority; (void)label;
|
||||
(void)commit; (void)priority; (void)label;
|
||||
(void)decrypt; (void)key_of; (void)plain;
|
||||
(void)sheet; (void)compose; (void)filter; (void)last_id;
|
||||
(void)sheet; (void)filter; (void)last_id;
|
||||
(void)find_start; (void)find_poll; (void)find_cancel; (void)id_named;
|
||||
(void)claim; (void)send_done; (void)send_start; (void)send_poll;
|
||||
(void)imap_start; (void)imap_poll; (void)absorb; (void)rescan;
|
||||
(void)shown_at; (void)can_hold; (void)make_folder; (void)can_change;
|
||||
(void)change_folder; (void)forget; (void)has_box; (void)place;
|
||||
(void)change_folder; (void)forget; (void)has_box;
|
||||
(void)imap_create; (void)book_start; (void)book_poll; (void)book_list;
|
||||
(void)queue_sent; (void)html; (void)images; (void)attachments;
|
||||
(void)path;
|
||||
@@ -60,7 +59,9 @@ int gd_run(gd_folder_fn folder, gd_open_fn open, gd_cell_fn cell,
|
||||
EngineBridge::keepCallbacks(folder, open, cell, body, unread,
|
||||
mark_read, id_of, move, commit,
|
||||
imap_start, imap_poll, rescan, attachments, sort,
|
||||
absorb, sender, header);
|
||||
absorb, sender, header, compose, claim,
|
||||
send_start, send_poll, send_done, queue_sent,
|
||||
place, log, empty);
|
||||
return QCoreApplication::exec();
|
||||
}
|
||||
|
||||
|
||||
+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.5.4"));
|
||||
app->setApplicationVersion(QStringLiteral("0.6.9"));
|
||||
|
||||
qDebug() << "harbour-grumpydove v0.5.4 build" << __DATE__ << __TIME__;
|
||||
qDebug() << "harbour-grumpydove v0.6.9 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