diff options
author | Chris Toshok <toshok@ximian.com> | 2003-10-23 04:50:36 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2003-10-23 04:50:36 +0800 |
commit | cbfab681c1576d4de27d48fbd6b4b7780670494a (patch) | |
tree | 70e99033907a1f5dada728e785835a07ca6ab98c /addressbook/tools | |
parent | f7cbb839adf3fd47aa07ca2080063acd6fff6978 (diff) | |
download | gsoc2013-evolution-cbfab681c1576d4de27d48fbd6b4b7780670494a.tar.gz gsoc2013-evolution-cbfab681c1576d4de27d48fbd6b4b7780670494a.tar.zst gsoc2013-evolution-cbfab681c1576d4de27d48fbd6b4b7780670494a.zip |
use the synchronous api for this. simplifies it a bunch.
2003-10-21 Chris Toshok <toshok@ximian.com>
* tools/evolution-addressbook-abuse.c: use the synchronous api for
this. simplifies it a bunch.
2003-10-21 Chris Toshok <toshok@ximian.com>
* backend/pas/pas-book.c
(impl_GNOME_Evolution_Addressbook_Book_remove): we can ill afford
bad debug spew.
(view_listener_died_cb): implement.
(impl_GNOME_Evolution_Addressbook_Book_getBookView): hook up an
ORBit_small connection listener on the view's listener.
(pas_book_respond_create): use e_contact_get_const instead of
e_contact_get here. fixes a leak.
* backend/pas/pas-book-view.c
(impl_GNOME_Evolution_Addressbook_BookView_stop): implement, call
pas_backend_stop_book_view.
(pas_book_view_get_listener): return the book view's listener.
(pas_book_view_class_init): fill in epv->stop.
(pas_book_view_init): use a #define for THRESHOLD_MAX instead of
the constant.
* backend/pas/pas-book-view.h: add prototype for
pas_book_view_get_listener.
* backend/pas/pas-backend.c (pas_backend_stop_book_view):
implement.
(pas_backend_remove_book_view): implement.
* backend/pas/pas-backend.h: add prototype for stop_book_view and
remove_book_view.
* backend/pas/pas-backend-vcf.c (load_file): pass in the fd and
use fdopen here.
(foreach_build_list): don't creat EContacts here, because we'll
just be converting them back to vcards anyway.
(save_file): use char*'s instead of EContacts, and split entries
with 2 blank lines. Also, hold the lock over the entire function.
(do_create): hold the lock around uid generation and touching the
hash table.
(pas_backend_vcf_process_remove_contacts): same.
(pas_backend_vcf_process_modify_contact): same.
(pas_backend_vcf_stop_book_view): new function, but leave
unimplemented for now.
(pas_backend_vcf_load_uri): the uri contains the directory name,
not the filename.
(pas_backend_vcf_dispose): grab the lock here just for sanity's
sake. Also reorder things a bit, and free the hashtable and
mutex.
(pas_backend_vcf_init): init the mutex.
* backend/pas/pas-backend-summary.c
(pas_backend_summary_add_contact): don't unref the contact here.
* backend/pas/pas-backend-ldap.c
(pas_backend_ldap_process_stop_book_view): new function, but leave
unimplemented for now.
* backend/pas/pas-backend-file.c (build_summary): use an EContact
for this call.
(do_summary_query): nuke, the contents of this has been moved to
start_book_view.
(pas_backend_file_search_timeout): same.
(pas_backend_file_search): same.
(pas_backend_file_start_book_view): glom everything into here
involving searching. This function could (and should) be renamed
and reused from both this function and _get_contact_list.
(pas_backend_file_stop_book_view): new function.
(pas_backend_file_class_init): fill in backend->stop_book_view.
* backend/pas/Makefile.am (LDAP_BACKEND): libpasldap.a ->
libpasldap.la
(noinst_LTLIBRARIES): *.a -> *.la.
(libpas_la_SOURCES): same.
(libpasfile_la_SOURCES): same.
(libpasvcf_la_SOURCES): same.
(libpasldap_la_SOURCES): same.
* backend/idl/addressbook.idl: add BookView::stop.
* backend/ebook/e-vcard.c (read_attribute_value): fix GString
related leaks.
(read_attribute_params): same.
(parse): don't leak the EVCardAttributes corresponding to
BEGIN/END:vCard.
(free_gstring): new function
(e_vcard_attribute_remove_values): free the decoded_values list,
using free_gstring.
* backend/ebook/e-book.c (e_book_response_get_book_view): ref the
listener here.
* backend/ebook/e-book-view.h: add prototype for e_book_view_stop.
* backend/ebook/e-book-view.c (e_book_view_stop): new function.
* backend/ebook/e-book-async.c (_get_book_view_response_dtor):
unref the book view.
svn path=/trunk/; revision=23000
Diffstat (limited to 'addressbook/tools')
-rw-r--r-- | addressbook/tools/evolution-addressbook-abuse.c | 76 |
1 files changed, 20 insertions, 56 deletions
diff --git a/addressbook/tools/evolution-addressbook-abuse.c b/addressbook/tools/evolution-addressbook-abuse.c index 7801ed7e9d..3446e15938 100644 --- a/addressbook/tools/evolution-addressbook-abuse.c +++ b/addressbook/tools/evolution-addressbook-abuse.c @@ -2,15 +2,12 @@ #include <config.h> -#include <bonobo-activation/bonobo-activation.h> #include <bonobo/bonobo-main.h> -#include <backend/ebook/e-book-async.h> +#include <backend/ebook/e-book.h> #include <gnome.h> -static int contacts_to_add_total = 1000; -static int contacts_to_add = 50; -static int call_count = 0; +#define CONTACTS_TO_ADD 2000 static gchar * make_random_string (void) @@ -53,58 +50,12 @@ make_random_vcard (void) return vcard; } -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -static void -add_cb (EBook *book, EBookStatus status, const char *id, gpointer closure) -{ - switch (status) { - case E_BOOK_ERROR_OK: - --contacts_to_add_total; - g_message ("succesful add! (%d remaining)", contacts_to_add_total); - if (contacts_to_add_total <= 0) - g_main_loop_quit (NULL); - break; - default: - g_message ("something went wrong..."); - g_main_loop_quit (NULL); - break; - } -} - -static void -use_addressbook (EBook *book, EBookStatus status, gpointer closure) -{ - gint i; - - if (book == NULL || status != E_BOOK_ERROR_OK) - g_error (_("Error loading default addressbook.")); - - for (i = 0; i < contacts_to_add; ++i) { - gchar *vcard = make_random_vcard (); - EContact *contact = e_contact_new_from_vcard (vcard); - g_message ("adding %d", i); - e_book_async_add_contact (book, contact, add_cb, NULL); - g_free (vcard); - g_object_unref (contact); - } - - g_object_unref (book); -} - -static gint -abuse_timeout (gpointer foo) -{ - e_book_async_get_default_addressbook (use_addressbook, NULL); - - ++call_count; - g_message ("timeout!"); - return call_count < contacts_to_add_total / contacts_to_add; -} - int main (int argc, char *argv[]) { + EBook *book; + int i; + if (getenv ("ABUSE_THE_WOMBAT") == NULL) { g_print ("You probably don't want to use this program.\n" "It isn't very nice.\n"); @@ -119,9 +70,22 @@ main (int argc, char *argv[]) GNOME_PROGRAM_STANDARD_PROPERTIES, NULL); - g_timeout_add (20, abuse_timeout, NULL); + if (!e_book_get_default_addressbook (&book, NULL)) { + g_warning ("couldn't open addressbook"); + exit (1); + } - bonobo_main (); + for (i = 0; i < CONTACTS_TO_ADD; ++i) { + gchar *vcard = make_random_vcard (); + EContact *contact = e_contact_new_from_vcard (vcard); + g_message ("adding %d", i); + if (!e_book_add_contact (book, contact, NULL)) { + g_warning ("something went wrong..."); + exit (1); + } + g_free (vcard); + g_object_unref (contact); + } return 0; } |