Ejemplo n.º 1
0
        /// <summary>
        /// Make the registry entries Bloom requires.
        /// We do this every time a version of Bloom runs, so that if more than one is installed the latest wins.
        /// </summary>
        internal static void MakeBloomRegistryEntries(string[] programArgs)
        {
            if (Program.RunningUnitTests)
            {
                return;                 // unit testing.
            }
            // When installed in program files we only do registry entries when we are first installed,
            // thus keeping them consistent for all users, stored in HKLM.
            if (SharedByAllUsers() && !IsFirstTimeInstall(programArgs))
            {
                return;
            }
            _installInLocalMachine = SharedByAllUsers();
            if (Platform.IsLinux)
            {
                // This will be done by the package installer.
                return;
            }

            var iconDir = FileLocationUtilities.GetDirectoryDistributedWithApplication(true, "icons");

            if (iconDir == null)
            {
                // Note: if this happens a lot we'd want to make it localizable. I think that's unlikely, so it may not be worth the
                // burden on localizers.
                var exception =
                    new FileNotFoundException(
                        "Bloom was not able to find some of its files. The shortcut icon you clicked on may be out of date. Try deleting it and reinstalling Bloom");
                ProblemReportApi.ShowProblemDialog(null, exception, "", "fatal");
                // Not sure these lines are reachable. Just making sure.
                Application.Exit();
                return;
            }

            // BloomCollection icon
            CreateIconRegistrySettings("BloomCollection", iconDir, "BloomCollectionIcon.ico", "Bloom Book Collection");
            // BloomPack icon
            CreateIconRegistrySettings("BloomPack", iconDir, "BloomPack.ico", "Bloom Book Pack", "FriendlyTypeName");
            // JoinBloomTC icon
            CreateIconRegistrySettings("JoinBloomTC", iconDir, "JoinBloomTC.ico", "Join Bloom Team Collection");

            // This might be part of registering as the executable for various file types?
            // I don't know what does it in wix but it's one of the things the old wix installer created.
            var exe = Assembly.GetExecutingAssembly().Location;

            EnsureRegistryValue(@"bloom\shell\open\command", "\"" + exe + "\" \"%1\"");

            BeTheExecutableFor(".BloomCollection", "BloomCollection file");
            BeTheExecutableFor(".BloomPack", "BloomPack file");
            BeTheExecutableFor(".JoinBloomTC", "JoinBloom file");
            // Make the OS run Bloom when it sees bloom://somebooktodownload
            BookDownloadSupport.RegisterForBloomUrlProtocol(_installInLocalMachine);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Make the registry entries Bloom requires.
        /// We do this every time a version of Bloom runs, so that if more than one is installed the latest wins.
        /// </summary>
        internal static void MakeBloomRegistryEntries(string[] programArgs)
        {
            if (Program.RunningUnitTests)
            {
                return;                 // unit testing.
            }
            // When installed in program files we only do registry entries when we are first installed,
            // thus keeping them consistent for all users, stored in HKLM.
            if (SharedByAllUsers() && !IsFirstTimeInstall(programArgs))
            {
                return;
            }
            _installInLocalMachine = SharedByAllUsers();
            if (Platform.IsLinux)
            {
                // This will be done by the package installer.
                return;
            }

            var iconDir = FileLocator.GetDirectoryDistributedWithApplication("icons");

            // This is what I (JohnT) think should make Bloom display the right icon for .BloomCollection files.
            EnsureRegistryValue(@".BloomCollection\DefaultIcon", Path.Combine(iconDir, "BloomCollectionIcon.ico"));
            EnsureRegistryValue(@".BloomPack\DefaultIcon", Path.Combine(iconDir, "BloomPack.ico"));

            // These may also be connected with making BloomCollection files display the correct icon.
            // Based on things found in (or done by) the old wix installer.
            EnsureRegistryValue(".BloomCollection", "Bloom.BloomCollectionFile");
            EnsureRegistryValue(".BloomCollectionFile", "Bloom.BloomCollectionFile");
            EnsureRegistryValue("Bloom.BloomCollectionFile", "Bloom Book Collection");
            EnsureRegistryValue(@"Bloom.BloomCollectionFile\DefaultIcon", Path.Combine(iconDir, "BloomCollectionIcon.ico, 0"));

            // I think these help BloomPack files display the correct icon.
            EnsureRegistryValue(".BloomPack", "Bloom.BloomPackFile");
            EnsureRegistryValue("Bloom.BloomPackFile", "Bloom Book Collection");
            EnsureRegistryValue(".BloomPackFile", "Bloom Book Collection");
            EnsureRegistryValue(@"Bloom.BloomPackFile\DefaultIcon", Path.Combine(iconDir, "BloomPack.ico, 0"));
            EnsureRegistryValue(@".BloomPackFile\DefaultIcon", Path.Combine(iconDir, "BloomPack.ico, 0"));
            EnsureRegistryValue(@"SOFTWARE\Classes\Bloom.BloomPack", "Bloom Book Pack", "FriendlyTypeName");

            // This might be part of registering as the executable for various file types?
            // I don't know what does it in wix but it's one of the things the old wix installer created.
            var exe = Assembly.GetExecutingAssembly().Location;

            EnsureRegistryValue(@"bloom\shell\open\command", "\"" + exe + "\" \"%1\"");

            BeTheExecutableFor(".BloomCollection", "BloomCollection file");
            BeTheExecutableFor(".BloomPack", "BloomPack file");
            // Make the OS run Bloom when it sees bloom://somebooktodownload
            BookDownloadSupport.RegisterForBloomUrlProtocol(_installInLocalMachine);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Make the registry entries Bloom requires.
        /// We do this every time a version of Bloom runs, so that if more than one is installed the latest wins.
        /// </summary>
        internal static void MakeBloomRegistryEntries(string[] programArgs)
        {
            if (Program.RunningUnitTests)
            {
                return;                 // unit testing.
            }
            // When installed in program files we only do registry entries when we are first installed,
            // thus keeping them consistent for all users, stored in HKLM.
            if (SharedByAllUsers() && !IsFirstTimeInstall(programArgs))
            {
                return;
            }
            _installInLocalMachine = SharedByAllUsers();
            if (Platform.IsLinux)
            {
                // This will be done by the package installer.
                return;
            }

            var iconDir = FileLocator.GetDirectoryDistributedWithApplication(true, "icons");

            if (iconDir == null)
            {
                // Note: if this happens a lot we'd want to make it localizable. I think that's unlikely, so it may not be worth the
                // burden on localizers.
                ErrorReport.ReportFatalException(new FileNotFoundException("Bloom was not able to find some of its files. The shortcut icon you clicked on may be out of date. Try deleting it and reinstalling Bloom"));
                // Not sure these lines are reachable. Just making sure.
                Application.Exit();
                return;
            }

            // This is what I (JohnT) think should make Bloom display the right icon for .BloomCollection files.
            EnsureRegistryValue(@".BloomCollection\DefaultIcon", Path.Combine(iconDir, "BloomCollectionIcon.ico"));
            EnsureRegistryValue(@".BloomPack\DefaultIcon", Path.Combine(iconDir, "BloomPack.ico"));

            // These may also be connected with making BloomCollection files display the correct icon.
            // Based on things found in (or done by) the old wix installer.
            EnsureRegistryValue(".BloomCollection", "Bloom.BloomCollectionFile");
            EnsureRegistryValue(".BloomCollectionFile", "Bloom.BloomCollectionFile");
            EnsureRegistryValue("Bloom.BloomCollectionFile", "Bloom Book Collection");
            EnsureRegistryValue(@"Bloom.BloomCollectionFile\DefaultIcon", Path.Combine(iconDir, "BloomCollectionIcon.ico, 0"));

            // I think these help BloomPack files display the correct icon.
            EnsureRegistryValue(".BloomPack", "Bloom.BloomPackFile");
            EnsureRegistryValue("Bloom.BloomPackFile", "Bloom Book Collection");
            EnsureRegistryValue(".BloomPackFile", "Bloom Book Collection");
            EnsureRegistryValue(@"Bloom.BloomPackFile\DefaultIcon", Path.Combine(iconDir, "BloomPack.ico, 0"));
            EnsureRegistryValue(@".BloomPackFile\DefaultIcon", Path.Combine(iconDir, "BloomPack.ico, 0"));
            EnsureRegistryValue(@"SOFTWARE\Classes\Bloom.BloomPack", "Bloom Book Pack", "FriendlyTypeName");

            // This might be part of registering as the executable for various file types?
            // I don't know what does it in wix but it's one of the things the old wix installer created.
            var exe = Assembly.GetExecutingAssembly().Location;

            EnsureRegistryValue(@"bloom\shell\open\command", "\"" + exe + "\" \"%1\"");

            BeTheExecutableFor(".BloomCollection", "BloomCollection file");
            BeTheExecutableFor(".BloomPack", "BloomPack file");
            // Make the OS run Bloom when it sees bloom://somebooktodownload
            BookDownloadSupport.RegisterForBloomUrlProtocol(_installInLocalMachine);
        }