public void ToggleSignal(string iface, string member, Delegate dlg, bool adding) { MatchRule rule = new MatchRule(); rule.MessageType = MessageType.Signal; rule.Fields.Add(FieldCode.Interface, new MatchTest(iface)); rule.Fields.Add(FieldCode.Member, new MatchTest(member)); rule.Fields.Add(FieldCode.Path, new MatchTest(object_path)); // FIXME: Cause a regression compared to 0.6 as name wasn't matched before // the problem arises because busname is not used by DBus daemon and // instead it uses the canonical name of the sender (i.e. similar to ':1.13') // rule.Fields.Add (FieldCode.Sender, new MatchTest (bus_name)); if (adding) { if (conn.Handlers.ContainsKey(rule)) { conn.Handlers[rule] = Delegate.Combine(conn.Handlers[rule], dlg); } else { conn.Handlers[rule] = dlg; conn.AddMatch(rule.ToString()); } } else if (conn.Handlers.ContainsKey(rule)) { conn.Handlers[rule] = Delegate.Remove(conn.Handlers[rule], dlg); if (conn.Handlers[rule] == null) { conn.RemoveMatch(rule.ToString()); conn.Handlers.Remove(rule); } } }
public void ToggleSignal(string iface, string member, Delegate dlg, bool adding) { MatchRule rule = new MatchRule(); rule.MessageType = MessageType.Signal; rule.Fields.Add(FieldCode.Interface, new MatchTest(iface)); rule.Fields.Add(FieldCode.Member, new MatchTest(member)); rule.Fields.Add(FieldCode.Path, new MatchTest(object_path)); // FIXME: Cause a regression compared to 0.6 as name wasn't matched before // the problem arises because busname is not used by DBus daemon and // instead it uses the canonical name of the sender (i.e. similar to ':1.13') if (IsUniqueName(bus_name)) { rule.Fields.Add(FieldCode.Sender, new MatchTest(bus_name)); } else { Console.Error.WriteLine("Warning: Registering handler for signal on object without unique name ({0}), this will receive signals from all senders", bus_name); } if (adding) { if (conn.Handlers.ContainsKey(rule)) { conn.Handlers[rule] = Delegate.Combine(conn.Handlers[rule], dlg); } else { conn.Handlers[rule] = dlg; conn.AddMatch(rule.ToString()); } } else if (conn.Handlers.ContainsKey(rule)) { conn.Handlers[rule] = Delegate.Remove(conn.Handlers[rule], dlg); if (conn.Handlers[rule] == null) { conn.RemoveMatch(rule.ToString()); conn.Handlers.Remove(rule); } } }