|
|
|
@ -34,7 +34,7 @@ typedef guint8 MuContainerFlag;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* MuContainer data structure, as seen in JWZs document:
|
|
|
|
* MuContainer data structure, as seen in JWZs document:
|
|
|
|
* http://www.jwz.org/doc/threading.html
|
|
|
|
* http://www.jwz.org/doc/threading.html
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
struct _MuContainer {
|
|
|
|
struct _MuContainer {
|
|
|
|
struct _MuContainer *parent, *child, *next;
|
|
|
|
struct _MuContainer *parent, *child, *next;
|
|
|
|
@ -48,11 +48,11 @@ typedef struct _MuContainer MuContainer;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* create a new Container object
|
|
|
|
* create a new Container object
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param msg a MuMsg, or NULL; when it's NULL, docid should be 0
|
|
|
|
* @param msg a MuMsg, or NULL; when it's NULL, docid should be 0
|
|
|
|
* @param docid a Xapian docid, or 0
|
|
|
|
* @param docid a Xapian docid, or 0
|
|
|
|
* @param msgid a message id, or NULL
|
|
|
|
* @param msgid a message id, or NULL
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return a new Container instance, or NULL in case of error; free
|
|
|
|
* @return a new Container instance, or NULL in case of error; free
|
|
|
|
* with mu_container_destroy
|
|
|
|
* with mu_container_destroy
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ -61,7 +61,7 @@ MuContainer* mu_container_new (MuMsg *msg, guint docid, const char* msgid);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* free a Container object
|
|
|
|
* free a Container object
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param c a Container object, or NULL
|
|
|
|
* @param c a Container object, or NULL
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void mu_container_destroy (MuContainer *c);
|
|
|
|
void mu_container_destroy (MuContainer *c);
|
|
|
|
@ -71,10 +71,10 @@ void mu_container_destroy (MuContainer *c);
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* append new child(ren) to this container; the child(ren) container's
|
|
|
|
* append new child(ren) to this container; the child(ren) container's
|
|
|
|
* parent pointer will point to this one
|
|
|
|
* parent pointer will point to this one
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param c a Container instance
|
|
|
|
* @param c a Container instance
|
|
|
|
* @param child a child
|
|
|
|
* @param child a child
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return the Container instance with a child added
|
|
|
|
* @return the Container instance with a child added
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
MuContainer* mu_container_append_children (MuContainer *c, MuContainer *child);
|
|
|
|
MuContainer* mu_container_append_children (MuContainer *c, MuContainer *child);
|
|
|
|
@ -82,20 +82,20 @@ MuContainer* mu_container_append_children (MuContainer *c, MuContainer *child);
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* append a new sibling to this (list of) containers; all the siblings
|
|
|
|
* append a new sibling to this (list of) containers; all the siblings
|
|
|
|
* will get the same parent that @c has
|
|
|
|
* will get the same parent that @c has
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param c a container instance
|
|
|
|
* @param c a container instance
|
|
|
|
* @param sibling a sibling
|
|
|
|
* @param sibling a sibling
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return the container (list) with the sibling(s) appended
|
|
|
|
* @return the container (list) with the sibling(s) appended
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
MuContainer* mu_container_append_siblings (MuContainer *c, MuContainer *sibling);
|
|
|
|
MuContainer* mu_container_append_siblings (MuContainer *c, MuContainer *sibling);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* remove a _single_ child container from a container
|
|
|
|
* remove a _single_ child container from a container
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param c a container instance
|
|
|
|
* @param c a container instance
|
|
|
|
* @param child the child container to remove
|
|
|
|
* @param child the child container to remove
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return the container with the child removed; if the container did
|
|
|
|
* @return the container with the child removed; if the container did
|
|
|
|
* have this child, nothing changes
|
|
|
|
* have this child, nothing changes
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ -103,10 +103,10 @@ MuContainer* mu_container_remove_child (MuContainer *c, MuContainer *child);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* remove a _single_ sibling container from a container
|
|
|
|
* remove a _single_ sibling container from a container
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param c a container instance
|
|
|
|
* @param c a container instance
|
|
|
|
* @param sibling the sibling container to remove
|
|
|
|
* @param sibling the sibling container to remove
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return the container with the sibling removed; if the container did
|
|
|
|
* @return the container with the sibling removed; if the container did
|
|
|
|
* have this sibling, nothing changes
|
|
|
|
* have this sibling, nothing changes
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ -115,10 +115,10 @@ MuContainer* mu_container_remove_sibling (MuContainer *c, MuContainer *sibling);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* promote child's children to be parent's children and remove child
|
|
|
|
* promote child's children to be parent's children and remove child
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param parent a container instance
|
|
|
|
* @param parent a container instance
|
|
|
|
* @param child a child of this container
|
|
|
|
* @param child a child of this container
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return the new container with it's children's children promoted
|
|
|
|
* @return the new container with it's children's children promoted
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
MuContainer* mu_container_splice_children (MuContainer *parent,
|
|
|
|
MuContainer* mu_container_splice_children (MuContainer *parent,
|
|
|
|
@ -130,12 +130,12 @@ typedef gboolean (*MuContainerForeachFunc) (MuContainer*, gpointer);
|
|
|
|
* execute some function on all siblings an children of some container
|
|
|
|
* execute some function on all siblings an children of some container
|
|
|
|
* (recursively) until all children have been visited or the callback
|
|
|
|
* (recursively) until all children have been visited or the callback
|
|
|
|
* function returns FALSE
|
|
|
|
* function returns FALSE
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param c a container
|
|
|
|
* @param c a container
|
|
|
|
* @param func a function to call for each container
|
|
|
|
* @param func a function to call for each container
|
|
|
|
* @param user_data a pointer to pass to the callback function
|
|
|
|
* @param user_data a pointer to pass to the callback function
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
gboolean mu_container_foreach (MuContainer *c,
|
|
|
|
gboolean mu_container_foreach (MuContainer *c,
|
|
|
|
MuContainerForeachFunc func,
|
|
|
|
MuContainerForeachFunc func,
|
|
|
|
@ -144,10 +144,10 @@ gboolean mu_container_foreach (MuContainer *c,
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* check wither container needle is a child or sibling (recursively)
|
|
|
|
* check wither container needle is a child or sibling (recursively)
|
|
|
|
* of container haystack
|
|
|
|
* of container haystack
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param haystack a container
|
|
|
|
* @param haystack a container
|
|
|
|
* @param needle a container
|
|
|
|
* @param needle a container
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return TRUE if needle is reachable from haystack, FALSE otherwise
|
|
|
|
* @return TRUE if needle is reachable from haystack, FALSE otherwise
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
gboolean mu_container_reachable (MuContainer *haystack, MuContainer *needle);
|
|
|
|
gboolean mu_container_reachable (MuContainer *haystack, MuContainer *needle);
|
|
|
|
@ -155,8 +155,8 @@ gboolean mu_container_reachable (MuContainer *haystack, MuContainer *needle);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* dump the container to stdout (for debugging)
|
|
|
|
* dump the container to stdout (for debugging)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param c a container
|
|
|
|
* @param c a container
|
|
|
|
* @param recursive whether to include siblings, children
|
|
|
|
* @param recursive whether to include siblings, children
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void mu_container_dump (MuContainer *c, gboolean recursive);
|
|
|
|
void mu_container_dump (MuContainer *c, gboolean recursive);
|
|
|
|
@ -169,26 +169,26 @@ typedef int (*MuContainerCmpFunc) (MuContainer *c1, MuContainer *c2,
|
|
|
|
* sort the tree of MuContainers, recursively; ie. each of the list of
|
|
|
|
* sort the tree of MuContainers, recursively; ie. each of the list of
|
|
|
|
* siblings (children) will be sorted according to @func; if the
|
|
|
|
* siblings (children) will be sorted according to @func; if the
|
|
|
|
* container is empty, the first non-empty 'leftmost' child is used.
|
|
|
|
* container is empty, the first non-empty 'leftmost' child is used.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param c a container
|
|
|
|
* @param c a container
|
|
|
|
* @param mfid the field to sort by
|
|
|
|
* @param mfid the field to sort by
|
|
|
|
|
|
|
|
* @param revert if TRUE, revert the sorting order *
|
|
|
|
* @param user_data a user pointer to pass to the sorting function
|
|
|
|
* @param user_data a user pointer to pass to the sorting function
|
|
|
|
* @param invert if TRUE, invert the sorting order
|
|
|
|
*
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return a sorted container
|
|
|
|
* @return a sorted container
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
MuContainer* mu_container_sort (MuContainer *c, MuMsgFieldId mfid,
|
|
|
|
MuContainer* mu_container_sort (MuContainer *c, MuMsgFieldId mfid, gboolean revert,
|
|
|
|
gpointer user_data, gboolean invert);
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* create a hashtable with maps document-ids to information about them,
|
|
|
|
* create a hashtable with maps document-ids to information about them,
|
|
|
|
* ie. Xapian docid => MuMsgIterThreadInfo
|
|
|
|
* ie. Xapian docid => MuMsgIterThreadInfo
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param root_set the containers @param matchnum the number of
|
|
|
|
* @param root_set the containers @param matchnum the number of
|
|
|
|
* matches in the list (this is needed to determine the shortest
|
|
|
|
* matches in the list (this is needed to determine the shortest
|
|
|
|
* possible collation keys ('threadpaths') for the messages
|
|
|
|
* possible collation keys ('threadpaths') for the messages
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return a hash; free with g_hash_table_destroy
|
|
|
|
* @return a hash; free with g_hash_table_destroy
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
GHashTable* mu_container_thread_info_hash_new (MuContainer *root_set,
|
|
|
|
GHashTable* mu_container_thread_info_hash_new (MuContainer *root_set,
|
|
|
|
|