Ejemplo n.º 1
0
        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 };
            }
        }
Ejemplo n.º 2
0
        private Dictionary<string,bool> AvailableOnRep(ModuleInfo moduleInfo)
        {
            string[] URIs = Settings.RepositoryURIs.Split('|'); 
            String[] path = moduleInfo.BinaryName().Split('.');
            Dictionary<string, bool> retval = new Dictionary<string,bool>();

            foreach (string uri in URIs)
            {
                //logger.Log("Checking " + moduleInfo.BinaryName() + " v" + moduleInfo.GetVersion() + "  availability on Rep: " + uri);

                //string zipuri = uri +'/' + path[0] + '/' + path[1] + '/' + path[2] + '/' + path[3] + '/' + moduleInfo.GetVersion() + '/' + moduleInfo.BinaryName() + ".zip";

                string zipuri = uri;

                foreach (string pathElement in path)
                    zipuri += "/" + pathElement;


                //by default platform should point to the Latest on the repository if a version of the binary isn't specified

                string binaryversion = "Latest";

                if (moduleInfo.GetDesiredVersion() != null && moduleInfo.GetDesiredVersion() != "0.0.0.0")
                {
                    binaryversion = moduleInfo.GetDesiredVersion();
                }

                zipuri += '/' + binaryversion + '/' + moduleInfo.BinaryName() + ".zip";

                if (UrlIsValid(zipuri))
                {
                    retval[zipuri]=true;
                    return retval;
                }
            }
            retval[""] = false;
            return retval;
        }
Ejemplo n.º 3
0
        public void ConfiguredStart()
        {

            guiService.ConfiguredStart();

            //initialize the scout helper; needed for scouts that rely on upnp discovery
            ScoutHelper.Init(logger);

            //start the configured scouts. starting scouts before modules.
            foreach (var sInfo in config.GetAllScouts())
            {
                StartScout(sInfo);
            }

            //start the heartbeat service (directly writes to cloud)
            if (Settings.HeartbeatServiceMode != "Off")
            {
                InitHeartbeatService();
            }

            //config updater
            if(this.configLookup==null)
            {
                ConfigUpdater configLookup = null;
                LoadConfig loadNewConfig = this.LoadConfigFromDir;

                configLookup = new ConfigUpdater(null, logger, Settings.ConfigLookupFrequency, loadNewConfig, this);
                this.configLookup = configLookup;
                if (this.configLookup != null)
                {
                    this.configLookup.setConfig(this.config);
                }

            }

            // start the authentication service
            {
                authenticationService = new HomeOS.Hub.Platform.Authentication.AuthenticationService(logger, this);
                authenticationServiceHost = HomeOS.Hub.Platform.Authentication.AuthenticationService.CreateServiceHost(logger, this, authenticationService);
                authenticationServiceHost.Open();
            }

            InitHomeService();

            if (Settings.RunningMode.Equals("standard"))
            {
                InitAutoStartModules();
            }
            else
            #region developers' running modes
            {
                if (Settings.RunningMode.Equals("unittesting"))
                {

                    // don't start any modules, we just need a module-less platform to initialize the module (app/device)
                    // being unit tested
                }
                else if (Settings.RunningMode.Equals("ratul"))
                {
                    //StartModule(new ModuleInfo("axiscamdriver", "DriverAxisCamera", "DriverAxisCamera", null, false, "192.168.0.198", "root", "homeos"));
                    //StartModule(new ModuleInfo("foscamdriver1", "DriverFoscam", "HomeOS.Hub.Drivers.Foscam", null, false, "192.168.1.125", "admin", ""));
                    
                    StartModule(new ModuleInfo("webcamdriver", "DriverWebCam", "HomeOS.Hub.Drivers.WebCam", null, false, @"Microsoft® LifeCam VX-7000"));
                    StartModule(new ModuleInfo("AppCam", "AppCamera", "HomeOS.Hub.Apps.SmartCam", null, false));

                    //string para1 = "C:\\Users\\t-chuchu\\Desktop\\homeos\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera1.txt";
                    //string para2 = "C:\\Users\\t-chuchu\\Desktop\\homeos\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera2.txt";
                    //StartModule(new ModuleInfo("trackingapp", "AppTracking", "AppTracking", null, false, para1, para2));                   

                    //StartModule(new ModuleInfo("HomeOS.Hub.Drivers.Gadgeteer.MicrosoftResearch.WindowCamera for HomeOSGadgeteerDevice_WindowCamera_MicrosoftResearch_65355695098562951548", "DriverGadgetCamera", "HomeOS.Hub.Drivers.Gadgeteer.MicrosoftResearch.WindowCamera", null, false, "192.168.0.197"));

                    //StartModule(new ModuleInfo("zwavezensys", "DriverZwaveZensys", "HomeOS.Hub.Drivers.ZwaveZensys_4_55", null, false));
                    //StartModule(new ModuleInfo("switchapp", "AppSwitch", "HomeOS.Hub.Apps.Switch", null, false));

                    //StartModule(new ModuleInfo("alerts", "AppAlerts", "HomeOS.Hub.Apps.Alerts", null, false));

                    //StartModule(new ModuleInfo("foscamdriver1", "DriverFoscam", "HomeOS.Hub.Drivers.Foscam", null, false, "192.168.1.125", "admin", ""));

                    //StartModule(new ModuleInfo("AppDummy1", "AppDummy1", "HomeOS.Hub.Apps.Dummy", null, false, null));
                    //StartModule(new ModuleInfo("DriverDummy1", "DriverDummy1", "HomeOS.Hub.Drivers.Dummy", null, false, null));
                }
                else if (Settings.RunningMode.Equals("rayman"))
                {
                    ModuleInfo d = new ModuleInfo("HomeOS.Hub.Drivers.Mic", "HomeOS.Hub.Drivers.Mic", "HomeOS.Hub.Drivers.Mic", null, false,"foo", "8000", "1" );
                    StartModule(d);

                    /*
                    HomeOS.Hub.Platform.Authentication.AuthenticationService auth = new HomeOS.Hub.Platform.Authentication.AuthenticationService(logger, this);
                    System.ServiceModel.ServiceHost s = HomeOS.Hub.Platform.Authentication.AuthenticationService.CreateServiceHost(logger, this, auth);
                    s.Open();


                    ModuleInfo app = new ModuleInfo("AppDummy1", "AppDummy1", "HomeOS.Hub.Apps.Dummy", null, false, null);
                    StartModule(app);
                    ModuleInfo app1 = new ModuleInfo("DriverDummy1", "DriverDummy1", "HomeOS.Hub.Drivers.Dummy", null, false, null);
                    StartModule(app1);
                    
                    HomeOS.Hub.Common.TokenHandler.SafeTokenHandler t = new Common.TokenHandler.SafeTokenHandler("randomsalt");
                    string s1 = t.GenerateToken("helloworlergwergwergwergwergwegrwegewgewrgwergwregwgwgd"); 
                    logger.Log("Encryting helloworld: "+s1);
                    t = null;
                    t = new Common.TokenHandler.SafeTokenHandler("randomsalt");
                    logger.Log("decrypting token: " + t.ProcessToken(s1).Name);*/


                    //    DateTime t = policyEngine.AllowAccess("*","AppDummy1", "jeff");
                    //    logger.Log(">>>>>>>>>>> " + t.ToString()+ "  , " + DateTime.Now);


                    // Dont touch my running mode
                    /*
                     AddInToken t =  null ; 
                         foreach (AddInToken token in allAddinTokens)
                         {
                             if (token.Name.Equals("HomeOS.Hub.Drivers.Dummy") )
                             {
                                 t = token ; 
                             }
                         }
                         VModule a = t.Activate<VModule>(AddInSecurityLevel.FullTrust);
                      ModuleInfo info = new ModuleInfo("friendlyName", "moduleName", "moduleName", null, false, null);
                         AddInController aic = AddInController.GetAddInController(a);
                         a.Initialize(this, logger,info, 0);
                         SafeThread moduleThread = new SafeThread(delegate() { a.Start(); },"", logger);
                         moduleThread.Start();
                         System.Threading.Thread.Sleep(1 * 11 * 1000);
                         aic.Shutdown();
                    

                     ModuleInfo[] app = new ModuleInfo[100];
                     int i;
                     for (i = 0; i < 30; i++)
                     {
                         app[i] = new ModuleInfo("AppDummy"+i.ToString(), "AppDummy"+i.ToString(), "HomeOS.Hub.Apps.Dummy", null, false, null);
                         StartModule(app[i]);
                     }
            

                 

                     ModuleInfo[] driver = new ModuleInfo[3000]; 
                     int j;
                     for (j = 0; j <30; j++)
                     {
                         driver[j] = new ModuleInfo("DriverDummy"+j.ToString(), "DriverDummy"+j.ToString(), "HomeOS.Hub.Drivers.Dummy", null, false, null);
                         StartModule(driver[j]);
                     }
            
                     System.Threading.Thread.Sleep(1 * 20 * 1000);
                    
                     
                     for (j = 29; j >=0; j--)
                     {
                         StopModule(runningModules.First(x => x.Value.Equals(driver[j])).Key.Secret());

                     }
                     for (i = 29;i >= 1; i--)
                     {
                         StopModule(runningModules.First(x => x.Value.Equals(app[j])).Key.Secret());

                     }
          */


                }
                else if (Settings.RunningMode.Equals("chunte"))
                {
                    //StartModule(new ModuleInfo("webcamdriver", "DriverWebCam", "DriverWebCam", null, false, "logitech"));
                    //StartModule(new ModuleInfo("foscamdriver", "DriverFoscam", "DriverFoscam", null, false, "192.168.0.196", "admin", "whoareyou?"));
                    //StartModule(new ModuleInfo("foscamdriver", "DriverFoscam", "DriverFoscam", null, false, "172.31.42.177", "admin", ""));
                    string video1 = "c:\\img\\cam2_20120821165455_test1.avi";
                    string video2 = "c:\\img\\DSCN7066_test1.avi";
                    StartModule(new ModuleInfo("loadvideo1", "DriverVideoLoading", "DriverVideoLoading", null, false, video1));
                    StartModule(new ModuleInfo("loadvideo2", "DriverVideoLoading", "DriverVideoLoading", null, false, video2));
                    //StartModule(new ModuleInfo("cameraapp", "AppCamera", "AppCamera", null, false));

                    string para1 = "C:\\Users\\t-chuchu\\Desktop\\homeos\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera1.txt";
                    string para2 = "C:\\Users\\t-chuchu\\Desktop\\homeos\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera2.txt";
                    StartModule(new ModuleInfo("trackingapp", "AppTracking", "AppTracking", null, false, para1, para2));
                }
                else if (Settings.RunningMode.Contains("khurshed"))
                {
                    if (Settings.RunningMode.Equals("khurshed_test_smartcam_foscam"))
                    {
                        StartModule(new ModuleInfo("foscamdriver2", "DriverFoscam", "HomeOS.Hub.Drivers.Foscam", null, false, "157.54.148.65", "admin", ""));
                        StartModule(new ModuleInfo("SmartCamApp", "AppSmartCam", "HomeOS.Hub.Apps.SmartCam", null, false));
                    }
                    else if (Settings.RunningMode.Equals("khurshed_test_smartcam_foscam_notifications"))
                    {
                        StartModule(new ModuleInfo("foscamdriver2", "DriverFoscam", "DriverFoscam", null, false, "157.54.148.65", "admin", ""));
                        StartModule(new ModuleInfo("SmartCamApp", "AppSmartCam", "AppSmartCam", null, false));
                    }
                    else if (Settings.RunningMode.Equals("khurshed_test_smartcam_webcam"))
                    {
                        StartModule(new ModuleInfo("webcamdriver", "DriverWebCam", "DriverWebCam", null, false, "Logitech QuickCam Pro 9000"));
                        StartModule(new ModuleInfo("SmartCamApp", "AppSmartCam", "AppSmartCam", null, false));
                    }
                    else if (Settings.RunningMode.Equals("khurshed_test_smartcam_foscam_webcam"))
                    {
                        StartModule(new ModuleInfo("webcamdriver", "DriverWebCam", "DriverWebCam", null, false, "Logitech QuickCam Pro 9000"));
                        StartModule(new ModuleInfo("foscamdriver2", "DriverFoscam", "DriverFoscam", null, false, "157.54.148.65", "admin", ""));
                        StartModule(new ModuleInfo("SmartCamApp", "AppSmartCam", "AppSmartCam", null, false));
                    }
                    else if (Settings.RunningMode.Equals("khurshed_test_tracking_foscam"))
                    {
                        string para1 = "C:\\homeos2\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera1.txt";
                        string para2 = "C:\\homeos2\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera2.txt";
                        StartModule(new ModuleInfo("foscamdriver2", "DriverFoscam", "DriverFoscam", null, false, "157.54.148.65", "admin", ""));
                        StartModule(new ModuleInfo("trackingapp", "AppTracking", "AppTracking", null, false, para1, para2));
                    }
                    else if (Settings.RunningMode.Equals("khurshed_test_tracking_videoloading"))
                    {
                        string video1 = "c:\\img\\cam2_20120821165455_test1.avi";
                        string video2 = "c:\\img\\DSCN7066_test1.avi";
                        StartModule(new ModuleInfo("loadvideo1", "DriverVideoLoading", "DriverVideoLoading", null, false, video1));
                        StartModule(new ModuleInfo("loadvideo2", "DriverVideoLoading", "DriverVideoLoading", null, false, video2));
                        string para1 = "C:\\homeos2\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera1.txt";
                        string para2 = "C:\\homeos2\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera2.txt";
                        StartModule(new ModuleInfo("trackingapp", "AppTracking", "AppTracking", null, false, para1, para2));
                    }
                }
                else if (Settings.RunningMode.Equals("jamie"))
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(new XmlTextReader(@"C:\homeos\LightSettings.xml"));

                    XmlNode xmlData = xmlDoc.SelectSingleNode("data");
                    string strLightsIP = xmlData.SelectSingleNode("lightsIP").InnerText;
                    string strLightsUser = xmlData.SelectSingleNode("lightsUser").InnerText;
                    string strfoscamIP = xmlData.SelectSingleNode("foscamIP").InnerText;
                    string strfoscamUser = xmlData.SelectSingleNode("foscamUser").InnerText;
                    string strLightCount = xmlData.SelectSingleNode("light_count").InnerText;

                    StartModule(new ModuleInfo("foscamdriver1", "DriverFoscam", "HomeOS.Hub.Drivers.Foscam", null, false, strfoscamIP, strfoscamUser, ""));
                    StartModule(new ModuleInfo("huedriver1", "HueBridge", "HomeOS.Hub.Drivers.HueBridge", null, false, strLightsIP, strLightsUser, strLightCount));
                    StartModule(new ModuleInfo("LightsHome1", "LightsHome", "HomeOS.Hub.Apps.LightsHome", null, false));
                }
                else if (Settings.RunningMode.Equals("sarah"))
                {
                    //Sarah to fill in the right device id
                    StartModule(new ModuleInfo("couchdriver", "DriverCouch", "HomeOS.Hub.Drivers.GadgetCouch", null, false, ".."));
                    StartModule(new ModuleInfo("couchapp", "EmotoCouch", "HomeOS.Hub.Apps.EmotoCouch", null, false));
                }
                else if (Settings.RunningMode.Equals("erin"))
                {
                    //app startup needed since it's not in the install repository
                    StartModule(new ModuleInfo("AppDoorjamb", "AppDoorjamb", "HomeOS.Hub.Apps.Doorjamb", null, false));
                }
                else
                {
                    throw new Exception("Unknown running mode: " + Settings.RunningMode);
                }

                //we ran using a non-standard running mode
                //make sure that the modules we ran are entered in the config, so that we can keep it consistent
                //otherwise, a service (port) will get added without its exporting module
                lock (this)
                {
                    foreach (ModuleInfo moduleInfo in runningModules.Values)
                    {
                        if (moduleInfo.GetManifest() == null)
                            moduleInfo.SetManifest(new Manifest());

                        config.AddModuleIfMissing(moduleInfo);
                    }
                }

            }
            #endregion


            if (String.IsNullOrEmpty(Settings.WifiSsid))
                logger.Log("Warning: WiFi credentials are not configured");

            if (!Settings.StayOffline)
            {
                //start checking for the uniqueness of home id on a separate thread
                SafeThread uniqueHomeIdCheck = new SafeThread(delegate()
                {
                    heartbeatService.CanIClaimHomeId(Utils.HardwareId, Settings.HomeId, UniqueHomeIdCheckCompleted);
                }, "UniqueHomeIdCheck", logger);

                uniqueHomeIdCheck.Start();
            }
        }
Ejemplo n.º 4
0
        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");
        }
Ejemplo n.º 5
0
        private bool GetAddInFromRep(ModuleInfo moduleInfo , bool rebuild = true)
        {

            Dictionary<string,bool> repAvailability = AvailableOnRep(moduleInfo) ; 
            if (!repAvailability.ContainsValue(true))
            {
                logger.Log("Can't find "+moduleInfo.BinaryName() + " v "+ moduleInfo.GetDesiredVersion()+" on any rep.");
                return false;
            }
                      
            // on fetching the binaries of a module existing older versions shall be overwritten
            // making sure older version module is not running.
            foreach (ModuleInfo runningModuleInfo in runningModules.Values)
            {
                if (runningModuleInfo.BinaryName().Equals(moduleInfo.BinaryName()))
                    throw new Exception(String.Format("Attempted to fetch module, with same binary name module running. Running: ({0}, v {1}) Fetching: ({2}, v{3})", runningModuleInfo.BinaryName(), runningModuleInfo.GetRunningVersion() , moduleInfo.BinaryName() , moduleInfo.GetDesiredVersion()));
            }

            //unloading addin
            AddInToken removeToken = null;
            foreach (AddInToken t in allAddinTokens)
            {
                if (t.Name.Equals(moduleInfo.BinaryName()))
                {
                    removeToken = t;
                    break;
                }
            }
            allAddinTokens.Remove(removeToken);
            removeToken = null;
            GC.Collect();
            try
            {
                CreateAddInDirectory(Constants.AddInRoot + "\\AddIns\\", moduleInfo.BinaryName());
                DownloadFile(repAvailability.FirstOrDefault(x => x.Value == true).Key, Constants.AddInRoot + "\\AddIns\\" + moduleInfo.BinaryName(), moduleInfo.BinaryName() + ".zip");
                UnpackZip(Constants.AddInRoot + "\\AddIns\\" + moduleInfo.BinaryName() + "\\" + moduleInfo.BinaryName() + ".zip", Constants.AddInRoot + "\\AddIns\\" + moduleInfo.BinaryName());
                if(rebuild)
                    rebuildAddInTokens();

                File.Delete(Constants.AddInRoot + "\\AddIns\\" + moduleInfo.BinaryName() + "\\" + moduleInfo.BinaryName() + ".zip");

            }
            catch (Exception e)
            {
                logger.Log("Exception : " + e);
                return false;
            }
            return true; 
        }
Ejemplo n.º 6
0
 // Ratul
 public void UninstallModule(ModuleInfo moduleInfo) {
     // TODO:
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Reads commands from console (some functionality might be out-of-date)
        /// </summary>
        private void ReadCommandsFromConsole()
        {
            Console.Out.WriteLine("Waiting for commands");
            string[] separators = new string[2] { " ", "\n" };

            while (true)
            {
                Console.Write("> ");

                try
                {
                    string input = Console.ReadLine();
                    string[] words = input.Split(separators, StringSplitOptions.RemoveEmptyEntries);

                    if (words.Length == 0) continue;

                    string command = words[0].ToLower();

                    switch (command)
                    {
                        case "quit":
                        case "exit":
                            Console.WriteLine("Auf Wiedersehen!\nLive Long and Prosper. ");
                            //this.Shutdown();
                            //System.Environment.Exit(0);
                            ForceShutdown();
                            break;
                        case "restart":
                            this.Restart();
                            break;
                        case "help":
                        case "?":
                            PrintInteractiveUsage();
                            break;
                        case "starthomeservice":
                            if (null != this.homeService)
                                this.homeService.Start(null);
                            break;
                        case "stophomeservice" :
                            if (null != this.homeService)
                                this.homeService.Stop();
                            break;
                            //***
                        case "loadconfig":
                            string configdir = words[1];
                            lock (Settings.ConfigDir)
                            {
                                Settings.SetParameter("ConfigDir", configdir);
                            }
                            this.LoadConfigFromDir(Settings.ConfigDir);
                            break; 
                            /*
                        case "loadaddins":
                            rebuildAddInTokens();
                            break;
                        case "unloadaddin":
                            string tokenName = words[1];
                            AddInToken removeToken =null; 
                            foreach (AddInToken t in allAddinTokens)
                                {
                                    if (t.Name.Equals(tokenName))
                                    {
                                        removeToken = t;
                                        break;
                                    }
                                }
                                allAddinTokens.Remove(removeToken);
                                removeToken = null;
                               // GC.Collect();

                            break;
                        case "getaddin":
                            string url = words[1];
                            string dirname = words[2];
                            this.CreateAddInDirectory(Globals.AddInRoot+"\\AddIns\\",dirname);
                            this.GetAddInZip(url, Globals.AddInRoot + "\\AddIns\\" + dirname, "newaddin.zip");
                            this.UnpackZip(Globals.AddInRoot + "\\AddIns\\" + dirname + "\\newaddin.zip", Globals.AddInRoot + "\\AddIns\\" + dirname);

                            break;
                            */
                        case "clear":
                            Console.Clear();
                            break;
                        case "stopallmodules":
                            this.StopAllModules();
                            break;
                            //***
                        case "startmodule":
                            {
                                string friendlyName = words[1];
                                string moduleName = words[2];

                                string[] moduleArgs = new string[words.Length - 3];
                                for (int index = 0; index < moduleArgs.Length; index++)
                                    moduleArgs[index] = words[index + 3];

                                ModuleInfo info = new ModuleInfo(friendlyName, moduleName, moduleName, null, false, moduleArgs);
                                StartModule(info);
                            }
                            break;
                        case "show":
                            {
                                string showWhat = words[1].ToLower();
                                switch (showWhat)
                                {
                                        //*** Adding new command that iterates over run-time states of running modules
                                    case "modulesstates":
                                        lock (this)
                                        {
                                            foreach (VModule module in runningModulesStates.Keys)
                                                Console.WriteLine("{0} state: {1} time: {2} runningverion: {3} desiredversion: {4}", module, (ModuleState.SimpleState)runningModulesStates[module].GetSimpleState(), runningModulesStates[module].GetTimestamp(), runningModules[module].GetRunningVersion(), runningModules[module].GetDesiredVersion());
                                        }
                                        break;
                                    case "addins": 
                                        lock (this)
                                        {
                                            foreach (AddInToken token in allAddinTokens)
                                            {
                                                Console.Write("AddInToken : {0}",token.Name.ToString()); 
                                             //   if(token.Version!=null)
                                                    // Console.Write(", Version: {0}", token.Version);
                                                    Console.Write(", Version: {0}", Utils.GetHomeOSUpdateVersion(Utils.GetAddInConfigFilepath(token.Name), logger));
                                              //  if(token.Publisher!=null)
                                                    Console.Write(", Publisher: {0}", token.Publisher);
                                               // if(token.AssemblyName!=null)
                                                    Console.Write(", Assembly: {0}", token.AssemblyName.Name);

                                                Console.WriteLine("");
                                            }
                                            break;
                                        }
                                    case "getconfsetting":
                                        lock (this)
                                        {
                                            string parameter = words[2];
                                            Console.WriteLine(GetConfSetting(parameter));
                                        }
                                        break;
                                    case "configdir":
                                        lock (this)
                                        {
                                            Console.WriteLine(Settings.ConfigDir);
                                        }
                                        break;
                                        //***
                                    case "ports":
                                        lock (this)
                                        {
                                            foreach (VPort port in registeredPorts.Keys)
                                                Console.WriteLine("{0} {1}", port.GetInfo(), registeredPorts[port]);
                                        }
                                        break;
                                    case "modules":
                                        lock (this)
                                        {
                                            foreach (VModule module in runningModules.Keys)
                                                Console.WriteLine(module.Secret() + " " + runningModules[module] + " " +runningModules[module].GetRunningVersion());
                                        }
                                        break;
                                    case "resourceusage":
                                        {
                                            if (null != heartbeatService)
                                            {
                                                HomeOS.Shared.HeartbeatInfo hbi = heartbeatService.GetPlatformHeartBeatInfo();
                                                if (null != hbi)
                                                    Console.WriteLine(hbi.ToString());
                                            }
                                        }
                                        break;
                                    default:
                                        Console.WriteLine("unknown show command " + words[1]);
                                        break;
                                }
                            }
                            break;
                        case "sendemail":
                            {
                                string dest = words[1];
                                string subject = "homeos testing";
                                string body = "This should be fine, cheers";
                                string mimeType = "image/jpeg";
                                List<Attachment> attachmentList = new List<Attachment>();                                
                                Attachment attachment = new Attachment(new MemoryStream(Common.Utils.CreateTestJpegImage(10,10,9,9,30)), "test.jpg", mimeType);
                                attachmentList.Add(attachment);

                                Tuple<bool,string> result = Utils.SendEmail(dest, subject, body, attachmentList, this, logger);
                                logger.Log("result of email: Succeeded = " + result.Item1 + " " + "Message=" + result.Item2);
                            }
                            break;
                        case "sendhubemail":
                            {
                                string dest = words[1];
                                string subject = "homeos testing";
                                string body = "This should be fine, cheers";
                                string mimeType = "image/jpeg";
                                List<Attachment> attachmentList = new List<Attachment>();
                                Attachment attachment1 = new Attachment(new MemoryStream(Common.Utils.CreateTestJpegImage(10, 10, 3, 3, 30)), "test1.jpg", mimeType);
                                Attachment attachment2 = new Attachment(new MemoryStream(Common.Utils.CreateTestJpegImage(10, 10, 4, 4, 30)), "test2.jpg", mimeType);
                                Attachment attachment3 = new Attachment(new MemoryStream(Common.Utils.CreateTestJpegImage(10, 10, 5, 5, 30)), "test3.jpg", mimeType);
                                Attachment attachment4 = new Attachment(new MemoryStream(Common.Utils.CreateTestJpegImage(10, 10, 6, 6, 30)), "test4.jpg", mimeType);
                                Attachment attachment5 = new Attachment(new MemoryStream(Common.Utils.CreateTestJpegImage(10, 10, 7, 7, 30)), "test5.jpg", mimeType);
                                attachmentList.Add(attachment1);
                                attachmentList.Add(attachment2);
                                attachmentList.Add(attachment3);
                                attachmentList.Add(attachment4);
                                attachmentList.Add(attachment5);

                                Tuple<bool, string> result = Utils.SendHubEmail(dest, subject, body, attachmentList, this, logger);
                                logger.Log("result of email: Succeeded = " + result.Item1 + " " + "Message=" + result.Item2);
                            }
                            break;
                        case "sendcloudemail":
                            {
                                string dest = words[1];
                                string subject = "homeos testing";
                                string body = "This should be fine, cheers";
                                string mimeType = "image/jpeg";
                                List<Attachment> attachmentList = new List<Attachment>();
                                Attachment attachment1 = new Attachment(new MemoryStream(Common.Utils.CreateTestJpegImage(10, 10, 3, 3, 30)), "test1.jpg", mimeType);
                                Attachment attachment2 = new Attachment(new MemoryStream(Common.Utils.CreateTestJpegImage(10, 10, 4, 4, 30)), "test2.jpg", mimeType);
                                Attachment attachment3 = new Attachment(new MemoryStream(Common.Utils.CreateTestJpegImage(10, 10, 5, 5, 30)), "test3.jpg", mimeType);
                                Attachment attachment4 = new Attachment(new MemoryStream(Common.Utils.CreateTestJpegImage(10, 10, 6, 6, 30)), "test4.jpg", mimeType);
                                Attachment attachment5 = new Attachment(new MemoryStream(Common.Utils.CreateTestJpegImage(10, 10, 7, 7, 30)), "test5.jpg", mimeType);
                                attachmentList.Add(attachment1);
                                attachmentList.Add(attachment2);
                                attachmentList.Add(attachment3);
                                attachmentList.Add(attachment4);
                                attachmentList.Add(attachment5);

                                Tuple<bool, string> result = Utils.SendCloudEmail(dest, subject, body, attachmentList, this, logger);
                                logger.Log("result of email: Succeeded = " + result.Item1 + " " + "Message=" + result.Item2);
                            }
                            break;
                        case "stopmodule":
                            {
                                int moduleSecret = int.Parse(words[1]);
                                StopModule(moduleSecret);
                            }
                            break;
                        //case "configurefoscam":
                        //    {
                        //        string username = words[1];
                        //        string password = (words.Length == 3) ? words[2] : "";

                        //        guiService.FindFoscamOnWire(username, password);
                        //    }
                        //    break;
                        case "test":
                            {
                                //do anything here that you like

                                //Gatekeeper.Settings.Configure(Settings.ConfigDir);

                                //int numTimes = int.Parse(words[1]);

                                //for (int i = 0; i < numTimes; i++)
                                //{
                                //    config.UpdateConfSetting(i.ToString(), i.ToString());
                                //}

                                while (true)
                                {
                                    //string url = words[1];

                                    string url = "http://localhost:51430/ratul/GuiWeb/webapp/GetAllUnconfiguredDevices";
                                    // string json = ""; // Your JSON message
                                    WebRequest request = WebRequest.Create(url);
                                    //request.Method = "POST";
                                    //var postData = Encoding.UTF8.GetBytes(json);
                                    //request.ContentLength = postData.Length;
                                    //request.ContentType = "text/json";
                                    //using (var reqStream = request.GetRequestStream())
                                    //{
                                    //    reqStream.Write(postData, 0, postData.Length);
                                    //}
                                    try
                                    {
                                        var response = request.GetResponse();

                                        logger.Log("response = " + response.ToString());

                                    }
                                    catch (WebException e)
                                    {
                                        logger.Log(e.Message);
                                    }
                                    catch (Exception ex)
                                    {
                                        logger.Log("EXCEPTION: " + ex.ToString());
                                    }

                                    Thread.Sleep(1000);
                                }

                            }
                            break;
                        case "configurewebcam":
                            {
                                string devName = "Integrated Camera";

                                var result1 = guiService.GetUnconfiguredDevicesForScout("HomeOS.Hub.Scouts.WebCam");
                                var result2 = guiService.StartDriver(devName);

                                var result3 = guiService.IsDeviceReady(devName);

                                while (!result3[0].Equals(""))
                                {
                                    logger.Log("Device not ready yet. Will try again in 2 seconds");
                                    Thread.Sleep(2000);
                                    result3 = guiService.IsDeviceReady(devName);
                                }

                                var result4 = guiService.InstallAppWeb("SmartCam");
                                var result5 = guiService.ConfigureDeviceWeb(devName, "mycam", true, "Basement", new string[1] {"SmartCam"});
                            }
                            break;
                        case "starthostednetwork":
                            {
                                try
                                {
                                    var result = StartHostedNetwork();
                                    logger.Log("Result = " + result.ToString());
                                }
                                catch (Exception e)
                                {
                                    logger.Log("Exception: " + e.ToString());
                                }
                            }
                            break;
                        case "stophostednetwork":
                            {
                                try
                                {
                                    var result = StopHostedNetwork();
                                    logger.Log("Result = " + result.ToString());
                                }
                                catch (Exception e)
                                {
                                    logger.Log("Exception: " + e.ToString());
                                }
                            }
                            break;
                        case "guigeneric":
                            {
                                string methodName = words[1];
                                Type type = guiService.GetType();
                                System.Reflection.MethodInfo method = type.GetMethod(methodName);

                                if (method == null)
                                {
                                    logger.Log("Method {0} not found (check for proper capitalization)", methodName);
                                    break;
                                }

                                object[] parameters = new object[words.Length - 2];

                                for (int index = 0; index < parameters.Length; index++)
                                    parameters[index] = words[2 + index];
                                                                
                                var result = (List<string>) method.Invoke(guiService, parameters);
                                PrintGuiCallResult(result);
                            }
                            break;
                        case "setscouts":
                            {
                                string[] scouts = new string[words.Length - 1];

                                for (int index = 1; index < words.Length; index++)
                                {
                                    scouts[index - 1] = words[index];
                                }

                                var result = guiService.SetScouts(scouts);
                                PrintGuiCallResult(result);
                            }
                            break;
                        case "removezwavenode":
                            {
                                // get and check the zwave driver
                                VModule driverZwave = GetDriverZwave();

                                if (driverZwave == null)
                                {
                                    logger.Log("zwave driver is not running");
                                    break;
                                }
                                
                                string result = (string) driverZwave.OpaqueCall("RemoveDevice"); 

                                logger.Log("Result of remove zwave = " + result);
                            }
                            break;
                        default:
                            //didn't see any recognized command
                            Console.WriteLine("unknown command " + command);
                            PrintInteractiveUsage();
                            break;
                    }

                }
                catch (Exception e)
                {
                    Console.Error.WriteLine("Problem parsing/executing command: " + e);
                    PrintInteractiveUsage();
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Starts a module by searching for a matching token
        /// </summary>
        /// <param name="moduleInfo">The ModuleInfo for the module to start</param>
        public VModule StartModule(ModuleInfo moduleInfo, bool exactlyMatchVersions = false)
        {
            VModule startedModule = null;

            foreach (AddInToken token in allAddinTokens)
            {
                if (token.Name.Equals(moduleInfo.BinaryName()) &&
                    (!exactlyMatchVersions || CompareModuleVersions(moduleInfo.GetDesiredVersion(), Utils.GetHomeOSUpdateVersion(Utils.GetAddInConfigFilepath(moduleInfo.BinaryName()), logger))))
                {
                    if (startedModule != null)
                    {
                        logger.Log("WARNING: Found multiple matching tokens for " + moduleInfo.ToString());
                        continue;
                    }

                    try
                    {
                        startedModule = StartModule(moduleInfo, token);
                    }
                    catch (Exception exception)
                    {
                        logger.Log("Could not start module {0}: {1}", moduleInfo.ToString(), exception.ToString());
                        return null;
                    }
                }
            }

            //we ran something, lets return it
            if (startedModule != null)
                return startedModule;

            //we didn't run anything.
            //if we were doing exact match on versions, this could be because we didn't find an exact match
            if (exactlyMatchVersions)
            {
                logger.Log("No exact-match-version token found for Module: Binary name: " + moduleInfo.BinaryName() + ", App Name: " + moduleInfo.AppName() + ", Version: " + moduleInfo.GetDesiredVersion());

              
                Version versionRep = new Version(GetVersionFromRep(Settings.RepositoryURIs, moduleInfo.BinaryName()));
                Version versionLocal = new Version(Utils.GetHomeOSUpdateVersion((Utils.GetAddInConfigFilepath(moduleInfo.BinaryName())), logger));

                logger.Log("The latest version for {0} on the repository: {1}", moduleInfo.BinaryName(), versionRep.ToString());
                logger.Log("The version for {0} in the local AddIn dir: {1}", moduleInfo.BinaryName(), versionLocal.ToString()); 

                if (versionRep.CompareTo(versionLocal) > 0)
                {
                    logger.Log("The latest version on the repository ({0}) > local version ({1}) in AddIn for {2} - the latest from the rep will be downloaded!", versionRep.ToString(), versionLocal.ToString(), moduleInfo.BinaryName());

                    //try to get an exact match from the homestore
                    GetAddInFromRep(moduleInfo);

                }
                //maybe, we got the right version, maybe we didn't; in any case, lets now run what we can find, without being strict about version numbers
                return StartModule(moduleInfo, false);
            }
            else
            {
                logger.Log("No matching token at all found for Module: Binary name: " + moduleInfo.BinaryName() + ", App Name: " + moduleInfo.AppName() + ", Version: " + moduleInfo.GetDesiredVersion());
                return null;
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Starts a module given its token
        ///    We don't do this anymore: Has the side effect of updating the moduleInfo object's version to what was exactly ran
        /// </summary>
        /// <param name="moduleInfo"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        private VModule StartModule(ModuleInfo moduleInfo, AddInToken token)
        {
            VModule startedModule = null;

            string moduleVersion = Utils.GetHomeOSUpdateVersion(Utils.GetAddInConfigFilepath(moduleInfo.BinaryName()), logger);
            if (!CompareModuleVersions(moduleInfo.GetDesiredVersion(), moduleVersion))
            {
                logger.Log("WARNING: Starting an inexact match for {0}", moduleInfo.FriendlyName());                
            }

            moduleInfo.SetRunningVersion(moduleVersion);

            switch (Constants.ModuleIsolationLevel)
            {
                case ModuleIsolationModes.AppDomain:
                    //     AppDomain addInAppDomain = AppDomain.CreateDomain(moduleInfo.BinaryName());
                    //    startedModule = token.Activate<VModule>(addInAppDomain);

                    // Adding upfront, to check if the module is already running.
                    // So that token is not re-activated if not needed - rayman
                    if (runningModules.Values.Contains(moduleInfo))
                        throw new Exception(string.Format("Attempted to run duplicate module. New = {0}. Old = {1}", moduleInfo, moduleInfo));

                    startedModule = token.Activate<VModule>(AddInSecurityLevel.FullTrust);

                    //AddInController ainController = AddInController.GetAddInController(startedModule);
                    //AppDomain domain = ainController.AppDomain;

                    break;
                case ModuleIsolationModes.Process:
                    AddInProcess addInProc = new AddInProcess();
                    startedModule = token.Activate<VModule>(addInProc, AddInSecurityLevel.FullTrust);
                    break;
                case ModuleIsolationModes.NoAddInAppDomain:
                    //this requires putting Views.dll in the directory with AppBenchmarker.dll
                    //the simplest way to do that is to just add AppBenchmarker as a reference
                    //AppDomainSetup ads = new AppDomainSetup();
                    //ads.ApplicationBase = Environment.CurrentDirectory;//AddInRoot + "\\AddIns\\" + "AppBenchmarker";
                    var ad = AppDomain.CreateDomain(moduleInfo.FriendlyName());//, null, ads);
                    startedModule = (VModule)ad.CreateInstanceAndUnwrap("AppBenchmarker", "AppBenchmarker.Benchmarker");
                    break;
                case ModuleIsolationModes.None:
                    //this requires adding AppBenchmarker and ModuleBase projects as References
                    //startedModule = (VModule)new AppBenchmarker.Benchmarker();
                    //if (moduleInfo.BinaryName().Equals("AppCamera"))
                    //    startedModule = (VModule)new AppCamera.CameraController();
                    //else if (moduleInfo.BinaryName().Equals("DriverFoscam"))
                    //    startedModule = (VModule)new DriverFoscam.DriverFoscam();
                    //else
                    //    logger.Log("Unknown module: {0}", moduleInfo.BinaryName());
                    break;
            }

            if (moduleInfo.WorkingDir() == null)
                moduleInfo.SetWorkingDir(Settings.ModuleWorkingDirBase + "\\" + moduleInfo.FriendlyName());

            if (String.IsNullOrEmpty(moduleInfo.BaseURL()))
                moduleInfo.SetBaseURL(GetBaseUrl() + "/" + moduleInfo.FriendlyName());

            if (string.IsNullOrEmpty(moduleInfo.BinaryDir()))
                moduleInfo.SetBinaryDir(Constants.AddInRoot + "\\AddIns\\" + moduleInfo.BinaryName());

            int secret = GetNewSecret();
            startedModule.Initialize(this, logger, moduleInfo, secret);

            lock (this)
            {
                //check if we already have this module running
                foreach (ModuleInfo runningModuleInfo in runningModules.Values)
                {
                    if (runningModuleInfo.Equals(moduleInfo))
                    {
                        //moduleThread.Abort();
                        throw new Exception(string.Format("Attempted to run duplicate module. New = {0}. Old = {1}", moduleInfo, moduleInfo));
                    }
                }

                runningModules[startedModule] = moduleInfo;
            }

            SafeThread moduleThread = new SafeThread(delegate() { startedModule.Start(); }, moduleInfo.FriendlyName(), logger);
            moduleThread.Start();

            return startedModule;
        }
Ejemplo n.º 10
0
        private Dictionary<string,bool> AvailableOnRep(ModuleInfo moduleInfo)
        {
            string[] URIs = Settings.RepositoryURIs.Split('|'); 
            String[] path = moduleInfo.BinaryName().Split('.');
            Dictionary<string, bool> retval = new Dictionary<string,bool>();

            foreach (string uri in URIs)
            {
                //logger.Log("Checking " + moduleInfo.BinaryName() + " v" + moduleInfo.GetVersion() + "  availability on Rep: " + uri);

                //string zipuri = uri +'/' + path[0] + '/' + path[1] + '/' + path[2] + '/' + path[3] + '/' + moduleInfo.GetVersion() + '/' + moduleInfo.BinaryName() + ".zip";

                string zipuri = uri;

                foreach (string pathElement in path)
                    zipuri += "/" + pathElement;

                zipuri += '/' + moduleInfo.GetVersion() + '/' + moduleInfo.BinaryName() + ".zip";

                if (UrlIsValid(zipuri))
                {
                    retval[zipuri]=true;
                    return retval;
                }
            }
            retval[""] = false;
            return retval;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Starts a module by searching for a matching token
        /// </summary>
        /// <param name="moduleInfo">The ModuleInfo for the module to start</param>
        public VModule StartModule(ModuleInfo moduleInfo, bool exactlyMatchVersions = false)
        {
            VModule startedModule = null;

            foreach (AddInToken token in allAddinTokens)
            {
                if (token.Name.Equals(moduleInfo.BinaryName()) &&
                    (!exactlyMatchVersions || CompareModuleVersions(moduleInfo.GetVersion(), GetHomeOSUpdateVersion(GetAddInConfigFilepath(moduleInfo.BinaryName())))))
                {
                    if (startedModule != null)
                    {
                        logger.Log("WARNING: Found multiple matching tokens for " + moduleInfo.ToString());
                        continue;
                    }

                    try
                    {
                        startedModule = StartModule(moduleInfo, token);
                    }
                    catch (Exception exception)
                    {
                        logger.Log("Could not start module {0}: {1}", moduleInfo.ToString(), exception.ToString());
                        return null;
                    }
                }
            }

            //we ran something, lets return it
            if (startedModule != null)
                return startedModule;

            //we didn't run anything.
            //if we were doing exact match on versions, this could be because we didn't find an exact match
            if (exactlyMatchVersions)
            {
                logger.Log("No exact-match-version token found for Module: Binary name: " + moduleInfo.BinaryName() + ", App Name: " + moduleInfo.AppName() + ", Version: " + moduleInfo.GetVersion());

                //try to get an exact match from the homestore
                GetAddInFromRep(moduleInfo);

                //maybe, we got the right version, maybe we didn't; in any case, lets now run what we can find, without being strict about version numbers
                return StartModule(moduleInfo, false);
            }
            else
            {
                logger.Log("No matching token at all found for Module: Binary name: " + moduleInfo.BinaryName() + ", App Name: " + moduleInfo.AppName() + ", Version: " + moduleInfo.GetVersion());
                return null;
            }
        }
Ejemplo n.º 12
0
 public void AddModuleIfMissing(ModuleInfo moduleInfo)
 {
     lock (allModules)
     {
         if (!allModules.ContainsKey(moduleInfo.FriendlyName()))
             AddModule(moduleInfo);
     }
 }
Ejemplo n.º 13
0
        public void AddModule(ModuleInfo moduleInfo, bool writeConfigToDisk=true)
        {
            lock (allModules)
            {
                if (!allModules.ContainsKey(moduleInfo.FriendlyName())) 
                {
                    allModules.Add(moduleInfo.FriendlyName(), moduleInfo);
                }
                else 
                { 
                    logger.Log("Warning: Attempt to add an already added module " + moduleInfo.FriendlyName());
                }

                if (writeConfigToDisk)
                    WriteModuleList();
            }
        }
Ejemplo n.º 14
0
        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();
        }