diff options
Diffstat (limited to 'addressbook/backend/pas/pas-backend-file.c')
-rw-r--r-- | addressbook/backend/pas/pas-backend-file.c | 107 |
1 files changed, 64 insertions, 43 deletions
diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c index 2848fcda71..3daed9d7c6 100644 --- a/addressbook/backend/pas/pas-backend-file.c +++ b/addressbook/backend/pas/pas-backend-file.c @@ -54,11 +54,9 @@ struct _PASBackendFilePrivate { GList *clients; gboolean loaded; char *uri; - char *filename; DB *file_db; EList *book_views; gboolean writable; - GHashTable *address_lists; }; struct _PASBackendFileCursorPrivate { @@ -370,7 +368,6 @@ pas_backend_file_changes (PASBackendFile *bf, DBC *dbc; PASBackendFileBookView *view = (PASBackendFileBookView *)cnstview; PASBackendFileChangeContext *ctx = cnstview->change_context; - char *dirname, *slash; memset (&id_dbt, 0, sizeof (id_dbt)); memset (&vcard_dbt, 0, sizeof (vcard_dbt)); @@ -378,16 +375,11 @@ pas_backend_file_changes (PASBackendFile *bf, if (!bf->priv->loaded) return; - /* Find the changed ids */ - dirname = g_strdup (bf->priv->filename); - slash = strrchr (dirname, '/'); - *slash = '\0'; - - filename = g_strdup_printf ("%s/%s.db", dirname, view->change_id); + /* Find the changed ids - FIX ME, path should not be hard coded */ + filename = g_strdup_printf ("%s/evolution/local/Contacts/%s.db", g_get_home_dir (), view->change_id); ehash = e_dbhash_new (filename); g_free (filename); - g_free (dirname); - + db_error = db->cursor (db, NULL, &dbc, 0); if (db_error != 0) { @@ -535,7 +527,7 @@ do_create(PASBackend *backend, static void pas_backend_file_process_create_card (PASBackend *backend, PASBook *book, - PASCreateCardRequest *req) + PASRequest *req) { char *id; char *vcard; @@ -570,12 +562,14 @@ pas_backend_file_process_create_card (PASBackend *backend, GNOME_Evolution_Addressbook_BookListener_CardNotFound, ""); } + + g_free(req->vcard); } static void pas_backend_file_process_remove_card (PASBackend *backend, PASBook *book, - PASRemoveCardRequest *req) + PASRequest *req) { PASBackendFile *bf = PAS_BACKEND_FILE (backend); DB *db = bf->priv->file_db; @@ -594,6 +588,7 @@ pas_backend_file_process_remove_card (PASBackend *backend, pas_book_respond_remove ( book, GNOME_Evolution_Addressbook_BookListener_CardNotFound); + g_free (req->id); return; } @@ -602,6 +597,7 @@ pas_backend_file_process_remove_card (PASBackend *backend, pas_book_respond_remove ( book, GNOME_Evolution_Addressbook_BookListener_CardNotFound); + g_free (req->id); return; } @@ -625,12 +621,14 @@ pas_backend_file_process_remove_card (PASBackend *backend, pas_book_respond_remove ( book, GNOME_Evolution_Addressbook_BookListener_Success); + + g_free (req->id); } static void pas_backend_file_process_modify_card (PASBackend *backend, PASBook *book, - PASModifyCardRequest *req) + PASRequest *req) { PASBackendFile *bf = PAS_BACKEND_FILE (backend); DB *db = bf->priv->file_db; @@ -665,6 +663,7 @@ 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); @@ -695,12 +694,10 @@ pas_backend_file_process_modify_card (PASBackend *backend, pas_book_view_notify_add_1 (view->book_view, req->vcard); else /* if (old_match) */ pas_book_view_notify_remove (view->book_view, id); - pas_book_view_notify_complete (view->book_view); bonobo_object_release_unref(bonobo_object_corba_objref(BONOBO_OBJECT(view->book_view)), &ev); } - gtk_object_unref(GTK_OBJECT(iterator)); pas_book_respond_modify ( @@ -716,12 +713,13 @@ pas_backend_file_process_modify_card (PASBackend *backend, g_free(old_vcard_string); gtk_object_unref(GTK_OBJECT(card)); + g_free (req->vcard); } 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; @@ -780,7 +778,7 @@ pas_backend_file_build_cards_list(PASBackend *backend, static void pas_backend_file_process_get_vcard (PASBackend *backend, PASBook *book, - PASGetVCardRequest *req) + PASRequest *req) { PASBackendFile *bf; DB *db; @@ -813,7 +811,7 @@ pas_backend_file_process_get_vcard (PASBackend *backend, static void pas_backend_file_process_get_cursor (PASBackend *backend, PASBook *book, - PASGetCursorRequest *req) + PASRequest *req) { /* PASBackendFile *bf = PAS_BACKEND_FILE (backend); @@ -863,9 +861,10 @@ pas_backend_file_process_get_cursor (PASBackend *backend, static void pas_backend_file_process_get_book_view (PASBackend *backend, PASBook *book, - PASGetBookViewRequest *req) + PASRequest *req) { PASBackendFile *bf = PAS_BACKEND_FILE (backend); + CORBA_Environment ev; PASBookView *book_view; PASBackendFileBookView view; EIterator *iterator; @@ -880,7 +879,7 @@ pas_backend_file_process_get_book_view (PASBackend *backend, GTK_SIGNAL_FUNC(view_destroy), book); view.book_view = book_view; - view.search = g_strdup (req->search); + view.search = req->search; view.card_sexp = NULL; view.change_id = NULL; view.change_context = NULL; @@ -897,14 +896,28 @@ 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, - PASGetChangesRequest *req) + PASRequest *req) { PASBackendFile *bf = PAS_BACKEND_FILE (backend); + CORBA_Environment ev; PASBookView *book_view; PASBackendFileBookView view; PASBackendFileChangeContext ctx; @@ -943,12 +956,23 @@ pas_backend_file_process_get_changes (PASBackend *backend, e_iterator_last(iterator); pas_backend_file_changes (bf, book, e_iterator_get(iterator)); gtk_object_unref(GTK_OBJECT(iterator)); + + g_free(req->search); + CORBA_exception_init(&ev); + bonobo_object_release_unref (req->listener, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning("pas_backend_file_process_get_changed: Exception unreffing " + "listener.\n"); + } + + CORBA_exception_free(&ev); } static void pas_backend_file_process_check_connection (PASBackend *backend, PASBook *book, - PASCheckConnectionRequest *req) + PASRequest *req) { PASBackendFile *bf = PAS_BACKEND_FILE (backend); @@ -966,7 +990,7 @@ pas_backend_file_extract_path_from_uri (const char *uri) static void pas_backend_file_process_authenticate_user (PASBackend *backend, PASBook *book, - PASAuthenticateUserRequest *req) + PASRequest *req) { pas_book_respond_authenticate_user (book, GNOME_Evolution_Addressbook_BookListener_Success); @@ -975,7 +999,7 @@ pas_backend_file_process_authenticate_user (PASBackend *backend, static void pas_backend_file_process_get_supported_fields (PASBackend *backend, PASBook *book, - PASGetSupportedFieldsRequest *req) + PASRequest *req) { EList *fields = e_list_new ((EListCopyFunc)g_strdup, (EListFreeFunc)g_free, NULL); ECardSimple *simple; @@ -1013,47 +1037,47 @@ pas_backend_file_process_client_requests (PASBook *book) switch (req->op) { case CreateCard: - pas_backend_file_process_create_card (backend, book, (PASCreateCardRequest*)req); + pas_backend_file_process_create_card (backend, book, req); break; case RemoveCard: - pas_backend_file_process_remove_card (backend, book, (PASRemoveCardRequest*)req); + pas_backend_file_process_remove_card (backend, book, req); break; case ModifyCard: - pas_backend_file_process_modify_card (backend, book, (PASModifyCardRequest*)req); + pas_backend_file_process_modify_card (backend, book, req); break; case CheckConnection: - pas_backend_file_process_check_connection (backend, book, (PASCheckConnectionRequest*)req); + pas_backend_file_process_check_connection (backend, book, req); break; case GetVCard: - pas_backend_file_process_get_vcard (backend, book, (PASGetVCardRequest*)req); + pas_backend_file_process_get_vcard (backend, book, req); break; case GetCursor: - pas_backend_file_process_get_cursor (backend, book, (PASGetCursorRequest*)req); + pas_backend_file_process_get_cursor (backend, book, req); break; case GetBookView: - pas_backend_file_process_get_book_view (backend, book, (PASGetBookViewRequest*)req); + pas_backend_file_process_get_book_view (backend, book, req); break; case GetChanges: - pas_backend_file_process_get_changes (backend, book, (PASGetChangesRequest*)req); + pas_backend_file_process_get_changes (backend, book, req); break; case AuthenticateUser: - pas_backend_file_process_authenticate_user (backend, book, (PASAuthenticateUserRequest*)req); + pas_backend_file_process_authenticate_user (backend, book, req); break; case GetSupportedFields: - pas_backend_file_process_get_supported_fields (backend, book, (PASGetSupportedFieldsRequest*)req); + pas_backend_file_process_get_supported_fields (backend, book, req); break; } - pas_book_free_request (req); + g_free (req); } static void @@ -1278,6 +1302,9 @@ pas_backend_file_load_uri (PASBackend *backend, } } + g_free (filename); + + if (db_error != 0) { bf->priv->file_db = NULL; return GNOME_Evolution_Addressbook_BookListener_OtherError; @@ -1297,9 +1324,6 @@ pas_backend_file_load_uri (PASBackend *backend, g_free(bf->priv->uri); bf->priv->uri = g_strdup (uri); - g_free (bf->priv->filename); - bf->priv->filename = filename; - return GNOME_Evolution_Addressbook_BookListener_Success; } @@ -1446,9 +1470,6 @@ pas_backend_file_destroy (GtkObject *object) gtk_object_unref(GTK_OBJECT(bf->priv->book_views)); g_free (bf->priv->uri); - g_free (bf->priv->filename); - - g_free (bf->priv); GTK_OBJECT_CLASS (pas_backend_file_parent_class)->destroy (object); } |