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", "\x000304DCC ERROR, no Router/Firewall IP Address specified in DCC Settings", "", 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.LocalIP = localIP;

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

            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);

            //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
        public FormUserInfo(IRCConnection connection)
        {
            InitializeComponent();
            this.FormClosing += new FormClosingEventHandler(OnFormClosing);
            this.Load+=new EventHandler(OnLoad);

            _connection = connection;
            _connection.UserInfoWindow = this;

            ApplyLanguage();
        }
Example #3
0
 public User(string nick, IRCConnection connection)
 {
     if (connection != null)
     {
         this.connection = connection;
         Level = new bool[connection.ServerSetting.StatusModes[0].Length];
         for (int i = 0; i < this.Level.Length; i++)
         {
             if (nick.StartsWith(connection.ServerSetting.StatusModes[1][i].ToString()))
             {
                 this.Level[i] = true;
                 nick = nick.Substring(1);
             }
         }
     }
     nickName = nick;
 }
Example #4
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 #5
0
        //just return for channel - tab order
        internal int GetTabPage(string sCaption, IRCConnection connection)
        {
            for (int i = 0; i < _TabPages.Count; i++)
            {
                if (_TabPages[i].TabCaption.ToLower() == sCaption && _TabPages[i].Connection == connection && _TabPages[i].WindowStyle == IceTabPage.WindowType.Channel)
                    return i;
            }

            return 0;
        }
Example #6
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, string host, string account, string timeStamp)
        {
            //check if channel window already exists
            IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel);
            if (t == null)
            {
                t = AddWindow(connection, channel, IceTabPage.WindowType.Channel);

                //System.Diagnostics.Debug.WriteLine("joined:" + channel);
                if (connection.ServerSetting.ChannelJoins.ContainsKey(channel))
                {
                    //System.Diagnostics.Debug.WriteLine("key exists:" + channel + ":" + connection.ServerSetting.ChannelJoins[channel]);
                    t.ChannelKey = connection.ServerSetting.ChannelJoins[channel];
                    connection.ServerSetting.ChannelJoins.Remove(channel);
                }

                PluginArgs args = new PluginArgs(t.TextWindow, channel, connection.ServerSetting.CurrentNickName, host, "");
                args.Connection = connection;
                args.Extra = "self";

                foreach (Plugin p in loadedPlugins)
                {
                    IceChatPlugin ipc = p as IceChatPlugin;
                    if (ipc != null)
                    {
                        if (ipc.plugin.Enabled == true)
                            ipc.plugin.ChannelJoin(args);
                    }
                }

                serverTree.Invalidate();
            }
            else
            {
                if (loadedPlugins.Count > 0)
                {
                    PluginArgs args = new PluginArgs(t.TextWindow, channel, connection.ServerSetting.CurrentNickName, host, "");
                    args.Connection = connection;

                    foreach (Plugin p in loadedPlugins)
                    {
                        IceChatPlugin ipc = p as IceChatPlugin;
                        if (ipc != null)
                        {
                            if (ipc.plugin.Enabled == true)
                                ipc.plugin.ChannelJoin(args);
                        }
                    }
                }

                serverTree.Invalidate();

                string msg = GetMessageFormat("Self Channel Join");

                System.Diagnostics.Debug.WriteLine(msg);
                System.Diagnostics.Debug.WriteLine(host);
                msg = msg.Replace("$nick", connection.ServerSetting.CurrentNickName).Replace("$channel", t.TabCaption);
                msg = msg.Replace("$host", host);

                t.TextWindow.AppendText(msg, timeStamp);

            }
        }
Example #7
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, string account, bool refresh, string timeStamp)
        {
            try
            {
                IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel);
                if (t != null)
                {
                    bool refreshNicklist = true;

                    if (refresh)
                    {
                        string msg = GetMessageFormat("Channel Join");
                        msg = msg.Replace("$nick", nick).Replace("$channel", channel).Replace("$host", host);
                        if (account.Length > 0)
                            msg = msg.Replace("$account", " [" + account + "]");
                        else
                            msg = msg.Replace("$account", "");

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

                        foreach (Plugin p in loadedPlugins)
                        {
                            IceChatPlugin ipc = p as IceChatPlugin;
                            if (ipc != null)
                            {
                                if (ipc.plugin.Enabled == true)
                                    args = ipc.plugin.ChannelJoin(args);
                            }
                        }

                        if (args.DisableEvent == false)
                        {
                            int JoinEventLocation = iceChatOptions.JoinEventLocation;
                            if (t.JoinEventLocationOverload)
                                JoinEventLocation = t.JoinEventLocation;

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

                    if (refreshNicklist)
                        t.AddNick(nick, refresh);
                }
            }
            catch (Exception e)
            {
                WriteErrorFile(connection, "OnChannelJoin:" + nick, e);
            }
        }
Example #8
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 #9
0
 private void OnChannelInfoAddException(IRCConnection connection, string channel, string host, string bannedBy)
 {
     IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel);
     if (t != null)
     {
         if (t.HasChannelInfo)
         {
             t.ChannelInfoForm.AddChannelException(host, bannedBy);
         }
     }
 }
Example #10
0
        /// <summary>
        /// A User changed their Nick Name
        /// </summary>
        /// <param name="connection">Which Connection it came from</param>
        /// <param name="oldnick">Original Nick Name</param>
        /// <param name="newnick">New Nick Name</param>
        private void OnChangeNick(IRCConnection connection, string oldnick, string newnick, string host, string timeStamp)
        {
            try
            {
                string network = "";
                if (connection.ServerSetting.NetworkName.Length > 0)
                    network = " (" + connection.ServerSetting.NetworkName + ")";

                string away = "";
                if (connection.ServerSetting.Away == true)
                    away = " {AWAY}";

                if (CurrentWindowStyle == IceTabPage.WindowType.Console)
                {
                    if (inputPanel.CurrentConnection == connection)
                    {
                        //check if we are on a BNC
                        string ssl = "";
                        if (inputPanel.CurrentConnection.ServerSetting.UseSSL)
                            ssl = " {SSL}";

                        if (inputPanel.CurrentConnection.ServerSetting.UseBNC)
                            StatusText(inputPanel.CurrentConnection.ServerSetting.CurrentNickName + " connected to " + inputPanel.CurrentConnection.ServerSetting.RealServerName + " {BNC}" + ssl + network + away);
                        else
                            StatusText(inputPanel.CurrentConnection.ServerSetting.CurrentNickName + " connected to " + inputPanel.CurrentConnection.ServerSetting.RealServerName + ssl + network + away);

                        if (connection.ServerSetting.CurrentNickName == newnick)
                        {
                            string msg = GetMessageFormat("Self Nick Change");
                            msg = msg.Replace("$nick", oldnick).Replace("$newnick", newnick).Replace("$host", host); ;

                            mainChannelBar.GetTabPage("Console").AddText(connection, msg, timeStamp, false, ServerMessageType.Other);

                        }
                    }
                }

                string cmsg = "";
                if (connection.ServerSetting.CurrentNickName == newnick)
                    cmsg = GetMessageFormat("Self Nick Change");
                else
                    cmsg = GetMessageFormat("Channel Nick Change");

                cmsg = cmsg.Replace("$nick", oldnick).Replace("$newnick", newnick).Replace("$host", host); ;

                string consoleMessage = "";

                if (loadedPlugins.Count > 0)
                {
                    PluginArgs args = new PluginArgs(mainChannelBar.GetTabPage("Console").TextWindow, "", oldnick, newnick, cmsg);
                    args.Connection = connection;

                    foreach (Plugin p in loadedPlugins)
                    {
                        IceChatPlugin ipc = p as IceChatPlugin;
                        if (ipc != null)
                        {
                            if (ipc.plugin.Enabled == true)
                                ipc.plugin.NickChange(args);
                        }
                    }
                }

                foreach (IceTabPage t in mainChannelBar.TabPages)
                {
                    if (t.Connection == connection)
                    {
                        if (t.WindowStyle == IceTabPage.WindowType.Channel)
                        {
                            if (t.NickExists(oldnick))
                            {
                                if (connection.ServerSetting.CurrentNickName == newnick)
                                {
                                    string msg = GetMessageFormat("Self Nick Change");
                                    msg = msg.Replace("$nick", oldnick).Replace("$newnick", newnick).Replace("$host", host); ;
                                    consoleMessage = msg;

                                    if (iceChatOptions.NickChangeEventLocation == 0)
                                        t.TextWindow.AppendText(msg, timeStamp);

                                    //update status bar as well if current channel
                                    if ((inputPanel.CurrentConnection == connection) && (CurrentWindowStyle == IceTabPage.WindowType.Channel))
                                    {
                                        if (CurrentWindow == t)
                                        {
                                            User uu = t.GetNick(t.Connection.ServerSetting.CurrentNickName);
                                            if (uu != null)
                                                StatusText(uu.ToString() + " in channel " + t.TabCaption + " [" + t.ChannelModes + "] {" + t.Connection.ServerSetting.RealServerName + "}" + network + away);
                                            else
                                                StatusText(t.Connection.ServerSetting.CurrentNickName + " in channel " + t.TabCaption + " [" + t.ChannelModes + "] {" + t.Connection.ServerSetting.RealServerName + "}" + network + away);
                                        }
                                    }
                                }
                                else
                                {
                                    string msg = GetMessageFormat("Channel Nick Change");
                                    msg = msg.Replace("$nick", oldnick).Replace("$newnick", newnick).Replace("$host", host);
                                    consoleMessage = msg;

                                    if (iceChatOptions.NickChangeEventLocation == 0)
                                    {
                                        t.TextWindow.AppendText(msg, timeStamp);
                                        t.LastMessageType = ServerMessageType.Other;
                                    }
                                }

                                User u = t.GetNick(oldnick);
                                string nick = newnick;
                                if (u != null)
                                {
                                    for (int i = 0; i < u.Level.Length; i++)
                                    {
                                        if (u.Level[i])
                                        {
                                            if (!nick.StartsWith(connection.ServerSetting.StatusModes[1][i].ToString()))
                                                nick = connection.ServerSetting.StatusModes[1][i] + nick;
                                            break;
                                        }
                                    }

                                    t.RemoveNick(oldnick);
                                    t.AddNick(nick, true);
                                }

                                if (nickList.CurrentWindow == t)
                                    nickList.RefreshList(t);

                            }
                        }
                        else if (t.WindowStyle == IceTabPage.WindowType.Query)
                        {
                            if (t.TabCaption == oldnick)
                            {
                                //check if a tab for the new newnick exists
                                IceTabPage tCheck = GetWindow(connection, newnick, IceTabPage.WindowType.Query);
                                if (tCheck == null)
                                    t.TabCaption = newnick;

                                string msg = GetMessageFormat("Channel Nick Change");
                                msg = msg.Replace("$nick", oldnick);
                                msg = msg.Replace("$newnick", newnick);
                                msg = msg.Replace("$host", host);

                                if (iceChatOptions.NickChangeEventLocation == 0)
                                {
                                    t.TextWindow.AppendText(msg, timeStamp);
                                    t.LastMessageType = ServerMessageType.Other;
                                }

                                if ((inputPanel.CurrentConnection == connection) && (CurrentWindowStyle == IceTabPage.WindowType.Query))
                                {
                                    if (CurrentWindow == t)
                                    {
                                        User u = t.GetNick(t.Connection.ServerSetting.CurrentNickName);
                                        if (u != null)
                                            StatusText(u.ToString() + " in channel " + t.TabCaption + " [" + t.ChannelModes + "] {" + t.Connection.ServerSetting.RealServerName + "}" + network + away);
                                        else
                                            StatusText(t.Connection.ServerSetting.CurrentNickName + " in channel " + t.TabCaption + " [" + t.ChannelModes + "] {" + t.Connection.ServerSetting.RealServerName + "}" + network + away);
                                    }
                                }

                                if (nickList.CurrentWindow == t)
                                    nickList.RefreshList(t);

                                this.mainChannelBar.Invalidate();
                                this.serverTree.Invalidate();
                            }
                            else if (connection.ServerSetting.CurrentNickName == newnick)
                            {
                                string msg = GetMessageFormat("Self Nick Change");
                                msg = msg.Replace("$nick", oldnick).Replace("$newnick", newnick).Replace("$host", host); ;

                                if (iceChatOptions.NickChangeEventLocation == 0)
                                    t.TextWindow.AppendText(msg, timeStamp);

                                if (nickList.CurrentWindow == t)
                                    nickList.RefreshList(t);

                                this.mainChannelBar.Invalidate();
                                this.serverTree.Invalidate();

                            }
                        }

                    }
                }
                if (iceChatOptions.NickChangeEventLocation == 1)
                {
                    if (consoleMessage.Length > 0)
                        mainChannelBar.GetTabPage("Console").AddText(connection, consoleMessage, timeStamp, false, ServerMessageType.Other);
                }

            }
            catch (Exception e)
            {
                WriteErrorFile(connection, "OnChangeNick Error:" + oldnick + ":" + newnick ,e);
            }
        }
Example #11
0
 private void OnUserInfoServer(IRCConnection connection, string nick, string server)
 {
     if (connection.UserInfoWindow != null)
     {
         ((FormUserInfo)connection.UserInfoWindow).Server(server);
     }
 }
Example #12
0
        private void OnBuddyList(IRCConnection connection, string[] buddies, string timeStamp)
        {
            PluginArgs args = new PluginArgs(connection);

            foreach (BuddyListItem b in connection.ServerSetting.BuddyList)
            {
                if (b.IsOnSent && !b.IsOnReceived)
                {
                    bool isFound = false;
                    foreach (string buddy in buddies)
                    {
                        //this nick is connected
                        if (b.Nick.ToLower() == buddy.ToLower())
                        {
                            if (!b.Connected)
                            {
                                //send message we are now online
                                string msg = GetMessageFormat("Server Message");
                                if (connection.ServerSetting.RealServerName.Length > 0)
                                    msg = msg.Replace("$server", connection.ServerSetting.RealServerName);
                                else
                                    msg = msg.Replace("$server", connection.ServerSetting.ServerName);

                                msg = msg.Replace("$message", b.Nick + " is online");

                                mainChannelBar.GetTabPage("Console").AddText(connection, msg, timeStamp, false, ServerMessageType.BuddyNotice);
                                mainChannelBar.GetTabPage("Console").LastMessageType = ServerMessageType.BuddyNotice;
                            }

                            b.Connected = true;
                            b.IsOnReceived = true;
                            isFound = true;

                            if (loadedPlugins.Count > 0)
                            {
                                args.Nick = b.Nick;
                                args.Extra = "online";
                                foreach (Plugin p in loadedPlugins)
                                {
                                    IceChatPlugin ipc = p as IceChatPlugin;
                                    if (ipc != null)
                                    {
                                        if (ipc.plugin.Enabled == true)
                                            ipc.plugin.BuddyList(args);
                                    }
                                }
                            }
                        }
                    }
                    if (!isFound)
                    {
                        if (!b.IsOnReceived && b.Connected)
                        {
                            //send message we are now online
                            string msg = GetMessageFormat("Server Message");
                            if (connection.ServerSetting.RealServerName.Length > 0)
                                msg = msg.Replace("$server", connection.ServerSetting.RealServerName);
                            else
                                msg = msg.Replace("$server", connection.ServerSetting.ServerName);
                            msg = msg.Replace("$message", b.Nick + " is offline");

                            mainChannelBar.GetTabPage("Console").AddText(connection, msg, timeStamp, false, ServerMessageType.BuddyNotice);
                            mainChannelBar.GetTabPage("Console").LastMessageType = ServerMessageType.BuddyNotice;
                        }

                        b.Connected = false;
                        b.IsOnReceived = true;

                        args.Nick = b.Nick;
                        args.Extra = "offline";
                        if (loadedPlugins.Count > 0)
                        {
                            foreach (Plugin p in loadedPlugins)
                            {
                                IceChatPlugin ipc = p as IceChatPlugin;
                                if (ipc != null)
                                {
                                    if (ipc.plugin.Enabled == true)
                                        ipc.plugin.BuddyList(args);
                                }
                            }
                        }
                    }
                }
            }

            //System.Diagnostics.Debug.WriteLine("Clear Buddy List Status");

            if (connection.buddiesIsOnSent == connection.ServerSetting.BuddyList.Length)
            {
                //reset all the isonsent values
                foreach (BuddyListItem buddy in connection.ServerSetting.BuddyList)
                {
                    buddy.IsOnSent = false;
                    buddy.IsOnReceived = false;
                }
                connection.buddiesIsOnSent = 0;

                //send a user event to refresh the buddy list for this server
                this.buddyList.ClearBuddyList(connection);

                foreach (BuddyListItem buddy in connection.ServerSetting.BuddyList)
                {
                    this.buddyList.UpdateBuddy(connection, buddy);
                }

            }
        }
Example #13
0
 private void OnUserInfoLoggedIn(IRCConnection connection, string nick, string name)
 {
     if (connection.UserInfoWindow != null)
     {
         ((FormUserInfo)connection.UserInfoWindow).LoggedIn(name);;
     }
 }
Example #14
0
 private void OnUserInfoIdleLogon(IRCConnection connection, string nick, string idleTime, string logonTime)
 {
     if (connection.UserInfoWindow != null)
     {
         ((FormUserInfo)connection.UserInfoWindow).IdleTime(idleTime);
         ((FormUserInfo)connection.UserInfoWindow).LogonTime(logonTime);
     }
 }
Example #15
0
 private void OnUserInfoHostFullName(IRCConnection connection, string nick, string host, string full)
 {
     if (connection.UserInfoWindow != null)
     {
         ((FormUserInfo)connection.UserInfoWindow).HostName(host);
         ((FormUserInfo)connection.UserInfoWindow).FullName(full);
     }
 }
Example #16
0
 private void OnBuddyListClear(IRCConnection connection)
 {
     buddyList.ClearBuddyList(connection);
 }
Example #17
0
 private void OnBuddyRemove(IRCConnection connection, BuddyListItem buddy)
 {
     System.Diagnostics.Debug.WriteLine("Remove:" + buddy.Nick);
     buddyList.RemoveBuddy(connection, buddy);
 }
Example #18
0
 private bool OnUserInfoWindowExists(IRCConnection connection, string nick)
 {
     if (connection.UserInfoWindow != null)
     {
         if (connection.UserInfoWindow.Text.ToLower() == "user information: " + nick.ToLower())
         {
             return true;
         }
     }
     return false;
 }
Example #19
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, string timeStamp)
        {
            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("$message", message);

                if (msg.Contains("$color") && t.NickExists(nick))
                {
                    User u = t.GetNick(nick);

                    //get the nick color
                    if (u.nickColor == -1)
                    {
                        if (iceChatColors.RandomizeNickColors == true)
                        {
                            int randColor = new Random().Next(0, 71);
                            if (randColor == iceChatColors.NickListBackColor)
                                randColor = new Random().Next(0, 71);

                            u.nickColor = randColor;
                        }
                        else
                        {
                            //get the correct nickname color for channel status
                            for (int y = 0; y < u.Level.Length; y++)
                            {
                                if (u.Level[y])
                                {
                                    switch (connection.ServerSetting.StatusModes[0][y])
                                    {
                                        case 'q':
                                            u.nickColor = iceChatColors.ChannelOwnerColor;
                                            break;
                                        case 'a':
                                            u.nickColor = iceChatColors.ChannelAdminColor;
                                            break;
                                        case 'o':
                                            u.nickColor = iceChatColors.ChannelOpColor;
                                            break;
                                        case 'h':
                                            u.nickColor = iceChatColors.ChannelHalfOpColor;
                                            break;
                                        case 'v':
                                            u.nickColor = iceChatColors.ChannelVoiceColor;
                                            break;
                                        default:
                                            u.nickColor = iceChatColors.ChannelRegularColor;
                                            break;
                                    }

                                    break;
                                }
                            }

                            if (u.nickColor == -1)
                                u.nickColor = iceChatColors.ChannelRegularColor;
                        }

                    }

                    msg = msg.Replace("$color", ((char)3).ToString() + u.nickColor.ToString("00"));
                }
                else
                {
                    msg = msg.Replace("$color", string.Empty);
                }

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

                foreach (Plugin p in loadedPlugins)
                {
                    IceChatPlugin ipc = p as IceChatPlugin;
                    if (ipc != null)
                    {
                        if (ipc.plugin.Enabled == true)
                            args = ipc.plugin.ChannelAction(args);
                    }
                }

                if (args.DisableEvent == true)
                    return;

                if (args.Message.Contains(connection.ServerSetting.CurrentNickName))
                {
                    //check if sounds are disabled for this window
                    if (!t.DisableSounds)
                    {
                        if ((CurrentWindow != t || iceChatOptions.SoundPlayActive) || this.notifyIcon.Visible == true)
                            PlaySoundFile("nickchan");
                    }
                }

                if (iceChatOptions.FlashTaskBarChannelAction == true)
                {
                    //check if we are minimized or program is not in foreground
                    if (this.WindowState == FormWindowState.Minimized || this.IsForeGround == false)
                    {
                        if (t.EventOverLoad == false)
                            FlashTaskBar();
                    }
                }

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

                    if (!t.DisableSounds)
                    {
                        if ((CurrentWindow != t || iceChatOptions.SoundPlayActive) || this.notifyIcon.Visible == true)
                            PlaySoundFile("chanmsg");
                    }
                }
                else if (iceChatOptions.ChannelActionEventLocation == 1)
                {
                    //send it to the console
                    mainChannelBar.GetTabPage("Console").AddText(connection, args.Message, timeStamp, false, ServerMessageType.Action);
                }

            }
        }
Example #20
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 timeStamp)
        {
            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);

            mainChannelBar.GetTabPage("Console").AddText(connection, msg, timeStamp, false, ServerMessageType.Other);
            if (!connection.ServerSetting.DisableSounds)
                PlaySoundFile("conmsg");

            //parse out the user modes
            //set the mode in Server Setting
        }
Example #21
0
 private void OnChannelInfoTopicSet(IRCConnection connection, string channel, string nick, string time)
 {
     IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel);
     if (t != null)
     {
         if (t.HasChannelInfo)
         {
             t.ChannelInfoForm.ChannelTopicSetBy(nick, time);
         }
     }
 }
Example #22
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, string timeStamp)
        {
            if (message.ToUpper().StartsWith("DCC CHAT"))
            {
                if (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 (Plugin p in loadedPlugins)
            {
                IceChatPlugin ipc = p as IceChatPlugin;
                if (ipc != null)
                {
                    if (ipc.plugin.Enabled == true)
                            args = ipc.plugin.UserNotice(args);
                }
            }

            if (args.DisableEvent == true)
                return;

            if (iceChatOptions.UserNoticeEventLocation == 0)
            {
                mainChannelBar.GetTabPage("Console").AddText(connection, args.Message, timeStamp, false, ServerMessageType.Other);
                mainChannelBar.GetTabPage("Console").LastMessageType = ServerMessageType.Other;
            }
            else if (iceChatOptions.UserNoticeEventLocation == 1)
            {
                CurrentWindowMessage(connection, args.Message, timeStamp, false);
                CurrentWindow.LastMessageType = ServerMessageType.Other;
            }

            if (iceChatOptions.UserNoticeEventLocation < 2)
                if (!connection.ServerSetting.DisableSounds)
                    PlaySoundFile("notice");
        }
Example #23
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 timeStamp)
        {
            string msg = GetMessageFormat("Channel Invite");
            msg = msg.Replace("$channel", channel).Replace("$nick", nick).Replace("$host", host);

            mainChannelBar.GetTabPage("Console").AddText(connection, msg, timeStamp, false, ServerMessageType.Other);

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

            if (loadedPlugins.Count > 0)
            {
                PluginArgs args = new PluginArgs(mainChannelBar.GetTabPage("Console").TextWindow, channel, nick, host, msg);
                args.Connection = connection;

                foreach (Plugin p in loadedPlugins)
                {
                    IceChatPlugin ipc = p as IceChatPlugin;
                    if (ipc != null)
                    {
                        if (ipc.plugin.Enabled == true)
                            args = ipc.plugin.ChannelInvite(args);
                    }
                }

                if (args.DisableEvent == true)
                    return;

            }

            if (iceChatOptions.AutoJoinInvite)
            {
                ParseOutGoingCommand(connection, "/join " + channel);
            }
        }
Example #24
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 timeStamp)
        {
            string msg = GetMessageFormat("User Whois");
            msg = msg.Replace("$nick", nick);
            msg = msg.Replace("$data", data);

            if (loadedPlugins.Count > 0)
            {
                PluginArgs args = new PluginArgs(mainChannelBar.GetTabPage("Console").TextWindow, "", nick, "", msg);
                args.Connection = connection;

                foreach (Plugin p in loadedPlugins)
                {
                    IceChatPlugin ipc = p as IceChatPlugin;
                    if (ipc != null)
                    {
                        if (ipc.plugin.Enabled == true)
                            ipc.plugin.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, timeStamp);
                    t.LastMessageType = ServerMessageType.Other;
                }
                else
                {
                    mainChannelBar.GetTabPage("Console").AddText(connection, msg, timeStamp, false, ServerMessageType.Other);
                }
            }
            else
            {
                if (iceChatOptions.WhoisEventLocation == 0)
                    //send whois data to the current window
                    CurrentWindowMessage(connection, msg, timeStamp, false);
                else
                    mainChannelBar.GetTabPage("Console").AddText(connection, msg, timeStamp, false, ServerMessageType.Other);

            }
        }
Example #25
0
 private void OnAutoAwayTrigger(IRCConnection connection)
 {
     string msg = iceChatOptions.AutoAwayMessage;
     msg = msg.Replace("$autoawaytime", iceChatOptions.AutoAwayTime.ToString());
     ParseOutGoingCommand(connection, "/away " + msg);
 }
Example #26
0
        private void OnWhoReply(IRCConnection connection, string channel, string nick, string host, string flags, string message)
        {
            IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel);
            if (t != null)
            {
                //user flags in ircData[8] H-here G-gone(away) *-irc operator x-hiddenhost d-deaf

                bool away = false;

                if (flags.Contains("G")) away = true;

                OnIALUserDataAway(connection, nick, host, channel, away, "");

                if (t.GotWhoList)
                    OnServerMessage(connection, message, "");

                if (loadedPlugins.Count > 0)
                {
                    PluginArgs args = new PluginArgs(t, channel, nick, host, message);
                    args.Connection = connection;

                    foreach (Plugin p in loadedPlugins)
                    {
                        IceChatPlugin ipc = p as IceChatPlugin;
                        if (ipc != null)
                        {
                            if (ipc.plugin.Enabled == true)
                                ipc.plugin.WhoReply(args);
                        }
                    }
                }
            }
            else
            {
                OnServerMessage(connection, message, "");
            }
        }
Example #27
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 #28
0
 private void OnWriteErrorFile(IRCConnection connection, string method, Exception e)
 {
     WriteErrorFile(connection, method, e);
 }
Example #29
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 #30
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);
 }