diff options
Diffstat (limited to 'src/burn')
-rw-r--r-- | src/burn/engine/registration.cpp | 2 | ||||
-rw-r--r-- | src/burn/engine/relatedbundle.cpp | 55 | ||||
-rw-r--r-- | src/burn/engine/relatedbundle.h | 3 |
3 files changed, 60 insertions, 0 deletions
diff --git a/src/burn/engine/registration.cpp b/src/burn/engine/registration.cpp index 9cc4b199..ffeb39d1 100644 --- a/src/burn/engine/registration.cpp +++ b/src/burn/engine/registration.cpp | |||
@@ -585,6 +585,8 @@ extern "C" HRESULT RegistrationDetectRelatedBundles( | |||
585 | hr = RelatedBundlesInitializeForScope(FALSE, pRegistration, &pRegistration->relatedBundles); | 585 | hr = RelatedBundlesInitializeForScope(FALSE, pRegistration, &pRegistration->relatedBundles); |
586 | ExitOnFailure(hr, "Failed to initialize per-user related bundles."); | 586 | ExitOnFailure(hr, "Failed to initialize per-user related bundles."); |
587 | 587 | ||
588 | RelatedBundlesSort(&pRegistration->relatedBundles); | ||
589 | |||
588 | LExit: | 590 | LExit: |
589 | return hr; | 591 | return hr; |
590 | } | 592 | } |
diff --git a/src/burn/engine/relatedbundle.cpp b/src/burn/engine/relatedbundle.cpp index e2380aab..1eafef07 100644 --- a/src/burn/engine/relatedbundle.cpp +++ b/src/burn/engine/relatedbundle.cpp | |||
@@ -4,6 +4,11 @@ | |||
4 | 4 | ||
5 | // internal function declarations | 5 | // internal function declarations |
6 | 6 | ||
7 | static __callback int __cdecl CompareRelatedBundles( | ||
8 | __in void* pvContext, | ||
9 | __in const void* pvLeft, | ||
10 | __in const void* pvRight | ||
11 | ); | ||
7 | static HRESULT LoadIfRelatedBundle( | 12 | static HRESULT LoadIfRelatedBundle( |
8 | __in BOOL fPerMachine, | 13 | __in BOOL fPerMachine, |
9 | __in HKEY hkUninstallKey, | 14 | __in HKEY hkUninstallKey, |
@@ -128,9 +133,59 @@ LExit: | |||
128 | return hr; | 133 | return hr; |
129 | } | 134 | } |
130 | 135 | ||
136 | extern "C" void RelatedBundlesSort( | ||
137 | __in BURN_RELATED_BUNDLES* pRelatedBundles | ||
138 | ) | ||
139 | { | ||
140 | qsort_s(pRelatedBundles->rgRelatedBundles, pRelatedBundles->cRelatedBundles, sizeof(BURN_RELATED_BUNDLE), CompareRelatedBundles, NULL); | ||
141 | } | ||
142 | |||
131 | 143 | ||
132 | // internal helper functions | 144 | // internal helper functions |
133 | 145 | ||
146 | static __callback int __cdecl CompareRelatedBundles( | ||
147 | __in void* /*pvContext*/, | ||
148 | __in const void* pvLeft, | ||
149 | __in const void* pvRight | ||
150 | ) | ||
151 | { | ||
152 | int ret = 0; | ||
153 | const BURN_RELATED_BUNDLE* pBundleLeft = static_cast<const BURN_RELATED_BUNDLE*>(pvLeft); | ||
154 | const BURN_RELATED_BUNDLE* pBundleRight = static_cast<const BURN_RELATED_BUNDLE*>(pvRight); | ||
155 | |||
156 | // Sort by relation type, then version, then bundle id. | ||
157 | if (pBundleLeft->relationType != pBundleRight->relationType) | ||
158 | { | ||
159 | // Upgrade bundles last, everything else according to the enum. | ||
160 | if (BOOTSTRAPPER_RELATION_UPGRADE == pBundleLeft->relationType) | ||
161 | { | ||
162 | ret = 1; | ||
163 | } | ||
164 | else if (BOOTSTRAPPER_RELATION_UPGRADE == pBundleRight->relationType) | ||
165 | { | ||
166 | ret = -1; | ||
167 | } | ||
168 | else if (pBundleLeft->relationType < pBundleRight->relationType) | ||
169 | { | ||
170 | ret = -1; | ||
171 | } | ||
172 | else | ||
173 | { | ||
174 | ret = 1; | ||
175 | } | ||
176 | } | ||
177 | else | ||
178 | { | ||
179 | VerCompareParsedVersions(pBundleLeft->pVersion, pBundleRight->pVersion, &ret); | ||
180 | if (0 == ret) | ||
181 | { | ||
182 | ret = ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pBundleLeft->package.sczId, -1, pBundleRight->package.sczId, -1) - 2; | ||
183 | } | ||
184 | } | ||
185 | |||
186 | return ret; | ||
187 | } | ||
188 | |||
134 | static HRESULT LoadIfRelatedBundle( | 189 | static HRESULT LoadIfRelatedBundle( |
135 | __in BOOL fPerMachine, | 190 | __in BOOL fPerMachine, |
136 | __in HKEY hkUninstallKey, | 191 | __in HKEY hkUninstallKey, |
diff --git a/src/burn/engine/relatedbundle.h b/src/burn/engine/relatedbundle.h index 0113c8ee..be039421 100644 --- a/src/burn/engine/relatedbundle.h +++ b/src/burn/engine/relatedbundle.h | |||
@@ -19,6 +19,9 @@ HRESULT RelatedBundleFindById( | |||
19 | __in_z LPCWSTR wzId, | 19 | __in_z LPCWSTR wzId, |
20 | __out BURN_RELATED_BUNDLE** ppRelatedBundle | 20 | __out BURN_RELATED_BUNDLE** ppRelatedBundle |
21 | ); | 21 | ); |
22 | void RelatedBundlesSort( | ||
23 | __in BURN_RELATED_BUNDLES* pRelatedBundles | ||
24 | ); | ||
22 | 25 | ||
23 | #if defined(__cplusplus) | 26 | #if defined(__cplusplus) |
24 | } | 27 | } |