public FileTransfer(XmppClientConnection XmppCon, IQ iq) { Console.WriteLine("Accepting a file from " + iq.From.ToString()); siIq = iq; si = iq.SelectSingleElement(typeof(agsXMPP.protocol.extensions.si.SI)) as agsXMPP.protocol.extensions.si.SI; // get SID for file transfer m_Sid = si.Id; m_From = iq.From; file = si.File; m_lFileLength = file.Size; m_XmppCon = XmppCon; XmppCon.OnIq += new IqHandler(XmppCon_OnIq); agsXMPP.protocol.extensions.featureneg.FeatureNeg fNeg = si.FeatureNeg; if (fNeg != null) { agsXMPP.protocol.x.data.Data data = fNeg.Data; if (data != null) { agsXMPP.protocol.x.data.Field[] field = data.GetFields(); if (field.Length == 1) { Dictionary <string, string> methods = new Dictionary <string, string>(); foreach (agsXMPP.protocol.x.data.Option o in field[0].GetOptions()) { string val = o.GetValue(); methods.Add(val, val); } if (methods.ContainsKey(agsXMPP.Uri.BYTESTREAMS)) { // supports bytestream, so choose this option agsXMPP.protocol.extensions.si.SIIq sIq = new agsXMPP.protocol.extensions.si.SIIq(); sIq.Id = siIq.Id; sIq.To = siIq.From; sIq.Type = IqType.result; sIq.SI.Id = si.Id; sIq.SI.FeatureNeg = new agsXMPP.protocol.extensions.featureneg.FeatureNeg(); Data xdata = new Data(); xdata.Type = XDataFormType.submit; Field f = new Field(); //f.Type = FieldType.List_Single; f.Var = "stream-method"; f.AddValue(agsXMPP.Uri.BYTESTREAMS); xdata.AddField(f); sIq.SI.FeatureNeg.Data = xdata; m_XmppCon.Send(sIq); } } } } }
private void cmdAccept_Click(object sender, EventArgs e) { cmdAccept.Enabled = false; cmdRefuse.Enabled = false; agsXMPP.protocol.extensions.featureneg.FeatureNeg fNeg = si.FeatureNeg; if (fNeg != null) { agsXMPP.protocol.x.data.Data data = fNeg.Data; if (data != null) { agsXMPP.protocol.x.data.Field[] field = data.GetFields(); if (field.Length == 1) { Dictionary <string, string> methods = new Dictionary <string, string>(); foreach (agsXMPP.protocol.x.data.Option o in field[0].GetOptions()) { string val = o.GetValue(); methods.Add(val, val); } if (methods.ContainsKey(agsXMPP.Uri.BYTESTREAMS)) { // supports bytestream, so choose this option agsXMPP.protocol.extensions.si.SIIq sIq = new agsXMPP.protocol.extensions.si.SIIq(); sIq.Id = siIq.Id; sIq.To = siIq.From; sIq.Type = IqType.result; sIq.SI.Id = si.Id; sIq.SI.FeatureNeg = new agsXMPP.protocol.extensions.featureneg.FeatureNeg(); Data xdata = new Data(); xdata.Type = XDataFormType.submit; Field f = new Field(); //f.Type = FieldType.List_Single; f.Var = "stream-method"; f.AddValue(agsXMPP.Uri.BYTESTREAMS); xdata.AddField(f); sIq.SI.FeatureNeg.Data = xdata; m_XmppCon.Send(sIq); } } } } }
/// <summary> /// Creates the Xdata from from the given XData Element /// </summary> /// <param name="xdata"></param> public void CreateForm(Data xdata) { this.SuspendLayout(); this.panelFields.SuspendLayout(); this.panelFields.Controls.Clear(); lblTitle.Text = xdata.Title; lblInstructions.Text = xdata.Instructions; XDataControl_Resize(this, null); Field[] fields = xdata.GetFields(); for (int i = fields.Length -1; i >= 0; i--) { CreateField(fields[i], i); } this.panelFields.ResumeLayout(); this.ResumeLayout(); }