Пример #1
0
Файл: xtapi.c Проект: btb/d2x
int xtapi_device_dialin()
{
	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 dialin_exit;
	}

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

dialin_exit:
	return xtapi_ret;
}
Пример #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;
}
Пример #3
0
JNIEXPORT jint JNICALL Java_net_xtapi_serviceProvider_MSTAPI_openLine
  (JNIEnv *pEnv, jobject oObj, jint lLine, jobject oTerminalName)
{
	long	lRc;
	DWORD	lNegVer;
	char	szDebug[256];

	long	lUnused = 0;
	long	sizeBuffer;
	HLINE	hLine;

	LINEEXTENSIONID lpExtensionID;
	LPLINEDEVCAPS	lpLineDevCaps = NULL;

    lRc = lineNegotiateAPIVersion(g_hTAPI, lLine, TAPIVERSION,
        TAPIVERSION, &lNegVer, &lpExtensionID);

	if(TAPIVERSION == lNegVer)
	{
		wsprintf(szDebug,"Negotiated TAPI 1.4 on line %d.",lLine);
		debugString(8,"openLine",szDebug,_where());
	}
	else
	{
		wsprintf(szDebug,"Failed to Negotiate TAPI 1.4 on line %d.",lLine);
		debugString(4,"openLine",szDebug,_where());
		return -1;
	}


	lRc = lineOpen(g_hTAPI, lLine, &hLine, lNegVer, lUnused, lLine, 
		LINECALLPRIVILEGE_OWNER, LINEMEDIAMODE_AUTOMATEDVOICE, 0);

	wsprintf(szDebug,"lineOpen on line %d returned with %d",lLine, lRc);

	if(lRc < 0)
	{
		debugString(4,"openLine",szDebug,_where());
		return lRc;
	}
	else
		debugString(8,"openLine",szDebug,_where());
	

	sizeBuffer = sizeof(lpLineDevCaps) + 1024;

	lpLineDevCaps = (LINEDEVCAPS *) malloc(sizeBuffer);

	memset(lpLineDevCaps, 0, sizeBuffer);

	lpLineDevCaps->dwTotalSize = sizeBuffer;


	lRc = lineGetDevCaps(g_hTAPI, lLine, lNegVer, 0, lpLineDevCaps);

	wsprintf(szDebug,"lineGetDevCaps returned -> %d",lRc);
	debugString(8,"openLine",szDebug,_where());

	if(0 == lRc)
	{
		if(lpLineDevCaps->dwLineNameSize > 0)
		{
			// lpLineDevCaps holds the name of the terminal, push that name up
			// to Java.

			long lpName = (long)lpLineDevCaps  + lpLineDevCaps->dwLineNameOffset;

			jstring oName = pEnv->NewStringUTF((const char *)lpName);

			jclass cls;
			jmethodID mid;

			cls = pEnv->GetObjectClass (oTerminalName);

			mid = pEnv->GetMethodID(cls,"append",
				"(Ljava/lang/String;)Ljava/lang/StringBuffer;");

			pEnv->CallObjectMethod (oTerminalName, mid, oName);

		}

		lRc = lineSetStatusMessages(hLine,lpLineDevCaps->dwLineStates,0);

		if(lRc != 0)
		{
			debugString(4,"openLine","lineSetStatusMessages failed",_where());
			hLine = (HLINE)-1;
		}
	}

	free(lpLineDevCaps);

	return (long)hLine;
}