mirror of https://github.com/djcb/mu.git
* MuResult/MuExitCode => MuError
This commit is contained in:
parent
4a995b509c
commit
e55eb4ed25
|
@ -165,7 +165,7 @@ each_contact (const char *email, const char *name, time_t tstamp,
|
|||
}
|
||||
|
||||
|
||||
static MuExitCode
|
||||
static MuError
|
||||
run_cmd_cfind (const char* pattern, MuConfigFormat format,
|
||||
gboolean color)
|
||||
{
|
||||
|
@ -177,24 +177,21 @@ run_cmd_cfind (const char* pattern, MuConfigFormat format,
|
|||
contacts = mu_contacts_new (mu_runtime_path(MU_RUNTIME_PATH_CONTACTS));
|
||||
if (!contacts) {
|
||||
g_warning ("could not retrieve contacts");
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_CONTACTS_CANNOT_RETRIEVE;
|
||||
}
|
||||
|
||||
print_header (format);
|
||||
rv = mu_contacts_foreach (contacts,
|
||||
(MuContactsForeachFunc)each_contact,
|
||||
&ecdata, pattern, &num);
|
||||
|
||||
mu_contacts_destroy (contacts);
|
||||
|
||||
if (num == 0) {
|
||||
g_warning ("no matching contacts found");
|
||||
return MU_EXITCODE_NO_MATCHES;
|
||||
return MU_ERROR_NO_MATCHES;
|
||||
}
|
||||
|
||||
return rv ? MU_EXITCODE_OK : MU_EXITCODE_ERROR;
|
||||
|
||||
|
||||
return rv ? MU_OK : MU_ERROR_CONTACTS;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -225,15 +222,15 @@ cfind_params_valid (MuConfig *opts)
|
|||
}
|
||||
|
||||
|
||||
MuExitCode
|
||||
MuError
|
||||
mu_cmd_cfind (MuConfig *opts)
|
||||
{
|
||||
g_return_val_if_fail (opts, MU_EXITCODE_ERROR);
|
||||
g_return_val_if_fail (opts, MU_ERROR_INTERNAL);
|
||||
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_CFIND,
|
||||
MU_EXITCODE_ERROR);
|
||||
MU_ERROR_INTERNAL);
|
||||
|
||||
if (!cfind_params_valid (opts))
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_IN_PARAMETERS;
|
||||
|
||||
return run_cmd_cfind (opts->params[1], opts->format, opts->color);
|
||||
}
|
||||
|
|
|
@ -381,17 +381,17 @@ check_params (MuConfig *opts)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
MuExitCode
|
||||
MuError
|
||||
mu_cmd_extract (MuConfig *opts)
|
||||
{
|
||||
int rv;
|
||||
|
||||
g_return_val_if_fail (opts, MU_EXITCODE_ERROR);
|
||||
g_return_val_if_fail (opts, MU_ERROR_INTERNAL);
|
||||
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_EXTRACT,
|
||||
MU_EXITCODE_ERROR);
|
||||
MU_ERROR_INTERNAL);
|
||||
|
||||
if (!check_params (opts))
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_IN_PARAMETERS;
|
||||
|
||||
if (!opts->params[2] && !opts->parts &&
|
||||
!opts->save_attachments && !opts->save_all)
|
||||
|
@ -407,5 +407,5 @@ mu_cmd_extract (MuConfig *opts)
|
|||
opts); /* save */
|
||||
}
|
||||
|
||||
return rv ? MU_EXITCODE_OK : MU_EXITCODE_ERROR;
|
||||
return rv ? MU_OK : MU_ERROR;
|
||||
}
|
||||
|
|
|
@ -808,7 +808,7 @@ output_xml (MuMsgIter *iter, gboolean include_unreadable, size_t *count)
|
|||
}
|
||||
|
||||
|
||||
MuExitCode
|
||||
MuError
|
||||
mu_cmd_find (MuConfig *opts)
|
||||
{
|
||||
MuQuery *xapian;
|
||||
|
@ -816,17 +816,18 @@ mu_cmd_find (MuConfig *opts)
|
|||
gchar *query;
|
||||
size_t count = 0;
|
||||
|
||||
g_return_val_if_fail (opts, FALSE);
|
||||
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_FIND, FALSE);
|
||||
g_return_val_if_fail (opts, MU_ERROR_INTERNAL);
|
||||
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_FIND,
|
||||
MU_ERROR_INTERNAL);
|
||||
|
||||
if (!query_params_valid (opts) || !format_params_valid(opts))
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_IN_PARAMETERS;
|
||||
|
||||
xapian = get_query_obj();
|
||||
query = get_query (opts);
|
||||
|
||||
if (!xapian ||!query)
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_INTERNAL;
|
||||
|
||||
if (opts->format == MU_CONFIG_FORMAT_XQUERY)
|
||||
rv = print_xapian_query (xapian, query, &count);
|
||||
|
@ -839,7 +840,7 @@ mu_cmd_find (MuConfig *opts)
|
|||
g_free (query);
|
||||
|
||||
if (!rv)
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR;
|
||||
|
||||
return count == 0 ? MU_EXITCODE_NO_MATCHES : MU_EXITCODE_OK;
|
||||
return count == 0 ? MU_ERROR_NO_MATCHES : MU_OK;
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ check_maildir (const char *maildir)
|
|||
}
|
||||
|
||||
|
||||
static MuResult
|
||||
static MuError
|
||||
index_msg_silent_cb (MuIndexStats* stats, void *user_data)
|
||||
{
|
||||
return MU_CAUGHT_SIGNAL ? MU_STOP: MU_OK;
|
||||
|
@ -180,7 +180,7 @@ print_stats (MuIndexStats* stats, gboolean clear)
|
|||
}
|
||||
|
||||
|
||||
static MuResult
|
||||
static MuError
|
||||
index_msg_cb (MuIndexStats* stats, void *user_data)
|
||||
{
|
||||
if (stats->_processed % 25)
|
||||
|
@ -271,11 +271,11 @@ update_maildir_path_maybe (MuIndex *idx, MuConfig *opts)
|
|||
}
|
||||
|
||||
|
||||
static MuExitCode
|
||||
static MuError
|
||||
cmd_cleanup (MuIndex *midx, MuConfig *opts, MuIndexStats *stats,
|
||||
gboolean show_progress)
|
||||
{
|
||||
MuResult rv;
|
||||
MuError rv;
|
||||
time_t t;
|
||||
|
||||
g_message ("cleaning up messages [%s]",
|
||||
|
@ -292,17 +292,16 @@ cmd_cleanup (MuIndex *midx, MuConfig *opts, MuIndexStats *stats,
|
|||
show_time ((unsigned)(time(NULL)-t),stats->_processed);
|
||||
}
|
||||
|
||||
return (rv == MU_OK || rv == MU_STOP) ?
|
||||
MU_EXITCODE_OK: MU_EXITCODE_ERROR;
|
||||
return (rv == MU_OK || rv == MU_STOP) ? MU_OK: MU_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static MuExitCode
|
||||
static MuError
|
||||
cmd_index (MuIndex *midx, MuConfig *opts, MuIndexStats *stats,
|
||||
gboolean show_progress)
|
||||
{
|
||||
MuResult rv;
|
||||
MuError rv;
|
||||
time_t t;
|
||||
|
||||
g_message ("indexing messages under %s [%s]", opts->maildir,
|
||||
|
@ -329,38 +328,38 @@ cmd_index (MuIndex *midx, MuConfig *opts, MuIndexStats *stats,
|
|||
if (rv == MU_OK) {
|
||||
MU_WRITE_LOG ("cleanup: processed: %u; cleaned-up: %u",
|
||||
stats->_processed, stats->_cleaned_up);
|
||||
return MU_EXITCODE_OK;
|
||||
return MU_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return (rv==MU_OK||rv==MU_STOP) ? MU_EXITCODE_OK : MU_EXITCODE_ERROR;
|
||||
return (rv==MU_OK||rv==MU_STOP) ? MU_OK : MU_ERROR;
|
||||
}
|
||||
|
||||
static MuExitCode
|
||||
static MuError
|
||||
handle_index_error_and_free (GError *err)
|
||||
{
|
||||
MuExitCode code;
|
||||
MuError code;
|
||||
|
||||
if (!err)
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_INTERNAL;
|
||||
|
||||
switch (err->code) {
|
||||
|
||||
case MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK:
|
||||
g_warning ("cannot get Xapian writelock");
|
||||
g_warning ("maybe mu index is already running?");
|
||||
code = MU_EXITCODE_DB_LOCKED;
|
||||
code = MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK;
|
||||
break;
|
||||
|
||||
case MU_ERROR_XAPIAN_CORRUPTION:
|
||||
g_warning ("xapian database seems to be corrupted");
|
||||
g_warning ("try 'mu index --rebuild");
|
||||
code = MU_EXITCODE_DB_CORRUPTED;
|
||||
code = MU_ERROR_XAPIAN_CORRUPTION;
|
||||
break;
|
||||
default:
|
||||
g_warning ("indexing error: %s",
|
||||
err->message ? err->message : "");
|
||||
code = MU_EXITCODE_ERROR;
|
||||
code = MU_ERROR;
|
||||
}
|
||||
|
||||
g_error_free (err);
|
||||
|
@ -368,14 +367,18 @@ handle_index_error_and_free (GError *err)
|
|||
}
|
||||
|
||||
static MuIndex*
|
||||
init_mu_index (MuConfig *opts, MuExitCode *code)
|
||||
init_mu_index (MuConfig *opts, MuError *code)
|
||||
{
|
||||
MuIndex *midx;
|
||||
GError *err;
|
||||
|
||||
if (!check_index_or_cleanup_params (opts) ||
|
||||
!database_version_check_and_update(opts)) {
|
||||
*code = MU_EXITCODE_ERROR;
|
||||
if (!check_index_or_cleanup_params (opts)) {
|
||||
*code = MU_ERROR_IN_PARAMETERS;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!database_version_check_and_update(opts)) {
|
||||
*code = MU_ERROR_XAPIAN_NOT_UP_TO_DATE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -395,13 +398,13 @@ init_mu_index (MuConfig *opts, MuExitCode *code)
|
|||
}
|
||||
|
||||
|
||||
static MuExitCode
|
||||
static MuError
|
||||
cmd_index_or_cleanup (MuConfig *opts)
|
||||
{
|
||||
MuIndex *midx;
|
||||
MuIndexStats stats;
|
||||
gboolean rv, show_progress;
|
||||
MuExitCode code;
|
||||
MuError code;
|
||||
|
||||
/* create, and do error handling if needed */
|
||||
midx = init_mu_index (opts, &code);
|
||||
|
@ -412,7 +415,7 @@ cmd_index_or_cleanup (MuConfig *opts)
|
|||
* mu_index_last_used_maildir
|
||||
*/
|
||||
if (!update_maildir_path_maybe (midx, opts))
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_FILE;
|
||||
|
||||
/* note, 'opts->quiet' already cause g_message output not to
|
||||
* be shown; here, we make sure we only print progress info if
|
||||
|
@ -428,7 +431,7 @@ cmd_index_or_cleanup (MuConfig *opts)
|
|||
case MU_CONFIG_CMD_CLEANUP:
|
||||
rv = cmd_cleanup (midx, opts, &stats, show_progress); break;
|
||||
default:
|
||||
rv = MU_EXITCODE_ERROR;
|
||||
rv = MU_ERROR_INTERNAL;
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
|
@ -437,7 +440,7 @@ cmd_index_or_cleanup (MuConfig *opts)
|
|||
}
|
||||
|
||||
|
||||
MuExitCode
|
||||
MuError
|
||||
mu_cmd_index (MuConfig *opts)
|
||||
{
|
||||
g_return_val_if_fail (opts, FALSE);
|
||||
|
@ -447,12 +450,12 @@ mu_cmd_index (MuConfig *opts)
|
|||
return cmd_index_or_cleanup (opts);
|
||||
}
|
||||
|
||||
MuExitCode
|
||||
MuError
|
||||
mu_cmd_cleanup (MuConfig *opts)
|
||||
{
|
||||
g_return_val_if_fail (opts, MU_EXITCODE_ERROR);
|
||||
g_return_val_if_fail (opts, MU_ERROR_INTERNAL);
|
||||
g_return_val_if_fail (opts->cmd != MU_CONFIG_CMD_CLEANUP,
|
||||
MU_EXITCODE_ERROR);
|
||||
MU_ERROR_INTERNAL);
|
||||
|
||||
return cmd_index_or_cleanup (opts);
|
||||
}
|
||||
|
|
92
src/mu-cmd.c
92
src/mu-cmd.c
|
@ -163,7 +163,7 @@ view_msg_plain (MuMsg *msg, const gchar *fields, gboolean summary,
|
|||
|
||||
|
||||
static gboolean
|
||||
handle_msg (const char *fname, MuConfig *opts, MuExitCode *code)
|
||||
handle_msg (const char *fname, MuConfig *opts, MuError *code)
|
||||
{
|
||||
GError *err;
|
||||
MuMsg *msg;
|
||||
|
@ -175,7 +175,7 @@ handle_msg (const char *fname, MuConfig *opts, MuExitCode *code)
|
|||
if (!msg) {
|
||||
g_warning ("error: %s", err->message);
|
||||
g_error_free (err);
|
||||
*code = MU_EXITCODE_ERROR;
|
||||
*code = MU_ERROR;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ handle_msg (const char *fname, MuConfig *opts, MuExitCode *code)
|
|||
break;
|
||||
default:
|
||||
g_critical ("bug: should not be reached");
|
||||
*code = MU_EXITCODE_ERROR;
|
||||
*code = MU_ERROR_INTERNAL;
|
||||
rv = FALSE;
|
||||
}
|
||||
|
||||
|
@ -220,21 +220,21 @@ view_params_valid (MuConfig *opts)
|
|||
}
|
||||
|
||||
|
||||
MuExitCode
|
||||
MuError
|
||||
mu_cmd_view (MuConfig *opts)
|
||||
{
|
||||
int i;
|
||||
gboolean rv;
|
||||
MuExitCode code;
|
||||
MuError code;
|
||||
|
||||
g_return_val_if_fail (opts, MU_EXITCODE_ERROR);
|
||||
g_return_val_if_fail (opts, MU_ERROR_INTERNAL);
|
||||
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_VIEW,
|
||||
MU_EXITCODE_ERROR);
|
||||
MU_ERROR_INTERNAL);
|
||||
|
||||
if (!view_params_valid(opts))
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_IN_PARAMETERS;
|
||||
|
||||
for (i = 1, code = MU_EXITCODE_OK; opts->params[i]; ++i) {
|
||||
for (i = 1, code = MU_OK; opts->params[i]; ++i) {
|
||||
|
||||
rv = handle_msg (opts->params[i], opts, &code);
|
||||
if (!rv)
|
||||
|
@ -248,19 +248,19 @@ mu_cmd_view (MuConfig *opts)
|
|||
}
|
||||
|
||||
|
||||
MuExitCode
|
||||
MuError
|
||||
mu_cmd_mkdir (MuConfig *opts)
|
||||
{
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (opts, MU_EXITCODE_ERROR);
|
||||
g_return_val_if_fail (opts, MU_ERROR_INTERNAL);
|
||||
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_MKDIR,
|
||||
MU_EXITCODE_ERROR);
|
||||
MU_ERROR_INTERNAL);
|
||||
|
||||
if (!opts->params[1]) {
|
||||
g_warning ("usage: mu mkdir [-u,--mode=<mode>] "
|
||||
"<dir> [more dirs]");
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_IN_PARAMETERS;
|
||||
}
|
||||
|
||||
for (i = 1; opts->params[i]; ++i) {
|
||||
|
@ -274,11 +274,11 @@ mu_cmd_mkdir (MuConfig *opts)
|
|||
g_warning ("%s", err->message);
|
||||
g_error_free (err);
|
||||
}
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return MU_EXITCODE_OK;
|
||||
return MU_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -291,37 +291,33 @@ mv_check_params (MuConfig *opts, MuMsgFlags *flags)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* FIXME: check for invalid flags */
|
||||
if (!opts->flagstr)
|
||||
*flags = MU_MSG_FLAG_NONE;
|
||||
else {
|
||||
*flags = MU_MSG_FLAG_INVALID; /* ie., ignore flags */
|
||||
else
|
||||
*flags = mu_msg_flags_from_str (opts->flagstr);
|
||||
if (*flags == MU_MSG_FLAG_NONE) {
|
||||
g_warning ("error in flags");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static MuExitCode
|
||||
static MuError
|
||||
cmd_mv_dev_null (MuConfig *opts)
|
||||
{
|
||||
if (unlink (opts->params[1]) != 0) {
|
||||
g_warning ("unlink failed: %s", strerror (errno));
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_FILE;
|
||||
}
|
||||
|
||||
if (opts->printtarget)
|
||||
g_print ("/dev/null\n"); /* /dev/null */
|
||||
|
||||
return MU_EXITCODE_OK;
|
||||
return MU_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
MuExitCode
|
||||
MuError
|
||||
mu_cmd_mv (MuConfig *opts)
|
||||
{
|
||||
GError *err;
|
||||
|
@ -329,31 +325,35 @@ mu_cmd_mv (MuConfig *opts)
|
|||
MuMsgFlags flags;
|
||||
|
||||
if (!mv_check_params (opts, &flags))
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_IN_PARAMETERS;
|
||||
|
||||
/* special case: /dev/null */
|
||||
if (g_strcmp0 (opts->params[2], "/dev/null") == 0)
|
||||
return cmd_mv_dev_null (opts);
|
||||
|
||||
err = NULL;
|
||||
fullpath = mu_msg_file_move_to_maildir (opts->params[1], opts->params[2],
|
||||
fullpath = mu_msg_file_move_to_maildir (opts->params[1],
|
||||
opts->params[2],
|
||||
flags, &err);
|
||||
if (!fullpath) {
|
||||
if (err) {
|
||||
MuError code;
|
||||
code = err->code;
|
||||
g_warning ("move failed: %s", err->message);
|
||||
g_error_free (err);
|
||||
return code;
|
||||
}
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_FILE;
|
||||
|
||||
} else {
|
||||
if (opts->printtarget)
|
||||
g_print ("%s\n", fullpath);
|
||||
return MU_EXITCODE_OK;
|
||||
return MU_OK;
|
||||
}
|
||||
|
||||
g_free (fullpath);
|
||||
|
||||
return MU_EXITCODE_OK;
|
||||
return MU_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -399,26 +399,26 @@ get_store (void)
|
|||
|
||||
|
||||
|
||||
MuExitCode
|
||||
MuError
|
||||
mu_cmd_add (MuConfig *opts)
|
||||
{
|
||||
MuStore *store;
|
||||
gboolean allok;
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (opts, MU_EXITCODE_ERROR);
|
||||
g_return_val_if_fail (opts, MU_ERROR_INTERNAL);
|
||||
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_ADD,
|
||||
MU_EXITCODE_ERROR);
|
||||
MU_ERROR_INTERNAL);
|
||||
|
||||
/* note: params[0] will be 'add' */
|
||||
if (!opts->params[0] || !opts->params[1]) {
|
||||
g_warning ("usage: mu add <file> [<files>]");
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_IN_PARAMETERS;
|
||||
}
|
||||
|
||||
store = get_store ();
|
||||
if (!store)
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_INTERNAL;
|
||||
|
||||
for (i = 1, allok = TRUE; opts->params[i]; ++i) {
|
||||
|
||||
|
@ -438,30 +438,30 @@ mu_cmd_add (MuConfig *opts)
|
|||
|
||||
mu_store_destroy (store);
|
||||
|
||||
return allok ? MU_EXITCODE_OK : MU_EXITCODE_ERROR;
|
||||
return allok ? MU_OK : MU_ERROR;
|
||||
}
|
||||
|
||||
|
||||
MuExitCode
|
||||
MuError
|
||||
mu_cmd_remove (MuConfig *opts)
|
||||
{
|
||||
MuStore *store;
|
||||
gboolean allok;
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (opts, MU_EXITCODE_ERROR);
|
||||
g_return_val_if_fail (opts, MU_ERROR_INTERNAL);
|
||||
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_REMOVE,
|
||||
MU_EXITCODE_ERROR);
|
||||
MU_ERROR_INTERNAL);
|
||||
|
||||
/* note: params[0] will be 'add' */
|
||||
if (!opts->params[0] || !opts->params[1]) {
|
||||
g_warning ("usage: mu remove <file> [<files>]");
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_IN_PARAMETERS;
|
||||
}
|
||||
|
||||
store = get_store ();
|
||||
if (!store)
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_INTERNAL;
|
||||
|
||||
for (i = 1, allok = TRUE; opts->params[i]; ++i) {
|
||||
|
||||
|
@ -481,9 +481,5 @@ mu_cmd_remove (MuConfig *opts)
|
|||
|
||||
mu_store_destroy (store);
|
||||
|
||||
return allok ? MU_EXITCODE_OK : MU_EXITCODE_ERROR;
|
||||
return allok ? MU_OK : MU_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
20
src/mu-cmd.h
20
src/mu-cmd.h
|
@ -36,7 +36,7 @@ G_BEGIN_DECLS
|
|||
* @return MU_EXITCODE_OK (0) if the command succeeded,
|
||||
* MU_EXITCODE_ERROR otherwise
|
||||
*/
|
||||
MuExitCode mu_cmd_mkdir (MuConfig *opts);
|
||||
MuError mu_cmd_mkdir (MuConfig *opts);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,7 @@ MuExitCode mu_cmd_mkdir (MuConfig *opts);
|
|||
* @return MU_EXITCODE_OK (0) if the command succeeded,
|
||||
* MU_EXITCODE_ERROR otherwise
|
||||
*/
|
||||
MuExitCode mu_cmd_view (MuConfig *opts);
|
||||
MuError mu_cmd_view (MuConfig *opts);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -58,7 +58,7 @@ MuExitCode mu_cmd_view (MuConfig *opts);
|
|||
* @return MU_EXITCODE_OK (0) if the command succeeded,
|
||||
* MU_EXITCODE_ERROR otherwise
|
||||
*/
|
||||
MuExitCode mu_cmd_index (MuConfig *opts);
|
||||
MuError mu_cmd_index (MuConfig *opts);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -69,7 +69,7 @@ MuExitCode mu_cmd_index (MuConfig *opts);
|
|||
* @return MU_EXITCODE_OK (0) if the command succeeds,
|
||||
* MU_EXITCODE_ERROR otherwise
|
||||
*/
|
||||
MuExitCode mu_cmd_cleanup (MuConfig *opts);
|
||||
MuError mu_cmd_cleanup (MuConfig *opts);
|
||||
|
||||
/**
|
||||
* execute the 'find' command
|
||||
|
@ -80,7 +80,7 @@ MuExitCode mu_cmd_cleanup (MuConfig *opts);
|
|||
* >MU_EXITCODE_OK (0) results, MU_EXITCODE_NO_MATCHES if the command
|
||||
* succeeds but there no matches, MU_EXITCODE_ERROR for all other errors
|
||||
*/
|
||||
MuExitCode mu_cmd_find (MuConfig *opts);
|
||||
MuError mu_cmd_find (MuConfig *opts);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -91,7 +91,7 @@ MuExitCode mu_cmd_find (MuConfig *opts);
|
|||
* @return MU_EXITCODE_OK (0) if the command succeeds,
|
||||
* MU_EXITCODE_ERROR otherwise
|
||||
*/
|
||||
MuExitCode mu_cmd_extract (MuConfig *opts);
|
||||
MuError mu_cmd_extract (MuConfig *opts);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -102,7 +102,7 @@ MuExitCode mu_cmd_extract (MuConfig *opts);
|
|||
* @return MU_EXITCODE_OK (0) if the command succeeds,
|
||||
* MU_EXITCODE_ERROR otherwise
|
||||
*/
|
||||
MuExitCode mu_cmd_mv (MuConfig *opts);
|
||||
MuError mu_cmd_mv (MuConfig *opts);
|
||||
|
||||
|
||||
|
||||
|
@ -115,7 +115,7 @@ MuExitCode mu_cmd_mv (MuConfig *opts);
|
|||
* @return MU_EXITCODE_OK (0) if the command succeeds,
|
||||
* MU_EXITCODE_ERROR otherwise
|
||||
*/
|
||||
MuExitCode mu_cmd_cfind (MuConfig *opts);
|
||||
MuError mu_cmd_cfind (MuConfig *opts);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -126,7 +126,7 @@ MuExitCode mu_cmd_cfind (MuConfig *opts);
|
|||
* @return MU_EXITCODE_OK (0) if the command succeeds,
|
||||
* MU_EXITCODE_ERROR otherwise
|
||||
*/
|
||||
MuExitCode mu_cmd_add (MuConfig *opts);
|
||||
MuError mu_cmd_add (MuConfig *opts);
|
||||
|
||||
/**
|
||||
* execute the remove command
|
||||
|
@ -136,7 +136,7 @@ MuExitCode mu_cmd_add (MuConfig *opts);
|
|||
* @return MU_EXITCODE_OK (0) if the command succeeds,
|
||||
* MU_EXITCODE_ERROR otherwise
|
||||
*/
|
||||
MuExitCode mu_cmd_remove (MuConfig *opts);
|
||||
MuError mu_cmd_remove (MuConfig *opts);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
||||
|
||||
/*
|
||||
** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||
**
|
||||
|
@ -538,21 +539,21 @@ show_version (void)
|
|||
}
|
||||
|
||||
|
||||
MuExitCode
|
||||
MuError
|
||||
mu_config_execute (MuConfig *opts)
|
||||
{
|
||||
g_return_val_if_fail (opts, MU_EXITCODE_ERROR);
|
||||
g_return_val_if_fail (opts, MU_ERROR_INTERNAL);
|
||||
|
||||
if (opts->version) {
|
||||
show_version ();
|
||||
return MU_EXITCODE_OK;
|
||||
return MU_OK;
|
||||
}
|
||||
|
||||
if (!opts->params||!opts->params[0]) {/* no command? */
|
||||
show_version ();
|
||||
g_print ("\n");
|
||||
show_usage (TRUE);
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_IN_PARAMETERS;
|
||||
}
|
||||
|
||||
switch (opts->cmd) {
|
||||
|
@ -570,9 +571,9 @@ mu_config_execute (MuConfig *opts)
|
|||
case MU_CONFIG_CMD_UNKNOWN:
|
||||
g_printerr ("mu: unknown command '%s'\n\n", opts->cmdstr);
|
||||
show_usage (FALSE);
|
||||
return MU_EXITCODE_ERROR;
|
||||
return MU_ERROR_IN_PARAMETERS;
|
||||
default:
|
||||
g_return_val_if_reached (MU_EXITCODE_ERROR);
|
||||
g_return_val_if_reached (MU_ERROR_INTERNAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -179,10 +179,10 @@ void mu_config_destroy (MuConfig *opts);
|
|||
* @param opts the commands/options
|
||||
*
|
||||
* @return a value denoting the success/failure of the execution;
|
||||
* MU_CONFIG_RETVAL_OK (0) for success, non-zero for a failure. This
|
||||
* is to used for the exit code of the process
|
||||
* MU_ERROR_NONE (0) for success, non-zero for a failure. This is to used for
|
||||
* the exit code of the process
|
||||
*/
|
||||
MuExitCode mu_config_execute (MuConfig *opts);
|
||||
MuError mu_config_execute (MuConfig *opts);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -129,7 +129,7 @@ needs_index (MuIndexCallbackData *data, const char *fullpath,
|
|||
}
|
||||
|
||||
|
||||
static MuResult
|
||||
static MuError
|
||||
insert_or_update_maybe (const char* fullpath, const char* mdir,
|
||||
time_t filestamp, MuIndexCallbackData *data,
|
||||
gboolean *updated)
|
||||
|
@ -162,10 +162,10 @@ insert_or_update_maybe (const char* fullpath, const char* mdir,
|
|||
return MU_OK;
|
||||
}
|
||||
|
||||
static MuResult
|
||||
static MuError
|
||||
run_msg_callback_maybe (MuIndexCallbackData *data)
|
||||
{
|
||||
MuResult result;
|
||||
MuError result;
|
||||
|
||||
if (!data || !data->_idx_msg_cb)
|
||||
return MU_OK;
|
||||
|
@ -178,11 +178,11 @@ run_msg_callback_maybe (MuIndexCallbackData *data)
|
|||
}
|
||||
|
||||
|
||||
static MuResult
|
||||
static MuError
|
||||
on_run_maildir_msg (const char* fullpath, const char* mdir,
|
||||
struct stat *statbuf, MuIndexCallbackData *data)
|
||||
{
|
||||
MuResult result;
|
||||
MuError result;
|
||||
gboolean updated;
|
||||
|
||||
/* protect against too big messages */
|
||||
|
@ -211,7 +211,7 @@ on_run_maildir_msg (const char* fullpath, const char* mdir,
|
|||
}
|
||||
|
||||
|
||||
static MuResult
|
||||
static MuError
|
||||
on_run_maildir_dir (const char* fullpath, gboolean enter,
|
||||
MuIndexCallbackData *data)
|
||||
{
|
||||
|
@ -321,14 +321,14 @@ mu_index_set_xbatch_size (MuIndex *index, guint xbatchsize)
|
|||
|
||||
|
||||
|
||||
MuResult
|
||||
MuError
|
||||
mu_index_run (MuIndex *index, const char* path,
|
||||
gboolean reindex, MuIndexStats *stats,
|
||||
MuIndexMsgCallback msg_cb, MuIndexDirCallback dir_cb,
|
||||
void *user_data)
|
||||
{
|
||||
MuIndexCallbackData cb_data;
|
||||
MuResult rv;
|
||||
MuError rv;
|
||||
|
||||
g_return_val_if_fail (index && index->_store, MU_ERROR);
|
||||
g_return_val_if_fail (msg_cb, MU_ERROR);
|
||||
|
@ -357,12 +357,12 @@ mu_index_run (MuIndex *index, const char* path,
|
|||
return rv;
|
||||
}
|
||||
|
||||
static MuResult
|
||||
static MuError
|
||||
on_stats_maildir_file (const char *fullpath, const char* mdir,
|
||||
struct stat *statbuf,
|
||||
MuIndexCallbackData *cb_data)
|
||||
{
|
||||
MuResult result;
|
||||
MuError result;
|
||||
|
||||
if (cb_data && cb_data->_idx_msg_cb)
|
||||
result = cb_data->_idx_msg_cb (cb_data->_stats,
|
||||
|
@ -380,7 +380,7 @@ on_stats_maildir_file (const char *fullpath, const char* mdir,
|
|||
}
|
||||
|
||||
|
||||
MuResult
|
||||
MuError
|
||||
mu_index_stats (MuIndex *index, const char* path,
|
||||
MuIndexStats *stats, MuIndexMsgCallback cb_msg,
|
||||
MuIndexDirCallback cb_dir, void *user_data)
|
||||
|
@ -420,7 +420,7 @@ struct _CleanupData {
|
|||
typedef struct _CleanupData CleanupData;
|
||||
|
||||
|
||||
static MuResult
|
||||
static MuError
|
||||
foreach_doc_cb (const char* path, CleanupData *cudata)
|
||||
{
|
||||
if (access (path, R_OK) != 0) {
|
||||
|
@ -442,12 +442,12 @@ foreach_doc_cb (const char* path, CleanupData *cudata)
|
|||
}
|
||||
|
||||
|
||||
MuResult
|
||||
MuError
|
||||
mu_index_cleanup (MuIndex *index, MuIndexStats *stats,
|
||||
MuIndexCleanupDeleteCallback cb,
|
||||
void *user_data)
|
||||
{
|
||||
MuResult rv;
|
||||
MuError rv;
|
||||
CleanupData cudata;
|
||||
|
||||
g_return_val_if_fail (index, MU_ERROR);
|
||||
|
@ -459,8 +459,8 @@ mu_index_cleanup (MuIndex *index, MuIndexStats *stats,
|
|||
cudata._user_data = user_data;
|
||||
|
||||
rv = mu_store_foreach (index->_store,
|
||||
(MuStoreForeachFunc)foreach_doc_cb,
|
||||
&cudata);
|
||||
(MuStoreForeachFunc)foreach_doc_cb,
|
||||
&cudata);
|
||||
mu_store_flush (index->_store);
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -109,7 +109,7 @@ const char* mu_index_last_used_maildir (MuIndex *index);
|
|||
* @return MU_OK to continue, MU_STOP to stop, or MU_ERROR in
|
||||
* case of some error.
|
||||
*/
|
||||
typedef MuResult (*MuIndexMsgCallback) (MuIndexStats* stats, void *user_data);
|
||||
typedef MuError (*MuIndexMsgCallback) (MuIndexStats* stats, void *user_data);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -122,7 +122,7 @@ typedef MuResult (*MuIndexMsgCallback) (MuIndexStats* stats, void *user_data);
|
|||
* @return MU_OK to contiue, MU_STOP to stopd or MU_ERROR in
|
||||
* case of some error.
|
||||
*/
|
||||
typedef MuResult (*MuIndexDirCallback) (const char* path, gboolean enter,
|
||||
typedef MuError (*MuIndexDirCallback) (const char* path, gboolean enter,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
|
@ -144,9 +144,9 @@ typedef MuResult (*MuIndexDirCallback) (const char* path, gboolean enter,
|
|||
* MU_STOP if the user stopped or MU_ERROR in
|
||||
* case of some error.
|
||||
*/
|
||||
MuResult mu_index_run (MuIndex *index, const char* path, gboolean force,
|
||||
MuIndexStats *stats, MuIndexMsgCallback msg_cb,
|
||||
MuIndexDirCallback dir_cb, void *user_data);
|
||||
MuError mu_index_run (MuIndex *index, const char* path, gboolean force,
|
||||
MuIndexStats *stats, MuIndexMsgCallback msg_cb,
|
||||
MuIndexDirCallback dir_cb, void *user_data);
|
||||
|
||||
/**
|
||||
* gather some statistics about the Maildir; this is usually much faster
|
||||
|
@ -168,22 +168,20 @@ MuResult mu_index_run (MuIndex *index, const char* path, gboolean force,
|
|||
* MU_STOP if the user stopped or MU_ERROR in
|
||||
* case of some error.
|
||||
*/
|
||||
MuResult mu_index_stats (MuIndex *index, const char* path, MuIndexStats *stats,
|
||||
MuIndexMsgCallback msg_cb, MuIndexDirCallback dir_cb,
|
||||
void *user_data);
|
||||
MuError mu_index_stats (MuIndex *index, const char* path, MuIndexStats *stats,
|
||||
MuIndexMsgCallback msg_cb, MuIndexDirCallback dir_cb,
|
||||
void *user_data);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* callback function to determine if a message should be delete from
|
||||
* the database; if it returs MU_OK it will be delete, if returns
|
||||
* MU_IGNORE, the message will be ignored. In other cases, stop the callback
|
||||
* callback function called for each message
|
||||
*
|
||||
* @param MuIndexCleanupCallback
|
||||
*
|
||||
* @return
|
||||
* @return a MuResult
|
||||
*/
|
||||
typedef MuResult (*MuIndexCleanupDeleteCallback) (MuIndexStats *stats,
|
||||
typedef MuError (*MuIndexCleanupDeleteCallback) (MuIndexStats *stats,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
|
@ -202,9 +200,9 @@ typedef MuResult (*MuIndexCleanupDeleteCallback) (MuIndexStats *stats,
|
|||
* MU_STOP if the user stopped or MU_ERROR in
|
||||
* case of some error.
|
||||
*/
|
||||
MuResult mu_index_cleanup (MuIndex *index, MuIndexStats *stats,
|
||||
MuIndexCleanupDeleteCallback cb,
|
||||
void *user_data);
|
||||
MuError mu_index_cleanup (MuIndex *index, MuIndexStats *stats,
|
||||
MuIndexCleanupDeleteCallback cb,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* clear the stats structure
|
||||
|
|
|
@ -217,15 +217,16 @@ mu_maildir_link (const char* src, const char *targetpath, GError **err)
|
|||
}
|
||||
|
||||
|
||||
static MuResult process_dir (const char* path, const gchar *mdir,
|
||||
MuMaildirWalkMsgCallback msg_cb,
|
||||
MuMaildirWalkDirCallback dir_cb, void *data);
|
||||
static MuError
|
||||
process_dir (const char* path, const gchar *mdir,
|
||||
MuMaildirWalkMsgCallback msg_cb,
|
||||
MuMaildirWalkDirCallback dir_cb, void *data);
|
||||
|
||||
static MuResult
|
||||
static MuError
|
||||
process_file (const char* fullpath, const gchar* mdir,
|
||||
MuMaildirWalkMsgCallback msg_cb, void *data)
|
||||
{
|
||||
MuResult result;
|
||||
MuError result;
|
||||
struct stat statbuf;
|
||||
|
||||
if (!msg_cb)
|
||||
|
@ -367,7 +368,7 @@ get_mdir_for_path (const gchar *old_mdir, const gchar *dir)
|
|||
}
|
||||
|
||||
|
||||
static MuResult
|
||||
static MuError
|
||||
process_dir_entry (const char* path, const char* mdir, struct dirent *entry,
|
||||
MuMaildirWalkMsgCallback cb_msg,
|
||||
MuMaildirWalkDirCallback cb_dir,
|
||||
|
@ -398,7 +399,7 @@ process_dir_entry (const char* path, const char* mdir, struct dirent *entry,
|
|||
|
||||
case DT_DIR: {
|
||||
char *my_mdir;
|
||||
MuResult rv;
|
||||
MuError rv;
|
||||
|
||||
my_mdir = get_mdir_for_path (mdir, entry->d_name);
|
||||
rv = process_dir (fullpath, my_mdir, cb_msg, cb_dir, data);
|
||||
|
@ -447,12 +448,12 @@ dirent_cmp (struct dirent *d1, struct dirent *d2)
|
|||
}
|
||||
#endif /*HAVE_STRUCT_DIRENT_D_INO*/
|
||||
|
||||
static MuResult
|
||||
static MuError
|
||||
process_dir_entries (DIR *dir, const char* path, const char* mdir,
|
||||
MuMaildirWalkMsgCallback msg_cb,
|
||||
MuMaildirWalkDirCallback dir_cb, void *data)
|
||||
{
|
||||
MuResult result;
|
||||
MuError result;
|
||||
GSList *lst, *c;
|
||||
struct dirent *entry;
|
||||
|
||||
|
@ -482,12 +483,12 @@ process_dir_entries (DIR *dir, const char* path, const char* mdir,
|
|||
}
|
||||
|
||||
|
||||
static MuResult
|
||||
static MuError
|
||||
process_dir (const char* path, const char* mdir,
|
||||
MuMaildirWalkMsgCallback msg_cb,
|
||||
MuMaildirWalkDirCallback dir_cb, void *data)
|
||||
{
|
||||
MuResult result;
|
||||
MuError result;
|
||||
DIR* dir;
|
||||
|
||||
/* if it has a noindex file, we ignore this dir */
|
||||
|
@ -504,7 +505,7 @@ process_dir (const char* path, const char* mdir,
|
|||
}
|
||||
|
||||
if (dir_cb) {
|
||||
MuResult rv;
|
||||
MuError rv;
|
||||
rv = dir_cb (path, TRUE, data);
|
||||
if (rv != MU_OK) {
|
||||
closedir (dir);
|
||||
|
@ -523,11 +524,11 @@ process_dir (const char* path, const char* mdir,
|
|||
}
|
||||
|
||||
|
||||
MuResult
|
||||
MuError
|
||||
mu_maildir_walk (const char *path, MuMaildirWalkMsgCallback cb_msg,
|
||||
MuMaildirWalkDirCallback cb_dir, void *data)
|
||||
{
|
||||
MuResult rv;
|
||||
MuError rv;
|
||||
char *mypath;
|
||||
|
||||
g_return_val_if_fail (path && cb_msg, MU_ERROR);
|
||||
|
@ -760,8 +761,8 @@ get_new_dir_name (const char* oldpath, MuMsgFlags flags)
|
|||
|
||||
g_return_val_if_fail (oldpath, NULL);
|
||||
/* if MU_MSG_FLAG_NEW is set, it must be the only flag */
|
||||
g_return_val_if_fail (flags & MU_MSG_FLAG_NEW ?
|
||||
flags == MU_MSG_FLAG_NEW : TRUE, NULL);
|
||||
/* g_return_val_if_fail (flags & MU_MSG_FLAG_NEW ? */
|
||||
/* flags == MU_MSG_FLAG_NEW : TRUE, NULL); */
|
||||
|
||||
newpath = g_path_get_dirname (oldpath);
|
||||
if (g_str_has_suffix (newpath, cur4) || g_str_has_suffix (newpath, new4))
|
||||
|
@ -792,11 +793,12 @@ static char*
|
|||
get_new_file_name (const char *oldpath, MuMsgFlags flags)
|
||||
{
|
||||
gchar *newname, *sep;
|
||||
|
||||
gchar sepa;
|
||||
|
||||
/* if MU_MSG_FLAG_NEW is set, it must be the only flag */
|
||||
g_return_val_if_fail (flags & MU_MSG_FLAG_NEW ?
|
||||
flags == MU_MSG_FLAG_NEW : TRUE, NULL);
|
||||
|
||||
/* g_return_val_if_fail (flags & MU_MSG_FLAG_NEW ? */
|
||||
/* flags == MU_MSG_FLAG_NEW : TRUE, NULL); */
|
||||
|
||||
/* the normal separator is ':', but on e.g. vfat, '!' is seen
|
||||
* as well */
|
||||
newname = g_path_get_basename (oldpath);
|
||||
|
@ -805,26 +807,27 @@ get_new_file_name (const char *oldpath, MuMsgFlags flags)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
sep = ":";
|
||||
if (!(flags & MU_MSG_FLAG_NEW) &&
|
||||
!(sep = g_strrstr (newname, ":")) &&
|
||||
!(sep = g_strrstr (newname, "!"))) {
|
||||
g_warning ("not a valid msg file name: '%s'", oldpath);
|
||||
g_free (newname);
|
||||
return NULL;
|
||||
/* 'INVALID' means: "don't change flags" */
|
||||
if (flags == (unsigned)MU_MSG_FLAG_INVALID)
|
||||
return newname;
|
||||
|
||||
/* the filename may or may not end in "[:!]2,..." */
|
||||
sepa = ':'; /* FIXME: this will break on vfat, but we don't
|
||||
* want to generate '!' files on non-VFAT */
|
||||
if ((sep = g_strrstr (newname, ":")) ||
|
||||
(sep = g_strrstr (newname, "!"))) {
|
||||
sepa = *sep;
|
||||
*sep = '\0';
|
||||
}
|
||||
|
||||
if (flags & MU_MSG_FLAG_NEW)
|
||||
sep[0] = '\0'; /* remove all, including ':' or '!' */
|
||||
else {
|
||||
|
||||
{
|
||||
gchar *tmp;
|
||||
sep[1] = '\0'; /* remove flags, but keep ':' or '!' */
|
||||
sep[flags & MU_MSG_FLAG_NEW ? 0 : 1] = '\0';
|
||||
tmp = newname;
|
||||
newname = g_strdup_printf ("%s2,%s", newname, get_flags_str_s (flags));
|
||||
g_free (tmp);
|
||||
tmp = g_strdup_printf ("%s%c2,%s", newname, sepa,
|
||||
get_flags_str_s (flags));
|
||||
g_free (newname);
|
||||
newname = tmp;
|
||||
}
|
||||
|
||||
|
||||
return newname;
|
||||
}
|
||||
|
||||
|
@ -836,8 +839,8 @@ mu_maildir_get_path_from_flags (const char *oldpath, MuMsgFlags newflags)
|
|||
g_return_val_if_fail (oldpath, NULL);
|
||||
g_return_val_if_fail (newflags != MU_MSG_FLAG_NONE, NULL);
|
||||
/* if MU_MSG_FLAG_NEW is set, it must be the only flag */
|
||||
g_return_val_if_fail (newflags & MU_MSG_FLAG_NEW ?
|
||||
newflags == MU_MSG_FLAG_NEW : TRUE, NULL);
|
||||
/* g_return_val_if_fail (newflags & MU_MSG_FLAG_NEW ? */
|
||||
/* newflags == MU_MSG_FLAG_NEW : TRUE, NULL); */
|
||||
|
||||
newname = get_new_file_name (oldpath, newflags);
|
||||
if (!newname)
|
||||
|
|
|
@ -71,7 +71,7 @@ gboolean mu_maildir_link (const char* src, const char *targetpath, GError **er
|
|||
* the maildir "foo/bar". Then, the information from 'stat' of this
|
||||
* file (see stat(3)), and a user_data pointer
|
||||
*/
|
||||
typedef MuResult (*MuMaildirWalkMsgCallback)
|
||||
typedef MuError (*MuMaildirWalkMsgCallback)
|
||||
(const char* fullpath, const char* mdir, struct stat *statinfo, void *user_data);
|
||||
|
||||
/**
|
||||
|
@ -79,7 +79,7 @@ typedef MuResult (*MuMaildirWalkMsgCallback)
|
|||
* documentation there. It will be called each time a dir is entered or left,
|
||||
* with 'enter' being TRUE upon entering, FALSE otherwise
|
||||
*/
|
||||
typedef MuResult (*MuMaildirWalkDirCallback)
|
||||
typedef MuError (*MuMaildirWalkDirCallback)
|
||||
(const char* fullpath, gboolean enter, void *user_data);
|
||||
|
||||
/**
|
||||
|
@ -106,8 +106,8 @@ typedef MuResult (*MuMaildirWalkDirCallback)
|
|||
* MU_STOP if we want to stop, or MU_ERROR in
|
||||
* case of error
|
||||
*/
|
||||
MuResult mu_maildir_walk (const char *path, MuMaildirWalkMsgCallback cb_msg,
|
||||
MuMaildirWalkDirCallback cb_dir, void *data);
|
||||
MuError mu_maildir_walk (const char *path, MuMaildirWalkMsgCallback cb_msg,
|
||||
MuMaildirWalkDirCallback cb_dir, void *data);
|
||||
/**
|
||||
* recursively delete all the symbolic links in a directory tree
|
||||
*
|
||||
|
|
|
@ -711,7 +711,6 @@ get_maildir_type (const char *path)
|
|||
return mtype;
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
get_new_fullpath (const char *oldpath, const char *targetmdir,
|
||||
MaildirType mtype, MuMsgFlags flags)
|
||||
|
@ -744,8 +743,9 @@ get_new_fullpath (const char *oldpath, const char *targetmdir,
|
|||
if (flags != MU_MSG_FLAG_NONE) {
|
||||
gchar *tmp;
|
||||
tmp = mu_maildir_get_path_from_flags (newfullpath, flags);
|
||||
g_free (newfullpath);
|
||||
newfullpath = tmp;
|
||||
g_free (tmp);
|
||||
|
||||
}
|
||||
|
||||
return newfullpath;
|
||||
|
@ -858,7 +858,7 @@ mu_msg_file_move_to_maildir (const char* oldpath, const char* targetmdir,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (g_strcmp0 (oldpath, newfullpath)) {
|
||||
if (g_strcmp0 (oldpath, newfullpath) == 0) {
|
||||
g_set_error (err, 0, MU_ERROR_FILE,
|
||||
"target equals source");
|
||||
return FALSE;
|
||||
|
|
|
@ -197,7 +197,7 @@ get_query (MuQuery *mqx, const char* searchexpr, GError **err)
|
|||
|
||||
} catch (...) {
|
||||
/* some error occured */
|
||||
g_set_error (err, 0, MU_ERROR_QUERY,
|
||||
g_set_error (err, 0, MU_ERROR_XAPIAN_QUERY,
|
||||
"parse error in query");
|
||||
g_free (preprocessed);
|
||||
throw;
|
||||
|
@ -242,13 +242,13 @@ mu_query_new (const char* xpath, GError **err)
|
|||
g_return_val_if_fail (xpath, NULL);
|
||||
|
||||
if (!mu_util_check_dir (xpath, TRUE, FALSE)) {
|
||||
g_set_error (err, 0, MU_ERROR_XAPIAN_DIR,
|
||||
g_set_error (err, 0, MU_ERROR_XAPIAN_DIR_NOT_ACCESSIBLE,
|
||||
"'%s' is not a readable xapian dir", xpath);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (mu_util_xapian_needs_upgrade (xpath)) {
|
||||
g_set_error (err, 0, MU_ERROR_XAPIAN_NOT_UPTODATE,
|
||||
g_set_error (err, 0, MU_ERROR_XAPIAN_NOT_UP_TO_DATE,
|
||||
"%s is not up-to-date, needs a full update",
|
||||
xpath);
|
||||
return NULL;
|
||||
|
|
|
@ -775,7 +775,7 @@ mu_store_set_timestamp (MuStore *store, const char* msgpath,
|
|||
}
|
||||
|
||||
|
||||
MuResult
|
||||
MuError
|
||||
mu_store_foreach (MuStore *self,
|
||||
MuStoreForeachFunc func, void *user_data)
|
||||
{
|
||||
|
@ -796,7 +796,7 @@ mu_store_foreach (MuStore *self,
|
|||
iter != matches.end(); ++iter) {
|
||||
Xapian::Document doc (iter.get_document());
|
||||
const std::string path(doc.get_value(MU_MSG_FIELD_ID_PATH));
|
||||
MuResult res = func (path.c_str(), user_data);
|
||||
MuError res = func (path.c_str(), user_data);
|
||||
if (res != MU_OK)
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <glib.h>
|
||||
#include <inttypes.h>
|
||||
#include <mu-msg.h>
|
||||
#include <mu-util.h> /* for MuResult, MuError */
|
||||
#include <mu-util.h> /* for MuError, MuError */
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -182,9 +182,9 @@ time_t mu_store_get_timestamp (MuStore *store,
|
|||
* @return MU_OK if all went well, MU_STOP if the foreach was interrupted,
|
||||
* MU_ERROR in case of error
|
||||
*/
|
||||
typedef MuResult (*MuStoreForeachFunc) (const char* path,
|
||||
typedef MuError (*MuStoreForeachFunc) (const char* path,
|
||||
void *user_data);
|
||||
MuResult mu_store_foreach (MuStore *self,
|
||||
MuError mu_store_foreach (MuStore *self,
|
||||
MuStoreForeachFunc func,
|
||||
void *user_data);
|
||||
|
||||
|
|
|
@ -393,53 +393,57 @@ typedef gpointer XapianEnquire;
|
|||
} G_STMT_END
|
||||
|
||||
|
||||
enum _MuResult {
|
||||
MU_OK, /* all went ok */
|
||||
MU_STOP, /* user wants to stop */
|
||||
MU_ERROR /* some other error occured */
|
||||
};
|
||||
typedef enum _MuResult MuResult;
|
||||
|
||||
enum _MuExitCode {
|
||||
MU_EXITCODE_OK = 0,
|
||||
MU_EXITCODE_ERROR = 1,
|
||||
MU_EXITCODE_NO_MATCHES = 2,
|
||||
MU_EXITCODE_DB_LOCKED = 3,
|
||||
MU_EXITCODE_DB_CORRUPTED = 4,
|
||||
MU_EXITCODE_DB_UPDATE_ERROR = 5,
|
||||
|
||||
MU_EXITCODE_FILE_ERROR = 6
|
||||
};
|
||||
typedef enum _MuExitCode MuExitCode;
|
||||
|
||||
|
||||
enum _MuError {
|
||||
MU_ERROR_XAPIAN, /* general xapian related error */
|
||||
MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK, /* can't get write lock */
|
||||
MU_ERROR_XAPIAN_CORRUPTION, /* database corruption */
|
||||
MU_ERROR_XAPIAN_DIR, /* xapian dir is not accessible */
|
||||
MU_ERROR_XAPIAN_NOT_UPTODATE, /* database version is not uptodate */
|
||||
MU_ERROR_XAPIAN_MISSING_DATA, /* missing data for a document */
|
||||
MU_ERROR_QUERY, /* (parsing) error in the query */
|
||||
/* no error at all! */
|
||||
MU_OK = 0,
|
||||
|
||||
MU_ERROR_GMIME, /* gmime parsing related error */
|
||||
/* generic error */
|
||||
MU_ERROR = 1,
|
||||
MU_ERROR_IN_PARAMETERS = 2,
|
||||
MU_ERROR_INTERNAL = 3,
|
||||
MU_ERROR_NO_MATCHES = 4,
|
||||
|
||||
/* general xapian related error */
|
||||
MU_ERROR_XAPIAN = 11,
|
||||
|
||||
/* (parsing) error in the query */
|
||||
MU_ERROR_XAPIAN_QUERY = 13,
|
||||
/* xapian dir is not accessible */
|
||||
MU_ERROR_XAPIAN_DIR_NOT_ACCESSIBLE = 14,
|
||||
/* database version is not up-to-date */
|
||||
MU_ERROR_XAPIAN_NOT_UP_TO_DATE = 15,
|
||||
/* missing data for a document */
|
||||
MU_ERROR_XAPIAN_MISSING_DATA = 16,
|
||||
/* database corruption */
|
||||
MU_ERROR_XAPIAN_CORRUPTION = 17,
|
||||
/* can't get write lock */
|
||||
MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK = 18,
|
||||
|
||||
/* GMime related errors */
|
||||
|
||||
/* gmime parsing related error */
|
||||
MU_ERROR_GMIME = 30,
|
||||
|
||||
/* contacts related errors */
|
||||
MU_ERROR_CONTACTS = 50,
|
||||
MU_ERROR_CONTACTS_CANNOT_RETRIEVE = 51,
|
||||
|
||||
|
||||
/* File errors */
|
||||
MU_ERROR_FILE_INVALID_SOURCE,
|
||||
MU_ERROR_FILE_INVALID_NAME,
|
||||
MU_ERROR_FILE_CANNOT_LINK,
|
||||
MU_ERROR_FILE_CANNOT_OPEN,
|
||||
MU_ERROR_FILE_CANNOT_READ,
|
||||
MU_ERROR_FILE_CANNOT_CREATE,
|
||||
MU_ERROR_FILE_CANNOT_MKDIR,
|
||||
MU_ERROR_FILE_STAT_FAILED,
|
||||
MU_ERROR_FILE_READDIR_FAILED,
|
||||
|
||||
/* generic file-related error */
|
||||
MU_ERROR_FILE,
|
||||
|
||||
/* some other, internal error */
|
||||
MU_ERROR_INTERNAL
|
||||
MU_ERROR_FILE = 70,
|
||||
MU_ERROR_FILE_INVALID_NAME = 71,
|
||||
MU_ERROR_FILE_CANNOT_LINK = 72,
|
||||
MU_ERROR_FILE_CANNOT_OPEN = 73,
|
||||
MU_ERROR_FILE_CANNOT_READ = 74,
|
||||
MU_ERROR_FILE_CANNOT_CREATE = 75,
|
||||
MU_ERROR_FILE_CANNOT_MKDIR = 76,
|
||||
MU_ERROR_FILE_STAT_FAILED = 77,
|
||||
MU_ERROR_FILE_READDIR_FAILED = 78,
|
||||
MU_ERROR_FILE_INVALID_SOURCE = 79,
|
||||
|
||||
/* not really an error, used in callbacks */
|
||||
MU_STOP = 99,
|
||||
};
|
||||
typedef enum _MuError MuError;
|
||||
|
||||
|
|
Loading…
Reference in New Issue