public Channel(Server parent, string name) { Server = parent; Name = name; Users = new UserList(); }
// Data structure management public static void AddLoggable(Server network) { // Add value to Network key to hold the different loggables LogFiles.Add(network.Url, new Dictionary<string, LoggedItem>()); // Add the network log LogFiles[network.Url].Add('!' + network.Url, new LoggedItem('!' + network.Url, network.Url)); }
public Server Create(ConnectionArgs args) { var newServer = new Server(args); ServerList.Add(newServer); ServerAdded.Fire(this, new ServerEventArgs(newServer)); return newServer; }
public ServerTreeNode GetServerNode(Server server) { foreach (ServerTreeNode serverNode in ServerNodes) { if (serverNode.ServerWindow.Server == server) return serverNode; } return null; }
/// <summary> /// Parts the specified channel with the specified message /// </summary> /// <param name="context"></param> /// <param name="channel"></param> /// <param name="message"></param> public void Execute(Server context, ChannelInfo channel, string message) { if (context.InChannel(channel.Name)) { context.Channels[channel.Name].Part(message); } else { //TODO: Error? } }
public static void RemoveLoggable(Server network) { if (!NetworkExists(network)) return; foreach (LoggedItem log in LogFiles[network.Url].Values) { log.Close(); } LogFiles[network.Url].Clear(); LogFiles.Remove(network.Url); }
public void Execute(Server context, string server, string port) { var args = new ConnectionArgs(Settings.Default.FirstNick, server, false); try { args.Port = int.Parse(port); } catch (Exception) { args.Port = 6667; } context.ChangeServer(args); context.Connect(); }
public ServerViewModel(Server newServer) { System.Windows.DependencyObject dep = new System.Windows.DependencyObject(); if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(dep)) return; server = newServer; Name = server.Url; //server.RawMessageReceived += Server_RawMessageReceived; server.Registered += Server_Registered; server.ConnectFailed += Server_ConnectFailed; server.PrivateNotice += Server_PrivateNotice; server.ErrorMessageRecieved += Server_ErrorMessageRecieved; server.Connecting += Server_Connecting; server.Disconnected += Server_Disconnected; server.ConnectionLost += Server_ConnectionLost; server.ConnectCancelled += Server_ConnectCancelled; server.NickError += Server_NickError; server.PartSelf += Server_PartSelf; }
public void Execute(Server context, char[] switches, string server, string port) { foreach (char c in switches) { switch (c) { case 'n': //New window and connect var args = new ConnectionArgs(Settings.Default.FirstNick, server, false); try { args.Port = int.Parse(port); } catch (Exception) { args.Port = 6667; } var svr = ServerManager.Instance.Create(args); svr.Connect(); return; } } }
public static void TextEntry(Server network, User person, String text) { WriteText(LogFiles[network.Url][person.Nick], text); }
public static void TextEntry(Server network, User person, String text) { if (LoggerActive) TextLogger.TextEntry(network, person, text); }
/// <summary> /// Changes your nick /// </summary> /// <param name="server"></param> /// <param name="nick"></param> public void Execute(Server server, string nick) { server.ChangeNick(nick); }
public static void RemoveLoggable(Server network, User person) { if (!PersonExists(network, person)) return; LogFiles[network.Url][person.Nick].Close(); LogFiles[network.Url].Remove(person.Nick); }
public ServerEventArgs(Server server) { Server = server; }
public PrivateMessageSession(Server parentServer, User user) { Server = parentServer; User = user; }
public void DisableAutoConnect(Server server) { var settings = GetServer(server); settings.AutoConnect = false; }
private void CreateServerPanel(Server server) { Panels.Add(new ServerViewModel(server)); }
public void Teardown() { _server = null; }
/// <summary> /// Joins you to the specified channel. /// </summary> public void Execute(Server context, ChannelInfo channelToJoin) { context.JoinChannel(channelToJoin.Name); }
// Logging functions public static void TextEntry(Server network, String text) { WriteText(LogFiles[network.Url]['!' + network.Url], text); }
/// <summary> /// Summary of command with these specific parameters /// </summary> public void Execute(Server context, char[] switches, string server) { Execute(context, switches, server, "6667"); }
/// <summary> /// Connect to a server in the same window /// </summary> public void Execute(Server context, string server) { context.ChangeServer(Settings.Default.FirstNick, server, false); context.Connect(); }
public void Setup() { var args = new ConnectionArgs("test", "irc.fake.com", false); var connMock = A.Fake<Connection>(x => x.WithArgumentsForConstructor(() => new Connection(args, false, false))); _server = new Server(connMock); }
private static bool NetworkExists(Server network) { return LogFiles.ContainsKey(network.Url); }
/// <summary> /// Parts the specified channel /// </summary> /// <param name="context"></param> /// <param name="channel"></param> public void Execute(Server context, ChannelInfo channel) { Execute(context, channel, defaultMessage); }
private static bool PersonExists(Server network, User person) { return (NetworkExists(network) && LogFiles[network.Url].ContainsKey(person.Nick)); }
private ServerSettings GetServer(Server server) { foreach (NetworkSettings networkSettings in Networks) { foreach (ServerSettings serverSettings in networkSettings.Servers) { if (server.Url == serverSettings.Url) { return serverSettings; } } } return null; }
public void Remove(Server ntw) { if (ServerList.Remove(ntw)) ServerRemoved.Fire(this, new ServerEventArgs(ntw)); }
public NetworkSettings GetNetwork(Server server) { foreach (NetworkSettings networkSettings in Networks) { foreach (ServerSettings serverSettings in networkSettings.Servers) { if (server.Url == serverSettings.Url) { return networkSettings; } } } return null; }
public static void AddLoggable(Server network, User person) { // Add pmsg log to the data struture LogFiles[network.Url].Add(person.Nick, new LoggedItem(person.Nick, network.Url)); }