X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=blobdiff_plain;f=src%2Fplugins%2Fvcalendar%2Fvcal_manager.c;h=1f11f26f448eb1307e304c24adda106b13d9120a;hp=7ae557e959022b44ce50496330311c2b2bb944f2;hb=e727be6329c2589a739f2260bbf164c43701ba77;hpb=9bf8ceff3443878a49a4d8a726fe1299922edad4 diff --git a/src/plugins/vcalendar/vcal_manager.c b/src/plugins/vcalendar/vcal_manager.c index 7ae557e95..1f11f26f4 100644 --- a/src/plugins/vcalendar/vcal_manager.c +++ b/src/plugins/vcalendar/vcal_manager.c @@ -567,7 +567,7 @@ static gchar *write_headers_date(const gchar *uid) t = time(NULL) + (86400*7); t_subject = _("Later"); } else { - g_warning("unknown spec date\n"); + g_warning("unknown spec date"); return NULL; } @@ -638,8 +638,8 @@ gchar *vcal_manager_dateevent_dump(const gchar *uid, FolderItem *item) if (str_write_to_file(body, tmpfile) < 0) { g_free(tmpfile); tmpfile = NULL; - } - chmod(tmpfile, S_IRUSR|S_IWUSR); + } else + chmod(tmpfile, S_IRUSR|S_IWUSR); g_free(body); g_free(headers); @@ -751,8 +751,8 @@ gchar *vcal_manager_icalevent_dump(icalcomponent *event, gchar *orga, icalcompon if (str_write_to_file(body, tmpfile) < 0) { g_free(tmpfile); tmpfile = NULL; - } - chmod(tmpfile, S_IRUSR|S_IWUSR); + } else + chmod(tmpfile, S_IRUSR|S_IWUSR); g_strfreev(lines); g_free(body); @@ -776,7 +776,7 @@ VCalEvent * vcal_manager_new_event (const gchar *uid, const gchar *url, enum icalproperty_method method, gint sequence, - enum icalproperty_kind type) + enum icalcomponent_kind type) { VCalEvent *event = g_new0(VCalEvent, 1); @@ -920,7 +920,7 @@ void vcal_manager_save_event (VCalEvent *event, gboolean export_after) xml_tag_add_attr(tag, xml_attr_new("type", tmp)); g_free(tmp); - tmp = g_strdup_printf("%lu", event->postponed); + tmp = g_strdup_printf("%lld", (long long)event->postponed); xml_tag_add_attr(tag, xml_attr_new("postponed", tmp)); g_free(tmp); @@ -953,20 +953,26 @@ void vcal_manager_save_event (VCalEvent *event, gboolean export_after) path = vcal_manager_get_event_file(event->uid); if ((pfile = prefs_write_open(path)) == NULL) { - make_dir(vcal_manager_get_event_path()); + gchar *dir_path = vcal_manager_get_event_path(); + if (!is_dir_exist(dir_path) && make_dir(vcal_manager_get_event_path()) != 0) { + g_free(dir_path); + g_free(path); + return; + } + g_free(dir_path); if ((pfile = prefs_write_open(path)) == NULL) { - free(path); + g_free(path); return; } } - free(path); + g_free(path); xml_file_put_xml_decl(pfile->fp); xml_write_tree(rootnode, pfile->fp); xml_free_tree(rootnode); if (prefs_file_close(pfile) < 0) { - g_warning("failed to write event.\n"); + g_warning("failed to write event."); return; } @@ -983,7 +989,7 @@ static VCalEvent *event_get_from_xml (const gchar *uid, GNode *node) gchar *description = NULL, *url = NULL, *recur = NULL; VCalEvent *event = NULL; enum icalproperty_method method = ICAL_METHOD_REQUEST; - enum icalproperty_kind type = ICAL_VEVENT_COMPONENT; + enum icalcomponent_kind type = ICAL_VEVENT_COMPONENT; gint sequence = 0, rec_occurence = 0; time_t postponed = (time_t)0; @@ -991,7 +997,7 @@ static VCalEvent *event_get_from_xml (const gchar *uid, GNode *node) xmlnode = node->data; if (strcmp2(xmlnode->tag->tag, "event") != 0) { - g_warning("tag name != \"event\"\n"); + g_warning("tag name != \"event\""); return NULL; } @@ -1059,7 +1065,7 @@ static VCalEvent *event_get_from_xml (const gchar *uid, GNode *node) xmlnode = node->data; if (strcmp2(xmlnode->tag->tag, "answer") != 0) { - g_warning("tag name != \"answer\"\n"); + g_warning("tag name != \"answer\""); return event; } list = xmlnode->tag->attr; @@ -1105,7 +1111,7 @@ VCalEvent *vcal_manager_load_event (const gchar *uid) g_free(path); if (!node) { - g_warning("no node\n"); + g_warning("no node"); return NULL; } @@ -1174,6 +1180,8 @@ static gchar *write_headers(PrefsAccount *account, gchar msgid[128]; gchar *calmsgid = NULL; + cm_return_val_if_fail(account != NULL, NULL); + memset(date, 0, sizeof(date)); if (is_pseudo_display) { @@ -1237,11 +1245,14 @@ static gchar *write_headers(PrefsAccount *account, else if (status == ICAL_PARTSTAT_TENTATIVE) prefix = _("Tentatively Accepted: "); else - prefix = "Re: "; - } else if (event->method == ICAL_METHOD_PUBLISH) + prefix = "Re: "; + } else if (event->method == ICAL_METHOD_PUBLISH) { method_str = "PUBLISH"; - else - method_str = "REQUEST"; + } else if (event->method == ICAL_METHOD_CANCEL) { + method_str = "CANCEL"; + } else { + method_str = "REQUEST"; + } subject = g_strdup_printf("%s%s", prefix, event->summary); @@ -1412,7 +1423,7 @@ static gboolean vcal_manager_send (PrefsAccount *account, folderitem = account_get_special_folder(account, F_QUEUE); if (!folderitem) { - g_warning("can't find queue folder for %s\n", account->address); + g_warning("can't find queue folder for %s", account->address); g_unlink(tmpfile); g_free(tmpfile); return FALSE; @@ -1420,7 +1431,7 @@ static gboolean vcal_manager_send (PrefsAccount *account, folder_item_scan(folderitem); if ((msgnum = folder_item_add_msg(folderitem, tmpfile, NULL, TRUE)) < 0) { - g_warning("can't queue the message\n"); + g_warning("can't queue the message"); g_unlink(tmpfile); g_free(tmpfile); return FALSE;