ApplicationHost.cs 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161
  1. using MediaBrowser.Api;
  2. using MediaBrowser.Common;
  3. using MediaBrowser.Common.Configuration;
  4. using MediaBrowser.Common.Events;
  5. using MediaBrowser.Common.Implementations;
  6. using MediaBrowser.Common.Implementations.ScheduledTasks;
  7. using MediaBrowser.Common.IO;
  8. using MediaBrowser.Common.Net;
  9. using MediaBrowser.Common.Progress;
  10. using MediaBrowser.Controller;
  11. using MediaBrowser.Controller.Activity;
  12. using MediaBrowser.Controller.Channels;
  13. using MediaBrowser.Controller.Chapters;
  14. using MediaBrowser.Controller.Collections;
  15. using MediaBrowser.Controller.Configuration;
  16. using MediaBrowser.Controller.Connect;
  17. using MediaBrowser.Controller.Devices;
  18. using MediaBrowser.Controller.Dlna;
  19. using MediaBrowser.Controller.Drawing;
  20. using MediaBrowser.Controller.Dto;
  21. using MediaBrowser.Controller.Entities;
  22. using MediaBrowser.Controller.FileOrganization;
  23. using MediaBrowser.Controller.Library;
  24. using MediaBrowser.Controller.LiveTv;
  25. using MediaBrowser.Controller.Localization;
  26. using MediaBrowser.Controller.MediaEncoding;
  27. using MediaBrowser.Controller.Net;
  28. using MediaBrowser.Controller.News;
  29. using MediaBrowser.Controller.Notifications;
  30. using MediaBrowser.Controller.Persistence;
  31. using MediaBrowser.Controller.Playlists;
  32. using MediaBrowser.Controller.Plugins;
  33. using MediaBrowser.Controller.Providers;
  34. using MediaBrowser.Controller.Resolvers;
  35. using MediaBrowser.Controller.Security;
  36. using MediaBrowser.Controller.Session;
  37. using MediaBrowser.Controller.Sorting;
  38. using MediaBrowser.Controller.Subtitles;
  39. using MediaBrowser.Controller.Sync;
  40. using MediaBrowser.Controller.Themes;
  41. using MediaBrowser.Controller.TV;
  42. using MediaBrowser.Dlna;
  43. using MediaBrowser.Dlna.ConnectionManager;
  44. using MediaBrowser.Dlna.ContentDirectory;
  45. using MediaBrowser.Dlna.Main;
  46. using MediaBrowser.LocalMetadata.Providers;
  47. using MediaBrowser.MediaEncoding.BdInfo;
  48. using MediaBrowser.MediaEncoding.Encoder;
  49. using MediaBrowser.MediaEncoding.Subtitles;
  50. using MediaBrowser.Model.Logging;
  51. using MediaBrowser.Model.MediaInfo;
  52. using MediaBrowser.Model.System;
  53. using MediaBrowser.Model.Updates;
  54. using MediaBrowser.Providers.Chapters;
  55. using MediaBrowser.Providers.Manager;
  56. using MediaBrowser.Providers.Subtitles;
  57. using MediaBrowser.Server.Implementations;
  58. using MediaBrowser.Server.Implementations.Activity;
  59. using MediaBrowser.Server.Implementations.Channels;
  60. using MediaBrowser.Server.Implementations.Collections;
  61. using MediaBrowser.Server.Implementations.Configuration;
  62. using MediaBrowser.Server.Implementations.Connect;
  63. using MediaBrowser.Server.Implementations.Devices;
  64. using MediaBrowser.Server.Implementations.Drawing;
  65. using MediaBrowser.Server.Implementations.Dto;
  66. using MediaBrowser.Server.Implementations.EntryPoints;
  67. using MediaBrowser.Server.Implementations.FileOrganization;
  68. using MediaBrowser.Server.Implementations.HttpServer;
  69. using MediaBrowser.Server.Implementations.HttpServer.Security;
  70. using MediaBrowser.Server.Implementations.IO;
  71. using MediaBrowser.Server.Implementations.Library;
  72. using MediaBrowser.Server.Implementations.LiveTv;
  73. using MediaBrowser.Server.Implementations.Localization;
  74. using MediaBrowser.Server.Implementations.MediaEncoder;
  75. using MediaBrowser.Server.Implementations.Notifications;
  76. using MediaBrowser.Server.Implementations.Persistence;
  77. using MediaBrowser.Server.Implementations.Playlists;
  78. using MediaBrowser.Server.Implementations.Security;
  79. using MediaBrowser.Server.Implementations.ServerManager;
  80. using MediaBrowser.Server.Implementations.Session;
  81. using MediaBrowser.Server.Implementations.Sync;
  82. using MediaBrowser.Server.Implementations.Themes;
  83. using MediaBrowser.Server.Implementations.TV;
  84. using MediaBrowser.Server.Startup.Common.FFMpeg;
  85. using MediaBrowser.Server.Startup.Common.Migrations;
  86. using MediaBrowser.WebDashboard.Api;
  87. using MediaBrowser.XbmcMetadata.Providers;
  88. using System;
  89. using System.Collections.Generic;
  90. using System.Globalization;
  91. using System.IO;
  92. using System.Linq;
  93. using System.Reflection;
  94. using System.Threading;
  95. using System.Threading.Tasks;
  96. namespace MediaBrowser.Server.Startup.Common
  97. {
  98. /// <summary>
  99. /// Class CompositionRoot
  100. /// </summary>
  101. public class ApplicationHost : BaseApplicationHost<ServerApplicationPaths>, IServerApplicationHost
  102. {
  103. /// <summary>
  104. /// Gets the server configuration manager.
  105. /// </summary>
  106. /// <value>The server configuration manager.</value>
  107. public IServerConfigurationManager ServerConfigurationManager
  108. {
  109. get { return (IServerConfigurationManager)ConfigurationManager; }
  110. }
  111. /// <summary>
  112. /// Gets the name of the web application that can be used for url building.
  113. /// All api urls will be of the form {protocol}://{host}:{port}/{appname}/...
  114. /// </summary>
  115. /// <value>The name of the web application.</value>
  116. public string WebApplicationName
  117. {
  118. get { return "mediabrowser"; }
  119. }
  120. /// <summary>
  121. /// Gets the HTTP server URL prefix.
  122. /// </summary>
  123. /// <value>The HTTP server URL prefix.</value>
  124. private IEnumerable<string> HttpServerUrlPrefixes
  125. {
  126. get
  127. {
  128. var list = new List<string>
  129. {
  130. "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/" + WebApplicationName + "/"
  131. };
  132. return list;
  133. }
  134. }
  135. /// <summary>
  136. /// Gets the configuration manager.
  137. /// </summary>
  138. /// <returns>IConfigurationManager.</returns>
  139. protected override IConfigurationManager GetConfigurationManager()
  140. {
  141. return new ServerConfigurationManager(ApplicationPaths, LogManager, XmlSerializer);
  142. }
  143. /// <summary>
  144. /// Gets or sets the server manager.
  145. /// </summary>
  146. /// <value>The server manager.</value>
  147. private IServerManager ServerManager { get; set; }
  148. /// <summary>
  149. /// Gets or sets the user manager.
  150. /// </summary>
  151. /// <value>The user manager.</value>
  152. public IUserManager UserManager { get; set; }
  153. /// <summary>
  154. /// Gets or sets the library manager.
  155. /// </summary>
  156. /// <value>The library manager.</value>
  157. internal ILibraryManager LibraryManager { get; set; }
  158. /// <summary>
  159. /// Gets or sets the directory watchers.
  160. /// </summary>
  161. /// <value>The directory watchers.</value>
  162. private ILibraryMonitor LibraryMonitor { get; set; }
  163. /// <summary>
  164. /// Gets or sets the provider manager.
  165. /// </summary>
  166. /// <value>The provider manager.</value>
  167. private IProviderManager ProviderManager { get; set; }
  168. /// <summary>
  169. /// Gets or sets the HTTP server.
  170. /// </summary>
  171. /// <value>The HTTP server.</value>
  172. private IHttpServer HttpServer { get; set; }
  173. private IDtoService DtoService { get; set; }
  174. private IImageProcessor ImageProcessor { get; set; }
  175. private ISeriesOrderManager SeriesOrderManager { get; set; }
  176. /// <summary>
  177. /// Gets or sets the media encoder.
  178. /// </summary>
  179. /// <value>The media encoder.</value>
  180. private IMediaEncoder MediaEncoder { get; set; }
  181. private IConnectManager ConnectManager { get; set; }
  182. private ISessionManager SessionManager { get; set; }
  183. private ILiveTvManager LiveTvManager { get; set; }
  184. public ILocalizationManager LocalizationManager { get; set; }
  185. private IEncodingManager EncodingManager { get; set; }
  186. private IChannelManager ChannelManager { get; set; }
  187. private ISyncManager SyncManager { get; set; }
  188. /// <summary>
  189. /// Gets or sets the user data repository.
  190. /// </summary>
  191. /// <value>The user data repository.</value>
  192. private IUserDataManager UserDataManager { get; set; }
  193. private IUserRepository UserRepository { get; set; }
  194. internal IDisplayPreferencesRepository DisplayPreferencesRepository { get; set; }
  195. internal IItemRepository ItemRepository { get; set; }
  196. private INotificationsRepository NotificationsRepository { get; set; }
  197. private IFileOrganizationRepository FileOrganizationRepository { get; set; }
  198. private IProviderRepository ProviderRepository { get; set; }
  199. private INotificationManager NotificationManager { get; set; }
  200. private ISubtitleManager SubtitleManager { get; set; }
  201. private IChapterManager ChapterManager { get; set; }
  202. private IDeviceManager DeviceManager { get; set; }
  203. internal IUserViewManager UserViewManager { get; set; }
  204. private IAuthenticationRepository AuthenticationRepository { get; set; }
  205. private ISyncRepository SyncRepository { get; set; }
  206. private ITVSeriesManager TVSeriesManager { get; set; }
  207. private ICollectionManager CollectionManager { get; set; }
  208. private readonly StartupOptions _startupOptions;
  209. private readonly string _remotePackageName;
  210. private readonly bool _supportsNativeWebSocket;
  211. internal INativeApp NativeApp { get; set; }
  212. /// <summary>
  213. /// Initializes a new instance of the <see cref="ApplicationHost" /> class.
  214. /// </summary>
  215. /// <param name="applicationPaths">The application paths.</param>
  216. /// <param name="logManager">The log manager.</param>
  217. /// <param name="options">The options.</param>
  218. /// <param name="fileSystem">The file system.</param>
  219. /// <param name="remotePackageName">Name of the remote package.</param>
  220. /// <param name="supportsNativeWebSocket">if set to <c>true</c> [supports native web socket].</param>
  221. /// <param name="nativeApp">The native application.</param>
  222. public ApplicationHost(ServerApplicationPaths applicationPaths,
  223. ILogManager logManager,
  224. StartupOptions options,
  225. IFileSystem fileSystem,
  226. string remotePackageName,
  227. bool supportsNativeWebSocket,
  228. INativeApp nativeApp)
  229. : base(applicationPaths, logManager, fileSystem)
  230. {
  231. _startupOptions = options;
  232. _remotePackageName = remotePackageName;
  233. _supportsNativeWebSocket = supportsNativeWebSocket;
  234. NativeApp = nativeApp;
  235. SetBaseExceptionMessage();
  236. }
  237. private Version _version;
  238. /// <summary>
  239. /// Gets the current application version
  240. /// </summary>
  241. /// <value>The application version.</value>
  242. public override Version ApplicationVersion
  243. {
  244. get
  245. {
  246. return _version ?? (_version = NativeApp.GetType().Assembly.GetName().Version);
  247. }
  248. }
  249. public override string OperatingSystemDisplayName
  250. {
  251. get { return NativeApp.Environment.OperatingSystemVersionString; }
  252. }
  253. public override bool IsRunningAsService
  254. {
  255. get { return NativeApp.IsRunningAsService; }
  256. }
  257. public bool SupportsRunningAsService
  258. {
  259. get { return NativeApp.SupportsRunningAsService; }
  260. }
  261. /// <summary>
  262. /// Gets the name.
  263. /// </summary>
  264. /// <value>The name.</value>
  265. public override string Name
  266. {
  267. get
  268. {
  269. return "Media Browser Server";
  270. }
  271. }
  272. /// <summary>
  273. /// Gets a value indicating whether this instance can self restart.
  274. /// </summary>
  275. /// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value>
  276. public override bool CanSelfRestart
  277. {
  278. get { return NativeApp.CanSelfRestart; }
  279. }
  280. public bool SupportsAutoRunAtStartup
  281. {
  282. get { return NativeApp.SupportsAutoRunAtStartup; }
  283. }
  284. private void SetBaseExceptionMessage()
  285. {
  286. var builder = GetBaseExceptionMessage(ApplicationPaths);
  287. // Skip if plugins haven't been loaded yet
  288. //if (Plugins != null)
  289. //{
  290. // var pluginString = string.Join("|", Plugins.Select(i => i.Name + "-" + i.Version.ToString()).ToArray());
  291. // builder.Insert(0, string.Format("Plugins: {0}{1}", pluginString, Environment.NewLine));
  292. //}
  293. builder.Insert(0, string.Format("Version: {0}{1}", ApplicationVersion, Environment.NewLine));
  294. builder.Insert(0, "*** Error Report ***" + Environment.NewLine);
  295. LogManager.ExceptionMessagePrefix = builder.ToString();
  296. }
  297. /// <summary>
  298. /// Runs the startup tasks.
  299. /// </summary>
  300. /// <returns>Task.</returns>
  301. public override async Task RunStartupTasks()
  302. {
  303. await base.RunStartupTasks().ConfigureAwait(false);
  304. Logger.Info("Core startup complete");
  305. Parallel.ForEach(GetExports<IServerEntryPoint>(), entryPoint =>
  306. {
  307. try
  308. {
  309. entryPoint.Run();
  310. }
  311. catch (Exception ex)
  312. {
  313. Logger.ErrorException("Error in {0}", ex, entryPoint.GetType().Name);
  314. }
  315. });
  316. LogManager.RemoveConsoleOutput();
  317. }
  318. public override async Task Init(IProgress<double> progress)
  319. {
  320. PerformPreInitMigrations();
  321. await base.Init(progress).ConfigureAwait(false);
  322. PerformPostInitMigrations();
  323. }
  324. private void PerformPreInitMigrations()
  325. {
  326. var migrations = new List<IVersionMigration>
  327. {
  328. new MigrateUserFolders(ApplicationPaths),
  329. new RenameXbmcOptions(ServerConfigurationManager),
  330. new RenameXmlOptions(ServerConfigurationManager),
  331. new DeprecatePlugins(ApplicationPaths),
  332. new DeleteDlnaProfiles(ApplicationPaths)
  333. };
  334. foreach (var task in migrations)
  335. {
  336. task.Run();
  337. }
  338. }
  339. private void PerformPostInitMigrations()
  340. {
  341. var migrations = new List<IVersionMigration>
  342. {
  343. new MigrateTranscodingPath(ServerConfigurationManager)
  344. };
  345. foreach (var task in migrations)
  346. {
  347. task.Run();
  348. }
  349. }
  350. /// <summary>
  351. /// Registers resources that classes will depend on
  352. /// </summary>
  353. /// <returns>Task.</returns>
  354. protected override async Task RegisterResources(IProgress<double> progress)
  355. {
  356. await base.RegisterResources(progress).ConfigureAwait(false);
  357. RegisterSingleInstance<IHttpResultFactory>(new HttpResultFactory(LogManager, FileSystemManager, JsonSerializer));
  358. RegisterSingleInstance<IServerApplicationHost>(this);
  359. RegisterSingleInstance<IServerApplicationPaths>(ApplicationPaths);
  360. RegisterSingleInstance(ServerConfigurationManager);
  361. LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer);
  362. RegisterSingleInstance(LocalizationManager);
  363. RegisterSingleInstance<IBlurayExaminer>(() => new BdInfoExaminer());
  364. UserDataManager = new UserDataManager(LogManager);
  365. RegisterSingleInstance(UserDataManager);
  366. UserRepository = await GetUserRepository().ConfigureAwait(false);
  367. RegisterSingleInstance(UserRepository);
  368. DisplayPreferencesRepository = new SqliteDisplayPreferencesRepository(ApplicationPaths, JsonSerializer, LogManager);
  369. RegisterSingleInstance(DisplayPreferencesRepository);
  370. ItemRepository = new SqliteItemRepository(ApplicationPaths, JsonSerializer, LogManager);
  371. RegisterSingleInstance(ItemRepository);
  372. ProviderRepository = new SqliteProviderInfoRepository(ApplicationPaths, LogManager);
  373. RegisterSingleInstance(ProviderRepository);
  374. FileOrganizationRepository = await GetFileOrganizationRepository().ConfigureAwait(false);
  375. RegisterSingleInstance(FileOrganizationRepository);
  376. AuthenticationRepository = await GetAuthenticationRepository().ConfigureAwait(false);
  377. RegisterSingleInstance(AuthenticationRepository);
  378. SyncRepository = await GetSyncRepository().ConfigureAwait(false);
  379. RegisterSingleInstance(SyncRepository);
  380. UserManager = new UserManager(LogManager.GetLogger("UserManager"), ServerConfigurationManager, UserRepository, XmlSerializer, NetworkManager, () => ImageProcessor, () => DtoService, () => ConnectManager, this, JsonSerializer);
  381. RegisterSingleInstance(UserManager);
  382. LibraryManager = new LibraryManager(Logger, TaskManager, UserManager, ServerConfigurationManager, UserDataManager, () => LibraryMonitor, FileSystemManager, () => ProviderManager);
  383. RegisterSingleInstance(LibraryManager);
  384. var musicManager = new MusicManager(LibraryManager);
  385. RegisterSingleInstance<IMusicManager>(new MusicManager(LibraryManager));
  386. LibraryMonitor = new LibraryMonitor(LogManager, TaskManager, LibraryManager, ServerConfigurationManager, FileSystemManager);
  387. RegisterSingleInstance(LibraryMonitor);
  388. ProviderManager = new ProviderManager(HttpClient, ServerConfigurationManager, LibraryMonitor, LogManager, FileSystemManager);
  389. RegisterSingleInstance(ProviderManager);
  390. SeriesOrderManager = new SeriesOrderManager();
  391. RegisterSingleInstance(SeriesOrderManager);
  392. RegisterSingleInstance<ISearchEngine>(() => new SearchEngine(LogManager, LibraryManager, UserManager));
  393. HttpServer = ServerFactory.CreateServer(this, LogManager, "Media Browser", WebApplicationName, "dashboard/index.html", _supportsNativeWebSocket);
  394. RegisterSingleInstance(HttpServer, false);
  395. progress.Report(10);
  396. ServerManager = new ServerManager(this, JsonSerializer, LogManager.GetLogger("ServerManager"), ServerConfigurationManager);
  397. RegisterSingleInstance(ServerManager);
  398. var innerProgress = new ActionableProgress<double>();
  399. innerProgress.RegisterAction(p => progress.Report((.75 * p) + 15));
  400. await RegisterMediaEncoder(innerProgress).ConfigureAwait(false);
  401. progress.Report(90);
  402. ImageProcessor = new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, MediaEncoder);
  403. RegisterSingleInstance(ImageProcessor);
  404. SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager);
  405. RegisterSingleInstance(SyncManager);
  406. DtoService = new DtoService(Logger, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this);
  407. RegisterSingleInstance(DtoService);
  408. var encryptionManager = new EncryptionManager();
  409. RegisterSingleInstance<IEncryptionManager>(encryptionManager);
  410. ConnectManager = new ConnectManager(LogManager.GetLogger("Connect"), ApplicationPaths, JsonSerializer, encryptionManager, HttpClient, this, ServerConfigurationManager, UserManager, ProviderManager);
  411. RegisterSingleInstance(ConnectManager);
  412. DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, Logger), UserManager, FileSystemManager, LibraryMonitor, ConfigurationManager, LogManager.GetLogger("DeviceManager"));
  413. RegisterSingleInstance(DeviceManager);
  414. SessionManager = new SessionManager(UserDataManager, ServerConfigurationManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, ItemRepository, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager);
  415. RegisterSingleInstance(SessionManager);
  416. var newsService = new Implementations.News.NewsService(ApplicationPaths, JsonSerializer);
  417. RegisterSingleInstance<INewsService>(newsService);
  418. var fileOrganizationService = new FileOrganizationService(TaskManager, FileOrganizationRepository, LogManager.GetLogger("FileOrganizationService"), LibraryMonitor, LibraryManager, ServerConfigurationManager, FileSystemManager, ProviderManager);
  419. RegisterSingleInstance<IFileOrganizationService>(fileOrganizationService);
  420. progress.Report(15);
  421. ChannelManager = new ChannelManager(UserManager, DtoService, LibraryManager, Logger, ServerConfigurationManager, FileSystemManager, UserDataManager, JsonSerializer, LocalizationManager, HttpClient);
  422. RegisterSingleInstance(ChannelManager);
  423. TVSeriesManager = new TVSeriesManager(UserManager, UserDataManager, LibraryManager);
  424. RegisterSingleInstance(TVSeriesManager);
  425. var appThemeManager = new AppThemeManager(ApplicationPaths, FileSystemManager, JsonSerializer, Logger);
  426. RegisterSingleInstance<IAppThemeManager>(appThemeManager);
  427. var dlnaManager = new DlnaManager(XmlSerializer, FileSystemManager, ApplicationPaths, LogManager.GetLogger("Dlna"), JsonSerializer);
  428. RegisterSingleInstance<IDlnaManager>(dlnaManager);
  429. var connectionManager = new ConnectionManager(dlnaManager, ServerConfigurationManager, LogManager.GetLogger("UpnpConnectionManager"), HttpClient);
  430. RegisterSingleInstance<IConnectionManager>(connectionManager);
  431. CollectionManager = new CollectionManager(LibraryManager, FileSystemManager, LibraryMonitor, LogManager.GetLogger("CollectionManager"));
  432. RegisterSingleInstance(CollectionManager);
  433. var playlistManager = new PlaylistManager(LibraryManager, FileSystemManager, LibraryMonitor, LogManager.GetLogger("PlaylistManager"), UserManager);
  434. RegisterSingleInstance<IPlaylistManager>(playlistManager);
  435. LiveTvManager = new LiveTvManager(this, ServerConfigurationManager, FileSystemManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer);
  436. RegisterSingleInstance(LiveTvManager);
  437. UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, FileSystemManager, UserManager, ChannelManager, LiveTvManager, ApplicationPaths, playlistManager);
  438. RegisterSingleInstance(UserViewManager);
  439. var contentDirectory = new ContentDirectory(dlnaManager, UserDataManager, ImageProcessor, LibraryManager, ServerConfigurationManager, UserManager, LogManager.GetLogger("UpnpContentDirectory"), HttpClient, LocalizationManager, ChannelManager);
  440. RegisterSingleInstance<IContentDirectory>(contentDirectory);
  441. NotificationManager = new NotificationManager(LogManager, UserManager, ServerConfigurationManager);
  442. RegisterSingleInstance(NotificationManager);
  443. SubtitleManager = new SubtitleManager(LogManager.GetLogger("SubtitleManager"), FileSystemManager, LibraryMonitor, LibraryManager, ItemRepository);
  444. RegisterSingleInstance(SubtitleManager);
  445. ChapterManager = new ChapterManager(LibraryManager, LogManager.GetLogger("ChapterManager"), ServerConfigurationManager, ItemRepository);
  446. RegisterSingleInstance(ChapterManager);
  447. EncodingManager = new EncodingManager(FileSystemManager, Logger,
  448. MediaEncoder, ChapterManager);
  449. RegisterSingleInstance(EncodingManager);
  450. var activityLogRepo = await GetActivityLogRepository().ConfigureAwait(false);
  451. RegisterSingleInstance(activityLogRepo);
  452. RegisterSingleInstance<IActivityManager>(new ActivityManager(LogManager.GetLogger("ActivityManager"), activityLogRepo, UserManager));
  453. var authContext = new AuthorizationContext(AuthenticationRepository);
  454. RegisterSingleInstance<IAuthorizationContext>(authContext);
  455. RegisterSingleInstance<ISessionContext>(new SessionContext(UserManager, authContext, SessionManager));
  456. RegisterSingleInstance<IAuthService>(new AuthService(UserManager, authContext, ServerConfigurationManager, ConnectManager, SessionManager));
  457. RegisterSingleInstance<ISubtitleEncoder>(new SubtitleEncoder(LibraryManager, LogManager.GetLogger("SubtitleEncoder"), ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer));
  458. await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false);
  459. await ConfigureItemRepositories().ConfigureAwait(false);
  460. await ConfigureUserDataRepositories().ConfigureAwait(false);
  461. await ConfigureNotificationsRepository().ConfigureAwait(false);
  462. progress.Report(100);
  463. SetStaticProperties();
  464. await ((UserManager)UserManager).Initialize().ConfigureAwait(false);
  465. SetKernelProperties();
  466. }
  467. protected override INetworkManager CreateNetworkManager(ILogger logger)
  468. {
  469. return NativeApp.CreateNetworkManager(logger);
  470. }
  471. /// <summary>
  472. /// Registers the media encoder.
  473. /// </summary>
  474. /// <returns>Task.</returns>
  475. private async Task RegisterMediaEncoder(IProgress<double> progress)
  476. {
  477. var info = await new FFMpegDownloader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager, NativeApp.Environment)
  478. .GetFFMpegInfo(NativeApp.Environment, _startupOptions, progress).ConfigureAwait(false);
  479. new FFmpegValidator(Logger, ApplicationPaths).Validate(info);
  480. MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), JsonSerializer, info.EncoderPath, info.ProbePath, info.Version);
  481. RegisterSingleInstance(MediaEncoder);
  482. }
  483. /// <summary>
  484. /// Sets the kernel properties.
  485. /// </summary>
  486. private void SetKernelProperties()
  487. {
  488. LocalizedStrings.StringFiles = GetExports<LocalizedStringData>();
  489. }
  490. /// <summary>
  491. /// Gets the user repository.
  492. /// </summary>
  493. /// <returns>Task{IUserRepository}.</returns>
  494. private async Task<IUserRepository> GetUserRepository()
  495. {
  496. var repo = new SqliteUserRepository(JsonSerializer, LogManager, ApplicationPaths);
  497. await repo.Initialize().ConfigureAwait(false);
  498. return repo;
  499. }
  500. /// <summary>
  501. /// Gets the file organization repository.
  502. /// </summary>
  503. /// <returns>Task{IUserRepository}.</returns>
  504. private async Task<IFileOrganizationRepository> GetFileOrganizationRepository()
  505. {
  506. var repo = new SqliteFileOrganizationRepository(LogManager, ServerConfigurationManager.ApplicationPaths);
  507. await repo.Initialize().ConfigureAwait(false);
  508. return repo;
  509. }
  510. private async Task<IAuthenticationRepository> GetAuthenticationRepository()
  511. {
  512. var repo = new AuthenticationRepository(LogManager.GetLogger("AuthenticationRepository"), ServerConfigurationManager.ApplicationPaths);
  513. await repo.Initialize().ConfigureAwait(false);
  514. return repo;
  515. }
  516. private async Task<IActivityRepository> GetActivityLogRepository()
  517. {
  518. var repo = new ActivityRepository(LogManager.GetLogger("ActivityRepository"), ServerConfigurationManager.ApplicationPaths);
  519. await repo.Initialize().ConfigureAwait(false);
  520. return repo;
  521. }
  522. private async Task<ISyncRepository> GetSyncRepository()
  523. {
  524. var repo = new SyncRepository(LogManager.GetLogger("SyncRepository"), ServerConfigurationManager.ApplicationPaths);
  525. await repo.Initialize().ConfigureAwait(false);
  526. return repo;
  527. }
  528. /// <summary>
  529. /// Configures the repositories.
  530. /// </summary>
  531. /// <returns>Task.</returns>
  532. private async Task ConfigureNotificationsRepository()
  533. {
  534. var repo = new SqliteNotificationsRepository(LogManager, ApplicationPaths);
  535. await repo.Initialize().ConfigureAwait(false);
  536. NotificationsRepository = repo;
  537. RegisterSingleInstance(NotificationsRepository);
  538. }
  539. /// <summary>
  540. /// Configures the repositories.
  541. /// </summary>
  542. /// <returns>Task.</returns>
  543. private async Task ConfigureDisplayPreferencesRepositories()
  544. {
  545. await DisplayPreferencesRepository.Initialize().ConfigureAwait(false);
  546. }
  547. /// <summary>
  548. /// Configures the item repositories.
  549. /// </summary>
  550. /// <returns>Task.</returns>
  551. private async Task ConfigureItemRepositories()
  552. {
  553. await ItemRepository.Initialize().ConfigureAwait(false);
  554. await ProviderRepository.Initialize().ConfigureAwait(false);
  555. ((LibraryManager)LibraryManager).ItemRepository = ItemRepository;
  556. }
  557. /// <summary>
  558. /// Configures the user data repositories.
  559. /// </summary>
  560. /// <returns>Task.</returns>
  561. private async Task ConfigureUserDataRepositories()
  562. {
  563. var repo = new SqliteUserDataRepository(ApplicationPaths, LogManager);
  564. await repo.Initialize().ConfigureAwait(false);
  565. ((UserDataManager)UserDataManager).Repository = repo;
  566. }
  567. /// <summary>
  568. /// Dirty hacks
  569. /// </summary>
  570. private void SetStaticProperties()
  571. {
  572. // For now there's no real way to inject these properly
  573. BaseItem.Logger = LogManager.GetLogger("BaseItem");
  574. BaseItem.ConfigurationManager = ServerConfigurationManager;
  575. BaseItem.LibraryManager = LibraryManager;
  576. BaseItem.ProviderManager = ProviderManager;
  577. BaseItem.LocalizationManager = LocalizationManager;
  578. BaseItem.ItemRepository = ItemRepository;
  579. User.XmlSerializer = XmlSerializer;
  580. User.UserManager = UserManager;
  581. LocalizedStrings.ApplicationPaths = ApplicationPaths;
  582. Folder.UserManager = UserManager;
  583. BaseItem.FileSystem = FileSystemManager;
  584. BaseItem.UserDataManager = UserDataManager;
  585. BaseItem.ChannelManager = ChannelManager;
  586. BaseItem.LiveTvManager = LiveTvManager;
  587. Folder.UserViewManager = UserViewManager;
  588. UserView.TVSeriesManager = TVSeriesManager;
  589. BaseItem.CollectionManager = CollectionManager;
  590. }
  591. /// <summary>
  592. /// Finds the parts.
  593. /// </summary>
  594. protected override void FindParts()
  595. {
  596. if (IsFirstRun)
  597. {
  598. RegisterServerWithAdministratorAccess();
  599. }
  600. base.FindParts();
  601. HttpServer.Init(GetExports<IRestfulService>(false));
  602. ServerManager.AddWebSocketListeners(GetExports<IWebSocketListener>(false));
  603. StartServer(true);
  604. LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(),
  605. GetExports<IVirtualFolderCreator>(),
  606. GetExports<IItemResolver>(),
  607. GetExports<IIntroProvider>(),
  608. GetExports<IBaseItemComparer>(),
  609. GetExports<ILibraryPostScanTask>());
  610. ProviderManager.AddParts(GetExports<IImageProvider>(),
  611. GetExports<IMetadataService>(),
  612. GetExports<IItemIdentityProvider>(),
  613. GetExports<IItemIdentityConverter>(),
  614. GetExports<IMetadataProvider>(),
  615. GetExports<IMetadataSaver>(),
  616. GetExports<IImageSaver>(),
  617. GetExports<IExternalId>());
  618. SeriesOrderManager.AddParts(GetExports<ISeriesOrderProvider>());
  619. ImageProcessor.AddParts(GetExports<IImageEnhancer>());
  620. LiveTvManager.AddParts(GetExports<ILiveTvService>());
  621. SubtitleManager.AddParts(GetExports<ISubtitleProvider>());
  622. ChapterManager.AddParts(GetExports<IChapterProvider>());
  623. SessionManager.AddParts(GetExports<ISessionControllerFactory>());
  624. ChannelManager.AddParts(GetExports<IChannel>(), GetExports<IChannelFactory>());
  625. NotificationManager.AddParts(GetExports<INotificationService>(), GetExports<INotificationTypeFactory>());
  626. SyncManager.AddParts(GetExports<ISyncProvider>());
  627. }
  628. /// <summary>
  629. /// Starts the server.
  630. /// </summary>
  631. /// <param name="retryOnFailure">if set to <c>true</c> [retry on failure].</param>
  632. private void StartServer(bool retryOnFailure)
  633. {
  634. try
  635. {
  636. ServerManager.Start(HttpServerUrlPrefixes);
  637. }
  638. catch (Exception ex)
  639. {
  640. Logger.ErrorException("Error starting http server", ex);
  641. if (retryOnFailure)
  642. {
  643. RegisterServerWithAdministratorAccess();
  644. StartServer(false);
  645. }
  646. else
  647. {
  648. throw;
  649. }
  650. }
  651. }
  652. /// <summary>
  653. /// Called when [configuration updated].
  654. /// </summary>
  655. /// <param name="sender">The sender.</param>
  656. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  657. protected override void OnConfigurationUpdated(object sender, EventArgs e)
  658. {
  659. base.OnConfigurationUpdated(sender, e);
  660. if (!HttpServer.UrlPrefixes.SequenceEqual(HttpServerUrlPrefixes, StringComparer.OrdinalIgnoreCase))
  661. {
  662. NotifyPendingRestart();
  663. }
  664. }
  665. /// <summary>
  666. /// Restarts this instance.
  667. /// </summary>
  668. public override async Task Restart()
  669. {
  670. if (!CanSelfRestart)
  671. {
  672. throw new InvalidOperationException("The server is unable to self-restart. Please restart manually.");
  673. }
  674. try
  675. {
  676. await SessionManager.SendServerRestartNotification(CancellationToken.None).ConfigureAwait(false);
  677. }
  678. catch (Exception ex)
  679. {
  680. Logger.ErrorException("Error sending server restart notification", ex);
  681. }
  682. Logger.Debug("Calling NativeApp.Restart");
  683. NativeApp.Restart();
  684. }
  685. /// <summary>
  686. /// Gets or sets a value indicating whether this instance can self update.
  687. /// </summary>
  688. /// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>
  689. public override bool CanSelfUpdate
  690. {
  691. get
  692. {
  693. #if DEBUG
  694. return false;
  695. #endif
  696. #pragma warning disable 162
  697. return NativeApp.CanSelfUpdate;
  698. #pragma warning restore 162
  699. }
  700. }
  701. /// <summary>
  702. /// Gets the composable part assemblies.
  703. /// </summary>
  704. /// <returns>IEnumerable{Assembly}.</returns>
  705. protected override IEnumerable<Assembly> GetComposablePartAssemblies()
  706. {
  707. var list = GetPluginAssemblies()
  708. .ToList();
  709. // Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that
  710. // This will prevent the .dll file from getting locked, and allow us to replace it when needed
  711. // Include composable parts in the Api assembly
  712. list.Add(typeof(ApiEntryPoint).Assembly);
  713. // Include composable parts in the Dashboard assembly
  714. list.Add(typeof(DashboardService).Assembly);
  715. // Include composable parts in the Model assembly
  716. list.Add(typeof(SystemInfo).Assembly);
  717. // Include composable parts in the Common assembly
  718. list.Add(typeof(IApplicationHost).Assembly);
  719. // Include composable parts in the Controller assembly
  720. list.Add(typeof(IServerApplicationHost).Assembly);
  721. // Include composable parts in the Providers assembly
  722. list.Add(typeof(ProviderUtils).Assembly);
  723. // Common implementations
  724. list.Add(typeof(TaskManager).Assembly);
  725. // Server implementations
  726. list.Add(typeof(ServerApplicationPaths).Assembly);
  727. // MediaEncoding
  728. list.Add(typeof(MediaEncoder).Assembly);
  729. // Dlna
  730. list.Add(typeof(DlnaEntryPoint).Assembly);
  731. // Local metadata
  732. list.Add(typeof(AlbumXmlProvider).Assembly);
  733. // Xbmc
  734. list.Add(typeof(ArtistNfoProvider).Assembly);
  735. list.AddRange(NativeApp.GetAssembliesWithParts());
  736. // Include composable parts in the running assembly
  737. list.Add(GetType().Assembly);
  738. return list;
  739. }
  740. /// <summary>
  741. /// Gets the plugin assemblies.
  742. /// </summary>
  743. /// <returns>IEnumerable{Assembly}.</returns>
  744. private IEnumerable<Assembly> GetPluginAssemblies()
  745. {
  746. try
  747. {
  748. return Directory.EnumerateFiles(ApplicationPaths.PluginsPath, "*.dll", SearchOption.TopDirectoryOnly)
  749. .Select(LoadAssembly)
  750. .Where(a => a != null)
  751. .ToList();
  752. }
  753. catch (DirectoryNotFoundException)
  754. {
  755. return new List<Assembly>();
  756. }
  757. }
  758. /// <summary>
  759. /// Gets the system status.
  760. /// </summary>
  761. /// <returns>SystemInfo.</returns>
  762. public virtual SystemInfo GetSystemInfo()
  763. {
  764. return new SystemInfo
  765. {
  766. HasPendingRestart = HasPendingRestart,
  767. Version = ApplicationVersion.ToString(),
  768. IsNetworkDeployed = CanSelfUpdate,
  769. WebSocketPortNumber = HttpServerPort,
  770. SupportsNativeWebSocket = true,
  771. FailedPluginAssemblies = FailedAssemblies.ToList(),
  772. InProgressInstallations = InstallationManager.CurrentInstallations.Select(i => i.Item1).ToList(),
  773. CompletedInstallations = InstallationManager.CompletedInstallations.ToList(),
  774. Id = SystemId,
  775. ProgramDataPath = ApplicationPaths.ProgramDataPath,
  776. LogPath = ApplicationPaths.LogDirectoryPath,
  777. ItemsByNamePath = ApplicationPaths.ItemsByNamePath,
  778. InternalMetadataPath = ApplicationPaths.InternalMetadataPath,
  779. CachePath = ApplicationPaths.CachePath,
  780. MacAddress = GetMacAddress(),
  781. HttpServerPortNumber = HttpServerPort,
  782. OperatingSystem = OperatingSystemDisplayName,
  783. CanSelfRestart = CanSelfRestart,
  784. CanSelfUpdate = CanSelfUpdate,
  785. WanAddress = ConnectManager.WanApiAddress,
  786. HasUpdateAvailable = HasUpdateAvailable,
  787. SupportsAutoRunAtStartup = SupportsAutoRunAtStartup,
  788. TranscodingTempPath = ApplicationPaths.TranscodingTempPath,
  789. IsRunningAsService = IsRunningAsService,
  790. SupportsRunningAsService = SupportsRunningAsService,
  791. ServerName = FriendlyName,
  792. LocalAddress = GetLocalIpAddress()
  793. };
  794. }
  795. /// <summary>
  796. /// Gets the local ip address.
  797. /// </summary>
  798. /// <returns>System.String.</returns>
  799. private string GetLocalIpAddress()
  800. {
  801. // Return the first matched address, if found, or the first known local address
  802. var address = HttpServerIpAddresses.FirstOrDefault();
  803. if (!string.IsNullOrWhiteSpace(address))
  804. {
  805. address = string.Format("http://{0}:{1}",
  806. address,
  807. ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(CultureInfo.InvariantCulture));
  808. }
  809. return address;
  810. }
  811. public IEnumerable<string> HttpServerIpAddresses
  812. {
  813. get
  814. {
  815. var localAddresses = NetworkManager.GetLocalIpAddresses()
  816. .ToList();
  817. var httpServerAddresses = HttpServer.LocalEndPoints
  818. .Select(i => i.Split(':').FirstOrDefault())
  819. .Where(i => !string.IsNullOrEmpty(i))
  820. .ToList();
  821. // Cross-check the local ip addresses with addresses that have been received on with the http server
  822. var matchedAddresses = httpServerAddresses
  823. .Where(i => localAddresses.Contains(i, StringComparer.OrdinalIgnoreCase))
  824. .ToList();
  825. if (matchedAddresses.Count == 0)
  826. {
  827. return localAddresses;
  828. }
  829. return matchedAddresses;
  830. }
  831. }
  832. public string FriendlyName
  833. {
  834. get
  835. {
  836. return string.IsNullOrWhiteSpace(ServerConfigurationManager.Configuration.ServerName)
  837. ? Environment.MachineName
  838. : ServerConfigurationManager.Configuration.ServerName;
  839. }
  840. }
  841. public int HttpServerPort
  842. {
  843. get { return ServerConfigurationManager.Configuration.HttpServerPortNumber; }
  844. }
  845. /// <summary>
  846. /// Gets the mac address.
  847. /// </summary>
  848. /// <returns>System.String.</returns>
  849. private string GetMacAddress()
  850. {
  851. try
  852. {
  853. return NetworkManager.GetMacAddress();
  854. }
  855. catch (Exception ex)
  856. {
  857. Logger.ErrorException("Error getting mac address", ex);
  858. return null;
  859. }
  860. }
  861. /// <summary>
  862. /// Shuts down.
  863. /// </summary>
  864. public override async Task Shutdown()
  865. {
  866. try
  867. {
  868. await SessionManager.SendServerShutdownNotification(CancellationToken.None).ConfigureAwait(false);
  869. }
  870. catch (Exception ex)
  871. {
  872. Logger.ErrorException("Error sending server shutdown notification", ex);
  873. }
  874. NativeApp.Shutdown();
  875. }
  876. /// <summary>
  877. /// Registers the server with administrator access.
  878. /// </summary>
  879. private void RegisterServerWithAdministratorAccess()
  880. {
  881. Logger.Info("Requesting administrative access to authorize http server");
  882. try
  883. {
  884. NativeApp.AuthorizeServer(
  885. ServerConfigurationManager.Configuration.HttpServerPortNumber,
  886. HttpServerUrlPrefixes.First(),
  887. UdpServerEntryPoint.PortNumber,
  888. ConfigurationManager.CommonApplicationPaths.TempDirectory);
  889. }
  890. catch (Exception ex)
  891. {
  892. Logger.ErrorException("Error authorizing server", ex);
  893. }
  894. }
  895. public event EventHandler HasUpdateAvailableChanged;
  896. private bool _hasUpdateAvailable;
  897. public bool HasUpdateAvailable
  898. {
  899. get { return _hasUpdateAvailable; }
  900. set
  901. {
  902. var fireEvent = value && !_hasUpdateAvailable;
  903. _hasUpdateAvailable = value;
  904. if (fireEvent)
  905. {
  906. EventHelper.FireEventIfNotNull(HasUpdateAvailableChanged, this, EventArgs.Empty, Logger);
  907. }
  908. }
  909. }
  910. /// <summary>
  911. /// Checks for update.
  912. /// </summary>
  913. /// <param name="cancellationToken">The cancellation token.</param>
  914. /// <param name="progress">The progress.</param>
  915. /// <returns>Task{CheckForUpdateResult}.</returns>
  916. public override async Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
  917. {
  918. var availablePackages = await InstallationManager.GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false);
  919. var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, _remotePackageName, null, ApplicationVersion, ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
  920. var versionObject = version == null || string.IsNullOrWhiteSpace(version.versionStr) ? null : new Version(version.versionStr);
  921. var isUpdateAvailable = versionObject != null && versionObject > ApplicationVersion;
  922. var result = versionObject != null ?
  923. new CheckForUpdateResult { AvailableVersion = versionObject.ToString(), IsUpdateAvailable = isUpdateAvailable, Package = version } :
  924. new CheckForUpdateResult { AvailableVersion = ApplicationVersion.ToString(), IsUpdateAvailable = false };
  925. HasUpdateAvailable = result.IsUpdateAvailable;
  926. if (result.IsUpdateAvailable)
  927. {
  928. Logger.Info("New application version is available: {0}", result.AvailableVersion);
  929. }
  930. return result;
  931. }
  932. /// <summary>
  933. /// Updates the application.
  934. /// </summary>
  935. /// <param name="package">The package that contains the update</param>
  936. /// <param name="cancellationToken">The cancellation token.</param>
  937. /// <param name="progress">The progress.</param>
  938. /// <returns>Task.</returns>
  939. public override async Task UpdateApplication(PackageVersionInfo package, CancellationToken cancellationToken, IProgress<double> progress)
  940. {
  941. await InstallationManager.InstallPackage(package, progress, cancellationToken).ConfigureAwait(false);
  942. HasUpdateAvailable = false;
  943. OnApplicationUpdated(package);
  944. }
  945. /// <summary>
  946. /// Configures the automatic run at startup.
  947. /// </summary>
  948. /// <param name="autorun">if set to <c>true</c> [autorun].</param>
  949. protected override void ConfigureAutoRunAtStartup(bool autorun)
  950. {
  951. if (SupportsAutoRunAtStartup)
  952. {
  953. NativeApp.ConfigureAutoRun(autorun);
  954. }
  955. }
  956. }
  957. }