📄 sessionwnd.h
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*************************************************************************
Disclaimer:
This code and information is provided "as is" without warranty of
any kind, either expressed or implied, including but not limited to
the implied warranties of merchantability and/or fitness for a
particular purpose.
Module Name:
SessionWnd.h
Abstract:
Header for Session window, definitions of CSessionWnd and
CSessionWndContainer
Notes:
**************************************************************************/
#if !defined(AFX_SESSIONWND_H__EF3270B0_308C_4C6B_9F01_CB1BA760B8D7__INCLUDED_)
#define AFX_SESSIONWND_H__EF3270B0_308C_4C6B_9F01_CB1BA760B8D7__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "resource.h"
#include "voipdemo.h"
#include "rtcs.h"
#define SESSIONWND_TOOLBARHEIGHT 68
#define SESSIONWND_STATUSBARHEIGHT 20
#define SESSIONWND_EDITBOXHEIGHT 80
#define SESSIONWND_MAXEDITLENGTH 1000
#define SESSIONWND_MAXMSGNUM 1000
// Caller Callee
// ------ ------
//
// - User selects Buddy
//
// - User clicks Call or Send
//
// - Main calls SessionWndCallback()
// with SWCBM_x_INITIATING
// status is SS_INITIATING
//
// - Main calls RtcXSessionTo()
//
// - Rtc sends invitation
// ------------------------->
// - Rtc Event signals
//
// - Rtc calls SessionWndCallback()
// with SWCBM_X_INITIATING
// status is SS_INITIATING
//
// - SessionWndCallback calls OpenSessionWindow()
//
// - User accepts session
//
// - Rtc accepts session
// <-------------------------
// - Rtc calls SessionWndCallback()
// with SWCBM_X_PARTICIPANT_JOINED
// status is SS_GOING
//
// [ ............ ]
//
// - User terminates session
// status is SS_QUITTING
//
// - SessionWnd calls RtcXSessionStop()
//
// - Rtc sends termination
// ------------------------->
// - Rtc Event signals
//
// - Rtc calls SessionWndCallback()
// with SWCBM_X_PARTICIPANT_LEFT
// status is SS_OFF
//
// - Rtc says goodbye
// <-------------------------
// - Rtc calls SessionWndCallback()
// with SWCBM_X_PARTICIPANT_LEFT
// status is SS_OFF
//
// [ ............ ]
//
// - User clicks Call or Send
// in session window
// status is SS_INITIATING
//
// - SessionWnd calls RtcXSessionTo()
//
// - Rtc sends invitation
// ------------------------->
// - Rtc Event signals
//
// - Rtc calls SessionWndCallback()
// with SWCBM_X_INITIATING
// status is SS_INITIATING
//
// - SessionWndCallback calls OpenSessionWindow()
//
// - User accepts session
//
// - Rtc accepts session
// <-------------------------
// - Rtc calls SessionWndCallback()
// with SWCBM_X_PARTICIPANT_JOINED
// status is SS_GOING
//
// [ ............ ]
//
// - User clicks Call or Send
// in session window
// status is SS_INITIATING
//
// - SessionWnd calls RtcXSessionTo()
//
// - Rtc sends invitation
// ------------------------->
// - Rtc Event signals
//
// - Rtc calls SessionWndCallback()
// with SWCBM_X_INITIATING
// status is SS_INITIATING
//
// - SessionWndCallback calls OpenSessionWindow()
//
// - User rejects session (or times out)
//
// - Rtc rejects session
// <-------------------------
// - Rtc calls SessionWndCallback()
// with SWCBM_X_PARTICIPANT_REJECTED
// status is SS_OFF
// Pointer to this structure is to be given in pMsgBody for any participant related callback
// For each SESSIONWNDCALLBACKMSGS the following should be in pMsgBody and the return value is:
// eMsgType == SWCBM_NOMSG; pMsgBody = don't care; return 0
// eMsgType == SWCBM_PRESENCECHANGED; pMsgBody = don't care; return 1
// eMsgType == SWCBM_IM_INITIATING_INCOMING; if from RTC, return 1; if from SWCBM_IM_MESSAGE_ARRIVED, pMsgBody = SWCB_MESSAGE_ARRIVED*; return 1 if accepted, 0 if rejected, 2 if timed out
// eMsgType == SWCBM_IM_INITIATING_OUTGOING; pMsgBody = SWCB_PARTICIPANT_INFO*; return 1
// eMsgType == SWCBM_IM_PARTICIPANT_JOINED; pMsgBody = SWCB_PARTICIPANT_INFO*; return 1
// eMsgType == SWCBM_IM_PARTICIPANT_LEFT; pMsgBody = SWCB_PARTICIPANT_INFO*; return 1
// eMsgType == SWCBM_IM_PARTICIPANT_REJECTED; pMsgBody = SWCB_PARTICIPANT_INFO*; return 1
// eMsgType == SWCBM_CALL_INITIATING; if window exitst, pMsgBody = don't care otherwise pMsgBody = SWCB_PARTICIPANT_INFO*; return 1 if accepted, 0 if rejected, 2 if timed out
// eMsgType == SWCBM_CALL_PARTICIPANT_JOINED; pMsgBody = SWCB_PARTICIPANT_INFO*; return 1
// eMsgType == SWCBM_CALL_PARTICIANT_LEFT; pMsgBody = SWCB_PARTICIPANT_INFO*; return 1
// eMsgType == SWCBM_CALL_PARTICIPANT_REJECTED; pMsgBody = SWCB_PARTICIPANT_INFO*; return 1
// eMsgType == SWCBM_IM_MESSAGE_ARRIVED; pMsgBody = SWCB_MESSAGE_ARRIVED*; return 1
// eMsgType == SWCBM_IM_MESSAGE_LOCAL; pMsgBody = SWCB_MESSAGE_ARRIVED*; pMsgBody->sFrom can be NULL; return 1
// eMsgType == SWCBM_IM_MESSAGE_STATUS; pMsgBody = SWCB_MESSAGE_ARRIVED*; pMsgBody->sFrom does not matter; return 1
static enum SESSIONSTATUS
{
SS_OFF, // Initial status or after participant left
SS_INITIATING, // Waiting for participant to signal back
SS_INITIATING_INCOMING, // Only for IM: incoming session is initiating, accept or decline
SS_GOING, // Session is going on
SS_QUITTING // session is going down
};
static enum LOCALMSGTYPE
{
LMT_TEXT,
LMT_SAYS,
LMT_PARTY_STATUS_CHANGE,
LMT_PARTY_JOINED,
LMT_PARTY_LEFT,
LMT_PARTY_ACCEPTED,
LMT_PARTY_DECLINED
};
class CSessionWnd
{
// Give the container full access to the private members
friend class CSessionWndContainer;
public:
CSessionWnd();
~CSessionWnd();
private:
BOOL OpenSessionWnd( SWCB_PARTICIPANT_INFO* pPart, SESSIONWNDCALLBACKMSGS eMsg );
int AddMessage( TCHAR* szTxt, LOCALMSGTYPE mt );
HWND m_hWndSession; // Session window
HWND m_hWndSessionCB; // The command bar handle
HWND m_hMsgWindow; // The message window
HWND m_hEditWindow; // The edit window
HANDLE m_hIMSession; // Handle to this window's IM session
HANDLE m_hCallSession; // Handle to this window's Voice session
BOOL m_bP2PSession; // phone to phone session
static WNDPROC m_pEditProc; // The edit window's original WndProc before subclassing
int m_nSessionButtonPointed;
BUDDY_SELECTION cOtherParty;
TCHAR szPartyName[256];
TCHAR szPartyIPAddr[256];
SESSIONSTATUS ssVoice;
SESSIONSTATUS ssMessage;
BOOL bToolbar;
BOOL bStatusbar;
BOOL bAlwaysOnTop;
BOOL bTemporaryBuddy;
TCHAR szStatus[64];
HFONT m_hFont;
int nMsgFontHight;
int nMsgLineLength;
BOOL bSetEditPos;
BOOL bSetMsgPos;
static LRESULT CALLBACK SessionWndProc( HWND, UINT, WPARAM, LPARAM );
LRESULT DoSessionWndPaint( WPARAM wParam, LPARAM lParam );
LRESULT DoSessionWndMouseMove( WPARAM wParam, LPARAM lParam );
void DrawSessionWndButtons( HDC hdc );
void InvalidateSessionButton( int nButton );
void SessionWndUpdateTitle();
void SessionWndRedrawClient();
void SessionWndScrollMessages();
void LocalMessage( LOCALMSGTYPE eType, TCHAR* szPartyName, TCHAR* szTxt );
};
class CSessionWndContainer
{
public:
CSessionWndContainer( HINSTANCE );
~CSessionWndContainer();
static int SessionWndCallback( SESSIONWNDCALLBACKMSGS eMsgType, void* pMsgBody, HANDLE pSess);
static ATOM MyRegisterSessionWnd( HINSTANCE, LPTSTR );
static BOOL DestroySessionWindow( CSessionWnd* );
CSessionWnd* get_ActiveSessionWindow() // return the active session window, if exist
{
return pSessionWindow;
}
HWND get_ActiveSessionWindowHWnd()
{
if (pSessionWindow)
return pSessionWindow->m_hWndSession;
else
return NULL;
}
static HINSTANCE hInstance;
private:
static CSessionWnd* pSessionWindow; // The one and only window we can handle so far
TCHAR szMyName[256];
TCHAR szMyIPAddr[256];
};
#endif // !defined(AFX_SESSIONWND_H__EF3270B0_308C_4C6B_9F01_CB1BA760B8D7__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -