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.

290 lines
6.7 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1997 **/
  4. /**********************************************************************/
  5. /*
  6. sfmsess.cpp
  7. Implementation for the sessions property page.
  8. FILE HISTORY:
  9. 8/20/97 ericdav Code moved into file managemnet snapin
  10. */
  11. #include "stdafx.h"
  12. #include "sfmcfg.h"
  13. #include "sfmsess.h"
  14. #include "sfmutil.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CMacFilesSessions property page
  22. IMPLEMENT_DYNCREATE(CMacFilesSessions, CPropertyPage)
  23. CMacFilesSessions::CMacFilesSessions() : CPropertyPage(CMacFilesSessions::IDD)
  24. {
  25. //{{AFX_DATA_INIT(CMacFilesSessions)
  26. //}}AFX_DATA_INIT
  27. }
  28. CMacFilesSessions::~CMacFilesSessions()
  29. {
  30. }
  31. void CMacFilesSessions::DoDataExchange(CDataExchange* pDX)
  32. {
  33. CPropertyPage::DoDataExchange(pDX);
  34. //{{AFX_DATA_MAP(CMacFilesSessions)
  35. DDX_Control(pDX, IDC_EDIT_MESSAGE, m_editMessage);
  36. DDX_Control(pDX, IDC_STATIC_SESSIONS, m_staticSessions);
  37. DDX_Control(pDX, IDC_STATIC_FORKS, m_staticForks);
  38. DDX_Control(pDX, IDC_STATIC_FILE_LOCKS, m_staticFileLocks);
  39. DDX_Control(pDX, IDC_BUTTON_SEND, m_buttonSend);
  40. //}}AFX_DATA_MAP
  41. }
  42. BEGIN_MESSAGE_MAP(CMacFilesSessions, CPropertyPage)
  43. //{{AFX_MSG_MAP(CMacFilesSessions)
  44. ON_BN_CLICKED(IDC_BUTTON_SEND, OnButtonSend)
  45. ON_EN_CHANGE(IDC_EDIT_MESSAGE, OnChangeEditMessage)
  46. ON_WM_HELPINFO()
  47. ON_WM_CONTEXTMENU()
  48. //}}AFX_MSG_MAP
  49. END_MESSAGE_MAP()
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CMacFilesSessions message handlers
  52. BOOL CMacFilesSessions::OnApply()
  53. {
  54. // TODO: Add your specialized code here and/or call the base class
  55. return CPropertyPage::OnApply();
  56. }
  57. BOOL CMacFilesSessions::OnKillActive()
  58. {
  59. // TODO: Add your specialized code here and/or call the base class
  60. return CPropertyPage::OnKillActive();
  61. }
  62. void CMacFilesSessions::OnOK()
  63. {
  64. // TODO: Add your specialized code here and/or call the base class
  65. CPropertyPage::OnOK();
  66. }
  67. BOOL CMacFilesSessions::OnSetActive()
  68. {
  69. // TODO: Add your specialized code here and/or call the base class
  70. return CPropertyPage::OnSetActive();
  71. }
  72. void CMacFilesSessions::OnButtonSend()
  73. {
  74. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  75. AFP_MESSAGE_INFO AfpMsg;
  76. CString strMessage;
  77. DWORD err;
  78. if ( !g_SfmDLL.LoadFunctionPointers() )
  79. return;
  80. //
  81. // Message goes to everybody
  82. //
  83. AfpMsg.afpmsg_session_id = 0;
  84. //
  85. // Attempt to send the message
  86. //
  87. m_editMessage.GetWindowText(strMessage);
  88. //
  89. // Was there any text? -- should never happen
  90. //
  91. if (strMessage.IsEmpty())
  92. {
  93. CString strTemp;
  94. strTemp.LoadString(IDS_NEED_TEXT_TO_SEND);
  95. ::AfxMessageBox(IDS_NEED_TEXT_TO_SEND);
  96. m_editMessage.SetFocus();
  97. return;
  98. }
  99. //
  100. // Message too long? -- should never happen
  101. //
  102. if (strMessage.GetLength() > AFP_MESSAGE_LEN)
  103. {
  104. CString strTemp;
  105. strTemp.LoadString(IDS_MESSAGE_TOO_LONG);
  106. ::AfxMessageBox(strTemp);
  107. m_editMessage.SetFocus();
  108. m_editMessage.SetSel(0, -1);
  109. return;
  110. }
  111. AfpMsg.afpmsg_text = (LPWSTR) ((LPCTSTR) strMessage);
  112. err = ((MESSAGESENDPROC) g_SfmDLL[AFP_MESSAGE_SEND])(m_pSheet->m_hAfpServer, &AfpMsg);
  113. CString strTemp;
  114. switch( err )
  115. {
  116. case AFPERR_InvalidId:
  117. strTemp.LoadString(IDS_SESSION_DELETED);
  118. ::AfxMessageBox(strTemp);
  119. break;
  120. case NO_ERROR:
  121. strTemp.LoadString(IDS_MESSAGE_SENT);
  122. ::AfxMessageBox(strTemp, MB_ICONINFORMATION);
  123. break;
  124. case AFPERR_InvalidSessionType:
  125. strTemp.LoadString(IDS_NOT_RECEIVED);
  126. ::AfxMessageBox(strTemp);
  127. break;
  128. default:
  129. ::SFMMessageBox(err);
  130. break;
  131. }
  132. }
  133. BOOL CMacFilesSessions::OnInitDialog()
  134. {
  135. CPropertyPage::OnInitDialog();
  136. DWORD err;
  137. if ( !g_SfmDLL.LoadFunctionPointers() )
  138. return S_OK;
  139. //
  140. // This string will contain our "??" string.
  141. //
  142. const TCHAR * pszNotAvail = _T("??");
  143. //
  144. // Retrieve the statitistics server info.
  145. //
  146. PAFP_STATISTICS_INFO pAfpStats;
  147. err = ((STATISTICSGETPROC) g_SfmDLL[AFP_STATISTICS_GET])(m_pSheet->m_hAfpServer, (LPBYTE*)&pAfpStats);
  148. if( err == NO_ERROR )
  149. {
  150. CString strTemp;
  151. strTemp.Format(_T("%u"), pAfpStats->stat_CurrentSessions);
  152. m_staticSessions.EnableWindow(TRUE);
  153. m_staticSessions.SetWindowText(strTemp);
  154. strTemp.Format(_T("%u"), pAfpStats->stat_CurrentFilesOpen);
  155. m_staticForks.EnableWindow(TRUE);
  156. m_staticForks.SetWindowText(strTemp);
  157. strTemp.Format(_T("%u"), pAfpStats->stat_CurrentFileLocks);
  158. m_staticFileLocks.EnableWindow(TRUE);
  159. m_staticFileLocks.SetWindowText(strTemp);
  160. ((SFMBUFFERFREEPROC) g_SfmDLL[AFP_BUFFER_FREE])(pAfpStats);
  161. }
  162. else
  163. {
  164. m_staticSessions.SetWindowText(pszNotAvail);
  165. m_staticSessions.EnableWindow(FALSE);
  166. m_staticForks.SetWindowText(pszNotAvail);
  167. m_staticForks.EnableWindow(FALSE);
  168. m_staticFileLocks.SetWindowText(pszNotAvail);
  169. m_staticFileLocks.EnableWindow(FALSE);
  170. }
  171. //
  172. // Setup the message edit box
  173. //
  174. m_editMessage.SetLimitText(AFP_MESSAGE_LEN);
  175. m_editMessage.FmtLines(FALSE);
  176. //
  177. // Set the state of the send button
  178. //
  179. OnChangeEditMessage();
  180. return TRUE; // return TRUE unless you set the focus to a control
  181. // EXCEPTION: OCX Property Pages should return FALSE
  182. }
  183. void CMacFilesSessions::OnChangeEditMessage()
  184. {
  185. CString strTemp;
  186. m_editMessage.GetWindowText(strTemp);
  187. if (strTemp.IsEmpty())
  188. {
  189. //
  190. // Disable the send button
  191. //
  192. m_buttonSend.EnableWindow(FALSE);
  193. }
  194. else
  195. {
  196. //
  197. // Enable the send button
  198. //
  199. m_buttonSend.EnableWindow(TRUE);
  200. }
  201. }
  202. BOOL CMacFilesSessions::OnHelpInfo(HELPINFO* pHelpInfo)
  203. {
  204. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  205. if (pHelpInfo->iContextType == HELPINFO_WINDOW)
  206. {
  207. ::WinHelp ((HWND)pHelpInfo->hItemHandle,
  208. m_pSheet->m_strHelpFilePath,
  209. HELP_WM_HELP,
  210. g_aHelpIDs_CONFIGURE_SFM);
  211. }
  212. return TRUE;
  213. }
  214. void CMacFilesSessions::OnContextMenu(CWnd* pWnd, CPoint /*point*/)
  215. {
  216. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  217. if (this == pWnd)
  218. return;
  219. ::WinHelp (pWnd->m_hWnd,
  220. m_pSheet->m_strHelpFilePath,
  221. HELP_CONTEXTMENU,
  222. g_aHelpIDs_CONFIGURE_SFM);
  223. }