public Tuple<bool, string> StartDriverForDevice(Device device, List<string> driverParams) { if (device.DriverBinaryName.Equals("")) { return new Tuple<bool, string>(false, "Driver not specified"); } string driverFriendlyName = device.DriverBinaryName + " for " + device.FriendlyName; string driverAppName = "driver for " + device.FriendlyName; ModuleInfo moduleInfo = new ModuleInfo(driverFriendlyName, driverAppName, device.DriverBinaryName, null, true, driverParams.ToArray()); // this will be set in StartModule -- why set here //moduleInfo.SetWorkingDir(Environment.CurrentDirectory + "\\" + moduleInfo.FriendlyName()); moduleInfo.SetManifest(new Manifest()); moduleInfo.Background = true; StartModule(moduleInfo); //add the module to the configuration and update details for the device //these changes are written to disk config.AddModule(moduleInfo); config.UpdateDeviceDetails(device.UniqueName, true, driverFriendlyName); return new Tuple<bool, string>(true, "Added driver module"); }
public List<string> InstallAppWeb(string appName) { try { logger.Log("UICalled:InstallAppWeb " + appName); HomeStoreApp app = homeStoreInfo.GetHomeStoreAppByName(appName); if (app == null) { logger.Log("HomeStore app {0} was not found", appName); return new List<string>() { "HomeStore app not found" }; } //by default, we make the app auto start ModuleInfo moduleInfo = new ModuleInfo(app.AppName, app.AppName, app.BinaryName, null, true); moduleInfo.SetManifest(app.Manifest); if (String.IsNullOrWhiteSpace(app.Version)) moduleInfo.SetRunningVersion(Common.Constants.UnknownHomeOSUpdateVersionValue); else moduleInfo.SetRunningVersion(app.Version); AccessRule accessRule = new AccessRule(); accessRule.ModuleName = moduleInfo.FriendlyName(); accessRule.RuleName = "Access for " + moduleInfo.FriendlyName(); accessRule.UserGroup = "everyone"; accessRule.AccessMode = AccessMode.Allow; accessRule.DeviceList = new List<string> { "*" }; accessRule.TimeList = new List<TimeOfWeek> { new TimeOfWeek(-1, 0, 2400) }; accessRule.Priority = 0; platform.AddAccessRule(accessRule); //we now call startmodule: if we don't already have the binaries, this will download them as well var startedModule = platform.StartModule(moduleInfo, true); if (startedModule != null) { //add this to our configuration config.AddModule(moduleInfo); return new List<string>() { "" }; } else { //remove the rule we just added, since we are not starting the module platform.RemoveAccessRulesForModule(moduleInfo.FriendlyName()); return new List<string>() { "Could not start module. Perhaps because we didn't find the right binaries" }; } } catch (Exception e) { logger.Log("Exception in InstallAppWeb: " + e.ToString()); return new List<string>() { "Got exception: " + e.Message }; } }
private void ReadModuleList() { string fileName = ModulesFile; XmlDocument xmlDoc = new XmlDocument(); XmlReader xmlReader = XmlReader.Create(fileName, xmlReaderSettings); xmlDoc.Load(xmlReader); XmlElement root = xmlDoc.FirstChild as XmlElement; if (!root.Name.Equals("Modules")) throw new Exception(fileName + " doesn't start with Modules"); foreach (XmlElement xmlModule in root.ChildNodes) { if (!xmlModule.Name.Equals("Module")) throw new Exception("child is not a Module in " + fileName); string name = xmlModule.GetAttribute("FriendlyName"); string appName = xmlModule.GetAttribute("AppName"); string binaryName = xmlModule.GetAttribute("BinaryName"); string workingDir = xmlModule.GetAttribute("WorkingDir"); string autoStartStr = xmlModule.GetAttribute("AutoStart"); string backgroundStr = xmlModule.GetAttribute("Background"); string version = xmlModule.GetAttribute("Version"); string argStr = xmlModule.GetAttribute("ModuleArgStr"); if (!argStr.Equals("")) throw new Exception("module arguments are being supplied in old-fashioned way"); //string[] words = argStr.Split(" "); if (workingDir.Equals("")) workingDir = null; bool autoStart = (autoStartStr.Equals("1")) ? true : false; bool background = (backgroundStr.Equals("1")) ? true : false; string[] words = ReadModuleArguments(xmlModule); ModuleInfo moduleInfo = new ModuleInfo(name, appName, binaryName, workingDir, autoStart, words); moduleInfo.Background = background; // now lets set the version. if the version is missing in the xml file set it as UnknownHomeOSUpdateVersionValue(0.0.0.0) if(string.IsNullOrWhiteSpace(version)) moduleInfo.SetDesiredVersion(Constants.UnknownHomeOSUpdateVersionValue); else moduleInfo.SetDesiredVersion(version); //now let's attach the manifest Manifest manifest = ReadManifest(xmlModule); moduleInfo.SetManifest(manifest); AddModule(moduleInfo, false); } xmlReader.Close(); }