aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend
diff options
context:
space:
mode:
authorChris Toshok <toshok@src.gnome.org>2000-03-28 13:32:40 +0800
committerChris Toshok <toshok@src.gnome.org>2000-03-28 13:32:40 +0800
commit8b355664ab9cabed3c0dd1ec25dba20a8e2827a9 (patch)
tree153aacad7222e1ae9fb6543c65686f0014fa0d8e /addressbook/backend
parentea9b13f015089fdb90e1bc07e214bc80381fb08a (diff)
downloadgsoc2013-evolution-8b355664ab9cabed3c0dd1ec25dba20a8e2827a9.tar.gz
gsoc2013-evolution-8b355664ab9cabed3c0dd1ec25dba20a8e2827a9.tar.zst
gsoc2013-evolution-8b355664ab9cabed3c0dd1ec25dba20a8e2827a9.zip
implement function. (get_nth): implement function. (cursor_destroy): free
* addressbook/backend/pas/pas-backend-file.c (get_length): implement function. (get_nth): implement function. (cursor_destroy): free up the internal glist of vcards, and fix warning. (pas_backend_file_build_all_cards_list): new function, to build up the list of cards in the db. (pas_backend_file_process_get_all_cards): call pas_backend_file_build_+all_cards_list, and fix warning. svn path=/trunk/; revision=2210
Diffstat (limited to 'addressbook/backend')
-rw-r--r--addressbook/backend/pas/pas-backend-file.c63
1 files changed, 54 insertions, 9 deletions
diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c
index 2c0b156b33..94c87f655b 100644
--- a/addressbook/backend/pas/pas-backend-file.c
+++ b/addressbook/backend/pas/pas-backend-file.c
@@ -34,24 +34,26 @@ struct _PASBackendFilePrivate {
struct _PASBackendFileCursorPrivate {
PASBackend *backend;
PASBook *book;
+
+ GList *elements;
+ guint32 num_elements;
};
static long
get_length(PASCardCursor *cursor, gpointer data)
{
-#if 0
PASBackendFileCursorPrivate *cursor_data = (PASBackendFileCursorPrivate *) data;
-#endif
- return 0;
+
+ return cursor_data->num_elements;
}
static char *
get_nth(PASCardCursor *cursor, long n, gpointer data)
{
-#if 0
PASBackendFileCursorPrivate *cursor_data = (PASBackendFileCursorPrivate *) data;
-#endif
- return "";
+ GList *nth_item = g_list_nth(cursor_data->elements, n);
+
+ return (char*)nth_item->data;
}
static void
@@ -61,7 +63,7 @@ cursor_destroy(GtkObject *object, gpointer data)
Evolution_Book corba_book;
PASBackendFileCursorPrivate *cursor_data = (PASBackendFileCursorPrivate *) data;
- corba_book = bonobo_object_corba_objref(cursor_data->book);
+ corba_book = bonobo_object_corba_objref(BONOBO_OBJECT(cursor_data->book));
CORBA_exception_init(&ev);
@@ -74,6 +76,9 @@ cursor_destroy(GtkObject *object, gpointer data)
CORBA_exception_free(&ev);
+ g_list_foreach(cursor_data->elements, (GFunc)g_free, NULL);
+ g_list_free (cursor_data->elements);
+
g_free(cursor_data);
}
@@ -204,6 +209,44 @@ pas_backend_file_process_modify_card (PASBackend *backend,
}
static void
+pas_backend_file_build_all_cards_list(PASBackend *backend,
+ PASBackendFileCursorPrivate *cursor_data)
+{
+ PASBackendFile *bf = PAS_BACKEND_FILE (backend);
+ DB *db = bf->priv->file_db;
+ int db_error;
+
+ cursor_data->elements = NULL;
+ do {
+ DBT id_dbt, vcard_dbt;
+ char *id;
+
+ db_error = db->seq(db, &id_dbt, &vcard_dbt, R_NEXT);
+
+ id = g_strndup(id_dbt.data, id_dbt.size);
+
+ /* don't include the version in the list of cards */
+ if (!strcmp (id, PAS_BACKEND_FILE_VERSION_NAME)) {
+ g_free(id);
+ continue;
+ }
+ else {
+ g_free(id);
+ g_list_append(cursor_data->elements, g_strndup(vcard_dbt.data,
+ vcard_dbt.size));
+ }
+
+ } while (db_error == 0);
+
+ if (db_error == -1) {
+ g_warning ("pas_backend_file_build_all_cards_list: error building list\n");
+ }
+ else {
+ cursor_data->num_elements = g_list_length (cursor_data->elements);
+ }
+}
+
+static void
pas_backend_file_process_get_all_cards (PASBackend *backend,
PASBook *book,
PASRequest *req)
@@ -222,8 +265,10 @@ pas_backend_file_process_get_all_cards (PASBackend *backend,
cursor_data = g_new(PASBackendFileCursorPrivate, 1);
cursor_data->backend = backend;
cursor_data->book = book;
-
- corba_book = bonobo_object_corba_objref(book);
+
+ pas_backend_file_build_all_cards_list(backend, cursor_data);
+
+ corba_book = bonobo_object_corba_objref(BONOBO_OBJECT(book));
CORBA_exception_init(&ev);