* minor / cosmetic changes

This commit is contained in:
Dirk-Jan C. Binnema 2011-09-12 20:38:40 +03:00
parent 1a7414dd6d
commit 628d154a2c
11 changed files with 245 additions and 206 deletions

View File

@ -272,7 +272,7 @@ AS_IF([test "x$PMCCABE" = "xno"],[
*** Please install it if you want to run the automated code checks])
],[have_pmccabe="yes"])
#toys/procmule/Makefile
AC_CONFIG_FILES([
Makefile
@ -284,6 +284,7 @@ toys/Makefile
toys/mug/Makefile
toys/mug2/Makefile
toys/muile/Makefile
toys/procmule/Makefile
man/Makefile
m4/Makefile
contrib/Makefile

View File

@ -42,9 +42,7 @@ get_query (void)
if (!query) {
mu_guile_g_error ("<internal error>", err);
if (err)
g_error_free (err);
return NULL;
g_clear_error (&err);
}
return query;
@ -60,10 +58,9 @@ get_query_iter (MuQuery *query, const char* expr)
err = NULL;
iter = mu_query_run (query, expr,
FALSE, MU_MSG_FIELD_ID_NONE, TRUE, &err);
if (err) {
if (!iter) {
mu_guile_g_error ("<internal error>", err);
g_error_free (err);
return NULL;
g_clear_error (&err);
}
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));
scm_call_1 (FUNC, msgsmob);
}

View File

@ -53,7 +53,7 @@ enum _MuConfigFormat {
/* for find */
MU_CONFIG_FORMAT_LINKS, /* output as symlinks */
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;
@ -72,7 +72,7 @@ enum _MuConfigCmd {
MU_CONFIG_CMD_REMOVE,
MU_CONFIG_CMD_SERVER,
MU_CONFIG_CMD_NONE,
MU_CONFIG_CMD_NONE
};
typedef enum _MuConfigCmd MuConfigCmd;

View File

@ -359,7 +359,11 @@ mu_container_sort (MuContainer *c, MuMsgFieldId mfid, gpointer user_data,
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 (mu_msg_field_id_is_valid(mfid), NULL);

View File

@ -137,26 +137,29 @@ insert_or_update_maybe (const char* fullpath, const char* mdir,
err = NULL;
msg = mu_msg_new_from_file (fullpath, mdir, &err);
if ((G_UNLIKELY(!msg))) {
g_warning ("%s: failed to create mu_msg for %s",
__FUNCTION__, fullpath);
return MU_ERROR;
}
if ((G_UNLIKELY(!msg)))
goto errexit;
/* we got a valid id; scan the message contents as well */
if (G_UNLIKELY((!mu_store_store_msg (data->_store, msg, TRUE)))) {
g_warning ("%s: storing content %s failed", __FUNCTION__,
fullpath);
return MU_ERROR;
}
if (G_UNLIKELY((!mu_store_add_msg (data->_store, msg, TRUE, &err))))
goto errexit;
mu_msg_unref (msg);
*updated = TRUE;
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)
{
MuError result;

View File

@ -235,7 +235,8 @@ log_write (const char* domain, GLogLevelFlags level,
/* get the time/date string */
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 */
len = snprintf (buf, sizeof(buf), "%s [%s] %s\n", timebuf,

View File

@ -102,7 +102,18 @@ mu_msg_part_foreach (MuMsg *msg, MuMsgPartForeachFunc func,
PartData pdata;
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));
pdata._msg = msg;
@ -117,7 +128,7 @@ mu_msg_part_foreach (MuMsg *msg, MuMsgPartForeachFunc func,
static gboolean
write_to_stream (GMimeObject *part, int fd)
write_to_stream (GMimeObject *part, int fd, GError **err)
{
GMimeStream *stream;
GMimeDataWrapper *wrapper;
@ -125,14 +136,16 @@ write_to_stream (GMimeObject *part, int fd)
stream = g_mime_stream_fs_new (fd);
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;
}
g_mime_stream_fs_set_owner (GMIME_STREAM_FS(stream), FALSE);
wrapper = g_mime_part_get_content_object (GMIME_PART(part));
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);
return FALSE;
}
@ -141,7 +154,8 @@ write_to_stream (GMimeObject *part, int fd)
rv = g_mime_data_wrapper_write_to_stream (wrapper, stream);
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 (stream);
@ -171,15 +185,15 @@ save_part (GMimeObject *part, const char *fullpath,
return FALSE;
}
rv = write_to_stream (part, fd);
if (close (fd) != 0) {
rv = write_to_stream (part, fd, err);
if (close (fd) != 0 && !err) { /* don't write on top of old err */
g_set_error (err, 0, MU_ERROR_FILE,
"could not close '%s': %s",
fullpath, errno ? strerror(errno) : "error");
return FALSE;
}
return TRUE;
return rv;
}

View File

@ -161,6 +161,8 @@ const char* mu_store_version (MuStore *store);
*/
void mu_store_flush (MuStore *store);
#define MU_STORE_INVALID_DOCID 0
/**
* 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'
* 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
@ -185,12 +188,13 @@ gboolean mu_store_store_msg (MuStore *store, MuMsg *msg, gboolean replace);
* @param store a valid store
* @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 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);
/**
* 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
#endif /*__MU_STORE_H__*/

View File

@ -377,15 +377,17 @@ GSList*
mu_str_esc_to_list (const char *strings)
{
GSList *lst;
char *str, *mystrings, *freeme;
char *mystrings, *freeme;
const char* cur;
g_return_val_if_fail (strings, NULL);
freeme = mystrings = g_strdup (strings);
mystrings = g_strdup(g_strchug(mystrings));
lst = NULL;
for (cur = strings; *cur && (*cur == ' ' || *cur == '\t'); ++cur);
freeme = mystrings = g_strdup (cur);
lst = NULL;
do {
gchar *str;
str = eat_esc_string (&mystrings);
if (str)
lst = g_slist_prepend (lst, str);
@ -433,14 +435,9 @@ char*
mu_str_ascii_xapian_escape_in_place (char *query)
{
gchar *cur;
gboolean replace_dot;
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) {
*cur = tolower(*cur);

View File

@ -85,7 +85,7 @@ mu_threader_calculate (MuMsgIter *iter, size_t matchnum, MuMsgFieldId sortfield)
NULL, FALSE);
/* step 5: group root set by subject */
//group_root_set_by_subject (root_set);
/* group_root_set_by_subject (root_set); */
/* sort */
mu_msg_iter_reset (iter); /* go all the way back */

View File

@ -418,9 +418,10 @@ enum _MuError {
MU_ERROR_FILE_INVALID_SOURCE = 79,
MU_ERROR_FILE_TARGET_EQUALS_SOURCE = 80,
MU_ERROR_FILE_CANNOT_WRITE = 81,
MU_ERROR_FILE_CANNOT_UNLINK = 82,
/* not really an error, used in callbacks */
MU_STOP = 99,
MU_STOP = 99
};
typedef enum _MuError MuError;