#include "addressbook/gui/merging/eab-contact-merging.h"
#include "addressbook/gui/widgets/eab-contact-display.h"
#include "addressbook/util/eab-book-util.h"
#include "mail/em-format-hook.h"
#include "mail/em-format-html.h"
#define d(x)
typedef struct _VCardInlinePObject VCardInlinePObject;
struct _VCardInlinePObject {
EMFormatHTMLPObject object;
GSList *contact_list;
ESourceList *source_list;
GtkWidget *contact_display;
GtkWidget *message_label;
};
static gint org_gnome_vcard_inline_classid;
/* Forward Declarations */
void org_gnome_vcard_inline_format (gpointer ep, EMFormatHookTarget *target);
gint e_plugin_lib_enable (EPlugin *ep, gint enable);
gint
e_plugin_lib_enable (EPlugin *ep,
gint enable)
{
return 0;
}
static void
org_gnome_vcard_inline_pobject_free (EMFormatHTMLPObject *object)
{
VCardInlinePObject *vcard_object;
vcard_object = (VCardInlinePObject *) object;
e_client_util_free_object_slist (vcard_object->contact_list);
vcard_object->contact_list = NULL;
if (vcard_object->source_list != NULL) {
g_object_unref (vcard_object->source_list);
vcard_object->source_list = NULL;
}
if (vcard_object->contact_display != NULL) {
g_object_unref (vcard_object->contact_display);
vcard_object->contact_display = NULL;
}
if (vcard_object->message_label != NULL) {
g_object_unref (vcard_object->message_label);
vcard_object->message_label = NULL;
}
}
static void
org_gnome_vcard_inline_decode (VCardInlinePObject *vcard_object,
CamelMimePart *mime_part)
{
CamelDataWrapper *data_wrapper;
CamelMedium *medium;
CamelStream *stream;
GSList *contact_list;
GByteArray *array;
const gchar *string;
const guint8 padding[2] = {0};
array = g_byte_array_new ();
medium = CAMEL_MEDIUM (mime_part);
/* Stream takes ownership of the byte array. */
stream = camel_stream_mem_new_with_byte_array (array);
data_wrapper = camel_medium_get_content (medium);
camel_data_wrapper_decode_to_stream_sync (
data_wrapper, stream, NULL, NULL);
/* because the result is not NULL-terminated */
g_byte_array_append (array, padding, 2);
string = (gchar *) array->data;
contact_list = eab_contact_list_from_string (string);
vcard_object->contact_list = contact_list;
g_object_unref (mime_part);
g_object_unref (stream);
}
static void
org_gnome_vcard_inline_client_loaded_cb (ESource *source,
GAsyncResult *result,
GSList *contact_list)
{
EClient *client = NULL;
EBookClient *book_client;
GSList *iter;
GError *error = NULL;
e_client_utils_open_new_finish (source, result, &client, &error);
if (error != NULL) {
g_warn_if_fail (client == NULL);
g_warning (
"%s: Failed to open book client: %s",
G_STRFUNC, error->message);
g_error_free (error);
goto exit;
}
g_return_if_fail (E_IS_BOOK_CLIENT (client));
book_client = E_BOOK_CLIENT (client);
for (iter = contact_list; iter != NULL; iter = iter->next) {
EContact *contact;
contact = E_CONTACT (iter->data);
eab_merging_book_add_contact (book_client, contact, NULL, NULL);
}
g_object_unref (client);
exit:
e_client_util_free_object_slist (contact_list);
}
static void
org_gnome_vcard_inline_save_cb (VCardInlinePObject *vcard_object)
{
ESource *source;
GSList *contact_list;
GtkWidget *dialog;
g_return_if_fail (vcard_object->source_list != NULL);
dialog = e_source_selector_dialog_new (NULL, vcard_object->source_list);
e_source_selector_dialog_select_default_source (
E_SOURCE_SELECTOR_DIALOG (dialog));
if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK) {
gtk_widget_destroy (dialog);
return;
}
source = e_source_selector_dialog_peek_primary_selection (
E_SOURCE_SELECTOR_DIALOG (dialog));
gtk_widget_destroy (dialog);
g_return_if_fail (source != NULL);
contact_list = e_client_util_copy_object_slist (NULL, vcard_object->contact_list);
e_client_utils_open_new (
source, E_CLIENT_SOURCE_TYPE_CONTACTS, FALSE,
NULL, e_client_utils_authenticate_handler, NULL,
(GAsyncReadyCallback) org_gnome_vcard_inline_client_loaded_cb,
contact_list);
}
static void
org_gnome_vcard_inline_toggle_cb (VCardInlinePObject *vcard_object,
GtkButton *button)
{
EABContactDisplay *contact_display;
EABContactDisplayMode mode;
const gchar *label;
contact_display = EAB_CONTACT_DISPLAY (vcard_object->contact_display);
mode = eab_contact_display_get_mode (contact_display);
/* Toggle between "full" and "compact" modes. */
if (mode == EAB_CONTACT_DISPLAY_RENDER_NORMAL) {
mode = EAB_CONTACT_DISPLAY_RENDER_COMPACT;
label = _("Show Full vCard");
} else {
mode = EAB_CONTACT_DISPLAY_RENDER_NORMAL;
label = _("Show Compact vCard");
}
eab_contact_display_set_mode (contact_display, mode);
gtk_button_set_label (button, label);
}
static gboolean
org_gnome_vcard_inline_embed (EMFormatHTML *format,
GtkHTMLEmbedded *embedded,
EMFormatHTMLPObject *object)
{
VCardInlinePObject *vcard_object;
GtkWidget *button_box;
GtkWidget *container;
GtkWidget *widget;
EContact *contact;
guint length;
vcard_object = (VCardInlinePObject *) object;
length = g_slist_length (vcard_object->contact_list);
if (vcard_object->contact_list != NULL)
contact = E_CONTACT (vcard_object->contact_list->data);
else
contact = NULL;
container = GTK_WIDGET (embedded);
widget = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (container), widget);
gtk_widget_show (widget);
container = widget;
widget = gtk_hbutton_box_new ();
gtk_button_box_set_layout (
GTK_BUTTON_BOX (widget), GTK_BUTTONBOX_START);
gtk_box_set_spacing (GTK_BOX (widget), 12);
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0);
gtk_widget_show (widget);
button_box = widget;
widget = eab_contact_display_new ();
eab_contact_display_set_contact (
EAB_CONTACT_DISPLAY (widget), contact);
eab_contact_display_set_mode (
EAB_CONTACT_DISPLAY (widget),
EAB_CONTACT_DISPLAY_RENDER_COMPACT);
gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
vcard_object->contact_display = g_object_ref (widget);
gtk_widget_show (widget);
widget = gtk_label_new (NULL);
gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
vcard_object->message_label = g_object_ref (widget);
if (length == 2) {
const gchar *text;
text = _("There is one other contact.");
gtk_label_set_text (GTK_LABEL (widget), text);
gtk_widget_show (widget);
} else if (length > 2) {
gchar *text;
/* Translators: This will always be two or more. */
text = g_strdup_printf (ngettext (
"There is %d other contact.",
"There are %d other contacts.",
length - 1), length - 1);
gtk_label_set_text (GTK_LABEL (widget), text);
gtk_widget_show (widget);
g_free (text);
} else
gtk_widget_hide (widget);
container = button_box;
widget = gtk_button_new_with_label (_("Show Full vCard"));
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
gtk_widget_show (widget);
g_signal_connect_swapped (
widget, "clicked",
G_CALLBACK (org_gnome_vcard_inline_toggle_cb),
vcard_object);
widget = gtk_button_new_with_label (_("Save in Address Book"));
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
/* This depends on having a source list. */
if (vcard_object->source_list != NULL)
gtk_widget_show (widget);
else
gtk_widget_hide (widget);
g_signal_connect_swapped (
widget, "clicked",
G_CALLBACK (org_gnome_vcard_inline_save_cb),
vcard_object);
return TRUE;
}
void
org_gnome_vcard_inline_format (gpointer ep,
EMFormatHookTarget *target)
{
VCardInlinePObject *vcard_object;
gchar *classid;
gchar *content;
classid = g_strdup_printf (
"org-gnome-vcard-inline-display-%d",
org_gnome_vcard_inline_classid++);
vcard_object = (VCardInlinePObject *)
em_format_html_add_pobject (
EM_FORMAT_HTML (target->format),
sizeof (VCardInlinePObject),
classid, target->part,
org_gnome_vcard_inline_embed);
g_object_ref (target->part);
vcard_object->object.free = org_gnome_vcard_inline_pobject_free;
org_gnome_vcard_inline_decode (vcard_object, target->part);
e_book_client_get_sources (&vcard_object->source_list, NULL);
content = g_strdup_printf ("", classid);
camel_stream_write_string (target->stream, content, NULL, NULL);
g_free (content);
g_free (classid);
}
class='insertions'>+155
* | Use RUBY_MOD*. | knu | 2002-10-07 | 2 | -8/+8 |
* | cant be fetched for a long time, only evaluation-version available | ijliao | 2002-09-17 | 7 | -221/+0 |
* | texas chainsaw kde2 massacre | alane | 2002-09-11 | 1 | -1/+0 |
* | kde2 massacre. | alane | 2002-09-10 | 5 | -72/+0 |
* | Add USE_GNOMENG | pat | 2002-09-08 | 1 | -1/+2 |
* | USE_REINPLACE rather than a somewhat convoluted perl expression. | hoek | 2002-09-06 | 1 | -2/+5 |
* | The configure script was trying to modify CFLAGS to prevent | hoek | 2002-09-05 | 1 | -0/+20 |
* | "libuu" -> "uulib" | hoek | 2002-09-02 | 1 | -1/+1 |
* | Update to xdeview 0.5.18. | hoek | 2002-09-02 | 7 | -88/+22 |
* | Updated uudeview version doesn't need to be patched | hoek | 2002-09-02 | 1 | -23/+0 |
* | Update to uudeview 0.5.18. | hoek | 2002-09-02 | 9 | -39/+37 |
* | Upgrade to uulib 0.5.18. This adds support for yEnc. | hoek | 2002-09-02 | 8 | -25/+23 |
* | Use safe temp files. I'll try to cook-up a different version of | hoek | 2002-09-02 | 2 | -0/+45 |
* | Update webpage URL. List yEnc as a supported encoding method (which | hoek | 2002-09-01 | 1 | -5/+3 |
* | Better control filenames validity, ctype fixes | ache | 2002-08-29 | 3 | -16/+72 |
* | Wrong version of patch was committed, fix it. | ache | 2002-08-28 | 2 | -15/+16 |
* | Add missing .pyo files to each pkg-plist | perky | 2002-08-23 | 1 | -0/+1 |
* | change my email address to leeym@FreeBSD.org | leeym | 2002-08-19 | 1 | -1/+1 |
* | Minor port cleanups | skv | 2002-08-16 | 2 | -7/+11 |
* | Add --without-libintl-prefix as a CONFIGURE_ARG so to eliminate a | marcus | 2002-08-04 | 1 | -1/+3 |
* | Chase shlib rev of devel/gettext | ade | 2002-08-02 | 1 | -1/+1 |
* | Update to 0.213. | tobez | 2002-07-28 | 2 | -2/+2 |
* | Change master site to MASTER_SITE_LOCAL | perky | 2002-07-02 | 1 | -3/+2 |
* | Update to 1.04 | pat | 2002-06-28 | 2 | -2/+2 |
* | add p5-Unicode-IMAPUtf7 1.02 | ijliao | 2002-06-26 | 6 | -0/+44 |
* | add p5-String-Multibyte 0.07 | ijliao | 2002-06-26 | 6 | -0/+46 |
* | add p5-Unicode-MapUTF8 1.09 | ijliao | 2002-06-25 | 6 | -0/+46 |
* | add p5-Unicode-Map 0.112 | ijliao | 2002-06-25 | 6 | -0/+157 |
* | Updating my email address. | perky | 2002-06-25 | 1 | -1/+1 |
* | Update to 1.8, and retain shared lib version of 3. | marcus | 2002-06-17 | 6 | -25/+30 |
* | Add a few other distfile mirrors. | marcus | 2002-06-16 | 1 | -2/+5 |
* | Update to 0.10.4. | tobez | 2002-06-13 | 3 | -2/+3 |
* | Fix build on -current. | petef | 2002-06-08 | 1 | -0/+13 |
* | Unbreak on -current by catching up to *.mk changes | kris | 2002-06-04 | 1 | -4/+6 |
* | Update to 1.0.13 | pat | 2002-06-01 | 2 | -2/+2 |
* | Speed up fetching. | obrien | 2002-05-30 | 1 | -2/+2 |
* | Update to 0.212. | tobez | 2002-05-28 | 2 | -2/+2 |
* | Update to 1.27. | tobez | 2002-05-28 | 2 | -2/+2 |
* | Update to 1.7.0.1. | obrien | 2002-05-28 | 2 | -3/+3 |
* | Correct the path to gperf. | marcus | 2002-05-27 | 1 | -1/+1 |
* | * Add support for Korean real-world locales | marcus | 2002-05-23 | 2 | -5/+33 |
* | Fix PLIST and update to 0.17 while I'm here. | sobomax | 2002-05-22 | 3 | -18/+4 |
* | Update as a satellite port of `converters/mule-ucs'. | okazaki | 2002-05-17 | 5 | -212/+5 |
* | Stop installing a backup file created by `patch'. | okazaki | 2002-05-17 | 2 | -6/+11 |
* | Connect mule-ucs. | okazaki | 2002-05-16 | 1 | -0/+1 |
* | Update to support Emacs 21. | okazaki | 2002-05-16 | 5 | -22/+53 |
* | Allow libiconv to be built by a non-root user. | marcus | 2002-05-15 | 2 | -0/+22 |
* | Update to 0.5. | knu | 2002-05-12 | 2 | -3/+2 |
* | Fix invalid distfiles | dwcjr | 2002-05-09 | 5 | -11/+63 |
* | Give maintainership | dwcjr | 2002-05-08 | 1 | -2/+3 |
* | Correct BUILD_DEPENDS on p5-Crypt-DES_EDE3 | kris | 2002-05-05 | 1 | -1/+1 |
* | Use USE_LIBTOOL. | sobomax | 2002-04-30 | 5 | -57/+28 |
* | Actually add the new patches from the last commit.... | marcus | 2002-04-30 | 2 | -0/+139 |
* | Fix a few problems in libiconv. | marcus | 2002-04-30 | 2 | -6/+15 |
* | use USE_PYDISTUTILS | ijliao | 2002-04-29 | 1 | -8/+1 |
* | Put back ru.po, it was deleted by mistake. | demon | 2002-04-29 | 2 | -1/+576 |
* | As it was advertised more than a month ago complete giconv -> iconv | sobomax | 2002-04-24 | 2 | -11/+1 |
* | add fribidi 0.10.3 | ijliao | 2002-04-20 | 6 | -0/+64 |
* | Say goodbye to Qt 1.x and all of its dependents. The one port I found | will | 2002-04-19 | 12 | -168/+0 |
* | Use devel/gettext port; | demon | 2002-04-17 | 3 | -587/+5 |
* | gettext upgrade uber-patch (stage 3) | ade | 2002-04-13 | 1 | -4/+8 |
* | Remove iconv->giconv hack. | sobomax | 2002-04-08 | 1 | -9/+0 |
* | more clean pkg-plist | nork | 2002-04-07 | 2 | -1/+5 |
* | Replace characters illegal in the specified encoding of the Greek | naddy | 2002-04-03 | 1 | -0/+66 |
* | Fixed port build error. | hosokawa | 2002-03-29 | 1 | -0/+28 |
* | Fix another few places where giconv used instead of iconv. | sobomax | 2002-03-19 | 1 | -1/+1 |
* | Change MAINTAINER to ports | ache | 2002-03-19 | 1 | -1/+1 |
* | Add a patch to fix a bug where iconv() did not return -1 properly on | knu | 2002-03-18 | 2 | -1/+56 |
* | Bump PORTREVISION to reflect the (lib)iconv upgrade. | knu | 2002-03-18 | 4 | -0/+4 |
* | Iconv cleanup, stage 1b: correct {BUILD,LIB,RUN}_DEPENDS of all ports that need | sobomax | 2002-03-18 | 4 | -4/+4 |
* | Iconv cleanup, stage 1a: remove `g' prefix from binaries, headers, libraries and | sobomax | 2002-03-18 | 22 | -191/+308 |
* | Upgrade to 0.15 | jesper | 2002-03-17 | 2 | -2/+2 |
* | Stage 1 of gettext update. | ade | 2002-03-16 | 1 | -1/+1 |
* | Add extra dependency of ports/security/p5-Crypt-DES_EDE3 | jesper | 2002-03-15 | 1 | -0/+1 |
* | Upgrade to 0.06 | jesper | 2002-03-14 | 2 | -2/+2 |
* | Update to 0.8.3. | sobomax | 2002-02-23 | 3 | -3/+3 |
* | Delete a nonexistent port entry: "gb2jis". | knu | 2002-02-14 | 1 | -1/+0 |
* | Update maintainer email address | pat | 2002-01-29 | 1 | -1/+1 |
* | Update to 1.25. | tobez | 2002-01-23 | 2 | -2/+2 |
* | - Add NOPORTDOCS support to pkg-plist | pat | 2002-01-17 | 2 | -8/+7 |
* | - Add NOPORTDOCS support (pkg-plist) | pat | 2002-01-17 | 2 | -10/+8 |
* | Remove tcs. | kuriyama | 2002-01-08 | 1 | -1/+0 |
* | Bell-labs is not distributing Plan-9 (and tcs) from anonymous ftp as did before. | kuriyama | 2002-01-08 | 5 | -43/+0 |
* | Remove converter/gb2jis,which is in chinese/ now, by MAINTAINER's request. | clive | 2002-01-08 | 6 | -46/+0 |
* | Update to version 1.0 | kevlo | 2001-12-22 | 6 | -8/+34 |
* | Backout previous change - it seems that new revision of the patch doesn't | sobomax | 2001-12-20 | 1 | -17/+8 |
* | Don't filter libc_r on 5-CURRENT. | sobomax | 2001-12-20 | 1 | -8/+17 |