Beispiel #1
0
        /// <summary>
        /// Creates the node using the specified configuration form.
        /// </summary>
        /// <param name="config">Null for the default configuration</param>
        public void Create(jabber.protocol.x.Data config)
        {
            lock (this)
            {
                if (!NeedsAsking(this[Op.CREATE]))
                {
                    SubscribeIfPending();
                    return;
                }

                this[Op.CREATE] = STATE.Asking;
            }

/*
 * <iq type='set'
 *  from='[email protected]/elsinore'
 *  to='pubsub.shakespeare.lit'
 *  id='create1'>
 *  <pubsub xmlns='http://jabber.org/protocol/pubsub'>
 *    <create node='princely_musings'/>
 *    <configure/>
 *  </pubsub>
 * </iq>
 */
            PubSubCommandIQ <Create> iq = new PubSubCommandIQ <Create>(m_stream.Document, m_node);

            iq.To   = m_jid;
            iq.Type = IQType.set;
            iq.Command.CreateConfiguration(config);
            BeginIQ(iq, GotCreated, null);
        }
Beispiel #2
0
 private void jc_OnMessage(object sender, jabber.protocol.client.Message msg)
 {
     jabber.protocol.x.Data x = msg["x", URI.XDATA] as jabber.protocol.x.Data;
     if (x != null)
     {
         muzzle.XDataForm f = new muzzle.XDataForm(msg);
         f.ShowDialog(this);
         jc.Write(f.GetResponse());
     }
     else
     {
         MessageBox.Show(this, msg.Body, msg.From, MessageBoxButtons.OK);
     }
 }
Beispiel #3
0
        private void OnGetRegister(object sender, IQ iq, object data)
        {
            if (iq == null)
            {
                FireOnError(new IQTimeoutException((JID)data));
                return;
            }

            if (iq.Type == IQType.error)
            {
                if (OnRegistered != null)
                {
                    if (InvokeRequired)
                    {
                        CheckedInvoke(OnRegistered, new object[] { this, iq });
                    }
                    else
                    {
                        OnRegistered(this, iq);
                    }
                }
            }
            else if (iq.Type == IQType.result)
            {
                JID jid = (JID)data;
                iq.Type = IQType.set;
                iq.From = null;
                iq.To   = jid.Server;
                iq.ID   = Element.NextID();
                Register r = iq.Query as Register;
                if (r == null)
                {
                    throw new BadProtocolException(iq, "Expected a register response");
                }

                jabber.protocol.x.Data  xdata = r["x", URI.XDATA] as jabber.protocol.x.Data;
                jabber.protocol.x.Field f;
                if (xdata != null)
                {
                    f = xdata.GetField("username");
                    if (f != null)
                    {
                        f.Val = jid.User;
                    }
                    f = xdata.GetField("password");
                    if (f != null)
                    {
                        f.Val = this.Password;
                    }
                }
                else
                {
                    r.Username = jid.User;
                    r.Password = this.Password;
                }

                bool res = true;
                if (OnRegisterInfo != null)
                {
                    if (InvokeRequired)
                    {
                        // Don't use CheckedInvoke, since we want this to be synchronous
                        res = (bool)this.InvokeControl.Invoke(OnRegisterInfo, new object[] { this, r });
                    }
                    else
                    {
                        res = OnRegisterInfo(this, r);
                    }
                    if (xdata != null)
                    {
                        f = xdata.GetField("username");
                        if (f != null)
                        {
                            this.User = f.Val;
                        }
                        f = xdata.GetField("password");
                        if (f != null)
                        {
                            this.Password = f.Val;
                        }
                    }
                    else
                    {
                        this.User     = r.Username;
                        this.Password = r.Password;
                    }
                }
                if (!res)
                {
                    this.Close();
                    return;
                }
                if (xdata != null)
                {
                    xdata.Type = jabber.protocol.x.XDataType.result;
                }
                Tracker.BeginIQ(iq, new IqCB(OnSetRegister), jid);
            }
        }