/// <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> /// This is a parser for command which is received when services send us a list of networks /// </summary> /// <param name="curr">XmlNode</param> /// <param name="protocol">Protocol which owns this request</param> public static void sNetworkList(XmlNode curr, ProtocolSv protocol) { if (!string.IsNullOrEmpty(curr.InnerText)) { string[] _networks = curr.InnerText.Split('|'); string[] mq = null; if (Configuration.Services.UsingCache) { if (curr.Attributes.Count > 0) { mq = curr.Attributes[0].Value.Split('|'); if (_networks.Length != mq.Length) { Core.DebugLog("Invalid buffer " + curr.Attributes[0].Value); mq = null; } } } if (Configuration.Services.UsingCache) { Core.SystemForm.Status("Loading disk cache from disk..."); protocol.sBuffer.ReadDisk(); } int id = 0; foreach (string i in _networks) { if (!string.IsNullOrEmpty(i)) { protocol.Deliver(new Datagram("NETWORKINFO", i)); Network nw = new Network(i, protocol); nw.Nickname = protocol.nick; protocol.cache.Add(new Cache()); protocol.NetworkList.Add(nw); // we flag the network as connected until we really know that nw.flagConnection(); // we ask for information about every channel on that network Datagram response = new Datagram("CHANNELINFO"); response._InnerText = "LIST"; response.Parameters.Add("network", i); protocol.Deliver(response); Datagram request = new Datagram("BACKLOGSV"); request.Parameters.Add("network", i); request.Parameters.Add("size", Configuration.Services.Depth.ToString()); // we insert this network to a list of waiting networks lock (protocol.WaitingNetw) { protocol.WaitingNetw.Add(i); } // we need to recover data from local storage if (Configuration.Services.UsingCache && mq != null) { if (!protocol.sBuffer.Networks.ContainsValue(mq[id])) { protocol.sBuffer.Make(i, mq[id]); protocol.sBuffer.networkInfo[mq[id]].NetworkID = mq[id]; protocol.sBuffer.networkInfo[mq[id]].Nick = nw.Nickname; protocol.sBuffer.networkInfo[mq[id]].Server = nw.ServerName; } else { Services.Buffer.NetworkInfo info = protocol.sBuffer.networkInfo[mq[id]]; info.recoverWindowText(nw.SystemWindow, nw.SystemWindow.WindowName); nw.CModes = info.CModes; nw.CUModes = info.CUModes; nw.PModes = info.PModes; nw.SModes = info.SModes; nw.UChars = info.UChars; nw.UModes = info.UModes; nw.XModes = info.XModes; nw.Nickname = info.Nick; nw.IrcdVersion = info.Version; nw.ChannelList.Clear(); nw.ChannelList.AddRange(info.ChannelList); info.ChannelList.Clear(); lock (nw.Descriptions) { nw.Descriptions.Clear(); foreach (Client.Services.Buffer.NetworkInfo.Description description in info.Descriptions) { nw.Descriptions.Add(description.Char, description.String); } } foreach (string ms in info.PrivateWins) { User current_pm = nw.Private(ms); info.recoverWindowText(nw.PrivateWins[current_pm], ms); } int mqid = info.lastMQID; request.Parameters.Add("last", mqid.ToString()); } } protocol.Deliver(request); } id++; } Core.SystemForm.Status("Waiting for services to send us remaining backlog"); } }