[Xfce4-commits] <parole:master> Reserve plugin dbus name based on socket id to distinguish which plugin to shutdown when needed.
Ali Abdallah
noreply at xfce.org
Tue Nov 17 15:02:01 CET 2009
Updating branch refs/heads/master
to dc92c89c56848596c374c265a98b26fcaafd7262 (commit)
from 8d0543c88805348e4b188908bebd771211679ff6 (commit)
commit dc92c89c56848596c374c265a98b26fcaafd7262
Author: Ali Abdallah <ali at ali-xfce.org>
Date: Tue Nov 17 14:57:05 2009 +0100
Reserve plugin dbus name based on socket id to
distinguish which plugin to shutdown when needed.
browser-plugin/media-plugin/main.c | 9 ++++
browser-plugin/media-plugin/parole-gst.c | 6 +--
browser-plugin/parole-plugin.cpp | 60 +++++++++++++++++-------------
3 files changed, 45 insertions(+), 30 deletions(-)
diff --git a/browser-plugin/media-plugin/main.c b/browser-plugin/media-plugin/main.c
index 4039cdc..34fbdd7 100644
--- a/browser-plugin/media-plugin/main.c
+++ b/browser-plugin/media-plugin/main.c
@@ -36,6 +36,8 @@
#include "parole-gst.h"
+#include "common/parole-dbus.h"
+
static gboolean
parole_terminate (GtkWidget *widget, GdkEvent *ev, ParoleGst *gst)
{
@@ -51,6 +53,7 @@ int main (int argc, char **argv)
GOptionContext *ctx;
GOptionGroup *gst_option_group;
GError *error = NULL;
+ gchar *dbus_name;
GOptionEntry option_entries[] =
{
@@ -92,6 +95,11 @@ int main (int argc, char **argv)
g_option_context_free (ctx);
{
+ dbus_name = g_strdup_printf ("org.Parole.Media.Plugin%d", socket_id);
+ parole_dbus_register_name (dbus_name);
+ }
+
+ {
GtkWidget *box;
GtkWidget *plug;
GtkWidget *gst;
@@ -118,6 +126,7 @@ int main (int argc, char **argv)
gtk_main ();
g_signal_handler_disconnect (plug, sig_id);
gtk_widget_destroy (plug);
+ parole_dbus_release_name (dbus_name);
}
gst_deinit ();
diff --git a/browser-plugin/media-plugin/parole-gst.c b/browser-plugin/media-plugin/parole-gst.c
index e308e50..8151633 100644
--- a/browser-plugin/media-plugin/parole-gst.c
+++ b/browser-plugin/media-plugin/parole-gst.c
@@ -647,8 +647,6 @@ parole_gst_init (ParoleGst *gst)
gst->priv = PAROLE_GST_GET_PRIVATE (gst);
- parole_dbus_register_name ("org.Parole.Media.Plugin");
-
gst->priv->state = GST_STATE_VOID_PENDING;
gst->priv->target = GST_STATE_VOID_PENDING;
@@ -705,8 +703,6 @@ parole_gst_finalize (GObject *object)
gst = PAROLE_GST (object);
- parole_dbus_release_name ("org.Parole.Media.Plugin");
-
g_object_unref (gst->priv->playbin);
if ( gst->priv->tick_id != 0)
@@ -779,6 +775,8 @@ static gboolean
parole_gst_dbus_quit (ParoleGst *gst,
GError **error)
{
+ g_debug ("Quit message received");
+
parole_gst_terminate (gst);
return TRUE;
diff --git a/browser-plugin/parole-plugin.cpp b/browser-plugin/parole-plugin.cpp
index d6a986c..bf5f4ca 100644
--- a/browser-plugin/parole-plugin.cpp
+++ b/browser-plugin/parole-plugin.cpp
@@ -102,6 +102,15 @@ NPError ParolePlugin::NewStream (NPMIMEType type, NPStream *stream,
g_free (socket);
g_free (app);
+
+ bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+
+ if ( error )
+ {
+ g_critical ("%s : ", error->message);
+ g_error_free (error);
+ return NPERR_GENERIC_ERROR;
+ }
}
return NPERR_NO_ERROR;
@@ -109,44 +118,43 @@ NPError ParolePlugin::NewStream (NPMIMEType type, NPStream *stream,
ParolePlugin::ParolePlugin (NPP pNPInstance)
{
- GError *error = NULL;
-
g_debug ("Constructor");
window_set = FALSE;
url = NULL;
bus = NULL;
proxy = NULL;
-
- bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
-
- if ( error )
- {
- g_critical ("%s : ", error->message);
- g_error_free (error);
- return;
- }
-
- proxy = dbus_g_proxy_new_for_name (bus,
- "org.Parole.Media.Plugin",
- "/org/Parole/Media/Plugin",
- "org.Parole.Media.Plugin");
-
- if ( !proxy )
- g_critical ("Unable to create proxy for 'org.Parole.Media.Plugin'");
}
ParolePlugin::~ParolePlugin ()
{
- if ( url )
- g_free (url);
g_debug ("Destructor");
-
- if ( proxy )
+ if ( bus )
{
- dbus_g_proxy_call_no_reply (proxy, "Quit",
- G_TYPE_INVALID,
- G_TYPE_INVALID);
+ if ( window_set )
+ {
+ gchar *dbus_name;
+ dbus_name = g_strdup_printf ("org.Parole.Media.Plugin%ld", window);
+
+ proxy = dbus_g_proxy_new_for_name (bus,
+ dbus_name,
+ "/org/Parole/Media/Plugin",
+ "org.Parole.Media.Plugin");
+
+ if ( !proxy )
+ g_critical ("Unable to create proxy for %s", dbus_name);
+ else
+ dbus_g_proxy_call_no_reply (proxy, "Quit",
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+
+ dbus_g_connection_unref (bus);
+ g_free (dbus_name);
+ }
}
+
+ if ( url )
+ g_free (url);
+
}
char *ParolePlugin::PluginName (void)
More information about the Xfce4-commits
mailing list