Exemple #1
0
 public UsageReporter(IApplicationHost applicationHost, IHttpClient httpClient, IUserManager userManager, ILogger logger)
 {
     _applicationHost = applicationHost;
     _httpClient = httpClient;
     _userManager = userManager;
     _logger = logger;
 }
 bool IServerConfig.GetUncUser(IApplicationHost appHost, VirtualPath path, out string username, out string password)
 {
     bool flag = false;
     username = null;
     password = null;
     IntPtr zero = IntPtr.Zero;
     int cchUserName = 0;
     IntPtr bstrPassword = IntPtr.Zero;
     int cchPassword = 0;
     try
     {
         if (UnsafeIISMethods.MgdGetVrPathCreds(IntPtr.Zero, appHost.GetSiteName(), path.VirtualPathString, out zero, out cchUserName, out bstrPassword, out cchPassword) == 0)
         {
             username = (cchUserName > 0) ? StringUtil.StringFromWCharPtr(zero, cchUserName) : null;
             password = (cchPassword > 0) ? StringUtil.StringFromWCharPtr(bstrPassword, cchPassword) : null;
             flag = !string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password);
         }
     }
     finally
     {
         if (zero != IntPtr.Zero)
         {
             Marshal.FreeBSTR(zero);
         }
         if (bstrPassword != IntPtr.Zero)
         {
             Marshal.FreeBSTR(bstrPassword);
         }
     }
     return flag;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ReloadLoggerFileTask" /> class.
 /// </summary>
 /// <param name="logManager">The logManager.</param>
 /// <param name="appHost"></param>
 /// <param name="httpClient"></param>
 public StatisticsTask(ILogManager logManager, IApplicationHost appHost, INetworkManager networkManager, IHttpClient httpClient)
 {
     LogManager = logManager;
     ApplicationHost = appHost;
     NetworkManager = networkManager;
     HttpClient = httpClient;
 }
 public ChannelViewControl(IApplicationHost host, string consoleName)
 {
     InitializeComponent();
     Host = host;
     Items = new ChannelViewItemCollection();
     ControlName = consoleName;
 }
Exemple #5
0
        private void CreateContainer(HttpConfiguration configuration,IApplicationHost applicationHost,IConfigurationProvider configurationProvider)
        {
            var assemblies          = applicationHost.Assemblies.ToArray();
            var containerBuilder    = new ContainerBuilder();

            containerBuilder.RegisterModelBinderProvider();
            //containerBuilder.RegisterFilterProvider(); TODO: Seems to be an autofac MVC4 integration issue
            containerBuilder.RegisterModelBinders(assemblies);
            containerBuilder.RegisterApiControllers(assemblies);
            containerBuilder.RegisterControllers(assemblies);
            containerBuilder.RegisterWebApiFilterProvider(configuration);
            containerBuilder.RegisterWebApiModelBinders(assemblies);
            containerBuilder.RegisterModule(new AutofacWebTypesModule());

            containerBuilder.RegisterAssemblyModules(assemblies);
            containerBuilder.RegisterAssemblyTypes(assemblies).Where(t => t.IsAssignableTo<IRouteProvider>()).As<IRouteProvider>();
            containerBuilder.RegisterAssemblyTypes(assemblies).Where(t => t.IsAssignableTo<IBootTask>()).As<IBootTask>();
            containerBuilder.RegisterAssemblyTypes(assemblies).Where(t => t.IsAssignableTo<AreaRegistration>()).As<AreaRegistration>();

            containerBuilder.RegisterInstance(applicationHost).As<IApplicationHost>();
            containerBuilder.RegisterInstance(configurationProvider).As<IConfigurationProvider>();

            var container = containerBuilder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
            configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container);
            SignalR.GlobalHost.DependencyResolver = new AutofacSignalRDependencyResolver(container);
        }
 public PluginCategoryListViewModel(IPresentationManager presentationManager, IInstallationManager installationManager, INavigationService nav, IApplicationHost appHost)
 {
     _presentationManager = presentationManager;
     _installationManager = installationManager;
     _nav = nav;
     _appHost = appHost;
 }
Exemple #7
0
		public void UnloadHost ()
		{
			if (AppHost != null)
				AppHost.Unload ();

			AppHost = null;
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="PluginUpdater" /> class.
 /// </summary>
 /// <param name="appHost">The app host.</param>
 /// <param name="logger">The logger.</param>
 public PluginUpdater(IApplicationHost appHost, ILogger logger, IApplicationPaths appPaths, ApiClient apiClient)
 {
     _appHost = appHost;
     _logger = logger;
     _appPaths = appPaths;
     _apiClient = apiClient;
 }
        public PageContentViewModel(INavigationService navigationService, ISessionManager sessionManager, IPlaybackManager playbackManager, ILogger logger, ITheaterApplicationHost appHost, IApiClient apiClient, IPresentationManager presentationManager, IServerEvents serverEvents)
        {
            NavigationService = navigationService;
            SessionManager = sessionManager;
            PlaybackManager = playbackManager;
            Logger = logger;
            AppHost = appHost;
            ApiClient = apiClient;
            PresentationManager = presentationManager;
            ServerEvents = serverEvents;

            MasterCommands = new MasterCommandsViewModel(navigationService, sessionManager, presentationManager, apiClient, logger, appHost, serverEvents);

            NavigationService.Navigated += NavigationServiceNavigated;
            SessionManager.UserLoggedIn += SessionManagerUserLoggedIn;
            SessionManager.UserLoggedOut += SessionManagerUserLoggedOut;
            PlaybackManager.PlaybackStarted += PlaybackManager_PlaybackStarted;
            PlaybackManager.PlaybackCompleted += PlaybackManager_PlaybackCompleted;            

            _dispatcher = Dispatcher.CurrentDispatcher;

            _clockTimer = new Timer(ClockTimerCallback, null, 0, 10000);

            IsLoggedIn = SessionManager.CurrentUser != null;
            var page = NavigationService.CurrentPage;
            IsOnHomePage = page is IHomePage;
            IsOnFullscreenVideo = page is IFullscreenVideoPage;
        }
 public PluginsPageViewModel(IApplicationHost appHost, INavigationService nav, IInstallationManager installationManager, IPresentationManager presentationManager)
 {
     _appHost = appHost;
     _nav = nav;
     _installationManager = installationManager;
     _presentationManager = presentationManager;
 }
 public ChannelImageProvider(ILiveTvManager liveTvManager, IHttpClient httpClient, ILogger logger, IApplicationHost appHost)
 {
     _liveTvManager = liveTvManager;
     _httpClient = httpClient;
     _logger = logger;
     _appHost = appHost;
 }
 public UsageEntryPoint(ILogger logger, IApplicationHost applicationHost, INetworkManager networkManager, IHttpClient httpClient)
 {
     _logger = logger;
     _applicationHost = applicationHost;
     _networkManager = networkManager;
     _httpClient = httpClient;
 }
Exemple #13
0
 public UsageReporter(IApplicationHost applicationHost, INetworkManager networkManager, IHttpClient httpClient, IUserManager userManager)
 {
     _applicationHost = applicationHost;
     _networkManager = networkManager;
     _httpClient = httpClient;
     _userManager = userManager;
 }
		public virtual void Configure(ulong requestId, int requestNumber, IApplicationHost appHost)
		{
			this.requestId = requestId;
			this.requestNumber = requestNumber;
			this.appHost = appHost;
			this.transport = appHost.AppHostTransport;
		}
Exemple #15
0
 public SchedulesDirect(ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient, IApplicationHost appHost)
 {
     _logger = logger;
     _jsonSerializer = jsonSerializer;
     _httpClient = httpClient;
     _appHost = appHost;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindow" /> class.
        /// </summary>
        public MainWindow(ILogger logger, IPlaybackManager playbackManager, IApiClient apiClient, IImageManager imageManager, IApplicationHost appHost, IPresentationManager appWindow, IUserInputManager userInput, ITheaterConfigurationManager config, INavigationService nav, IScreensaverManager screensaverManager)
            : base()
        {
            _logger = logger;
            _appHost = appHost;
            _appWindow = appWindow;
            _config = config;
            _playbackManager = playbackManager;
            UserInputManager = userInput;
            NavigationManager = nav;

            Loaded += MainWindow_Loaded;

            InitializeComponent();

            RotatingBackdrops = new RotatingBackdropsViewModel(apiClient, _config, imageManager, playbackManager, logger, screensaverManager);

            _config.ConfigurationUpdated += _config_ConfigurationUpdated;
            _playbackManager.PlaybackStarted += _playbackManager_PlaybackStarted;
            _playbackManager.PlaybackCompleted += _playbackManager_PlaybackCompleted;

            //Timeline.DesiredFrameRateProperty.OverrideMetadata(
            //    typeof(Timeline),
            //    new FrameworkPropertyMetadata { DefaultValue = 30 }
            //);
        }
 public LiveTvDtoService(IDtoService dtoService, IUserDataManager userDataManager, IImageProcessor imageProcessor, ILogger logger, IApplicationHost appHost)
 {
     _dtoService = dtoService;
     _userDataManager = userDataManager;
     _imageProcessor = imageProcessor;
     _logger = logger;
     _appHost = appHost;
 }
Exemple #18
0
		static bool VirtualPathExists (IApplicationHost appHost, string verb, string uri)
		{
			if (appHost.IsHttpHandler (verb, uri))
				return true;

			VirtualPathProvider vpp = HostingEnvironment.VirtualPathProvider;
			return vpp != null && vpp.FileExists ("/" + uri);
		}
		protected override void OnHostUnload (IApplicationHost host, bool isShutdown)
		{
			UnregisterHost (
				host.VHost,
				host.VPort,
				host.VPath
			);
		}
 // if appHost is null, we use the site name for the current application
 string IServerConfig.MapPath(IApplicationHost appHost, VirtualPath path) {
     string siteName = (appHost == null) ? _siteNameForCurrentApplication : appHost.GetSiteName();
     string physicalPath = ProcessHostConfigUtils.MapPathActual(siteName, path);
     if (FileUtil.IsSuspiciousPhysicalPath(physicalPath)) {
         throw new InvalidOperationException(SR.GetString(SR.Cannot_map_path, path.VirtualPathString));
     }
     return physicalPath;
 }
        public PluginsPage(IApplicationHost appHost, INavigationService nav, IPresentationManager presentation, IInstallationManager installationManager)
        {
            _presentation = presentation;
            InitializeComponent();

            var viewModel = new PluginsPageViewModel(appHost, nav, installationManager, presentation);
            viewModel.PropertyChanged += viewModel_PropertyChanged;
            DataContext = viewModel;
        }
        public DlnaServerEntryPoint(IServerConfigurationManager config, ILogManager logManager, IApplicationHost appHost, INetworkManager network)
        {
            Instance = this;

            _config = config;
            _appHost = appHost;
            _network = network;
            _logger = logManager.GetLogger("DlnaServer");
        }
Exemple #23
0
        public SsdpHandler(ILogger logger, IServerConfigurationManager config, IApplicationHost appHost)
        {
            _logger = logger;
            _config = config;
            _appHost = appHost;

            _config.NamedConfigurationUpdated += _config_ConfigurationUpdated;
            _serverSignature = GenerateServerSignature();
        }
        public PackageInfoPage(PackageInfo packageInfo, IApplicationHost appHost, IInstallationManager installationManager, INavigationService nav)
        {
            _packageInfo = packageInfo;
            _appHost = appHost;
            _installationManager = installationManager;
            _nav = nav;

            InitializeComponent();
        }
 public UIKernel(IApplicationHost appHost)
 {
     if (Instance != null)
     {
         throw new InvalidOperationException("Can only have one Kernel");
     }
     Instance = this;
     _appHost = appHost;
 }
        public InstalledPluginListViewModel(IApplicationHost appHost, INavigationService nav, IInstallationManager installationManager, IPresentationManager presentationManager)
        {
            _appHost = appHost;
            _nav = nav;
            _installationManager = installationManager;
            _presentationManager = presentationManager;

            NavigateCommand = new RelayCommand(Navigate);
        }
 public ConnectEntryPoint(IHttpClient httpClient, IApplicationPaths appPaths, ILogger logger, INetworkManager networkManager, IConnectManager connectManager, IApplicationHost appHost)
 {
     _httpClient = httpClient;
     _appPaths = appPaths;
     _logger = logger;
     _networkManager = networkManager;
     _connectManager = connectManager;
     _appHost = appHost;
 }
        public PluginCategoryViewModel(IPresentationManager presentationManager, IInstallationManager installationManager, INavigationService nav, IApplicationHost appHost)
        {
            _presentationManager = presentationManager;
            _installationManager = installationManager;
            _nav = nav;
            _appHost = appHost;

            NavigateCommand = new RelayCommand(Navigate);
        }
Exemple #29
0
		public bool TryClearHost (IApplicationHost host)
		{
			if (AppHost == host) {
				AppHost = null;
				return true;
			}

			return false;
		}
        public static void Init(IApplicationPaths appPaths, INetworkManager networkManager, ILogManager logManager, IApplicationHost appHost)
        {
            // Ugly alert (static init)

            _appPaths = appPaths;
            _networkManager = networkManager;
            _logger = logManager.GetLogger("SecurityManager");
            _applicationHost = appHost;
        }
Exemple #31
0
 public BaseController(IServiceLocator currentLocator = null)
 {
     // DI ready
     _locator              = currentLocator ?? ServiceLocator.Current;
     _host                 = _locator.GetService <IApplicationHost>();
     _dbContext            = _locator.GetService <IDbContext>();
     _renderer             = _locator.GetServiceOrNull <IRenderer>();
     _workflowEngine       = _locator.GetServiceOrNull <IWorkflowEngine>();
     _localizer            = _locator.GetService <ILocalizer>();
     _scripter             = _locator.GetService <IDataScripter>();
     _messageService       = _locator.GetServiceOrNull <IMessageService>();
     _userStateManager     = _locator.GetServiceOrNull <IUserStateManager>();
     _externalDataProvider = _locator.GetServiceOrNull <IExternalDataProvider>();
     _tokenProvider        = _locator.GetService <ITokenProvider>();
     _userLocale           = _locator.GetService <IUserLocale>();
 }
Exemple #32
0
        public FirebaseSessionController(IHttpClient httpClient,
                                         IApplicationHost appHost,
                                         IJsonSerializer json,
                                         SessionInfo session,
                                         string token, ISessionManager sessionManager)
        {
            _httpClient     = httpClient;
            _json           = json;
            _appHost        = appHost;
            Session         = session;
            _token          = token;
            _sessionManager = sessionManager;

            _applicationId = _appHost.GetValue("firebase_applicationid");
            _senderId      = _appHost.GetValue("firebase_senderid");
        }
Exemple #33
0
        public HttpListenerHost(IApplicationHost applicationHost,
                                ILogManager logManager,
                                IServerConfigurationManager config,
                                string serviceName,
                                string defaultRedirectPath, INetworkManager networkManager, IMemoryStreamProvider memoryStreamProvider, params Assembly[] assembliesWithServices)
            : base(serviceName, assembliesWithServices)
        {
            DefaultRedirectPath   = defaultRedirectPath;
            _networkManager       = networkManager;
            _memoryStreamProvider = memoryStreamProvider;
            _config = config;

            _logger = logManager.GetLogger("HttpServer");

            _containerAdapter = new ContainerAdapter(applicationHost);
        }
Exemple #34
0
        static bool VirtualPathExists(IApplicationHost appHost, string verb, string uri)
        {
            if (appHost.IsHttpHandler(verb, uri))
            {
                return(true);
            }

            VirtualPathProvider vpp = HostingEnvironment.VirtualPathProvider;

            if (vpp != null && vpp.FileExists("/" + uri))
            {
                return(true);
            }

            return(false);
        }
Exemple #35
0
        public static void GetPathsFromUri(IApplicationHost appHost, string verb, string uri, out string realUri, out string pathInfo)
        {
            // There's a hidden missing feature here... :)
            realUri = uri; pathInfo = String.Empty;
            string vpath    = HttpRuntime.AppDomainAppVirtualPath;
            int    vpathLen = vpath.Length;

            if (vpath [vpathLen - 1] != '/')
            {
                vpath += '/';
            }

            if (vpathLen > uri.Length)
            {
                return;
            }

            uri = uri.Substring(vpathLen);
            while (uri.Length > 0 && uri [0] == '/')
            {
                uri = uri.Substring(1);
            }

            int lastSlash = uri.Length;

            for (int dot = uri.LastIndexOf('.'); dot > 0; dot = uri.LastIndexOf('.', dot - 1))
            {
                int slash = uri.IndexOf('/', dot);

                if (slash == -1)
                {
                    slash = lastSlash;
                }

                string partial = uri.Substring(0, slash);
                lastSlash = slash;

                if (!VirtualPathExists(appHost, verb, partial))
                {
                    continue;
                }

                realUri  = vpath + uri.Substring(0, slash);
                pathInfo = uri.Substring(slash);
                break;
            }
        }
Exemple #36
0
        public OmdbItemProvider(
            IApplicationHost appHost,
            IHttpClientFactory httpClientFactory,
            ILibraryManager libraryManager,
            IFileSystem fileSystem,
            IServerConfigurationManager configurationManager)
        {
            _httpClientFactory    = httpClientFactory;
            _libraryManager       = libraryManager;
            _fileSystem           = fileSystem;
            _configurationManager = configurationManager;
            _appHost = appHost;

            _jsonOptions = new JsonSerializerOptions(JsonDefaults.Options);
            _jsonOptions.Converters.Add(new JsonOmdbNotAvailableStringConverter());
            _jsonOptions.Converters.Add(new JsonOmdbNotAvailableInt32Converter());
        }
Exemple #37
0
        public MusicBrainzAlbumProvider(
            IHttpClient httpClient,
            IApplicationHost appHost,
            ILogger logger,
            IConfiguration configuration)
        {
            _httpClient = httpClient;
            _appHost    = appHost;
            _logger     = logger;

            _musicBrainzBaseUrl = configuration["MusicBrainz:BaseUrl"];

            // Use a stopwatch to ensure we don't exceed the MusicBrainz rate limit
            _stopWatchMusicBrainz.Start();

            Current = this;
        }
        public HttpListenerHost(IApplicationHost applicationHost,
                                ILogManager logManager,
                                string serviceName,
                                string handlerPath,
                                string defaultRedirectPath,
                                bool supportsNativeWebSocket,
                                params Assembly[] assembliesWithServices)
            : base(serviceName, assembliesWithServices)
        {
            DefaultRedirectPath      = defaultRedirectPath;
            _supportsNativeWebSocket = supportsNativeWebSocket;
            HandlerPath = handlerPath;

            _logger = logManager.GetLogger("HttpServer");

            _containerAdapter = new ContainerAdapter(applicationHost);
        }
Exemple #39
0
        public static String AppStyleSheetsLink(this IApplicationHost host, String controllerName)
        {
            controllerName = controllerName ?? throw new ArgumentNullException(nameof(controllerName));
            // TODO _host AssestsDistionary
            var fp = host.MakeFullPath(false, "_assets", "");

            if (!Directory.Exists(fp))
            {
                return(String.Empty);
            }
            foreach (var f in Directory.EnumerateFiles(fp, "*.css"))
            {
                // at least one file
                return($"<link  href=\"/{controllerName.ToLowerInvariant()}/appstyles\" rel=\"stylesheet\" />");
            }
            return(String.Empty);
        }
Exemple #40
0
        public MusicBrainzAlbumProvider(
            IHttpClientFactory httpClientFactory,
            IApplicationHost appHost,
            ILogger <MusicBrainzAlbumProvider> logger)
        {
            _httpClientFactory = httpClientFactory;
            _appHost           = appHost;
            _logger            = logger;

            _musicBrainzBaseUrl         = Plugin.Instance.Configuration.Server;
            _musicBrainzQueryIntervalMs = Plugin.Instance.Configuration.RateLimit;

            // Use a stopwatch to ensure we don't exceed the MusicBrainz rate limit
            _stopWatchMusicBrainz.Start();

            Current = this;
        }
Exemple #41
0
        public static String AppStyleSheetsLink(this IApplicationHost host, String controllerName)
        {
            controllerName = controllerName ?? throw new ArgumentNullException(nameof(controllerName));
            // TODO _host AssestsDistionary
            var files = host.ApplicationReader.EnumerateFiles("_assets", "*.css");

            if (files == null)
            {
                return(String.Empty);
            }
            // at least one file
            foreach (var f in files)
            {
                return($"<link  href=\"/{controllerName.ToLowerInvariant()}/appstyles\" rel=\"stylesheet\" />");
            }
            return(String.Empty);
        }
Exemple #42
0
        public NavigationService(IThemeManager themeManager, Func <IPlaybackManager> playbackManagerFactory, IPresentationManager presentationManager, ITheaterConfigurationManager config, Func <ISessionManager> sessionFactory, IApplicationHost appHost, IInstallationManager installationManager, IImageManager imageManager, ILogger logger, Func <IUserInputManager> userInputManagerFactory, IHiddenWindow hiddenWindow, IConnectionManager connectionManager)
        {
            _themeManager           = themeManager;
            _playbackManagerFactory = playbackManagerFactory;
            _presentationManager    = presentationManager;
            _config                  = config;
            _sessionFactory          = sessionFactory;
            _appHost                 = appHost;
            _installationManager     = installationManager;
            _imageManager            = imageManager;
            _logger                  = logger;
            _userInputManagerFactory = userInputManagerFactory;
            _hiddenWindow            = hiddenWindow;
            _connectionManager       = connectionManager;

            presentationManager.WindowLoaded += presentationManager_WindowLoaded;
        }
        public AspNetNativeWebRequest(ulong requestId, int requestNumber, IApplicationHost appHost, IApplicationHostTransport transport,
                                      bool addTrailingSlash) : base(appHost)
        {
            this.requestId     = requestId;
            this.requestNumber = requestNumber;
            knownHeaders       = new string[HttpWorkerRequest.RequestHeaderMaximum];

            this.transport        = transport;
            this.addTrailingSlash = addTrailingSlash;
            //			try {
            //				//TODO: cache paths
            //				Paths.GetPathsFromUri (appHost, GetHttpVerbName (), GetFilePath (), out file_path, out path_info);
            //			} catch {
            //				path_info = null;
            //				file_path = null;
            //			}
        }
Exemple #44
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NavigationService" /> class.
        /// </summary>
        /// <param name="themeManager">The theme manager.</param>
        /// <param name="playbackManagerFactory">The playback manager factory.</param>
        /// <param name="apiClient">The API client.</param>
        /// <param name="presentationManager">The presentation manager.</param>
        public NavigationService(IThemeManager themeManager, Func <IPlaybackManager> playbackManagerFactory, IApiClient apiClient, IPresentationManager presentationManager, ITheaterConfigurationManager config, Func <ISessionManager> sessionFactory, IApplicationHost appHost, IInstallationManager installationManager, IImageManager imageManager, ILogger logger, IUserInputManager userInputManager, IServerEvents serverEvents)
        {
            _themeManager           = themeManager;
            _playbackManagerFactory = playbackManagerFactory;
            _apiClient           = apiClient;
            _presentationManager = presentationManager;
            _config              = config;
            _sessionFactory      = sessionFactory;
            _appHost             = appHost;
            _installationManager = installationManager;
            _imageManager        = imageManager;
            _logger              = logger;
            _userInputManager    = userInputManager;
            _serverEvents        = serverEvents;

            presentationManager.WindowLoaded += presentationManager_WindowLoaded;
        }
Exemple #45
0
        public static WorkflowResult AutoStart(Int64 processId, IApplicationHost host, IDbContext dbContext, IMessaging messaging, ILogger logger)
        {
            var p = dbContext.Load <Process>(null, "a2workflow.[ProcessStart.Load]", new { Id = processId });
            StartWorkflowInfo info = new StartWorkflowInfo()
            {
                ProcessId  = p.Id,
                UserId     = 0,             // System
                ActionBase = p.ActionBase,
                Source     = p.Source,
                DataSource = p.DataSource,
                Schema     = p.Schema,
                Model      = p.ModelName,
                ModelId    = p.ModelId
            };

            return(StartWorkflow(host, dbContext, messaging, info).Result);
        }
Exemple #46
0
        public void CreateHost(ApplicationServer server, WebSource webSource)
        {
            string v = vpath;

            if (v != "/" && v.EndsWith("/"))
            {
                v = v.Substring(0, v.Length - 1);
            }

            var domain      = AppDomain.CurrentDomain;
            var debugDomain = domain.GetData("DebugDomain") as DebugDomain;
            var listAsm     = domain.GetAssemblies();
            // { Mono.WebServer, Version = 4.4.0.0, Culture = neutral, PublicKeyToken = 0738eb9f132ed756}
            // { Mono.WebServer.XSP, Version = 4.9.0.0, Culture = neutral, PublicKeyToken = 0738eb9f132ed756}

            Exception error = null;

            try
            {
                var hostType = webSource.GetApplicationHostType();
                AppHost =
                    Mono.Web.Hosting.
                    ApplicationHost.CreateApplicationHost(hostType, v, realPath) as IApplicationHost;
                AppHost.Server = server;
            } catch (Exception err) { error = err.InnerException ?? err; }

            if (AppHost == null && error != null)
            {
                Console.WriteLine(error.Message);
                if (Debugger.IsAttached)
                {
                    Debugger.Break();
                }

                Console.ReadKey();
                // throw error;
            }

            if (!server.SingleApplication)
            {
                // Link the host in the application domain with a request broker in the main domain
                RequestBroker         = webSource.CreateRequestBroker();
                AppHost.RequestBroker = RequestBroker;
            }
        }
Exemple #47
0
        public static string GetOmdbUrl(string query, IApplicationHost appHost, CancellationToken cancellationToken)
        {
            var baseUrl = appHost.GetValue("omdb_baseurl");

            if (string.IsNullOrEmpty(baseUrl))
            {
                baseUrl = "https://www.omdbapi.com";
            }

            var url = baseUrl + "?apikey=fe53f97e";

            if (!string.IsNullOrWhiteSpace(query))
            {
                url += "&" + query;
            }

            return(url);
        }
Exemple #48
0
 public TmdbMovieProvider(
     IJsonSerializer jsonSerializer,
     IHttpClient httpClient,
     IFileSystem fileSystem,
     IServerConfigurationManager configurationManager,
     ILogger <TmdbMovieProvider> logger,
     ILibraryManager libraryManager,
     IApplicationHost appHost)
 {
     _jsonSerializer       = jsonSerializer;
     _httpClient           = httpClient;
     _fileSystem           = fileSystem;
     _configurationManager = configurationManager;
     _logger         = logger;
     _libraryManager = libraryManager;
     _appHost        = appHost;
     Current         = this;
 }
Exemple #49
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LibraryExplorer" /> class.
        /// </summary>
        public LibraryExplorer(IJsonSerializer jsonSerializer, ILogger logger, IApplicationHost appHost, IUserManager userManager, ILibraryManager libraryManager)
        {
            _logger         = logger;
            _jsonSerializer = jsonSerializer;
            _libraryManager = libraryManager;

            InitializeComponent();
            lblVersion.Content = "Version: " + appHost.ApplicationVersion;
            foreach (var user in userManager.Users)
            {
                ddlProfile.Items.Add(user);
            }
            ddlProfile.Items.Insert(0, new User {
                Name = "Physical"
            });
            ddlProfile.SelectedIndex = 0;
            ddlIndexBy.Visibility    = ddlSortBy.Visibility = lblIndexBy.Visibility = lblSortBy.Visibility = Visibility.Hidden;
        }
Exemple #50
0
 public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, Func <IDtoService> dtoService, IApplicationHost appHost, ITVSeriesManager tvSeriesManager, Func <IMediaEncoder> mediaEncoder, IFileSystem fileSystem, Func <ISubtitleEncoder> subtitleEncoder, IConfigurationManager config, IUserDataManager userDataManager, Func <IMediaSourceManager> mediaSourceManager, IJsonSerializer json)
 {
     _libraryManager     = libraryManager;
     _repo               = repo;
     _imageProcessor     = imageProcessor;
     _logger             = logger;
     _userManager        = userManager;
     _dtoService         = dtoService;
     _appHost            = appHost;
     _tvSeriesManager    = tvSeriesManager;
     _mediaEncoder       = mediaEncoder;
     _fileSystem         = fileSystem;
     _subtitleEncoder    = subtitleEncoder;
     _config             = config;
     _userDataManager    = userDataManager;
     _mediaSourceManager = mediaSourceManager;
     _json               = json;
 }
        public IRegisteredObject CreateObject(IApplicationHost appHost, Type type)
        {
            if (appHost == null)
            {
                throw new ArgumentNullException("appHost");
            }
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            return(CreateObject(appHost.GetSiteID(),
                                type,
                                appHost.GetVirtualPath(),
                                appHost.GetPhysicalPath(),
                                true,
                                true));
        }
Exemple #52
0
        public PluginService(IJsonSerializer jsonSerializer,
                             IApplicationHost appHost,
                             IInstallationManager installationManager,
                             INetworkManager network,
                             IDeviceManager deviceManager)
            : base()
        {
            if (jsonSerializer == null)
            {
                throw new ArgumentNullException(nameof(jsonSerializer));
            }

            _appHost             = appHost;
            _installationManager = installationManager;
            _network             = network;
            _deviceManager       = deviceManager;
            _jsonSerializer      = jsonSerializer;
        }
Exemple #53
0
        public InstallationManager(ILogger logger, IApplicationHost appHost, IApplicationPaths appPaths, IHttpClient httpClient, IJsonSerializer jsonSerializer, ISecurityManager securityManager, IConfigurationManager config)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            CurrentInstallations   = new List <Tuple <InstallationInfo, CancellationTokenSource> >();
            CompletedInstallations = new ConcurrentBag <InstallationInfo>();

            _applicationHost = appHost;
            _appPaths        = appPaths;
            _httpClient      = httpClient;
            _jsonSerializer  = jsonSerializer;
            _securityManager = securityManager;
            _config          = config;
            _logger          = logger;
        }
Exemple #54
0
        private void OnHostUnload(object sender, HostUnloadEventArgs e)
        {
            try
            {}
            finally
            {
                HostInfo host = null;

                lock (hosts) {
                    foreach (HostInfo info in hosts)
                    {
                        if (info.Host == sender)
                        {
                            host = info;
                            break;
                        }
                    }
                }

                if (host == null)
                {
                    IApplicationHost appHost = sender as IApplicationHost;
                    Logger.Write(LogLevel.Error, "Can't unload host {0}:{1}:{2}:{3}", appHost.VHost, appHost.VPort, appHost.VPath, appHost.Path);
                }
                else
                {
                    Logger.Write(LogLevel.Debug, "Domain={0} Unload host in domain {1} id={2}", AppDomain.CurrentDomain.FriendlyName, ((IApplicationHost)sender).Domain.FriendlyName, ((IApplicationHost)sender).Domain.Id);

                    lock (hosts) {
                        hosts.Remove(host);
                    }

                    if (!e.IsShutdown)
                    {
                        CreateAppHost(host.AppHostType, host.AppHostConfig, host.AppConfig,
                                      host.ListenerTransport, host.AppHostTransportType, host.AppHostTransportConfig);
                    }
                    else
                    {
                        Logger.Write(LogLevel.Debug, "Domain is shutdown. Host is not recreated");
                    }
                }
            }
        }
Exemple #55
0
        private bool Match(IApplicationHost apphost, string vhost, int vport, string vpath)
        {
            if (vport != -1 && apphost.VPort != -1 && vport != apphost.VPort)
            {
                return(false);
            }

//			if (vhost != null && apphost.VHost != null && apphost.VHost != "*") {
//				int length = apphost.VHost.Length;
//				string lwrvhost = vhost.ToLower (CultureInfo.InvariantCulture);
//				if (haveWildcard) {
//					if (length > vhost.Length)
//						return false;
//
//					if (length == vhost.Length && apphost.VHost != lwrvhost)
//						return false;
//
//					if (vhost [vhost.Length - length - 1] != '.')
//						return false;
//
//					if (!lwrvhost.EndsWith (apphost.VHost))
//						return false;
//
//				} else if (apphost.VHost != lwrvhost) {
//					return false;
//				}
//			}

            int local   = vpath.Length;
            int vlength = apphost.VPath.Length;

            if (vlength > local)
            {
                // Check for /xxx requests to be redirected to /xxx/
                if (apphost.VPath [vlength - 1] != '/')
                {
                    return(false);
                }

                return(vlength - 1 == local && apphost.VPath.Substring(0, vlength - 1) == vpath);
            }

            return(vpath.StartsWith(apphost.VPath, StringComparison.Ordinal));
        }
Exemple #56
0
        public PageContentViewModel(INavigationService navigationService, ISessionManager sessionManager, IPlaybackManager playbackManager, ILogger logger, IApplicationHost appHost, IApiClient apiClient, IPresentationManager presentationManager, IServerEvents serverEvents)
        {
            NavigationService   = navigationService;
            SessionManager      = sessionManager;
            PlaybackManager     = playbackManager;
            Logger              = logger;
            AppHost             = appHost;
            ApiClient           = apiClient;
            PresentationManager = presentationManager;
            ServerEvents        = serverEvents;

            NavigationService.Navigated       += NavigationServiceNavigated;
            SessionManager.UserLoggedIn       += SessionManagerUserLoggedIn;
            SessionManager.UserLoggedOut      += SessionManagerUserLoggedOut;
            PlaybackManager.PlaybackStarted   += PlaybackManager_PlaybackStarted;
            PlaybackManager.PlaybackCompleted += PlaybackManager_PlaybackCompleted;

            SettingsCommand           = new RelayCommand(i => NavigationService.NavigateToSettingsPage());
            HomeCommand               = new RelayCommand(i => NavigationService.NavigateToHomePage());
            FullscreenVideoCommand    = new RelayCommand(i => NavigationService.NavigateToInternalPlayerPage());
            RestartServerCommand      = new RelayCommand(i => RestartServer());
            RestartApplicationCommand = new RelayCommand(i => RestartApplication());

            _dispatcher = Dispatcher.CurrentDispatcher;

            _clockTimer = new Timer(ClockTimerCallback, null, 0, 10000);

            IsLoggedIn = SessionManager.CurrentUser != null;
            var page = NavigationService.CurrentPage;

            IsOnHomePage        = page is IHomePage;
            IsOnFullscreenVideo = page is IFullscreenVideoPage;

            ServerEvents.RestartRequired     += ServerEvents_RestartRequired;
            ServerEvents.ServerRestarting    += ServerEvents_ServerRestarting;
            ServerEvents.ServerShuttingDown  += ServerEvents_ServerShuttingDown;
            ServerEvents.Connected           += ServerEvents_Connected;
            AppHost.HasPendingRestartChanged += AppHostHasPendingRestartChanged;
            RefreshRestartApplicationNotification();

            // If already connected, get system info now.
            RefreshRestartServerNotification();
        }
Exemple #57
0
        public void CreateHost(ApplicationServer server, WebSource webSource)
        {
            string v = vpath;

            if (v != "/" && v.EndsWith("/"))
            {
                v = v.Substring(0, v.Length - 1);
            }

            AppHost        = ApplicationHost.CreateApplicationHost(webSource.GetApplicationHostType(), v, realPath) as IApplicationHost;
            AppHost.Server = server;

            if (!server.SingleApplication)
            {
                // Link the host in the application domain with a request broker in the main domain
                RequestBroker         = webSource.CreateRequestBroker();
                AppHost.RequestBroker = RequestBroker;
            }
        }
        public override void Configure(IApplicationHost host, object config)
        {
            base.Configure(host, config);

            try {
                //add apphost transport to list of hosts in unmanaged code
                RegisterHost(host.VHost, host.VPort, host.VPath, host.Path);

                //We have to call RegisterAppHostTransport each time
                //otherwise when domain unloaded it frees jit-tables
                //for classes were loaded in this domain. This means
                //that calling unmanaged thunks pointed to old jitted methods
                //in native-to-managed wrapper produces SEGFAULT.
                //Reregistering thunks via RegisterAppHostTransport helps to avoid the issue.
                RegisterAppHostTransport(this.GetType());
            } catch (Exception ex) {
                Logger.Write(LogLevel.Error, "Error in configuring CombinedAppHostTransport {0}", ex);
            }
        }
        public InstallationManager(ILogger logger, IApplicationHost appHost, IApplicationPaths appPaths, IHttpClient httpClient, IJsonSerializer jsonSerializer, IConfigurationManager config, IFileSystem fileSystem, ICryptoProvider cryptographyProvider, string packageRuntime)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            CurrentInstallations           = new List <Tuple <InstallationInfo, CancellationTokenSource> >();
            CompletedInstallationsInternal = new ConcurrentBag <InstallationInfo>();

            _applicationHost      = appHost;
            _appPaths             = appPaths;
            _httpClient           = httpClient;
            _jsonSerializer       = jsonSerializer;
            _config               = config;
            _fileSystem           = fileSystem;
            _cryptographyProvider = cryptographyProvider;
            _packageRuntime       = packageRuntime;
            _logger               = logger;
        }
Exemple #60
0
        public PdfReportHelper(IApplicationHost host)
        {
            _host = host;
            IServiceLocator locator = host.Locator;

            _pdfReportShim = locator.GetService <IPdfReportShim>(sloc =>
            {
                var inst = System.Activator.CreateInstance("A2v10.Pdf.Report", "A2v10.Pdf.Report.PdfReportShim");
                if (inst == null)
                {
                    throw new ArgumentNullException("A2v10.Stimulsoft");
                }
                var instUnwrap = inst.Unwrap();
                var ass        = Assembly.GetAssembly(instUnwrap.GetType());

                var shim = instUnwrap as IPdfReportShim;
                shim.Inject(sloc.GetService <ILocalizer>(), sloc.GetService <IUserLocale>());
                return(shim);
            });
        }