Exemple #1
0
        private void NotifyReplyAction(uint packetType)
        {
            uint packetSize = ReadUint();

            if (packetSize > 0 && NetStream.DataAvailable)
            {
                GGUser user = new GGUser();
                user.GGNumber         = (int)ReadUint() & 0xffffff;
                user.vGGStatus        = StatusDecode((uint)NetStream.ReadByte());
                user.vIPAdress        = ReadUint().ToString(); // todo
                user.vRemotePort      = (int)ReadShort();
                user.vGGClientVersion = GGClientVersionDecode((byte)NetStream.ReadByte());
                user.vMaxImageSize    = (byte)NetStream.ReadByte();

                NetStream.ReadByte(); // unknown

                if (packetSize > 14)
                {
                    int    descSize = (packetType == IN_NOTIFY_REPLY60) ? (byte)NetStream.ReadByte() : (int)packetSize - 14;
                    byte[] desc     = new byte[descSize];
                    for (int i = 0; i < descSize; i++)
                    {
                        desc[i] = (byte)NetStream.ReadByte();
                    }
                    user.vDescription = Encoding.GetEncoding(DEFAULT_ENCODING).GetString(desc);
                }
                this.Users.UserChangedHandler(user);
            }
        }
Exemple #2
0
        internal void OutUsersNotify(GGUser user, uint notifyType, bool block)
        {
            stUsersNotify outUsersNotify = new stUsersNotify();

            outUsersNotify.Header.Type = notifyType;
            outUsersNotify.Header.Size = 5;
            outUsersNotify.GGNumber    = user.GGNumber;
            outUsersNotify.Type        = USER_BUDDY;
            if (user.Friend)
            {
                outUsersNotify.Type |= USER_FRIEND;
            }
            if (block)
            {
                outUsersNotify.Type = USER_BLOCKED;
            }
            ForwardData(RawSerialize(outUsersNotify), 13);
        }
Exemple #3
0
        internal static int GetStatusOrder(GGUser user)
        {
            switch (user.GGStatus)
            {
            case GGStatusType.Available:
            case GGStatusType.Busy:
                return(3);

            case GGStatusType.Invisible:
                return(2);

            case GGStatusType.Blocked:
                return(1);

            case GGStatusType.NotAvailable:
                return(0);
            }
            return(0);
        }
Exemple #4
0
 private List<GGUser> ReplyQuery2List(string query, out int nextStart, bool readMode) {
     nextStart = 0;
     List<GGUser> reply = new List<GGUser>();            
     if (string.IsNullOrEmpty(query))
         return reply;
     string pattern = (readMode) ? READ_QUERY_PATTERN : SEARCH_QUERY_PATTERN;
     Regex regex = new Regex(pattern, RegexOptions.Compiled);
     MatchCollection matches = regex.Matches(query);
     foreach(Match match in matches) {
         GGUser user = new GGUser();
         user.GGNumber = match.Groups["NUM"].Success ? int.Parse(match.Groups["NUM"].Value) : 0;
         user.vGGStatus = match.Groups["STS"].Success ? StatusDecode(uint.Parse(match.Groups["STS"].Value)) : GGStatusType.NotAvailable;
         user.Name = match.Groups["NAME"].Success ? match.Groups["NAME"].Value : string.Empty;
         user.GGNick = match.Groups["NNAME"].Success ? match.Groups["NNAME"].Value : string.Empty;
         user.BirthYear = match.Groups["BIRTH"].Success ? int.Parse(match.Groups["BIRTH"].Value) : 0;
         user.City = match.Groups["CITY"].Success ? match.Groups["CITY"].Value : string.Empty;
         user.FamilyCity = match.Groups["FCITY"].Success ? match.Groups["FCITY"].Value : string.Empty;
         user.FamilyName = match.Groups["MNAME"].Success ? match.Groups["MNAME"].Value : string.Empty;
         nextStart = match.Groups["NEXT"].Success ? int.Parse(match.Groups["NEXT"].Value) : nextStart;
         reply.Add(user);
     }
     return reply;
 }