Пример #1
0
Файл: xtapi.c Проект: btb/d2x
LINECALLINFO *tapi_line_getcallinfo(HCALL hCall)
{
	LINECALLINFO *ad=NULL;
	LONG retval;
	int size;

	size = sizeof(LINECALLINFO) + 256;

	while (1)
	{
		ad = (LINECALLINFO *)realloc(ad, size);
		if (!ad) return NULL;
		 
		memset(ad, 0, size);
		ad->dwTotalSize = size;

		retval = lineGetCallInfo(hCall,ad); 

		if (retval!=0) {
			free(ad);
			return NULL;
		}
		
		if (ad->dwNeededSize > ad->dwTotalSize) {
			size = ad->dwNeededSize;
			continue;
		}
		else break;
	}

	return ad;
}
Пример #2
0
JNIEXPORT jobjectArray JNICALL Java_net_xtapi_serviceProvider_MSTAPI_getCallInfo
  (JNIEnv *pEnv, jobject oObj, jint lHandle)
{
	LPLINECALLINFO	lpCallInfo	= NULL;
	jobjectArray	oCallID		= NULL;		// String array of Name and Address

	try{

		long sizeBuffer = sizeof(lpCallInfo) + 1024;

		lpCallInfo = (LINECALLINFO *) malloc(sizeBuffer);

		lpCallInfo->dwTotalSize = sizeBuffer;

		long lRc = lineGetCallInfo((HCALL)lHandle,lpCallInfo);

		if(0 == lRc)
		{
			if(lpCallInfo->dwOrigin == LINECALLORIGIN_OUTBOUND)
			{
				// We placed this call, we don't need the info!
				debugString(8,"getCallInfo",
					"LINECALLORIGIN_OUTBOUND",_where());
				free(lpCallInfo);
				return NULL;
			}

			char szName[256];
			char szAddress[256];

			strcpy(szAddress,"UNKNOWN");
			strcpy(szName,"UNKNOWN");

			// See if we have the phone number
			if ((lpCallInfo->dwCallerIDFlags & LINECALLPARTYID_ADDRESS) != 0)
			{
				if(lpCallInfo->dwCallerIDSize < 256)
				{
					strcpy(szAddress,
						(char*)lpCallInfo + lpCallInfo->dwCallerIDOffset);
				}
			}

			// See if we have the name
			if ((lpCallInfo->dwCallerIDFlags & LINECALLPARTYID_NAME) != 0)
			{
				if(lpCallInfo->dwCallerIDNameSize < 256)
				{
					strcpy(szName,
						(char*)lpCallInfo + lpCallInfo->dwCallerIDNameOffset);
				}
			}

			if ((lpCallInfo->dwCallerIDFlags & LINECALLPARTYID_BLOCKED) != 0)
			{
				strcpy(szName,"BLOCKED");
				strcpy(szAddress,"BLOCKED");
			}

			if ((lpCallInfo->dwCallerIDFlags & LINECALLPARTYID_OUTOFAREA) != 0)
			{
				strcpy(szName,"OUTOFAREA");
				strcpy(szAddress,"OUTOFAREA");
			}

			jclass		oCls;				// String Class
			jobject		oElement;			// Array element

			oCls = pEnv->FindClass("java/lang/String");

			// Create a two element string array to hold the Name and Address
			oCallID = pEnv->NewObjectArray(2,oCls,NULL);

			oElement = pEnv->NewStringUTF(szName);
			pEnv->SetObjectArrayElement(oCallID, 0, oElement);

			oElement = pEnv->NewStringUTF(szAddress);
			pEnv->SetObjectArrayElement(oCallID, 1, oElement);

  
		}
		else
		{
			char szMsg[256];
			wsprintf(szMsg,"lineGetCallInfo returned %d",lRc);
			debugString(1,"getCallInfo",szMsg,_where());
		}

	}catch(...){
		debugString(1,"getCallInfo","Exception Handler",_where());
		oCallID = NULL;
	}

	free(lpCallInfo);

	return oCallID;
}