📄 callntfy.cpp
字号:
//****************************************************************************
// Module: AVPHONE.EXE
// File: CALLNTFY.CPP
// Content:
//
//
// Copyright (c) Microsoft Corporation 1995-1997
//
// 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.
//****************************************************************************
#include "stdafx.h"
#include "precomp.h"
#include "mmsystem.h"//多媒体
#include "tapiutils.h"
#include "netprodlg.h"
#include "AcceptDlg.h"
//****************************************************************************
//
// Constructor
//
//****************************************************************************
//extern int bForLink;
CCallNotify::CCallNotify()
{
strcpy(strName," ");
strcpy(strPhonenum," ");
strcpy(strNameAndNum," ");
}
CCallNotify::CCallNotify(Conf *pConf)
{
m_pConf = pConf;
strcpy(strName," ");
strcpy(strPhonenum," ");
strcpy(strNameAndNum," ");
m_Acceptdlg = new CAcceptDlg(this);
}
//****************************************************************************
//
// Destructor
//
//****************************************************************************
CCallNotify::~CCallNotify()
{
if(m_Acceptdlg)
delete m_Acceptdlg;
}
//****************************************************************************
//
// methods from IUnknown
//
//****************************************************************************
ULONG STDMETHODCALLTYPE CCallNotify::AddRef()
{
return RefCount::AddRef();
}
ULONG STDMETHODCALLTYPE CCallNotify::Release()
{
return RefCount::Release();
}
HRESULT STDMETHODCALLTYPE CCallNotify::QueryInterface(REFIID riid, PVOID * ppvObject)
{
*ppvObject = NULL;
if (riid == IID_IUnknown)
*ppvObject = (PVOID *)this;
else if (riid == IID_INmCallNotify)
*ppvObject = (PVOID *)this;
else
return E_NOINTERFACE;
AddRef();
return S_OK;
}
//****************************************************************************
//
// Sink connection methods
//
//****************************************************************************
HRESULT CCallNotify::Connect(IUnknown * pUnkOuter)
{
return CNotify::Connect(pUnkOuter, IID_INmCallNotify, (IUnknown *)this);
}
HRESULT CCallNotify::Disconnect()
{
return CNotify::Disconnect();
}
//****************************************************************************
//
// Main sink notification methods
//
//****************************************************************************
HRESULT STDMETHODCALLTYPE CCallNotify::Failed(ULONG uError)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE CCallNotify::Accepted(INmConference *pConference)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE CCallNotify::NmUI(CONFN uNotify)
{
return S_OK;
}
HRESULT STDMETHODCALLTYPE CCallNotify::StateChanged(NM_CALL_STATE uState)
{
BOOL nResponse;
CString m_Tmp;
//CMapStringToString *pMap;
CString value;
HWND hwnd;
hwnd = ::AfxGetApp()->m_pMainWnd->m_hWnd;
switch (uState)
{
case NM_CALL_RING:
BSTR PhoneName;
(m_pConf->m_pINmCall)->GetName(&PhoneName);
sprintf(strPhonenum,"%ls",PhoneName);
::SysFreeString(PhoneName);
//Add phonenum to Name map. Modify:2000/03/10
if(m_pConf->pNetproDlg->m_mapPhonebook.Lookup(strPhonenum,(CString&)value))
{
sprintf(strName,"%s",(LPCTSTR)value);
sprintf(strNameAndNum,"%s %s",strPhonenum,strName);
}
else
{
sprintf(strName,"%s","");
sprintf(strNameAndNum,"%s %s",strPhonenum,strName);
}
m_pConf->m_sRemoteUsername = strPhonenum;
/*
r = sndPlaySound("start.wav",SND_ASYNC|SND_NODEFAULT);//播放WAV文件
ASSERT(r);
Sleep(1000);
r =sndPlaySound("",SND_ASYNC|SND_NODEFAULT);//停止播放
*/
::EnableWindow(::GetDlgItem(hwnd,IDC_ACCEPT),TRUE);
::EnableWindow(::GetDlgItem(hwnd,IDC_ACCEPT),TRUE);
::EnableWindow(::GetDlgItem(hwnd,IDC_CALLHANGUP),FALSE);
::ShowWindow(hwnd,SW_NORMAL);
::SetForegroundWindow(hwnd);
// if (MessageBox(NULL,"接受呼叫?",strName,MB_YESNO|MB_TASKMODAL)== IDYES)
m_Tmp.Format(IDS_CONFIRM_ACCEPT,strNameAndNum);
//m_pConf->pNetproDlg->m_cMsgwnd.m_cStatus = m_Tmp;
m_pConf->pNetproDlg->m_pMsgWndOwner->SetMsgWndStatus( m_Tmp,0);
m_pConf->pNetproDlg->StartCallTimer();
/*
if(m_Acceptdlg->GetSafeHwnd()!=0)
{
m_Acceptdlg->DestroyWindow();
}
m_Acceptdlg->m_cSUB = m_Tmp;
nResponse = m_Acceptdlg->Create(IDD_DIALOG_RING);
m_Acceptdlg->StartTimer();
*/
/*
if(nResponse == IDOK)
m_pConf->AcceptCall();
else
m_pConf->RejectCall();
*/
break;
case NM_CALL_REJECTED:
// Notify my Conf object that the call was rejected.
m_pConf->CallRejected();
break;
case NM_CALL_ACCEPTED:
// Notify my Conf object that the call was accepted
m_pConf->CallAccepted();
break;
case NM_CALL_INIT:
break;
case NM_CALL_SEARCH:
break;
case NM_CALL_WAIT:
break;
case NM_CALL_CANCELED:
m_pConf->pNetproDlg->KillCallTimer();
m_pConf->CallCanceled();
break;
}
return S_OK;
}
void CCallNotify::AcceptCall()
{
m_pConf->AcceptCall();
}
void CCallNotify::RejectCall()
{
m_pConf->RejectCall();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -