diff options
author | Chris Toshok <toshok@ximian.com> | 2002-03-08 08:51:11 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2002-03-08 08:51:11 +0800 |
commit | da6e1ea98dcf2614ea71ea5dfb88ef63e194c8f6 (patch) | |
tree | 613214c31c5e45a6a21357a2e8ca652c2294e413 /addressbook/backend/pas/pas-book.c | |
parent | a9791c82f0513cdeb607c94f8b73c8040dc16bf5 (diff) | |
download | gsoc2013-evolution-da6e1ea98dcf2614ea71ea5dfb88ef63e194c8f6.tar gsoc2013-evolution-da6e1ea98dcf2614ea71ea5dfb88ef63e194c8f6.tar.gz gsoc2013-evolution-da6e1ea98dcf2614ea71ea5dfb88ef63e194c8f6.tar.bz2 gsoc2013-evolution-da6e1ea98dcf2614ea71ea5dfb88ef63e194c8f6.tar.lz gsoc2013-evolution-da6e1ea98dcf2614ea71ea5dfb88ef63e194c8f6.tar.xz gsoc2013-evolution-da6e1ea98dcf2614ea71ea5dfb88ef63e194c8f6.tar.zst gsoc2013-evolution-da6e1ea98dcf2614ea71ea5dfb88ef63e194c8f6.zip |
track union/struct change. (pas_book_queue_remove_card): same.
2002-03-07 Chris Toshok <toshok@ximian.com>
* backend/pas/pas-book.c (pas_book_queue_create_card): track
union/struct change.
(pas_book_queue_remove_card): same.
(pas_book_queue_modify_card): same.
(pas_book_queue_get_cursor): same.
(pas_book_queue_get_vcard): same.
(pas_book_queue_authenticate_user): same.
(pas_book_queue_get_book_view): same.
(pas_book_queue_get_changes): same.
(pas_book_free_request): new function - free everything we need to
for each type of request.
(pas_book_destroy): call pas_book_free_request here instead of
just freeing 3 elements of the old struct. yay plugging memleaks.
* backend/pas/pas-book.h: make PASRequest a union and split out
members into structs, so it's a little clearer which fields are
used by which requests. Also, add prototype for
pas_book_free_request so backends can just free everything at once
(usually in their requests_queued signal func.)
* backend/pas/pas-backend-file.c
(pas_backend_file_process_create_card): track struct/union change.
(pas_backend_file_process_remove_card): same.
(pas_backend_file_process_modify_card): same.
(pas_backend_file_build_cards_list): same.
(pas_backend_file_process_get_vcard): same.
(pas_backend_file_process_get_cursor): same.
(pas_backend_file_process_get_book_view): same.
(pas_backend_file_process_get_changes): same.
(pas_backend_file_process_check_connection): same.
(pas_backend_file_process_authenticate_user): same.
(pas_backend_file_process_get_supported_fields): same.
(pas_backend_file_process_client_requests): case the union to the
specific struct and pass it to the process_* functions. also,
call pas_book_free_request here, instead of relying on each of the
functions to free their stuff.
svn path=/trunk/; revision=15987
Diffstat (limited to 'addressbook/backend/pas/pas-book.c')
-rw-r--r-- | addressbook/backend/pas/pas-book.c | 87 |
1 files changed, 70 insertions, 17 deletions
diff --git a/addressbook/backend/pas/pas-book.c b/addressbook/backend/pas/pas-book.c index b0b35b2c0f..9bb2cd348e 100644 --- a/addressbook/backend/pas/pas-book.c +++ b/addressbook/backend/pas/pas-book.c @@ -74,7 +74,7 @@ pas_book_queue_create_card (PASBook *book, const char *vcard) req = g_new0 (PASRequest, 1); req->op = CreateCard; - req->vcard = g_strdup (vcard); + req->create.vcard = g_strdup (vcard); pas_book_queue_request (book, req); } @@ -86,7 +86,7 @@ pas_book_queue_remove_card (PASBook *book, const char *id) req = g_new0 (PASRequest, 1); req->op = RemoveCard; - req->id = g_strdup (id); + req->remove.id = g_strdup (id); pas_book_queue_request (book, req); } @@ -98,7 +98,7 @@ pas_book_queue_modify_card (PASBook *book, const char *vcard) req = g_new0 (PASRequest, 1); req->op = ModifyCard; - req->vcard = g_strdup (vcard); + req->modify.vcard = g_strdup (vcard); pas_book_queue_request (book, req); } @@ -110,7 +110,7 @@ pas_book_queue_get_cursor (PASBook *book, const char *search) req = g_new0 (PASRequest, 1); req->op = GetCursor; - req->search = g_strdup(search); + req->get_cursor.search = g_strdup(search); pas_book_queue_request (book, req); } @@ -122,7 +122,7 @@ pas_book_queue_get_vcard (PASBook *book, const char *id) req = g_new0 (PASRequest, 1); req->op = GetVCard; - req->id = g_strdup(id); + req->get_vcard.id = g_strdup(id); pas_book_queue_request (book, req); } @@ -135,9 +135,9 @@ pas_book_queue_authenticate_user (PASBook *book, req = g_new0 (PASRequest, 1); req->op = AuthenticateUser; - req->user = g_strdup(user); - req->passwd = g_strdup(passwd); - req->auth_method = g_strdup(auth_method); + req->auth_user.user = g_strdup(user); + req->auth_user.passwd = g_strdup(passwd); + req->auth_user.auth_method = g_strdup(auth_method); pas_book_queue_request (book, req); } @@ -162,11 +162,11 @@ pas_book_queue_get_book_view (PASBook *book, const GNOME_Evolution_Addressbook_B req = g_new0 (PASRequest, 1); req->op = GetBookView; - req->search = g_strdup(search); + req->get_book_view.search = g_strdup(search); CORBA_exception_init (&ev); - req->listener = bonobo_object_dup_ref(listener, &ev); + req->get_book_view.listener = bonobo_object_dup_ref(listener, &ev); if (ev._major != CORBA_NO_EXCEPTION) { g_warning ("pas_book_queue_get_book_view: Exception " @@ -186,11 +186,11 @@ pas_book_queue_get_changes (PASBook *book, const GNOME_Evolution_Addressbook_Boo req = g_new0 (PASRequest, 1); req->op = GetChanges; - req->change_id= g_strdup(change_id); + req->get_changes.change_id= g_strdup(change_id); CORBA_exception_init (&ev); - req->listener = bonobo_object_dup_ref(listener, &ev); + req->get_changes.listener = bonobo_object_dup_ref(listener, &ev); if (ev._major != CORBA_NO_EXCEPTION) { g_warning ("pas_book_queue_get_changes: Exception " @@ -766,6 +766,63 @@ pas_book_new (PASBackend *backend, return book; } +void +pas_book_free_request (PASRequest *req) +{ + CORBA_Environment ev; + switch (req->op) { + case CreateCard: + g_free (req->create.id); + g_free (req->create.vcard); + break; + case RemoveCard: + g_free (req->remove.id); + break; + case ModifyCard: + g_free (req->modify.vcard); + break; + case GetVCard: + g_free (req->get_vcard.id); + break; + case GetCursor: + g_free (req->get_cursor.search); + break; + case GetBookView: + g_free (req->get_book_view.search); + CORBA_exception_init (&ev); + bonobo_object_release_unref (req->get_book_view.listener, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) + g_message ("pas_book_free_request(GetBookView): could not release the listener"); + + CORBA_exception_free (&ev); + break; + case GetChanges: + g_free (req->get_changes.change_id); + CORBA_exception_init (&ev); + bonobo_object_release_unref (req->get_changes.listener, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) + g_message ("pas_book_free_request(GetChanges): could not release the listener"); + + CORBA_exception_free (&ev); + break; + case CheckConnection: + /* nothing to free */ + break; + case AuthenticateUser: + g_free (req->auth_user.user); + g_free (req->auth_user.passwd); + g_free (req->auth_user.auth_method); + break; + case GetSupportedFields: + /* nothing to free */ + break; + } + + g_free (req); +} + static void pas_book_destroy (GtkObject *object) { @@ -774,11 +831,7 @@ pas_book_destroy (GtkObject *object) CORBA_Environment ev; for (l = book->priv->request_queue; l != NULL; l = l->next) { - PASRequest *req = l->data; - - g_free (req->id); - g_free (req->vcard); - g_free (req); + pas_book_free_request ((PASRequest *)l->data); } g_list_free (book->priv->request_queue); |