Cartelle sul server: IMAP CREATE accodato (0.22.0)

Il motore aveva I_Create ma nessuno lo chiamava: Make_Folder crea solo sotto
Local (Can_Hold=1). Aggiunte tre patch (Note_Make in Mail_Pending, ramo mkdir
nel Flush) e l'unita' Make_Remote che esporta gd_make_remote. L'interfaccia ha
'Nuova cartella nell'account': la cartella nasce al controllo successivo.
This commit is contained in:
Carlo Baratto committed 2026-11-17 16:08:40 +01:00
1 parent e6f3786aef
commit 9ed2bd614e
13 files changed
+189 -8

No files matched your search

+2 -1
View File
@@ -41,7 +41,8 @@ mkdir -p "$WORK/src"
cp "$SRC"/src/*.adb "$SRC"/src/*.ads "$SRC"/src/*.c "$SRC"/src/*.cpp \
"$SRC"/src/*.h "$WORK/src/"
cp "$HERE"/engine_entry.ads "$HERE"/engine_entry.adb \
"$HERE"/filing_keep.ads "$HERE"/filing_keep.adb "$WORK/src/"
"$HERE"/filing_keep.ads "$HERE"/filing_keep.adb \
"$HERE"/make_remote.ads "$HERE"/make_remote.adb "$WORK/src/"
# Le modifiche al motore (log redirigibile, cancellazione sul server) stanno
# in uno script: si applicano ai sorgenti originali a ogni build, e se un
+11
View File
@@ -1,5 +1,7 @@
-- Corpo dell'entry point: quello di src/grumpydove.adb, con la sola
-- differenza del nome e nessun uso di Ada.Command_Line.
with System;
with GNAT.Exception_Traces;
with GNAT.Traceback.Symbolic;
with Interfaces.C; use Interfaces.C;
@@ -7,6 +9,7 @@ with Interfaces.C; use Interfaces.C;
with Mail_Boxes;
with Mail_Find;
with Filing_Keep;
with Make_Remote;
with Mail_Folders;
with Mail_Carddav;
with Mail_Imap;
@@ -28,6 +31,14 @@ begin
Mail_Log.Start;
-- Nomina i filtri che imparano, così entrano nella libreria.
Filing_Keep;
-- E la creazione di cartelle sul server: la funzione e' esportata, ma se
-- nessuno la nomina gnatmake non la compila e gd_make_remote manca.
declare
Ignored : constant int := Make_Remote.Make (-1, System.Null_Address, 0);
pragma Unreferenced (Ignored);
begin
null;
end;
if Single_Instance = 0 then
Mail_Log.Write ("another GrumpyDove is open: this one leaves");
Already_Open;
+4
View File
@@ -6,6 +6,10 @@
extern "C" {
#endif
/* Creare una cartella sul server: accoda la nota, la esegue il controllo
successivo (IMAP CREATE). Restituisce 1 se accodata, -1 se non si puo'. */
int gd_make_remote(int folder, const char *name, int length);
/* Folders, rows and columns count from 0. A text callback writes at most cap
bytes of UTF-8 into buf, with no terminator, and returns how many. */
typedef int (*gd_folder_fn)(int index, int *depth, char *buf, int cap);
+33
View File
@@ -0,0 +1,33 @@
with Ada.Exceptions;
with Mail_Folders;
with Mail_Log;
with Mail_Pending;
package body Make_Remote is
function Make (Folder : int; Name : System.Address; Length : int) return int is
Path : constant String := Mail_Folders.Path_Of (Folder);
Text : String (1 .. Natural (Length)) with Import, Address => Name;
begin
-- Senza nome non c'è niente da creare; senza percorso la cartella non
-- esiste (indice vecchio, di un albero ricaricato).
if Length <= 0 or else Path = "" then
return -1;
end if;
-- Solo le cartelle di un account: sotto Local ci pensa Make_Folder.
if Mail_Folders.Can_Hold (Folder) /= 2 then
return -1;
end if;
Mail_Pending.Note_Make (Path, Text);
return 1;
exception
when Error : others =>
Mail_Log.Write
("ERR make remote: " & Ada.Exceptions.Exception_Message (Error));
return -1;
end Make;
end Make_Remote;
+19
View File
@@ -0,0 +1,19 @@
-- Creare una cartella sul server, per un account.
--
-- Mail_Folders.Make_Folder sa creare solo sotto Local (Can_Hold vale 1 lì, 2
-- per le cartelle di un account) e Mail_Imap.Create — la funzione che fa IMAP
-- CREATE — non è accodata da nessuno. Questa funzione scrive la nota nel
-- pending dell'account; il controllo successivo la esegue.
--
-- Il nome è quello che l'utente ha scritto: la cartella nasce nella radice
-- dell'account, non dentro una sua sottocartella.
with Interfaces.C; use Interfaces.C;
with System;
package Make_Remote is
function Make (Folder : int; Name : System.Address; Length : int) return int
with Export, Convention => C, External_Name => "gd_make_remote";
end Make_Remote;
+60
View File
@@ -184,6 +184,66 @@ with Mail_Log;''',
Mail_Pending.Note_Delete (To_String (M.Path));
GNAT.OS_Lib.Delete_File (To_String (M.Path), Done);''',
"Empty propaga la cancellazione"),
# Creare una cartella sul server. Make_Folder sa creare solo sotto Local
# (Can_Hold = 1); per le cartelle di un account la via e' IMAP CREATE, che
# nel motore esiste (Mail_Imap.I_Create) ma non e' mai accodata da nessuno.
# La nota sta nel pending della INBOX dell'account e la esegue il Flush.
("mail_pending.ads",
''' -- File was written in Goal by us: the server gets it at the next check.
procedure Note_Copy (Goal, File : String);''',
''' -- File was written in Goal by us: the server gets it at the next check.
procedure Note_Copy (Goal, File : String);
-- A mailbox to make on the server. Box is the account's INBOX, Name what
-- the user called it: the next check runs IMAP CREATE.
procedure Note_Make (Box, Name : String);''',
"Note_Make in Mail_Pending (specifica)"),
("mail_pending.adb",
''' procedure Note_Copy (Goal, File : String) is
begin''',
''' procedure Note_Make (Box, Name : String) is
begin
if In_Account (Box) and then Name /= "" then
Write (Box, Name & ".mkdir", Name);
Mail_Log.Write ("pending: mkdir " & Name & " in " & Box);
end if;
exception
when Error : others =>
Mail_Log.Write ("ERR pending: " & Ada.Exceptions.Exception_Message (Error));
end Note_Make;
procedure Note_Copy (Goal, File : String) is
begin''',
"Note_Make in Mail_Pending (corpo)"),
# Il Flush esegue la creazione. "Esiste gia'" non e' un guasto: la
# cartella c'e', che e' quello che l'utente voleva.
("mail_imap.adb",
''' elsif Kind = "delete" then''',
''' elsif Kind = "mkdir" then
declare
Wanted : constant String := Read_File (Path);
New_Box : chars_ptr := New_String (Wanted);
begin
Ok := C_Create (S, New_Box, Why\'Address, Why_Size) /= 0;
if not Ok then
declare
Said : constant String := To_Ada (Why);
begin
Ok := Ada.Strings.Fixed.Index (Said, "ALREADYEXISTS") > 0
or else Ada.Strings.Fixed.Index (Said, "already exists") > 0;
end;
end if;
if not Ok then
Channel.Put ("!" & Tab & Clean (Name) & ": create "
& Clean (Wanted) & ": " & To_Ada (Why));
end if;
Free (New_Box);
end;
elsif Kind = "delete" then''',
"ramo mkdir nel Flush"),
]
Binary file not shown.