Example #1
0
int dequeueEventMessage(unsigned char* data,int dataLen)
{
    EventMessage* root;
    if (head==NULL) {
        return 0;
    }
    dataLen=min(dataLen, head->dataLen);
    memcpy(data, head->data, dataLen);
    root=head->next;
    javacall_free(head->data);
    javacall_free(head);
    head=root;

    return dataLen;
}
    /**
     * The function javacall_lcd_finalize is called by during Java VM shutdown,
     * allowing the  * platform to perform device specific lcd-related shutdown
     * operations.
     * The VM guarantees not to call other lcd functions before calling
     * javacall_lcd_init( ) again.
     *
     * @retval JAVACALL_OK      success
     * @retval JAVACALL_FAIL    fail
     */
    javacall_result javacall_lcd_finalize(void) {
        if (VRAM.hdc != NULL) {
            VRAM.height = 0;
            VRAM.width = 0;
            javacall_free(VRAM.hdc);
            VRAM.hdc = NULL;
        }

        return JAVACALL_OK;
    }
Example #3
0
/**
 * Destroys the event queue lock.
 *
 * @return <tt>JAVACALL_OK</tt> if successully destroyed lock
 *         <tt>JAVACALL_FAIL</tt> or negative value otherwise
 */
javacall_result javacall_destroy_event_queue_lock(void){
    /* Clean up thread local data */
    void* ptr = (void*) TlsGetValue(specialId);

    if (ptr != NULL) {
        /* Must free TLS data before freeing the TLS (special) ID */
        javacall_free(ptr);
        TlsFree(specialId);
        return JAVACALL_OK;
    }
    else {
        return JAVACALL_FAIL;
    }
}
javacall_result 
    javacall_media_processor_destroy(
        javacall_media_processor_handle media_processor_handle)
{
    if (media_processor_handle == NULL)
        return JAVACALL_INVALID_ARGUMENT;

    {
        javacall_amms_media_processor_s* pMP = 
            (javacall_amms_media_processor_s*)media_processor_handle;
        javacall_result res = javacall_media_processor_reset(pMP);
        DeleteCriticalSection(&pMP->csHandle);
        javacall_free(pMP);
        return res;
    }
}
void permissions_dealloc(void* array) {
    javacall_free(array);
}
/*
 * 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");
}
INT_PTR CALLBACK
ProgressDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    javacall_result res = JAVACALL_FAIL;

    switch (uMsg) {

    case WM_COMMAND: {
        WORD wCmd = LOWORD(wParam);

        switch (wCmd) {

        case IDCANCEL: {
            CloseInstallerDlg(hwndDlg);
            break;
        }

        default: {
            return FALSE;
        }

        } // end of switch (wCmd)

        return TRUE;
    }

    case WM_JAVA_AMS_INSTALL_ASK: {
        javacall_ams_install_data resultData, *pRequestData;
        javacall_ams_install_request_code requestCode;
        javacall_ams_install_state* pInstallState;
        InstallRequestData* pRqData;
        int nRes;
        LPTSTR pszText = NULL;

        requestCode = (javacall_ams_install_request_code)wParam;
        pRqData = (InstallRequestData*)lParam;

        if (pRqData == NULL) {
            // should not happen
            resultData.fAnswer = JAVACALL_FALSE;
            break;
        }

        pInstallState = &pRqData->installState;
        pRequestData  = &pRqData->requestData;

        for (int i = 0; i < INSTALL_REQUEST_NUM; i++) {
            if (g_szInstallRequestText[i][0]  == (LONG)requestCode) {
                pszText = (LPTSTR)g_szInstallRequestText[i][1];
                break;
            }
        }

        if (pszText) {
            TCHAR szBuf[256];
            if (requestCode == JAVACALL_INSTALL_REQUEST_WARNING &&
                    pInstallState != NULL) {
                javacall_ams_install_exception_code reason =
                    pInstallState->exceptionCode;

                if ((reason == JAVACALL_INSTALL_EXC_OLD_VERSION) ||
                        (reason == JAVACALL_INSTALL_EXC_ALREADY_INSTALLED) ||
                            (reason == JAVACALL_INSTALL_EXC_NEW_VERSION)) {
                    // if this is an update, add some additional information
                    // to the message
                    wsprintf(szBuf, 
                             _T("%s\nMIDlet suite is already installed!\n")
                             _T("Overwrite it?"), pszText);
                    pszText = szBuf;
                }
            }

            nRes = MessageBox(hwndDlg, pszText, g_szTitle,
                              MB_ICONQUESTION | MB_YESNO);

            resultData.fAnswer = (nRes == IDYES) ?
                JAVACALL_TRUE : JAVACALL_FALSE;
        } else {
            MessageBox(hwndDlg,
                       _T("Unknown confirmation has been requested!"),
                       g_szTitle, NULL);
            resultData.fAnswer = JAVACALL_TRUE;
        }

        res = javanotify_ams_install_answer(requestCode, pInstallState,
                                            &resultData);

        if (res != JAVACALL_OK) {
            wprintf(_T("ERROR: java_amsnotify_install_answer() ")
                    _T("returned %d\n"), (int)res);
        }

        javacall_free(pRqData);

        break;
    }

    case WM_JAVA_AMS_INSTALL_STATUS: {
       static nDownloaded = 0;

       HWND hOperProgress, hTotalProgress, hEditInfo;
       WORD wCurProgress, wTotalProgress;
       javacall_ams_install_status status;
       TCHAR szBuf[256];
       LPTSTR pszInfo;

       hOperProgress = GetDlgItem(hwndDlg, IDC_PROGRESS_OPERATION);

       if (hOperProgress != NULL) {
           wCurProgress = LOWORD(wParam);

            // Validate progress values
           if (wCurProgress < 0) {
               wCurProgress = 0;
           } else if (wCurProgress > 100) {
              wCurProgress = 100;
           }
       
           SendMessage(hOperProgress, PBM_SETPOS, (WPARAM)wCurProgress, 0);
       }

       hTotalProgress = GetDlgItem(hwndDlg, IDC_PROGRESS_TOTAL);

       if (hTotalProgress != NULL) {
           wTotalProgress = HIWORD(wParam);

           if (wTotalProgress < 0) {
              wTotalProgress = 0;
           } else if (wTotalProgress > 100) {
              wTotalProgress = 100;
           }

           SendMessage(hTotalProgress, PBM_SETPOS, (WPARAM)wTotalProgress, 0);
       }

       hEditInfo = GetDlgItem(hwndDlg, IDC_EDIT_INFO);

       if (hEditInfo) {
           status = (javacall_ams_install_status)lParam;

           switch (status) {

           case JAVACALL_INSTALL_STATUS_DOWNLOADING_JAD:
           case JAVACALL_INSTALL_STATUS_DOWNLOADING_JAR: {
               nDownloaded = 0;

               pszInfo = (status == JAVACALL_INSTALL_STATUS_DOWNLOADING_JAD) ?
                   _T("JAD") : _T("JAR");
               wsprintf(szBuf, _T("Downloading of the %s is started"), pszInfo);
               break;
           }

           case JAVACALL_INSTALL_STATUS_DOWNLOADED_1K_OF_JAD:
           case JAVACALL_INSTALL_STATUS_DOWNLOADED_1K_OF_JAR: {
               nDownloaded++;

               pszInfo = 
                   (status == JAVACALL_INSTALL_STATUS_DOWNLOADED_1K_OF_JAD) ?
                   _T("JAD") : _T("JAR");
               wsprintf(szBuf, _T("%dK of %s downloaded"), nDownloaded, pszInfo);
               break;
           }

           case JAVACALL_INSTALL_STATUS_VERIFYING_SUITE: {
               wsprintf(szBuf, _T("Verifing the suite..."));
               break;
           }

           case JAVACALL_INSTALL_STATUS_GENERATING_APP_IMAGE: {
               wsprintf(szBuf, _T("Generating application image..."));
               break;
           }

           case JAVACALL_INSTALL_STATUS_VERIFYING_SUITE_CLASSES: {
               wsprintf(szBuf, _T("Verifing classes of the suite..."));
               break;
           }

           case JAVACALL_INSTALL_STATUS_STORING_SUITE: {
               wsprintf(szBuf, _T("Storing the suite..."));
               break;
           }

           default: {
               // Show no text if status is unknown
               wsprintf(szBuf, _T(""));
               break;
           }

           } // end of switch (installStatus)

            SendMessage(hEditInfo, WM_SETTEXT, 0, (LPARAM)szBuf);
       }

       break;
    }

    case WM_JAVA_AMS_INSTALL_FINISHED: {
       TCHAR szBuf[256];
       javacall_ams_install_data* pResult = (javacall_ams_install_data*)lParam;

       // update progress bars: 100% completed
       HWND hOperProgress = GetDlgItem(hwndDlg, IDC_PROGRESS_OPERATION);
       if (hOperProgress != NULL) {
           SendMessage(hOperProgress, PBM_SETPOS, 100, 0);
       }

       HWND hTotalProgress = GetDlgItem(hwndDlg, IDC_PROGRESS_TOTAL);
       if (hTotalProgress != NULL) {
           SendMessage(hTotalProgress, PBM_SETPOS, 100, 0);
       }

       if (pResult != NULL) {
           if ((pResult->installStatus == JAVACALL_INSTALL_STATUS_COMPLETED) &&
               (pResult->installResultCode == JAVACALL_INSTALL_EXC_ALL_OK)) {

               MessageBox(hwndDlg, _T("Installation completed!"), g_szTitle,
                          MB_ICONINFORMATION | MB_OK);
         
               PostMessage(GetParent(hwndDlg), WM_NOTIFY_SUITE_INSTALLED, 0, 0);
           } else {
               wsprintf(szBuf,
                        _T("Installation failed!\n\n Error status %d, code %d"),
                        pResult->installStatus, pResult->installResultCode);
               MessageBox(hwndDlg, szBuf, g_szTitle, MB_ICONERROR | MB_OK);
           }

           // Free memory alloced by us in javacall_ams_operation_completed
           javacall_free(pResult);
       } else {
           MessageBox(hwndDlg, _T("Installation failed! Reason unknown."),
                      g_szTitle, MB_ICONERROR | MB_OK);
       }

       CloseInstallerDlg(hwndDlg);

       break;
    }

    default: {
        return FALSE;
    }

    } // end of switch (uMsg)

    return TRUE;
}