예제 #1
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);
        }
예제 #2
0
        /// <summary>
        /// Builds the send activity box.
        /// </summary>
        /// <param name="it">It.</param>
        /// <remarks></remarks>
        private void BuildSendActivityBox(DiscoItem it, ToolboxCategoryItems items)
        {
            var cat = new ToolboxCategory(it.Contract);
            var ops = MetadataHelper
                      .GetOperationDescriptions(it.Endpoint + "/mex")
                      .First()
                      .DeclaringContract
                      .Operations;
            var httpEndpoint = MetadataHelper
                               .GetEndpoints(it.Endpoint + "/mex").FirstOrDefault(x => x.Address.Uri.Scheme == Uri.UriSchemeHttp);

            AddOperationsToCategory(httpEndpoint, ops, cat);
            items.Add(cat);
        }
예제 #3
0
        /// <summary>
        /// To the disco information.
        /// </summary>
        /// <param name="target">The target.</param>
        /// <returns>DiscoInfo.</returns>
        public static DiscoInfo ToDiscoInfo(this DiscoItem target)
        {
            var ep = new Uri(target.Endpoint);

            return(new DiscoInfo()
            {
                Layer = GetLayer(ep.Segments),
                Application = GetApplication(ep.Segments),
                Service = GetService(ep.Segments),
                Host = ep.DnsSafeHost,
                Port = Convert.ToString(ep.Port),
                Protocol = ep.Scheme,
                Contract = target.Contract,
                Endpoint = target.Endpoint
            });
        }
예제 #4
0
        /// <summary>
        /// Creates the error address.
        /// </summary>
        /// <param name="it">It.</param>
        /// <param name="exp">The exp.</param>
        /// <returns>DiscoItem.</returns>
        private DiscoItem CreateErrorAddress(EndpointDiscoveryMetadata it, Exception exp)
        {
            try
            {
                var edi = new DiscoItem()
                {
                    Id       = Guid.NewGuid().ToString(),
                    Endpoint = exp.Message,
                    Contract = "Error in Service",
                };
                edi.AddError(exp.Message);
                if (exp.InnerException != null)
                {
                    edi.AddError(String.Format("Inner: {0}", exp.InnerException.Message));
                }
                return(edi);
            }
            catch (Exception exep)
            {
                FxLog <Discos> .LogException(exep);

                return(null);
            }
        }
예제 #5
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);
        }
예제 #6
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;
 }
예제 #7
0
        private void GotAgents(object sender, IQ iq, object onode)
        {
            DiscoNode dn = onode as DiscoNode;
            Debug.Assert(dn != null);

            if (iq.Type != IQType.result)
            {
                dn.AddItems(this, null);
                return;
            }

            AgentsQuery aq = iq.Query as AgentsQuery;
            if (aq == null)
            {
                dn.AddItems(this, null);
                return;
            }

            if (dn.Children == null)
                dn.Children = new Set();

            foreach (Agent agent in aq.GetAgents())
            {
                DiscoItem di = new DiscoItem(m_stream.Document);
                di.Jid = agent.JID;
                di.Named = agent.AgentName;

                DiscoNode child = dn.AddItem(this, di);
                if (child.Features == null)
                    child.Features = new StringSet();
                if (child.Identity == null)
                    child.Identity = new Set();

                Ident id = new Ident();
                id.Name = agent.Description;
                switch (agent.Service)
                {
                case "groupchat":
                    id.Category = "conference";
                    id.Type = "text";
                    child.Identity.Add(id);
                    break;
                case "jud":
                    id.Category = "directory";
                    id.Type = "user";
                    child.Identity.Add(id);
                    break;
                case null:
                case "":
                    break;
                default:
                    // guess this is a transport
                    id.Category = "gateway";
                    id.Type = agent.Service;
                    child.Identity.Add(id);
                    break;
                }

                if (agent.Register)
                    child.Features.Add(URI.REGISTER);
                if (agent.Search)
                    child.Features.Add(URI.SEARCH);
                if (agent.Groupchat)
                    child.Features.Add(URI.MUC);
                if (agent.Transport)
                {
                    if (id.Category != "gateway")
                    {
                        Ident tid = new Ident();
                        tid.Name = id.Name;
                        tid.Category = "gateway";
                        child.Identity.Add(tid);
                    }
                }

                foreach (XmlElement ns in agent.GetElementsByTagName("ns"))
                {
                    child.Features.Add(ns.InnerText);
                }
                child.AddItems(this, null);
                child.AddIdentities(null);
                child.AddFeatures((StringSet)null);
            }
            dn.AddItems(this, null);
            dn.AddIdentities(null);
            dn.AddFeatures((StringSet)null);
        }
예제 #8
0
        private void GotAgents(object sender, IQ iq, object onode)
        {
            DiscoNode dn = onode as DiscoNode;

            Debug.Assert(dn != null);

            if (iq.Type != IQType.result)
            {
                dn.AddItems(this, null);
                return;
            }

            AgentsQuery aq = iq.Query as AgentsQuery;

            if (aq == null)
            {
                dn.AddItems(this, null);
                return;
            }

            if (dn.Children == null)
            {
                dn.Children = new Set();
            }

            foreach (Agent agent in aq.GetAgents())
            {
                DiscoItem di = new DiscoItem(m_stream.Document);
                di.Jid   = agent.JID;
                di.Named = agent.AgentName;

                DiscoNode child = dn.AddItem(this, di);
                if (child.Features == null)
                {
                    child.Features = new StringSet();
                }
                if (child.Identity == null)
                {
                    child.Identity = new Set();
                }

                Ident id = new Ident();
                id.Name = agent.Description;
                switch (agent.Service)
                {
                case "groupchat":
                    id.Category = "conference";
                    id.Type     = "text";
                    child.Identity.Add(id);
                    break;

                case "jud":
                    id.Category = "directory";
                    id.Type     = "user";
                    child.Identity.Add(id);
                    break;

                case null:
                case "":
                    break;

                default:
                    // guess this is a transport
                    id.Category = "gateway";
                    id.Type     = agent.Service;
                    child.Identity.Add(id);
                    break;
                }

                if (agent.Register)
                {
                    child.Features.Add(URI.REGISTER);
                }
                if (agent.Search)
                {
                    child.Features.Add(URI.SEARCH);
                }
                if (agent.Groupchat)
                {
                    child.Features.Add(URI.MUC);
                }
                if (agent.Transport)
                {
                    if (id.Category != "gateway")
                    {
                        Ident tid = new Ident();
                        tid.Name     = id.Name;
                        tid.Category = "gateway";
                        child.Identity.Add(tid);
                    }
                }

                foreach (XmlElement ns in agent.GetElementsByTagName("ns"))
                {
                    child.Features.Add(ns.InnerText);
                }
                child.AddItems(this, null);
                child.AddIdentities(null);
                child.AddFeatures((StringSet)null);
            }
            dn.AddItems(this, null);
            dn.AddIdentities(null);
            dn.AddFeatures((StringSet)null);
        }