# HG changeset patch # User Carl Byington # Date 1311899329 25200 # Node ID 8b3a827b71f47ca870517d44ef30338335ba4dc6 # Parent 2066f13990a30c3a13b45e89208c8fcfb85d1e6b add alarm reminders to calendar events diff -r 2066f13990a3 -r 8b3a827b71f4 python/python-libpst.cpp --- a/python/python-libpst.cpp Sun Jul 10 17:03:17 2011 -0700 +++ b/python/python-libpst.cpp Thu Jul 28 17:28:49 2011 -0700 @@ -556,6 +556,7 @@ .add_property("extra_fields", make_getter(&pst_item::extra_fields, return_value_policy())) .add_property("journal", make_getter(&pst_item::journal, return_value_policy())) .add_property("appointment", make_getter(&pst_item::appointment, return_value_policy())) + .def_readonly("block_id", &pst_item::block_id) .def_readonly("type", &pst_item::type) .def_readonly("ascii_type", &pst_item::ascii_type) .def_readonly("flags", &pst_item::flags) diff -r 2066f13990a3 -r 8b3a827b71f4 regression/regression-tests.bash --- a/regression/regression-tests.bash Sun Jul 10 17:03:17 2011 -0700 +++ b/regression/regression-tests.bash Thu Jul 28 17:28:49 2011 -0700 @@ -118,14 +118,14 @@ #$func 15 hourig1.pst #$func 16 test-mac.pst #$func 18 spam.pst -#$func 19 rendgen.pst # single email appointment -#$func 20 rendgen2.pst # email appointment with no termination date -#$func 21 rendgen3.pst # mime signed email -#$func 22 rendgen4.pst # appointment test cases -#$func 23 rendgen5.pst # appointment test cases +$func 19 rendgen.pst # single email appointment +$func 20 rendgen2.pst # email appointment with no termination date +$func 21 rendgen3.pst # mime signed email +$func 22 rendgen4.pst # appointment test cases +$func 23 rendgen5.pst # appointment test cases #$func 24 paul.sheer.pst # embedded rfc822 attachment #$func 25 jerry.pst # non ascii subject lines -$func 26 phill.bertolus.pst # possible segfault in forked process, cannot reproduce +#$func 26 phill.bertolus.pst # possible segfault in forked process, cannot reproduce #$func 27 justin.phelps.pst # segfault? diff -r 2066f13990a3 -r 8b3a827b71f4 src/libpst.c --- a/src/libpst.c Sun Jul 10 17:03:17 2011 -0700 +++ b/src/libpst.c Thu Jul 28 17:28:49 2011 -0700 @@ -281,7 +281,7 @@ static pst_mapi_object* pst_parse_block(pst_file *pf, uint64_t block_id, pst_id2_tree *i2_head); static void pst_printDptr(pst_file *pf, pst_desc_tree *ptr); static void pst_printID2ptr(pst_id2_tree *ptr); -static int pst_process(pst_mapi_object *list, pst_item *item, pst_item_attach *attach); +static int pst_process(uint64_t block_id, pst_mapi_object *list, pst_item *item, pst_item_attach *attach); static size_t pst_read_block_size(pst_file *pf, int64_t offset, size_t size, char **buf); static int pst_decrypt(uint64_t i_id, char *buf, size_t size, unsigned char type); static int pst_stricmp(char *a, char *b); @@ -1246,7 +1246,7 @@ item = (pst_item*) pst_malloc(sizeof(pst_item)); memset(item, 0, sizeof(pst_item)); - if (pst_process(list, item, NULL)) { + if (pst_process(d_ptr->desc->i_id, list, item, NULL)) { DEBUG_WARN(("pst_process() returned non-zero value. That is an error\n")); pst_freeItem(item); pst_free_list(list); @@ -1267,7 +1267,7 @@ attach->next = item->attach; item->attach = attach; } - if (pst_process(list, item, item->attach)) { + if (pst_process(id2_ptr->id->i_id, list, item, item->attach)) { DEBUG_WARN(("ERROR pst_process() failed with DSN/MDN attachments\n")); pst_freeItem(item); pst_free_list(list); @@ -1299,7 +1299,7 @@ attach->next = item->attach; item->attach = attach; } - if (pst_process(list, item, item->attach)) { + if (pst_process(id2_ptr->id->i_id, list, item, item->attach)) { DEBUG_WARN(("ERROR pst_process() failed with attachments\n")); pst_freeItem(item); pst_free_list(list); @@ -1329,7 +1329,7 @@ } // reprocess the same attachment list against new data // this might update attach->id2_val - if (pst_process(list, item, attach)) { + if (pst_process(id2_ptr->id->i_id, list, item, attach)) { DEBUG_WARN(("ERROR pst_process() failed with an attachment\n")); pst_free_list(list); continue; @@ -2121,7 +2121,7 @@ * * @return 0 for ok, -1 for error. */ -static int pst_process(pst_mapi_object *list, pst_item *item, pst_item_attach *attach) { +static int pst_process(uint64_t block_id, pst_mapi_object *list, pst_item *item, pst_item_attach *attach) { DEBUG_ENT("pst_process"); if (!item) { DEBUG_WARN(("item cannot be NULL.\n")); @@ -2129,6 +2129,7 @@ return -1; } + item->block_id = block_id; while (list) { int32_t x; char time_buffer[30]; diff -r 2066f13990a3 -r 8b3a827b71f4 src/libpst.h --- a/src/libpst.h Sun Jul 10 17:03:17 2011 -0700 +++ b/src/libpst.h Thu Jul 28 17:28:49 2011 -0700 @@ -760,6 +760,8 @@ * each major mapi item type. It represents a complete mapi object. */ typedef struct pst_item { + /** block id that can be used to generate uid */ + uint64_t block_id; /** email mapi elements */ pst_item_email *email; /** folder mapi elements */ diff -r 2066f13990a3 -r 8b3a827b71f4 src/readpst.c --- a/src/readpst.c Sun Jul 10 17:03:17 2011 -0700 +++ b/src/readpst.c Thu Jul 28 17:28:49 2011 -0700 @@ -1377,10 +1377,10 @@ fprintf(f_output, "BEGIN:VEVENT\n"); if (sender) { if (item->email->outlook_sender_name.str) { - fprintf(f_output, "ORGANIZER;CN=\"%s\":MAILTO:%s\n", item->email->outlook_sender_name.str, sender); - } else { - fprintf(f_output, "ORGANIZER;CN=\"\":MAILTO:%s\n", sender); - } + fprintf(f_output, "ORGANIZER;CN=\"%s\":MAILTO:%s\n", item->email->outlook_sender_name.str, sender); + } else { + fprintf(f_output, "ORGANIZER;CN=\"\":MAILTO:%s\n", sender); + } } write_appointment(f_output, item); fprintf(f_output, "END:VCALENDAR\n"); @@ -1965,6 +1965,7 @@ pst_convert_utf8_null(item, &item->body); pst_convert_utf8_null(item, &appointment->location); + fprintf(f_output, "UID:%#"PRIx64"\n", item->block_id); fprintf(f_output, "DTSTAMP:%s\n", pst_rfc2445_datetime_format_now(sizeof(time_buffer), time_buffer)); if (item->create_date) fprintf(f_output, "CREATED:%s\n", pst_rfc2445_datetime_format(item->create_date, sizeof(time_buffer), time_buffer)); @@ -2058,6 +2059,14 @@ fprintf(f_output, "CATEGORIES:PHONE-CALL\n"); break; } + // ignore bogus alarms + if (appointment->alarm && (appointment->alarm_minutes >= 0) && (appointment->alarm_minutes < 1440)) { + fprintf(f_output, "BEGIN:VALARM\n"); + fprintf(f_output, "TRIGGER:-PT%dM\n", appointment->alarm_minutes); + fprintf(f_output, "ACTION:DISPLAY\n"); + fprintf(f_output, "DESCRIPTION:Reminder\n"); + fprintf(f_output, "END:VALARM\n"); + } } fprintf(f_output, "END:VEVENT\n"); if (result) free(result);