Skip to content

Commit

Permalink
ECS-1953 Improved handling of forwarding for addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
JanFellner committed Jul 11, 2024
1 parent 3572b33 commit fe01b2f
Show file tree
Hide file tree
Showing 7 changed files with 1,040 additions and 962 deletions.
3 changes: 2 additions & 1 deletion julmar/ATAPI/include/Atapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class ECSTAAddressCaps
{
public:
bool valid() const;
CString getDisplayText() const;
CString getDisplayText(const bool bWithAdditions = true) const;
DWORD m_dwAddressFlags = 0;
CString m_strDeviceID;
CString m_strDeviceType;
Expand Down Expand Up @@ -470,6 +470,7 @@ class CTapiAddress : public CTapiObject
DWORD GetID(LPVARSTRING lpDeviceID, LPCTSTR lpszDeviceClass);
void GetValidIDs(CStringArray& arrKeys) const;
CString GetDialableAddress();
CString GetDisplayText(const bool bWithAdditions);
LONG DevSpecific(LPVOID lpParams, DWORD dwSize);
LONG GetNewCalls(CObList& lstCalls);
LONG GetNumRings(LPDWORD lpdwNumRings);
Expand Down
56 changes: 40 additions & 16 deletions julmar/ATAPI/src/Tapiaddr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bool ECSTAAddressCaps::valid() const
return false;
}

CString ECSTAAddressCaps::getDisplayText() const
CString ECSTAAddressCaps::getDisplayText(const bool bWithAdditions /*= true*/) const
{
CString strDisplayText;
if (!m_strDeviceName.IsEmpty())
Expand All @@ -54,22 +54,25 @@ CString ECSTAAddressCaps::getDisplayText() const
strDisplayText += L" - ";
strDisplayText += m_strDeviceType;
}
if (m_dwAddressFlags & ECSTA_ADDRESSFLAG_IS_ACTIVEADDRESS)
strDisplayText += L" - active";
if (m_dwAddressFlags & (ECSTA_ADDRESSFLAG_IS_ACD_GROUP_ADDRESS | ECSTA_ADDRESSFLAG_SUPPORTS_FORWARDS_ONLY))
if (bWithAdditions)
{
strDisplayText += L" (";
CString strAddon;
if (m_dwAddressFlags & ECSTA_ADDRESSFLAG_IS_ACD_GROUP_ADDRESS)
strAddon += L"ACD";
if (m_dwAddressFlags & ECSTA_ADDRESSFLAG_SUPPORTS_FORWARDS_ONLY)
if (m_dwAddressFlags & ECSTA_ADDRESSFLAG_IS_ACTIVEADDRESS)
strDisplayText += L" - active";
if (m_dwAddressFlags & (ECSTA_ADDRESSFLAG_IS_ACD_GROUP_ADDRESS | ECSTA_ADDRESSFLAG_SUPPORTS_FORWARDS_ONLY))
{
if (!strAddon.IsEmpty())
strAddon += L" | ";
strAddon += L"FWD";
strDisplayText += L" (";
CString strAddon;
if (m_dwAddressFlags & ECSTA_ADDRESSFLAG_IS_ACD_GROUP_ADDRESS)
strAddon += L"ACD";
if (m_dwAddressFlags & ECSTA_ADDRESSFLAG_SUPPORTS_FORWARDS_ONLY)
{
if (!strAddon.IsEmpty())
strAddon += L" | ";
strAddon += L"FWD";
}
strDisplayText += strAddon;
strDisplayText += L")";
}
strDisplayText += strAddon;
strDisplayText += L")";
}
return strDisplayText;
}
Expand Down Expand Up @@ -322,11 +325,32 @@ CString CTapiAddress::GetDialableAddress()
strAddress = lpszAddress;
}
}

return strAddress;

} // CTapiAddress::GetDialableAddress

CString CTapiAddress::GetDisplayText(const bool bWithAdditions)
{
LPLINEADDRESSCAPS lpAddrCaps = GetAddressCaps();

CString strDisplayText;
if (lpAddrCaps && lpAddrCaps->dwAddressSize && lpAddrCaps->dwAddressOffset)
{
LPCTSTR lpszAddress = (LPCTSTR)(((LPBYTE)lpAddrCaps) + lpAddrCaps->dwAddressOffset);
strDisplayText = lpszAddress;
}

if (strDisplayText.IsEmpty())
strDisplayText.Format(_T("Address %ld"), GetAddressID());
else
strDisplayText.AppendFormat(L" - ID %ld", GetAddressID());

ECSTAAddressCaps addressCaps;
if (GetECSTAAddressCaps(addressCaps) == NO_ERROR)
strDisplayText += addressCaps.getDisplayText(bWithAdditions);

return strDisplayText;
}

////////////////////////////////////////////////////////////////////////////////////
// CTapiAddress::DevSpecific
//
Expand Down
80 changes: 62 additions & 18 deletions julmar/Phone/ForwardDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CForwardDlg::CForwardDlg(CWnd* pParent, CTapiLine* pLine)

//{{AFX_DATA_INIT(CForwardDlg)
m_bAllAddresses = FALSE;
m_fSupportsDND = FALSE;
m_bSupportsAllModes = FALSE;
m_strCaller = _T("");
m_strDest = _T("");
m_iNumRings = 0;
Expand Down Expand Up @@ -79,11 +79,8 @@ BOOL CForwardDlg::OnInitDialog()
{
CDialog::OnInitDialog();

LINEDEVCAPS* pCaps = m_pLine->GetLineCaps();
if (pCaps && (pCaps->dwLineFeatures & LINEFEATURE_FORWARDDND))
m_fSupportsDND = TRUE;
if (GetKeyState(VK_CONTROL) < 0)
m_fSupportsDND = TRUE;
m_bSupportsAllModes = TRUE;

((CEdit*)GetDlgItem(IDC_NUMRINGS))->LimitText(3);
m_ctlSpin.SetRange(0, 999);
Expand All @@ -92,7 +89,7 @@ BOOL CForwardDlg::OnInitDialog()
for (unsigned int i = 0; i < m_pLine->GetAddressCount(); i++)
{
CTapiAddress* pAddr = m_pLine->GetAddress(i);
int iPos = m_cbAddress.AddString(pAddr->GetDialableAddress());
int iPos = m_cbAddress.AddString(pAddr->GetDisplayText(false));
m_cbAddress.SetItemData(iPos, (DWORD_PTR)pAddr);
}

Expand Down Expand Up @@ -168,9 +165,7 @@ void CForwardDlg::OnChange()
int iCurSel = m_cbFwdModes.GetCurSel();
if (iCurSel != CB_ERR)
dwFwdMode = (DWORD)m_cbFwdModes.GetItemData(iCurSel);
if (dwFwdMode == LINEFORWARDMODE_UNCOND && m_fSupportsDND && m_strDest.IsEmpty())
m_btnOK.EnableWindow(TRUE);
else if (dwFwdMode == EPHONEEXELINEFORWARDMODE_DND)
if (dwFwdMode == EPHONEEXELINEFORWARDMODE_DND)
m_btnOK.EnableWindow(TRUE);
else
m_btnOK.EnableWindow(!m_strDest.IsEmpty() && m_cbFwdModes.GetCurSel() != CB_ERR);
Expand All @@ -184,6 +179,31 @@ void CForwardDlg::OnAllAddresses()
if (m_bAllAddresses)
{
m_cbAddress.EnableWindow(FALSE);
bool bFindEntry = true;
{
CTapiAddress* pAddr = (CTapiAddress*)m_cbAddress.GetItemData(m_cbAddress.GetCurSel());
if (pAddr)
{
LINEADDRESSCAPS* lpCaps = pAddr->GetAddressCaps();
if (lpCaps && (lpCaps->dwForwardModes || lpCaps->dwAddressFeatures & LINEADDRFEATURE_FORWARDDND))
bFindEntry = false;
}
}
if (bFindEntry)
{
for (int iCount = 0; iCount < m_cbAddress.GetCount(); iCount++)
{
CTapiAddress* pAddr = (CTapiAddress*)m_cbAddress.GetItemData(iCount);

LINEADDRESSCAPS* lpCaps = pAddr->GetAddressCaps();
if (lpCaps && (lpCaps->dwForwardModes || lpCaps->dwAddressFeatures & LINEADDRFEATURE_FORWARDDND))
{
m_cbAddress.SetCurSel(iCount);
OnAddressChange();
break;
}
}
}
}
else
{
Expand Down Expand Up @@ -255,32 +275,56 @@ void CForwardDlg::OnAddressChange()
iCurSel = m_cbFwdModes.GetCurSel();
if (iCurSel != CB_ERR)
m_cbFwdModes.GetLBText(iCurSel, strFwdMode);

m_cbFwdModes.ResetContent();

LINEADDRESSCAPS* lpCaps = pAddr->GetAddressCaps(0, 0, TRUE);
if (lpCaps == NULL)
return;

if (m_iMinRings == 0 && m_iMaxRings == 0 && GetDlgItem(IDC_NUMRINGS)->IsWindowEnabled())
{
m_iMinRings = lpCaps->dwMinFwdNumRings;
m_iMaxRings = lpCaps->dwMaxFwdNumRings;
if (m_iMinRings == 0 && m_iMaxRings == 0)
GetDlgItem(IDC_NUMRINGS)->EnableWindow(FALSE);
}
m_iMinRings = lpCaps->dwMinFwdNumRings;
m_iMaxRings = lpCaps->dwMaxFwdNumRings;
GetDlgItem(IDC_NUMRINGS)->EnableWindow(m_iMinRings == 0 && m_iMaxRings == 0);

m_dwAvailFwdModes = lpCaps->dwForwardModes;

for (int i = 0; i < (sizeof(FwdModes) / sizeof(FwdModes[0])); i++)
{
if (lpCaps->dwForwardModes & FwdModes[i].dwFwdMode || FwdModes[i].dwFwdMode == EPHONEEXELINEFORWARDMODE_DND && (lpCaps->dwAddressFeatures & LINEADDRFEATURE_FORWARDDND || m_fSupportsDND))
bool bAddEntry = false;
if (m_bSupportsAllModes)
{
// Support all entries by holding control on dlg open
bAddEntry = true;
}
else if (FwdModes[i].dwFwdMode == EPHONEEXELINEFORWARDMODE_DND)
{
// DND is supported on the current address
if (lpCaps->dwAddressFeatures & LINEADDRFEATURE_FORWARDDND)
bAddEntry = true;
}
else if (lpCaps->dwForwardModes & FwdModes[i].dwFwdMode)
{
// The mode we are currently handling is supported by the tapi driver on the given address
bAddEntry = true;
}

if (bAddEntry)
{
iCurSel = m_cbFwdModes.AddString(FwdModes[i].pszName);
m_cbFwdModes.SetItemData(iCurSel, FwdModes[i].dwFwdMode);
}
}

if (m_cbFwdModes.GetCount() == 0)
{
if (m_cbAddress.GetCount() == 0)
m_cbFwdModes.AddString(L"Line does not support forwarding");
else
m_cbFwdModes.AddString(L"Address does not support forwarding");
m_cbFwdModes.EnableWindow(FALSE);
}
else
m_cbFwdModes.EnableWindow(TRUE);

iCurSel = CB_ERR;
if (!strFwdMode.IsEmpty())
iCurSel = m_cbFwdModes.SelectString(-1, strFwdMode);
Expand Down
2 changes: 1 addition & 1 deletion julmar/Phone/ForwardDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CForwardDlg : public CDialog
CComboBox m_cbFwdModes;
CComboBox m_cbAddress;
BOOL m_bAllAddresses;
BOOL m_fSupportsDND;
BOOL m_bSupportsAllModes;
CString m_strCaller;
CString m_strDest;
UINT m_iNumRings;
Expand Down
12 changes: 6 additions & 6 deletions julmar/Phone/ForwardList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ BOOL CForwardList::OnInitDialog()

if (m_dwAddressCount > 1)
{
m_List.InsertColumn(0, _T("Address"), 0, 70);
m_List.InsertColumn(1, _T("Type"), 0, 230);
m_List.InsertColumn(2, _T("Destination"), 0, 150);
m_List.InsertColumn(0, _T("Address"), 0, 170);
m_List.InsertColumn(1, _T("Type"), 0, 220);
m_List.InsertColumn(2, _T("Destination"), 0, 155);
}
else
{
m_List.InsertColumn(0, _T("Type"), 0, 225);
m_List.InsertColumn(1, _T("Destination"), 0, 225);
m_List.InsertColumn(0, _T("Type"), 0, 272);
m_List.InsertColumn(1, _T("Destination"), 0, 272);
}

UpdateList();
Expand Down Expand Up @@ -116,7 +116,7 @@ void CForwardList::UpdateList()
if (pAddress)
{
LPLINEADDRESSSTATUS lpStatus = pAddress->GetAddressStatus(TRUE);
m_ForwardList.AddAddressStatus(lpStatus, pAddress->GetDialableAddress(), dwCount);
m_ForwardList.AddAddressStatus(lpStatus, pAddress->GetDisplayText(false), dwCount);
}
}
ETapiForwardEntryList::iterator it;
Expand Down
Loading

0 comments on commit fe01b2f

Please sign in to comment.