2009-11-28 13:06:21 +01:00
|
|
|
/*
|
2010-01-01 14:56:45 +01:00
|
|
|
** Copyright (C) 2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
2009-11-28 13:06:21 +01:00
|
|
|
**
|
|
|
|
** 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 the
|
|
|
|
** Free Software Foundation; either version 3, or (at your option) any
|
|
|
|
** later version.
|
|
|
|
**
|
|
|
|
** This program is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with this program; if not, write to the Free Software Foundation,
|
|
|
|
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __MU_CONFIG_H__
|
|
|
|
#define __MU_CONFIG_H__
|
|
|
|
|
|
|
|
#include <glib.h>
|
2010-01-21 19:05:19 +01:00
|
|
|
#include <sys/types.h> /* for mode_t */
|
2011-01-04 22:19:03 +01:00
|
|
|
#include <mu-msg-fields.h>
|
|
|
|
#include <mu-util.h>
|
2009-11-28 13:06:21 +01:00
|
|
|
|
2010-01-02 13:44:26 +01:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2011-01-05 19:35:50 +01:00
|
|
|
#define MU_CONFIG_FORMAT_PLAIN "plain" /* plain text output */
|
|
|
|
#define MU_CONFIG_FORMAT_LINKS "links" /* output as symlinks */
|
|
|
|
#define MU_CONFIG_FORMAT_XML "xml" /* output xml */
|
|
|
|
#define MU_CONFIG_FORMAT_JSON "json" /* output json */
|
|
|
|
#define MU_CONFIG_FORMAT_SEXP "sexp" /* output sexps */
|
|
|
|
#define MU_CONFIG_FORMAT_XQUERY "xquery" /* output the xapian query */
|
|
|
|
|
2011-03-04 23:59:35 +01:00
|
|
|
/* for cfind */
|
2011-03-06 11:40:08 +01:00
|
|
|
#define MU_CONFIG_FORMAT_MUTT_ALIAS "mutt-alias" /* mutt alias style */
|
|
|
|
#define MU_CONFIG_FORMAT_MUTT_AB "mutt-ab" /* mutt ext addr book */
|
2011-03-05 08:42:06 +01:00
|
|
|
#define MU_CONFIG_FORMAT_WL "wl" /* Wanderlust address-book */
|
|
|
|
#define MU_CONFIG_FORMAT_CSV "csv" /* comma-sep'd values */
|
|
|
|
#define MU_CONFIG_FORMAT_ORG_CONTACT "org-contact" /* org-contact */
|
|
|
|
#define MU_CONFIG_FORMAT_BBDB "bbdb" /* BBDB */
|
2011-03-04 23:59:35 +01:00
|
|
|
|
2011-01-02 17:05:43 +01:00
|
|
|
enum _MuConfigCmd {
|
2011-01-04 22:19:03 +01:00
|
|
|
MU_CONFIG_CMD_INDEX,
|
|
|
|
MU_CONFIG_CMD_FIND,
|
|
|
|
MU_CONFIG_CMD_CLEANUP,
|
|
|
|
MU_CONFIG_CMD_MKDIR,
|
|
|
|
MU_CONFIG_CMD_VIEW,
|
|
|
|
MU_CONFIG_CMD_EXTRACT,
|
2011-03-02 22:26:54 +01:00
|
|
|
MU_CONFIG_CMD_CFIND,
|
2011-01-04 22:19:03 +01:00
|
|
|
MU_CONFIG_CMD_NONE,
|
2011-01-02 17:05:43 +01:00
|
|
|
|
2011-01-04 22:19:03 +01:00
|
|
|
MU_CONFIG_CMD_UNKNOWN
|
2011-01-02 17:05:43 +01:00
|
|
|
};
|
|
|
|
typedef enum _MuConfigCmd MuConfigCmd;
|
|
|
|
|
|
|
|
|
2009-11-28 13:06:21 +01:00
|
|
|
/* struct with all configuration options for mu; it will be filled
|
|
|
|
* from the config file, and/or command line arguments */
|
|
|
|
|
2011-01-04 22:19:03 +01:00
|
|
|
struct _MuConfig {
|
2011-01-02 17:05:43 +01:00
|
|
|
|
2011-01-04 22:19:03 +01:00
|
|
|
MuConfigCmd cmd; /* the command, or
|
|
|
|
* MU_CONFIG_CMD_NONE */
|
|
|
|
const char *cmdstr; /* cmd string, for user info */
|
2009-11-28 13:06:21 +01:00
|
|
|
|
2011-01-04 22:19:03 +01:00
|
|
|
/* general options */
|
|
|
|
gboolean quiet; /* don't give any output */
|
|
|
|
gboolean debug; /* spew out debug info */
|
|
|
|
char *muhome; /* the House of Mu */
|
|
|
|
gboolean version; /* request mu version */
|
|
|
|
gboolean log_stderr; /* log to stderr (not logfile) */
|
|
|
|
gchar** params; /* parameters (for querying) */
|
2009-11-28 13:06:21 +01:00
|
|
|
|
2011-01-04 22:19:03 +01:00
|
|
|
/* options for indexing */
|
|
|
|
char *maildir; /* where the mails are */
|
|
|
|
gboolean nocleanup; /* don't cleanup deleted mails from db */
|
|
|
|
gboolean reindex; /* re-index existing mails */
|
|
|
|
gboolean rebuild; /* empty the database before indexing */
|
|
|
|
gboolean autoupgrade; /* automatically upgrade db
|
|
|
|
* when needed */
|
2011-01-15 12:27:41 +01:00
|
|
|
int xbatchsize; /* batchsize for xapian
|
2011-01-04 22:19:03 +01:00
|
|
|
* commits, or 0 for
|
|
|
|
* default */
|
2011-01-15 12:27:41 +01:00
|
|
|
int max_msg_size; /* maximum size for message files */
|
2011-01-02 17:05:43 +01:00
|
|
|
|
2011-03-04 23:59:35 +01:00
|
|
|
/* options for querying */
|
2011-01-06 15:34:21 +01:00
|
|
|
gboolean xquery; /* (obsolete) give the Xapian
|
|
|
|
query instead of search
|
2011-01-04 22:19:03 +01:00
|
|
|
results */
|
|
|
|
char *fields; /* fields to show in output */
|
|
|
|
char *sortfield; /* field to sort by (string) */
|
|
|
|
gboolean descending; /* sort descending? */
|
|
|
|
unsigned summary_len; /* max # of lines of msg in summary */
|
|
|
|
char *bookmark; /* use bookmark */
|
|
|
|
|
2011-01-05 19:35:50 +01:00
|
|
|
char *formatstr; /* output type
|
|
|
|
* (plain*,links,xml,json,sexp) */
|
|
|
|
|
2011-01-04 22:19:03 +01:00
|
|
|
/* output to a maildir with symlinks */
|
|
|
|
char *linksdir; /* maildir to output symlinks */
|
|
|
|
gboolean clearlinks; /* clear a linksdir before filling */
|
|
|
|
mode_t dirmode; /* mode for the created maildir */
|
|
|
|
|
|
|
|
/* options for extracting parts */
|
|
|
|
gboolean *save_all; /* extract all parts */
|
|
|
|
gboolean *save_attachments; /* extract all attachment parts */
|
|
|
|
gchar *parts; /* comma-sep'd list of parts
|
2011-01-09 13:55:25 +01:00
|
|
|
* to save / open */
|
2011-01-04 22:19:03 +01:00
|
|
|
char *targetdir; /* where to save the attachments */
|
|
|
|
gboolean overwrite; /* should we overwrite same-named files */
|
2011-01-09 13:55:25 +01:00
|
|
|
gboolean play; /* after saving, try to play (open) the attmnt */
|
2009-11-28 13:06:21 +01:00
|
|
|
};
|
2011-01-04 22:19:03 +01:00
|
|
|
typedef struct _MuConfig MuConfig;
|
2009-11-28 13:06:21 +01:00
|
|
|
|
2011-01-04 22:19:03 +01:00
|
|
|
/**
|
|
|
|
* create a new mu config object
|
|
|
|
*
|
2009-11-29 23:04:16 +01:00
|
|
|
* set default values for the configuration options; when you call
|
|
|
|
* mu_config_init, you should also call mu_config_uninit when the data
|
|
|
|
* is no longer needed.
|
2009-11-28 13:06:21 +01:00
|
|
|
*
|
2009-11-29 23:04:16 +01:00
|
|
|
* @param opts options
|
2009-11-28 13:06:21 +01:00
|
|
|
*/
|
2011-01-05 19:35:50 +01:00
|
|
|
MuConfig *mu_config_new (int *argcp, char ***argvp)
|
|
|
|
G_GNUC_WARN_UNUSED_RESULT;
|
2011-01-04 22:19:03 +01:00
|
|
|
/**
|
|
|
|
* free the MuOptionsConfig structure; the the muhome and maildir
|
2009-11-29 23:04:16 +01:00
|
|
|
* members are heap-allocated, so must be freed.
|
|
|
|
*
|
2011-01-04 22:19:03 +01:00
|
|
|
* @param opts a MuConfig struct, or NULL
|
2009-11-29 23:04:16 +01:00
|
|
|
*/
|
2011-01-04 22:19:03 +01:00
|
|
|
void mu_config_destroy (MuConfig *opts);
|
2009-11-29 23:04:16 +01:00
|
|
|
|
2011-01-04 22:19:03 +01:00
|
|
|
/**
|
|
|
|
* execute the command / options in this config
|
|
|
|
*
|
|
|
|
* @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
|
|
|
|
*/
|
|
|
|
MuExitCode mu_config_execute (MuConfig *opts);
|
2009-11-29 23:04:16 +01:00
|
|
|
|
2010-01-02 13:44:26 +01:00
|
|
|
G_END_DECLS
|
|
|
|
|
2009-11-28 13:06:21 +01:00
|
|
|
#endif /*__MU_CONFIG_H__*/
|