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.

296 lines
6.7 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. #include"stdafx.h"
  3. #include"rnodes.h"
  4. #include"resource.h"
  5. //----------------------------------------------------------------------------------
  6. CResultNode::CResultNode( )
  7. {
  8. m_pszConnectionName = NULL;
  9. m_pszTransportTypeName = NULL;
  10. m_pszTypeName = NULL;
  11. m_pszComment = NULL;
  12. m_pCfgcomp = NULL;
  13. SetNodeType( RESULT_NODE );
  14. m_bEditMode = FALSE;
  15. }
  16. //CResultNode( CResultNode& x );
  17. //----------------------------------------------------------------------------------
  18. CResultNode::~CResultNode( )
  19. {
  20. ODS( L"CResultNode::dtor -- Deleting result node\n" );
  21. if( m_pszConnectionName != NULL )
  22. {
  23. delete[] m_pszConnectionName;
  24. }
  25. if( m_pszTransportTypeName != NULL )
  26. {
  27. delete[] m_pszTransportTypeName;
  28. }
  29. if( m_pszTypeName != NULL )
  30. {
  31. delete[] m_pszTypeName;
  32. }
  33. if( m_pszComment != NULL )
  34. {
  35. delete[] m_pszComment;
  36. }
  37. }
  38. //----------------------------------------------------------------------------------
  39. LPTSTR CResultNode::GetConName( )
  40. {
  41. return m_pszConnectionName;
  42. }
  43. //----------------------------------------------------------------------------------
  44. LPTSTR CResultNode::GetTTName( )
  45. {
  46. return m_pszTransportTypeName;
  47. }
  48. //----------------------------------------------------------------------------------
  49. LPTSTR CResultNode::GetTypeName( )
  50. {
  51. return m_pszTypeName;
  52. }
  53. //----------------------------------------------------------------------------------
  54. LPTSTR CResultNode::GetComment( )
  55. {
  56. return m_pszComment;
  57. }
  58. //----------------------------------------------------------------------------------
  59. DWORD CResultNode::GetImageIdx( )
  60. {
  61. return m_dwImageidx;
  62. }
  63. //----------------------------------------------------------------------------------
  64. int CResultNode::SetConName( LPTSTR psz , int cwSz )
  65. {
  66. if( IsBadReadPtr( psz , cwSz * sizeof( TCHAR ) ) )
  67. {
  68. return 0;
  69. }
  70. if( m_pszConnectionName != NULL )
  71. {
  72. delete[] m_pszConnectionName;
  73. m_pszConnectionName = NULL;
  74. }
  75. m_pszConnectionName = ( LPTSTR ) new TCHAR[ cwSz + 1];
  76. if( m_pszConnectionName == NULL )
  77. {
  78. return 0;
  79. }
  80. lstrcpy( m_pszConnectionName , psz );
  81. return cwSz;
  82. }
  83. //----------------------------------------------------------------------------------
  84. int CResultNode::SetTTName( LPTSTR psz , int cwSz )
  85. {
  86. if( IsBadReadPtr( psz , cwSz * sizeof( TCHAR ) ) )
  87. {
  88. return 0;
  89. }
  90. m_pszTransportTypeName = ( LPTSTR ) new TCHAR[ cwSz + 1];
  91. if( m_pszTransportTypeName == NULL )
  92. {
  93. return 0;
  94. }
  95. lstrcpy( m_pszTransportTypeName , psz );
  96. return cwSz;
  97. }
  98. //----------------------------------------------------------------------------------
  99. int CResultNode::SetTypeName( LPTSTR psz , int cwSz)
  100. {
  101. if( IsBadReadPtr( psz , cwSz * sizeof( TCHAR ) ) )
  102. {
  103. return 0;
  104. }
  105. m_pszTypeName = ( LPTSTR ) new TCHAR[ cwSz + 1];
  106. if( m_pszTypeName == NULL )
  107. {
  108. return 0;
  109. }
  110. lstrcpy( m_pszTypeName , psz );
  111. return cwSz;
  112. }
  113. //----------------------------------------------------------------------------------
  114. int CResultNode::SetComment( LPTSTR psz , int cwSz )
  115. {
  116. if( IsBadReadPtr( psz , cwSz * sizeof( TCHAR ) ) )
  117. {
  118. return 0;
  119. }
  120. if( m_pszComment != NULL )
  121. {
  122. delete[] m_pszComment;
  123. m_pszComment = NULL;
  124. }
  125. m_pszComment = ( LPTSTR ) new TCHAR[ cwSz + 1];
  126. if( m_pszComment == NULL )
  127. {
  128. return 0;
  129. }
  130. lstrcpy( m_pszComment , psz );
  131. return cwSz;
  132. }
  133. //----------------------------------------------------------------------------------
  134. int CResultNode::SetImageIdx( DWORD dwIdx )
  135. {
  136. // Check for invalid dwIdx
  137. m_dwImageidx = dwIdx;
  138. return dwIdx;
  139. }
  140. //----------------------------------------------------------------------------------
  141. BOOL CResultNode::EnableConnection( BOOL bSet )
  142. {
  143. m_bEnableConnection = bSet;
  144. return TRUE;
  145. }
  146. //----------------------------------------------------------------------------------
  147. int CResultNode::SetServer( ICfgComp *pCfgcomp )
  148. {
  149. if( pCfgcomp == NULL )
  150. {
  151. return 0;
  152. }
  153. if( m_pCfgcomp != NULL )
  154. {
  155. m_pCfgcomp->Release( );
  156. }
  157. m_pCfgcomp = pCfgcomp;
  158. return m_pCfgcomp->AddRef( );
  159. }
  160. //----------------------------------------------------------------------------------
  161. int CResultNode::GetServer( ICfgComp **ppCfgcomp )
  162. {
  163. if( m_pCfgcomp != NULL )
  164. {
  165. *ppCfgcomp = m_pCfgcomp;
  166. return ( ( ICfgComp * )*ppCfgcomp )->AddRef( );
  167. }
  168. return 0;
  169. }
  170. //----------------------------------------------------------------------------------
  171. int CResultNode::FreeServer( )
  172. {
  173. if( m_pCfgcomp != NULL )
  174. {
  175. return m_pCfgcomp->Release( );
  176. }
  177. return 0;
  178. }
  179. //----------------------------------------------------------------------------------
  180. BOOL CResultNode::AddMenuItems( LPCONTEXTMENUCALLBACK pcmc , PLONG pl )
  181. {
  182. HRESULT hr;
  183. TCHAR tchName[ 80 ];
  184. TCHAR tchStatus[ 256 ];
  185. CONTEXTMENUITEM cmi;
  186. if( GetConnectionState( ) )
  187. {
  188. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_DISABLECON , tchName , SIZE_OF_BUFFER( tchName ) ) );
  189. cmi.strName = tchName;
  190. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_DISABLECON_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  191. cmi.strStatusBarText = tchStatus;
  192. }
  193. else
  194. {
  195. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_ENABLECON , tchName , SIZE_OF_BUFFER( tchName ) ) );
  196. cmi.strName = tchName;
  197. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_ENABLECON_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  198. cmi.strStatusBarText = tchStatus;
  199. }
  200. cmi.lCommandID = IDM_ENABLE_CONNECTION;
  201. cmi.lInsertionPointID = CCM_INSERTIONPOINTID_PRIMARY_TASK;
  202. cmi.fFlags = cmi.fSpecialFlags = 0;
  203. *pl |= CCM_INSERTIONALLOWED_TASK;
  204. hr = pcmc->AddItem( &cmi );
  205. if( SUCCEEDED( hr ) )
  206. {
  207. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_RENAMECON , tchName , SIZE_OF_BUFFER( tchName ) ) );
  208. cmi.strName = tchName;
  209. VERIFY_E( 0 , LoadString( _Module.GetResourceInstance( ) , IDS_RENAMECON_STATUS , tchStatus , SIZE_OF_BUFFER( tchStatus ) ) );
  210. cmi.strStatusBarText = tchStatus;
  211. cmi.lCommandID = IDM_RENAME_CONNECTION;
  212. hr = pcmc->AddItem( &cmi );
  213. }
  214. return ( SUCCEEDED( hr ) ? TRUE : FALSE );
  215. }