Beispiel #1
0
        public override void Parse()
        {
            base.Parse();

            if (RequestKeyValues.ContainsKey(""))
            {
            }
            //cpubrandid
            //cpuspeed
            //memory
            //videocard1ram
            //videocard2ram
            //connectionid
            //connectionspeed
            //hasnetwork
            //pic
        }
        public override void Parse()
        {
            base.Parse();

            if (!RequestKeyValues.ContainsKey("delprofileid"))
            {
                throw new GPParseException("delprofileid is missing.");
            }

            int deleteProfileID;

            if (!int.TryParse(RequestKeyValues["delprofileid"], out deleteProfileID))
            {
                throw new GPParseException("delprofileid format is incorrect.");
            }

            DeleteProfileID = deleteProfileID;
        }
Beispiel #3
0
        public override void Parse()
        {
            base.Parse();

            if (!RequestKeyValues.ContainsKey("profileid"))
            {
                throw new GPParseException("profileid is missing");
            }

            int profileID;

            if (!int.TryParse(RequestKeyValues["profileid"], out profileID))
            {
                throw new GPParseException("profileid format is incorrect");
            }

            ProfileId = profileID;
        }
Beispiel #4
0
 private void ParseOtherInfo()
 {
     //parse other info
     if (RequestKeyValues.ContainsKey("partnerid"))
     {
         int partnerid;
         if (!int.TryParse(RequestKeyValues["partnerid"], out partnerid))
         {
             throw new GPParseException("partnerid is incorrect.");
         }
         HasPartnerIDFlag = true;
         PartnerID        = partnerid;
     }
     if (RequestKeyValues.ContainsKey("productid"))
     {
         int productid;
         if (!int.TryParse(RequestKeyValues["productid"], out productid))
         {
             throw new GPParseException("productid is incorrect.");
         }
         HasProductIDFlag = true;
         ProductID        = productid;
     }
     if (RequestKeyValues.ContainsKey("gamename"))
     {
         HasGameNameFlag = true;
         GameName        = RequestKeyValues["gamename"];
     }
     if (RequestKeyValues.ContainsKey("port"))
     {
         int port;
         if (!int.TryParse(RequestKeyValues["port"], out port))
         {
             throw new GPParseException("port is incorrect.");
         }
         HasGamePortFlag = true;
         GamePort        = port;
     }
     if (RequestKeyValues.ContainsKey("cdkey"))
     {
         HasCDKeyEncFlag = true;
         CDKey           = RequestKeyValues["cdkey"];
     }
 }
        public override void Parse()
        {
            base.Parse();


            if (!RequestKeyValues.ContainsKey("sesskey") || !RequestKeyValues.ContainsKey("newprofileid") || !RequestKeyValues.ContainsKey("reason"))
            {
                throw new GPParseException("addbuddy request is invalid.");
            }

            int friendPID;

            if (!int.TryParse(RequestKeyValues["newprofileid"], out friendPID))
            {
                throw new GPParseException("newprofileid format is incorrect.");
            }

            FriendProfileID = friendPID;
            Reason          = RequestKeyValues["reason"];
        }
        public override void Parse()
        {
            base.Parse();
            Password = PasswordEncoder.ProcessPassword(RequestKeyValues);
            if (!RequestKeyValues.ContainsKey("nick") || !RequestKeyValues.ContainsKey("email") || Password is null)
            {
                throw new GPParseException("check request is incompelete.");
            }

            if (!GameSpyUtils.IsEmailFormatCorrect(RequestKeyValues["email"]))
            {
                throw new GPParseException("email format is incorrect");
            }

            Nick  = RequestKeyValues["nick"];
            Email = RequestKeyValues["email"];

            if (RequestKeyValues.ContainsKey("partnerid"))
            {
                PartnerId = int.Parse(RequestKeyValues["partnerid"]);
            }
        }
        public override void Parse()
        {
            base.Parse();


            if (!RequestKeyValues.ContainsKey("email") && !GameSpyUtils.IsEmailFormatCorrect(RequestKeyValues["email"]))
            {
                throw new GPParseException("valid request is incomplete.");
            }

            Email = RequestKeyValues["email"];

            if (RequestKeyValues.ContainsKey("namespaceid"))
            {
                int namespaceID;
                if (!int.TryParse(RequestKeyValues["namespaceid"], out namespaceID))
                {
                    throw new GPParseException("namespaceid is incorrect.");
                }

                NamespaceID = namespaceID;
            }
        }
        public override void Parse()
        {
            base.Parse();


            if (!RequestKeyValues.ContainsKey("gamename"))
            {
                throw new GPParseException("gamename is missing.");
            }

            if (!RequestKeyValues.ContainsKey("profileid") || !RequestKeyValues.ContainsKey("namespaceid"))
            {
                throw new GPParseException("profileid or namespaceid is missing.");
            }

            int profileID = 0;

            if (!RequestKeyValues.ContainsKey("profileid") && !int.TryParse(RequestKeyValues["profileid"], out profileID))
            {
                throw new GPParseException("profileid is incorrect.");
            }

            if (RequestKeyValues.ContainsKey("namespaceid"))
            {
                int namespaceID;
                if (!int.TryParse(RequestKeyValues["namespaceid"], out namespaceID))
                {
                    throw new GPParseException("namespaceid is incorrect.");
                }

                NamespaceID = namespaceID;
            }

            ProfileId = profileID;
            GameName  = RequestKeyValues["gamename"];
        }
        public override void Parse()
        {
            base.Parse();
            Password = PasswordEncoder.ProcessPassword(RequestKeyValues);

            if (!RequestKeyValues.ContainsKey("nick"))
            {
                throw new GPParseException("nickname is missing.");
            }
            Nick = RequestKeyValues["nick"];

            if (!RequestKeyValues.ContainsKey("email"))
            {
                throw new GPParseException("email is missing.");
            }
            if (!GameSpyUtils.IsEmailFormatCorrect(RequestKeyValues["email"]))
            {
                throw new GPParseException("email format is incorrect.");
            }
            Email = RequestKeyValues["email"];

            if (RequestKeyValues.ContainsKey("uniquenick") && RequestKeyValues.ContainsKey("namespaceid"))
            {
                if (RequestKeyValues.ContainsKey("namespaceid"))
                {
                    int namespaceID;
                    if (!int.TryParse(RequestKeyValues["namespaceid"], out namespaceID))
                    {
                        throw new GPParseException("namespaceid is incorrect.");
                    }
                    NamespaceID = namespaceID;
                }
                Uniquenick = RequestKeyValues["uniquenick"];
            }
            ParseOtherInfo();
        }
        public override void Parse()
        {
            base.Parse();


            if (!RequestKeyValues.ContainsKey("profileid") &&
                !RequestKeyValues.ContainsKey("nick") &&
                !RequestKeyValues.ContainsKey("email") &&
                !RequestKeyValues.ContainsKey("namespaceid") &&
                !RequestKeyValues.ContainsKey("gamename"))
            {
                throw new GPParseException(" Search request is incomplete.");
            }

            if (RequestKeyValues.ContainsKey("gamename"))
            {
                GameName = RequestKeyValues["gamename"];
            }

            if (RequestKeyValues.ContainsKey("profileid"))
            {
                int profileID;
                if (!int.TryParse(RequestKeyValues["profileid"], out profileID))
                {
                    throw new GPParseException("profileid is incorrect.");
                }
                ProfileId = profileID;
            }

            if (RequestKeyValues.ContainsKey("partnerid"))
            {
                int partnerID;
                if (!int.TryParse(RequestKeyValues["partnerid"], out partnerID))
                {
                    throw new GPParseException("partnerid is incorrect.");
                }
                PartnerID = partnerID;
            }

            if (RequestKeyValues.ContainsKey("skip"))
            {
                int skip;
                if (!int.TryParse(RequestKeyValues["skip"], out skip))
                {
                    throw new GPParseException("skip number is incorrect.");
                }
                SkipNum = skip;
            }

            if (RequestKeyValues.ContainsKey("uniquenick") && RequestKeyValues.ContainsKey("namespaceid"))
            {
                if (RequestKeyValues.ContainsKey("namespaceid"))
                {
                    int namespaceID;
                    if (!int.TryParse(RequestKeyValues["namespaceid"], out namespaceID))
                    {
                        throw new GPParseException("namespaceid is incorrect.");
                    }
                    NamespaceID = namespaceID;
                }
                RequestType = SearchRequestType.UniquenickNamespaceIDSearch;

                Uniquenick = RequestKeyValues["uniquenick"];
            }
            else if (RequestKeyValues.ContainsKey("nick") && RequestKeyValues.ContainsKey("email"))
            {
                RequestType = SearchRequestType.NickEmailSearch;
                Nick        = RequestKeyValues["nick"];
                Email       = RequestKeyValues["email"];
            }
            else if (RequestKeyValues.ContainsKey("nick"))
            {
                RequestType = SearchRequestType.NickSearch;
                Nick        = RequestKeyValues["nick"];
            }
            else if (RequestKeyValues.ContainsKey("email"))
            {
                //\search\\sesskey\0\profileid\0\namespaceid\1\email\[email protected]\gamename\conflictsopc\final\
                Email       = RequestKeyValues["email"];
                RequestType = SearchRequestType.EmailSearch;
            }
            else
            {
                throw new GPParseException("unknown search request type.");
            }
        }
        public override void Parse()
        {
            base.Parse();

            if (RequestKeyValues.ContainsKey("publicmask"))
            {
                PublicMasks mask;
                if (!Enum.TryParse(RequestKeyValues["publicmask"], out mask))
                {
                    throw new GPParseException("publicmask format is incorrect");
                }
                HasPublicMaskFlag = true;
                PublicMask        = mask;
            }

            if (!RequestKeyValues.ContainsKey("sesskey"))
            {
                throw new GPParseException("sesskey is missing");
            }
            SessionKey = RequestKeyValues["sesskey"];

            if (RequestKeyValues.ContainsKey("firstname"))
            {
                FirstName        = RequestKeyValues["firstname"];
                HasFirstNameFlag = true;
            }

            if (RequestKeyValues.ContainsKey("lastname"))
            {
                LastName        = RequestKeyValues["lastname"];
                HasLastNameFlag = true;
            }

            if (RequestKeyValues.ContainsKey("icquin"))
            {
                int icq;
                if (!int.TryParse(RequestKeyValues["icquin"], out icq))
                {
                    throw new GPParseException("icquin format is incorrect");
                }
                HasICQFlag = true;
                ICQUIN     = icq;
            }


            if (RequestKeyValues.ContainsKey("homepage"))
            {
                HasHomePageFlag = true;
                HomePage        = RequestKeyValues["homepage"];
            }

            if (RequestKeyValues.ContainsKey("birthday"))
            {
                int date;

                if (int.TryParse(RequestKeyValues["birthday"], out date))
                {
                    int    d = ((date >> 24) & 0xFF);
                    ushort m = (ushort)((date >> 16) & 0xFF);
                    ushort y = (ushort)(date & 0xFFFF);

                    if (GameSpyUtils.IsValidDate(d, m, y))
                    {
                        BirthDay   = d;
                        BirthMonth = m;
                        BirthYear  = y;
                    }
                }
            }
            if (RequestKeyValues.ContainsKey("sex"))
            {
                byte sex;

                if (!byte.TryParse(RequestKeyValues["sex"], out sex))
                {
                    throw new GPParseException("sex format is incorrect");
                }
                HasSexFlag = true;
                Sex        = sex;
            }

            if (RequestKeyValues.ContainsKey("zipcode"))
            {
                HasZipCode = true;
                ZipCode    = RequestKeyValues["zipcode"];
            }

            if (RequestKeyValues.ContainsKey("countrycode"))
            {
                HasCountryCode = true;
                CountryCode    = RequestKeyValues["countrycode"];
            }

            if (RequestKeyValues.ContainsKey("partnerid"))
            {
                int partnerid;
                if (!int.TryParse(RequestKeyValues["partnerid"], out partnerid))
                {
                    throw new GPParseException("partnerid is incorrect");
                }
                PartnerID = partnerid;
            }

            if (!RequestKeyValues.ContainsKey("nick"))
            {
                throw new GPParseException("nickname is missing.");
            }
            Nick = RequestKeyValues["nick"];

            if (!RequestKeyValues.ContainsKey("uniquenick"))
            {
                throw new GPParseException("uniquenick is missing.");
            }
            Uniquenick = RequestKeyValues["uniquenick"];
        }
        public override void Parse()
        {
            base.Parse();


            if (!RequestKeyValues.ContainsKey("challenge"))
            {
                throw new GPParseException("challenge is missing");
            }

            if (!RequestKeyValues.ContainsKey("response"))
            {
                throw new GPParseException("response is missing");
            }

            UserChallenge = RequestKeyValues["challenge"];
            Response      = RequestKeyValues["response"];

            if (RequestKeyValues.ContainsKey("uniquenick") && RequestKeyValues.ContainsKey("namespaceid"))
            {
                int namespaceID;
                if (!int.TryParse(RequestKeyValues["namespaceid"], out namespaceID))
                {
                    throw new GPParseException("namespaceid format is incorrect");
                }
                Type        = LoginType.UniquenickNamespaceID;
                UniqueNick  = RequestKeyValues["uniquenick"];
                UserData    = UniqueNick;
                NamespaceID = namespaceID;
            }
            else if (RequestKeyValues.ContainsKey("authtoken"))
            {
                Type      = LoginType.AuthToken;
                AuthToken = RequestKeyValues["authtoken"];
                UserData  = AuthToken;
            }
            else if (RequestKeyValues.ContainsKey("user"))
            {
                Type     = LoginType.NickEmail;
                UserData = RequestKeyValues["user"];

                int Pos = UserData.IndexOf('@');
                if (Pos == -1 || Pos < 1 || (Pos + 1) >= UserData.Length)
                {
                    throw new GPParseException("user format is incorrect");
                }
                Nick  = UserData.Substring(0, Pos);
                Email = UserData.Substring(Pos + 1);

                // we need to get namespaceid for email login
                if (RequestKeyValues.ContainsKey("namespaceid"))
                {
                    int namespaceID;
                    if (!int.TryParse(RequestKeyValues["namespaceid"], out namespaceID))
                    {
                        throw new GPParseException("namespaceid format is incorrect");
                    }
                    NamespaceID = namespaceID;
                }
            }
            else
            {
                throw new GPParseException("Unknown login method detected.");
            }

            ParseOtherData();
        }
        private void ParseOtherData()
        {
            if (RequestKeyValues.ContainsKey("userid"))
            {
                int userID;
                if (!int.TryParse(RequestKeyValues["userid"], out userID))
                {
                    throw new GPParseException("partnerid format is incorrect");
                }
                UserID = userID;
            }
            if (RequestKeyValues.ContainsKey("profileid"))
            {
                int profileID;
                if (!int.TryParse(RequestKeyValues["profileid"], out profileID))
                {
                    throw new GPParseException("profileid format is incorrect");
                }
                ProfileId = profileID;
            }
            if (RequestKeyValues.ContainsKey("partnerid"))
            {
                int partnerID;
                if (!int.TryParse(RequestKeyValues["partnerid"], out partnerID))
                {
                    throw new GPParseException("partnerid format is incorrect");
                }
                PartnerID = partnerID;
            }

            //store sdkrevision
            if (RequestKeyValues.ContainsKey("sdkrevision"))
            {
                int sdkRevisionType;
                if (!int.TryParse(RequestKeyValues["sdkrevision"], out sdkRevisionType))
                {
                    throw new GPParseException("sdkrevision format is incorrect");
                }

                SdkRevisionType = (SdkRevisionType)sdkRevisionType;
            }

            if (RequestKeyValues.ContainsKey("gamename"))
            {
                GameName = RequestKeyValues["gamename"];
            }

            if (RequestKeyValues.ContainsKey("port"))
            {
                int htonGamePort;
                if (!int.TryParse(RequestKeyValues["port"], out htonGamePort))
                {
                    throw new GPParseException("port format is incorrect");
                }
                GamePort = htonGamePort;
            }
            if (RequestKeyValues.ContainsKey("productid"))
            {
                int productID;
                if (!int.TryParse(RequestKeyValues["productid"], out productID))
                {
                    throw new GPParseException("productid format is incorrect");
                }
                ProductID = productID;
            }

            if (RequestKeyValues.ContainsKey("firewall"))
            {
                Firewall = RequestKeyValues["firewall"];
            }

            if (RequestKeyValues.ContainsKey("quiet"))
            {
                int quiet;
                if (!int.TryParse(RequestKeyValues["quiet"], out quiet))
                {
                    throw new GPParseException("quiet format is incorrect");
                }

                QuietModeFlags = (QuietModeType)quiet;
            }
        }