📄 rtcs.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:
rtcs.h
Abstract:
Common include file between UI and RTC backend.
Notes:
All general functions, data structures, etc. are defined here (or have
been included as header files).
**************************************************************************/
#ifndef __RTCS_H__
#define __RTCS_H__
#include "stdafx.h"
#include <windows.h>
#include <rtccore.h>
#include "resource.h"
#include "DBase.h"
/************************************************************************************************
Common enums, defines & structures
************************************************************************************************/
// Code modification flags
//#define USE_AMUNSERVER 1
//#define NO_PHONE_TO_PHONE 1
// debug zones
#define ZONE_STATUS DEBUGZONE(0)
#define ZONE_CALL DEBUGZONE(4) // detailed call info/state
#define ZONE_INIT DEBUGZONE(8)
#define ZONE_PRESENCE DEBUGZONE(10)
#define ZONE_PROVISION DEBUGZONE(11)
#define ZONE_FUNC DEBUGZONE(13)
#define ZONE_WARN DEBUGZONE(14)
#define ZONE_ERROR DEBUGZONE(15)
// defines
#define DEFAULT_GATEWAYADDRESS L"157.59.132.46"
#define GATEWAYADDRESS_VAL_NAME L"PSTN Gateway Address"
#define LOCAL_USER_KEY_NAME L"\\Software\\Microsoft\\Voipdemo"
#define LOCAL_USER_VAL_NAME L"User Name"
#define LOCAL_USER_VAL_URI L"User URI"
#define LOCAL_USER_VAL_PHONE L"User Phone Number"
#define MSG_END_TESTCASE ( WM_USER+23968 )
#define MAX_REG_STRING_LENGTH 512
#define SHUTDOWN_TIME_LIMIT 10000 // ~10 sec
#define MAX_LOADSTRING 100
#define LISTVIEW_BEGIN -1
#define END_VAL -1
#define INCOMING_BUDDY TRUE
#define EXISTING_BUDDY FALSE
#define NO_ALLOC FALSE
#define ALLOC TRUE
#ifdef _Instantiate_Globals_
#define EXTERN(x,y) x = y
#else // if (!_Instantiate_Globals_)
#define EXTERN(x,y) extern x
#endif //_Instantiate_Globals_
extern DBGPARAM dpCurSettings;
#define ZeroMem(x) memset( &x, 0, sizeof( x ) );
// types / structures
/************************************************************************************************
ESTATUS is used to relate the status of the user to the user status string (a resource
displayed in the buddy status area) and is further related by use of a simple table to the
RTC status enums.
************************************************************************************************/
static enum ESTATUS
{
ES_NOSTATUS = -1,
ES_ONLINE = IDS_STATUSONLINE,
ES_OFFLINE = IDS_STATUSOFFLINE,
ES_BUSY = IDS_STATUSBUSY,
ES_BEBACK = IDS_STATUSBEBACK,
ES_AWAY = IDS_STATUSAWAY,
ES_PHONE = IDS_STATUSPHONE,
ES_LUNCH = IDS_STATUSLUNCH
};
/************************************************************************************************
BUDDYTYPE is used by the application to know how to handle a particular participant. The
Phone and Computer types determine the formatting and persistent storage of the buddies and
buddys' URIs. MYSELF and WATCHER are used for storage into the database.
************************************************************************************************/
static enum BUDDYTYPE
{
BT_NONE = 0,
BT_COMPUTER,
BT_PHONE,
BT_MYSELF,
BT_WATCHER
};
/************************************************************************************************
PARTICIPANT_INFO is used as our local way of keeping information about buddies / participants /
etc. for use in making calls, storage of some information and communication between the separate
parts of the application.
************************************************************************************************/
class PARTICIPANT_INFO
{
public:
PARTICIPANT_INFO() { Init(); }
PARTICIPANT_INFO(WCHAR* szName, WCHAR* szAddr, IRTCBuddy* PBuddy, BUDDYTYPE BTBuddyType)
{
Init();
pBuddy = PBuddy;
btBuddyType = BTBuddyType;
put_Name(szName);
put_Addr(szAddr);
}
~PARTICIPANT_INFO() { Clear(); }
IRTCBuddy* pBuddy;
BUDDYTYPE btBuddyType;
BOOL put_Name( IN WCHAR* szName, BOOL bAlloc = TRUE);
BOOL put_Addr( IN WCHAR* szAddr, BOOL bAlloc = TRUE);
const BSTR get_Name();
const BSTR get_Addr();
BOOL Copy( PARTICIPANT_INFO* rhs) ;
VOID Init();
VOID Clear();
private:
BSTR bstrName;
BSTR bstrAddr;
private:
};
typedef PARTICIPANT_INFO SWCB_PARTICIPANT_INFO , * P_PARTICIPANT_INFO;
/************************************************************************************************
BUDDY_SELECTION is used as a way to specify which users are selected inside the listview of
the main window proc. It stores the number and type of selected users, and provides some
simple logic check functions for the send-message and make-call actions.
************************************************************************************************/
class BUDDY_SELECTION : public SWCB_PARTICIPANT_INFO
{
public:
BUDDY_SELECTION() { Init(); }
ESTATUS eStat;
INT iSelectedBuddies;
VOID Init();
VOID Clear();
BOOL IMCapable();
BOOL CallCapable();
};
/************************************************************************************************
LOCAL_USER_INFO is used to provide accessor functions to the global local user data.
************************************************************************************************/
class LOCAL_USER_INFO : public SWCB_PARTICIPANT_INFO
{
public:
LOCAL_USER_INFO() { Init(); }
~LOCAL_USER_INFO() { Clear(); }
VOID Init();
VOID Clear();
BOOL put_LocalPhoneURI(IN WCHAR* szLocalPhoneURI, BOOL bAlloc = TRUE);
const BSTR get_LocalPhoneURI();
private:
BSTR bstrLocalPhoneURI;
};
/************************************************************************************************
Simple dual structure. It is used to make static lookup tables for some common functions, like
converting an RTC enum to a VoipDemo internal ESTATUS.
************************************************************************************************/
typedef struct _IDENTIFER_RESOURCE_TBL {
int st_res;
int st_idex;
} IRES_TBL, * PIRES_TBL, EINDEX_TBL, * PEINDEX_TBL;
typedef struct _STRING_TBL {
DWORD st_val;
LPWSTR st_str;
} STRING_TBL, * PSTRING_TBL;
typedef struct SWCB_MESSAGE_ARRIVED
{
SWCB_PARTICIPANT_INFO* sFrom;
TCHAR* szMsg;
} IM_MSG, * P_IM_MSG;
/************************************************************************************************
These messages are used to communicate with the callback function of the session window
both from the event handler, the main window proc, and the callback itself.
************************************************************************************************/
static enum SESSIONWNDCALLBACKMSGS
{
SWCBM_NOMSG, // No message - nothing to process
SWCBM_PRESENCECHANGED, // Somebody's presence changed
SWCBM_IM_INITIATING_OUTGOING, // Initiating IM session (waiting for other party)
SWCBM_IM_INITIATING_INCOMING, // Initiating IM session (should accept or reject)
SWCBM_IM_PARTICIPANT_JOINED, // Other party joined to IM session
SWCBM_IM_PARTICIPANT_LEFT, // Other party quit the IM session
SWCBM_IM_PARTICIPANT_REJECTED, // Other party did not accept IM session
SWCBM_CALL_INITIATING_OUTGOING, // Initiating voice session (waiting for other party)
SWCBM_P2P_CALL_INITIATING_OUTGOING, // Initiating p2p session (multiple participants, no
// IM possible
SWCBM_CALL_INITIATING_INCOMING, // Initiating voice session (should accept or reject)
SWCBM_CALL_PARTICIPANT_JOINED, // Other party joined the voice session
SWCBM_CALL_PARTICIPANT_LEFT, // Other party left the voice session
SWCBM_CALL_PARTICIPANT_REJECTED, // Other party did not accept call session
SWCBM_IM_MESSAGE_ARRIVED, // Other party sent an IM message (indented)
SWCBM_IM_MESSAGE_LOCAL, // Message to be displayed locally (indented)
SWCBM_IM_MESSAGE_STATUS // Status to be displayed (not indented)
};
/************************************************************************************************
Function Prototypes
************************************************************************************************/
// RTC init / shutdown
BOOL InitializeRTC( FARPROC fnSWCB, HINSTANCE hInst = NULL );
DWORD WINAPI ShutdownRTC( LPVOID option );
VOID ForceShutdownRTC( VOID );
// RTC Session related
HANDLE OpenSessionTo( IN P_PARTICIPANT_INFO pPart, IN RTC_SESSION_TYPE, IN FARPROC fnSWCB );
BOOL SessionStop( IN HANDLE );
BOOL AddParticipantToSession( IN P_PARTICIPANT_INFO, IN HANDLE hSess, IN FARPROC fnSWCB);
BOOL SendIMTo( IN HANDLE pSess, IN P_IM_MSG msg );
// RTC Presence related
BOOL InitBuddiesRTC();
VOID SetMyStatusRTC( ESTATUS eMyStatus);
IRTCBuddy* AddBuddyRTC(IN BSTR bstrURI, IN BSTR bstrName, IN BUDDYTYPE eBt, IN VARIANT_BOOL bPersistent, HINSTANCE hInst = NULL);
VOID EditBuddyRTC( IN IRTCBuddy* pBuddy, IN WCHAR* szName, IN WCHAR* szURI, IN BUDDYTYPE eBt, HINSTANCE hInst = NULL );
VOID RemoveBuddyRTC( IN IRTCBuddy* pBuddy, IN BUDDYTYPE enBt, IN BOOL bPersistent = FALSE, IN HINSTANCE hInst = NULL );
VOID AddWatcherRTC( BSTR bstrURI, BSTR bstrName, WCHAR* szIsBlocked, BOOL bStore );
VOID ChangeLocalUserInfoRTC(); // input taken from g_pLocalUserInfo
// Buddy related (shared)
BUDDYTYPE DetermineBuddyType( IN IRTCBuddy* pBuddy, IN BOOL bIncoming );
IRTCBuddy* CheckForExistingBuddy(IN P_PARTICIPANT_INFO pPart);
ESTATUS GetBuddyStatus(IN IRTCBuddy* pBuddy, IN BUDDYTYPE enBt);
// UI Buddy ListView related
BOOL AddBuddyListView( ESTATUS eStat, IRTCBuddy* pBuddy, TCHAR* szName, BUDDYTYPE bType = BT_COMPUTER );
BOOL ChangeBuddyListView( IRTCBuddy* pBuddy, WCHAR* szName, BUDDYTYPE bt, ESTATUS eStat);
VOID DoBuddyStatusChangeListView(IRTCBuddy* pBuddy);
BOOL FindAndRemoveBuddyListView(IRTCBuddy* pBuddy, ESTATUS eStat);
VOID CleanupListViews();
BOOL FormCalleeAryListView(PARTICIPANT_INFO*** pppPart, int* numParticipants);
// Helper functions
BOOL NewStrCopy( IN BSTR rhs, OUT BSTR& lhs, BOOL bAlloc = TRUE );
int GetIndexFromRes( IN int res, IN PIRES_TBL pst);
int GetResFromIndex( IN int idex, IN PIRES_TBL pst );
DWORD GetValFromString( IN LPWSTR pstr, IN PSTRING_TBL pst );
LPWSTR GetStringFromVal( IN DWORD dwVal, IN PSTRING_TBL pst );
BOOL ReadLocalUserRegistry(HKEY HKey, BSTR* bstrName, BSTR* bstrURI, BSTR* bstrLocalPhone);
BOOL UpdateLocalUserRegistry(BSTR bstrName, BSTR bstrURI, BSTR bstrLocalPhone);
#endif // __RTCS_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -