* cosmetics

This commit is contained in:
djcb
2012-09-23 11:42:17 +03:00
parent bfc2ba9c55
commit 725059f03b

View File

@ -669,7 +669,8 @@ print_sexps (MuMsgIter *iter, gboolean threads, unsigned maxnum)
static MuError static MuError
save_part (MuMsg *msg, unsigned index, GSList *args, GError **err) save_part (MuMsg *msg, unsigned docid,
unsigned index, GSList *args, GError **err)
{ {
gboolean rv; gboolean rv;
const gchar *path; const gchar *path;
@ -694,7 +695,7 @@ save_part (MuMsg *msg, unsigned index, GSList *args, GError **err)
static MuError static MuError
open_part (MuMsg *msg, unsigned index, GError **err) open_part (MuMsg *msg, unsigned docid, unsigned index, GError **err)
{ {
char *targetpath; char *targetpath;
gboolean rv; gboolean rv;
@ -719,7 +720,7 @@ open_part (MuMsg *msg, unsigned index, GError **err)
gchar *path; gchar *path;
path = mu_str_escape_c_literal (targetpath, FALSE); path = mu_str_escape_c_literal (targetpath, FALSE);
print_expr ("(:info open :message \"%s has been opened\")", print_expr ("(:info open :message \"%s has been opened\")",
path); path);
g_free (path); g_free (path);
} }
leave: leave:
@ -729,13 +730,14 @@ leave:
static MuError static MuError
temp_part (MuMsg *msg, unsigned index, GSList *args, GError **err) temp_part (MuMsg *msg, unsigned docid, unsigned index, GSList *args,
GError **err)
{ {
const char *what, *param; const char *what, *param;
char *path; char *path;
GET_STRING_OR_ERROR_RETURN (args, "what", &what, err); GET_STRING_OR_ERROR_RETURN (args, "what", &what, err);
GET_STRING_OR_ERROR_RETURN (args, "param", &param, err); param = get_string_from_args (args, "param", TRUE, NULL);
path = mu_msg_part_get_cache_path (msg, MU_MSG_OPTION_NONE, index, err); path = mu_msg_part_get_cache_path (msg, MU_MSG_OPTION_NONE, index, err);
if (!path) if (!path)
@ -744,14 +746,24 @@ temp_part (MuMsg *msg, unsigned index, GSList *args, GError **err)
path, index, err)) path, index, err))
print_and_clear_g_error (err); print_and_clear_g_error (err);
else { else {
gchar *escpath, *escparam; gchar *escpath;
escpath = mu_str_escape_c_literal (path, FALSE); escpath = mu_str_escape_c_literal (path, FALSE);
escparam = mu_str_escape_c_literal (param, FALSE);
print_expr ("(:temp \"%s\"" if (param) {
" :what \"%s\"" char *escparam;
" :param \"%s\")", escpath, what, escparam); escparam = mu_str_escape_c_literal (param, FALSE);
print_expr ("(:temp \"%s\""
" :what \"%s\""
" :docid %u"
" :param \"%s\""")",
escpath, what, docid, escparam);
g_free (escparam);
} else
print_expr ("(:temp \"%s\" :what \"%s\" :docid %u)",
escpath, what, docid);
g_free (escpath); g_free (escpath);
g_free (escparam);
} }
g_free (path); g_free (path);
@ -803,9 +815,9 @@ cmd_extract (ServerContext *ctx, GSList *args, GError **err)
} }
switch (action) { switch (action) {
case SAVE: rv = save_part (msg, index, args, err); break; case SAVE: rv = save_part (msg, docid, index, args, err); break;
case OPEN: rv = open_part (msg, index, err); break; case OPEN: rv = open_part (msg, docid, index, err); break;
case TEMP: rv = temp_part (msg, index, args, err); break; case TEMP: rv = temp_part (msg, docid, index, args, err); break;
default: print_error (MU_ERROR_INTERNAL, "unknown action"); default: print_error (MU_ERROR_INTERNAL, "unknown action");
} }