LONG LineCallStateProc(DWORD dwDevice, DWORD dwInstance,DWORD dwParam1, DWORD dwParam2,DWORD dwParam3) { long lRc; char szDebug[256]; switch(dwParam1) { case LINECALLSTATE_IDLE: lRc = lineDeallocateCall((HCALL)dwDevice); wsprintf(szDebug,"lineDeallocateCall returned: %d",lRc); debugString(4,"LineCallStateProc",szDebug,_where()); break; default: break; } return 0; }
int xtapi_device_hangup() { LONG retval; Assert(TapiDev.valid); // Device should be locked! // if (!TapiDev.hCall) return XTAPI_SUCCESS; // if (!TapiDev.hLine) return XTAPI_SUCCESS; // drop any call in progress if (TapiDev.hCall) { LINECALLSTATUS *lcallstat = NULL; MSG msg; DWORD call_state; lcallstat = tapi_line_getcallstatus(TapiDev.hCall); if (!lcallstat) { return XTAPI_OUT_OF_MEMORY; } mprintf((0, "XTAPI: Got linestatus.\n")); if (!(lcallstat->dwCallState & LINECALLSTATE_IDLE)) { // line not IDLE so drop it! retval = xtapi_device_wait_for_reply( lineDrop(TapiDev.hCall, NULL, 0) ); if (retval != XTAPI_SUCCESS) { mprintf((1, "XTAPI: error when lineDrop.\n")); } mprintf((0, "XTAPI: dropped line.\n")); // wait for IDLE mprintf((0, "XTAPI: Waiting for idle.\n")); while (1) { xtapi_device_poll_callstate((uint*)&call_state); if (call_state == XTAPI_LINE_IDLE) break; if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } } } retval = lineDeallocateCall(TapiDev.hCall); mprintf((0, "XTAPI: deallocated call.\n")); if (retval != 0) { free(lcallstat); return XTAPI_GENERAL_ERR; } TapiDev.hCall = NULL; if (lcallstat) free(lcallstat); } // Free up line. if (TapiDev.hLine) { retval = lineClose(TapiDev.hLine); if (retval != 0) { return XTAPI_GENERAL_ERR; } TapiDev.hLine = NULL; } mprintf((0, "XTAPI: Closed line.\n")); TapiDev.connected = FALSE; return XTAPI_SUCCESS; }