예제 #1
0
        private SUUpdater(KNBundle aBundle)
        {
            KNBundle bundle = KNBundle.BundleWithAssembly(Assembly.GetAssembly(this.GetType()));

            if (aBundle == null)
            {
                aBundle = KNBundle.MainBundle();
            }

            if (sharedUpdaters.ContainsKey(aBundle))
            {
                throw new Exception("Updater for this bundle exists - use SUUpdater.UpdaterForBundle()");
            }

            SUInstaller.AddInstallerForFileType(new SUExecutableInstaller(), ".exe");
            SUInstaller.AddInstallerForFileType(new SUMSIInstaller(), ".msi");

            SUUnarchiver.AddUnarchiverForFileType(new SUZipUnarchiver(), ".zip");
            SUUnarchiver.AddUnarchiverForFileType(new SUExeUnarchiver(), ".exe");
            SUUnarchiver.AddUnarchiverForFileType(new SUExeUnarchiver(), ".msi");

            sharedUpdaters.Add(aBundle, this);
            host = new SUHost(aBundle);

            // Clean out old update files if they exist

            if (host.ObjectForUserDefaultsKey(SUConstants.SUExtractedFilesForCleanupKey) != null)
            {
                string path = (string)host.ObjectForUserDefaultsKey(SUConstants.SUExtractedFilesForCleanupKey);

                try {
                    FileAttributes attr = File.GetAttributes(path);
                    if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                    {
                        Directory.Delete(path, true);
                    }
                    else
                    {
                        File.Delete(path);
                    }
                } catch {
                } finally {
                    host.SetObjectForUserDefaultsKey(null, SUConstants.SUExtractedFilesForCleanupKey);
                }
            }

            OfferToAutomaticallyUpdateIfAppropriate();
            ScheduleNextUpdateCheck();
        }
예제 #2
0
        private SUUpdater(KNBundle aBundle)
        {
            KNBundle bundle = KNBundle.BundleWithAssembly(Assembly.GetAssembly(this.GetType()));

            if (aBundle == null) {
                aBundle = KNBundle.MainBundle();
            }

            if (sharedUpdaters.ContainsKey(aBundle)) {
                throw new Exception("Updater for this bundle exists - use SUUpdater.UpdaterForBundle()");
            }

            SUInstaller.AddInstallerForFileType(new SUExecutableInstaller(), ".exe");
            SUInstaller.AddInstallerForFileType(new SUMSIInstaller(), ".msi");

            SUUnarchiver.AddUnarchiverForFileType(new SUZipUnarchiver(), ".zip");
            SUUnarchiver.AddUnarchiverForFileType(new SUExeUnarchiver(), ".exe");
            SUUnarchiver.AddUnarchiverForFileType(new SUExeUnarchiver(), ".msi");

            sharedUpdaters.Add(aBundle, this);
            host = new SUHost(aBundle);

            // Clean out old update files if they exist

            if (host.ObjectForUserDefaultsKey(SUConstants.SUExtractedFilesForCleanupKey) != null) {
                string path = (string)host.ObjectForUserDefaultsKey(SUConstants.SUExtractedFilesForCleanupKey);

                try {

                    FileAttributes attr = File.GetAttributes(path);
                    if ((attr & FileAttributes.Directory) == FileAttributes.Directory) {
                        Directory.Delete(path, true);
                    } else {
                        File.Delete(path);
                    }
                } catch {
                } finally {
                    host.SetObjectForUserDefaultsKey(null, SUConstants.SUExtractedFilesForCleanupKey);
                }
            }

            OfferToAutomaticallyUpdateIfAppropriate();
            ScheduleNextUpdateCheck();
        }
예제 #3
0
        // -------------------

        private void OfferToAutomaticallyUpdateIfAppropriate()
        {
            bool shouldPrompt = false;

            if (host.ObjectForUserDefaultsKey(SUConstants.SUEnableAutomaticChecksKey) == null)
            {
                object val = host.ObjectForUserDefaultsKey(SUConstants.SUHasLaunchedBeforeKey);
                if (val == null || (bool)val == false)
                {
                    host.SetObjectForUserDefaultsKey(true, SUConstants.SUHasLaunchedBeforeKey);
                }
                else
                {
                    shouldPrompt = true;
                }
            }

            if (shouldPrompt)
            {
                SUUpdatePermissionPromptWindowController controller = new SUUpdatePermissionPromptWindowController(host);
                controller.Delegate = this;
                controller.ShowWindow();
            }
        }