/// <summary> /// Back log data /// </summary> /// <param name="curr">XmlNode</param> /// <param name="protocol">Protocol which owns this request</param> public static void sBacklog(XmlNode curr, ProtocolSv protocol) { string network = curr.Attributes[0].Value; lock (protocol.WaitingNetw) { if (protocol.WaitingNetw.Contains(network)) { protocol.WaitingNetw.Remove(network); } if (protocol.WaitingNetw.Count == 0) { Core.SystemForm.Status(protocol.getInfo()); } else { Core.SystemForm.Status("Waiting for backlog for " + protocol.WaitingNetw[0]); } } Network server = protocol.retrieveNetwork(network); if (server != null) { protocol.cache[protocol.NetworkList.IndexOf(server)].size = int.Parse(curr.InnerText); foreach (Channel i in server.Channels) { i.IsParsingWhoData = true; i.IsParsingBanData = true; i.TemporarilyHidden = true; } } }
/// <summary> /// Channel info /// </summary> /// <param name="curr">XmlNode</param> /// <param name="protocol">Protocol which owns this request</param> public static void sChannelInfo(XmlNode curr, ProtocolSv protocol) { if (string.IsNullOrEmpty(curr.InnerText)) { if (curr.Attributes.Count > 1) { if (curr.Attributes[1].Name == "channels") { string[] channellist = curr.Attributes[1].Value.Split('!'); Network nw = protocol.retrieveNetwork(curr.Attributes[0].Value); if (nw != null) { foreach (string channel in channellist) { if (!string.IsNullOrEmpty(channel)) { if (nw.getChannel(channel) == null) { Channel xx = nw.Channel(channel, !Configuration.UserData.SwitchWindowOnJoin); if (Configuration.Services.UsingCache) { string ID = protocol.sBuffer.getUID(curr.Attributes[0].Value); if (ID != null && protocol.sBuffer.networkInfo.ContainsKey(ID)) { Graphics.Window window = xx.RetrieveWindow(); if (xx != null) { protocol.sBuffer.networkInfo[ID].recoverWindowText(window, window.WindowName); } Services.Buffer.ChannelInfo channel_info = protocol.sBuffer.networkInfo[ID].getChannel(channel); if (channel_info != null) { xx.Bans = channel_info.Bans; xx.Exceptions = channel_info.Exceptions; xx.ChannelWork = channel_info.ChannelWork; xx.Invites = channel_info.Invites; xx.Name = channel_info.Name; xx.IsParsingBanData = channel_info.parsing_bans; xx.IsParsingWhoisData = channel_info.parsing_wh; xx.IsParsingWhoData = channel_info.parsing_who; xx.ChannelMode = new NetworkMode(channel_info.mode); xx.IsParsingExceptionData = channel_info.parsing_xe; xx.Redraw = channel_info.Redraw; xx.TemporarilyHidden = channel_info.temporary_hide; xx.Topic = channel_info.Topic; xx.TopicDate = channel_info.TopicDate; xx.TopicUser = channel_info.TopicUser; } } } } if (!Configuration.Services.Retrieve_Sv) { protocol.SendData(nw.ServerName, "TOPIC " + channel, Configuration.Priority.Normal); protocol.SendData(nw.ServerName, "MODE " + channel, Configuration.Priority.Low); } Datagram response2 = new Datagram("CHANNELINFO", "INFO"); response2.Parameters.Add("network", curr.Attributes[0].Value); response2.Parameters.Add("channel", channel); lock (protocol.RemainingJobs) { protocol.RemainingJobs.Add(new ProtocolSv.Request(channel, ProtocolSv.Request.Type.ChannelInfo)); } protocol.Deliver(response2); } } System.Threading.Thread.Sleep(800); } } } return; } if (curr.Attributes[1].Name == "channel") { string[] userlist = curr.Attributes[2].Value.Split(':'); Network nw = protocol.retrieveNetwork(curr.Attributes[0].Value); if (nw != null) { lock (protocol.RemainingJobs) { ProtocolSv.Request item = null; foreach (ProtocolSv.Request work in protocol.RemainingJobs) { if (work.type == ProtocolSv.Request.Type.ChannelInfo && curr.Attributes[1].Value == work.Name) { item = work; } } if (item != null) { protocol.RemainingJobs.Remove(item); Core.SystemForm.Status(protocol.getInfo()); } } Channel channel = nw.getChannel(curr.Attributes[1].Value); if (channel != null) { foreach (string user in userlist) { if (user.Contains("!") && user.Contains("@")) { string us = ""; string ident; us = user.Substring(0, user.IndexOf("!", StringComparison.Ordinal)); if (channel.ContainsUser(us)) { continue; } ident = user.Substring(user.IndexOf("!", StringComparison.Ordinal) + 1); if (ident.StartsWith("@", StringComparison.Ordinal)) { ident = ""; } else { if (ident.Contains("@")) { ident = ident.Substring(0, ident.IndexOf("@", StringComparison.Ordinal)); } } string host = user.Substring(user.IndexOf("@", StringComparison.Ordinal) + 1); if (host.StartsWith("+", StringComparison.Ordinal)) { host = ""; } else { if (host.Contains("+")) { host = host.Substring(0, host.IndexOf("+", StringComparison.Ordinal)); } } lock (channel.UserList) { if (!channel.ContainsUser(us)) { User f2 = new User(us, host, nw, ident); if (user.Contains("+") && !user.StartsWith("+", StringComparison.Ordinal)) { f2.ChannelMode.ChangeMode(user.Substring(user.IndexOf("+", StringComparison.Ordinal))); f2.ResetMode(); } channel.UserList.Add(f2); } } } } Datagram response = new Datagram("USERLIST", "INFO"); response.Parameters.Add("network", curr.Attributes[0].Value); response.Parameters.Add("channel", channel.Name); protocol.Deliver(response); channel.RedrawUsers(); channel.UpdateInfo(); } } } }
/// <summary> /// Data /// </summary> /// <param name="curr">XmlNode</param> /// <param name="protocol">Protocol which owns this request</param> public static void sData(XmlNode curr, ProtocolSv protocol) { long date = 0; bool backlog = false; bool IsBacklog = false; string MQID = null; bool range = false; string id = ""; foreach (XmlAttribute xx in curr.Attributes) { switch (xx.Name) { case "time": if (!long.TryParse(xx.Value, out date)) { Core.DebugLog("Warning: " + xx.Value + " is not a correct time"); } break; case "MQID": MQID = xx.Value; break; case "buffer": if (xx.Name == "buffer") { id = xx.Value; backlog = true; } break; case "range": range = true; break; } } string name = curr.Attributes[0].Value; Network server = null; server = protocol.retrieveNetwork(name); if (server == null) { server = new Network(name, protocol); protocol.NetworkList.Add(server); protocol.cache.Add(new Cache()); server.Nickname = protocol.nick; server.flagConnection(); } if (Configuration.Services.UsingCache) { if (MQID != null) { string UID = protocol.sBuffer.getUID(name); if (UID != null) { protocol.sBuffer.networkInfo[UID].MQID(MQID); } } } ProcessorIRC processor = null; if (backlog || range) { if (Core.SystemForm.DisplayingProgress == false) { Core.SystemForm.progress = double.Parse(id); Core.SystemForm.DisplayingProgress = true; protocol.FinishedLoading = false; protocol.SuppressChanges = true; Core.SystemForm.ProgressMax = protocol.cache[protocol.NetworkList.IndexOf(server)].size; } IsBacklog = true; Core.SystemForm.progress = double.Parse(id); Core.SystemForm.Status("Retrieving backlog from " + name + ", got " + id + "/" + protocol.cache[protocol.NetworkList.IndexOf(server)].size.ToString() + " datagrams"); if ((protocol.cache[protocol.NetworkList.IndexOf(server)].size - 2) < double.Parse(id)) { IsBacklog = false; Core.SystemForm.Status(protocol.getInfo()); Core.SystemForm.DisplayingProgress = false; Core.SystemForm.progress = 0; protocol.SuppressChanges = false; if (Configuration.Services.UsingCache && Configuration.Services.MissingFix) { // get all holes we are missing from backlog protocol.sBuffer.retrieveData(name); } foreach (Channel i in server.Channels) { i.TemporarilyHidden = false; i.IsParsingExceptionData = false; i.IsParsingBanData = false; i.IsParsingWhoData = false; } } processor = new ProcessorIRC(server, curr.InnerText, ref protocol.pong, date, false); processor.IsBacklog = IsBacklog; processor.ProfiledResult(); return; } processor = new ProcessorIRC(server, curr.InnerText, ref protocol.pong, date); processor.IsBacklog = IsBacklog; processor.ProfiledResult(); }