コード例 #1
0
ファイル: IcqManager.cs プロジェクト: saroj82/OscarLib
        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);
            }
        }