예제 #1
0
        public AutoUpdate(IXenStoreItemFactory XSFactory, IGetReg getreg)
        {
            session           = XSFactory;
            licensed          = XSFactory.newXenStoreItem("/guest_agent_features/Guest_agent_auto_update/licensed");
            enabled           = XSFactory.newXenStoreItem("/guest_agent_features/Guest_agent_auto_update/parameters/enabled");
            update_url        = XSFactory.newXenStoreItem("/guest_agent_features/Guest_agent_auto_update/parameters/update_url");
            allowdriverupdate = XSFactory.newXenStoreItem("/guest_agent_features/Guest_agent_auto_update/parameters/allow-driver-install");
            xdvdapresent      = XSFactory.newXenStoreItem("data/xd/present");
            uuid        = XSFactory.newXenStoreItem("vm");
            this.getreg = getreg;
            int major = (int)getreg.GetReg("HKEY_LOCAL_MACHINE\\SOFTWARE\\XCP-ng\\XenTools", "MajorVersion", 0);
            int minor = (int)getreg.GetReg("HKEY_LOCAL_MACHINE\\SOFTWARE\\XCP-ng\\XenTools", "MinorVersion", 0);
            int micro = (int)getreg.GetReg("HKEY_LOCAL_MACHINE\\SOFTWARE\\XCP-ng\\XenTools", "MicroVersion", 0);
            int build = (int)getreg.GetReg("HKEY_LOCAL_MACHINE\\SOFTWARE\\XCP-ng\\XenTools", "BuildVersion", 0);

            version = new Version(major, minor, micro, build);
        }
예제 #2
0
            public bool Download(string url, string file, int maxsize)
            {
                maxSize  = maxsize;
                complete = false;
                error    = false;

                string userAgent = (string)getreg.GetReg("HKEY_LOCAL_MACHINE\\SOFTWARE\\Citrix\\XenTools\\AutoUpdate", "UserAgent", BrandingControl.getString("BRANDING_userAgent"));

                client = new WebClient();
                client.Headers.Add("User-Agent", userAgent);
                client.DownloadFileCompleted   += new System.ComponentModel.AsyncCompletedEventHandler(DownloadCompleted);
                client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged);
                client.DownloadFileAsync(new Uri(url), file);

                finished.WaitOne(900000); // 15 min
                return(complete && !error);
            }