📄 dialer.c
字号:
{
if ( gMakeCallRequestID == LINEERR_CALLUNAVAIL )
{
DialogBoxParam (
ghInst,
MAKEINTRESOURCE(IDD_CALLFAILED),
ghWndMain,
(DLGPROC)LineInUseProc,
0
);
}
else
{
errString( ghWndMain, gMakeCallRequestID, MB_ICONEXCLAMATION | MB_OK );
}
DialerLineClose();
gfCurrentLineAvail = TRUE;
}
error :
if ( lpLineCallParams )
{
DialerFree( lpLineCallParams );
}
if ( lpTransOut )
{
DialerFree( lpTransOut );
}
// if makecall did not succeed but line
// was opened, close it.
if ( ( gMakeCallRequestID <= 0 ) && ( gCurrentLineInfo.hLine ) )
{
DialerLineClose ();
gfCurrentLineAvail = TRUE;
}
SetFocus( GetDlgItem( ghWndMain, IDD_DCOMBO ) );
return;
}
//***************************************************************************
//***************************************************************************
//***************************************************************************
DWORD GetLineInfo ( DWORD iLine, LPLINEINFO lpLineInfo )
{
DWORD errCode = 0;
DWORD dwNeededSize = 0;
LINEEXTENSIONID ExtensionID;
LPSTR pszLineName = NULL;
LPLINEDEVCAPS lpDevCaps = NULL;
errCode = lineNegotiateAPIVersion (
ghLineApp,
iLine,
TAPI_VERSION_1_0,
TAPI_CURRENT_VERSION,
&( lpLineInfo->dwAPIVersion ),
&ExtensionID
);
if ( errCode )
{
GetLineInfoFailed( iLine, lpDevCaps, lpLineInfo );
goto error;
}
dwNeededSize = sizeof( LINEDEVCAPS );
do
{
lpDevCaps = ( LPLINEDEVCAPS ) DialerAlloc( dwNeededSize );
if ( !lpDevCaps )
{
GetLineInfoFailed( iLine, lpDevCaps, lpLineInfo );
errCode = LINEERR_NOMEM;
goto error;
}
lpDevCaps->dwTotalSize = dwNeededSize;
errCode = lineGetDevCaps (
ghLineApp,
iLine,
lpLineInfo->dwAPIVersion,
0,
lpDevCaps
);
if ( errCode )
{
GetLineInfoFailed( iLine, lpDevCaps, lpLineInfo );
goto error;
}
if ( lpDevCaps-> dwNeededSize <= lpDevCaps-> dwTotalSize )
{
break;
}
dwNeededSize = lpDevCaps->dwNeededSize;
DialerFree( lpDevCaps );
lpDevCaps = NULL;
} while ( TRUE );
lpLineInfo->nAddr = lpDevCaps->dwNumAddresses;
lpLineInfo->fVoiceLine =
( (lpDevCaps->dwMediaModes & LINEMEDIAMODE_INTERACTIVEVOICE) != 0 );
pszLineName = (LPSTR) DialerAlloc( MAXBUFSIZE );
if ( !pszLineName )
{
errCode = LINEERR_NOMEM;
goto error;
}
if ( lpDevCaps->dwLineNameSize > 0 )
{
if ( lpDevCaps-> dwLineNameSize > (MAXBUFSIZE - 1) )
{
strncpy (
pszLineName,
(LPSTR) lpDevCaps + lpDevCaps->dwLineNameOffset,
MAXBUFSIZE - 1
);
pszLineName[ MAXBUFSIZE - 1 ] = '\0';
}
else
{
lstrcpy( pszLineName, (LPSTR) lpDevCaps + lpDevCaps-> dwLineNameOffset );
}
}
else
{
wsprintf ( pszLineName, "Line %d", iLine );
}
lstrcpy( lpLineInfo->szLineName, pszLineName );
lpLineInfo->dwPermanentLineID = lpDevCaps->dwPermanentLineID;
error:
if ( lpDevCaps )
DialerFree( lpDevCaps );
if ( pszLineName )
DialerFree( pszLineName );
return errCode;
}
//***************************************************************************
//***************************************************************************
//***************************************************************************
VOID GetLineInfoFailed ( DWORD iLine, LPLINEDEVCAPS lpDevCaps, LPLINEINFO lpLineInfo )
{
if ( lpDevCaps )
DialerFree(lpDevCaps);
lpLineInfo->nAddr = 0;
lpLineInfo->fVoiceLine = FALSE;
lpLineInfo->dwAPIVersion = 0;
lpLineInfo->hLine = (HLINE)0;
lpLineInfo->dwPermanentLineID = 0;
lpLineInfo->szLineName[0] = 0;
}
//***************************************************************************
//***************************************************************************
//***************************************************************************
LPSTR GetAddressName(DWORD iLine, DWORD iAddress)
{
DWORD errCode = 0;
DWORD dwNeededSize = 0;
LPSTR pszAddressName = NULL;
LPLINEADDRESSCAPS lpAddressCaps = NULL;
// allocate space for lineGetAddressCaps data
dwNeededSize = sizeof( LINEADDRESSCAPS );
do
{
lpAddressCaps = ( LPLINEADDRESSCAPS )DialerAlloc( dwNeededSize );
if ( !lpAddressCaps )
{
goto error;
}
lpAddressCaps->dwTotalSize = dwNeededSize;
errCode = lineGetAddressCaps (
ghLineApp,
iLine,
iAddress,
gCurrentLineInfo.dwAPIVersion,
0,
lpAddressCaps
);
if ( errCode )
{
errString( ghWndMain, errCode, MB_ICONSTOP | MB_OK );
goto error;
}
if ( lpAddressCaps-> dwNeededSize <= lpAddressCaps-> dwTotalSize )
{
break;
}
dwNeededSize = lpAddressCaps->dwNeededSize;
DialerFree( lpAddressCaps );
lpAddressCaps = NULL;
} while( TRUE );
// get the address name
pszAddressName = DialerAlloc( MAXBUFSIZE );
if ( !pszAddressName )
{
goto error;
}
if ( lpAddressCaps-> dwAddressSize > 0 )
{
// keep string length bounded
if ( lpAddressCaps-> dwAddressSize > (MAXBUFSIZE - 1 ) )
{
strncpy(
pszAddressName,
(LPSTR) lpAddressCaps + lpAddressCaps->dwAddressOffset,
MAXBUFSIZE - 1
);
pszAddressName[ MAXBUFSIZE - 1] = '\0';
}
else
{
lstrcpy (
pszAddressName,
(LPSTR) lpAddressCaps + lpAddressCaps->dwAddressOffset
);
}
}
else
// use default name
{
wsprintf(pszAddressName, "Address %d", iAddress);
}
error:
if ( lpAddressCaps )
{
DialerFree( lpAddressCaps );
}
return pszAddressName;
}
//***************************************************************************
//***************************************************************************
//***************************************************************************
BOOL CALLBACK DialingProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
char szTemp[ TAPIMAXCALLEDPARTYSIZE ];
case WM_INITDIALOG:
// set global handle to window
ghWndDialing = hwnd;
AmpersandCompensate( gszCurrentName, szTemp );
SetDlgItemText(hwnd, IDD_DGNUMBERTEXT, gszCurrentNumber);
SetDlgItemText(hwnd, IDD_DGNAMETEXT, szTemp );
break;
case WM_COMMAND:
switch ( LOWORD( (DWORD)wParam ) )
{
// hang up
case IDCANCEL:
//gfDropping = TRUE;
// if lineMakeCall has completed
// only then drop call.
if ( !gfMakeCallReplyPending && ghCall )
{
if ( ( gDropCallRequestID = lineDrop ( ghCall, NULL, 0 ) ) < 0 )
{
errString ( ghWndDialing, gDropCallRequestID, MB_ICONSTOP | MB_OK );
}
}
else
{
DialerLineClose();
gfCurrentLineAvail = TRUE;
gfMakeCallReplyPending = FALSE;
}
ghWndDialing = NULL;
EndDialog(hwnd, FALSE);
return TRUE;
// something else terminated the call
// all we have to do is terminate this dialog box
case IDOK:
ghWndDialing = NULL;
EndDialog(hwnd, TRUE);
return TRUE;
}
break;
default:
;
}
return FALSE;
}
//***************************************************************************
//***************************************************************************
//***************************************************************************
BOOL CALLBACK AboutProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_INITDIALOG:
{
return TRUE;
}
case WM_CLOSE:
EndDialog(hwnd, TRUE);
return TRUE;
case WM_COMMAND:
if(LOWORD((DWORD)wParam) == IDOK)
{
EndDialog(hwnd, TRUE);
return TRUE;
}
break;
}
return FALSE;
}
//***************************************************************************
//***************************************************************************
//***************************************************************************
BOOL CALLBACK ConnectUsingProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch(msg)
{
case WM_INITDIALOG:
{
BOOL fEnable;
DWORD dwPriority;
//
// Is there any point in even showing this dialog box?
if ( gnAvailDevices == 0 )
{
// Nope. Let's tell the user what we don't like.
errString ( ghWndMain, ERR_NOLINES, MB_ICONEXCLAMATION | MB_OK );
EndDialog(hwnd, FALSE);
return TRUE;
}
// if not brought up by InitializeTAPI()
if ( lParam != INVALID_LINE )
{
// hide error text
EnableWindow( GetDlgItem( hwnd, IDD_CUERRORTEXT ), FALSE );
}
// get list of lines into the line list box.
fEnable = InitializeLineBox( GetDlgItem(hwnd, IDD_CULISTLINE) );
EnableWindow( GetDlgItem( hwnd, IDD_CULISTLINE ), fEnable);
// get list of addresses into the address list box.
fEnable = fEnable &&
InitializeAddressBox (
GetDlgItem(hwnd, IDD_CULISTLINE),
GetDlgItem(hwnd, IDD_CULISTADDRESS)
);
EnableWindow( GetDlgItem( hwnd, IDD_CULISTADDRESS ), fEnable );
EnableWindow( GetDlgItem( hwnd, IDOK ), fEnable );
EnableWindow( GetDlgItem( hwnd, IDD_CUPROPERTIES ), fEnable );
lineGetAppPriority (
"DIALER.EXE",
0, // checking app priority for Assisted Telephony requests
NULL,
LINEREQUESTMODE_MAKECALL,
NULL,
&dwPriority
);
CheckDlgButton(hwnd, IDD_CUSIMPLETAPICHKBOX, (dwPriority == 1));
// if dwPriority == 1, we're supporting Assisted Telephony AND
// have the highest priority.
EnableWindow (
GetDlgItem(hwnd, IDD_CUSIMPLETAPICHKBOX),
gfRegistered
);
return FA
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -