aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-12-06 00:37:32 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-12-06 01:09:51 +0800
commit45a31136e917d8d763dfb56dda7dcf486c2ed242 (patch)
treecadb9b2051df61794e7ef81071e61e9d7b4cf319
parent2cbdd00f55f0598a3c7d060c1a973f5c3f6bd15e (diff)
downloadgsoc2013-evolution-45a31136e917d8d763dfb56dda7dcf486c2ed242.tar
gsoc2013-evolution-45a31136e917d8d763dfb56dda7dcf486c2ed242.tar.gz
gsoc2013-evolution-45a31136e917d8d763dfb56dda7dcf486c2ed242.tar.bz2
gsoc2013-evolution-45a31136e917d8d763dfb56dda7dcf486c2ed242.tar.lz
gsoc2013-evolution-45a31136e917d8d763dfb56dda7dcf486c2ed242.tar.xz
gsoc2013-evolution-45a31136e917d8d763dfb56dda7dcf486c2ed242.tar.zst
gsoc2013-evolution-45a31136e917d8d763dfb56dda7dcf486c2ed242.zip
Remove audio-inline module.
Drop our explicit gstreamer requirement and merge audio support directly into libevolution-mail-formatter. We now use the HTML5 <audio> tag and let WebKit show much nicer playback controls, with volume and seeking.
-rw-r--r--configure.ac32
-rw-r--r--em-format/Makefile.am4
-rw-r--r--em-format/e-mail-formatter-audio.c155
-rw-r--r--em-format/e-mail-formatter.c2
-rw-r--r--em-format/e-mail-parser-audio.c (renamed from modules/audio-inline/e-mail-parser-audio.c)41
-rw-r--r--em-format/e-mail-parser.c2
-rw-r--r--em-format/e-mail-part-audio.c (renamed from modules/audio-inline/e-mail-part-audio.c)79
-rw-r--r--em-format/e-mail-part-audio.h (renamed from modules/audio-inline/e-mail-part-audio.h)10
-rw-r--r--modules/Makefile.am5
-rw-r--r--modules/audio-inline/Makefile.am34
-rw-r--r--modules/audio-inline/e-mail-formatter-audio.c338
-rw-r--r--modules/audio-inline/e-mail-formatter-audio.h30
-rw-r--r--modules/audio-inline/e-mail-parser-audio.h30
-rw-r--r--modules/audio-inline/evolution-module-audio-inline.c54
14 files changed, 182 insertions, 634 deletions
diff --git a/configure.ac b/configure.ac
index a3ae349cf9..427e8f26aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1188,37 +1188,6 @@ dnl They must be explicitly disabled if the libraries are not present.
dnl ******************************************************************
dnl **************************************************
-dnl audio-inline plugin requires gstreamer-1.0 or 0.10
-dnl **************************************************
-AC_ARG_ENABLE([audio-inline],
- [AS_HELP_STRING([--enable-audio-inline],
- [Enable audio-inline plugin @<:@default=yes@:>@])],
- [enable_audio_inline="$enableval"], [enable_audio_inline=yes])
-
-if test "x$enable_audio_inline" = "xyes"; then
- PKG_CHECK_MODULES([GSTREAMER], [gstreamer-1.0], have_gst=yes,
- [PKG_CHECK_MODULES([GSTREAMER], [gstreamer-0.10], have_gst=yes, have_gst=no)],
- have_gst=no)
- AC_SUBST(GSTREAMER_CFLAGS)
- AC_SUBST(GSTREAMER_LIBS)
-
- if test "x$have_gst" = "xyes"; then
- AC_DEFINE(ENABLE_AUDIO_INLINE, 1, [Define to add support for inlining audio attachments])
- else
- AC_MSG_ERROR([
-
- gstreamer-1.0 or 0.10 not found.
-
- If you want to disable support for playing audio attachments,
- please append --disable-audio-inline to configure.
-
- ])
- fi
-fi
-
-AM_CONDITIONAL([ENABLE_AUDIO_INLINE], [test "x$enable_audio_inline" = "xyes"])
-
-dnl **************************************************
dnl text-highlight plugins requires highlight utility
dnl **************************************************
AC_ARG_ENABLE([text-highlight],
@@ -1519,7 +1488,6 @@ mail/importers/Makefile
maint/Makefile
modules/Makefile
modules/addressbook/Makefile
-modules/audio-inline/Makefile
modules/backup-restore/Makefile
modules/bogofilter/Makefile
modules/book-config-google/Makefile
diff --git a/em-format/Makefile.am b/em-format/Makefile.am
index 2983eb0ecf..69da12db0c 100644
--- a/em-format/Makefile.am
+++ b/em-format/Makefile.am
@@ -35,6 +35,7 @@ evolution_mail_formatter_include_HEADERS = \
e-mail-part.h \
e-mail-part-attachment.h \
e-mail-part-attachment-bar.h \
+ e-mail-part-audio.h \
e-mail-part-headers.h \
e-mail-part-image.h \
e-mail-part-list.h \
@@ -68,6 +69,7 @@ libevolution_mail_formatter_la_SOURCES = \
e-mail-formatter-utils.c \
e-mail-formatter-attachment.c \
e-mail-formatter-attachment-bar.c \
+ e-mail-formatter-audio.c \
e-mail-formatter-enumtypes.c \
e-mail-formatter-error.c \
e-mail-formatter-extension.c \
@@ -90,6 +92,7 @@ libevolution_mail_formatter_la_SOURCES = \
e-mail-parser.c \
e-mail-parser-application-mbox.c \
e-mail-parser-attachment-bar.c \
+ e-mail-parser-audio.c \
e-mail-parser-headers.c \
e-mail-parser-image.c \
e-mail-parser-inlinepgp-encrypted.c \
@@ -113,6 +116,7 @@ libevolution_mail_formatter_la_SOURCES = \
e-mail-part.c \
e-mail-part-attachment.c \
e-mail-part-attachment-bar.c \
+ e-mail-part-audio.c \
e-mail-part-headers.c \
e-mail-part-image.c \
e-mail-part-list.c \
diff --git a/em-format/e-mail-formatter-audio.c b/em-format/e-mail-formatter-audio.c
new file mode 100644
index 0000000000..e36cc06ff1
--- /dev/null
+++ b/em-format/e-mail-formatter-audio.c
@@ -0,0 +1,155 @@
+/*
+ * e-mail-formatter-audio.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib/gi18n-lib.h>
+
+#include <camel/camel.h>
+
+#include "e-mail-formatter-extension.h"
+#include "e-mail-formatter.h"
+#include "e-mail-part-audio.h"
+
+#define d(x)
+
+typedef EMailFormatterExtension EMailFormatterAudio;
+typedef EMailFormatterExtensionClass EMailFormatterAudioClass;
+
+GType e_mail_formatter_audio_get_type (void);
+
+G_DEFINE_TYPE (
+ EMailFormatterAudio,
+ e_mail_formatter_audio,
+ E_TYPE_MAIL_FORMATTER_EXTENSION)
+
+static const gchar *formatter_mime_types[] = {
+ "application/vnd.evolution.widget.audio",
+ "audio/ac3",
+ "audio/x-ac3",
+ "audio/basic",
+ "audio/mpeg",
+ "audio/x-mpeg",
+ "audio/mpeg3",
+ "audio/x-mpeg3",
+ "audio/mp3",
+ "audio/x-mp3",
+ "audio/mp4",
+ "audio/flac",
+ "audio/x-flac",
+ "audio/mod",
+ "audio/x-mod",
+ "audio/x-wav",
+ "audio/microsoft-wav",
+ "audio/x-wma",
+ "audio/x-ms-wma",
+ "audio/ogg",
+ "audio/x-vorbis+ogg",
+ "application/ogg",
+ "application/x-ogg",
+ NULL
+};
+
+static gboolean
+mail_formatter_audio_format (EMailFormatterExtension *extension,
+ EMailFormatter *formatter,
+ EMailFormatterContext *context,
+ EMailPart *part,
+ CamelStream *stream,
+ GCancellable *cancellable)
+{
+ CamelMimePart *mime_part;
+ CamelDataWrapper *content;
+ CamelTransferEncoding encoding;
+ CamelStream *mem_stream;
+ GByteArray *byte_array;
+ const gchar *mime_type;
+ gchar *html;
+ GError *local_error = NULL;
+
+ mime_part = e_mail_part_ref_mime_part (part);
+ encoding = camel_mime_part_get_encoding (mime_part);
+ content = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
+
+ mime_type = e_mail_part_get_mime_type (part);
+ if (mime_type == NULL)
+ mime_type = "audio/*";
+
+ mem_stream = camel_stream_mem_new ();
+ byte_array = camel_stream_mem_get_byte_array (
+ CAMEL_STREAM_MEM (mem_stream));
+
+ if (encoding == CAMEL_TRANSFER_ENCODING_BASE64) {
+ camel_data_wrapper_write_to_stream_sync (
+ content, mem_stream, cancellable, &local_error);
+
+ html = g_strdup_printf (
+ "<audio controls>"
+ "<source src=\"data:%s;base64,%s\"/>"
+ "</audio>",
+ mime_type, (gchar *) byte_array->data);
+
+ } else {
+ gchar *base64;
+
+ camel_data_wrapper_decode_to_stream_sync (
+ content, mem_stream, cancellable, &local_error);
+
+ base64 = g_base64_encode (
+ (guchar *) byte_array->data, byte_array->len);
+ html = g_strdup_printf (
+ "<audio controls>"
+ "<source src=\"data:%s;base64,%s\"/>"
+ "</audio>",
+ mime_type, base64);
+ g_free (base64);
+ }
+
+ /* XXX Should show the error message in the UI somehow. */
+ if (local_error != NULL) {
+ g_warning ("%s: %s", G_STRFUNC, local_error->message);
+ g_error_free (local_error);
+ }
+
+ camel_stream_write_string (stream, html, NULL, NULL);
+
+ g_free (html);
+
+ g_object_unref (mime_part);
+ g_object_unref (mem_stream);
+
+ return TRUE;
+}
+
+static void
+e_mail_formatter_audio_class_init (EMailFormatterExtensionClass *class)
+{
+ class->display_name = _("Audio Player");
+ class->description = _("Play the attachment in embedded audio player");
+ class->mime_types = formatter_mime_types;
+ class->priority = G_PRIORITY_LOW;
+ class->format = mail_formatter_audio_format;
+}
+
+static void
+e_mail_formatter_audio_init (EMailFormatterExtension *extension)
+{
+}
+
diff --git a/em-format/e-mail-formatter.c b/em-format/e-mail-formatter.c
index 2f201dd07e..41bd7fdf31 100644
--- a/em-format/e-mail-formatter.c
+++ b/em-format/e-mail-formatter.c
@@ -62,6 +62,7 @@ struct _AsyncContext {
/* internal formatter extensions */
GType e_mail_formatter_attachment_get_type (void);
GType e_mail_formatter_attachment_bar_get_type (void);
+GType e_mail_formatter_audio_get_type (void);
GType e_mail_formatter_error_get_type (void);
GType e_mail_formatter_headers_get_type (void);
GType e_mail_formatter_image_get_type (void);
@@ -534,6 +535,7 @@ e_mail_formatter_base_init (EMailFormatterClass *class)
/* Register internal extensions. */
g_type_ensure (e_mail_formatter_attachment_get_type ());
g_type_ensure (e_mail_formatter_attachment_bar_get_type ());
+ g_type_ensure (e_mail_formatter_audio_get_type ());
g_type_ensure (e_mail_formatter_error_get_type ());
g_type_ensure (e_mail_formatter_headers_get_type ());
g_type_ensure (e_mail_formatter_image_get_type ());
diff --git a/modules/audio-inline/e-mail-parser-audio.c b/em-format/e-mail-parser-audio.c
index 9fed607e4e..c5e351ee76 100644
--- a/modules/audio-inline/e-mail-parser-audio.c
+++ b/em-format/e-mail-parser-audio.c
@@ -20,32 +20,21 @@
#endif
#include <string.h>
-#include <gtk/gtk.h>
-#include <glib.h>
-#include <glib/gi18n.h>
-
-#include "e-mail-parser-audio.h"
-#include "e-mail-part-audio.h"
+#include <glib/gi18n-lib.h>
#include <camel/camel.h>
-#include <em-format/e-mail-extension-registry.h>
-#include <em-format/e-mail-parser-extension.h>
-#include <em-format/e-mail-part.h>
-
-#include <libebackend/libebackend.h>
-
-#define d(x)
+#include "e-mail-extension-registry.h"
+#include "e-mail-parser-extension.h"
+#include "e-mail-part-audio.h"
+#include "e-mail-part.h"
typedef EMailParserExtension EMailParserAudio;
typedef EMailParserExtensionClass EMailParserAudioClass;
-typedef EExtension EMailParserAudioLoader;
-typedef EExtensionClass EMailParserAudioLoaderClass;
-
GType e_mail_parser_audio_get_type (void);
-G_DEFINE_DYNAMIC_TYPE (
+G_DEFINE_TYPE (
EMailParserAudio,
e_mail_parser_audio,
E_TYPE_MAIL_PARSER_EXTENSION)
@@ -89,12 +78,10 @@ mail_parser_audio_parse (EMailParserExtension *extension,
gint len;
len = part_id->len;
- g_string_append (part_id, ".org-gnome-audio-button-panel");
+ g_string_append (part_id, ".audio");
camel_mime_part_set_disposition (part, "inline");
- d (printf ("audio formatter: format classid %s\n", part_id->str));
-
mail_part = e_mail_part_audio_new (part, part_id->str);
g_string_truncate (part_id, len);
@@ -113,24 +100,12 @@ static void
e_mail_parser_audio_class_init (EMailParserExtensionClass *class)
{
class->mime_types = parser_mime_types;
+ class->priority = G_PRIORITY_LOW;
class->flags = E_MAIL_PARSER_EXTENSION_INLINE_DISPOSITION;
class->parse = mail_parser_audio_parse;
}
static void
-e_mail_parser_audio_class_finalize (EMailParserExtensionClass *class)
-{
-
-}
-
-static void
e_mail_parser_audio_init (EMailParserExtension *extension)
{
}
-
-void
-e_mail_parser_audio_type_register (GTypeModule *type_module)
-{
- e_mail_parser_audio_register_type (type_module);
-}
-
diff --git a/em-format/e-mail-parser.c b/em-format/e-mail-parser.c
index 57c362e286..f90f4d328e 100644
--- a/em-format/e-mail-parser.c
+++ b/em-format/e-mail-parser.c
@@ -51,6 +51,7 @@ enum {
/* internal parser extensions */
GType e_mail_parser_application_mbox_get_type (void);
GType e_mail_parser_attachment_bar_get_type (void);
+GType e_mail_parser_audio_get_type (void);
GType e_mail_parser_headers_get_type (void);
GType e_mail_parser_message_get_type (void);
GType e_mail_parser_secure_button_get_type (void);
@@ -206,6 +207,7 @@ e_mail_parser_base_init (EMailParserClass *class)
/* Register internal extensions. */
g_type_ensure (e_mail_parser_application_mbox_get_type ());
g_type_ensure (e_mail_parser_attachment_bar_get_type ());
+ g_type_ensure (e_mail_parser_audio_get_type ());
g_type_ensure (e_mail_parser_headers_get_type ());
g_type_ensure (e_mail_parser_message_get_type ());
g_type_ensure (e_mail_parser_secure_button_get_type ());
diff --git a/modules/audio-inline/e-mail-part-audio.c b/em-format/e-mail-part-audio.c
index 0c8ae7fa16..f8ba9ab428 100644
--- a/modules/audio-inline/e-mail-part-audio.c
+++ b/em-format/e-mail-part-audio.c
@@ -18,66 +18,21 @@
#include "e-mail-part-audio.h"
-#include <glib/gstdio.h>
-
#define E_MAIL_PART_AUDIO_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_MAIL_PART_AUDIO, EMailPartAudioPrivate))
-struct _EMailPartAudioPrivate {
- gint placeholder;
-};
-
-G_DEFINE_DYNAMIC_TYPE (
+G_DEFINE_TYPE (
EMailPartAudio,
e_mail_part_audio,
E_TYPE_MAIL_PART)
static void
-mail_part_audio_dispose (GObject *object)
-{
- EMailPartAudio *part = E_MAIL_PART_AUDIO (object);
-
- if (part->bus_id > 0) {
- g_source_remove (part->bus_id);
- part->bus_id = 0;
- }
-
- if (part->playbin != NULL) {
- gst_element_set_state (part->playbin, GST_STATE_NULL);
- gst_object_unref (part->playbin);
- part->playbin = NULL;
- }
-
- g_clear_object (&part->play_button);
- g_clear_object (&part->pause_button);
- g_clear_object (&part->stop_button);
-
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_mail_part_audio_parent_class)->dispose (object);
-}
-
-static void
-mail_part_audio_finalize (GObject *object)
-{
- EMailPartAudio *part = E_MAIL_PART_AUDIO (object);
-
- if (part->filename != NULL) {
- g_unlink (part->filename);
- g_free (part->filename);
- }
-
- /* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (e_mail_part_audio_parent_class)->finalize (object);
-}
-
-static void
mail_part_audio_constructed (GObject *object)
{
EMailPart *part;
CamelMimePart *mime_part;
CamelContentType *content_type;
- gchar *mime_type;
part = E_MAIL_PART (object);
@@ -89,9 +44,16 @@ mail_part_audio_constructed (GObject *object)
mime_part = e_mail_part_ref_mime_part (part);
content_type = camel_mime_part_get_content_type (mime_part);
- mime_type = camel_content_type_simple (content_type);
- e_mail_part_set_mime_type (part, mime_type);
- g_free (mime_type);
+
+ if (content_type != NULL) {
+ gchar *mime_type;
+
+ mime_type = camel_content_type_simple (content_type);
+ e_mail_part_set_mime_type (part, mime_type);
+ g_free (mime_type);
+ } else {
+ e_mail_part_set_mime_type (part, "audio/*");
+ }
g_object_unref (mime_part);
}
@@ -101,32 +63,13 @@ e_mail_part_audio_class_init (EMailPartAudioClass *class)
{
GObjectClass *object_class;
- g_type_class_add_private (class, sizeof (EMailPartAudioPrivate));
-
object_class = G_OBJECT_CLASS (class);
- object_class->dispose = mail_part_audio_dispose;
- object_class->finalize = mail_part_audio_finalize;
object_class->constructed = mail_part_audio_constructed;
}
static void
-e_mail_part_audio_class_finalize (EMailPartAudioClass *class)
-{
-}
-
-static void
e_mail_part_audio_init (EMailPartAudio *part)
{
- part->priv = E_MAIL_PART_AUDIO_GET_PRIVATE (part);
-}
-
-void
-e_mail_part_audio_type_register (GTypeModule *type_module)
-{
- /* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
- * function, so we have to wrap it with a public function in
- * order to register types from a separate compilation unit. */
- e_mail_part_audio_register_type (type_module);
}
EMailPart *
diff --git a/modules/audio-inline/e-mail-part-audio.h b/em-format/e-mail-part-audio.h
index 42459e01ff..4aeea05b4a 100644
--- a/modules/audio-inline/e-mail-part-audio.h
+++ b/em-format/e-mail-part-audio.h
@@ -20,7 +20,6 @@
#define E_MAIL_PART_AUDIO_H
#include <em-format/e-mail-part.h>
-#include <gst/gst.h>
/* Standard GObject macros */
#define E_TYPE_MAIL_PART_AUDIO \
@@ -50,14 +49,6 @@ typedef struct _EMailPartAudioPrivate EMailPartAudioPrivate;
struct _EMailPartAudio {
EMailPart parent;
EMailPartAudioPrivate *priv;
-
- gchar *filename;
- GstElement *playbin;
- gulong bus_id;
- GstState target_state;
- GtkWidget *play_button;
- GtkWidget *pause_button;
- GtkWidget *stop_button;
};
struct _EMailPartAudioClass {
@@ -65,7 +56,6 @@ struct _EMailPartAudioClass {
};
GType e_mail_part_audio_get_type (void) G_GNUC_CONST;
-void e_mail_part_audio_type_register (GTypeModule *type_module);
EMailPart * e_mail_part_audio_new (CamelMimePart *mime_part,
const gchar *id);
diff --git a/modules/Makefile.am b/modules/Makefile.am
index d08372d710..ac6655ffd0 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -18,10 +18,6 @@ if ENABLE_TNEF
TNEF_ATTACHMENT_DIR = tnef-attachment
endif
-if ENABLE_AUDIO_INLINE
-AUDIO_INLINE_DIR = audio-inline
-endif
-
if ENABLE_TEXT_HIGHLIGHT
TEXT_HIGHLIGHT_DIR = text-highlight
endif
@@ -59,7 +55,6 @@ SUBDIRS = \
$(BOGOFILTER_DIR) \
$(SPAMASSASSIN_DIR) \
$(TNEF_ATTACHMENT_DIR) \
- $(AUDIO_INLINE_DIR) \
$(TEXT_HIGHLIGHT_DIR)
-include $(top_srcdir)/git.mk
diff --git a/modules/audio-inline/Makefile.am b/modules/audio-inline/Makefile.am
deleted file mode 100644
index 3f54407e3e..0000000000
--- a/modules/audio-inline/Makefile.am
+++ /dev/null
@@ -1,34 +0,0 @@
-module_LTLIBRARIES = module-audio-inline.la
-
-module_audio_inline_la_CPPFLAGS = \
- $(AM_CPPFLAGS) \
- -I$(top_srcdir) \
- -DEVOLUTION_PRIVDATADIR=\""$(privdatadir)"\" \
- -DG_LOG_DOMAIN=\"evolution-module-audio-inline\" \
- $(EVOLUTION_DATA_SERVER_CFLAGS) \
- $(GNOME_PLATFORM_CFLAGS) \
- $(GTKHTML_CFLAGS) \
- $(GSTREAMER_CFLAGS)
-
-module_audio_inline_la_SOURCES = \
- e-mail-formatter-audio.c \
- e-mail-formatter-audio.h \
- e-mail-parser-audio.c \
- e-mail-parser-audio.h \
- e-mail-part-audio.c \
- e-mail-part-audio.h \
- evolution-module-audio-inline.c
-
-module_audio_inline_la_LIBADD = \
- $(top_builddir)/e-util/libevolution-util.la \
- $(top_builddir)/mail/libevolution-mail.la \
- $(top_builddir)/em-format/libevolution-mail-formatter.la \
- $(EVOLUTION_DATA_SERVER_LIBS) \
- $(GNOME_PLATFORM_LIBS) \
- $(GTKHTML_LIBS) \
- $(GSTREAMER_LIBS)
-
-module_audio_inline_la_LDFLAGS = \
- -avoid-version -module $(NO_UNDEFINED)
-
--include $(top_srcdir)/git.mk
diff --git a/modules/audio-inline/e-mail-formatter-audio.c b/modules/audio-inline/e-mail-formatter-audio.c
deleted file mode 100644
index f1535a6bc6..0000000000
--- a/modules/audio-inline/e-mail-formatter-audio.c
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * e-mail-formatter-audio.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-mail-formatter-audio.h"
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib/gi18n-lib.h>
-
-#include <camel/camel.h>
-#include <gst/gst.h>
-
-#include <libebackend/libebackend.h>
-
-#include <em-format/e-mail-formatter-extension.h>
-#include <em-format/e-mail-formatter.h>
-
-#include "e-mail-part-audio.h"
-
-#define d(x)
-
-typedef EMailFormatterExtension EMailFormatterAudio;
-typedef EMailFormatterExtensionClass EMailFormatterAudioClass;
-
-typedef EExtension EMailFormatterAudioLoader;
-typedef EExtensionClass EMailFormatterAudioLoaderClass;
-
-GType e_mail_formatter_audio_get_type (void);
-
-G_DEFINE_DYNAMIC_TYPE (
- EMailFormatterAudio,
- e_mail_formatter_audio,
- E_TYPE_MAIL_FORMATTER_EXTENSION)
-
-static const gchar *formatter_mime_types[] = {
- "application/vnd.evolution.widget.audio",
- "audio/ac3",
- "audio/x-ac3",
- "audio/basic",
- "audio/mpeg",
- "audio/x-mpeg",
- "audio/mpeg3",
- "audio/x-mpeg3",
- "audio/mp3",
- "audio/x-mp3",
- "audio/mp4",
- "audio/flac",
- "audio/x-flac",
- "audio/mod",
- "audio/x-mod",
- "audio/x-wav",
- "audio/microsoft-wav",
- "audio/x-wma",
- "audio/x-ms-wma",
- "audio/ogg",
- "audio/x-vorbis+ogg",
- "application/ogg",
- "application/x-ogg",
- NULL
-};
-
-static void
-pause_clicked (GtkWidget *button,
- EMailPartAudio *part)
-{
- if (part->playbin) {
- /* pause playing */
- gst_element_set_state (part->playbin, GST_STATE_PAUSED);
- }
-}
-
-static void
-stop_clicked (GtkWidget *button,
- EMailPartAudio *part)
-{
- if (part->playbin) {
- /* ready to play */
- gst_element_set_state (part->playbin, GST_STATE_READY);
- part->target_state = GST_STATE_READY;
- }
-}
-
-static void
-set_audiosink (GstElement *playbin)
-{
- GstElement *audiosink;
-
- /* now it's time to get the audio sink */
- audiosink = gst_element_factory_make ("gconfaudiosink", "play_audio");
- if (audiosink == NULL) {
- audiosink = gst_element_factory_make ("autoaudiosink", "play_audio");
- }
-
- if (audiosink) {
- g_object_set (playbin, "audio-sink", audiosink, NULL);
- }
-}
-
-static gboolean
-gst_callback (GstBus *bus,
- GstMessage *message,
- gpointer data)
-{
- EMailPartAudio *part = data;
- GstMessageType msg_type;
-
- g_return_val_if_fail (part != NULL, TRUE);
- g_return_val_if_fail (part->playbin != NULL, TRUE);
-
- msg_type = GST_MESSAGE_TYPE (message);
-
- switch (msg_type) {
- case GST_MESSAGE_ERROR:
- gst_element_set_state (part->playbin, GST_STATE_NULL);
- break;
- case GST_MESSAGE_EOS:
- gst_element_set_state (part->playbin, GST_STATE_READY);
- break;
- case GST_MESSAGE_STATE_CHANGED:
- {
- GstState old_state, new_state;
-
- if (GST_MESSAGE_SRC (message) != GST_OBJECT (part->playbin))
- break;
-
- gst_message_parse_state_changed (message, &old_state, &new_state, NULL);
-
- if (old_state == new_state)
- break;
-
- if (part->play_button)
- gtk_widget_set_sensitive (
- part->play_button,
- new_state <= GST_STATE_PAUSED);
- if (part->pause_button)
- gtk_widget_set_sensitive (
- part->pause_button,
- new_state > GST_STATE_PAUSED);
- if (part->stop_button)
- gtk_widget_set_sensitive (
- part->stop_button,
- new_state >= GST_STATE_PAUSED);
- }
-
- break;
- default:
- break;
- }
-
- return TRUE;
-}
-
-static void
-play_clicked (GtkWidget *button,
- EMailPartAudio *part)
-{
- GstState cur_state;
-
- d (printf ("audio formatter: play\n"));
-
- if (!part->filename) {
- CamelStream *stream;
- CamelDataWrapper *data;
- CamelMimePart *mime_part;
- GError *error = NULL;
- gint argc = 1;
- const gchar *argv[] = { "org_gnome_audio", NULL };
-
- /* FIXME this is ugly, we should stream this directly to gstreamer */
- part->filename = e_mktemp ("org-gnome-audio-file-XXXXXX");
-
- d (printf ("audio formatter: write to temp file %s\n", part->filename));
-
- stream = camel_stream_fs_new_with_name (
- part->filename, O_RDWR | O_CREAT | O_TRUNC, 0600, NULL);
- mime_part = e_mail_part_ref_mime_part (E_MAIL_PART (part));
- data = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
- camel_data_wrapper_decode_to_stream_sync (data, stream, NULL, NULL);
- camel_stream_flush (stream, NULL, NULL);
- g_object_unref (mime_part);
- g_object_unref (stream);
-
- d (printf ("audio formatter: init gst playbin\n"));
-
- if (gst_init_check (&argc, (gchar ***) &argv, &error)) {
- gchar *uri;
- GstBus *bus;
-
- /* create a disk reader */
- part->playbin = gst_element_factory_make ("playbin", "playbin");
- if (part->playbin == NULL) {
- g_printerr ("Failed to create gst_element_factory playbin; check your installation\n");
- return;
-
- }
-
- uri = g_filename_to_uri (part->filename, NULL, NULL);
- g_object_set (part->playbin, "uri", uri, NULL);
- g_free (uri);
- set_audiosink (part->playbin);
-
- bus = gst_element_get_bus (part->playbin);
- part->bus_id = gst_bus_add_watch (bus, gst_callback, part);
- gst_object_unref (bus);
-
- } else {
- g_printerr ("GStreamer failed to initialize: %s",error ? error->message : "");
- g_error_free (error);
- }
- }
-
- gst_element_get_state (part->playbin, &cur_state, NULL, 0);
-
- if (cur_state >= GST_STATE_PAUSED) {
- gst_element_set_state (part->playbin, GST_STATE_READY);
- }
-
- if (part->playbin) {
- /* start playing */
- gst_element_set_state (part->playbin, GST_STATE_PLAYING);
- }
-}
-
-static GtkWidget *
-add_button (GtkWidget *box,
- const gchar *stock_icon,
- GCallback cb,
- gpointer data,
- gboolean sensitive)
-{
- GtkWidget *button;
-
- button = gtk_button_new_from_stock (stock_icon);
- gtk_widget_set_sensitive (button, sensitive);
- g_signal_connect (button, "clicked", cb, data);
-
- gtk_widget_show (button);
- gtk_box_pack_end (GTK_BOX (box), button, TRUE, TRUE, 0);
-
- return button;
-}
-
-static gboolean
-mail_formatter_audio_format (EMailFormatterExtension *extension,
- EMailFormatter *formatter,
- EMailFormatterContext *context,
- EMailPart *part,
- CamelStream *stream,
- GCancellable *cancellable)
-{
- gchar *str;
-
- str = g_strdup_printf (
- "<object type=\"application/vnd.evolution.widget.audio\" "
- "width=\"100%%\" height=\"auto\" data=\"%s\" id=\"%s\"></object>",
- e_mail_part_get_id (part),
- e_mail_part_get_id (part));
-
- camel_stream_write_string (stream, str, cancellable, NULL);
-
- g_free (str);
-
- return TRUE;
-}
-
-static GtkWidget *
-mail_formatter_audio_get_widget (EMailFormatterExtension *extension,
- EMailPartList *context,
- EMailPart *part,
- GHashTable *params)
-{
- GtkWidget *box;
- EMailPartAudio *ai_part;
-
- g_return_val_if_fail (E_IS_MAIL_PART_AUDIO (part), NULL);
-
- ai_part = (EMailPartAudio *) part;
-
- /* it is OK to call UI functions here, since we are called from UI thread */
- box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
- ai_part->play_button = g_object_ref (
- add_button (box, GTK_STOCK_MEDIA_PLAY,
- G_CALLBACK (play_clicked), part, TRUE));
- ai_part->pause_button = g_object_ref (
- add_button (box, GTK_STOCK_MEDIA_PAUSE,
- G_CALLBACK (pause_clicked), part, FALSE));
- ai_part->stop_button = g_object_ref (
- add_button (box, GTK_STOCK_MEDIA_STOP,
- G_CALLBACK (stop_clicked), part, FALSE));
-
- gtk_widget_show (box);
-
- return box;
-}
-
-static void
-e_mail_formatter_audio_class_init (EMailFormatterExtensionClass *class)
-{
- class->display_name = _("Audio Player");
- class->description = _("Play the attachment in embedded audio player");
- class->mime_types = formatter_mime_types;
- class->format = mail_formatter_audio_format;
- class->get_widget = mail_formatter_audio_get_widget;
-}
-
-static void
-e_mail_formatter_audio_class_finalize (EMailFormatterExtensionClass *class)
-{
-}
-
-static void
-e_mail_formatter_audio_init (EMailFormatterExtension *extension)
-{
-}
-
-void
-e_mail_formatter_audio_type_register (GTypeModule *type_module)
-{
- e_mail_formatter_audio_register_type (type_module);
-}
-
diff --git a/modules/audio-inline/e-mail-formatter-audio.h b/modules/audio-inline/e-mail-formatter-audio.h
deleted file mode 100644
index 8e486298b2..0000000000
--- a/modules/audio-inline/e-mail-formatter-audio.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * e-mail-formatter-audio.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_MAIL_FORMATTER_AUDIO_H
-#define E_MAIL_FORMATTER_AUDIO_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-void e_mail_formatter_audio_type_register (GTypeModule *type_module);
-
-G_END_DECLS
-
-#endif /* E_MAIL_FORMATTER_AUDIO_H */
diff --git a/modules/audio-inline/e-mail-parser-audio.h b/modules/audio-inline/e-mail-parser-audio.h
deleted file mode 100644
index fa7119c796..0000000000
--- a/modules/audio-inline/e-mail-parser-audio.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * e-mail-parser-audio.h
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#ifndef E_MAIL_PARSER_AUDIO_H
-#define E_MAIL_PARSER_AUDIO_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-void e_mail_parser_audio_type_register (GTypeModule *type_module);
-
-G_END_DECLS
-
-#endif /* E_MAIL_PARSER_AUDIO_H */
diff --git a/modules/audio-inline/evolution-module-audio-inline.c b/modules/audio-inline/evolution-module-audio-inline.c
deleted file mode 100644
index 678bfe436c..0000000000
--- a/modules/audio-inline/evolution-module-audio-inline.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * evolution-module-audio-inline.c
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) version 3.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the program; if not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include "e-mail-formatter-audio.h"
-#include "e-mail-parser-audio.h"
-#include "e-mail-part-audio.h"
-
-#include <gmodule.h>
-
-void e_module_load (GTypeModule *type_module);
-void e_module_unload (GTypeModule *type_module);
-const gchar * g_module_check_init (GModule *module);
-
-G_MODULE_EXPORT void
-e_module_load (GTypeModule *type_module)
-{
- e_mail_part_audio_type_register (type_module);
- e_mail_parser_audio_type_register (type_module);
- e_mail_formatter_audio_type_register (type_module);
-}
-
-G_MODULE_EXPORT void
-e_module_unload (GTypeModule *type_module)
-{
-}
-
-G_MODULE_EXPORT const gchar *
-g_module_check_init (GModule *module)
-{
- /* FIXME Until mail is split into a module library and a
- * reusable shared library, prevent the module from
- * being unloaded. Unloading the module resets all
- * static variables, which screws up foo_get_type()
- * functions among other things. */
- g_module_make_resident (module);
-
- return NULL;
-}
-