/** * See pcsl_datagram.h for definition. */ int pcsl_datagram_read_start( void *handle, unsigned char *pAddress, int *port, char *buffer, int length, int *pBytesRead, void **pContext) { int res; res = (int)javacall_datagram_recvfrom_start((javacall_handle) handle,pAddress, port,buffer,length,pBytesRead,pContext); return javacall_to_pcsl_result(res); }
/** * Checks if the handle is of wma_emulator sockets. * returns JAVACALL_FAIL for mismatch * returns JAVACALL_OK for proper sockets and processes the emulation */ javacall_result try_process_wma_emulator(javacall_handle handle) { javacall_result result; unsigned char pAddress[256]; int port; char buffer[2048]; int length = 2048; int pBytesRead; void *pContext = NULL; int ok; if ( handle != smsDatagramSocketHandle) { // Not WMA message (Regular Datagram) return JAVACALL_FAIL; } ok = javacall_datagram_recvfrom_start( handle, pAddress, &port, buffer, length, &pBytesRead, &pContext); if (strstr(buffer, "sms://")!= NULL){ ///vrifies buffer starts with "sms" javautil_debug_print (JAVACALL_LOG_INFORMATION, "jsr120_UDPEmulator", "This is an SMS message"); result = process_UDPEmulator_sms_incoming(pAddress, &port, buffer, length, &pBytesRead, &pContext); if (result == JAVACALL_OK){ return JAVACALL_OK; } }else if(strstr(buffer, "cbs://")!= NULL){ ///vrifies buffer starts with "cbs" javautil_debug_print (JAVACALL_LOG_INFORMATION, "jsr120_UDPEmulator", "This is an CBS message"); result = process_UDPEmulator_cbs_incoming(pAddress, &port, buffer, length, &pBytesRead, &pContext); if (result == JAVACALL_OK){ return JAVACALL_OK; } } #if (ENABLE_JSR_205) if (strstr(buffer, "mms://")) { process_UDPEmulator_mms_incoming(handle,pAddress, &port, buffer, length, &pBytesRead, &pContext); return JAVACALL_OK; } #endif return JAVACALL_FAIL; }
javacall_result process_UDPEmulator_mms_incoming(javacall_handle handle) { unsigned char pAddress[256]; int port; char buffer[PACKET_MAX_SIZE]; int length = PACKET_MAX_SIZE; int pBytesRead; void *pContext = NULL; int ok; char* fromAddress = "fromAddress"; char* appID = "appID"; char* replyToAppID = "replyToAppID"; int bodyLen; unsigned char* body; int rc; ok = javacall_datagram_recvfrom_start( handle, pAddress, &port, buffer, length, &pBytesRead, &pContext); if (ok != JAVACALL_OK) { javacall_print("MMS: Failed to receive a datagram!\n"); return JAVACALL_FAIL; } rc = recvMMS_readPacket(buffer, pBytesRead); if (!rc) { javacall_print("MMS UDP emulation package received\n"); return JAVACALL_OK; } decodeMmsBuffer(&fromAddress, &appID, &replyToAppID, &bodyLen, &body); //printf("received: %s %s %s %i\n", fromAddress, appID, replyToAppID, bodyLen); if (javacall_is_mms_appID_registered(appID) != JAVACALL_OK) { javacall_print("MMS on unregistered appID received!\n"); return JAVACALL_FAIL; } javanotify_incoming_mms_singlecall(fromAddress, appID, replyToAppID, bodyLen, body); return JAVACALL_OK; }