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.

255 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1994-95 Microsoft Corporation
  3. Module Name:
  4. liccol.cpp
  5. Abstract:
  6. License collection 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(CLicenses, CCmdTarget)
  20. BEGIN_MESSAGE_MAP(CLicenses, CCmdTarget)
  21. //{{AFX_MSG_MAP(CLicenses)
  22. // NOTE - the ClassWizard will add and remove mapping macros here.
  23. //}}AFX_MSG_MAP
  24. END_MESSAGE_MAP()
  25. BEGIN_DISPATCH_MAP(CLicenses, CCmdTarget)
  26. //{{AFX_DISPATCH_MAP(CLicenses)
  27. DISP_PROPERTY_EX(CLicenses, "Application", GetApplication, SetNotSupported, VT_DISPATCH)
  28. DISP_PROPERTY_EX(CLicenses, "Parent", GetParent, SetNotSupported, VT_DISPATCH)
  29. DISP_PROPERTY_EX(CLicenses, "Count", GetCount, SetNotSupported, VT_I4)
  30. DISP_FUNCTION(CLicenses, "Item", GetItem, VT_DISPATCH, VTS_VARIANT)
  31. //}}AFX_DISPATCH_MAP
  32. END_DISPATCH_MAP()
  33. CLicenses::CLicenses(CCmdTarget* pParent, CObArray* pObArray)
  34. /*++
  35. Routine Description:
  36. Constructor for license collection object.
  37. Arguments:
  38. pParent - creator of object.
  39. pObArray - object list to enumerate.
  40. Return Values:
  41. None.
  42. --*/
  43. {
  44. EnableAutomation();
  45. #ifdef ENABLE_PARENT_CHECK
  46. ASSERT(pParent &&
  47. (pParent->IsKindOf(RUNTIME_CLASS(CProduct)) ||
  48. pParent->IsKindOf(RUNTIME_CLASS(CController))));
  49. #endif // ENABLE_PARENT_CHECK
  50. ASSERT_VALID(pObArray);
  51. m_pParent = pParent;
  52. m_pObArray = pObArray;
  53. }
  54. CLicenses::~CLicenses()
  55. /*++
  56. Routine Description:
  57. Destructor for license collection object.
  58. Arguments:
  59. None.
  60. Return Values:
  61. None.
  62. --*/
  63. {
  64. //
  65. // Nothing to do here.
  66. //
  67. }
  68. void CLicenses::OnFinalRelease()
  69. /*++
  70. Routine Description:
  71. When the last reference for an automation object is released
  72. OnFinalRelease is called. This implementation deletes object.
  73. Arguments:
  74. None.
  75. Return Values:
  76. None.
  77. --*/
  78. {
  79. delete this;
  80. }
  81. LPDISPATCH CLicenses::GetApplication()
  82. /*++
  83. Routine Description:
  84. Returns the application object.
  85. Arguments:
  86. None.
  87. Return Values:
  88. VT_DISPATCH.
  89. --*/
  90. {
  91. return theApp.GetAppIDispatch();
  92. }
  93. long CLicenses::GetCount()
  94. /*++
  95. Routine Description:
  96. Returns number of items in collection.
  97. Arguments:
  98. None.
  99. Return Values:
  100. VT_I4.
  101. --*/
  102. {
  103. ASSERT_VALID(m_pObArray);
  104. return (long)m_pObArray->GetSize();
  105. }
  106. LPDISPATCH CLicenses::GetItem(const VARIANT FAR& index)
  107. /*++
  108. Routine Description:
  109. Retrieves specified license object from collection.
  110. Arguments:
  111. index - optional argument that may a number (VT_I4)
  112. indicating the position within collection.
  113. Return Values:
  114. VT_DISPATCH or VT_EMPTY.
  115. --*/
  116. {
  117. ASSERT_VALID(m_pObArray);
  118. LPDISPATCH lpdispatch = NULL;
  119. CLicense* pLicense;
  120. INT_PTR iLicense;
  121. VARIANT vLicense;
  122. VariantInit(&vLicense);
  123. iLicense = m_pObArray->GetSize();
  124. if (NULL != iLicense)
  125. {
  126. if (SUCCEEDED(VariantChangeType(&vLicense, (VARIANT FAR *)&index, 0, VT_I4)))
  127. {
  128. if (((int)vLicense.lVal >= 0) && ((int)vLicense.lVal < iLicense))
  129. {
  130. pLicense = (CLicense*)m_pObArray->GetAt((int)vLicense.lVal);
  131. if (NULL != pLicense)
  132. {
  133. ASSERT(pLicense->IsKindOf(RUNTIME_CLASS(CLicense)));
  134. lpdispatch = pLicense->GetIDispatch(TRUE);
  135. }
  136. }
  137. }
  138. }
  139. return lpdispatch;
  140. }
  141. LPDISPATCH CLicenses::GetParent()
  142. /*++
  143. Routine Description:
  144. Returns the parent of the object.
  145. Arguments:
  146. None.
  147. Return Values:
  148. VT_DISPATCH.
  149. --*/
  150. {
  151. return m_pParent ? m_pParent->GetIDispatch(TRUE) : NULL;
  152. }