ApplicationHost.cs 47 KB

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