Exemplo n.º 1
0
        /// <summary>
        /// Sets the away message and/or profile of the client
        /// </summary>
        /// <param name="awayMessage">The away message to set</param>
        /// <param name="profile">The profile to set</param>
        private void SetAwayMessageProfileInternal(string awayMessage, string profile)
        {
            // Build the SNAC header
            SNACHeader sh = new SNACHeader();

            sh.FamilyServiceID = SNAC_LOCATION_FAMILY;
            sh.FamilySubtypeID = LOCATION_PARAMETER_USERINFO;

            ByteStream stream = new ByteStream();

            using (TlvBlock tlvs = new TlvBlock())
            {
                if (profile != null)
                {
                    Encoding profileEncoding = UtilityMethods.FindBestOscarEncoding(profile);
                    tlvs.WriteString(LOCATION_PROFILE_ENCODING, Marshal.EncodingToAolMime(profileEncoding), Encoding.ASCII);
                    tlvs.WriteString(LOCATION_PROFILE, profile, profileEncoding);
                }
                if (awayMessage != null)
                {
                    Encoding awayMessageEncoding = UtilityMethods.FindBestOscarEncoding(awayMessage);
                    tlvs.WriteString(LOCATION_AWAYMESSAGE_ENCODING, Marshal.EncodingToAolMime(awayMessageEncoding),
                                     Encoding.ASCII);
                    tlvs.WriteString(LOCATION_AWAYMESSAGE, awayMessage, awayMessageEncoding);
                }
                stream.WriteByteArray(tlvs.GetBytes());
            }

            SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(parent, sh, stream));
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 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));
        }