/* NB: duplicated in maildir store */ static void fill_fi (CamelStore *store, CamelFolderInfo *fi, guint32 flags) { CamelFolder *folder; fi->unread = -1; fi->total = -1; folder = camel_object_bag_peek (store->folders, fi->full_name); if (folder) { if ((flags & CAMEL_STORE_FOLDER_INFO_FAST) == 0) camel_folder_refresh_info_sync (folder, NULL, NULL); fi->unread = camel_folder_get_unread_message_count (folder); fi->total = camel_folder_get_message_count (folder); g_object_unref (folder); } else { CamelLocalStore *local_store; gchar *folderpath; CamelMboxSummary *mbs; local_store = CAMEL_LOCAL_STORE (store); /* This should be fast enough not * to have to test for INFO_FAST. */ folderpath = camel_local_store_get_full_path ( local_store, fi->full_name); mbs = (CamelMboxSummary *) camel_mbox_summary_new ( NULL, folderpath, NULL); /* FIXME[disk-summary] track exception */ if (camel_folder_summary_header_load_from_db ((CamelFolderSummary *) mbs, store, fi->full_name, NULL)) { fi->unread = camel_folder_summary_get_unread_count ( (CamelFolderSummary *) mbs); fi->total = camel_folder_summary_get_saved_count ( (CamelFolderSummary *) mbs); } g_object_unref (mbs); g_free (folderpath); } if (camel_local_store_is_main_store (CAMEL_LOCAL_STORE (store)) && fi->full_name && (fi->flags & CAMEL_FOLDER_TYPE_MASK) == CAMEL_FOLDER_TYPE_NORMAL) fi->flags = (fi->flags & ~CAMEL_FOLDER_TYPE_MASK) | camel_local_store_get_folder_type_by_full_name ( CAMEL_LOCAL_STORE (store), fi->full_name); }
static CamelFolder * vee_store_get_folder_sync (CamelStore *store, const gchar *folder_name, CamelStoreGetFolderFlags flags, GCancellable *cancellable, GError **error) { CamelVeeFolder *vf; CamelFolder *folder; gchar *name, *p; gsize name_len; vf = (CamelVeeFolder *) camel_vee_folder_new (store, folder_name, flags); if (vf && ((vf->flags & CAMEL_STORE_FOLDER_PRIVATE) == 0)) { const gchar *full_name; full_name = camel_folder_get_full_name (CAMEL_FOLDER (vf)); /* Check that parents exist, if not, create dummy ones */ name_len = strlen (full_name) + 1; name = alloca (name_len); g_strlcpy (name, full_name, name_len); p = name; while ( (p = strchr (p, '/'))) { *p = 0; folder = camel_object_bag_reserve (store->folders, name); if (folder == NULL) { /* create a dummy vFolder for this, makes get_folder_info simpler */ folder = camel_vee_folder_new (store, name, flags); camel_object_bag_add (store->folders, name, folder); change_folder (store, name, CHANGE_ADD | CHANGE_NOSELECT, 0); /* FIXME: this sort of leaks folder, nobody owns a ref to it but us */ } else { g_object_unref (folder); } *p++='/'; } change_folder (store, full_name, CHANGE_ADD, camel_folder_get_message_count ((CamelFolder *) vf)); } return (CamelFolder *) vf; }
static struct _send_data * build_infra (EMailSession *session, gboolean allow_send) { struct _send_data *data; struct _send_info *info; CamelService *transport = NULL; GList *link; GList *list = NULL; GList *accounts=NULL; transport = ref_default_transport (session); accounts = mail_get_all_accounts(); data = setup_send_data (session); link = accounts; while (link) { ESource *source; CamelService *service; const gchar *uid; source = (ESource *)link->data; if (!e_source_get_enabled(source)) { link = link->next; continue; } uid = e_source_get_uid (source); service = camel_session_ref_service ( CAMEL_SESSION (session), uid); /* see if we have an outstanding download active */ info = g_hash_table_lookup (data->active, uid); if (info == NULL) { send_info_t type = SEND_INVALID; type = get_receive_type (service); if (type == SEND_INVALID || type == SEND_SEND) { link = link->next; continue; } info = g_malloc0 (sizeof (*info)); info->type = type; info->session = g_object_ref (session); d(printf("adding source %s\n", source->url)); info->service = g_object_ref (service); info->keep_on_server = mail_get_keep_on_server (service); info->cancellable = camel_operation_new (); info->state = allow_send ? SEND_ACTIVE : SEND_COMPLETE; info->timeout_id = g_timeout_add ( STATUS_TIMEOUT, operation_status_timeout, info); g_signal_connect ( info->cancellable, "status", G_CALLBACK (operation_status), info); g_hash_table_insert ( data->active, g_strdup(uid), info); list = g_list_prepend (list, info); } else if (info->timeout_id == 0) info->timeout_id = g_timeout_add ( STATUS_TIMEOUT, operation_status_timeout, info); info->data = data; link = link->next; } g_list_free_full (accounts, (GDestroyNotify) g_object_unref); /* Skip displaying the SMTP row if we've got no outbox, * outgoing account or unsent mails. */ CamelFolder *local_outbox; local_outbox = e_mail_session_get_local_folder ( session, E_MAIL_LOCAL_FOLDER_OUTBOX); if (allow_send && local_outbox && CAMEL_IS_TRANSPORT (transport) && (camel_folder_get_message_count (local_outbox) - camel_folder_get_deleted_message_count (local_outbox)) != 0) { info = g_hash_table_lookup (data->active, SEND_URI_KEY); if (info == NULL) { info = g_malloc0 (sizeof (*info)); info->type = SEND_SEND; info->service = g_object_ref (transport); info->keep_on_server = FALSE; info->cancellable = camel_operation_new (); info->state = SEND_ACTIVE; info->timeout_id = g_timeout_add ( STATUS_TIMEOUT, operation_status_timeout, info); g_signal_connect ( info->cancellable, "status", G_CALLBACK (operation_status), info); g_hash_table_insert (data->active, g_strdup(SEND_URI_KEY), info); list = g_list_prepend (list, info); } else if (info->timeout_id == 0) info->timeout_id = g_timeout_add ( STATUS_TIMEOUT, operation_status_timeout, info); info->data = data; } data->infos = list; return data; }