/// <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(); }
/// <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"); } }
/// <summary> /// Connect to irc network /// </summary> /// <param name="curr">XmlNode</param> /// <param name="protocol">Protocol which owns this request</param> public static void sConnect(XmlNode curr, ProtocolSv protocol) { string network = curr.Attributes[0].Value; switch (curr.InnerText) { case "CONNECTED": protocol.Windows["!root"].scrollback.InsertText("You are already connected to " + network, Client.ContentLine.MessageStyle.System); return; case "PROBLEM": protocol.Windows["!root"].scrollback.InsertText(messages.get("service_error", Core.SelectedLanguage, new List<string> { network, curr.Attributes[1].Value }), Client.ContentLine.MessageStyle.System, false); return; case "OK": Network _network = new Network(network, protocol); _network.flagConnection(); _network.Nickname = protocol.nick; protocol.cache.Add(new Cache()); protocol.NetworkList.Add(_network); return; } }