~dylanmccall/indicator-sound/notifications-use-new-volume

« back to all changes in this revision

Viewing changes to src/sound-service-dbus.c

  • Committer: Conor Curran
  • Date: 2011-03-07 15:28:40 UTC
  • mfrom: (213.1.2 indicator-sound)
  • Revision ID: conor.curran@canonical.com-20110307152840-ijbi5q7ng542fchj
extra dbus blacklist method added to complete api

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
                                                     gchar* player_name,
75
75
                                                     gboolean blacklist); 
76
76
 
 
77
static gboolean sound_service_dbus_is_blacklisted (SoundServiceDbus* self,
 
78
                                                   gchar* player_name);
77
79
 
78
80
G_DEFINE_TYPE (SoundServiceDbus, sound_service_dbus, G_TYPE_OBJECT);
79
81
 
281
283
                                                           player_name,
282
284
                                                           blacklist);
283
285
    retval =  g_variant_new ("(b)", result);
284
 
  }     
 
286
  }
 
287
  else if (g_strcmp0(method, "IsBlacklisted") == 0) {
 
288
    gchar* player_name;
 
289
    g_variant_get (params, "(s)", &player_name);
 
290
 
 
291
    g_debug ("IsBlacklisted - name %s", player_name);
 
292
    gboolean result = sound_service_dbus_is_blacklisted (service,
 
293
                                                         player_name);
 
294
    retval =  g_variant_new ("(b)", result);
 
295
  }
285
296
  else {
286
297
    g_warning("Calling method '%s' on the sound service but it's unknown", method); 
287
298
  }
296
307
                                                     gboolean blacklist) 
297
308
{
298
309
  g_return_val_if_fail (player_name != NULL, FALSE);
 
310
  g_return_val_if_fail (IS_SOUND_SERVICE_DBUS (self), FALSE);
299
311
 
 
312
  GVariant* the_black_list;
300
313
  gboolean result = FALSE;
301
 
  GSettings* our_settings = NULL;
302
 
  our_settings  = g_settings_new ("com.canonical.indicators.sound");
303
 
  GVariant* the_black_list = g_settings_get_value (our_settings,
304
 
                                                   "blacklisted-media-players");
 
314
  GSettings* our_settings;
305
315
  GVariantIter iter;
306
316
  gchar *str;
307
 
  // Firstly prep new array which will be set on the key.
308
317
  GVariantBuilder builder;
309
 
  
 
318
 
 
319
  our_settings  = g_settings_new ("com.canonical.indicators.sound");
 
320
  the_black_list = g_settings_get_value (our_settings,
 
321
                                         "blacklisted-media-players");  
310
322
  g_variant_iter_init (&iter, the_black_list);
311
323
  g_variant_builder_init(&builder, G_VARIANT_TYPE_STRING_ARRAY);  
312
324
 
373
385
  return result;
374
386
}
375
387
 
 
388
static gboolean sound_service_dbus_is_blacklisted (SoundServiceDbus *self,
 
389
                                                   gchar            *player_name)
 
390
{
 
391
  GSettings    *our_settings;
 
392
  GVariant     *the_black_list;
 
393
  GVariantIter  iter;
 
394
  gchar        *str;
 
395
  gboolean      result = FALSE;
 
396
 
 
397
  g_return_val_if_fail (player_name != NULL, FALSE);
 
398
  g_return_val_if_fail (IS_SOUND_SERVICE_DBUS (self), FALSE);
 
399
 
 
400
  our_settings = g_settings_new ("com.canonical.indicators.sound");
 
401
  the_black_list = g_settings_get_value (our_settings,
 
402
                                         "blacklisted-media-players");
 
403
  g_variant_iter_init (&iter, the_black_list);
 
404
  while (g_variant_iter_next (&iter, "s", &str)){
 
405
    if (g_strcmp0 (player_name, str) == 0) {
 
406
      result = TRUE;
 
407
      g_free (str);
 
408
      break;
 
409
    }
 
410
    g_free (str);
 
411
  }
 
412
 
 
413
  g_object_unref (our_settings);
 
414
  g_variant_unref (the_black_list);
 
415
 
 
416
  return result;
 
417
}
376
418