diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-10-24 22:08:27 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-10-27 21:25:01 +0800 |
commit | c58b70659747967568a536e217b9440424709f92 (patch) | |
tree | 1d730d70de24b72ca0b9d200ad25cf28da3cbd05 /mail | |
parent | 4bc632c800acd4d8228224bb628f2de38090f550 (diff) | |
download | gsoc2013-evolution-c58b70659747967568a536e217b9440424709f92.tar.gz gsoc2013-evolution-c58b70659747967568a536e217b9440424709f92.tar.zst gsoc2013-evolution-c58b70659747967568a536e217b9440424709f92.zip |
Prefer GQueue (or GNode) over EDList.
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-searching-tokenizer.c | 57 | ||||
-rw-r--r-- | mail/em-config.c | 1 | ||||
-rw-r--r-- | mail/em-event.c | 1 | ||||
-rw-r--r-- | mail/em-format-hook.h | 7 | ||||
-rw-r--r-- | mail/em-format-html-display.c | 1 | ||||
-rw-r--r-- | mail/em-format-html.c | 180 | ||||
-rw-r--r-- | mail/em-format-html.h | 16 | ||||
-rw-r--r-- | mail/em-subscribe-editor.c | 51 | ||||
-rw-r--r-- | mail/mail-folder-cache.c | 41 |
9 files changed, 191 insertions, 164 deletions
diff --git a/mail/e-searching-tokenizer.c b/mail/e-searching-tokenizer.c index b9a00cddf3..aac8a0a34f 100644 --- a/mail/e-searching-tokenizer.c +++ b/mail/e-searching-tokenizer.c @@ -34,7 +34,6 @@ #include "e-searching-tokenizer.h" #include "libedataserver/e-memory.h" -#include "libedataserver/e-msgport.h" #define d(x) @@ -353,8 +352,8 @@ struct _searcher { gint matchcount; - EDList input; /* pending 'input' tokens, processed but might match */ - EDList output; /* output tokens ready for source */ + GQueue input; /* pending 'input' tokens, processed but might match */ + GQueue output; /* output tokens ready for source */ struct _token *current; /* for token output memory management */ @@ -392,8 +391,8 @@ searcher_new (gint flags, gint argc, guchar **argv, const gchar *tags, const gch s->state = &s->t->root; s->matchcount = 0; - e_dlist_init(&s->input); - e_dlist_init(&s->output); + g_queue_init (&s->input); + g_queue_init (&s->output); s->current = NULL; s->offset = 0; @@ -420,9 +419,9 @@ searcher_free (struct _searcher *s) { struct _token *t; - while ((t = (struct _token *)e_dlist_remhead (&s->input))) + while ((t = g_queue_pop_head (&s->input)) != NULL) g_free (t); - while ((t = (struct _token *)e_dlist_remhead (&s->output))) + while ((t = g_queue_pop_head (&s->output)) != NULL) g_free (t); g_free (s->tags); g_free (s->tage); @@ -431,8 +430,9 @@ searcher_free (struct _searcher *s) free_trie (s->t); g_free (s); } + static struct _token * -append_token(EDList *list, const gchar *tok, gint len) +append_token (GQueue *queue, const gchar *tok, gint len) { struct _token *token; @@ -442,7 +442,7 @@ append_token(EDList *list, const gchar *tok, gint len) token->offset = 0; /* set by caller when required */ memcpy(token->tok, tok, len); token->tok[len] = 0; - e_dlist_addtail(list, (EDListNode *)token); + g_queue_push_tail (queue, token); return token; } @@ -458,7 +458,7 @@ output_token(struct _searcher *s, struct _token *token) if (token->tok[0] == TAG_ESCAPE) { if (token->offset >= s->offout) { d (printf("moving tag token '%s' from input to output\n", token->tok[0]==TAG_ESCAPE?token->tok+1:token->tok)); - e_dlist_addtail(&s->output, (EDListNode *)token); + g_queue_push_tail (&s->output, token); } else { d (printf("discarding tag token '%s' from input\n", token->tok[0]==TAG_ESCAPE?token->tok+1:token->tok)); free_token(token); @@ -472,7 +472,7 @@ output_token(struct _searcher *s, struct _token *token) memmove (token->tok, token->tok+pre, left+1); d (printf("adding partial remaining/failed '%s'\n", token->tok[0]==TAG_ESCAPE?token->tok+1:token->tok)); s->offout = offend; - e_dlist_addtail(&s->output, (EDListNode *)token); + g_queue_push_tail (&s->output, token); } else { d (printf("discarding whole token '%s'\n", token->tok[0]==TAG_ESCAPE?token->tok+1:token->tok)); free_token(token); @@ -483,14 +483,17 @@ output_token(struct _searcher *s, struct _token *token) static struct _token * find_token(struct _searcher *s, gint start) { - register struct _token *token; + GList *link; /* find token which is start token, from end of list back */ - token = (struct _token *)s->input.tailpred; - while (token->prev) { + link = g_queue_peek_tail_link (&s->input); + while (link != NULL) { + struct _token *token = link->data; + if (token->offset <= start) return token; - token = token->prev; + + link = g_list_previous (link); } return NULL; @@ -517,8 +520,8 @@ output_match(struct _searcher *s, guint start, guint end) d (printf("end in token '%s'\n", endtoken->tok[0]==TAG_ESCAPE?endtoken->tok+1:endtoken->tok)); /* output pending stuff that didn't match afterall */ - while ((struct _token *)s->input.head != starttoken) { - token = (struct _token *)e_dlist_remhead (&s->input); + while ((struct _token *) g_queue_peek_head (&s->input) != starttoken) { + token = g_queue_pop_head (&s->input); d (printf("appending failed match '%s'\n", token->tok[0]==TAG_ESCAPE?token->tok+1:token->tok)); output_token(s, token); } @@ -540,8 +543,8 @@ output_match(struct _searcher *s, guint start, guint end) /* output match node (s) */ if (starttoken != endtoken) { - while ((struct _token *)s->input.head != endtoken) { - token = (struct _token *)e_dlist_remhead (&s->input); + while ((struct _token *) g_queue_peek_head (&s->input) != endtoken) { + token = g_queue_pop_head (&s->input); d (printf("appending (partial) match node (head) '%s'\n", token->tok[0]==TAG_ESCAPE?token->tok+1:token->tok)); output_token(s, token); } @@ -622,7 +625,7 @@ output_pending (struct _searcher *s) { struct _token *token; - while ( (token = (struct _token *)e_dlist_remhead (&s->input)) ) + while ((token = g_queue_pop_head (&s->input)) != NULL) output_token(s, token); } @@ -645,8 +648,8 @@ flush_extra(struct _searcher *s) if (starttoken == NULL) return; - while ((struct _token *)s->input.head != starttoken) { - token = (struct _token *)e_dlist_remhead (&s->input); + while ((struct _token *) g_queue_peek_head (&s->input) != starttoken) { + token = g_queue_pop_head (&s->input); output_token(s, token); } } @@ -662,7 +665,7 @@ searcher_next_token(struct _searcher *s) gint offstart, offend; guint32 c; - while (e_dlist_empty(&s->output)) { + while (g_queue_is_empty (&s->output)) { /* get next token */ tok = (guchar *)s->next_token(s->next_data); if (tok == NULL) { @@ -724,7 +727,7 @@ searcher_next_token(struct _searcher *s) output_subpending (s); push_subpending (s, offstart, offend); /*output_match(s, offstart, offend);*/ - } else if (e_dlist_length(&s->input) > 8) { + } else if (g_queue_get_length (&s->input) > 8) { /* we're continuing to match and merge, but we have a lot of stuff waiting, so flush it out now since this is a safe point to do it */ output_subpending (s); @@ -749,7 +752,7 @@ searcher_next_token(struct _searcher *s) if (s->current) free_token(s->current); - s->current = token = (struct _token *)e_dlist_remhead (&s->output); + s->current = token = g_queue_pop_head (&s->output); return token ? g_strdup (token->tok) : NULL; } @@ -763,7 +766,7 @@ searcher_peek_token(struct _searcher *s) tok = searcher_next_token(s); if (tok) { /* need to clear this so we dont free it while its still active */ - e_dlist_addhead (&s->output, (EDListNode *)s->current); + g_queue_push_head (&s->output, s->current); s->current = NULL; } @@ -773,7 +776,7 @@ searcher_peek_token(struct _searcher *s) static gint searcher_pending (struct _searcher *s) { - return !(e_dlist_empty(&s->input) && e_dlist_empty(&s->output)); + return !(g_queue_is_empty (&s->input) && g_queue_is_empty (&s->output)); } /* ********************************************************************** */ diff --git a/mail/em-config.c b/mail/em-config.c index dcdf9b10ef..4b1e835627 100644 --- a/mail/em-config.c +++ b/mail/em-config.c @@ -30,7 +30,6 @@ #include <gtk/gtk.h> #include "em-config.h" -#include "libedataserver/e-msgport.h" #include "em-utils.h" #include "em-composer-utils.h" diff --git a/mail/em-event.c b/mail/em-event.c index de8f468fa9..4434e0a447 100644 --- a/mail/em-event.c +++ b/mail/em-event.c @@ -31,7 +31,6 @@ #include "em-event.h" #include "composer/e-msg-composer.h" -#include "libedataserver/e-msgport.h" #include <camel/camel-store.h> #include <camel/camel-folder.h> diff --git a/mail/em-format-hook.h b/mail/em-format-hook.h index e0560f4994..c03a826731 100644 --- a/mail/em-format-hook.h +++ b/mail/em-format-hook.h @@ -24,11 +24,8 @@ #ifndef __EM_FORMAT_HOOK_H__ #define __EM_FORMAT_HOOK_H__ -#include <glib-object.h> -#include "libedataserver/e-msgport.h" -#include "e-util/e-plugin.h" - -#include "em-format/em-format.h" +#include <e-util/e-plugin.h> +#include <em-format/em-format.h> G_BEGIN_DECLS diff --git a/mail/em-format-html-display.c b/mail/em-format-html-display.c index 620f56e85a..46241186aa 100644 --- a/mail/em-format-html-display.c +++ b/mail/em-format-html-display.c @@ -62,7 +62,6 @@ #include <e-util/e-util.h> #include <e-util/e-util-private.h> -#include <libedataserver/e-msgport.h> #include "e-util/e-datetime-format.h" #include <e-util/e-dialog-utils.h> #include <e-util/e-icon-factory.h> diff --git a/mail/em-format-html.c b/mail/em-format-html.c index 80fa6b6567..53d10e8f12 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -72,8 +72,6 @@ #include <camel/camel-data-cache.h> #include <camel/camel-file-utils.h> -#include <libedataserver/e-msgport.h> - #include "mail-config.h" #include "mail-mt.h" @@ -105,7 +103,7 @@ struct _EMFormatHTMLPrivate { /* Table that re-maps text parts into a mutlipart/mixed, EMFormatHTMLCache * */ GHashTable *text_inline_parts; - EDList pending_jobs; + GQueue pending_jobs; GMutex *lock; GdkColor colors[EM_FORMAT_HTML_NUM_COLOR_TYPES]; @@ -168,14 +166,17 @@ efh_format_desc (struct _format_msg *m) static void efh_format_exec (struct _format_msg *m) { + EMFormat *format; struct _EMFormatHTMLJob *job; - struct _EMFormatPURITree *puri_level; + GNode *puri_level; gint cancelled = FALSE; CamelURL *base; if (m->format->html == NULL) return; + format = EM_FORMAT (m->format); + camel_stream_printf ( (CamelStream *)m->estream, "<!doctype html public \"-//W3C//DTD HTML 4.0 TRANSITIONAL//EN\">\n<html>\n" @@ -190,28 +191,40 @@ efh_format_exec (struct _format_msg *m) /* <insert top-header stuff here> */ - if (((EMFormat *)m->format)->mode == EM_FORMAT_SOURCE) { - em_format_format_source((EMFormat *)m->format, (CamelStream *)m->estream, (CamelMimePart *)m->message); + if (format->mode == EM_FORMAT_SOURCE) { + em_format_format_source ( + format, (CamelStream *) m->estream, + (CamelMimePart *) m->message); } else { const EMFormatHandler *handle; + const gchar *mime_type; + + mime_type = "x-evolution/message/prefix"; + handle = em_format_find_handler (format, mime_type); + + if (handle != NULL) + handle->handler ( + format, (CamelStream *) m->estream, + (CamelMimePart *) m->message, handle); - handle = em_format_find_handler((EMFormat *)m->format, "x-evolution/message/prefix"); - if (handle) - handle->handler((EMFormat *)m->format, (CamelStream *)m->estream, (CamelMimePart *)m->message, handle); - handle = em_format_find_handler((EMFormat *)m->format, "x-evolution/message/rfc822"); - if (handle) - handle->handler((EMFormat *)m->format, (CamelStream *)m->estream, (CamelMimePart *)m->message, handle); + mime_type = "x-evolution/message/rfc822"; + handle = em_format_find_handler (format, mime_type); + + if (handle != NULL) + handle->handler ( + format, (CamelStream *) m->estream, + (CamelMimePart *) m->message, handle); } camel_stream_flush((CamelStream *)m->estream); - puri_level = ((EMFormat *)m->format)->pending_uri_level; - base = ((EMFormat *)m->format)->base; + puri_level = format->pending_uri_level; + base = format->base; do { /* now dispatch any added tasks ... */ g_mutex_lock(m->format->priv->lock); - while ((job = (struct _EMFormatHTMLJob *)e_dlist_remhead(&m->format->priv->pending_jobs))) { + while ((job = g_queue_pop_head (&m->format->priv->pending_jobs))) { g_mutex_unlock(m->format->priv->lock); /* This is an implicit check to see if the gtkhtml has been destroyed */ @@ -223,11 +236,11 @@ efh_format_exec (struct _format_msg *m) cancelled = camel_operation_cancel_check(NULL); /* call jobs even if cancelled, so they can clean up resources */ - ((EMFormat *)m->format)->pending_uri_level = job->puri_level; + format->pending_uri_level = job->puri_level; if (job->base) - ((EMFormat *)m->format)->base = job->base; - job->callback(job, cancelled); - ((EMFormat *)m->format)->base = base; + format->base = job->base; + job->callback (job, cancelled); + format->base = base; /* clean up the job */ camel_object_unref(job->stream); @@ -249,12 +262,11 @@ efh_format_exec (struct _format_msg *m) m->estream = NULL; } - /* e_dlist_empty is atomic and doesn't need locking */ - } while (!e_dlist_empty(&m->format->priv->pending_jobs)); + } while (!g_queue_is_empty (&m->format->priv->pending_jobs)); d(printf("out of jobs, done\n")); - ((EMFormat *)m->format)->pending_uri_level = puri_level; + format->pending_uri_level = puri_level; } static void @@ -312,7 +324,7 @@ efh_format_timeout(struct _format_msg *m) return TRUE; } - g_return_val_if_fail (e_dlist_empty(&p->pending_jobs), FALSE); + g_return_val_if_fail (g_queue_is_empty (&p->pending_jobs), FALSE); d(printf(" ready to go, firing off format thread\n")); @@ -879,8 +891,8 @@ efh_init (EMFormatHTML *efh, efh->priv = EM_FORMAT_HTML_GET_PRIVATE (efh); - e_dlist_init(&efh->pending_object_list); - e_dlist_init(&efh->priv->pending_jobs); + g_queue_init (&efh->pending_object_list); + g_queue_init (&efh->priv->pending_jobs); efh->priv->lock = g_mutex_new(); efh->priv->format_id = -1; efh->priv->text_inline_parts = g_hash_table_new_full ( @@ -1173,57 +1185,84 @@ em_format_html_add_pobject(EMFormatHTML *efh, gsize size, const gchar *classid, pobj->func = func; pobj->part = part; - e_dlist_addtail(&efh->pending_object_list, (EDListNode *)pobj); + g_queue_push_tail (&efh->pending_object_list, pobj); return pobj; } EMFormatHTMLPObject * -em_format_html_find_pobject(EMFormatHTML *emf, const gchar *classid) +em_format_html_find_pobject (EMFormatHTML *emf, + const gchar *classid) { - EMFormatHTMLPObject *pw; + GList *link; + + g_return_val_if_fail (EM_IS_FORMAT_HTML (emf), NULL); + g_return_val_if_fail (classid != NULL, NULL); + + link = g_queue_peek_head_link (&emf->pending_object_list); - pw = (EMFormatHTMLPObject *)emf->pending_object_list.head; - while (pw->next) { - if (!strcmp(pw->classid, classid)) + while (link != NULL) { + EMFormatHTMLPObject *pw = link->data; + + if (!strcmp (pw->classid, classid)) return pw; - pw = pw->next; + + link = g_list_next (link); } return NULL; } EMFormatHTMLPObject * -em_format_html_find_pobject_func(EMFormatHTML *emf, CamelMimePart *part, EMFormatHTMLPObjectFunc func) +em_format_html_find_pobject_func (EMFormatHTML *emf, + CamelMimePart *part, + EMFormatHTMLPObjectFunc func) { - EMFormatHTMLPObject *pw; + GList *link; + + g_return_val_if_fail (EM_IS_FORMAT_HTML (emf), NULL); + + link = g_queue_peek_head_link (&emf->pending_object_list); + + while (link != NULL) { + EMFormatHTMLPObject *pw = link->data; - pw = (EMFormatHTMLPObject *)emf->pending_object_list.head; - while (pw->next) { if (pw->func == func && pw->part == part) return pw; - pw = pw->next; + + link = g_list_next (link); } return NULL; } void -em_format_html_remove_pobject(EMFormatHTML *emf, EMFormatHTMLPObject *pobject) +em_format_html_remove_pobject (EMFormatHTML *emf, + EMFormatHTMLPObject *pobject) { - e_dlist_remove((EDListNode *)pobject); - if (pobject->free) - pobject->free(pobject); - g_free(pobject->classid); - g_free(pobject); + g_return_if_fail (EM_IS_FORMAT_HTML (emf)); + g_return_if_fail (pobject != NULL); + + g_queue_remove (&emf->pending_object_list, pobject); + + if (pobject->free != NULL) + pobject->free (pobject); + + g_free (pobject->classid); + g_free (pobject); } void -em_format_html_clear_pobject(EMFormatHTML *emf) +em_format_html_clear_pobject (EMFormatHTML *emf) { - d(printf("clearing pending objects\n")); - while (!e_dlist_empty(&emf->pending_object_list)) - em_format_html_remove_pobject(emf, (EMFormatHTMLPObject *)emf->pending_object_list.head); + g_return_if_fail (EM_IS_FORMAT_HTML (emf)); + + while (!g_queue_is_empty (&emf->pending_object_list)) { + EMFormatHTMLPObject *pobj; + + pobj = g_queue_pop_head (&emf->pending_object_list); + em_format_html_remove_pobject (emf, pobj); + } } struct _EMFormatHTMLJob * @@ -1245,7 +1284,7 @@ void em_format_html_job_queue(EMFormatHTML *emfh, struct _EMFormatHTMLJob *job) { g_mutex_lock(emfh->priv->lock); - e_dlist_addtail(&emfh->priv->pending_jobs, (EDListNode *)job); + g_queue_push_tail (&emfh->priv->pending_jobs, job); g_mutex_unlock(emfh->priv->lock); } @@ -1432,9 +1471,9 @@ efh_object_requested(GtkHTML *html, GtkHTMLEmbedded *eb, EMFormatHTML *efh) pobject = em_format_html_find_pobject(efh, eb->classid); if (pobject) { /* This stops recursion of the part */ - e_dlist_remove((EDListNode *)pobject); + g_queue_remove (&efh->pending_object_list, pobject); res = pobject->func(efh, eb, pobject); - e_dlist_addhead(&efh->pending_object_list, (EDListNode *)pobject); + g_queue_push_head (&efh->pending_object_list, pobject); } else { d(printf("HTML Includes reference to unknown object '%s'\n", eb->classid)); } @@ -1891,34 +1930,37 @@ emfh_write_related(EMFormat *emf, CamelStream *stream, EMFormatPURI *puri) static void emfh_multipart_related_check(struct _EMFormatHTMLJob *job, gint cancelled) { - struct _EMFormatPURITree *ptree; - EMFormatPURI *puri, *purin; + EMFormat *format; + GList *link; gchar *oldpartid; if (cancelled) return; + format = EM_FORMAT (job->format); + d(printf(" running multipart/related check task\n")); - oldpartid = g_strdup(((EMFormat *)job->format)->part_id->str); + oldpartid = g_strdup (format->part_id->str); + + link = g_queue_peek_head_link (job->puri_level->data); + + while (link->next != NULL) { + EMFormatPURI *puri = link->data; - ptree = job->puri_level; - puri = (EMFormatPURI *)ptree->uri_list.head; - purin = puri->next; - while (purin) { if (puri->use_count == 0) { d(printf("part '%s' '%s' used '%d'\n", puri->uri?puri->uri:"", puri->cid, puri->use_count)); if (puri->func == emfh_write_related) { - g_string_printf(((EMFormat *)job->format)->part_id, "%s", puri->part_id); - em_format_part((EMFormat *)job->format, (CamelStream *)job->stream, puri->part); + g_string_printf (format->part_id, "%s", puri->part_id); + em_format_part (format, (CamelStream *)job->stream, puri->part); } /* else it was probably added by a previous format this loop */ } - puri = purin; - purin = purin->next; + + link = g_list_next (link); } - g_string_printf(((EMFormat *)job->format)->part_id, "%s", oldpartid); - g_free(oldpartid); + g_string_printf (format->part_id, "%s", oldpartid); + g_free (oldpartid); } /* RFC 2387 */ @@ -2407,7 +2449,6 @@ static void efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part) { EMFormat *emf = (EMFormat *) efh; - EMFormatHeader *h; const gchar *charset; CamelContentType *ct; struct _camel_header_raw *header; @@ -2499,7 +2540,6 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part) camel_stream_printf (stream, "<tr><td><table border=0 cellpadding=\"0\">\n"); /* dump selected headers */ - h = (EMFormatHeader *)emf->header_list.head; if (emf->mode == EM_FORMAT_ALLHEADERS) { header = ((CamelMimePart *)part)->headers; while (header) { @@ -2507,8 +2547,13 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part) header = header->next; } } else { + GList *link; gint mailer_shown = FALSE; - while (h->next) { + + link = g_queue_peek_head_link (&emf->header_list); + + while (link != NULL) { + EMFormatHeader *h = link->data; gint mailer, face; header = ((CamelMimePart *)part)->headers; @@ -2565,7 +2610,8 @@ efh_format_headers(EMFormatHTML *efh, CamelStream *stream, CamelMedium *part) header = header->next; } - h = h->next; + + link = g_list_next (link); } } diff --git a/mail/em-format-html.h b/mail/em-format-html.h index 4f9c0b209b..a76ae9cfb7 100644 --- a/mail/em-format-html.h +++ b/mail/em-format-html.h @@ -92,8 +92,6 @@ typedef struct _EMFormatHTMLJob EMFormatHTMLJob; /** * struct _EMFormatHTMLJob - A formatting job. * - * @next: Double linked list header. - * @prev: Double linked list header. * @format: Set by allocation function. * @stream: Free for use by caller. * @puri_level: Set by allocation function. @@ -113,15 +111,12 @@ typedef struct _EMFormatHTMLJob EMFormatHTMLJob; * may be used to allocate these. **/ struct _EMFormatHTMLJob { - EMFormatHTMLJob *next; - EMFormatHTMLJob *prev; - EMFormatHTML *format; CamelStream *stream; /* We need to track the state of the visibility tree at the point this uri was generated */ - struct _EMFormatPURITree *puri_level; + GNode *puri_level; CamelURL *base; void (*callback)(EMFormatHTMLJob *job, gint cancelled); @@ -129,7 +124,7 @@ struct _EMFormatHTMLJob { gchar *uri; CamelMedium *msg; EMFormatPURI *puri; - struct _EMFormatPURITree *puri_level; + GNode *puri_level; gpointer data; } u; }; @@ -142,8 +137,6 @@ typedef gboolean (*EMFormatHTMLPObjectFunc)(EMFormatHTML *md, GtkHTMLEmbedded *e /** * struct _EMFormatHTMLPObject - Pending object. * - * @next: Double linked list header. - * @prev: Double linked list header. * @free: Invoked when the object is no longer needed. * @format: The parent formatter. * @classid: The assigned class id as passed to add_pobject(). @@ -158,9 +151,6 @@ typedef gboolean (*EMFormatHTMLPObjectFunc)(EMFormatHTML *md, GtkHTMLEmbedded *e * em_format_html_add_pobject() may be used to allocate these. **/ struct _EMFormatHTMLPObject { - EMFormatHTMLPObject *next; - EMFormatHTMLPObject *prev; - void (*free)(EMFormatHTMLPObject *); EMFormatHTML *format; @@ -211,7 +201,7 @@ struct _EMFormatHTML { GtkHTML *html; - EDList pending_object_list; + GQueue pending_object_list; GSList *headers; diff --git a/mail/em-subscribe-editor.c b/mail/em-subscribe-editor.c index e9c933de50..b6d7404795 100644 --- a/mail/em-subscribe-editor.c +++ b/mail/em-subscribe-editor.c @@ -33,7 +33,6 @@ #include "camel/camel-exception.h" #include "camel/camel-store.h" #include "camel/camel-session.h" -#include "libedataserver/e-msgport.h" #include "e-util/e-account-utils.h" #include "e-util/e-util-private.h" @@ -49,7 +48,7 @@ typedef struct _EMSubscribeEditor EMSubscribeEditor; struct _EMSubscribeEditor { - EDList stores; + GQueue stores; gint busy; guint busy_id; @@ -65,9 +64,6 @@ struct _EMSubscribeEditor { typedef struct _EMSubscribe EMSubscribe; struct _EMSubscribe { - struct _EMSubscribe *next; - struct _EMSubscribe *prev; - gint ref_count; gint cancel; gint seq; /* upped every time we refresh */ @@ -88,11 +84,11 @@ struct _EMSubscribe { /* pending LISTs, EMSubscribeNode's */ gint pending_id; - EDList pending; + GQueue pending; /* queue of pending UN/SUBSCRIBEs, EMsg's */ gint subscribe_id; - EDList subscribe; + GQueue subscribe; /* working variables at runtime */ gint selected_count; @@ -102,16 +98,12 @@ struct _EMSubscribe { typedef struct _EMSubscribeNode EMSubscribeNode; struct _EMSubscribeNode { - struct _EMSubscribeNode *next; - struct _EMSubscribeNode *prev; - CamelFolderInfo *info; GtkTreePath *path; }; typedef struct _MailMsgListNode MailMsgListNode; struct _MailMsgListNode { - EDListNode node; MailMsg *msg; }; @@ -215,7 +207,7 @@ sub_folder_done (struct _zsubscribe_msg *m) } /* queue any further ones, or if out, update the ui */ - msgListNode = (MailMsgListNode *) e_dlist_remhead(&m->sub->subscribe); + msgListNode = g_queue_pop_head (&m->sub->subscribe); if (msgListNode) { next = (struct _zsubscribe_msg *) msgListNode->msg; /* Free the memory of the MailMsgListNode which won't be used anymore. */ @@ -267,7 +259,7 @@ sub_subscribe_folder (EMSubscribe *sub, EMSubscribeNode *node, gint state, const msgListNode = g_malloc0(sizeof(MailMsgListNode)); msgListNode->msg = (MailMsg *) m; d(printf("queueing subscribe folder '%s'\n", spath)); - e_dlist_addtail(&sub->subscribe, (EDListNode *)msgListNode); + g_queue_push_tail (&sub->subscribe, msgListNode); } return id; @@ -325,7 +317,7 @@ sub_fill_level(EMSubscribe *sub, CamelFolderInfo *info, GtkTreeIter *parent, gi } else { if (pending) - e_dlist_addtail(&sub->pending, (EDListNode *)node); + g_queue_push_tail (&sub->pending, node); } } else { d(printf("%s:%s: fi->flags & CAMEL_FOLDER_NOINFERIORS=%d\t node->path=[%p]\n", @@ -388,7 +380,7 @@ sub_folderinfo_done (struct _emse_folderinfo_msg *m) } /* check for more to do */ - node = (EMSubscribeNode *)e_dlist_remhead(&m->sub->pending); + node = g_queue_pop_head (&m->sub->pending); if (node) sub_queue_fill_level(m->sub, node); } @@ -548,10 +540,10 @@ sub_row_expanded(GtkTreeView *tree, GtkTreeIter *iter, GtkTreePath *path, EMSubs } } - e_dlist_addhead(&sub->pending, (EDListNode *)node); + g_queue_push_head (&sub->pending, node); if (sub->pending_id == -1 - && (node = (EMSubscribeNode *)e_dlist_remtail(&sub->pending))) + && (node = g_queue_pop_tail (&sub->pending)) != NULL) sub_queue_fill_level(sub, node); } @@ -570,7 +562,7 @@ sub_destroy(GtkWidget *w, EMSubscribe *sub) if (sub->subscribe_id != -1) mail_msg_cancel(sub->subscribe_id); - while ( (msgListNode = (MailMsgListNode *)e_dlist_remhead(&sub->subscribe))) { + while ((msgListNode = g_queue_pop_head (&sub->subscribe)) != NULL) { m = (struct _zsubscribe_msg *) msgListNode->msg; /* Free the memory of MailMsgListNode which won't be used anymore. */ g_free(msgListNode); @@ -590,9 +582,9 @@ subscribe_new(EMSubscribeEditor *se, const gchar *uri) sub->editor = se; sub->ref_count = 1; sub->pending_id = -1; - e_dlist_init(&sub->pending); + g_queue_init (&sub->pending); sub->subscribe_id = -1; - e_dlist_init(&sub->subscribe); + g_queue_init (&sub->subscribe); sub->store_id = -1; return sub; @@ -696,7 +688,7 @@ sub_editor_refresh(GtkWidget *w, EMSubscribeEditor *se) gtk_tree_store_clear((GtkTreeStore *)gtk_tree_view_get_model(sub->tree)); - e_dlist_init(&sub->pending); + g_queue_init (&sub->pending); if (sub->folders) g_hash_table_destroy(sub->folders); @@ -732,7 +724,7 @@ static void sub_editor_combobox_changed (GtkWidget *w, EMSubscribeEditor *se) { gint i, n; - struct _EMSubscribe *sub; + GList *link; d(printf("combobox changed\n")); @@ -757,8 +749,10 @@ sub_editor_combobox_changed (GtkWidget *w, EMSubscribeEditor *se) } se->current = NULL; - sub = (struct _EMSubscribe *)se->stores.head; - while (sub->next) { + link = g_queue_peek_head_link (&se->stores); + while (link != NULL) { + struct _EMSubscribe *sub = link->data; + if (i == n) { se->current = sub; if (sub->widget) { @@ -772,7 +766,8 @@ sub_editor_combobox_changed (GtkWidget *w, EMSubscribeEditor *se) gtk_widget_hide(sub->widget); } i++; - sub = sub->next; + + link = g_list_next (link); } } @@ -833,7 +828,7 @@ em_subscribe_editor_new(void) gchar *gladefile; se = g_malloc0(sizeof(*se)); - e_dlist_init(&se->stores); + g_queue_init (&se->stores); gladefile = g_build_filename (EVOLUTION_GLADEDIR, "mail-dialogs.glade", @@ -910,7 +905,9 @@ em_subscribe_editor_new(void) 0, account->name, 1, TRUE, -1); - e_dlist_addtail(&se->stores, (EDListNode *)subscribe_new(se, account->source->url)); + g_queue_push_tail ( + &se->stores, subscribe_new ( + se, account->source->url)); } else { d(printf("not adding account '%s'\n", account->name)); } diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c index e7144df0f9..e9ffc5196e 100644 --- a/mail/mail-folder-cache.c +++ b/mail/mail-folder-cache.c @@ -45,7 +45,6 @@ #include <camel/camel-disco-store.h> #include <libedataserver/e-data-server-util.h> -#include <libedataserver/e-msgport.h> #include "e-util/e-util.h" #include "shell/e-shell.h" @@ -89,9 +88,6 @@ struct _folder_info { /* pending list of updates */ struct _folder_update { - struct _folder_update *next; - struct _folder_update *prev; - guint remove:1; /* removing from vfolders */ guint delete:1; /* deleting as well? */ guint add:1; /* add to vfolder */ @@ -114,7 +110,7 @@ struct _store_info { CamelStore *store; /* the store for these folders */ /* Outstanding folderinfo requests */ - EDList folderinfo_updates; + GQueue folderinfo_updates; }; static void folder_changed(CamelObject *o, gpointer event_data, gpointer user_data); @@ -128,7 +124,7 @@ static gboolean ping_cb (gpointer user_data); static GHashTable *stores = NULL; /* List of folder changes to be executed in gui thread */ -static EDList updates = E_DLIST_INITIALISER(updates); +static GQueue updates = G_QUEUE_INIT; static gint update_id = -1; /* hack for people who LIKE to have unsent count */ @@ -158,7 +154,7 @@ real_flush_updates (void) default_model = em_folder_tree_model_get_default (); G_LOCK (stores); - while ((up = (struct _folder_update *)e_dlist_remhead(&updates))) { + while ((up = g_queue_pop_head (&updates)) != NULL) { G_UNLOCK (stores); if (up->remove) { @@ -235,7 +231,7 @@ real_flush_updates (void) static void flush_updates (void) { - if (update_id == -1 && !e_dlist_empty(&updates)) + if (update_id == -1 && !g_queue_is_empty (&updates)) update_id = mail_async_event_emit ( mail_async_event, MAIL_ASYNC_GUI, (MailAsyncFunc) real_flush_updates, @@ -268,7 +264,7 @@ unset_folder_info(struct _folder_info *mfi, gint delete, gint unsub) camel_object_ref(up->store); up->uri = g_strdup(mfi->uri); - e_dlist_addtail(&updates, (EDListNode *)up); + g_queue_push_head (&updates, up); flush_updates(); } } @@ -355,7 +351,7 @@ update_1folder(struct _folder_info *mfi, gint new, CamelFolderInfo *info) up->store = mfi->store_info->store; up->uri = g_strdup(mfi->uri); camel_object_ref(up->store); - e_dlist_addtail(&updates, (EDListNode *)up); + g_queue_push_head (&updates, up); flush_updates(); } @@ -389,7 +385,7 @@ setup_folder(CamelFolderInfo *fi, struct _store_info *si) if ((fi->flags & CAMEL_FOLDER_NOSELECT) == 0) up->add = TRUE; - e_dlist_addtail(&updates, (EDListNode *)up); + g_queue_push_head (&updates, up); flush_updates(); } } @@ -669,7 +665,7 @@ rename_folders(struct _store_info *si, const gchar *oldbase, const gchar *newbas if ((fi->flags & CAMEL_FOLDER_NOSELECT) == 0) up->add = TRUE; - e_dlist_addtail(&updates, (EDListNode *)up); + g_queue_push_tail (&updates, up); flush_updates(); #if 0 if (fi->sibling) @@ -755,9 +751,6 @@ store_folder_renamed(CamelObject *o, gpointer event_data, gpointer data) } struct _update_data { - struct _update_data *next; - struct _update_data *prev; - gint id; /* id for cancellation */ guint cancel:1; /* also tells us we're cancelled */ @@ -780,7 +773,6 @@ free_folder_info_hash(gchar *path, struct _folder_info *mfi, gpointer data) void mail_note_store_remove(CamelStore *store) { - struct _update_data *ud; struct _store_info *si; g_return_if_fail (CAMEL_IS_STORE(store)); @@ -792,6 +784,7 @@ mail_note_store_remove(CamelStore *store) G_LOCK (stores); si = g_hash_table_lookup(stores, store); if (si) { + GList *link; g_hash_table_remove(stores, store); camel_object_unhook_event(store, "folder_opened", store_folder_opened, NULL); @@ -802,12 +795,16 @@ mail_note_store_remove(CamelStore *store) camel_object_unhook_event(store, "folder_unsubscribed", store_folder_unsubscribed, NULL); g_hash_table_foreach(si->folders, (GHFunc)unset_folder_info_hash, NULL); - ud = (struct _update_data *)si->folderinfo_updates.head; - while (ud->next) { + link = g_queue_peek_head_link (&si->folderinfo_updates); + + while (link != NULL) { + struct _update_data *ud = link->data; + d(printf("Cancelling outstanding folderinfo update %d\n", ud->id)); mail_msg_cancel(ud->id); ud->cancel = 1; - ud = ud->next; + + link = g_list_next (link); } camel_object_unref(si->store); @@ -834,7 +831,7 @@ update_folders(CamelStore *store, CamelFolderInfo *fi, gpointer data) if (si && !ud->cancel) { /* the 'si' is still there, so we can remove ourselves from its list */ /* otherwise its not, and we're on our own and free anyway */ - e_dlist_remove((EDListNode *)ud); + g_queue_remove (&si->folderinfo_updates, ud); if (fi) create_folders(fi, si); @@ -979,7 +976,7 @@ mail_note_store(CamelStore *store, CamelOperation *op, si->store = store; camel_object_ref((CamelObject *)store); g_hash_table_insert(stores, store, si); - e_dlist_init(&si->folderinfo_updates); + g_queue_init (&si->folderinfo_updates); hook = TRUE; } @@ -1010,7 +1007,7 @@ mail_note_store(CamelStore *store, CamelOperation *op, ud->id = mail_get_folderinfo (store, op, update_folders, ud); } - e_dlist_addtail (&si->folderinfo_updates, (EDListNode *) ud); + g_queue_push_tail (&si->folderinfo_updates, ud); G_UNLOCK (stores); |