diff --git a/src/mu-cmd-server.c b/src/mu-cmd-server.c index c7638024..da5357ea 100644 --- a/src/mu-cmd-server.c +++ b/src/mu-cmd-server.c @@ -332,7 +332,8 @@ cmd_find (MuStore *store, MuQuery *query, GSList *lst, GError **err) char *sexp; sexp = mu_msg_to_sexp (msg, mu_msg_iter_get_docid (iter), - NULL, TRUE); + mu_msg_iter_get_thread_info (iter), + TRUE); send_expr ("%s", sexp); g_free (sexp); ++u; diff --git a/src/mu-container.c b/src/mu-container.c index df812f3e..325246c7 100644 --- a/src/mu-container.c +++ b/src/mu-container.c @@ -356,7 +356,6 @@ MuContainer* mu_container_sort (MuContainer *c, MuMsgFieldId mfid, gboolean revert, gpointer user_data) { - SortFuncData sfdata; sfdata.mfid = mfid; @@ -489,21 +488,37 @@ path_to_string (Path *p, const char* frmt) return str; } +static unsigned +count_colons (const char *str) +{ + unsigned num; + + num = 0; + while (str++ && *str) + if (*str == ':') + ++num; + + return num; +} + + static MuMsgIterThreadInfo* thread_info_new (gchar *threadpath, gboolean root, gboolean child, - gboolean empty_parent, gboolean is_dup) + gboolean empty_parent, gboolean has_child, gboolean is_dup) { MuMsgIterThreadInfo *ti; ti = g_slice_new (MuMsgIterThreadInfo); ti->threadpath = threadpath; + ti->level = count_colons (threadpath); /* hacky... */ ti->prop = 0; - ti->prop |= root ? MU_MSG_ITER_THREAD_PROP_ROOT : 0; + ti->prop |= root ? MU_MSG_ITER_THREAD_PROP_ROOT : 0; ti->prop |= child ? MU_MSG_ITER_THREAD_PROP_FIRST_CHILD : 0; ti->prop |= empty_parent ? MU_MSG_ITER_THREAD_PROP_EMPTY_PARENT : 0; - ti->prop |= is_dup ? MU_MSG_ITER_THREAD_PROP_DUP : 0; + ti->prop |= is_dup ? MU_MSG_ITER_THREAD_PROP_DUP : 0; + ti->prop |= has_child ? MU_MSG_ITER_THREAD_PROP_HAS_CHILD : 0; return ti; } @@ -529,14 +544,15 @@ static void add_to_thread_info_hash (GHashTable *thread_info_hash, MuContainer *c, char *threadpath) { - gboolean is_root, first_child, empty_parent, is_dup; + gboolean is_root, first_child, empty_parent, is_dup, has_child; /* 'root' means we're a child of the dummy root-container */ is_root = (c->parent == NULL); first_child = is_root ? FALSE : (c->parent->child == c); empty_parent = is_root ? FALSE : (!c->parent->msg); - is_dup = c->flags & MU_CONTAINER_FLAG_DUP; + is_dup = c->flags & MU_CONTAINER_FLAG_DUP; + has_child = c->child ? TRUE : FALSE; g_hash_table_insert (thread_info_hash, GUINT_TO_POINTER(c->docid), @@ -544,6 +560,7 @@ add_to_thread_info_hash (GHashTable *thread_info_hash, MuContainer *c, is_root, first_child, empty_parent, + has_child, is_dup)); } diff --git a/src/mu-msg-iter.h b/src/mu-msg-iter.h index c5cb7fa2..a06cdc9e 100644 --- a/src/mu-msg-iter.h +++ b/src/mu-msg-iter.h @@ -135,12 +135,16 @@ enum _MuMsgIterThreadProp { MU_MSG_ITER_THREAD_PROP_ROOT = 1 << 0, MU_MSG_ITER_THREAD_PROP_FIRST_CHILD = 1 << 1, MU_MSG_ITER_THREAD_PROP_EMPTY_PARENT = 1 << 2, - MU_MSG_ITER_THREAD_PROP_DUP = 1 << 3 + MU_MSG_ITER_THREAD_PROP_DUP = 1 << 3, + MU_MSG_ITER_THREAD_PROP_HAS_CHILD = 1 << 4 }; typedef guint8 MuMsgIterThreadProp; struct _MuMsgIterThreadInfo { - gchar *threadpath; + gchar *threadpath; /* a string decribing the thread-path in + * such a way that we can sort by this + * string to get the right order. */ + guint level; /* thread-depth -- [0...] */ MuMsgIterThreadProp prop; }; typedef struct _MuMsgIterThreadInfo MuMsgIterThreadInfo; diff --git a/src/mu-msg-sexp.c b/src/mu-msg-sexp.c index be1bf214..1f57f1b9 100644 --- a/src/mu-msg-sexp.c +++ b/src/mu-msg-sexp.c @@ -196,6 +196,7 @@ append_sexp_flags (GString *gstr, MuMsg *msg) g_free (fdata.flagstr); } + static void each_part (MuMsg *msg, MuMsgPart *part, gchar **parts) { @@ -206,12 +207,13 @@ each_part (MuMsg *msg, MuMsgPart *part, gchar **parts) char *esc; esc = mu_str_escape_c_literal (fname, TRUE); *parts = g_strdup_printf - ("%s(%d %s \"%s/%s\")", + ("%s(:index %d :name %s :mime-type \"%s/%s\" :size %d)", *parts ? *parts : "", part->index, esc, part->type ? part->type : "application", - part->subtype ? part->subtype : "octet-stream"); + part->subtype ? part->subtype : "octet-stream", + part->size); } } @@ -251,13 +253,26 @@ static void append_sexp_thread_info (GString *gstr, const MuMsgIterThreadInfo *ti) { g_string_append_printf - (gstr, "\t:thread (:path \"%s\" :root %s :first-child %s " - ":empty-parent %s :duplicate %s)\n", + (gstr, "\t:thread (:path \"%s\":level %u%s%s%s%s)\n", ti->threadpath, - ti->prop & MU_MSG_ITER_THREAD_PROP_ROOT ? "t" : "nil", - ti->prop & MU_MSG_ITER_THREAD_PROP_FIRST_CHILD ? "t" : "nil", - ti->prop & MU_MSG_ITER_THREAD_PROP_EMPTY_PARENT ? "t" : "nil", - ti->prop & MU_MSG_ITER_THREAD_PROP_DUP ? "t" : "nil"); + ti->level, + ti->prop & MU_MSG_ITER_THREAD_PROP_FIRST_CHILD ? + " :first-child t" : "", + ti->prop & MU_MSG_ITER_THREAD_PROP_EMPTY_PARENT ? + " :empty-parent t" : "", + ti->prop & MU_MSG_ITER_THREAD_PROP_DUP ? + " :duplicate t" : "", + ti->prop & MU_MSG_ITER_THREAD_PROP_HAS_CHILD ? + " :has-child t" : ""); + + /* g_string_append_printf */ + /* (gstr, "\t:thread (:path \"%s\" :level %u :root %s :first-child %s " */ + /* ":empty-parent %s :duplicate %s)\n", */ + /* ti->threadpath, ti->level, */ + /* ti->prop & MU_MSG_ITER_THREAD_PROP_ROOT ? "t" : "nil", */ + /* ti->prop & MU_MSG_ITER_THREAD_PROP_FIRST_CHILD ? "t" : "nil", */ + /* ti->prop & MU_MSG_ITER_THREAD_PROP_EMPTY_PARENT ? "t" : "nil", */ + /* ti->prop & MU_MSG_ITER_THREAD_PROP_DUP ? "t" : "nil"); */ }