/// <summary> /// An IQ Element is received. Now check if its one we are looking for and /// raise the event in this case. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OnIq(object sender, XMPPProtocol.Protocol.client.IQ iq) { if (iq == null) return; string id = iq.Id; if(id == null) return; TrackerData td; lock (m_grabbing) { td = (TrackerData) m_grabbing[id]; if (td == null) { return; } m_grabbing.Remove(id); } td.cb(this, iq, td.data); }
public Message(Jid to, XMPPProtocol.Protocol.client.MessageType type, string body, string subject, string thread) : base(to, type, body, subject, thread) { this.Namespace = Uri.ACCEPT; }
public Message(Jid to, XMPPProtocol.Protocol.client.MessageType type, string body) : base(to, type, body) { this.Namespace = Uri.ACCEPT; }
public Message(Jid to, Jid from, XMPPProtocol.Protocol.client.MessageType type, string body, string subject) : base(to, from, type, body, subject) { this.Namespace = Uri.ACCEPT; }
public Presence(XMPPProtocol.Protocol.client.ShowType show, string status) : this() { this.Show = show; this.Status = status; }
public Error(XMPPProtocol.Protocol.client.ErrorType type) : base(type) { this.Namespace = Uri.ACCEPT; }
void m_Xmpp_OnRosterItem(object sender, XMPPProtocol.Protocol.iq.roster.RosterItem item) { //throw new NotImplementedException(); }
void m_Xmpp_OnMessage(object sender, XMPPProtocol.Protocol.client.Message msg) { //throw new NotImplementedException(); }
/// <summary> /// Sends an Iq synchronous and return the response or null on timeout /// </summary> /// <param name="iq">The IQ to send</param> /// <param name="timeout"></param> /// <returns>The response IQ or null on timeout</returns> public IQ SendIq(XMPPProtocol.Protocol.client.IQ iq, int timeout) { synchronousResponse = null; AutoResetEvent are = new AutoResetEvent(false); SendIq(iq, new IqCB(SynchronousIqResult), are); if (!are.WaitOne(timeout, true)) { // Timed out lock (m_grabbing) { if (m_grabbing.ContainsKey(iq.Id)) m_grabbing.Remove(iq.Id); } return null; } return synchronousResponse; }
internal void OnStreamElement(object sender, XMPPProtocol.Xml.Dom.Node e) { if ( m_XmppClient.XmppConnectionState == XmppConnectionState.Securing || m_XmppClient.XmppConnectionState == XmppConnectionState.StartCompression) return; if ( e.GetType() == typeof(Protocol.stream.Features) ) { Features f = e as Features; if (!m_XmppClient.Authenticated) { // RECV: <stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'> // <mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism> // </mechanisms> // <register xmlns='http://jabber.org/features/iq-register'/> // </stream:features> // SENT: <auth mechanism="DIGEST-MD5" xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/> // Select a SASL mechanism SaslEventArgs args = new SaslEventArgs(f.Mechanisms); if (OnSaslStart != null) OnSaslStart(this, args); if (args.Auto == true) { // Library handles the Sasl stuff if (f.Mechanisms!=null) { if (m_XmppClient.UseStartTLS == false && m_XmppClient.UseSSL == false && f.Mechanisms.SupportsMechanism(MechanismType.X_GOOGLE_TOKEN) ) { // This is the only way to connect to GTalk on a unsecure Socket for now // Secure authentication is done over https requests to pass the // authentication credentials on a secure connection args.Mechanism = XMPPProtocol.Protocol.sasl.Mechanism.GetMechanismName(MechanismType.X_GOOGLE_TOKEN); } else if (f.Mechanisms.SupportsMechanism(MechanismType.DIGEST_MD5)) { args.Mechanism = XMPPProtocol.Protocol.sasl.Mechanism.GetMechanismName(MechanismType.DIGEST_MD5); } else if (f.Mechanisms.SupportsMechanism(MechanismType.PLAIN)) { args.Mechanism = XMPPProtocol.Protocol.sasl.Mechanism.GetMechanismName(MechanismType.PLAIN); } else { args.Mechanism = null; } } else { // Hack for Google // TODO: i don't think we need this anymore. This was in an very early version of the gtalk server. args.Mechanism = null; //args.Mechanism = XMPPProtocol.Protocol.sasl.Mechanism.GetMechanismName(XMPPProtocol.Protocol.sasl.MechanismType.PLAIN); } } if (args.Mechanism != null) { m_Mechanism = Factory.SaslFactory.GetMechanism(args.Mechanism); // Set properties for the SASL mechanism m_Mechanism.Username = m_XmppClient.Username; m_Mechanism.Password = m_XmppClient.Password; m_Mechanism.Server = m_XmppClient.Server; // Call Init Method on the mechanism m_Mechanism.Init(m_XmppClient); } else { m_XmppClient.RequestLoginInfo(); } } else if(!m_XmppClient.Binded) { if (f.SupportsBind) { m_XmppClient.DoChangeXmppConnectionState(XmppConnectionState.Binding); BindIq bIq; if (m_XmppClient.Resource == null || m_XmppClient.Resource.Length == 0) bIq = new BindIq(IqType.set, new Jid(m_XmppClient.Server)); else bIq = new BindIq(IqType.set, new Jid(m_XmppClient.Server), m_XmppClient.Resource); m_XmppClient.IqGrabber.SendIq(bIq, new IqCB(BindResult), null); } } } else if ( e.GetType() == typeof(Protocol.sasl.Challenge) ) { if (m_Mechanism != null && !m_XmppClient.Authenticated) { m_Mechanism.Parse(e); } } else if ( e.GetType() == typeof(Protocol.sasl.Success) ) { // SASL authentication was successfull if (OnSaslEnd!=null) OnSaslEnd(this); m_XmppClient.DoChangeXmppConnectionState(XmppConnectionState.Authenticated); m_Mechanism = null; m_XmppClient.Reset(); } else if ( e.GetType() == typeof(Protocol.sasl.Failure) ) { // Authentication failure m_XmppClient.FireOnAuthError(e as Element); } }
public IQ(XMPPProtocol.Protocol.client.IqType type, Jid from, Jid to) : base(type, from, to) { this.Namespace = Uri.ACCEPT; }
public IQ(XMPPProtocol.Protocol.client.IqType type) : base(type) { this.Namespace = Uri.ACCEPT; }
public XmppConnection(XMPPProtocol.net.SocketConnectionType type) : this() { m_SocketConnectionType = XMPPProtocol.net.SocketConnectionType.Direct; }
public Presence(XMPPProtocol.Protocol.client.ShowType show, string status, int priority) : this(show, status) { this.Priority = priority; }
void m_Xmpp_OnAgentItem(object sender, XMPPProtocol.Protocol.iq.agent.Agent agent) { //throw new NotImplementedException(); }
void m_Xmpp_OnIq(object sender, XMPPProtocol.Protocol.client.IQ iq) { //throw new NotImplementedException(); }
private void OnIqComponent(object sender, XMPPProtocol.Protocol.component.IQ iq) { OnIq(sender, iq); }
void m_Xmpp_OnPresence(object sender, XMPPProtocol.Protocol.client.Presence pres) { //throw new NotImplementedException(); }
public void ModifyList(Jid room, XMPPProtocol.Protocol.x.muc.iq.admin.Item[] items, IqCB cb) { ModifyList(room, items, cb, null); }
public Error(XMPPProtocol.Protocol.client.ErrorCode code) : base(code) { this.Namespace = Uri.ACCEPT; }
public void ModifyList(Jid room, XMPPProtocol.Protocol.x.muc.iq.admin.Item[] items, IqCB cb, object cbArg) { AdminIq aIq = new AdminIq(); aIq.To = room; aIq.Type = IqType.set; foreach (XMPPProtocol.Protocol.x.muc.iq.admin.Item itm in items) { aIq.Query.AddItem(itm); } if (cb == null) m_connection.Send(aIq); else m_connection.IqGrabber.SendIq(aIq, cb, cbArg); }
/// <summary> /// Creates an error Element according the the condition /// The type attrib as added automatically as decribed in the XMPP specs /// This is the prefered way to create error Elements /// </summary> /// <param name="condition"></param> public Error(XMPPProtocol.Protocol.client.ErrorCondition condition) : base(condition) { this.Namespace = Uri.ACCEPT; }
void m_Xmpp_OnAuthError(object sender, XMPPProtocol.Xml.Dom.Element e) { XMPPProtocol.Protocol.client.IQ iq = (XMPPProtocol.Protocol.client.IQ)e; MessageBox.Show(iq.Error.Message, "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Error); JSCall("OnAuthError"); }