/// <summary> /// Kicks off the authorization hash request when the initial connection is complete /// </summary> void loginConnection_ServerConnectionCompleted(Connection conn) { conn.ReadyForData = true; /*** Send SNAC(17,06) to get the auth key ***/ SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = SNAC_AUTH_FAMILY; sh.FamilySubtypeID = AUTH_KEY_REQUEST; ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteString(0x0001, parent.ScreenName, Encoding.ASCII); tlvs.WriteEmpty(0x004B); tlvs.WriteEmpty(0x005A); stream.WriteTlvBlock(tlvs); } SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(parent, sh, stream)); conn.ReadHeader(); }
/// <summary> /// Send a message to this chatroom using a specific character set and language /// </summary> /// <param name="message">The message to send</param> /// <param name="charset">The character set in which to encode the message</param> /// <param name="language">The two-letter code of the language of the message</param> private void SendMessage(string message, Encoding charset, string language) { if (!Connection.Connected) { // TODO: The semantics here aren't right throw new NotLoggedInException(); } SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = 0x000E; sh.FamilySubtypeID = (ushort)ChatService.MessageFromClient; byte[] cookie = new byte[8]; Random r = new Random(); r.NextBytes(cookie); ByteStream stream = new ByteStream(); stream.WriteByteArray(cookie); stream.WriteUshort(0x0003); TlvBlock tlvs = new TlvBlock(); using (TlvBlock messageBlock = new TlvBlock()) { Encoding messageEncoding = UtilityMethods.FindBestOscarEncoding(message); messageBlock.WriteString(CHATMESSAGE_MESSAGE, message, messageEncoding); messageBlock.WriteString(CHATMESSAGE_CHARSET, UtilityMethods.OscarEncodingToString(messageEncoding), Encoding.ASCII); messageBlock.WriteString(CHATMESSAGE_LANGUAGE, language, Encoding.ASCII); messageBlock.WriteString(CHATMESSAGE_CONTENTTYPE, "text/x-aolrtf", Encoding.ASCII); messageBlock.WriteString(CHATMESSAGE_ENCODING, "binary", Encoding.ASCII); tlvs.WriteByteArray(0x0005, messageBlock.GetBytes()); } tlvs.WriteEmpty(0x0001); stream.WriteTlvBlock(tlvs); DataPacket dp = Marshal.BuildDataPacket(Connection.ParentSession, sh, stream); dp.ParentConnection = Connection; SNACFunctions.BuildFLAP(dp); }
/// <summary> /// Sends authorization request -- SNAC(17,02) /// </summary> /// <param name="dp">A <see cref="DataPacket"/> object containing SNAC(17,07)</param> void SendAuthorizationRequest(DataPacket dp) { // Pull apart SNAC(17,07) byte[] key = dp.Data.ReadByteArray(dp.Data.ReadUshort()); // Construct SNAC(17,02) SNACHeader header = new SNACHeader(); header.FamilyServiceID = SNAC_AUTH_FAMILY; header.FamilySubtypeID = AUTH_LOGIN_REQUEST; OSCARIdentification id = parent.ClientIdentification; ByteStream stream = new ByteStream(); using (TlvBlock tlvs = new TlvBlock()) { tlvs.WriteString(0x0001, parent.ScreenName, Encoding.ASCII); tlvs.WriteString(0x0003, id.ClientName, Encoding.ASCII); tlvs.WriteString(0x000F, "en", Encoding.ASCII); tlvs.WriteString(0x000E, "us", Encoding.ASCII); tlvs.WriteUint(0x0014, id.ClientDistribution); tlvs.WriteUshort(0x0016, id.ClientId); tlvs.WriteUshort(0x0017, id.ClientMajor); tlvs.WriteUshort(0x0018, id.ClientMinor); tlvs.WriteUshort(0x0019, id.ClientLesser); tlvs.WriteUshort(0x001A, id.ClientBuild); tlvs.WriteByteArray(0x0025, parent.HashPassword(key)); tlvs.WriteByte(0x004A, 0x01); tlvs.WriteEmpty(0x004C); stream.WriteTlvBlock(tlvs); } DataPacket newPacket = Marshal.BuildDataPacket(parent, header, stream); newPacket.ParentConnection = dp.ParentConnection; SNACFunctions.BuildFLAP(newPacket); }
/// <summary> /// Send a message to this chatroom using a specific character set and language /// </summary> /// <param name="message">The message to send</param> /// <param name="charset">The character set in which to encode the message</param> /// <param name="language">The two-letter code of the language of the message</param> private void SendMessage(string message, Encoding charset, string language) { if (!Connection.Connected) { // TODO: The semantics here aren't right throw new NotLoggedInException(); } SNACHeader sh = new SNACHeader(); sh.FamilyServiceID = 0x000E; sh.FamilySubtypeID = (ushort) ChatService.MessageFromClient; byte[] cookie = new byte[8]; Random r = new Random(); r.NextBytes(cookie); ByteStream stream = new ByteStream(); stream.WriteByteArray(cookie); stream.WriteUshort(0x0003); TlvBlock tlvs = new TlvBlock(); using (TlvBlock messageBlock = new TlvBlock()) { Encoding messageEncoding = UtilityMethods.FindBestOscarEncoding(message); messageBlock.WriteString(CHATMESSAGE_MESSAGE, message, messageEncoding); messageBlock.WriteString(CHATMESSAGE_CHARSET, UtilityMethods.OscarEncodingToString(messageEncoding), Encoding.ASCII); messageBlock.WriteString(CHATMESSAGE_LANGUAGE, language, Encoding.ASCII); messageBlock.WriteString(CHATMESSAGE_CONTENTTYPE, "text/x-aolrtf", Encoding.ASCII); messageBlock.WriteString(CHATMESSAGE_ENCODING, "binary", Encoding.ASCII); tlvs.WriteByteArray(0x0005, messageBlock.GetBytes()); } tlvs.WriteEmpty(0x0001); stream.WriteTlvBlock(tlvs); DataPacket dp = Marshal.BuildDataPacket(Connection.ParentSession, sh, stream); dp.ParentConnection = Connection; SNACFunctions.BuildFLAP(dp); }