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.

289 lines
7.5 KiB

  1. /////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1997 Active Voice Corporation. All Rights Reserved.
  4. //
  5. // Active Agent(r) and Unified Communications(tm) are trademarks of Active Voice Corporation.
  6. //
  7. // Other brand and product names used herein are trademarks of their respective owners.
  8. //
  9. // The entire program and user interface including the structure, sequence, selection,
  10. // and arrangement of the dialog, the exclusively "yes" and "no" choices represented
  11. // by "1" and "2," and each dialog message are protected by copyrights registered in
  12. // the United States and by international treaties.
  13. //
  14. // Protected by one or more of the following United States patents: 5,070,526, 5,488,650,
  15. // 5,434,906, 5,581,604, 5,533,102, 5,568,540, 5,625,676, 5,651,054.
  16. //
  17. // Active Voice Corporation
  18. // Seattle, Washington
  19. // USA
  20. //
  21. /////////////////////////////////////////////////////////////////////////////////////////
  22. // DlgConfRoomTalker.cpp : Implementation of CDlgConfRoomTalker
  23. #include "stdafx.h"
  24. #include "TapiDialer.h"
  25. #include "ConfRoom.h"
  26. #define TOOLTIP_ID 1
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CDlgConfRoomTalker
  29. CDlgConfRoomTalker::CDlgConfRoomTalker()
  30. {
  31. m_callState = CS_DISCONNECTED;
  32. m_bstrCallerID = NULL;
  33. m_bstrConfName = NULL;
  34. m_bstrCallerInfo = NULL;
  35. m_pszDetails = NULL;
  36. m_hWndTips = NULL;
  37. m_pConfRoomTalkerWnd = NULL;
  38. }
  39. CDlgConfRoomTalker::~CDlgConfRoomTalker()
  40. {
  41. if ( m_pszDetails ) delete m_pszDetails;
  42. SysFreeString( m_bstrCallerID );
  43. SysFreeString( m_bstrConfName );
  44. SysFreeString( m_bstrCallerInfo );
  45. }
  46. LRESULT CDlgConfRoomTalker::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  47. {
  48. // Tool tips for conference room
  49. if ( !m_hWndTips )
  50. {
  51. m_hWndTips = CreateWindow( TOOLTIPS_CLASS, NULL, WS_POPUP | WS_EX_TOOLWINDOW | TTS_ALWAYSTIP,
  52. CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
  53. m_hWnd, (HMENU) NULL, _Module.GetResourceInstance(), NULL );
  54. }
  55. UpdateData( false );
  56. return 1; // Let the system set the focus
  57. }
  58. void CDlgConfRoomTalker::UpdateData( bool bSaveAndValidate )
  59. {
  60. USES_CONVERSION;
  61. TCHAR szText[255] = _T("");
  62. if ( bSaveAndValidate )
  63. {
  64. _ASSERT( false ); // not implemented
  65. }
  66. else
  67. {
  68. // Caller ID -- use default text if none available
  69. if ( (!m_bstrCallerID || (SysStringLen(m_bstrCallerID) == 0)) &&
  70. (!m_bstrCallerInfo || (SysStringLen(m_bstrCallerInfo) == 0)) )
  71. {
  72. if ( m_callState == CS_CONNECTED )
  73. LoadString( _Module.GetResourceInstance(), IDS_CONFROOM_NO_CALLERID, szText, ARRAYSIZE(szText) );
  74. SetDlgItemText( IDC_LBL_CALLERID, szText );
  75. }
  76. else
  77. {
  78. CComBSTR bstrTemp( m_bstrCallerID );
  79. if ( m_bstrCallerInfo && (SysStringLen(m_bstrCallerInfo) > 0) )
  80. {
  81. if ( bstrTemp.Length() > 0 )
  82. bstrTemp.Append( L"\n" );
  83. bstrTemp.Append( m_bstrCallerInfo );
  84. }
  85. SetDlgItemText( IDC_LBL_CALLERID, OLE2CT(bstrTemp) );
  86. }
  87. // Status (combine conference name and status)
  88. TCHAR szText[255], szState[100];
  89. UINT nIDS = IDS_CONFROOM_CONF_DISCONNECTED;
  90. switch ( m_callState )
  91. {
  92. case AV_CS_DIALING: nIDS = IDS_CONFROOM_CONF_DIALING; break;
  93. case CS_INPROGRESS: nIDS = IDS_CONFROOM_CONF_INPROGRESS; break;
  94. case CS_CONNECTED: nIDS = IDS_CONFROOM_CONF_CONNECTED; break;
  95. case AV_CS_DISCONNECTING: nIDS = IDS_CONFROOM_CONF_DISCONNECTING; break;
  96. case AV_CS_ABORT: nIDS = IDS_CONFROOM_CONF_ABORT; break;
  97. }
  98. LoadString( _Module.GetResourceInstance(), nIDS, szState, ARRAYSIZE(szState) );
  99. // Default to null
  100. if ( !m_bstrConfName )
  101. m_bstrConfName = SysAllocString( T2COLE(_T("")) );
  102. _sntprintf( szText, ARRAYSIZE(szText), _T("%s\n%s"), OLE2CT(m_bstrConfName), szState );
  103. SetDlgItemText( IDC_LBL_STATUS, szText );
  104. // Update Status bitmaps
  105. UpdateStatusBitmaps();
  106. if ( m_hWndTips )
  107. {
  108. RECT rc;
  109. ::GetWindowRect( GetDlgItem(IDC_LBL_STATUS), &rc );
  110. ScreenToClient( &rc );
  111. AddToolTip( m_hWndTips, rc );
  112. }
  113. }
  114. }
  115. void CDlgConfRoomTalker::UpdateStatusBitmaps()
  116. {
  117. HWND hWndAnimate = GetDlgItem(IDC_ANIMATE);
  118. UINT nIDA;
  119. switch ( m_callState )
  120. {
  121. case AV_CS_ABORT:
  122. case AV_CS_DIALING:
  123. nIDA = IDA_CONNECTING;
  124. break;
  125. case CS_INPROGRESS:
  126. nIDA = IDA_RINGING;
  127. break;
  128. case CS_CONNECTED:
  129. case AV_CS_DISCONNECTING:
  130. nIDA = IDA_CONNECTED;
  131. break;
  132. default:
  133. // Stop animation and show disconnected bitmap
  134. Animate_Stop( hWndAnimate );
  135. ::ShowWindow( hWndAnimate, SW_HIDE );
  136. RECT rc;
  137. ::GetWindowRect( hWndAnimate, &rc );
  138. ScreenToClient( &rc );
  139. RedrawWindow( &rc );
  140. return;
  141. }
  142. // Play the animation that corresponds to the current call state
  143. Animate_OpenEx( hWndAnimate, GetModuleHandle(NULL), MAKEINTRESOURCE(nIDA) );
  144. Animate_Play( hWndAnimate, 0, -1, -1 );
  145. ::ShowWindow( hWndAnimate, SW_SHOW );
  146. }
  147. ////////////////////////////////////////////////////////////////////////
  148. // Message handlers
  149. //
  150. LRESULT CDlgConfRoomTalker::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  151. {
  152. bHandled = true;
  153. return ::SendMessage( ::GetParent( GetParent() ), uMsg, wParam, lParam );
  154. }
  155. LRESULT CDlgConfRoomTalker::OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  156. {
  157. Animate_Close( GetDlgItem(IDC_ANIMATE) );
  158. return 0;
  159. }
  160. LRESULT CDlgConfRoomTalker::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  161. {
  162. PAINTSTRUCT ps;
  163. HDC hDC = BeginPaint( &ps );
  164. if ( !hDC ) return 0;
  165. // Draw stock bitmap
  166. switch ( m_callState )
  167. {
  168. case CS_DISCONNECTED:
  169. case AV_CS_DISCONNECTING:
  170. case AV_CS_ABORT:
  171. {
  172. HBITMAP hBmp = LoadBitmap( _Module.GetResourceInstance(), MAKEINTRESOURCE(IDB_DISCONNECTED) );
  173. if ( hBmp )
  174. {
  175. RECT rc;
  176. ::GetWindowRect( GetDlgItem(IDC_ANIMATE), &rc );
  177. ScreenToClient( &rc );
  178. DrawTrans( hDC, hBmp, rc.left, rc.top );
  179. }
  180. }
  181. break;
  182. }
  183. EndPaint( &ps );
  184. bHandled = true;
  185. return 0;
  186. }
  187. void CDlgConfRoomTalker::AddToolTip( HWND hWndToolTip, const RECT& rc )
  188. {
  189. TOOLINFO ti;
  190. ti.cbSize = sizeof(TOOLINFO);
  191. ti.uFlags = 0;
  192. ti.hwnd = m_hWnd;
  193. ti.hinst = _Module.GetResourceInstance();
  194. ti.uId = TOOLTIP_ID;
  195. ti.lpszText = NULL;
  196. ti.rect = rc;
  197. // Make sure the tool doesn't already exist
  198. ::SendMessage( hWndToolTip, TTM_DELTOOL, 0, (LPARAM) &ti );
  199. // Add the tool to the list
  200. if ( m_pConfRoomTalkerWnd &&
  201. m_pConfRoomTalkerWnd->m_pConfRoomWnd &&
  202. m_pConfRoomTalkerWnd->m_pConfRoomWnd->m_pConfRoom )
  203. {
  204. USES_CONVERSION;
  205. BSTR bstrText = NULL;
  206. m_pConfRoomTalkerWnd->m_pConfRoomWnd->m_pConfRoom->get_bstrConfDetails( &bstrText );
  207. // delete previous value
  208. if ( m_pszDetails )
  209. {
  210. delete m_pszDetails;
  211. m_pszDetails = NULL;
  212. }
  213. // Allocate for new tool tip
  214. int nLen = SysStringLen(bstrText);
  215. if ( nLen > 0 )
  216. {
  217. m_pszDetails = new TCHAR[nLen + 1];
  218. if ( m_pszDetails )
  219. {
  220. _tcscpy( m_pszDetails, OLE2CT(bstrText) );
  221. ti.lpszText = m_pszDetails;
  222. ::SendMessage( hWndToolTip, TTM_ADDTOOL, 0, (LPARAM) &ti );
  223. }
  224. }
  225. SysFreeString( bstrText );
  226. }
  227. }
  228. LRESULT CDlgConfRoomTalker::OnMouse(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
  229. {
  230. // Forward message on to tool tip
  231. if ( m_hWndTips )
  232. {
  233. MSG msg;
  234. msg.hwnd = m_hWnd;
  235. msg.message = nMsg;
  236. msg.wParam = wParam;
  237. msg.lParam = lParam;
  238. bHandled = false;
  239. ::SendMessage( m_hWndTips, TTM_RELAYEVENT, 0, (LPARAM) &msg );
  240. }
  241. return 0;
  242. }