Example #1
0
        internal void RequestDCCFile(IRCConnection connection , string nick, string file)
        {
            //send out a dccfile request
            string localIP = "";
            if (FormMain.Instance.IceChatOptions.DCCLocalIP != null && FormMain.Instance.IceChatOptions.DCCLocalIP.Length > 0)
            {
                localIP = IPAddressToLong(IPAddress.Parse(FormMain.Instance.IceChatOptions.DCCLocalIP)).ToString();
            }
            else
            {
                if (connection.ServerSetting.LocalIP == null || connection.ServerSetting.LocalIP.ToString().Length == 0)
                {
                    //error. no local IP found
                    FormMain.Instance.WindowMessage(connection, "Console", "DCC ERROR, no Router/Firewall IP Address specified in DCC Settings", 4, true);
                    return;
                }
                else
                {
                    localIP = IPAddressToLong(connection.ServerSetting.LocalIP).ToString();
                }
            }

            Random port = new Random();
            int p = port.Next(FormMain.Instance.IceChatOptions.DCCPortLower, FormMain.Instance.IceChatOptions.DCCPortUpper);

            //DccFileStruct dcc = new DccFileStruct();
            DccFileStruct dcc = new DccFileStruct();
            dcc.FileStream = new FileStream(file, FileMode.Open);

            FileInfo f = new FileInfo(file);
            dcc.FileSize = (uint)f.Length;
            dcc.StartFileSize = 0;

            dcc.FileName = file;
            dcc.Nick = nick;
            dcc.Style = "Upload";
            dcc.Connection = connection;
            dcc.Port = p.ToString();

            dcc.ListingTag = RandomListingTag();

            dcc.ListenerSocket = new TcpListener(new IPEndPoint(IPAddress.Any, Convert.ToInt32(p)));
            dcc.ListenerThread = new Thread(new ParameterizedThreadStart(ListenForConnection));
            dcc.ListenerThread.Name = "DCCListenerThread";
            dcc.ListenerThread.Start(dcc);

            string fname = dcc.FileName.Replace(' ', '_'); // strip spaces from filename
            //get the file from the path
            fname = Path.GetFileName(fname);

            dcc.Connection.SendData("PRIVMSG " + dcc.Nick + " :DCC SEND " + fname + " " + localIP + " " + p.ToString() + " " + dcc.FileSize.ToString() + "");

            dcc.timeoutTimer = new System.Timers.Timer();
            dcc.timeoutTimer.Interval = 1000 * FormMain.Instance.IceChatOptions.DCCChatTimeOut;
            dcc.timeoutTimer.Elapsed += new System.Timers.ElapsedEventHandler(timeoutTimer_Elapsed);
            dcc.timeoutTimer.Start();

            AddDCCFile(dcc);
        }
Example #2
0
 private void OnAutoPerform(IRCConnection connection, string[] commands)
 {
     string autoCommand;
     foreach (string command in commands)
     {
         autoCommand = command.Replace("\r", String.Empty);
         if (!autoCommand.StartsWith(";"))
             ParseOutGoingCommand(connection, autoCommand);
     }
 }
Example #3
0
        public FormUserInfo(IRCConnection connection)
        {
            InitializeComponent();
            this.FormClosing += new FormClosingEventHandler(OnFormClosing);

            _connection = connection;
            _connection.UserInfoWindow = this;

            ApplyLanguage();
        }
Example #4
0
 private void OnAutoJoin(IRCConnection connection, string[] channels)
 {
     foreach (string chan in channels)
     {
         if (!chan.StartsWith(";"))
         {
             if (connection.ServerSetting.AutoJoinDelay)
                 ParseOutGoingCommand(connection, "/timer autojoin 6 1 /join " + chan);
             else
                 connection.SendData("JOIN " + chan);
         }
     }
 }
Example #5
0
 private void OnAutoRejoin(IRCConnection connection)
 {
     foreach (IceTabPage tw in mainTabControl.TabPages)
     {
         if (tw.WindowStyle == IceTabPage.WindowType.Channel)
         {
             if (tw.Connection == connection)
             {
                 if (connection.ServerSetting.AutoJoinDelay)
                     ParseOutGoingCommand(connection, "/timer rejoin 6 1 /join " + tw.TabCaption);
                 else
                     connection.SendData("JOIN " + tw.TabCaption);
             }
         }
     }
 }
Example #6
0
        public FormDCCFileAccept(IRCConnection connection, string nick, string host, string port, string ip, string file, uint fileSize, bool resume, uint filePos)
        {
            //for normal dcc connections
            InitializeComponent();

            labelUser.Text = nick + "@" + host + " is trying to send you a file";
            labelFile.Text = file + " (" + fileSize.ToString() + " bytes)";

            _connection = connection;
            _nick = nick;
            _host = host;
            _port = port;
            _ip = ip;
            _file = file;
            _fileSize = fileSize;
            _filePos = filePos;
            _resume = resume;
        }
Example #7
0
 internal bool WindowExists(IRCConnection connection, string windowName, IceTabPage.WindowType windowType)
 {
     foreach (IceTabPage t in this.TabPages)
     {
         if (t.Connection == null)
         {
             if (t.WindowStyle == IceTabPage.WindowType.DCCFile)
             {
                 if (t.TabCaption.ToLower() == windowName.ToLower())
                     return true;
             }
         }
         else if (t.Connection == connection)
         {
             if (t.WindowStyle == windowType)
             {
                 if (t.TabCaption.ToLower() == windowName.ToLower())
                     return true;
             }
         }
     }
     return false;
 }
Example #8
0
        /// <summary>
        /// Add a new Tab/Connection to the Console Tab Control
        /// </summary>
        /// <param name="connection"></param>
        internal void AddConsoleTab(IRCConnection connection)
        {
            ConsoleTab t = new ConsoleTab(connection.ServerSetting.ServerName);
            t.Connection = connection;

            TextWindow w = new TextWindow();
            w.Dock = DockStyle.Fill;
            w.Font = new System.Drawing.Font(FormMain.Instance.IceChatFonts.FontSettings[0].FontName, FormMain.Instance.IceChatFonts.FontSettings[0].FontSize);
            w.IRCBackColor = FormMain.Instance.IceChatColors.ConsoleBackColor;
            w.NoEmoticons = true;

            t.Controls.Add(w);
            if (FormMain.Instance.IceChatOptions.LogConsole)
                w.SetLogFile(FormMain.Instance.LogsFolder + System.IO.Path.DirectorySeparatorChar + connection.ServerSetting.ServerName);

            consoleTab.TabPages.Add(t);
            consoleTab.SelectedTab = t;
        }
Example #9
0
 /// <summary>
 /// Clear the Channel List Window if it is Already Open
 /// </summary>
 /// <param name="connection"></param>
 private void OnChannelListStart(IRCConnection connection)
 {
     IceTabPage t = GetWindow(connection, "Channels", IceTabPage.WindowType.ChannelList);
     if (t != null)
         t.ClearChannelList();
 }
Example #10
0
 /// <summary>
 /// Send out a message to be parsed
 /// </summary>
 /// <param name="connection">Which Connection it came from</param>
 /// <param name="data">The message to be parsed</param>
 private void OutGoingCommand(IRCConnection connection, string data)
 {
     ParseOutGoingCommand(connection, data);
 }
Example #11
0
 private void OnWriteErrorFile(IRCConnection connection, string method, Exception e)
 {
     WriteErrorFile(connection, method, e);
 }
Example #12
0
        private void OnWhoReply(IRCConnection connection, string channel, string nick, string host, string message)
        {
            IceTabPage t = FormMain.Instance.GetWindow(connection, channel, IceTabPage.WindowType.Channel);
            if (t != null)
            {
                OnIALUserData(connection, nick, host, channel);
                if (t.GotWhoList)
                    OnServerMessage(connection, message);

            }
        }
Example #13
0
        /// <summary>
        /// Received Whois Data on a Nick
        /// </summary>
        /// <param name="connection">Which Connection it came from</param>
        /// <param name="nick">The nick whois data is from</param>
        /// <param name="data">The Whois data</param>
        private void OnWhoisData(IRCConnection connection, string nick, string data)
        {
            string msg = GetMessageFormat("User Whois");
            msg = msg.Replace("$nick", nick);
            msg = msg.Replace("$data", data);

            PluginArgs args = new PluginArgs(mainTabControl.GetTabPage("Console").TextWindow, "", nick, "", msg);
            args.Connection = connection;

            foreach (IPluginIceChat ipc in loadedPlugins)
            {
                if (ipc.Enabled == true)
                    ipc.WhoisUser(args);
            }

            if (iceChatOptions.WhoisEventLocation == 2) //hide the event
                return;

            //check if there is a query window open
            IceTabPage t = GetWindow(connection, nick, IceTabPage.WindowType.Query);
            if (t != null)
            {
                if (iceChatOptions.WhoisEventLocation == 0)
                {
                    t.TextWindow.AppendText(msg, 1);
                    t.LastMessageType = ServerMessageType.Message;
                }
                else
                {
                    mainTabControl.GetTabPage("Console").AddText(connection, msg, 1, false);
                }
            }
            else
            {
                if (iceChatOptions.WhoisEventLocation == 0)
                    //send whois data to the current window
                    CurrentWindowMessage(connection, msg, 1, false);
                else
                    mainTabControl.GetTabPage("Console").AddText(connection, msg, 1, false);

            }
        }
Example #14
0
        /// <summary>
        /// Received a User Notice
        /// </summary>
        /// <param name="connection">Which Connection it came from</param>
        /// <param name="nick">The Nick who sent the Notice</param>
        /// <param name="message">The Notice message</param>
        private void OnUserNotice(IRCConnection connection, string nick, string message)
        {
            if (message.ToUpper().StartsWith("DCC CHAT"))
            {
                if (FormMain.Instance.IceChatOptions.DCCChatIgnore)
                    return;
            }

            string msg = GetMessageFormat("User Notice");
            if (connection.ServerSetting.RealServerName.Length > 0)
                msg = msg.Replace("$server", connection.ServerSetting.RealServerName);
            else
                msg = msg.Replace("$server", connection.ServerSetting.ServerName);
            msg = msg.Replace("$nick", nick);
            msg = msg.Replace("$message", message);

            PluginArgs args = new PluginArgs(CurrentWindow.TextWindow, "", nick, "", msg);
            args.Extra = message;
            args.Connection = connection;

            foreach (IPluginIceChat ipc in loadedPlugins)
            {
                if (ipc.Enabled == true)
                    args = ipc.UserNotice(args);
            }

            CurrentWindowMessage(connection, args.Message, 1, false);

            PlaySoundFile("notice");
        }
Example #15
0
        /// <summary>
        /// Your User Mode for the Server has Changed
        /// </summary>
        /// <param name="connection">Which Connection it came from</param>
        /// <param name="nick">Your Nick Name</param>
        /// <param name="mode">New User Mode(s)</param>
        private void OnUserMode(IRCConnection connection, string nick, string mode)
        {
            string msg = GetMessageFormat("Server Mode");
            if (connection.ServerSetting.RealServerName.Length > 0)
                msg = msg.Replace("$server", connection.ServerSetting.RealServerName);
            else
                msg = msg.Replace("$server", connection.ServerSetting.ServerName);
            msg = msg.Replace("$mode", mode);
            msg = msg.Replace("$nick", nick);

            mainTabControl.GetTabPage("Console").AddText(connection, msg, 1, false);
            if (!connection.ServerSetting.DisableSounds)
                PlaySoundFile("conmsg");

            //parse out the user modes
            //set the mode in Server Setting
        }
Example #16
0
        /// <summary>
        /// A User was kicked from a Channel
        /// </summary>
        /// <param name="connection">Which Connection it came from</param>
        /// <param name="channel">Which Channel the User was Kicked from</param>
        /// <param name="nick">Nickname of who was Kicked</param>
        /// <param name="reason">Kick Reason</param>
        /// <param name="kickUser">Full User Host of Who kicked the User</param>
        private void OnChannelKick(IRCConnection connection, string channel, string nick, string reason, string kickUser)
        {
            IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel);
            if (t != null)
            {
                string kickNick = NickFromFullHost(kickUser);
                string kickHost = HostFromFullHost(kickUser);

                string msg = GetMessageFormat("Channel Kick");
                msg = msg.Replace("$nick", kickNick);
                msg = msg.Replace("$host", kickHost);
                msg = msg.Replace("$kickee", nick);
                msg = msg.Replace("$channel", channel);
                msg = msg.Replace("$reason", reason);

                PluginArgs args = new PluginArgs(iceChatOptions.KickEventLocation == 0 ? t.TextWindow : mainTabControl.GetTabPage("Console").TextWindow, channel, nick, "", msg);
                args.Connection = connection;

                foreach (IPluginIceChat ipc in loadedPlugins)
                {
                    if (ipc.Enabled == true)
                        args = ipc.ChannelKick(args);
                }

                if (iceChatOptions.KickEventLocation == 0)
                {
                    //send it to the channel
                    t.TextWindow.AppendText(args.Message, 1);
                    t.LastMessageType = ServerMessageType.Other;
                }
                else if (iceChatOptions.KickEventLocation == 1)
                {
                    //send to the console
                    mainTabControl.GetTabPage("Console").AddText(connection, args.Message, 1, false);
                }

                t.RemoveNick(nick);
            }
        }
Example #17
0
        /// <summary>
        /// You where Kicked from a Channel
        /// </summary>
        /// <param name="connection">Which Connection it came from</param>
        /// <param name="channel">Which Channel you were kicked from</param>
        /// <param name="reason">Kick Reason</param>
        /// <param name="kickUser">Full User Host of who kicked you</param>
        private void OnChannelKickSelf(IRCConnection connection, string channel, string reason, string kickUser)
        {
            try
            {
                IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel);
                if (iceChatOptions.ChannelOpenKick)
                {
                    if (t != null)
                    {
                        t.ClearNicks();
                        t.IsFullyJoined = false;
                        t.GotNamesList = false;
                        t.GotWhoList = false;

                        if (CurrentWindow == t)
                            nickList.Header = t.TabCaption + ":0";

                        FormMain.Instance.NickList.Invalidate();
                    }
                }
                else
                {
                    RemoveWindow(connection, channel, IceTabPage.WindowType.Channel);
                }

                string nick = NickFromFullHost(kickUser);
                string host = HostFromFullHost(kickUser);

                string msg = GetMessageFormat("Self Channel Kick");
                msg = msg.Replace("$nick", connection.ServerSetting.NickName);
                msg = msg.Replace("$kicker", nick);
                msg = msg.Replace("$host", host);
                msg = msg.Replace("$channel", channel);
                msg = msg.Replace("$reason", reason);

                PluginArgs args = new PluginArgs(mainTabControl.GetTabPage("Console").TextWindow, channel, nick, connection.ServerSetting.NickName, msg);
                args.Extra = reason;
                args.Connection = connection;

                foreach (IPluginIceChat ipc in loadedPlugins)
                {
                    if (ipc.Enabled == true)
                    {
                        System.Diagnostics.Debug.WriteLine(ipc.Name);
                        args = ipc.ChannelKick(args);
                    }
                }
                if (iceChatOptions.ChannelOpenKick)
                {
                    if (t != null)
                        t.TextWindow.AppendText(args.Message, 1);
                    else
                        mainTabControl.GetTabPage("Console").AddText(connection, args.Message, 1, false);
                }
                else
                    mainTabControl.GetTabPage("Console").AddText(connection, args.Message, 1, false);

            }
            catch (Exception e)
            {
                WriteErrorFile(connection, "OnKickSelf", e);
            }
        }
Example #18
0
        /// <summary>
        /// Received a Channel Action
        /// </summary>
        /// <param name="connection">Which Connection it came from</param>
        /// <param name="channel">Which Channel it is from</param>
        /// <param name="nick">Nick who sent the action</param>
        /// <param name="message">Channel action</param>
        private void OnChannelAction(IRCConnection connection, string channel, string nick, string host, string message)
        {
            IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel);
            if (t != null)
            {
                string msg = GetMessageFormat("Channel Action");
                msg = msg.Replace("$nick", nick).Replace("$channel", channel);
                msg = msg.Replace("$color", "");
                msg = msg.Replace("$message", message);

                PluginArgs args = new PluginArgs(t.TextWindow, channel, nick, host, msg);
                args.Extra = message;
                args.Connection = connection;

                foreach (IPluginIceChat ipc in loadedPlugins)
                {
                    if (ipc.Enabled == true)
                        args = ipc.ChannelAction(args);
                }

                if (iceChatOptions.ChannelActionEventLocation == 0)
                {
                    //send it to the channel
                    t.TextWindow.AppendText(args.Message, 1);
                    t.LastMessageType = ServerMessageType.Action;
                }
                else if (iceChatOptions.ChannelActionEventLocation == 1)
                {
                    //send it to the console
                    mainTabControl.GetTabPage("Console").AddText(connection, args.Message, 1, false);
                }

            }
        }
Example #19
0
        /// <summary>
        /// Received a Channel for the Server Channel List
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="channel">Channel Name</param>
        /// <param name="users">Total Users in Channel</param>
        /// <param name="topic">Channel Topic</param>
        private void OnChannelList(IRCConnection connection, string channel, string users, string topic)
        {
            //will make a seperate window for this eventually
            if (!mainTabControl.WindowExists(connection, "Channels", IceTabPage.WindowType.ChannelList))
                AddWindow(connection, "Channels", IceTabPage.WindowType.ChannelList);

            IceTabPage t = GetWindow(connection, "Channels", IceTabPage.WindowType.ChannelList);
            if (t != null)
                t.AddChannelList(channel, Convert.ToInt32(users), StripColorCodes(topic));
        }
Example #20
0
 private void OnChannelInfoAddException(IRCConnection connection, string channel, string host, string bannedBy)
 {
     IceTabPage t = FormMain.Instance.GetWindow(connection, channel, IceTabPage.WindowType.Channel);
     if (t != null)
     {
         if (t.HasChannelInfo)
         {
             t.ChannelInfoForm.AddChannelException(host, bannedBy);
         }
     }
 }
Example #21
0
        /// <summary>
        /// Received a Channel Message
        /// </summary>
        /// <param name="connection">Which Connection it came from</param>
        /// <param name="channel">Which Channel it is from</param>
        /// <param name="nick">Nick who sent the message</param>
        /// <param name="message">Channel Message</param>
        private void OnChannelMessage(IRCConnection connection, string channel, string nick, string host, string message)
        {
            IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel);
            if (t != null)
            {
                string msg = GetMessageFormat("Channel Message");
                msg = msg.Replace("$nick", nick).Replace("$channel", channel).Replace("$host", host);

                //assign $color to the nickname color
                //get the user mode for the nickname
                if (msg.Contains("$color") && t.NickExists(nick))
                {
                    User u = t.GetNick(nick);
                    if (iceChatColors.RandomizeNickColors)
                        msg = msg.Replace("$color", ((char)3).ToString() + u.nickColor);
                    else
                    {
                        for (int i = 0; i < u.Level.Length; i++)
                        {
                            if (u.Level[i])
                            {
                                if (connection.ServerSetting.StatusModes[0][i] == 'q')
                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOwnerColor.ToString("00"));
                                else if (connection.ServerSetting.StatusModes[0][i] == 'a')
                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelAdminColor.ToString("00"));
                                else if (connection.ServerSetting.StatusModes[0][i] == 'o')
                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOpColor.ToString("00"));
                                else if (connection.ServerSetting.StatusModes[0][i] == 'h')
                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelHalfOpColor.ToString("00"));
                                else if (connection.ServerSetting.StatusModes[0][i] == 'v')
                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelVoiceColor.ToString("00"));
                                else
                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOwnerColor.ToString("00"));

                                break;
                            }
                        }
                        if (msg.Contains("$color"))
                            msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelRegularColor.ToString("00"));
                    }
                }
                else
                {
                    //System.Diagnostics.Debug.WriteLine("$color:" + t.NickExists(nick) + ":" + msg);
                    msg = msg.Replace("$color", string.Empty);
                }

                //check if the nickname exists
                if (t.NickExists(nick))
                    msg = msg.Replace("$status", t.GetNick(nick).ToString().Replace(nick, ""));
                else
                    msg = msg.Replace("$status", "");

                msg = msg.Replace("$message", message);

                PluginArgs args = new PluginArgs(t.TextWindow, channel, nick, host, msg);
                args.Extra = message;
                args.Connection = connection;

                foreach (IPluginIceChat ipc in loadedPlugins)
                {
                    if (ipc.Enabled == true)
                        args = ipc.ChannelMessage(args);
                }

                args.Message = args.Message.Replace("$message", message);

                if (args.Message.Contains(connection.ServerSetting.NickName))
                {
                    //check if sounds are disabled for this window
                    if (!t.DisableSounds)
                        PlaySoundFile("nickchan");
                }

                if (iceChatOptions.ChannelMessageEventLocation == 0)
                {
                    //send it to the channel
                    t.TextWindow.AppendText(args.Message, 1);
                    t.LastMessageType = ServerMessageType.Message;

                    if (!t.DisableSounds)
                        PlaySoundFile("chanmsg");
                }
                else if (iceChatOptions.ChannelMessageEventLocation == 1)
                {
                    //send it to the console
                    mainTabControl.GetTabPage("Console").AddText(connection, args.Message, 1, false);
                }
            }
        }
Example #22
0
 private void OnChannelInfoTopicSet(IRCConnection connection, string channel, string nick, string time)
 {
     IceTabPage t = FormMain.Instance.GetWindow(connection, channel, IceTabPage.WindowType.Channel);
     if (t != null)
     {
         if (t.HasChannelInfo)
         {
             t.ChannelInfoForm.ChannelTopicSetBy(nick, time);
         }
     }
 }
Example #23
0
        /// <summary>
        /// Channel Mode Changed
        /// </summary>
        /// <param name="connection">Which Connection it came from</param>
        /// <param name="modeSetter">Who set the mode(s)</param>
        /// <param name="channel">Channel which mode change is for</param>
        /// <param name="fullmode">All the modes and parameters</param>
        private void OnChannelMode(IRCConnection connection, string modeSetter, string modeSetterHost, string channel, string fullmode)
        {
            try
            {
                string mode = "";
                string parameter = "";

                if (fullmode.IndexOf(' ') == -1)
                {
                    mode = fullmode;
                }
                else
                {
                    mode = fullmode.Substring(0, fullmode.IndexOf(' '));
                    parameter = fullmode.Substring(fullmode.IndexOf(' ') + 1);
                }

                string msg = GetMessageFormat("Channel Mode");
                msg = msg.Replace("$modeparam", parameter);
                msg = msg.Replace("$mode", mode);
                msg = msg.Replace("$nick", modeSetter);
                msg = msg.Replace("$host", modeSetterHost);
                msg = msg.Replace("$channel", channel);

                IceTabPage chan = GetWindow(connection, channel, IceTabPage.WindowType.Channel);
                if (chan != null)
                {
                    PluginArgs args = new PluginArgs(chan, channel, modeSetter, modeSetterHost, msg);
                    args.Extra = fullmode;
                    args.Connection = connection;

                    foreach (IPluginIceChat ipc in loadedPlugins)
                    {
                        if (ipc.Enabled == true)
                            ipc.ChannelMode(args);
                    }

                    if (modeSetter != channel)
                    {
                        if (iceChatOptions.ModeEventLocation == 0)
                        {
                            chan.TextWindow.AppendText(msg, 1);
                            chan.LastMessageType = ServerMessageType.Other;
                        }
                        else if (iceChatOptions.ModeEventLocation == 1)
                        {
                            //send it to the console
                            mainTabControl.GetTabPage("Console").AddText(connection, msg, 1, false);
                        }
                    }
                    else
                    {
                        chan.ChannelModes = fullmode.Trim();
                    }

                    string[] parameters = parameter.Split(new char[] { ' ' });

                    bool addMode = false;
                    int modelength = mode.Length;
                    string temp;

                    IEnumerator parametersEnumerator = parameters.GetEnumerator();
                    parametersEnumerator.MoveNext();
                    for (int i = 0; i < modelength; i++)
                    {
                        switch (mode[i])
                        {
                            case '-':
                                addMode = false;
                                break;
                            case '+':
                                addMode = true;
                                break;
                            case 'b':
                                //handle bans seperately
                                temp = (string)parametersEnumerator.Current;
                                parametersEnumerator.MoveNext();
                                break;
                            default:
                                //check if it's a status mode which can vary by server
                                //temp = (string)parametersEnumerator.Current;
                                bool isChecked = false;

                                for (int j = 0; j < connection.ServerSetting.StatusModes[0].Length; j++)
                                {
                                    if (mode[i] == connection.ServerSetting.StatusModes[0][j])
                                    {
                                        temp = (string)parametersEnumerator.Current;
                                        //make sure its not an address
                                        if (temp.IndexOf("@") == -1)
                                        {
                                            chan.UpdateNick(temp, connection.ServerSetting.StatusModes[1][j].ToString(), addMode);
                                            parametersEnumerator.MoveNext();
                                            isChecked = true;
                                        }
                                        break;
                                    }
                                }

                                if (!isChecked)
                                {
                                    for (int j = 0; j < connection.ServerSetting.ChannelModeAddress.Length ; j++)
                                    {
                                        if (mode[i] == connection.ServerSetting.ChannelModeAddress[j])
                                        {
                                            temp = (string)parametersEnumerator.Current;
                                            chan.UpdateNick(temp, connection.ServerSetting.ChannelModeAddress[j].ToString(), addMode);
                                            parametersEnumerator.MoveNext();
                                            isChecked = true;
                                            break;
                                        }
                                    }
                                }

                                if (!isChecked)
                                {
                                    for (int j = 0; j < connection.ServerSetting.ChannelModeParam.Length; j++)
                                    {
                                        if (mode[i] == connection.ServerSetting.ChannelModeParam[j])
                                        {
                                            temp = (string)parametersEnumerator.Current;
                                            chan.UpdateChannelMode(mode[i], temp, addMode);
                                            parametersEnumerator.MoveNext();
                                            isChecked = true;
                                            break;
                                        }
                                    }
                                }

                                if (!isChecked)
                                {
                                    for (int j = 0; j < connection.ServerSetting.ChannelModeParamNotRemove.Length; j++)
                                    {
                                        if (mode[i] == connection.ServerSetting.ChannelModeParamNotRemove[j])
                                        {
                                            if (addMode)
                                            {
                                                temp = (string)parametersEnumerator.Current;
                                                chan.UpdateChannelMode(mode[i], temp, addMode);
                                                parametersEnumerator.MoveNext();
                                            }
                                            else
                                            {
                                                chan.UpdateChannelMode(mode[i], addMode);
                                            }
                                            isChecked = true;
                                            break;
                                        }
                                    }
                                }

                                if (!isChecked)
                                {
                                    for (int j = 0; j < connection.ServerSetting.ChannelModeNoParam.Length; j++)
                                    {
                                        if (mode[i] == connection.ServerSetting.ChannelModeNoParam[j])
                                        {
                                            chan.UpdateChannelMode(mode[i], addMode);
                                            break;
                                        }
                                    }
                                }

                                /*
                                //check if the mode has a parameter (CHANMODES= from 005)
                                if (connection.ServerSetting.ChannelModeParam.Contains(mode[i].ToString()))
                                {
                                    //even though mode l requires a param to add it, it does not to remove it
                                    //if (!addMode && mode[i] != 'l')
                                    {
                                        //mode has parameter
                                        temp = (string)parametersEnumerator.Current;
                                        parametersEnumerator.MoveNext();
                                    }
                                    chan.UpdateChannelMode(mode[i], temp, addMode);
                                }
                                else
                                    //check if it is an actual channel mode, and not a user mode
                                    if (connection.ServerSetting.ChannelModeNoParam.Contains(mode[i].ToString()))
                                        chan.UpdateChannelMode(mode[i], addMode);
                                */
                                break;

                        }
                    }

                    if (inputPanel.CurrentConnection == connection)
                    {
                        string network = "";
                        if (connection.ServerSetting.NetworkName.Length > 0)
                            network = " (" + connection.ServerSetting.NetworkName + ")";

                        if (mainTabControl.CurrentTab == chan)
                            StatusText(connection.ServerSetting.NickName + " in " + chan.TabCaption + " [" + chan.ChannelModes + "] {" + chan.Connection.ServerSetting.RealServerName + "}" + network);
                    }
                }
            }
            catch (Exception e)
            {
                WriteErrorFile(connection, "OnChannelMode", e);
            }
        }
Example #24
0
 private bool OnChannelInfoWindowExists(IRCConnection connection, string channel)
 {
     IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel);
     if (t != null)
     {
         return t.HasChannelInfo;
     }
     return false;
 }
Example #25
0
        /// <summary>
        /// Received a Channel Notice
        /// </summary>
        /// <param name="connection">The connection the notice was received on</param>
        /// <param name="nick">The nick who sent the notice</param>
        /// <param name="host">The host of the nick who sent the notice</param>
        /// <param name="status">The status char that the notice was sent to</param>
        /// <param name="channel">The channel the notice was sent to</param>
        /// <param name="notice">The notice message</param>
        private void OnChannelNotice(IRCConnection connection, string nick, string host, char status, string channel, string message)
        {
            IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel);
            if (t != null)
            {
                string msg = GetMessageFormat("Channel Notice");
                msg = msg.Replace("$nick", nick);
                msg = msg.Replace("$host", host);
                if (status == '0')
                    msg = msg.Replace("$status", "");
                else
                    msg = msg.Replace("$status", status.ToString());

                msg = msg.Replace("$channel", channel);
                msg = msg.Replace("$message", message);

                PluginArgs args = new PluginArgs(t, channel, nick, host, msg);
                args.Connection = connection;

                foreach (IPluginIceChat ipc in loadedPlugins)
                {
                    if (ipc.Enabled == true)
                        args = ipc.ChannelNotice(args);
                }

                t.TextWindow.AppendText(args.Message, 1);
                t.LastMessageType = ServerMessageType.Message;
            }
        }
Example #26
0
        /// <summary>
        /// When a User Invites you to a Channel
        /// </summary>
        /// <param name="connection">Which connection it came from</param>
        /// <param name="channel">The channel you are being invited to</param>
        /// <param name="nick">The nick who invited you</param>
        /// <param name="host">The host of the nick who invited you</param>
        private void OnChannelInvite(IRCConnection connection, string channel, string nick, string host)
        {
            string msg = GetMessageFormat("Channel Invite");
            msg = msg.Replace("$channel", channel).Replace("$nick", nick).Replace("$host", host);

            mainTabControl.GetTabPage("Console").AddText(connection, msg, 1, false);

            if (!connection.ServerSetting.DisableSounds)
                PlaySoundFile("conmsg");

            PluginArgs args = new PluginArgs(mainTabControl.GetTabPage("Console").TextWindow, channel, nick, host, msg);
            args.Connection = connection;

            foreach (IPluginIceChat ipc in loadedPlugins)
            {
                if (ipc.Enabled == true)
                    ipc.ChannelInvite(args);
            }
        }
Example #27
0
 /// <summary>
 /// Add a message to the Text Window for Selected Console Tab Connection
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="data"></param>
 /// <param name="color"></param>
 internal void AddText(IRCConnection connection, string data, int color, bool scrollToBottom)
 {
     foreach (ConsoleTab t in consoleTab.TabPages)
     {
         if (t.Connection == connection)
         {
             ((TextWindow)t.Controls[0]).AppendText(data, color);
             if (scrollToBottom)
                 ((TextWindow)t.Controls[0]).ScrollToBottom();
             return;
         }
     }
 }
Example #28
0
        /// <summary>
        /// A User Joined a Channel
        /// </summary>
        /// <param name="connection">Which Connection it came from</param>
        /// <param name="channel">Which Channel was Joined</param>
        /// <param name="user">Full User Host of who Joined</param>
        /// <param name="refresh">Whether to Refresh the Nick List</param>
        private void OnChannelJoin(IRCConnection connection, string channel, string nick, string host, bool refresh)
        {
            IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel);
            if (t != null)
            {
                if (refresh)
                {
                    string msg = GetMessageFormat("Channel Join");
                    msg = msg.Replace("$nick", nick).Replace("$channel", channel).Replace("$host", host);

                    PluginArgs args = new PluginArgs(t.TextWindow, channel, nick, host, msg);
                    args.Connection = connection;

                    foreach (IPluginIceChat ipc in loadedPlugins)
                    {
                        if (ipc.Enabled == true)
                            args = ipc.ChannelJoin(args);
                    }

                    if (iceChatOptions.JoinEventLocation == 0)
                    {
                        //send to the channel window
                        t.TextWindow.AppendText(args.Message, 1);
                        t.LastMessageType = ServerMessageType.JoinChannel;
                    }
                    else if (iceChatOptions.JoinEventLocation == 1)
                    {
                        //send to the console
                        mainTabControl.GetTabPage("Console").AddText(connection, args.Message, 1, false);
                    }
                }

                t.AddNick(nick, refresh);
            }
        }
Example #29
0
 public void AddConnection(IRCConnection c)
 {
     if (ServerConnections.ContainsKey(c.ServerSetting.ID))
     {
         Random r = new Random();
         do
         {
             c.ServerSetting.ID = r.Next(10000, 49999);
         } while (ServerConnections.ContainsKey(c.ServerSetting.ID));
     }
     ServerConnections.Add(c.ServerSetting.ID, c);
     //check if it exists in the servers collection
     foreach (ServerSetting s in serversCollection.listServers)
     {
         if (s.ID == c.ServerSetting.ID)
             return;
     }
     serversCollection.AddServer(c.ServerSetting);
 }
Example #30
0
        /// <summary>
        /// You have Joined a Channel
        /// </summary>
        /// <param name="connection">Which Connection it came from</param>
        /// <param name="channel">Which Channel you joined</param>
        private void OnChannelJoinSelf(IRCConnection connection, string channel)
        {
            //check if channel window already exists
            IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel);
            if (t == null)
            {
                t = AddWindow(connection, channel, IceTabPage.WindowType.Channel);

                PluginArgs args = new PluginArgs(t.TextWindow, channel, connection.ServerSetting.NickName, "", "");
                args.Connection = connection;

                foreach (IPluginIceChat ipc in loadedPlugins)
                {
                    if (ipc.Enabled == true)
                        ipc.ChannelJoin(args);
                }

                serverTree.Invalidate();
            }
            else
            {
                PluginArgs args = new PluginArgs(t.TextWindow, channel, connection.ServerSetting.NickName, "", "");
                args.Connection = connection;

                foreach (IPluginIceChat ipc in loadedPlugins)
                {
                    if (ipc.Enabled == true)
                        ipc.ChannelJoin(args);
                }

                serverTree.Invalidate();
            }
        }