Ejemplo n.º 1
0
/**
 * Force Bluetooth stack to listen for incoming client connections.
 *
 * Note: the method gets native connection handle directly from
 * <code>handle<code> field of <code>BTSPPNotifierImpl</code> object.
 *
 * @throws IOException if an I/O error occurs
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_midp_io_j2me_btspp_BTSPPNotifierImpl_listen0(void) {

    bt_handle_t handle = BT_INVALID_HANDLE;

    REPORT_INFO(LC_PROTOCOL, "btspp_notif::listen");

    KNI_StartHandles(1);
    KNI_DeclareHandle(thisHandle);
    KNI_GetThisPointer(thisHandle);
    if (KNI_GetIntField(thisHandle, pushHandleID) == BT_INVALID_PUSH_HANDLE) {
        handle = (bt_handle_t)KNI_GetIntField(thisHandle, notifHandleID);

        /* force listening */
        if (bt_rfcomm_listen(handle) == BT_RESULT_FAILURE) {
            bt_rfcomm_close(handle);
            REPORT_ERROR(LC_PROTOCOL,
                "RFCOMM notifier listen failed in btspp_notif::listen");
            KNI_ThrowNew(midpIOException,
                EXCEPTION_MSG("RFCOMM notifier listen failed"));
        } else {
            REPORT_INFO(LC_PROTOCOL, "btspp_notif::listen done!");
        }
    }
    KNI_EndHandles();
    KNI_ReturnVoid();
}
Ejemplo n.º 2
0
/**
 * private static native void getLinks0(Link[] linkarray);
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_midp_links_LinkPortal_getLinks0(void)
{
    int targetIsolate;
    jsize len;
    int i;
    KNI_StartHandles(2);
    KNI_DeclareHandle(linkArray);
    KNI_DeclareHandle(linkObj);

    targetIsolate = JVM_CurrentIsolateID();
    KNI_GetParameterAsObject(1, linkArray);
    len = KNI_GetArrayLength(linkArray);

    if (portals != NULL) {
        if (portals[targetIsolate].count > 0) {
            rendezvous **rpp = portals[targetIsolate].rppa;
            for (i = 0; i < len; i++) {
                KNI_GetObjectArrayElement(linkArray, i, linkObj);
                setNativePointer(linkObj, rpp[i]);
                rp_incref(rpp[i]);
            }
        }
        portal_free(&portals[targetIsolate]);
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
Ejemplo n.º 3
0
/**
 * Native method void removeAllComponents(int suiteId) of
 * com.sun.midp.midletsuite.DynamicComponentStorage.
 * <p>
 * Removes all dynamic components belonging to the given suite.
 * <p>
 * If any component is in use, no components are removed, and
 * an exception is thrown.
 *
 * @param suiteId ID of the suite whose components must be removed
 *
 * @throws IllegalArgumentException if there is no suite with
 *                                  the specified ID
 * @throws MIDletSuiteLockedException is thrown, if any component is
 *                                    locked
 */
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(com_sun_midp_midletsuite_DynamicComponentStorage_removeAllComponents) {
    MIDPError status;
    SuiteIdType suiteId = KNI_GetParameterAsInt(1);

    do {
        status = begin_transaction(TRANSACTION_REMOVE_ALL_COMPONENTS,
                                   suiteId, NULL);
        if (status != ALL_OK) {
            break;
        }

        status = delete_components_files(suiteId, UNUSED_COMPONENT_ID);
        if (status != ALL_OK) {
            break;
        }
        
        (void)remove_from_component_list_and_save(suiteId, UNUSED_COMPONENT_ID);
    } while(0);

    (void)finish_transaction();

    if (status == SUITE_LOCKED) {
        KNI_ThrowNew(midletsuiteLocked, NULL);
    } else if (status == BAD_PARAMS) {
        KNI_ThrowNew(midpIllegalArgumentException, "bad component ID");
    } else if (status != ALL_OK) {
        KNI_ThrowNew(midpRuntimeException,
            (status == OUT_OF_MEMORY) ? "Remove failed" : "Out of memory!");
    }

    KNI_ReturnVoid();
}
Ejemplo n.º 4
0
/**
 * public native void close();
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_midp_links_Link_close(void)
{
    rendezvous *rp;
    KNI_StartHandles(1);
    KNI_DeclareHandle(thisObj);

    KNI_GetThisPointer(thisObj);
    rp = getNativePointer(thisObj);

    /* ignore if closed twice */
    if (rp != NULL) {
        if (rp->sender == JVM_CurrentIsolateID()
                && rp->msg != INVALID_REFERENCE_ID) {
            /* we're the sender, make sure to clean out our message */
            SNI_DeleteReference(rp->msg);
            rp->msg = INVALID_REFERENCE_ID;
        }

        rp->state = CLOSED;
        midp_thread_signal(LINK_READY_SIGNAL, (int)rp, 0);
        setNativePointer(thisObj, NULL);
        rp_decref(rp);
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
Ejemplo n.º 5
0
/**
 * KNI function that makes native form visible.
 * Java Prototype: void showNativeResource0(int nativeId,
 * 					   int modelVersion,
 *                                         int w, int h) 
 * CLASS:         javax.microedition.lcdui.FormLFImpl
 * Param: nativeId Id of previously created Form native resource
 * Param: modelVersion version id of the data passed in from Java
 * Param: w width of all form content
 * Param: h height of all form content
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_lcdui_FormLFImpl_showNativeResource0() {
    int w, h;
    MidpError err;
    MidpDisplayable *formPtr = (MidpDisplayable *)KNI_GetParameterAsInt(1);
    
    /* Initialize data model version for this new visible period */
    formPtr->frame.component.modelVersion = KNI_GetParameterAsInt(2);
    w = KNI_GetParameterAsInt(3);
    h = KNI_GetParameterAsInt(4);

    /* Set form window virtual size */
    err = lfpport_form_set_content_size(formPtr, w, h);
    if (err != KNI_OK) goto cleanup;

    if (MidpCurrentScreen != &formPtr->frame) {
	/* Becomes the new current screen that receives events */
	MidpCurrentScreen = &formPtr->frame;
    
	/*
	 * NOTE: MidpCurrentScreen is needed before it is shown because
	 * on show its children may want to notify their appearance.
	 */

	/* Show Form window */
	err = formPtr->frame.show(&formPtr->frame);
    }

cleanup:
    if (err != KNI_OK) {
	KNI_ThrowNew(midpOutOfMemoryError, NULL);
    }

    KNI_ReturnVoid();
}
Ejemplo n.º 6
0
/**
 * Reports a fatal error that cannot be handled in Java.
 * Must be called from a KNI method
 *
 */
void handleFatalError(void) {
    KNI_StartHandles(1);
    KNI_DeclareHandle(throwableObj);
    KNI_GetParameterAsObject(1, throwableObj);

    /* IMPL NOTE: Figure out what throwable class this is and log the error? */
    REPORT_CRIT1(LC_CORE, "handleFatalError: uncaught exception in "
        "isolate %d event processing thread", getCurrentIsolateId());
    
    KNI_EndHandles();

    if (getCurrentIsolateId() == midpGetAmsIsolateId()) {
        /* AMS isolate or SVM mode, terminate VM */
        midp_exitVM(-1);
    } else {
        MidpEvent event;

        /* Application isolate, notify the AMS isolate. */
        MIDP_EVENT_INITIALIZE(event);
        event.type = FATAL_ERROR_NOTIFICATION;
        event.intParam1 = getCurrentIsolateId();

        /* Send the shutdown event. */
        StoreMIDPEventInVmThread(event, midpGetAmsIsolateId());
    }

    KNI_ReturnVoid();
}
Ejemplo n.º 7
0
/**
 * The function blocks the calling thread if Transaction Store is locked.
 * <p>Java declaration:
 * <pre>
 * private native void lockStore();
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_j2me_payment_TransactionStorageImpl_lockStore() {
    MidpReentryData *info = NULL;

    KNI_StartHandles(1);
    KNI_DeclareHandle(thisObject);
    KNI_GetThisPointer(thisObject);

    if (locked == KNI_FALSE) {
        locked = KNI_TRUE;
        KNI_GetThisPointer(thisObject);
        getStorageOpenFlag(thisObject)->isOpen = (jboolean)KNI_TRUE;
    } else {
        info = (MidpReentryData*)SNI_GetReentryData(NULL);
        if (info == NULL) {
            info = (MidpReentryData*)
                (SNI_AllocateReentryData(sizeof (MidpReentryData)));
        }
        info->waitingFor = PAYMENT_TRANSACTION_STORE_SIGNAL;
        info->descriptor = 0;
        info->status = KNI_FALSE;
        info->pResult = NULL;

        /* try again later */
        SNI_BlockThread();
    }
    KNI_EndHandles();
    KNI_ReturnVoid();
}
Ejemplo n.º 8
0
/**
 * Native finalizer to reset the native peer event queue when
 * the Isolate ends.
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_midp_events_EventQueue_finalize(void) {
   jint queueId;
   EventQueue* pEventQueue;

   KNI_StartHandles(1);
   KNI_DeclareHandle(thisObject);
   KNI_GetThisPointer(thisObject);

   SNI_BEGIN_RAW_POINTERS;
   queueId = getEventQueuePtr(thisObject)->queueId;
   SNI_END_RAW_POINTERS;

   KNI_EndHandles();

   if (queueId >= 0) {
       resetEventQueue(queueId);

       /* Mark queue as inactive */
       GET_EVENT_QUEUE_BY_ID(pEventQueue, queueId);
       pEventQueue->isActive = KNI_FALSE;
   }

   KNI_ReturnVoid();
}
Ejemplo n.º 9
0
/**
* Native method void init() of
* com.sun.midp.jsr229.Initializer.
* <p>
* Do the basic initialization of the JSR229.
* Registers a callback on a midlet suite removal.
*/
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_midp_jsr229_Initializer_init() {
    (void) midp_suite_add_listener(jsr229_remove_listener,
                                   SUITESTORE_LISTENER_TYPE_REMOVE,
                                   SUITESTORE_OPERATION_START);
    KNI_ReturnVoid();
}
Ejemplo n.º 10
0
/**
 * 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.
 * Native implementation of Java function:
 * private static native int setContentBuffer0 ( int nativeId, Image img );
 * @param nativeId native resource is for this CustomItem
 * @param img mutable image that serves as an offscreen buffer
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_lcdui_CustomItemLFImpl_setContentBuffer0() {

  MidpError err = KNI_OK;
  unsigned char* imgPtr = NULL;
  MidpItem *ciPtr = (MidpItem *)KNI_GetParameterAsInt(1);

  KNI_StartHandles(1);
  KNI_DeclareHandle(image);

  KNI_GetParameterAsObject(2, image);
  
  if (KNI_IsNullHandle(image) != KNI_TRUE) {
    imgPtr = gxp_get_imagedata(image);
  }

  KNI_EndHandles();

  err = lfpport_customitem_set_content_buffer(ciPtr, imgPtr);
  
  if (err != KNI_OK) {
    KNI_ThrowNew(midpOutOfMemoryError, NULL);
  }
  
  KNI_ReturnVoid();
}
Ejemplo n.º 11
0
/**
 * KNI function that sets new content on the native resource corresponding to
 * the current StringItem.
 *
 * Class: javax.microedition.lcdui.StringLFImpl
 * Java prototype:
 * private native int setContent0(int nativeId, Image image, altText,
 *                                appearanceMode)
 *
 * INTERFACE (operand stack manipulation):
 *   parameters:  nativeId pointer to the native resource of the StringItem
 *                text     the new string set in the StringItem
 *                appearanceMode the appearance mode of the passed in text
 *   returns:     <nothing>
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_lcdui_StringItemLFImpl_setContent0() {
    MidpError err = KNI_OK;
    MidpItem *itemPtr = (MidpItem *)KNI_GetParameterAsInt(1);
    int appearanceMode = KNI_GetParameterAsInt(3);
    pcsl_string text;
    pcsl_string_status rc;

    KNI_StartHandles(1);
    KNI_DeclareHandle(textJString);

    KNI_GetParameterAsObject(2, textJString);

    rc = midp_kjstring_to_pcsl_string(textJString, &text);

    KNI_EndHandles();

    if (PCSL_STRING_OK != rc) {
        err = KNI_ENOMEM;
    } else {
        err = lfpport_stringitem_set_content(itemPtr, &text, appearanceMode);
    }

    pcsl_string_free(&text);

    if (err == KNI_ENOMEM) {
        KNI_ThrowNew(midpOutOfMemoryError, NULL);
    }

    KNI_ReturnVoid();
}
/**
 * Releases any native resources used by this immutable <tt>ImageData</tt>.
 * <p>
 * Java declaration:
 * <pre>
 *     finalize()V
 * </pre>
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_lcdui_ImageData_finalize() {
    java_imagedata * imageDataPtr = NULL;
    gxpport_image_native_handle h;

    KNI_StartHandles(1);
    KNI_DeclareHandle(thisObject);
    KNI_GetThisPointer(thisObject);

    imageDataPtr = IMGAPI_GET_IMAGEDATA_PTR(thisObject);

    /*
     * Image objects with NULL nativeImageData could exist when loading
     * romized image but failed.
     */
    h = (gxpport_image_native_handle)imageDataPtr->nativeImageData;
    if (h != NULL) {
        if (imageDataPtr->isMutable) {
            gxpport_destroy_mutable(h);
        } else {
            gxpport_destroy_immutable(h);
        }
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
Ejemplo n.º 13
0
/**
 * Sets the requested socket option.
 * <p>
 * Java declaration:
 * <pre>
 *     setSockOpt(II)V
 * </pre>
 *
 * @param option socket option to set
 * @param value the value to set <tt>option</tt> to
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_midp_io_j2me_socket_Protocol_setSockOpt0(void) {
    int option;
    int value;
    void *pcslHandle;
    int status = PCSL_NET_INVALID;
    
    value  = (int)KNI_GetParameterAsInt(2);
    option = (int)KNI_GetParameterAsInt(1);

    KNI_StartHandles(1);
    KNI_DeclareHandle(thisObject);
    KNI_GetThisPointer(thisObject);

    pcslHandle = (void *)(getMidpSocketProtocolPtr(thisObject)->handle);

    KNI_EndHandles();

    if (INVALID_HANDLE == pcslHandle) {
        KNI_ThrowNew(midpIOException, 
                     "invalid handle during socket::getPort");
    } else {
        status = pcsl_network_setsockopt(pcslHandle, option, value);
        if (status == PCSL_NET_IOERROR) {
            KNI_ThrowNew(midpIllegalArgumentException, "Unsupported Socket Option");
        } else if (PCSL_NET_INVALID == status) {
            KNI_ThrowNew(midpIllegalArgumentException, "Illegal Socket Option Value");
        }
    }

    KNI_ReturnVoid();
}
/**
 * Initializes the native peer of this <tt>Font</tt>.
 * <p>
 * Java declaration:
 * <pre>
 *     init(III)V
 * </pre>
 *
 * @param face The face of the font to initialize
 * @param style The style of the font to initialize
 * @param size The point size of the font to initialize
 */
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(javax_microedition_lcdui_Font_init) {
    jboolean free_size = KNI_GetParameterAsBoolean(4);
    int size  = (int)KNI_GetParameterAsInt(3);
    int style = (int)KNI_GetParameterAsInt(2);
    int face  = (int)KNI_GetParameterAsInt(1);
    int ascent, descent, leading;

    KNI_StartHandles(1);
    KNI_DeclareHandle(thisObject);

    if (free_size == KNI_FALSE) {
        /* size is one of the SIZE_XXX constants */
        size = OEM_FONT_SIZE(size);
    }

    KNI_GetParameterAsObject(0, thisObject);

    gx_get_fontinfo(face, style, size, &ascent, &descent, &leading);

    SNI_BEGIN_RAW_POINTERS;

    GET_FONT_PTR(thisObject)->baseline = (jint)ascent;
    GET_FONT_PTR(thisObject)->height = (jint)(ascent + descent + leading);
    GET_FONT_PTR(thisObject)->size = (jint)size;
    GET_FONT_PTR(thisObject)->sizeRounded = (jint) LCDUI_FONT_SIZE(size);

    SNI_END_RAW_POINTERS;

    KNI_EndHandles();
    KNI_ReturnVoid();
}
Ejemplo n.º 15
0
/**
 * private native void init0(int sender, int receiver);
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_midp_links_Link_init0(void)
{
    int sender;
    int receiver;
    rendezvous *rp;

    KNI_StartHandles(1);
    KNI_DeclareHandle(thisObj);

    sender = KNI_GetParameterAsInt(1);
    receiver = KNI_GetParameterAsInt(2);
    KNI_GetThisPointer(thisObj);

    rp = rp_create(sender, receiver);
    if (rp == NULL) {
        KNI_ThrowNew(midpOutOfMemoryError, NULL);
    } else {
        setNativePointer(thisObj, rp);
        rp_incref(rp);
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
Ejemplo n.º 16
0
/**
 * Mark of the existing Invocations for a content handler
 * by suiteId and classname so they can be cleaned up on
 * exit.
 *
 * @param suiteId to match a pending invocation
 * @param classname to match a pending invocation
 * @see StoredInvoc
 * @see #invocQueue
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_midp_content_InvocationStore_setCleanup0(void) {
    StoredLink* link;
    StoredInvoc* invoc;
    SuiteIdType desiredSuiteId;
    pcsl_string desiredClassname = PCSL_STRING_NULL_INITIALIZER;
    jboolean cleanup;

    KNI_StartHandles(1);
    KNI_DeclareHandle(classname); /* Arg2: non-null classname */

    /* Argument indices must match Java native method declaration */
#define markSuiteIdArg 1
#define markClassnameArg 2
#define markCleanup 3

    do {/* Block to break out of on exceptions */

    if (!isEmpty()) {
        /* Queue is not empty
         * Need a string copy of the desired classname
         * to use for comparisons
         */
        desiredSuiteId = KNI_GetParameterAsInt(markSuiteIdArg);

        KNI_GetParameterAsObject(markClassnameArg, classname);
        if (PCSL_STRING_OK != midp_jstring_to_pcsl_string(classname, 
                           &desiredClassname)) {
            KNI_ThrowNew(midpOutOfMemoryError, 
          "InvocationStore_setListenCleanup0 no memory for [desiredClassname]");
            break;
        }

        cleanup = KNI_GetParameterAsInt(markCleanup);

        /* Inspect the queue of Invocations and pick one that
         * matches the suiteId and classname.
         */
        for (link = invocQueue; link != NULL; link = link->flink) {
            invoc = link->invoc;
            /*
             * If the suite matches and the classname matches
             * set cleanup to the next tid;
             */
            if (desiredSuiteId == invoc->suiteId &&
                pcsl_string_equals(&desiredClassname, &invoc->classname)) {
                /* Found an entry for the Invocation */
                invoc->cleanup = cleanup;
                invoc->notified = KNI_FALSE;
            }
        }
    }
    } while (0);
    
    pcsl_string_free(&desiredClassname);

    KNI_EndHandles();
    KNI_ReturnVoid();
}
Ejemplo n.º 17
0
Archivo: emul.c Proyecto: sfsy1989/j2me
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_midp_jsr82emul_DeviceEmul_inquiryCompleted() {
    jboolean success = (int)KNI_GetParameterAsBoolean(1);
    LOG("DeviceEmul_inquiryCompleteted()");
    
    javanotify_bt_inquiry_complete(success ? JAVACALL_TRUE : JAVACALL_FALSE);
    KNI_ReturnVoid();
}
Ejemplo n.º 18
0
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(com_sun_midp_midlet_MIDletPeer_dismissNativeEditors) {
    if (editBoxShown) {
        ShowWindow(hwndTextActive, SW_HIDE);
        editBoxShown = 0;
    }
    KNI_ReturnVoid();
}
Ejemplo n.º 19
0
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(com_sun_mmedia_DefaultConfiguration_nListProtocolsClose) {
    ListIterator *iterator;
    if ((iterator = (ListIterator *)KNI_GetParameterAsInt(1)) != NULL) {
        MMP_FREE(iterator);
    }
    KNI_ReturnVoid();
}
Ejemplo n.º 20
0
/**
 * Close a serial port.
 *
 * @param hPort handle to a native serial port
 *
 * @exception  IOException  if an I/O error occurs
 */
KNIEXPORT KNI_RETURNTYPE_VOID
    Java_com_sun_midp_io_j2me_comm_Protocol_native_1close() {

    int hPort = (int)KNI_GetParameterAsInt(1);

    closePort(hPort);
    KNI_ReturnVoid();
}
Ejemplo n.º 21
0
/*
 * Reads information about the installed midlet suite's component
 * from the storage.
 *
 * @param componentId unique ID of the component
 * @param ci ComponentInfo object to fill with the information about
 *           the midlet suite's component having the given ID
 *
 * @exception IOException if an the information cannot be read
 * @exception IllegalArgumentException if suiteId is invalid or ci is null
 */
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(
    com_sun_midp_midletsuite_DynamicComponentStorage_getComponentInfo) {
    ComponentIdType componentId = KNI_GetParameterAsInt(1);
    MIDPError status = ALL_OK;

    KNI_StartHandles(3);
    KNI_DeclareHandle(componentInfoObject);
    KNI_DeclareHandle(componentInfoClass);
    KNI_DeclareHandle(tmpHandle);

    KNI_GetParameterAsObject(2, componentInfoObject);
    KNI_GetObjectClass(componentInfoObject, componentInfoClass);

    do {
        char *pszError = NULL;
        MidletSuiteData *pData = NULL;

        /* Ensure that suite data are read */
        status = read_suites_data(&pszError);
        storageFreeError(pszError);
        if (status != ALL_OK) {
            break;
        }

        pData = get_component_data(componentId);
        if (!pData) {
            status = NOT_FOUND;
            break;
        }

        KNI_RESTORE_INT_FIELD(componentInfoObject, componentInfoClass,
                              "componentId", componentId);
        KNI_RESTORE_INT_FIELD(componentInfoObject, componentInfoClass,
                              "suiteId", pData->suiteId);
        KNI_RESTORE_PCSL_STRING_FIELD(componentInfoObject, componentInfoClass,
                                     "displayName",
                                      &(pData->varSuiteData.displayName),
                                      tmpHandle);
        KNI_RESTORE_PCSL_STRING_FIELD(componentInfoObject, componentInfoClass,
                                     "version",
                                      &(pData->varSuiteData.suiteVersion),
                                      tmpHandle);
        KNI_RESTORE_BOOLEAN_FIELD(componentInfoObject, componentInfoClass,
                                  "trusted", pData->isTrusted);
    } while (0);

    if (status != ALL_OK) {
        if (status == NOT_FOUND) {
            KNI_ThrowNew(midpIllegalArgumentException, "bad component ID");
        } else {
            KNI_ThrowNew(midpIOException, NULL);
        }
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
/* JAVADOC COMMENT ELIDED */
KNIEXPORT KNI_RETURNTYPE_VOID
    KNIDECL(com_sun_j2me_location_LocationPersistentStorage_closeLandmarkList) {
    
    jint hndl = KNI_GetParameterAsInt(1);

    javacall_landmarkstore_landmarklist_close((javacall_handle)hndl);

    KNI_ReturnVoid();
}
Ejemplo n.º 23
0
/*=========================================================================
 * FUNCTION:      nativetx([B[I[I[BII[BI)V (STATIC)
 * CLASS:         com/sun/midp/crypto/ARC4
 * TYPE:          static native function
 * OVERVIEW:      Transform the given buffer
 * INTERFACE (operand stack manipulation):
 *   parameters:  S      array of S box values
 *                X      first set intermediate results
 *                Y      second set of intermediate results
 *                inbuf  input buffer of data 
 *                inoff  offset in the provided input buffer
 *                inlen  length of data to be processed
 *                outbuf output buffer of data 
 *                outoff offset in the provided output buffer
 *   returns:     <nothing>
 *=======================================================================*/
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_midp_crypto_ARC4_nativetx() {
    unsigned int x;
    unsigned int y;
    unsigned int tx;
    unsigned int ty;
    long outoff;
    long len;
    long inoff;
    long temp;
    long i;

    outoff = KNI_GetParameterAsInt(8);
    len    = KNI_GetParameterAsInt(6);
    inoff  = KNI_GetParameterAsInt(5);

    KNI_StartHandles(5);

    KNI_DeclareHandle(outbuf);
    KNI_DeclareHandle(inbuf);
    KNI_DeclareHandle(Y);
    KNI_DeclareHandle(X);
    KNI_DeclareHandle(S);

    KNI_GetParameterAsObject(7, outbuf);
    KNI_GetParameterAsObject(4, inbuf);
    KNI_GetParameterAsObject(3, Y);
    KNI_GetParameterAsObject(2, X);
    KNI_GetParameterAsObject(1, S);

    /*copy in the counters*/
    KNI_GetRawArrayRegion(X, 0, 4, (jbyte*)&temp);
    x = temp;
    KNI_GetRawArrayRegion(Y, 0, 4, (jbyte*)&temp);
    y = temp;

    for (i = 0 ; i < len; i++) {
        x = (x + 1) & 0xff;
        y = (y + JavaByteArray(S)[x]) & 0xff;
        tx = JavaByteArray(S)[x];
        JavaByteArray(S)[x] = JavaByteArray(S)[y];
        JavaByteArray(S)[y] = tx;
        ty = (unsigned int)(JavaByteArray(S)[x] + 
                            JavaByteArray(S)[y]) & 0xff;
        JavaByteArray(outbuf)[i+outoff] = 
            JavaByteArray(S)[ty] ^ 
            JavaByteArray(inbuf)[i+inoff];
    }

    temp = x;
    KNI_SetRawArrayRegion(X, 0, 4, (jbyte*)&temp);
    temp = y;
    KNI_SetRawArrayRegion(Y, 0, 4, (jbyte*)&temp);

    KNI_EndHandles();
    KNI_ReturnVoid();
}
Ejemplo n.º 24
0
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(com_sun_midp_main_IndicatorManager_toggleHomeIcon0) {

    jboolean isHomeOn = KNI_GetParameterAsBoolean(1);

    anc_toggle_home_icon(isHomeOn);

    KNI_ReturnVoid();
}
Ejemplo n.º 25
0
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_midp_suspend_test_TestUtil_setVMSuspendMode() {
    REPORT_INFO(LC_LIFECYCLE, "TestUtil_setVMSuspendMode()");
    if (!vmSuspendMode) {
        vmSuspendMode = KNI_TRUE;
        sr_registerResource((void*)&vm, &suspend_vm, &resume_vm);
    }
    KNI_ReturnVoid();
}
Ejemplo n.º 26
0
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_midp_suspend_test_TestUtil_setNoVMSuspendMode() {
    REPORT_INFO(LC_LIFECYCLE, "TestUtil_setNoVMSuspendMode()");
    if (vmSuspendMode) {
        vmSuspendMode = KNI_FALSE;
        sr_unregisterResource((void*)&vm);
    }
    KNI_ReturnVoid();
}
Ejemplo n.º 27
0
/**
 * Deletes all push registry entries for the given MIDlet suite.
 * <p>
 * Java declaration:
 * <pre>
 *     delAllForSuite0(I)V
 * </pre>
 *
 * @param suiteID The MIDlet Suite ID.
 */
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(com_sun_midp_io_j2me_push_ConnectionRegistry_delAllForSuite0) {
    SuiteIdType suiteId;

    suiteId = KNI_GetParameterAsInt(1);
    pushdeletesuite(suiteId);

    KNI_ReturnVoid();
}
Ejemplo n.º 28
0
/**
 * Decodes the given byte array into the <tt>ImageData</tt>.
 * <p>
 * Java declaration:
 * <pre>
 *     loadJPG(Ljavax/microedition/lcdui/ImageData;[BII)V
 * </pre>
 *
 * @param imageData the ImageData to load to
 * @param imageBytes A byte array containing the encoded JPEG image data
 * @param imageOffset The start of the image data within the byte array
 * @param imageLength The length of the image data in the byte array
 */
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(javax_microedition_lcdui_ImageDataFactory_loadJPEG) {
    int            length = KNI_GetParameterAsInt(4);
    int            offset = KNI_GetParameterAsInt(3);
    unsigned char* srcBuffer = NULL;
    gxj_screen_buffer            image;
    java_imagedata * midpImageData = NULL;

    /* variable to hold error codes */
    gxutl_native_image_error_codes creationError = GXUTL_NATIVE_IMAGE_NO_ERROR;

    KNI_StartHandles(3);
    /* KNI_DeclareHandle(alphaData); */
    KNI_DeclareHandle(pixelData);
    KNI_DeclareHandle(jpegData);
    KNI_DeclareHandle(imageData);

    KNI_GetParameterAsObject(2, jpegData);
    KNI_GetParameterAsObject(1, imageData);

    midpImageData = GXAPI_GET_IMAGEDATA_PTR(imageData);

    /* assert
     * (KNI_IsNullHandle(jpegData))
     */

    srcBuffer = (unsigned char *)JavaByteArray(jpegData);
    /*
     * JAVA_TRACE("loadJPEG jpegData length=%d  %x\n",
     *            JavaByteArray(jpegData)->length, srcBuffer);
     */

    image.width = midpImageData->width;
    image.height = midpImageData->height;

    unhand(jbyte_array, pixelData) = midpImageData->pixelData;
    if (!KNI_IsNullHandle(pixelData)) {
        image.pixelData = (gxj_pixel_type *)JavaByteArray(pixelData);
        /*
         * JAVA_TRACE("loadJPEG pixelData length=%d\n",
         *            JavaByteArray(pixelData)->length);
         */
    }

    /* assert
     * (imagedata.pixelData != NULL)
     */
    decode_jpeg((srcBuffer + offset), length, &image, &creationError);

    if (GXUTL_NATIVE_IMAGE_NO_ERROR != creationError) {
        KNI_ThrowNew(midpIllegalArgumentException, NULL);
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
Ejemplo n.º 29
0
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(com_sun_amms_DirectSoundSource3D_finalize)
{
    javacall_audio3d_soundsource3d_t *src = getNativePtr(KNIPASSARGS 0);
    javacall_amms_local_manager_t *mgr = getNativeMgrPtr(KNIPASSARGS 0);

    javacall_amms_local_manager_destroy_sound_source3d( mgr, src );

    KNI_ReturnVoid();
}
/**
 * Restore the state of the MIDlet suite loader.
 * <p>
 * Java declaration:
 * <pre>
 *   restoreCommandState(Lcom/sun/midp/CommandState;)V
 * </pre>
 */
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(com_sun_midp_main_CommandState_restoreCommandState) {
    KNI_StartHandles(5);
    KNI_DeclareHandle(runtimeInfo);
    KNI_DeclareHandle(commandState);
    KNI_DeclareHandle(clazz);
    KNI_DeclareHandle(rtiClazz);
    KNI_DeclareHandle(string);

    KNI_GetParameterAsObject(1, commandState);
    KNI_GetObjectClass(commandState, clazz);

    KNI_GetObjectField(commandState, midp_get_field_id(KNIPASSARGS clazz,
        "runtimeInfo", "Lcom/sun/midp/main/RuntimeInfo;"), runtimeInfo);
    KNI_GetObjectClass(runtimeInfo, rtiClazz);

    KNI_RESTORE_INT_FIELD(commandState, clazz, "status",
                          MidpCommandState.status);
    KNI_RESTORE_BOOLEAN_FIELD(commandState, clazz, "logoDisplayed",
                              MidpCommandState.logoDisplayed);
    KNI_RESTORE_PCSL_STRING_FIELD(commandState, clazz, "midletClassName",
                                  &MidpCommandState.midletClassName, string);
    KNI_RESTORE_INT_FIELD(commandState, clazz, "suiteId",
                          MidpCommandState.suiteId);
    KNI_RESTORE_INT_FIELD(commandState, clazz, "lastSuiteId",
                          MidpCommandState.lastSuiteId);
    KNI_RESTORE_INT_FIELD(commandState, clazz, "debugMode",
                          MidpCommandState.debugMode);

    KNI_RESTORE_INT_FIELD(runtimeInfo, rtiClazz, "memoryReserved",
                          MidpCommandState.runtimeInfo.memoryReserved);
    KNI_RESTORE_INT_FIELD(runtimeInfo, rtiClazz, "memoryTotal",
                          MidpCommandState.runtimeInfo.memoryTotal);
    KNI_RESTORE_INT_FIELD(runtimeInfo, rtiClazz, "priority",
                          MidpCommandState.runtimeInfo.priority);

    KNI_RESTORE_PCSL_STRING_FIELD(commandState, clazz, "lastMidletClassName",
                                  &MidpCommandState.lastMidletClassName,
                                  string);
    KNI_RESTORE_PCSL_STRING_FIELD(commandState, clazz, "lastArg0",
                                  &MidpCommandState.lastArg0, string);
    KNI_RESTORE_PCSL_STRING_FIELD(commandState, clazz, "lastArg1",
                                  &MidpCommandState.lastArg1, string);
    KNI_RESTORE_PCSL_STRING_FIELD(commandState, clazz, "arg0",
                                  &MidpCommandState.arg0, string);
    KNI_RESTORE_PCSL_STRING_FIELD(commandState, clazz, "arg1",
                                  &MidpCommandState.arg1, string);
    KNI_RESTORE_PCSL_STRING_FIELD(commandState, clazz, "arg2",
                                  &MidpCommandState.arg2, string);
    KNI_RESTORE_PCSL_STRING_FIELD(runtimeInfo, rtiClazz, "profileName",
                                  &MidpCommandState.profileName, string);

    KNI_EndHandles();
    KNI_ReturnVoid();
}