diff options
author | Christopher James Lahey <clahey@ximian.com> | 2002-02-14 03:35:13 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2002-02-14 03:35:13 +0800 |
commit | 22c314f7226679706f06cbd9d2b7dcc0edaf7279 (patch) | |
tree | 2d6ab334fcfac49670ae2650a76c6d849f5f60ea /addressbook/backend/ebook | |
parent | 2a3cd23e86c1321815181c27746524f99d6fcd31 (diff) | |
download | gsoc2013-evolution-22c314f7226679706f06cbd9d2b7dcc0edaf7279.tar gsoc2013-evolution-22c314f7226679706f06cbd9d2b7dcc0edaf7279.tar.gz gsoc2013-evolution-22c314f7226679706f06cbd9d2b7dcc0edaf7279.tar.bz2 gsoc2013-evolution-22c314f7226679706f06cbd9d2b7dcc0edaf7279.tar.lz gsoc2013-evolution-22c314f7226679706f06cbd9d2b7dcc0edaf7279.tar.xz gsoc2013-evolution-22c314f7226679706f06cbd9d2b7dcc0edaf7279.tar.zst gsoc2013-evolution-22c314f7226679706f06cbd9d2b7dcc0edaf7279.zip |
New functions that take a file:// url ending in the directory name and
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.
svn path=/trunk/; revision=15710
Diffstat (limited to 'addressbook/backend/ebook')
-rw-r--r-- | addressbook/backend/ebook/e-book-util.c | 95 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-book-util.h | 68 |
2 files changed, 125 insertions, 38 deletions
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 |