diff options
author | Dan Vrátil <dvratil@redhat.com> | 2012-06-06 21:29:38 +0800 |
---|---|---|
committer | Dan Vrátil <dvratil@redhat.com> | 2012-06-06 21:29:38 +0800 |
commit | 931191474643164e96b5778c790e42cca517e729 (patch) | |
tree | aec00f3303dbcd95a8a3f18ee324ac80594ff9b5 /plugins/audio-inline | |
parent | 5b8340563c271fb684a88c6e5bb6dd3bfb629058 (diff) | |
download | gsoc2013-evolution-931191474643164e96b5778c790e42cca517e729.tar gsoc2013-evolution-931191474643164e96b5778c790e42cca517e729.tar.gz gsoc2013-evolution-931191474643164e96b5778c790e42cca517e729.tar.bz2 gsoc2013-evolution-931191474643164e96b5778c790e42cca517e729.tar.lz gsoc2013-evolution-931191474643164e96b5778c790e42cca517e729.tar.xz gsoc2013-evolution-931191474643164e96b5778c790e42cca517e729.tar.zst gsoc2013-evolution-931191474643164e96b5778c790e42cca517e729.zip |
Mail formatter rewrite - convert some plugins to modules
audio-inline, itip-formatter, prefer-plain, tnef-attachments
and vcard-inline plugins were converted to modules so that they
can fit into concept of the new formatter.
Every module still installs .eplug file, because there is no
suitable API at the moment to register plugins to the plugins dialog
and to extend the Preferences dialog.
Diffstat (limited to 'plugins/audio-inline')
-rw-r--r-- | plugins/audio-inline/Makefile.am | 39 | ||||
-rw-r--r-- | plugins/audio-inline/audio-inline.c | 347 | ||||
-rw-r--r-- | plugins/audio-inline/org-gnome-audio-inline.eplug.xml | 100 |
3 files changed, 0 insertions, 486 deletions
diff --git a/plugins/audio-inline/Makefile.am b/plugins/audio-inline/Makefile.am deleted file mode 100644 index 7afdceec97..0000000000 --- a/plugins/audio-inline/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -if OS_WIN32 -NO_UNDEFINED_REQUIRED_LIBS = \ - $(top_builddir)/mail/libevolution-mail.la \ - $(top_builddir)/e-util/libeutil.la \ - $(GNOME_PLATFORM_LIBS) -endif - -@EVO_PLUGIN_RULE@ - -plugin_DATA = org-gnome-audio-inline.eplug - -plugin_LTLIBRARIES = liborg-gnome-audio-inline.la - -liborg_gnome_audio_inline_la_CPPFLAGS = \ - $(AM_CPPFLAGS) \ - -I$(top_srcdir) \ - -I$(top_srcdir)/widgets \ - $(EVOLUTION_DATA_SERVER_CFLAGS) \ - $(GNOME_PLATFORM_CFLAGS) \ - $(GSTREAMER_CFLAGS) - -liborg_gnome_audio_inline_la_SOURCES = audio-inline.c - -liborg_gnome_audio_inline_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED) - -liborg_gnome_audio_inline_la_LIBADD = \ - $(top_builddir)/mail/libevolution-mail.la \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/em-format/libemformat.la \ - $(EVOLUTION_DATA_SERVER_LIBS) \ - $(GNOME_PLATFORM_LIBS) \ - $(GSTREAMER_LIBS) - -EXTRA_DIST = org-gnome-audio-inline.eplug.xml - -BUILT_SOURCES = $(plugin_DATA) -CLEANFILES = $(BUILT_SOURCES) - --include $(top_srcdir)/git.mk diff --git a/plugins/audio-inline/audio-inline.c b/plugins/audio-inline/audio-inline.c deleted file mode 100644 index 45238db2eb..0000000000 --- a/plugins/audio-inline/audio-inline.c +++ /dev/null @@ -1,347 +0,0 @@ -/* - * 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/> - * - * - * Authors: - * Radek Doulik <rodo@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtk.h> -#include <glib/gstdio.h> -#include "e-util/e-mktemp.h" -#include "mail/em-format-hook.h" -#include "mail/em-format-html.h" -#include "gst/gst.h" - -#define d(x) - -gint e_plugin_lib_enable (EPlugin *ep, gint enable); - -gint -e_plugin_lib_enable (EPlugin *ep, - gint enable) -{ - return 0; -} - -void org_gnome_audio_inline_format (gpointer ep, EMFormatHookTarget *t); - -typedef struct _EMFormatInlineAudioPURI EMFormatInlineAudioPURI; - -struct _EMFormatInlineAudioPURI { - EMFormatPURI puri; - - gchar *filename; - GstElement *playbin; - gulong bus_id; - GstState target_state; - GtkWidget *play_button; - GtkWidget *pause_button; - GtkWidget *stop_button; -}; - -static void -org_gnome_audio_inline_pobject_free (EMFormatPURI *o) -{ - EMFormatInlineAudioPURI *po = (EMFormatInlineAudioPURI *) o; - - d(printf ("audio inline formatter: pobject free\n")); - - if (po->play_button) { - g_object_unref (po->play_button); - po->play_button = NULL; - } - - if (po->pause_button) { - g_object_unref (po->pause_button); - po->pause_button = NULL; - } - - if (po->stop_button) { - g_object_unref (po->stop_button); - po->stop_button = NULL; - } - - if (po->filename) { - g_unlink (po->filename); - g_free (po->filename); - po->filename = NULL; - } - - if (po->bus_id) { - g_source_remove (po->bus_id); - po->bus_id = 0; - } - - if (po->playbin) { - gst_element_set_state (po->playbin, GST_STATE_NULL); - gst_object_unref (po->playbin); - po->playbin = NULL; - } -} - -static void -org_gnome_audio_inline_pause_clicked (GtkWidget *button, - EMFormatPURI *puri) -{ - EMFormatInlineAudioPURI *po = (EMFormatInlineAudioPURI *) puri; - - if (po->playbin) { - /* pause playing */ - gst_element_set_state (po->playbin, GST_STATE_PAUSED); - } -} - -static void -org_gnome_audio_inline_stop_clicked (GtkWidget *button, - EMFormatPURI *puri) -{ - EMFormatInlineAudioPURI *po = (EMFormatInlineAudioPURI *) puri; - - if (po->playbin) { - /* ready to play */ - gst_element_set_state (po->playbin, GST_STATE_READY); - po->target_state = GST_STATE_READY; - } -} - -static void -org_gnome_audio_inline_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 -org_gnome_audio_inline_gst_callback (GstBus *bus, - GstMessage *message, - gpointer data) -{ - EMFormatInlineAudioPURI *po = (EMFormatInlineAudioPURI *) data; - GstMessageType msg_type; - - g_return_val_if_fail (po != NULL, TRUE); - g_return_val_if_fail (po->playbin != NULL, TRUE); - - msg_type = GST_MESSAGE_TYPE (message); - - switch (msg_type) { - case GST_MESSAGE_ERROR: - gst_element_set_state (po->playbin, GST_STATE_NULL); - break; - case GST_MESSAGE_EOS: - gst_element_set_state (po->playbin, GST_STATE_READY); - break; - case GST_MESSAGE_STATE_CHANGED: - { - GstState old_state, new_state; - - if (GST_MESSAGE_SRC (message) != GST_OBJECT (po->playbin)) - break; - - gst_message_parse_state_changed (message, &old_state, &new_state, NULL); - - if (old_state == new_state) - break; - - if (po->play_button) - gtk_widget_set_sensitive (po->play_button, new_state <= GST_STATE_PAUSED); - if (po->pause_button) - gtk_widget_set_sensitive (po->pause_button, new_state > GST_STATE_PAUSED); - if (po->stop_button) - gtk_widget_set_sensitive (po->stop_button, new_state >= GST_STATE_PAUSED); - } - - break; - default: - break; - } - - return TRUE; -} - -static void -org_gnome_audio_inline_play_clicked (GtkWidget *button, - EMFormatPURI *puri) -{ - EMFormatInlineAudioPURI *po = (EMFormatInlineAudioPURI *) puri; - GstState cur_state; - - d(printf ("audio inline formatter: play\n")); - - if (!po->filename) { - CamelStream *stream; - CamelDataWrapper *data; - GError *error = NULL; - gint argc = 1; - const gchar *argv [] = { "org_gnome_audio_inline", NULL }; - - /* FIXME this is ugly, we should stream this directly to gstreamer */ - po->filename = e_mktemp ("org-gnome-audio-inline-file-XXXXXX"); - - d(printf ("audio inline formatter: write to temp file %s\n", po->filename)); - - stream = camel_stream_fs_new_with_name (po->filename, O_RDWR | O_CREAT | O_TRUNC, 0600, NULL); - data = camel_medium_get_content (CAMEL_MEDIUM (po->puri.part)); - camel_data_wrapper_decode_to_stream_sync ( - data, stream, NULL, NULL); - camel_stream_flush (stream, NULL, NULL); - g_object_unref (stream); - - d(printf ("audio inline formatter: init gst playbin\n")); - - if (gst_init_check (&argc, (gchar ***) &argv, &error)) { - gchar *uri; - GstBus *bus; - - /* create a disk reader */ - po->playbin = gst_element_factory_make ("playbin", "playbin"); - if (po->playbin == NULL) { - g_printerr ("Failed to create gst_element_factory playbin; check your installation\n"); - return; - - } - - uri = g_filename_to_uri (po->filename, NULL, NULL); - g_object_set (po->playbin, "uri", uri, NULL); - g_free (uri); - org_gnome_audio_inline_set_audiosink (po->playbin); - - bus = gst_element_get_bus (po->playbin); - po->bus_id = gst_bus_add_watch (bus, org_gnome_audio_inline_gst_callback, po); - gst_object_unref (bus); - - } else { - g_printerr ("GStreamer failed to initialize: %s",error ? error->message : ""); - g_error_free (error); - } - } - - gst_element_get_state (po->playbin, &cur_state, NULL, 0); - - if (cur_state >= GST_STATE_PAUSED) { - gst_element_set_state (po->playbin, GST_STATE_READY); - } - - if (po->playbin) { - /* start playing */ - gst_element_set_state (po->playbin, GST_STATE_PLAYING); - } -} - -static GtkWidget * -org_gnome_audio_inline_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 void -write_button_panel (EMFormat *emf, - EMFormatPURI *puri, - CamelStream *stream, - EMFormatWriterInfo *info, - GCancellable *cancellable) -{ - gchar *str; - - str = g_strdup_printf ( - "<object type=\"application/x-org-gnome-audio-inline-button-panel\" " - "width=\"100%%\" height=\"auto\" data=\"%s\" id=\"%s\"></object>", - puri->uri, puri->uri); - camel_stream_write_string (stream, str, cancellable, NULL); - - g_free (str); -} - -static GtkWidget * -org_gnome_audio_inline_button_panel (EMFormat *emf, - EMFormatPURI *puri, - GCancellable *cancellable) -{ - GtkWidget *box; - EMFormatInlineAudioPURI *po = (EMFormatInlineAudioPURI *) puri; - - /* it is OK to call UI functions here, since we are called from UI thread */ - - box = gtk_hbutton_box_new (); - po->play_button = g_object_ref (org_gnome_audio_inline_add_button (box, GTK_STOCK_MEDIA_PLAY, G_CALLBACK (org_gnome_audio_inline_play_clicked), po, TRUE)); - po->pause_button = g_object_ref (org_gnome_audio_inline_add_button (box, GTK_STOCK_MEDIA_PAUSE, G_CALLBACK (org_gnome_audio_inline_pause_clicked), po, FALSE)); - po->stop_button = g_object_ref (org_gnome_audio_inline_add_button (box, GTK_STOCK_MEDIA_STOP, G_CALLBACK (org_gnome_audio_inline_stop_clicked), po, FALSE)); - - gtk_widget_show (box); - - return box; -} - -void -org_gnome_audio_inline_format (gpointer ep, - EMFormatHookTarget *t) -{ - EMFormatInlineAudioPURI *pobj; - gint len; - - len = t->part_id->len; - g_string_append (t->part_id, ".org-gnome-audio-inline-button-panel"); - - d(printf ("audio inline formatter: format classid %s\n", t->part_id->str)); - - pobj = (EMFormatInlineAudioPURI *) em_format_puri_new ( - t->format, sizeof (EMFormatInlineAudioPURI), - t->part, t->part_id->str); - pobj->puri.widget_func = org_gnome_audio_inline_button_panel; - pobj->puri.write_func = write_button_panel; - pobj->puri.part = g_object_ref (t->part); - pobj->puri.is_attachment = TRUE; - pobj->filename = NULL; - pobj->playbin = NULL; - pobj->play_button = NULL; - pobj->stop_button = NULL; - pobj->pause_button = NULL; - pobj->bus_id = 0; - pobj->puri.free = org_gnome_audio_inline_pobject_free; - pobj->target_state = GST_STATE_NULL; - - em_format_add_puri (t->format, (EMFormatPURI *) pobj); - - g_string_truncate (t->part_id, len); -} diff --git a/plugins/audio-inline/org-gnome-audio-inline.eplug.xml b/plugins/audio-inline/org-gnome-audio-inline.eplug.xml deleted file mode 100644 index 06903e796f..0000000000 --- a/plugins/audio-inline/org-gnome-audio-inline.eplug.xml +++ /dev/null @@ -1,100 +0,0 @@ -<?xml version="1.0"?> -<e-plugin-list> - <e-plugin - type="shlib" - id="org.gnome.evolution.plugin.audioInline" - location="@PLUGINDIR@/liborg-gnome-audio-inline@SOEXT@" - _name="Inline Audio" - system_plugin="true"> - - <author name="Radek Doulík" email="rodo@novell.com"/> - <_description> - Play audio attachments directly in mail messages. - </_description> - - <hook class="org.gnome.evolution.mail.format:1.0"> - <group id="EMFormatHTMLDisplay"> - <item - mime_type="audio/ac3" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/x-ac3" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/basic" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/mpeg" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/x-mpeg" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/mpeg3" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/x-mpeg3" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/mp3" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/x-mp3" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/mp4" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/flac" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/x-flac" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/mod" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/x-mod" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/x-wav" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/microsoft-wav" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/x-wma" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="audio/x-ms-wma" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item - mime_type="application/ogg" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - <item mime_type="application/x-ogg" - format="org_gnome_audio_inline_format" - flags="inline_disposition"/> - </group> - </hook> - - </e-plugin> -</e-plugin-list> |