/// <summary> /// Handle Capabilities /// </summary> private void ProxyManager_OnMessageLog(CapsRequest req, CapsStage stage) { if (this.InvokeRequired) { this.BeginInvoke(new MethodInvoker(() => ProxyManager_OnMessageLog(req, stage))); } else { ListViewItem found = FindListViewItem(listViewMessageFilters, req.Info.CapType, false); if (found != null && found.Checked) { PacketCounter++; int size = 0; string contentType = String.Empty; if (req.RawRequest != null) { size += req.RawRequest.Length; contentType = req.RequestHeaders.Get("Content-Type"); //req.RequestHeaders["Content-Type"]; } if (req.RawResponse != null) { size += req.RawResponse.Length; contentType = req.ResponseHeaders.Get("Content-Type"); } Direction direction; if (stage == CapsStage.Request) { CapsOutCounter++; CapsOutBytes += req.Request.ToString().Length; direction = Direction.Outgoing; } else { CapsInCounter++; CapsInBytes += req.Response.ToString().Length; direction = Direction.Incoming; } string proto = found.SubItems[1].Text; Session capsSession = null; if (found.Group.Header.Equals("Capabilities")) { capsSession = new SessionCaps(req.RawRequest, req.RawResponse, req.RequestHeaders, req.ResponseHeaders, direction, req.Info.URI, req.Info.CapType, proto); } else { capsSession = new SessionEvent(req.RawResponse, req.ResponseHeaders, req.Info.URI, req.Info.CapType, proto); } string[] s = { PacketCounter.ToString(), capsSession.Protocol, capsSession.Name, capsSession.Length.ToString(), capsSession.Host, capsSession.ContentType }; ListViewItem session = new ListViewItem(s); session.ImageIndex = (int)direction; session.Tag = capsSession; session.BackColor = found.BackColor; m_SessionViewItems.Add(capsSession); } else { if (found == null) { // must be a new event not in KnownCaps, lets add it to the listview ListViewItem addedItem = listViewMessageFilters.Items.Add(new ListViewItem(req.Info.CapType)); addedItem.BackColor = Color_Cap; if (autoAddNewDiscoveredMessagesToolStripMenuItem.Checked) addedItem.Checked = true; } } } }
private bool FixupEventQueueGet(CapsRequest capReq, CapsStage stage) { if (stage != CapsStage.Response) return false; OSDMap map = (OSDMap)capReq.Response; OSDArray array = (OSDArray)map["events"]; for (int i = 0; i < array.Count; i++) { OSDMap evt = (OSDMap)array[i]; string message = evt["message"].AsString(); OSDMap body = (OSDMap)evt["body"]; if (message == "TeleportFinish" || message == "CrossedRegion") { OSDMap info = null; if (message == "TeleportFinish") info = (OSDMap)(((OSDArray)body["Info"])[0]); else info = (OSDMap)(((OSDArray)body["RegionData"])[0]); byte[] bytes = info["SimIP"].AsBinary(); uint simIP = Utils.BytesToUInt(bytes); ushort simPort = (ushort)info["SimPort"].AsInteger(); string capsURL = info["SeedCapability"].AsString(); GenericCheck(ref simIP, ref simPort, ref capsURL, capReq.Info.Sim == activeCircuit); info["SeedCapability"] = OSD.FromString(capsURL); bytes[0] = (byte)(simIP % 256); bytes[1] = (byte)((simIP >> 8) % 256); bytes[2] = (byte)((simIP >> 16) % 256); bytes[3] = (byte)((simIP >> 24) % 256); info["SimIP"] = OSD.FromBinary(bytes); info["SimPort"] = OSD.FromInteger(simPort); } else if (message == "EnableSimulator") { OSDMap info = null; info = (OSDMap)(((OSDArray)body["SimulatorInfo"])[0]); byte[] bytes = info["IP"].AsBinary(); uint IP = Utils.BytesToUInt(bytes); ushort Port = (ushort)info["Port"].AsInteger(); string capsURL = null; GenericCheck(ref IP, ref Port, ref capsURL, capReq.Info.Sim == activeCircuit); bytes[0] = (byte)(IP % 256); bytes[1] = (byte)((IP >> 8) % 256); bytes[2] = (byte)((IP >> 16) % 256); bytes[3] = (byte)((IP >> 24) % 256); info["IP"] = OSD.FromBinary(bytes); info["Port"] = OSD.FromInteger(Port); } else if (message == "EstablishAgentCommunication") { string ipAndPort = body["sim-ip-and-port"].AsString(); string[] pieces = ipAndPort.Split(':'); byte[] bytes = IPAddress.Parse(pieces[0]).GetAddressBytes(); uint simIP = Utils.BytesToUInt(bytes); ushort simPort = (ushort)Convert.ToInt32(pieces[1]); string capsURL = body["seed-capability"].AsString(); OpenMetaverse.Logger.Log("DEBUG: Got EstablishAgentCommunication for " + ipAndPort + " with seed cap " + capsURL, Helpers.LogLevel.Debug); GenericCheck(ref simIP, ref simPort, ref capsURL, false); body["seed-capability"] = OSD.FromString(capsURL); string ipport = String.Format("{0}:{1}", new IPAddress(simIP), simPort); body["sim-ip-and-port"] = OSD.FromString(ipport); OpenMetaverse.Logger.Log("DEBUG: Modified EstablishAgentCommunication to " + body["sim-ip-and-port"].AsString() + " with seed cap " + capsURL, Helpers.LogLevel.Debug); } } return false; }
/// <summary> /// Adds a new EventQueue message to the Message Filters listview. /// </summary> /// <param name="req"></param> /// <param name="stage"></param> void ProxyManager_OnEventMessageLog(CapsRequest req, CapsStage stage) { if (this.InvokeRequired) { this.BeginInvoke(new MethodInvoker(() => ProxyManager_OnEventMessageLog(req, stage))); } else { ListViewItem foundCap = FindListViewItem(listViewMessageFilters, req.Info.CapType, false); if (foundCap == null) { ListViewItem addedItem = listViewMessageFilters.Items.Add(new ListViewItem(req.Info.CapType, listViewMessageFilters.Groups["EventQueueMessages"])); addedItem.SubItems.Add(PROTO_EVENTMESSAGE); addedItem.BackColor = Color_Event; if (autoAddNewDiscoveredMessagesToolStripMenuItem.Checked) addedItem.Checked = true; } else { ProxyManager_OnMessageLog(req, CapsStage.Response); } } }
private bool FixupSeedCapsResponse(CapsRequest capReq, CapsStage stage) { if (stage != CapsStage.Response) return false; OSDMap nm = new OSDMap(); if (capReq.Response.Type == OSDType.Map) { OSDMap m = (OSDMap)capReq.Response; foreach (string key in m.Keys) { string val = m[key].AsString(); if (!String.IsNullOrEmpty(val)) { if (!KnownCaps.ContainsKey(val)) { CapInfo newCap = new CapInfo(val, capReq.Info.Sim, key); newCap.AddDelegate(new CapsDelegate(KnownCapDelegate)); lock (this) { KnownCaps[val] = newCap; } } nm[key] = OSD.FromString(loginURI + val); } else { nm[key] = OSD.FromString(val); } } } capReq.Response = nm; return false; }
private bool KnownCapDelegate(CapsRequest capReq, CapsStage stage) { lock (this) { if (!KnownCapsDelegates.ContainsKey(capReq.Info.CapType)) return false; if (stage == CapsStage.Response) { if (capReq.Response != null) { OSDMap map = (OSDMap)capReq.Response; if (map.ContainsKey("uploader")) { string val = map["uploader"].AsString(); if (!KnownCaps.ContainsKey(val)) { CapInfo newCap = new CapInfo(val, capReq.Info.Sim, capReq.Info.CapType, CapsDataFormat.Binary, CapsDataFormat.OSD); newCap.AddDelegate(new CapsDelegate(KnownCapDelegate)); lock (this) { KnownCaps[val] = newCap; } } map["uploader"] = OSD.FromString(loginURI + val); } } } List<CapsDelegate> delegates = KnownCapsDelegates[capReq.Info.CapType]; foreach (CapsDelegate d in delegates) { if (d(capReq, stage)) { return true; } } } return false; }
private bool KnownCapDelegate(CapsRequest capReq, CapsStage stage) { lock (this) { if (!KnownCapsDelegates.ContainsKey(capReq.Info.CapType)) return false; List<CapsDelegate> delegates = KnownCapsDelegates[capReq.Info.CapType]; foreach (CapsDelegate d in delegates) { if (d(capReq, stage)) { return true; } } } return false; }
//private Dictionary<string, bool> SubHack = new Dictionary<string, bool>(); private void ProxyCaps(NetworkStream netStream, string meth, string uri, Dictionary<string, string> headers, byte[] content, int reqNo) { Match match = new Regex(@"^(https?)://([^:/]+)(:\d+)?(/.*)$").Match(uri); if (!match.Success) { OpenMetaverse.Logger.Log("[" + reqNo + "] Malformed proxy URI: " + uri, Helpers.LogLevel.Error); byte[] wr = Encoding.ASCII.GetBytes("HTTP/1.0 404 Not Found\r\nContent-Length: 0\r\n\r\n"); netStream.Write(wr, 0, wr.Length); return; } CapInfo cap = null; lock (this) { if (KnownCaps.ContainsKey(uri)) { cap = KnownCaps[uri]; } } CapsRequest capReq = null; bool shortCircuit = false; bool requestFailed = false; if (cap != null) { capReq = new CapsRequest(cap); if (cap.ReqFmt == CapsDataFormat.OSD) { capReq.Request = OSDParser.DeserializeLLSDXml(content); } else { capReq.Request = OSDParser.DeserializeLLSDXml(content); } capReq.RawRequest = content; foreach (CapsDelegate d in cap.GetDelegates()) { if (d(capReq, CapsStage.Request)) { shortCircuit = true; break; } } if (cap.ReqFmt == CapsDataFormat.OSD) { content = OSDParser.SerializeLLSDXmlBytes((OSD)capReq.Request); } } byte[] respBuf = null; string consoleMsg = String.Empty; if (shortCircuit) { byte[] wr = Encoding.UTF8.GetBytes("HTTP/1.0 200 OK\r\n"); netStream.Write(wr, 0, wr.Length); } else { HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(uri); req.KeepAlive = false; foreach (string header in headers.Keys) { if (header == "accept" || header == "connection" || header == "content-length" || header == "date" || header == "expect" || header == "host" || header == "if-modified-since" || header == "referer" || header == "transfer-encoding" || header == "user-agent" || header == "proxy-connection") { // can't touch these! } else if (header == "content-type") { req.ContentType = headers["content-type"]; } else { req.Headers[header] = headers[header]; } } if (capReq == null) { // this probably occured when we shut down the proxy and restarted it and are receiving // data from a dead connection return; } capReq.RequestHeaders = req.Headers; req.Method = meth; // can't do gets on requests with a content body // without throwing a protocol exception. So force it to post // incase our parser stupidly set it to GET due to the viewer // doing something stupid like sending an empty request if(content.Length > 0) req.Method = "POST"; req.ContentLength = content.Length; HttpWebResponse resp; try { Stream reqStream = req.GetRequestStream(); reqStream.Write(content, 0, content.Length); reqStream.Close(); resp = (HttpWebResponse)req.GetResponse(); } catch (WebException e) { if (e.Status == WebExceptionStatus.Timeout || e.Status == WebExceptionStatus.SendFailure) { OpenMetaverse.Logger.Log("Request timeout", Helpers.LogLevel.Warning, e); byte[] wr = Encoding.ASCII.GetBytes("HTTP/1.0 504 Proxy Request Timeout\r\nContent-Length: 0\r\n\r\n"); netStream.Write(wr, 0, wr.Length); return; } else if (e.Status == WebExceptionStatus.ProtocolError && e.Response != null) { resp = (HttpWebResponse)e.Response; requestFailed = true; } else { OpenMetaverse.Logger.Log("Request error", Helpers.LogLevel.Error, e); byte[] wr = Encoding.ASCII.GetBytes("HTTP/1.0 502 Gateway Error\r\nContent-Length: 0\r\n\r\n"); // FIXME netStream.Write(wr, 0, wr.Length); return; } } try { Stream respStream = resp.GetResponseStream(); int read; int length = 0; respBuf = new byte[256]; do { read = respStream.Read(respBuf, length, 256); if (read > 0) { length += read; Array.Resize(ref respBuf, length + 256); } } while (read > 0); Array.Resize(ref respBuf, length); if (capReq != null && !requestFailed) { if (cap.RespFmt == CapsDataFormat.OSD) { capReq.Response = OSDParser.DeserializeLLSDXml(respBuf); } else { capReq.Response = OSDParser.DeserializeLLSDXml(respBuf); } capReq.RawResponse = respBuf; } consoleMsg += "[" + reqNo + "] Response from " + uri + "\nStatus: " + (int)resp.StatusCode + " " + resp.StatusDescription + "\n"; { byte[] wr = Encoding.UTF8.GetBytes("HTTP/1.0 " + (int)resp.StatusCode + " " + resp.StatusDescription + "\r\n"); netStream.Write(wr, 0, wr.Length); } capReq.ResponseHeaders = resp.Headers; for (int i = 0; i < resp.Headers.Count; i++) { string key = resp.Headers.Keys[i]; string val = resp.Headers[i]; string lkey = key.ToLower(); if (lkey != "content-length" && lkey != "transfer-encoding" && lkey != "connection") { consoleMsg += key + ": " + val + "\n"; byte[] wr = Encoding.UTF8.GetBytes(key + ": " + val + "\r\n"); netStream.Write(wr, 0, wr.Length); } } } catch (Exception) { // TODO: Should we handle this somehow? } } if (cap != null && !requestFailed && !capReq.Response.ToString().Equals("undef")) { foreach (CapsDelegate d in cap.GetDelegates()) { try { if (d(capReq, CapsStage.Response)) { break; } } catch (InvalidCastException ex) { OpenMetaverse.Logger.Log("Invalid Cast thrown trying to cast OSD to OSDMap: \n'" + capReq.Response.AsString() + "' Length="+capReq.RawResponse.Length.ToString() + "\n", Helpers.LogLevel.Error, ex); } catch (Exception ex) { OpenMetaverse.Logger.Log("Error firing delegate", Helpers.LogLevel.Error, ex); } } if (cap.RespFmt == CapsDataFormat.OSD) { respBuf = OSDParser.SerializeLLSDXmlBytes((OSD)capReq.Response); } else { respBuf = OSDParser.SerializeLLSDXmlBytes(capReq.Response); } } consoleMsg += "\n" + Encoding.UTF8.GetString(respBuf) + "\n--------"; OpenMetaverse.Logger.Log(consoleMsg, Helpers.LogLevel.Debug); OpenMetaverse.Logger.Log("[" + reqNo + "] Fixed-up response:\n" + Encoding.UTF8.GetString(respBuf) + "\n--------", Helpers.LogLevel.Debug); try { byte[] wr2 = Encoding.UTF8.GetBytes("Content-Length: " + respBuf.Length + "\r\n\r\n"); netStream.Write(wr2, 0, wr2.Length); netStream.Write(respBuf, 0, respBuf.Length); } catch (SocketException) {} catch (IOException) {} catch (Exception e) { OpenMetaverse.Logger.Log("Exception: Error writing to stream " + e, Helpers.LogLevel.Error, e); } return; }
//private Dictionary<string, bool> SubHack = new Dictionary<string, bool>(); private void ProxyCaps(NetworkStream netStream, string meth, string uri, Dictionary<string, string> headers, byte[] content, int reqNo) { Match match = new Regex(@"^(https?)://([^:/]+)(:\d+)?(/.*)$").Match(uri); if (!match.Success) { Console.WriteLine("[" + reqNo + "] Malformed proxy URI: " + uri); byte[] wr = Encoding.ASCII.GetBytes("HTTP/1.0 404 Not Found\r\nContent-Length: 0\r\n\r\n"); netStream.Write(wr, 0, wr.Length); return; } //DEBUG: Console.WriteLine("[" + reqNo + "] : " + meth); CapInfo cap = null; lock (this) { if (KnownCaps.ContainsKey(uri)) { cap = KnownCaps[uri]; } } CapsRequest capReq = null; bool shortCircuit = false; bool requestFailed = false; if (cap != null) { capReq = new CapsRequest(cap); if (cap.ReqFmt == CapsDataFormat.SD) { capReq.Request = OSDParser.DeserializeLLSDXml(content); } else { capReq.Request = OSDParser.DeserializeLLSDXml(content); } foreach (CapsDelegate d in cap.GetDelegates()) { if (d(capReq, CapsStage.Request)) { shortCircuit = true; break; } } if (cap.ReqFmt == CapsDataFormat.SD) { content = OSDParser.SerializeLLSDXmlBytes((OSD)capReq.Request); } else { content = OSDParser.SerializeLLSDXmlBytes(capReq.Request); } } byte[] respBuf = null; string consoleMsg = String.Empty; if (shortCircuit) { byte[] wr = Encoding.UTF8.GetBytes("HTTP/1.0 200 OK\r\n"); netStream.Write(wr, 0, wr.Length); } else { HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(uri); req.KeepAlive = false; foreach (string header in headers.Keys) { if (header == "accept" || header == "connection" || header == "content-length" || header == "date" || header == "expect" || header == "host" || header == "if-modified-since" || header == "referer" || header == "transfer-encoding" || header == "user-agent" || header == "proxy-connection") { // can't touch these! } else if (header == "content-type") { req.ContentType = headers["content-type"]; } else { req.Headers[header] = headers[header]; } } req.Method = meth; req.ContentLength = content.Length; HttpWebResponse resp; try { Stream reqStream = req.GetRequestStream(); reqStream.Write(content, 0, content.Length); reqStream.Close(); resp = (HttpWebResponse)req.GetResponse(); } catch (WebException e) { if (e.Status == WebExceptionStatus.Timeout || e.Status == WebExceptionStatus.SendFailure) { Console.WriteLine("Request timeout"); byte[] wr = Encoding.ASCII.GetBytes("HTTP/1.0 504 Proxy Request Timeout\r\nContent-Length: 0\r\n\r\n"); netStream.Write(wr, 0, wr.Length); return; } else if (e.Status == WebExceptionStatus.ProtocolError && e.Response != null) { resp = (HttpWebResponse)e.Response; requestFailed = true; } else { Console.WriteLine("Request error: " + e.ToString()); byte[] wr = Encoding.ASCII.GetBytes("HTTP/1.0 502 Gateway Error\r\nContent-Length: 0\r\n\r\n"); // FIXME netStream.Write(wr, 0, wr.Length); return; } } try { Stream respStream = resp.GetResponseStream(); int read; int length = 0; respBuf = new byte[256]; do { read = respStream.Read(respBuf, length, 256); if (read > 0) { length += read; Array.Resize(ref respBuf, length + 256); } } while (read > 0); Array.Resize(ref respBuf, length); if (capReq != null && !requestFailed) { if (cap.RespFmt == CapsDataFormat.SD) { capReq.Response = OSDParser.DeserializeLLSDXml(respBuf); } else { capReq.Response = OSDParser.DeserializeLLSDXml(respBuf); } } consoleMsg += "[" + reqNo + "] Response from " + uri + "\nStatus: " + (int)resp.StatusCode + " " + resp.StatusDescription + "\n"; { byte[] wr = Encoding.UTF8.GetBytes("HTTP/1.0 " + (int)resp.StatusCode + " " + resp.StatusDescription + "\r\n"); netStream.Write(wr, 0, wr.Length); } for (int i = 0; i < resp.Headers.Count; i++) { string key = resp.Headers.Keys[i]; string val = resp.Headers[i]; string lkey = key.ToLower(); if (lkey != "content-length" && lkey != "transfer-encoding" && lkey != "connection") { consoleMsg += key + ": " + val + "\n"; byte[] wr = Encoding.UTF8.GetBytes(key + ": " + val + "\r\n"); netStream.Write(wr, 0, wr.Length); } } } catch (Exception) { // TODO: Should we handle this somehow? } } if (cap != null && !requestFailed) { foreach (CapsDelegate d in cap.GetDelegates()) { try { if (d(capReq, CapsStage.Response)) { break; } } catch (Exception e) { Console.WriteLine(e.ToString()); break; } } if (cap.RespFmt == CapsDataFormat.SD) { respBuf = OSDParser.SerializeLLSDXmlBytes((OSD)capReq.Response); } else { respBuf = OSDParser.SerializeLLSDXmlBytes(capReq.Response); } } consoleMsg += "\n" + Encoding.UTF8.GetString(respBuf) + "\n--------"; #if DEBUG_CAPS Console.WriteLine(consoleMsg); #endif /* try { if(resp.StatusCode == HttpStatusCode.OK) respBuf = CapsFixup(uri,respBuf); } catch(Exception e) { Console.WriteLine("["+reqNo+"] Couldn't fixup response: "+e.ToString()); } */ #if DEBUG_CAPS Console.WriteLine("[" + reqNo + "] Fixed-up response:\n" + Encoding.UTF8.GetString(respBuf) + "\n--------"); #endif try { byte[] wr2 = Encoding.UTF8.GetBytes("Content-Length: " + respBuf.Length + "\r\n\r\n"); netStream.Write(wr2, 0, wr2.Length); netStream.Write(respBuf, 0, respBuf.Length); } catch (Exception e) { Console.WriteLine(e.ToString()); } return; }
/// <summary> /// Process individual messages that arrive via the EventQueue and convert each indvidual event into a format /// suitable for processing by the IMessage system /// </summary> /// <param name="req"></param> /// <param name="stage"></param> /// <returns></returns> private bool EventQueueGetHandler(CapsRequest req, CapsStage stage) { if (stage == CapsStage.Response && req.Response is OSDMap) { OSDMap map = (OSDMap)req.Response; if (map.ContainsKey("events")) { OSDArray eventsArray = (OSDArray)map["events"]; for (int i = 0; i < eventsArray.Count; i++) { OSDMap bodyMap = (OSDMap)eventsArray[i]; if (OnEventMessageLog != null) { CapInfo capInfo = new CapInfo(req.Info.URI, req.Info.Sim, bodyMap["message"].AsString()); CapsRequest capReq = new CapsRequest(capInfo); capReq.RequestHeaders = req.RequestHeaders; capReq.ResponseHeaders = req.ResponseHeaders; capReq.Request = null;// req.Request; capReq.RawRequest = null;// req.RawRequest; capReq.RawResponse = OSDParser.SerializeLLSDXmlBytes(bodyMap); capReq.Response = bodyMap; OnEventMessageLog(capReq, CapsStage.Response); } } } } return false; }
private bool CapsHandler(CapsRequest req, CapsStage stage) { if (OnMessageLog != null) OnMessageLog(req, stage); return false; }
void ProxyManager_OnMessageLog(CapsRequest req, CapsStage stage) { if (this.InvokeRequired) { this.BeginInvoke(new MethodInvoker(delegate() { ProxyManager_OnMessageLog(req, stage); })); } else { ListViewItem found = FindListViewItem(listViewMessageFilters, req.Info.CapType, false); if (found != null && found.Checked) { PacketCounter++; int size = 0; string cType = String.Empty; if (req.RawRequest != null) { size += req.RawRequest.Length; cType = req.RequestHeaders.Get("Content-Type"); //req.RequestHeaders["Content-Type"]; } if (req.RawResponse != null) { size += req.RawResponse.Length; cType = req.ResponseHeaders.Get("Content-Type"); } string[] s = { PacketCounter.ToString(), found.SubItems[1].Text, req.Info.CapType, size.ToString(), req.Info.URI, cType }; ListViewItem session = new ListViewItem(s); session.BackColor = found.BackColor; session.Tag = req; if (stage == CapsStage.Request) { CapsOutCounter++; CapsOutBytes += req.Request.ToString().Length; session.ImageIndex = 1; } else { CapsInCounter++; CapsInBytes += req.Response.ToString().Length; session.ImageIndex = 0; } AddSession(session); } else { if (found == null) { // must be a new event not in KnownCaps, lets add it to the listview ListViewItem addedItem = listViewMessageFilters.Items.Add(new ListViewItem(req.Info.CapType)); addedItem.BackColor = Color.AliceBlue; if (autoAddNewDiscoveredMessagesToolStripMenuItem.Checked) addedItem.Checked = true; } } } }
/// <summary> /// Adds a new EventQueue message to the Message Filters listview. /// </summary> /// <param name="req"></param> /// <param name="stage"></param> void ProxyManager_OnEventMessageLog(CapsRequest req, CapsStage stage) { if (this.InvokeRequired) { this.BeginInvoke(new MethodInvoker(delegate() { ProxyManager_OnEventMessageLog(req, stage); })); } else { ListViewItem foundCap = FindListViewItem(listViewMessageFilters, req.Info.CapType, false); if (foundCap == null) { ListViewItem addedItem = listViewMessageFilters.Items.Add(new ListViewItem(req.Info.CapType, new ListViewGroup("EventQueue Messages"))); addedItem.SubItems.Add("EventMessage"); addedItem.BackColor = Color.AliceBlue; if (autoAddNewDiscoveredMessagesToolStripMenuItem.Checked) addedItem.Checked = true; } else { ProxyManager_OnMessageLog(req, CapsStage.Response); } } }