public void Accept() { FeatureNeg fNeg = _si.FeatureNeg; bool ok = false; if (fNeg != null) { agsXMPP.protocol.x.data.Data data = fNeg.Data; if (data != null) { Field[] field = data.GetFields(); if (field.Length == 1) { Dictionary<string, string> methods = new Dictionary<string, string>(); foreach (Option o in field[0].GetOptions()) { string val = o.GetValue(); methods.Add(val, val); } if (methods.ContainsKey(Uri.BYTESTREAMS)) { // supports bytestream, so choose this option SIIq sIq = new SIIq(); sIq.Id = _siIq.Id; sIq.To = _siIq.From; sIq.Type = IqType.result; sIq.SI.Id = _si.Id; sIq.SI.FeatureNeg = new FeatureNeg(); agsXMPP.protocol.x.data.Data xdata = new agsXMPP.protocol.x.data.Data(); xdata.Type = XDataFormType.submit; Field f = new Field(); //f.Type = FieldType.List_Single; f.Var = "stream-method"; f.AddValue(Uri.BYTESTREAMS); xdata.AddField(f); sIq.SI.FeatureNeg.Data = xdata; _xmppConnection.OnIq += _xmppConnection_OnIq; _xmppConnection.Send(sIq); ok = true; } } } } if (ok) { State = FileTransferState.WaitingForResponse; } else { State = FileTransferState.Error; EventErrorFileTransfer transfer = new EventErrorFileTransfer("Error while negotiating file transfer conditions"); Events.Instance.OnEvent(this, transfer); } }
private void ActivateBytestreamResult(object sender, IQ iq, object dat) { if (iq.Type == IqType.result) { SendFile(null); } else { EventErrorFileTransfer transfer = new EventErrorFileTransfer("Error activating file stream"); Events.Instance.OnEvent(this, transfer); State = FileTransferState.Error; } }