aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-05-12 11:33:28 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-05-12 11:33:28 +0800
commitc31e31f1fd019ac4297d840761026e64ea6a0adf (patch)
tree1d6e09604f49d15ec00d3ee26bca8ba9477d6e12 /e-util
parent443ab1ee8c4abf0c07727bc2e93b8f892294d324 (diff)
downloadgsoc2013-evolution-c31e31f1fd019ac4297d840761026e64ea6a0adf.tar
gsoc2013-evolution-c31e31f1fd019ac4297d840761026e64ea6a0adf.tar.gz
gsoc2013-evolution-c31e31f1fd019ac4297d840761026e64ea6a0adf.tar.bz2
gsoc2013-evolution-c31e31f1fd019ac4297d840761026e64ea6a0adf.tar.lz
gsoc2013-evolution-c31e31f1fd019ac4297d840761026e64ea6a0adf.tar.xz
gsoc2013-evolution-c31e31f1fd019ac4297d840761026e64ea6a0adf.tar.zst
gsoc2013-evolution-c31e31f1fd019ac4297d840761026e64ea6a0adf.zip
Tool to do i18n string extraction for error xml files.
2004-05-12 Not Zed <NotZed@Ximian.com> * e-error-tool.c: Tool to do i18n string extraction for error xml files. 2004-05-10 Not Zed <NotZed@Ximian.com> * e-fsutils.c (e_fsutils_usage): new file/function, get disk usage of a path, in 1024 byte blocks. (e_fsutils_avail): new file/function, get disk space available for a given path, in 1024 byte blocks. * e-meta.[ch]: Removed. Poor idea badly executed, and no longer used. * e-path.h: add a fixme about deprecation. svn path=/trunk/; revision=25868
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog16
-rw-r--r--e-util/Makefile.am17
-rw-r--r--e-util/e-error-tool.c131
-rw-r--r--e-util/e-fsutils.c145
-rw-r--r--e-util/e-fsutils.h34
-rw-r--r--e-util/e-meta.c521
-rw-r--r--e-util/e-meta.h60
-rw-r--r--e-util/e-path.h3
8 files changed, 343 insertions, 584 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 731e4c3227..96d6aa32e9 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,19 @@
+2004-05-12 Not Zed <NotZed@Ximian.com>
+
+ * e-error-tool.c: Tool to do i18n string extraction for error xml
+ files.
+
+2004-05-10 Not Zed <NotZed@Ximian.com>
+
+ * e-fsutils.c (e_fsutils_usage): new file/function, get disk usage
+ of a path, in 1024 byte blocks.
+ (e_fsutils_avail): new file/function, get disk space available for
+ a given path, in 1024 byte blocks.
+
+ * e-meta.[ch]: Removed. Poor idea badly executed, and no longer used.
+
+ * e-path.h: add a fixme about deprecation.
+
2004-04-30 Not Zed <NotZed@Ximian.com>
* e-lang-utils.[ch]: Removed. This is covered by
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index 54fd0affa6..e37aba449c 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -23,6 +23,7 @@ eutilinclude_HEADERS = \
e-dialog-utils.h \
e-dialog-widgets.h \
e-folder-map.h \
+ e-fsutils.h \
e-gtk-utils.h \
e-gui-utils.h \
e-host-utils.h \
@@ -32,7 +33,6 @@ eutilinclude_HEADERS = \
e-list-iterator.h \
e-list.h \
e-memory.h \
- e-meta.h \
e-mktemp.h \
e-msgport.h \
e-passwords.h \
@@ -53,7 +53,6 @@ libeutil_la_SOURCES = \
e-account-list.c \
e-account.c \
e-bconf-map.c \
- e-folder-map.c \
e-categories-config.c \
e-categories-master-list-wombat.c \
e-component-listener.c \
@@ -61,6 +60,8 @@ libeutil_la_SOURCES = \
e-corba-utils.c \
e-dialog-utils.c \
e-dialog-widgets.c \
+ e-folder-map.c \
+ e-fsutils.c \
e-gtk-utils.c \
e-gui-utils.c \
e-host-utils.c \
@@ -70,7 +71,6 @@ libeutil_la_SOURCES = \
e-list-iterator.c \
e-list.c \
e-memory.c \
- e-meta.c \
e-mktemp.c \
e-msgport.c \
e-passwords.c \
@@ -111,6 +111,17 @@ endif
libeconduit_la_SOURCES = $(pilot_compile)
+# e-error-tool
+
+e_error_tool_SOURCES = \
+ e-error-tool.c
+
+e_error_tool_LDADD = \
+ $(GNOME_FULL_LIBS)
+
+noinst_PROGRAMS = \
+ e-error-tool
+
EXTRA_DIST = \
$(pilot_sources) \
ChangeLog.pre-1-4 \
diff --git a/e-util/e-error-tool.c b/e-util/e-error-tool.c
new file mode 100644
index 0000000000..c6f1e0ff8c
--- /dev/null
+++ b/e-util/e-error-tool.c
@@ -0,0 +1,131 @@
+
+#include <errno.h>
+
+#include <stdio.h>
+
+#include <string.h>
+#include <sys/types.h>
+#include <dirent.h>
+
+#include <unistd.h>
+
+#include <libxml/parser.h>
+#include <libxml/xmlmemory.h>
+
+#include <glib.h>
+
+static void
+dump_cstring(FILE *out, const char *tmp)
+{
+ const char *p;
+ int c;
+
+ fprintf(out, "char *s = N_(\"");
+ p = tmp;
+ while ( (c = *p++) ) {
+ switch (c) {
+ case '\n':
+ fprintf(out, "\\n\"\n\t\"");
+ break;
+ case '\r':
+ fprintf(out, "\\r");
+ break;
+ case '\t':
+ fprintf(out, "\\t");
+ break;
+ case '"':
+ case '\\':
+ fprintf(out, "\\%c", c);
+ break;
+ default:
+ fputc(c, out);
+ }
+ }
+
+ fprintf(out, "\");\n");
+}
+
+static void
+extract_strings(FILE *out, const char *path)
+{
+ xmlDocPtr doc;
+ xmlNodePtr root, error, scan;
+ char *tmp, *domain;
+
+ doc = xmlParseFile(path);
+ if (doc == NULL) {
+ g_warning("Error file '%s' not found", path);
+ return;
+ }
+
+ root = xmlDocGetRootElement(doc);
+ if (root == NULL
+ || strcmp(root->name, "error-list") != 0
+ || (domain = xmlGetProp(root, "domain")) == NULL) {
+ g_warning("Error file '%s' invalid format", path);
+ xmlFreeDoc(doc);
+ return;
+ }
+
+ for (error = root->children;error;error = error->next) {
+ char *id;
+
+ if (strcmp(error->name, "error") != 0)
+ continue;
+
+ id = xmlGetProp(error, "id");
+ if (id == NULL) {
+ g_warning("Error format invalid, missing error id");
+ _exit(1);
+ }
+
+ for (scan = error->children;scan;scan=scan->next) {
+ if (!strcmp(scan->name, "primary")
+ || !strcmp(scan->name, "secondary")
+ || !strcmp(scan->name, "title")) {
+ fprintf(out, "/* %s:%s %s */\n", domain, id, scan->name);
+ tmp = xmlNodeGetContent(scan);
+ if (tmp) {
+ dump_cstring(out, tmp);
+ xmlFree(tmp);
+ }
+ } else if (!strcmp(scan->name, "button")) {
+ tmp = xmlGetProp(scan, "label");
+ if (tmp) {
+ dump_cstring(out, tmp);
+ xmlFree(tmp);
+ }
+ }
+ }
+ xmlFree(id);
+ }
+
+ xmlFree(domain);
+
+ xmlFreeDoc(doc);
+}
+
+int main(int argc, char **argv)
+{
+ int i;
+ FILE *out;
+
+ for (i=1;i<argc;i++) {
+ char *name;
+
+ name = g_strdup_printf("%s.h", argv[i]);
+ out = fopen(name, "w");
+ if (out == NULL) {
+ fprintf(stderr, "Error creating %s: %s\n", name, strerror(errno));
+ return 1;
+ }
+ extract_strings(out, argv[i]);
+ if (fclose(out) != 0) {
+ fprintf(stderr, "Error writing to %s: %s\n", name, strerror(errno));
+ return 1;
+ }
+ g_free(name);
+ }
+
+ return 0;
+}
diff --git a/e-util/e-fsutils.c b/e-util/e-fsutils.c
new file mode 100644
index 0000000000..d2c615124b
--- /dev/null
+++ b/e-util/e-fsutils.c
@@ -0,0 +1,145 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Authors: Michael Zucchi <notzed@ximian.com>
+ *
+ * Copyright 2004 Ximian, Inc. (www.ximian.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * 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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dirent.h>
+
+/* This isn't as portable as, say, the stuff in GNU coreutils. But I care not for OSF1. */
+#ifdef HAVE_STATFS
+# ifdef HAVE_SYS_VFS_H
+# include <sys/vfs.h> /* linux interface */
+# endif
+# ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h> /* bsd interface */
+# endif
+# ifdef HAVE_SYS_MOUNT_H
+# include <sys/mount.h>
+# endif
+#endif
+
+#include <errno.h>
+#include <string.h>
+
+#include "e-fsutils.h"
+
+/**
+ * e_fsutils_usage:
+ * @path:
+ *
+ * Calculate the amount of disk space used by a given path.
+ *
+ * Return value: The number of 1024 byte blocks used by the
+ * filesystem.
+ **/
+long e_fsutils_usage(const char *inpath)
+{
+ DIR *dir;
+ struct dirent *d;
+ long size = 0;
+ GSList *paths;
+
+ /* iterative, depth-first scan, because i can ... */
+ paths = g_slist_prepend(NULL, g_strdup(inpath));
+
+ while (paths) {
+ char *path = paths->data;
+
+ paths = g_slist_remove_link(paths, paths);
+
+ dir = opendir(path);
+ if (dir == NULL) {
+ g_free(path);
+ goto fail;
+ }
+
+ while ((d = readdir(dir))) {
+ char *full_path;
+ struct stat st;
+
+ if (strcmp(d->d_name, ".") == 0
+ || strcmp(d->d_name, "..") == 0)
+ continue;
+
+ full_path = g_build_filename(path, d->d_name, NULL);
+ if (stat(full_path, &st) == -1) {
+ g_free(full_path);
+ closedir(dir);
+ g_free(path);
+ goto fail;
+ } else if (S_ISDIR(st.st_mode)) {
+ paths = g_slist_prepend(paths, full_path);
+ full_path = NULL;
+ } else if (S_ISREG(st.st_mode)) {
+ /* This is in 512 byte blocks. st_blksize is page size on linux,
+ on *BSD it might be significant. */
+ size += st.st_blocks/2;
+ }
+
+ g_free(full_path);
+ }
+
+ closedir(dir);
+ g_free(path);
+ }
+
+ return size;
+
+fail:
+ g_slist_foreach(paths, (GFunc)g_free, NULL);
+ g_slist_free(paths);
+
+ return -1;
+}
+
+/**
+ * e_fsutils_avail:
+ * @path:
+ *
+ * Find the available disk space at the given path.
+ *
+ * Return value: -1 if it could not be determined, otherwise the
+ * number of disk blocks, expressed as system-independent, 1024 byte
+ * blocks.
+ **/
+long
+e_fsutils_avail(const char *path)
+{
+#ifdef HAVE_STATFS
+ struct statfs stfs;
+
+ if (statfs(path, &stfs) == -1)
+ return -1;
+
+ /* On linux at least, bavail is in 512 byte blocks */
+ /* For BSD this isn't clear, it may be dependent on f_bsize, which on linux is rather, the page size! */
+ return stfs.f_bavail / 2;
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+}
+
diff --git a/e-util/e-fsutils.h b/e-util/e-fsutils.h
new file mode 100644
index 0000000000..915e702a9a
--- /dev/null
+++ b/e-util/e-fsutils.h
@@ -0,0 +1,34 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Authors: Michael Zucchi <notzed@ximian.com>
+ *
+ * Copyright 2004 Ximian, Inc. (www.ximian.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * 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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef E_FSUTILS_H
+#define E_FSUTILS_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+long e_fsutils_usage(const char *path);
+long e_fsutils_avail(const char *path);
+
+G_END_DECLS
+
+#endif /* !E_FOLDER_MAP_H */
diff --git a/e-util/e-meta.c b/e-util/e-meta.c
deleted file mode 100644
index a4c0ad562b..0000000000
--- a/e-util/e-meta.c
+++ /dev/null
@@ -1,521 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Authors: Michael Zucchi <notzed@ximian.com>
- *
- * Copyright 2003 Ximian, Inc. (www.ximian.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
-
-#include <glib.h>
-
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <libxml/xmlmemory.h>
-
-#include <sys/stat.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-
-#include <gal/util/e-xml-utils.h>
-#include <gal/util/e-util.h>
-#include "e-meta.h"
-
-static GObjectClass *e_meta_parent_class;
-
-struct _meta_data {
- struct _meta_data *next;
-
- char *md_key;
- char *md_value;
-};
-
-struct _EMetaPrivate {
- char *path;
- struct _meta_data *data;
- gulong sync_id;
- /* if set, we wont try and save/etc */
- unsigned int deleted:1;
-};
-
-static int meta_save(EMeta *em)
-{
- struct _EMetaPrivate *p = em->priv;
- xmlDocPtr doc;
- xmlNodePtr root, work;
- struct _meta_data *md;
- int res;
- char *dir;
- struct stat st;
-
- if (p->deleted)
- return 0;
-
- /* since we can, build the full path if we need to */
- dir = g_path_get_dirname(p->path);
- if (stat(dir, &st) == -1) {
- e_mkdir_hier(dir, 0777);
- g_free(dir);
- }
-
- /* of course, saving in xml is overkill, but everyone loves this shit ... */
-
- doc = xmlNewDoc("1.0");
- root = xmlNewDocNode(doc, NULL, "e-meta-data", NULL);
- xmlDocSetRootElement(doc, root);
-
- md = p->data;
- while (md) {
- work = xmlNewChild(root, NULL, "item", NULL);
- xmlSetProp(work, "name", md->md_key);
- xmlSetProp(work, "value", md->md_value);
- md = md->next;
- }
-
- res = e_xml_save_file(p->path, doc);
- if (res != 0)
- g_warning("Could not save folder meta-data `%s': %s", p->path, g_strerror(errno));
-
- xmlFreeDoc(doc);
-
- return res;
-}
-
-static int meta_load(EMeta *em)
-{
- struct _EMetaPrivate *p = em->priv;
- struct _meta_data *tail, *md;
- xmlDocPtr doc = NULL;
- xmlNodePtr root, work;
- char *name, *val;
- struct stat st;
-
- if (stat (p->path, &st) == -1 || !S_ISREG (st.st_mode))
- return -1;
-
- doc = xmlParseFile(p->path);
- if (doc == NULL)
- return -1;
-
- root = xmlDocGetRootElement(doc);
- if (root == NULL || strcmp(root->name, "e-meta-data")) {
- xmlFreeDoc(doc);
- errno = EINVAL;
- return -1;
- }
-
- work = root->children;
- tail = (struct _meta_data *)&p->data;
- while (work) {
- if (strcmp(work->name, "item") == 0) {
- name = xmlGetProp(work, "name");
- val = xmlGetProp(work, "value");
- if (name && val) {
- md = g_malloc(sizeof(*md));
- md->md_key = g_strdup(name);
- md->md_value = g_strdup(val);
- md->next = NULL;
- tail->next = md;
- tail = md;
- }
- if (name)
- xmlFree(name);
- if (val)
- xmlFree(val);
- }
- work = work->next;
- }
-
- xmlFreeDoc(doc);
-
- return 0;
-}
-
-static struct _meta_data *meta_find(EMeta *em, const char *key, struct _meta_data **mpp)
-{
- struct _meta_data *mp = (struct _meta_data *)&em->priv->data;
- struct _meta_data *md = mp->next;
-
- while (md && strcmp(md->md_key, key) != 0) {
- mp = md;
- md = md->next;
- }
-
- *mpp = mp;
-
- return md;
-}
-
-static void meta_free(struct _meta_data *md)
-{
- g_free(md->md_key);
- g_free(md->md_value);
- g_free(md);
-}
-
-static void
-e_meta_init (EMeta *em)
-{
- em->priv = g_malloc0(sizeof(*em->priv));
-}
-
-static void
-e_meta_finalise(GObject *crap)
-{
- EMeta *em = (EMeta *)crap;
- struct _EMetaPrivate *p = em->priv;
- struct _meta_data *md, *mn;
-
- if (p->sync_id != 0)
- e_meta_sync(em);
-
- md = p->data;
- while (md) {
- mn = md->next;
- meta_free(md);
- md = mn;
- }
-
- g_free(p->path);
- g_free(p);
- e_meta_parent_class->finalize((GObject *)em);
-}
-
-static void
-e_meta_class_init (EMetaClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS(klass);
-
- e_meta_parent_class = g_type_class_ref (G_TYPE_OBJECT);
-
- ((GObjectClass *)klass)->finalize = e_meta_finalise;
-}
-
-static GTypeInfo e_meta_type_info = {
- sizeof (EMetaClass),
- NULL, /* base_class_init */
- NULL, /* base_class_finalize */
- (GClassInitFunc) e_meta_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (EMeta),
- 0, /* n_preallocs */
- (GInstanceInitFunc) e_meta_init
-};
-
-static GType e_meta_type;
-
-GType
-e_meta_get_type (void)
-{
- return e_meta_type?e_meta_type:(e_meta_type = g_type_register_static (G_TYPE_OBJECT, "EMeta", &e_meta_type_info, 0));
-}
-
-/**
- * e_meta_new:
- * @path: full path to meta-data storage object.
- *
- * Create a new meta-data storage object. Any existing meta-data stored for
- * this key will be loaded.
- *
- * Return value:
- **/
-EMeta *
-e_meta_new(const char *path)
-{
- EMeta *em;
-
- em = g_object_new(e_meta_get_type(), NULL);
- em->priv->path = g_strdup(path);
- meta_load(em);
-
- return em;
-}
-
-static gboolean
-meta_flush(EMeta *em)
-{
- em->priv->sync_id = 0;
- meta_save(em);
-
- return FALSE;
-}
-
-/* returns TRUE if the value changed */
-static int meta_set(EMeta *em, const char *key, const char *val)
-{
- struct _EMetaPrivate *p = em->priv;
- struct _meta_data *md, *mp;
-
- md = meta_find(em, key, &mp);
- if (md == NULL) {
- /* already unset / or new case */
- if (val == NULL)
- return FALSE;
- md = g_malloc0(sizeof(*md));
- md->md_key = g_strdup(key);
- md->next = p->data;
- p->data = md;
- } else if (val == NULL) {
- /* unset case */
- mp->next = md->next;
- meta_free(md);
- return TRUE;
- } else if (strcmp(md->md_value, val) == 0) {
- /* unchanged value */
- return FALSE;
- } else {
- /* changed value */
- g_free(md->md_value);
- }
- md->md_value = g_strdup(val);
-
- return TRUE;
-}
-
-/* get a value, returns NULL if it doesn't exist */
-static const char *meta_get(EMeta *em, const char *key)
-{
- struct _meta_data *md, *mp;
-
- md = meta_find(em, key, &mp);
-
- return md?md->md_value:NULL;
-}
-
-/**
- * e_meta_set:
- * @em:
- * @key:
- * @...: value, key, value, ..., NULL.
- *
- * Set any number of meta-data key-value pairs.
- * Unset a key by passing a value of NULL.
- *
- * If the meta-data set changes as a result of this
- * call, then a sync will be implicitly queued for
- * a later time.
- **/
-void
-e_meta_set(EMeta *em, const char *key, ...)
-{
- struct _EMetaPrivate *p = em->priv;
- const char *val;
- va_list ap;
- int changed = FALSE;
-
- va_start(ap, key);
- while (key != NULL) {
- val = va_arg(ap, const char *);
- changed = meta_set(em, key, val);
- key = va_arg(ap, const char *);
- }
- va_end(ap);
-
- /* todo: could do changed events ? */
-
- if (changed && p->sync_id == 0)
- p->sync_id = g_timeout_add(2000, (GSourceFunc)meta_flush, em);
-}
-
-/**
- * e_meta_get:
- * @em:
- * @key:
- * @...: value, key, value, ..., NULL.
- *
- * Get any number of meta-data key-value pairs.
- **/
-void
-e_meta_get(EMeta *em, const char *key, ...)
-{
- const char **valp;
- va_list ap;
-
- va_start(ap, key);
- while (key) {
- valp = va_arg(ap, const char **);
- *valp = meta_get(em, key);
- key = va_arg(ap, const char *);
- }
- va_end(ap);
-}
-
-/**
- * e_meta_get_bool:
- * @em:
- * @key:
- * @def:
- *
- * Get a boolean value at @key, with a default fallback @def.
- *
- * If the default value is used, then it will become the persistent
- * new value for the key.
- *
- * Return value: The value of the key, or if the key was not
- * previously set, then the new value of the key, @def.
- **/
-gboolean
-e_meta_get_bool(EMeta *em, const char *key, gboolean def)
-{
- const char *v;
-
- v = meta_get(em, key);
- /* this forces the value to become 'static' from first use */
- if (v == NULL) {
- e_meta_set_bool(em, key, def);
- return def;
- }
-
- return atoi(v);
-}
-
-/**
- * e_meta_set_bool:
- * @em:
- * @key:
- * @val:
- *
- * Helper to set a boolean value. Boolean TRUE is mapped to
- * the string "1", FALSE to "0".
- **/
-void
-e_meta_set_bool(EMeta *em, const char *key, gboolean val)
-{
- e_meta_set(em, key, val?"1":"0", NULL);
-}
-
-/**
- * e_meta_sync:
- * @em:
- *
- * Force an explicit and immediate sync of the meta-data to disk.
- *
- * This is not normally required unless part of transactional
- * processing, as updates will always be flushed to disk automatically.
- *
- * Return value: 0 on success.
- **/
-int
-e_meta_sync(EMeta *em)
-{
- struct _EMetaPrivate *p = em->priv;
-
- if (p->sync_id != 0) {
- g_source_remove(p->sync_id);
- p->sync_id = 0;
- }
-
- return meta_save(em);
-}
-
-static GHashTable *e_meta_table;
-
-static char *meta_filename(const char *base, const char *key)
-{
- const char *p;
- char *keyp, *o, c;
-
- p = key;
- o = keyp = alloca(strlen(key)+8);
-
- while ( (c = *p++) ) {
- if (c == '/')
- c = '_';
- *o++ = c;
- }
- strcpy(o, ".emeta");
- o = g_build_filename(base, keyp, NULL);
-
- return o;
-}
-
-static void
-meta_weak_notify(char *path, void *o)
-{
- g_hash_table_remove(e_meta_table, path);
- g_free(path);
-}
-
-/**
- * e_meta_data_lookup:
- * @base: Base storage directory.
- * @key: key for file.
- *
- * Lookup a meta-data object from a storage directory.
- *
- * Return value: The metadata object.
- **/
-EMeta *e_meta_data_find(const char *base, const char *key)
-{
- EMeta *em;
- char *path;
-
- if (e_meta_table == NULL)
- e_meta_table = g_hash_table_new(g_str_hash, g_str_equal);
-
- path = meta_filename(base, key);
- em = g_hash_table_lookup(e_meta_table, path);
- if (em) {
- g_free(path);
- g_object_ref(em);
- return em;
- }
-
- em = e_meta_new(path);
- g_hash_table_insert(e_meta_table, path, em);
- g_object_weak_ref((GObject *)em, (GWeakNotify)meta_weak_notify, path);
-
- return em;
-}
-
-/**
- * e_meta_data_delete:
- * @base:
- * @key:
- *
- * Delete a key from storage. If the key is still cached, it will be
- * marked as deleted, and will not be saved from then on.
- **/
-void e_meta_data_delete(const char *base, const char *key)
-{
- EMeta *em;
- char *path;
-
- path = meta_filename(base, key);
-
- if (e_meta_table && (em = g_hash_table_lookup(e_meta_table, path))) {
- if (em->priv->sync_id) {
- g_source_remove(em->priv->sync_id);
- em->priv->sync_id = 0;
- }
- em->priv->deleted = TRUE;
- }
-
- unlink(path);
- g_free(path);
-}
diff --git a/e-util/e-meta.h b/e-util/e-meta.h
deleted file mode 100644
index 19c23e3a06..0000000000
--- a/e-util/e-meta.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- *
- *
- * A simple persistent meta-data api.
- *
- * Authors: Michael Zucchi <notzed@ximian.com>
- *
- * Copyright 2003 Ximian, Inc. (www.ximian.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * 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., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef _E_META_H
-#define _E_META_H 1
-
-#include <glib.h>
-#include <glib-object.h>
-
-typedef struct _EMeta EMeta;
-typedef struct _EMetaClass EMetaClass;
-
-struct _EMeta {
- GObject object;
-
- struct _EMetaPrivate *priv;
-};
-
-struct _EMetaClass {
- GObjectClass object;
-};
-
-GType e_meta_get_type (void);
-
-/* 'trivial' meta-data api */
-EMeta *e_meta_new(const char *path);
-void e_meta_set(EMeta *em, const char *key, ...);
-void e_meta_get(EMeta *em, const char *key, ...);
-int e_meta_sync(EMeta *em);
-
-/* helpers */
-gboolean e_meta_get_bool(EMeta *, const char *key, gboolean def);
-void e_meta_set_bool(EMeta *, const char *key, gboolean val);
-
-/* 'class' methods */
-EMeta *e_meta_data_find(const char *base, const char *key);
-void e_meta_data_delete(const char *base, const char *key);
-
-#endif /* ! _E_META_H */
diff --git a/e-util/e-path.h b/e-util/e-path.h
index 2295889778..58c12874da 100644
--- a/e-util/e-path.h
+++ b/e-util/e-path.h
@@ -22,6 +22,9 @@
#include <glib.h>
+/* FIXME: deprecated
+ This is used exclusively for the legacy imap cache code. DO NOT use this in any new code */
+
typedef gboolean (*EPathFindFoldersCallback) (const char *physical_path,
const char *path,
gpointer user_data);