Exemplo n.º 1
0
 public FrmUser()
 {
     userMode = UserMode.Add;
     InitializeComponent();
     this.Text = "添加用户";
     InitValidationRules();
 }
Exemplo n.º 2
0
 // Unlike HashSet, Dictionary throws an exception if a key exists. This avoids the exception
 // and updates the UserMode if necessary.
 public void AddChannel(ChannelData d, UserMode? m = null)
 {
     if (channels.ContainsKey(d)) {
         if (m.HasValue) channels[d] = m.Value;
     } else {
         channels.Add(d, m.GetValueOrDefault(UserMode.None));
     }
 }
Exemplo n.º 3
0
        private bool fail = false; // удалять пользователя или нет

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Инициализирует новый экземпляр класса
        /// </summary>
        protected User()
        {
            handle = new Handle();

            selected = false;
            mode = UserMode.Active;

            indexes = new List<int>();
        }
Exemplo n.º 4
0
 public FrmUser(UserInfo ui)
 {
     userInfo = ui;
     userMode = UserMode.UPDATE;
     InitializeComponent();
     this.Text = "重置密码";
     textEditUserName.Text = ui.UserName;
     comboBoxEditUserType.Visible = false;
     labelControl4.Visible = false;
     textEditUserName.Enabled = false;
     InitValidationRules();
 }
Exemplo n.º 5
0
        public string Register()
        {
            string   Json = "";
            string   a    = new StreamReader(HttpContext.Request.Body).ReadToEnd();
            UserMode user = JsonConvert.DeserializeObject <UserMode>(a);

            if (!string.IsNullOrEmpty(user.Name) | !string.IsNullOrWhiteSpace(user.Name) | !string.IsNullOrEmpty(user.Pwds) | !string.IsNullOrWhiteSpace(user.Pwds))
            {
                if (0 != SQLControl.Execute($"insert testbase.UserTable value (0,'{user.Name}','{user.Pwds}');"))
                {
                    if (0 != SQLControl.Execute($"insert testbase.UserDataTable value ('{user.Name}','{user.Pwds}','InitialImage.jpg');"))
                    {
                        if (0 != SQLControl.Execute($"insert testbase.UserFileTable value ('{user.Name}','{Token.s}',1);"))
                        {
                            Json = JsonConvert.SerializeObject(new ReturnMode()
                            {
                                Data = "注册成功", Message = "OK"
                            });
                        }
                        else
                        {
                            Json = JsonConvert.SerializeObject(new ReturnMode()
                            {
                                Data = "注册失败,服务器错误", Message = "OK"
                            });
                        }
                    }
                }
                else
                {
                    Json = JsonConvert.SerializeObject(new ReturnMode()
                    {
                        Data = "注册失败,或有重复用户名", Message = "Error"
                    });
                }
            }
            else
            {
                Json = JsonConvert.SerializeObject(new ReturnMode()
                {
                    Data = "空!", Message = "Error"
                });
            }
            return(Json);
        }
Exemplo n.º 6
0
 public string Post()
 {
     string Json = "";
     string a = new StreamReader(HttpContext.Request.Body).ReadToEnd();
     UserMode user = JsonConvert.DeserializeObject<UserMode>(a);
     if (!string.IsNullOrEmpty(user.Name) | !string.IsNullOrWhiteSpace(user.Name) | !string.IsNullOrEmpty(user.Pwds) | !string.IsNullOrWhiteSpace(user.Pwds))
     {
         DataTable s;
         if ((s = SQLControl.Select($"SELECT * FROM CDNABASE.UserTable where  UserName='******'and PassWord='******';")) == null)
             Json = JsonConvert.SerializeObject(new ReturnMode() { Data = "数据库错误", Message = "Error" });
         if (s.Rows.Count != 0)
             Json = JsonConvert.SerializeObject(new ReturnMode() { Data = Token.GetToken(s.Rows[0][0].ToString()), Message = "OK" });
         else
             Json = JsonConvert.SerializeObject(new ReturnMode() { Data = "用户名密码错误", Message = "Error" });
     }
     else
         Json = JsonConvert.SerializeObject(new ReturnMode() { Data = "空!", Message = "Error" });
     return Json;
 }
Exemplo n.º 7
0
        public async void Load(UserMode mode)
        {
            if (mode == UserMode.Admin)
            {
                var users = await client.Users.GetUsersAsync();

                if (users)
                {
                    await sync.StartNew(() => Users.AddRange(users.Response));
                }
            }

            var staff = await client.Staff.GetStaffsAsync();

            if (staff)
            {
                await sync.StartNew(() => Staff.AddRange(staff.Response));
            }

            Groups_Imported();
        }
Exemplo n.º 8
0
        private void But_Back_Click(object sender, EventArgs e)
        {
            //卸载界面
            switch (((Button)sender).Name)
            {
            case "but_BackFromKeyset":
                gb_KeySet.Visible = false;
                break;

            case "but_BackFromArrangeTask":
                gb_ArrangeTask.Visible = false;
                break;

            case "but_BackFromTaskCompleted":
                gb_TaskComplete.Visible = false;
                break;
            }
            gb_Control.Visible = true;
            Mode = UserMode.View;
            ViewReFresh();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Handle a close message from the device.
        /// </summary>
        /// <param name="closeMessage">the close message</param>
        private void OnReceiveCloseMessage(PayloadMessageBase closeMessage)
        {
            if (applicationLogic == null || device == null || IsDisposed)
            {
                return;
            }

            if (!(applicationLogic.GetAutoRestart()))
            {
                userMode = UserMode.Stopped;
            }

            var deviceState = device.GetDeviceState();

            if (deviceState == DeviceState.Playing ||
                deviceState == DeviceState.Buffering ||
                deviceState == DeviceState.Paused ||
                deviceState == DeviceState.LoadingMedia ||
                deviceState == DeviceState.LoadingMediaCheckFirewall)
            {
                Stop();
            }
            device.SetDeviceState(DeviceState.Closed, null);
            Connected = false;
            var cancellationTokeSource = new CancellationTokenSource();

            applicationLogic.StartTask(() => {
                for (int i = 0; i < 20; i++)
                {
                    Task.Delay(100).Wait();

                    if (cancellationTokeSource.IsCancellationRequested)
                    {
                        return;
                    }
                }

                GetReceiverStatus();
            }, cancellationTokeSource);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Send a stop message.
        /// </summary>
        public void Stop(bool changeUserMode = false)
        {
            if (chromeCastMessages == null || device == null || IsDisposed)
            {
                return;
            }

            if (changeUserMode)
            {
                userMode = UserMode.Stopped;
            }

            var deviceState = device.GetDeviceState();

            // Hack to stop a device. If nothing is send the device is in buffering state and doesn't respond to stop messages. Send some silence first.
            if (deviceState == DeviceState.Buffering)
            {
                device.SendSilence();
            }

            SendMessage(chromeCastMessages.GetStopMessage(chromeCastApplicationSessionNr, chromeCastMediaSessionId, GetNextRequestId(), chromeCastSource, chromeCastDestination));
        }
Exemplo n.º 11
0
 /// <summary>
 /// Установить режим работы
 /// </summary>
 /// <param name="mode">Требуемый режим работы</param>
 /// <param name="handle">Описатель пользователя для которого установливается режим работы</param>
 public void SetMode(Handle handle, UserMode mode)
 {
     try
     {
         locker.AcquireWriterLock(500);
         try
         {
             foreach (User user in users)
             {
                 if (user.Handle.Identifier == handle.Identifier)
                 {
                     user.Mode = mode;
                     break;
                 }
             }
         }
         finally
         {
             locker.ReleaseWriterLock();
         }
     }
     catch { }
     return;
 }
Exemplo n.º 12
0
        public void SendIntroModeEvent(UserMode mode)
        {
            string label;

            switch (mode)
            {
            case UserMode.NormalMode:
                label = "Normal";
                break;

            case UserMode.NoUserMode:
                label = "NoUser";
                break;

            default:
                #if DEBUG
                throw new ArgumentException("Invalid value", "userMode");
                #else
                return;
                #endif
            }

            SendEvent("NoUser", "IntroRegister", label);
        }
Exemplo n.º 13
0
        public bool ChangeUser(UserMode user, string password)
        {
            if (user == UserMode.Manager && password == Param.ManagerPassword)
            {
                m_dicForm[btnMainCamera].Enabled             = true;
                m_dicForm[btnSideCamera].Enabled             = true;
                m_dicForm[RoundButton_Communication].Enabled = true;
                m_dicForm[btnSystemConfig].Enabled           = true;

                return(true);
            }

            if (user == UserMode.Operator && password == Param.OperatorPassword)
            {
                m_dicForm[btnMainCamera].Enabled             = false;
                m_dicForm[btnSideCamera].Enabled             = false;
                m_dicForm[RoundButton_Communication].Enabled = false;
                m_dicForm[btnSystemConfig].Enabled           = false;

                return(true);
            }

            return(false);
        }
Exemplo n.º 14
0
        public void OrchestrateMode(UserMode mode, string word)
        {
            var path = Path.Combine(Environment.CurrentDirectory, "SavedWords.txt");
            switch (mode)
            {
                case UserMode.RETRIEVE:
                    IWordService handler = _wordService;
                    handler.RetrieveAllWordsToConsole(path);
                    break;
                case UserMode.INSERT:
                    IValidator validator = _validator;
                    if (validator.IsValid(word))
                    {
                    IWordInverter inverter = _wordInverter;
                    word = inverter.GetInvertedWord(word);

                    IWordService writer = _wordService;
                    writer.AddWord(path, word);
                    }
                    break;
                default:
                    break;
            }
        }
Exemplo n.º 15
0
 protected string GetModeForAttribute()
 {
     return(UserMode.ToString().ToUpperInvariant());
 }
Exemplo n.º 16
0
 /// <summary>
 /// Dispose
 /// </summary>
 public void Dispose()
 {
     IsDisposed = true;
     userMode   = UserMode.Stopped;
 }
 private void NavigateToGame(string gameid, UserMode mode)
 {
     this.UriHelper.NavigateTo($"/MiniatureGolf/{gameid}/{(int)mode}");
 }
Exemplo n.º 18
0
 public void cancelTeleport()
 {
     userMode = UserMode.normal;
     teleportModeBehaviour.destroyMarker();
 }
Exemplo n.º 19
0
    public void cancelRotation()
    {
        rotationModeBehaviour.destroyGhost();

        userMode = UserMode.normal;
    }
Exemplo n.º 20
0
 public void cancelPlacingObject()
 {
     userMode = UserMode.inMenu;
     placementModeBehaviour.destroyGhost();
 }
Exemplo n.º 21
0
 /// <summary>
 /// Converts a UserMode into its RFC2812 character.
 /// </summary>
 /// <param name="mode">The mode enum.</param>
 /// <returns>The corresponding char.</returns>
 public static char UserModeToChar(UserMode mode)
 {
     return(Convert.ToChar((byte)mode, CultureInfo.InvariantCulture));
 }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            // validate parameters

            var appSettings = ConfigurationManager.AppSettings;

            ClientIdForUserAuthn = appSettings["ida:ClientId"];
            Tenant = appSettings["ida:Tenant"];

            if (!CheckConfiguration(args))
            {
                return;
            }

            HttpRequestMessage request = null;
            var authHelper             = new AuthenticationHelper(ClientIdForUserAuthn, Tenant);

            ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

            try
            {
                // Login as global admin of the Azure AD B2C tenant
                authHelper.LoginAsAdmin();

                // Graph client does not yet support trustFrameworkPolicy, so using HttpClient to make rest calls
                userMode = new UserMode(authHelper.TokenForUser);

                do
                {
                    //content is the the request body
                    string cont = string.Empty;
                    //last command is only meant to ensure that this is not the first time.
                    LastCommand = false;
                    //Get resource from console
                    resType = ProcessResourceInput();
                    //set resource for request to be constructed.
                    userMode.SetResouce(resType);
                    //Get Command from console
                    cmdType = ProcessCommandInput();
                    //initialize test request
                    testRequests = new TestRequests(userMode, resType, cmdType);
                    switch (cmdType)
                    {
                    case CommandType.LIST:

                        // List all polcies using "GET /trustFrameworkPolicies"
                        request = userMode.HttpGet();
                        ExecuteResponse(request);
                        break;

                    case CommandType.GET:
                        // Get a specific policy using "GET /trustFrameworkPolicies/{id}"
                        args = ProcessParametersInput();
                        testRequests.CheckAndGenerateTest(ref args[0], ref cont);

                        request = userMode.HttpGetID(args[0]);
                        ExecuteResponse(request);

                        break;

                    case CommandType.CREATE:
                        // Create a policy using "POST /trustFrameworkPolicies" with XML in the body
                        args = ProcessParametersInput();

                        if (!testRequests.CheckAndGenerateTest(ref args[0], ref cont))
                        {
                            cont    = System.IO.File.ReadAllText(args[0].Replace("\"", ""));
                            request = userMode.HttpPost(cont);
                            ExecuteResponse(request);
                        }


                        break;

                    case CommandType.UPDATE:
                        // Update using "PUT /trustFrameworkPolicies/{id}" with XML in the body
                        args = ProcessParametersInput();

                        if (!testRequests.CheckAndGenerateTest(ref args[0], ref cont))
                        {
                            cont = System.IO.File.ReadAllText(args[1].Replace("\"", ""));
                        }
                        request = userMode.HttpPutID(args[0], cont);
                        ExecuteResponse(request);
                        break;

                    case CommandType.DELETE:
                        // Delete using "DELETE /trustFrameworkPolicies/{id}"
                        args = ProcessParametersInput();

                        testRequests.CheckAndGenerateTest(ref args[0], ref cont);

                        request = userMode.HttpDeleteID(args[0]);
                        ExecuteResponse(request);
                        break;

                    case CommandType.BACKUPKEYSETS:
                    case CommandType.GETACTIVEKEY:
                        args = ProcessParametersInput();

                        request = userMode.HttpGetByCommandType(cmdType, args[0]);
                        ExecuteResponse(request);
                        break;

                    case CommandType.GENERATEKEY:
                    case CommandType.UPLOADCERTIFICATE:
                    case CommandType.UPLOADPKCS:
                    case CommandType.UPLOADSECRET:
                        args = ProcessParametersInput();


                        cont = args.Length == 1 ? string.Empty : args[1];
                        if (!testRequests.CheckAndGenerateTest(ref args[0], ref cont))
                        {
                            testRequests.GenerateKeySetID(ref args[0]);
                            cont = File.ReadAllText(args[1].Replace("\"", ""));
                        }
                        request = userMode.HttpPostByCommandType(cmdType, args[0], cont);
                        ExecuteResponse(request);
                        break;

                    case CommandType.EXIT:

                        CheckLastCommandAndExitApp();
                        break;
                    }
                } while (cmdType != CommandType.EXIT);
            }
            catch (Exception e)
            {
                Print(request);
                Console.WriteLine("\nError {0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : "");
            }
        }
Exemplo n.º 23
0
 public void OnUserModeRequest( UserMode[] modes )
 {
     Assertion.AssertEquals("OnUserModeRequest: size", 2, modes.Length );
     Assertion.AssertEquals("OnUserModeRequest: invisible", UserMode.Invisible, modes[0] );
     Assertion.AssertEquals("OnUserModeRequest: wallops", UserMode.Wallops, modes[1] );
     Console.WriteLine("OnUserModeRequest");
 }
Exemplo n.º 24
0
 public void OnUserModeChange( ModeAction action, UserMode mode )
 {
     Assertion.AssertEquals("OnUserModeChange: action", ModeAction.Add, action );
     Assertion.AssertEquals("OnUserModeChange: mode", UserMode.Wallops, mode );
     Console.WriteLine("OnUserModeChange");
 }
Exemplo n.º 25
0
 public XCommasApi(string apiKey, string secret, IHttpClientFactory httpClientFactory = null, UserMode userMode = UserMode.Real)
 {
     this.ApiKey             = apiKey;
     this.Secret             = secret;
     this._httpClientFactory = httpClientFactory;
     this.UserMode           = userMode;
 }
Exemplo n.º 26
0
 public void Mode(UserMode usermode, string nick, bool isAdd)
 {
     if(isAdd)
         Send("MODE " + nick + "+" + usermode.ToString());
     else
         Send("MODE " + nick + "-" + usermode.ToString());
 }
 // Start is called before the first frame update
 void Start()
 {
     _userMode = XRSocialSDK.myPlayer.userNickname == Constants.InterviewerId ? UserMode.Interviewer : UserMode.Interviewee;
     InitRoom();
 }
Exemplo n.º 28
0
 public void AddMenuItem(string title, InsertLocation location, UserMode mode, CustomMenuHandler handler)
 {
     AddMenuItem(UUID.Zero, title, location, mode, handler);
 }
Exemplo n.º 29
0
        public void AddMenuItem(UUID agentID, string title, InsertLocation location, UserMode mode, CustomMenuHandler handler)
        {
            if (!m_menuItems.ContainsKey(agentID))
                m_menuItems[agentID] = new List<MenuItemData>();

            m_menuItems[agentID].Add(new MenuItemData() { Title = title, AgentID = agentID, Location = location, Mode = mode, Handler = handler });
        }
Exemplo n.º 30
0
 /// <summary>
 /// Converts a UserMode into its RFC2812 character.
 /// </summary>
 /// <param name="mode">The mode enum.</param>
 /// <returns>The corresponding char.</returns>
 public static char UserModeToChar(UserMode mode)
 {
     return ((byte)mode).ToChar(CultureInfo.InvariantCulture);
 }
Exemplo n.º 31
0
 public void SetUserMode(HttpResponseBase response, UserMode userMode)
 {
     HttpCookie modeCookie = new HttpCookie("CurrentMode", userMode.ToString());
     response.SetCookie(modeCookie);
 }
Exemplo n.º 32
0
        // RPL_NAMREPLY
        private IrcEvent Parse353(string sender, string[] param, string text, string raw)
        {
            string chname = param[param.Length - 1]; // Channel is last part of param
            ChannelData ch = Entities.GetChannel(chname);
            string[] userinfo = text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string user in userinfo) {
                // Assuming NAMESX and UHNAMES are set, users are prefixed with modes and end with their host
                var m = NamesParseRegex.Match(user);
                UserData ud = Entities.GetUser(m.Groups["nick"].Value);
                Entities.Join(ch, ud);

                // TODO replace hardcoded symbols with data from PREFIX given in 005 (not all servers use qaohv)
                // however @ and + are universal
                if (m.Groups["prefix"].Success) { // User has modes
                    UserMode um = new UserMode();
                    foreach (char c in m.Groups["prefix"].Value) {
                        if (c == '~') um |= UserMode.Owner;
                        else if (c == '~') um |= UserMode.Owner;
                        else if (c == '&') um |= UserMode.Admin;
                        else if (c == '@') um |= UserMode.Op;
                        else if (c == '%') um |= UserMode.HalfOp;
                        else if (c == '+') um |= UserMode.Voice;
                    }
                    ud.channels[ch] = um;
                }

                if (m.Groups["host"].Success) { // User's hostname exists in reply
                    ud.host = m.Groups["host"].Value;
                }

                ud.incomplete = false;
            }
            return null;
        }
Exemplo n.º 33
0
    public void cancelMove()
    {
        movingModeBehaviour.destroyGhost();

        userMode = UserMode.normal;
    }
Exemplo n.º 34
0
 /// <summary>
 /// This user's mode has changed.
 /// </summary>
 /// <param name="action">Whether a mode was added or removed.</param>
 /// <param name="mode">The mode that was changed.</param>
 /// <seealso cref="Listener.OnUserModeChange"/>
 public UserModeChangeEventArgs(ModeAction action, UserMode mode)
 {
     Action = action;
     Mode = mode;
 }
Exemplo n.º 35
0
 public void validateTeleport()
 {
     userMode = UserMode.normal;
     teleportModeBehaviour.teleportPlayer();
     teleportModeBehaviour.destroyMarker();
 }
Exemplo n.º 36
0
 public void UnsetUserMode(ChannelData c, UserData u, UserMode um)
 {
     if (u.channels.ContainsKey(c)) {
         u.channels[c] &= ~um;
     }
 }
		/// <summary>
		/// Converts a UserMode into its RFC2812 character.
		/// </summary>
		/// <param name="mode">The mode enum.</param>
		/// <returns>The corresponding char.</returns>
		public static char UserModeToChar( UserMode mode ) 
		{
			return Convert.ToChar( (byte) mode, CultureInfo.InvariantCulture ) ;
		}
Exemplo n.º 38
0
        /// <summary>
        /// Установить режим работы
        /// </summary>
        /// <param name="mode">Требуемый режим работы</param>
        /// <param name="handle">Описатель пользователя для которого установливается режим работы</param>
        public void SetMode(Handle handle, UserMode mode)
        {
            try
            {
                locker.AcquireWriterLock(500);
                try
                {
                    foreach (User user in users)
                    {
                        if (user.Handle.Identifier == handle.Identifier)
                        {
                            user.Mode = mode;
                            break;
                        }
                    }
                }
                finally
                {
                    locker.ReleaseWriterLock();
                }

            }
            catch { }
            return;
        }
Exemplo n.º 39
0
        public void SendIntroModeEvent (UserMode mode)
        {
            string label;
            switch (mode) {
            case UserMode.NormalMode:
                label = "Normal";
                break;
            case UserMode.NoUserMode:
                label = "NoUser";
                break;
            default:
                #if DEBUG
                throw new ArgumentException ("Invalid value", "userMode");
                #else
                return;
                #endif
            }

            SendEvent ("NoUser", "IntroRegister", label);
        }
Exemplo n.º 40
0
 internal void OnUserMode(UserModeMessage message) => UserMode?.Invoke(message);
Exemplo n.º 41
0
 /// <summary>
 /// Creates a new user.
 /// </summary>
 /// <param name="name">Username</param>
 /// <param name="mode">Usermode (@, +, ...)</param>
 public User(string name, UserMode mode)
 {
     Name = name;
     Mode = mode;
 }
Exemplo n.º 42
0
 public void enterInMenu()
 {
     userMode = UserMode.inMenu;
     normalModeBehaviour.unhighlightTargetedObject();
 }
Exemplo n.º 43
0
 public XCommasResponse <bool> ChangeUserMode(UserMode userMode) => this.ChangeUserModeAsync(userMode).Result;
Exemplo n.º 44
0
 public void exitMenu()
 {
     userMode = UserMode.normal;
 }
Exemplo n.º 45
0
 public void AddMenuItem(string title, InsertLocation location, UserMode mode, CustomMenuHandler handler)
 {
     AddMenuItem(UUID.Zero, title, location, mode, handler);
 }
Exemplo n.º 46
0
 public void placeObject()
 {
     userMode = UserMode.placingObject;
     placementModeBehaviour.instanciateGhost();
 }
Exemplo n.º 47
0
        private IRCQEvent HandleNumeric(string sender, int numeric, string[] param, string text, string raw)
        {
            // param[0] appears to always be the current nick

            if (numeric == 001) { // Welcome message - all commands are recognized after this is received
                IrcAuthenticated = true;
                string msg = "Connected to server.";
                if (Entities.Self.nick != _settings.DefaultNick)
                    msg += " The requested nick specified in settings is currently in use. Client's nick is now "
                        + Entities.Self.nick + ".";
                return new ServerStatusEvent(ServerStatus.Connected, msg, null);
            } else if (numeric == 005) { // RPL_ISUPPORT
                // Enable UHNAMES and NAMESX if available.
                // NOTE: If these are not supported by the server, modes and nick host info will always be inaccurate
                // will need to find some way to make do without those later...
                if (param.Contains("NAMESX")) WriteOut("PROTOCTL NAMESX");
                if (param.Contains("UHNAMES")) WriteOut("PROTOCTL UHNAMES");
            } else if (numeric == 324) { // RPL_CHANNELMODEIS
                string fullmode = "";
                for (int i = 2; i < param.Length; i++) {
                    fullmode += " " + param[i];
                }
                if (fullmode.Length > 0) fullmode = fullmode.Substring(1);
                Entities.GetChannel(param[1]).ModeSet(fullmode);
            } else if (numeric == 331) { // RPL_NOTOPIC
                ChannelData chan = Entities.GetChannel(param[1]);
                chan.topic = String.Empty;
                chan.topic_setter = String.Empty;
                chan.topic_settime = null;
                chan.incomplete = false;
                // RPL_TOPICINFO is not sent
            } else if (numeric == 332) { // RPL_TOPIC
                ChannelData chan = Entities.GetChannel(param[1]);
                chan.topic = text;
                // This should be accompanied by RPL_TOPICINFO
            } else if (numeric == 333) { // RPL_TOPICINFO
                ChannelData chan = Entities.GetChannel(param[1]);
                chan.topic_setter = param[2];
                // Topic set time is given as a unix timestamp
                long settime = long.Parse(param[3]);
                chan.topic_settime =
                    new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(settime).ToLocalTime();
                chan.incomplete = false;
                // TODO consider sending topic despite it not being new
            } else if (numeric == 352) { // RPL_WHOREPLY
                // param: [1]channel [2]ident [3]host [4]server [5]nick [6]modes
                // param2: [0]hops [1]realname
                string[] param2 = text.Split(new char[] { ' ' }, 2);

                // Update user
                UserData user = Entities.GetUser(param[5]);
                user.host = param[2] + "@" + param[3];
                user.incomplete = false;

                // Update channel
                ChannelData chan = Entities.GetChannel(param[1]);
                Entities.Join(chan, user);

                // Parse modes and update
                Entities.UnsetUserMode(chan, user, UserMode.All);
                UserMode mode = UserMode.None;
                foreach (char m in param[6]) {
                    if (m == '~') mode |= UserMode.Owner;
                    else if (m == '&') mode |= UserMode.Admin;
                    else if (m == '@') mode |= UserMode.Op;
                    else if (m == '%') mode |= UserMode.HalfOp;
                    else if (m == '+') mode |= UserMode.Voice;
                }
                Entities.SetUserMode(chan, user, mode);
            } else if (numeric == 353) { // RPL_NAMREPLY
                string chname = param[param.Length - 1]; // Channel is last part of param
                ChannelData ch = Entities.GetChannel(chname);
                string[] userinfo = text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string user in userinfo) {
                    // Assuming NAMESX and UHNAMES are set, users are prefixed with modes and end with their host
                    var m = NamesParseRegex.Match(user);
                    UserData ud = Entities.GetUser(m.Groups["nick"].Value);
                    Entities.Join(ch, ud);

                    if (m.Groups["prefix"].Success) { // User has modes
                        UserMode um = new UserMode();
                        foreach (char c in m.Groups["prefix"].Value) {
                            if (c == '~') um |= UserMode.Owner;
                            else if (c == '~') um |= UserMode.Owner;
                            else if (c == '&') um |= UserMode.Admin;
                            else if (c == '@') um |= UserMode.Op;
                            else if (c == '%') um |= UserMode.HalfOp;
                            else if (c == '+') um |= UserMode.Voice;
                        }
                        ud.channels[ch] = um;
                    }

                    if (m.Groups["host"].Success) { // User's hostname exists in reply
                        ud.host = m.Groups["host"].Value;
                    }

                    ud.incomplete = false;
                }
            } else if (numeric == 433) { // ERR_NICKNAMEINUSE
                // Appending random number to requested nick
                string nick = _settings.DefaultNick + (new Random()).Next(100, 999);
                Entities.Self.nick = nick;
                WriteOut("NICK " + nick);
            }
            return null;
        }
Exemplo n.º 48
0
 public void validatePlacementObject()
 {
     userMode = UserMode.normal;
     placementModeBehaviour.instanciatePrefab();
     placementModeBehaviour.destroyGhost();
 }
Exemplo n.º 49
0
		/// <summary>Changes this client's mode. To change another nick's mode
		/// use <see cref="ChangeChannelMode"/>.</summary>
		/// <remarks>
		/// Away cannot be set here but should be set using <see cref="Sender.Away"/> 
		/// or removed using <see cref="Sender.UnAway"/>.
		/// </remarks>
		/// <param name="action">Add or remove a mode.</param>
		/// <param name="mode">The mode to be changed.</param>
		/// <example><code>
		/// //Turn off invisibility
		/// connection.Sender.ChangeUserMode( ModeAction.Remove, UserMode.Invisible );
		/// //Turn on wallops (and get a lot of IRC garbage)
		/// connection.Sender.ChangeUserMode( ModeAction.Add, UserMode.Wallops );
		/// </code></example>
		/// <exception cref="ArgumentException">If the UserMode parameter is Away.</exception> 
		/// <seealso cref="Listener.OnUserModeChange"/>
		public void ChangeUserMode( ModeAction action, UserMode mode ) 
		{
			lock( this ) 
			{
				if ( mode == UserMode.Away ) 
				{
					ClearBuffer();
					throw new ArgumentException("Away mode can only be changed with the Away and Unaway commands.");
				}
				Buffer.Append("MODE");
				Buffer.Append( SPACE );
				Buffer.Append( Connection.ConnectionData.Nick );
				Buffer.Append( SPACE );
				Buffer.Append( Rfc2812Util.ModeActionToChar( action ) );
				Buffer.Append( Rfc2812Util.UserModeToChar( mode ) );
				Connection.SendCommand( Buffer );
			}
		}
Exemplo n.º 50
0
 /// <summary>
 /// This user's mode has changed.
 /// </summary>
 /// <param name="action">Whether a mode was added or removed.</param>
 /// <param name="mode">The mode that was changed.</param>
 /// <seealso cref="Listener.OnUserModeChange"/>
 public UserModeChangeEventArgs(ModeAction action, UserMode mode)
 {
     Action = action;
     Mode   = mode;
 }