Example #1
0
        public int CompareTo(PluginInfo cf)
        {
            if (cf == null)
            {
                return(1);
            }

            // See if version numbers differ
            int comp = this.VersionNumber.CompareTo(cf);

            if (comp != 0)
            {
                return(comp);
            }

            /*
             * this.RhinoSDKVersion;
             * this.RhinoSDKServiceRelease;
             * this.DotNetSDKVersion;
             * this.RhinoCommonSDKVersion;
             */

            // See if RhinoSdkVersion numbers differ:
            if (!string.IsNullOrEmpty(this.RhinoSDKVersion) || !string.IsNullOrEmpty(cf.RhinoSDKVersion))
            {
                comp = string.Compare(this.RhinoSDKVersion, cf.RhinoSDKVersion, StringComparison.OrdinalIgnoreCase);
                if (comp != 0)
                {
                    return(comp); // RhinoSdkVersion difference
                }
            }
            else
            {
                // RhinoSdkVersion is empty on one or more objects; cannot compare
            }

            // See if RhinoSDKServiceRelease numbers differ:
            if (!string.IsNullOrEmpty(this.RhinoSDKServiceRelease) || !string.IsNullOrEmpty(cf.RhinoSDKServiceRelease))
            {
                comp = string.Compare(this.RhinoSDKServiceRelease, cf.RhinoSDKServiceRelease, StringComparison.OrdinalIgnoreCase);
                if (comp != 0)
                {
                    return(comp); // RhinoSDKServiceRelease difference
                }
            }
            else
            {
                // RhinoSDKServiceRelease is empty on one or more objects; cannot compare
            }

            // See if DotNetSDKVersion numbers differ:
            if (!string.IsNullOrEmpty(this.DotNetSDKVersion) || !string.IsNullOrEmpty(cf.DotNetSDKVersion))
            {
                comp = string.Compare(this.DotNetSDKVersion, cf.DotNetSDKVersion, StringComparison.OrdinalIgnoreCase);
                if (comp != 0)
                {
                    return(comp); // DotNetSDKVersion difference
                }
            }
            else
            {
                // DotNetSDKVersion is empty on one or more objects; cannot compare
            }

            // See if RhinoCommonSDKVersion numbers differ:
            if (!string.IsNullOrEmpty(this.RhinoCommonSDKVersion) || !string.IsNullOrEmpty(cf.RhinoCommonSDKVersion))
            {
                comp = string.Compare(this.RhinoCommonSDKVersion, cf.RhinoCommonSDKVersion, StringComparison.OrdinalIgnoreCase);
                if (comp != 0)
                {
                    return(comp); // RhinoCommonSDKVersion difference
                }
            }
            else
            {
                // RhinoCommonSDKVersion is empty on one or more objects; cannot compare
            }

            // Exact match
            return(0);
        }
Example #2
0
        public bool IsCompatible(RhinoInfo rhino)
        {
            PluginInfo plugin = this;

            if (!rhino.IsValid())
            {
                Logger.Log(LogLevel.Debug, "RhinoInfo::IsPluginCompatible called with invalid PluginInfo: " + plugin.m_plugin_path);
                return(false);
            }

            // Plug-in uses RhinoDotNet?
            if (!string.IsNullOrEmpty(plugin.DotNetSDKVersion))
            {
                // Get last section of Rhino DotNet version number
                Match  m         = Regex.Match(rhino.RhinoDotNetVersion, @"\.(\d+)$");
                string sRhinoRev = m.Groups[1].Value;
                int    nRhinoRev = -1;
                if (!int.TryParse(sRhinoRev, out nRhinoRev))
                {
                    nRhinoRev = -1;
                }

                // Get last section of Plug-in DotNet version number
                m = Regex.Match(plugin.DotNetSDKVersion, @"\.(\d+)$");
                string sPluginRev = m.Groups[1].Value;
                int    nPluginRev = -1;

                if (!int.TryParse(sPluginRev, out nPluginRev))
                {
                    nPluginRev = -1;
                }

                if (nRhinoRev < 0 || nPluginRev < 0)
                {
                    Logger.Log(LogLevel.Debug, "RhinoDotNet version incompatibility: Rhino: " + rhino.RhinoDotNetVersion + ", Plug-in: " + plugin.DotNetSDKVersion);
                    return(false);
                }

                if (nRhinoRev < 100)
                {
                    // Rhino is 4.0
                    if (nPluginRev < 100)
                    {
                        // Plug-in is 4.0; go ahead and install
                    }
                    else
                    {
                        // Plug-in is newer than 4.0; do not install.
                        Logger.Log(LogLevel.Debug, "RhinoDotNet version incompatibility: Rhino: " + rhino.RhinoDotNetVersion + ", Plug-in: " + plugin.DotNetSDKVersion);
                        return(false);
                    }
                }
                else
                {
                    // Rhino is 5.0
                }

                // Plug-in is dotNet, but Rhino has older version of dotNet
                int cf = string.Compare(rhino.RhinoDotNetVersion, plugin.DotNetSDKVersion, StringComparison.OrdinalIgnoreCase);
                if (cf < 0)
                {
                    Logger.Log(LogLevel.Debug, "RhinoDotNet version incompatibility: Rhino: " + rhino.RhinoDotNetVersion + ", Plug-in: " + plugin.DotNetSDKVersion);
                    return(false);
                }
            }

            // Plug-in uses RhinoCommon?
            if (!string.IsNullOrEmpty(plugin.RhinoCommonSDKVersion))
            {
                // Plug-in uses RhinoCommon, but Rhino doesn't have it
                if (string.IsNullOrEmpty(rhino.RhinoCommonVersion))
                {
                    Logger.Log(LogLevel.Debug, "RhinoCommon version incompatibility: Rhino: not found, Plug-in: " + plugin.RhinoCommonSDKVersion);
                    return(false);
                }

                // Plug-in uses RhinoCommon, but Rhino has older version of RhinoCommon
                int cf = string.Compare(rhino.RhinoCommonVersion, plugin.RhinoCommonSDKVersion, StringComparison.OrdinalIgnoreCase);
                if (cf < 0)
                {
                    Logger.Log(LogLevel.Debug, "RhinoCommon version incompatibility: Rhino: " + rhino.RhinoCommonVersion + ", Plug-in: " + plugin.RhinoCommonSDKVersion);
                    return(false);
                }
            }

            // Plug-in uses C++?
            if (!string.IsNullOrEmpty(plugin.RhinoSDKVersion))
            {
                if (rhino.RhinoSdkVersion.EndsWith("0", StringComparison.OrdinalIgnoreCase))
                {
                    // Rhino is 4.0
                    if (plugin.RhinoSDKVersion.EndsWith("0", StringComparison.OrdinalIgnoreCase))
                    {
                        // Do nothing. Plug-in is compatible.
                    }
                    else
                    {
                        Logger.Log(LogLevel.Debug, "RhinoSdkVersion incompatibility: Rhino: " + rhino.RhinoSdkVersion + ", Plug-in: " + plugin.RhinoSDKVersion);
                        return(false); // Plug-in is not compatible
                    }
                }
                else if (rhino.RhinoSdkVersion.EndsWith("5", StringComparison.OrdinalIgnoreCase))
                {
                    // Rhino is 5.0
                    if (plugin.RhinoSDKVersion.EndsWith("5", StringComparison.OrdinalIgnoreCase))
                    {
                        // Plugin is 4.0 or 5.0
                        // do nothing; rhino is compatible
                    }
                    else
                    {
                        Logger.Log(LogLevel.Debug, "RhinoSdkVersion incompatibility: Rhino: " + rhino.RhinoSdkVersion + ", Plug-in: " + plugin.RhinoSDKVersion);
                        return(false);
                    }
                }
                else
                {
                    Logger.Log(LogLevel.Debug, "RhinoSdkVersion incompatibility: Rhino: " + rhino.RhinoSdkVersion + ", Plug-in: " + plugin.RhinoSDKVersion);
                    return(false);
                }
            }

            if (!string.IsNullOrEmpty(plugin.RhinoSDKServiceRelease))
            {
                if (rhino.RhinoSdkServiceRelease.EndsWith("0", StringComparison.OrdinalIgnoreCase))
                {
                    // Rhino is 4.0
                    if (plugin.RhinoSDKServiceRelease.EndsWith("0", StringComparison.OrdinalIgnoreCase))
                    {
                        // do nothing, rhino is compatible
                    }
                    else
                    {
                        Logger.Log(LogLevel.Debug, "RhinoSdkServiceRelease incompatibility: Rhino: " + rhino.RhinoSdkServiceRelease + ", Plug-in: " + plugin.RhinoSDKServiceRelease);
                        return(false);
                    }
                }
                else if (rhino.RhinoSdkServiceRelease.EndsWith("5", StringComparison.OrdinalIgnoreCase))
                {
                    if (plugin.RhinoSDKServiceRelease.EndsWith("0", StringComparison.OrdinalIgnoreCase) ||
                        plugin.RhinoSDKServiceRelease.EndsWith("5", StringComparison.OrdinalIgnoreCase))
                    {
                        // do nothing, rhino is compatible
                    }
                    else
                    {
                        Logger.Log(LogLevel.Debug, "RhinoSdkServiceRelease incompatibility: Rhino: " + rhino.RhinoSdkServiceRelease + ", Plug-in: " + plugin.RhinoSDKServiceRelease);
                        return(false);
                    }
                }
                else
                {
                    // unknown Rhino
                    Logger.Log(LogLevel.Debug, "RhinoSdkServiceRelease incompatibility: Rhino: " + rhino.RhinoSdkServiceRelease + ", Plug-in: " + plugin.RhinoSDKServiceRelease);
                    return(false);
                }
            }

            Logger.Log(LogLevel.Info, "Compatible Rhino found: " + rhino.RhinoExePath);
            return(true);
        }
Example #3
0
        public static InstallerPhase InspectPlugin(string PathToPlugin)
        {
            // This should only be called from a separate process.
              PluginInfo info = new PluginInfo();
              info.ContentType = PackageContentType.Plugin;
              info.InspectPlugin(PathToPlugin);
              if (!info.IsValid())
            return InstallerPhase.InspctFailed;

              info.PluginPath = PathToPlugin;
              info.WriteXml();
              return InstallerPhase.Success;
        }
Example #4
0
        private bool RegisterPlugin(PluginInfo plugin_info, RhinoInfo rhino_info)
        {
            ReportProgress("Registering plugin: " + plugin_info.PluginPath, LogLevel.Info);
              RegistryKey PluginsRegKey = null;
              if (m_user == InstallerUser.AllUsers)
              {
            ReportProgress("Registering for all users", LogLevel.Debug);
            PluginsRegKey = rhino_info.OpenAllUsersPluginKey();
              }
              else if (m_user == InstallerUser.CurrentUser)
              {
            ReportProgress("Registering for current user", LogLevel.Debug);
            PluginsRegKey = rhino_info.OpenCurrentUserPluginKey();
              }
              else
              {
            throw new RhinoInstallerException(string.Format(CultureInfo.InvariantCulture, "Unexpected user '{0}' encountered in RegisterPlugin.", m_user));
              }

              if (PluginsRegKey == null)
              {
            ReportProgress("Plug-in registration failed: RegKey == null", LogLevel.Error);
            return false;
              }

              // 2012-04-03, Brian Gillespie.
              // Plug-ins installed by the RHI file should always be re-loaded by Rhino;
              // Older versions of this code would check for existing plug-in registrations
              // and would set the {GUID}\Plug-in\Name and {GUID}\Plug-in\FileName keys instead.
              // But the old behavior fails to update the plug-in commands, or cause new .RUI files
              // to be loaded by Rhino.
              ReportProgress("Creating new plug-in registration", LogLevel.Debug);
              // Doesn't exist; Create it and register the plug-in
              RegistryKey ThisPluginGuidKey = PluginsRegKey.CreateSubKey(plugin_info.ID.ToString().ToUpperInvariant());
              if (ThisPluginGuidKey == null)
            return false;

              // Create Name key
              ReportProgress("Setting Name to '" + plugin_info.Title + "'", LogLevel.Debug);
              ThisPluginGuidKey.SetValue("Name", plugin_info.Title);
              ReportProgress("Setting FileName to '" + plugin_info.PluginPath + "'", LogLevel.Debug);
              ThisPluginGuidKey.SetValue("FileName", plugin_info.PluginPath);

              // Delete load mode:
              object loadMode = ThisPluginGuidKey.GetValue("LoadMode");
              if (loadMode != null)
            ThisPluginGuidKey.DeleteValue("LoadMode");

              return true;
        }
Example #5
0
 private PackageInstallState GetPluginInstallState(PluginInfo plugin_info)
 {
     return GetPackageInstallState(plugin_info.VersionNumber);
 }
Example #6
0
        public override bool Initialize(Package package)
        {
            m_package = package;
              // See if at least one compatible Rhino is installed.

              Guid last_plugin_id = Guid.Empty;
              Collection<PackageFileKey> rhp_files = ListRhpFiles(package);

              bool foundOneValidRhino = false;

              foreach (PackageFileKey rhp in rhp_files)
              {
            string rhp_full_path = package.GetFullPath(rhp);
            InstallerPhase rc = ExecutePluginInspector(rhp_full_path);

            if (rc != InstallerPhase.Success)
              continue;

            foundOneValidRhino = true;
            PluginInfo pii = new PluginInfo();
            pii.PluginPath = rhp_full_path;
            pii.ReadXml();
            m_plugin_lookup.Add(rhp, pii);

            if (last_plugin_id != Guid.Empty && pii.ID != last_plugin_id)
            {
              ReportProgress("Plug-in GUID mismatch: " + pii.ID + " != " + last_plugin_id, LogLevel.Error);
              throw new GuidMismatchException("All plug-ins in an installer must have the same GUID. Two different GUIDs were found.");
            }

            last_plugin_id = pii.ID;
              }

              if (!foundOneValidRhino)
              {
            ReportProgress("Plug-in inspection failed", LogLevel.Error);
            throw new PackageNotCompatibleException(package.PackagePath);
              }

              m_id = last_plugin_id;
              return true;
        }
Example #7
0
        public int CompareTo(PluginInfo cf)
        {
            if (cf == null)
            return 1;

              // See if version numbers differ
              int comp = this.VersionNumber.CompareTo(cf);
              if (comp != 0)
            return comp;

              /*
              this.RhinoSDKVersion;
              this.RhinoSDKServiceRelease;
              this.DotNetSDKVersion;
              this.RhinoCommonSDKVersion;
              */

              // See if RhinoSdkVersion numbers differ:
              if (!string.IsNullOrEmpty(this.RhinoSDKVersion) || !string.IsNullOrEmpty(cf.RhinoSDKVersion))
              {
            comp = string.Compare(this.RhinoSDKVersion, cf.RhinoSDKVersion, StringComparison.OrdinalIgnoreCase);
            if (comp != 0)
              return comp; // RhinoSdkVersion difference
              }
              else
              {
            // RhinoSdkVersion is empty on one or more objects; cannot compare
              }

              // See if RhinoSDKServiceRelease numbers differ:
              if (!string.IsNullOrEmpty(this.RhinoSDKServiceRelease) || !string.IsNullOrEmpty(cf.RhinoSDKServiceRelease))
              {
            comp = string.Compare(this.RhinoSDKServiceRelease, cf.RhinoSDKServiceRelease, StringComparison.OrdinalIgnoreCase);
            if (comp != 0)
              return comp; // RhinoSDKServiceRelease difference
              }
              else
              {
            // RhinoSDKServiceRelease is empty on one or more objects; cannot compare
              }

              // See if DotNetSDKVersion numbers differ:
              if (!string.IsNullOrEmpty(this.DotNetSDKVersion) || !string.IsNullOrEmpty(cf.DotNetSDKVersion))
              {
            comp = string.Compare(this.DotNetSDKVersion, cf.DotNetSDKVersion, StringComparison.OrdinalIgnoreCase);
            if (comp != 0)
              return comp; // DotNetSDKVersion difference
              }
              else
              {
            // DotNetSDKVersion is empty on one or more objects; cannot compare
              }

              // See if RhinoCommonSDKVersion numbers differ:
              if (!string.IsNullOrEmpty(this.RhinoCommonSDKVersion) || !string.IsNullOrEmpty(cf.RhinoCommonSDKVersion))
              {
            comp = string.Compare(this.RhinoCommonSDKVersion, cf.RhinoCommonSDKVersion, StringComparison.OrdinalIgnoreCase);
            if (comp != 0)
              return comp; // RhinoCommonSDKVersion difference
              }
              else
              {
            // RhinoCommonSDKVersion is empty on one or more objects; cannot compare
              }

              // Exact match
              return 0;
        }