From e6e90be39e65631059a99fc44f5f9ec43355c7a8 Mon Sep 17 00:00:00 2001 From: Sankar P Date: Tue, 17 Jul 2007 11:44:49 +0000 Subject: Initial set of files. Implements Face header support. 2007-07-17 Sankar P * org-gnome-face.eplug.xml: * org-gnome-face-ui.xml: * org-gnome-face.errors.xml: * Makefile.am: * face.c: Initial set of files. Implements Face header support. svn path=/trunk/; revision=33812 --- plugins/face/ChangeLog | 8 +++ plugins/face/Makefile.am | 46 ++++++++++++ plugins/face/face.c | 127 +++++++++++++++++++++++++++++++++ plugins/face/org-gnome-face-ui.xml | 12 ++++ plugins/face/org-gnome-face.eplug.xml | 22 ++++++ plugins/face/org-gnome-face.errors.xml | 24 +++++++ 6 files changed, 239 insertions(+) create mode 100644 plugins/face/ChangeLog create mode 100644 plugins/face/Makefile.am create mode 100644 plugins/face/face.c create mode 100644 plugins/face/org-gnome-face-ui.xml create mode 100644 plugins/face/org-gnome-face.eplug.xml create mode 100644 plugins/face/org-gnome-face.errors.xml (limited to 'plugins') diff --git a/plugins/face/ChangeLog b/plugins/face/ChangeLog new file mode 100644 index 0000000000..a720c47727 --- /dev/null +++ b/plugins/face/ChangeLog @@ -0,0 +1,8 @@ +2007-07-17 Sankar P + + * org-gnome-face.eplug.xml: + * org-gnome-face-ui.xml: + * org-gnome-face.errors.xml: + * Makefile.am: + * face.c: + Initial set of files. Implements Face header support. diff --git a/plugins/face/Makefile.am b/plugins/face/Makefile.am new file mode 100644 index 0000000000..ec53eee1c2 --- /dev/null +++ b/plugins/face/Makefile.am @@ -0,0 +1,46 @@ +INCLUDES = -I. \ + -I$(top_srcdir) \ + -I$(top_srcdir)/widgets \ + -I$(top_srcdir)/widgets/misc \ + -I$(top_builddir)/mail \ + -I$(top_srcdir)/camel \ + -I$(top_builddir)/composer \ + $(EVOLUTION_MAIL_CFLAGS) \ + -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ + -DCONNECTOR_GLADEDIR=\""$(gladedir)"\" + + +@EVO_PLUGIN_RULE@ + +plugin_DATA = \ + org-gnome-face.eplug \ + org-gnome-face-ui.xml + +plugin_LTLIBRARIES = liborg-gnome-face.la + +liborg_gnome_face_la_SOURCES = \ + face.c +liborg_gnome_face_la_LIBADD = \ + $(top_builddir)/e-util/libeutil.la \ + $(top_builddir)/widgets/misc/libemiscwidgets.la \ + $(top_builddir)/mail/libevolution-mail.la \ + $(EVOLUTION_MAIL_LIBS) \ + $(NO_UNDEFINED_REQUIRED_LIBS) + +liborg_gnome_face_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED) + +error_DATA = \ + org-gnome-face.errors.xml + +errordir = $(privdatadir)/errors + +EXTRA_DIST = \ + org-gnome-face.eplug.xml \ + org-gnome-face-ui.xml \ + $(error_DATA) + +BUILT_SOURCES = \ + org-gnome-face.eplug \ + $(error_i18n) + +CLEANFILES = $(BUILT_SOURCES) diff --git a/plugins/face/face.c b/plugins/face/face.c new file mode 100644 index 0000000000..3d06ec6e87 --- /dev/null +++ b/plugins/face/face.c @@ -0,0 +1,127 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Author: Sankar P + * + * Copyright 2004 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "composer/e-msg-composer.h" +#include +#include +#include +#include + +#define d(x) x + +void org_gnome_composer_face (EPlugin * ep, EMMenuTargetWidget * target); +int e_plugin_lib_configure (EPlugin * ep); + +void org_gnome_composer_face (EPlugin * ep, EMMenuTargetWidget * t) +{ + EMsgComposer *composer; + gchar *filename, *file_contents; + GError *error = NULL; + + composer = (EMsgComposer *) t->target.widget; + filename = g_build_filename (g_get_home_dir (), ".evolution", "faces", NULL); + g_file_get_contents (filename, &file_contents, NULL, &error); + + if (error) { + + GtkWidget *filesel; + const char *image_filename; + gsize length; + +#ifdef USE_GTKFILECHOOSER + GtkFileFilter *filter; + + filesel = gtk_file_chooser_dialog_new (_ + ("Select a (48*48) png of size < 700bytes"), + NULL, + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL); + + gtk_dialog_set_default_response (GTK_DIALOG (filesel), GTK_RESPONSE_OK); + + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, _("PNG files")); + gtk_file_filter_add_mime_type (filter, "image/png"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (filesel), filter); + +#else + filesel = gtk_file_selection_new (_("Select a (48*48) png of size < 720bytes")); +#endif + + if (GTK_RESPONSE_OK == gtk_dialog_run (GTK_DIALOG (filesel))) { +#ifdef USE_GTKFILECHOOSER + image_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filesel)); +#else + image_filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (filesel)); +#endif + + error = NULL; + file_contents = NULL; + g_file_get_contents (image_filename, &file_contents, &length, &error); + + if (!error) { + error = NULL; + if (length < 720) { + + GdkPixbuf *pixbuf, *new; + GdkPixbufLoader *loader = gdk_pixbuf_loader_new(); + + gdk_pixbuf_loader_write (loader, (guchar *)file_contents, length, NULL); + gdk_pixbuf_loader_close (loader, NULL); + + pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); + if (pixbuf) { + int width, height, prompt_response; + + g_object_ref (pixbuf); + + height = gdk_pixbuf_get_height (pixbuf); + width = gdk_pixbuf_get_width (pixbuf); + + if (height != 48 || width != 48) { + d (printf ("\n\a Invalid Image Size. Please choose a 48*48 image\n\a")); + e_error_run (NULL, "org.gnome.evolution.plugins.face:invalid-image-size", NULL, NULL); + } else { + file_contents = camel_base64_encode_simple (file_contents, length); + g_file_set_contents (filename, file_contents, -1, &error); + } + } + } else { + d (printf ("File too big")); + e_error_run (NULL, "org.gnome.evolution.plugins.face:invalid-file-size", NULL, NULL); + } + + } else { + d (printf ("\n\a File cannot be read\n\a")); + e_error_run (NULL, "org.gnome.evolution.plugins.face:file-not-found", NULL, NULL); + } + } + gtk_widget_destroy (filesel); + } + e_msg_composer_modify_header (composer, "Face", file_contents); +} diff --git a/plugins/face/org-gnome-face-ui.xml b/plugins/face/org-gnome-face-ui.xml new file mode 100644 index 0000000000..2bf2a75c65 --- /dev/null +++ b/plugins/face/org-gnome-face-ui.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/plugins/face/org-gnome-face.eplug.xml b/plugins/face/org-gnome-face.eplug.xml new file mode 100644 index 0000000000..2c50e65685 --- /dev/null +++ b/plugins/face/org-gnome-face.eplug.xml @@ -0,0 +1,22 @@ + + + + + + <_description>Attach Face header to outgoing mails. First time the user needs to configure a 48*48 png image. It is base64 encoded and stored in ~/.evolution/faces This will be used in mails that are sent further. + + + + + + + + + diff --git a/plugins/face/org-gnome-face.errors.xml b/plugins/face/org-gnome-face.errors.xml new file mode 100644 index 0000000000..02695dd758 --- /dev/null +++ b/plugins/face/org-gnome-face.errors.xml @@ -0,0 +1,24 @@ + + + + + Failed Read + The file cannot be read + + + + Invalid Image Size + Please select an image of size 48 * 48 + + + + Invalid File Size + The file you selected is too big. Please select a file of size less than 720 bytes. + + + + Not an image + The file you selected does not look like a valid .png image. + + + -- cgit