private void XmppCon_OnIq(object sender, agsXMPP.protocol.client.IQ iq) { if (InvokeRequired) { // Windows Forms are not Thread Safe, we need to invoke this :( // We're not in the UI thread, so we need to call BeginInvoke BeginInvoke(new IqHandler(XmppCon_OnIq), new object[] { sender, iq }); return; } if (iq != null) { // No Iq with query if (iq.HasTag(typeof(agsXMPP.protocol.extensions.si.SI))) { if (iq.Type == IqType.set) { agsXMPP.protocol.extensions.si.SI si = iq.SelectSingleElement(typeof(agsXMPP.protocol.extensions.si.SI)) as agsXMPP.protocol.extensions.si.SI; agsXMPP.protocol.extensions.filetransfer.File file = si.File; if (file != null) { // somebody wants to send a file to us Console.WriteLine(file.Size.ToString()); Console.WriteLine(file.Name); frmFileTransfer frmFile = new frmFileTransfer(XmppCon, iq); frmFile.Show(); } } } else { Element query = iq.Query; if (query != null) { if (query.GetType() == typeof(agsXMPP.protocol.iq.version.Version)) { // its a version IQ VersionIQ agsXMPP.protocol.iq.version.Version version = query as agsXMPP.protocol.iq.version.Version; if (iq.Type == IqType.get) { // Somebody wants to know our client version, so send it back iq.SwitchDirection(); iq.Type = IqType.result; version.Name = "MiniClient"; version.Ver = "0.5"; version.Os = Environment.OSVersion.ToString(); XmppCon.Send(iq); } } } } } }
private void sendFileToolStripMenuItem_Click(object sender, EventArgs e) { RosterNode node = rosterControl.SelectedItem(); if (node != null) { if (node.Nodes.Count > 0) { Jid jid = node.RosterItem.Jid; jid.Resource = node.FirstNode.Text; frmFileTransfer ft = new frmFileTransfer(XmppCon, jid); ft.Show(); } } }