/// <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); }
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.Forms.XDataForm f = new Muzzle.Forms.XDataForm(msg); f.ShowDialog(this); jc.Write(f.GetResponse()); } else { MessageBox.Show(this, msg.Body, msg.From, MessageBoxButtons.OK); } }
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); } }