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
This commit is contained in:
committed by
Chris Toshok
parent
a9791c82f0
commit
da6e1ea98d
@ -1,3 +1,42 @@
|
||||
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.
|
||||
|
||||
2002-03-07 Dan Winship <danw@ximian.com>
|
||||
|
||||
* gui/component/addressbook-storage.c
|
||||
|
||||
@ -535,7 +535,7 @@ do_create(PASBackend *backend,
|
||||
static void
|
||||
pas_backend_file_process_create_card (PASBackend *backend,
|
||||
PASBook *book,
|
||||
PASRequest *req)
|
||||
PASCreateCardRequest *req)
|
||||
{
|
||||
char *id;
|
||||
char *vcard;
|
||||
@ -577,7 +577,7 @@ pas_backend_file_process_create_card (PASBackend *backend,
|
||||
static void
|
||||
pas_backend_file_process_remove_card (PASBackend *backend,
|
||||
PASBook *book,
|
||||
PASRequest *req)
|
||||
PASRemoveCardRequest *req)
|
||||
{
|
||||
PASBackendFile *bf = PAS_BACKEND_FILE (backend);
|
||||
DB *db = bf->priv->file_db;
|
||||
@ -636,7 +636,7 @@ pas_backend_file_process_remove_card (PASBackend *backend,
|
||||
static void
|
||||
pas_backend_file_process_modify_card (PASBackend *backend,
|
||||
PASBook *book,
|
||||
PASRequest *req)
|
||||
PASModifyCardRequest *req)
|
||||
{
|
||||
PASBackendFile *bf = PAS_BACKEND_FILE (backend);
|
||||
DB *db = bf->priv->file_db;
|
||||
@ -671,7 +671,6 @@ pas_backend_file_process_modify_card (PASBackend *backend,
|
||||
pas_book_respond_modify (
|
||||
book,
|
||||
GNOME_Evolution_Addressbook_BookListener_CardNotFound);
|
||||
g_free (req->id);
|
||||
return;
|
||||
}
|
||||
old_vcard_string = g_strdup(vcard_dbt.data);
|
||||
@ -728,8 +727,8 @@ pas_backend_file_process_modify_card (PASBackend *backend,
|
||||
|
||||
static void
|
||||
pas_backend_file_build_cards_list(PASBackend *backend,
|
||||
PASBackendFileCursorPrivate *cursor_data,
|
||||
char *search)
|
||||
PASBackendFileCursorPrivate *cursor_data,
|
||||
char *search)
|
||||
{
|
||||
PASBackendFile *bf = PAS_BACKEND_FILE (backend);
|
||||
DB *db = bf->priv->file_db;
|
||||
@ -788,7 +787,7 @@ pas_backend_file_build_cards_list(PASBackend *backend,
|
||||
static void
|
||||
pas_backend_file_process_get_vcard (PASBackend *backend,
|
||||
PASBook *book,
|
||||
PASRequest *req)
|
||||
PASGetVCardRequest *req)
|
||||
{
|
||||
PASBackendFile *bf;
|
||||
DB *db;
|
||||
@ -821,7 +820,7 @@ pas_backend_file_process_get_vcard (PASBackend *backend,
|
||||
static void
|
||||
pas_backend_file_process_get_cursor (PASBackend *backend,
|
||||
PASBook *book,
|
||||
PASRequest *req)
|
||||
PASGetCursorRequest *req)
|
||||
{
|
||||
/*
|
||||
PASBackendFile *bf = PAS_BACKEND_FILE (backend);
|
||||
@ -871,10 +870,9 @@ pas_backend_file_process_get_cursor (PASBackend *backend,
|
||||
static void
|
||||
pas_backend_file_process_get_book_view (PASBackend *backend,
|
||||
PASBook *book,
|
||||
PASRequest *req)
|
||||
PASGetBookViewRequest *req)
|
||||
{
|
||||
PASBackendFile *bf = PAS_BACKEND_FILE (backend);
|
||||
CORBA_Environment ev;
|
||||
PASBookView *book_view;
|
||||
PASBackendFileBookView view;
|
||||
EIterator *iterator;
|
||||
@ -889,7 +887,7 @@ pas_backend_file_process_get_book_view (PASBackend *backend,
|
||||
GTK_SIGNAL_FUNC(view_destroy), book);
|
||||
|
||||
view.book_view = book_view;
|
||||
view.search = req->search;
|
||||
view.search = g_strdup (req->search);
|
||||
view.card_sexp = NULL;
|
||||
view.change_id = NULL;
|
||||
view.change_context = NULL;
|
||||
@ -906,25 +904,12 @@ pas_backend_file_process_get_book_view (PASBackend *backend,
|
||||
e_iterator_last(iterator);
|
||||
pas_backend_file_search (bf, book, e_iterator_get(iterator));
|
||||
gtk_object_unref(GTK_OBJECT(iterator));
|
||||
|
||||
g_free(req->search);
|
||||
CORBA_exception_init(&ev);
|
||||
|
||||
bonobo_object_unref (BONOBO_OBJECT (book_view));
|
||||
bonobo_object_release_unref (req->listener, &ev);
|
||||
|
||||
if (ev._major != CORBA_NO_EXCEPTION) {
|
||||
g_warning("pas_backend_file_process_get_book_view: Exception unreffing "
|
||||
"listener.\n");
|
||||
}
|
||||
|
||||
CORBA_exception_free(&ev);
|
||||
}
|
||||
|
||||
static void
|
||||
pas_backend_file_process_get_changes (PASBackend *backend,
|
||||
PASBook *book,
|
||||
PASRequest *req)
|
||||
PASGetChangesRequest *req)
|
||||
{
|
||||
PASBackendFile *bf = PAS_BACKEND_FILE (backend);
|
||||
CORBA_Environment ev;
|
||||
@ -967,7 +952,7 @@ pas_backend_file_process_get_changes (PASBackend *backend,
|
||||
pas_backend_file_changes (bf, book, e_iterator_get(iterator));
|
||||
gtk_object_unref(GTK_OBJECT(iterator));
|
||||
|
||||
g_free(req->search);
|
||||
g_free(req->change_id);
|
||||
CORBA_exception_init(&ev);
|
||||
bonobo_object_release_unref (req->listener, &ev);
|
||||
|
||||
@ -982,7 +967,7 @@ pas_backend_file_process_get_changes (PASBackend *backend,
|
||||
static void
|
||||
pas_backend_file_process_check_connection (PASBackend *backend,
|
||||
PASBook *book,
|
||||
PASRequest *req)
|
||||
PASCheckConnectionRequest *req)
|
||||
{
|
||||
PASBackendFile *bf = PAS_BACKEND_FILE (backend);
|
||||
|
||||
@ -1000,7 +985,7 @@ pas_backend_file_extract_path_from_uri (const char *uri)
|
||||
static void
|
||||
pas_backend_file_process_authenticate_user (PASBackend *backend,
|
||||
PASBook *book,
|
||||
PASRequest *req)
|
||||
PASAuthenticateUserRequest *req)
|
||||
{
|
||||
pas_book_respond_authenticate_user (book,
|
||||
GNOME_Evolution_Addressbook_BookListener_Success);
|
||||
@ -1009,7 +994,7 @@ pas_backend_file_process_authenticate_user (PASBackend *backend,
|
||||
static void
|
||||
pas_backend_file_process_get_supported_fields (PASBackend *backend,
|
||||
PASBook *book,
|
||||
PASRequest *req)
|
||||
PASGetSupportedFieldsRequest *req)
|
||||
{
|
||||
EList *fields = e_list_new ((EListCopyFunc)g_strdup, (EListFreeFunc)g_free, NULL);
|
||||
ECardSimple *simple;
|
||||
@ -1047,47 +1032,47 @@ pas_backend_file_process_client_requests (PASBook *book)
|
||||
|
||||
switch (req->op) {
|
||||
case CreateCard:
|
||||
pas_backend_file_process_create_card (backend, book, req);
|
||||
pas_backend_file_process_create_card (backend, book, (PASCreateCardRequest*)req);
|
||||
break;
|
||||
|
||||
case RemoveCard:
|
||||
pas_backend_file_process_remove_card (backend, book, req);
|
||||
pas_backend_file_process_remove_card (backend, book, (PASRemoveCardRequest*)req);
|
||||
break;
|
||||
|
||||
case ModifyCard:
|
||||
pas_backend_file_process_modify_card (backend, book, req);
|
||||
pas_backend_file_process_modify_card (backend, book, (PASModifyCardRequest*)req);
|
||||
break;
|
||||
|
||||
case CheckConnection:
|
||||
pas_backend_file_process_check_connection (backend, book, req);
|
||||
pas_backend_file_process_check_connection (backend, book, (PASCheckConnectionRequest*)req);
|
||||
break;
|
||||
|
||||
case GetVCard:
|
||||
pas_backend_file_process_get_vcard (backend, book, req);
|
||||
pas_backend_file_process_get_vcard (backend, book, (PASGetVCardRequest*)req);
|
||||
break;
|
||||
|
||||
case GetCursor:
|
||||
pas_backend_file_process_get_cursor (backend, book, req);
|
||||
pas_backend_file_process_get_cursor (backend, book, (PASGetCursorRequest*)req);
|
||||
break;
|
||||
|
||||
case GetBookView:
|
||||
pas_backend_file_process_get_book_view (backend, book, req);
|
||||
pas_backend_file_process_get_book_view (backend, book, (PASGetBookViewRequest*)req);
|
||||
break;
|
||||
|
||||
case GetChanges:
|
||||
pas_backend_file_process_get_changes (backend, book, req);
|
||||
pas_backend_file_process_get_changes (backend, book, (PASGetChangesRequest*)req);
|
||||
break;
|
||||
|
||||
case AuthenticateUser:
|
||||
pas_backend_file_process_authenticate_user (backend, book, req);
|
||||
pas_backend_file_process_authenticate_user (backend, book, (PASAuthenticateUserRequest*)req);
|
||||
break;
|
||||
|
||||
case GetSupportedFields:
|
||||
pas_backend_file_process_get_supported_fields (backend, book, req);
|
||||
pas_backend_file_process_get_supported_fields (backend, book, (PASGetSupportedFieldsRequest*)req);
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (req);
|
||||
pas_book_free_request (req);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -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);
|
||||
|
||||
|
||||
@ -38,16 +38,71 @@ typedef enum {
|
||||
} PASOperation;
|
||||
|
||||
typedef struct {
|
||||
PASOperation op;
|
||||
char *id;
|
||||
char *vcard;
|
||||
char *search;
|
||||
char *change_id;
|
||||
char *user;
|
||||
char *passwd;
|
||||
char *auth_method;
|
||||
PASOperation op;
|
||||
char *id;
|
||||
char *vcard;
|
||||
} PASCreateCardRequest;
|
||||
|
||||
typedef struct {
|
||||
PASOperation op;
|
||||
char *id;
|
||||
} PASRemoveCardRequest;
|
||||
|
||||
typedef struct {
|
||||
PASOperation op;
|
||||
char *vcard;
|
||||
} PASModifyCardRequest;
|
||||
|
||||
typedef struct {
|
||||
PASOperation op;
|
||||
char *id;
|
||||
} PASGetVCardRequest;
|
||||
|
||||
typedef struct {
|
||||
PASOperation op;
|
||||
char *search;
|
||||
} PASGetCursorRequest;
|
||||
|
||||
typedef struct {
|
||||
PASOperation op;
|
||||
char *search;
|
||||
GNOME_Evolution_Addressbook_BookViewListener listener;
|
||||
GNOME_Evolution_Addressbook_stringlist fields;
|
||||
} PASGetBookViewRequest;
|
||||
|
||||
typedef struct {
|
||||
PASOperation op;
|
||||
char *change_id;
|
||||
GNOME_Evolution_Addressbook_BookViewListener listener;
|
||||
} PASGetChangesRequest;
|
||||
|
||||
typedef struct {
|
||||
PASOperation op;
|
||||
} PASCheckConnectionRequest;
|
||||
|
||||
typedef struct {
|
||||
PASOperation op;
|
||||
char *user;
|
||||
char *passwd;
|
||||
char *auth_method;
|
||||
} PASAuthenticateUserRequest;
|
||||
|
||||
typedef struct {
|
||||
PASOperation op;
|
||||
} PASGetSupportedFieldsRequest;
|
||||
|
||||
typedef union {
|
||||
PASOperation op;
|
||||
|
||||
PASCreateCardRequest create;
|
||||
PASRemoveCardRequest remove;
|
||||
PASModifyCardRequest modify;
|
||||
PASGetVCardRequest get_vcard;
|
||||
PASGetCursorRequest get_cursor;
|
||||
PASGetBookViewRequest get_book_view;
|
||||
PASGetChangesRequest get_changes;
|
||||
PASCheckConnectionRequest check_connection;
|
||||
PASAuthenticateUserRequest auth_user;
|
||||
PASGetSupportedFieldsRequest get_supported_fields;
|
||||
} PASRequest;
|
||||
|
||||
struct _PASBook {
|
||||
@ -71,6 +126,7 @@ PASBackend *pas_book_get_backend (PASBook
|
||||
GNOME_Evolution_Addressbook_BookListener pas_book_get_listener (PASBook *book);
|
||||
int pas_book_check_pending (PASBook *book);
|
||||
PASRequest *pas_book_pop_request (PASBook *book);
|
||||
void pas_book_free_request (PASRequest *request);
|
||||
void pas_book_respond_open (PASBook *book,
|
||||
GNOME_Evolution_Addressbook_BookListener_CallStatus status);
|
||||
void pas_book_respond_create (PASBook *book,
|
||||
|
||||
Reference in New Issue
Block a user