Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns the shared updater for the given bundle.
        /// </summary>
        /// <param name="bundle">The bundle to get the updater for.</param>
        /// <returns>A shared updater for the given bundle.</returns>
        public static SUUpdater UpdaterForBundle(KNBundle bundle) {

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

            SUUpdater updater = null;

            if (!sharedUpdaters.TryGetValue(bundle, out updater)) {
                updater = new SUUpdater(bundle);

            }
           
            return updater;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns the shared updater for the given bundle.
        /// </summary>
        /// <param name="bundle">The bundle to get the updater for.</param>
        /// <returns>A shared updater for the given bundle.</returns>
        public static SUUpdater UpdaterForBundle(KNBundle bundle)
        {
            if (bundle == null)
            {
                bundle = KNBundle.MainBundle();
            }

            SUUpdater updater = null;

            if (!sharedUpdaters.TryGetValue(bundle, out updater))
            {
                updater = new SUUpdater(bundle);
            }

            return(updater);
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
0
 public SUHost(KNBundle aBundle)
 {
     bundle   = aBundle;
     defaults = KNUserDefaults.UserDefaultsForDomain(bundle.BundleIdentifier);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Get the shared update for the main bundle.
 /// </summary>
 /// <returns>The updater for the main bundle.</returns>
 public static SUUpdater SharedUpdater()
 {
     return(UpdaterForBundle(KNBundle.MainBundle()));
 }
Ejemplo n.º 7
0
 private SUUpdater()
     : this(KNBundle.MainBundle())
 {
 }
Ejemplo n.º 8
0
        public SUHost(KNBundle aBundle) {
            bundle = aBundle;
            defaults = KNUserDefaults.UserDefaultsForDomain(bundle.BundleIdentifier);

        }