예제 #1
0
 public JoinedUITask(IRCCommunicator sender, string channelHash, string clientName, string clan)
 {
     this.Sender      = sender;
     this.ChannelHash = channelHash;
     this.ClientName  = clientName;
     this.Clan        = clan;
 }
예제 #2
0
 public ClientAddOrRemoveTask(IRCCommunicator sender, string channelHash, string senderName, string clientName, TaskType type)
 {
     this.Sender      = sender;
     this.ChannelHash = channelHash;
     this.SenderName  = senderName;
     this.ClientName  = clientName;
     this.Type        = type;
 }
예제 #3
0
 public MessageUITask(IRCCommunicator sender, string clientName, string channelHash, string message, MessageSetting setting)
 {
     this.Sender      = sender;
     this.ClientName  = clientName;
     this.ChannelHash = channelHash;
     this.Message     = message;
     this.Setting     = setting;
 }
예제 #4
0
 public ClientUITask(IRCCommunicator sender, string channelHash, string clientName, CountryClass country, string clan, int rank, bool clientGreatSnooper, string clientApp)
 {
     this.Sender             = sender;
     this.ChannelHash        = channelHash;
     this.ClientName         = clientName;
     this.Country            = country;
     this.Clan               = clan;
     this.Rank               = rank;
     this.ClientGreatSnooper = clientGreatSnooper;
     this.ClientApp          = clientApp;
 }
예제 #5
0
        public bool Equals(IRCCommunicator irc)
        {
            // If parameter is null return false:
            if ((object)irc == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return(this.serverAddress == irc.serverAddress);
        }
예제 #6
0
        private void TUSLoginWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                this.Close();
                return;
            }

            switch (tusState)
            {
            case TUSStates.TUSError:
                MessageBox.Show(this, "An error occoured! Please try again!", "Fail", MessageBoxButton.OK, MessageBoxImage.Error);
                break;

            case TUSStates.OK:
                GlobalManager.User              = new Client(nickName, null, nickClan);
                GlobalManager.User.Country      = nickCountry;
                GlobalManager.User.Rank         = RanksClass.GetRankByInt(nickRank);
                GlobalManager.User.GreatSnooper = true;
                GlobalManager.User.TusNick      = tusNickStr;

                if (Properties.Settings.Default.ChangeWormsNick)
                {
                    Properties.Settings.Default.WormsNick = nickName;
                    Properties.Settings.Default.Save();
                }

                // Initialize the WormNet Communicator
                wormNetC = new IRCCommunicator(serverAddress, serverPort);
                wormNetC.ConnectionState += ConnectionState;
                wormNetC.Connect();
                return;

            case TUSStates.UserError:
                MessageBox.Show(this, "The given username or password was incorrent!", "Wrong username or password", MessageBoxButton.OK, MessageBoxImage.Error);
                break;

            case TUSStates.ConnectionError:
                MessageBox.Show(this, "The communication with TUS has failed. Please try again!", "Fail", MessageBoxButton.OK, MessageBoxImage.Error);
                break;
            }

            Container.IsEnabled  = true;
            LoadingRing.IsActive = false;
        }
예제 #7
0
        public override bool Equals(System.Object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return(false);
            }

            // If parameter cannot be cast to Point return false.
            IRCCommunicator irc = obj as IRCCommunicator;

            if ((System.Object)irc == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return(this.serverAddress == irc.serverAddress);
        }
예제 #8
0
        // Constructor
        public Client(string name, IRCCommunicator server, string clan = "")
        {
            this.Name         = name;
            this.LowerName    = name.ToLower();
            this.Clan         = clan;
            this.Rank         = RanksClass.GetRankByInt(0);
            this.Channels     = new List <Channel>();
            this.PMChannels   = new List <Channel>();
            this.AddToChannel = new List <Channel>();
            UserGroup group = null;

            if (UserGroups.Users.TryGetValue(this.LowerName, out group))
            {
                Group = group;
            }
            if (server != null)
            {
                this.IsBanned = GlobalManager.BanList.ContainsKey(this.LowerName);
                server.Clients.Add(this.LowerName, this);
            }
        }
예제 #9
0
 public ClientLeaveConvTask(IRCCommunicator sender, string channelHash, string clientName)
 {
     this.Sender      = sender;
     this.ChannelHash = channelHash;
     this.ClientName  = clientName;
 }
예제 #10
0
 public NickUITask(IRCCommunicator sender, string oldClientName, string newClientName)
 {
     this.Sender        = sender;
     this.OldClientName = oldClientName;
     this.NewClientName = newClientName;
 }
예제 #11
0
 public NickNameInUseTask(IRCCommunicator sender)
 {
     this.Sender = sender;
 }
예제 #12
0
 public OfflineUITask(IRCCommunicator sender, string clientName)
 {
     this.Sender     = sender;
     this.ClientName = clientName;
 }
예제 #13
0
 public PartedUITask(IRCCommunicator sender, string channelHash, string clientNameL)
 {
     this.Sender      = sender;
     this.ChannelHash = channelHash;
     this.ClientNameL = clientNameL;
 }
예제 #14
0
 public QuitUITask(IRCCommunicator sender, string clientNameL, string message)
 {
     this.Sender      = sender;
     this.ClientNameL = clientNameL;
     this.Message     = message;
 }
예제 #15
0
        private void LogIn()
        {
            serverAddress = Server.Text.Trim().ToLower();
            if (serverAddress.Length == 0)
            {
                MakeErrorTooltip(Server, "Please choose a server!");
                return;
            }

            int colon;

            if ((colon = serverAddress.IndexOf(':')) != -1)
            {
                string portstr = serverAddress.Substring(colon + 1);
                if (!int.TryParse(portstr, out serverPort))
                {
                    serverPort = 6667;
                }
                else
                {
                    serverAddress = serverAddress.Substring(0, colon);
                }
            }
            else
            {
                serverPort = 6667;
            }


            switch (LoginTypeChooser.SelectedIndex)
            {
            // Simple login
            case 0:
                if (clanRegex == null)
                {
                    clanRegex = new Regex(@"^[a-z0-9]*$", RegexOptions.IgnoreCase);
                }

                nickName = Nick.Text.Trim();
                nickClan = Clan.Text.Trim();

                if (nickName.Length == 0)
                {
                    MakeErrorTooltip(Nick, "Please enter your nickname!");
                }
                else if (!nickRegex.IsMatch(nickName))
                {
                    MakeErrorTooltip(Nick, "Your nickname should begin with a character" + Environment.NewLine + "of the English aplhabet or with ` character!");
                }
                else if (!nickRegex2.IsMatch(nickName))
                {
                    MakeErrorTooltip(Nick, "Your nickname contains one or more" + Environment.NewLine + "forbidden characters! Use characters from" + Environment.NewLine + "the English alphabet, numbers, - or `!");
                }
                else if (!clanRegex.IsMatch(nickClan))
                {
                    MakeErrorTooltip(Clan, "Your clan can contain only characters" + Environment.NewLine + "from the English alphabet or numbers");
                }
                else
                {
                    Container.IsEnabled  = false;
                    LoadingRing.IsActive = true;

                    nickCountry = Country.SelectedValue as CountryClass;
                    nickRank    = Rank.SelectedIndex;

                    Properties.Settings.Default.LoginType     = "simple";
                    Properties.Settings.Default.ServerAddress = Server.Text.Trim().ToLower();
                    Properties.Settings.Default.AutoLogIn     = AutoLogIn.IsChecked.Value;
                    Properties.Settings.Default.UserName      = nickName;
                    Properties.Settings.Default.UserClan      = nickClan;
                    Properties.Settings.Default.UserCountry   = nickCountry.ID;
                    Properties.Settings.Default.UserRank      = nickRank;
                    if (Properties.Settings.Default.ChangeWormsNick)
                    {
                        Properties.Settings.Default.WormsNick = nickName;
                    }
                    Properties.Settings.Default.Save();

                    GlobalManager.User         = new Client(nickName, null, nickClan);
                    GlobalManager.User.Country = nickCountry;
                    GlobalManager.User.Rank    = RanksClass.GetRankByInt(nickRank);

                    // Initialize the WormNet Communicator
                    wormNetC = new IRCCommunicator(serverAddress, serverPort);
                    wormNetC.ConnectionState += ConnectionState;
                    wormNetC.Connect();
                }
                break;

            // TUS login
            case 1:
                nickName    = TUSNick.Text.Trim();
                tusPassword = TUSPass.Password.Trim();

                if (nickName.Length == 0)
                {
                    MakeErrorTooltip(TUSNick, "Please enter your nickname!");
                }
                else if (!nickRegex.IsMatch(nickName))
                {
                    MakeErrorTooltip(TUSNick, "Your nickname should begin with a character" + Environment.NewLine + "of the English aplhabet or with ` character!");
                }
                else if (!nickRegex2.IsMatch(nickName))
                {
                    MakeErrorTooltip(TUSNick, "Your nickname contains one or more" + Environment.NewLine + "forbidden characters! Use characters from" + Environment.NewLine + "the English alphabet, numbers, - or `!");
                }
                else if (tusPassword.Length == 0)
                {
                    MakeErrorTooltip(TUSPass, "Please enter your password!");
                }
                else
                {
                    Container.IsEnabled  = false;
                    LoadingRing.IsActive = true;

                    Properties.Settings.Default.LoginType     = "tus";
                    Properties.Settings.Default.ServerAddress = serverAddress;
                    Properties.Settings.Default.AutoLogIn     = AutoLogIn.IsChecked.Value;
                    Properties.Settings.Default.TusNick       = nickName;
                    Properties.Settings.Default.TusPass       = tusPassword;
                    Properties.Settings.Default.Save();

                    tusState = TUSStates.TUSError;

                    if (tusLoginWorker == null)
                    {
                        tusLoginWorker = new BackgroundWorker();
                        tusLoginWorker.WorkerSupportsCancellation = true;
                        tusLoginWorker.DoWork             += TUSLoginWorker_DoWork;
                        tusLoginWorker.RunWorkerCompleted += TUSLoginWorker_RunWorkerCompleted;
                    }
                    tusLoginWorker.RunWorkerAsync();
                }
                break;
            }
        }
예제 #16
0
 public ChannelListUITask(IRCCommunicator sender, SortedDictionary <string, string> channelList)
 {
     this.Sender      = sender;
     this.ChannelList = channelList;
 }
예제 #17
0
        // Constructor
        public Channel(MainWindow mw, IRCCommunicator server, string name, string description, Client theClient = null)
        {
            this.mw          = mw;
            this.Server      = server;
            this.Name        = name;
            this.Description = description;

            // Make channel layout
            this.ChannelTabItem             = new TabItem();
            this.ChannelTabItem.DataContext = this;

            if (theClient != null)
            {
                this.Clients = new SortedObservableCollection <Client>();
                this.Clients.CollectionChanged += Clients_CollectionChanged;
                this.ChannelTabItem.Style       = (Style)mw.Channels.FindResource("PrivMsgTabItem");
                this.ChannelTabItem.ApplyTemplate();
                this.header = (TextBlock)this.ChannelTabItem.Template.FindName("ContentSite", this.ChannelTabItem);
                this.LoadConnectedLayout();
                this.IsPrivMsgChannel = true;

                if (this.Name.Contains(","))
                {
                    string[] helper = this.Name.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string clientName in helper)
                    {
                        Client c = null;
                        if (!this.Server.Clients.TryGetValue(clientName.ToLower(), out c))
                        {
                            c = new Client(clientName, Server);
                        }

                        this.Clients.Add(c);
                    }
                }
                else
                {
                    this.Clients.Add(theClient);
                }

                this.HashName = GetNewHashName();
                this.GenerateHeader();

                Border b = (Border)this.ChannelTabItem.Template.FindName("Border", this.ChannelTabItem);
                b.MouseEnter += b_MouseEnter;
                b.MouseLeave += b_MouseLeave;

                this.Messages     = new List <MessageClass>(GlobalManager.MaxMessagesInMemory);
                this.userMessages = new List <string>(5);

                if (!theClient.IsBanned)
                {
                    mw.Channels.Items.Add(this.ChannelTabItem);
                }
            }
            else
            {
                this.ChannelTabItem.Header = this.Name;
                this.HashName             = name.ToLower();
                this.ChannelTabItem.Style = (Style)mw.Channels.FindResource("ChannelTabItem");
                this.LoadDisconnectedLayout();
                if (Name != "#worms" || Properties.Settings.Default.ShowWormsChannel)
                {
                    mw.Channels.Items.Add(this.ChannelTabItem);
                }

                // Make user list layout
                this.TheDataGrid             = mw.MakeUserListTemplate();
                this.TheDataGrid.DataContext = this;

                TabItem ti = new TabItem();
                ti.Content = this.TheDataGrid;
                mw.UserList.Items.Add(ti);

                TabItem gameListTabItem = mw.MakeGameListTabItem(this);
                GameListBox = (ListBox)((Border)((Grid)gameListTabItem.Content).Children[1]).Child;
                mw.GameList.Items.Add(gameListTabItem);
            }

            this.Server.ChannelList.Add(this.HashName, this);
        }