From 8396b1bfff3c3cd40a83e00058ae26bab03239ac Mon Sep 17 00:00:00 2001 From: Stefan Ritt Date: Wed, 28 Jan 2004 15:27:18 +0000 Subject: [PATCH] Version 2.5.0 SVN revision: 723 --- checklist.txt | 2 + doc/ChangeLog | 11 ++++ doc/config.html | 131 ++++++++++++++++++++++++++++++++++++++++++++ doc/index.html | 2 +- eloglang.brazilian | 28 ++++++++-- eloglang.dutch | 24 ++++++-- eloglang.french | 25 +++++++-- eloglang.german | 24 ++++++-- eloglang.italian | 56 ++++++++----------- eloglang.spanish | 24 ++++++-- src/elogd.c | 134 ++++++++++++++++++++++++++++++++------------- 11 files changed, 363 insertions(+), 98 deletions(-) diff --git a/checklist.txt b/checklist.txt index 0c995904..699750b3 100755 --- a/checklist.txt +++ b/checklist.txt @@ -9,6 +9,8 @@ On PC4534: - Modify ChangeLog - Add release date to ChangeLog - Do a "make indent" +- Do a "make loc" +- Translate new strings in eloglang.german - c:\elog> cvs commit -m "Version x.x.x" - build xxx diff --git a/doc/ChangeLog b/doc/ChangeLog index 26ae3a52..d5ac5303 100755 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,14 @@ +Version 2.5.0, released January 28th, 2004 +========================================== + +- Implemented mirroring, see new section in config.html +- Updated all translation files with current set of required stings +- Search 'all logbooks' only for current top group +- Changed 'message' to 'entry' consistently +- Removed '{n}' in quick filter and find page list +- Display months on find page localized +- Implemented setlocale() for strftime() + Version 2.4.1, released January 13th, 2004 ========================================== diff --git a/doc/config.html b/doc/config.html index c92b7da0..662e2ebc 100755 --- a/doc/config.html +++ b/doc/config.html @@ -28,6 +28,7 @@  [Access Control]   [Flags]   [Themes]  + [Mirroring]  * 

Global and individual logbook options for an ELOG server
@@ -1530,6 +1531,136 @@ These two images display the same logbook entry using different themes:   

+


+
  Mirroring  
+

+Sometimes it can be useful to have the same ELOG logbook on two different computers. This +might be the case if you travel with your laptop, but want to keep the logbooks from your +desktop computer on the laptop. The problem is that if you add an entry on your laptop, +the logbooks on the laptop and the desktop get out of sync. Merging only the ELOG database +files does not help, since two entries could be made at the same day on the laptop and +the desktop, which would lead to a conflict in that day's database file. +

+ +To solve this problem, mirroring was introduced from Version 2.5.0 on. This technology +allows to synchronize one ELOG server with a number of other servers on a per-entry basis. No +additional software is needed, only two elogd daemons talking to each other. The synchronization +can be executed manually or periodically. If entries are changed/added/deleted on both sides, +they get merged properly during synchronization. In order to minimize network traffic, each +ELOG server calculates a MD5 checksum for each message, which gets exchanged during synchronization. +Only when the MD5 checksum differs, entries are transferred. +

+ +To set-up mirroring, following configuration options are available. They should be put +into the [global] section of the cofiguration file:

+ +

+ + +

Home of the Electronic Logbook package by Stefan Ritt

-
  Current version is : 2.4.1  
+
  Current version is : 2.5.0  

  What is ELOG ?  
diff --git a/eloglang.brazilian b/eloglang.brazilian index f0958d60..8473539b 100755 --- a/eloglang.brazilian +++ b/eloglang.brazilian @@ -157,7 +157,6 @@ Only user %s can delete this entry = Are you sure to delete these messages? = and all their replies = Synchronization = -Synchronizing with = Entry is currently edited by = Date = Threaded = @@ -211,13 +210,9 @@ Entry #%d is locked on remote server = Cannot save remote entry locally = local = remote = -Entry has been changed locally and remotely. = Please delete %s or %s entry to resolve conflict = -Entry identical = -Entry has been deleted locally = Error sending local entry = Local entry submitted = -Entry has been deleted remotely = Error deleting remote entry = ID = Full = @@ -232,3 +227,26 @@ copied successfully from "%s" to "%s" = This entry has been deleted = Login = by = + +# +#---- please translate following items and then remove this comment ----# +# +Cannot connect to remote server "%s" = +Remote server is not an ELOG server = +Incorrect remote ELOG server version %s = +User "%s" has no access to remote logbook = +Passwords for user "%s" do not match locally and remotely = +Error accessing remote logbook = +Invalid HTTP header = +No user name supplied to access remote logbook = +Synchronizing logbook %s with server "%s" = +Configuration has been changed locally and remotely = +Please merge manually to resolve conflict = +Logbook "%s" does not exist on remote server = +Entry has been changed locally and remotely = +Entry deleted locally = +Changed local entry ID to %d = +Entry deleted remotely = +All entries identical = +Invalid mirror_id or entry_date = +Synchronize all logbooks = diff --git a/eloglang.dutch b/eloglang.dutch index b7535d40..b0cd5f83 100755 --- a/eloglang.dutch +++ b/eloglang.dutch @@ -198,7 +198,6 @@ Expand all = Alles uitbreiden Add %s = Voeg %s toe No mirror server defined in configuration file =Geen mirror server gedefinieerd in het configuratie bestand Synchronization = Synchronisatie -Synchronizing with = Synchronizeren met Error: Value %s not allowed for boolean attributes = Fout: Waarde %s niet toegestaan voor booleaanse attributen Error: Attribute option %s not existing = Fout: Attribuut optie %s bestaat niet Last submission = Laatste toevoeging @@ -224,13 +223,9 @@ Entry #%d is locked on remote server = Cannot save remote entry locally = local = remote = -Entry has been changed locally and remotely. = Please delete %s or %s entry to resolve conflict = -Entry identical = -Entry has been deleted locally = Error sending local entry = Local entry submitted = -Entry has been deleted remotely = Error deleting remote entry = New entry cannot be written to directory "%s" = Entry %s cannot be read from logbook "%s" = @@ -238,3 +233,22 @@ No entry selected = One entry = This entry has been deleted = Entries = +Cannot connect to remote server "%s" = +Remote server is not an ELOG server = +Incorrect remote ELOG server version %s = +User "%s" has no access to remote logbook = +Passwords for user "%s" do not match locally and remotely = +Error accessing remote logbook = +Invalid HTTP header = +No user name supplied to access remote logbook = +Synchronizing logbook %s with server "%s" = +Configuration has been changed locally and remotely = +Please merge manually to resolve conflict = +Logbook "%s" does not exist on remote server = +Entry has been changed locally and remotely = +Entry deleted locally = +Changed local entry ID to %d = +Entry deleted remotely = +All entries identical = +Invalid mirror_id or entry_date = +Synchronize all logbooks = diff --git a/eloglang.french b/eloglang.french index fe05177f..f6754951 100755 --- a/eloglang.french +++ b/eloglang.french @@ -182,6 +182,7 @@ Maximum number of attachments reached = Le nombre maximal d'attachements a Invalid user name "%s" = Le nom d'utilisateur "%s" est incorrect on = sur Entry is currently edited by = Entrée actuellement en cours de modification par + # #---------- please translate following items ----------# # @@ -195,7 +196,6 @@ Change %s = Error sending Email via "%s" = User name "%s" not registered = Synchronization = -Synchronizing with = recipients = Error: Value %s not allowed for boolean attributes = Error: Attribute option %s not existing = @@ -219,13 +219,9 @@ Entry #%d is locked on remote server = Cannot save remote entry locally = local = remote = -Entry has been changed locally and remotely. = Please delete %s or %s entry to resolve conflict = -Entry identical = -Entry has been deleted locally = Error sending local entry = Local entry submitted = -Entry has been deleted remotely = Error deleting remote entry = New entry cannot be written to directory "%s" = Entry %s cannot be read from logbook "%s" = @@ -234,3 +230,22 @@ One entry = This entry has been deleted = by = Entries = +Cannot connect to remote server "%s" = +Remote server is not an ELOG server = +Incorrect remote ELOG server version %s = +User "%s" has no access to remote logbook = +Passwords for user "%s" do not match locally and remotely = +Error accessing remote logbook = +Invalid HTTP header = +No user name supplied to access remote logbook = +Synchronizing logbook %s with server "%s" = +Configuration has been changed locally and remotely = +Please merge manually to resolve conflict = +Logbook "%s" does not exist on remote server = +Entry has been changed locally and remotely = +Entry deleted locally = +Changed local entry ID to %d = +Entry deleted remotely = +All entries identical = +Invalid mirror_id or entry_date = +Synchronize all logbooks = diff --git a/eloglang.german b/eloglang.german index 246f7146..36010a67 100755 --- a/eloglang.german +++ b/eloglang.german @@ -195,7 +195,6 @@ Expand all = Alles erweitern Add %s = %s hinzufügen User name "%s" not registered = Benutzername "%s" ist nicht registriert Synchronization = Synchronisation -Synchronizing with = Synchronisieren mit Error: Value %s not allowed for boolean attributes = Fehler: Wert %s ist nicht erlaubt für bool'sche Attribute Error: Attribute option %s not existing = Fehler: Attribut Option %s existiert nicht Last submission = Letzter Eintrag @@ -217,13 +216,9 @@ Entry #%d is locked on remote server = Eintrag #%d is auf anderem Computer in Be Cannot save remote entry locally = Kann fremden Eintrag nicht lokal speichern local = lokalen remote = fremden -Entry has been changed locally and remotely. = Eintrag wurde lokal und auf anderem Rechner gelöscht. Please delete %s or %s entry to resolve conflict = Bitte %s oder %s Eintrag löschen um Konflikt zu lösen -Entry identical = Einträge sind identisch -Entry has been deleted locally = Eintrag wurde lokal gelöscht Error sending local entry = Fehler beim senden von lokalem Eintrag Local entry submitted = Lokaler Eintrag gesendet -Entry has been deleted remotely = Fremder Eintrag wurde gelöscht Error deleting remote entry = Fehler beim Löschen von fremdem Eintrag New entry cannot be written to directory "%s" = Neuer Eintrag kann nicht in Verzeichnis "%s" geschrieben werden Entry %s cannot be read from logbook "%s" = Eintrag %s kann nicht aus Logbuch "%s" gelesen werden @@ -231,4 +226,23 @@ No entry selected = Kein Eintrag ausgew One entry = Ein Eintrag This entry has been deleted = Dieser Eintrag wurde gelöscht Entries = Einträge +Cannot connect to remote server "%s" = Verbindung mit entferntem Server "%s" kann nicht hergestellt werden +Remote server is not an ELOG server = Entfernter Server ist kein ELOG Server +Incorrect remote ELOG server version %s = Falsche Version %s des entefernten Servers +User "%s" has no access to remote logbook = Benutzer "%s" hat keinen Zugriff auf entferntes Logbuch +Passwords for user "%s" do not match locally and remotely = Kennwörter für Benutzer "%s" sind lokal und entfernt verschieden +Error accessing remote logbook = Fehler beim Zugriff auf entfertes Logbuch +Invalid HTTP header = Falscher HTTP Kopf +No user name supplied to access remote logbook = Kein Benutzername definiert zum Zugriff auf entferntes Logbuch +Synchronizing logbook %s with server "%s" = Synchronisiere Logbuch %s mit Server "%s" +Configuration has been changed locally and remotely = Konfiguration wurde lokal und entfernt geändert +Please merge manually to resolve conflict = Bitte manuell zusammenfügen um Konflikt aufzulösen +Logbook "%s" does not exist on remote server = Logbuch "%s" existiert nicht auf entferntem Server +Entry has been changed locally and remotely = Eintrag ist lokal und entfernt geändert worden +Entry deleted locally = Eintrag lokal entfernt +Changed local entry ID to %d = Lokale ID des Eintrages auf %d geändert +Entry deleted remotely = Entfernter Eintrag gelöscht +All entries identical = Alle Einträge identisch +Invalid mirror_id or entry_date = Falsche mirror_id oder entry_date +Synchronize all logbooks = Alle Logbücher synchronisieren diff --git a/eloglang.italian b/eloglang.italian index 05120f30..b4466ec5 100755 --- a/eloglang.italian +++ b/eloglang.italian @@ -54,19 +54,15 @@ Suppress Email notification = Disattiva l'invio di e-mail Resubmit as new entry = Reinvia come nuovo elemento Attachment = Allegato Attachments = Allegati -No message available = Nessun messaggio disponibile Reply to this = Rispondi a questo In reply to = In risposta a -ELOG Error = ELOG Errore Fields marked with = I campi segnati con are required = sono obbligatori -New message cannot be written to directory "%s" = Il nuovo messaggio non può essere scritto nella cartella "%s" Please check that it exists and elogd has write access = Per favore controlla che esista e che ELOGD abbia diritti di accesso in scrittura Error: Attribute %s not supplied = Errore: Attributo %s non fornito Please go back and enter the %s field = Per favore torna indietro ed inserisci il campo %s Please use your browser's back button to go back = Per favore usa il pulsante indietro del tuo browser Only user %s can edit this entry = Solo l'utente %s può modificare questo elemento -ELOG search result = ELOG risultato della ricerca ELOG find = ELOG Cerca Find = Trova Search = Cerca @@ -90,21 +86,14 @@ Copy ELog entry = Copia elemento ELOG Are you sure to delete this message? = Sei sicuro di voler cancellare questo messaggio? Yes = Si No = No -Message successfully deleted = Messaggio cancellato con successo Error deleting message: status = Errore nel cancellare il messaggio: stato -Goto last message = Vai all'ultimo messaggio Error: Command "%s" not allowed = Errore: Comando "%s" non permesso -Error: Command "%s" is not allowed for user "%s" = Errore: Comando "%s" non permesso all'utente "%s" Cannot open file %s = Non posso aprire il file %s Cannot write to %s = Non posso scrivere su %s No SMTP host defined in [global] section of configuration file = Nessun server SMTP definito nella sezione [global] del file di configurazione -Messags %s cannot be read from logbook "%s" = Il messaggio %s non può essere letto dal registro "%s" -New message cannot be written to directory "%s" = Il nuovo messaggio non può essere scritto nella cartella "%s" Only user %s can edit this entry = Solo l'utente %s può modificare questo elemento -Display full message = Mostra il messaggio completo Display threads = Mostra le discussioni Logbook is empty = Il registro è vuoto -This message has been deleted = Questo messaggio è stato cancellato Download = Scarica and all its replies = e tutte le sue risposte Message ID = ID messaggio @@ -112,14 +101,12 @@ Not logged in = Non entrato Login = Entra Page %d of %d = Pagina %d di %d all entries = tutti gli elementi -%d entries = %d elementi Login name = Nome utente Full name = Nome completo ELOG user config = ELOG configurazione utente ELOG new user = ELOG nuovo utente Admin = Amministratore Select user = Scegli l'utente -Go = Vai Remove user = Cancella l'utente New user = Crea nuovo utente Retype new password = Riscrivi la nuova password @@ -138,8 +125,6 @@ Your ELOG account has been activated on host = Il tuo account ELOG You can access it at = Puoi accedervi da Are you sure to delete these messages? = Sei sicuro di voler cancellare questi messaggi? Select = Seleziona -No message selected for deletion = Nessun messaggio selezionato per la cancellazione -No message selected = Nessun messaggio selezionato All entries = Tutti gli elementi Day = Giorno Week = Settimana @@ -159,24 +144,20 @@ Expand = Espandi Full = Completo Summary = Sommario Threaded = Ad albero -ELOG Entries = ELOG Elementi Filters = Filtri Mode = Modo Options = Opzioni Error: start date after end date = Errore: la data iniziale è posteriore a quella finale and all their replies = e tutte le loro risposte -Your request has been forwarded to the administrator. You will be notified by email upon activation of your new account. = La tua richiesta è stata inoltrata all'amministratore. Ti verrà inviata notifica per e-mail dell'attivazione del tuo nuovo account. Upload = Carica Requested = Richiesto Registration request on logbook "%s" = Richiesta di registrazione nel registro "%s" A new ELOG user wants to register on "%s" = Un nuovo utente ELOG vuole registrarsi su "%s" -One message = Un messaggio %d messages = %d messaggi and its replies = e le sue risposte and their replies = e le loro risposte moved successfully from "%s" to "%s" = spostate con successo da "%s" a "%s" copied successfully from "%s" to "%s" = copiate con successo da "%s" a "%s" -Last x = Ultimi x Only user %s can delete this entry = Solo l'utente %s può cancellare questo elemento Search text also in attributes = Ricerca il testo anche negli attributi Goto logbook selection page = Vai alla pagina di selezione dei registri @@ -188,7 +169,6 @@ Change elogd.cfg = Modifica elogd.cfg Remember me on this computer = Ricordami su questo computer Forgot password? = Dimenticata la password? Email address "%s" not registered = Indirizzo e-mail "%s" non registrato -User name \%s\ not registered = Nome utente "%s" non registrato ELOG password recovery = ELOG ripristino password No Email address registered with user name "%s" = Nessun indirizzo e-mail registrato con il nome utente "%s" Error sending Email via "%s" = Errore nell'nvio della e-mail con "%s" @@ -196,35 +176,26 @@ A new password for user "%s" has been sent to %s = Una nuova password per Forgot = Dimenticata User "%s" registered on host "%s" = Utente "%s" registrato sul server "%s" Registration request on host "%s" = Richiesta di registrazione sul server "%s" -Please log on by clicking on following link and change your password = Per favore entra cliccando sul seguente collegamento e cambia la tua password A new password has been created for you on host %s = Ti è stata creata una nuova password sul server %s Enter your user name or email address = Inserisci il tuo nome utente o l'indirizzo e-mail Password recovery for ELOG %s = Ripristino password per ELOG %s Host = Server Your ELOG account has been activated = Il tuo account ELOG è stato attivato -Activate = Attiva Maximum number of attachments reached = Raggiunto il massimo numero di allegati consentito Invalid user name "%s" = Nome utente non valido "%s" -User = Utente on = su -computer = Server Entry is currently edited by = L'elemento è ora modificato da recipients = destinatari Suppress shell execution = Disattiva esecuzione da shell Maximum number of replies (%d) exceeded = Superato il numero massimo di risposte (%d) Update = Aggiorna Change %s = Cambia %s -Editing %s = Modifica %s Add new option here = Aggiungi qui una nuova opzione -Message can only be edited %1.2lg hours after creation = Il messaggio può essere modificato solo per %1.2lg ore dopo la creazione Add %s = Aggiungi %s User name "%s" not registered = Il nome "%s" non è registrato Synchronization = Sincronizzazione -Synchronizing with = In sincronizzazione con -Message identical = Messaggio identico Error: Value %s not allowed for boolean attributes = Errore: valore %s non consentito per elementi booleani Error: Attribute option %s not existing = Errore: l'opzione %s dell'elemento non esiste -Message %s cannot be read from logbook "%s" = Il messaggio %s non si può leggere dal registro "%s" Last submission = Ultima immissione Expand all = Espandi tutto Synchronize = Sincronizza @@ -244,13 +215,9 @@ Entry #%d is locked on remote server = L'elemento #%d Cannot save remote entry locally = Non posso salvare l'elemento remoto in locale local = locale remote = remoto -Entry has been changed locally and remotely. = L'elemento è stato modificato localmente e in remoto Please delete %s or %s entry to resolve conflict = Per favore cancella %s o %s per risolvere il conflitto -Entry identical = Elemento identico -Entry has been deleted locally = L'elemento è stato cancellato localmente Error sending local entry = Errore nell'invio dell'elemento locale Local entry submitted = Elemento locale inviato -Entry has been deleted remotely = L'elemento è stato cancellato in remoto Error deleting remote entry = Errore nel cancellare l'elemento remoto New entry cannot be written to directory "%s" = Il nuovo elemento non può essere scritto nella cartella "%s" Entry %s cannot be read from logbook "%s" = L'elemento %s non può essere letto dal registro "%s" @@ -259,3 +226,26 @@ One entry = Un elemento This entry has been deleted = Questo elemento è stato cancellato by = da Entries = Elementi + +# +#---- please translate following items and then remove this comment ----# +# +Cannot connect to remote server "%s" = +Remote server is not an ELOG server = +Incorrect remote ELOG server version %s = +User "%s" has no access to remote logbook = +Passwords for user "%s" do not match locally and remotely = +Error accessing remote logbook = +Invalid HTTP header = +No user name supplied to access remote logbook = +Synchronizing logbook %s with server "%s" = +Configuration has been changed locally and remotely = +Please merge manually to resolve conflict = +Logbook "%s" does not exist on remote server = +Entry has been changed locally and remotely = +Entry deleted locally = +Changed local entry ID to %d = +Entry deleted remotely = +All entries identical = +Invalid mirror_id or entry_date = +Synchronize all logbooks = diff --git a/eloglang.spanish b/eloglang.spanish index e26153d7..9a5599ec 100755 --- a/eloglang.spanish +++ b/eloglang.spanish @@ -158,7 +158,6 @@ Only user %s can delete this entry = Are you sure to delete these messages? = and all their replies = Synchronization = -Synchronizing with = Entry is currently edited by = Date = Threaded = @@ -212,13 +211,9 @@ Entry #%d is locked on remote server = Cannot save remote entry locally = local = remote = -Entry has been changed locally and remotely. = Please delete %s or %s entry to resolve conflict = -Entry identical = -Entry has been deleted locally = Error sending local entry = Local entry submitted = -Entry has been deleted remotely = Error deleting remote entry = ID = Full = @@ -233,3 +228,22 @@ copied successfully from "%s" to "%s" = This entry has been deleted = Login = by = +Cannot connect to remote server "%s" = +Remote server is not an ELOG server = +Incorrect remote ELOG server version %s = +User "%s" has no access to remote logbook = +Passwords for user "%s" do not match locally and remotely = +Error accessing remote logbook = +Invalid HTTP header = +No user name supplied to access remote logbook = +Synchronizing logbook %s with server "%s" = +Configuration has been changed locally and remotely = +Please merge manually to resolve conflict = +Logbook "%s" does not exist on remote server = +Entry has been changed locally and remotely = +Entry deleted locally = +Changed local entry ID to %d = +Entry deleted remotely = +All entries identical = +Invalid mirror_id or entry_date = +Synchronize all logbooks = diff --git a/src/elogd.c b/src/elogd.c index 7ab8d572..1b0a8bd9 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -6,6 +6,9 @@ Contents: Web server program for Electronic Logbook ELOG $Log$ + Revision 1.216 2004/01/28 15:27:18 midas + Version 2.5.0 + Revision 1.215 2004/01/27 16:18:10 midas Use HTTP 1.0 in receive_message @@ -3472,9 +3475,15 @@ int el_submit(LOGBOOK * lbs, int message_id, BOOL bedit, /* if index not ordered, sort it */ i = *lbs->n_el_index; - if (i > 1 && lbs->el_index[i - 1].file_time < lbs->el_index[i - 2].file_time) + if (i > 1 && lbs->el_index[i - 1].file_time < lbs->el_index[i - 2].file_time) { qsort(lbs->el_index, i, sizeof(EL_INDEX), eli_compare); + /* search message again, index could have been changed by sorting */ + for (index = 0; index < *lbs->n_el_index; index++) + if (lbs->el_index[index].message_id == message_id) + break; + } + /* if other logbook has same index, update pointers */ for (i = 0; lb_list[i].name[0]; i++) if (&lb_list[i] != lbs && lb_list[i].n_el_index == lbs->n_el_index) @@ -3642,7 +3651,7 @@ INT el_delete_message(LOGBOOK * lbs, int message_id, \********************************************************************/ { - INT i, index, n, size, fh, tail_size; + INT i, index, n, size, fh, tail_size, old_offset; char str[MAX_PATH_LENGTH], file_name[MAX_PATH_LENGTH], reply_to[MAX_REPLY_TO * 10], in_reply_to[256]; char *buffer, *p; @@ -3773,14 +3782,19 @@ INT el_delete_message(LOGBOOK * lbs, int message_id, /* remove message from index */ strcpy(str, lbs->el_index[index].file_name); + old_offset = lbs->el_index[index].offset; for (i = index; i < *lbs->n_el_index - 1; i++) { memcpy(&lbs->el_index[i], &lbs->el_index[i + 1], sizeof(EL_INDEX)); - if (equal_ustring(lbs->el_index[i].file_name, str)) - lbs->el_index[i].offset -= size; } (*lbs->n_el_index)--; lbs->el_index = realloc(lbs->el_index, sizeof(EL_INDEX) * (*lbs->n_el_index)); + /* correct all offsets after deleted message */ + for (i = 0; i < *lbs->n_el_index; i++) + if (equal_ustring(lbs->el_index[i].file_name, str) && + lbs->el_index[i].offset > old_offset) + lbs->el_index[i].offset -= size; + /* if other logbook has same index, update pointers */ for (i = 0; lb_list[i].name[0]; i++) if (&lb_list[i] != lbs && lb_list[i].n_el_index == lbs->n_el_index) @@ -3896,13 +3910,14 @@ This routine corrects that. */ int el_move_message_thread(LOGBOOK * lbs, int message_id) { int i, n, size, new_id; - char date[80], attrib[MAX_N_ATTR][NAME_LENGTH], text[TEXT_SIZE], + char date[80], attrib[MAX_N_ATTR][NAME_LENGTH], *text, in_reply_to[80], reply_to[MAX_REPLY_TO * 10], encoding[80], locked_by[256]; char list[MAX_N_ATTR][NAME_LENGTH], str[256]; char att_file[MAX_ATTACHMENTS][256]; /* retrieve message */ - size = sizeof(text); + text = malloc(TEXT_SIZE); + size = TEXT_SIZE; el_retrieve(lbs, message_id, date, attr_list, attrib, lbs->n_attr, text, &size, in_reply_to, reply_to, att_file, encoding, locked_by); @@ -3911,6 +3926,8 @@ int el_move_message_thread(LOGBOOK * lbs, int message_id) new_id = el_submit(lbs, 0, FALSE, date, attr_list, attrib, lbs->n_attr, text, in_reply_to, reply_to, encoding, att_file, FALSE, locked_by); + free(text); + /* correct links */ el_correct_links(lbs, message_id, new_id); @@ -3931,6 +3948,42 @@ int el_move_message_thread(LOGBOOK * lbs, int message_id) /*------------------------------------------------------------------*/ +int el_move_message(LOGBOOK * lbs, int old_id, int new_id) +{ + int status, size; + char date[80], attrib[MAX_N_ATTR][NAME_LENGTH], *text, in_reply_to[80], + reply_to[MAX_REPLY_TO * 10], encoding[80], locked_by[256], + att_file[MAX_ATTACHMENTS][256]; + + /* retrieve message */ + text = malloc(TEXT_SIZE); + size = TEXT_SIZE; + status = el_retrieve(lbs, old_id, date, attr_list, attrib, lbs->n_attr, + text, &size, in_reply_to, reply_to, att_file, encoding, + locked_by); + if (status != EL_SUCCESS) + return 0; + + /* submit as new message */ + status = el_submit(lbs, new_id, FALSE, date, attr_list, attrib, lbs->n_attr, text, + in_reply_to, reply_to, encoding, att_file, FALSE, locked_by); + + free(text); + + if (status != new_id) + return 0; + + /* correct links */ + el_correct_links(lbs, old_id, new_id); + + /* delete original message */ + el_delete_message(lbs, old_id, FALSE, NULL, FALSE, FALSE); + + return 1; +} + +/*------------------------------------------------------------------*/ + int el_lock_message(LOGBOOK * lbs, int message_id, char *user) /* lock message for editing */ { @@ -8231,18 +8284,6 @@ int retrieve_remote_md5(LOGBOOK * lbs, char *host, MD5_INDEX ** md5_index, sprintf(error_str, loc("Error accessing remote logbook")); } - /* debugging only - for (i = 0; i < n; i++) { - int j; - - printf("ID %d MD5:", (*md5_index)[i].message_id); - for (j = 0; j < 16; j++) - printf("%02X", (*md5_index)[i].md5_digest[j]); - - printf("\n"); - } - */ - free(text); return n; @@ -8947,7 +8988,7 @@ BOOL equal_md5(unsigned char m1[16], unsigned char m2[16]) void synchronize_logbook(LOGBOOK * lbs, BOOL bcron) { int index, i, j, i_msg, i_remote, i_cache, n_remote, n_cache, nserver, - remote_id, exist_remote, exist_cache, message_id; + remote_id, exist_remote, exist_cache, message_id, max_id; int priority_remote = 0, all_identical; char str[2000], url[256], loc_ref[256], rem_ref[256]; MD5_INDEX *md5_remote, *md5_cache; @@ -9128,19 +9169,6 @@ void synchronize_logbook(LOGBOOK * lbs, BOOL bcron) /* if message exists in both lists, compare MD5s */ if (exist_remote && exist_cache) { - /* - printf("ID%02d: ", message_id); - for (j = 0; j < 16; j++) - printf("%02X", lbs->el_index[i_msg].md5_digest[j]); - printf("\nCache : "); - for (j = 0; j < 16; j++) - printf("%02X", md5_cache[i_cache].md5_digest[j]); - printf("\nRemote: "); - for (j = 0; j < 16; j++) - printf("%02X", md5_remote[i_remote].md5_digest[j]); - printf("\n\n"); - */ - /* if message has been changed on this server, but not remotely, send it */ if (!equal_md5(md5_cache[i_cache].md5_digest, lbs->el_index[i_msg].md5_digest) && equal_md5(md5_cache[i_cache].md5_digest, @@ -9210,7 +9238,8 @@ void synchronize_logbook(LOGBOOK * lbs, BOOL bcron) all_identical = FALSE; if (!bcron) { - rsprintf("%s.\n\t", loc("Entry has been changed locally and remotely")); + rsprintf("ID%d:\t%s.\n\t", message_id, + loc("Entry has been changed locally and remotely")); rsprintf(loc("Please delete %s or %s entry to resolve conflict"), loc_ref, rem_ref); rsprintf(".\n"); @@ -9271,6 +9300,37 @@ void synchronize_logbook(LOGBOOK * lbs, BOOL bcron) rsprintf("ID%d:\t%s\n", message_id, loc("Local entry submitted")); } + /* if message does not exist in cache but remotely, + messages were added on both sides, so resubmit local one and retrieve remote one */ + if (!exist_cache && exist_remote) { + + /* find max id both locally and remotely */ + max_id = 1; + for (i = 0; i < *lbs->n_el_index; i++) + if (lbs->el_index[i].message_id > max_id) + max_id = lbs->el_index[i].message_id; + + for (i = 0; i < n_remote; i++) + if (md5_remote[i].message_id > max_id) + max_id = md5_remote[i].message_id; + + if (_logging_level > 1) + logf(lbs, "MIRROR change entry #%d to #%d", message_id, max_id + 1); + + /* rearrange local message not to conflict with remote message */ + if (!getcfg(lbs->name, "Mirror simulate", str) || atoi(str) == 0) + el_move_message(lbs, message_id, max_id + 1); + all_identical = FALSE; + + if (!bcron) { + sprintf(str, loc("Changed local entry ID to %d"), max_id + 1); + rsprintf("ID%d:\t%s\n", message_id, str); + } + + /* current message has been changed, so start over */ + i_msg--; + } + flush_return_buffer(); } @@ -12044,6 +12104,7 @@ void submit_elog(LOGBOOK * lbs) if (*getparam("edit_id") && *getparam("resubmit") && atoi(getparam("resubmit")) == 1) { resubmit_orig = atoi(getparam("edit_id")); + bedit = TRUE; /* get old links */ el_retrieve(lbs, resubmit_orig, NULL, NULL, NULL, 0, NULL, 0, in_reply_to, @@ -12087,8 +12148,7 @@ void submit_elog(LOGBOOK * lbs) message_id = el_submit(lbs, message_id, bedit, date, attr_list, attrib, lbs->n_attr, getparam("text"), in_reply_to, reply_to, - *getparam("html") ? "HTML" : "plain", att_file, - !isparam("mirror_id"), NULL); + *getparam("html") ? "HTML" : "plain", att_file, TRUE, NULL); if (message_id <= 0) { sprintf(str, loc("New entry cannot be written to directory \"%s\""), lbs->data_dir); @@ -14907,10 +14967,6 @@ void check_cron() time(&now); ts = localtime(&now); - strcpy(str, ctime(&now)); - str[24] = 0; - printf("Cron: %s\r", str); - /* check once every minute */ if (last_time.tm_year && last_time.tm_min != ts->tm_min) {