Example #1
0
 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);
     }
 }
Example #2
0
        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);
        }
Example #3
0
        /// <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);
        }
Example #4
0
 /// <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);
         }
     }
 }
Example #5
0
            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);
                    }
                }
            }
Example #6
0
        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;
        }
Example #7
0
 /// <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);
         }
     }
 }
Example #8
0
 /// <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);
         }
     }
 }
Example #9
0
 public NodeCallback(DiscoManager m, DiscoNodeHandler h, object s)
 {
     manager  = m;
     callback = h;
     state    = s;
 }