예제 #1
0
        private void HandleFriendMoved(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            byte index = dr.ReadByte();
            byte newIndex = dr.ReadByte();

            FriendUser friend = m_friendsList[index];
            friend.Index = newIndex;
            m_friendsList.Insert(newIndex, friend);

            if (newIndex < index)
            {
                for (int i = newIndex + 1; i <= index; i++)
                {
                    m_friendsList[i].Index += 1;
                }
            }
            else if (newIndex > index)
            {
                for (int i = index; i < newIndex; i++)
                {
                    m_friendsList[i].Index -= 1;
                }
            }

            FriendMovedEventArgs args = new FriendMovedEventArgs(friend, newIndex) { EventData = pd };
            OnFriendMoved(args);
        }
예제 #2
0
        private void HandleFriendUpdate(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            byte entry = dr.ReadByte();
            if (m_friendsList.Count <= entry)
            {
                return;
            }
            FriendUser friend = m_friendsList[entry];
            friend.Status = (FriendStatus)dr.ReadByte();
            friend.LocationType = (FriendLocation)dr.ReadByte();
            string prodID = dr.ReadDwordString(0);
            friend.Location = dr.ReadCString();

            if (friend.LocationType != FriendLocation.Offline)
            {
                friend.Product = Product.GetByProductCode(prodID);
            }
            else
            {
                friend.Product = null;
            }

            FriendUpdatedEventArgs args = new FriendUpdatedEventArgs(friend) { EventData = pd };
            OnFriendUpdated(args);
        }
        private void HandleClanMemberInformation(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            int cookie = dr.ReadInt32();
            if (!m_warcraftProfileRequests.ContainsKey(cookie))
            {
                Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Unable to locate profile request with cookie {0:x2}", cookie));
                return;
            }
            WarcraftProfileEventArgs args = m_warcraftProfileRequests[cookie];

            byte success = dr.ReadByte();
            if (success != 0)
            {
                m_warcraftProfileRequests.Remove(cookie);
                ProfileLookupFailedEventArgs profileFailed = new ProfileLookupFailedEventArgs(args.Username, args.Product) { EventData = pd };
                OnProfileLookupFailed(profileFailed);
                return;
            }

            string clanName = dr.ReadCString();
            ClanRank rank = (ClanRank)dr.ReadByte();
            DateTime joined = DateTime.FromFileTime(dr.ReadInt64());

            args.Clan = new ClanProfile(clanName, rank, joined);

            BncsPacket pck = new BncsPacket((byte)BncsPacketId.WarcraftGeneral);
            pck.InsertByte((byte)WarcraftCommands.ClanInfoRequest);
            pck.InsertInt32(cookie);
            pck.InsertDwordString(args.Profile.ClanTag, 0);
            pck.InsertDwordString(args.Product.ProductCode);
            Send(pck);

            BattleNetClientResources.IncomingBufferPool.FreeBuffer(pd.Data);
        }
예제 #4
0
        private void HandleFriendAdded(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            int nextIndex = m_friendsList.Count;
            FriendUser newFriend = __ParseNewFriend(dr, nextIndex);
            m_friendsList.Add(newFriend);

            FriendAddedEventArgs args = new FriendAddedEventArgs(newFriend) { EventData = pd };
            OnFriendAdded(args);
        }
예제 #5
0
        private void HandleClanInfo(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            dr.Seek(1);
            string clanTag = dr.ReadDwordString(0);
            ClanRank rank = (ClanRank)dr.ReadByte();

            ClanMembershipEventArgs args = new ClanMembershipEventArgs(clanTag, rank);
            args.EventData = pd;
            OnClanMembershipReceived(args);

            BncsPacket pck = new BncsPacket((byte)BncsPacketId.ClanMemberList);
            pck.InsertInt32(Interlocked.Increment(ref m_clanCookie));
            Send(pck);
        }
예제 #6
0
        private void HandleFriendRemoved(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            byte index = dr.ReadByte();

            FriendUser removed = m_friendsList[index];
            m_friendsList.RemoveAt(index);

            for (int i = index; i < m_friendsList.Count; i++)
            {
                m_friendsList[i].Index -= 1;
            }

            FriendRemovedEventArgs args = new FriendRemovedEventArgs(removed) { EventData = pd };
            OnFriendRemoved(args);
        }
예제 #7
0
        private void HandleFriendsList(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            int numEntries = dr.ReadByte();
            FriendUser[] list = new FriendUser[numEntries];
            for (int i = 0; i < numEntries; i++)
            {
                FriendUser friend = __ParseNewFriend(dr, i);
                list[i] = friend;
            }

            m_friendsList.AddRange(list);

            Debug.WriteLine("Received friends list; " + list.Length + " user on it.");

            FriendListReceivedEventArgs args = new FriendListReceivedEventArgs(list) { EventData = pd };
            OnFriendListReceived(args);
        }
예제 #8
0
        private void HandleClanRankChange(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            int cookie = dr.ReadInt32();
            string userName = m_clanRankChangeToMemberList[cookie];
            m_clanRankChangeToMemberList.Remove(cookie);
            ClanRankChangeStatus status = (ClanRankChangeStatus)dr.ReadByte();

            ClanRankChangeEventArgs args = new ClanRankChangeEventArgs(userName, status) { EventData = pd };
            OnClanRankChangeResponseReceived(args);
        }
예제 #9
0
 // 0x73
 private void HandleDisbandClan(ParseData pd)
 {
     DataReader dr = new DataReader(pd.Data);
     dr.Seek(4);
     ClanResponseCode status = (ClanResponseCode)dr.ReadByte();
     ClanDisbandEventArgs args = new ClanDisbandEventArgs(status == ClanResponseCode.Success);
     args.EventData = pd;
     OnClanDisbandCompleted(args);
 }
예제 #10
0
		private RazorCodeGenerator(Microsoft.VisualStudio.Text.ITextBuffer buffer, Version razorVersion, string physicalPath, string virtualPath)
		{
			WebEditor.CompositionService.SatisfyImportsOnce(this);
			_parseData = new ParseData();
			_viewBuffer = buffer;
			_viewBuffer.Changed += TextBuffer_OnChanged;
			_viewBuffer.PostChanged += TextBuffer_OnPostChanged;
			_htmlDocument = ServiceManager.GetService<HtmlEditorDocument>(_viewBuffer);
			_htmlDocument.OnDocumentClosing += OnClose;
            _htmlDocument.MassiveChangeEnded += OnMassiveChangeEnded;
			_fullPath = ((!string.IsNullOrEmpty(physicalPath)) ? physicalPath : "Default.cshtml");
			if (virtualPath == null)
			{
				virtualPath = "Default.cshtml";
			}
			_runtimeError = new RazorRuntimeError(_viewBuffer);
			_razorEditorParser = new ShimRazorEditorParserImpl(virtualPath, _fullPath);
			_razorEditorParser.DocumentParseComplete += DocumentParseComplete;
			ReparseFile();
			WebEditor.OnIdle += OnFirstIdle;
			ServiceManager.AddService(this, _viewBuffer);
			ServiceManager.AddService<IRazorCodeGenerator>(this, _viewBuffer);
			ServiceManager.AddService<IContainedCodeGenerator>(this, _viewBuffer);
		}
        private void HandleProfile(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            int cookie = dr.ReadInt32();
            if (!m_warcraftProfileRequests.ContainsKey(cookie))
            {
                Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Unable to locate profile request with cookie {0:x2}", cookie));
                return;
            }
            WarcraftProfileEventArgs args = m_warcraftProfileRequests[cookie];

            byte success = dr.ReadByte();
            if (success != 0)
            {
                m_warcraftProfileRequests.Remove(cookie);
                ProfileLookupFailedEventArgs profileFailed = new ProfileLookupFailedEventArgs(args.Username, args.Product) { EventData = pd };
                OnProfileLookupFailed(profileFailed);
                return;
            }

            string desc = dr.ReadCString();
            string location = dr.ReadCString();
            string tag = dr.ReadDwordString(0);

            WarcraftProfile profile = new WarcraftProfile(desc, location, tag);
            args.Profile = profile;
            if (!string.IsNullOrEmpty(tag))
            {
                BncsPacket pck = new BncsPacket((byte)BncsPacketId.ClanMemberInformation);
                pck.InsertInt32(cookie);
                pck.InsertDwordString(tag, 0);
                pck.InsertCString(args.Username);
                Send(pck);
            }
            else
            {
                BncsPacket pck = new BncsPacket((byte)BncsPacketId.WarcraftGeneral);
                pck.InsertByte((byte)WarcraftCommands.UserInfoRequest);
                pck.InsertInt32(cookie);
                pck.InsertCString(args.Username);
                pck.InsertDwordString(args.Product.ProductCode);
                Send(pck);
            }
            

            BattleNetClientResources.IncomingBufferPool.FreeBuffer(pd.Data);
        }
        private static void CompleteToken(ParseData data)
        {
            bool isVariadic = false;

            if (data.Token.EndsWith("...")) {
                data.Token = data.Token.Substring(0, data.Token.Length - 3);
                isVariadic = true;
            }

            if (data.Token.Length > 0 || isVariadic) {
                if (data.Token.Length > 0)
                    data.Tokens.Add(data.Token);

                if (data.IsParsingValue && data.Token.Length > 0) {
                    CommandParam p;
                    if (data.IsParsingDefaultValue) {
                        CommandReferenceParam refParam = data.RefParamStack
                            .Peek().GetChildren().ElementAt(data.ValParamStack.Peek().ChildCount);
                        p = new CommandParam(refParam);
                        p.SetValueByParse(data.Tokens[0]);
                    }
                    else {
                        p = new CommandParam(data.Tokens[0]);
                    }
                    data.ValParamStack.Peek().AddChild(p);
                    data.Tokens.Clear();
                }
                if (!data.IsParsingValue) {
                    if (data.Token.Length > 0 && data.Tokens.Count == 2) {
                        data.RefParamStack.Peek().AddChild(new CommandReferenceParam() {
                            Type		= ParseCommandParamType(data.Tokens[0]),
                            Name		= data.Tokens[1],
                            IsVariadic	= isVariadic
                        });
                        data.Tokens.Clear();
                    }
                    else if (isVariadic) {
                        data.RefParamStack.Peek().GetChildren().Last().IsVariadic = true;
                    }
                }

                data.Token = "";
            }
        }
예제 #13
0
파일: PgStorage.cs 프로젝트: Prizmer/ps
        private Object GetRecordFromReader(string query, ParseData func_parse_data)
        {
            NpgsqlCommand command = new NpgsqlCommand(query, m_pg_con);
            NpgsqlDataReader dr = null;

            try
            {
                dr = command.ExecuteReader();

                if (dr.HasRows)
                {
                    if (dr.Read())
                    {
                        return (Object)func_parse_data(dr);
                    }
                }
            }
            catch
            {

            }
            finally
            {
                if (dr != null)
                {
                    if (!dr.IsClosed)
                    {
                        dr.Close();
                    }
                }
            }

            return null;
        }
예제 #14
0
        private void HandleClanMemberRankChange(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            ClanRank old = (ClanRank)dr.ReadByte();
            ClanRank newRank = (ClanRank)dr.ReadByte();
            string memberName = dr.ReadCString();
            ClanMember member = null;
            if (m_clanList.ContainsKey(memberName))
                member = m_clanList[memberName];

            ClanMemberRankChangeEventArgs args = new ClanMemberRankChangeEventArgs(old, newRank, member);
            args.EventData = pd;
            OnClanMemberRankChanged(args);
        }
예제 #15
0
        private void HandleClanMemberRemoved(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            string memberName = dr.ReadCString();
            ClanMember member = m_clanList[memberName];
            m_clanList.Remove(memberName);

            ClanMemberStatusEventArgs args = new ClanMemberStatusEventArgs(member) { EventData = pd };
            OnClanMemberRemoved(args);
        }
예제 #16
0
 private void HandleClanMotd(ParseData pd)
 {
     DataReader dr = new DataReader(pd.Data);
     dr.Seek(8);
     string motd = dr.ReadCString();
     InformationEventArgs args = new InformationEventArgs(motd);
     args.EventData = pd;
     OnClanMessageOfTheDay(args);
 }
예제 #17
0
        // 0x72
        private void HandleClanCreationInvitation(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            int cookie = dr.ReadInt32();
            string tag = dr.ReadDwordString(0);
            string name = dr.ReadCString();
            string inviter = dr.ReadCString();
            int inviteeCount = dr.ReadByte();
            string[] invitees = new string[inviteeCount];
            for (int i = 0; i < inviteeCount; i++)
            {
                invitees[i] = dr.ReadCString();
            }

            ClanFormationInvitationEventArgs args = new ClanFormationInvitationEventArgs(cookie, tag, name, inviter, invitees) { EventData = pd };
            OnClanFormationInvitationReceived(args);
        }
예제 #18
0
        // 0x71
        private void HandleClanInviteMultiple(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            dr.Seek(4); // cookie
            ClanResponseCode response = (ClanResponseCode)dr.ReadByte();
            ClanFormationEventArgs args = null;
            if (response == ClanResponseCode.Success)
            {
                args = new ClanFormationEventArgs();
            }
            else
            {
                List<string> names = new List<string>();
                int nextByte = dr.Peek();
                while (nextByte > 0)
                {
                    names.Add(dr.ReadCString());
                    nextByte = dr.Peek();
                }
                args = new ClanFormationEventArgs(response == ClanResponseCode.InvitationDeclined, response == ClanResponseCode.Decline, names.ToArray());
            }
            args.EventData = pd;

            OnClanFormationCompleted(args);
        }
예제 #19
0
        private void HandleClanMemberList(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            dr.Seek(4);
            byte memCount = dr.ReadByte();
            for (int i = 0; i < memCount; i++)
            {
                string userName = dr.ReadCString();
                ClanRank rank = (ClanRank)dr.ReadByte();
                ClanMemberStatus status = (ClanMemberStatus)dr.ReadByte();
                string location = dr.ReadCString();
                m_clanList.Add(userName, new ClanMember(userName, rank, status, location));

            }

            ClanMember[] members = new ClanMember[m_clanList.Count];
            m_clanList.Values.CopyTo(members, 0);

            ClanMemberListEventArgs args = new ClanMemberListEventArgs(members);
            args.EventData = pd;
            OnClanMemberListReceived(args);
        }
예제 #20
0
 private void HandleClanMakeChieftan(ParseData pd)
 {
     DataReader dr = new DataReader(pd.Data);
     dr.Seek(4);
     ClanChieftanChangeResult result = (ClanChieftanChangeResult)dr.ReadByte();
     ClanChieftanChangeEventArgs args = new ClanChieftanChangeEventArgs(result);
     args.EventData = pd;
     OnClanChangeChieftanCompleted(args);
 }
예제 #21
0
        private void HandleClanMemberStatusChanged(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            string userName = dr.ReadCString();
            if (m_clanList.ContainsKey(userName))
            {
                ClanMember member = m_clanList[userName];
                ClanRank rank = (ClanRank)dr.ReadByte();
                ClanMemberStatus status = (ClanMemberStatus)dr.ReadByte();
                string location = dr.ReadCString();
                member.Rank = rank;
                member.CurrentStatus = status;
                member.Location = location;

                ClanMemberStatusEventArgs args = new ClanMemberStatusEventArgs(member);
                args.EventData = pd;
                OnClanMemberStatusChanged(args);
            }
        }
예제 #22
0
 private void HandleClanQuitNotify(ParseData pd)
 {
     bool removed = (pd.Data[0] == 1);
     LeftClanEventArgs args = new LeftClanEventArgs(removed) { EventData = pd };
     OnLeftClan(args);
 }
 private static void CompleteDefaultValue(ParseData data)
 {
     // Finish parsing the default value.
     if (data.IsParsingValue && data.IsParsingDefaultValue && data.ValParamStack.Count == 1) {
         data.IsParsingValue = false;
         data.IsParsingDefaultValue = false;
         data.RefParamStack.Pop();
         data.RefParamStack.Peek().GetChildren().Last().DefaultValue =
             data.ValParamStack.Peek().Children;
         data.ValParamStack.Clear();
     }
 }
예제 #24
0
        private void HandleClanInvitation(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            int cookie = dr.ReadInt32();
            ClanInvitationResponse response = (ClanInvitationResponse)dr.ReadByte();

            ClanInvitationResponseEventArgs args = new ClanInvitationResponseEventArgs(cookie, response) { EventData = pd };
            OnClanInvitationResponseReceived(args);
        }
        private static ParseData ParseParameters(string format, bool parseValue)
        {
            ParseData parseData = new ParseData();
            parseData.RefParamStack		= new Stack<CommandReferenceParam>();
            parseData.ValParamStack		= new Stack<CommandParam>();
            parseData.Tokens			= new List<string>();
            parseData.Token				= "";
            parseData.IsParsingValue	= parseValue;

            // Create the root parameter.
            if (parseData.IsParsingValue)
                parseData.ValParamStack.Push(new CommandParam(CommandParamType.Array));
            else
                parseData.RefParamStack.Push(new CommandReferenceParam(CommandParamType.Array));

            // Parse the format, character by character.
            bool quotes = false;
            for (int i = 0; i < format.Length; i++) {
                char c = format[i];

                // Parse strings between quotes.
                if (quotes) {
                    if (c == '"') {
                        quotes = false;
                        CompleteToken(parseData);
                    }
                    else
                        parseData.Token += c;
                }
                else if (c == '"')
                    quotes = true;

                // Whitespace.
                else if (c == ' ' || c == '\t')
                    CompleteToken(parseData);

                // Parameter delimiter (comma)
                else if (c == ',') {
                    CompleteToken(parseData);
                    CompleteDefaultValue(parseData);
                }

                // Parameter array begin
                else if (c == '(') {
                    if (parseData.IsParsingValue) {
                        if (parseData.IsParsingDefaultValue) {
                            parseData.RefParamStack.Push(parseData.RefParamStack.Peek()
                                .GetChildren().ElementAt(parseData.ValParamStack.Peek().ChildCount));
                        }
                        parseData.ValParamStack.Push(parseData.ValParamStack.Peek()
                            .AddChild(new CommandParam(CommandParamType.Array)));
                    }
                    else {
                        parseData.RefParamStack.Push(parseData.RefParamStack.Peek()
                            .AddChild(new CommandReferenceParam(CommandParamType.Array)));
                    }
                }

                // Parameter array end.
                else if (c == ')') {
                    CompleteToken(parseData);
                    if (parseData.IsParsingValue)
                        parseData.ValParamStack.Pop();
                    if (!parseData.IsParsingValue || (parseData.IsParsingValue && parseData.IsParsingDefaultValue))
                        parseData.RefParamStack.Pop();
                }

                // Default parameter value.
                else if (c == '=') {
                    parseData.IsParsingValue = true;
                    parseData.IsParsingDefaultValue = true;
                    CommandReferenceParam refParent = new CommandReferenceParam(CommandParamType.Array);
                    refParent.AddChild(parseData.RefParamStack.Peek().GetChildren().Last());
                    parseData.RefParamStack.Push(refParent);
                    parseData.ValParamStack.Push(new CommandParam(CommandParamType.Array));
                }
                //else if (c == '.') { TODO: variadic parameters.
                //}
                else {
                    parseData.Token += c;
                }
            }

            CompleteToken(parseData);
            CompleteDefaultValue(parseData);

            return parseData;
        }
예제 #26
0
        private void HandleClanRemoveMember(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            int reqID = dr.ReadInt32();
            ClanMemberRemovalResponse response = (ClanMemberRemovalResponse)dr.ReadByte();

            ClanRemovalResponseEventArgs args = new ClanRemovalResponseEventArgs(reqID, response) { EventData = pd };
            OnClanRemovalResponse(args);
        }
예제 #27
0
파일: PgStorage.cs 프로젝트: Prizmer/ps
        private List<Object> GetRecordsFromReader(string query, ParseData func_parse_data)
        {
            List<Object> result = new List<Object>();

            NpgsqlCommand command = new NpgsqlCommand(query, m_pg_con);
            NpgsqlDataReader dr = null;

            try
            {
                dr = command.ExecuteReader();

                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        result.Add((Object)func_parse_data(dr));
                    }
                }
            }
            catch (Exception e)
            {

            }
            finally
            {
                if (dr != null)
                {
                    if (!dr.IsClosed)
                    {
                        dr.Close();
                    }
                }
            }

            return result;
        }
예제 #28
0
        private void HandleClanInvitationResponse(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            int cookie = dr.ReadInt32();
            string tag = dr.ReadDwordString(0);
            string name = dr.ReadCString();
            string inviter = dr.ReadCString();

            ClanInvitationEventArgs args = new ClanInvitationEventArgs(cookie, tag, name, inviter) { EventData = pd };
            OnClanInvitationReceived(args);
        }
예제 #29
0
		private void Close()
		{
			if (_parseData == null)
			{
				return;
			}
            ParseData parseData = _parseData;
			lock (parseData)
			{
				_fullPath = null;
				_htmlDocument.OnDocumentClosing -= OnClose;
				_htmlDocument.MassiveChangeEnded -= OnMassiveChangeEnded;
				_htmlDocument = null;
				ServiceManager.RemoveService<RazorCodeGenerator>(_viewBuffer);
				ServiceManager.RemoveService<IRazorCodeGenerator>(_viewBuffer);
				ServiceManager.RemoveService<IContainedCodeGenerator>(_viewBuffer);
				_parseData = null;
				_runtimeError.Close();
				_viewBuffer.Changed -= TextBuffer_OnChanged;
				_viewBuffer.PostChanged -= TextBuffer_OnPostChanged;
				SetProvisionallyAcceptedState(false);
				_viewBuffer = null;
				if (_razorEditorParser != null)
				{
					_razorEditorParser.DocumentParseComplete -= DocumentParseComplete;
					_razorEditorParser.Close();
					_razorEditorParser = null;
				}
			}
		}
예제 #30
0
        private void HandleClanFindCandidates(ParseData pd)
        {
            DataReader dr = new DataReader(pd.Data);
            dr.Seek(4); // skip the cookie
            ClanCandidatesSearchStatus status = (ClanCandidatesSearchStatus)dr.ReadByte();
            int numCandidates = dr.ReadByte();
            string[] usernames = new string[numCandidates];
            for (int i = 0; i < numCandidates; i++)
            {
                usernames[i] = dr.ReadCString();
            }

            ClanCandidatesSearchEventArgs args = new ClanCandidatesSearchEventArgs(status, usernames);
            args.EventData = pd;
            OnClanCandidatesSearchCompleted(args);
        }