void objXmpp_OnIq(object sender, IQ iq) { if (iq != null) { // No Iq with query if (iq.HasTag(typeof(agsXMPP.protocol.extensions.si.SI))) { if (iq.Type == IqType.set) { agsXMPP.protocol.extensions.si.SI si = iq.SelectSingleElement(typeof(agsXMPP.protocol.extensions.si.SI)) as agsXMPP.protocol.extensions.si.SI; agsXMPP.protocol.extensions.filetransfer.File file = si.File; if (file != null) { // somebody wants to send a file to us //frmFileTransfer frmFile = new frmFileTransfer(XmppCon, iq); //frmFile.Show(); Console.WriteLine(file.Description); FileTransfer FT = new FileTransfer(objXmpp, iq); } } } else { Element query = iq.Query; if (query != null) { if (query.GetType() == typeof(agsXMPP.protocol.iq.version.Version)) { // its a version IQ VersionIQ agsXMPP.protocol.iq.version.Version version = query as agsXMPP.protocol.iq.version.Version; if (iq.Type == IqType.get) { // Somebody wants to know our client version, so send it back iq.SwitchDirection(); iq.Type = IqType.result; version.Name = "MiniClient"; version.Ver = "0.5"; version.Os = Environment.OSVersion.ToString(); objXmpp.Send(iq); } } } } } }
private void OnIqVersion(agsXMPP.protocol.client.IQ iq, Element query) { ts.TraceInformation("OnIqVersion {0}", this.Jid.ToString()); // its a version IQ VersionIQ agsXMPP.protocol.iq.version.Version version = query as agsXMPP.protocol.iq.version.Version; if (iq.Type == IqType.get) { iq.SwitchDirection(); iq.Type = IqType.result; version.Name = "StateForgeClient"; version.Ver = "0.1"; version.Os = Environment.OSVersion.ToString(); this.xmppClientConnection.Send(iq); } }
private void _connection_OnIq(object sender, IQ iq) { if (InvokeRequired) { BeginInvoke(new IqHandler(_connection_OnIq), new[] { sender, iq }); return; } if (iq != null) { if (iq.HasTag(typeof(SI))) { if (iq.Type == IqType.set) { SI si = iq.SelectSingleElement(typeof(SI)) as SI; if (si != null) { XMPPFile file = si.File; if (file != null) { //todo:文件传输 } } } } else { Element query = iq.Query; if (query != null) { if (query.GetType() == typeof(XMPPVersion)) { XMPPVersion version = query as XMPPVersion; if (iq.Type == IqType.get && version != null) { iq.SwitchDirection(); iq.Type = IqType.result; version.Name = "XMPP"; version.Ver = "1.0"; version.Os = Environment.OSVersion.ToString(); _connection.Send(iq); } } } } } }
/// <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); } } } }
private void xmppOnIq(object sender, IQ iq) { if (iq.Type == IqType.get) { if (iq.Query != null) { if (iq.Query is DiscoInfo) { iq.SwitchDirection(); iq.Type = IqType.result; DiscoInfo di = getDiscoInfo(); iq.Query = di; Jabber.xmpp.Send(iq); } else if (iq.Query is DiscoItems) { iq.SwitchDirection(); iq.Type = IqType.error; iq.Error = new Error(ErrorType.cancel, ErrorCondition.FeatureNotImplemented); Jabber.xmpp.Send(iq); } else if (iq.Query is agsXMPP.protocol.iq.version.Version) { iq.SwitchDirection(); iq.Type = IqType.result; agsXMPP.protocol.iq.version.Version version = iq.Query as agsXMPP.protocol.iq.version.Version; version.Name = Assembly.GetExecutingAssembly().GetName().Name; version.Ver = Assembly.GetExecutingAssembly().GetName().Version.ToString(); version.Os = Environment.OSVersion.ToString(); Jabber.xmpp.Send(iq); } else if (iq.Query is agsXMPP.protocol.iq.last.Last) { iq.SwitchDirection(); iq.Type = IqType.result; agsXMPP.protocol.iq.last.Last last = iq.Query as agsXMPP.protocol.iq.last.Last; last.Seconds = new TimeSpan(Jabber._presence.getLastActivityTicks()).Seconds; Jabber.xmpp.Send(iq); } else if (iq.Query is agsXMPP.protocol.iq.time.Time) { iq.SwitchDirection(); iq.Type = IqType.result; agsXMPP.protocol.iq.time.Time time = iq.Query as agsXMPP.protocol.iq.time.Time; time.Display = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(); time.Tz = TimeZone.CurrentTimeZone.StandardName; time.Utc = agsXMPP.util.Time.ISO_8601Date(DateTime.Now); Jabber.xmpp.Send(iq); } else if (iq.Query is agsXMPP.protocol.extensions.ping.Ping) { iq.SwitchDirection(); iq.Type = IqType.result; agsXMPP.protocol.extensions.ping.Ping ping = iq.Query as agsXMPP.protocol.extensions.ping.Ping; Jabber.xmpp.Send(iq); } else if (iq.Query is agsXMPP.protocol.iq.avatar.Avatar) { iq.SwitchDirection(); iq.Type = IqType.result; agsXMPP.protocol.iq.avatar.Avatar avatar = iq.Query as agsXMPP.protocol.iq.avatar.Avatar; //avatar.Data = null; if (Jabber._identity.photo != null && Jabber._identity.photoFormat != null) { MemoryStream ms = new MemoryStream(); Jabber._identity.photo.Save(ms, Jabber._identity.photoFormat); avatar.Data = ms.ToArray(); avatar.MimeType = "image/" + Jabber._identity.photoFormat.ToString(); ms.Close(); ms.Dispose(); } Jabber.xmpp.Send(iq); } else if (iq.Query is agsXMPP.protocol.iq.vcard.Vcard) { iq.SwitchDirection(); iq.Type = IqType.result; iq.Query = Jabber._identity.toVcard(); Jabber.xmpp.Send(iq); } } } }
public void SetVersion(Version version) { throw new NotImplementedException(); }
public void SetVersion(Version version) { _version = version; NotifyPropertyChanged("ClientVersion"); NotifyPropertyChanged("ClientName"); NotifyPropertyChanged("ClientOS"); }
public void SetVersion(Version version) { _activeContact.SetVersion(version); }