コード例 #1
0
ファイル: midpDebug.c プロジェクト: Sektor/phoneme-qtopia
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" );
    }
}
コード例 #2
0
/**
 * 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 */
コード例 #3
0
ファイル: midpDebug.c プロジェクト: Sektor/phoneme-qtopia
/**
 * 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);
        }
    }
}
コード例 #4
0
/**
 * The platform should invoke this function in platform context to start
 * the Java VM and run i3test framework.
 *
 * @param arg1 optional argument 1
 * @param arg2 optional argument 2
 *
 * @note allowed argument description can be obtained by '-help' value as arg1.
 */
void javanotify_start_i3test(char* arg1, char* arg2) {
    int argc = 0;
    char *argv[MIDP_RUNMIDLET_MAXIMUM_ARGS];
    javacall_result res;

    REPORT_INFO2(LC_CORE,"javanotify_start_i3test() >> %s %s\n",arg1,arg2);

    JVM_Initialize();

    if (initialize_memory_slavemode() != JAVACALL_OK) {
        return;
    }

    argv[argc++] = "runMidlet";
    argv[argc++] = "-1";
    argv[argc++] = "com.sun.midp.i3test.Framework";
    if (NULL != arg1) {
        argv[argc++] = arg1;
        if (NULL != arg2)
            argv[argc++] = arg2;
    }

    javacall_lifecycle_state_changed(JAVACALL_LIFECYCLE_MIDLET_STARTED, JAVACALL_OK);

    res = runMidlet(argc, argv);
}
コード例 #5
0
void DateField::bodyRelocate(int x, int y) {
  TRACE_DF(DateField::bodyRelocate);

  REPORT_INFO2(LC_HIGHUI, "\tx,y = %d,%d\n", x, y);
  
  dateEdit->move(x, y);
}
コード例 #6
0
ファイル: btL2CAPNotifierGlue.c プロジェクト: sfsy1989/j2me
/**
 * Creates a server connection object.
 *
 * Note: the method sets native connection handle directly to
 * <code>handle<code> field of <code>L2CAPNotifierImpl</code> object.
 *
 * @param imtu receive MTU or <code>-1</code> if not specified
 * @param omtu transmit MTU or <code>-1</code> if not specified
 * @param auth   <code>true</code> if authication is required
 * @param authz  <code>true</code> if authorization is required
 * @param enc    <code>true</code> indicates
 *                what connection must be encrypted
 * @param master <code>true</code> if client requires to be
 *               a connection's master
 * @return reserved PSM to listen for incoming connections on
 * @throws IOException if any I/O error occurs
 */
KNIEXPORT KNI_RETURNTYPE_INT
Java_com_sun_midp_io_j2me_btl2cap_L2CAPNotifierImpl_create0(void) {
    int imtu = (int)KNI_GetParameterAsInt(1);
    int omtu = (int)KNI_GetParameterAsInt(2);
    javacall_bool auth  = (KNI_GetParameterAsBoolean(3) == KNI_TRUE)
        ? JAVACALL_TRUE : JAVACALL_FALSE;
    javacall_bool authz  = (KNI_GetParameterAsBoolean(4) == KNI_TRUE)
        ? JAVACALL_TRUE : JAVACALL_FALSE;
    javacall_bool enc  = (KNI_GetParameterAsBoolean(5) == KNI_TRUE)
        ? JAVACALL_TRUE : JAVACALL_FALSE;
    javacall_bool master  = (KNI_GetParameterAsBoolean(6) == KNI_TRUE)
        ? JAVACALL_TRUE : JAVACALL_FALSE;

    javacall_handle handle = BT_INVALID_HANDLE;
    int psm = BT_L2CAP_INVALID_PSM;

    REPORT_INFO(LC_PROTOCOL, "btl2cap_notif::create");

    // Need revisit: add resource counting
/*
    if (midpCheckResourceLimit(RSC_TYPE_BT_SER, 1) == 0) {
        const char* pMsg = "Resource limit exceeded for BT server sockets";
        REPORT_INFO(LC_PROTOCOL, pMsg);
        KNI_ThrowNew(midpIOException, EXCEPTION_MSG(pMsg));
    } else {
*/

    /* create L2CAP server connection */
    if (javacall_bt_l2cap_create_server(imtu, omtu, auth, authz, enc, master,
            &handle, &psm) == JAVACALL_FAIL) {
        REPORT_ERROR(LC_PROTOCOL,
            "L2CAP notifier creation failed in btl2cap_notif::create");
        KNI_ThrowNew(midpIOException,
            EXCEPTION_MSG("Can not create L2CAP notifier "));
        KNI_ReturnInt(BT_L2CAP_INVALID_PSM);
    }

    KNI_StartHandles(1);
    KNI_DeclareHandle(thisHandle);
    KNI_GetThisPointer(thisHandle);

    /* store native connection handle to Java object */
    KNI_SetIntField(thisHandle, notifHandleID, (jint)handle);

    // Need revisit: add resource counting
/*
    if (midpIncResourceCount(RSC_TYPE_BT_SER, 1) == 0) {
        REPORT_INFO(LC_PROTOCOL, "BT Server: Resource limit update error");
    }
*/

//    }

    REPORT_INFO2(LC_PROTOCOL, "btl2cap_notif::create notifier created"
        ", port = %d, handle = %d\n", psm, handle);

    KNI_EndHandles();
    KNI_ReturnInt(psm);
}
コード例 #7
0
ファイル: btSPPNotifierGlue.c プロジェクト: sfsy1989/j2me
/**
 * Creates a server connection object.
 *
 * Note: the method sets native connection handle directly to
 * <code>handle<code> field of <code>BTSPPNotifierImpl</code> object.
 *
 * @param auth   <code>true</code> if authication is required
 * @param authz  <code>true</code> if authorization is required
 * @param enc    <code>true</code> indicates
 *                what connection must be encrypted
 * @param master <code>true</code> if client requires to be
 *               a connection's master
 * @return selected channel number to listen for incoming connections on
 * @throws IOException if any I/O error occurs
 */
KNIEXPORT KNI_RETURNTYPE_INT
Java_com_sun_midp_io_j2me_btspp_BTSPPNotifierImpl_create0(void) {
    bt_bool_t auth  = (KNI_GetParameterAsBoolean(1) == KNI_TRUE)
        ? BT_BOOL_TRUE : BT_BOOL_FALSE;
    bt_bool_t authz  = (KNI_GetParameterAsBoolean(2) == KNI_TRUE)
        ? BT_BOOL_TRUE : BT_BOOL_FALSE;
    bt_bool_t enc  = (KNI_GetParameterAsBoolean(3) == KNI_TRUE)
        ? BT_BOOL_TRUE : BT_BOOL_FALSE;
    bt_bool_t master  = (KNI_GetParameterAsBoolean(4) == KNI_TRUE)
        ? BT_BOOL_TRUE : BT_BOOL_FALSE;

    bt_handle_t handle = BT_INVALID_HANDLE;
    int cn = BT_RFCOMM_INVALID_CN;

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

    // IMPL_NOTE: add resource counting
/*
    if (midpCheckResourceLimit(RSC_TYPE_BT_SER, 1) == 0) {
        const char* pMsg = "Resource limit exceeded for BT server sockets";
        REPORT_INFO(LC_PROTOCOL, pMsg);
        KNI_ThrowNew(midpIOException, EXCEPTION_MSG(pMsg));
    } else {
*/

    /* create RFCOMM server connection */
    if (bt_rfcomm_create_server(auth, authz, enc, master, &handle, &cn)
            == BT_RESULT_FAILURE) {
        REPORT_ERROR(LC_PROTOCOL,
            "RFCOMM notifier creation failed in btspp_notif::create");
        KNI_ThrowNew(midpIOException,
            EXCEPTION_MSG("Can not create RFCOMM notifier"));
        KNI_ReturnInt(BT_RFCOMM_INVALID_CN);
    }

    KNI_StartHandles(1);
    KNI_DeclareHandle(thisHandle);
    KNI_GetThisPointer(thisHandle);

    /* store native connection handle to Java object */
    KNI_SetIntField(thisHandle, notifHandleID, (jint)handle);

    // IMPL_NOTE: add resource counting
/*
    if (midpIncResourceCount(RSC_TYPE_BT_SER, 1) == 0) {
        REPORT_INFO(LC_PROTOCOL, "BT Server: Resource limit update error");
    }
*/

//    }

    REPORT_INFO2(LC_PROTOCOL, "btspp_notif::create notifier created"
        ", port = %d, handle = %d\n", cn, handle);

    KNI_EndHandles();
    KNI_ReturnInt(cn);
}
コード例 #8
0
/**
 * The notification function to be called by platform for keypress
 * occurences.
 * The platform will invoke the call back in platform context for
 * each key press, key release and key repeat occurence
 * @param key the key that was pressed
 * @param type <tt>JAVACALL_KEYPRESSED</tt> when key was pressed
 *             <tt>JAVACALL_KEYRELEASED</tt> when key was released
 *             <tt>JAVACALL_KEYREPEATED</tt> when to be called repeatedly
 *             by platform during the duration that the key was held
 */
void javanotify_key_event(javacall_key key, javacall_keypress_type type) {
    midp_jc_event_union e;

    REPORT_INFO2(LC_CORE,"javanotify_key_event() >> key=%d , type=%d\n",key,type);

    e.eventType = MIDP_JC_EVENT_KEY;
    e.data.keyEvent.key = key;
    e.data.keyEvent.keyEventType = type;

    midp_jc_event_send(&e);
}
コード例 #9
0
/** 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);
}
コード例 #10
0
void DateField::bodyResize(int w, int h)
{
  TRACE_DF(DateField::setSize);

  REPORT_INFO2(LC_HIGHUI, "\tw & h = %d & %d\n", w, h);

  QSize size = dateEdit->sizeHint();
  if (size.width() < w) {
      w = size.width();
  }

  dateEdit->resize(w, h);
}
コード例 #11
0
ファイル: mastermode_export.c プロジェクト: sfsy1989/j2me
/**
 * Adjust timeout value to not miss new comming timer
 * alarms while the system is blocked
 */
static void adjustTimeout(jlong currentTime, jlong *timeout) {
    TimerHandle* timer = peek_timer();
    if (timer != NULL) {
        jlong wakeupTime = get_timer_wakeup(timer);
        if (wakeupTime > currentTime) {
            jlong delta = wakeupTime - currentTime;
            if (*timeout < 0 || *timeout > delta) {
                REPORT_INFO2(LC_PUSH, "[adjustTimeout] timeout=%lu adjusted to %lu",
                    (long)*timeout, (long)delta);

                *timeout = delta;
            }
        }
    }
}
コード例 #12
0
ファイル: midpStorage.c プロジェクト: sfsy1989/j2me
/*
 * Change the read/write position of an open file in storage.
 * The position is a number of bytes from beginning of the file.
 *
 * If not successful *ppszError will set to point to an error string,
 * on success it will be set to NULL.
 */
void
storagePosition(char** ppszError, int handle, long absolutePosition) {
    long newPosition;

    newPosition = pcsl_file_seek((void *)handle, absolutePosition,
                                  PCSL_FILE_SEEK_SET);

    REPORT_INFO2(LC_CORE, "storagePostion on fd %d res = %d\n",
          handle, newPosition);

    if (-1 == newPosition) {
        *ppszError = getLastError("storagePosition()");
        return;
    }

    *ppszError = NULL;
}
コード例 #13
0
ファイル: midpStorage.c プロジェクト: sfsy1989/j2me
/*
 * Change the read/write position of an open file in storage.
 * The position is a number of bytes from current position.
 *
 * If not successful *ppszError will set to point to an error string,
 * on success it will be set to NULL.
 *
 * @return new absolute read/write position
 */
long
storageRelativePosition(char** ppszError, int handle, long offset) {
    long newPosition;

    newPosition = pcsl_file_seek((void *)handle, offset, PCSL_FILE_SEEK_CUR);

    REPORT_INFO2(LC_CORE, "storageRelativePostion on fd %d res = %d\n",
         handle, newPosition);

    if (-1 == newPosition) {
        *ppszError = getLastError("storageRelativePosition()");
        return -1;
    }

    *ppszError = NULL;

    return newPosition;
}
コード例 #14
0
/**
 * A notification function for telling Java to perform installation of
 * a MIDlet with parameters
 *
 * 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
 * @param silentInstall install the MIDlet without user interaction
 * @param forceUpdate install the MIDlet even if it already exist regardless
 *                    of version
 */
void javanotify_install_midlet_wparams(const char* httpUrl,
                                       int silentInstall, int forceUpdate) {
    int argc = 0;
    char *argv[MIDP_RUNMIDLET_MAXIMUM_ARGS];
    javacall_result res;
    int length;

    REPORT_INFO2(LC_CORE,"javanotify_install_midlet_wparams() >> "
                         "httpUrl = %s, silentInstall = %d\n",
                 httpUrl, silentInstall);

    JVM_Initialize();

    if (initialize_memory_slavemode() != JAVACALL_OK) {
        return;
    }

    argv[argc++] = "runMidlet";
    argv[argc++] = "-1";
    argv[argc++] = "com.sun.midp.installer.GraphicalInstaller";

    if (silentInstall == 1) {
        if (forceUpdate == 1) {
            argv[argc++] = "FU";
        } else {
            argv[argc++] = "FI";
        }
    } else {
        argv[argc++] = "I";
    }

    length = strlen(httpUrl);
    if (length >= BINARY_BUFFER_MAX_LEN) {
        REPORT_ERROR(LC_AMS, "javanotify_install_midlet_wparams(): httpUrl is too long");
        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);
}
コード例 #15
0
ファイル: datagramProtocol.c プロジェクト: jiangxilong/yari
/**
 * Gets the nominal length of a datagram.
 * <p>
 * Java declaration:
 * <pre>
 *     getNominalLength0(V)I
 * </pre>
 *
 * @return nominal length of a datagram
 */
KNIEXPORT KNI_RETURNTYPE_INT
Java_com_sun_midp_io_j2me_datagram_Protocol_getNominalLength0(void) {
    /*
     * IMPL NOTE:
     * This implementation is identical to getMaximumLength0().
     * Is this useful? Should this just call getMaxiumumLength0()?
     */

    void *socketHandle;
    int len = -1;

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

    socketHandle =
        (void *)getMidpDatagramProtocolPtr(thisObject)->nativeHandle;

    if (socketHandle != INVALID_HANDLE) {
        int status;

        /*
         * IMPL NOTE:
         * Option=3 represents SO_RCVBUF
         * The SO_RCVBUF option is used by the the network implementation
         * as a hint to size the underlying network I/O buffers.
         */
        status = pcsl_network_getsockopt(socketHandle, 3, &len);
        if (status != PCSL_NET_SUCCESS) {
            KNI_ThrowNew(midpIOException, NULL);
        }
    } else {
        KNI_ThrowNew(midpIOException, "socket closed");
    }

    REPORT_INFO2(LC_PROTOCOL,
        "datagram::getNominalLength0 handle=%d len=%d\n",
        (int)socketHandle, len);

    KNI_EndHandles();
    KNI_ReturnInt((jint)len);
}
コード例 #16
0
ファイル: midpStorage.c プロジェクト: sfsy1989/j2me
/*
 * Write to an open file in storage. Will write all of the bytes in the
 * buffer or pass back an error.
 *
 * If not successful *ppszError will set to point to an error string,
 * on success it will be set to NULL.
 */
void
storageWrite(char** ppszError, int handle, char* buffer, long length) {
    long bytesWritten;

    *ppszError = NULL;
    bytesWritten = pcsl_file_write((void *)handle, (unsigned char*)buffer, length);

    REPORT_INFO2(LC_CORE, "storageWrite on fd %d res = %ld\n",
          handle, bytesWritten);

    if (-1 == bytesWritten) {
        *ppszError = getLastError("storageWrite()");
        return;
    }

    if (bytesWritten != length) {
        *ppszError = "storage full";
        return;
    }
}
コード例 #17
0
ファイル: midpStorage.c プロジェクト: sfsy1989/j2me
/*
 * Close a opened by storage_open. Does no block.
 *
 * If not successful *ppszError will set to point to an error string,
 * on success it will be set to NULL.
 */
void
storageClose(char** ppszError, int handle) {
    int status;

    *ppszError = NULL;
    status = pcsl_file_close((void *)handle);

    REPORT_INFO2(LC_CORE, "storageClose on file_desc %d returns %d\n",
          handle, status);

    if (status < 0) {
        *ppszError = getLastError("storageClose()");
    }

    /* File is successfully closed, decrement the count */
    if (midpDecResourceCount(RSC_TYPE_FILE, 1) == 0) {
        REPORT_INFO(LC_CORE, "FILE: resource"
                             " limit update error");
    }
}
コード例 #18
0
/**
 * The platform should invoke this function in platform context to start
 * the Java VM and run i3test framework.
 *
 * @param arg1 optional argument 1
 * @param arg2 optional argument 2
 *
 * @note allowed argument description can be obtained by '-help' value as arg1.
 */
void javanotify_start_i3test(char* arg1, char* arg2) {
    midp_jc_event_union e;
    midp_jc_event_start_arbitrary_arg *data = &e.data.startMidletArbitraryArgEvent;

    REPORT_INFO2(LC_CORE,"javanotify_start_i3test() >> %s %s\n",arg1,arg2);

    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.i3test.Framework";
    if (NULL != arg1) {
        data->argv[data->argc++] = arg1;
        if (NULL != arg2)
            data->argv[data->argc++] = arg2;
    }

    midp_jc_event_send(&e);
}
コード例 #19
0
/**
 * Gets the height of the custom item's native label. 
 *
 * @param width the tentative width for the label (without padding)
 * @param heightRet the calculated label height, based on tentative 
 *                  width passed in.
 * @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_label_height(int width,
				    int *heightRet,
				    MidpItem* ciPtr)
{

  REPORT_INFO1(LC_HIGHUI, "[lfpport_qte_customitem.cpp:%d] "
	       "lfpport_customitem_GetLabelHeight" , __LINE__);

  if (width < 0) {
    width = qteapp_get_mscreen()->getScreenWidth() - ITEM_BOUND_PAD - ITEM_BOUND_PAD;
  }
  *heightRet = ((Item *)ciPtr->widgetPtr)->getLabelHeight(width);

  REPORT_INFO2(LC_HIGHUI, 
	      "\t lfpport_customitem_GetLabelHeight(%d): labelHeight=%d\n",
	      width, heightRet);


  return KNI_OK;
}
コード例 #20
0
/**
 * The platform should invoke this function in platform context to start
 * Java in local context (not OTA).
 */
void javanotify_start_local(char* classname, char* descriptor,
                            char* classpath, javacall_bool debug) {
    int argc = 0;
    char *argv[MIDP_RUNMIDLET_MAXIMUM_ARGS];
    javacall_result res;

    REPORT_INFO2(LC_CORE,"javanotify_start_local() >> classname=%s, descriptor=%d \n",
                 classname, descriptor);

    JVM_Initialize();
    if (initialize_memory_slavemode() != JAVACALL_OK) {
        return;
    }

    argv[argc++] = "runMidlet";
    argv[argc++] = "-1";

    if (classname == NULL) {
        argv[argc++] = "internal";
    } else {
        argv[argc++] = classname;
    }

    if (descriptor != NULL) {
        argv[argc++] = descriptor;
    } else {
        argv[argc++] = classpath;
    }

    if (classpath != NULL) {
        argv[argc++] = "-classpathext";
        argv[argc++] = classpath;
    }

    javacall_lifecycle_state_changed(JAVACALL_LIFECYCLE_MIDLET_STARTED, JAVACALL_OK);

    res = runMidlet(argc, argv);
}
コード例 #21
0
/**
 * The platform should invoke this function in platform context to start
 * the Java VM and run TCK.
 *
 * @param url the http location of the TCK server
 *            the url should be of the form: "http://host:port"
 * @param domain the TCK execution domain
 */
void javanotify_start_tck(char *tckUrl, javacall_lifecycle_tck_domain domain_type) {

    int length;
    midp_jc_event_union e;
    midp_jc_event_start_arbitrary_arg *data = &e.data.startMidletArbitraryArgEvent;

    REPORT_INFO2(LC_CORE,"javanotify_start_tck() >> tckUrl=%s, domain_type=%d \n",tckUrl,domain_type);

    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.AutoTester";

    length = strlen(tckUrl);
    if (length >= BINARY_BUFFER_MAX_LEN)
        return;
    
    memset(urlAddress, 0, BINARY_BUFFER_MAX_LEN);
    memcpy(urlAddress, tckUrl, length);
    if(strcmp(urlAddress, "none") != 0)
        data->argv[data->argc++] = urlAddress;


    if(domain_type == JAVACALL_LIFECYCLE_TCK_DOMAIN_UNTRUSTED) {
        data->argv[data->argc++] = "untrusted";
    } else if(domain_type == JAVACALL_LIFECYCLE_TCK_DOMAIN_TRUSTED) {
        data->argv[data->argc++] = "trusted";
    } else if(domain_type == JAVACALL_LIFECYCLE_TCK_DOMAIN_UNTRUSTED_MIN) {
        data->argv[data->argc++] = "minimum";
    } else if(domain_type == JAVACALL_LIFECYCLE_TCK_DOMAIN_UNTRUSTED_MAX) {
        data->argv[data->argc++] = "maximum";
    } else
        return;

    midp_jc_event_send(&e);
}
コード例 #22
0
ファイル: midpStorage.c プロジェクト: sfsy1989/j2me
/*
 * Read from an open file in storage, returning the number of bytes read or
 * -1 for the end of the file. May read less than the length of the buffer.
 *
 * If not successful *ppszError will set to point to an error string,
 * on success it will be set to NULL.
 */
long
storageRead(char** ppszError, int handle, char* buffer, long length) {
    long bytesRead;

    *ppszError = NULL;
    if (0 == length) {
        return 0;
    }

    bytesRead = pcsl_file_read((void *)handle, (unsigned char*)buffer, length);

    REPORT_INFO2(LC_CORE, "storageRead on fd %d res = %ld\n",
          handle, bytesRead);

    if (-1 == bytesRead) {
        *ppszError = getLastError("storageRead()");
    } else if (0 == bytesRead) {
        /* end of file in java is -1 */
        bytesRead = -1;
    }

    return bytesRead;
}
コード例 #23
0
/**
 * Post native media event to Java event handler
 * 
 * @param type          Event type
 * @param playerId      Player ID that came from javacall_media_create function
 * @param data          Data for this event type
 */
void javanotify_on_media_notification(javacall_media_notification_type type,
                                      javacall_int64 playerId,
                                      void *data) {
#if ENABLE_JSR_135
    extern int g_currentPlayer;

    midp_jc_event_union e;

    if (-1 == playerId) {
        playerId = g_currentPlayer;
    }

    REPORT_INFO2(LC_MMAPI, "javanotify_on_media_notification type=%d id=%d\n", type, (int)(playerId & 0xFFFFFFFF));

    e.eventType = MIDP_JC_EVENT_MULTIMEDIA;
    e.data.multimediaEvent.mediaType = type;
    e.data.multimediaEvent.isolateId = (int)((playerId >> 32) & 0xFFFF);
    e.data.multimediaEvent.playerId = (int)(playerId & 0xFFFF);
    e.data.multimediaEvent.data = (int) data;

    midp_jc_event_send(&e);
#endif
}
コード例 #24
0
ファイル: datagramProtocol.c プロジェクト: jiangxilong/yari
/**
 * Releases any native resources used by the datagram connection.
 * <p>
 * Java declaration:
 * <pre>
 *     finalize(V)V
 * </pre>
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_midp_io_j2me_datagram_Protocol_finalize(void) {
    void *handle;
    int status;
    void *context = NULL;

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

    handle = (void *)getMidpDatagramProtocolPtr(thisObject)->nativeHandle;

    if (handle != INVALID_HANDLE) {
        if (pushcheckin((int)handle) == -1) {
            status = pcsl_datagram_close_start(handle, &context);
            if (status == PCSL_NET_SUCCESS) {
                if (midpDecResourceCount(RSC_TYPE_UDP, 1) == 0) {
                    REPORT_INFO(LC_PROTOCOL,
                        "Datagrams: resource limit update error");
                }
            } else if (status == PCSL_NET_IOERROR) {
                REPORT_INFO2(LC_PROTOCOL,
                    "datagram::finalize handle 0x%x I/O error code %d",
                    (int)handle, pcsl_network_error(handle));
            } else if (status == PCSL_NET_WOULDBLOCK) {
                REPORT_ERROR1(LC_PROTOCOL,
                    "datagram::finalize handle 0x%x WOULDBLOCK not supported",
                    (int)handle);
            }
            getMidpDatagramProtocolPtr(thisObject)->nativeHandle =
                (jint)INVALID_HANDLE;
        }
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
コード例 #25
0
/**
 * The platform should invoke this function in platform context to start
 * the Java VM and run TCK.
 *
 * @param url the http location of the TCK server
 *            the url should be of the form: "http://host:port"
 * @param domain the TCK execution domain
 */
void javanotify_start_tck(char *tckUrl, javacall_lifecycle_tck_domain domain_type) {
    int length;
    int argc = 0;
    char *argv[MIDP_RUNMIDLET_MAXIMUM_ARGS];
    javacall_result res;

    REPORT_INFO2(LC_CORE,"javanotify_start_tck() >> tckUrl=%s, domain_type=%d \n",tckUrl,domain_type);

    midp_thread_set_timeslice_proc(midp_slavemode_schedule_vm_timeslice);
    JVM_Initialize();

    if (initialize_memory_slavemode() != JAVACALL_OK) {
        return;
    }

    argv[argc++] = "runMidlet";
    argv[argc++] = "-1";
    argv[argc++] = "com.sun.midp.installer.AutoTester";

    length = strlen(tckUrl);
    if (length >= BINARY_BUFFER_MAX_LEN) {
        REPORT_ERROR(LC_AMS, "javanotify_start_tck(): tckUrl is too long");
        return;
    }

    memset(urlAddress, 0, BINARY_BUFFER_MAX_LEN);
    memcpy(urlAddress, tckUrl, length);
    if (strcmp(urlAddress, "none") != 0) {
        argv[argc++] = urlAddress;
    }

    switch (domain_type) {
    case JAVACALL_LIFECYCLE_TCK_DOMAIN_UNTRUSTED: 
        argv[argc] = "untrusted";
        break;
    case JAVACALL_LIFECYCLE_TCK_DOMAIN_TRUSTED:
        argv[argc] = "trusted";
        break;
    case JAVACALL_LIFECYCLE_TCK_DOMAIN_UNTRUSTED_MIN:
        argv[argc] = "minimum";
        break;
    case JAVACALL_LIFECYCLE_TCK_DOMAIN_UNTRUSTED_MAX:
        argv[argc] = "maximum";
        break;
    case JAVACALL_LIFECYCLE_TCK_DOMAIN_MANUFACTURER:
        argv[argc] = "manufacturer";
        break;
    case JAVACALL_LIFECYCLE_TCK_DOMAIN_OPERATOR:
        argv[argc] = "operator";
        break;
    case JAVACALL_LIFECYCLE_TCK_DOMAIN_IDENTIFIED:
        argv[argc] = "identified_third_party";
        break;
    case JAVACALL_LIFECYCLE_TCK_DOMAIN_UNIDENTIFIED:
        argv[argc] = "unidentified_third_party";
        break;
    default:
        REPORT_ERROR(LC_CORE, "javanotify_start_tck() [slave mode] Can not recognize TCK domain\n");
        REPORT_ERROR1(LC_CORE, "TCK domain type is %d. System will now exit\n", domain_type);
        return;
    }
    argc++;

    javacall_lifecycle_state_changed(JAVACALL_LIFECYCLE_MIDLET_STARTED, JAVACALL_OK);

    res = runMidlet(argc, argv);
}
コード例 #26
0
static MidpProperties verifyJadMustProperties(MidpProperties jadsmp) {

    /* 5 MUST fields in JAD */
    pcsl_string * name = NULL;
    pcsl_string * version = NULL;
    pcsl_string * vendor = NULL;
    pcsl_string * jarUrl = NULL;
    pcsl_string * jarSizeString = NULL;

    int permittedJarSize = 0;
    jint jarSizeByJad = 0;

    jarUrl = midp_find_property(&jadsmp, &JAR_URL_PROP);
    if (pcsl_string_is_null(jarUrl)) {
        REPORT_INFO(LC_AMS,  "Missing Jar URL");
        jadsmp.status = NO_JAR_URL_PROP;
        return jadsmp;
    }

    jarSizeString = midp_find_property(&jadsmp, &JAR_SIZE_PROP);
    if (pcsl_string_is_null(jarSizeString)) {
        REPORT_INFO(LC_AMS,  "Missing Jar size");
        jadsmp.status = NO_JAR_SIZE_PROP;
        return jadsmp;
    }

    if (PCSL_STRING_OK !=
        pcsl_string_convert_to_jint(jarSizeString, &jarSizeByJad)) {
        /* NUMBER_ERROR */
        REPORT_INFO1(LC_AMS, "JAD size ERROR %d", jarSizeByJad);
        jadsmp.status = NUMBER_ERROR;
        return jadsmp;
    }

    /* verify that requested jar size is not to big  */
    permittedJarSize = midpGetMaxJarSizePermitted();
    if (jarSizeByJad > permittedJarSize) {
        REPORT_INFO2(LC_AMS, "Jar size requested by Jad is to big %d > %d",
		     jarSizeByJad, permittedJarSize);
        REPORT_INFO(LC_AMS,  "Out Of Storage");
        jadsmp.status = OUT_OF_STORAGE;
        return jadsmp;
    }

    name = midp_find_property(&jadsmp, &SUITE_NAME_PROP);
    if (pcsl_string_is_null(name)) {
        REPORT_INFO(LC_AMS, "Missing suite name");
        jadsmp.status = NO_SUITE_NAME_PROP;
        return jadsmp;
    }

    vendor = midp_find_property(&jadsmp, &SUITE_VENDOR_PROP);
    if (pcsl_string_is_null(vendor)) {
        REPORT_INFO(LC_AMS,  "Missing suite vendor");
        jadsmp.status =  NO_SUITE_VENDOR_PROP;
        return jadsmp;
    }

    version = midp_find_property(&jadsmp, &SUITE_VERSION_PROP);
    if (pcsl_string_is_null(version)) {
        REPORT_INFO(LC_AMS,  "Missing suite version");
        jadsmp.status = NO_SUITE_VERSION_PROP;
        return jadsmp;
    }
    if (!midpCheckVersion(version)) {
        REPORT_INFO(LC_AMS,  "Corrupted suite version");
        jadsmp.status = NO_SUITE_VERSION_PROP;
        return jadsmp;
    }
    return jadsmp;
} /* verifyJadMUSTProperties */