/// <summary> /// Synchronously sends a rendezvous proxy INITSEND message /// </summary> void ProxyInitializeSend(RendezvousData rd) { Socket sock = rd.DirectConnection.Transfer; Encoding enc = Marshal.ASCII; byte screennamelength = (byte)enc.GetByteCount(_parent.ScreenName); int index = 0, bytessent = 0; byte[] data = new byte[12 + 1 + screennamelength + 8 + 4 + 16]; // Proxy header InsertProxyHeader(data, RendezvousProxyCommand.InitializeSend, ref index); // Screenname size + string data[index++] = screennamelength; Marshal.InsertString(data, _parent.ScreenName, enc, ref index); // The rendezvous cookie Marshal.CopyArray(rd.Cookie, data, 0, ref index); // TLV 0x0001, length 0x0010 Marshal.InsertUint(data, 0x00010010, ref index); // The Send File capability Marshal.CopyArray(CapabilityProcessor.GetCapabilityArray(rd.Capability), data, 0, ref index); while (bytessent < data.Length) { bytessent += sock.Send(data, bytessent, data.Length - bytessent, SocketFlags.None); } Logging.DumpFLAP(data, "Rendezvous proxy initialize send"); }
/// <summary> /// Synchronously sends a rendezvous proxy INITRECV message /// </summary> private void ProxyInitializeReceive() { Encoding enc = Encoding.ASCII; //byte screennamelength = (byte)enc.GetByteCount(rd.UserInfo.ScreenName); byte screennamelength = (byte)enc.GetByteCount(parent.ScreenName); int index = 0, bytessent = 0; byte[] data = new byte[12 + 1 + screennamelength + 2 + 8 + 20]; // Proxy header InsertProxyHeader(data, RendezvousProxyCommand.InitializeReceive, ref index); // Screenname size + string data[index++] = screennamelength; //Marshal.InsertString(data, rd.UserInfo.ScreenName, enc, ref index); Marshal.InsertString(data, parent.ScreenName, enc, ref index); // The fake (heh) port Marshal.InsertUshort(data, (ushort)port, ref index); // The rendezvous cookie Marshal.CopyArray(Cookie.ToByteArray(), data, 0, ref index); // TLV 0x0001, length 0x0010 Marshal.InsertUint(data, 0x00010010, ref index); // The Send File capability Marshal.CopyArray(CapabilityProcessor.GetCapabilityArray(Capability), data, 0, ref index); while (bytessent < data.Length) { bytessent += socket.Write(data, bytessent, data.Length - bytessent); } Logging.DumpFLAP(data, "Rendezvous proxy initialize receive"); }
/// <summary> /// Reads a <see cref="UserInfo"/> from the stream /// </summary> public UserInfo ReadUserInfo() { UserInfo retval = new UserInfo(); byte screenNameLength = ReadByte(); if (screenNameLength == 0) { return(null); } retval.ScreenName = ReadString(screenNameLength, Encoding.ASCII); retval.WarningLevel = ReadUshort(); using (TlvBlock tlvBlock = ReadTlvBlock(ReadUshort())) { retval.Class = (UserClass)tlvBlock.ReadUshort(0x0001); retval.CreateTime = tlvBlock.ReadDateTime(0x0002); retval.SignonTime = tlvBlock.ReadDateTime(0x0003); retval.IdleTime = tlvBlock.ReadUshort(0x0004); if (retval.IdleTime == 0xFFFF) { retval.IdleTime = 0; } retval.RegisterTime = tlvBlock.ReadDateTime(0x0005); retval.ICQUserStatus = tlvBlock.ReadUint(0x0006); retval.ExternalIPAddress = tlvBlock.ReadUint(0x000A); // Read the DC info from 0x000C retval.ClientCapabilities = CapabilityProcessor.ProcessCLSIDList(tlvBlock.ReadByteArray(0x000D)); retval.OnlineTime = tlvBlock.ReadUint(0x000F); if (tlvBlock.HasTlv(0x001D)) { ReadIconInfo(tlvBlock.ReadByteArray(0x001D), retval); } } return(retval); }