Example #1
0
        /// <summary>
        /// Writes the ChatRoomInfo's parameters to a byte stream for transmission
        /// </summary>
        internal void WriteToByteStream(ByteStream stream)
        {
            // Write the basic info header
            stream.WriteUshort(exchangeNumber);
            stream.WriteByte((byte)"create".Length);
            stream.WriteString("create", Encoding.ASCII);
            stream.WriteUshort(instance);

            // Write details
            stream.WriteByte(0x01);     // Detail level
            stream.WriteUshort(0x0003); // An unknown code, AIM 5.9 sets this to 0x0003
            using (TlvBlock tlvs = new TlvBlock())
            {
                tlvs.WriteString(CHATROOM_CHARSET1, UtilityMethods.OscarEncodingToString(charSet1), Encoding.ASCII);
                tlvs.WriteString(CHATROOM_DISPLAYNAME, displayName, Encoding.ASCII);
                tlvs.WriteString(CHATROOM_LANGUAGE1, language1, Encoding.ASCII);

                // Everything else is optional
                if (contentType != "text/x-aolrtf")
                {
                    tlvs.WriteString(CHATROOM_CONTENTTYPE, contentType, Encoding.ASCII);
                }

                if (Flags != 0xFFFF)
                {
                    tlvs.WriteUshort(CHATROOM_FLAGS, Flags);
                }
                if (MaxMessageLength != 0xFFFF)
                {
                    tlvs.WriteUshort(CHATROOM_MESSAGE_LENGTH, MaxMessageLength);
                }
                if (MaxOccupants != 0xFFFF)
                {
                    tlvs.WriteUshort(CHATROOM_MAX_OCCUPANTS, MaxOccupants);
                }
                if (CreationPermissions != 0xFF)
                {
                    tlvs.WriteByte(CHATROOM_PERMISSIONS, CreationPermissions);
                }
                if (charSet2 != null)
                {
                    tlvs.WriteString(CHATROOM_CHARSET2, charSet2.WebName, Encoding.ASCII);
                }
                if (!String.IsNullOrEmpty(language2))
                {
                    tlvs.WriteString(CHATROOM_LANGUAGE2, language2, Encoding.ASCII);
                }

                //stream.WriteUshort((ushort) tlvs.GetByteCount());
                stream.WriteTlvBlock(tlvs);
            }
        }
Example #2
0
        /// <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);
        }
Example #3
0
        /// <summary>
        /// Writes the ChatRoomInfo's parameters to a byte stream for transmission
        /// </summary>
        internal void WriteToByteStream(ByteStream stream)
        {
            // Write the basic info header
            stream.WriteUshort(exchangeNumber);
            stream.WriteByte((byte) "create".Length);
            stream.WriteString("create", Encoding.ASCII);
            stream.WriteUshort(instance);

            // Write details
            stream.WriteByte(0x01); // Detail level
            stream.WriteUshort(0x0003); // An unknown code, AIM 5.9 sets this to 0x0003
            using (TlvBlock tlvs = new TlvBlock())
            {
                tlvs.WriteString(CHATROOM_CHARSET1, UtilityMethods.OscarEncodingToString(charSet1), Encoding.ASCII);
                tlvs.WriteString(CHATROOM_DISPLAYNAME, displayName, Encoding.ASCII);
                tlvs.WriteString(CHATROOM_LANGUAGE1, language1, Encoding.ASCII);

                // Everything else is optional
                if (contentType != "text/x-aolrtf")
                {
                    tlvs.WriteString(CHATROOM_CONTENTTYPE, contentType, Encoding.ASCII);
                }

                if (Flags != 0xFFFF)
                {
                    tlvs.WriteUshort(CHATROOM_FLAGS, Flags);
                }
                if (MaxMessageLength != 0xFFFF)
                {
                    tlvs.WriteUshort(CHATROOM_MESSAGE_LENGTH, MaxMessageLength);
                }
                if (MaxOccupants != 0xFFFF)
                {
                    tlvs.WriteUshort(CHATROOM_MAX_OCCUPANTS, MaxOccupants);
                }
                if (CreationPermissions != 0xFF)
                {
                    tlvs.WriteByte(CHATROOM_PERMISSIONS, CreationPermissions);
                }
                if (charSet2 != null)
                {
                    tlvs.WriteString(CHATROOM_CHARSET2, charSet2.WebName, Encoding.ASCII);
                }
                if (!String.IsNullOrEmpty(language2))
                {
                    tlvs.WriteString(CHATROOM_LANGUAGE2, language2, Encoding.ASCII);
                }

                //stream.WriteUshort((ushort) tlvs.GetByteCount());
                stream.WriteTlvBlock(tlvs);
            }
        }
Example #4
0
        /// <summary>
        /// Set my icq contact informations.
        /// </summary>
        /// <param name="ui">My Details</param>
        /// <remarks>
        /// <para>The following properties can't be set:</para>
        /// <para><seealso cref="FullUserInfo.Screenname"/>, <seealso cref="FullUserInfo.Email"/> (use <seealso cref="SendUserEmail"/> instead), <seealso cref="FullUserInfo.Age"/>, <seealso cref="FullUserInfo.CodePage"/>,
        /// <seealso cref="FullUserInfo.Timezone"/></para>
        /// </remarks>
        public void SendUserInfo(FullUserInfo ui)
        {
            TlvBlock tlvs = new TlvBlock();

            // Names
            tlvs.WriteString(0x64, ui.Firstname, Encoding.UTF8);
            tlvs.WriteString(0x6e, ui.Lastname, Encoding.UTF8);
            tlvs.WriteString(0x78, ui.Nickname, Encoding.UTF8);

            // Home Address
            tlvs.WriteByteArray(0x96, ProcessDirectoryUpdateRequestUserDetails(0x96, ui));
            // Origin Address
            tlvs.WriteByteArray(0xa0, ProcessDirectoryUpdateRequestUserDetails(0xa0, ui));
            // Phone Numbers
            tlvs.WriteByteArray(0xc8, ProcessDirectoryUpdateRequestUserDetails(0xc8, ui));
            // Emails
            tlvs.WriteByteArray(0x8c, ProcessDirectoryUpdateRequestUserDetails(0x8c, ui));
            // Work
            tlvs.WriteByteArray(0x118, ProcessDirectoryUpdateRequestUserDetails(0x118, ui));
            // Education
            tlvs.WriteByteArray(0x10e, ProcessDirectoryUpdateRequestUserDetails(0x10e, ui));
            // Interests
            tlvs.WriteByteArray(0x122, ProcessDirectoryUpdateRequestUserDetails(0x122, ui));

            // Timezone
            TimeSpan ts = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);

            if (TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now))
            {
                ts -= TimeZone.CurrentTimeZone.GetDaylightChanges(DateTime.Now.Year).Delta;
            }
            tlvs.WriteSshort(0x17c, (short)(ts.TotalMinutes / -30));

            switch (ui.Gender.ToString().ToUpper())
            {
            case "F": tlvs.WriteByte(0x82, 1); break;

            case "M": tlvs.WriteByte(0x82, 2); break;

            default: tlvs.WriteByte(0x82, 0); break;
            }

            tlvs.WriteString(0xfa, ui.Website, Encoding.ASCII);

            if (ui.Birthday == DateTime.MinValue)
            {
                tlvs.WriteDouble(0x1a4, 0);
            }
            else
            {
                tlvs.WriteDouble(0x1a4, ui.Birthday.ToOADate() - 2);
            }

            tlvs.WriteUshort(0xaa, (ushort)ui.Language1);
            tlvs.WriteUshort(0xb4, (ushort)ui.Language2);
            tlvs.WriteUshort(0xbe, (ushort)ui.Language3);

            tlvs.WriteUshort(0x12c, (ushort)ui.MaritalStatus);
            tlvs.WriteString(0x186, ui.About, Encoding.UTF8);

            tlvs.WriteString(0x226, ui.StatusNote, Encoding.UTF8);
            tlvs.WriteUshort(0x1f9, ui.PrivacyLevel);
            tlvs.WriteUshort(0x19a, ui.Auth);
            tlvs.WriteByte(0x212, ui.WebAware);
            tlvs.WriteByte(0x1ea, ui.AllowSpam);
            tlvs.WriteUshort(0x1c2, (ushort)Encoding.Default.CodePage);     //ui.CodePage

            ByteStream stream = new ByteStream();

            stream.WriteUshort(0x0003);
            stream.WriteUshort((ushort)tlvs.GetByteCount());
            stream.WriteByteArray(tlvs.GetBytes());

            /* * * * * Header * * * * */
            SNACHeader sh = CreateIcqMetaHeader();

            stream = CreateDirectoryHeader(DirectoryRequestType.SetInfoRequest, stream);
            stream = CreateMetaInfoHeader(parent, sh, MetaInfoRequestType.DirectoryUpdateRequest, stream);

            //parent.StoreRequestID(sh.RequestID, DirecotyQueryType.InfoUser);
            SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(parent, sh, stream));
        }