mirror of https://github.com/djcb/mu.git
* minor / cosmetic changes
This commit is contained in:
parent
1a7414dd6d
commit
628d154a2c
|
@ -272,7 +272,7 @@ AS_IF([test "x$PMCCABE" = "xno"],[
|
||||||
*** Please install it if you want to run the automated code checks])
|
*** Please install it if you want to run the automated code checks])
|
||||||
],[have_pmccabe="yes"])
|
],[have_pmccabe="yes"])
|
||||||
|
|
||||||
#toys/procmule/Makefile
|
|
||||||
|
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
Makefile
|
Makefile
|
||||||
|
@ -284,6 +284,7 @@ toys/Makefile
|
||||||
toys/mug/Makefile
|
toys/mug/Makefile
|
||||||
toys/mug2/Makefile
|
toys/mug2/Makefile
|
||||||
toys/muile/Makefile
|
toys/muile/Makefile
|
||||||
|
toys/procmule/Makefile
|
||||||
man/Makefile
|
man/Makefile
|
||||||
m4/Makefile
|
m4/Makefile
|
||||||
contrib/Makefile
|
contrib/Makefile
|
||||||
|
|
|
@ -42,9 +42,7 @@ get_query (void)
|
||||||
|
|
||||||
if (!query) {
|
if (!query) {
|
||||||
mu_guile_g_error ("<internal error>", err);
|
mu_guile_g_error ("<internal error>", err);
|
||||||
if (err)
|
g_clear_error (&err);
|
||||||
g_error_free (err);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
|
@ -60,10 +58,9 @@ get_query_iter (MuQuery *query, const char* expr)
|
||||||
err = NULL;
|
err = NULL;
|
||||||
iter = mu_query_run (query, expr,
|
iter = mu_query_run (query, expr,
|
||||||
FALSE, MU_MSG_FIELD_ID_NONE, TRUE, &err);
|
FALSE, MU_MSG_FIELD_ID_NONE, TRUE, &err);
|
||||||
if (err) {
|
if (!iter) {
|
||||||
mu_guile_g_error ("<internal error>", err);
|
mu_guile_g_error ("<internal error>", err);
|
||||||
g_error_free (err);
|
g_clear_error (&err);
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return iter;
|
return iter;
|
||||||
|
@ -80,6 +77,7 @@ call_func (SCM FUNC, MuMsgIter *iter, const char* func_name)
|
||||||
|
|
||||||
msgsmob = mu_guile_msg_to_scm (mu_msg_ref(msg));
|
msgsmob = mu_guile_msg_to_scm (mu_msg_ref(msg));
|
||||||
scm_call_1 (FUNC, msgsmob);
|
scm_call_1 (FUNC, msgsmob);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ enum _MuConfigFormat {
|
||||||
/* for find */
|
/* for find */
|
||||||
MU_CONFIG_FORMAT_LINKS, /* output as symlinks */
|
MU_CONFIG_FORMAT_LINKS, /* output as symlinks */
|
||||||
MU_CONFIG_FORMAT_XML, /* output xml */
|
MU_CONFIG_FORMAT_XML, /* output xml */
|
||||||
MU_CONFIG_FORMAT_XQUERY, /* output the xapian query */
|
MU_CONFIG_FORMAT_XQUERY /* output the xapian query */
|
||||||
};
|
};
|
||||||
typedef enum _MuConfigFormat MuConfigFormat;
|
typedef enum _MuConfigFormat MuConfigFormat;
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ enum _MuConfigCmd {
|
||||||
MU_CONFIG_CMD_REMOVE,
|
MU_CONFIG_CMD_REMOVE,
|
||||||
MU_CONFIG_CMD_SERVER,
|
MU_CONFIG_CMD_SERVER,
|
||||||
|
|
||||||
MU_CONFIG_CMD_NONE,
|
MU_CONFIG_CMD_NONE
|
||||||
};
|
};
|
||||||
typedef enum _MuConfigCmd MuConfigCmd;
|
typedef enum _MuConfigCmd MuConfigCmd;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
* path data structure, to determine the thread paths mentioned above;
|
* path data structure, to determine the thread paths mentioned above;
|
||||||
* the path is filled as we're traversing the tree of MuContainers
|
* the path is filled as we're traversing the tree of MuContainers
|
||||||
* (messages)
|
* (messages)
|
||||||
*/
|
*/
|
||||||
struct _Path {
|
struct _Path {
|
||||||
int *_data;
|
int *_data;
|
||||||
guint _len;
|
guint _len;
|
||||||
|
@ -47,14 +47,14 @@ mu_container_new (MuMsg *msg, guint docid, const char *msgid)
|
||||||
MuContainer *c;
|
MuContainer *c;
|
||||||
|
|
||||||
g_return_val_if_fail (!msg || docid != 0, NULL);
|
g_return_val_if_fail (!msg || docid != 0, NULL);
|
||||||
|
|
||||||
c = g_slice_new0 (MuContainer);
|
c = g_slice_new0 (MuContainer);
|
||||||
if (msg)
|
if (msg)
|
||||||
c->msg = mu_msg_ref (msg);
|
c->msg = mu_msg_ref (msg);
|
||||||
|
|
||||||
c->docid = docid;
|
c->docid = docid;
|
||||||
c->msgid = msgid;
|
c->msgid = msgid;
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ set_parent (MuContainer *c, MuContainer *parent)
|
||||||
|
|
||||||
static MuContainer*
|
static MuContainer*
|
||||||
find_last (MuContainer *c)
|
find_last (MuContainer *c)
|
||||||
{
|
{
|
||||||
while (c && c->next)
|
while (c && c->next)
|
||||||
c = c->next;
|
c = c->next;
|
||||||
|
|
||||||
|
@ -111,11 +111,11 @@ assert_no_duplicates (MuContainer *c)
|
||||||
GHashTable *hash;
|
GHashTable *hash;
|
||||||
|
|
||||||
hash = g_hash_table_new (g_direct_hash, g_direct_equal);
|
hash = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||||
|
|
||||||
mu_container_foreach (c,
|
mu_container_foreach (c,
|
||||||
(MuContainerForeachFunc)check_dup,
|
(MuContainerForeachFunc)check_dup,
|
||||||
hash);
|
hash);
|
||||||
|
|
||||||
g_hash_table_destroy (hash);
|
g_hash_table_destroy (hash);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -125,18 +125,18 @@ MuContainer*
|
||||||
mu_container_append_siblings (MuContainer *c, MuContainer *sibling)
|
mu_container_append_siblings (MuContainer *c, MuContainer *sibling)
|
||||||
{
|
{
|
||||||
g_assert (c);
|
g_assert (c);
|
||||||
|
|
||||||
g_return_val_if_fail (c, NULL);
|
g_return_val_if_fail (c, NULL);
|
||||||
g_return_val_if_fail (sibling, NULL);
|
g_return_val_if_fail (sibling, NULL);
|
||||||
g_return_val_if_fail (c != sibling, NULL);
|
g_return_val_if_fail (c != sibling, NULL);
|
||||||
|
|
||||||
/* assert_no_duplicates (c); */
|
/* assert_no_duplicates (c); */
|
||||||
|
|
||||||
set_parent (sibling, c->parent);
|
set_parent (sibling, c->parent);
|
||||||
(find_last(c))->next = sibling;
|
(find_last(c))->next = sibling;
|
||||||
|
|
||||||
/* assert_no_duplicates (c); */
|
/* assert_no_duplicates (c); */
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,25 +144,25 @@ MuContainer*
|
||||||
mu_container_remove_sibling (MuContainer *c, MuContainer *sibling)
|
mu_container_remove_sibling (MuContainer *c, MuContainer *sibling)
|
||||||
{
|
{
|
||||||
MuContainer *cur, *prev;
|
MuContainer *cur, *prev;
|
||||||
|
|
||||||
g_return_val_if_fail (c, NULL);
|
g_return_val_if_fail (c, NULL);
|
||||||
g_return_val_if_fail (sibling, NULL);
|
g_return_val_if_fail (sibling, NULL);
|
||||||
|
|
||||||
for (prev = NULL, cur = c; cur; cur = cur->next) {
|
for (prev = NULL, cur = c; cur; cur = cur->next) {
|
||||||
|
|
||||||
if (cur == sibling) {
|
if (cur == sibling) {
|
||||||
if (!prev)
|
if (!prev)
|
||||||
c = cur->next;
|
c = cur->next;
|
||||||
else
|
else
|
||||||
prev->next = cur->next;
|
prev->next = cur->next;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
prev = cur;
|
prev = cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
MuContainer*
|
MuContainer*
|
||||||
mu_container_append_children (MuContainer *c, MuContainer *child)
|
mu_container_append_children (MuContainer *c, MuContainer *child)
|
||||||
{
|
{
|
||||||
|
@ -171,7 +171,7 @@ mu_container_append_children (MuContainer *c, MuContainer *child)
|
||||||
g_return_val_if_fail (c != child, NULL);
|
g_return_val_if_fail (c != child, NULL);
|
||||||
|
|
||||||
/* assert_no_duplicates (c); */
|
/* assert_no_duplicates (c); */
|
||||||
|
|
||||||
set_parent (child, c);
|
set_parent (child, c);
|
||||||
if (!c->child)
|
if (!c->child)
|
||||||
c->child = child;
|
c->child = child;
|
||||||
|
@ -179,7 +179,7 @@ mu_container_append_children (MuContainer *c, MuContainer *child)
|
||||||
c->child = mu_container_append_siblings (c->child, child);
|
c->child = mu_container_append_siblings (c->child, child);
|
||||||
|
|
||||||
/* assert_no_duplicates (c->child); */
|
/* assert_no_duplicates (c->child); */
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ mu_container_path_foreach_real (MuContainer *c, guint level, Path *path,
|
||||||
|
|
||||||
path_inc (path, level);
|
path_inc (path, level);
|
||||||
func (c, user_data, path);
|
func (c, user_data, path);
|
||||||
|
|
||||||
/* children */
|
/* children */
|
||||||
mu_container_path_foreach_real (c->child, level + 1, path, func, user_data);
|
mu_container_path_foreach_real (c->child, level + 1, path, func, user_data);
|
||||||
|
|
||||||
|
@ -223,9 +223,9 @@ mu_container_path_foreach (MuContainer *c, MuContainerPathForeachFunc func,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
Path *path;
|
Path *path;
|
||||||
|
|
||||||
path = path_new (100);
|
path = path_new (100);
|
||||||
|
|
||||||
mu_container_path_foreach_real (c, 0, path, func, user_data);
|
mu_container_path_foreach_real (c, 0, path, func, user_data);
|
||||||
|
|
||||||
path_destroy (path);
|
path_destroy (path);
|
||||||
|
@ -237,17 +237,17 @@ mu_container_foreach (MuContainer *c, MuContainerForeachFunc func,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (func, FALSE);
|
g_return_val_if_fail (func, FALSE);
|
||||||
|
|
||||||
if (!c)
|
if (!c)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (!mu_container_foreach (c->child, func, user_data))
|
if (!mu_container_foreach (c->child, func, user_data))
|
||||||
return FALSE; /* recurse into children */
|
return FALSE; /* recurse into children */
|
||||||
|
|
||||||
/* recurse into siblings */
|
/* recurse into siblings */
|
||||||
if (!mu_container_foreach (c->next, func, user_data))
|
if (!mu_container_foreach (c->next, func, user_data))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return func (c, user_data);
|
return func (c, user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,9 +275,9 @@ mu_container_to_list (MuContainer *c)
|
||||||
{
|
{
|
||||||
GSList *lst;
|
GSList *lst;
|
||||||
|
|
||||||
for (lst = NULL; c; c = c->next)
|
for (lst = NULL; c; c = c->next)
|
||||||
lst = g_slist_prepend (lst, c);
|
lst = g_slist_prepend (lst, c);
|
||||||
|
|
||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ mu_container_from_list (GSList *lst)
|
||||||
cur->next = lst ? (MuContainer*)lst->data : NULL;
|
cur->next = lst ? (MuContainer*)lst->data : NULL;
|
||||||
cur=cur->next;
|
cur=cur->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ sort_func_wrapper (MuContainer *a, MuContainer *b, SortFuncData *data)
|
||||||
MuContainer *a1, *b1;
|
MuContainer *a1, *b1;
|
||||||
|
|
||||||
/* use the first non-empty 'left child' message if this one
|
/* use the first non-empty 'left child' message if this one
|
||||||
* is */
|
* is */
|
||||||
for (a1 = a; a1->msg == NULL && a1->child != NULL; a1 = a1->child);
|
for (a1 = a; a1->msg == NULL && a1->child != NULL; a1 = a1->child);
|
||||||
for (b1 = b; b1->msg == NULL && b1->child != NULL; b1 = b1->child);
|
for (b1 = b; b1->msg == NULL && b1->child != NULL; b1 = b1->child);
|
||||||
|
|
||||||
|
@ -322,11 +322,11 @@ sort_func_wrapper (MuContainer *a, MuContainer *b, SortFuncData *data)
|
||||||
return 1;
|
return 1;
|
||||||
else if (!b1->msg)
|
else if (!b1->msg)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (data->invert)
|
if (data->invert)
|
||||||
return mu_msg_cmp (b1->msg, a1->msg, data->mfid);
|
return mu_msg_cmp (b1->msg, a1->msg, data->mfid);
|
||||||
else
|
else
|
||||||
return mu_msg_cmp (a1->msg, b1->msg, data->mfid);
|
return mu_msg_cmp (a1->msg, b1->msg, data->mfid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static MuContainer*
|
static MuContainer*
|
||||||
|
@ -334,22 +334,22 @@ mu_container_sort_real (MuContainer *c, SortFuncData *sfdata)
|
||||||
{
|
{
|
||||||
GSList *lst;
|
GSList *lst;
|
||||||
MuContainer *cur;
|
MuContainer *cur;
|
||||||
|
|
||||||
if (!c)
|
if (!c)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (cur = c; cur; cur = cur->next)
|
for (cur = c; cur; cur = cur->next)
|
||||||
if (cur->child)
|
if (cur->child)
|
||||||
cur->child = mu_container_sort_real (cur->child, sfdata);
|
cur->child = mu_container_sort_real (cur->child, sfdata);
|
||||||
|
|
||||||
/* sort siblings */
|
/* sort siblings */
|
||||||
lst = mu_container_to_list (c);
|
lst = mu_container_to_list (c);
|
||||||
lst = g_slist_sort_with_data(lst,
|
lst = g_slist_sort_with_data(lst,
|
||||||
(GCompareDataFunc)sort_func_wrapper,
|
(GCompareDataFunc)sort_func_wrapper,
|
||||||
sfdata);
|
sfdata);
|
||||||
c = mu_container_from_list (lst);
|
c = mu_container_from_list (lst);
|
||||||
g_slist_free (lst);
|
g_slist_free (lst);
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,14 +358,18 @@ MuContainer*
|
||||||
mu_container_sort (MuContainer *c, MuMsgFieldId mfid, gpointer user_data,
|
mu_container_sort (MuContainer *c, MuMsgFieldId mfid, gpointer user_data,
|
||||||
gboolean invert)
|
gboolean invert)
|
||||||
{
|
{
|
||||||
|
|
||||||
SortFuncData sfdata = { mfid, invert, user_data };
|
SortFuncData sfdata;
|
||||||
|
|
||||||
|
sfdata.mfid = mfid;
|
||||||
|
sfdata.invert = invert;
|
||||||
|
sfdata.user_data = user_data;
|
||||||
|
|
||||||
g_return_val_if_fail (c, NULL);
|
g_return_val_if_fail (c, NULL);
|
||||||
g_return_val_if_fail (mu_msg_field_id_is_valid(mfid), NULL);
|
g_return_val_if_fail (mu_msg_field_id_is_valid(mfid), NULL);
|
||||||
|
|
||||||
return mu_container_sort_real (c, &sfdata);
|
return mu_container_sort_real (c, &sfdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -384,7 +388,7 @@ mu_container_reachable (MuContainer *haystack, MuContainer *needle)
|
||||||
if (!mu_container_foreach
|
if (!mu_container_foreach
|
||||||
(haystack, (MuContainerForeachFunc)unequal, needle))
|
(haystack, (MuContainerForeachFunc)unequal, needle))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,14 +397,14 @@ static gboolean
|
||||||
dump_container (MuContainer *c)
|
dump_container (MuContainer *c)
|
||||||
{
|
{
|
||||||
const gchar* subject;
|
const gchar* subject;
|
||||||
|
|
||||||
if (!c) {
|
if (!c) {
|
||||||
g_print ("<empty>\n");
|
g_print ("<empty>\n");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
subject = (c->msg) ? mu_msg_get_subject (c->msg) : "<none>";
|
subject = (c->msg) ? mu_msg_get_subject (c->msg) : "<none>";
|
||||||
|
|
||||||
g_print ("[%s][%s m:%p p:%p docid:%u %s]\n",c->msgid, subject, (void*)c,
|
g_print ("[%s][%s m:%p p:%p docid:%u %s]\n",c->msgid, subject, (void*)c,
|
||||||
(void*)c->parent, c->docid,
|
(void*)c->parent, c->docid,
|
||||||
c->msg ? mu_msg_get_path (c->msg) : "");
|
c->msg ? mu_msg_get_path (c->msg) : "");
|
||||||
|
@ -429,10 +433,10 @@ path_new (guint initial)
|
||||||
Path *p;
|
Path *p;
|
||||||
|
|
||||||
p = g_slice_new0 (Path);
|
p = g_slice_new0 (Path);
|
||||||
|
|
||||||
p->_data = g_new0 (int, initial);
|
p->_data = g_new0 (int, initial);
|
||||||
p->_len = initial;
|
p->_len = initial;
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,7 +445,7 @@ path_destroy (Path *p)
|
||||||
{
|
{
|
||||||
if (!p)
|
if (!p)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_free (p->_data);
|
g_free (p->_data);
|
||||||
g_slice_free (Path, p);
|
g_slice_free (Path, p);
|
||||||
}
|
}
|
||||||
|
@ -454,7 +458,7 @@ path_inc (Path *p, guint index)
|
||||||
memset (&p->_data[p->_len], 0, p->_len);
|
memset (&p->_data[p->_len], 0, p->_len);
|
||||||
p->_len *= 2;
|
p->_len *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
++p->_data[index];
|
++p->_data[index];
|
||||||
p->_data[index + 1] = 0;
|
p->_data[index + 1] = 0;
|
||||||
}
|
}
|
||||||
|
@ -468,13 +472,13 @@ path_to_string (Path *p, const char* frmt)
|
||||||
|
|
||||||
if (!p->_data)
|
if (!p->_data)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (u = 0, str = NULL; p->_data[u] != 0; ++u) {
|
for (u = 0, str = NULL; p->_data[u] != 0; ++u) {
|
||||||
|
|
||||||
char segm[16];
|
char segm[16];
|
||||||
snprintf (segm, sizeof(segm), frmt, p->_data[u] - 1);
|
snprintf (segm, sizeof(segm), frmt, p->_data[u] - 1);
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
str = g_strdup (segm);
|
str = g_strdup (segm);
|
||||||
else {
|
else {
|
||||||
gchar *tmp;
|
gchar *tmp;
|
||||||
|
@ -483,7 +487,7 @@ path_to_string (Path *p, const char* frmt)
|
||||||
str = tmp;
|
str = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,7 +497,7 @@ thread_info_new (gchar *threadpath, gboolean root, gboolean child,
|
||||||
gboolean empty_parent, gboolean is_dup)
|
gboolean empty_parent, gboolean is_dup)
|
||||||
{
|
{
|
||||||
MuMsgIterThreadInfo *ti;
|
MuMsgIterThreadInfo *ti;
|
||||||
|
|
||||||
ti = g_slice_new (MuMsgIterThreadInfo);
|
ti = g_slice_new (MuMsgIterThreadInfo);
|
||||||
ti->threadpath = threadpath;
|
ti->threadpath = threadpath;
|
||||||
|
|
||||||
|
@ -502,7 +506,7 @@ thread_info_new (gchar *threadpath, gboolean root, gboolean child,
|
||||||
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;
|
||||||
|
|
||||||
return ti;
|
return ti;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,14 +532,14 @@ 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;
|
||||||
|
|
||||||
/* '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;
|
||||||
|
|
||||||
g_hash_table_insert (thread_info_hash,
|
g_hash_table_insert (thread_info_hash,
|
||||||
GUINT_TO_POINTER(c->docid),
|
GUINT_TO_POINTER(c->docid),
|
||||||
thread_info_new (threadpath,
|
thread_info_new (threadpath,
|
||||||
|
@ -552,21 +556,21 @@ thread_segment_format_string (size_t matchnum)
|
||||||
{
|
{
|
||||||
unsigned digitnum;
|
unsigned digitnum;
|
||||||
static char frmt[16];
|
static char frmt[16];
|
||||||
|
|
||||||
/* get the number of digits needed in a hex-representation of
|
/* get the number of digits needed in a hex-representation of
|
||||||
* matchnum */
|
* matchnum */
|
||||||
digitnum = (unsigned) (ceil (log(matchnum)/log(16)));
|
digitnum = (unsigned) (ceil (log(matchnum)/log(16)));
|
||||||
snprintf (frmt, sizeof(frmt),"%%0%ux", digitnum);
|
snprintf (frmt, sizeof(frmt),"%%0%ux", digitnum);
|
||||||
|
|
||||||
return frmt;
|
return frmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
add_thread_info (MuContainer *c, ThreadInfo *ti, Path *path)
|
add_thread_info (MuContainer *c, ThreadInfo *ti, Path *path)
|
||||||
{
|
{
|
||||||
gchar *pathstr;
|
gchar *pathstr;
|
||||||
|
|
||||||
pathstr = path_to_string (path, ti->format);
|
pathstr = path_to_string (path, ti->format);
|
||||||
add_to_thread_info_hash (ti->hash, c, pathstr);
|
add_to_thread_info_hash (ti->hash, c, pathstr);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -580,14 +584,14 @@ mu_container_thread_info_hash_new (MuContainer *root_set, size_t matchnum)
|
||||||
|
|
||||||
g_return_val_if_fail (root_set, NULL);
|
g_return_val_if_fail (root_set, NULL);
|
||||||
g_return_val_if_fail (matchnum > 0, NULL);
|
g_return_val_if_fail (matchnum > 0, NULL);
|
||||||
|
|
||||||
/* create hash docid => thread-info */
|
/* create hash docid => thread-info */
|
||||||
ti.hash = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
ti.hash = g_hash_table_new_full (g_direct_hash, g_direct_equal,
|
||||||
NULL,
|
NULL,
|
||||||
(GDestroyNotify)thread_info_destroy);
|
(GDestroyNotify)thread_info_destroy);
|
||||||
|
|
||||||
ti.format = thread_segment_format_string (matchnum);
|
ti.format = thread_segment_format_string (matchnum);
|
||||||
|
|
||||||
mu_container_path_foreach (root_set,
|
mu_container_path_foreach (root_set,
|
||||||
(MuContainerPathForeachFunc)add_thread_info,
|
(MuContainerPathForeachFunc)add_thread_info,
|
||||||
&ti);
|
&ti);
|
||||||
|
|
|
@ -137,26 +137,29 @@ insert_or_update_maybe (const char* fullpath, const char* mdir,
|
||||||
|
|
||||||
err = NULL;
|
err = NULL;
|
||||||
msg = mu_msg_new_from_file (fullpath, mdir, &err);
|
msg = mu_msg_new_from_file (fullpath, mdir, &err);
|
||||||
if ((G_UNLIKELY(!msg))) {
|
if ((G_UNLIKELY(!msg)))
|
||||||
g_warning ("%s: failed to create mu_msg for %s",
|
goto errexit;
|
||||||
__FUNCTION__, fullpath);
|
|
||||||
return MU_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we got a valid id; scan the message contents as well */
|
/* we got a valid id; scan the message contents as well */
|
||||||
if (G_UNLIKELY((!mu_store_store_msg (data->_store, msg, TRUE)))) {
|
if (G_UNLIKELY((!mu_store_add_msg (data->_store, msg, TRUE, &err))))
|
||||||
g_warning ("%s: storing content %s failed", __FUNCTION__,
|
goto errexit;
|
||||||
fullpath);
|
|
||||||
return MU_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
mu_msg_unref (msg);
|
mu_msg_unref (msg);
|
||||||
*updated = TRUE;
|
*updated = TRUE;
|
||||||
|
|
||||||
return MU_OK;
|
return MU_OK;
|
||||||
|
|
||||||
|
errexit:
|
||||||
|
{
|
||||||
|
MuError me;
|
||||||
|
me = err ? err->code : MU_ERROR;
|
||||||
|
g_clear_error (&err);
|
||||||
|
if (msg)
|
||||||
|
mu_msg_unref (msg);
|
||||||
|
return me;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static MuError
|
static MuError
|
||||||
run_msg_callback_maybe (MuIndexCallbackData *data)
|
run_msg_callback_maybe (MuIndexCallbackData *data)
|
||||||
{
|
{
|
||||||
MuError result;
|
MuError result;
|
||||||
|
|
|
@ -235,7 +235,8 @@ log_write (const char* domain, GLogLevelFlags level,
|
||||||
|
|
||||||
/* get the time/date string */
|
/* get the time/date string */
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
strftime (timebuf, sizeof(timebuf), "%F %T", localtime(&now));
|
strftime (timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S",
|
||||||
|
localtime(&now));
|
||||||
|
|
||||||
/* now put it all together */
|
/* now put it all together */
|
||||||
len = snprintf (buf, sizeof(buf), "%s [%s] %s\n", timebuf,
|
len = snprintf (buf, sizeof(buf), "%s [%s] %s\n", timebuf,
|
||||||
|
|
|
@ -54,7 +54,7 @@ find_part (MuMsg* msg, guint partidx)
|
||||||
fpdata.wanted_idx = partidx;
|
fpdata.wanted_idx = partidx;
|
||||||
fpdata.idx = 0;
|
fpdata.idx = 0;
|
||||||
fpdata.part = NULL;
|
fpdata.part = NULL;
|
||||||
|
|
||||||
g_mime_message_foreach (msg->_file->_mime_msg,
|
g_mime_message_foreach (msg->_file->_mime_msg,
|
||||||
(GMimeObjectForeachFunc)find_part_cb,
|
(GMimeObjectForeachFunc)find_part_cb,
|
||||||
&fpdata);
|
&fpdata);
|
||||||
|
@ -84,15 +84,15 @@ part_foreach_cb (GMimeObject *parent, GMimeObject *part, PartData *pdata)
|
||||||
|
|
||||||
if (GMIME_IS_CONTENT_TYPE(ct)) {
|
if (GMIME_IS_CONTENT_TYPE(ct)) {
|
||||||
pi.type = (char*)g_mime_content_type_get_media_type (ct);
|
pi.type = (char*)g_mime_content_type_get_media_type (ct);
|
||||||
pi.subtype = (char*)g_mime_content_type_get_media_subtype (ct);
|
pi.subtype = (char*)g_mime_content_type_get_media_subtype (ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GMIME_IS_PART(part)) {
|
if (GMIME_IS_PART(part)) {
|
||||||
pi.disposition = (char*)g_mime_object_get_disposition (part);
|
pi.disposition = (char*)g_mime_object_get_disposition (part);
|
||||||
pi.file_name = (char*)g_mime_part_get_filename (GMIME_PART(part));
|
pi.file_name = (char*)g_mime_part_get_filename (GMIME_PART(part));
|
||||||
}
|
}
|
||||||
|
|
||||||
pdata->_func(pdata->_msg, &pi, pdata->_user_data);
|
pdata->_func(pdata->_msg, &pi, pdata->_user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -100,16 +100,27 @@ mu_msg_part_foreach (MuMsg *msg, MuMsgPartForeachFunc func,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
PartData pdata;
|
PartData pdata;
|
||||||
|
|
||||||
g_return_if_fail (msg);
|
g_return_if_fail (msg);
|
||||||
g_return_if_fail (msg->_file);
|
|
||||||
|
/* if we don't have a file yet, we need to open it now... */
|
||||||
|
if (!msg->_file) {
|
||||||
|
GError *err;
|
||||||
|
err = NULL;
|
||||||
|
msg->_file = mu_msg_file_new (mu_msg_get_path(msg), NULL,
|
||||||
|
&err);
|
||||||
|
if (!msg->_file) {
|
||||||
|
MU_HANDLE_G_ERROR(err); /* will free it */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
g_return_if_fail (GMIME_IS_OBJECT(msg->_file->_mime_msg));
|
g_return_if_fail (GMIME_IS_OBJECT(msg->_file->_mime_msg));
|
||||||
|
|
||||||
pdata._msg = msg;
|
pdata._msg = msg;
|
||||||
pdata._idx = 0;
|
pdata._idx = 0;
|
||||||
pdata._func = func;
|
pdata._func = func;
|
||||||
pdata._user_data = user_data;
|
pdata._user_data = user_data;
|
||||||
|
|
||||||
g_mime_message_foreach (msg->_file->_mime_msg,
|
g_mime_message_foreach (msg->_file->_mime_msg,
|
||||||
(GMimeObjectForeachFunc)part_foreach_cb,
|
(GMimeObjectForeachFunc)part_foreach_cb,
|
||||||
&pdata);
|
&pdata);
|
||||||
|
@ -117,35 +128,38 @@ mu_msg_part_foreach (MuMsg *msg, MuMsgPartForeachFunc func,
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
write_to_stream (GMimeObject *part, int fd)
|
write_to_stream (GMimeObject *part, int fd, GError **err)
|
||||||
{
|
{
|
||||||
GMimeStream *stream;
|
GMimeStream *stream;
|
||||||
GMimeDataWrapper *wrapper;
|
GMimeDataWrapper *wrapper;
|
||||||
gboolean rv;
|
gboolean rv;
|
||||||
|
|
||||||
stream = g_mime_stream_fs_new (fd);
|
stream = g_mime_stream_fs_new (fd);
|
||||||
if (!GMIME_IS_STREAM(stream)) {
|
if (!GMIME_IS_STREAM(stream)) {
|
||||||
g_critical ("%s: failed to create stream",__FUNCTION__);
|
g_set_error (err, 0, MU_ERROR_GMIME,
|
||||||
|
"failed to create stream");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
g_mime_stream_fs_set_owner (GMIME_STREAM_FS(stream), FALSE);
|
g_mime_stream_fs_set_owner (GMIME_STREAM_FS(stream), FALSE);
|
||||||
|
|
||||||
wrapper = g_mime_part_get_content_object (GMIME_PART(part));
|
wrapper = g_mime_part_get_content_object (GMIME_PART(part));
|
||||||
if (!GMIME_IS_DATA_WRAPPER(wrapper)) {
|
if (!GMIME_IS_DATA_WRAPPER(wrapper)) {
|
||||||
g_critical ("%s: failed to create wrapper", __FUNCTION__);
|
g_set_error (err, 0, MU_ERROR_GMIME,
|
||||||
|
"failed to create wrapper");
|
||||||
g_object_unref (stream);
|
g_object_unref (stream);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
g_object_ref (part); /* FIXME: otherwise, the unrefs below
|
g_object_ref (part); /* FIXME: otherwise, the unrefs below
|
||||||
* give errors...*/
|
* give errors...*/
|
||||||
|
|
||||||
rv = g_mime_data_wrapper_write_to_stream (wrapper, stream);
|
rv = g_mime_data_wrapper_write_to_stream (wrapper, stream);
|
||||||
if (!rv)
|
if (!rv)
|
||||||
g_critical ("%s: failed to write to stream", __FUNCTION__);
|
g_set_error (err, 0, MU_ERROR_GMIME,
|
||||||
|
"failed to write to stream");
|
||||||
|
|
||||||
g_object_unref (wrapper);
|
g_object_unref (wrapper);
|
||||||
g_object_unref (stream);
|
g_object_unref (stream);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,12 +170,12 @@ save_part (GMimeObject *part, const char *fullpath,
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
gboolean rv;
|
gboolean rv;
|
||||||
|
|
||||||
/* don't try to overwrite when we already have it; useful when
|
/* don't try to overwrite when we already have it; useful when
|
||||||
* you're sure it's not a different file with the same name */
|
* you're sure it's not a different file with the same name */
|
||||||
if (use_existing && access (fullpath, F_OK) == 0)
|
if (use_existing && access (fullpath, F_OK) == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* ok, try to create the file */
|
/* ok, try to create the file */
|
||||||
fd = mu_util_create_writeable_fd (fullpath, 0600, overwrite);
|
fd = mu_util_create_writeable_fd (fullpath, 0600, overwrite);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
|
@ -169,17 +183,17 @@ save_part (GMimeObject *part, const char *fullpath,
|
||||||
"could not open '%s' for writing: %s",
|
"could not open '%s' for writing: %s",
|
||||||
fullpath, errno ? strerror(errno) : "error");
|
fullpath, errno ? strerror(errno) : "error");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = write_to_stream (part, fd);
|
rv = write_to_stream (part, fd, err);
|
||||||
if (close (fd) != 0) {
|
if (close (fd) != 0 && !err) { /* don't write on top of old err */
|
||||||
g_set_error (err, 0, MU_ERROR_FILE,
|
g_set_error (err, 0, MU_ERROR_FILE,
|
||||||
"could not close '%s': %s",
|
"could not close '%s': %s",
|
||||||
fullpath, errno ? strerror(errno) : "error");
|
fullpath, errno ? strerror(errno) : "error");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -194,7 +208,7 @@ mu_msg_part_filepath (MuMsg *msg, const char* targetdir, guint partidx)
|
||||||
g_warning ("%s: cannot find part %u", __FUNCTION__, partidx);
|
g_warning ("%s: cannot find part %u", __FUNCTION__, partidx);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the easy case: the part has a filename */
|
/* the easy case: the part has a filename */
|
||||||
fname = (gchar*)g_mime_part_get_filename (GMIME_PART(part));
|
fname = (gchar*)g_mime_part_get_filename (GMIME_PART(part));
|
||||||
if (fname) /* security: don't include any directory components... */
|
if (fname) /* security: don't include any directory components... */
|
||||||
|
@ -218,9 +232,9 @@ mu_msg_part_filepath_cache (MuMsg *msg, guint partid)
|
||||||
{
|
{
|
||||||
char *dirname, *filepath;
|
char *dirname, *filepath;
|
||||||
const char* path;
|
const char* path;
|
||||||
|
|
||||||
g_return_val_if_fail (msg, NULL);
|
g_return_val_if_fail (msg, NULL);
|
||||||
|
|
||||||
path = mu_msg_get_path (msg);
|
path = mu_msg_get_path (msg);
|
||||||
if (!path)
|
if (!path)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -231,7 +245,7 @@ mu_msg_part_filepath_cache (MuMsg *msg, guint partid)
|
||||||
mu_util_cache_dir(), G_DIR_SEPARATOR,
|
mu_util_cache_dir(), G_DIR_SEPARATOR,
|
||||||
g_str_hash (path), G_DIR_SEPARATOR,
|
g_str_hash (path), G_DIR_SEPARATOR,
|
||||||
partid);
|
partid);
|
||||||
|
|
||||||
if (!mu_util_create_dir_maybe (dirname, 0700, FALSE)) {
|
if (!mu_util_create_dir_maybe (dirname, 0700, FALSE)) {
|
||||||
g_free (dirname);
|
g_free (dirname);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -239,9 +253,9 @@ mu_msg_part_filepath_cache (MuMsg *msg, guint partid)
|
||||||
|
|
||||||
filepath = mu_msg_part_filepath (msg, dirname, partid);
|
filepath = mu_msg_part_filepath (msg, dirname, partid);
|
||||||
g_free (dirname);
|
g_free (dirname);
|
||||||
if (!filepath)
|
if (!filepath)
|
||||||
g_warning ("%s: could not get filename", __FUNCTION__);
|
g_warning ("%s: could not get filename", __FUNCTION__);
|
||||||
|
|
||||||
return filepath;
|
return filepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,18 +265,18 @@ mu_msg_part_save (MuMsg *msg, const char *fullpath, guint partidx,
|
||||||
gboolean overwrite, gboolean use_cached, GError **err)
|
gboolean overwrite, gboolean use_cached, GError **err)
|
||||||
{
|
{
|
||||||
GMimeObject *part;
|
GMimeObject *part;
|
||||||
|
|
||||||
g_return_val_if_fail (msg, FALSE);
|
g_return_val_if_fail (msg, FALSE);
|
||||||
g_return_val_if_fail (fullpath, FALSE);
|
g_return_val_if_fail (fullpath, FALSE);
|
||||||
g_return_val_if_fail (!overwrite||!use_cached, FALSE);
|
g_return_val_if_fail (!overwrite||!use_cached, FALSE);
|
||||||
|
|
||||||
part = find_part (msg, partidx);
|
part = find_part (msg, partidx);
|
||||||
if (!GMIME_IS_PART(part)) {
|
if (!GMIME_IS_PART(part)) {
|
||||||
g_set_error (err, 0, MU_ERROR_GMIME,
|
g_set_error (err, 0, MU_ERROR_GMIME,
|
||||||
"cannot find part %u", partidx);
|
"cannot find part %u", partidx);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!save_part (part, fullpath, overwrite, use_cached, err))
|
if (!save_part (part, fullpath, overwrite, use_cached, err))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -284,7 +298,7 @@ part_match_foreach_cb (GMimeObject *parent, GMimeObject *part, MatchData *mdata)
|
||||||
if (mdata->_found_idx < 0)
|
if (mdata->_found_idx < 0)
|
||||||
if (mdata->_matcher (part, mdata->_user_data))
|
if (mdata->_matcher (part, mdata->_user_data))
|
||||||
mdata->_found_idx = mdata->_idx;
|
mdata->_found_idx = mdata->_idx;
|
||||||
|
|
||||||
++mdata->_idx;
|
++mdata->_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,15 +306,15 @@ static int
|
||||||
msg_part_find_idx (GMimeMessage *msg, MatchFunc func, gpointer user_data)
|
msg_part_find_idx (GMimeMessage *msg, MatchFunc func, gpointer user_data)
|
||||||
{
|
{
|
||||||
MatchData mdata;
|
MatchData mdata;
|
||||||
|
|
||||||
g_return_val_if_fail (msg, -1);
|
g_return_val_if_fail (msg, -1);
|
||||||
g_return_val_if_fail (GMIME_IS_MESSAGE(msg), -1);
|
g_return_val_if_fail (GMIME_IS_MESSAGE(msg), -1);
|
||||||
|
|
||||||
mdata._idx = 0;
|
mdata._idx = 0;
|
||||||
mdata._found_idx = -1;
|
mdata._found_idx = -1;
|
||||||
mdata._matcher = func;
|
mdata._matcher = func;
|
||||||
mdata._user_data = user_data;
|
mdata._user_data = user_data;
|
||||||
|
|
||||||
g_mime_message_foreach (msg,
|
g_mime_message_foreach (msg,
|
||||||
(GMimeObjectForeachFunc)part_match_foreach_cb,
|
(GMimeObjectForeachFunc)part_match_foreach_cb,
|
||||||
&mdata);
|
&mdata);
|
||||||
|
@ -320,13 +334,13 @@ int
|
||||||
mu_msg_part_find_cid (MuMsg *msg, const char* sought_cid)
|
mu_msg_part_find_cid (MuMsg *msg, const char* sought_cid)
|
||||||
{
|
{
|
||||||
const char* cid;
|
const char* cid;
|
||||||
|
|
||||||
g_return_val_if_fail (msg, -1);
|
g_return_val_if_fail (msg, -1);
|
||||||
g_return_val_if_fail (sought_cid, -1);
|
g_return_val_if_fail (sought_cid, -1);
|
||||||
|
|
||||||
cid = g_str_has_prefix (sought_cid, "cid:") ?
|
cid = g_str_has_prefix (sought_cid, "cid:") ?
|
||||||
sought_cid + 4 : sought_cid;
|
sought_cid + 4 : sought_cid;
|
||||||
|
|
||||||
return msg_part_find_idx (msg->_file->_mime_msg,
|
return msg_part_find_idx (msg->_file->_mime_msg,
|
||||||
(MatchFunc)match_content_id,
|
(MatchFunc)match_content_id,
|
||||||
(gpointer)cid);
|
(gpointer)cid);
|
||||||
|
@ -344,14 +358,14 @@ static void
|
||||||
match_filename_rx (GMimeObject *parent, GMimeObject *part, MatchData2 *mdata)
|
match_filename_rx (GMimeObject *parent, GMimeObject *part, MatchData2 *mdata)
|
||||||
{
|
{
|
||||||
const char *fname;
|
const char *fname;
|
||||||
|
|
||||||
if (!GMIME_IS_PART(part))
|
if (!GMIME_IS_PART(part))
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
fname = g_mime_part_get_filename (GMIME_PART(part));
|
fname = g_mime_part_get_filename (GMIME_PART(part));
|
||||||
if (!fname)
|
if (!fname)
|
||||||
goto leave;
|
goto leave;
|
||||||
|
|
||||||
if (g_regex_match (mdata->_rx, fname, 0, NULL))
|
if (g_regex_match (mdata->_rx, fname, 0, NULL))
|
||||||
mdata->_lst = g_slist_prepend (mdata->_lst,
|
mdata->_lst = g_slist_prepend (mdata->_lst,
|
||||||
GUINT_TO_POINTER(mdata->_idx));
|
GUINT_TO_POINTER(mdata->_idx));
|
||||||
|
@ -364,14 +378,14 @@ GSList*
|
||||||
mu_msg_part_find_files (MuMsg *msg, const GRegex *pattern)
|
mu_msg_part_find_files (MuMsg *msg, const GRegex *pattern)
|
||||||
{
|
{
|
||||||
MatchData2 mdata;
|
MatchData2 mdata;
|
||||||
|
|
||||||
g_return_val_if_fail (msg, NULL);
|
g_return_val_if_fail (msg, NULL);
|
||||||
g_return_val_if_fail (pattern, NULL);
|
g_return_val_if_fail (pattern, NULL);
|
||||||
|
|
||||||
mdata._lst = NULL;
|
mdata._lst = NULL;
|
||||||
mdata._rx = pattern;
|
mdata._rx = pattern;
|
||||||
mdata._idx = 0;
|
mdata._idx = 0;
|
||||||
|
|
||||||
g_mime_message_foreach (msg->_file->_mime_msg,
|
g_mime_message_foreach (msg->_file->_mime_msg,
|
||||||
(GMimeObjectForeachFunc)match_filename_rx,
|
(GMimeObjectForeachFunc)match_filename_rx,
|
||||||
&mdata);
|
&mdata);
|
||||||
|
|
|
@ -161,6 +161,8 @@ const char* mu_store_version (MuStore *store);
|
||||||
*/
|
*/
|
||||||
void mu_store_flush (MuStore *store);
|
void mu_store_flush (MuStore *store);
|
||||||
|
|
||||||
|
#define MU_STORE_INVALID_DOCID 0
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* store an email message in the XapianStore
|
* store an email message in the XapianStore
|
||||||
*
|
*
|
||||||
|
@ -172,10 +174,11 @@ void mu_store_flush (MuStore *store);
|
||||||
* of a initial fill or rebuild of the database), we can set 'replace'
|
* of a initial fill or rebuild of the database), we can set 'replace'
|
||||||
* to FALSE for a couple% performance gain
|
* to FALSE for a couple% performance gain
|
||||||
*
|
*
|
||||||
* @return TRUE if it succeeded, FALSE otherwise
|
* @return the docid of the stored message, or 0
|
||||||
|
* (MU_STORE_INVALID_DOCID) in case of error
|
||||||
*/
|
*/
|
||||||
gboolean mu_store_store_msg (MuStore *store, MuMsg *msg, gboolean replace);
|
unsigned mu_store_add_msg (MuStore *store, MuMsg *msg, gboolean replace,
|
||||||
|
GError **err);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* store an email message in the XapianStore; similar to
|
* store an email message in the XapianStore; similar to
|
||||||
|
@ -185,12 +188,13 @@ gboolean mu_store_store_msg (MuStore *store, MuMsg *msg, gboolean replace);
|
||||||
* @param store a valid store
|
* @param store a valid store
|
||||||
* @param path full filesystem path to a valid message
|
* @param path full filesystem path to a valid message
|
||||||
*
|
*
|
||||||
* @return TRUE if it succeeded, FALSE otherwise
|
* @return the docid of the stored message, or 0
|
||||||
|
* (MU_STORE_INVALID_DOCID) in case of error
|
||||||
*/
|
*/
|
||||||
gboolean mu_store_store_path (MuStore *store, const char *path);
|
unsigned mu_store_add_path (MuStore *store, const char *path, GError **err);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* remove a message from the database
|
* remove a message from the database based on its path
|
||||||
*
|
*
|
||||||
* @param store a valid store
|
* @param store a valid store
|
||||||
* @param msgpath path of the message (note, this is only used to
|
* @param msgpath path of the message (note, this is only used to
|
||||||
|
@ -340,6 +344,22 @@ gboolean mu_store_clear (MuStore *store, GError **err);
|
||||||
*/
|
*/
|
||||||
gboolean mu_store_database_is_locked (const gchar *xpath);
|
gboolean mu_store_database_is_locked (const gchar *xpath);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get a specific message, based on its Xapian docid
|
||||||
|
*
|
||||||
|
* @param self a valid MuQuery instance
|
||||||
|
* @param docid the Xapian docid for the wanted message
|
||||||
|
* @param err receives error information, or NULL
|
||||||
|
*
|
||||||
|
* @return a MuMsg instance (use mu_msg_unref when done with it), or
|
||||||
|
* NULL in case of error
|
||||||
|
*/
|
||||||
|
MuMsg* mu_store_get_msg (MuStore *self, unsigned docid, GError **err);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /*__MU_STORE_H__*/
|
#endif /*__MU_STORE_H__*/
|
||||||
|
|
131
src/mu-str.c
131
src/mu-str.c
|
@ -1,22 +1,22 @@
|
||||||
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify
|
** This program is free software; you can redistribute it and/or modify
|
||||||
** it under the terms of the GNU General Public License as published by
|
** it under the terms of the GNU General Public License as published by
|
||||||
** the Free Software Foundation; either version 3 of the License, or
|
** the Free Software Foundation; either version 3 of the License, or
|
||||||
** (at your option) any later version.
|
** (at your option) any later version.
|
||||||
**
|
**
|
||||||
** This program is distributed in the hope that it will be useful,
|
** This program is distributed in the hope that it will be useful,
|
||||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
** GNU General Public License for more details.
|
** GNU General Public License for more details.
|
||||||
**
|
**
|
||||||
** You should have received a copy of the GNU General Public License
|
** You should have received a copy of the GNU General Public License
|
||||||
** along with this program; if not, write to the Free Software Foundation,
|
** along with this program; if not, write to the Free Software Foundation,
|
||||||
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,11 +66,11 @@ mu_str_size_s (size_t s)
|
||||||
g_snprintf(buf, sizeof(buf), "%.1f kB", (double)s/(1000));
|
g_snprintf(buf, sizeof(buf), "%.1f kB", (double)s/(1000));
|
||||||
#endif /*HAVE_GLIB216*/
|
#endif /*HAVE_GLIB216*/
|
||||||
|
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
mu_str_size (size_t s)
|
mu_str_size (size_t s)
|
||||||
{
|
{
|
||||||
return g_strdup (mu_str_size_s(s));
|
return g_strdup (mu_str_size_s(s));
|
||||||
|
@ -98,7 +98,7 @@ mu_str_summarize (const char* str, size_t max_lines)
|
||||||
|
|
||||||
g_return_val_if_fail (str, NULL);
|
g_return_val_if_fail (str, NULL);
|
||||||
g_return_val_if_fail (max_lines > 0, NULL);
|
g_return_val_if_fail (max_lines > 0, NULL);
|
||||||
|
|
||||||
/* len for summary <= original len */
|
/* len for summary <= original len */
|
||||||
summary = g_new (gchar, strlen(str) + 1);
|
summary = g_new (gchar, strlen(str) + 1);
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ static void
|
||||||
cleanup_contact (char *contact)
|
cleanup_contact (char *contact)
|
||||||
{
|
{
|
||||||
char *c, *c2;
|
char *c, *c2;
|
||||||
|
|
||||||
/* replace "'<> with space */
|
/* replace "'<> with space */
|
||||||
for (c2 = contact; *c2; ++c2)
|
for (c2 = contact; *c2; ++c2)
|
||||||
if (*c2 == '"' || *c2 == '\'' || *c2 == '<' || *c2 == '>')
|
if (*c2 == '"' || *c2 == '\'' || *c2 == '<' || *c2 == '>')
|
||||||
|
@ -145,7 +145,7 @@ cleanup_contact (char *contact)
|
||||||
c = g_strstr_len (contact, -1, "(");
|
c = g_strstr_len (contact, -1, "(");
|
||||||
if (c && c - contact > 5)
|
if (c && c - contact > 5)
|
||||||
*c = '\0';
|
*c = '\0';
|
||||||
|
|
||||||
g_strstrip (contact);
|
g_strstrip (contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ mu_str_display_contact_s (const char *str)
|
||||||
{
|
{
|
||||||
static gchar contact[255];
|
static gchar contact[255];
|
||||||
gchar *c, *c2;
|
gchar *c, *c2;
|
||||||
|
|
||||||
str = str ? str : "";
|
str = str ? str : "";
|
||||||
g_strlcpy (contact, str, sizeof(contact));
|
g_strlcpy (contact, str, sizeof(contact));
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ mu_str_display_contact_s (const char *str)
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup_contact (contact);
|
cleanup_contact (contact);
|
||||||
|
|
||||||
return contact;
|
return contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ each_check_prefix (MuMsgFieldId mfid, CheckPrefix *cpfx)
|
||||||
|
|
||||||
if (!cpfx || cpfx->match)
|
if (!cpfx || cpfx->match)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
field_shortcut = mu_msg_field_shortcut (mfid);
|
field_shortcut = mu_msg_field_shortcut (mfid);
|
||||||
if (field_shortcut == cpfx->pfx[0] && cpfx->pfx[1] == ':') {
|
if (field_shortcut == cpfx->pfx[0] && cpfx->pfx[1] == ':') {
|
||||||
cpfx->match = TRUE;
|
cpfx->match = TRUE;
|
||||||
|
@ -223,10 +223,10 @@ static gboolean
|
||||||
is_xapian_prefix (const char *q, const char *colon)
|
is_xapian_prefix (const char *q, const char *colon)
|
||||||
{
|
{
|
||||||
const char *cur;
|
const char *cur;
|
||||||
|
|
||||||
if (colon == q)
|
if (colon == q)
|
||||||
return FALSE; /* : at beginning, not a prefix */
|
return FALSE; /* : at beginning, not a prefix */
|
||||||
|
|
||||||
/* track back from colon until a boundary or beginning of the
|
/* track back from colon until a boundary or beginning of the
|
||||||
* str */
|
* str */
|
||||||
for (cur = colon - 1; cur >= q; --cur) {
|
for (cur = colon - 1; cur >= q; --cur) {
|
||||||
|
@ -239,15 +239,15 @@ is_xapian_prefix (const char *q, const char *colon)
|
||||||
cpfx.pfx = cur;
|
cpfx.pfx = cur;
|
||||||
cpfx.len = (colon - cur);
|
cpfx.len = (colon - cur);
|
||||||
cpfx.match = FALSE;
|
cpfx.match = FALSE;
|
||||||
|
|
||||||
mu_msg_field_foreach ((MuMsgFieldForEachFunc)
|
mu_msg_field_foreach ((MuMsgFieldForEachFunc)
|
||||||
each_check_prefix,
|
each_check_prefix,
|
||||||
&cpfx);
|
&cpfx);
|
||||||
|
|
||||||
return (cpfx.match);
|
return (cpfx.match);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,10 +261,10 @@ mu_str_size_parse_bkm (const char* str)
|
||||||
|
|
||||||
if (!isdigit(str[0]))
|
if (!isdigit(str[0]))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
num = atoi(str);
|
num = atoi(str);
|
||||||
for (++str; isdigit(*str); ++str);
|
for (++str; isdigit(*str); ++str);
|
||||||
|
|
||||||
switch (tolower(*str)) {
|
switch (tolower(*str)) {
|
||||||
case '\0':
|
case '\0':
|
||||||
case 'b' : return num; /* bytes */
|
case 'b' : return num; /* bytes */
|
||||||
|
@ -284,12 +284,12 @@ mu_str_from_list (const GSList *lst, char sepa)
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
g_return_val_if_fail (sepa, NULL);
|
g_return_val_if_fail (sepa, NULL);
|
||||||
|
|
||||||
for (cur = lst, str = NULL; cur; cur = g_slist_next(cur)) {
|
for (cur = lst, str = NULL; cur; cur = g_slist_next(cur)) {
|
||||||
|
|
||||||
char *tmp;
|
char *tmp;
|
||||||
/* two extra dummy '\0' so -Wstack-protector won't complain */
|
/* two extra dummy '\0' so -Wstack-protector won't complain */
|
||||||
char sep[4] = { '\0', '\0', '\0', '\0' };
|
char sep[4] = { '\0', '\0', '\0', '\0' };
|
||||||
sep[0] = cur->next ? sepa : '\0';
|
sep[0] = cur->next ? sepa : '\0';
|
||||||
|
|
||||||
tmp = g_strdup_printf ("%s%s%s",
|
tmp = g_strdup_printf ("%s%s%s",
|
||||||
|
@ -299,7 +299,7 @@ mu_str_from_list (const GSList *lst, char sepa)
|
||||||
g_free (str);
|
g_free (str);
|
||||||
str = tmp;
|
str = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,10 +309,10 @@ mu_str_to_list (const char *str, char sepa, gboolean strip)
|
||||||
GSList *lst;
|
GSList *lst;
|
||||||
gchar **strs, **cur;
|
gchar **strs, **cur;
|
||||||
/* two extra dummy '\0' so -Wstack-protector won't complain */
|
/* two extra dummy '\0' so -Wstack-protector won't complain */
|
||||||
char sep[4] = { '\0', '\0', '\0', '\0' };
|
char sep[4] = { '\0', '\0', '\0', '\0' };
|
||||||
|
|
||||||
g_return_val_if_fail (sepa, NULL);
|
g_return_val_if_fail (sepa, NULL);
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -324,10 +324,10 @@ mu_str_to_list (const char *str, char sepa, gboolean strip)
|
||||||
elm = g_strdup(*cur);
|
elm = g_strdup(*cur);
|
||||||
if (strip)
|
if (strip)
|
||||||
elm = g_strstrip (elm);
|
elm = g_strstrip (elm);
|
||||||
|
|
||||||
lst = g_slist_prepend (lst, elm);
|
lst = g_slist_prepend (lst, elm);
|
||||||
}
|
}
|
||||||
|
|
||||||
lst = g_slist_reverse (lst);
|
lst = g_slist_reverse (lst);
|
||||||
g_strfreev (strs);
|
g_strfreev (strs);
|
||||||
|
|
||||||
|
@ -341,12 +341,12 @@ eat_esc_string (char **strlst)
|
||||||
char *str;
|
char *str;
|
||||||
gboolean quoted;
|
gboolean quoted;
|
||||||
GString *gstr;
|
GString *gstr;
|
||||||
|
|
||||||
str = g_strchug (*strlst);
|
str = g_strchug (*strlst);
|
||||||
gstr = g_string_sized_new (strlen(str));
|
gstr = g_string_sized_new (strlen(str));
|
||||||
|
|
||||||
for (quoted = FALSE; *str; ++str) {
|
for (quoted = FALSE; *str; ++str) {
|
||||||
|
|
||||||
if (*str == '"') {
|
if (*str == '"') {
|
||||||
quoted = !quoted;
|
quoted = !quoted;
|
||||||
continue;
|
continue;
|
||||||
|
@ -360,7 +360,7 @@ eat_esc_string (char **strlst)
|
||||||
} else if (*str == ' ') {
|
} else if (*str == ' ') {
|
||||||
++str;
|
++str;
|
||||||
goto leave;
|
goto leave;
|
||||||
} else
|
} else
|
||||||
g_string_append_c (gstr, *str);
|
g_string_append_c (gstr, *str);
|
||||||
}
|
}
|
||||||
leave:
|
leave:
|
||||||
|
@ -377,15 +377,17 @@ GSList*
|
||||||
mu_str_esc_to_list (const char *strings)
|
mu_str_esc_to_list (const char *strings)
|
||||||
{
|
{
|
||||||
GSList *lst;
|
GSList *lst;
|
||||||
char *str, *mystrings, *freeme;
|
char *mystrings, *freeme;
|
||||||
|
const char* cur;
|
||||||
|
|
||||||
g_return_val_if_fail (strings, NULL);
|
g_return_val_if_fail (strings, NULL);
|
||||||
|
|
||||||
freeme = mystrings = g_strdup (strings);
|
for (cur = strings; *cur && (*cur == ' ' || *cur == '\t'); ++cur);
|
||||||
mystrings = g_strdup(g_strchug(mystrings));
|
freeme = mystrings = g_strdup (cur);
|
||||||
lst = NULL;
|
|
||||||
|
lst = NULL;
|
||||||
do {
|
do {
|
||||||
|
gchar *str;
|
||||||
str = eat_esc_string (&mystrings);
|
str = eat_esc_string (&mystrings);
|
||||||
if (str)
|
if (str)
|
||||||
lst = g_slist_prepend (lst, str);
|
lst = g_slist_prepend (lst, str);
|
||||||
|
@ -402,7 +404,7 @@ void
|
||||||
mu_str_free_list (GSList *lst)
|
mu_str_free_list (GSList *lst)
|
||||||
{
|
{
|
||||||
g_slist_foreach (lst, (GFunc)g_free, NULL);
|
g_slist_foreach (lst, (GFunc)g_free, NULL);
|
||||||
g_slist_free (lst);
|
g_slist_free (lst);
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar*
|
const gchar*
|
||||||
|
@ -433,14 +435,9 @@ char*
|
||||||
mu_str_ascii_xapian_escape_in_place (char *query)
|
mu_str_ascii_xapian_escape_in_place (char *query)
|
||||||
{
|
{
|
||||||
gchar *cur;
|
gchar *cur;
|
||||||
gboolean replace_dot;
|
|
||||||
|
|
||||||
g_return_val_if_fail (query, NULL);
|
g_return_val_if_fail (query, NULL);
|
||||||
|
|
||||||
/* only replace the '.' if the string looks like an e-mail
|
|
||||||
* address or msg-id */
|
|
||||||
replace_dot = (g_strstr_len(query, -1, "@") != NULL);
|
|
||||||
|
|
||||||
for (cur = query; *cur; ++cur) {
|
for (cur = query; *cur; ++cur) {
|
||||||
|
|
||||||
*cur = tolower(*cur);
|
*cur = tolower(*cur);
|
||||||
|
@ -451,7 +448,7 @@ mu_str_ascii_xapian_escape_in_place (char *query)
|
||||||
*cur = '_'; break;
|
*cur = '_'; break;
|
||||||
case '.': {
|
case '.': {
|
||||||
/* don't replace a final cur */
|
/* don't replace a final cur */
|
||||||
if (cur[1]== ' ' || cur[1]=='\t' || cur[1]== '.')
|
if (cur[1]== ' ' || cur[1]=='\t' || cur[1]== '.')
|
||||||
++cur;
|
++cur;
|
||||||
else if (cur[1] == '\0')
|
else if (cur[1] == '\0')
|
||||||
break;
|
break;
|
||||||
|
@ -463,13 +460,13 @@ mu_str_ascii_xapian_escape_in_place (char *query)
|
||||||
/* if there's a registered xapian prefix before the
|
/* if there's a registered xapian prefix before the
|
||||||
* ':', don't touch it. Otherwise replace ':' with
|
* ':', don't touch it. Otherwise replace ':' with
|
||||||
* a space'... ugh yuck ugly...
|
* a space'... ugh yuck ugly...
|
||||||
*/
|
*/
|
||||||
if (!is_xapian_prefix (query, cur))
|
if (!is_xapian_prefix (query, cur))
|
||||||
*cur = '_';
|
*cur = '_';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,12 +484,12 @@ const char*
|
||||||
mu_str_fullpath_s (const char* path, const char* name)
|
mu_str_fullpath_s (const char* path, const char* name)
|
||||||
{
|
{
|
||||||
static char buf[PATH_MAX + 1];
|
static char buf[PATH_MAX + 1];
|
||||||
|
|
||||||
g_return_val_if_fail (path, NULL);
|
g_return_val_if_fail (path, NULL);
|
||||||
|
|
||||||
snprintf (buf, sizeof(buf), "%s%c%s", path, G_DIR_SEPARATOR,
|
snprintf (buf, sizeof(buf), "%s%c%s", path, G_DIR_SEPARATOR,
|
||||||
name ? name : "");
|
name ? name : "");
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,14 +499,14 @@ mu_str_escape_c_literal (const gchar* str, gboolean in_quotes)
|
||||||
{
|
{
|
||||||
const char* cur;
|
const char* cur;
|
||||||
GString *tmp;
|
GString *tmp;
|
||||||
|
|
||||||
g_return_val_if_fail (str, NULL);
|
g_return_val_if_fail (str, NULL);
|
||||||
|
|
||||||
tmp = g_string_sized_new (2 * strlen(str));
|
tmp = g_string_sized_new (2 * strlen(str));
|
||||||
|
|
||||||
if (in_quotes)
|
if (in_quotes)
|
||||||
g_string_append_c (tmp, '"');
|
g_string_append_c (tmp, '"');
|
||||||
|
|
||||||
for (cur = str; *cur; ++cur)
|
for (cur = str; *cur; ++cur)
|
||||||
switch (*cur) {
|
switch (*cur) {
|
||||||
case '\\': tmp = g_string_append (tmp, "\\\\"); break;
|
case '\\': tmp = g_string_append (tmp, "\\\\"); break;
|
||||||
|
@ -547,10 +544,10 @@ mu_str_convert_to_utf8 (const char* buffer, const char *charset)
|
||||||
|
|
||||||
g_return_val_if_fail (buffer, NULL);
|
g_return_val_if_fail (buffer, NULL);
|
||||||
g_return_val_if_fail (charset, NULL );
|
g_return_val_if_fail (charset, NULL );
|
||||||
|
|
||||||
err = NULL;
|
err = NULL;
|
||||||
utf8 = g_convert_with_fallback (buffer, -1, "UTF-8",
|
utf8 = g_convert_with_fallback (buffer, -1, "UTF-8",
|
||||||
charset, NULL,
|
charset, NULL,
|
||||||
NULL, NULL, &err);
|
NULL, NULL, &err);
|
||||||
if (!utf8) {
|
if (!utf8) {
|
||||||
g_debug ("%s: conversion failed from %s: %s",
|
g_debug ("%s: conversion failed from %s: %s",
|
||||||
|
@ -558,7 +555,7 @@ mu_str_convert_to_utf8 (const char* buffer, const char *charset)
|
||||||
if (err)
|
if (err)
|
||||||
g_error_free (err);
|
g_error_free (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
return utf8;
|
return utf8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,9 +568,9 @@ mu_str_guess_last_name (const char *name)
|
||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
return g_strdup ("");
|
return g_strdup ("");
|
||||||
|
|
||||||
lastsp = g_strrstr (name, " ");
|
lastsp = g_strrstr (name, " ");
|
||||||
|
|
||||||
return g_strdup (lastsp ? lastsp + 1 : "");
|
return g_strdup (lastsp ? lastsp + 1 : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,7 +582,7 @@ mu_str_guess_first_name (const char *name)
|
||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
return g_strdup ("");
|
return g_strdup ("");
|
||||||
|
|
||||||
lastsp = g_strrstr (name, " ");
|
lastsp = g_strrstr (name, " ");
|
||||||
|
|
||||||
if (lastsp)
|
if (lastsp)
|
||||||
|
@ -603,9 +600,9 @@ cleanup_str (const char* str)
|
||||||
|
|
||||||
if (mu_str_is_empty(str))
|
if (mu_str_is_empty(str))
|
||||||
return g_strdup ("");
|
return g_strdup ("");
|
||||||
|
|
||||||
s = g_new0 (char, strlen(str) + 1);
|
s = g_new0 (char, strlen(str) + 1);
|
||||||
|
|
||||||
for (cur = str, i = 0; *cur; ++cur) {
|
for (cur = str, i = 0; *cur; ++cur) {
|
||||||
if (ispunct(*cur) || isspace(*cur))
|
if (ispunct(*cur) || isspace(*cur))
|
||||||
continue;
|
continue;
|
||||||
|
@ -622,17 +619,17 @@ mu_str_guess_nick (const char* name)
|
||||||
{
|
{
|
||||||
gchar *fname, *lname, *nick;
|
gchar *fname, *lname, *nick;
|
||||||
gchar initial[7];
|
gchar initial[7];
|
||||||
|
|
||||||
fname = mu_str_guess_first_name (name);
|
fname = mu_str_guess_first_name (name);
|
||||||
lname = mu_str_guess_last_name (name);
|
lname = mu_str_guess_last_name (name);
|
||||||
|
|
||||||
/* if there's no last name, use first name as the nick */
|
/* if there's no last name, use first name as the nick */
|
||||||
if (mu_str_is_empty(fname) || mu_str_is_empty(lname)) {
|
if (mu_str_is_empty(fname) || mu_str_is_empty(lname)) {
|
||||||
g_free (lname);
|
g_free (lname);
|
||||||
nick = fname;
|
nick = fname;
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (initial, 0, sizeof(initial));
|
memset (initial, 0, sizeof(initial));
|
||||||
/* couldn't we get an initial for the last name? */
|
/* couldn't we get an initial for the last name? */
|
||||||
if (g_unichar_to_utf8 (g_utf8_get_char (lname), initial) == 0) {
|
if (g_unichar_to_utf8 (g_utf8_get_char (lname), initial) == 0) {
|
||||||
|
@ -644,7 +641,7 @@ mu_str_guess_nick (const char* name)
|
||||||
nick = g_strdup_printf ("%s%s", fname, initial);
|
nick = g_strdup_printf ("%s%s", fname, initial);
|
||||||
g_free (fname);
|
g_free (fname);
|
||||||
g_free (lname);
|
g_free (lname);
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
{
|
{
|
||||||
gchar *tmp;
|
gchar *tmp;
|
||||||
|
@ -652,6 +649,6 @@ leave:
|
||||||
g_free (nick);
|
g_free (nick);
|
||||||
nick = tmp;
|
nick = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nick;
|
return nick;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ mu_threader_calculate (MuMsgIter *iter, size_t matchnum, MuMsgFieldId sortfield)
|
||||||
NULL, FALSE);
|
NULL, FALSE);
|
||||||
|
|
||||||
/* step 5: group root set by subject */
|
/* step 5: group root set by subject */
|
||||||
//group_root_set_by_subject (root_set);
|
/* group_root_set_by_subject (root_set); */
|
||||||
|
|
||||||
/* sort */
|
/* sort */
|
||||||
mu_msg_iter_reset (iter); /* go all the way back */
|
mu_msg_iter_reset (iter); /* go all the way back */
|
||||||
|
|
|
@ -418,9 +418,10 @@ enum _MuError {
|
||||||
MU_ERROR_FILE_INVALID_SOURCE = 79,
|
MU_ERROR_FILE_INVALID_SOURCE = 79,
|
||||||
MU_ERROR_FILE_TARGET_EQUALS_SOURCE = 80,
|
MU_ERROR_FILE_TARGET_EQUALS_SOURCE = 80,
|
||||||
MU_ERROR_FILE_CANNOT_WRITE = 81,
|
MU_ERROR_FILE_CANNOT_WRITE = 81,
|
||||||
|
MU_ERROR_FILE_CANNOT_UNLINK = 82,
|
||||||
|
|
||||||
/* not really an error, used in callbacks */
|
/* not really an error, used in callbacks */
|
||||||
MU_STOP = 99,
|
MU_STOP = 99
|
||||||
};
|
};
|
||||||
typedef enum _MuError MuError;
|
typedef enum _MuError MuError;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue