Example #1
0
 /// <summary>
 /// Creates an offer or result from the specified data-form.
 /// </summary>
 /// <param name="form">The data-form to include in the feature negotiation
 /// offer or result.</param>
 /// <returns>An XML element representing the feature negotiation
 /// offer or result.</returns>
 /// <exception cref="ArgumentNullException">The form parameter is
 /// null.</exception>
 public static XmlElement Create(DataForm form)
 {
     form.ThrowIfNull("form");
     return(Xml.Element("feature",
                        "http://jabber.org/protocol/feature-neg").Child(form.ToXmlElement()));
 }
Example #2
0
        public bool SendRegistration(Jid room, DataForm form)
        {
            Iq iq = im.IqRequest(IqType.Set, room, im.Jid, Xml.Element("query", "jabber:iq:register").Child(form.ToXmlElement()));

            if (iq.Type != IqType.Result)
            {
                throw new NotSupportedException("Could not query features: " + iq);
            }

            return(true);
        }
Example #3
0
        /// <summary>
        /// Submit a serach forms
        /// </summary>
        /// <returns>Search result based on DataForm request</returns>
        public DataForm Search(DataForm search)
        {
            Jid searchDomain = SearchDomain();

            if (searchDomain == null)
            {
                throw new Exception("Feauture not supported");
            }

            Iq iq = im.IqRequest(IqType.Set, searchDomain, im.Jid, Xml.Element("query", xmlns).Child(search.ToXmlElement()));

            if (iq.Type == IqType.Result)
            {
                var query = iq.Data["query"];
                if (query == null || query.NamespaceURI != xmlns)
                {
                    throw new XmppException("Erroneous server response.");
                }

                return(DataFormFactory.Create(query["x"]));
            }
            else
            {
                var error = iq.Data["error"];
                throw new Exception(error["text"].InnerText);
            }
        }