JNIEXPORT jint JNICALL Java_net_xtapi_serviceProvider_MSTAPI_dropCall (JNIEnv *pEnv, jobject oObj, jint lHandle) { long lRc; char szDebug[256]; wsprintf(szDebug,"dropCall dropping call handle %d.",lHandle); debugString(4,"dropCall",szDebug,_where()); lRc = lineDrop((HCALL)lHandle, "", 0); wsprintf(szDebug,"lineDrop returned %d.",lRc); debugString(4,"dropCall",szDebug,_where()); /* -- Removed. lineDeallocateCall is now called automatically -- from the LINECALLSTATE_IDLE message. Sleep(1000); lRc = lineDeallocateCall((HCALL)lHandle); wsprintf(szDebug,"lineDeallocateCall returned %d.",lRc); debugString(4,"dropCall",szDebug,_where()); */ 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; }