📄 vdtypes.cpp
字号:
//
// 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:
vdtypes.cpp
Abstract:
Definitions of common programmer-defined types used throughout
the VoipDemo application.
Notes:
**************************************************************************/
#include "rtcs.h"
/************************************************************************************************
PARTICIPANT_INFO Functions (self-explanatory)
Note use of NewStrCopy() for local storage of BSTRs.
************************************************************************************************/
BOOL
PARTICIPANT_INFO::Copy( PARTICIPANT_INFO* rhs)
{
if (this == rhs) return TRUE;
NewStrCopy(rhs->bstrName, bstrName);
NewStrCopy(rhs->bstrAddr, bstrAddr);
if (!bstrName || !bstrAddr) {
Clear();
return FALSE;
}
return TRUE;
}
VOID
PARTICIPANT_INFO::Init()
{
bstrName = NULL;
bstrAddr = NULL;
pBuddy = NULL;
btBuddyType = BT_NONE;
}
VOID
PARTICIPANT_INFO::Clear()
{
if (bstrName)
{
SysFreeString( bstrName );
bstrName = NULL;
}
if (bstrAddr) {
SysFreeString( bstrAddr );
bstrAddr = NULL;;
}
Init();
}
BOOL
PARTICIPANT_INFO::put_Name( IN WCHAR* szName, BOOL bAlloc)
{
return NewStrCopy(szName, bstrName, bAlloc);
}
BOOL
PARTICIPANT_INFO::put_Addr( IN WCHAR* szAddr, BOOL bAlloc)
{
return NewStrCopy(szAddr, bstrAddr, bAlloc);
}
const BSTR
PARTICIPANT_INFO::get_Name()
{
return bstrName;
}
const BSTR
PARTICIPANT_INFO::get_Addr()
{
return bstrAddr;
}
/************************************************************************************************
BUDDY_SELECTION Functions (self-explanatory)
************************************************************************************************/
VOID BUDDY_SELECTION::Init()
{
((SWCB_PARTICIPANT_INFO*) this)->Init();
eStat = ES_NOSTATUS;
iSelectedBuddies = 0;
}
VOID
BUDDY_SELECTION::Clear()
{
((SWCB_PARTICIPANT_INFO*) this)->Clear();
eStat = ES_NOSTATUS;
iSelectedBuddies--;
if (iSelectedBuddies < 0)
iSelectedBuddies = 0;
}
BOOL
BUDDY_SELECTION::IMCapable()
{
BOOL rv = FALSE;
if (/*iSelectedBuddies == 1
&&*/ btBuddyType == BT_COMPUTER)
// && pBuddy != NULL)
rv = TRUE;
return rv;
}
BOOL
BUDDY_SELECTION::CallCapable()
{
BOOL rv = FALSE;
if (/*iSelectedBuddies > 0 &&*/ eStat == ES_ONLINE) {
if (btBuddyType == BT_COMPUTER && iSelectedBuddies < 2)
rv = TRUE;
else if (btBuddyType == BT_PHONE)
rv = TRUE;
else
rv = FALSE;
}
return rv;
}
/************************************************************************************************
LOCAL_USER_INFO Functions (self-explanatory)
************************************************************************************************/
VOID
LOCAL_USER_INFO::Init()
{
bstrLocalPhoneURI = NULL;
((PARTICIPANT_INFO*) this)->Init();
}
VOID
LOCAL_USER_INFO::Clear()
{
if (bstrLocalPhoneURI) {
SysFreeString(bstrLocalPhoneURI);
}
((PARTICIPANT_INFO*) this)->Clear();
}
BOOL
LOCAL_USER_INFO::put_LocalPhoneURI( IN WCHAR* szLocalPhoneURI, BOOL bAlloc)
{
return NewStrCopy(szLocalPhoneURI, bstrLocalPhoneURI, bAlloc);
}
const BSTR
LOCAL_USER_INFO::get_LocalPhoneURI()
{
return bstrLocalPhoneURI;
}
/*************************************************************************************************
NewStrCopy
Useful function for copying SysAlloc'ed strings (removing the pre-existing ones if exist)
*************************************************************************************************/
BOOL
NewStrCopy(
IN BSTR rhs,
OUT BSTR& lhs,
BOOL bAlloc
)
{
if (lhs != NULL) {
SysFreeString(lhs);
}
if (rhs == NULL) {
return TRUE;
}
if (bAlloc) {
lhs = SysAllocString( rhs );
} else {
lhs = rhs;
}
return lhs != NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -