Skip to content

Commit

Permalink
Merge pull request #243 from MediaPortal/MP1-5185-MP_MPE_Installation…
Browse files Browse the repository at this point in the history
…_fixes_rework_enhancement

MP1-5185: MP MPE Installation fixes / rework / enhancement
  • Loading branch information
andrewjswan authored Dec 26, 2023
2 parents d0eb0f2 + 664f0af commit deb96e0
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public int GetHashCode(UsesSubsystemAttribute obj)

private static readonly HashSet<Assembly> AppAssemblies = new HashSet<Assembly>();
private static readonly Dictionary<string, Version> SubSystemVersions = new Dictionary<string, Version>();
private static readonly Version AppVersion;
public static readonly Version AppVersion;
public static readonly Version SkinVersion = new Version(1, 4, 0, 0);
private static readonly string MinRequiredVersionDefault = "1.1.8.0"; // 1.2.0 RC1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,73 +118,68 @@ public CheckResult CheckStatus()
return result;
}

#region Check by uninstall guids
string[] guids;
if (Utils.Is64bit())
{
string keySection = Utils.CheckUninstallString(x64GUID, "DisplayName");
if (!string.IsNullOrEmpty(keySection))
{
result.state = CheckState.INSTALLED;
return result;
}

// Visual C++ 2015-2019 Redistributable x64 (14.24.28127.4)
keySection = Utils.CheckUninstallString("{282975d8-55fe-4991-bbbb-06a72581ce58}", "DisplayName");
if (!string.IsNullOrEmpty(keySection))
{
result.state = CheckState.INSTALLED;
return result;
}
// Visual C++ 2015-2022 Redistributable x64 (14.36.32532.0)
keySection = Utils.CheckUninstallString("{8bdfe669-9705-4184-9368-db9ce581e0e7}", "DisplayName");
if (!string.IsNullOrEmpty(keySection))
{
result.state = CheckState.INSTALLED;
return result;
}
guids = new string[]
{
//"{282975d8-55fe-4991-bbbb-06a72581ce58}", // Visual C++ 2015-2019 Redistributable x64 (14.24.28127.4)
"{8bdfe669-9705-4184-9368-db9ce581e0e7}", // Visual C++ 2015-2022 Redistributable x64 (14.36.32532.0)
"{1CA7421F-A225-4A9C-B320-A36981A2B789}", // Visual C++ 2015-2022 Redistributable x64 (14.38.33130.0)
};
}
else
{
string keySection = Utils.CheckUninstallString(x86GUID, "DisplayName");
if (!string.IsNullOrEmpty(keySection))
{
result.state = CheckState.INSTALLED;
return result;
}
guids = new string[]
{
//"{e31cb1a4-76b5-46a5-a084-3fa419e82201}", // Visual C++ 2015-2019 Redistributable x86 (14.24.28127.4)
"{410c0ee1-00bb-41b6-9772-e12c2828b02f}", // Visual C++ 2015-2022 Redistributable x86 (14.36.32532.0)
"{DF1B52DF-C88E-4DDF-956B-6E7A03327F46}", // Visual C++ 2015-2022 Redistributable x64 (14.38.33130.0)
};

// Visual C++ 2015-2019 Redistributable x86 (14.24.28127.4)
keySection = Utils.CheckUninstallString("{e31cb1a4-76b5-46a5-a084-3fa419e82201}", "DisplayName");
if (!string.IsNullOrEmpty(keySection))
{
result.state = CheckState.INSTALLED;
return result;
}
// Visual C++ 2015-2022 Redistributable x86 (14.36.32532.0)
keySection = Utils.CheckUninstallString("{410c0ee1-00bb-41b6-9772-e12c2828b02f}", "DisplayName");
}

for (int i = 0; i < guids.Length; i++)
{
string keySection = Utils.CheckUninstallString(guids[i], "DisplayName");
if (!string.IsNullOrEmpty(keySection))
{
result.state = CheckState.INSTALLED;
return result;
}
}
#endregion

#region Check by system files
string InstallDir = Environment.GetEnvironmentVariable("SystemRoot") + "\\system32\\";
string[] dll = new string[5];
//CRT
dll[0] = "msvcp140.dll";
//MFC
dll[1] = "mfc140.dll";
dll[2] = "mfc140u.dll";
dll[3] = "mfcm140.dll";
dll[4] = "mfcm140u.dll";
string[] dll = new string[]
{
//CRT
"msvcp140.dll",
//MFC
"mfc140.dll",
"mfc140u.dll",
"mfcm140.dll",
"mfcm140u.dll",
//RUNTIME
"vcruntime140.dll",
"vcruntime140_1.dll" //x64 only
};

for (int i = 0; i < dll.Length; i++)
{
//Skip x64 only files
if (i + 1 == dll.Length && !Utils.Is64bit())
break;

if (!File.Exists(InstallDir + dll[i]))
{
result.state = CheckState.NOT_INSTALLED;
return result;
}
}
#endregion

result.state = CheckState.INSTALLED;
return result;
Expand Down
92 changes: 77 additions & 15 deletions mediaportal/MPE/MpeCore/Classes/DependencyItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ namespace MpeCore.Classes
{
public class DependencyItem
{
private string _name;
private string _message;
private VersionInfo _MinVersion = new VersionInfo();
private VersionInfo _MaxVersion = new VersionInfo();

public DependencyItem()
{
Type = string.Empty;
Id = string.Empty;
MinVersion = new VersionInfo();
MaxVersion = new VersionInfo();
WarnOnly = true;
Message = string.Empty;
Name = string.Empty;
Expand All @@ -41,34 +44,90 @@ public DependencyItem(string type)
{
Type = type;
Id = string.Empty;
MinVersion = new VersionInfo();
MaxVersion = new VersionInfo();
WarnOnly = true;
Message = string.Empty;
Name = string.Empty;
}

public string Type { get; set; }

public string Id { get; set; }
public VersionInfo MinVersion { get; set; }
public VersionInfo MaxVersion { get; set; }
public bool WarnOnly { get; set; }

private string _message;
public VersionInfo MinVersion
{
get
{
return this._MinVersion;
}
set
{
//Check old MP versioning
if (this.Type != "MediaPortal" || value.Major != "1" || value.Minor != "1" || value.Build != "6" || value.Revision != "27644")
{
this._MinVersion = value;
this._message = null; //force to reload the message
}
}
}

public VersionInfo MaxVersion
{
get
{
return this._MaxVersion;
}
set
{
//Check old MP versioning
if (this.Type != "MediaPortal" || value.Major != "1" || value.Minor != "1" || value.Build != "6" || value.Revision != "27644")
{
this._MaxVersion = value;
this._message = null; //force to reload the message
}
}
}

public bool WarnOnly { get; set; }

public string Message
{
get
{
if (!string.IsNullOrEmpty(_message)
) return _message;
return string.Format("requires {0} version {1} to {2}.", Name, MinVersion, MaxVersion);
if (this._message == null)
{
if (!this.MinVersion.IsAnyVersion && this.MaxVersion.IsAnyVersion)
{
this._message = string.Format("Requires {0} {1} or higher!",
this.Name,
this.MinVersion);
}
else if (this.MinVersion.IsAnyVersion && !this.MaxVersion.IsAnyVersion)
{
this._message = string.Format("Requires {0} {1} or lower!",
this.Name,
this.MaxVersion);
}
else if (!this.MinVersion.IsAnyVersion && !this.MaxVersion.IsAnyVersion)
{
if (this.MinVersion.ToString().Equals(this.MaxVersion.ToString()))
this._message = string.Format("Requires {0} {1}!",
this.Name,
this.MinVersion);
else
this._message = string.Format("Requires {0} from {1} to {2}!",
this.Name,
this.MinVersion,
this.MaxVersion);
}
else
this._message = string.Empty;
}

return this._message;
}
set { _message = value; }
}

private string _name;

public string Name
{
get
Expand All @@ -81,8 +140,11 @@ public string Name

public override string ToString()
{
return string.Format("{0}{1}({2})-({3})", Type,
"", MinVersion, MaxVersion);
return string.Format("{0}{1} ({2})-({3})",
Type,
string.Empty,
MinVersion,
MaxVersion);
}
}
}
44 changes: 32 additions & 12 deletions mediaportal/MPE/MpeCore/Classes/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public override int GetHashCode()
/// </summary>
public VersionInfo()
{
Major = "0";
Minor = "0";
Build = "0";
Revision = "0";
Major = "*";
Minor = "*";
Build = "*";
Revision = "*";
}

public VersionInfo(Version version)
Expand All @@ -75,32 +75,41 @@ public VersionInfo(Version version)

public string Major
{
get { return string.IsNullOrEmpty(_major) ? "0" : _major; }
set { _major = value; }
get { return string.IsNullOrEmpty(_major) ? "*" : _major; }
set { _major = SanityValue(value); }
}

private string _minor;

public string Minor
{
get { return string.IsNullOrEmpty(_minor) ? "0" : _minor; }
set { _minor = value; }
get { return string.IsNullOrEmpty(_minor) ? "*" : _minor; }
set { _minor = SanityValue(value); }
}

private string _build;

public string Build
{
get { return string.IsNullOrEmpty(_build) ? "0" : _build; }
set { _build = value; }
get { return string.IsNullOrEmpty(_build) ? "*" : _build; }
set { _build = SanityValue(value); }
}

private string _revision;

public string Revision
{
get { return string.IsNullOrEmpty(_revision) ? "0" : _revision; }
set { _revision = value; }
get { return string.IsNullOrEmpty(_revision) ? "*" : _revision; }
set { _revision = SanityValue(value); }
}

public bool IsAnyVersion
{
get
{
return this._major == "*" && this._minor == "*"
&& this._build == "*" && this._revision == "*";
}
}

public static VersionInfo Parse(string s)
Expand Down Expand Up @@ -206,5 +215,16 @@ private static int CompareNumber(string s1, string s2)
{
return v1.CompareTo(v2) > 0;
}


private static string SanityValue(string strValue)
{
int i;
if (string.IsNullOrWhiteSpace(strValue) || !int.TryParse(strValue, out i))
return "*";

return i.ToString();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,32 @@ namespace MpeCore.Classes.VersionProvider
{
public class MediaPortalVersion : VersionProvider
{
public static readonly VersionInfo MinimumMPVersionRequired = new VersionInfo(MediaPortal.Common.Utils.CompatibilityManager.GetCurrentVersion());

public override string DisplayName
{
get { return "MediaPortal"; }
}

public override bool Validate(DependencyItem dependency)
{
if (dependency.MinVersion < MinimumMPVersionRequired)
return false;

return base.Validate(dependency);
}

public override VersionInfo Version(string id)
{
return new VersionInfo(MediaPortal.Common.Utils.CompatibilityManager.GetCurrentVersion());
RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\MediaPortal");
if (key != null)
{
VersionInfo version = new VersionInfo
{
Build = ((int)key.GetValue("VersionBuild", 0)).ToString(),
Major = ((int)key.GetValue("VersionMajor", 0)).ToString(),
Minor = ((int)key.GetValue("VersionMinor", 0)).ToString(),
Revision = ((int)key.GetValue("VersionRevision", 0)).ToString(),
};
key.Close();
return version;
}
return new VersionInfo(MediaPortal.Common.Utils.CompatibilityManager.AppVersion);
}
}
}
2 changes: 1 addition & 1 deletion mediaportal/MPE/MpeInstaller/Dialogs/DependencyForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public DependencyForm(MpeCore.PackageClass pak)
package = pak;
this.Text = pak.GeneralInfo.Name + " - Dependencies";
versionLabel.Text = string.Format("MediaPortal {0} (API: {1}) - Skin {2}",
MediaPortal.Common.Utils.CompatibilityManager.MediaPortalReleaseForApiVersion(MediaPortal.Common.Utils.CompatibilityManager.GetCurrentMaxVersion()),
MediaPortal.Common.Utils.CompatibilityManager.AppVersion,
MediaPortal.Common.Utils.CompatibilityManager.GetCurrentVersion(),
MediaPortal.Common.Utils.CompatibilityManager.SkinVersion);
generalDepBindSource.DataSource = package.Dependencies.Items;
Expand Down
Loading

0 comments on commit deb96e0

Please sign in to comment.