diff options
-rw-r--r-- | addressbook/ChangeLog | 47 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-book-util.c | 95 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-book-util.h | 68 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-backend-card-sexp.c | 18 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-backend-card-sexp.h | 21 |
5 files changed, 211 insertions, 38 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 101e23ea06..7319003b67 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,5 +1,52 @@ 2002-02-13 Christopher James Lahey <clahey@ximian.com> + * backend/ebook/e-book-util.c, backend/ebook/e-book-util.h + (e_book_expand_uri, e_book_load_address_book_by_uri, + e_book_use_address_book_by_uri): New functions that take a file:// + url ending in the directory name and automatically append the + addressbook.db and do the appropriate thing. + + * backend/pas/pas-backend-card-sexp.c, + backend/pas/pas-backend-card-sexp.h: Added copyright notice here. + + * gui/component/addressbook-component.c + (destination_folder_handle_drop), gui/component/addressbook.c + (set_prop): Use e_book_expand_uri instead of + addressbook_expand_uri. + + * gui/component/addressbook-storage.c: Fixed the fcntl include + here. + + * gui/component/addressbook.c (ContactsCopyToFolder, + ContactsMoveToFolder): Added handlers for these two verbs. + + * gui/component/addressbook.h: Removed addressbook_expand_uri in + favor of e_book_expand_uri. + + * gui/widgets/e-addressbook-reflow-adapter.c (transfer_cards): + Added code to handle Move to and Copy to right click menu items. + + * gui/widgets/e-addressbook-util.c, + gui/widgets/e-addressbook-util.h (e_addressbook_transfer_cards): + New function to pop up a dialog and transfer a set of cards to the + given folder. + + * gui/widgets/e-addressbook-view.c, + gui/widgets/e-addressbook-view.h (display_view): Don't attach to + the view if it doesn't exist yet. We have to make this then + attach later. + (e_addressbook_view_copy_to_folder, + e_addressbook_view_move_to_folder): New functions utilizing + e_addressbook_transfer_cards. + (table_right_click): Add copy_to_folder and move_to_folder to the + right click menu for tables here. + (e_addressbook_view_discard_menus): Handle menu unmerging here. + + * gui/widgets/e-minicard-view-widget.h (struct + _EMinicardViewWidget): Removed unused field. + +2002-02-13 Christopher James Lahey <clahey@ximian.com> + * gui/widgets/e-addressbook-view.c (display_view): Attach the GalViewMinicard to the EMinicardView here. diff --git a/addressbook/backend/ebook/e-book-util.c b/addressbook/backend/ebook/e-book-util.c index 04f8a88131..d214937843 100644 --- a/addressbook/backend/ebook/e-book-util.c +++ b/addressbook/backend/ebook/e-book-util.c @@ -33,6 +33,93 @@ #include <libgnome/gnome-util.h> #include "e-card-compare.h" +typedef struct _CommonBookInfo CommonBookInfo; +struct _CommonBookInfo { + EBookCommonCallback cb; + gpointer closure; +}; + +char * +e_book_expand_uri (const char *uri) +{ + char *new_uri; + + if (!strncmp (uri, "file:", 5)) { + if (strlen (uri + 7) > 3 + && !strcmp (uri + strlen(uri) - 3, ".db")) { + /* it's a .db file */ + new_uri = g_strdup (uri); + } + else { + char *file_name; + /* we assume it's a dir and glom addressbook.db onto the end. */ + file_name = g_concat_dir_and_file(uri + 7, "addressbook.db"); + new_uri = g_strdup_printf("file://%s", file_name); + g_free(file_name); + } + } + else { + new_uri = g_strdup (uri); + } + + return new_uri; +} + +static void +got_uri_book_cb (EBook *book, EBookStatus status, gpointer closure) +{ + CommonBookInfo *info = (CommonBookInfo *) closure; + + if (status == E_BOOK_STATUS_SUCCESS) { + info->cb (book, info->closure); + } else { + info->cb (NULL, info->closure); + } + g_free (info); +} + +gboolean +e_book_load_address_book_by_uri (EBook *book, const char *uri, EBookCallback open_response, gpointer closure) +{ + gboolean rv; + char *real_uri; + + g_return_val_if_fail (book != NULL, FALSE); + g_return_val_if_fail (E_IS_BOOK (book), FALSE); + g_return_val_if_fail (open_response != NULL, FALSE); + + real_uri = e_book_expand_uri (uri); + + rv = e_book_load_uri (book, real_uri, open_response, closure); + + if (!rv) { + g_warning ("Couldn't load addressbook %s", real_uri); + } + + g_free (real_uri); + + return rv; +} + +void +e_book_use_address_book_by_uri (const char *uri, EBookCommonCallback cb, gpointer closure) +{ + EBook *book; + CommonBookInfo *info; + + g_return_if_fail (cb != NULL); + + info = g_new0 (CommonBookInfo, 1); + info->cb = cb; + info->closure = closure; + + book = e_book_new (); + if (! e_book_load_address_book_by_uri (book, uri, got_uri_book_cb, info)) { + gtk_object_unref (GTK_OBJECT (book)); + g_free (info); + } +} + Bonobo_ConfigDatabase e_book_get_config_database (CORBA_Environment *ev) { @@ -43,7 +130,7 @@ e_book_get_config_database (CORBA_Environment *ev) return config_db; } - + gboolean e_book_load_local_address_book (EBook *book, EBookCallback open_response, gpointer closure) { @@ -72,12 +159,6 @@ e_book_load_local_address_book (EBook *book, EBookCallback open_response, gpoint static EBook *common_local_book = NULL; -typedef struct _CommonBookInfo CommonBookInfo; -struct _CommonBookInfo { - EBookCommonCallback cb; - gpointer closure; -}; - static void got_local_book_cb (EBook *book, EBookStatus status, gpointer closure) { diff --git a/addressbook/backend/ebook/e-book-util.h b/addressbook/backend/ebook/e-book-util.h index 39e32e633d..33f90c399f 100644 --- a/addressbook/backend/ebook/e-book-util.h +++ b/addressbook/backend/ebook/e-book-util.h @@ -40,46 +40,52 @@ typedef void (*EBookCommonCallback) (EBook *book, gpointer closure); typedef void (*EBookSimpleQueryCallback) (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure); typedef void (*EBookHaveAddressCallback) (EBook *book, const gchar *addr, ECard *card, gpointer closure); -gboolean e_book_load_local_address_book (EBook *book, - EBookCallback open_response, - gpointer closure); - -void e_book_use_local_address_book (EBookCommonCallback cb, gpointer closure); - -gboolean e_book_load_default_book (EBook *book, - EBookCallback open_response, - gpointer closure); +/* expand file:///foo/foo/ to file:///foo/foo/addressbook.db */ +char *e_book_expand_uri (const char *uri); +gboolean e_book_load_address_book_by_uri (EBook *book, + const char *uri, + EBookCallback open_response, + gpointer closure); +void e_book_use_address_book_by_uri (const char *uri, + EBookCommonCallback cb, + gpointer closure); + +gboolean e_book_load_local_address_book (EBook *book, + EBookCallback open_response, + gpointer closure); +void e_book_use_local_address_book (EBookCommonCallback cb, + gpointer closure); +gboolean e_book_load_default_book (EBook *book, + EBookCallback open_response, + gpointer closure); /* Bonoboconf database interface. */ -Bonobo_ConfigDatabase e_book_get_config_database (CORBA_Environment *ev); +Bonobo_ConfigDatabase e_book_get_config_database (CORBA_Environment *ev); /* Simple Query Interface. */ - -guint e_book_simple_query (EBook *book, - const char *query, - EBookSimpleQueryCallback cb, - gpointer closure); -void e_book_simple_query_cancel (EBook *book, - guint tag); +guint e_book_simple_query (EBook *book, + const char *query, + EBookSimpleQueryCallback cb, + gpointer closure); +void e_book_simple_query_cancel (EBook *book, + guint tag); /* Specialized Name/Email Queries */ - -guint e_book_name_and_email_query (EBook *book, - const char *name, - const char *email, - EBookSimpleQueryCallback cb, - gpointer closure); - -guint e_book_nickname_query (EBook *book, - const char *nickname, - EBookSimpleQueryCallback cb, - gpointer closure); +guint e_book_name_and_email_query (EBook *book, + const char *name, + const char *email, + EBookSimpleQueryCallback cb, + gpointer closure); +guint e_book_nickname_query (EBook *book, + const char *nickname, + EBookSimpleQueryCallback cb, + gpointer closure); /* Returns the ECard associated to email in the callback, or NULL if no match is found in the local address book. */ -void e_book_query_address_locally (const gchar *email, - EBookHaveAddressCallback cb, - gpointer closure); +void e_book_query_address_locally (const gchar *email, + EBookHaveAddressCallback cb, + gpointer closure); END_GNOME_DECLS diff --git a/addressbook/backend/pas/pas-backend-card-sexp.c b/addressbook/backend/pas/pas-backend-card-sexp.c index 705eb667fd..8b531d5ede 100644 --- a/addressbook/backend/pas/pas-backend-card-sexp.c +++ b/addressbook/backend/pas/pas-backend-card-sexp.c @@ -1,4 +1,22 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * pas-backend-card-sexp.c + * Copyright 1999, 2000, 2001, Ximian, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License, version 2, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ #include "pas-backend-card-sexp.h" diff --git a/addressbook/backend/pas/pas-backend-card-sexp.h b/addressbook/backend/pas/pas-backend-card-sexp.h index e1cb75c77d..ee51a75dab 100644 --- a/addressbook/backend/pas/pas-backend-card-sexp.h +++ b/addressbook/backend/pas/pas-backend-card-sexp.h @@ -1,4 +1,25 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * pas-backend-card-sexp.h + * Copyright 2000, 2001, Ximian, Inc. + * + * Authors: + * Chris Lahey <clahey@ximian.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License, version 2, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ #ifndef __PAS_BACKEND_CARD_SEXP_H__ #define __PAS_BACKEND_CARD_SEXP_H__ |