aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/tools/evolution-addressbook-export-list-folders.c
diff options
context:
space:
mode:
authorChris Toshok <toshok@ximian.com>2004-05-25 02:52:39 +0800
committerChris Toshok <toshok@src.gnome.org>2004-05-25 02:52:39 +0800
commit9b2ab206c225392b204b62db389f387bba6103f9 (patch)
tree0f0b3cd1763b1e6ef47a217297d4328229eeb0b2 /addressbook/tools/evolution-addressbook-export-list-folders.c
parent0235a365dd12798e7b8f1881d053f96485009d4d (diff)
downloadgsoc2013-evolution-9b2ab206c225392b204b62db389f387bba6103f9.tar.gz
gsoc2013-evolution-9b2ab206c225392b204b62db389f387bba6103f9.tar.zst
gsoc2013-evolution-9b2ab206c225392b204b62db389f387bba6103f9.zip
fix this for current build foo.
2004-05-24 Chris Toshok <toshok@ximian.com> * tools/Makefile.am: fix this for current build foo. * tools/evolution-addressbook-export-list-folders.c, * tools/evolution-addressbook-export-list-cards.c, * tools/evolution-addressbook-export.c: revive this. svn path=/trunk/; revision=26065
Diffstat (limited to 'addressbook/tools/evolution-addressbook-export-list-folders.c')
-rw-r--r--addressbook/tools/evolution-addressbook-export-list-folders.c104
1 files changed, 52 insertions, 52 deletions
diff --git a/addressbook/tools/evolution-addressbook-export-list-folders.c b/addressbook/tools/evolution-addressbook-export-list-folders.c
index 8922422a8f..78fdca7f9f 100644
--- a/addressbook/tools/evolution-addressbook-export-list-folders.c
+++ b/addressbook/tools/evolution-addressbook-export-list-folders.c
@@ -28,72 +28,72 @@
#include <libbonobo.h>
#include <libgnome/libgnome.h>
-#include <ebook/e-book.h>
-#include <ebook/e-book-util.h>
+#include <libebook/e-book.h>
#include "evolution-addressbook-export.h"
-static void
-action_list_folders_get_cursor_cb (EBook * book, EBookStatus status, ECardCursor * cursor, ActionContext * p_actctx)
+guint
+action_list_folders_init (ActionContext * p_actctx)
{
- FILE *outputfile;
- long length;
- const char *uri;
- char *name;
-
- uri = e_book_get_default_book_uri ();
- length = e_card_cursor_get_length (cursor);
-
- /*Fix me *
- can not get name, should be a bug of e-book.Anyway, should set a default name.
- */
- /*name = e_book_get_name (book); */
- name = g_strdup (_("Contacts"));
-
- if (p_actctx->action_list_folders.output_file == NULL) {
- printf ("\"%s\",\"%s\",%d\n", uri, name, (int) length);
- } else {
- /*output to a file */
+ ESourceList *addressbooks = NULL;
+ GSList *groups, *group;
+ FILE *outputfile = NULL;
+
+ if (!e_book_get_addressbooks (&addressbooks, NULL)) {
+ g_warning (_("Couldn't get list of addressbooks"));
+ exit (-1);
+ }
+
+ if (p_actctx->action_list_folders.output_file != NULL) {
if (!(outputfile = fopen (p_actctx->action_list_folders.output_file, "w"))) {
g_warning (_("Can not open file"));
exit (-1);
}
- fprintf (outputfile, "\"%s\",\"%s\",%d\n", uri, name, (int) length);
- fclose (outputfile);
}
- g_free (name);
- g_object_unref (G_OBJECT (book));
- bonobo_main_quit ();
-}
+ groups = e_source_list_peek_groups (addressbooks);
+ for (group = groups; group; group = group->next) {
+ ESourceGroup *g = group->data;
+ GSList *sources, *source;
-static void
-action_list_folders_open_cb (EBook * book, EBookStatus status, ActionContext * p_actctx)
-{
- if (E_BOOK_STATUS_SUCCESS == status) {
- e_book_get_cursor (book, "(contains \"full_name\" \"\")",
- (EBookCursorCallback)action_list_folders_get_cursor_cb, p_actctx);
- } else {
- g_object_unref (G_OBJECT (book));
- g_warning (_("Can not load URI"));
- exit (-1);
- }
-}
+ sources = e_source_group_peek_sources (g);
+ for (source = sources; source; source = source->next) {
+ ESource *s = source->data;
+ EBook *book;
+ EBookQuery *query;
+ GList *contacts;
+ char *uri;
+ const char *name;
-static guint
-action_list_folders_run (ActionContext * p_actctx)
-{
- EBook *book;
- book = e_book_new ();
+ book = e_book_new (s, NULL);
+ if (!book
+ || !e_book_open (book, TRUE, NULL)) {
+ g_warning (_("failed to open book"));
+ continue;
+ }
- e_book_load_default_book (book, (EBookCallback)action_list_folders_open_cb, p_actctx);
- return SUCCESS;
-}
+ query = e_book_query_any_field_contains ("");
+ e_book_get_contacts (book, query, &contacts, NULL);
+ e_book_query_unref (query);
-guint
-action_list_folders_init (ActionContext * p_actctx)
-{
- g_idle_add ((GSourceFunc) action_list_folders_run, p_actctx);
+ uri = e_source_get_uri (s);
+ name = e_source_peek_name (s);
+
+ if (outputfile)
+ fprintf (outputfile, "\"%s\",\"%s\",%d\n", uri, name, g_list_length (contacts));
+ else
+ printf ("\"%s\",\"%s\",%d\n", uri, name, g_list_length (contacts));
+
+ g_free (uri);
+ g_list_foreach (contacts, (GFunc)g_object_unref, NULL);
+ g_list_free (contacts);
+
+ g_object_unref (book);
+ }
+ }
+
+ if (outputfile)
+ fclose (outputfile);
return SUCCESS;
}