/** * Opens a file and fills the content of the file in the result_buf. <BR> * This function made memory allocation inside. * * @param filename Path to the file. * @param result_buf Pointer to the buffer that will be filled by content of the file. * @return buffer file size in bytes */ long readJadFile(const pcsl_string * filename, char** result_buf) { int fd = 0; char* err = NULL; long bufsize = -1; int numread = 0; char* res = *result_buf; if (pcsl_string_length(filename) <= 0) { REPORT_INFO(LC_AMS, "readJadFile():No file name."); return BAD_PARAMS; } fd = storage_open(&err, filename, OPEN_READ); if(err != NULL) { REPORT_INFO1(LC_AMS, "readJadFile():Can't open jad file '%s'",err); storageFreeError(err); return NO_JAD_FILE; } bufsize = storageSizeOf(&err, fd); if((bufsize <= 0) || (err != NULL)) { REPORT_INFO1(LC_AMS, "readJadFile():Problem getting file size: %s", err ); storageFreeError(err); return IO_ERROR; } res = (char*)midpMalloc(bufsize+1); if (res == NULL || (err != NULL)) { REPORT_INFO1(LC_AMS, "readJadFile():Can't allocate memory. %s", err); storageFreeError(err); return OUT_OF_MEMORY; } memset(res,0,(bufsize+1)); REPORT_INFO2(LC_AMS, "fd = %d, bufsize = %ld\n", fd, bufsize); numread = storageRead(&err, fd, res, bufsize); if((numread <= 0) || (numread != bufsize) || (err)) { REPORT_INFO3(LC_AMS, "size = %ld, numread = %d, err = %s.", bufsize, numread, err); storageClose(&err, fd); return IO_ERROR; } REPORT_INFO2(LC_AMS, "size = %ld, numread = %d", bufsize, numread); storageClose(&err, fd); if(err != NULL) { REPORT_INFO1(LC_AMS, "Can't close jad file %s\n", err); } *result_buf = res; return bufsize; } /* end of readJadFile */
void printPcslStringWithMessageImpl(char* message, const pcsl_string* pstr) { char* tag; if ((pcsl_string_length(pstr) <= 0) && (!message)) { REPORT_INFO(LC_MIDPSTRING, "printPcslStringWithMessage() No input"); return; } if (message) { tag = message; } else { tag = "message = NULL:"; } if (pcsl_string_length(pstr) > 0) { const char* msg = pcsl_string_get_utf8_data(pstr); if (msg) { REPORT_INFO2(LC_MIDPSTRING, "%s: %s", tag, msg); pcsl_string_release_utf8_data(msg, pstr); } else { REPORT_INFO1(LC_MIDPSTRING, "%s: printPcslStringWithMessage can't convert pcsl_string to char*", tag); } } else { REPORT_INFO2(LC_MIDPSTRING, "%s: pcsl_string is %s", tag, 0 == pcsl_string_length(pstr) ? "empty" : "null" ); } }
/** * Prints a <tt>MidpString</tt> with a given message. A new line will * be emitted after <tt>mstr</tt>. This output goes to the log in cases * were the log service defined <code>REPORT_LEVEL <= LOG_INFORMATION</code> * conditional is true. * * @param message the specified message to print * @param mstr the <tt>MidpString</tt> to print */ void printMidpStringWithMessageImpl(char* message, MidpString mstr) { char* msg = NULL; char* tag; if ((mstr.len <= 0) && (!message)) { REPORT_INFO(LC_MIDPSTRING, "printMidpString() No input"); return; } if (message) { tag = message; } else { tag = "message = NULL:"; } if (mstr.len > 0) { msg = midpJcharsToChars(mstr); if (msg) { REPORT_INFO2(LC_MIDPSTRING, "%s: %s", tag, msg); midpFree(msg); } else { REPORT_INFO1(LC_MIDPSTRING, "%s: printMidpString can't convert MidpString to char*",tag); } } }
javacall_result bt_push_unregister_url(const char *url) { bt_port_t port; bt_push_t *push, *prev; REPORT_INFO(LC_PUSH, "Bluetooth PushRegistry URL un-registration:"); REPORT_INFO1(LC_PUSH, "%s", url); bt_push_parse_url(url, &port, NULL); push = find_push(&port, &prev); if (push == NULL) { return JAVACALL_FAIL; } /* remove the service record */ javacall_bt_sddb_remove_record(push->record.id); /* close server and client connections */ close_all(push); /* remove the entry */ if (prev != NULL) { prev->next = push->next; } else { g_registry = push->next; } g_count--; pcsl_mem_free(push); push_save(); javacall_bt_stack_set_service_classes(javacall_bt_sddb_get_service_classes(0)); REPORT_INFO(LC_PUSH, "Un-registration successful."); return JAVACALL_OK; }
/* * Return the amount of free bytes of file storage. * The maximum amount of free space is limited by the value set with * the <tt>storageSetTotalSpace</tt> method. * * @param storageId ID of the storage to check for free space */ jlong storage_get_free_space(StorageIdType storageId) { jlong freeSpace; jlong usedSpace; if (storageId < 0 || storageId >= MAX_STORAGE_NUM) { return 0; /* Invalid storage ID: no free space available */ } usedSpace = pcsl_file_getusedspace(&sRoot[storageId]); if (usedSpace == -1) { /* PCSL error */ return 0; /* No free space available */ } if (totalSpace > usedSpace) { freeSpace = totalSpace - usedSpace; } else { freeSpace = 0; } REPORT_INFO1(LC_CORE, "Free space = %ld\n", freeSpace); return freeSpace; }
/** * A notification function for telling Java to perform installation of * a MIDletl, * * * If the given url is of the form http://www.sun.com/a/b/c/d.jad then * java will start a graphical installer will download the MIDlet * fom the internet. * If the given url is a file url (see below, file:///a/b/c/d.jar or * file:///a/b/c/d/jad) installation will be performed * in the backgroudn without launching the graphic installer application * * * @param url of MIDlet to install, can be either one of the following * 1. A full path to the jar file, of the following form file:///a/b/c/d.jar * 2. A full path to the JAD file, of the following form file:///a/b/c/d.jad * 3. An http url of jad file, of the following form, * http://www.sun.com/a/b/c/d.jad * */ void javanotify_install_midlet(const char *httpUrl) { int length; midp_jc_event_union e; midp_jc_event_start_arbitrary_arg *data = &e.data.startMidletArbitraryArgEvent; REPORT_INFO1(LC_CORE,"javanotify_install_midlet() >> httpUrl=%s\n",httpUrl); e.eventType = MIDP_JC_EVENT_START_ARBITRARY_ARG; data->argc = 0; data->argv[data->argc++] = "runMidlet"; data->argv[data->argc++] = "-1"; data->argv[data->argc++] = "com.sun.midp.installer.GraphicalInstaller"; data->argv[data->argc++] = "I"; length = strlen(httpUrl); if (length >= BINARY_BUFFER_MAX_LEN) return; memset(urlAddress, 0, BINARY_BUFFER_MAX_LEN); memcpy(urlAddress, httpUrl, length); data->argv[data->argc++] = urlAddress; midp_jc_event_send(&e); }
/** * Create the native peer of a DateField. * Upon successful return, *datefieldPtr should be filled in properly. * Param time is number of milliseconds since the standard base time known as * "the epoch", namely January 1, 1970, 00:00:00 GMT. * (defined in midp_datefield.h) */ extern "C" MidpError lfpport_datefield_create(MidpItem* datefieldPtr, MidpDisplayable* formPtr, const pcsl_string* label, int layout, int input_mode, long time, const pcsl_string* timezoneID) { QString qlabel, qtzone; TRACE_DF(lfpport_datefield_Create); REPORT_INFO1(LC_HIGHUI, "\tinput_mode=%d\n", input_mode); pcsl_string2QString(*label, qlabel); pcsl_string2QString(*timezoneID, qtzone); // Fill in MidpItem structure datefieldPtr->widgetPtr = new DateField((formPtr == INVALID_NATIVE_ID ? 0 : (QWidget *)formPtr->frame.widgetPtr), qlabel, layout, time, input_mode, qtzone); initItemPtr(datefieldPtr, formPtr); return KNI_OK; }
int testReadJadFile_2(void) { int jadsize = 0; char* jad_buf = NULL; char* jad = "../../../src/common/native/share/unittests/no_such_a_file.jad"; int res = NO_JAD_FILE; MidpString jadURL = {0,NULL}; REPORT_INFO(LC_AMS, "############# This test should fail. Trying to load file that doesn't exist.\n"); jadURL = midpCharsToJchars(jad); jadsize = (int)readJadFile (jadURL, &jad_buf); if ((jadsize <= 0) || (!jad_buf)) { REPORT_WARN1(LC_AMS, "\nCan't open JAD file %s\n", jad); res = ALL_OK; } else { REPORT_INFO1(LC_AMS, "JAD content is:\n%s\n", jad_buf); } midpFreeString(jadURL); if (jad_buf) { midpFree(jad_buf); } /* end of if */ return res; } /* testReadJadFile_2 */
int testReadJadFile_1(void) { int jadsize = 0; char* jad_buf = NULL; char* jad = "../../../src/common/native/share/unittests/jad1.jad"; int res = ALL_OK; MidpString jadURL = {0,NULL}; REPORT_INFO(LC_AMS, "############# This test should pass."); jadURL = midpCharsToJchars(jad); jadsize = (int)readJadFile (jadURL, &jad_buf); if ((jadsize <= 0) || (!jad_buf)) { REPORT_WARN1(LC_AMS, "Can't open JAD file %s", jad); res = NO_JAD_FILE; } else { REPORT_INFO1(LC_AMS, "JAD content is:\n%s\n", jad_buf); } midpFreeString(jadURL); if (jad_buf) { midpFree(jad_buf); } /* end of if */ return res; } /* testReadJadFile_1 */
/** * A notification function for telling Java to perform installation of * a MIDlet * * If the given url is of the form http://www.sun.com/a/b/c/d.jad then * java will start a graphical installer will download the MIDlet * fom the internet. * If the given url is a file url (see below, file:///a/b/c/d.jar or * file:///a/b/c/d/jad) installation will be performed * in the backgroudn without launching the graphic installer application * * * @param url of MIDlet to install, can be either one of the following * 1. A full path to the jar file, of the following form file:///a/b/c/d.jar * 2. A full path to the JAD file, of the following form file:///a/b/c/d.jad * 3. An http url of jad file, of the following form, * http://www.sun.com/a/b/c/d.jad */ void javanotify_install_midlet(const char *httpUrl) { int length; int argc = 0; char *argv[MIDP_RUNMIDLET_MAXIMUM_ARGS]; javacall_result res; REPORT_INFO1(LC_CORE,"javanotify_install_midlet() >> httpUrl = %s\n", httpUrl); if (initialize_memory_slavemode() != JAVACALL_OK) { return; } argv[argc++] = "runMidlet"; argv[argc++] = "-1"; argv[argc++] = "com.sun.midp.installer.GraphicalInstaller"; argv[argc++] = "I"; length = strlen(httpUrl); if (length >= BINARY_BUFFER_MAX_LEN){ REPORT_ERROR(LC_AMS, "javanotify_install_midlet(): httpUrl is too long\n"); return; } memset(urlAddress, 0, BINARY_BUFFER_MAX_LEN); memcpy(urlAddress, httpUrl, length); argv[argc++] = urlAddress; javacall_lifecycle_state_changed(JAVACALL_LIFECYCLE_MIDLET_STARTED, JAVACALL_OK); res = runMidlet(argc, argv); }
/** * Gets a raw IPv4 address for the given hostname. * <p> * Java declaration: * <pre> * static getIpNumber([B)I * </pre> * * @param szHost the hostname to lookup as a 'C' string * @return raw IPv4 address or <tt>-1</tt> if there was an error */ KNIEXPORT KNI_RETURNTYPE_INT Java_com_sun_midp_io_j2me_datagram_Protocol_getIpNumber(void) { int len; int status; int ipn = -1; unsigned char ipBytes[MAX_ADDR_LENGTH]; void* context = NULL; void* handle; MidpReentryData* info; KNI_StartHandles(1); KNI_DeclareHandle(hostObject); KNI_GetParameterAsObject(1, hostObject); info = (MidpReentryData*)SNI_GetReentryData(NULL); if (info == NULL) { /* First invocation */ SNI_BEGIN_RAW_POINTERS; status = pcsl_network_gethostbyname_start( (char*)JavaByteArray(hostObject), ipBytes, MAX_ADDR_LENGTH, &len, &handle, &context); SNI_END_RAW_POINTERS; } else { /* Reinvocation after unblocking the thread */ handle = (void*)info->descriptor; /* IMPL NOTE: Please see 6440539 for details. */ /* All but windows implementations of pcsl_network_gethostbyname_finish */ /* ignore context parameter. Windows one expects status code there. */ context = (void*)info->status; status = pcsl_network_gethostbyname_finish(ipBytes, MAX_ADDR_LENGTH, &len, handle, context); } KNI_EndHandles(); if (status == PCSL_NET_SUCCESS) { /* * Convert the unsigned char ip bytes array into an integer * that represents a raw IP address. */ //ipn = pcsl_network_getRawIpNumber(ipBytes); memcpy(&ipn, ipBytes, MAX_ADDR_LENGTH); } else if (status == PCSL_NET_WOULDBLOCK) { midp_thread_wait(HOST_NAME_LOOKUP_SIGNAL, (int)handle, context); } else { /* status is either PCSL_NET_IOERROR or PCSL_NET_INVALID */ ipn = -1; REPORT_INFO1(LC_PROTOCOL, "datagram::getIpNumber returns PCSL error code %d", status); /* * IOException is thrown at the Java layer when return value * is -1 */ //KNI_ThrowNew(midpIOException, "Host name could not be resolved"); } KNI_ReturnInt((jint)ipn); }
/* * Return a 32 bit handle to an open a file in storage in different modes. * * See "I/O Modes" and "Filenames" above for move information. * * If not successful *ppszError will set to point to an error string, * on success it will be set to NULL. */ int storage_open(char** ppszError, const pcsl_string* filename_str, int ioMode) { int flags = 0; int openStatus; void *handle; *ppszError = NULL; if (OPEN_READ == ioMode) { DEBUGP2F("opening for read only %s\n", filename_str); flags |= PCSL_FILE_O_RDONLY; } else { if (!storage_file_exists(filename_str)) { flags |= PCSL_FILE_O_CREAT; } else if (OPEN_READ_WRITE_TRUNCATE == ioMode) { flags |= PCSL_FILE_O_TRUNC; } if (OPEN_WRITE == ioMode) { DEBUGP2F("opening write only %s\n", filename_str); flags |= PCSL_FILE_O_WRONLY; } else { DEBUGP2F("opening read write %s\n", filename_str); flags |= PCSL_FILE_O_RDWR; } } /** * Verify that the resource is available well within limit as per * the policy in ResourceLimiter */ if (midpCheckResourceLimit(RSC_TYPE_FILE, 1) == 0) { REPORT_INFO(LC_CORE, "Resource limit exceeded for file handles"); *ppszError = (char *)FILE_LIMIT_ERROR; return -1; } openStatus = pcsl_file_open(filename_str, flags, &handle); REPORT_INFO1(LC_CORE, "storage_open allocated file_desc %d\n", (int)handle); if (-1 == openStatus) { *ppszError = storage_get_last_file_error("storage_open()", filename_str); return -1; } /* Update the resource count */ if (midpIncResourceCount(RSC_TYPE_FILE, 1) == 0) { REPORT_INFO(LC_CORE, "FILE : resource limit update error"); } #if REPORT_LEVEL <= LOG_INFORMATION DEBUGP2F("created %s\n", filename_str); #endif return (int)handle; }
/** * Remove specified timer handler from queue and free allocated memory * * @param timer instance of timer that should be remove */ void delete_timer(TimerHandle* timer) { TimerHandle **ptr = get_timer_ptr(timer); REPORT_INFO1(LC_PUSH, "[delete_timer] timer=%p", timer); if (ptr != NULL) { *ptr = timer->next; midpFree(timer); } }
int CustomItem::bodyWidthForHeight(int *takenHeight, int ) { REPORT_INFO1(LC_HIGHUI, "[lfpport_qte_customitem.cpp:%d] " "***CustomItem::bodyWidthForHeight ", __LINE__); *takenHeight = drawable->height(); return drawable->width(); }
/** * Remove specified timer handler from queue but don't free allocated memory * * @param timer instance that should be remove * * @return poitner to timer instance that should be remove from queue */ TimerHandle* remove_timer(TimerHandle* timer) { TimerHandle **ptr = get_timer_ptr(timer); REPORT_INFO1(LC_PUSH, "[remove_timer] timer=%p", timer); if (ptr != NULL) { *ptr = timer->next; } return timer; }
/** * Sets the content buffer. All paints are done to that buffer. * When paint is processed snapshot of the buffer is flushed to * the native resource content area. * * @param ciPtr pointer to the custom item's MidpItem structure. * @param imgPtr pointer to the native resource corresponding * to the Java offcreen buffer for CustomItem content */ extern "C" MidpError lfpport_customitem_set_content_buffer(MidpItem* ciPtr, unsigned char* imgPtr) { REPORT_INFO1(LC_HIGHUI, "[lfpport_qte_customitem.cpp:%d] " "lfpport_customitem_SetContentBuffer", __LINE__); ((CustomItem *)ciPtr->widgetPtr)-> setContentBuffer(gxpportqt_get_mutableimage_pixmap(imgPtr)); return KNI_OK; }
/** Implement virtual function (defined in lfpport_qte_item.h) */ void CustomItem::bodyResize(int w, int h) { REPORT_INFO1(LC_HIGHUI, "[lfpport_qte_customitem.cpp:%d] " "CustomItem::bodyResize " , __LINE__); REPORT_INFO2(LC_HIGHUI, " @@@@@ \tw & h = %d & %d @@@@@\n",w, h); drawable->resize(w, h); }
/** * Gets the padding for the custom item. * * @param pad the padding for the custom item. * @param ciPtr pointer to the custom item's MidpItem structure. * * @return an indication of success or the reason for failure */ extern "C" MidpError lfpport_customitem_get_item_pad(int *pad, MidpItem* ciPtr) { REPORT_INFO1(LC_HIGHUI, "[lfpport_qte_customitem.cpp:%d] " "lfpport_customitem_GetItemPad", __LINE__); (void)ciPtr; // Suppress unused parameter warning *pad = ITEM_BOUND_PAD; return KNI_OK; }
/** * Remove a specific entry indicated by user data. * Only first element matching the userData is removed. * * @param userdata user specified data used to identify the entry to remove */ void delete_timer_by_userdata(void* userdata) { TimerHandle* timer; REPORT_INFO1(LC_PUSH, "[delete_timer_by_userdata] userdata=%p", userdata); for(timer = rootTimer; timer != NULL; timer = timer->next) { if (timer->userData == userdata) { delete_timer(timer); return; } } }
/** * Insert new timer to the correct place in timer queue * ordered by wakeup time * * @param newTimer new timer to add to queue */ void add_timer(TimerHandle* newTimer) { TimerHandle **ptr = &rootTimer; REPORT_INFO1(LC_PUSH, "[add_timer] newTimer=%p", newTimer); for(; *ptr != NULL; ptr = &((*ptr)->next)) { if ((*ptr)->timeToWakeup > newTimer->timeToWakeup) { break; } } newTimer->next = *ptr; (*ptr) = newTimer; }
int testMidpCompareVersion_3(void) { jchar ver1[] = {'1','.','0','.','2','3'}; MidpString in1 = {sizeof (ver1) / sizeof (jchar),ver1}; jchar ver2[] = {'1','.','0','.','2','4'}; MidpString in2 = {sizeof (ver2) / sizeof (jchar),ver2}; int res = 0; res = midpCompareVersion(in1,in2); REPORT_INFO1(LC_AMS, "testMidpCompareVersion_3 res = %d\n", res); if(res < 0 ) { return 1; } return -1; }
/* * Truncate the size of an open file in storage. * * If not successful *ppszError will set to point to an error string, * on success it will be set to NULL. */ void storageTruncate(char** ppszError, int handle, long size) { int rv; rv = pcsl_file_truncate((void *)handle, size); if (rv == -1) { *ppszError = getLastError("storageTruncate()"); } else { *ppszError = NULL; } REPORT_INFO1(LC_CORE, "storageTruncate got rv %d\n", rv); }
/* positive test */ int testMidpGetVersion_4(void) { int major; int minor; int micro; int res = 0; jchar ver[] = {'1','1','.','0','1','.','2','3'}; MidpString in = {sizeof (ver) / sizeof (jchar),ver}; res = midpGetVersion(in, &major, &minor, µ); REPORT_INFO1(LC_AMS, "testMidpGetVersion_4 res = %d\n", res); if(res != 1) { return -1; } /* end of if */ return 1; }
/* * See javacall_vscl.h for description */ void javanotify_vscl_incoming_event(javacall_vscl_event_type type, javacall_utf16* str1, javacall_utf16* str2) { midp_jc_event_union e; switch (type) { case JAVACALL_VSCL_INCOMING_CALL: e.eventType = MIDP_JC_EVENT_VSCL_INCOMING_CALL; REPORT_INFO(LC_VSCL,"javanotify_vscl_incoming_event() got EVENT=INCOMING_CALL\n"); break; case JAVACALL_VSCL_CALL_DROPPED: e.eventType = MIDP_JC_EVENT_VSCL_CALL_DROPPED; REPORT_INFO(LC_VSCL,"javanotify_vscl_incoming_event() got EVENT=CALL_DROPPED\n"); break; case JAVACALL_VSCL_INCOMING_MAIL_CBS: case JAVACALL_VSCL_INCOMING_MAIL_DELIVERY_CONF: case JAVACALL_VSCL_INCOMING_MAIL_MMS: case JAVACALL_VSCL_INCOMING_MAIL_SMS: case JAVACALL_VSCL_INCOMING_MAIL_WAP_PUSH: case JAVACALL_VSCL_SCHEDULED_ALARM: REPORT_INFO1(LC_VSCL,"javanotify_vscl_incoming_event() EVENT=%d NOT IMPLEMENTED!\n", (int)type); return; case JAVACALL_VSCL_FLIP_OPEN: REPORT_INFO(LC_VSCL,"javanotify_vscl_incoming_event() got EVENT=FLIP_OPEN\n"); e.eventType = MIDP_JC_EVENT_VSCL_FLIP_OPENED; break; case JAVACALL_VSCL_FLIP_CLOSED: REPORT_INFO(LC_VSCL,"javanotify_vscl_incoming_event() got EVENT=FLIP_CLOSED\n"); e.eventType = MIDP_JC_EVENT_VSCL_FLIP_CLOSED; break; default: REPORT_INFO1(LC_VSCL,"javanotify_vscl_incoming_event() EVENT=%d NOT IMPLEMENTED!\n", (int)type); return; } midp_jc_event_send(&e); }
javacall_result bt_push_register_url(const char *url, const void *data, size_t size) { bt_port_t port; bt_params_t params; bt_push_t *push; REPORT_INFO(LC_PUSH, "Bluetooth PushRegistry URL registration:"); REPORT_INFO1(LC_PUSH, "%s", url); bt_push_parse_url(url, &port, ¶ms); push = find_push(&port, NULL); if (push != NULL) { /* found existing entry with the same protocol/uuid, can not proceed */ REPORT_ERROR(LC_PUSH, "Entry already exists, registration failed."); return JAVACALL_FAIL; } /* save the entry in the registry */ push = (bt_push_t *)pcsl_mem_malloc(sizeof(bt_push_t)); if (push == NULL) { REPORT_ERROR(LC_PUSH, "Failed to allocate memory."); return JAVACALL_FAIL; } memcpy(&push->port, &port, sizeof(bt_port_t)); memcpy(&push->params, ¶ms, sizeof(bt_params_t)); push->record.id = BT_INVALID_SDDB_HANDLE; push->record.classes = 0; if (data != NULL) { push->record.data = pcsl_mem_malloc(size); if (push->record.data == NULL) { pcsl_mem_free(push); return JAVACALL_FAIL; } memcpy(push->record.data, data, size); } else { push->record.data = NULL; } push->record.size = size; push->server = BT_INVALID_HANDLE; push->client = NULL; push->next = g_registry; g_registry = push; g_count++; if (javacall_bt_sddb_update_record(&push->record.id, push->record.classes, push->record.data, push->record.size) != JAVACALL_OK) { return JAVACALL_FAIL; } push_save(); REPORT_INFO(LC_PUSH, "Registration successful."); return JAVACALL_OK; }
/** Override to notify Form focus change */ void CustomItem::focusInEvent(QFocusEvent *event) { REPORT_INFO1(LC_HIGHUI, "[lfpport_qte_customitem.cpp:%d] " "CustomItem::focusInEvent ", __LINE__); // Notify Java if this is caused by user action if (event->reason() != QFocusEvent::Other) { MidpFormFocusChanged(this); } // Continue with focus activation QWidget::focusInEvent(event); }
int testInstalFileUsingJar(void) { int res = ALL_OK; int myArgc = 2; REPORT_INFO(LC_AMS, "############# This test should pass.\n"); res = fileInstaller(myArgc, mrgv); if (res != ALL_OK) { REPORT_WARN2(LC_AMS, "\n%s failed. Result code is %d\n", fileInstallerTestJar, res); } else { REPORT_INFO1(LC_AMS, "%s passed\n", fileInstallerTestJar); } return res; } /* testInstalFileUsingJad */
/* * Commit or flush pending writes * * If not successful *ppszError will set to point to an error string, * on success it will be set to NULL. */ void storageCommitWrite(char** ppszError, int handle) { int status; REPORT_INFO1(LC_CORE, "trying to flush pending writes on file handle %d\n", handle); status = pcsl_file_commitwrite((void *)handle); if (status < 0) { *ppszError = getLastError("storageCommit()"); return; } *ppszError = NULL; }
/** * Gets the number of bytes that can be read without blocking. * <p> * Java declaration: * <pre> * available0(V)I * </pre> * * @return number of bytes that can be read without blocking */ KNIEXPORT KNI_RETURNTYPE_INT Java_com_sun_midp_io_j2me_socket_Protocol_available0(void) { void *pcslHandle; int bytesAvailable = 0; KNI_StartHandles(1); KNI_DeclareHandle(thisObject); KNI_GetThisPointer(thisObject); pcslHandle = (void *)(getMidpSocketProtocolPtr(thisObject)->handle); KNI_EndHandles(); REPORT_INFO1(LC_PROTOCOL, "socket::available0 fd=%d\n", (int)pcslHandle); if (INVALID_HANDLE == pcslHandle) { KNI_ThrowNew(midpIOException, "invalid handle during socket::available"); } else { int status; status = pcsl_socket_available(pcslHandle, &bytesAvailable); /* status is only PCSL_NET_SUCCESS or PCSL_NET_IOERROR */ if (status == PCSL_NET_IOERROR) { bytesAvailable = 0; midp_snprintf(gKNIBuffer, KNI_BUFFER_SIZE, "IOError %d during socket::available0", pcsl_network_error(pcslHandle)); KNI_ThrowNew(midpIOException, gKNIBuffer); } } REPORT_INFO1(LC_PROTOCOL, "socket::available0 bytesAvailable=%d\n", bytesAvailable); KNI_ReturnInt((jint)bytesAvailable); }
/** * Post native advanced multimedia event to Java event handler * * @param type Event type * @param processorId Processor ID that came from javacall_media_processor_create * @param data Data for this event type */ void javanotify_on_amms_notification(javacall_amms_notification_type type, javacall_int64 processorId, void *data) { midp_jc_event_union e; e.eventType = MIDP_JC_EVENT_ADVANCED_MULTIMEDIA; e.data.multimediaEvent.mediaType = type; e.data.multimediaEvent.isolateId = (int)((processorId >> 32) & 0xFFFF); e.data.multimediaEvent.playerId = (int)(processorId & 0xFFFF); e.data.multimediaEvent.data = (int) data; REPORT_INFO1(LC_NONE, "[javanotify_on_amms_notification] type=%d\n", type); midp_jc_event_send(&e); }