Exemplo n.º 1
0
		/**
     * Constructs a new Packet. The JID address contained in the XML Element may not be
     * validated. When validation can be skipped then stringprep operations will not be performed
     * on the JIDs to verify that addresses are well-formed. However, when validation cannot be
     * skipped then <tt>only</tt> the TO address will be verified. The FROM address is assigned by
     * the server so there is no need to verify it. 
     *
     * @param element the XML Element that contains the packet contents.
     * @param skipValidation true if stringprep should not be applied to the TO address.
     */
		public Packet(XElement element, bool skipValidation) {
			this.element = element;
			// Apply stringprep profiles to the "to" and "from" values.
			string to = element.Attribute("to").Value;
			if (to != null) {
				if (to.Length == 0) {
					// Remove empty TO values
					element.SetAttributeValue("to", null);
				}
				else {
					string[] parts = JID.getParts(to);
					toJID = new JID(parts[0], parts[1], parts[2], skipValidation);
					element.SetAttributeValue("to", toJID.ToString());
				}
			}
			string from = element.Attribute("from").Value;
			if (from != null) {
				if (from.Length == 0) {
					// Remove empty FROM values
					element.SetAttributeValue("from", null);
				}
				else {
					string[] parts = JID.getParts(from);
					fromJID = new JID(parts[0], parts[1], parts[2], true);
					element.SetAttributeValue("from", fromJID.ToString());
				}
			}
		}
Exemplo n.º 2
0
		/**
     * Sets the XMPP address (JID) that the packet comes from. The XMPP protocol
     * often makes the "from" attribute optional, so it does not always need to be set.
     *
     * @param from the XMPP address (JID) that the packet comes from.
     */
		public void setFrom(JID from) {
			fromJID = from;
			if (from == null) {
				element.Add(new XAttribute("from", null));
			}
			else {
				element.Add(new XAttribute("from", from.ToString()));
			}
		}
Exemplo n.º 3
0
		/**
     * Sets the XMPP address (JID) that the packet is address to. The XMPP protocol
     * often makes the "to" attribute optional, so it does not always need to be set.
     *
     * @param to the XMPP address (JID) that the packet is addressed to.
     */
		public void setTo(JID to) {
			toJID = to;
			if (to == null) {
                element.Add(new XAttribute("to", null));
			}
			else {
				element.Add(new XAttribute("to", to.ToString()));
			}
		}
Exemplo n.º 4
0
		/**
     * Sets the XMPP address (JID) that the packet comes from. The XMPP protocol
     * often makes the "from" attribute optional, so it does not always need to be set.
     *
     * @param from the XMPP address (JID) that the packet comes from.
     */
		public void setFrom(string from) {
			// Apply stringprep profiles to value.
			if (from != null) {
				fromJID = new JID(from);
				from = fromJID.ToString();
			} else {
				fromJID = null;
			}
			element.Add(new XAttribute("from", from));
		}
Exemplo n.º 5
0
		/**
     * Sets the XMPP address (JID) that the packet is addressed to. The XMPP protocol
     * often makes the "to" attribute optional, so it does not always need to be set.
     *
     * @param to the XMPP address (JID) that the packet is addressed to.
     */
		public void setTo(String to) {
			// Apply stringprep profiles to value.
			if (to !=  null) {
				toJID = new JID(to);
				to = toJID.ToString();
			} else {
				toJID = null;
			}
			element.Add(new XAttribute("to", to));
		}