public void SendIqerror(agsXMPP.protocol.client.IQ iq) { var ack = new agsXMPP.protocol.client.IQ(agsXMPP.protocol.client.IqType.error, iq.To, iq.From); ack.Attributes["id"] = iq.Attributes["id"]; conn.Send(ack); }
/// <summary> /// Suprimme la notification de ce que j'�coute /// </summary> public void clearTune() { if (Jabber.xmpp.Authenticated && Jabber._pepCapable) { agsXMPP.protocol.client.IQ iq = new agsXMPP.protocol.client.IQ(); iq.Type = agsXMPP.protocol.client.IqType.set; iq.GenerateId(); agsXMPP.Xml.Dom.Element pb = new agsXMPP.Xml.Dom.Element("pubsub"); pb.Namespace = "http://jabber.org/protocol/pubsub"; agsXMPP.Xml.Dom.Element ps = new agsXMPP.Xml.Dom.Element("publish"); ps.Attributes.Add("node", "http://jabber.org/protocol/tune"); agsXMPP.Xml.Dom.Element item = new agsXMPP.Xml.Dom.Element("item"); item.Attributes.Add("id", "current"); agsXMPP.Xml.Dom.Element tune = new agsXMPP.Xml.Dom.Element("tune"); tune.Namespace = "http://jabber.org/protocol/tune"; item.AddChild(tune); ps.AddChild(item); pb.AddChild(ps); iq.AddChild(pb); Jabber.xmpp.Send(iq); _tune = new Tune(); _tune.artist = string.Empty; _tune.length = 0; _tune.rating = 1; _tune.source = string.Empty; _tune.title = string.Empty; _tune.track = 0; _tune.uri = string.Empty; } }
public agsXMPP.protocol.client.IQ BuildJingleIQPacket(string action) { var ack = new agsXMPP.protocol.client.IQ(agsXMPP.protocol.client.IqType.set, iq_from, iq_to); ack.GenerateId(); var jingle = new Element("jingle", null, "urn:xmpp:jingle:1"); ack.AddChild(jingle); jingle.Attributes["action"] = action; jingle.Attributes["initiator"] = jingle_initiator; jingle.Attributes["sid"] = jingle_sid; var content = new Element("content"); content.Attributes["creator"] = "initiator"; content.Attributes["name"] = content_name; jingle.AddChild(content); var transport = new Element("transport", null, "urn:xmpp:jingle:transports:s5b:1"); transport.Attributes["sid"] = transportSid; content.AddChild(transport); return(ack); }
/// <summary> /// make outgoing Jingle Session /// </summary> /// <param name="xmppClient"></param> /// <param name="to"></param> /// <param name="fileName"></param> /// <param name="proxy"></param> /// <param name="proxyPort"></param> public JingleSession(XmppClientConnection xmppClient, string to, string fileName, string proxy, string proxyPort) { selfInitiated = true; localFilespec = fileName; this.conn = xmppClient; iq_to = new Jid(to); iq_from = Program.Jabber.conn.MyJID; content_name = Guid.NewGuid().ToString(); jingle_initiator = iq_from; jingle_sid = Guid.NewGuid().ToString(); transportSid = Guid.NewGuid().ToString(); initiateIq = BuildSessionInitiate(fileName); this.initiateJingle = initiateIq.SelectSingleElement("jingle"); this.contentIn = initiateJingle.SelectSingleElement("content"); this.transportIn = contentIn.SelectSingleElement("transport"); Element candidate = new Element("candidate"); candidate.SetAttribute("priority", "999999"); candidate.SetAttribute("jid", proxy); candidate.SetAttribute("cid", "1000"); candidate.SetAttribute("type", "proxy"); candidate.SetAttribute("host", proxy); candidate.SetAttribute("port", proxyPort); transportIn.AddChild(candidate); conn.Send(initiateIq); }
void conn_OnIq(object sender, agsXMPP.protocol.client.IQ iq) { if (this.IsHandleCreated) { this.Invoke(new OnStanzaDelegate(OnStanza), iq); } }
private void OnMembershipResult(object sender, agsXMPP.protocol.client.IQ iq, object data) { var logger = NLog.LogManager.GetCurrentClassLogger(); if (iq.Type == agsXMPP.protocol.client.IqType.result) { var item = iq.Query.FirstChild as agsXMPP.protocol.x.muc.Item; if (item != null && item.Nickname != "Posh-UC Support") { var tem = new RoomMember(); tem.Affiliation = item.Affiliation.ToString(); tem.Jid = item.Jid.Bare; tem.Role = item.Role.ToString(); tem.Nickname = item.Nickname; tem.FullJid = item.Jid; members.Add(tem); } } else { logger.Error("Failed to get result: {0}", iq.Error.ToString()); } messageComplete = true; messageReceived.Set(); }
private void getListResult(object sender, agsXMPP.protocol.client.IQ iq, object data) { if (iq.Type == agsXMPP.protocol.client.IqType.result && iq.Error == null) { if (iq.Query != null && iq.Query is agsXMPP.protocol.iq.privacy.Privacy) { agsXMPP.protocol.iq.privacy.Privacy privacy = iq.Query as agsXMPP.protocol.iq.privacy.Privacy; if (Jabber.xmpp.IqGrabber != null) { Jabber.xmpp.IqGrabber.Remove(data as string); } agsXMPP.protocol.iq.privacy.List customList = null; agsXMPP.protocol.iq.privacy.List[] lists = privacy.GetList(); if (lists != null) { foreach (agsXMPP.protocol.iq.privacy.List list in lists) { if (list.Name == Jabber.xmpp.MyJID.Bare.Replace("@", "_").Replace("/", "_").Replace(".", "_")) { customList = list; break; } } } if (customList != null) { agsXMPP.protocol.iq.privacy.Item[] items = customList.GetItems(); if (items != null) { bool updated = false; foreach (agsXMPP.protocol.iq.privacy.Item item in items) { if (item.Type == agsXMPP.protocol.iq.privacy.Type.jid) { agsXMPP.Jid jid = new agsXMPP.Jid(item.Val); if (jid != null) { if (item.Action == agsXMPP.protocol.iq.privacy.Action.deny && !_blockedJid.Contains(jid.ToString())) { _blockedJid.Add(jid.ToString()); updated = true; } else if (item.Action == agsXMPP.protocol.iq.privacy.Action.allow && _blockedJid.Contains(jid.ToString())) { _blockedJid.Remove(jid.ToString()); updated = true; } } } } if (updated) { OnPrivacyListUpdated(); } } } } } }
/// <summary> /// Resultat de la requette RequestBookmarks /// </summary> /// <param name="sender">Objet parent</param> /// <param name="iq">Requette</param> /// <param name="data">Données supplémentaires</param> private void retrieveResult(object sender, agsXMPP.protocol.client.IQ iq, object data) { if (iq.Type == agsXMPP.protocol.client.IqType.result) { if (iq.Query != null && iq.Query.HasTag(typeof(agsXMPP.protocol.extensions.bookmarks.Storage))) { if (iq.Query.SelectSingleElement(typeof(agsXMPP.protocol.extensions.bookmarks.Storage)) != null) { agsXMPP.protocol.extensions.bookmarks.Storage st = iq.Query.SelectSingleElement(typeof(agsXMPP.protocol.extensions.bookmarks.Storage)) as agsXMPP.protocol.extensions.bookmarks.Storage; agsXMPP.protocol.extensions.bookmarks.Url[] urls = st.GetUrls(); if (urls != null) { _favorites.Clear(); foreach (agsXMPP.protocol.extensions.bookmarks.Url url in urls) { if (url.Address != null && url.Name != null) { Favorite f = new Favorite(); f.address = url.Address; f.name = url.Name; if (!_favorites.Contains(f)) { _favorites.Add(f); } } } OnFavoritesAvailables(); } agsXMPP.protocol.extensions.bookmarks.Conference[] conferences = st.GetConferences(); if (conferences != null) { _rooms.Clear(); foreach (agsXMPP.protocol.extensions.bookmarks.Conference conference in conferences) { if (conference.Name != null && conference.Jid != null && conference.Nickname != null) { Room r = new Room(); r.autoJoin = conference.AutoJoin; r.jabberID = new JabberID(); r.jabberID.user = conference.Jid.User; r.jabberID.resource = conference.Jid.Resource; r.jabberID.domain = conference.Jid.Server; r.jabberID.bare = conference.Jid.Bare; r.jabberID.full = conference.Jid.ToString(); r.name = conference.Name; r.nickname = conference.Nickname; r.password = (conference.Password != null) ? conference.Password : string.Empty; if (!_rooms.Contains(r)) { _rooms.Add(r); } } } OnRoomsAvailables(); } } } } }
/// <summary> /// Change la lecture en cours /// </summary> /// <param name="utune">Informations sur la lecture en cours</param> public void setTune(Tune utune) { if (Jabber.xmpp.Authenticated && Jabber._pepCapable) { agsXMPP.protocol.client.IQ iq = new agsXMPP.protocol.client.IQ(); iq.Type = agsXMPP.protocol.client.IqType.set; iq.GenerateId(); agsXMPP.Xml.Dom.Element pb = new agsXMPP.Xml.Dom.Element("pubsub"); pb.Namespace = "http://jabber.org/protocol/pubsub"; agsXMPP.Xml.Dom.Element ps = new agsXMPP.Xml.Dom.Element("publish"); ps.Attributes.Add("node", "http://jabber.org/protocol/tune"); agsXMPP.Xml.Dom.Element item = new agsXMPP.Xml.Dom.Element("item"); item.Attributes.Add("id", "current"); agsXMPP.Xml.Dom.Element tune = new agsXMPP.Xml.Dom.Element("tune"); tune.Namespace = "http://jabber.org/protocol/tune"; tune.AddChild(new agsXMPP.Xml.Dom.Element("length", Convert.ToString(utune.length, System.Globalization.CultureInfo.InvariantCulture))); tune.AddChild(new agsXMPP.Xml.Dom.Element("rating", Convert.ToString(utune.rating, System.Globalization.CultureInfo.InvariantCulture))); tune.AddChild(new agsXMPP.Xml.Dom.Element("track", Convert.ToString(utune.track, System.Globalization.CultureInfo.InvariantCulture))); tune.AddChild(new agsXMPP.Xml.Dom.Element("artist", (utune.artist != null) ? utune.artist.Trim() : string.Empty)); tune.AddChild(new agsXMPP.Xml.Dom.Element("source", (utune.source != null) ? utune.source.Trim() : string.Empty)); tune.AddChild(new agsXMPP.Xml.Dom.Element("title", (utune.title != null) ? utune.title.Trim() : string.Empty)); tune.AddChild(new agsXMPP.Xml.Dom.Element("uri", (utune.uri != null) ? utune.uri.Trim() : string.Empty)); item.AddChild(tune); ps.AddChild(item); pb.AddChild(ps); agsXMPP.Xml.Dom.Element conf = new agsXMPP.Xml.Dom.Element("configure"); agsXMPP.Xml.Dom.Element x = new agsXMPP.Xml.Dom.Element("x"); agsXMPP.Xml.Dom.Element field1 = new agsXMPP.Xml.Dom.Element("field"); field1.Attributes.Add("type", "hidden"); field1.Attributes.Add("var", "FORM_TYPE"); agsXMPP.Xml.Dom.Element value1 = new agsXMPP.Xml.Dom.Element("value"); value1.Value = "http://jabber.org/protocol/pubsub#node_config"; field1.AddChild(value1); x.AddChild(field1); agsXMPP.Xml.Dom.Element field2 = new agsXMPP.Xml.Dom.Element("field"); field2.Attributes.Add("var", "pubsub#access_model"); agsXMPP.Xml.Dom.Element value2 = new agsXMPP.Xml.Dom.Element("value"); value2.Value = "presence"; field2.AddChild(value2); x.AddChild(field2); conf.AddChild(x); pb.AddChild(conf); iq.AddChild(pb); Jabber.xmpp.Send(iq); _tune = new Tune(); _tune.artist = (utune.artist != null) ? utune.artist.Trim() : string.Empty; _tune.length = utune.length; _tune.rating = utune.rating; _tune.source = (utune.source != null) ? utune.source.Trim() : string.Empty; _tune.title = (utune.title != null) ? utune.title.Trim() : string.Empty; _tune.track = utune.track; _tune.uri = (utune.uri != null) ? utune.uri.Trim() : string.Empty; } }
private void unblockResult(object sender, agsXMPP.protocol.client.IQ iq, object data) { PrivacyStructure ps = (PrivacyStructure)data; if (iq.Type == agsXMPP.protocol.client.IqType.result && iq.Id == ps.id) { if (_blockedJid.Contains(ps.jid.ToString())) { _blockedJid.Remove(ps.jid.ToString()); } } }
public agsXMPP.protocol.client.IQ BuildActivateBytestream(Jid proxy_jid) { var ack = new agsXMPP.protocol.client.IQ(agsXMPP.protocol.client.IqType.set, conn.MyJID, proxy_jid); ack.GenerateId(); var query = new Element("query", null, "http://jabber.org/protocol/bytestreams"); ack.AddChild(query); query.Attributes["sid"] = initiateJingle.Attributes["sid"]; query.SetTag("activate", iq_to); return(ack); }
/// <summary> /// Resultat de la requète getLast /// </summary> /// <param name="sender">Objet parent</param> /// <param name="iq">Résultat de la requète</param> /// <param name="data">Données supplémentaires</param> private void getLastResult(object sender, agsXMPP.protocol.client.IQ iq, object data) { if (iq.Type == agsXMPP.protocol.client.IqType.result) { if (iq.Query != null && iq.Query is agsXMPP.protocol.iq.last.Last) { agsXMPP.protocol.iq.last.Last last = iq.Query as agsXMPP.protocol.iq.last.Last; OnClientLastAvailable(new TimeSpan(0, 0, 0, last.Seconds)); if (Jabber.xmpp.IqGrabber != null && liqID != string.Empty) { Jabber.xmpp.IqGrabber.Remove(liqID); } } } }
/// <summary> /// Resultat de la requète getTime /// </summary> /// <param name="sender">Objet parent</param> /// <param name="iq">Résultat de la requète</param> /// <param name="data">Données supplémentaires</param> private void getTimeResult(object sender, agsXMPP.protocol.client.IQ iq, object data) { if (iq.Type == agsXMPP.protocol.client.IqType.result) { if (iq.Query != null && iq.Query is agsXMPP.protocol.iq.time.Time) { agsXMPP.protocol.iq.time.Time time = iq.Query as agsXMPP.protocol.iq.time.Time; OnClientTimeAvailable(DateTime.Parse(time.Utc)); if (Jabber.xmpp.IqGrabber != null && tiqID != string.Empty) { Jabber.xmpp.IqGrabber.Remove(tiqID); } } } }
private void xmppOnIq(object sender, agsXMPP.protocol.client.IQ iq) { if (iq.Type == agsXMPP.protocol.client.IqType.set && iq.Id.ToLower().Contains("push")) { if (iq.Query != null && iq.Query is agsXMPP.protocol.iq.privacy.Privacy) { agsXMPP.protocol.client.IQ pushIqResult = new agsXMPP.protocol.client.IQ(); pushIqResult.From = Jabber.xmpp.MyJID; pushIqResult.To = iq.From; pushIqResult.Type = agsXMPP.protocol.client.IqType.result; pushIqResult.Id = iq.Id; Jabber.xmpp.Send(pushIqResult); getList(); } } }
void ProcessIq(Iq iq) { var query = iq.Query ?? iq.FirstChild; if (query != null) { if (query.TagName == "bind" && query.Namespace == Namespaces.BIND) { this.ProcessBind(iq, query); } else if (query.TagName == "session" && query.Namespace == Namespaces.SESSION) { this.ProcessSession(iq); } } }
/// <summary> /// Change son activit� /// </summary> /// <param name="type">Type de l'activit�</param> /// <param name="text">Description</param> public void setActivity(Enumerations.ActivityType type, string text) { if (Jabber.xmpp.Authenticated && Jabber._pepCapable) { agsXMPP.protocol.client.IQ iq = new agsXMPP.protocol.client.IQ(); iq.Type = agsXMPP.protocol.client.IqType.set; iq.GenerateId(); agsXMPP.Xml.Dom.Element pb = new agsXMPP.Xml.Dom.Element("pubsub"); pb.Namespace = "http://jabber.org/protocol/pubsub"; agsXMPP.Xml.Dom.Element ps = new agsXMPP.Xml.Dom.Element("publish"); ps.Attributes.Add("node", "http://jabber.org/protocol/activity"); agsXMPP.Xml.Dom.Element item = new agsXMPP.Xml.Dom.Element("item"); item.Attributes.Add("id", "current"); agsXMPP.Xml.Dom.Element activity = new agsXMPP.Xml.Dom.Element("activity"); activity.Namespace = "http://jabber.org/protocol/activity"; agsXMPP.Xml.Dom.Element activityType = new agsXMPP.Xml.Dom.Element(Enum.GetName(typeof(Enumerations.ActivityType), type)); activity.AddChild(activityType); agsXMPP.Xml.Dom.Element activityText = new agsXMPP.Xml.Dom.Element("text"); activityText.Value = text; activity.AddChild(activityText); item.AddChild(activity); ps.AddChild(item); pb.AddChild(ps); agsXMPP.Xml.Dom.Element conf = new agsXMPP.Xml.Dom.Element("configure"); agsXMPP.Xml.Dom.Element x = new agsXMPP.Xml.Dom.Element("x"); agsXMPP.Xml.Dom.Element field1 = new agsXMPP.Xml.Dom.Element("field"); field1.Attributes.Add("type", "hidden"); field1.Attributes.Add("var", "FORM_TYPE"); agsXMPP.Xml.Dom.Element value1 = new agsXMPP.Xml.Dom.Element("value"); value1.Value = "http://jabber.org/protocol/pubsub#node_config"; field1.AddChild(value1); x.AddChild(field1); agsXMPP.Xml.Dom.Element field2 = new agsXMPP.Xml.Dom.Element("field"); field2.Attributes.Add("var", "pubsub#access_model"); agsXMPP.Xml.Dom.Element value2 = new agsXMPP.Xml.Dom.Element("value"); value2.Value = "presence"; field2.AddChild(value2); x.AddChild(field2); conf.AddChild(x); pb.AddChild(conf); iq.AddChild(pb); Jabber.xmpp.Send(iq); _activity = new Activity(); _activity.type = type; _activity.text = text; } }
public agsXMPP.protocol.client.IQ BuildSessionTerminate(string reason) { var ack = new agsXMPP.protocol.client.IQ(agsXMPP.protocol.client.IqType.set, iq_from, iq_to); ack.GenerateId(); var jingle = new Element("jingle", null, "urn:xmpp:jingle:1"); ack.AddChild(jingle); jingle.Attributes["action"] = "session-terminate"; jingle.Attributes["initiator"] = initiateJingle.Attributes["initiator"]; jingle.Attributes["sid"] = initiateJingle.Attributes["sid"]; var content = new Element("reason"); content.AddTag(reason); jingle.AddChild(content); return(ack); }
/// <summary> /// Resultat de la requète getVersion /// </summary> /// <param name="sender">Objet parent</param> /// <param name="iq">Résultat de la requète</param> /// <param name="data">Données supplémentaires</param> private void getVersionResult(object sender, agsXMPP.protocol.client.IQ iq, object data) { if (iq.Type == agsXMPP.protocol.client.IqType.result) { if (iq.Query != null && iq.Query is agsXMPP.protocol.iq.version.Version) { agsXMPP.protocol.iq.version.Version version = iq.Query as agsXMPP.protocol.iq.version.Version; ClientVersion cv = new ClientVersion(); cv.name = (version.Name != null) ? version.Name.Trim() : string.Empty; cv.os = (version.Os != null) ? version.Os.Trim() : string.Empty; cv.version = (version.Ver != null) ? version.Ver.Trim() : string.Empty; OnClientVersionAvailable(cv); if (Jabber.xmpp.IqGrabber != null && viqID != string.Empty) { Jabber.xmpp.IqGrabber.Remove(viqID); } } } }
/// <summary> /// make incoming Jingle session /// </summary> /// <param name="xmppClient"></param> /// <param name="initIq"></param> public JingleSession(XmppClientConnection xmppClient, agsXMPP.protocol.client.IQ initIq) { selfInitiated = false; this.conn = xmppClient; this.initiateIq = initIq; this.initiateJingle = initIq.SelectSingleElement("jingle"); this.contentIn = initiateJingle.SelectSingleElement("content"); this.transportIn = contentIn.SelectSingleElement("transport"); this.transportSid = (string)transportIn.Attributes["sid"]; jingle_initiator = initiateJingle.GetAttribute("initiator"); jingle_sid = initiateJingle.GetAttribute("sid"); content_name = contentIn.GetAttribute("name"); iq_from = initiateIq.To; iq_to = initiateIq.From; var filename = contentIn.SelectSingleElement("file", true).GetTag("name"); localFilespec = Program.dataDir + "received files\\" + filename; }
void ProcessBind(Iq iq, Element bind) { var resource = bind.SelectSingleElement("resource").Value; var search = new Jid(this.Session.Jid.Bare + $"/{resource}"); var conflict = this._listener.GetConnection(search) != null; if (conflict) { this.Send(iq.ToError(agsXMPP.protocol.client.ErrorType.modify, agsXMPP.protocol.client.ErrorCondition.Conflict)); return; } this.Session.Bind(resource); iq.SwitchDirection(); iq.Type = IqType.result; iq.RemoveAllChildNodes(); iq.C("bind", ns: Namespaces.BIND) .C("jid", this.Session.Jid); this.Send(iq); }
private void xmppDiscoServerInformation(object sender, agsXMPP.protocol.client.IQ iq, object data) { if (iq.Type == agsXMPP.protocol.client.IqType.result) { if (iq.Query != null && iq.Query is DiscoInfo) { DiscoInfo di = iq.Query as DiscoInfo; List <string> features = new List <string>(); if (di.GetFeatures() != null) { DiscoFeature[] fs = di.GetFeatures(); foreach (DiscoFeature f in fs) { if (!features.Contains(f.Var)) { features.Add(f.Var); } } } if (features.Contains("http://jabber.org/protocol/pubsub")) { if (features.Contains("http://jabber.org/protocol/pubsub#publish")) { _pepCapable = true; Jabber._presence.setMood(Jabber._presence.mood.type, Jabber._presence.mood.text); Jabber._presence.setActivity(Jabber._presence.activity.type, Jabber._presence.activity.text); Jabber._presence.setLocation(Jabber._presence.location); Jabber._presence.clearTune(); } } } } if (Jabber.xmpp.IqGrabber != null && iq.Id != null) { Jabber.xmpp.IqGrabber.Remove(iq.Id); } }
/// <summary> /// D�finit un nouvel emplacement g�ographique /// </summary> /// <param name="location">Informations compl�te sur l'emplacement</param> public void setLocation(Location location) { if (Jabber.xmpp.Authenticated && Jabber._pepCapable) { agsXMPP.protocol.client.IQ iq = new agsXMPP.protocol.client.IQ(); iq.Type = agsXMPP.protocol.client.IqType.set; iq.GenerateId(); agsXMPP.Xml.Dom.Element pb = new agsXMPP.Xml.Dom.Element("pubsub"); pb.Namespace = "http://jabber.org/protocol/pubsub"; agsXMPP.Xml.Dom.Element ps = new agsXMPP.Xml.Dom.Element("publish"); ps.Attributes.Add("node", "http://jabber.org/protocol/geoloc"); agsXMPP.Xml.Dom.Element item = new agsXMPP.Xml.Dom.Element("item"); item.Attributes.Add("id", "current"); agsXMPP.Xml.Dom.Element geoloc = new agsXMPP.Xml.Dom.Element("geoloc"); geoloc.Namespace = "http://jabber.org/protocol/geoloc"; geoloc.AddChild(new agsXMPP.Xml.Dom.Element("alt", Convert.ToString(location.altitude, System.Globalization.CultureInfo.InvariantCulture))); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("lat", Convert.ToString(location.latitude, System.Globalization.CultureInfo.InvariantCulture))); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("lon", Convert.ToString(location.longitude, System.Globalization.CultureInfo.InvariantCulture))); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("bearing", Convert.ToString(location.bearing, System.Globalization.CultureInfo.InvariantCulture))); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("error", Convert.ToString(location.error, System.Globalization.CultureInfo.InvariantCulture))); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("speed", Convert.ToString(location.speed, System.Globalization.CultureInfo.InvariantCulture))); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("area", (location.area != null) ? location.area.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("building", (location.building != null) ? location.building.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("country", (location.country != null) ? location.country.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("datum", (location.datum != null) ? location.datum.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("description", (location.description != null) ? location.description.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("floor", (location.floor != null) ? location.floor.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("locality", (location.locality != null) ? location.locality.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("postalcode", (location.postalcode != null) ? location.postalcode.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("region", (location.region != null) ? location.region.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("room", (location.room != null) ? location.room.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("street", (location.street != null) ? location.street.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("text", (location.text != null) ? location.text.Trim() : string.Empty)); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("timestamp", agsXMPP.util.Time.ISO_8601Date(location.timestamp))); geoloc.AddChild(new agsXMPP.Xml.Dom.Element("uri", (location.uri != null) ? location.uri.Trim() : string.Empty)); item.AddChild(geoloc); ps.AddChild(item); pb.AddChild(ps); agsXMPP.Xml.Dom.Element conf = new agsXMPP.Xml.Dom.Element("configure"); agsXMPP.Xml.Dom.Element x = new agsXMPP.Xml.Dom.Element("x"); agsXMPP.Xml.Dom.Element field1 = new agsXMPP.Xml.Dom.Element("field"); field1.Attributes.Add("type", "hidden"); field1.Attributes.Add("var", "FORM_TYPE"); agsXMPP.Xml.Dom.Element value1 = new agsXMPP.Xml.Dom.Element("value"); value1.Value = "http://jabber.org/protocol/pubsub#node_config"; field1.AddChild(value1); x.AddChild(field1); agsXMPP.Xml.Dom.Element field2 = new agsXMPP.Xml.Dom.Element("field"); field2.Attributes.Add("var", "pubsub#access_model"); agsXMPP.Xml.Dom.Element value2 = new agsXMPP.Xml.Dom.Element("value"); value2.Value = "presence"; field2.AddChild(value2); x.AddChild(field2); conf.AddChild(x); pb.AddChild(conf); iq.AddChild(pb); Jabber.xmpp.Send(iq); _location = new Location(); _location.altitude = location.altitude; _location.area = (location.area != null) ? location.area.Trim() : string.Empty; _location.bearing = location.bearing; _location.building = (location.building != null) ? location.building.Trim() : string.Empty; _location.country = (location.country != null) ? location.country.Trim() : string.Empty; _location.datum = (location.datum != null) ? location.datum.Trim() : string.Empty; _location.description = (location.description != null) ? location.description.Trim() : string.Empty; _location.error = location.error; _location.floor = (location.floor != null) ? location.floor.Trim() : string.Empty; _location.latitude = location.latitude; _location.locality = (location.locality != null) ? location.locality.Trim() : string.Empty; _location.longitude = location.longitude; _location.postalcode = (location.postalcode != null) ? location.postalcode.Trim() : string.Empty; _location.region = (location.region != null) ? location.region.Trim() : string.Empty; _location.room = (location.room != null) ? location.room.Trim() : string.Empty; _location.speed = location.speed; _location.street = (location.street != null) ? location.street.Trim() : string.Empty; _location.text = (location.text != null) ? location.text.Trim() : string.Empty; _location.timestamp = location.timestamp; _location.uri = (location.uri != null) ? location.uri.Trim() : string.Empty; } }
public void OnJingleIq(object sender, agsXMPP.protocol.client.IQ iq) { if (!iq.HasTag("jingle")) { return; } var jingle = iq.SelectSingleElement("jingle"); Element contentIn, transportIn; string sid; JingleSession session; switch (jingle.GetAttribute("action")) { // incoming, first step case "session-initiate": session = new JingleSession(conn, iq); var fileName = ""; try { fileName = jingle.SelectSingleElement("file", true).GetTag("name"); } catch (Exception exx) { } if (!AutoAccept) // && MessageBox.Show("Incoming File Transfer from " + iq.From.ToString() + "\n\n" +fileName, "Jingle file-transfer", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.Cancel) { { SendIqResult(iq); var sesTerm = session.BuildSessionTerminate("decline"); conn.Send(sesTerm); return; } SendIqResult(iq); ongoingTransports[session.transportSid] = session; session.OnFileReceived += ses_OnFileReceived; var ack = session.BuildSessionAccept(); conn.Send(ack); var cFirst = session.transportIn.FirstChild; var cUsed = session.BuildCandidateUsed(cFirst.GetAttribute("cid"), "candidate-used"); conn.Send(cUsed); session.DoTransmission(cFirst); break; // incoming AND sending, second step case "transport-info": contentIn = jingle.SelectSingleElement("content"); transportIn = contentIn.SelectSingleElement("transport"); sid = transportIn.GetAttribute("sid"); if (!ongoingTransports.ContainsKey(sid)) { SendIqerror(iq); return; } session = ongoingTransports[sid]; if (transportIn.HasTag("candidate-used")) { var cid = transportIn.SelectSingleElement("candidate-used").GetAttribute("cid"); var info = session.GetTransportCandidate(cid); bool ok = session.DoTransmission(info); if (ok) { SendIqResult(iq); } else { SendIqerror(iq); } } else if (transportIn.HasTag("candidate-error")) { SendIqResult(iq); } break; // sending, first step case "session-accept": contentIn = jingle.SelectSingleElement("content"); transportIn = contentIn.SelectSingleElement("transport"); sid = transportIn.GetAttribute("sid"); if (!ongoingTransports.ContainsKey(sid)) { SendIqerror(iq); return; } session = ongoingTransports[sid]; var cFirst1 = session.transportIn.FirstChild; var cUsed1 = session.BuildCandidateUsed(cFirst1.GetAttribute("cid"), "candidate-used"); conn.Send(cUsed1); break; } }
/// <summary> /// Traitement du résultat de la demande de récupération de la fiche d'identité /// </summary> /// <param name="sender">Objet représentant la routine ayant fait appel à cette méthode</param> /// <param name="iq">Requète représentant le résultat de la demande</param> /// <param name="data">Identifiant de la requète</param> private void retrieveIqResult(object sender, agsXMPP.protocol.client.IQ iq, object data) { string iqID = data as string; // si on a une erreur alors on en informe la librairie if (iq.Type == agsXMPP.protocol.client.IqType.error) { return; } // sinon et seulement si c'est le résultat, on lance le traitement else if (iq.Type == agsXMPP.protocol.client.IqType.result) { // si la requette nous transmet la carte de visite if (iq.Vcard != null) { _birthday = iq.Vcard.Birthday; _description = (iq.Vcard.Description != null) ? iq.Vcard.Description.Trim() : string.Empty; _fullname = (iq.Vcard.Fullname != null) ? iq.Vcard.Fullname.Trim() : string.Empty; _name = new Name(); _name.firstname = (iq.Vcard.Name != null && iq.Vcard.Name.Given != null) ? iq.Vcard.Name.Given.Trim() : string.Empty; _name.middle = (iq.Vcard.Name != null && iq.Vcard.Name.Middle != null) ? iq.Vcard.Name.Middle.Trim() : string.Empty; _name.lastname = (iq.Vcard.Name != null && iq.Vcard.Name.Family != null) ? iq.Vcard.Name.Family.Trim() : string.Empty; if (iq.Vcard.Nickname != null) { nickname = iq.Vcard.Nickname.Trim(); } _organization = new Organization(); _organization.name = (iq.Vcard.Organization != null && iq.Vcard.Organization.Name != null) ? iq.Vcard.Organization.Name.Trim() : string.Empty; _organization.unit = (iq.Vcard.Organization != null && iq.Vcard.Organization.Unit != null) ? iq.Vcard.Organization.Unit.Trim() : string.Empty; _role = (iq.Vcard.Role != null) ? iq.Vcard.Role.Trim() : string.Empty; _title = (iq.Vcard.Title != null) ? iq.Vcard.Title.Trim() : string.Empty; _url = (iq.Vcard.Url != null) ? iq.Vcard.Url.Trim() : string.Empty; if (iq.Vcard.GetEmailAddresses() != null) { _email.Clear(); foreach (agsXMPP.protocol.iq.vcard.Email em in iq.Vcard.GetEmailAddresses()) { if (em != null && em.UserId != null) { Email m = new Email(); m.type = Enums.EmailTypeConverter(em.Type); m.address = em.UserId; _email.Add(m); } } } if (iq.Vcard.GetTelephoneNumbers() != null) { _telephone.Clear(); foreach (agsXMPP.protocol.iq.vcard.Telephone phone in iq.Vcard.GetTelephoneNumbers()) { if (phone != null && phone.Number != null) { Telehone t = new Telehone(); t.location = Enums.LocationTypeConverter(phone.Location); t.type = Enums.PhoneTypeConverter(phone.Type); t.number = phone.Number; _telephone.Add(t); } } } if (iq.Vcard.GetAddresses() != null) { _address.Clear(); foreach (agsXMPP.protocol.iq.vcard.Address ad in iq.Vcard.GetAddresses()) { if (ad != null) { Address a = new Address(); a.location = Enums.AddressLocationTypeConverter(ad.Location); a.city = (ad.Locality != null) ? ad.Locality.Trim() : string.Empty; a.country = (ad.Country != null) ? ad.Country.Trim() : string.Empty; a.extra = (ad.ExtraAddress != null) ? ad.ExtraAddress.Trim() : string.Empty; a.region = (ad.Region != null) ? ad.Region.Trim() : string.Empty; a.street = (ad.Street != null) ? ad.Street.Trim() : string.Empty; a.zipcode = (ad.PostalCode != null) ? ad.PostalCode.Trim() : string.Empty; _address.Add(a); } } } photo = (iq.Vcard.Photo != null) ? iq.Vcard.Photo.Image : null; onIdentityRetrieved(); } } if (Jabber.xmpp.IqGrabber != null) { Jabber.xmpp.IqGrabber.Remove(iqID); } }
public void SendIQ(agsXMPP.protocol.client.IQ iq) { connection.IqGrabber.SendIq(iq); }
private void OnIq(object sender, agsXMPP.protocol.client.IQ iq) { logger.Debug(iq.InnerXml); }
/// <summary> /// Réceptionne l'intégralité des requètes du stream en cours pour traiter seulement celles qui nous interresse /// </summary> /// <param name="sender">Objet parent</param> /// <param name="iq">Requete reçue</param> private void iqManager(object sender, agsXMPP.protocol.client.IQ iq) { }
void ProcessSession(Iq iq) { iq.SwitchDirection(); iq.Type = IqType.result; this.Send(iq); }