Example #1
0
        void ReceivedItems(DiscoManager manager, DiscoNode node, object state)
        {
            string jid = node.JID.ToString();
            string nodeName = String.Empty;
            if (node.Node != null)
                nodeName = node.Node;

            string templateContent = Util.ReadResource("ServiceDiscovery.html");
            Template template = new Template(templateContent);
            template.SetField("NAME", jid);
            template.SetField("HREF", String.Format("xmpp:{0}?disco", jid));
            template.SetField("NODE", nodeName);

            template.SelectSection("FEATURES");
            foreach (var feature in node.FeatureNames) {
                template.SetField("FEATURE_NAME", feature);
                template.AppendSection();
            }
            template.DeselectSection();

            template.SelectSection("ITEMS");
            foreach (DiscoNode item in node.Children) {
                template.SetField("ITEM_NAME", item.Name);
                template.SetField("ITEM_URL", String.Format("xmpp:{0}?disco;node={1}", item.JID.ToString(), item.Node));
                template.AppendSection();
            }
            template.DeselectSection();

            template.SelectSection("IDENTITIES");
            foreach (var identity in node.GetIdentities()) {
                template.SetField("IDENTITY_NAME", identity.Name);
                template.SetField("IDENTITY_CATEGORY", identity.Category);
                template.SetField("IDENTITY_TYPE", identity.Type);
                template.AppendSection();
            }
            template.DeselectSection();

            QApplication.Invoke(delegate {
                Uri uri = new Uri(String.Format("xmpp:{0}?disco;node={1}", node.JID.ToString(), node.Node));
                LoadContent(uri, template.getContent());
            });
        }