* minor updates / cleanups

This commit is contained in:
Dirk-Jan C. Binnema
2011-05-22 17:39:10 +03:00
parent 744b363d8e
commit 34683157d1
5 changed files with 26 additions and 35 deletions

View File

@ -1,3 +1,5 @@
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
/* /*
** Copyright (C) 2010-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2010-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
@ -50,7 +52,7 @@ each_part (MuMsg *msg, MuMsgPart *part, gchar **attach)
} }
/* return comma-sep'd list of attachments */ /* return comma-sep'd list of attachments */
gchar * static gchar *
get_attach_str (MuMsg *msg) get_attach_str (MuMsg *msg)
{ {
gchar *attach; gchar *attach;

View File

@ -1,3 +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> ** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **

View File

@ -1,5 +1,7 @@
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
/* /*
** Copyright (C) 2008-2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify ** 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 ** it under the terms of the GNU General Public License as published by
@ -56,8 +58,8 @@ gboolean mu_log_init_with_fd (int fd, gboolean doclose, gboolean quiet,
gboolean debug) G_GNUC_WARN_UNUSED_RESULT; gboolean debug) G_GNUC_WARN_UNUSED_RESULT;
/** /**
* be absolutely silent, except for runtime errors, which will be * be silent except for runtime errors, which will be written to
* written to stderr. * stderr.
* *
* @return TRUE if initialization succeeds, FALSE otherwise * @return TRUE if initialization succeeds, FALSE otherwise
*/ */

View File

@ -1,3 +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> ** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
@ -28,8 +30,8 @@
#include "mu-util.h" #include "mu-util.h"
char* static char*
mu_util_xapian_get_metadata (const gchar *xpath, const gchar *key) xapian_get_metadata (const gchar *xpath, const gchar *key)
{ {
g_return_val_if_fail (xpath, NULL); g_return_val_if_fail (xpath, NULL);
g_return_val_if_fail (key, NULL); g_return_val_if_fail (key, NULL);
@ -49,37 +51,12 @@ mu_util_xapian_get_metadata (const gchar *xpath, const gchar *key)
return NULL; return NULL;
} }
gboolean
mu_util_xapian_set_metadata (const gchar *xpath,
const gchar *key, const gchar *val)
{
g_return_val_if_fail (xpath, FALSE);
g_return_val_if_fail (key, FALSE);
g_return_val_if_fail (val, FALSE);
if (!access(xpath, F_OK) == 0) {
g_warning ("cannot access %s: %s", xpath, strerror(errno));
return FALSE;
}
try {
Xapian::WritableDatabase db (xpath, Xapian::DB_OPEN);
db.set_metadata (key, val);
return TRUE;
} MU_XAPIAN_CATCH_BLOCK;
return FALSE;
}
char* char*
mu_util_xapian_dbversion (const gchar *xpath) mu_util_xapian_dbversion (const gchar *xpath)
{ {
g_return_val_if_fail (xpath, NULL); g_return_val_if_fail (xpath, NULL);
return mu_util_xapian_get_metadata (xpath, MU_STORE_VERSION_KEY); return xapian_get_metadata (xpath, MU_STORE_VERSION_KEY);
} }
gboolean gboolean
@ -151,7 +128,8 @@ mu_util_xapian_is_locked (const gchar *xpath)
} catch (const Xapian::DatabaseLockError& xer) { } catch (const Xapian::DatabaseLockError& xer) {
return TRUE; return TRUE;
} catch (const Xapian::Error &xer) { } catch (const Xapian::Error &xer) {
g_warning ("%s: error: %s", __FUNCTION__, xer.get_msg().c_str()); g_warning ("%s: error: %s", __FUNCTION__,
xer.get_msg().c_str());
} }
return FALSE; return FALSE;

View File

@ -159,7 +159,14 @@ gboolean mu_util_play (const char *path,
gchar* mu_util_xapian_dbversion (const gchar *xpath) G_GNUC_WARN_UNUSED_RESULT; gchar* mu_util_xapian_dbversion (const gchar *xpath) G_GNUC_WARN_UNUSED_RESULT;
/**
* check whether the database needs to be upgraded, e.g., when it was
* created with a different version of mu
*
* @param xpath path to the database dir
*
* @return TRUE if the database needs upgrading, FALSE otherwise
*/
gboolean mu_util_xapian_needs_upgrade (const gchar *xpath); gboolean mu_util_xapian_needs_upgrade (const gchar *xpath);
@ -322,7 +329,7 @@ typedef gpointer XapianEnquire;
/* name of the bookmark file */ /* name of the bookmark file */
#define MU_BOOKMARK_FILENAME "bookmarks" #define MU_BOOKMARK_FILENAME "bookmarks"
/* metdata key for the xapian 'schema' version */ /* metadata key for the xapian 'schema' version */
#define MU_STORE_VERSION_KEY "db_version" #define MU_STORE_VERSION_KEY "db_version"