static EPassMsg * ep_msg_new (void (*dispatch) (EPassMsg *)) { EPassMsg *msg; e_passwords_init (); msg = g_malloc0 (sizeof (*msg)); msg->dispatch = dispatch; msg->done = e_flag_new (); msg->ismain = (g_thread_self () == main_thread); return msg; }
static VCFBackendSearchClosure* init_closure (EDataBookView *book_view, EBookBackendVCF *bvcf) { VCFBackendSearchClosure *closure = g_new (VCFBackendSearchClosure, 1); closure->bvcf = bvcf; closure->view = book_view; closure->thread = NULL; closure->running = e_flag_new (); g_object_set_data_full (G_OBJECT (book_view), "EBookBackendVCF.BookView::closure", closure, (GDestroyNotify)closure_destroy); return closure; }
static WebdavBackendSearchClosure * init_closure (EDataBookView *book_view, EBookBackendWebdav *webdav) { WebdavBackendSearchClosure *closure = g_new (WebdavBackendSearchClosure, 1); closure->webdav = webdav; closure->thread = NULL; closure->running = e_flag_new (); g_object_set_data_full ( G_OBJECT (book_view), WEBDAV_CLOSURE_NAME, closure, (GDestroyNotify) closure_destroy); return closure; }
static void emss_sync_op (EMSyncStream *emss, enum _write_msg_t op, const gchar *string, gsize len) { struct _write_msg msg; msg.done = e_flag_new (); msg.emss = emss; msg.op = op; msg.string = string; msg.len = len; camel_object_ref (emss); g_idle_add ((GSourceFunc) emss_process_message, &msg); e_flag_wait (msg.done); e_flag_free (msg.done); camel_object_unref (emss); }
static void set_attachments (ECalClient *client, ECalComponent *comp, CamelMimeMessage *message) { /* XXX Much of this is copied from CompEditor::get_attachment_list(). * Perhaps it should be split off as a separate utility? */ EAttachmentStore *store; CamelDataWrapper *content; CamelMultipart *multipart; GFile *destination; GList *attachment_list = NULL; GSList *uri_list = NULL; const gchar *comp_uid = NULL; const gchar *local_store; gchar *filename_prefix, *tmp; gint ii, n_parts; struct _att_async_cb_data cb_data; cb_data.flag = e_flag_new (); cb_data.uris = NULL; content = camel_medium_get_content ((CamelMedium *) message); if (!content || !CAMEL_IS_MULTIPART (content)) return; n_parts = camel_multipart_get_number (CAMEL_MULTIPART (content)); if (n_parts < 1) return; e_cal_component_get_uid (comp, &comp_uid); g_return_if_fail (comp_uid != NULL); tmp = g_strdup (comp_uid); e_filename_make_safe (tmp); filename_prefix = g_strconcat (tmp, "-", NULL); g_free (tmp); local_store = e_cal_client_get_local_attachment_store (client); destination = g_file_new_for_path (local_store); /* Create EAttachments from the MIME parts and add them to the * attachment store. */ multipart = CAMEL_MULTIPART (content); store = E_ATTACHMENT_STORE (e_attachment_store_new ()); for (ii = 1; ii < n_parts; ii++) { EAttachment *attachment; CamelMimePart *mime_part; attachment = e_attachment_new (); mime_part = camel_multipart_get_part (multipart, ii); e_attachment_set_mime_part (attachment, mime_part); attachment_list = g_list_append (attachment_list, attachment); } e_flag_clear (cb_data.flag); e_attachment_store_load_async ( store, attachment_list, (GAsyncReadyCallback) attachment_load_finished, &cb_data); /* Loading should be instantaneous since we already have * the full content, but we need to wait for the callback. */ e_flag_wait (cb_data.flag); g_list_foreach (attachment_list, (GFunc) g_object_unref, NULL); g_list_free (attachment_list); cb_data.uris = NULL; e_flag_clear (cb_data.flag); e_attachment_store_save_async ( store, destination, filename_prefix, (GAsyncReadyCallback) attachment_save_finished, &cb_data); g_free (filename_prefix); /* We can't return until we have results. */ e_flag_wait (cb_data.flag); if (cb_data.uris == NULL) { e_flag_free (cb_data.flag); g_warning ("No attachment URIs retrieved."); return; } /* Transfer the URI strings to the GSList. */ for (ii = 0; cb_data.uris[ii] != NULL; ii++) { uri_list = g_slist_prepend (uri_list, cb_data.uris[ii]); cb_data.uris[ii] = NULL; } e_flag_free (cb_data.flag); g_free (cb_data.uris); /* XXX Does this take ownership of the list? */ e_cal_component_set_attachment_list (comp, uri_list); e_attachment_store_remove_all (store); g_object_unref (destination); g_object_unref (store); }