diff options
author | Dan Winship <danw@src.gnome.org> | 2003-03-01 02:02:35 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2003-03-01 02:02:35 +0800 |
commit | 5597bf794e72cd92935a7ac9828bcb590fcbb853 (patch) | |
tree | 8c4a461a70977e4de82433c90d0baa173db38b60 /addressbook/gui | |
parent | 4ab6d9ca9b4695fc7bd9358db93cac9a5f78df6c (diff) | |
download | gsoc2013-evolution-5597bf794e72cd92935a7ac9828bcb590fcbb853.tar.gz gsoc2013-evolution-5597bf794e72cd92935a7ac9828bcb590fcbb853.tar.zst gsoc2013-evolution-5597bf794e72cd92935a7ac9828bcb590fcbb853.zip |
Remove these from here; talking to the mailer doesn't really belong at the
* backend/ebook/e-card.c (e_card_list_send, e_card_send): Remove
these from here; talking to the mailer doesn't really belong at
the libebook level anyway.
* backend/ebook/Makefile.am: Remove Evolution-Composer CORBA
stuff, which fixes some linking problems on OS X.
* gui/widgets/e-addressbook-util.c (e_addressbook_send_card_list,
e_addressbook_send_card): Move from e-card.c and rename.
* gui/widgets/Makefile.am: move Evolution-Composer CORBA stuff
here
* gui/widgets/e-addressbook-view.c (send_as, send_to,
e_addressbook_view_send, e_addressbook_view_send_to): Update for
new function names.
* gui/contact-list-editor/e-contact-list-editor.c (file_send_as_cb,
file_send_to_cb): Likewise
* gui/contact-editor/e-contact-editor.c (file_send_as_cb,
file_send_to_cb): Likewise
svn path=/trunk/; revision=20103
Diffstat (limited to 'addressbook/gui')
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-editor.c | 4 | ||||
-rw-r--r-- | addressbook/gui/contact-list-editor/e-contact-list-editor.c | 4 | ||||
-rw-r--r-- | addressbook/gui/widgets/.cvsignore | 5 | ||||
-rw-r--r-- | addressbook/gui/widgets/Makefile.am | 24 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-util.c | 267 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-util.h | 10 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-addressbook-view.c | 8 |
7 files changed, 314 insertions, 8 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 038ca7825d..d3b6301e11 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -1030,7 +1030,7 @@ file_send_as_cb (GtkWidget *widget, gpointer data) e_card_simple_sync_card (ce->simple); card = ce->card; - e_card_send(card, E_CARD_DISPOSITION_AS_ATTACHMENT); + e_addressbook_send_card(card, E_ADDRESSBOOK_DISPOSITION_AS_ATTACHMENT); } static void @@ -1045,7 +1045,7 @@ file_send_to_cb (GtkWidget *widget, gpointer data) e_card_simple_sync_card (ce->simple); card = ce->card; - e_card_send(card, E_CARD_DISPOSITION_AS_TO); + e_addressbook_send_card(card, E_ADDRESSBOOK_DISPOSITION_AS_TO); } gboolean diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c index e378ecfcd5..ecb63b2e2a 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -463,7 +463,7 @@ file_send_as_cb (GtkWidget *widget, gpointer data) extract_info (cle); - e_card_send(cle->card, E_CARD_DISPOSITION_AS_ATTACHMENT); + e_addressbook_send_card(cle->card, E_ADDRESSBOOK_DISPOSITION_AS_ATTACHMENT); } static void @@ -473,7 +473,7 @@ file_send_to_cb (GtkWidget *widget, gpointer data) extract_info (cle); - e_card_send(cle->card, E_CARD_DISPOSITION_AS_TO); + e_addressbook_send_card(cle->card, E_ADDRESSBOOK_DISPOSITION_AS_TO); } static void diff --git a/addressbook/gui/widgets/.cvsignore b/addressbook/gui/widgets/.cvsignore index 8f18401976..d3b9ac4305 100644 --- a/addressbook/gui/widgets/.cvsignore +++ b/addressbook/gui/widgets/.cvsignore @@ -12,3 +12,8 @@ minicard-widget-test reflow-test e-addressbook-marshal.c e-addressbook-marshal.h +Evolution-Composer-stubs.c +Evolution-Composer-skels.c +Evolution-Composer-common.c +Evolution-Composer.h + diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am index dbc38f62e2..aa9d26e067 100644 --- a/addressbook/gui/widgets/Makefile.am +++ b/addressbook/gui/widgets/Makefile.am @@ -17,10 +17,28 @@ INCLUDES = \ -DLIBGNOMEUI_DISABLE_DEPRECATED \ $(EVOLUTION_ADDRESSBOOK_CFLAGS) +CORBA_COMPOSER_SOURCE_H = \ + Evolution-Composer.h +CORBA_COMPOSER_SOURCE_C = \ + Evolution-Composer-common.c \ + Evolution-Composer-skels.c \ + Evolution-Composer-stubs.c +CORBA_COMPOSER_IDL = $(srcdir)/../../../composer/Evolution-Composer.idl + +$(CORBA_COMPOSER_SOURCE_H): $(CORBA_COMPOSER_IDL) + $(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES) $(CORBA_COMPOSER_IDL) + +$(CORBA_COMPOSER_SOURCE_C): $(CORBA_COMPOSER_SOURCE_H) + +CORBA_SOURCE_H = $(CORBA_COMPOSER_SOURCE_H) +CORBA_SOURCE_C = $(CORBA_COMPOSER_SOURCE_C) +CORBA_SOURCE = $(CORBA_SOURCE_H) $(CORBA_SOURCE_C) + noinst_LIBRARIES = \ libeminicard.a libeminicard_a_SOURCES = \ + $(CORBA_SOURCE) \ e-addressbook-marshal.c \ e-addressbook-reflow-adapter.c \ e-addressbook-reflow-adapter.h \ @@ -70,6 +88,12 @@ e-addressbook-marshal.c: e-addressbook-marshal.h MARSHAL_GENERATED = e-addressbook-marshal.c e-addressbook-marshal.h +BUILT_SOURCES = $(CORBA_SOURCE) $(MARSHAL_GENERATED) +CLEANFILES = $(BUILT_SOURCES) + +dist-hook: + cd $(distdir); rm -f $(BUILT_SOURCES) + #noinst_PROGRAMS = \ # minicard-widget-test \ # minicard-label-test \ diff --git a/addressbook/gui/widgets/e-addressbook-util.c b/addressbook/gui/widgets/e-addressbook-util.c index fa554b5dd2..30b50d81f3 100644 --- a/addressbook/gui/widgets/e-addressbook-util.c +++ b/addressbook/gui/widgets/e-addressbook-util.c @@ -362,3 +362,270 @@ e_addressbook_transfer_cards (EBook *source, GList *cards /* adopted */, gboolea CORBA_free (folder); } + +#include <Evolution-Composer.h> + +#define COMPOSER_OAFID "OAFIID:GNOME_Evolution_Mail_Composer" + +void +e_addressbook_send_card_list (GList *cards, EAddressbookDisposition disposition) +{ +#if PENDING_PORT_WORK + GNOME_Evolution_Composer composer_server; + CORBA_Environment ev; + + if (cards == NULL) + return; + + CORBA_exception_init (&ev); + + composer_server = bonobo_activation_activate_from_id (COMPOSER_OAFID, 0, NULL, &ev); + + if (disposition == E_ADDRESSBOOK_DISPOSITION_AS_TO) { + GNOME_Evolution_Composer_RecipientList *to_list, *cc_list, *bcc_list; + CORBA_char *subject; + int to_i, bcc_i; + GList *iter; + gint to_length = 0, bcc_length = 0; + + /* Figure out how many addresses of each kind we have. */ + for (iter = cards; iter != NULL; iter = g_list_next (iter)) { + ECard *card = E_CARD (iter->data); + if (e_card_evolution_list (card)) { + gint len = card->email ? e_list_length (card->email) : 0; + if (e_card_evolution_list_show_addresses (card)) + to_length += len; + else + bcc_length += len; + } else { + if (card->email != NULL) + ++to_length; + } + } + + /* Now I have to make a CORBA sequences that represents a recipient list with + the right number of entries, for the cards. */ + to_list = GNOME_Evolution_Composer_RecipientList__alloc (); + to_list->_maximum = to_length; + to_list->_length = to_length; + if (to_length > 0) { + to_list->_buffer = CORBA_sequence_GNOME_Evolution_Composer_Recipient_allocbuf (to_length); + } + + cc_list = GNOME_Evolution_Composer_RecipientList__alloc (); + cc_list->_maximum = cc_list->_length = 0; + + bcc_list = GNOME_Evolution_Composer_RecipientList__alloc (); + bcc_list->_maximum = bcc_length; + bcc_list->_length = bcc_length; + if (bcc_length > 0) { + bcc_list->_buffer = CORBA_sequence_GNOME_Evolution_Composer_Recipient_allocbuf (bcc_length); + } + + to_i = 0; + bcc_i = 0; + while (cards != NULL) { + ECard *card = cards->data; + EIterator *iterator; + gchar *name, *addr; + gboolean is_list, is_hidden, free_name_addr; + GNOME_Evolution_Composer_Recipient *recipient; + + if (card->email != NULL) { + + is_list = e_card_evolution_list (card); + is_hidden = is_list && !e_card_evolution_list_show_addresses (card); + + for (iterator = e_list_get_iterator (card->email); e_iterator_is_valid (iterator); e_iterator_next (iterator)) { + + if (is_hidden) { + recipient = &(bcc_list->_buffer[bcc_i]); + ++bcc_i; + } else { + recipient = &(to_list->_buffer[to_i]); + ++to_i; + } + + name = ""; + addr = ""; + free_name_addr = FALSE; + if (e_iterator_is_valid (iterator)) { + + if (is_list) { + /* We need to decode the list entries, which are XMLified EDestinations. */ + EDestination *dest = e_destination_import (e_iterator_get (iterator)); + if (dest != NULL) { + name = g_strdup (e_destination_get_name (dest)); + addr = g_strdup (e_destination_get_email (dest)); + free_name_addr = TRUE; + g_object_unref (dest); + } + + } else { /* is just a plain old card */ + if (card->name) + name = e_card_name_to_string (card->name); + addr = g_strdup ((char *) e_iterator_get (iterator)); + free_name_addr = TRUE; + } + } + + recipient->name = CORBA_string_dup (name ? name : ""); + recipient->address = CORBA_string_dup (addr ? addr : ""); + + if (free_name_addr) { + g_free ((gchar *) name); + g_free ((gchar *) addr); + } + + /* If this isn't a list, we quit after the first (i.e. the default) address. */ + if (!is_list) + break; + + } + g_object_unref (iterator); + } + + cards = g_list_next (cards); + } + + subject = CORBA_string_dup (""); + + GNOME_Evolution_Composer_setHeaders (composer_server, "", to_list, cc_list, bcc_list, subject, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_printerr ("gui/e-meeting-edit.c: I couldn't set the composer headers via CORBA! Aagh.\n"); + CORBA_exception_free (&ev); + return; + } + + CORBA_free (to_list); + CORBA_free (cc_list); + CORBA_free (bcc_list); + CORBA_free (subject); + } else if (disposition == E_ADDRESSBOOK_DISPOSITION_AS_ATTACHMENT) { + CORBA_char *content_type, *filename, *description; + GNOME_Evolution_Composer_AttachmentData *attach_data; + CORBA_boolean show_inline; + char *tempstr; + + GNOME_Evolution_Composer_RecipientList *to_list, *cc_list, *bcc_list; + CORBA_char *subject; + + content_type = CORBA_string_dup ("text/x-vcard"); + filename = CORBA_string_dup (""); + + if (cards->next) { + description = CORBA_string_dup (_("Multiple VCards")); + } else { + char *file_as; + + g_object_get(cards->data, + "file_as", &file_as, + NULL); + + tempstr = g_strdup_printf (_("VCard for %s"), file_as); + description = CORBA_string_dup (tempstr); + g_free (tempstr); + } + + show_inline = FALSE; + + tempstr = e_card_list_get_vcard (cards); + attach_data = GNOME_Evolution_Composer_AttachmentData__alloc(); + attach_data->_maximum = attach_data->_length = strlen (tempstr); + attach_data->_buffer = CORBA_sequence_CORBA_char_allocbuf (attach_data->_length); + strcpy (attach_data->_buffer, tempstr); + g_free (tempstr); + + GNOME_Evolution_Composer_attachData (composer_server, + content_type, filename, description, + show_inline, attach_data, + &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_printerr ("gui/e-meeting-edit.c: I couldn't attach data to the composer via CORBA! Aagh.\n"); + CORBA_exception_free (&ev); + return; + } + + CORBA_free (content_type); + CORBA_free (filename); + CORBA_free (description); + CORBA_free (attach_data); + + to_list = GNOME_Evolution_Composer_RecipientList__alloc (); + to_list->_maximum = to_list->_length = 0; + + cc_list = GNOME_Evolution_Composer_RecipientList__alloc (); + cc_list->_maximum = cc_list->_length = 0; + + bcc_list = GNOME_Evolution_Composer_RecipientList__alloc (); + bcc_list->_maximum = bcc_list->_length = 0; + + if (!cards || cards->next) { + subject = CORBA_string_dup ("Contact information"); + } else { + ECard *card = cards->data; + const gchar *tempstr2; + + tempstr2 = NULL; + g_object_get(card, + "file_as", &tempstr2, + NULL); + if (!tempstr2 || !*tempstr2) + g_object_get(card, + "full_name", &tempstr2, + NULL); + if (!tempstr2 || !*tempstr2) + g_object_get(card, + "org", &tempstr2, + NULL); + if (!tempstr2 || !*tempstr2) { + EList *list; + EIterator *iterator; + g_object_get(card, + "email", &list, + NULL); + iterator = e_list_get_iterator (list); + if (e_iterator_is_valid (iterator)) { + tempstr2 = e_iterator_get (iterator); + } + g_object_unref (iterator); + } + + if (!tempstr2 || !*tempstr2) + tempstr = g_strdup_printf ("Contact information"); + else + tempstr = g_strdup_printf ("Contact information for %s", tempstr2); + subject = CORBA_string_dup (tempstr); + g_free (tempstr); + } + + GNOME_Evolution_Composer_setHeaders (composer_server, "", to_list, cc_list, bcc_list, subject, &ev); + + CORBA_free (to_list); + CORBA_free (cc_list); + CORBA_free (bcc_list); + CORBA_free (subject); + } + + GNOME_Evolution_Composer_show (composer_server, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_printerr ("gui/e-meeting-edit.c: I couldn't show the composer via CORBA! Aagh.\n"); + CORBA_exception_free (&ev); + return; + } + + CORBA_exception_free (&ev); +#endif +} + +void +e_addressbook_send_card (ECard *card, EAddressbookDisposition disposition) +{ + GList *list; + list = g_list_prepend (NULL, card); + e_addressbook_send_card_list (list, disposition); + g_list_free (list); +} + diff --git a/addressbook/gui/widgets/e-addressbook-util.h b/addressbook/gui/widgets/e-addressbook-util.h index f0681cea4d..e6ea3ab73b 100644 --- a/addressbook/gui/widgets/e-addressbook-util.h +++ b/addressbook/gui/widgets/e-addressbook-util.h @@ -48,6 +48,16 @@ void e_addressbook_transfer_cards (EBook *source gboolean delete_from_source, GtkWindow *parent_window); +typedef enum { + E_ADDRESSBOOK_DISPOSITION_AS_ATTACHMENT, + E_ADDRESSBOOK_DISPOSITION_AS_TO, +} EAddressbookDisposition; + +void e_addressbook_send_card (ECard *card, + EAddressbookDisposition disposition); +void e_addressbook_send_card_list (GList *cards, + EAddressbookDisposition disposition); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index 6b6ddffe3f..8a4714bc19 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -681,7 +681,7 @@ send_as (GtkWidget *widget, CardAndBook *card_and_book) { GList *cards = get_card_list (card_and_book); if (cards) { - e_card_list_send(cards, E_CARD_DISPOSITION_AS_ATTACHMENT); + e_addressbook_send_card_list(cards, E_ADDRESSBOOK_DISPOSITION_AS_ATTACHMENT); e_free_object_list(cards); } } @@ -693,7 +693,7 @@ send_to (GtkWidget *widget, CardAndBook *card_and_book) GList *cards = get_card_list (card_and_book); if (cards) { - e_card_list_send(cards, E_CARD_DISPOSITION_AS_TO); + e_addressbook_send_card_list(cards, E_ADDRESSBOOK_DISPOSITION_AS_TO); e_free_object_list(cards); } } @@ -1877,7 +1877,7 @@ e_addressbook_view_send (EAddressbookView *view) { GList *list = get_selected_cards (view); if (list) - e_card_list_send (list, E_CARD_DISPOSITION_AS_ATTACHMENT); + e_addressbook_send_card_list (list, E_ADDRESSBOOK_DISPOSITION_AS_ATTACHMENT); e_free_object_list(list); } @@ -1886,7 +1886,7 @@ e_addressbook_view_send_to (EAddressbookView *view) { GList *list = get_selected_cards (view); if (list) - e_card_list_send (list, E_CARD_DISPOSITION_AS_TO); + e_addressbook_send_card_list (list, E_ADDRESSBOOK_DISPOSITION_AS_TO); e_free_object_list(list); } |