示例#1
0
JNIEXPORT jint JNICALL Java_net_xtapi_serviceProvider_MSTAPI_connectCall
  (JNIEnv *pEnv, jobject oObj, jint lLine, jstring oDest, jint lHandle)
{
	const char* utf_string;
	jboolean isCopy;
	long lRet = 0;
	char szDebug[256];
	HCALL hCall = 0;

	utf_string = pEnv->GetStringUTFChars(oDest,&isCopy);

	wsprintf(szDebug,"Will place call from line %d to %s.",lLine,utf_string);

	debugString(8,"connectCall",szDebug,_where());

	lRet = lineMakeCall((HLINE)lHandle, &hCall, utf_string, 0, 0);

	long lWait = (long)hCall;

	if(JNI_TRUE == isCopy) {
		pEnv->ReleaseStringUTFChars(oDest,utf_string);
	}

	// If lineMakeCall succeeded then lRet > 0.  However lineMakeCall is
	// async so we wait on the change of hCall befor returning if the
	// call to lineMakeCall was successfull....

	int loop = 0;

	wsprintf(szDebug,"lineMakeCall returned -> %d",lRet);

	if(lRet > 0)
	{
		debugString(8,"connectCall",szDebug,_where());

		while((long)hCall == 0)
		{
			Sleep(20);
			loop++;
			if(loop * 20 > MAXCALLWAIT_MS)
				break;	// Bail out!!
		}

	}
	else
	{
		debugString(1,"connectCall",szDebug,_where());
		return - 1;
	}

	wsprintf(szDebug,"Waited %d milliseconds for lineMakeCall",loop *20);
	debugString(8,"connectCall",szDebug,_where());

	wsprintf(szDebug,"hCall = -> %d",(long)hCall);
	debugString(8,"connectCall",szDebug,_where());

	return (long)hCall;

}
示例#2
0
文件: xtapi.c 项目: btb/d2x
int xtapi_device_dialout(char *phonenum)
{
	LINEDEVCAPS *ldevcaps=NULL;
	LINECALLPARAMS *lcallparams=NULL;
	LONG retval;
	int xtapi_ret = XTAPI_SUCCESS;

	if (TapiDev.hLine) return XTAPI_BUSY;

//	check if we can dial out
	if (TapiDev.type != XTAPI_MODEM_DEVICE) {
		xtapi_ret = XTAPI_NOT_SUPPORTED;
		goto dialout_exit;
	}
	ldevcaps = tapi_getdevcaps(TapiDev.id);
	if (!ldevcaps) return XTAPI_OUT_OF_MEMORY;
	if (!(ldevcaps->dwLineFeatures & LINEFEATURE_MAKECALL)) {
		xtapi_ret = XTAPI_NOT_SUPPORTED;
		goto dialout_exit;
	}

//	open the line!
	retval = lineOpen(TapiObj.hObj, TapiDev.id, 
								&TapiDev.hLine,
								TapiDev.apiver, 0, 0, 
								LINECALLPRIVILEGE_NONE,
								LINEMEDIAMODE_DATAMODEM,
								0);
	if (retval != 0) {
		xtapi_ret = xtapi_err(retval);
		goto dialout_exit;
	}

	retval = lineSetStatusMessages(TapiDev.hLine, 
						LINEDEVSTATE_OTHER |
						LINEDEVSTATE_RINGING | LINEDEVSTATE_CONNECTED | 
						LINEDEVSTATE_DISCONNECTED | LINEDEVSTATE_OUTOFSERVICE |
						LINEDEVSTATE_MAINTENANCE |	LINEDEVSTATE_REINIT,
						LINEADDRESSSTATE_INUSEZERO |
						LINEADDRESSSTATE_INUSEONE |
						LINEADDRESSSTATE_INUSEMANY);

	if (retval != 0) {
		xtapi_ret = xtapi_err(retval);
		goto dialout_exit;
	}

//	Setup calling parameters
	lcallparams = (LINECALLPARAMS *)malloc(sizeof(LINECALLPARAMS)+strlen(phonenum)+1);
	if (!lcallparams) {
		xtapi_ret = XTAPI_OUT_OF_MEMORY;
		goto dialout_exit;
	}
	memset(lcallparams, 0, sizeof(LINECALLPARAMS)+strlen(phonenum)+1);							
	lcallparams->dwTotalSize = sizeof(LINECALLPARAMS)+strlen(phonenum)+1;
	lcallparams->dwBearerMode = LINEBEARERMODE_VOICE;
	lcallparams->dwMediaMode = LINEMEDIAMODE_DATAMODEM;
	lcallparams->dwCallParamFlags = LINECALLPARAMFLAGS_IDLE;
	lcallparams->dwAddressMode = LINEADDRESSMODE_ADDRESSID;
	lcallparams->dwAddressID = 0;
	lcallparams->dwDisplayableAddressOffset = sizeof(LINECALLPARAMS);
	lcallparams->dwDisplayableAddressSize = strlen(phonenum)+1;
	strcpy((LPSTR)lcallparams + sizeof(LINECALLPARAMS), phonenum);
	
//	Dial it!
	mprintf((0, "XTAPI: dialing %s.\n", phonenum));
	retval = xtapi_device_wait_for_reply(
		lineMakeCall(TapiDev.hLine, &TapiDev.hCall, NULL, 0, lcallparams)
	);
	if (retval < 0) {
		xtapi_ret = xtapi_err(retval);
		goto dialout_exit;
	}

	retval = xtapi_device_wait_for_reply(
		lineDial(TapiDev.hCall, phonenum, 0)
	);
	if (retval < 0) {
		xtapi_ret = xtapi_err(retval);
		goto dialout_exit;
	}
	
dialout_exit:
	if (lcallparams) free(lcallparams);
	if (ldevcaps) free(ldevcaps);
	
	return xtapi_ret;
}