[totem] Add support for VLC's Playlist.Add options
- From: Bastien Nocera <hadess src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [totem] Add support for VLC's Playlist.Add options
- Date: Wed, 18 Nov 2009 15:56:52 +0000 (UTC)
commit 9efc634b38a7635cd0cb487d81272080897d02e1
Author: Bastien Nocera <hadess hadess net>
Date: Wed Nov 18 15:51:53 2009 +0000
Add support for VLC's Playlist.Add options
Add support for adding items with a subtitle option
in the VLC plugin. Not implemented on the viewer side.
https://bugzilla.gnome.org/show_bug.cgi?id=560946
browser-plugin/org_gnome_totem_PluginViewer.xml | 2 +
browser-plugin/totem-plugin-viewer.c | 17 ++++++++++---
browser-plugin/totemConePlaylist.cpp | 30 ++++++++++++++++++++++-
browser-plugin/totemPlugin.cpp | 26 ++++++++++++++++---
browser-plugin/totemPlugin.h | 2 +-
5 files changed, 67 insertions(+), 10 deletions(-)
---
diff --git a/browser-plugin/org_gnome_totem_PluginViewer.xml b/browser-plugin/org_gnome_totem_PluginViewer.xml
index c7bc92a..e704df6 100644
--- a/browser-plugin/org_gnome_totem_PluginViewer.xml
+++ b/browser-plugin/org_gnome_totem_PluginViewer.xml
@@ -52,6 +52,8 @@
<method name="ClearPlaylist" />
<method name="AddItem">
<arg type="s" name="URI" direction="in" />
+ <arg type="s" name="Title" direction="in" />
+ <arg type="s" name="Subtitle" direction="in" />
</method>
<method name="SetFullscreen">
<arg type="b" name="FullscreenEnabled" direction="in" />
diff --git a/browser-plugin/totem-plugin-viewer.c b/browser-plugin/totem-plugin-viewer.c
index e091cf2..aff21c3 100644
--- a/browser-plugin/totem-plugin-viewer.c
+++ b/browser-plugin/totem-plugin-viewer.c
@@ -94,6 +94,7 @@ typedef GObjectClass TotemEmbeddedClass;
typedef struct {
char *uri;
+ char *subtitle;
char *title;
int duration;
int starttime;
@@ -675,7 +676,8 @@ totem_pl_item_free (gpointer data, gpointer user_data)
return;
g_free (item->uri);
g_free (item->title);
- g_free (item);
+ g_free (item->subtitle);
+ g_slice_free (TotemPlItem, item);
}
static gboolean
@@ -698,14 +700,20 @@ totem_embedded_clear_playlist (TotemEmbedded *emb, GError *error)
}
static gboolean
-totem_embedded_add_item (TotemEmbedded *embedded, const char *uri, GError *error)
+totem_embedded_add_item (TotemEmbedded *embedded,
+ const char *uri,
+ const char *title,
+ const char *subtitle,
+ GError *error)
{
TotemPlItem *item;
g_message ("totem_embedded_add_item: %s", uri);
- item = g_new0 (TotemPlItem, 1);
+ item = g_slice_new0 (TotemPlItem);
item->uri = g_strdup (uri);
+ item->title = g_strdup (title);
+ item->subtitle = g_strdup (subtitle);
item->duration = -1;
item->starttime = -1;
@@ -862,6 +870,7 @@ totem_embedded_open_playlist_item (TotemEmbedded *emb,
bacon_video_widget_close (emb->bvw);
update_fill (emb, -1.0);
+ //FIXME set the title from the URI if possible
totem_embedded_update_title (emb, plitem->title);
if (totem_embedded_open_internal (emb, FALSE, NULL /* FIXME */)) {
if (plitem->starttime > 0) {
@@ -2083,7 +2092,7 @@ entry_parsed (TotemPlParser *parser,
if (duration == 0)
return;
- item = g_new0 (TotemPlItem, 1);
+ item = g_slice_new0 (TotemPlItem);
item->uri = g_strdup (uri);
item->title = g_strdup (g_hash_table_lookup (metadata, TOTEM_PL_PARSER_FIELD_TITLE));
item->duration = duration;
diff --git a/browser-plugin/totemConePlaylist.cpp b/browser-plugin/totemConePlaylist.cpp
index ac53f85..031096f 100644
--- a/browser-plugin/totemConePlaylist.cpp
+++ b/browser-plugin/totemConePlaylist.cpp
@@ -79,7 +79,35 @@ totemConePlaylist::InvokeByIndex (int aIndex,
if (!GetNPStringFromArguments (argv, argc, 0, mrl))
return false;
- Plugin()->AddItem (mrl);
+ NPString title;
+ GetNPStringFromArguments (argv, argc, 1, title);
+
+ NPString options;
+ GetNPStringFromArguments (argv, argc, 2, options);
+ //FIXME handle options as array
+ //http://wiki.videolan.org/Documentation:WebPlugin#Playlist_object
+ char *subtitle = NULL;
+ if (options.UTF8Characters && options.UTF8Length) {
+ char *str, **items;
+ guint i;
+
+ str = g_strndup (options.UTF8Characters, options.UTF8Length);
+ items = g_strsplit (str, " ", -1);
+
+ for (i = 0; items[i] != NULL; i++) {
+ if (g_str_has_prefix (items[i], ":sub-file=")) {
+ subtitle = g_strdup (items[i] + strlen (":sub-file="));
+ g_strfreev (items);
+ g_free (str);
+ break;
+ }
+ }
+ g_strfreev (items);
+ g_free (str);
+ }
+
+ Plugin()->AddItem (mrl, title, subtitle);
+ g_free (subtitle);
return Int32Variant (_result, 0);
}
diff --git a/browser-plugin/totemPlugin.cpp b/browser-plugin/totemPlugin.cpp
index 30dea4b..4e7d999 100644
--- a/browser-plugin/totemPlugin.cpp
+++ b/browser-plugin/totemPlugin.cpp
@@ -371,28 +371,45 @@ totemPlugin::ClearPlaylist ()
}
int32_t
-totemPlugin::AddItem (const NPString& aURI)
+totemPlugin::AddItem (const NPString& aURI,
+ const NPString& aTitle,
+ const char *aSubtitle)
{
+ Dm ("AddItem");
+
if (!aURI.UTF8Characters || !aURI.UTF8Length)
return -1;
/* FIXMEchpe: resolve against mBaseURI or mSrcURI ?? */
/* FIXME: queue the action instead */
- if (!mViewerReady)
+ if (!mViewerReady) {
+ Dm("Viewer not ready in AddItem");
return false;
+ }
assert (mViewerProxy);
char *uri = g_strndup (aURI.UTF8Characters, aURI.UTF8Length);
- D ("AddItem '%s'", uri);
+
+ char *title;
+ if (aTitle.UTF8Characters)
+ title = g_strndup (aTitle.UTF8Characters, aTitle.UTF8Length);
+ else
+ title = NULL;
+
+ D ("AddItem '%s' (title: '%s' sub: '%s')",
+ uri, title ? title : "", aSubtitle ? aSubtitle : "");
dbus_g_proxy_call_no_reply (mViewerProxy,
"AddItem",
G_TYPE_STRING, uri,
+ G_TYPE_STRING, title,
+ G_TYPE_STRING, aSubtitle,
G_TYPE_INVALID,
G_TYPE_INVALID);
g_free (uri);
+ g_free (title);
return 0;
}
@@ -1411,7 +1428,8 @@ totemPlugin::SetRealMimeType (const char *mimetype)
{
for (uint32_t i = 0; i < G_N_ELEMENTS (kMimeTypes); ++i) {
if (strcmp (kMimeTypes[i].mimetype, mimetype) == 0) {
- if (kMimeTypes[i].mime_alias != NULL) {
+ if (kMimeTypes[i].mime_alias != NULL &&
+ strchr (kMimeTypes[i].mime_alias, '/') != NULL) {
mMimeType = g_strdup (kMimeTypes[i].mime_alias);
} else {
mMimeType = g_strdup (mimetype);
diff --git a/browser-plugin/totemPlugin.h b/browser-plugin/totemPlugin.h
index 4f91ed6..e642946 100644
--- a/browser-plugin/totemPlugin.h
+++ b/browser-plugin/totemPlugin.h
@@ -345,7 +345,7 @@ class totemPlugin {
void Command (const char *aCommand);
void ClearPlaylist ();
- int32_t AddItem (const NPString&);
+ int32_t AddItem (const NPString&, const NPString&, const char *aSubtitle);
void SetIsWindowless (bool enabled) { mIsWindowless = enabled; }
bool IsWindowless () const { return mIsWindowless; }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]