Beispiel #1
0
        private void jc_OnIQ(object sender, IQ iq)
        {
            if (iq.Type != IQType.get)
            {
                return;
            }

            XmlElement query = iq.Query;

            if (query == null)
            {
                return;
            }

            // <iq id="jcl_8" to="me" from="you" type="get"><query xmlns="jabber:iq:version"/></iq>
            if (query is jabber.protocol.iq.Version)
            {
                iq = iq.GetResponse(jc.Document);
                jabber.protocol.iq.Version ver = iq.Query as jabber.protocol.iq.Version;
                if (ver != null)
                {
                    ver.OS         = Environment.OSVersion.ToString();
                    ver.EntityName = Application.ProductName;
                    ver.Ver        = Application.ProductVersion;
                }
                jc.Write(iq);
                return;
            }

            if (query is Time)
            {
                iq = iq.GetResponse(jc.Document);
                Time tim = iq.Query as Time;
                if (tim != null)
                {
                    tim.SetCurrentTime();
                }
                jc.Write(iq);
                return;
            }

            if (query is Last)
            {
                iq = iq.GetResponse(jc.Document);
                Last last = iq.Query as Last;
                if (last != null)
                {
                    last.Seconds = (int)IdleTime.GetIdleTime();
                }
                jc.Write(iq);
                return;
            }
        }
        private void GotVersionQuery(object sender, IQ iq, object state)
        {
            try {
                if (iq.Type == IQType.result)
                {
                    if (iq.Query is jabber.protocol.iq.Version)
                    {
                        jabber.protocol.iq.Version t = (jabber.protocol.iq.Version)iq.Query;

                        NameTextBox.Text    = t.EntityName;
                        VersionTextBox.Text = t.Ver;
                        OSTextBox.Text      = IsNull(t.OS, "(Not reported)");

                        Spinner.Visible = false;
                    }
                }
            } catch (Exception) {
                Spinner.Visible = false;
                MessageBox.Show(string.Format("Invalid Version response received:\n{0}", iq.OuterXml));
            }
        }