public void GotRootItems(DiscoManager manager, DiscoNode node, object state) { m_outstanding = node.Children.Count; foreach (DiscoNode n in node.Children) { manager.BeginGetFeatures(n, new DiscoNodeHandler(GotFeatures), state); } }
public void setup() { mocks = new MockRepository(); dm = new DiscoManager(); stream = mocks.DynamicMock<XmppStream>(); tracker = mocks.DynamicMock<IIQTracker>(); dm.Stream = stream; doc = new XmlDocument(); }
internal DiscoNode AddItem(DiscoManager manager, DiscoItem di) { DiscoNode dn = manager.GetNode(di.Jid, di.Node); if ((di.Named != null) && (di.Named != "")) { dn.Name = di.Named; } Children.Add(dn); return(dn); }
private void GotRoot(DiscoManager sender, DiscoNode node, object state) { if (node.Children != null) { foreach (DiscoNode component in node.Children) { if (component.HasFeature(Jabber.Protocol.URI.MUC)) cmbJID.Items.Add(component.JID); } if (cmbJID.Items.Count > 0) cmbJID.SelectedIndex = 0; } cmbJID.EndUpdate(); }
/// <summary> /// Adds the given items to the cache. /// </summary> /// <param name="manager">The DiscoManager used to create/cache nodes</param> /// <param name="items">Items to add.</param> public void AddItems(DiscoManager manager, DiscoItem[] items) { if (Children == null) { Children = new Set(); } // items may be null when used from outside. if (items != null) { foreach (DiscoItem di in items) { AddItem(manager, di); } } DoCallbacks(m_itemCallbacks); }
/// <summary> /// Add a callback for when identities are received. /// /// Calls the callback immediately if the features have already been retrieved. /// </summary> /// <param name="manager"></param> /// <param name="callback"></param> /// <param name="state"></param> /// <returns>True if there were no identities yet, and the callback was queued.</returns> public bool AddIdentityCallback(DiscoManager manager, DiscoNodeHandler callback, object state) { lock (this) { if (Identities != null) { if (callback != null) { callback(manager, this, state); } return(false); } else { m_identCallbacks.Add(new NodeCallback(manager, callback, state)); return(true); } } }
public void GotFeatures(DiscoManager manager, DiscoNode node, object state) { // yes, yes, this may call the handler more than once in multi-threaded world. Punt for now. if (m_handler != null) { if (node.HasFeature(m_URI)) { m_handler(manager, node, state); m_handler = null; } } if (Interlocked.Decrement(ref m_outstanding) == 0) { if (m_handler != null) { m_handler(manager, null, state); } } }
private void GotCaps(DiscoManager m, DiscoNode node, object state) { // timeout if (node == null) { return; } string ver = (string)state; string calc = CalculateVer(node); if (ver != calc) { Debug.WriteLine("WARNING: invalid caps ver hash: '" + ver + "' != '" + calc + "'"); if (node.Info != null) { Debug.WriteLine(node.Info.OuterXml); } return; } m_cache[ver] = node.Info; }
/// <summary> /// Add a callback for when items are received. /// /// Calls the callback immediately if the items have already been retrieved. /// </summary> /// <param name="manager"></param> /// <param name="callback"></param> /// <param name="state"></param> /// <returns>True if there were no items yet, and the callback was queued.</returns> public bool AddItemsCallback(DiscoManager manager, DiscoNodeHandler callback, object state) { lock (this) { if (Children != null) { if (callback != null) { callback(manager, this, state); } return(false); } else { if (callback != null) { m_itemCallbacks.Add(new NodeCallback(manager, callback, state)); } return(true); } } }
/// <summary> /// Add a callback for when features are received. /// /// Calls the callback immediately if the features have already been retrieved. /// </summary> /// <param name="manager"></param> /// <param name="callback"></param> /// <param name="state"></param> /// <returns>True if there were no features yet, and the callback was queued.</returns> public bool AddFeatureCallback(DiscoManager manager, DiscoNodeHandler callback, object state) { lock (this) { if (Features != null) { if (callback != null) { callback(manager, this, state); } return(false); } else { if (callback != null) { m_featureCallbacks.Add(new NodeCallback(manager, callback, state)); } return(true); } } }
internal DiscoNode AddItem(DiscoManager manager, DiscoItem di) { DiscoNode dn = manager.GetNode(di.Jid, di.Node); if ((di.Named != null) && (di.Named != "")) dn.Name = di.Named; Children.Add(dn); return dn; }
/// <summary> /// Add a callback for when identities are received. /// /// Calls the callback immediately if the features have already been retrieved. /// </summary> /// <param name="manager"></param> /// <param name="callback"></param> /// <param name="state"></param> /// <returns>True if there were no identities yet, and the callback was queued.</returns> public bool AddIdentityCallback(DiscoManager manager, DiscoNodeHandler callback, object state) { lock (this) { if (Identities != null) { if (callback != null) callback(manager, this, state); return false; } else { m_identCallbacks.Add(new NodeCallback(manager, callback, state)); return true; } } }
/// <summary> /// Add a callback for when items are received. /// /// Calls the callback immediately if the items have already been retrieved. /// </summary> /// <param name="manager"></param> /// <param name="callback"></param> /// <param name="state"></param> /// <returns>True if there were no items yet, and the callback was queued.</returns> public bool AddItemsCallback(DiscoManager manager, DiscoNodeHandler callback, object state) { lock (this) { if (Children != null) { if (callback != null) callback(manager, this, state); return false; } else { if (callback != null) m_itemCallbacks.Add(new NodeCallback(manager, callback, state)); return true; } } }
/// <summary> /// Add a callback for when features are received. /// /// Calls the callback immediately if the features have already been retrieved. /// </summary> /// <param name="manager"></param> /// <param name="callback"></param> /// <param name="state"></param> /// <returns>True if there were no features yet, and the callback was queued.</returns> public bool AddFeatureCallback(DiscoManager manager, DiscoNodeHandler callback, object state) { lock (this) { if (Features != null) { if (callback != null) callback(manager, this, state); return false; } else { if (callback != null) m_featureCallbacks.Add(new NodeCallback(manager, callback, state)); return true; } } }
public NodeCallback(DiscoManager m, DiscoNodeHandler h, object s) { manager = m; callback = h; state = s; }
public void GotRootItems(DiscoManager manager, DiscoNode node, object state) { m_outstanding = node.Children.Count; foreach (DiscoNode n in node.Children) manager.BeginGetFeatures(n, new DiscoNodeHandler(GotFeatures), state); }
private void GotItems(DiscoManager sender, Jabber.Connection.DiscoNode node, object state) { // TODO: some of this will break in 2003. TreeNode[] nodes = tvServices.Nodes.Find(node.Key, true); foreach (TreeNode n in nodes) { n.ImageIndex = 7; n.SelectedImageIndex = 7; foreach (Jabber.Connection.DiscoNode dn in node.Children) { TreeNode tn = n.Nodes.Add(dn.Key, dn.Name); tn.ToolTipText = dn.Key.Replace('\u0000', '\n'); tn.Tag = dn; tn.ImageIndex = 8; tn.SelectedImageIndex = 8; } } pgServices.Refresh(); }
private void GotInfo(DiscoManager sender, Jabber.Connection.DiscoNode node, object state) { pgServices.SelectedObject = node; }
/// <summary> /// Adds the given items to the cache. /// </summary> /// <param name="manager">The DiscoManager used to create/cache nodes</param> /// <param name="items">Items to add.</param> public void AddItems(DiscoManager manager, DiscoItem[] items) { if (Children == null) Children = new Set(); // items may be null when used from outside. if (items != null) { foreach (DiscoItem di in items) AddItem(manager, di); } DoCallbacks(m_itemCallbacks); }
public void GotFeatures(DiscoManager manager, DiscoNode node, object state) { // yes, yes, this may call the handler more than once in multi-threaded world. Punt for now. if (m_handler != null) { if (node.HasFeature(m_URI)) { m_handler(manager, node, state); m_handler = null; } } if (Interlocked.Decrement(ref m_outstanding) == 0) { if (m_handler != null) m_handler(manager, null, state); } }
public void IntialDiscoTest() { IEventRaiser onAuth; IQ sentIq = null; IqCB sentCallback = null; mocks.BackToRecordAll(); using (mocks.Record()) { Expect.Call(stream.Server).Return(jid); stream.OnAuthenticate += null; onAuth = LastCall.IgnoreArguments().GetEventRaiser(); Expect.Call(stream.Document).Return(doc); SetupTrackerBeginIq( delegate(IQ arg0, IqCB arg1, object arg2) { // Grab the iq and callback so this part of // the code can finish. Call the callback later. sentIq = arg0; sentCallback = arg1; string id = arg0.GetAttribute("id"); string original = arg0.OuterXml.Replace(" ", ""); string comparison = GetInfoXml(id).Replace(" ", ""); return original == comparison; }); Expect.Call(stream.Document).Return(doc); SetupTrackerBeginIq( delegate(IQ arg0, IqCB arg1, object arg2) { string id = arg0.GetAttribute("id"); string original = arg0.OuterXml; return original.Replace(" ", "") == GetItemsForServiceXml(id).Replace(" ", ""); }); } using (mocks.Playback()) { DiscoManager newDm = new DiscoManager(); newDm.Stream = stream; onAuth.Raise(new object[] { null }); if (sentIq != null) { string id = sentIq.GetAttribute("id"); if (sentCallback != null) sentCallback(null, CreateDiscoInfoResponse(id), newDm.Root); } } }
private void GotCaps(DiscoManager m, DiscoNode node, object state) { // timeout if (node == null) return; string ver = (string)state; string calc = CalculateVer(node); if (ver != calc) { Debug.WriteLine("WARNING: invalid caps ver hash: '" + ver + "' != '" + calc + "'"); if (node.Info != null) Debug.WriteLine(node.Info.OuterXml); return; } m_cache[ver] = node.Info; }
private void GotInitialFeatures(DiscoManager sender, Jabber.Connection.DiscoNode node, object state) { m_disco.BeginGetItems(node, new Jabber.Connection.DiscoNodeHandler(GotItems), state); }