Guest User

Untitled

a guest
May 28th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 2.16 KB | None | 0 0
  1. namespace Alm {
  2.  
  3.     [DBus (name = "org.gnome.zeitgeist.Blacklist")]
  4.     interface BlacklistInterface : Object {
  5.  
  6.         public abstract void add_template (string blacklist_id, Variant blacklist_template) throws IOError;
  7.         public abstract HashTable<string, Variant> get_templates () throws IOError;
  8.         public abstract void remove_template(string blacklist_id) throws IOError;
  9.  
  10.         public signal void template_added(string blacklist_id, Variant blacklist_template);
  11.         public signal void template_removed(string blacklist_id, Variant blacklist_template);
  12.     }
  13.  
  14.     public class Blacklist {
  15.  
  16.         private BlacklistInterface blacklist;
  17.         private HashTable<string, Event> blacklists;
  18.  
  19.         // Incognito
  20.         private string incognito_id = "block-all";
  21.         private Event incognito_event = new Event();
  22.  
  23.         public Blacklist () {
  24.  
  25.             blacklist = Bus.get_proxy_sync (BusType.SESSION, "org.gnome.zeitgeist.Engine",
  26.                                             "/org/gnome/zeitgeist/blacklist");
  27.  
  28.             blacklist.template_added.connect(on_template_added);
  29.             blacklist.template_removed.connect(on_template_removed);
  30.         }
  31.  
  32.         public signal void template_added(string blacklist_id, Event blacklist_template);
  33.  
  34.         public signal void template_removed(string blacklist_id, Event blacklist_template);
  35.  
  36.         public signal void incognito_toggled(bool status);
  37.  
  38.         public void add_template (string blacklist_id, Event blacklist_template) {
  39.             blacklist.add_template(blacklist_id, blacklist_template.to_variant());
  40.         }
  41.  
  42.         public HashTable<string, Event> get_templates() {
  43.             HashTable<string, Variant> var_blacklists = blacklist.get_templates();
  44.             blacklists = new HashTable<string, Event>(null, null);
  45.  
  46.             foreach(var val in var_blacklists.get_values()) {
  47.                 //debug("Checking if event is container: %s", (val == null).to_string());
  48.                 debug("Event type: %s", (val.get_type_string()).to_string());
  49.             }
  50.  
  51.             List<string> keys = var_blacklists.get_keys();
  52.             foreach(var key in keys) {
  53.                 debug("Vaiant Key: %s", key);
  54.                 //debug("Checking if event is null: %s", (var_blacklists.get(key) == null).to_string());
  55.                 blacklists.insert(key, new Event.from_variant(var_blacklists.get(key)));
  56.             }
  57.  
  58.             return blacklists;
  59.         }
  60. }
Add Comment
Please, Sign In to add comment