Example #1
0
/**
 * Initializes the UI.
 *
 * @return <tt>0</tt> upon successful initialization, otherwise
 *         <tt>-1</tt>
 */
static int
midpInitializeUI(void) {
    /*
    if (InitializeEvents() != 0) {
        return -1;
    }
    */

    /*
     * Porting consideration:
     * Here is a good place to put I18N init.
     * function. e.g. initLocaleMethod();
     */

    /*
     * Set AMS memory limits
     */
#if ENABLE_MULTIPLE_ISOLATES
    {
        int reserved = AMS_MEMORY_RESERVED_MVM;
        int limit = AMS_MEMORY_LIMIT_MVM;

        reserved = reserved * 1024;
        JVM_SetConfig(JVM_CONFIG_FIRST_ISOLATE_RESERVED_MEMORY, reserved);

        if (limit <= 0) {
            limit = 0x7FFFFFFF;  /* MAX_INT */
        } else {
            limit = limit * 1024;
        }
        JVM_SetConfig(JVM_CONFIG_FIRST_ISOLATE_TOTAL_MEMORY, limit);
    }
#endif

#if ENABLE_JAVA_DEBUGGER
    {
        char* argv[2];

        /* Get the VM debugger port property. */
        argv[1] = (char *)getInternalProp("VmDebuggerPort");
        if (argv[1] != NULL) {
            argv[0] = "-port";
            (void)JVM_ParseOneArg(2, argv);
        }
    }
#endif

    /* 
        IMPL_NOTE if (pushopen() != 0) {
            return -1;
        }
    */

    lcdlf_ui_init();
    return 0;
}
Example #2
0
/**
 * Gets the value of the specified property key in the internal
 * property set. If the key is not found in the internal property
 * set, the application property set is then searched. If neither
 * search finds the specified key, a default value is returned.
 *
 * @param key The key to search for
 * @param def The default value to return if <tt>key<tt> is not found.
 *
 * @return The value associated with <tt>key<tt> if found, otherwise
 *         <tt>def<tt>
 */
const char*
getInternalPropDefault(const char* key, const char* defValue) {
    const char* value;

    value = getInternalProp(key);
    if (NULL == value) {
        return defValue;
    } else {
        return value;
    }
}
/**
 * Starts a new process to handle the given URL. The new process executes
 * the value of the <tt>com.sun.midp.midlet.platformRequestCommand</tt>
 * system property. The URL is passed as this process' sole command-line
 * argument.
 *
 * @param pszUrl The 'C' string URL
 *
 * @return true if the platform request is configured
 */
int platformRequest(char* pszUrl) {
    (void)pszUrl;
#if 0
    char *execargs[3];
    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    if (strlen(pszUrl) == 0) {
        /*
         * This is a request to cancel. Since a process was already spawned
         * to handle the previous URL, it too late.
         */
        return 1;
    }

    execargs[0] = (char *)getInternalProp(PLATFORM_REQUEST_KEY);
    if (execargs[0] == NULL) {
        REPORT_WARN(LC_AMS, "PlatformRequest is not configured.");
	return 0;
    }

    execargs[1] = pszUrl;
    /* leave room for a space and zero terminator */
    execargs[2] = (char*)midpMalloc(strlen(execargs[0]) +
                     strlen(execargs[1]) + 2);
    if (execargs[2] == NULL) {
        REPORT_WARN(LC_AMS, "PlatformRequest ran out of memory.");
	return 0;
    }

    strcpy(execargs[2], execargs[0]);
    strcat(execargs[2], " ");
    strcat(execargs[2], execargs[1]);

    memset(&si, 0, sizeof(si));
    si.cb = sizeof(si);

    // spawn the request using the configured URL handler and URL parameter
    /*
     * do not inherit handles
     */
    if (CreateProcess(NULL, execargs[2], NULL, NULL, FALSE, 0,
	NULL, NULL, &si, &pi)) {
        CloseHandle(pi.hProcess);
	CloseHandle(pi.hThread);
    } else {
        REPORT_WARN(LC_AMS, "Spawning a handler process failed. Check the platformRequest configuration. ");
    }

    midpFree(execargs[2]);
#endif
    return 1;
}
Example #4
0
/**
 * Initializes the device.
 * <p>Java declaration:
 * <pre>
 * private native static int init0() throws IOException;
 * </pre>
 * @return number of supported slots 
 * @exception CardDeviceException If configuration failed.
 * @exception IOException in case of I/O problems.
 */
KNIEXPORT KNI_RETURNTYPE_INT 
Java_com_sun_midp_io_j2me_apdu_APDUManager_init0() {
    jint retcode;
    JSR177_STATUSCODE status;
    char *err_msg;
    const char *prop_value;

    prop_value = getInternalProp(hostsandports);
    if (prop_value != NULL) {
        status = jsr177_set_property((jbyte*)hostsandports, (jbyte*)prop_value);
        if (status == JSR177_STATUSCODE_NOT_IMPLEMENTED) {
            if (jsr177_get_error((jbyte*)gKNIBuffer, KNI_BUFFER_SIZE)) {
                err_msg = gKNIBuffer;
            } else {
                err_msg = "Required property not supported";
            }
            KNI_ThrowNew(midpCardDeviceException, err_msg);
            goto end;
        }
        if (status == JSR177_STATUSCODE_OUT_OF_MEMORY) {
            if (jsr177_get_error((jbyte*)gKNIBuffer, KNI_BUFFER_SIZE)) {
                err_msg = gKNIBuffer;
            } else {
                err_msg = "init0()";
            }
            KNI_ThrowNew(midpOutOfMemoryError, err_msg);
            goto end;
        }
        if (status != JSR177_STATUSCODE_OK) {
            if (jsr177_get_error((jbyte*)gKNIBuffer, KNI_BUFFER_SIZE)) {
                err_msg = gKNIBuffer;
            } else {
                err_msg = "Invalid 'hostsandports' property";
            }
            KNI_ThrowNew(midpCardDeviceException, err_msg);
            goto end;
        }
    }
    status = jsr177_init();
    if (status == JSR177_STATUSCODE_NOT_IMPLEMENTED) {
        
        /* We throw special exception to tell i3tests to skip real testing */
        KNI_ThrowNew(midpCardDeviceException, "stub");
        goto end;
    }
    if (status != JSR177_STATUSCODE_OK) {
    err:
        if (jsr177_get_error((jbyte*)gKNIBuffer, KNI_BUFFER_SIZE)) {
            err_msg = gKNIBuffer;
        } else {
            err_msg = "init0()";
        }
        KNI_ThrowNew(midpIOException, err_msg);
        goto end;
    }
    if (jsr177_get_slot_count(&retcode) != JSR177_STATUSCODE_OK ||
            retcode < 0) {
        goto err;
    }
    
end:
    KNI_ReturnInt(retcode);
}