diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-03-03 04:00:01 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2010-03-30 07:04:00 +0800 |
commit | 797acc24457e34c29332d9f1be5bd19e84aab111 (patch) | |
tree | 6a7ffd65d824ffab78c50794bfc9b20bdfdd35af /e-util | |
parent | 3c1c071f490c2b090326b53c29540fff713af380 (diff) | |
download | gsoc2013-evolution-797acc24457e34c29332d9f1be5bd19e84aab111.tar gsoc2013-evolution-797acc24457e34c29332d9f1be5bd19e84aab111.tar.gz gsoc2013-evolution-797acc24457e34c29332d9f1be5bd19e84aab111.tar.bz2 gsoc2013-evolution-797acc24457e34c29332d9f1be5bd19e84aab111.tar.lz gsoc2013-evolution-797acc24457e34c29332d9f1be5bd19e84aab111.tar.xz gsoc2013-evolution-797acc24457e34c29332d9f1be5bd19e84aab111.tar.zst gsoc2013-evolution-797acc24457e34c29332d9f1be5bd19e84aab111.zip |
Drop support for migrating from Evolution < 2.0.
There's too much ancient, crufty code there that we can't realistically
support anymore. A workaround for those poor users still on 1.x is to
upgrade to some 2.x release first, then upgrade again to 3.x. An error
dialog explaining this will be shown at startup.
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/Makefile.am | 4 | ||||
-rw-r--r-- | e-util/e-bconf-map.c | 537 | ||||
-rw-r--r-- | e-util/e-bconf-map.h | 95 | ||||
-rw-r--r-- | e-util/e-file-utils.c | 105 | ||||
-rw-r--r-- | e-util/e-file-utils.h | 3 | ||||
-rw-r--r-- | e-util/e-folder-map.c | 187 | ||||
-rw-r--r-- | e-util/e-folder-map.h | 36 |
7 files changed, 0 insertions, 967 deletions
diff --git a/e-util/Makefile.am b/e-util/Makefile.am index 99f873cbd8..3a9c723ec1 100644 --- a/e-util/Makefile.am +++ b/e-util/Makefile.am @@ -15,7 +15,6 @@ eutilinclude_HEADERS = \ e-alert.h \ e-alert-activity.h \ e-alert-dialog.h \ - e-bconf-map.h \ e-binding.h \ e-bit-array.h \ e-categories-config.h \ @@ -28,7 +27,6 @@ eutilinclude_HEADERS = \ e-extensible.h \ e-extension.h \ e-file-utils.h \ - e-folder-map.h \ e-html-utils.h \ e-icon-factory.h \ e-import.h \ @@ -95,7 +93,6 @@ libeutil_la_SOURCES = \ e-alert.c \ e-alert-activity.c \ e-alert-dialog.c \ - e-bconf-map.c \ e-binding.c \ e-bit-array.c \ e-categories-config.c \ @@ -108,7 +105,6 @@ libeutil_la_SOURCES = \ e-extensible.c \ e-extension.c \ e-file-utils.c \ - e-folder-map.c \ e-html-utils.c \ e-icon-factory.c \ e-import.c \ diff --git a/e-util/e-bconf-map.c b/e-util/e-bconf-map.c deleted file mode 100644 index d0bd526715..0000000000 --- a/e-util/e-bconf-map.c +++ /dev/null @@ -1,537 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <glib.h> - -#include <libxml/tree.h> -#include <libxml/parser.h> -#include <libxml/xmlmemory.h> - -#include "e-bconf-map.h" - -#define d(x) - -static gchar hexnib[256] = { - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,-1,-1,-1,-1,-1,-1, - -1,10,11,12,13,14,15,16,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,10,11,12,13,14,15,16,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, - -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -}; - -gchar * -e_bconf_hex_decode (const gchar *val) -{ - const guchar *p; - gchar *o, *res; - - o = res = g_malloc (strlen (val) / 2 + 1); - for (p = (const guchar *)val; (p[0] && p[1]); p += 2) - *o++ = (hexnib[p[0]] << 4) | hexnib[p[1]]; - *o = 0; - - return res; -} - -gchar * -e_bconf_url_decode (const gchar *val) -{ - const guchar *p = (const guchar *) val; - gchar *o, *res, c; - - o = res = g_malloc (strlen (val) + 1); - while (*p) { - c = *p++; - if (c == '%' - && hexnib[p[0]] != -1 && hexnib[p[1]] != -1) { - *o++ = (hexnib[p[0]] << 4) | hexnib[p[1]]; - p+=2; - } else - *o++ = c; - } - *o = 0; - - return res; -} - -xmlNodePtr -e_bconf_get_path (xmlDocPtr doc, const gchar *path) -{ - xmlNodePtr root; - gchar *val; - gint found; - - root = doc->children; - if (strcmp ((gchar *)root->name, "bonobo-config") != 0) { - g_warning ("not bonobo-config xml file"); - return NULL; - } - - root = root->children; - while (root) { - if (!strcmp ((gchar *)root->name, "section")) { - val = (gchar *)xmlGetProp (root, (const guchar *)"path"); - found = val && strcmp (val, path) == 0; - xmlFree (val); - if (found) - break; - } - root = root->next; - } - - return root; -} - -xmlNodePtr -e_bconf_get_entry (xmlNodePtr root, const gchar *name) -{ - xmlNodePtr node = root->children; - gint found; - gchar *val; - - while (node) { - if (!strcmp ((gchar *)node->name, "entry")) { - val = (gchar *)xmlGetProp (node, (const guchar *)"name"); - found = val && strcmp (val, name) == 0; - xmlFree (val); - if (found) - break; - } - node = node->next; - } - - return node; -} - -gchar * -e_bconf_get_value (xmlNodePtr root, const gchar *name) -{ - xmlNodePtr node = e_bconf_get_entry (root, name); - gchar *prop, *val = NULL; - - if (node && (prop = (gchar *)xmlGetProp (node, (const guchar *)"value"))) { - val = g_strdup (prop); - xmlFree (prop); - } - - return val; -} - -gchar * -e_bconf_get_bool (xmlNodePtr root, const gchar *name) -{ - gchar *val, *res; - - if ((val = e_bconf_get_value (root, name))) { - res = g_strdup (val[0] == '1' ? "true" : "false"); - g_free (val); - } else - res = NULL; - - return res; -} - -gchar * -e_bconf_get_long (xmlNodePtr root, const gchar *name) -{ - gchar *val, *res; - - if ((val = e_bconf_get_value (root, name))) { - res = g_strdup (val); - g_free (val); - } else - res = NULL; - - return res; -} - -gchar * -e_bconf_get_string (xmlNodePtr root, const gchar *name) -{ - gchar *val, *res; - - if ((val = e_bconf_get_value (root, name))) { - res = e_bconf_hex_decode (val); - g_free (val); - } else - res = NULL; - - return res; -} - -/* lookup functions */ -typedef gchar * (* bconf_lookup_func) (xmlNodePtr root, const gchar *name, e_bconf_map_t *nap); - -static gchar * -bconf_lookup_bool (xmlNodePtr root, const gchar *name, e_bconf_map_t *map) -{ - return e_bconf_get_bool (root, name); -} - -static gchar * -bconf_lookup_long (xmlNodePtr root, const gchar *name, e_bconf_map_t *map) -{ - return e_bconf_get_long (root, name); -} - -static gchar * -bconf_lookup_string (xmlNodePtr root, const gchar *name, e_bconf_map_t *map) -{ - return e_bconf_get_string (root, name); -} - -static gchar * -bconf_lookup_enum (xmlNodePtr root, const gchar *name, e_bconf_map_t *map) -{ - gint index = 0, i; - gchar *val; - - if ((val = e_bconf_get_value (root, name))) { - index = atoi (val); - g_free (val); - } - - for (i = 0; map->child[i].from; i++) { - if (i == index) - return g_strdup (map->child[i].from); - } - - return NULL; -} - -static bconf_lookup_func lookup_table[] = { - bconf_lookup_bool, bconf_lookup_long, bconf_lookup_string, bconf_lookup_enum -}; - -static gchar * -get_name (const gchar *in, gint index) -{ - GString *out = g_string_new (""); - gchar c, *res; - - while ((c = *in++)) { - if (c == '%') { - c = *in++; - switch (c) { - case '%': - g_string_append_c (out, '%'); - break; - case 'i': - g_string_append_printf (out, "%d", index); - break; - } - } else { - g_string_append_c (out, c); - } - } - - res = out->str; - g_string_free (out, FALSE); - - return res; -} - -static void -build_xml (xmlNodePtr root, e_bconf_map_t *map, gint index, xmlNodePtr source) -{ - gchar *name, *value; - xmlNodePtr node; - - while (map->type != E_BCONF_MAP_END) { - if ((map->type & E_BCONF_MAP_MASK) == E_BCONF_MAP_CHILD) { - node = xmlNewChild (root, NULL, (guchar *)map->to, NULL); - build_xml (node, map->child, index, source); - } else { - name = get_name (map->from, index); - value = lookup_table[(map->type & E_BCONF_MAP_MASK) - 1] (source, name, map); - - d(printf ("key '%s=%s' -> ", name, value)); - - if (map->type & E_BCONF_MAP_CONTENT) { - if (value && value[0]) - xmlNewTextChild (root, NULL, (guchar *)map->to, (guchar *)value); - } else { - xmlSetProp (root, (guchar *)map->to, (guchar *)value); - } - - g_free (value); - g_free (name); - } - map++; - } -} - -gint -e_bconf_import_xml_blob (GConfClient *gconf, xmlDocPtr config_xmldb, e_bconf_map_t *map, - const gchar *bconf_path, const gchar *gconf_path, - const gchar *name, const gchar *idparam) -{ - xmlNodePtr source; - gint count = 0, i; - GSList *list, *l; - gchar *val; - - source = e_bconf_get_path (config_xmldb, bconf_path); - if (source) { - list = NULL; - if ((val = e_bconf_get_value (source, "num"))) { - count = atoi (val); - g_free (val); - } - - d(printf("Found %d blobs at %s\n", count, bconf_path)); - - for (i = 0; i < count; i++) { - xmlDocPtr doc; - xmlNodePtr root; - xmlChar *xmlbuf; - gint n; - - doc = xmlNewDoc ((const guchar *)"1.0"); - root = xmlNewDocNode (doc, NULL, (guchar *)name, NULL); - xmlDocSetRootElement (doc, root); - - /* This could be set with a MAP_UID type ... */ - if (idparam) { - gchar buf[16]; - - sprintf (buf, "%d", i); - xmlSetProp (root, (guchar *)idparam, (guchar *)buf); - } - - build_xml (root, map, i, source); - - xmlDocDumpMemory (doc, &xmlbuf, &n); - xmlFreeDoc (doc); - - list = g_slist_append (list, xmlbuf); - } - - gconf_client_set_list (gconf, gconf_path, GCONF_VALUE_STRING, list, NULL); - - while (list) { - l = list->next; - xmlFree (list->data); - g_slist_free_1 (list); - list = l; - } - } else { - g_warning ("could not find '%s' in old config database, skipping", bconf_path); - } - - return 0; -} - -static gint gconf_type[] = { GCONF_VALUE_BOOL, GCONF_VALUE_BOOL, GCONF_VALUE_INT, GCONF_VALUE_STRING, GCONF_VALUE_STRING }; - -gint -e_bconf_import (GConfClient *gconf, xmlDocPtr config_xmldb, e_gconf_map_list_t *remap_list) -{ - gchar *path, *val, *tmp; - e_gconf_map_t *map; - xmlNodePtr source; - GSList *list, *l; - gchar buf[32]; - gint i, j, k; - - /* process all flat config */ - for (i = 0; remap_list[i].root; i++) { - d(printf ("Path: %s\n", remap_list[i].root)); - if (!(source = e_bconf_get_path (config_xmldb, remap_list[i].root))) - continue; - - map = remap_list[i].map; - for (j = 0; map[j].from; j++) { - if (map[j].type & E_GCONF_MAP_LIST) { - /* collapse a multi-entry indexed field into a list */ - list = NULL; - k = 0; - do { - path = get_name (map[j].from, k); - val = e_bconf_get_value (source, path); - d(printf ("finding path '%s' = '%s'\n", path, val)); - g_free (path); - if (val) { - switch (map[j].type & E_GCONF_MAP_MASK) { - case E_GCONF_MAP_BOOL: - case E_GCONF_MAP_INT: - list = g_slist_append (list, GINT_TO_POINTER (atoi (val))); - break; - case E_GCONF_MAP_STRING: - d(printf (" -> '%s'\n", e_bconf_hex_decode (val))); - list = g_slist_append (list, e_bconf_hex_decode (val)); - break; - } - - g_free (val); - k++; - } - } while (val); - - if (list) { - path = g_strdup_printf ("/apps/evolution/%s", map[j].to); - gconf_client_set_list (gconf, path, gconf_type[map[j].type & E_GCONF_MAP_MASK], list, NULL); - g_free (path); - if ((map[j].type & E_GCONF_MAP_MASK) == E_GCONF_MAP_STRING) - g_slist_foreach (list, (GFunc) g_free, NULL); - g_slist_free (list); - } - - continue; - } else if (map[j].type == E_GCONF_MAP_ANYLIST) { - val = NULL; - } else { - if (!(val = e_bconf_get_value (source, map[j].from))) - continue; - } - - d(printf (" %s = '%s' -> %s [%d]\n", - map[j].from, - val == NULL ? "(null)" : val, - map[j].to, - map[j].type)); - - path = g_strdup_printf ("/apps/evolution/%s", map[j].to); - switch (map[j].type) { - case E_GCONF_MAP_BOOL: - gconf_client_set_bool (gconf, path, atoi (val), NULL); - break; - case E_GCONF_MAP_BOOLNOT: - gconf_client_set_bool (gconf, path, !atoi (val), NULL); - break; - case E_GCONF_MAP_INT: - gconf_client_set_int (gconf, path, atoi (val), NULL); - break; - case E_GCONF_MAP_STRING: - tmp = e_bconf_hex_decode (val); - gconf_client_set_string (gconf, path, tmp, NULL); - g_free (tmp); - break; - case E_GCONF_MAP_SIMPLESTRING: - gconf_client_set_string (gconf, path, val, NULL); - break; - case E_GCONF_MAP_FLOAT: - gconf_client_set_float (gconf, path, strtod (val, NULL), NULL); - break; - case E_GCONF_MAP_STRLIST: { - gchar *v = e_bconf_hex_decode (val); - gchar **t = g_strsplit (v, " !<-->!", 8196); - - list = NULL; - for (k = 0; t[k]; k++) { - list = g_slist_append (list, t[k]); - d(printf (" [%d] = '%s'\n", k, t[k])); - } - - gconf_client_set_list (gconf, path, GCONF_VALUE_STRING, list, NULL); - g_slist_free (list); - g_strfreev (t); - g_free (v); - break; } - case E_GCONF_MAP_ANYLIST: { - xmlNodePtr node = source->children; - list = NULL; - - /* find the entry node */ - while (node) { - if (!strcmp ((gchar *)node->name, "entry")) { - gint found; - - if ((tmp = (gchar *)xmlGetProp (node, (const guchar *)"name"))) { - found = strcmp ((gchar *)tmp, map[j].from) == 0; - xmlFree (tmp); - if (found) - break; - } - } - - node = node->next; - } - - /* find the the any block */ - if (node) { - node = node->children; - while (node) { - if (strcmp ((gchar *)node->name, "any") == 0) - break; - node = node->next; - } - } - - /* skip to the value inside it */ - if (node) { - node = node->children; - while (node) { - if (strcmp ((gchar *)node->name, "value") == 0) - break; - node = node->next; - } - } - - if (node) { - node = node->children; - while (node) { - if (strcmp ((gchar *)node->name, "value") == 0) - list = g_slist_append (list, xmlNodeGetContent (node)); - node = node->next; - } - } - - /* & store */ - if (list) { - gconf_client_set_list (gconf, path, GCONF_VALUE_STRING, list, NULL); - while (list) { - l = list->next; - xmlFree (list->data); - g_slist_free_1 (list); - list = l; - } - } - - break; } - case E_GCONF_MAP_COLOUR: - sprintf (buf, "#%06x", atoi (val) & 0xffffff); - gconf_client_set_string (gconf, path, buf, NULL); - break; - } - - /* FIXME: handle errors */ - g_free (path); - g_free (val); - } - } - - return 0; -} diff --git a/e-util/e-bconf-map.h b/e-util/e-bconf-map.h deleted file mode 100644 index 181533dde4..0000000000 --- a/e-util/e-bconf-map.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __E_BCONF_MAP_H__ -#define __E_BCONF_MAP_H__ - -#include <gconf/gconf-client.h> - -#include <libxml/tree.h> - -G_BEGIN_DECLS - -enum { - E_BCONF_MAP_END = 0, /* end of table */ - E_BCONF_MAP_BOOL, /* bool -> prop of name 'to' value true or false */ - E_BCONF_MAP_LONG, /* long -> prop of name 'to' value a long */ - E_BCONF_MAP_STRING, /* string -> prop of name 'to' */ - E_BCONF_MAP_ENUM, /* long/bool -> prop of name 'to', with the value indexed into the child map table's from field */ - E_BCONF_MAP_CHILD, /* a new child of name 'to' */ - E_BCONF_MAP_MASK = 0x3f, - E_BCONF_MAP_CONTENT = 0x80 /* if set, create a new node of name 'to' instead of a property */ -}; - -typedef struct _e_bconf_map { - const gchar *from; - const gchar *to; - gint type; - struct _e_bconf_map *child; -} e_bconf_map_t; - -gchar *e_bconf_hex_decode (const gchar *val); -gchar *e_bconf_url_decode (const gchar *val); - -xmlNodePtr e_bconf_get_path (xmlDocPtr doc, const gchar *path); -xmlNodePtr e_bconf_get_entry (xmlNodePtr root, const gchar *name); - -gchar *e_bconf_get_value (xmlNodePtr root, const gchar *name); -gchar *e_bconf_get_bool (xmlNodePtr root, const gchar *name); -gchar *e_bconf_get_long (xmlNodePtr root, const gchar *name); -gchar *e_bconf_get_string (xmlNodePtr root, const gchar *name); - -gint e_bconf_import_xml_blob (GConfClient *gconf, xmlDocPtr config_xmldb, e_bconf_map_t *map, - const gchar *bconf_path, const gchar *gconf_path, - const gchar *name, const gchar *idparam); - -enum { - E_GCONF_MAP_BOOL, - E_GCONF_MAP_BOOLNOT, - E_GCONF_MAP_INT, - E_GCONF_MAP_STRING, - E_GCONF_MAP_SIMPLESTRING, /* a non-encoded string */ - E_GCONF_MAP_COLOUR, - E_GCONF_MAP_FLOAT, /* bloody floats, who uses floats ... idiots */ - E_GCONF_MAP_STRLIST, /* strings separated to !<-->! -> gconf list */ - E_GCONF_MAP_ANYLIST, /* corba sequence corba string -> gconf list */ - E_GCONF_MAP_MASK = 0x7f, - E_GCONF_MAP_LIST = 0x80 /* from includes a %i field for the index of the key, to be converted to a list of type MAP_* */ -}; - -typedef struct { - const gchar *from; - const gchar *to; - gint type; -} e_gconf_map_t; - -typedef struct { - const gchar *root; - e_gconf_map_t *map; -} e_gconf_map_list_t; - -gint e_bconf_import (GConfClient *gconf, xmlDocPtr config_xmldb, e_gconf_map_list_t *remap_list); - -G_END_DECLS - -#endif /* __E_BCONF_MAP_H__ */ diff --git a/e-util/e-file-utils.c b/e-util/e-file-utils.c index 571154733b..e647b8deb1 100644 --- a/e-util/e-file-utils.c +++ b/e-util/e-file-utils.c @@ -210,108 +210,3 @@ e_file_replace_contents_finish (GFile *file, return TRUE; } -/** - * e_fsutils_usage: - * @path: a file path - * - * Calculate the amount of disk space used by a given path. - * - * Return value: The number of 1024 byte blocks used by the - * filesystem. - **/ -glong e_fsutils_usage(const gchar *inpath) -{ - GDir *dir; - const gchar *d; - long size = 0; - GSList *paths; - - /* iterative, depth-first scan, because i can ... */ - paths = g_slist_prepend(NULL, g_strdup(inpath)); - - while (paths) { - gchar *path = paths->data; - - paths = g_slist_remove_link(paths, paths); - - dir = g_dir_open(path, 0, NULL); - if (dir == NULL) { - g_free(path); - goto fail; - } - - while ((d = g_dir_read_name(dir))) { - gchar *full_path; - struct stat st; - - full_path = g_build_filename(path, d, NULL); - if (g_stat(full_path, &st) == -1) { - g_free(full_path); - g_dir_close(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. */ -#ifndef G_OS_WIN32 - size += st.st_blocks/2; -#endif - } - - g_free(full_path); - } - - g_dir_close(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: a file 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. - **/ -glong -e_fsutils_avail(const gchar *path) -{ -#if defined(HAVE_STATVFS) - struct statvfs stfs; - - if (statvfs(path, &stfs) == -1) - return -1; - - /* Assumes that frsize === power of 2 */ - if (stfs.f_frsize >= 1024) - return stfs.f_bavail * (stfs.f_frsize / 1024); - else - return stfs.f_bavail / (1024 / stfs.f_frsize); -#elif defined(HAVE_STATFS) - struct statfs stfs; - - if (statfs(path, &stfs) == -1) - return -1; - - /* For BSD this isn't clear, it may be dependent on f_bsize */ - return stfs.f_bavail / 2; -#else - errno = ENOSYS; - return -1; -#endif -} - diff --git a/e-util/e-file-utils.h b/e-util/e-file-utils.h index 147b9b5b79..e1e8b29872 100644 --- a/e-util/e-file-utils.h +++ b/e-util/e-file-utils.h @@ -41,9 +41,6 @@ gboolean e_file_replace_contents_finish (GFile *file, gchar **new_etag, GError **error); -glong e_fsutils_usage (const gchar *path); -glong e_fsutils_avail (const gchar *path); - G_END_DECLS #endif /* E_FILE_UTILS_H */ diff --git a/e-util/e-folder-map.c b/e-util/e-folder-map.c deleted file mode 100644 index 7d775bed8a..0000000000 --- a/e-util/e-folder-map.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include <config.h> - -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <libxml/tree.h> -#include <libxml/parser.h> -#include <libxml/xmlmemory.h> - -#include <libedataserver/e-xml-utils.h> - -#include "e-folder-map.h" - -#define d(x) - -static gboolean -is_type_folder (const gchar *metadata, const gchar *search_type) -{ - xmlNodePtr node; - xmlDocPtr doc; - gchar *type; - - doc = e_xml_parse_file (metadata); - if (!doc) { - g_warning ("Cannot parse '%s'", metadata); - return FALSE; - } - - if (!(node = xmlDocGetRootElement (doc))) { - g_warning ("'%s' corrupt: document contains no root node", metadata); - xmlFreeDoc (doc); - return FALSE; - } - - if (!node->name || strcmp ((gchar *)node->name, "efolder") != 0) { - g_warning ("'%s' corrupt: root node is not 'efolder'", metadata); - xmlFreeDoc (doc); - return FALSE; - } - - node = node->children; - while (node != NULL) { - if (node->name && !strcmp ((gchar *)node->name, "type")) { - type = (gchar *)xmlNodeGetContent (node); - if (!strcmp (type, search_type)) { - xmlFreeDoc (doc); - xmlFree (type); - - return TRUE; - } - - xmlFree (type); - - break; - } - - node = node->next; - } - - xmlFreeDoc (doc); - - return FALSE; -} - -static void -e_folder_map_dir (const gchar *dirname, const gchar *type, GSList **dir_list) -{ - gchar *path; - const gchar *name; - GDir *dir; - GError *error = NULL; - - path = g_build_filename (dirname, "folder-metadata.xml", NULL); - if (!g_file_test (path, G_FILE_TEST_IS_REGULAR)) { - g_free (path); - return; - } - - if (!is_type_folder (path, type)) { - g_free (path); - goto try_subdirs; - } - - d(g_message ("Found '%s'", dirname)); - *dir_list = g_slist_prepend (*dir_list, g_strdup (dirname)); - - g_free (path); - - try_subdirs: - - path = g_build_filename (dirname, "subfolders", NULL); - if (!g_file_test (path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { - g_free (path); - return; - } - - if (!(dir = g_dir_open (path, 0, &error))) { - g_warning ("cannot open '%s': %s", path, error->message); - g_error_free (error); - g_free (path); - return; - } - - while ((name = g_dir_read_name (dir))) { - gchar *full_path; - - if (*name == '.') - continue; - - full_path = g_build_filename (path, name, NULL); - if (!g_file_test (full_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { - g_free (full_path); - continue; - } - - e_folder_map_dir (full_path, type, dir_list); - g_free (full_path); - } - - g_dir_close (dir); - - g_free (path); -} - -GSList * -e_folder_map_local_folders (const gchar *local_dir, const gchar *type) -{ - const gchar *name; - GDir *dir; - GSList *dir_list = NULL; - GError *error = NULL; - - if (!(dir = g_dir_open (local_dir, 0, &error))) { - g_warning ("cannot open '%s': %s", local_dir, error->message); - g_error_free (error); - return NULL; - } - - while ((name = g_dir_read_name (dir))) { - gchar *full_path; - - if (*name == '.') - continue; - - full_path = g_build_filename (local_dir, name, NULL); - d(g_message ("Looking in %s", full_path)); - if (!g_file_test (full_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { - g_free (full_path); - continue; - } - - e_folder_map_dir (full_path, type, &dir_list); - - g_free (full_path); - } - - g_dir_close (dir); - - return dir_list; -} diff --git a/e-util/e-folder-map.h b/e-util/e-folder-map.h deleted file mode 100644 index 3f41838882..0000000000 --- a/e-util/e-folder-map.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Jeffrey Stedfast <fejj@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef __E_FOLDER_MAP_H__ -#define __E_FOLDER_MAP_H__ - -#include <glib.h> - -G_BEGIN_DECLS - -GSList * e_folder_map_local_folders (const gchar *local_dir, - const gchar *type); - -G_END_DECLS - -#endif /* __E_FOLDER_MAP_H__ */ |