aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-03-23 10:17:41 +0000
committerConor Curran <conor.curran@canonical.com>2011-03-23 10:17:41 +0000
commit6d49a88f63282e4171d82b96177ecd9ca5441f1c (patch)
treed12435b6d66dc895a6745b2664d70baab1a42bea
parent6375d3eb602251a2374944817e34b9695ae50b65 (diff)
parenta82ab70e9e82f09ba3d2446dba1b57ead1bde5f8 (diff)
downloadayatana-indicator-sound-6d49a88f63282e4171d82b96177ecd9ca5441f1c.tar.gz
ayatana-indicator-sound-6d49a88f63282e4171d82b96177ecd9ca5441f1c.tar.bz2
ayatana-indicator-sound-6d49a88f63282e4171d82b96177ecd9ca5441f1c.zip
protection against rogue dbusmenu properties
-rw-r--r--src/playlists-menu-item.vala2
-rw-r--r--src/slider-menu-item.c15
-rw-r--r--src/sound-service.c2
-rw-r--r--src/voip-input-menu-item.c5
-rw-r--r--src/voip-input-widget.c7
-rw-r--r--src/volume-widget.c58
6 files changed, 49 insertions, 40 deletions
diff --git a/src/playlists-menu-item.vala b/src/playlists-menu-item.vala
index 79ab506..782b5a2 100644
--- a/src/playlists-menu-item.vala
+++ b/src/playlists-menu-item.vala
@@ -80,7 +80,7 @@ public class PlaylistsMenuitem : PlayerItem
if (this.root_item.property_get (MENUITEM_PATH) == item.property_get (MENUITEM_PATH)){
this.root_item.property_set (MENUITEM_PROP_LABEL, _("Choose Playlist"));
}
- this.root_item.child_delete (item);
+ this.root_item.child_delete (item);
}
}
}
diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c
index d7d08fb..8186fa3 100644
--- a/src/slider-menu-item.c
+++ b/src/slider-menu-item.c
@@ -69,9 +69,6 @@ slider_menu_item_class_init (SliderMenuItemClass *klass)
static void
slider_menu_item_init (SliderMenuItem *self)
{
-/*
- g_debug("Building new Slider Menu Item");
-*/
dbusmenu_menuitem_property_set( DBUSMENU_MENUITEM(self),
DBUSMENU_MENUITEM_PROP_TYPE,
DBUSMENU_VOLUME_MENUITEM_TYPE );
@@ -108,11 +105,13 @@ handle_event (DbusmenuMenuitem * mi,
SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (SLIDER_MENU_ITEM (mi));
gdouble volume_input = g_variant_get_double (value);
+
/*
g_debug ("slider menu item handle event with value %f on name %s",
volume_input,
name);
*/
+
slider_menu_item_update_volume (SLIDER_MENU_ITEM (mi), volume_input);
device_ensure_sink_is_unmuted (priv->a_sink);
}
@@ -135,7 +134,7 @@ slider_menu_item_populate (SliderMenuItem* self, const pa_sink_info* update)
dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
DBUSMENU_VOLUME_MENUITEM_LEVEL,
new_volume);
- GVariant* new_mute_update = g_variant_new_int32 (update->mute);
+ GVariant* new_mute_update = g_variant_new_boolean (update->mute == 1);
dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
DBUSMENU_VOLUME_MENUITEM_MUTE,
new_mute_update);
@@ -147,6 +146,7 @@ slider_menu_item_populate (SliderMenuItem* self, const pa_sink_info* update)
static void
slider_menu_item_update_volume (SliderMenuItem* self, gdouble percent)
{
+
/*
g_debug ("slider menu item update volume - about to set the volume to %f", percent);
*/
@@ -177,18 +177,21 @@ slider_menu_item_update (SliderMenuItem* self, const pa_sink_info* update)
gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
GVariant* new_volume = g_variant_new_double (volume_percent);
+
/*
g_debug ("slider menu item update - volume update to ui to %f", volume_percent);
*/
+
dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
DBUSMENU_VOLUME_MENUITEM_LEVEL,
new_volume);
+
if (priv->mute != update->mute){
priv->mute = update->mute;
/*
g_debug ("volume menu item - update - mute on ui = %i", update->mute);
*/
- GVariant* new_mute_update = g_variant_new_int32 (update->mute);
+ GVariant* new_mute_update = g_variant_new_boolean (update->mute == 1);
dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
DBUSMENU_VOLUME_MENUITEM_MUTE,
new_mute_update);
@@ -241,4 +244,4 @@ slider_menu_item_new (Device* sink)
SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self);
priv->a_sink = sink;
return self;
-} \ No newline at end of file
+}
diff --git a/src/sound-service.c b/src/sound-service.c
index 7e6426c..1324537 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -22,6 +22,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "sound-service-dbus.h"
#include "music-player-bridge.h"
+#include <locale.h>
+
static GMainLoop *mainloop = NULL;
/**********************************************************************************************************************/
diff --git a/src/voip-input-menu-item.c b/src/voip-input-menu-item.c
index a92f91c..e645e69 100644
--- a/src/voip-input-menu-item.c
+++ b/src/voip-input-menu-item.c
@@ -73,7 +73,6 @@ voip_input_menu_item_class_init (VoipInputMenuItemClass *klass)
static void
voip_input_menu_item_init (VoipInputMenuItem *self)
{
- g_debug("Building new Slider Menu Item");
dbusmenu_menuitem_property_set( DBUSMENU_MENUITEM(self),
DBUSMENU_MENUITEM_PROP_TYPE,
DBUSMENU_VOIP_INPUT_MENUITEM_TYPE );
@@ -117,7 +116,9 @@ handle_event (DbusmenuMenuitem * mi,
if (value != NULL){
if (IS_VOIP_INPUT_MENU_ITEM (mi)) {
VoipInputMenuItemPrivate* priv = VOIP_INPUT_MENU_ITEM_GET_PRIVATE (VOIP_INPUT_MENU_ITEM (mi));
+/*
g_debug ("Handle event in the voip input level backend instance - %f", percent);
+*/
pa_cvolume new_volume;
pa_cvolume_init(&new_volume);
new_volume.channels = 1;
@@ -167,7 +168,9 @@ voip_input_menu_item_update (VoipInputMenuItem* item,
// Only send over the mute updates if the state has changed.
// in this order - volume first mute last!!
if (priv->mute != source->mute){
+/*
g_debug ("voip menu item - update - mute = %i", priv->mute);
+*/
GVariant* new_mute_update = g_variant_new_int32 (source->mute);
dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(item),
DBUSMENU_VOIP_INPUT_MENUITEM_MUTE,
diff --git a/src/voip-input-widget.c b/src/voip-input-widget.c
index dcf858e..1b36496 100644
--- a/src/voip-input-widget.c
+++ b/src/voip-input-widget.c
@@ -141,6 +141,7 @@ voip_input_widget_property_update (DbusmenuMenuitem* item, gchar* property,
}
if(g_ascii_strcasecmp(DBUSMENU_VOIP_INPUT_MENUITEM_MUTE, property) == 0){
if(priv->grabbed == FALSE){
+ g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_INT32));
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_voip_input_slider);
GtkRange *range = (GtkRange*)slider;
gint update = g_variant_get_int32 (value);
@@ -149,8 +150,10 @@ voip_input_widget_property_update (DbusmenuMenuitem* item, gchar* property,
level = 0;
}
else{
- level = g_variant_get_double (dbusmenu_menuitem_property_get_variant (priv->twin_item,
- DBUSMENU_VOIP_INPUT_MENUITEM_LEVEL));
+ GVariant* variant = dbusmenu_menuitem_property_get_variant (priv->twin_item,
+ DBUSMENU_VOIP_INPUT_MENUITEM_LEVEL);
+ g_return_if_fail (g_variant_is_of_type (variant, G_VARIANT_TYPE_DOUBLE));
+ level = g_variant_get_double (variant);
}
gtk_range_set_value(range, level);
diff --git a/src/volume-widget.c b/src/volume-widget.c
index a54441c..e8e7bae 100644
--- a/src/volume-widget.c
+++ b/src/volume-widget.c
@@ -128,48 +128,48 @@ static void
volume_widget_property_update( DbusmenuMenuitem* item, gchar* property,
GVariant* value, gpointer userdata)
{
- g_return_if_fail (IS_VOLUME_WIDGET (userdata));
+ g_return_if_fail (IS_VOLUME_WIDGET(userdata));
VolumeWidget* mitem = VOLUME_WIDGET(userdata);
VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem);
+
if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_LEVEL, property) == 0){
g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_DOUBLE) );
if(priv->grabbed == FALSE){
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
GtkRange *range = (GtkRange*)slider;
gdouble update = g_variant_get_double (value);
+ gtk_range_set_value(range, update);
/*
- g_debug ("volume widget volume prop update with %f", update);
+ g_debug ("volume-widget::volume_widget_property_update - volume - value %f", update);
*/
- gtk_range_set_value(range, update);
update_accessible_desc(priv->indicator);
}
}
- if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_MUTE, property) == 0){
-/*
- g_debug ("volume widget - mute update ");
-*/
- g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_INT32) );
+ else if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_MUTE, property) == 0){
+ g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN));
if(priv->grabbed == FALSE){
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
GtkRange *range = (GtkRange*)slider;
- gint update = g_variant_get_int32 (value);
+ gboolean update = g_variant_get_boolean (value);
gdouble level;
-/*
- g_debug ("volume widget - mute update %i", update);
-*/
-
- if (update == 1){
+ if (update == TRUE){
level = 0;
}
else{
- level = g_variant_get_double (dbusmenu_menuitem_property_get_variant (priv->twin_item,
- DBUSMENU_VOLUME_MENUITEM_LEVEL));
+ GVariant* variant = dbusmenu_menuitem_property_get_variant (priv->twin_item,
+ DBUSMENU_VOLUME_MENUITEM_LEVEL);
+/*
+ g_debug ("variant for the volume - is it null = %i", variant == NULL);
+*/
+ g_return_if_fail (g_variant_is_of_type (variant, G_VARIANT_TYPE_DOUBLE) );
+
+ level = g_variant_get_double (variant);
}
- gtk_range_set_value(range, level);
/*
- g_debug ("volume-widget - update mute with value %i", update);
+ g_debug ("volume-widget::volume_widget_property_update - mute - value %i and level = %f", update, level);
*/
+ gtk_range_set_value(range, level);
}
}
}
@@ -185,13 +185,13 @@ volume_widget_set_twin_item(VolumeWidget* self,
G_CALLBACK(volume_widget_property_update), self);
gdouble initial_level = g_variant_get_double (dbusmenu_menuitem_property_get_variant(twin_item,
DBUSMENU_VOLUME_MENUITEM_LEVEL));
- gint initial_mute = g_variant_get_int32 (dbusmenu_menuitem_property_get_variant(twin_item,
- DBUSMENU_VOLUME_MENUITEM_MUTE));
+ gboolean initial_mute = g_variant_get_boolean (dbusmenu_menuitem_property_get_variant(twin_item,
+ DBUSMENU_VOLUME_MENUITEM_MUTE));
//g_debug("volume_widget_set_twin_item initial level = %f", initial_level);
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
GtkRange *range = (GtkRange*)slider;
- if(initial_mute == 1){
+ if(initial_mute == TRUE){
initial_level = 0;
}
gtk_range_set_value(range, initial_level);
@@ -206,9 +206,11 @@ volume_widget_change_value_cb (GtkRange *range,
{
g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE);
VolumeWidget* mitem = VOLUME_WIDGET(user_data);
+
/*
g_debug ("changed value %f", new_value);
*/
+
volume_widget_update(mitem, new_value, "change-value");
return FALSE;
}
@@ -222,22 +224,18 @@ volume_widget_value_changed_cb (GtkRange *range, gpointer user_data)
{
g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE);
- VolumeWidget* mitem = VOLUME_WIDGET(user_data);
+ VolumeWidget* mitem = VOLUME_WIDGET (user_data);
VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem);
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
gdouble current_value = CLAMP(gtk_range_get_value(GTK_RANGE(slider)), 0, 100);
-/*
- g_debug ("value changed %f", gtk_range_get_value(GTK_RANGE(slider)));
-*/
-
- gint mute = g_variant_get_int32 (dbusmenu_menuitem_property_get_variant (priv->twin_item,
- DBUSMENU_VOLUME_MENUITEM_MUTE));
- if((current_value == 0 && mute != 1) || current_value == 100){
+ gboolean mute = g_variant_get_boolean (dbusmenu_menuitem_property_get_variant (priv->twin_item,
+ DBUSMENU_VOLUME_MENUITEM_MUTE));
+ if((current_value == 0 && mute == FALSE) || current_value == 100){
/*
g_debug ("value changed - actual set %f", current_value);
*/
- volume_widget_update(mitem, current_value, "value-changed");
+ volume_widget_update (mitem, current_value, "value-changed");
}
return FALSE;