-rw-r--r-- | bin/kdepim/WhatsNew.txt | 4 | ||||
-rw-r--r-- | kmicromail/libetpan/mh/mailmh.c | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index 42b36f1..5864ce4 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt @@ -1,541 +1,541 @@ Info about the changes in new versions of KDE-Pim/Pi ********** VERSION 1.9.20 ************ KO/Pi: Added for the "dislplay one day" agenda mode info in the caption and in the day lables: Now it is displayed, if the selected day is from "day before yesterday" to "day after tomorrow". Made it possible to delete a Todo, which has sub-todos. Fixed two small problems in the todo view. Added missing German translation for filter edit and print dialog. Made search dialog closeable by cancel key. Made it possible to select in the date picker the (ligt grey ) dates of the prev./next month with the mouse. OM/Pi: "Delete mail" icon in main window now deletes all selected mails. Fixed the problem, that the state flag of imap mails was ignored. Now mails with "FLAG_SEEN" on the imap server get no icon in the list view to indecate that they are already seen. Fixed the problem that the body of some mails was not displayed in the mail viewer when fetching them from the imap server directly to read them. Made it (configurable) possible to show the "To:" field in the list view. Added to the mail viewer the option "View Source" to make it possible to see the raw mail data. Added a "Download Mail" button to the mail viewer to quickly download the viewed mail to the -local storage folder (specified in account setiings) of the account of the mail. - +local storage folder (specified in account settings) of the account of the mail. +Removed some memory leaks in OM/Pi. ********** VERSION 1.9.19 ************ Added a lot of missing translations to KA/Pi, Added some missing translations to KO/Pi and OM/Pi. Fixed some minor problems in KA/Pi + KO/Pi. Fixed a crash when closing PwM/Pi. Added German translation for PwM/Pi. Made view change and Month View update faster in KO/Pi. ********** VERSION 1.9.18 ************ FYI: The VERSION 1.9.17 was a testing release only. Please read the changelog of VERSION 1.9.17 as well. Cleaned up the syncing config dialog. Added sync config options for date range for events. Added sync config options for filters on incoming data. Added sync config options for filters on outgoing data. Please read the updated SyncHowTo about the new filter settings. These filter settings make it now possible to sync with shared calendars without writing back private or confidential data (via the outgoing filters). To sync only with particular parts of a shared calendar, the incoming filter settings can be used. An example can be found in the SyncHowTo. Same for shared addressbooks. Added a setting for the global kdepim data storage. Usually the data is stored in (yourhomedir/kdepim). Now you can set in the Global config dialog TAB, subTAB "Data storage path" a directory where all the kdepim data is stored. That makes it easy to save all kdepim data on a SD card on the Z, for example. KO/Pi: The timeedit input has a pulldown list for times. If opened, this pulldown list should now has the right time highlighted. Added the possibility to exclude events/todos/journals in a filter. You should exclude journals, if you do not want them to sync with a public calendar. KA/Pi: Added the possibility to in/exclude public/private/confidential contacts to a filter. If you have already defined filterrules in KA/Pi you have to adjust them all by setting the "include public/private/confidential" property manually. Sorry for that ... Added printing of card view and details view on desktop. Printing of list view is not working... Added button for removing pictures in contact editor. Parsing data fix of KA/Pi version 1.9.17. Fixed the "parse name automatically" problem of KA/Pi version 1.9.17. Fixed some syncing merging problems. ********** VERSION 1.9.17 ************ KO/Pi: Fixed that tooltips were not updated after moving an item in agenda view. Fixed a bug in sorting start date for recurring events in list view. Changed the left button in todo viewer from "Agenda" to "Set completed". This makes it possible to change a todo in the What's Next View quickly to the completed state without leaving the What's Next View. Added more info in the todo viewer: Startdate, parent/sub todos. KA/Pi: All fields search does now actually search all the (possible) fields, not only those listed in the contact list. Made is possible to inline a picture in a vcard on the Z. This was only possible on the desktop, now is it possible on the Z as well. Fixed of missing save settings after filter configuration. Made saving of addressbook much faster. Fixed extension widget layout problem. Fixed saving of default formatted name settings. Fixed formatted name handling in edit dialog. Added an option for changing formatted names of many contacts (menu: File - Change - Set formatted name). QWhatsThis was not working on the Z ( only black rectangle was shown). This is Fixed. KDE-Sync: Now readonly KDE resources are synced as well. (They are not changed in KDE itself, of course). ********** VERSION 1.9.16 ************ KO/Pi: Fixed search dialog size on Z 6000 (480x640 display). Added setting to hide/show time in agenda items. Added setting to hide not running todos in todo view. Added columns for start date/time in todo view. Replaced the solid half-hour lines in agenda view by dot lines. Added possibility of printing the What's Next View on the desktop (i.e. Windows and Linux). Fixed a crash in KO/Pi when starting KO/Pi with What's Next view. Added tooltips in month view.(Tooltips only available on desktop) Fixed a strange problem in KO/Pi alarm applet. Did not find the actual problem, such that now Qtopia reboots again if deinstalling the alarm applet. But the alarm applet should work again. KA/Pi: Fixed the problem, that internal pictures were not saved. Fixed a problem in the pi-sync mode by increasing the timeout for data transfer from 20 seconds to 5 minutes. Fixed some minor problems. (Like word wrap in help text windows). Fixed a compiling problem in microkde/kresources. KO/Pi is using zdbat (renamed to db2file) for syncing with Sharp DTM. This version now includes zdbat 1.0.0 (old version was zdbat 0.2.9) such that now syncing KO/Pi with Sharp DTM should work on the Zaurus C 3000 model. ********** VERSION 1.9.15 ************ Usebilty enhancements in KO/Pi: When clicking on the date in a month view cell, the day view is shown. Old behaviour was, that the "new event" dialog popped up. Added a one step "undo delete" in KO/Pi (Accessable in the "Action" menu). That means, you can restore the latest event/todo/journal you have deleted. A journal is deleted, if you clear all the text of the journal. Fixed the bug of the editor dialogs in KO/Pi of version 1.9.14. KA/Pi starting in 480x640 resolution: Hide the filter action in toolbar and added icons for undo/delete/redo in toolbar. Change in OM/Pi ViewMail dialog: When clicking on the "delete" icon the mail is deleted after confirmation as usual. But the edit dialog is not closed as before, now the next mail in the folder is shown automatically (if there is any). Fixed a crash when deleting mail-accounts in OM/Pi. ********** VERSION 1.9.14 ************ Fixed some problems with the dialog sizes when switching portrait/landscape mode on 640x480 PDA display. Fixed some other small bugs in KA/Pi KO/Pi and OM/Pi and PwM/Pi. Fixed an ugly bug in KOpieMail: KOpieMail was not able to write files (mails) to MSDOS file system, like on an usual preformatted SD card. That should work now. To save your mail data on the Sd card do the following: Create a dir on the SD card: mkdir /mnt/card/localmail Go to your home dir: cd Go to kopiemail data storage dir: cd kdepim/apps/kopiemail Create a symlink to the SD card: ls -s /mnt/card/localmail Now KOpieMail will store all mails on the SD card. KO/Pi Monthview: Now "Go to Today" selects the current month from day 1-end, not the current date + some days. I.e. "Go to Today" shows now always the current month with first day of month in the first row. Added missing German translation. Fixed icons of executeable on Wintendo. Added a "Show next Mail" button to the OM/Pi mail viewer such that the mail below the current mail in the mail list view of the current folder can be read with a single click. ********** VERSION 1.9.13 ************ Fixed nasty PwM/Pi file reading bug, when the used hash algo of file is different then the global hash algo. Added KA/Pi support for opie mailit mailapplication. Fixed some bugs in OM/Pi. Now character conversion tables are available for the Zaurus to make OM/Pi working properly. To get the character conversion in OM/Pi working, please download at the sourceforge project site the package sr-character-conversion_SharpROM_arm.ipk.zip (or oz-character-conversion_OZ-gcc3xx_arm.ipk.zip for OZ roms) from the section "general files for KDE/Pim" Instructions how to install this package are in a ReadMe in this file. Fixed the orientation change problem in KA/Pi when switching portrait/landscape mode. French translation available for KA/Pi and OM/Pi. Fixed some problems with categories in KO/Pi in DTM sync. Added selection dialog for export to phone in KA/Pi. If in KO/Pi is an attendee selected to add to a meeting and this attendee is already in the list of attendees, this person is not added again. Some menu cleanup in KA/Pi. ********** VERSION 1.9.12 ************ Fix for the bug in KO/Pi What's Next view of version 1.9.11. Bugfix: Licence file is now shown again. OM/Pi now supports Unicode (utf8 charset). Fixed some bugs in OM/Pi. KA/Pi has more German translation. ********** VERSION 1.9.11 ************ Fixed several problems in PWM/Pi, like asking the user, if unsaved changed are pending when closing the app. And PwM/Pi handles now different texts for the fields Description, Username, Password, configurable per category. Fixed a crash in KO/Pi , when importing/loading vcs files which have an entry with an attendee with state: NEEDS ACTION Fixed some problems in the German translation of OM/Pi, which makes some dialogs not fitting on the screen of the Z 5500. Fixed Qtopia crash, when disabling/deinstalling KO/Pi alarm applet. Implemented direct KDE<->KA/Pi sync for KA/Pi running on Linux desktop. Added feature "remove sync info" to sync menu. Tweaked the KO/Pi What's next view a bit, added setting to hide events that are done. Disabled "beam receive enabled" on startup to avoid problems if Fastload is enabled. Please set "beam receive enabled", if you want to receive data via IR. Fixed bug in direct KDE<->KO/Pi sync for KO/Pi running on Linux desktop. Made in KA/Pi scrolling possible, if details view is selected. (The keyboard focus is set automatically to the search line) Fixed a bug in DMT sync, that a new entry in DTM was added on every sync to Kx/Pi. Fixed missing writing of KA/Pi categories to DMT entries when syncing. Fixed a bug in DMT sync with todos created in KO/Pi containing non-latin1 characters. Rearranged package contents of Sharp-ipks and made all packages installable on SD again. Fixed the writing of addressbook data in DTM sync. Empty fields in KA/Pi were not removed. Added better category handling in KA/Pi: Added item Edit Categories and Manage new categories to the settings menu. Possible to configure a view to display categories. Added detailed "KDE Sync Howto" and "Multi Sync Howto" to Help menu. Fixed displaying of "free" days and time in KO Monthview and Agendaview. ... and many other bugfixes. ********** VERSION 1.9.10 ************ Many internal small bugfixes. And fix of the "big" bug in KO/Pi, that after Syncing the appointments had an offset by several hours. That was a problem with the internal timezone setting, introduced by the changed timezone configuration settings. German translation for OM/Pi is now available. ********** VERSION 1.9.9 ************ KDE-Pim/Pi has a new Member! It is called PWM/Pi (Passwordmanager/platform-independent) and it is available for the Zaurus. It is planned, that it will be available later for Windows. (And for Linux, of course). It is a port of the Passwordmanager of KDE. It will need the MicroKDElibs to run. Made loading of addressbooks in KA/Pi up to 7 times faster! The bigger your addressbook file, the more starting speed will you gain. (relatively) The Qtopia addressbook connector is now platform independend as well and should work on any platform for importing/exporting Qtopia and Opie XML files. Added a +30min feature to the timezone settings to make KDE-Pim/Pi useable in Australia and other parts on the world with strange timezones ;-) German "Umlaute" should now be sorted correctly on the Z in KA/Pi. It is now possible to disable the "receive data via infrared" feature, such that syncing with Outlook is now possible again with Kx/Pi runing. Please disable it, before syncing Sharp DTM with Outlook. For your convenience, the "receive data via infrared" feature is disabled automatically, if you sync Kx/Pi with DTM. You have to enable it again manually after syncing. Enabling this feature makes it impossible to start the Sharp DTM apps. If this feature is enabled, you will only get the alarm notification from KO/Pi and not from the Sharp calendar. This is very useful if you sync KO/Pi with Sharp DTM, because after syncing you usually would get notified about an alarm by KO/Pi and the Sharp Calendar. Together with the Linux desktop version of KO/Pi it is now possible to sync KO/Pi on the Zaurus with the complete KDE-desktop (3.3 or later) calendar data easily. That makes it possible to sync the Z with one click of a mouse with the KDE-Desktop. This feature it available for all Zaurus platforms KO/Pi is running on. The only thing needed is a running KO/Pi on Linux and a compiled version of the small KDE-Pim/Pi<->KDE-Desktop access command line program, which is in the KDE-Pim/Pi sources available. The "KDE-desktop" syncing feature for KA/Pi will follow in the next releases. Fixed the vcard export bug, which had the version 1.9.8. Added missing GERMAN translation to KO/Pi. Hi PsionX, could you add the missing french translation?Thx! Translation files for KA/Pi are available as well. GERMAN translation will be available in the next release. PsionX ( yres, you again ;-) ), could you start translating KA/Pi? Thx! You can download the version 1.9.9 at http://sourceforge.net/project/showfiles.php?group_id=104103&package_id=112604 Note: To run the mail program OM/Pi you need libopenssl. A link to a download loaction is available at ZSI at www.killefiz.de ********** VERSION 1.9.8 ************ Fixed character decoding in OM/Pi. (e.g. German "Umlaute" were not displayed properly.) Made is possible to reparent todos in KO/Pi. Use contextmenu or keys (look at Help-Keys + Colors) for that. Added the missing Sync-Howto and WhatsNew to the packages. KO/Pi on Linux desktop can now sync with KDE desktop. That means: When using KO/Pi on Linux desktop for syncing with KDE desktop and the Zaurus, the Zaurus can be synced now with all KDE-Calendar resources, not only with one local file. (That makes it possible to sync the Zaurus with the calendar data on a Kolab server) KA/Pi syncing with KDE desktop will be available in the next version. ********** VERSION 1.9.7 ************ KO/Pi - KA/Pi on Windows: Now a directory can be defined by the user, where the application/config data should be saved. Define your desired path in the evironment variable MICROKDEHOME before starting KO/Pi or KA/Pi. An easy Kx/Pi to Kx/Pi syncing is now possible (it is called Pi-Sync) via network. Please look at the Sync Howto. Exporting of calendar data and contacts to mobile phones is now possible. The SyncHowto is updated with information howto access/sync mobile phones. Please look at the Sync Howto. Now KO/Pi and KA/Pi on the Zaurus can receive data via infrared directly. Please disable Fastload for the original contact/calendar applications and close them. KO/Pi and KA/Pi must be running in order to receive the data. (KO/Pi and KA/Pi are always running if Fastload for them is enabled!) In the KA/Pi details view are now the preferred tel. numbers displayed on top of the other data ( emails/tel.numbers/addresses) Fixed some syncing problems in KA/Pi. Added font settings for the KA/Pi details view. Added fields "children's name" and "gender" to KA/Pi. Made searching in KA/Pi better: Now the first item in a view is selected after a search automatically and the views can be scrolled up/down when the search input field has the keyboard focus. And, of course, fixed a bunch of reported bugs in KO/Pi and KA/Pi. ********** VERSION 1.9.6 ************ Changes in the external application communication on the Zaurus in order to use less RAM when the apps are running. First syncing of addressbooks (KA/Pi) is possible. ********** VERSION 1.9.5a ************ Fixed a bug in KO/Pi in the SharpDTM sync of version 1.9.5. Fixed some small bugs. KA/Pi shows now the birthday in summary view. Now OM/Pi and KA/Pi are using the date format defined in KO/Pi for displaying dates. ********** VERSION 1.9.5 ************ There is still no Addressbook syncing! New in 1.9.5: Many bugfixes. Better searching in KA/Pi. You can configure in KA/Pi if you want to search only after <return> key pressed. Better mail downloading in OM/Pi. First experimental alpha version of sync of KO/Pi with mobile phones. See gammu documentation for supported phones. You need to install the package kammu_1.9.5_arm.ipk for sync of KO/Pi with mobile phones. kammu_1.9.5_arm.ipk needs libbluetooth and libsdp. Quick hint how to use: NOTE: MOBILE PHONE SYNC IS EXPERIMENTAL! Install kammu_1.9.5_arm.ipk , libbluetooth and libsdp. Create syncprofile - mobile device Remove entry for model. (Leave empty ). Enable infrared on Zaurus and your Phone. Sync. To get a more detailed log, start kopi from konsole. ********** VERSION 1.9.4 ************ This is the version 1.9.4 of KDE-Pim/Pi for the Zaurus. WARNING: PLEASE BACKUP ALL YOUR DATA! We have changed a lot and maybe there are some unknown problems. SYNC HANDLING HAS CHANGED! Such that, if you sync now with an already synded device, you will duplicated entries after the first sync. (This change was introduced to make it possible to sync with mobile phones, which will be available later (maybe in 4 weeks). You need the kmicrokdelibs_1.9.4_arm.ipk as a base for the other programs. If you get the error: "Install only possible in main memory", just try it again to install it on SD card. That worked for me. And it was reported that rebooting Qtopia did help in this case as well. As programs are available: KO/Pi (korganizer ipk) - a calendar program. KA/Pi (kaddressbook ipk ) - an addressbook OM/Pi (kopiemail ipk ) an email program with pop/smtp and IMAP support. An alarm notification program ( korganizer-alarm ipk ) for KO/Pi that notifies you about alarms, even if the Zaurus is in suspend mode. (If you do not see an icon in the taskbar after installing korganizer-alarm, please restart Qtopia) All the applications are installed in a "Pim" TAB. If this TAB is new on your system, you can get an icon in this TAB by installing pim_TAB_icon_1.9.4_arm.ipk All the application are integrated. Such that you can choose in KO/Pi the attendees of a meeting from the addresses in KA/Pi. When you click in KA/Pi on the email address, OM/Pi is started to write the mail. HINT: If you install KPhone/Pi 0.9.7, it will be called, if you click in KA/Pi on a phone number. What's new? SYNC HANDLING HAS CHANGED! diff --git a/kmicromail/libetpan/mh/mailmh.c b/kmicromail/libetpan/mh/mailmh.c index 1087ce1..2d1f26d 100644 --- a/kmicromail/libetpan/mh/mailmh.c +++ b/kmicromail/libetpan/mh/mailmh.c @@ -412,579 +412,582 @@ int mailmh_folder_update(struct mailmh_folder * folder) chashdatum key; chashdatum data; if (ent->d_name[0] == '.') { if (ent->d_name[1] == 0) continue; if ((ent->d_name[1] == '.') && (ent->d_name[2] == 0)) continue; } key.data = ent->d_name; key.len = strlen(ent->d_name); r = chash_get(folder->fl_subfolders_hash, &key, &data); if (r < 0) { subfolder = mailmh_folder_new(folder, ent->d_name); if (subfolder == NULL) { res = MAILMH_ERROR_MEMORY; goto closedir; } r = carray_add(folder->fl_subfolders_tab, subfolder, &array_index); if (r < 0) { mailmh_folder_free(subfolder); res = MAILMH_ERROR_MEMORY; goto closedir; } subfolder->fl_array_index = array_index; key.data = subfolder->fl_filename; key.len = strlen(subfolder->fl_filename); data.data = subfolder; data.len = 0; r = chash_set(folder->fl_subfolders_hash, &key, &data, NULL); if (r < 0) { carray_delete_fast(folder->fl_subfolders_tab, subfolder->fl_array_index); mailmh_folder_free(subfolder); res = MAILMH_ERROR_MEMORY; goto closedir; } } } } } while (ent != NULL); folder->fl_max_index = max_index; mh_seq = malloc(strlen(folder->fl_filename) + 2 + sizeof(".mh_sequences")); if (mh_seq == NULL) { res = MAILMH_ERROR_MEMORY; goto closedir; } strcpy(mh_seq, folder->fl_filename); strcat(mh_seq, MAIL_DIR_SEPARATOR_S); strcat(mh_seq, ".mh_sequences"); if (stat(mh_seq, &buf) == -1) { int fd; fd = creat(mh_seq, S_IRUSR | S_IWUSR); if (fd != -1) close(fd); } free(mh_seq); closedir(d); return MAILMH_NO_ERROR; closedir: closedir(d); err: return res; } int mailmh_folder_add_subfolder(struct mailmh_folder * parent, const char * name) { char * foldername; int r; struct mailmh_folder * folder; unsigned int array_index; chashdatum key; chashdatum data; foldername = malloc(strlen(parent->fl_filename) + strlen(name) + 2); if (foldername == NULL) return MAILMH_ERROR_MEMORY; strcpy(foldername, parent->fl_filename); strcat(foldername, MAIL_DIR_SEPARATOR_S); strcat(foldername, name); r = mkdir(foldername, 0700); free(foldername); if (r < 0) return MAILMH_ERROR_FOLDER; folder = mailmh_folder_new(parent, name); if (folder == NULL) return MAILMH_ERROR_MEMORY; r = carray_add(parent->fl_subfolders_tab, folder, &array_index); if (r < 0) { mailmh_folder_free(folder); return MAILMH_ERROR_MEMORY; } folder->fl_array_index = array_index; key.data = folder->fl_filename; key.len = strlen(folder->fl_filename); data.data = folder; data.len = 0; r = chash_set(parent->fl_subfolders_hash, &key, &data, NULL); if (r < 0) { carray_delete_fast(folder->fl_subfolders_tab, folder->fl_array_index); mailmh_folder_free(folder); return MAILMH_ERROR_MEMORY; } return MAILMH_NO_ERROR; } int mailmh_folder_remove_subfolder(struct mailmh_folder * folder) { struct mailmh_folder * parent; chashdatum key; chashdatum data; int r; parent = folder->fl_parent; key.data = folder->fl_filename; key.len = strlen(folder->fl_filename); r = chash_get(parent->fl_subfolders_hash, &key, &data); if (r < 0) return MAILMH_ERROR_FOLDER; chash_delete(parent->fl_subfolders_hash, &key, NULL); carray_delete_fast(parent->fl_subfolders_tab, folder->fl_array_index); mailmh_folder_free(folder); return MAILMH_NO_ERROR; } int mailmh_folder_rename_subfolder(struct mailmh_folder * src_folder, struct mailmh_folder * dst_folder, const char * new_name) { int r; struct mailmh_folder * folder; struct mailmh_folder * parent; char * new_foldername; parent = src_folder->fl_parent; if (parent == NULL) return MAILMH_ERROR_RENAME; new_foldername = malloc(strlen(dst_folder->fl_filename) + 2 + strlen(new_name)); if (new_foldername == NULL) return MAILMH_ERROR_MEMORY; strcpy(new_foldername, dst_folder->fl_filename); strcat(new_foldername, MAIL_DIR_SEPARATOR_S); strcat(new_foldername, new_name); r = rename(src_folder->fl_filename, new_foldername); free(new_foldername); if (r < 0) return MAILMH_ERROR_RENAME; r = mailmh_folder_remove_subfolder(src_folder); if (r != MAILMH_NO_ERROR) return r; folder = mailmh_folder_new(dst_folder, new_name); if (folder == NULL) return MAILMH_ERROR_MEMORY; r = carray_add(parent->fl_subfolders_tab, folder, NULL); if (r < 0) { mailmh_folder_free(folder); return MAILMH_ERROR_MEMORY; } return MAILMH_NO_ERROR; } #define MAX_TRY_ALLOC 32 /* initial file MUST be in the same directory */ static int mailmh_folder_alloc_msg(struct mailmh_folder * folder, char * filename, uint32_t * result) { uint32_t max; uint32_t k; char * new_filename; size_t len; struct stat f_stat; len = strlen(folder->fl_filename) + 20; new_filename = malloc(len); if (new_filename == NULL) return MAILMH_ERROR_MEMORY; max = folder->fl_max_index + 1; //fprintf(stderr,"mailmh_folder_alloc_msg filename: %s \n", filename); k = 0; while (k < MAX_TRY_ALLOC) { snprintf(new_filename, len, "%s%c%lu", folder->fl_filename, MAIL_DIR_SEPARATOR, (unsigned long) (max + k)); //fprintf(stderr,"mailmh_folder_alloc_msg new_filename: %s \n", new_filename); if ( stat( new_filename, &f_stat ) == -1 ) { // if (link(filename, new_filename) == 0) { int r; //fprintf(stderr,"filename found \n"); //unlink(filename); rename (filename,new_filename ); free(new_filename); if (k > MAX_TRY_ALLOC / 2) { r = mailmh_folder_update(folder); /* ignore errors */ } * result = max + k; folder->fl_max_index = max + k; return MAILMH_NO_ERROR; } else if (errno == EXDEV) { free(filename); return MAILMH_ERROR_FOLDER; } k ++; } free(new_filename); return MAILMH_ERROR_FOLDER; } int mailmh_folder_get_message_filename(struct mailmh_folder * folder, uint32_t index, char ** result) { char * filename; int len; #if 0 r = mailmh_folder_update(folder); if (r != MAILMH_NO_ERROR) return r; #endif len = strlen(folder->fl_filename) + 20; filename = malloc(len); if (filename == NULL) return MAILMH_ERROR_MEMORY; snprintf(filename, len, "%s%c%lu", folder->fl_filename, MAIL_DIR_SEPARATOR, (unsigned long) index); * result = filename; return MAILMH_NO_ERROR;; } int mailmh_folder_get_message_fd(struct mailmh_folder * folder, uint32_t index, int flags, int * result) { char * filename; int fd; int r; #if 0 r = mailmh_folder_update(folder); if (r != MAILMH_NO_ERROR) return r; #endif r = mailmh_folder_get_message_filename(folder, index, &filename); if (r != MAILMH_NO_ERROR) return r; fd = open(filename, flags); free(filename); if (fd == -1) return MAILMH_ERROR_MSG_NOT_FOUND; * result = fd; return MAILMH_NO_ERROR; } int mailmh_folder_get_message_size(struct mailmh_folder * folder, uint32_t index, size_t * result) { int r; char * filename; struct stat buf; r = mailmh_folder_get_message_filename(folder, index, &filename); if (r != MAILMH_NO_ERROR) return r; r = stat(filename, &buf); free(filename); if (r < 0) return MAILMH_ERROR_FILE; * result = buf.st_size; return MAILMH_NO_ERROR; } int mailmh_folder_add_message_uid(struct mailmh_folder * folder, const char * message, size_t size, uint32_t * pindex) { char * tmpname; int fd; size_t namesize; size_t left; ssize_t res; struct mailmh_msg_info * msg_info; uint32_t index; int error; int r; unsigned int array_index; struct stat buf; chashdatum key; chashdatum data; #if 0 r = mailmh_folder_update(folder); if (r != MAILMH_NO_ERROR) { error = r; goto err; } #endif namesize = strlen(folder->fl_filename) + 20; tmpname = malloc(namesize); snprintf(tmpname, namesize, "%s%ctmpXXXXXX", folder->fl_filename, MAIL_DIR_SEPARATOR); fd = mkstemp(tmpname); if (fd < 0) { error = MAILMH_ERROR_FILE; goto free; } left = size; while (left > 0) { res = write(fd, message, left); if (res == -1) { close(fd); error = MAILMH_ERROR_FILE; goto free; } left -= res; } close(fd); r = stat(tmpname, &buf); if (r < 0) { error = MAILMH_ERROR_FILE; goto free; } r = mailmh_folder_alloc_msg(folder, tmpname, &index); if (r != MAILMH_NO_ERROR) { unlink(tmpname); error = MAILMH_ERROR_COULD_NOT_ALLOC_MSG; goto free; } free(tmpname); msg_info = mailmh_msg_info_new(index, size, buf.st_mtime); if (msg_info == NULL) { mailmh_folder_remove_message(folder, index); error = MAILMH_ERROR_MEMORY; goto err; } r = carray_add(folder->fl_msgs_tab, msg_info, &array_index); if (r < 0) { mailmh_folder_remove_message(folder, index); mailmh_msg_info_free(msg_info); error = MAILMH_ERROR_MEMORY; goto err; } msg_info->msg_array_index = array_index; #if 0 r = cinthash_add(folder->fl_msgs_hash, index, msg_info); #endif key.data = &index; key.len = sizeof(index); data.data = msg_info; data.len = 0; if (pindex != NULL) * pindex = index; r = chash_set(folder->fl_msgs_hash, &key, &data, NULL); if (r < 0) { carray_delete_fast(folder->fl_msgs_tab, msg_info->msg_array_index); mailmh_msg_info_free(msg_info); error = MAILMH_ERROR_MEMORY; goto err; } return MAILMH_NO_ERROR; free: free(tmpname); err: return error; } int mailmh_folder_add_message(struct mailmh_folder * folder, const char * message, size_t size) { return mailmh_folder_add_message_uid(folder, message, size, NULL); } int mailmh_folder_add_message_file_uid(struct mailmh_folder * folder, int fd, uint32_t * pindex) { char * message; struct stat buf; int r; #if 0 r = mailmh_folder_update(folder); if (r != MAILMH_NO_ERROR) return r; #endif if (fstat(fd, &buf) == -1) return MAILMH_ERROR_FILE; message = mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (message == MAP_FAILED) return MAILMH_ERROR_FILE; r = mailmh_folder_add_message_uid(folder, message, buf.st_size, pindex); munmap(message, buf.st_size); return r; } int mailmh_folder_add_message_file(struct mailmh_folder * folder, int fd) { return mailmh_folder_add_message_file_uid(folder, fd, NULL); } int mailmh_folder_remove_message(struct mailmh_folder * folder, uint32_t index) { char * filename; struct mailmh_msg_info * msg_info; int res; int r; chashdatum key; chashdatum data; #if 0 r = mailmh_folder_update(folder); if (r != MAILMH_NO_ERROR) { res = r; goto err; } #endif r = mailmh_folder_get_message_filename(folder, index, &filename); if (filename == NULL) { res = r; goto err; } if (unlink(filename) == -1) { res = MAILMH_ERROR_FILE; goto free; } key.data = &index; key.len = sizeof(index); r = chash_get(folder->fl_msgs_hash, &key, &data); #if 0 msg_info = cinthash_find(folder->fl_msgs_hash, index); #endif if (r == 0) { msg_info = data.data; carray_delete_fast(folder->fl_msgs_tab, msg_info->msg_array_index); #if 0 cinthash_remove(folder->fl_msgs_hash, index); #endif chash_delete(folder->fl_msgs_hash, &key, NULL); } + // LR + mailmh_msg_info_free( msg_info ); + free(filename); return MAILMH_NO_ERROR; free: free(filename); err: return res; } int mailmh_folder_move_message(struct mailmh_folder * dest_folder, struct mailmh_folder * src_folder, uint32_t index) { int fd; char * filename; int r; #if 0 r = mailmh_folder_update(dest_folder); if (r != MAILMH_NO_ERROR) return r; r = mailmh_folder_update(src_folder); if (r != MAILMH_NO_ERROR) return r; #endif /* move on the same filesystem */ r = mailmh_folder_get_message_filename(src_folder, index, &filename); if (r != MAILMH_NO_ERROR) return r; r = mailmh_folder_alloc_msg(dest_folder, filename, &index); free(filename); if (r == MAILMH_NO_ERROR) return MAILMH_NO_ERROR; /* move on the different filesystems */ r = mailmh_folder_get_message_fd(src_folder, index, O_RDONLY, &fd); if (r != MAILMH_NO_ERROR) return r; r = mailmh_folder_add_message_file(dest_folder, fd); if (r != MAILMH_NO_ERROR) { close(fd); return r; } close(fd); r = mailmh_folder_remove_message(src_folder, index); return MAILMH_NO_ERROR; } unsigned int mailmh_folder_get_message_number(struct mailmh_folder * folder) { unsigned int i; unsigned int count; count = 0; for(i = 0 ; i < carray_count(folder->fl_msgs_tab) ; i ++) if (carray_get(folder->fl_msgs_tab, i) != NULL) count ++; return count; } |