Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

192 lines
6.0 KiB

  1. /***************************************************************************/
  2. /** Microsoft Windows **/
  3. /** Copyright(c) Microsoft Corp., 1995-1996 **/
  4. /***************************************************************************/
  5. /****************************************************************************
  6. erncvrsn.hpp
  7. Jun. 96 LenS
  8. Versioning.
  9. InitOurVersion() is called when constructing NCUI. After that local version
  10. information is available in the static variables below.
  11. GetVersionData() is used to extract versioning information from T120
  12. messages received.
  13. ****************************************************************************/
  14. #include "precomp.h"
  15. #include "ernccons.h"
  16. #include "nccglbl.hpp"
  17. #include "erncvrsn.hpp"
  18. #include <cuserdta.hpp>
  19. #include <version.h>
  20. #include "ernccm.hpp"
  21. // INFO_NOT_RETAIL: Product is not a retail release.
  22. #define INFO_NOT_RETAIL 0x00000001
  23. GUID g_csguidVerInfo = GUID_VERSION;
  24. UINT g_nVersionRecords;
  25. GCCUserData ** g_ppVersionUserData;
  26. T120PRODUCTVERSION g_OurVersion;
  27. CNCUserDataList *g_pUserDataVersion = NULL;
  28. HRESULT InitOurVersion(void)
  29. {
  30. HRESULT hr;
  31. ASSERT(NULL == g_pUserDataVersion);
  32. DBG_SAVE_FILE_LINE
  33. g_pUserDataVersion = new CNCUserDataList();
  34. if (NULL != g_pUserDataVersion)
  35. {
  36. // First get the entries that are in the binary.
  37. g_OurVersion.dwVersion = VER_PRODUCTVERSION_DW;
  38. g_OurVersion.dwExpirationDate = 0xffffffff;
  39. g_OurVersion.dwInformation = 0;
  40. // We no longer go to the registry for these. We just take the version
  41. // from the binaries.
  42. g_OurVersion.dwEarliestPossibleVersion = VER_EARLIEST_COMPATIBLE_DW;
  43. g_OurVersion.dwMaxDifference = VER_MAX_DIFFERENCE;
  44. // Save our version info in a user data list structure, ready to distribute.
  45. hr = g_pUserDataVersion->AddUserData(&g_csguidVerInfo, sizeof(g_OurVersion), &g_OurVersion);
  46. if (NO_ERROR == hr)
  47. {
  48. hr = g_pUserDataVersion->GetUserDataList(&g_nVersionRecords, &g_ppVersionUserData);
  49. }
  50. }
  51. else
  52. {
  53. hr = UI_RC_OUT_OF_MEMORY;
  54. }
  55. return hr;
  56. }
  57. void ReleaseOurVersion(void)
  58. {
  59. delete g_pUserDataVersion;
  60. g_pUserDataVersion = NULL;
  61. }
  62. PT120PRODUCTVERSION GetVersionData(UINT nRecords, GCCUserData **ppUserData)
  63. {
  64. UINT nData;
  65. LPVOID pData;
  66. // If no version info or bad version info, then do not
  67. // return any version.
  68. if (NO_ERROR == ::GetUserData(nRecords, ppUserData, &g_csguidVerInfo, &nData, &pData))
  69. {
  70. if (nData >= sizeof(T120PRODUCTVERSION))
  71. {
  72. return (PT120PRODUCTVERSION) pData;
  73. }
  74. }
  75. return NULL;
  76. }
  77. BOOL TimeExpired(DWORD dwTime)
  78. {
  79. SYSTEMTIME st;
  80. DWORD dwLocalTime;
  81. ::GetLocalTime(&st);
  82. dwLocalTime = ((((unsigned long)st.wYear) << 16) |
  83. (st.wMonth << 8) |
  84. st.wDay);
  85. return (dwLocalTime >= dwTime);
  86. }
  87. STDMETHODIMP DCRNCConferenceManager::
  88. CheckVersion ( PT120PRODUCTVERSION pRemoteVersion )
  89. {
  90. DWORD Status = NO_ERROR;
  91. // Don't bother with any checks if the versions are the same
  92. // or the remote site does not have versioning information.
  93. if ((NULL != pRemoteVersion) && (g_OurVersion.dwVersion != pRemoteVersion->dwVersion))
  94. {
  95. if (g_OurVersion.dwVersion < pRemoteVersion->dwVersion)
  96. {
  97. // Remote version is newer than local version.
  98. // Check to see if the local version is earlier than the mandatory and
  99. // recommended versions on the remote node.
  100. // Also, don't bother to check if the remote node has expired, because
  101. // if it has the local node will have also expired and the user will
  102. // already have been bugged by the time-bomb.
  103. if (g_OurVersion.dwVersion < pRemoteVersion->dwEarliestPossibleVersion)
  104. {
  105. Status = UI_RC_VERSION_LOCAL_INCOMPATIBLE;
  106. }
  107. else if (((DWORD)(pRemoteVersion->dwVersion - g_OurVersion.dwVersion)) >
  108. pRemoteVersion->dwMaxDifference)
  109. {
  110. Status = UI_RC_VERSION_LOCAL_UPGRADE_RECOMMENDED;
  111. }
  112. else
  113. {
  114. Status = UI_RC_VERSION_REMOTE_NEWER;
  115. }
  116. }
  117. else
  118. {
  119. // Local version is newer than remote version.
  120. // Check to see if the remote version is earlier than the mandatory and
  121. // recommended versions on the local node, and whether the remote node
  122. // has expired.
  123. if (pRemoteVersion->dwVersion < g_OurVersion.dwEarliestPossibleVersion)
  124. {
  125. Status = UI_RC_VERSION_REMOTE_INCOMPATIBLE;
  126. }
  127. else if (DWVERSION_NM_1 == pRemoteVersion->dwVersion)
  128. {
  129. // Unfortunately, v1.0 was marked as "pre-release" with a timebomb
  130. // of 10-15-96. Special case this version and return a simpler error
  131. // message.
  132. Status = UI_RC_VERSION_REMOTE_OLDER;
  133. }
  134. else if (DWVERSION_NM_2 == pRemoteVersion->dwVersion)
  135. {
  136. // Unfortunately, v2.0 was marked with INFO_NOT_RETAIL and a timebomb
  137. // of 09-30-97. Special case this and return a simpler error message
  138. Status = UI_RC_VERSION_REMOTE_OLDER;
  139. }
  140. else if ((INFO_NOT_RETAIL & pRemoteVersion->dwInformation) &&
  141. TimeExpired(pRemoteVersion->dwExpirationDate))
  142. {
  143. Status = UI_RC_VERSION_REMOTE_EXPIRED;
  144. }
  145. else if (((DWORD)(g_OurVersion.dwVersion - pRemoteVersion->dwVersion)) >
  146. g_OurVersion.dwMaxDifference)
  147. {
  148. Status = UI_RC_VERSION_REMOTE_UPGRADE_RECOMMENDED;
  149. }
  150. else
  151. {
  152. Status = UI_RC_VERSION_REMOTE_OLDER;
  153. }
  154. }
  155. }
  156. return Status;
  157. }