localfolder.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
  3. * Copyright (C) 2002 by the Claws Mail Team and Hiroyuki Yamamoto
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. */
  19. #include <glib.h>
  20. #include "folder.h"
  21. #include "localfolder.h"
  22. #include "xml.h"
  23. void folder_local_folder_init(Folder *folder, const gchar *name,
  24. const gchar *path)
  25. {
  26. folder_init(folder, name);
  27. LOCAL_FOLDER(folder)->rootpath = g_strdup(path);
  28. }
  29. void folder_local_folder_destroy(LocalFolder *lfolder)
  30. {
  31. g_return_if_fail(lfolder != NULL);
  32. g_free(lfolder->rootpath);
  33. }
  34. void folder_local_set_xml(Folder *_folder, XMLTag *tag)
  35. {
  36. LocalFolder *folder = LOCAL_FOLDER(_folder);
  37. GList *cur;
  38. folder_set_xml(_folder, tag);
  39. for (cur = tag->attr; cur != NULL; cur = g_list_next(cur)) {
  40. XMLAttr *attr = (XMLAttr *) cur->data;
  41. if (!attr || !attr->name || !attr->value) continue;
  42. if (!strcmp(attr->name, "path")) {
  43. g_free(folder->rootpath);
  44. folder->rootpath = g_strdup(attr->value);
  45. }
  46. }
  47. }
  48. XMLTag *folder_local_get_xml(Folder *_folder)
  49. {
  50. LocalFolder *folder = LOCAL_FOLDER(_folder);
  51. XMLTag *tag;
  52. tag = folder_get_xml(_folder);
  53. xml_tag_add_attr(tag, xml_attr_new("path", folder->rootpath));
  54. return tag;
  55. }