* tools/evolution-addressbook-export.c: #include bonobo-activation instead of oaf. (main): Initialize using gnome_program_init(). (save_cards): Use g_main_loop_quit() instead of gtk_exit(). * tools/evolution-addressbook-import.c: Update include list for GNOME 2. (main): Initialize using gnome_program_init(). (unref_executable): Use g_main_loop_quit() instead of gtk_exit(). (add_cb): Likewise. * tools/evolution-addressbook-abuse.c: Update include list for GNOME 2. (main): Initialize using gnome_program_init(). (use_addressbook): Use g_object_unref() instead of gtk_object_unref(). (main): Use g_timeout_add() instead of gtk_timeout_add(). (add_cb): Use g_main_loop_quit() instead of gtk_exit(). * configure.in (AC_SUBST): Add tools/Makefile. * Makefile.am (SUBDIRS): Add tools/ back into the list. * tools/Makefile.am: Install everything in $(datadir)/evolution-$(BASE_VERSION)/tools. (INCLUDES): Add the defines that gnome_program_init() likes and also add the _DISABLE_DEPRECATED stuff. svn path=/trunk/; revision=19656
66 lines
1.6 KiB
C
66 lines
1.6 KiB
C
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
|
|
|
#include <config.h>
|
|
|
|
#include <bonobo-activation/bonobo-activation.h>
|
|
#include <bonobo/bonobo-main.h>
|
|
#include <backend/ebook/e-book-util.h>
|
|
#include <gnome.h>
|
|
#include <fcntl.h>
|
|
#include <gal/util/e-util.h>
|
|
|
|
static void
|
|
save_cards (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure)
|
|
{
|
|
char *filename = closure;
|
|
char *vcard;
|
|
int result;
|
|
/* This has to be an array so that it's not const. */
|
|
char tmpname[] = "/tmp/evo-addressbook-tmp.XXXXXX";
|
|
|
|
vcard = e_card_list_get_vcard (cards);
|
|
|
|
if (filename)
|
|
result = e_write_file (filename, vcard, O_CREAT | O_EXCL);
|
|
else
|
|
result = e_write_file_mkstemp (tmpname, vcard);
|
|
printf (tmpname);
|
|
sync();
|
|
g_main_loop_quit (NULL);
|
|
}
|
|
|
|
static void
|
|
use_addressbook (EBook *book, gpointer closure)
|
|
{
|
|
if (book == NULL)
|
|
g_error (_("Error loading default addressbook."));
|
|
e_book_simple_query (book, "(contains \"x-evolution-any-field\" \"\")", save_cards, closure);
|
|
}
|
|
|
|
int
|
|
main (int argc, char *argv[])
|
|
{
|
|
char *filename = NULL;
|
|
|
|
struct poptOption options[] = {
|
|
{ "output-file", '\0', POPT_ARG_STRING, &filename, 0, N_("Output File"), NULL },
|
|
POPT_AUTOHELP
|
|
{ NULL, '\0', 0, NULL, 0, NULL, NULL }
|
|
};
|
|
|
|
bindtextdomain (PACKAGE, EVOLUTION_LOCALEDIR);
|
|
textdomain (PACKAGE);
|
|
|
|
gnome_program_init ("evolution-addressbook-export", VERSION,
|
|
LIBGNOMEUI_MODULE, argc, argv,
|
|
GNOME_PROGRAM_STANDARD_PROPERTIES,
|
|
GNOME_PARAM_POPT_TABLE, options,
|
|
NULL);
|
|
|
|
e_book_use_default_book (use_addressbook, filename);
|
|
|
|
bonobo_main ();
|
|
|
|
return 0;
|
|
}
|