static void local_summary_finalize (GObject *object) { CamelLocalSummary *local_summary; local_summary = CAMEL_LOCAL_SUMMARY (object); g_free (local_summary->folder_path); /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (camel_local_summary_parent_class)->finalize (object); }
static void local_summary_dispose (GObject *object) { CamelLocalSummary *local_summary; local_summary = CAMEL_LOCAL_SUMMARY (object); if (local_summary->index != NULL) { g_object_unref (local_summary->index); local_summary->index = NULL; } /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (camel_local_summary_parent_class)->dispose (object); }
static gboolean maildir_folder_append_message_sync (CamelFolder *folder, CamelMimeMessage *message, CamelMessageInfo *info, gchar **appended_uid, GCancellable *cancellable, GError **error) { CamelLocalFolder *lf = (CamelLocalFolder *)folder; CamelStream *output_stream; CamelMessageInfo *mi; CamelMaildirMessageInfo *mdi; gchar *name, *dest = NULL; gboolean success = TRUE; d(printf("Appending message\n")); /* If we can't lock, don't do anything */ if (camel_local_folder_lock (lf, CAMEL_LOCK_WRITE, error) == -1) return FALSE; /* add it to the summary/assign the uid, etc */ mi = camel_local_summary_add ( CAMEL_LOCAL_SUMMARY (folder->summary), message, info, lf->changes, error); if (mi == NULL) goto check_changed; if ((camel_message_info_flags (mi) & CAMEL_MESSAGE_ATTACHMENTS) && !camel_mime_message_has_attachment (message)) camel_message_info_set_flags (mi, CAMEL_MESSAGE_ATTACHMENTS, 0); mdi = (CamelMaildirMessageInfo *)mi; d(printf("Appending message: uid is %s filename is %s\n", camel_message_info_uid(mi), mdi->filename)); /* write it out to tmp, use the uid we got from the summary */ name = g_strdup_printf ("%s/tmp/%s", lf->folder_path, camel_message_info_uid(mi)); output_stream = camel_stream_fs_new_with_name ( name, O_WRONLY|O_CREAT, 0600, error); if (output_stream == NULL) goto fail_write; if (camel_data_wrapper_write_to_stream_sync ( (CamelDataWrapper *)message, output_stream, cancellable, error) == -1 || camel_stream_close (output_stream, cancellable, error) == -1) goto fail_write; /* now move from tmp to cur (bypass new, does it matter?) */ dest = g_strdup_printf("%s/cur/%s", lf->folder_path, camel_maildir_info_filename (mdi)); if (g_rename (name, dest) == -1) { g_set_error ( error, G_IO_ERROR, g_io_error_from_errno (errno), "%s", g_strerror (errno)); goto fail_write; } g_free (dest); g_free (name); if (appended_uid) *appended_uid = g_strdup(camel_message_info_uid(mi)); if (output_stream) g_object_unref (output_stream); goto check_changed; fail_write: /* remove the summary info so we are not out-of-sync with the mh folder */ camel_folder_summary_remove_uid (CAMEL_FOLDER_SUMMARY (folder->summary), camel_message_info_uid (mi)); g_prefix_error ( error, _("Cannot append message to maildir folder: %s: "), name); if (output_stream) { g_object_unref (CAMEL_OBJECT (output_stream)); unlink (name); } g_free (name); g_free (dest); success = FALSE; check_changed: camel_local_folder_unlock (lf); if (lf && camel_folder_change_info_changed (lf->changes)) { camel_folder_changed (folder, lf->changes); camel_folder_change_info_clear (lf->changes); } return success; }