bool OsFile_rename(const JvmPathChar *from, const JvmPathChar *to) { const int from_name_len = fn_strlen(from); const int to_name_len = fn_strlen(to); pcsl_string pcsl_filename_from = PCSL_STRING_NULL; pcsl_string pcsl_filename_to = PCSL_STRING_NULL; GUARANTEE(sizeof(jchar) == sizeof(JvmPathChar), "Types must match"); if (pcsl_string_convert_from_utf16(from, from_name_len, &pcsl_filename_from) != PCSL_STRING_OK) { return -1; } if (pcsl_string_convert_from_utf16(to, to_name_len, &pcsl_filename_to) != PCSL_STRING_OK) { return -1; } int result = pcsl_file_rename(&pcsl_filename_from, &pcsl_filename_to); pcsl_string_free(&pcsl_filename_from); pcsl_string_free(&pcsl_filename_to); return (result == 0) ? true : false; }
extern "C" MidpError QString2pcsl_string(QString &qstring, pcsl_string &pstring) { pcsl_string_status pe; if (qstring.isNull()) { pstring = PCSL_STRING_NULL; } else if (qstring.isEmpty()) { pstring = PCSL_STRING_EMPTY; } else { jint mstring_len = qstring.length(); jchar* mstring_data = (jchar *)midpMalloc(sizeof(jchar) * mstring_len); if (mstring_data == NULL) { pstring = PCSL_STRING_NULL; return KNI_ENOMEM; } else { for (int i = 0; i < mstring_len; i++) { mstring_data[i] = qstring[i].unicode(); } pe = pcsl_string_convert_from_utf16(mstring_data, mstring_len, &pstring); midpFree(mstring_data); if (PCSL_STRING_OK != pe) { return KNI_ENOMEM; } } } return KNI_OK; }
/** * Reads string from the file. * * @param string pointer to result string * @return number of bytes read */ static int read_string(pcsl_string* string) { jint string_len; jchar *string_data; storageRead(&io_error_message, table_file, (char*)&string_len, sizeof(int)); string_data = (jchar*)JSR211_MALLOC(string_len); storageRead(&io_error_message, table_file, (char*)string_data, string_len); pcsl_string_convert_from_utf16(string_data, string_len/sizeof(jchar), string); JSR211_FREE(string_data); return string_len + sizeof(int); }
/** * Perform the reverse conversion of unicodeToEscapedAscii(). * * @param str a string previously returned by escape() * @return the original string before the conversion by escape(). */ static pcsl_string_status escaped_ascii_to_unicode(const pcsl_string* str, pcsl_string* result) { int result_len=0; jchar* result_data = NULL; pcsl_string_status status = PCSL_STRING_OK; GET_PCSL_STRING_DATA_AND_LENGTH(str) do { int i; result_data = (jchar*)midpMalloc(str_len * sizeof (jchar)); if (result_data == NULL) { status = PCSL_STRING_ENOMEM; break; } for (i = 0, result_len = 0; i < str_len; i++) { jchar c = str_data[i]; if (c == '%') { jchar v = 0; v += hexValue(str_data[i+1]); v <<= 4; v += hexValue(str_data[i+2]); v <<= 4; v += hexValue(str_data[i+3]); v <<= 4; v += hexValue(str_data[i+4]); i += 4; result_data[result_len] = v; result_len++; } else if (c == '#') { /* drop c */ } else { result_data[result_len] = c; result_len++; } } } while(0); RELEASE_PCSL_STRING_DATA_AND_LENGTH if (PCSL_STRING_OK == status) { if (PCSL_STRING_OK != pcsl_string_convert_from_utf16(result_data, result_len, result)) { status = PCSL_STRING_ENOMEM; } } midpFree(result_data); return status; }
/** * Reads a line from a jad file. * * @param jadbuf pointer to the jad jchar_buffer; this pointer will move to * the next line * @param result pointer to pcsl_string where the new line from jad file * will be stored, the caller is responsible for freeing this * string * @return error code */ static MIDPError readJadLine(jchar** jadbuf, pcsl_string * result) { jchar* lineStart = NULL; jchar* p = NULL; int count = 0; /* will use p to avoid all the *(*jadbuf) stuff and make it more readable */ p = (*jadbuf); if (!(*p)) { /* end of jchar_buffer */ *result = PCSL_STRING_NULL; return END_OF_JAD; } /* skip commented out and blank lines */ while (COMMENTED_OUT(p) || NEW_LINE(p)) { while (!NEW_LINE(p)) { /* skip commented out line */ p++; } while (NEW_LINE(p)) { /* skip new line */ p++; } } lineStart = p; for (;*p ; ) { count++; p++; if (NEW_LINE(p)) { *p = 0x00; /* cut the line */ if (*(p+1)) { /* if not end of jchar_buffer */ p++; /* point to the next line beginning */ break; } /* end of if */ } /* end of if */ } /* end of for */ /* move jadbuf to point to the next line */ (*jadbuf) = p; if (PCSL_STRING_OK != pcsl_string_convert_from_utf16(lineStart, count, result)) { return OUT_OF_MEMORY; } return ALL_OK; } /* end of readJadLine */
// Disabled temporarily - pcsl_file_exist does not distinguish between // directory and "file". bool OsFile_exists(const JvmPathChar *filename) { int name_len = fn_strlen(filename); pcsl_string pcsl_filename = PCSL_STRING_NULL; GUARANTEE(sizeof(jchar) == sizeof(JvmPathChar), "Types must match"); if (pcsl_string_convert_from_utf16(filename, name_len, &pcsl_filename) != PCSL_STRING_OK) { return false; } jboolean result = pcsl_file_exist(&pcsl_filename); pcsl_string_free(&pcsl_filename); return result; }
/** * Read pcsl_string from storage. * First read a jint with length, then read the text * of that length in the utf-16 encoding. * * @param ppszError in the case of error, receives address of a string * describing the problem; receives NULL in the case of success * @param handle handle of the file to read from * @param str string to receive the text */ void storage_read_utf16_string(char** ppszError, int handle, pcsl_string* str) { jint bytesRead = 0; jchar *tempStr = NULL; jint tempLen = 0; pcsl_string_status prc; storageRead(ppszError, handle, (char*)&tempLen, sizeof (jint)); if (*ppszError != NULL) { return; } /* special cases: null and empty strings */ if (tempLen < 0) { if(0 == tempLen) { *str = PCSL_STRING_NULL; } else if (-1 == tempLen) { *str = PCSL_STRING_EMPTY; } else { *str = PCSL_STRING_NULL; *ppszError = (char *)STRING_CORRUPT_ERROR; } return; } tempStr = (jchar*)midpMalloc(tempLen * sizeof (jchar)); if (tempStr == NULL) { *ppszError = (char *)OUT_OF_MEM_ERROR; return; } bytesRead = storageRead(ppszError, handle, (char*)tempStr, tempLen * sizeof (jchar)); if (*ppszError != NULL) { /* do nothing: error code already there */ } else if (bytesRead != (signed)(tempLen * sizeof (jchar))) { *ppszError = (char *)STRING_CORRUPT_ERROR; } else if (PCSL_STRING_OK != (prc = pcsl_string_convert_from_utf16(tempStr, tempLen, str))) { *ppszError = PCSL_STRING_ENOMEM == prc ? (char *)OUT_OF_MEM_ERROR : (char *)STRING_CORRUPT_ERROR; } midpFree(tempStr); return; }
int OsFile_remove(const JvmPathChar * filename) { int name_len = fn_strlen(filename); pcsl_string pcsl_filename = PCSL_STRING_NULL; GUARANTEE(sizeof(jchar) == sizeof(JvmPathChar), "Types must match"); if (pcsl_string_convert_from_utf16(filename, name_len, &pcsl_filename) != PCSL_STRING_OK) { return -1; } int result = pcsl_file_unlink(&pcsl_filename); pcsl_string_free(&pcsl_filename); return result; }
OsFile_Handle OsFile_open(const JvmPathChar *filename, const char *mode) { int name_len = fn_strlen(filename); pcsl_string pcsl_filename = PCSL_STRING_NULL; GUARANTEE(sizeof(jchar) == sizeof(JvmPathChar), "Types must match"); if (pcsl_string_convert_from_utf16(filename, name_len, &pcsl_filename) != PCSL_STRING_OK) { return NULL; } /* int pcsl_flags = (*mode == 'w') ? (PCSL_FILE_O_CREAT|PCSL_FILE_O_WRONLY| PCSL_FILE_O_TRUNC) : (PCSL_FILE_O_RDONLY); */ int pcsl_flags; if(*mode == 'w') { pcsl_flags = (PCSL_FILE_O_CREAT | PCSL_FILE_O_WRONLY | PCSL_FILE_O_TRUNC); } else if(*mode == 'a') { pcsl_flags = (PCSL_FILE_O_WRONLY | PCSL_FILE_O_APPEND); } else { pcsl_flags = PCSL_FILE_O_RDONLY; } void *pcsl_handle; if (pcsl_file_open(&pcsl_filename, pcsl_flags, &pcsl_handle) == 0) { pcsl_string_free(&pcsl_filename); OsFile_Handle handle = (OsFile_Handle)pcsl_mem_malloc(sizeof(struct _OsFile_Handle)); if (handle) { handle->pcsl_handle = pcsl_handle; } else { pcsl_file_close(pcsl_handle); } return handle; } else { pcsl_string_free(&pcsl_filename); return NULL; } }
static int findNextMatch(PCSLFileIterator* pIterator, const pcsl_string * match, pcsl_string * result) { WIN32_FIND_DATAW findData; pcsl_string root = PCSL_STRING_NULL; pcsl_string foundName = PCSL_STRING_NULL; jsize rootLen = 0; if (result == NULL) { return -1; } * result = PCSL_STRING_NULL; if (!FindNextFileW(pIterator->iteratorHandle, &findData)) { return -1; } rootLen = pIterator->savedRootLength; if (pcsl_string_substring(match, 0, rootLen, &root) != PCSL_STRING_OK) { return -1; } if (pcsl_string_convert_from_utf16(findData.cFileName, wcslen(findData.cFileName), &foundName) != PCSL_STRING_OK) { pcsl_string_free(&root); return -1; } if (pcsl_string_cat(&root, &foundName, result) != PCSL_STRING_OK) { pcsl_string_free(&foundName); pcsl_string_free(&root); return -1; } pcsl_string_free(&foundName); pcsl_string_free(&root); return 0; }
/** * Create pcsl_string from the specified Java String object. * The caller is responsible for freeing the created pcsl_string when done. * * @param java_str pointer to the Java String instance * @param pcsl_str pointer to the pcsl_string instance * @return status of the operation */ pcsl_string_status midp_jstring_to_pcsl_string(jstring java_str, pcsl_string * pcsl_str) { if (pcsl_str == NULL) { return PCSL_STRING_EINVAL; } if (KNI_IsNullHandle(java_str)) { * pcsl_str = PCSL_STRING_NULL; return PCSL_STRING_OK; } else { const jsize length = KNI_GetStringLength(java_str); if (length < 0) { * pcsl_str = PCSL_STRING_NULL; return PCSL_STRING_ERR; } else if (length == 0) { * pcsl_str = PCSL_STRING_EMPTY; return PCSL_STRING_OK; } else { jchar * buffer = pcsl_mem_malloc(length * sizeof(jchar)); if (buffer == NULL) { * pcsl_str = PCSL_STRING_NULL; return PCSL_STRING_ENOMEM; } KNI_GetStringRegion(java_str, 0, length, buffer); { pcsl_string_status status = pcsl_string_convert_from_utf16(buffer, length, pcsl_str); pcsl_mem_free(buffer); return status; } } } }
/** * Create pcsl_string from the specified KNI CharArray object. * The caller is responsible for freeing the created pcsl_string when done. * * @param java_arr pointer to the KNI CharArray instance * @param length length of the text in the CharArray * @param pcsl_str pointer to the pcsl_string instance * @return status of the operation */ pcsl_string_status midp_jchar_array_to_pcsl_string(jcharArray java_arr, jint length, pcsl_string * pcsl_str) { if (pcsl_str == NULL) { return PCSL_STRING_EINVAL; } if (KNI_IsNullHandle(java_arr)) { *pcsl_str = PCSL_STRING_NULL; return PCSL_STRING_OK; } else if (length < 0) { *pcsl_str = PCSL_STRING_NULL; return PCSL_STRING_ERR; } else if (length == 0) { *pcsl_str = PCSL_STRING_EMPTY; return PCSL_STRING_OK; } else { jchar * buffer = pcsl_mem_malloc(length * sizeof(jchar)); if (buffer == NULL) { * pcsl_str = PCSL_STRING_NULL; return PCSL_STRING_ENOMEM; } KNI_GetRawArrayRegion(java_arr, 0, length * sizeof(jchar), (jbyte *) buffer); { pcsl_string_status status = pcsl_string_convert_from_utf16(buffer, length, pcsl_str); pcsl_mem_free(buffer); return status; } } }
/** * The function is called upon MIDlet suite removal. * It deletes suites's private directory and all it's content. * * @param suiteId the ID of MIDlet suite */ void jsr75_suite_remove_cleanup(SuiteIdType suiteId) { const pcsl_string* pStg = storage_get_root(INTERNAL_STORAGE_ID); const jchar jsep = pcsl_file_getfileseparator(); pcsl_string dirName1 = PCSL_STRING_NULL; pcsl_string dirName2 = PCSL_STRING_NULL; pcsl_string dirName = PCSL_STRING_NULL; pcsl_string sep = PCSL_STRING_NULL; if (pcsl_string_convert_from_utf16(&jsep, 1, &sep) != PCSL_STRING_OK) { return; } if (pcsl_string_cat(pStg, &privateDir, &dirName1) != PCSL_STRING_OK) { pcsl_string_free(&sep); return; } if (pcsl_string_cat(&dirName1, &sep, &dirName2) != PCSL_STRING_OK) { pcsl_string_free(&sep); pcsl_string_free(&dirName1); return; } if (pcsl_string_cat(&dirName2, midp_suiteid2pcsl_string(suiteId), &dirName) != PCSL_STRING_OK) { pcsl_string_free(&sep); pcsl_string_free(&dirName1); pcsl_string_free(&dirName2); return; } pcsl_string_free(&dirName1); pcsl_string_free(&dirName2); do_cleanup(&dirName, &sep); pcsl_string_free(&sep); pcsl_string_free(&dirName); }
/** * Reads the file with information about the installed suites. * * Note that if the value of the global variable g_numberOfSuites * is zero, this function does nothing. * * @param ppszError pointer to character string pointer to accept an error * * @return status code: ALL_OK if no errors, * OUT_OF_MEMORY if malloc failed * IO_ERROR if an IO_ERROR, * SUITE_CORRUPTED_ERROR if the suite database is corrupted */ MIDPError read_suites_data(char** ppszError) { MIDPError status; int i; long bufferLen, pos; char* buffer = NULL; pcsl_string_status rc; pcsl_string suitesDataFile; MidletSuiteData *pSuitesData = g_pSuitesData; MidletSuiteData *pData, *pPrevData = NULL; int numOfSuites = 0; *ppszError = NULL; if (g_isSuitesDataLoaded) { return ALL_OK; } if (midpInit(LIST_LEVEL) != 0) { return OUT_OF_MEMORY; } /* get a full path to the _suites.dat */ rc = pcsl_string_cat(storage_get_root(INTERNAL_STORAGE_ID), &SUITE_DATA_FILENAME, &suitesDataFile); if (rc != PCSL_STRING_OK) { return OUT_OF_MEMORY; } /* read the file */ status = read_file(ppszError, &suitesDataFile, &buffer, &bufferLen); pcsl_string_free(&suitesDataFile); if (status == NOT_FOUND || (status == ALL_OK && bufferLen == 0)) { /* _suites.dat is absent or empty, it's a normal situation */ g_pSuitesData = NULL; g_numberOfSuites = 0; g_isSuitesDataLoaded = 1; return ALL_OK; } if (status == ALL_OK && bufferLen < (long) sizeof(int)) { pcsl_mem_free(buffer); status = SUITE_CORRUPTED_ERROR; /* _suites.dat is corrupted */ } if (status != ALL_OK) { return status; } /* parse contents of the suite database */ pos = 0; numOfSuites = *(int*)&buffer[pos]; ADJUST_POS_IN_BUF(pos, bufferLen, sizeof(int)); for (i = 0; i < numOfSuites; i++) { pData = (MidletSuiteData*) pcsl_mem_malloc(sizeof(MidletSuiteData)); if (!pData) { status = OUT_OF_MEMORY; break; } if (pPrevData) { pPrevData->nextEntry = pData; } else { pSuitesData = pData; } /* IMPL_NOTE: introduce pcsl_mem_copy() */ if (bufferLen < (long)MIDLET_SUITE_DATA_SIZE) { status = IO_ERROR; break; } memcpy((char*)pData, (char*)&buffer[pos], MIDLET_SUITE_DATA_SIZE); ADJUST_POS_IN_BUF(pos, bufferLen, MIDLET_SUITE_DATA_SIZE); pData->nextEntry = NULL; /* this suite was not checked if it is corrupted */ pData->isChecked = 0; /* setup pJarHash */ if (pData->jarHashLen > 0) { pData->varSuiteData.pJarHash = (unsigned char*)pcsl_mem_malloc(pData->jarHashLen); if (pData->varSuiteData.pJarHash == NULL) { status = OUT_OF_MEMORY; break; } memcpy(pData->varSuiteData.pJarHash, (char*)&buffer[pos], pData->jarHashLen); ADJUST_POS_IN_BUF(pos, bufferLen, pData->jarHashLen); } else { pData->varSuiteData.pJarHash = NULL; } /* setup string fields */ { int i; jint strLen; pcsl_string* pStrings[] = { &pData->varSuiteData.midletClassName, &pData->varSuiteData.displayName, &pData->varSuiteData.iconName, &pData->varSuiteData.suiteVendor, &pData->varSuiteData.suiteName, &pData->varSuiteData.pathToJar, &pData->varSuiteData.pathToSettings }; status = ALL_OK; for (i = 0; i < (int) (sizeof(pStrings) / sizeof(pStrings[0])); i++) { if (bufferLen < (long)sizeof(jint)) { status = IO_ERROR; /* _suites.dat is corrupted */ break; } /* * We have to guarantee 4 - bytes alignment to use this: * strLen = *(jint*)&buffer[pos]; * on RISC CPUs. */ pos = SUITESTORE_ALIGN_4(pos); strLen = *(jint*)&buffer[pos]; ADJUST_POS_IN_BUF(pos, bufferLen, sizeof(jint)); if (bufferLen < (long)strLen) { status = IO_ERROR; /* _suites.dat is corrupted */ break; } if (strLen > 0) { rc = pcsl_string_convert_from_utf16( (jchar*)&buffer[pos], strLen, pStrings[i]); if (rc != PCSL_STRING_OK) { status = OUT_OF_MEMORY; break; } ADJUST_POS_IN_BUF(pos, bufferLen, strLen * sizeof(jchar)); } else { *pStrings[i] = strLen ? PCSL_STRING_NULL : PCSL_STRING_EMPTY; } } } if (status != ALL_OK) { break; } pData->nextEntry = NULL; pPrevData = pData; } /* end for (numOfSuites) */ pcsl_mem_free(buffer); if (status == ALL_OK) { g_numberOfSuites = numOfSuites; g_pSuitesData = pSuitesData; g_isSuitesDataLoaded = 1; } else { free_suites_data(); } return status; }
/** * Reads a line from a manifest file. Compacts continuation lines.<BR> * (Allocates memory for this line.) * * @param mfbuf pointer to the manifest jchar_buffer; this pointer will move to * the next line * @param result pointer to pcsl_string where the new line from manifest * will be stored * @return error code */ static MIDPError readMfLine(jchar** mfbuf, pcsl_string * result) { jchar* lineStart = NULL; int is_broken_line = 0; jchar* p = NULL; int count = 0; int i = 0; *result = PCSL_STRING_NULL; /* will use p to avoid all the *(*mfbuf) stuff and make it more readable */ p = (*mfbuf); if (!(*p)) { /* end of jchar_buffer */ return END_OF_MF; } /* skip commented out and blank lines */ while (COMMENTED_OUT(p) || NEW_LINE(p)) { while (!NEW_LINE(p)) { p++; /* skip commented out line */ } while (NEW_LINE(p)) { p++; /* skip new line */ } /* now pointing to the next line */ if (MF_SPACE(p)) { /* if starting with space */ while (!NEW_LINE(p)) { p++; /* skip the line */ } } /* end of if */ } /* end of while */ lineStart = p; for (;*p ;) { count++; p++; if (NEW_LINE(p) && !MF_BROKEN_LINE(p)) { *p = 0x00; /* cut the line */ if (*(p+1)) { /* if not end of the buffer */ p++; /* point to the next line beginning */ break; } } else if (MF_BROKEN_LINE(p)) { while (!MF_SPACE(p)) { /* look for the space */ count++; p++; } /* once space found, point to the next character and go ahead */ count++; p++; is_broken_line = 1; continue; } /* end of else */ } /* end of for */ /* move mfbuf to point to the next line */ (*mfbuf) = p; pcsl_string_predict_size(result, count); if (is_broken_line) { i = 0; while (*(lineStart+i)) { /* here once we have a new line it will be followed by space */ if (NEW_LINE_1(lineStart+i)) { i+=3; count-=3; } else if (NEW_LINE(lineStart+i)) { i+=2; count-=2; } if (PCSL_STRING_OK != pcsl_string_append_char(result, lineStart[i])) { pcsl_string_free(result); return OUT_OF_MEMORY; } i++; } } else { if (PCSL_STRING_OK != pcsl_string_convert_from_utf16(lineStart, count, result)) { return OUT_OF_MEMORY; } } return ALL_OK; } /* end of readMfLine */
/** * Get size in bytes of all files and possibly subdirectories contained * in the specified dir. * * @param pathName full directory path * @param pathNameLen length of path name * @param includeSubdirs if 0, do not include subdirectories, * otherwise include subdirectories size too * @param result returned value: size in bytes of all files contained in * the specified directory and possibly its subdirectories * @return 0 on success, -1 otherwise */ int fileconnection_dir_content_size(const jchar* pathName, int pathNameLen, int includeSubdirs, jlong* /* OUT */ result) { char subSearch[MAX_FILE_NAME_LENGTH]; int subSearchLen; struct dirent *dir_data; struct stat stat_buf; int status; jlong contentSize = 0; DIR* listHandle[MAX_DIRECTORY_NESTING_LEVEL]; int pathLen[MAX_DIRECTORY_NESTING_LEVEL]; int nestLevel = 0; int nextExists; pcsl_string name = PCSL_STRING_NULL; if (PCSL_STRING_OK != pcsl_string_convert_from_utf16(pathName, pathNameLen, &name)) { return -1; } if (PCSL_STRING_OK != pcsl_string_convert_to_utf8(&name, (jbyte*)subSearch, MAX_FILE_NAME_LENGTH, &subSearchLen)) { pcsl_string_free(&name); return -1; } pcsl_string_free(&name); listHandle[0] = opendir(subSearch); pathLen[0] = subSearchLen; if (NULL == listHandle[0]) { /* Cannot open directory */ return -1; } dir_data = readdir(listHandle[0]); nextExists = (NULL != dir_data); for ( ; ; ) { while (nextExists) { subSearch[pathLen[nestLevel]] = '/'; subSearch[pathLen[nestLevel] + 1] = 0; strcat(subSearch, dir_data->d_name); status = stat(subSearch, &stat_buf); if (status < 0) { /* Failed to get file status */ while (nestLevel >= 0) { closedir(listHandle[nestLevel--]); } return -1; } if (S_ISDIR(stat_buf.st_mode)) { /* Found subdirectory */ if (includeSubdirs) { /* Must count subdirectory sizes */ if (strcmp(dir_data->d_name, ".") && strcmp(dir_data->d_name, "..")) { /* The subdirectory is not "." or ".." */ int dirNameLen = strlen(dir_data->d_name); if (nestLevel >= MAX_DIRECTORY_NESTING_LEVEL - 1) { /* Nesting level overflow */ while (nestLevel >= 0) { closedir(listHandle[nestLevel--]); } return -1; } pathLen[nestLevel + 1] = pathLen[nestLevel] + dirNameLen + 1; listHandle[++nestLevel] = opendir(subSearch); if (NULL == listHandle[nestLevel]) { /* Cannot open subdirectory */ while (--nestLevel >= 0) { closedir(listHandle[nestLevel]); } return -1; } } } } else { contentSize += stat_buf.st_size; } dir_data = readdir(listHandle[nestLevel]); nextExists = (NULL != dir_data); } closedir(listHandle[nestLevel]); if (nestLevel == 0) { break; } dir_data = readdir(listHandle[--nestLevel]); nextExists = (NULL != dir_data); } *result = contentSize; return 0; }
static int findFirstMatch(PCSLFileIterator* pIterator, const pcsl_string * match, pcsl_string * result) { WIN32_FIND_DATAW findData; HANDLE handle; PCSL_DEFINE_ASCII_STRING_LITERAL_START(starSuffix) {'*', '\0'} PCSL_DEFINE_ASCII_STRING_LITERAL_END(starSuffix); pcsl_string root = PCSL_STRING_NULL; pcsl_string foundName = PCSL_STRING_NULL; pcsl_string matchStar = PCSL_STRING_NULL; jsize rootLen = 0; if (result == NULL) { return -1; } * result = PCSL_STRING_NULL; if (pcsl_string_cat(match, &starSuffix, &matchStar) != PCSL_STRING_OK) { return -1; } { const jchar * pwszMatch = pcsl_string_get_utf16_data(&matchStar); if (NULL == pwszMatch) { pcsl_string_free(&matchStar); return -1; } handle = FindFirstFileW(pwszMatch, &findData); pcsl_string_free(&matchStar); } if (INVALID_HANDLE_VALUE == handle) { return -1; } pIterator->iteratorHandle = handle; rootLen = pIterator->savedRootLength; if (pcsl_string_substring(match, 0, rootLen, &root) != PCSL_STRING_OK) { return -1; } if (pcsl_string_convert_from_utf16(findData.cFileName, wcslen(findData.cFileName), &foundName) != PCSL_STRING_OK) { pcsl_string_free(&root); return -1; } if (pcsl_string_cat(&root, &foundName, result) != PCSL_STRING_OK) { pcsl_string_free(&foundName); pcsl_string_free(&root); return -1; } pcsl_string_free(&foundName); pcsl_string_free(&root); return 0; }
/* * This function is called by the VM periodically. It has to check if * system has sent a signal to MIDP and return the result in the * structs given. * * Values for the <timeout> paramater: * >0 = Block until a signal sent to MIDP, or until <timeout> milliseconds * has elapsed. * 0 = Check the system for a signal but do not block. Return to the * caller immediately regardless of the if a signal was sent. * -1 = Do not timeout. Block until a signal is sent to MIDP. */ void checkForSystemSignal(MidpReentryData* pNewSignal, MidpEvent* pNewMidpEvent, jlong timeout) { midp_jc_event_union *event; static unsigned char binaryBuffer[BINARY_BUFFER_MAX_LEN]; javacall_bool res; int outEventLen; #if !ENABLE_CDC res = javacall_event_receive((long)timeout, binaryBuffer, BINARY_BUFFER_MAX_LEN, &outEventLen); #else res = javacall_event_receive_cvm(MIDP_EVENT_QUEUE_ID, binaryBuffer, BINARY_BUFFER_MAX_LEN, &outEventLen); #endif if (!JAVACALL_SUCCEEDED(res)) { return; } event = (midp_jc_event_union *) binaryBuffer; switch (event->eventType) { case MIDP_JC_EVENT_KEY: pNewSignal->waitingFor = UI_SIGNAL; pNewMidpEvent->type = MIDP_KEY_EVENT; pNewMidpEvent->CHR = event->data.keyEvent.key; pNewMidpEvent->ACTION = event->data.keyEvent.keyEventType; break; case MIDP_JC_EVENT_PEN: pNewSignal->waitingFor = UI_SIGNAL; pNewMidpEvent->type = MIDP_PEN_EVENT; pNewMidpEvent->ACTION = event->data.penEvent.type; pNewMidpEvent->X_POS = event->data.penEvent.x; pNewMidpEvent->Y_POS = event->data.penEvent.y; break; case MIDP_JC_EVENT_SOCKET: pNewSignal->waitingFor = event->data.socketEvent.waitingFor; pNewSignal->descriptor = (int)event->data.socketEvent.handle; pNewSignal->status = event->data.socketEvent.status; pNewSignal->pResult = (void *) event->data.socketEvent.extraData; break; case MIDP_JC_EVENT_END: pNewSignal->waitingFor = AMS_SIGNAL; pNewMidpEvent->type = SHUTDOWN_EVENT; break; #if !ENABLE_CDC case MIDP_JC_EVENT_PAUSE: /* * IMPL_NOTE: if VM is running, the following call will send * PAUSE_ALL_EVENT message to AMS; otherwise, the resources * will be suspended in the context of the caller. */ midp_suspend(); break; #endif case MIDP_JC_EVENT_PUSH: pNewSignal->waitingFor = PUSH_ALARM_SIGNAL; pNewSignal->descriptor = event->data.pushEvent.alarmHandle; break; case MIDP_JC_EVENT_ROTATION: pNewSignal->waitingFor = UI_SIGNAL; pNewMidpEvent->type = ROTATION_EVENT; break; case MIDP_JC_EVENT_CHANGE_LOCALE: pNewSignal->waitingFor = UI_SIGNAL; pNewMidpEvent->type = CHANGE_LOCALE_EVENT; break; case MIDP_JC_EVENT_VIRTUAL_KEYBOARD: pNewSignal->waitingFor = UI_SIGNAL; pNewMidpEvent->type = VIRTUAL_KEYBOARD_EVENT; break; case MIDP_JC_EVENT_DISPLAY_DEVICE_STATE_CHANGED: pNewSignal->waitingFor = DISPLAY_DEVICE_SIGNAL; pNewMidpEvent->type = DISPLAY_DEVICE_STATE_CHANGED_EVENT; pNewMidpEvent->intParam1 = event->data.displayDeviceEvent.hardwareId; pNewMidpEvent->intParam2 = event->data.displayDeviceEvent.state; break; case MIDP_JC_EVENT_CLAMSHELL_STATE_CHANGED: pNewSignal->waitingFor = UI_SIGNAL; pNewMidpEvent->type = DISPLAY_CLAMSHELL_STATE_CHANGED_EVENT; pNewMidpEvent->intParam1 = event->data.clamshellEvent.state; break; #if ENABLE_ON_DEVICE_DEBUG case MIDP_JC_ENABLE_ODD_EVENT: pNewSignal->waitingFor = AMS_SIGNAL; pNewMidpEvent->type = MIDP_ENABLE_ODD_EVENT; break; #endif #ifdef ENABLE_JSR_75 case JSR75_FC_JC_EVENT_ROOTCHANGED: notifyDisksChanged(); break; #endif #if ENABLE_JSR_120 case MIDP_JC_EVENT_SMS_INCOMING: pNewSignal->waitingFor = WMA_SMS_READ_SIGNAL; pNewSignal->descriptor = event->data.smsIncomingEvent.stub; break; case MIDP_JC_EVENT_CBS_INCOMING: pNewSignal->waitingFor = WMA_CBS_READ_SIGNAL; pNewSignal->descriptor = event->data.cbsIncomingEvent.stub; break; case MIDP_JC_EVENT_SMS_SENDING_RESULT: pNewSignal->waitingFor = WMA_SMS_WRITE_SIGNAL; pNewSignal->descriptor = (int)event->data.smsSendingResultEvent.handle; pNewSignal->status = event->data.smsSendingResultEvent.result; break; #endif #if ENABLE_JSR_205 case MIDP_JC_EVENT_MMS_INCOMING: pNewSignal->waitingFor = WMA_MMS_READ_SIGNAL; pNewSignal->descriptor = event->data.mmsIncomingEvent.stub; break; case MIDP_JC_EVENT_MMS_SENDING_RESULT: pNewSignal->waitingFor = WMA_MMS_WRITE_SIGNAL; pNewSignal->descriptor = (int)event->data.mmsSendingResultEvent.handle; pNewSignal->status = event->data.mmsSendingResultEvent.result; break; #endif case MIDP_JC_EVENT_MULTIMEDIA: #if ENABLE_JSR_135 pNewSignal->waitingFor = MEDIA_EVENT_SIGNAL; pNewSignal->status = JAVACALL_OK; pNewMidpEvent->type = MMAPI_EVENT; pNewMidpEvent->MM_PLAYER_ID = event->data.multimediaEvent.playerId; pNewMidpEvent->MM_DATA = event->data.multimediaEvent.data.num32; pNewMidpEvent->MM_ISOLATE = event->data.multimediaEvent.appId; pNewMidpEvent->MM_EVT_TYPE = event->data.multimediaEvent.mediaType; pNewMidpEvent->MM_EVT_STATUS= event->data.multimediaEvent.status; /* SYSTEM_VOLUME_CHANGED event must be sent to all players. */ /* MM_ISOLATE = -1 causes bradcast by StoreMIDPEventInVmThread() */ if( JAVACALL_EVENT_MEDIA_SYSTEM_VOLUME_CHANGED == event->data.multimediaEvent.mediaType ) pNewMidpEvent->MM_ISOLATE = -1; REPORT_CALL_TRACE4(LC_NONE, "[media event] External event recevied %d %d %d %d\n", pNewMidpEvent->type, event->data.multimediaEvent.appId, pNewMidpEvent->MM_PLAYER_ID, pNewMidpEvent->MM_DATA); #endif break; #ifdef ENABLE_JSR_234 case MIDP_JC_EVENT_ADVANCED_MULTIMEDIA: pNewSignal->waitingFor = AMMS_EVENT_SIGNAL; pNewSignal->status = JAVACALL_OK; pNewMidpEvent->type = AMMS_EVENT; pNewMidpEvent->MM_PLAYER_ID = event->data.multimediaEvent.playerId; pNewMidpEvent->MM_ISOLATE = event->data.multimediaEvent.appId; pNewMidpEvent->MM_EVT_TYPE = event->data.multimediaEvent.mediaType; switch( event->data.multimediaEvent.mediaType ) { case JAVACALL_EVENT_AMMS_SNAP_SHOOTING_STOPPED: case JAVACALL_EVENT_AMMS_SNAP_STORAGE_ERROR: { int len = 0; javacall_utf16_string str = event->data.multimediaEvent.data.str16; while( str[len] != 0 ) len++; pcsl_string_convert_from_utf16( str, len, &pNewMidpEvent->MM_STRING ); free( str ); } break; default: pNewMidpEvent->MM_DATA = event->data.multimediaEvent.data.num32; break; } REPORT_CALL_TRACE4(LC_NONE, "[jsr234 event] External event recevied %d %d %d %d\n", pNewMidpEvent->type, event->data.multimediaEvent.appId, pNewMidpEvent->MM_PLAYER_ID, pNewMidpEvent->MM_DATA); break; #endif #ifdef ENABLE_JSR_179 case JSR179_LOCATION_JC_EVENT: pNewSignal->waitingFor = event->data.jsr179LocationEvent.event; pNewSignal->descriptor = (int)event->data.jsr179LocationEvent.provider; pNewSignal->status = event->data.jsr179LocationEvent.operation_result; REPORT_CALL_TRACE2(LC_NONE, "[jsr179 event] JSR179_LOCATION_SIGNAL %d %d\n", pNewSignal->descriptor, pNewSignal->status); break; case JSR179_PROXIMITY_JC_EVENT: pNewSignal->waitingFor = JSR179_PROXIMITY_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr179ProximityEvent.provider; pNewSignal->status = event->data.jsr179ProximityEvent.operation_result; REPORT_CALL_TRACE2(LC_NONE, "[jsr179 event] JSR179_PROXIMITY_SIGNAL %d %d\n", pNewSignal->descriptor, pNewSignal->status); break; #endif #ifdef ENABLE_JSR_211 case JSR211_JC_EVENT_PLATFORM_FINISH: pNewSignal->waitingFor = JSR211_PLATFORM_FINISH_SIGNAL; pNewSignal->descriptor = event->data.jsr211PlatformEvent.invoc_id; pNewSignal->pResult = event->data.jsr211PlatformEvent.jsr211event; pNewMidpEvent->type = CHAPI_EVENT; break; case JSR211_JC_EVENT_JAVA_INVOKE: pNewSignal->waitingFor = JSR211_JAVA_INVOKE_SIGNAL; pNewSignal->descriptor = event->data.jsr211PlatformEvent.invoc_id; pNewSignal->pResult = event->data.jsr211PlatformEvent.jsr211event; pNewMidpEvent->type = CHAPI_EVENT; break; case JSR211_JC_EVENT_REQUEST_RECEIVED: pNewSignal->waitingFor = JSR211_REQUEST_SIGNAL; pNewSignal->pResult = event->data.jsr211RequestEvent.data; pNewMidpEvent->type = CHAPI_EVENT; break; case JSR211_JC_EVENT_RESPONSE_RECEIVED: pNewSignal->waitingFor = JSR211_RESPONSE_SIGNAL; pNewSignal->pResult = event->data.jsr211ResponseEvent.data; pNewMidpEvent->type = CHAPI_EVENT; break; #endif /* ENABLE_JSR_211 */ #ifdef ENABLE_JSR_290 case JSR290_JC_EVENT_FLUID_INVALIDATE: pNewSignal->waitingFor = JSR290_INVALIDATE_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr290FluidEvent.fluid_image; pNewSignal->pResult = event->data.jsr290FluidEvent.app_id; break; case JSR290_JC_EVENT_FLUID_LISTENER_COMPLETED: pNewSignal->waitingFor = JSR290_FLUID_EVENT_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr290FluidEvent.fluid_image; pNewSignal->pResult = event->data.jsr290FluidEvent.app_id; pNewMidpEvent->type = FLUID_EVENT; pNewMidpEvent->intParam2 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image)); pNewMidpEvent->intParam3 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image) >> 32); pNewMidpEvent->intParam1 = JSR290_LISTENER_COMPLETED; break; case JSR290_JC_EVENT_FLUID_LISTENER_FAILED: pNewSignal->waitingFor = JSR290_FLUID_EVENT_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr290FluidEvent.fluid_image; pNewSignal->pResult = event->data.jsr290FluidEvent.app_id; pNewMidpEvent->type = FLUID_EVENT; pNewMidpEvent->intParam2 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image)); pNewMidpEvent->intParam3 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image) >> 32); pNewMidpEvent->intParam1 = JSR290_LISTENER_FAILED; pNewMidpEvent->intParam4 = (jint)(event->data.jsr290FluidEvent.failure_type); { int len = 0; if (JAVACALL_OK != javautil_unicode_utf16_ulength(event->data.jsr290FluidEvent.text, &len)) { len = 0; } pcsl_string_convert_from_utf16(event->data.jsr290FluidEvent.text, len, &pNewMidpEvent->stringParam1); } javacall_free(event->data.jsr290FluidEvent.text); break; case JSR290_JC_EVENT_FLUID_LISTENER_PERCENTAGE: pNewSignal->waitingFor = JSR290_FLUID_EVENT_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr290FluidEvent.fluid_image; pNewSignal->pResult = event->data.jsr290FluidEvent.app_id; pNewMidpEvent->type = FLUID_EVENT; pNewMidpEvent->intParam2 = (int)(((jlong)event->data.jsr290FluidEvent.fluid_image)); pNewMidpEvent->intParam3 = (int)(((jlong)event->data.jsr290FluidEvent.fluid_image) >> 32); pNewMidpEvent->intParam1 = JSR290_LISTENER_PERCENTAGE; pNewMidpEvent->intParam4 = *((int*)&event->data.jsr290FluidEvent.percentage); break; case JSR290_JC_EVENT_FLUID_LISTENER_STARTED: pNewSignal->waitingFor = JSR290_FLUID_EVENT_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr290FluidEvent.fluid_image; pNewSignal->pResult = event->data.jsr290FluidEvent.app_id; pNewMidpEvent->type = FLUID_EVENT; pNewMidpEvent->intParam2 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image)); pNewMidpEvent->intParam3 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image) >> 32); pNewMidpEvent->intParam1 = JSR290_LISTENER_STARTED; break; case JSR290_JC_EVENT_FLUID_IMAGE_SPAWNED: pNewSignal->waitingFor = JSR290_FLUID_EVENT_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr290FluidEvent.fluid_image; pNewSignal->pResult = event->data.jsr290FluidEvent.app_id; pNewMidpEvent->type = FLUID_EVENT; pNewMidpEvent->intParam2 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image)); pNewMidpEvent->intParam3 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image) >> 32); pNewMidpEvent->intParam4 = (int)((jlong)(event->data.jsr290FluidEvent.spare)); pNewMidpEvent->intParam5 = (int)((jlong)(event->data.jsr290FluidEvent.spare) >> 32); pNewMidpEvent->intParam1 = JSR290_IMAGE_SPAWNED; break; case JSR290_JC_EVENT_FLUID_LISTENER_WARNING: pNewSignal->waitingFor = JSR290_FLUID_EVENT_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr290FluidEvent.fluid_image; pNewSignal->pResult = event->data.jsr290FluidEvent.app_id; pNewMidpEvent->type = FLUID_EVENT; pNewMidpEvent->intParam2 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image)); pNewMidpEvent->intParam3 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image) >> 32); pNewMidpEvent->intParam1 = JSR290_LISTENER_WARNING; { int len = 0; if (JAVACALL_OK != javautil_unicode_utf16_ulength(event->data.jsr290FluidEvent.text, &len)) { len = 0; } pcsl_string_convert_from_utf16(event->data.jsr290FluidEvent.text, len, &pNewMidpEvent->stringParam1); } javacall_free(event->data.jsr290FluidEvent.text); break; case JSR290_JC_EVENT_FLUID_LISTENER_DOCUMENT_AVAILABLE: pNewSignal->waitingFor = JSR290_FLUID_EVENT_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr290FluidEvent.fluid_image; pNewSignal->pResult = event->data.jsr290FluidEvent.app_id; pNewMidpEvent->type = FLUID_EVENT; pNewMidpEvent->intParam2 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image)); pNewMidpEvent->intParam3 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image) >> 32); pNewMidpEvent->intParam1 = JSR290_LISTENER_DOCUMENT_AVAILABLE; break; case JSR290_JC_EVENT_FLUID_REQUEST_RESOURCE: pNewSignal->waitingFor = JSR290_FLUID_EVENT_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr290FluidEvent.fluid_image; pNewSignal->pResult = event->data.jsr290FluidEvent.app_id; pNewMidpEvent->type = FLUID_EVENT; pNewMidpEvent->intParam2 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image)); pNewMidpEvent->intParam3 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image) >> 32); pNewMidpEvent->intParam4 = (int)((jlong)(event->data.jsr290FluidEvent.spare)); pNewMidpEvent->intParam5 = (int)((jlong)(event->data.jsr290FluidEvent.spare) >> 32); pNewMidpEvent->intParam1 = JSR290_REQUEST_RESOURCE; { int len = 0; if (JAVACALL_OK != javautil_unicode_utf16_ulength(event->data.jsr290FluidEvent.text, &len)) { len = 0; } pcsl_string_convert_from_utf16(event->data.jsr290FluidEvent.text, len, &pNewMidpEvent->stringParam1); } javacall_free(event->data.jsr290FluidEvent.text); break; case JSR290_JC_EVENT_FLUID_CANCEL_REQUEST: pNewSignal->waitingFor = JSR290_FLUID_EVENT_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr290FluidEvent.fluid_image; pNewSignal->pResult = event->data.jsr290FluidEvent.app_id; pNewMidpEvent->type = FLUID_EVENT; pNewMidpEvent->intParam2 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image)); pNewMidpEvent->intParam3 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image) >> 32); pNewMidpEvent->intParam4 = (int)((jlong)(event->data.jsr290FluidEvent.spare)); pNewMidpEvent->intParam5 = (int)((jlong)(event->data.jsr290FluidEvent.spare) >> 32); pNewMidpEvent->intParam1 = JSR290_CANCEL_REQUEST; break; case JSR290_JC_EVENT_FLUID_FILTER_XML_HTTP_REQUEST: pNewSignal->waitingFor = JSR290_FLUID_EVENT_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr290FluidEvent.fluid_image; pNewSignal->pResult = event->data.jsr290FluidEvent.app_id; pNewMidpEvent->type = FLUID_EVENT; pNewMidpEvent->intParam2 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image)); pNewMidpEvent->intParam3 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image) >> 32); pNewMidpEvent->intParam1 = JSR290_FILTER_XML_HTTP; pNewMidpEvent->intParam4 = (int)((jlong)(event->data.jsr290FluidEvent.spare)); pNewMidpEvent->intParam5 = (int)((jlong)(event->data.jsr290FluidEvent.spare) >> 32); { int len = 0; if (JAVACALL_OK != javautil_unicode_utf16_ulength(event->data.jsr290FluidEvent.text, &len)) { len = 0; } pcsl_string_convert_from_utf16(event->data.jsr290FluidEvent.text, len, &pNewMidpEvent->stringParam1); } javacall_free(event->data.jsr290FluidEvent.text); { int len = 0; if (JAVACALL_OK != javautil_unicode_utf16_ulength(event->data.jsr290FluidEvent.text1, &len)) { len = 0; } pcsl_string_convert_from_utf16(event->data.jsr290FluidEvent.text1, len, &pNewMidpEvent->stringParam2); } javacall_free(event->data.jsr290FluidEvent.text1); break; case JSR290_JC_EVENT_COMPLETION_NOTIFICATION: pNewSignal->waitingFor = JSR290_INVOCATION_COMPLETION_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr290NotificationEvent.invocation_id; break; case JSR290_JC_EVENT_HANDLE_EVENT: pNewSignal->waitingFor = JSR290_FLUID_EVENT_SIGNAL; pNewSignal->pResult = event->data.jsr290FluidEvent.app_id; pNewMidpEvent->type = FLUID_EVENT; pNewMidpEvent->intParam4 = (int)((jlong)(event->data.jsr290HandleEventRequest.request_handle)); pNewMidpEvent->intParam5 = (int)((jlong)(event->data.jsr290HandleEventRequest.request_handle) >> 32); pNewMidpEvent->intParam1 = JSR290_HANDLE_EVENT; break; case JSR290_JC_EVENT_DISPLAY_BOX: pNewSignal->waitingFor = JSR290_FLUID_EVENT_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr290FluidEvent.fluid_image; pNewSignal->pResult = event->data.jsr290FluidEvent.app_id; pNewMidpEvent->type = FLUID_EVENT; pNewMidpEvent->intParam2 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image)); pNewMidpEvent->intParam3 = (int)((jlong)(event->data.jsr290FluidEvent.fluid_image) >> 32); pNewMidpEvent->intParam4 = (int)((jlong)(event->data.jsr290FluidEvent.spare)); pNewMidpEvent->intParam5 = (int)((jlong)(event->data.jsr290FluidEvent.spare) >> 32); switch ((int)event->data.jsr290FluidEvent.result) { case 0: pNewMidpEvent->intParam1 = JSR290_DISPLAY_ALERT_BOX; break; case 1: pNewMidpEvent->intParam1 = JSR290_DISPLAY_CONFIRM_BOX; break; case 2: pNewMidpEvent->intParam1 = JSR290_DISPLAY_PROMPT_BOX; break; } { int len = 0; if (JAVACALL_OK != javautil_unicode_utf16_ulength(event->data.jsr290FluidEvent.text, &len)) { len = 0; } pcsl_string_convert_from_utf16(event->data.jsr290FluidEvent.text, len, &pNewMidpEvent->stringParam1); } javacall_free(event->data.jsr290FluidEvent.text); { int len = 0; if (JAVACALL_OK != javautil_unicode_utf16_ulength(event->data.jsr290FluidEvent.text1, &len)) { len = 0; } pcsl_string_convert_from_utf16(event->data.jsr290FluidEvent.text1, len, &pNewMidpEvent->stringParam2); } javacall_free(event->data.jsr290FluidEvent.text1); break; case JSR290_JC_EVENT_FLUID_LAYOUT_CHANGED: pNewSignal->waitingFor = JSR290_FLUID_EVENT_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr290FluidEvent.fluid_image; pNewSignal->pResult = event->data.jsr290FluidEvent.app_id; pNewMidpEvent->type = FLUID_EVENT; pNewMidpEvent->intParam1 = JSR290_LAYOUT_CHANGED; pNewMidpEvent->intParam2 = (int)(((jlong)event->data.jsr290FluidEvent.fluid_image)); pNewMidpEvent->intParam3 = (int)(((jlong)event->data.jsr290FluidEvent.fluid_image) >> 32); break; case JSR290_JC_EVENT_FLUID_FOCUS_CHANGED: pNewSignal->waitingFor = JSR290_FLUID_EVENT_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr290FluidEvent.fluid_image; pNewSignal->pResult = event->data.jsr290FluidEvent.app_id; pNewMidpEvent->type = FLUID_EVENT; pNewMidpEvent->intParam1 = JSR290_FOCUS_CHANGED; pNewMidpEvent->intParam2 = (int)(((jlong)event->data.jsr290FluidEvent.fluid_image)); pNewMidpEvent->intParam3 = (int)(((jlong)event->data.jsr290FluidEvent.fluid_image) >> 32); break; #endif /* ENABLE_JSR_290 */ #ifdef ENABLE_JSR_177 case MIDP_JC_EVENT_CARDDEVICE: switch (event->data.carddeviceEvent.eventType) { case MIDP_CARDDEVICE_RESET: pNewSignal->waitingFor = CARD_READER_DATA_SIGNAL; pNewSignal->descriptor = SIGNAL_RESET; pNewSignal->status = SIGNAL_RESET; pNewSignal->pResult = (void *)event->data.carddeviceEvent.handle; break; case MIDP_CARDDEVICE_XFER: pNewSignal->waitingFor = CARD_READER_DATA_SIGNAL; pNewSignal->descriptor = SIGNAL_XFER; pNewSignal->status = SIGNAL_XFER; pNewSignal->pResult = (void *)event->data.carddeviceEvent.handle; break; case MIDP_CARDDEVICE_UNLOCK: pNewSignal->waitingFor = CARD_READER_DATA_SIGNAL; pNewSignal->descriptor = SIGNAL_LOCK; pNewSignal->status = SIGNAL_LOCK; pNewSignal->pResult = NULL; break; default: /* just ignore invalid event type */ REPORT_ERROR1(LC_CORE,"Invalid carddevice event type: %d\n", event->data.carddeviceEvent.eventType); break; } break; #endif /* ENABLE_JSR_177 */ #ifdef ENABLE_JSR_257 case JSR257_JC_EVENT_CONTACTLESS: if(event->data.jsr257Event.eventType < JSR257_EVENTS_NUM) { pNewSignal->waitingFor = JSR257_CONTACTLESS_SIGNAL; pNewSignal->descriptor = event->data.jsr257Event.eventType; } else { REPORT_ERROR1(LC_CORE,"Invalid contactless event type: %d\n", event->data.jsr257Event.eventType); } break; case JSR257_JC_MIDP_EVENT: printf("\n DEBUG: midp_msgQueue_md.c(): data.jsr257Event.eventType = %d\n", event->data.jsr257Event.eventType); if(event->data.jsr257Event.eventType < JSR257_MIDP_EVENTS_NUM) { pNewSignal->waitingFor = JSR257_EVENT_SIGNAL; pNewSignal->descriptor = event->data.jsr257Event.eventType; pNewMidpEvent->type = CONTACTLESS_EVENT; pNewMidpEvent->intParam1 = event->data.jsr257Event.eventType; pNewMidpEvent->JSR257_ISOLATE = (int)(event->data.jsr257Event.isolateId); pNewMidpEvent->intParam3 = (int)(event->data.jsr257Event.eventData[0]); pNewMidpEvent->intParam4 = (int)(event->data.jsr257Event.eventData[1]); pNewMidpEvent->intParam5 = (int)(event->data.jsr257Event.eventData[2]); } else { REPORT_ERROR1(LC_CORE,"Invalid contactless MIDP event type: %d\n", event->data.jsr257Event.eventType); } break; case JSR257_JC_PUSH_NDEF_RECORD_DISCOVERED: pNewSignal->waitingFor = JSR257_PUSH_SIGNAL; pNewSignal->descriptor = event->data.jsr257Event.eventData[0]; break; #endif /* ENABLE_JSR_257 */ #if ENABLE_MULTIPLE_ISOLATES case MIDP_JC_EVENT_SWITCH_FOREGROUND: pNewSignal->waitingFor = AMS_SIGNAL; pNewMidpEvent->type = SELECT_FOREGROUND_EVENT; pNewMidpEvent->intParam1 = 1; break; case MIDP_JC_EVENT_SELECT_APP: pNewSignal->waitingFor = AMS_SIGNAL; pNewMidpEvent->type = SELECT_FOREGROUND_EVENT; pNewMidpEvent->intParam1 = 0; break; #endif /* ENABLE_MULTIPLE_ISOLATES */ #if !ENABLE_CDC #ifdef ENABLE_JSR_256 case JSR256_JC_EVENT_SENSOR_AVAILABLE: pNewSignal->waitingFor = JSR256_SIGNAL; pNewMidpEvent->type = SENSOR_EVENT; pNewMidpEvent->intParam1 = event->data.jsr256SensorAvailable.sensor_type; pNewMidpEvent->intParam2 = event->data.jsr256SensorAvailable.is_available; break; case JSR256_JC_EVENT_SENSOR_OPEN_CLOSE: pNewSignal->waitingFor = JSR256_SIGNAL; pNewSignal->descriptor = (int)event->data.jsr256_jc_event_sensor.sensor; break; #endif /* ENABLE_JSR_256 */ #endif /* !ENABLE_CDC */ #ifdef ENABLE_API_EXTENSIONS case MIDP_JC_EVENT_VOLUME: pNewSignal->waitingFor = VOLUME_SIGNAL; pNewSignal->status = JAVACALL_OK; break; #endif /* ENABLE_API_EXTENSIONS */ default: REPORT_ERROR(LC_CORE,"Unknown event.\n"); break; }; REPORT_CALL_TRACE(LC_HIGHUI, "LF:STUB:checkForSystemSignal()\n"); }