Ejemplo n.º 1
0
        public void HomePage(IDictionary <string, string> queryParameters)
        {
            if (queryParameters == null || !queryParameters.Any())
            {
                return;
            }

            var movieId = string.Empty;

            if (queryParameters.ContainsKey("movieid"))
            {
                movieId = queryParameters["movieid"] ?? string.Empty;
            }

            if (string.IsNullOrWhiteSpace(movieId))
            {
                return;
            }


            var tmdbMovieTask = Task.Run(() =>
            {
                return(GetTmdbMovieAsync(movieId));
            });

            tmdbMovieTask.Wait();

            var movie = tmdbMovieTask.Result;

            if (movie != null && !string.IsNullOrWhiteSpace(movie.homepage))
            {
                BrowserLauncher.Open(_config.Platform, movie.homepage);
            }
        }
Ejemplo n.º 2
0
 static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
 {
     if (e.Reason == SessionSwitchReason.SessionLogon)
     {
         BrowserLauncher.OpenDashboard(_appHost);
     }
 }
 public void ShowDevTools(IDictionary <string, string> queryParameters)
 {
     if (_config != null && !string.IsNullOrWhiteSpace(_config.DevToolsUrl))
     {
         BrowserLauncher.Open(_config.Platform, _config.DevToolsUrl);
     }
 }
Ejemplo n.º 4
0
 static void SystemEvents_SessionSwitch(object sender, SessionSwitchEventArgs e)
 {
     if (e.Reason == SessionSwitchReason.SessionLogon)
     {
         BrowserLauncher.OpenDashboard(_appHost.UserManager, _appHost.ServerConfigurationManager, _appHost, _logger);
     }
 }
Ejemplo n.º 5
0
        private void Run()
        {
            if (!_appHost.CanLaunchWebBrowser)
            {
                return;
            }

            // Always launch the startup wizard if possible when it has not been completed
            if (!_config.Configuration.IsStartupWizardCompleted && _appConfig.HostWebClient())
            {
                BrowserLauncher.OpenWebApp(_appHost);
                return;
            }

            // Do nothing if the web app is configured to not run automatically
            if (!_config.Configuration.AutoRunWebApp || _startupOptions.NoAutoRunWebApp)
            {
                return;
            }

            // Launch the swagger page if the web client is not hosted, otherwise open the web client
            if (_appConfig.HostWebClient())
            {
                BrowserLauncher.OpenWebApp(_appHost);
            }
            else
            {
                BrowserLauncher.OpenSwaggerPage(_appHost);
            }
        }
Ejemplo n.º 6
0
 public void ShowDevTools()
 {
     if (_config != null && !string.IsNullOrWhiteSpace(_config.DevToolsUrl))
     {
         BrowserLauncher.Open(_config.Platform, _config.DevToolsUrl);
     }
 }
Ejemplo n.º 7
0
        protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector config)
        {
            //check XSP is available

            var configuration = (AspNetAppProjectConfiguration)GetConfiguration(config);
            var cmd           = CreateExecutionCommand(config, configuration);

            IConsole console          = null;
            var      operationMonitor = new AggregatedOperationMonitor(monitor);

            try {
                if (configuration.ExternalConsole)
                {
                    console = context.ExternalConsoleFactory.CreateConsole(!configuration.PauseConsoleOutput);
                }
                else
                {
                    console = context.ConsoleFactory.CreateConsole(!configuration.PauseConsoleOutput);
                }

                string url = String.Format("http://{0}:{1}", this.XspParameters.Address, this.XspParameters.Port);

                bool isXsp = true;                 //FIXME: fix this when it might not be true

                if (isXsp)
                {
                    console = new XspBrowserLauncherConsole(console, delegate {
                        BrowserLauncher.LaunchDefaultBrowser(url);
                    });
                }

                monitor.Log.WriteLine("Running web server...");

                var op = context.ExecutionHandler.Execute(cmd, console);
                operationMonitor.AddOperation(op);                  //handles cancellation

                if (!isXsp)
                {
                    BrowserLauncher.LaunchDefaultBrowser(url);
                }

                op.WaitForCompleted();

                monitor.Log.WriteLine("The web server exited with code: {0}", op.ExitCode);
            } catch (Exception ex) {
                monitor.ReportError("Could not launch web server.", ex);
            } finally {
                operationMonitor.Dispose();
                if (console != null)
                {
                    console.Dispose();
                }
            }
        }
Ejemplo n.º 8
0
        public TvShowsViewModel()
        {
            launcher = new BrowserLauncher(ConfigurationData.LinksFilepath);
            OnDisplayTvShowDetailsCommand = new RelayCommand <TvShow>(OnDisplayTvShowDetails);

            OnHyperLink1NavigateCommand     = new RelayCommand <TvShow>(OnHyperLink1Navigate);
            OnHyperLink2NavigateCommand     = new RelayCommand <TvShow>(OnHyperLink2Navigate);
            OnHyperLink3NavigateCommand     = new RelayCommand <TvShow>(OnHyperLink3Navigate);
            OnHyperLink4NavigateCommand     = new RelayCommand <TvShow>(OnHyperLink4Navigate);
            OnHyperLink5NavigateCommand     = new RelayCommand <TvShow>(OnHyperLink5Navigate);
            OnHyperLinkMultiNavigateCommand = new RelayCommand <Websites>(OnHyperLinkMultiNavigate);
        }
Ejemplo n.º 9
0
        public TvShowsViewModel()
        {
            launcher = new BrowserLauncher(ConfigurationData.LinksFilepath);
            OnDisplayTvShowDetailsCommand = new RelayCommand<TvShow>(OnDisplayTvShowDetails);

            OnHyperLink1NavigateCommand = new RelayCommand<TvShow>(OnHyperLink1Navigate);
            OnHyperLink2NavigateCommand = new RelayCommand<TvShow>(OnHyperLink2Navigate);
            OnHyperLink3NavigateCommand = new RelayCommand<TvShow>(OnHyperLink3Navigate);
            OnHyperLink4NavigateCommand = new RelayCommand<TvShow>(OnHyperLink4Navigate);
            OnHyperLink5NavigateCommand = new RelayCommand<TvShow>(OnHyperLink5Navigate);
            OnHyperLinkMultiNavigateCommand = new RelayCommand<Websites>(OnHyperLinkMultiNavigate);
        }
Ejemplo n.º 10
0
        // Create the popup menu, on right click.
        static void OnTrayIconPopup(object o, EventArgs args)
        {
            Menu popupMenu = new Menu();

            var menuItemBrowse = new ImageMenuItem("Browse Library");

            menuItemBrowse.Image = new Gtk.Image(Stock.MediaPlay, IconSize.Menu);
            popupMenu.Add(menuItemBrowse);
            menuItemBrowse.Activated += delegate {
                BrowserLauncher.OpenWebClient(_appHost.UserManager, _appHost.ServerConfigurationManager, _appHost, _logger);
            };

            var menuItemConfigure = new ImageMenuItem("Configure Media Browser");

            menuItemConfigure.Image = new Gtk.Image(Stock.Edit, IconSize.Menu);
            popupMenu.Add(menuItemConfigure);
            menuItemConfigure.Activated += delegate {
                BrowserLauncher.OpenDashboard(_appHost.UserManager, _appHost.ServerConfigurationManager, _appHost, _logger);
            };

            var menuItemApi = new ImageMenuItem("View Api Docs");

            menuItemApi.Image = new Gtk.Image(Stock.Network, IconSize.Menu);
            popupMenu.Add(menuItemApi);
            menuItemApi.Activated += delegate {
                BrowserLauncher.OpenSwagger(_appHost.ServerConfigurationManager, _appHost, _logger);
            };

            var menuItemCommunity = new ImageMenuItem("Visit Community");

            menuItemCommunity.Image = new Gtk.Image(Stock.Help, IconSize.Menu);
            popupMenu.Add(menuItemCommunity);
            menuItemCommunity.Activated += delegate { BrowserLauncher.OpenCommunity(_logger); };

            var menuItemGithub = new ImageMenuItem("Visit Github");

            menuItemGithub.Image = new Gtk.Image(Stock.Network, IconSize.Menu);
            popupMenu.Add(menuItemGithub);
            menuItemGithub.Activated += delegate { BrowserLauncher.OpenGithub(_logger); };

            var menuItemQuit = new ImageMenuItem("Exit");

            menuItemQuit.Image = new Gtk.Image(Stock.Quit, IconSize.Menu);
            popupMenu.Add(menuItemQuit);
            menuItemQuit.Activated += delegate { Shutdown(); };

            popupMenu.ShowAll();
            popupMenu.Popup();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Launches the startup wizard.
        /// </summary>
        private void LaunchStartupWizard()
        {
            var user = _userManager.Users.FirstOrDefault(u => u.Configuration.IsAdministrator);

            try
            {
                BrowserLauncher.OpenDashboardPage("wizardstart.html", user, _configurationManager, _appHost, _logger);
            }
            catch (Exception ex)
            {
                _logger.ErrorException("Error launching startup wizard", ex);

                MessageBox.Show("There was an error launching the Media Browser startup wizard. Please ensure a web browser is installed on the machine and is configured as the default browser.", "Media Browser");
            }
        }
Ejemplo n.º 12
0
 static void ReadKeysUntilAbort(string url)
 {
     System.Console.TreatControlCAsInput = true;
     Console.WriteLine("Press enter to launch a browser or ctrl-c to shutdown.");
     do
     {
         ConsoleKeyInfo key = Console.ReadKey(/*intercept*/ true);
         if (key.Key == ConsoleKey.Enter)
         {
             BrowserLauncher.Launch(url);
         }
         else if ((key.Modifiers & ConsoleModifiers.Control) == ConsoleModifiers.Control && key.Key == ConsoleKey.C)
         {
             return;
         }
         // Otherwise keep going.
     } while (true);
 }
        protected override bool OnBeforeBrowse(IWebBrowser ChromiumBrowser, IBrowser browser, IFrame frame, IRequest request, bool userGesture, bool isRedirect)
        {
            var isUrlExternal = _config?.UrlSchemes?.IsUrlRegisteredExternalBrowserScheme(request.Url);

            if (isUrlExternal.HasValue && isUrlExternal.Value)
            {
                BrowserLauncher.Open(request.Url);
                return(true);
            }

            var isUrlCommand = _config?.UrlSchemes?.IsUrlRegisteredCommandScheme(request.Url);

            if (isUrlCommand.HasValue && isUrlCommand.Value)
            {
                _commandTaskRunner.RunAsync(request.Url);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 14
0
        public void HomePage(string movieId)
        {
            if (string.IsNullOrWhiteSpace(movieId))
            {
                return;
            }

            var tmdbMovieTask = Task.Run(() =>
            {
                return(GetTmdbMovieAsync(movieId));
            });

            tmdbMovieTask.Wait();

            var movie = tmdbMovieTask.Result;

            if (movie != null && !string.IsNullOrWhiteSpace(movie.homepage))
            {
                BrowserLauncher.Open(_config.Platform, movie.homepage);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Runs this instance.
        /// </summary>
        public void Run()
        {
            if (!_appHost.CanLaunchWebBrowser)
            {
                return;
            }

            if (!_config.Configuration.IsStartupWizardCompleted)
            {
                BrowserLauncher.OpenWebApp(_appHost);
            }
            else if (_config.Configuration.AutoRunWebApp)
            {
                var options = ((ApplicationHost)_appHost).StartupOptions;

                if (!options.NoAutoRunWebApp)
                {
                    BrowserLauncher.OpenWebApp(_appHost);
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Runs this instance.
        /// </summary>
        public void Run()
        {
            if (!_appHost.CanLaunchWebBrowser)
            {
                return;
            }

            if (_appHost.IsFirstRun)
            {
                BrowserLauncher.OpenWizard(_appHost);
            }
            else if (_config.Configuration.IsStartupWizardCompleted && _config.Configuration.AutoRunWebApp)
            {
                var options = ((ApplicationHost)_appHost).StartupOptions;

                if (!options.ContainsOption("-noautorunwebapp"))
                {
                    BrowserLauncher.OpenWebApp(_appHost);
                }
            }
        }
        protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref CefDictionaryValue extraInfo, ref bool noJavascriptAccess)
        {
            _browser.InvokeAsyncIfPossible(() => _browser.OnBeforePopup(new BeforePopupEventArgs(frame, targetUrl, targetFrameName)));

            var isUrlExternal = _config?.UrlSchemes?.IsUrlRegisteredExternalBrowserScheme(targetUrl);

            if (isUrlExternal.HasValue && isUrlExternal.Value)
            {
                BrowserLauncher.Open(_config.Platform, targetUrl);
                return(true);
            }

            var isUrlCommand = _config?.UrlSchemes?.IsUrlRegisteredCommandScheme(targetUrl);

            if (isUrlCommand.HasValue && isUrlCommand.Value)
            {
                _commandTaskRunner.RunAsync(targetUrl);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 18
0
        private void BtnChrome_Clicked(object?sender, EventArgs e)
        {
            try
            {
                NativeMessagingConfigurer.InstallNativeMessagingHost(Browser.Chrome);
            }
            catch (Exception ex)
            {
                Log.Debug(ex, "Error installing native host");
                GtkHelper.ShowMessageBox(this, TextResource.GetText("MSG_NATIVE_HOST_FAILED"));
                return;
            }

            try
            {
                BrowserLauncher.LaunchGoogleChrome(Links.ChromeExtensionUrl);
            }
            catch (Exception ex)
            {
                Log.Debug(ex, "Error launching Google Chrome");
                GtkHelper.ShowMessageBox(this, $"{TextResource.GetText("MSG_BROWSER_LAUNCH_FAILED")} Google Chrome");
            }
        }
Ejemplo n.º 19
0
        private void BtnFirefox_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                NativeMessagingConfigurer.InstallNativeMessagingHost(Browser.Firefox);
            }
            catch (Exception ex)
            {
                Log.Debug(ex, "Error installing native host");
                MessageBox.Show(TextResource.GetText("MSG_NATIVE_HOST_FAILED"));
                return;
            }

            try
            {
                BrowserLauncher.LaunchFirefox(Links.FirefoxExtensionUrl);
            }
            catch (Exception ex)
            {
                Log.Debug(ex, "Error launching Firefox");
                MessageBox.Show($"{TextResource.GetText("MSG_BROWSER_LAUNCH_FAILED")} Firefox");
            }
        }
Ejemplo n.º 20
0
    /// <inheritdoc/>
    protected override bool OnBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, bool userGesture, bool isRedirect)
    {
        if (_config is not null)
        {
            var isUrlExternal = _config.UrlSchemes?.IsUrlRegisteredExternalBrowserScheme(request.Url);
            if (isUrlExternal.HasValue && isUrlExternal.Value)
            {
                BrowserLauncher.Open(_config.Platform, request.Url);
                return(true);
            }
        }

        // Sample: http://chromely.com/democontroller/showdevtools
        // Expected to execute controller route action without return value
        var route = _routeProvider.GetRoute(request.Url);

        if (route is not null && !route.HasReturnValue)
        {
            _requestHandler.Execute(request.Url);
            return(true);
        }

        return(false);
    }
 void cmdSwagger_Click(object sender, EventArgs e)
 {
     BrowserLauncher.OpenSwagger(_configurationManager, _appHost, _logger);
 }
 void cmdGtihub_Click(object sender, EventArgs e)
 {
     BrowserLauncher.OpenGithub(_logger);
 }
 void cmdConfigure_Click(object sender, EventArgs e)
 {
     BrowserLauncher.OpenDashboard(_userManager, _configurationManager, _appHost, _logger);
 }
 void cmdCommunity_Click(object sender, EventArgs e)
 {
     BrowserLauncher.OpenCommunity(_logger);
 }
 void cmdBrowse_Click(object sender, EventArgs e)
 {
     BrowserLauncher.OpenWebClient(_userManager, _configurationManager, _appHost, _logger);
 }
Ejemplo n.º 26
0
        static void Main(string[] args)
        {
            var arguments = new Arguments
            {
                ApplicationPath = ConfigurationManager.AppSettings["GitPriseWebPath"]
            };

            var showHelp = false;

            var p = new OptionSet() {
                { "a|app|applicationPath:", "path to GitPrise web application", v => arguments.ApplicationPath = v },
               	            { "rn|repositoryName:", "repository name in local browsing mode", v => arguments.RepositoryName = v },
                { "rp|repositoryPath:", "repository path in local browsing mode", v => arguments.RepositoryPath = v },
                { "p|port:", "server port", (int v) => arguments.Port = v },
                { "nb|noBrowser", "doesn't auto start the browser", v => arguments.StartBrowser = (v == null) },
               	            { "h|?|help", "shows help", v => showHelp = (v != null) },
            };

            try
            {
                p.Parse(args);
            }
            catch (Exception ex)
            {
                Console.WriteLine(string.Format(
                    "Error parsing command line arguments:{0}{1}",
                    Environment.NewLine,
                    ex));
                return;
            }

            if (showHelp || ArgumentsAreInvalid(arguments))
            {
                ShowHelp(p);
                return;
            }
            var launcher = new BrowserLauncher(arguments.Port, arguments.RepositoryName, arguments.RepositoryPath);

            var result = GitPriseWebServer.CheckPortAvailability(arguments.Port);
            if (result == AvailabilityResult.InUseByGitPrise)
            {
                launcher.Launch();
                return;
            }

            if (result == AvailabilityResult.Unknown)
            {
                Console.WriteLine("Port is in use by an unknown application - please use a different port or shutdown the application that's using the port.");
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm(arguments, launcher));
        }
Ejemplo n.º 27
0
 void cmdStandardDocs_Click(object sender, EventArgs e)
 {
     BrowserLauncher.OpenStandardApiDocumentation(_configurationManager, _appHost, _logger);
 }
Ejemplo n.º 28
0
        protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector config)
        {
            //check XSP is available

            var configuration = (AspNetAppProjectConfiguration)GetConfiguration(config);
            var cmd           = CreateExecutionCommand(config, configuration);

            IConsole console          = null;
            var      operationMonitor = new AggregatedOperationMonitor(monitor);

            bool isXsp = true;             //FIXME: fix this when it might not be true - should delegate to the ExecutionHandler

            try {
                //HACK: check XSP exists first, because error UX is cleaner w/o displaying a blank console pad.
                if (isXsp)
                {
                    try {
                        AspNetExecutionHandler.GetXspPath((AspNetExecutionCommand)cmd);
                    } catch (UserException ex) {
                        MessageService.ShowError(
                            GettextCatalog.GetString("Could not launch ASP.NET web server"),
                            ex.Message);
                        throw;
                    }
                }

                if (configuration.ExternalConsole)
                {
                    console = context.ExternalConsoleFactory.CreateConsole(!configuration.PauseConsoleOutput);
                }
                else
                {
                    console = context.ConsoleFactory.CreateConsole(!configuration.PauseConsoleOutput);
                }

                string url = String.Format("http://{0}:{1}", this.XspParameters.Address, this.XspParameters.Port);


                if (isXsp)
                {
                    console = new XspBrowserLauncherConsole(console, delegate {
                        BrowserLauncher.LaunchDefaultBrowser(url);
                    });
                }

                monitor.Log.WriteLine("Running web server...");

                var op = context.ExecutionHandler.Execute(cmd, console);
                operationMonitor.AddOperation(op);                  //handles cancellation

                if (!isXsp)
                {
                    BrowserLauncher.LaunchDefaultBrowser(url);
                }

                op.WaitForCompleted();

                monitor.Log.WriteLine("The web server exited with code: {0}", op.ExitCode);
            } catch (Exception ex) {
                if (!(ex is UserException))
                {
                    LoggingService.LogError("Could not launch ASP.NET web server.", ex);
                }
                monitor.ReportError("Could not launch web server.", ex);
            } finally {
                operationMonitor.Dispose();
                if (console != null)
                {
                    console.Dispose();
                }
            }
        }
Ejemplo n.º 29
0
 void cmdConfigure_Click(object sender, EventArgs e)
 {
     BrowserLauncher.OpenDashboard(_appHost);
 }
Ejemplo n.º 30
0
 void cmdPremiere_Click(object sender, EventArgs e)
 {
     BrowserLauncher.OpenEmbyPremiere(_appHost);
 }
Ejemplo n.º 31
0
 void cmdBrowse_Click(object sender, EventArgs e)
 {
     BrowserLauncher.OpenWebClient(_appHost);
 }
Ejemplo n.º 32
0
 void notifyIcon1_DoubleClick(object sender, EventArgs e)
 {
     BrowserLauncher.OpenDashboard(_appHost);
 }