aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-10-21 04:09:29 +0800
committerDan Winship <danw@src.gnome.org>2000-10-21 04:09:29 +0800
commit88a7bcd6f7909a41cd5a0021f24dabe6897e1d8a (patch)
treede5560bf9a15eee1f28fd945f04b3c5178ac0588
parentc61e00755b5663bed37683155f408cb28f086080 (diff)
downloadgsoc2013-evolution-88a7bcd6f7909a41cd5a0021f24dabe6897e1d8a.tar
gsoc2013-evolution-88a7bcd6f7909a41cd5a0021f24dabe6897e1d8a.tar.gz
gsoc2013-evolution-88a7bcd6f7909a41cd5a0021f24dabe6897e1d8a.tar.bz2
gsoc2013-evolution-88a7bcd6f7909a41cd5a0021f24dabe6897e1d8a.tar.lz
gsoc2013-evolution-88a7bcd6f7909a41cd5a0021f24dabe6897e1d8a.tar.xz
gsoc2013-evolution-88a7bcd6f7909a41cd5a0021f24dabe6897e1d8a.tar.zst
gsoc2013-evolution-88a7bcd6f7909a41cd5a0021f24dabe6897e1d8a.zip
Evolution::Composer interface. So entirely not tested.
* Evolution-Composer.idl: * evolution-composer.[ch]: Evolution::Composer interface. So entirely not tested. * Makefile.am (libcomposer_la_SOURCES): Add evolution-composer.[ch] (IDLS): Update this for Evolution-Composer.idl / Composer.idl * main.c: Removed. (Old, dead code) svn path=/trunk/; revision=6077
-rw-r--r--composer/.cvsignore9
-rw-r--r--composer/ChangeLog12
-rw-r--r--composer/Composer.idl4
-rw-r--r--composer/Evolution-Composer.idl94
-rw-r--r--composer/Makefile.am25
-rw-r--r--composer/evolution-composer.c302
-rw-r--r--composer/evolution-composer.h69
-rw-r--r--composer/main.c76
8 files changed, 499 insertions, 92 deletions
diff --git a/composer/.cvsignore b/composer/.cvsignore
index 8acab05c77..430d126b34 100644
--- a/composer/.cvsignore
+++ b/composer/.cvsignore
@@ -5,8 +5,7 @@ Makefile
Makefile.in
*.lo
*.la
-Evolution-Addressbook-SelectNames-stubs.c
-Evolution-Addressbook-SelectNames-skels.c
-Evolution-Addressbook-SelectNames-common.c
-Evolution-Addressbook-SelectNames.h
-
+Composer-stubs.c
+Composer-skels.c
+Composer-common.c
+Composer.h
diff --git a/composer/ChangeLog b/composer/ChangeLog
index 3f82125033..cd01c926db 100644
--- a/composer/ChangeLog
+++ b/composer/ChangeLog
@@ -1,3 +1,15 @@
+2000-10-20 Dan Winship <danw@helixcode.com>
+
+ * Evolution-Composer.idl:
+ * evolution-composer.[ch]: Evolution::Composer interface. So
+ entirely not tested.
+
+ * Makefile.am (libcomposer_la_SOURCES): Add
+ evolution-composer.[ch]
+ (IDLS): Update this for Evolution-Composer.idl / Composer.idl
+
+ * main.c: Removed. (Old, dead code)
+
2000-10-19 Ettore Perazzoli <ettore@helixcode.com>
* Makefile.am (glade_data): Add `e-msg-composer-attachment.glade'.
diff --git a/composer/Composer.idl b/composer/Composer.idl
new file mode 100644
index 0000000000..a6cb35c037
--- /dev/null
+++ b/composer/Composer.idl
@@ -0,0 +1,4 @@
+/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <Evolution-Addressbook-SelectNames.idl>
+#include <Evolution-Composer.idl>
diff --git a/composer/Evolution-Composer.idl b/composer/Evolution-Composer.idl
new file mode 100644
index 0000000000..1e3701a594
--- /dev/null
+++ b/composer/Evolution-Composer.idl
@@ -0,0 +1,94 @@
+/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Evolution-Composer.idl: Mail composer interfaces for Evolution
+ *
+ * Author:
+ * Dan Winship <danw@helixcode.com>
+ *
+ * (C) 2000 Helix Code, Inc.
+ */
+
+#include <Bonobo.idl>
+
+module Evolution {
+
+ interface Composer : Bonobo::Unknown {
+ struct Recipient {
+ string name; /* UTF-8 */
+ string address;
+ };
+ typedef sequence<Recipient> RecipientList;
+
+ /**
+ * set_headers:
+ * @to: the "To" recipients
+ * @cc: the "CC" recipients
+ * @bcc: the "Bcc" recipients
+ * @subject: the subject of the message
+ *
+ * Sets the composer headers. Any of @to, @cc, and
+ * @bcc may be an empty list, and @subject may be an
+ * empty string.
+ **/
+ void set_headers (in RecipientList to, in RecipientList cc,
+ in RecipientList bcc, in string subject);
+
+ /**
+ * set_body_text:
+ * @body: the body
+ *
+ * Sets the text in the body of the composer to
+ * the given UTF-8 plain text.
+ **/
+ void set_body_text (in string body);
+
+ /**
+ * attach_MIME:
+ * @data: the attachment data
+ *
+ * This adds an attachment to the composer. @data
+ * should be a fully-formed MIME body part.
+ **/
+ exception CouldNotParse {};
+ void attach_MIME (in string data)
+ raises (CouldNotParse);
+
+ /**
+ * attach_data:
+ * @content_type: the Content-Type header
+ * @filename: the suggested filename, or ""
+ * @description: a description of the data, or ""
+ * @show_inline: whether the attachment should be
+ * displayed inline or not.
+ * @data: the raw attachment data
+ *
+ * This adds @data as an attachment, using the provided
+ * information to generate MIME headers. @content_type
+ * may contain just a MIME content type, or it may
+ * contain a complete Content-Type header. @filename
+ * is a filename for the Content-Disposition header
+ * @description (if not "") provides the
+ * Content-Description, and @show_inline determines if the
+ * Content-Disposition is "inline" or "attachment".
+ *
+ * If you need to specify headers or values other than
+ * what this function can do, you will need to generate
+ * all of the MIME headers yourself and use
+ * add_attachment ().
+ **/
+ void attach_data (in string content_type,
+ in string filename,
+ in string description,
+ in boolean show_inline,
+ in string data);
+
+
+ /**
+ * show:
+ *
+ * Shows the composer and lets the user edit things
+ * and send the message.
+ **/
+ void show ();
+ };
+};
diff --git a/composer/Makefile.am b/composer/Makefile.am
index 3c62e05644..4c0775b924 100644
--- a/composer/Makefile.am
+++ b/composer/Makefile.am
@@ -1,19 +1,20 @@
## CORBA stuff
-IDLS = \
- $(top_srcdir)/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl
+IDLS = \
+ Evolution-Composer.idl \
+ Composer.idl
-IDL_GENERATED = \
- Evolution-Addressbook-SelectNames.h \
- Evolution-Addressbook-SelectNames-common.c \
- Evolution-Addressbook-SelectNames-skels.c \
- Evolution-Addressbook-SelectNames-stubs.c
+IDL_GENERATED = \
+ Composer.h \
+ Composer-common.c \
+ Composer-skels.c \
+ Composer-stubs.c
-Evolution-Addressbook-SelectNames-impl.o: Evolution-Addressbook-SelectNames.h
+selectnamesdir = $(top_srcdir)/addressbook/gui/component/select-names
-$(IDL_GENERATED): $(IDLS)
+$(IDL_GENERATED): $(IDLS) $(selectnamesdir)/Evolution-Addressbook-SelectNames.idl
$(ORBIT_IDL) -I $(datadir)/idl `$(GNOME_CONFIG) --cflags idl` \
- $(top_srcdir)/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl
+ -I $(selectnamesdir) -I . Composer.idl
##
@@ -67,7 +68,9 @@ libcomposer_la_SOURCES = \
e-msg-composer.c \
e-msg-composer.h \
e-icon-list.c \
- e-icon-list.h
+ e-icon-list.h \
+ evolution-composer.c \
+ evolution-composer.h
EXTRA_DIST = \
$(glade_DATA) \
diff --git a/composer/evolution-composer.c b/composer/evolution-composer.c
new file mode 100644
index 0000000000..999731cb96
--- /dev/null
+++ b/composer/evolution-composer.c
@@ -0,0 +1,302 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* evolution-composer.c
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * 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 Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Dan Winship <danw@helixcode.com>
+ */
+
+#include <config.h>
+
+#include <bonobo.h>
+#include <camel/camel.h>
+#include <gal/util/e-util.h>
+#include <gal/widgets/e-gui-utils.h>
+
+#include "evolution-composer.h"
+
+#define PARENT_TYPE BONOBO_OBJECT_TYPE
+static BonoboObjectClass *parent_class = NULL;
+
+/* CORBA interface implementation. */
+
+static POA_Evolution_Composer__vepv Composer_vepv;
+
+static GList *
+corba_recipientlist_to_glist (const Evolution_Composer_RecipientList *cl)
+{
+ Evolution_Composer_Recipient *recip;
+ GList *gl = NULL;
+ char *str;
+ int i;
+
+ for (i = cl->_length - 1; i >= 0; i--) {
+ recip = &(cl->_buffer[i]);
+
+ /* Let's copy this code into yet another place! */
+ if (*recip->name) {
+ str = g_strdup_printf ("\"%s\" <%s>",
+ recip->name, recip->address);
+ } else
+ str = g_strdup (recip->address);
+
+ gl = g_list_prepend (gl, str);
+ }
+
+ return gl;
+}
+
+static void
+free_recipient_glist (GList *gl)
+{
+ GList *tmp;
+
+ while (gl) {
+ tmp = gl->next;
+ g_free (gl->data);
+ g_list_free_1 (gl);
+ gl = tmp;
+ }
+}
+
+static void
+impl_Composer_set_headers (PortableServer_Servant servant,
+ const Evolution_Composer_RecipientList *to,
+ const Evolution_Composer_RecipientList *cc,
+ const Evolution_Composer_RecipientList *bcc,
+ const CORBA_char *subject,
+ CORBA_Environment *ev)
+{
+ BonoboObject *bonobo_object;
+ EvolutionComposer *composer;
+ GList *gto, *gcc, *gbcc;
+
+ bonobo_object = bonobo_object_from_servant (servant);
+ composer = EVOLUTION_COMPOSER (bonobo_object);
+
+ gto = corba_recipientlist_to_glist (to);
+ gcc = corba_recipientlist_to_glist (cc);
+ gbcc = corba_recipientlist_to_glist (bcc);
+
+ e_msg_composer_set_headers (composer->composer, gto, gcc, gbcc,
+ subject);
+
+ free_recipient_glist (gto);
+ free_recipient_glist (gcc);
+ free_recipient_glist (gbcc);
+}
+
+static void
+impl_Composer_set_body_text (PortableServer_Servant servant,
+ const CORBA_char *text,
+ CORBA_Environment *ev)
+{
+ BonoboObject *bonobo_object;
+ EvolutionComposer *composer;
+
+ bonobo_object = bonobo_object_from_servant (servant);
+ composer = EVOLUTION_COMPOSER (bonobo_object);
+
+ e_msg_composer_set_body_text (composer->composer, text);
+}
+
+static void
+impl_Composer_attach_MIME (PortableServer_Servant servant,
+ const CORBA_char *data,
+ CORBA_Environment *ev)
+{
+ BonoboObject *bonobo_object;
+ EvolutionComposer *composer;
+ CamelMimePart *attachment;
+ CamelStream *mem_stream;
+ int status;
+
+ bonobo_object = bonobo_object_from_servant (servant);
+ composer = EVOLUTION_COMPOSER (bonobo_object);
+
+ mem_stream = camel_stream_mem_new_with_buffer (data, strlen (data));
+ attachment = camel_mime_part_new ();
+ status = camel_data_wrapper_construct_from_stream (
+ CAMEL_DATA_WRAPPER (attachment), mem_stream);
+ camel_object_unref (CAMEL_OBJECT (mem_stream));
+
+ if (status == -1) {
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_Evolution_Composer_CouldNotParse,
+ NULL);
+ return;
+ }
+
+ e_msg_composer_attach (composer->composer, attachment);
+ camel_object_unref (CAMEL_OBJECT (attachment));
+}
+
+static void
+impl_Composer_attach_data (PortableServer_Servant servant,
+ const CORBA_char *content_type,
+ const CORBA_char *filename,
+ const CORBA_char *description,
+ const CORBA_boolean show_inline,
+ const CORBA_char *data,
+ CORBA_Environment *ev)
+{
+ BonoboObject *bonobo_object;
+ EvolutionComposer *composer;
+ CamelMimePart *attachment;
+
+ bonobo_object = bonobo_object_from_servant (servant);
+ composer = EVOLUTION_COMPOSER (bonobo_object);
+
+ attachment = camel_mime_part_new ();
+ camel_mime_part_set_content (attachment, data, strlen (data),
+ content_type);
+
+ if (*filename)
+ camel_mime_part_set_filename (attachment, filename);
+ if (*description)
+ camel_mime_part_set_description (attachment, description);
+ camel_mime_part_set_disposition (attachment, show_inline ?
+ "inline" : "attachment");
+
+ e_msg_composer_attach (composer->composer, attachment);
+ camel_object_unref (CAMEL_OBJECT (attachment));
+}
+
+static void
+impl_Composer_show (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ BonoboObject *bonobo_object;
+ EvolutionComposer *composer;
+
+ bonobo_object = bonobo_object_from_servant (servant);
+ composer = EVOLUTION_COMPOSER (bonobo_object);
+
+ gtk_widget_show (GTK_WIDGET (composer->composer));
+}
+
+POA_Evolution_Composer__epv *
+evolution_composer_get_epv (void)
+{
+ POA_Evolution_Composer__epv *epv;
+
+ epv = g_new0 (POA_Evolution_Composer__epv, 1);
+ epv->set_headers = impl_Composer_set_headers;
+ epv->set_body_text = impl_Composer_set_body_text;
+ epv->attach_MIME = impl_Composer_attach_MIME;
+ epv->attach_data = impl_Composer_attach_data;
+ epv->show = impl_Composer_show;
+
+ return epv;
+}
+
+
+/* GtkObject stuff */
+
+static void
+destroy (GtkObject *object)
+{
+ EvolutionComposer *composer = EVOLUTION_COMPOSER (object);
+
+ if (composer->composer)
+ gtk_object_unref (GTK_OBJECT (composer->composer));
+
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
+}
+
+static void
+class_init (EvolutionComposerClass *klass)
+{
+ GtkObjectClass *object_class;
+
+ object_class = GTK_OBJECT_CLASS (klass);
+ object_class->destroy = destroy;
+
+ parent_class = gtk_type_class (bonobo_object_get_type ());
+
+ Composer_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv ();
+ Composer_vepv.Evolution_Composer_epv = evolution_composer_get_epv ();
+}
+
+static void
+init (EvolutionComposer *composer)
+{
+ composer->composer = e_msg_composer_new ();
+}
+
+
+void
+evolution_composer_construct (EvolutionComposer *composer,
+ Evolution_Composer corba_object)
+{
+ g_return_if_fail (composer != NULL);
+ g_return_if_fail (EVOLUTION_IS_COMPOSER (composer));
+ g_return_if_fail (corba_object != CORBA_OBJECT_NIL);
+
+ bonobo_object_construct (BONOBO_OBJECT (composer), corba_object);
+}
+
+EvolutionComposer *
+evolution_composer_new (void)
+{
+ EvolutionComposer *new;
+ POA_Evolution_Composer *servant;
+ CORBA_Environment ev;
+ Evolution_Composer corba_object;
+
+ servant = (POA_Evolution_Composer *) g_new0 (BonoboObjectServant, 1);
+ servant->vepv = &Composer_vepv;
+
+ CORBA_exception_init (&ev);
+ POA_Evolution_Composer__init ((PortableServer_Servant) servant, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_free (servant);
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+ CORBA_exception_free (&ev);
+
+ new = gtk_type_new (evolution_composer_get_type ());
+ corba_object = bonobo_object_activate_servant (BONOBO_OBJECT (new),
+ servant);
+ evolution_composer_construct (new, corba_object);
+
+ return new;
+}
+
+E_MAKE_TYPE (evolution_composer, "EvolutionComposer", EvolutionComposer, class_init, init, PARENT_TYPE)
+
+
+#define COMPOSER_FACTORY_ID "OAFIID:evolution-composer-factory:evolution-mail:fcfda393-60ee-485f-b782-e9323434bff3"
+
+static BonoboObject *
+factory_fn (BonoboGenericFactory *factory, void *closure)
+{
+ return BONOBO_OBJECT (evolution_composer_new ());
+}
+
+void
+evolution_composer_factory_init (void)
+{
+ if (bonobo_generic_factory_new (COMPOSER_FACTORY_ID,
+ factory_fn, NULL) == NULL) {
+ e_notice (NULL, GNOME_MESSAGE_BOX_ERROR,
+ _("Cannot initialize Evolution's composer."));
+ exit (1);
+ }
+}
diff --git a/composer/evolution-composer.h b/composer/evolution-composer.h
new file mode 100644
index 0000000000..fe6deb6eb0
--- /dev/null
+++ b/composer/evolution-composer.h
@@ -0,0 +1,69 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* evolution-composer.h
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * 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 Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Dan Winship
+ */
+
+#ifndef __EVOLUTION_COMPOSER_H__
+#define __EVOLUTION_COMPOSER_H__
+
+#include <bonobo/bonobo-object.h>
+
+#include "Composer.h"
+#include "e-msg-composer.h"
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+#define EVOLUTION_TYPE_COMPOSER (evolution_composer_get_type ())
+#define EVOLUTION_COMPOSER(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_TYPE_COMPOSER, EvolutionComposer))
+#define EVOLUTION_COMPOSER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_COMPOSER, EvolutionComposerClass))
+#define EVOLUTION_IS_COMPOSER(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_TYPE_COMPOSER))
+#define EVOLUTION_IS_COMPOSER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_COMPOSER))
+
+typedef struct _EvolutionComposer EvolutionComposer;
+typedef struct _EvolutionComposerClass EvolutionComposerClass;
+
+struct _EvolutionComposer {
+ BonoboObject parent;
+
+ EMsgComposer *composer;
+};
+
+struct _EvolutionComposerClass {
+ BonoboObjectClass parent_class;
+};
+
+POA_Evolution_Composer__epv *evolution_composer_get_epv (void);
+
+GtkType evolution_composer_get_type (void);
+void evolution_composer_construct (EvolutionComposer *,
+ Evolution_Composer);
+EvolutionComposer *evolution_composer_new (void);
+
+void evolution_composer_factory_init (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __EVOLUTION_COMPOSER_H__ */
diff --git a/composer/main.c b/composer/main.c
deleted file mode 100644
index 41520cdde4..0000000000
--- a/composer/main.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-#include <gnome.h>
-#include <libgnorba/gnorba.h>
-#include <bonobo.h>
-
-#include <glade/glade.h>
-
-#include <camel/camel-data-wrapper.h>
-#include <camel/camel-stream-fs.h>
-#include <camel/camel-stream.h>
-
-#include "e-msg-composer.h"
-
-static void
-send_cb (EMsgComposer *composer,
- gpointer data)
-{
- CamelMimeMessage *message;
- CamelStream *stream;
- gint stdout_dup;
-
- message = e_msg_composer_get_message (composer);
-
- stdout_dup = dup (1);
- stream = camel_stream_fs_new_with_fd (stdout_dup);
- camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message),
- stream);
- camel_stream_close (stream);
-
- camel_object_unref (CAMEL_OBJECT (message));
-
-#if 0
- gtk_widget_destroy (GTK_WIDGET (composer));
- gtk_main_quit ();
-#endif
-}
-
-static guint
-create_composer (void)
-{
- GtkWidget *composer;
-
- composer = e_msg_composer_new ();
- gtk_widget_show (composer);
-
- gtk_signal_connect (GTK_OBJECT (composer), "send", GTK_SIGNAL_FUNC (send_cb), NULL);
-
- return FALSE;
-}
-
-int
-main (int argc, char **argv)
-{
- CORBA_Environment ev;
- CORBA_ORB orb;
-
- CORBA_exception_init (&ev);
- gnome_CORBA_init ("evolution-test-msg-composer", "0.0", &argc, argv, 0, &ev);
- CORBA_exception_free (&ev);
-
- orb = gnome_CORBA_ORB ();
-
- glade_gnome_init ();
-
- if (bonobo_init (orb, NULL, NULL) == FALSE)
- g_error ("Could not initialize Bonobo\n");
-
- /* We can't make any CORBA calls unless we're in the main loop. So we
- delay creating the container here. */
- gtk_idle_add ((GtkFunction) create_composer, NULL);
-
- bonobo_main ();
-
- return 0;
-}