* improve thread information, allow for better display in mm
This commit is contained in:
@ -332,7 +332,8 @@ cmd_find (MuStore *store, MuQuery *query, GSList *lst, GError **err)
|
|||||||
char *sexp;
|
char *sexp;
|
||||||
sexp = mu_msg_to_sexp (msg,
|
sexp = mu_msg_to_sexp (msg,
|
||||||
mu_msg_iter_get_docid (iter),
|
mu_msg_iter_get_docid (iter),
|
||||||
NULL, TRUE);
|
mu_msg_iter_get_thread_info (iter),
|
||||||
|
TRUE);
|
||||||
send_expr ("%s", sexp);
|
send_expr ("%s", sexp);
|
||||||
g_free (sexp);
|
g_free (sexp);
|
||||||
++u;
|
++u;
|
||||||
|
|||||||
@ -356,7 +356,6 @@ MuContainer*
|
|||||||
mu_container_sort (MuContainer *c, MuMsgFieldId mfid, gboolean revert,
|
mu_container_sort (MuContainer *c, MuMsgFieldId mfid, gboolean revert,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
|
||||||
SortFuncData sfdata;
|
SortFuncData sfdata;
|
||||||
|
|
||||||
sfdata.mfid = mfid;
|
sfdata.mfid = mfid;
|
||||||
@ -489,21 +488,37 @@ path_to_string (Path *p, const char* frmt)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned
|
||||||
|
count_colons (const char *str)
|
||||||
|
{
|
||||||
|
unsigned num;
|
||||||
|
|
||||||
|
num = 0;
|
||||||
|
while (str++ && *str)
|
||||||
|
if (*str == ':')
|
||||||
|
++num;
|
||||||
|
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static MuMsgIterThreadInfo*
|
static MuMsgIterThreadInfo*
|
||||||
thread_info_new (gchar *threadpath, gboolean root, gboolean child,
|
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;
|
MuMsgIterThreadInfo *ti;
|
||||||
|
|
||||||
ti = g_slice_new (MuMsgIterThreadInfo);
|
ti = g_slice_new (MuMsgIterThreadInfo);
|
||||||
ti->threadpath = threadpath;
|
ti->threadpath = threadpath;
|
||||||
|
ti->level = count_colons (threadpath); /* hacky... */
|
||||||
|
|
||||||
ti->prop = 0;
|
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 |= child ? MU_MSG_ITER_THREAD_PROP_FIRST_CHILD : 0;
|
||||||
ti->prop |= empty_parent ? MU_MSG_ITER_THREAD_PROP_EMPTY_PARENT : 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;
|
return ti;
|
||||||
}
|
}
|
||||||
@ -529,14 +544,15 @@ static void
|
|||||||
add_to_thread_info_hash (GHashTable *thread_info_hash, MuContainer *c,
|
add_to_thread_info_hash (GHashTable *thread_info_hash, MuContainer *c,
|
||||||
char *threadpath)
|
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 */
|
/* 'root' means we're a child of the dummy root-container */
|
||||||
is_root = (c->parent == NULL);
|
is_root = (c->parent == NULL);
|
||||||
|
|
||||||
first_child = is_root ? FALSE : (c->parent->child == c);
|
first_child = is_root ? FALSE : (c->parent->child == c);
|
||||||
empty_parent = is_root ? FALSE : (!c->parent->msg);
|
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,
|
g_hash_table_insert (thread_info_hash,
|
||||||
GUINT_TO_POINTER(c->docid),
|
GUINT_TO_POINTER(c->docid),
|
||||||
@ -544,6 +560,7 @@ add_to_thread_info_hash (GHashTable *thread_info_hash, MuContainer *c,
|
|||||||
is_root,
|
is_root,
|
||||||
first_child,
|
first_child,
|
||||||
empty_parent,
|
empty_parent,
|
||||||
|
has_child,
|
||||||
is_dup));
|
is_dup));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -135,12 +135,16 @@ enum _MuMsgIterThreadProp {
|
|||||||
MU_MSG_ITER_THREAD_PROP_ROOT = 1 << 0,
|
MU_MSG_ITER_THREAD_PROP_ROOT = 1 << 0,
|
||||||
MU_MSG_ITER_THREAD_PROP_FIRST_CHILD = 1 << 1,
|
MU_MSG_ITER_THREAD_PROP_FIRST_CHILD = 1 << 1,
|
||||||
MU_MSG_ITER_THREAD_PROP_EMPTY_PARENT = 1 << 2,
|
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;
|
typedef guint8 MuMsgIterThreadProp;
|
||||||
|
|
||||||
struct _MuMsgIterThreadInfo {
|
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;
|
MuMsgIterThreadProp prop;
|
||||||
};
|
};
|
||||||
typedef struct _MuMsgIterThreadInfo MuMsgIterThreadInfo;
|
typedef struct _MuMsgIterThreadInfo MuMsgIterThreadInfo;
|
||||||
|
|||||||
@ -196,6 +196,7 @@ append_sexp_flags (GString *gstr, MuMsg *msg)
|
|||||||
g_free (fdata.flagstr);
|
g_free (fdata.flagstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
each_part (MuMsg *msg, MuMsgPart *part, gchar **parts)
|
each_part (MuMsg *msg, MuMsgPart *part, gchar **parts)
|
||||||
{
|
{
|
||||||
@ -206,12 +207,13 @@ each_part (MuMsg *msg, MuMsgPart *part, gchar **parts)
|
|||||||
char *esc;
|
char *esc;
|
||||||
esc = mu_str_escape_c_literal (fname, TRUE);
|
esc = mu_str_escape_c_literal (fname, TRUE);
|
||||||
*parts = g_strdup_printf
|
*parts = g_strdup_printf
|
||||||
("%s(%d %s \"%s/%s\")",
|
("%s(:index %d :name %s :mime-type \"%s/%s\" :size %d)",
|
||||||
*parts ? *parts : "",
|
*parts ? *parts : "",
|
||||||
part->index,
|
part->index,
|
||||||
esc,
|
esc,
|
||||||
part->type ? part->type : "application",
|
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)
|
append_sexp_thread_info (GString *gstr, const MuMsgIterThreadInfo *ti)
|
||||||
{
|
{
|
||||||
g_string_append_printf
|
g_string_append_printf
|
||||||
(gstr, "\t:thread (:path \"%s\" :root %s :first-child %s "
|
(gstr, "\t:thread (:path \"%s\":level %u%s%s%s%s)\n",
|
||||||
":empty-parent %s :duplicate %s)\n",
|
|
||||||
ti->threadpath,
|
ti->threadpath,
|
||||||
ti->prop & MU_MSG_ITER_THREAD_PROP_ROOT ? "t" : "nil",
|
ti->level,
|
||||||
ti->prop & MU_MSG_ITER_THREAD_PROP_FIRST_CHILD ? "t" : "nil",
|
ti->prop & MU_MSG_ITER_THREAD_PROP_FIRST_CHILD ?
|
||||||
ti->prop & MU_MSG_ITER_THREAD_PROP_EMPTY_PARENT ? "t" : "nil",
|
" :first-child t" : "",
|
||||||
ti->prop & MU_MSG_ITER_THREAD_PROP_DUP ? "t" : "nil");
|
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"); */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user