/// <summary> /// Creates a new <see cref="ChatRoom"/> from a received <see cref="ByteStream"/> /// </summary> public ChatRoom(ByteStream stream) { exchangeNumber = stream.ReadUshort(); fullName = stream.ReadString(stream.ReadByte(), Encoding.ASCII); instance = stream.ReadUshort(); // A small chat room info block will only contain the bare essentials: // exchange number, chat room name, and instance number. // The chat room class really wants a display name, so parse one here. if (stream.HasMoreData) { detailLevel = stream.ReadByte(); unknownCode = stream.ReadUshort(); // No idea what this is using (TlvBlock block = new TlvBlock(stream.ReadByteArrayToEnd())) { flags = block.ReadUshort(CHATROOM_FLAGS); if (block.HasTlv(CHATROOM_CREATION_TIME)) { creationTime = block.ReadDateTime(CHATROOM_CREATION_TIME); } maxMessageLength = block.ReadUshort(CHATROOM_MESSAGE_LENGTH); maxOccupants = block.ReadUshort(CHATROOM_MAX_OCCUPANTS); displayName = block.ReadString(CHATROOM_DISPLAYNAME, Encoding.ASCII); creationPermissions = block.ReadByte(CHATROOM_PERMISSIONS); string charset = block.ReadString(CHATROOM_CHARSET1, Encoding.ASCII); if (!String.IsNullOrEmpty(charset)) { charSet1 = Encoding.GetEncoding(charset); } language1 = block.ReadString(CHATROOM_LANGUAGE1, Encoding.ASCII); charset = block.ReadString(CHATROOM_CHARSET2, Encoding.ASCII); if (!String.IsNullOrEmpty(charset)) { charSet2 = Encoding.GetEncoding(charset); } language2 = block.ReadString(CHATROOM_LANGUAGE2, Encoding.ASCII); contentType = block.ReadString(CHATROOM_CONTENTTYPE, Encoding.ASCII); } } // Make sure there's a display name to show if (String.IsNullOrEmpty(displayName)) { Match match = AolUriParser.Match(fullName); if (match.Success) { //displayName = UtilityMethods.DeHexUri(match.Groups["roomname"].Value); int lastDashBeforeName = fullName.IndexOf('-', 16); displayName = fullName.Substring(lastDashBeforeName + 1); } else { displayName = fullName; } } }
/// <summary> /// Processes requested chat room information -- SNAC(0D,09) /// </summary> /// <param name="dp">A <see cref="DataPacket"/> object containing SNAC(0D,09)</param> public void ProcessChatRoomInformation(DataPacket dp) { ushort maxRooms = 0xFFFF; ReadOnlyCollection <Tlv> exchangeTlvs = null; ChatRoom newRoom = null; // Parse the response using (TlvBlock tlvs = new TlvBlock(dp.Data.ReadByteArrayToEnd())) { maxRooms = tlvs.ReadByte(0x0002); if (tlvs.HasTlv(0x0003)) { exchangeTlvs = tlvs.ReadAllTlvs(0x0003); } if (tlvs.HasTlv(0x0004)) { newRoom = new ChatRoom(new ByteStream(tlvs.ReadByteArray(0x0004))); } } // If this packet was received in response to a chat room creation request, // request a new chat room connection from the BOS connection if (newRoom != null) { RequestChatRoomConnection(newRoom); } }
private ChatExchangeInfo ParseChatExchangeInfo(ByteStream stream, int tlvLength) { ChatExchangeInfo retval = new ChatExchangeInfo(); retval.Exchange = stream.ReadUshort(); using (TlvBlock tlvs = new TlvBlock(stream.ReadByteArray(tlvLength))) { retval.ClassPermissions = tlvs.ReadUshort(0x0002); retval.Flags = tlvs.ReadUshort(0x00C9); retval.Name = tlvs.ReadString(0x00D3, Encoding.ASCII); retval.CreationPermissions = tlvs.ReadByte(0x00D5); retval.CharSet1 = tlvs.ReadString(0x00D6, Encoding.ASCII); retval.Language1 = tlvs.ReadString(0x00D7, Encoding.ASCII); retval.CharSet2 = tlvs.ReadString(0x00D8, Encoding.ASCII); retval.Language2 = tlvs.ReadString(0x00D9, Encoding.ASCII); } return(retval); }
private void ProcessDirectoryQueryResponseUserDetails(TlvBlock tlvs) { FullUserInfo ui = new FullUserInfo(); // Email ui.Email = tlvs.ReadString(0x50, Encoding.ASCII); // Verified e-mail if (string.IsNullOrEmpty(ui.Email)) { ui.Email = tlvs.ReadString(0x55, Encoding.ASCII); // Pending e-mail } // Names ui.Screenname = tlvs.ReadString(0x32, Encoding.ASCII); ui.Firstname = tlvs.ReadString(0x64, Encoding.UTF8); ui.Lastname = tlvs.ReadString(0x6e, Encoding.UTF8); ui.Nickname = tlvs.ReadString(0x78, Encoding.UTF8); // Home Address ProcessDirectoryQueryResponseUserDetails(tlvs.ReadTlv(0x96), ref ui); // Origin Address ProcessDirectoryQueryResponseUserDetails(tlvs.ReadTlv(0xa0), ref ui); // Phone Numbers ProcessDirectoryQueryResponseUserDetails(tlvs.ReadTlv(0xc8), ref ui); // Emails ProcessDirectoryQueryResponseUserDetails(tlvs.ReadTlv(0x8c), ref ui); // Work ProcessDirectoryQueryResponseUserDetails(tlvs.ReadTlv(0x118), ref ui); // Education ProcessDirectoryQueryResponseUserDetails(tlvs.ReadTlv(0x10e), ref ui); // Interests ProcessDirectoryQueryResponseUserDetails(tlvs.ReadTlv(0x122), ref ui); ui.Timezone = tlvs.ReadSshort(0x17c, 0); switch (tlvs.ReadByte(0x82)) { case 1: ui.Gender = 'F'; break; case 2: ui.Gender = 'M'; break; default: ui.Gender = '\0'; break; } ui.Website = tlvs.ReadString(0xfa, Encoding.ASCII); double birthday = tlvs.ReadDouble(0x1A4, 0); if (birthday != 0) { ui.Birthday = DateTime.FromOADate(birthday + 2); ui.Age = (byte)(DateTime.Now.Year - ui.Birthday.Year); if (ui.Birthday.DayOfYear > DateTime.Now.DayOfYear) { ui.Age--; } } ui.Language1 = (LanguageList)tlvs.ReadUshort(0xaa, 0); ui.Language2 = (LanguageList)tlvs.ReadUshort(0xb4, 0); ui.Language3 = (LanguageList)tlvs.ReadUshort(0xbe, 0); ui.MaritalStatus = (MartialList)tlvs.ReadUshort(0x12c, 0); ui.About = tlvs.ReadString(0x186, Encoding.UTF8); ui.StatusNote = tlvs.ReadString(0x226, Encoding.UTF8); ui.PrivacyLevel = tlvs.ReadUshort(0x1f9, 0); ui.Auth = tlvs.ReadUshort(0x19a, 0); ui.WebAware = tlvs.ReadByte(0x212, 0); ui.AllowSpam = tlvs.ReadByte(0x1ea, 0); ui.CodePage = tlvs.ReadUshort(0x1c2, 0); if (FullUserInfoReceived != null) { FullUserInfoReceived(this, ui); } }