Leaked source code of windows server 2003
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.

355 lines
5.0 KiB

  1. /*++
  2. Copyright (c) 1994-95 Microsoft Corporation
  3. Module Name:
  4. licobj.cpp
  5. Abstract:
  6. License object implementation.
  7. Author:
  8. Don Ryan (donryan) 04-Jan-1995
  9. Environment:
  10. User Mode - Win32
  11. Revision History:
  12. --*/
  13. #include "stdafx.h"
  14. #include "llsmgr.h"
  15. #ifdef _DEBUG
  16. #undef THIS_FILE
  17. static char BASED_CODE THIS_FILE[] = __FILE__;
  18. #endif
  19. IMPLEMENT_DYNCREATE(CLicense, CCmdTarget)
  20. BEGIN_MESSAGE_MAP(CLicense, CCmdTarget)
  21. //{{AFX_MSG_MAP(CLicense)
  22. // NOTE - the ClassWizard will add and remove mapping macros here.
  23. //}}AFX_MSG_MAP
  24. END_MESSAGE_MAP()
  25. BEGIN_DISPATCH_MAP(CLicense, CCmdTarget)
  26. //{{AFX_DISPATCH_MAP(CLicense)
  27. DISP_PROPERTY_EX(CLicense, "Application", GetApplication, SetNotSupported, VT_DISPATCH)
  28. DISP_PROPERTY_EX(CLicense, "Parent", GetParent, SetNotSupported, VT_DISPATCH)
  29. DISP_PROPERTY_EX(CLicense, "Date", GetDate, SetNotSupported, VT_DATE)
  30. DISP_PROPERTY_EX(CLicense, "Description", GetDescription, SetNotSupported, VT_BSTR)
  31. DISP_PROPERTY_EX(CLicense, "ProductName", GetProductName, SetNotSupported, VT_BSTR)
  32. DISP_PROPERTY_EX(CLicense, "Quantity", GetQuantity, SetNotSupported, VT_I4)
  33. DISP_PROPERTY_EX(CLicense, "UserName", GetUserName, SetNotSupported, VT_BSTR)
  34. DISP_DEFVALUE(CLicense, "ProductName")
  35. //}}AFX_DISPATCH_MAP
  36. END_DISPATCH_MAP()
  37. CLicense::CLicense(
  38. CCmdTarget* pParent,
  39. LPCTSTR pProduct,
  40. LPCTSTR pUser,
  41. long lDate,
  42. long lQuantity,
  43. LPCTSTR pDescription
  44. )
  45. /*++
  46. Routine Description:
  47. Constructor for license object.
  48. Arguments:
  49. pParent - creator of object.
  50. pUser - user who purchased license.
  51. pProduct - server product licensed.
  52. lDate - date of purchase.
  53. lQuantity - number of licenses purchased.
  54. pDescription - user-defined comment.
  55. Return Values:
  56. None.
  57. --*/
  58. {
  59. EnableAutomation();
  60. #ifdef ENABLE_PARENT_CHECK
  61. ASSERT(pParent &&
  62. (pParent->IsKindOf(RUNTIME_CLASS(CProduct)) ||
  63. pParent->IsKindOf(RUNTIME_CLASS(CController))));
  64. #endif // ENABLE_PARENT_CHECK
  65. m_pParent = pParent;
  66. ASSERT(pUser && *pUser);
  67. ASSERT(pProduct && *pProduct);
  68. m_strUser = pUser;
  69. m_strProduct = pProduct;
  70. m_strDescription = pDescription;
  71. m_lQuantity = lQuantity;
  72. m_lDate = lDate;
  73. }
  74. CLicense::~CLicense()
  75. /*++
  76. Routine Description:
  77. Destructor for license object.
  78. Arguments:
  79. None.
  80. Return Values:
  81. None.
  82. --*/
  83. {
  84. //
  85. // Nothing to do here.
  86. //
  87. }
  88. void CLicense::OnFinalRelease()
  89. /*++
  90. Routine Description:
  91. When the last reference for an automation object is released
  92. OnFinalRelease is called. This implementation deletes object.
  93. Arguments:
  94. None.
  95. Return Values:
  96. None.
  97. --*/
  98. {
  99. delete this;
  100. }
  101. LPDISPATCH CLicense::GetApplication()
  102. /*++
  103. Routine Description:
  104. Returns the application object.
  105. Arguments:
  106. None.
  107. Return Values:
  108. VT_DISPATCH.
  109. --*/
  110. {
  111. return theApp.GetAppIDispatch();
  112. }
  113. DATE CLicense::GetDate()
  114. /*++
  115. Routine Description:
  116. Returns the date of the purchase.
  117. Arguments:
  118. None.
  119. Return Values:
  120. VT_DATE.
  121. --*/
  122. {
  123. return SecondsSince1980ToDate(m_lDate);
  124. }
  125. BSTR CLicense::GetDescription()
  126. /*++
  127. Routine Description:
  128. Returns the user-defined message describing the purchase.
  129. Arguments:
  130. None.
  131. Return Values:
  132. VT_BSTR.
  133. --*/
  134. {
  135. return m_strDescription.AllocSysString();
  136. }
  137. LPDISPATCH CLicense::GetParent()
  138. /*++
  139. Routine Description:
  140. Returns the parent of the object.
  141. Arguments:
  142. None.
  143. Return Values:
  144. VT_DISPATCH.
  145. --*/
  146. {
  147. return m_pParent ? m_pParent->GetIDispatch(TRUE) : NULL;
  148. }
  149. BSTR CLicense::GetProductName()
  150. /*++
  151. Routine Description:
  152. Returns the name of the server product purchased.
  153. Arguments:
  154. None.
  155. Return Values:
  156. VT_BSTR.
  157. --*/
  158. {
  159. return m_strProduct.AllocSysString();
  160. }
  161. long CLicense::GetQuantity()
  162. /*++
  163. Routine Description:
  164. Returns the number of clients purchased or deleted.
  165. Arguments:
  166. None.
  167. Return Values:
  168. VT_I4.
  169. --*/
  170. {
  171. return m_lQuantity;
  172. }
  173. BSTR CLicense::GetUserName()
  174. /*++
  175. Routine Description:
  176. Returns the name of the administrator made the purchase.
  177. Arguments:
  178. None.
  179. Return Values:
  180. VT_BSTR.
  181. --*/
  182. {
  183. return m_strUser.AllocSysString();
  184. }
  185. BSTR CLicense::GetDateString()
  186. /*++
  187. Routine Description:
  188. Returns the date as a string.
  189. Arguments:
  190. None.
  191. Return Values:
  192. VT_BSTR.
  193. --*/
  194. {
  195. VARIANT vaIn;
  196. VARIANT vaOut;
  197. VariantInit(&vaIn);
  198. VariantInit(&vaOut);
  199. vaIn.vt = VT_DATE;
  200. vaIn.date = SecondsSince1980ToDate(m_lDate);
  201. BSTR bstrDate = NULL;
  202. if (SUCCEEDED(VariantChangeType(&vaOut, &vaIn, 0, VT_BSTR)))
  203. {
  204. bstrDate = vaOut.bstrVal;
  205. }
  206. return bstrDate;
  207. }