Exemplo n.º 1
0
        private string GetLogFile()
        {
            if (_ProtocolManager == null)
            {
                return(null);
            }

            var logPath  = Platform.LogPath;
            var protocol = _ProtocolManager.Protocol.ToLower();
            var network  = _ProtocolManager.NetworkID.ToLower();

            logPath = Path.Combine(logPath, protocol);
            if (network != protocol)
            {
                logPath = Path.Combine(logPath, network);
            }
            logPath = IOSecurity.GetFilteredPath(logPath);
            if (!Directory.Exists(logPath))
            {
                Directory.CreateDirectory(logPath);
            }

            var chatId = IOSecurity.GetFilteredFileName(ID.ToLower());

            logPath = Path.Combine(logPath, String.Format("{0}.log", chatId));
            return(logPath);
        }
Exemplo n.º 2
0
 public AddItemsViewModel()
 {
     _ioSecurity = new IOSecurity();
     _serviceLifetimeController = new LifetimeController();
     BrowseCommand     = new RelayCommand(OnBrowse);
     AddCommand        = new RelayCommand(OnAdd, CanAdd);
     BackToMenuCommand = new RelayCommand(OnBackToMenu);
     RemoveCommand     = new RelayCommand(OnRemove, CanRemove);
     ItemsToAdd        = new ObservableCollection <string>();
 }
Exemplo n.º 3
0
 public Mgr21CoreService()
 {
     InitializeComponent();
     _log = new EventLog();
     if (!EventLog.SourceExists("Prockillersrc"))
     {
         EventLog.CreateEventSource("Prockillersrc", "Mgr21log");
     }
     _log.Source     = "Prockillersrc";
     _log.Log        = "Mgr21log";
     _timer          = new Timer();
     _timer.Elapsed += OnTimerElapsed;
     _ioSecurity     = new IOSecurity();
     _processList    = new List <ProcessModel>();
 }
Exemplo n.º 4
0
        protected string GetBufferPath()
        {
            var path     = Platform.GetBuffersPath(SessionUsername);
            var protocol = Protocol.ToLower();
            var network  = NetworkID.ToLower();

            path = Path.Combine(path, protocol);
            if (network != protocol)
            {
                path = Path.Combine(path, network);
            }
            path = IOSecurity.GetFilteredPath(path);
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            var chatId = IOSecurity.GetFilteredFileName(ChatID.ToLower());

            return(Path.Combine(path, chatId));
        }
Exemplo n.º 5
0
        private async void UpdatePassword()
        {
            IOSecurity iOSecurity = new IOSecurity();
            //because we use non-UI thread to update password,
            //we must copy both passwords in variables.
            string oldPwd  = passwordBoxCurrentPassword.Password;
            string newPwd  = passwordBoxNewPassword.Password;
            string message = "";
            string title   = "";

            progressBarLoading.IsIndeterminate = true;
            await Task.Run(() =>
            {
                MainResult loginResult = iOSecurity.Login(oldPwd);
                if (loginResult.Success)
                {
                    MainResult changePasswordResult = iOSecurity.ChangeMasterKey(newPwd);
                    if (changePasswordResult.Success)
                    {
                        title   = LanguageChanger.Instance["SettingsView_CodeBehind_Success"];
                        message = LanguageChanger.Instance["SettingsView_CodeBehind_Code7"];
                    }
                    else
                    {
                        title   = LanguageChanger.Instance["SettingsView_CodeBehind_Error"];
                        message = changePasswordResult.ErrorMessage;
                    }
                }
                else
                {
                    title   = LanguageChanger.Instance["SettingsView_CodeBehind_Error"];
                    message = LanguageChanger.Instance["SettingsView_CodeBehind_Code8"];
                }
            });

            progressBarLoading.IsIndeterminate = false;
            await this.ShowMessageAsync(title, message);

            passwordBoxCurrentPassword.Password = passwordBoxNewPassword.Password = string.Empty;
        }
Exemplo n.º 6
0
        string GetDatabaseFile()
        {
            var dbPath   = Platform.GetBuffersPath(SessionUsername);
            var protocol = Protocol.ToLower();
            var network  = NetworkID.ToLower();

            dbPath = Path.Combine(dbPath, protocol);
            if (network != protocol)
            {
                dbPath = Path.Combine(dbPath, network);
            }
            dbPath = IOSecurity.GetFilteredPath(dbPath);
            if (!Directory.Exists(dbPath))
            {
                Directory.CreateDirectory(dbPath);
            }

            var chatId = IOSecurity.GetFilteredFileName(ChatID.ToLower());

            dbPath = Path.Combine(dbPath, String.Format("{0}.db4o", chatId));
            return(dbPath);
        }
Exemplo n.º 7
0
        private void DoExecute(CommandModel cmd)
        {
            Trace.Call(cmd);

            var handled = false;

            if (cmd.IsCommand)
            {
                switch (cmd.Command)
                {
                case "exec":
                    CommandExec(cmd);
                    handled = true;
                    break;

                case "echo":
                    CommandEcho(cmd);
                    handled = true;
                    break;

                case "benchmark_message_builder":
                    CommandBenchmarkMessageBuilder(cmd);
                    handled = true;
                    break;

                case "exception":
                    throw new Exception("You asked for it.");
                }
            }
            if (handled)
            {
                // no need to send the command to the engine
                return;
            }

            DateTime start, stop;

            start = DateTime.UtcNow;

            handled = f_Session.Command(cmd);
            IProtocolManager pm = null;

            if (!handled)
            {
                if (cmd.Chat is SessionChatModel && cmd.FrontendManager != null)
                {
                    pm = cmd.FrontendManager.CurrentProtocolManager;
                }
                else
                {
                    pm = cmd.Chat.ProtocolManager;
                }

                // we maybe have no network manager yet
                if (pm != null)
                {
                    handled = pm.Command(cmd);
                }
                else
                {
                    handled = false;
                }
            }
            if (!handled)
            {
                var filteredCmd = IOSecurity.GetFilteredPath(cmd.Command);
                var hooks       = new HookRunner("frontend", "command-manager",
                                                 "command-" + filteredCmd);
                hooks.EnvironmentVariables.Add("FRONTEND_VERSION", FrontendVersion);
                hooks.Environments.Add(new CommandHookEnvironment(cmd));
                hooks.Environments.Add(new ChatHookEnvironment(cmd.Chat));
                if (pm != null)
                {
                    hooks.Environments.Add(new ProtocolManagerHookEnvironment(pm));
                }

                var cmdChar = (string)f_Session.UserConfig["Interface/Entry/CommandCharacter"];
                hooks.Commands.Add(new SessionHookCommand(f_Session, cmd.Chat, cmdChar));
                if (pm != null)
                {
                    hooks.Commands.Add(new ProtocolManagerHookCommand(pm, cmd.Chat, cmdChar));
                }

                // show time
                hooks.Init();
                if (hooks.HasHooks)
                {
                    hooks.Run();
                    handled = true;
                }
            }
            if (!handled)
            {
                Unknown(cmd);
            }

            stop = DateTime.UtcNow;
            f_LastCommandTimeSpan = (stop - start);
        }