示例#1
0
        public void Initialize()
        {
            logger.Info("Starting initialization...");

            var cefSettings = InitializeCefSettings();

            cefSettings.CefCommandLineArgs.Add("enable-media-stream", "1");
            var success = Cef.Initialize(cefSettings, true, default(IApp));

            InitializeApplicationInfo();

            if (success)
            {
                if (settings.DeleteCookiesOnStartup)
                {
                    DeleteCookies();
                }

                logger.Info("Initialized browser.");
            }
            else
            {
                throw new Exception("Failed to initialize browser!");
            }
        }
示例#2
0
        private void Server_ProctoringInstructionReceived(string roomName, string serverUrl, string token)
        {
            logger.Info("Proctoring instruction received.");

            settings.JitsiMeet.RoomName  = roomName;
            settings.JitsiMeet.ServerUrl = serverUrl.Replace($"{Uri.UriSchemeHttp}{Uri.SchemeDelimiter}", "").Replace($"{Uri.UriSchemeHttps}{Uri.SchemeDelimiter}", "");
            settings.JitsiMeet.Token     = token;

            StopProctoring();
            StartProctoring();
        }
 public void Start()
 {
     try
     {
         logger.Info("Starting application...");
         InitializeInstance(processFactory.StartNew(executablePath, BuildArguments()));
         logger.Info("Successfully started application.");
     }
     catch (Exception e)
     {
         logger.Error("Failed to start application!", e);
     }
 }
        private void DialogHandler_DialogRequested(DialogRequestedEventArgs args)
        {
            var isDownload = args.Operation == FileSystemOperation.Save;
            var isUpload   = args.Operation == FileSystemOperation.Open;
            var isAllowed  = (isDownload && settings.AllowDownloads) || (isUpload && settings.AllowUploads);

            if (isAllowed)
            {
                var result = fileSystemDialog.Show(args.Element, args.Operation, args.InitialPath, title: args.Title, parent: window);

                if (result.Success)
                {
                    args.FullPath = result.FullPath;
                    args.Success  = result.Success;
                    logger.Debug($"User selected path '{result.FullPath}' when asked to {args.Operation}->{args.Element}.");
                }
                else
                {
                    logger.Debug($"User aborted file system dialog to {args.Operation}->{args.Element}.");
                }
            }
            else
            {
                logger.Info($"Blocked file system dialog to {args.Operation}->{args.Element}, as {(isDownload ? "downloading" : "uploading")} is not allowed.");
            }
        }
示例#5
0
        private void DownloadHandler_ConfigurationDownloadRequested(string fileName, DownloadEventArgs args)
        {
            if (settings.AllowConfigurationDownloads)
            {
                logger.Debug($"Forwarding download request for configuration file '{fileName}'.");
                ConfigurationDownloadRequested?.Invoke(fileName, args);

                if (args.AllowDownload)
                {
                    logger.Debug($"Download request for configuration file '{fileName}' was granted. Asking user to confirm the reconfiguration...");

                    var message = TextKey.MessageBox_ReconfigurationQuestion;
                    var title   = TextKey.MessageBox_ReconfigurationQuestionTitle;
                    var result  = messageBox.Show(message, title, MessageBoxAction.YesNo, MessageBoxIcon.Question, window);

                    args.AllowDownload = result == MessageBoxResult.Yes;
                    logger.Info($"The user chose to {(args.AllowDownload ? "start" : "abort")} the reconfiguration.");
                }
                else
                {
                    logger.Debug($"Download request for configuration file '{fileName}' was denied.");
                    messageBox.Show(TextKey.MessageBox_ReconfigurationDenied, TextKey.MessageBox_ReconfigurationDeniedTitle, parent: window);
                }
            }
            else
            {
                logger.Debug($"Discarded download request for configuration file '{fileName}'.");
            }
        }
        public void Delete(IFeatureConfiguration configuration)
        {
            lock (@lock)
            {
                var configurations = LoadFromFile();
                var obsolete       = configurations.Find(c => c.Id == configuration.Id);

                if (obsolete != default(IFeatureConfiguration))
                {
                    configurations.Remove(obsolete);
                    SaveToFile(configurations);
                    logger.Info($"Successfully removed {configuration} from backup.");
                }
                else
                {
                    logger.Warn($"Could not delete {configuration} as it does not exist in backup!");
                }
            }
        }
示例#7
0
        /// <summary>
        /// TODO: LoadError.html is not used, as navigating back from it doesn't work! Remove page if no better solution can be found.
        /// </summary>
        private void Control_LoadFailed(int errorCode, string errorText, string url)
        {
            if (errorCode == (int)CefErrorCode.None)
            {
                logger.Info($"Request for '{url}' was successful.");
            }
            else if (errorCode == (int)CefErrorCode.Aborted)
            {
                logger.Info($"Request for '{url}' was aborted.");
            }
            else
            {
                var title   = text.Get(TextKey.Browser_LoadErrorPageTitle);
                var message = text.Get(TextKey.Browser_LoadErrorPageMessage).Replace("%%URL%%", url) + $" {errorText} ({errorCode})";

                logger.Warn($"Request for '{url}' failed: {errorText} ({errorCode}).");

                Task.Run(() => messageBox.Show(message, title, icon: MessageBoxIcon.Error, parent: window)).ContinueWith(_ => control.NavigateBackwards());
            }
        }
示例#8
0
        private void LifeSpanHandler_PopupRequested(PopupRequestedEventArgs args)
        {
            var validCurrentUri = Uri.TryCreate(browser.Address, UriKind.Absolute, out var currentUri);
            var validNewUri     = Uri.TryCreate(args.Url, UriKind.Absolute, out var newUri);
            var sameHost        = validCurrentUri && validNewUri && string.Equals(currentUri.Host, newUri.Host, StringComparison.OrdinalIgnoreCase);

            switch (settings.PopupPolicy)
            {
            case PopupPolicy.Allow:
            case PopupPolicy.AllowSameHost when sameHost:
                logger.Debug($"Forwarding request to open new window for '{args.Url}'...");
                PopupRequested?.Invoke(args);
                break;

            case PopupPolicy.AllowSameWindow:
            case PopupPolicy.AllowSameHostAndWindow when sameHost:
                logger.Info($"Discarding request to open new window and loading '{args.Url}' directly...");
                browser.Load(args.Url);
                break;

            case PopupPolicy.AllowSameHost when !sameHost:
            case PopupPolicy.AllowSameHostAndWindow when !sameHost:
                logger.Info($"Blocked request to open new window for '{args.Url}' as it targets a different host.");
                break;

            default:
                logger.Info($"Blocked request to open new window for '{args.Url}'.");
                break;
            }
        }
示例#9
0
        public IProcess StartNew(string path, params string[] args)
        {
            var raw = default(System.Diagnostics.Process);

            logger.Info($"Attempting to start process '{path}'...");

            if (StartupDesktop != default(IDesktop))
            {
                raw = StartOnDesktop(path, args);
            }
            else
            {
                raw = StartNormal(path, args);
            }

            var(name, originalName) = LoadProcessNamesFor(raw);
            var process = new Process(raw, name, originalName, LoggerFor(raw, name));

            logger.Info($"Successfully started process '{path}' with ID = {process.Id}.");

            return(process);
        }
示例#10
0
        internal void CreateNewInstanceInvoke(string startUrl = null)
        {
            var id             = ++instanceIdCounter;
            var isMainInstance = instances.Count == 0;
            var numWindows     = instances.Count;
            var instanceLogger = new ModuleLogger(logger, nameof(MainWindow));
            var instance       = new BrowserApplicationInstance(appSettings, messageBox, id, isMainInstance, numWindows, startUrl, instanceLogger, text);

            instance.PopupRequested       += Instance_PopupRequested;
            instance.TerminationRequested += Instance_TerminationRequested;
            instance.Terminated           += Instance_Terminated;

            instance.Activate();
            instances.Add(instance);
            logger.Info($"Created browser instance {instance.Id}.");
            WindowsChanged?.Invoke();
        }
        public void Initialize()
        {
            var cefSettings = InitializeCefSettings();
            var success     = Cef.Initialize(cefSettings, true, default(IApp));

            logger.Info("Initialized browser.");

            if (!success)
            {
                throw new Exception("Failed to initialize browser!");
            }
        }
示例#12
0
 internal void Terminate()
 {
     logger.Info($"Instance has terminated.");
     window.Close();
     Terminated?.Invoke(Id);
 }
        private void Control_LoadFailed(int errorCode, string errorText, string url)
        {
            if (errorCode == (int)CefErrorCode.None)
            {
                logger.Info($"Request{(WindowSettings.UrlPolicy.CanLog() ? $" for '{url}'" : "")} was successful.");
            }
            else if (errorCode == (int)CefErrorCode.Aborted)
            {
                logger.Info($"Request{(WindowSettings.UrlPolicy.CanLog() ? $" for '{url}'" : "")} was aborted.");
            }
            else if (errorCode == (int)CefErrorCode.UnknownUrlScheme)
            {
                logger.Info($"Request{(WindowSettings.UrlPolicy.CanLog() ? $" for '{url}'" : "")} contains unknown URL scheme and will be handled by the OS.");
            }
            else
            {
                var title   = text.Get(TextKey.Browser_LoadErrorTitle);
                var message = text.Get(TextKey.Browser_LoadErrorMessage).Replace("%%URL%%", WindowSettings.UrlPolicy.CanLogError() ? url : "") + $" {errorText} ({errorCode})";

                logger.Warn($"Request{(WindowSettings.UrlPolicy.CanLogError() ? $" for '{url}'" : "")} failed: {errorText} ({errorCode}).");

                Task.Run(() => messageBox.Show(message, title, icon: MessageBoxIcon.Error, parent: window)).ContinueWith(_ => control.NavigateBackwards());
            }
        }