⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tapisampledlg.cpp

📁 基于TAPI 2.0的软电话源代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// Respond to the "Blind Transfer" button by transferring a call to the 
// specified address.
// For this to work, there must be a call active.
void CTapisampleDlg::OnBlindTransfer() 
{
	UpdateData(TRUE); // Get the target address from the edit box
	if (!m_Address.IsEmpty())
	{
		TapiLine *line = m_Tapi.GetTapiLine();
		if (line)
			line->BlindTransferCall(m_Address);
	}
	else
		AddText("Error(BlindTransferCall: No Address)");
}

// ----------------------------------------------------------------------------
// Respond to the "Get Call Status" button by getting the status of the 
// currently active call.
// For this to work, there must be an active call.
void CTapisampleDlg::OnGetcallstatus()
{
	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->GetCallStatus();
}

// ----------------------------------------------------------------------------
// Respond to the "Setup Transfer" button by creating a consultation call.
// If the actuve call is not already on hold, this will put the call on hold
// before creating a new call.
// This requires there to be an active call or a call on hold.
void CTapisampleDlg::OnSetupTransfer()
{
	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->SetupTransfer();
}

// ----------------------------------------------------------------------------
// Respond to the "Dial" button by dialling on the active call.
// This requires there to be a call active.
void CTapisampleDlg::OnDial()
{
	UpdateData(TRUE); // Get the number to dial from the edit box
	if (!m_Address.IsEmpty())
	{
		TapiLine *line = m_Tapi.GetTapiLine();
		if (line)
			line->Dial(m_Address);
	}
	else
		AddText("Error(lineDial: No Address)");
}

// ----------------------------------------------------------------------------
// Respond to the "Complete Transfer" button by transferring the held call to
// the active call.
// There must be a held call and active call for this to work.
void CTapisampleDlg::OnCompleteTransfer()
{
	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->CompleteTransfer();
}

// ----------------------------------------------------------------------------
// Respond to the "Swap Hold" button by swapping the held call and the active
// call.
// For this to work, there must be a held call and an active call.
void CTapisampleDlg::OnSwapHold()
{
	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->SwapHold();
}

// ----------------------------------------------------------------------------
// Respond to the "Park" button by parking the active call.
// Note that only a directed park will work on IP Office.
// For this to work there must be an active call and the edit box must contain
// a park slot id, e.g. 1, 2, 3 or 4.
void CTapisampleDlg::OnPark()
{
	UpdateData(TRUE); // Get the park id from the edit box
	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
	{
		if (m_Address.IsEmpty())
			line->Park(NULL);		// UNDIRECTED PARK (Doesn't work on IP400)
		else
			line->Park(m_Address);	// DIRECTED PARK
	}
}

// ----------------------------------------------------------------------------
// Respond to the "Unpark" button by retrieving the parked call.
// For this to work there must be a parked call and the edit box must contain
// the park id.
void CTapisampleDlg::OnUnpark()
{
	UpdateData(TRUE); // Get the park id from the edit box
	if (!m_Address.IsEmpty())
	{
		TapiLine *line = m_Tapi.GetTapiLine();
		if (line)
			line->Unpark(m_Address);	// Address of park slot (e.g. 1,2,3,4)
	}
	else
		AddText("Error(lineUnpark: No Park Address)");
}

// ----------------------------------------------------------------------------
// Respond to the "Redirect" button by redirecting a pending call.
// For this to work there must be a pending call and the edit box should 
// contain the target extension number.
void CTapisampleDlg::OnRedirect()
{
	UpdateData(TRUE); // In case the user has typed something in an edit box
	if (!m_Address.IsEmpty())
	{
		TapiLine *line = m_Tapi.GetTapiLine();
		if (line)
			line->Redirect(m_Address);	// Target Address
	}
	else
		AddText("Error(lineRedirect: No Target Address)");
}

// ----------------------------------------------------------------------------
// Respond to the "Add to Conference" button by adding the active call to the
// held conference.
// For this to work there must be an active call and a held conference.
void CTapisampleDlg::OnAddToConference()
{
	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->AddToConference();
}

// ----------------------------------------------------------------------------
// Respond to the "Remove from Conference" button by removing the last call 
// added to the conference.
// For this to work there must be an active conference.
void CTapisampleDlg::OnRemoveFromConference()
{
	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->RemoveFromConference();
}

// ----------------------------------------------------------------------------
// Respond to the "Address Status" button by displaying the status of the 
// address associated with the selected TAPI line.
void CTapisampleDlg::OnAddressStatus()
{
	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->AddressStatus();
}

// ----------------------------------------------------------------------------
// Respond to the "Get Call Info" button by displaying the call info of the 
// active call. 
// For this to work there must be an active call.
void CTapisampleDlg::OnGetCallInfo()
{
	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->GetCallInfo();
}

// ----------------------------------------------------------------------------
// This function is called when a new controlling extension is selected
//
void CTapisampleDlg::OnSelect()
{
	UpdateData(TRUE); // Get the new extension number from the edit box

	// Find the extension in the array of lines, and select the line
	DWORD extension = atoi(m_Extension);
	m_Tapi.SetExtension(extension);
	for (unsigned int i = 0; i < m_Tapi.m_NumDevs; i++)
	{
		if (m_Tapi.m_pLines[i] != NULL)
		{
			if (m_Tapi.m_pLines[i]->m_extension == extension)
			{
				m_Tapi.SetLine(i);
				CString txt;
				txt = CString("Extension ") + m_Extension + CString(" selected.");
				AddText(txt);
				break;
			}
		}
	}
}

// ----------------------------------------------------------------------------
// Respond to the "Log On" button by logging an extension on 
void CTapisampleDlg::OnLogOn()
{
	UpdateData(TRUE); // Get the new extension number from the edit box

	if (!m_Address.IsEmpty())
	{
		TapiLine *line = m_Tapi.GetTapiLine();
		if (line)
			line->LogOn(m_Address);	// Log On Id
	}
	else
		AddText("Error(Log On: No Log On Id)");
}

// ----------------------------------------------------------------------------
// Respond to the "Log Off" button by logging an extension off
void CTapisampleDlg::OnLogOff()
{
	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->LogOff();
}

// ----------------------------------------------------------------------------
// Respond to the "Config Dialog" button by displaying the config dialog
void CTapisampleDlg::OnConfigDialog()
{
	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->ConfigDialog();
}

// ----------------------------------------------------------------------------
// Respond to the "Divert Destination" button by setting the divert destination
// For this to work, the edit box must contain the divert destination
void CTapisampleDlg::OnDivertDestination()
{
	UpdateData(TRUE); // Get the divert destination from the edit box

	if (!m_Address.IsEmpty())
	{
		TapiLine *line = m_Tapi.GetTapiLine();
		if (line)
			line->DivertDestination(m_Address);
	}
	else
		AddText("Error(Log On: No Divert Destination)");
}

// ----------------------------------------------------------------------------
// Respond to the "Set Divert Settings" button by setting the divert settings
// The user should set the checkboxes before pressing this button.
void CTapisampleDlg::OnSetDivertSettings()
{
	UpdateData(TRUE); // Get the values from the divert settings check boxes

	BOOL FwdAll = m_CtlForwardAll.GetCheck();
	BOOL FwdBusy = m_CtlForwardBusy.GetCheck();
	BOOL FwdNoAnsw = m_CtlForwardNoAnswer.GetCheck();
	BOOL DND = m_CtlDoNotDisturb.GetCheck();

	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->SetDivertSettings(FwdAll,FwdBusy,FwdNoAnsw,DND);
}

// ----------------------------------------------------------------------------
// Respond to the "Get Divert Settings" button by displaying the divert 
// settings
void CTapisampleDlg::OnGetDivertSettings()
{
	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->GetDivertSettings();
}

// ----------------------------------------------------------------------------
// Respond to the "Set App Specific" button by setting the App Specific data 
// for a call.
// For this to work their must be a valid call handle in use, e.g. this could
// be a connected call, held call, etc. 
void CTapisampleDlg::OnSetAppSpecific()
{
	UpdateData(TRUE); // Get the value from the edit box

	if (!m_Address.IsEmpty())
	{
		DWORD num = atoi(m_Address);
		TapiLine *line = m_Tapi.GetTapiLine();
		if (line)
			line->SetAppSpecific(num);
	}
	else
		AddText("Error(SetAppSpecific: No number)");
}

// ----------------------------------------------------------------------------
// This function adds an icon into the TaskBar Notification Area,
// or Status Area, otherwise known as the system tray.
void CTapisampleDlg::AddSystemTrayIcon()
{
	NOTIFYICONDATA nda;

	nda.cbSize = sizeof(NOTIFYICONDATA);
	nda.hWnd = m_hWnd;
	nda.uID = 1;
	nda.hIcon = AfxGetApp()->LoadIcon(IDI_ICON1);
	strcpy(nda.szTip, "IP Office TAPI Sample");
	nda.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;
	nda.uCallbackMessage = WM_USER + 100; // Message Id;
	Shell_NotifyIcon(NIM_ADD, &nda); 
}

// ----------------------------------------------------------------------------
// This function remove the icon from the TaskBar Notification Area.
void CTapisampleDlg::DeleteSystemTrayIcon()
{
	NOTIFYICONDATA nda;

	nda.cbSize = sizeof(NOTIFYICONDATA);
	nda.hWnd = m_hWnd;
	nda.uID = 1;
	Shell_NotifyIcon(NIM_DELETE, &nda); 
}

// ----------------------------------------------------------------------------
// This function responds to the "Hide" button and hides the dialog display.
// It will reappear when a new call is created, or the user clicks on the icon
// in the system tray.
void CTapisampleDlg::OnHide()
{
	ShowWindow(SW_HIDE);
}


// ----------------------------------------------------------------------------
// This function displays the dialog when a user clicks on the icon in the 
// system tray.
LRESULT CTapisampleDlg::OnTrayMessage(WPARAM wParam, LPARAM lParam)
{
	switch (lParam)
	{
	case WM_LBUTTONDOWN: ShowWindow(SW_SHOWNORMAL); break;
	default:
		break;
	}
	return 0;
}

void CTapisampleDlg::OnMsgWaitLamp()
{
	UpdateData(TRUE); // Get the value from the edit box

	DWORD num = 0;
	if (!m_Address.IsEmpty())
		num = atoi(m_Address);

	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->SetMsgWaitLamp(num);
}

void CTapisampleDlg::OnInGroup()
{
	UpdateData(TRUE); // Get the value from the edit box

	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->SetInGroup(m_Address);
}

void CTapisampleDlg::OnOutGroup()
{
	UpdateData(TRUE); // Get the value from the edit box

	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->SetOutGroup(m_Address);
}

void CTapisampleDlg::OnSetCallData()
{
	UpdateData(TRUE); // Get the value from the edit box

	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->SetCallData(m_Address);
}

void CTapisampleDlg::OnListen()
{
	UpdateData(TRUE); // Get the value from the edit box

	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->Listen(m_Address);
}

void CTapisampleDlg::OnIntrude()
{
	UpdateData(TRUE); // Get the value from the edit box

	TapiLine *line = m_Tapi.GetTapiLine();
	if (line)
		line->Intrude(m_Address);
}

void CTapisampleDlg::OnEnableButtons()
{
	m_CtlConferenceCall.EnableWindow(true);
	m_CtlAnswerCall.EnableWindow(true);
	m_CtlDropCall.EnableWindow(true);
	m_CtlHoldCall.EnableWindow(true);
	m_CtlMakeCall.EnableWindow(true);
	m_CtlUnholdCall.EnableWindow(true);
	m_CtlBlindTransferCall.EnableWindow(true);
	m_CtlSetupTransfer.EnableWindow(true);
	m_CtlDial.EnableWindow(true);
	m_CtlCompleteTransfer.EnableWindow(true);
	m_CtlSwapHold.EnableWindow(true);
	m_CtlPark.EnableWindow(true);
	m_CtlUnpark.EnableWindow(true);
	m_CtlRedirect.EnableWindow(true);
	m_CtlAddToConference.EnableWindow(true);
	m_CtlRemoveFromConference.EnableWindow(true);
	m_CtlGetCallInfo.EnableWindow(true);
}

void CTapisampleDlg::OnReset()
{
	TapiLine *line = m_Tapi.GetTapiLine();
    line->m_hConnectedCall = 0;
	line->m_hWaitingCall = 0;
	line->m_hHeldCall = 0;
	line->m_hPendingCall = 0;
	line->m_hConferenceCall = 0;
	line->m_hConsultationCall = 0;
	line->m_hLastCallIntoConf = 0;
}

void CTapisampleDlg::OnAccountCode()
{
	UpdateData(TRUE); // Get the value from the edit box

	TapiLine *line = m_Tapi.GetTapiLine();
    if (line)
        line->SetAccountCode(m_Address);
}

void CTapisampleDlg::OnGenerateDigits()
{
	UpdateData(TRUE); // Get the value from the edit box

	TapiLine *line = m_Tapi.GetTapiLine();
    if (line)
        line->GenerateDigits(m_Address);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -