public AppShellModule( IAppServices aFullPrivilegeAppServices, IConfigFileCollection aConfiguration, IXappServer aXappServer, string aNodeGuid) { string storePath = aConfiguration.GetElementValueAsFilepath(e=>e.Element("system-settings").Element("store")); if (storePath == null) { storePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "store"); } DefaultStoreDirectory storeDirectory = new DefaultStoreDirectory(storePath); string installBase = aConfiguration.GetElementValueAsFilepath(e=>e.Element("system-settings").Element("installed-apps")); if (installBase == null) { installBase = Path.Combine(storePath, DefaultAppsDirectory); } string systemAppConfigDir = aConfiguration.GetElementValueAsFilepath(e => e.Element("system-settings").Element("system-app-config")); IConfigFileCollection systemAppsConfig; if (!string.IsNullOrEmpty(systemAppConfigDir)) { systemAppsConfig = ConfigFileCollection.ReadDirectoryInOrder(new DirectoryInfo(systemAppConfigDir), "*.xml"); } else { systemAppsConfig = new NullConfigFileCollection(); } DefaultAppsDirectory appsDirectory = new DefaultAppsDirectory(installBase); DefaultZipReader zipReader = new DefaultZipReader(); //DefaultAddinManager addinManager = new DefaultAddinManager(installBase, installBase, installBase); var addinManager = new MefAddinManager(appsDirectory); AppMetadataStore appMetadataStore = new AppMetadataStore(new DirectoryInfo(Path.Combine(storePath, "_installed"))); ZipVerifier zipVerifier = new ZipVerifier(zipReader); AppShell = new AppShell( aFullPrivilegeAppServices, aConfiguration, addinManager, appsDirectory, storeDirectory, (aDevice, aAppName, aAppIconUri, aAppDescriptionUri)=> new ProviderApp( aDevice, aNodeGuid, String.Format("/{0}/Upnp/Resources/", aNodeGuid), aAppName, aAppIconUri, aAppDescriptionUri), zipReader, appMetadataStore, zipVerifier, new SystemAppsConfiguration(systemAppsConfig), aXappServer, false); }
public AppContext( IAppServices aServices, string aStaticPath, string aStorePath, IConfigFileCollection aConfiguration, DvDevice aDevice, string aAppName, IXappServer aXappServer ) { iXappServer = aXappServer; Services = aServices; StaticPath = aStaticPath; StorePath = aStorePath; Configuration = aConfiguration; Device = aDevice; Name = aAppName; }
public AppShellImpl( IAppServices aFullPrivilegeAppServices, IConfigFileCollection aConfiguration, IAddinManager aAddinManager, IAppsDirectory aAppsDirectory, IStoreDirectory aStoreDirectory, Func<DvDevice, string, string, string, IDvProviderOpenhomeOrgApp1> aAppProviderConstructor, IZipReader aZipReader, IAppMetadataStore aMetadataStore, IZipVerifier aZipVerifier, ISystemAppsConfiguration aSystemAppsConfiguration, IXappServer aXappServer, bool aAutoStart) { iFullPrivilegeAppServices = aFullPrivilegeAppServices; iZipVerifier = aZipVerifier; iXappServer = aXappServer; //iZipReader = aZipReader; iMetadataStore = aMetadataStore; iConfiguration = aConfiguration; iAddinManager = aAddinManager; iAppsDirectory = aAppsDirectory; iStoreDirectory = aStoreDirectory; iAppProviderConstructor = aAppProviderConstructor; iNodeRebooter = iFullPrivilegeAppServices.NodeRebooter; //iApps = new Dictionary<string, PublishedApp>(); iHistory = new List<HistoryItem>(); // !!!! restore previous history from disk iKnownApps = new Dictionary<string, KnownApp>(); foreach (var app in iMetadataStore.LoadAppsFromStore()) { GetOrCreateKnownApp(app.AppName); } foreach (string dirname in iAppsDirectory.GetAppSubdirectories()) { GetOrCreateKnownApp(dirname); } MarkSystemApps(aSystemAppsConfiguration); if (aAutoStart) { Start(); } }
/// <summary> /// Create an app shell. Hosted apps are not automatically started. /// </summary> /// <param name="aFullPrivilegeAppServices"> /// Services that will be provided to apps granted permissions. /// (If we implement restricted permissions, such apps would /// receive only a subset of these services.) /// </param> /// <param name="aConfiguration"> /// Parsed config files. Some pre-installed apps need to read /// configuration information (such as location of serial devices) /// from these files. /// </param> /// <param name="aAddinManager"> /// Interface to the addin manager that handles actual loading of /// plugins. (Currently we use MEF.) /// </param> /// <param name="aAppsDirectory"> /// Interface to inspect and manipulate the apps directory, where /// we put app binaries and their static data. /// </param> /// <param name="aStoreDirectory"> /// Interface to inspect and manipulate the store directory, where /// apps store their dynamic, persistent data. /// </param> /// <param name="aAppProviderConstructor"> /// Constructor to create an AppProvider. The AppShell is responsible /// for creating a device for each app and publishing the app service /// on that device on behalf of the app, and it uses this to construct /// such a provider. (Unit tests need to be able to pass in a /// substitute here. /// </param> /// <param name="aZipReader"> /// Reads entries from a zip file. /// </param> /// <param name="aAppMetadataStore"> /// Stores persistent data about apps, such as deferred deletions or /// upgrades. /// </param> /// <param name="aZipVerifier"> /// Verifies that a zip file contains a valid OpenHome app. /// </param> /// <param name="aAutoStart"> /// If true, start the AppShell immediately. Otherwise, caller needs /// to call Start() when they want to start apps. /// </param> public AppShell( IAppServices aFullPrivilegeAppServices, IConfigFileCollection aConfiguration, IAddinManager aAddinManager, IAppsDirectory aAppsDirectory, IStoreDirectory aStoreDirectory, Func<DvDevice, string, string, string, IDvProviderOpenhomeOrgApp1> aAppProviderConstructor, IZipReader aZipReader, IAppMetadataStore aAppMetadataStore, IZipVerifier aZipVerifier, ISystemAppsConfiguration aSystemAppsConfiguration, IXappServer aXappServer, bool aAutoStart) { lock (iLock) { iImpl = new AppShellImpl( aFullPrivilegeAppServices, aConfiguration, aAddinManager, aAppsDirectory, aStoreDirectory, aAppProviderConstructor, aZipReader, aAppMetadataStore, aZipVerifier, aSystemAppsConfiguration, aXappServer, aAutoStart); iImpl.AppStatusChanged += OnAppStatusChanged; } }