mirror of https://github.com/djcb/mu.git
mu: Update for new querying APIs
This commit is contained in:
parent
e282d80bc0
commit
01ced9a356
108
mu/Makefile.am
108
mu/Makefile.am
|
@ -16,92 +16,92 @@
|
|||
|
||||
include $(top_srcdir)/gtest.mk
|
||||
|
||||
AM_CPPFLAGS= \
|
||||
-I${top_srcdir}/lib \
|
||||
$(GLIB_CFLAGS) \
|
||||
AM_CPPFLAGS= \
|
||||
-I${top_srcdir}/lib \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(CODE_COVERAGE_CFLAGS)
|
||||
|
||||
AM_CXXFLAGS= \
|
||||
$(JSON_GLIB_CFLAGS) \
|
||||
AM_CXXFLAGS= \
|
||||
$(JSON_GLIB_CFLAGS) \
|
||||
-DMU_SCRIPTS_DIR="\"$(pkgdatadir)/scripts/\""
|
||||
$(ASAN_CXXCFLAGS) \
|
||||
$(WARN_CXXFLAGS) \
|
||||
$(CODE_COVERAGE_CFLAGS) \
|
||||
$(ASAN_CXXCFLAGS) \
|
||||
$(WARN_CXXFLAGS) \
|
||||
$(CODE_COVERAGE_CFLAGS) \
|
||||
-Wno-switch-enum
|
||||
|
||||
|
||||
AM_LDFLAGS= \
|
||||
AM_LDFLAGS= \
|
||||
$(ASAN_LDFLAGS)
|
||||
|
||||
bin_PROGRAMS= \
|
||||
bin_PROGRAMS= \
|
||||
mu
|
||||
|
||||
# note, mu.cc is only '.cc' and not '.c' because libmu must explicitly
|
||||
# be linked as c++, not c.
|
||||
mu_SOURCES= \
|
||||
mu.cc \
|
||||
mu-cmd-cfind.cc \
|
||||
mu-config.cc \
|
||||
mu-config.hh \
|
||||
mu-cmd-extract.cc \
|
||||
mu-cmd-find.cc \
|
||||
mu-cmd-index.cc \
|
||||
mu-cmd-server.cc \
|
||||
mu-cmd-script.cc \
|
||||
mu-cmd.cc \
|
||||
mu_SOURCES= \
|
||||
mu.cc \
|
||||
mu-cmd-cfind.cc \
|
||||
mu-config.cc \
|
||||
mu-config.hh \
|
||||
mu-cmd-extract.cc \
|
||||
mu-cmd-find.cc \
|
||||
mu-cmd-index.cc \
|
||||
mu-cmd-server.cc \
|
||||
mu-cmd-script.cc \
|
||||
mu-cmd.cc \
|
||||
mu-cmd.hh
|
||||
|
||||
BUILT_SOURCES= \
|
||||
BUILT_SOURCES= \
|
||||
mu-help-strings.h
|
||||
|
||||
mu-help-strings.h: mu-help-strings.txt mu-help-strings.awk
|
||||
$(AM_V_GEN) $(AWK) -f ${top_srcdir}/mu/mu-help-strings.awk < $< > $@
|
||||
|
||||
mu_LDADD= \
|
||||
${top_builddir}/lib/libmu.la \
|
||||
${top_builddir}/lib/utils/libmu-utils.la \
|
||||
$(GLIB_LIBS) \
|
||||
$(READLINE_LIBS) \
|
||||
mu_LDADD= \
|
||||
${top_builddir}/lib/libmu.la \
|
||||
${top_builddir}/lib/utils/libmu-utils.la \
|
||||
$(GLIB_LIBS) \
|
||||
$(READLINE_LIBS) \
|
||||
$(CODE_COVERAGE_LIBS)
|
||||
|
||||
EXTRA_DIST= \
|
||||
mu-help-strings.awk \
|
||||
EXTRA_DIST= \
|
||||
mu-help-strings.awk \
|
||||
mu-help-strings.txt
|
||||
|
||||
noinst_PROGRAMS= $(TEST_PROGS)
|
||||
|
||||
test_cxxflags= \
|
||||
${AM_CXXFLAGS} \
|
||||
-DMU_TESTMAILDIR=\"${abs_top_srcdir}/lib/testdir\" \
|
||||
-DMU_TESTMAILDIR2=\"${abs_top_srcdir}/lib/testdir2\" \
|
||||
-DMU_TESTMAILDIR3=\"${abs_top_srcdir}/lib/testdir3\" \
|
||||
-DMU_TESTMAILDIR4=\"${abs_top_srcdir}/lib/testdir4\" \
|
||||
-DMU_PROGRAM=\"${abs_top_builddir}/mu/mu\" \
|
||||
-DABS_CURDIR=\"${abs_builddir}\" \
|
||||
test_cxxflags= \
|
||||
${AM_CXXFLAGS} \
|
||||
-DMU_TESTMAILDIR=\"${abs_top_srcdir}/lib/testdir\" \
|
||||
-DMU_TESTMAILDIR2=\"${abs_top_srcdir}/lib/testdir2\" \
|
||||
-DMU_TESTMAILDIR3=\"${abs_top_srcdir}/lib/testdir3\" \
|
||||
-DMU_TESTMAILDIR4=\"${abs_top_srcdir}/lib/testdir4\" \
|
||||
-DMU_PROGRAM=\"${abs_top_builddir}/mu/mu\" \
|
||||
-DABS_CURDIR=\"${abs_builddir}\" \
|
||||
-DABS_SRCDIR=\"${abs_srcdir}\"
|
||||
|
||||
TEST_PROGS += test-mu-query
|
||||
test_mu_query_SOURCES= test-mu-query.cc
|
||||
test_mu_query_CXXFLAGS=$(test_cxxflags)
|
||||
test_mu_query_LDADD=${top_builddir}/lib/libtestmucommon.la $(CODE_COVERAGE_LIBS)
|
||||
TEST_PROGS += test-query
|
||||
test_query_SOURCES= test-mu-query.cc
|
||||
test_query_CXXFLAGS=$(test_cxxflags)
|
||||
test_query_LDADD=${top_builddir}/lib/libtestmucommon.la $(CODE_COVERAGE_LIBS)
|
||||
|
||||
TEST_PROGS += test-mu-cmd
|
||||
test_mu_cmd_SOURCES= test-mu-cmd.cc
|
||||
test_mu_cmd_CXXFLAGS=$(test_cxxflags)
|
||||
test_mu_cmd_LDADD=${top_builddir}/lib/libtestmucommon.la $(CODE_COVERAGE_LIBS)
|
||||
TEST_PROGS += test-cmd
|
||||
test_cmd_SOURCES= test-mu-cmd.cc
|
||||
test_cmd_CXXFLAGS=$(test_cxxflags)
|
||||
test_cmd_LDADD=${top_builddir}/lib/libtestmucommon.la $(CODE_COVERAGE_LIBS)
|
||||
|
||||
TEST_PROGS += test-mu-cmd-cfind
|
||||
test_mu_cmd_cfind_SOURCES= test-mu-cmd-cfind.cc
|
||||
test_mu_cmd_cfind_CXXFLAGS=$(test_cxxflags)
|
||||
test_mu_cmd_cfind_LDADD=${top_builddir}/lib/libtestmucommon.la $(CODE_COVERAGE_LIBS)
|
||||
TEST_PROGS += test-cmd-cfind
|
||||
test_cmd_cfind_SOURCES= test-mu-cmd-cfind.cc
|
||||
test_cmd_cfind_CXXFLAGS=$(test_cxxflags)
|
||||
test_cmd_cfind_LDADD=${top_builddir}/lib/libtestmucommon.la $(CODE_COVERAGE_LIBS)
|
||||
|
||||
TEST_PROGS += test-mu-threads
|
||||
test_mu_threads_SOURCES= test-mu-threads.cc
|
||||
test_mu_threads_CXXFLAGS=$(test_cxxflags)
|
||||
test_mu_threads_LDADD=${top_builddir}/lib/libtestmucommon.la $(CODE_COVERAGE_LIBS)
|
||||
TEST_PROGS += test-threads
|
||||
test_threads_SOURCES= test-mu-threads.cc
|
||||
test_threads_CXXFLAGS=$(test_cxxflags)
|
||||
test_threads_LDADD=${top_builddir}/lib/libtestmucommon.la $(CODE_COVERAGE_LIBS)
|
||||
|
||||
TESTS=$(TEST_PROGS)
|
||||
include $(top_srcdir)/aminclude_static.am
|
||||
|
||||
CLEANFILES= \
|
||||
CLEANFILES= \
|
||||
$(BUILT_SOURCES)
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
#include "utils/mu-str.h"
|
||||
#include "utils/mu-date.h"
|
||||
|
||||
using namespace Mu;
|
||||
|
||||
/**
|
||||
* guess the last name for the given name; clearly,
|
||||
* this is just a rough guess for setting an initial value.
|
||||
|
@ -404,7 +406,7 @@ cfind_params_valid (const MuConfig *opts)
|
|||
}
|
||||
|
||||
MuError
|
||||
mu_cmd_cfind (const Mu::Store& store, const MuConfig *opts, GError **err)
|
||||
Mu::mu_cmd_cfind (const Mu::Store& store, const MuConfig *opts, GError **err)
|
||||
{
|
||||
g_return_val_if_fail (opts, MU_ERROR_INTERNAL);
|
||||
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_CFIND,
|
||||
|
|
|
@ -22,12 +22,14 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mu-msg.h"
|
||||
#include "mu-msg-part.h"
|
||||
#include "mu-msg.hh"
|
||||
#include "mu-msg-part.hh"
|
||||
|
||||
#include "mu-cmd.hh"
|
||||
#include "utils/mu-util.h"
|
||||
#include "utils/mu-str.h"
|
||||
|
||||
using namespace Mu;
|
||||
|
||||
static gboolean
|
||||
save_part (MuMsg *msg, const char *targetdir, guint partidx, const MuConfig *opts)
|
||||
|
@ -393,7 +395,7 @@ check_params (const MuConfig *opts, GError **err)
|
|||
}
|
||||
|
||||
MuError
|
||||
mu_cmd_extract (const MuConfig *opts, GError **err)
|
||||
Mu::mu_cmd_extract (const MuConfig *opts, GError **err)
|
||||
{
|
||||
int rv;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,7 +30,7 @@
|
|||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mu-msg.h"
|
||||
#include "mu-msg.hh"
|
||||
#include "index/mu-indexer.hh"
|
||||
#include "mu-store.hh"
|
||||
#include "mu-runtime.hh"
|
||||
|
@ -81,7 +81,7 @@ print_stats (const Indexer::Progress& stats, bool color)
|
|||
|
||||
|
||||
MuError
|
||||
mu_cmd_index (Mu::Store& store, const MuConfig *opts, GError **err)
|
||||
Mu::mu_cmd_index (Mu::Store& store, const MuConfig *opts, GError **err)
|
||||
{
|
||||
g_return_val_if_fail (opts, MU_ERROR);
|
||||
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_INDEX, MU_ERROR);
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
|
||||
#define COL(C) ((color)?C:"")
|
||||
|
||||
using namespace Mu;
|
||||
|
||||
static void
|
||||
print_script (const char *name, const char *oneline, const char *descr,
|
||||
gboolean color, gboolean verbose)
|
||||
|
@ -163,7 +165,7 @@ check_params (const MuConfig *opts, GError **err)
|
|||
|
||||
|
||||
MuError
|
||||
mu_cmd_script (const MuConfig *opts, GError **err)
|
||||
Mu::mu_cmd_script (const MuConfig *opts, GError **err)
|
||||
{
|
||||
MuScriptInfo *msi;
|
||||
GSList *scripts;
|
||||
|
|
|
@ -88,7 +88,7 @@ output_sexp_stdout (Sexp&& sexp)
|
|||
}
|
||||
|
||||
MuError
|
||||
mu_cmd_server (const MuConfig *opts, GError **err) try {
|
||||
Mu::mu_cmd_server (const MuConfig *opts, GError **err) try {
|
||||
|
||||
Store store{mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB), false/*writable*/};
|
||||
Server server{store, output_sexp_stdout};
|
||||
|
|
20
mu/mu-cmd.cc
20
mu/mu-cmd.cc
|
@ -29,13 +29,13 @@
|
|||
#include <errno.h>
|
||||
|
||||
|
||||
#include "mu-msg.h"
|
||||
#include "mu-msg-part.h"
|
||||
#include "mu-msg.hh"
|
||||
#include "mu-msg-part.hh"
|
||||
#include "mu-cmd.hh"
|
||||
#include "mu-maildir.h"
|
||||
#include "mu-maildir.hh"
|
||||
#include "mu-contacts.hh"
|
||||
#include "mu-runtime.hh"
|
||||
#include "mu-flags.h"
|
||||
#include "mu-flags.hh"
|
||||
|
||||
#include "utils/mu-util.h"
|
||||
#include "utils/mu-str.h"
|
||||
|
@ -45,15 +45,13 @@
|
|||
|
||||
#define VIEW_TERMINATOR '\f' /* form-feed */
|
||||
|
||||
using namespace Mu;
|
||||
|
||||
static gboolean
|
||||
view_msg_sexp (MuMsg *msg, const MuConfig *opts)
|
||||
{
|
||||
char *sexp;
|
||||
|
||||
sexp = mu_msg_to_sexp (msg, 0, NULL, mu_config_get_msg_options(opts));
|
||||
fputs (sexp, stdout);
|
||||
g_free (sexp);
|
||||
|
||||
::fputs(msg_to_sexp(msg,0,{}, mu_config_get_msg_options(opts))
|
||||
.to_sexp_string(). c_str(), stdout);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -689,7 +687,7 @@ check_params (const MuConfig *opts, GError **err)
|
|||
}
|
||||
|
||||
MuError
|
||||
mu_cmd_execute (const MuConfig *opts, GError **err) try
|
||||
Mu::mu_cmd_execute (const MuConfig *opts, GError **err) try
|
||||
{
|
||||
MuError merr;
|
||||
|
||||
|
|
10
mu/mu-cmd.hh
10
mu/mu-cmd.hh
|
@ -17,15 +17,14 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#ifndef __MU_CMD_H__
|
||||
#define __MU_CMD_H__
|
||||
#ifndef MU_CMD_HH__
|
||||
#define MU_CMD_HH__
|
||||
|
||||
#include <glib.h>
|
||||
#include <mu-config.hh>
|
||||
#include <mu-store.hh>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
namespace Mu {
|
||||
/**
|
||||
* execute the 'find' command
|
||||
*
|
||||
|
@ -107,6 +106,7 @@ MuError mu_cmd_index (Mu::Store& store, const MuConfig *opt, GError **err);
|
|||
*/
|
||||
MuError mu_cmd_server (const MuConfig *opts, GError **err);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
} // namespace Mu
|
||||
|
||||
#endif /*__MU_CMD_H__*/
|
||||
|
|
|
@ -26,14 +26,13 @@
|
|||
|
||||
#include "mu-config.hh"
|
||||
#include "mu-cmd.hh"
|
||||
#include "mu-msg.h"
|
||||
|
||||
using namespace Mu;
|
||||
|
||||
static MuConfig MU_CONFIG;
|
||||
|
||||
#define color_maybe(C) (MU_CONFIG.nocolor ? "" : (C))
|
||||
|
||||
|
||||
static MuConfigFormat
|
||||
get_output_format (const char *formatstr)
|
||||
{
|
||||
|
@ -627,7 +626,7 @@ get_help_string (MuConfigCmd cmd, gboolean long_help)
|
|||
|
||||
|
||||
void
|
||||
mu_config_show_help (MuConfigCmd cmd)
|
||||
Mu::mu_config_show_help (MuConfigCmd cmd)
|
||||
{
|
||||
GOptionContext *ctx;
|
||||
GOptionGroup *group;
|
||||
|
@ -725,15 +724,13 @@ parse_params (int *argcp, char ***argvp, GError **err)
|
|||
|
||||
|
||||
MuConfig*
|
||||
mu_config_init (int *argcp, char ***argvp, GError **err)
|
||||
Mu::mu_config_init (int *argcp, char ***argvp, GError **err)
|
||||
{
|
||||
g_return_val_if_fail (argcp && argvp, NULL);
|
||||
|
||||
memset (&MU_CONFIG, 0, sizeof(MU_CONFIG));
|
||||
|
||||
MU_CONFIG.maxnum = -1; /* By default, output all matching entries. */
|
||||
|
||||
if (!parse_cmd (argcp, argvp, err))
|
||||
if (!parse_cmd (argcp, argvp, err))
|
||||
goto errexit;
|
||||
|
||||
if (!parse_params(argcp, argvp, err))
|
||||
|
@ -757,7 +754,7 @@ errexit:
|
|||
|
||||
|
||||
void
|
||||
mu_config_uninit (MuConfig *opts)
|
||||
Mu::mu_config_uninit (MuConfig *opts)
|
||||
{
|
||||
if (!opts)
|
||||
return;
|
||||
|
@ -782,7 +779,7 @@ mu_config_uninit (MuConfig *opts)
|
|||
}
|
||||
|
||||
size_t
|
||||
mu_config_param_num (const MuConfig *opts)
|
||||
Mu::mu_config_param_num (const MuConfig *opts)
|
||||
{
|
||||
size_t n;
|
||||
|
||||
|
@ -794,7 +791,7 @@ mu_config_param_num (const MuConfig *opts)
|
|||
|
||||
|
||||
MuMsgOptions
|
||||
mu_config_get_msg_options (const MuConfig *muopts)
|
||||
Mu::mu_config_get_msg_options (const MuConfig *muopts)
|
||||
{
|
||||
int opts;
|
||||
|
||||
|
|
|
@ -17,21 +17,20 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#ifndef __MU_CONFIG_H__
|
||||
#define __MU_CONFIG_H__
|
||||
#ifndef MU_CONFIG_HH__
|
||||
#define MU_CONFIG_HH__
|
||||
|
||||
#include <glib.h>
|
||||
#include <sys/types.h> /* for mode_t */
|
||||
#include <mu-msg-fields.h>
|
||||
#include <mu-msg.h>
|
||||
#include <mu-msg.hh>
|
||||
#include <utils/mu-util.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
namespace Mu {
|
||||
|
||||
/* env var; if non-empty, color are disabled */
|
||||
#define MU_NOCOLOR "MU_NOCOLOR"
|
||||
|
||||
|
||||
typedef enum {
|
||||
MU_CONFIG_FORMAT_UNKNOWN = 0,
|
||||
|
||||
|
@ -257,6 +256,6 @@ MuMsgOptions mu_config_get_msg_options (const MuConfig *opts);
|
|||
*/
|
||||
void mu_config_show_help (const MuConfigCmd cmd);
|
||||
|
||||
G_END_DECLS
|
||||
} // namespace Mu.
|
||||
|
||||
#endif /*__MU_CONFIG_H__*/
|
||||
|
|
Loading…
Reference in New Issue