Example #1
0
/**
 * 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);
        }
    }
}
/*
 * Checks out (takes ownership of) an active server connection maintained
 * by push subsystem.
 *
 * @param url URL used during registration of the push entry
 * @param suiteId suite id
 * @return true if the operation succeeds, false otherwise
 */
KNIEXPORT KNI_RETURNTYPE_BOOLEAN
Java_com_sun_jsr082_bluetooth_btl2cap_L2CAPNotifierImpl_pushCheckout(void)
{
    jboolean retval = KNI_FALSE;
    SuiteIdType suiteId;
    MidpString wsUrl;
    char *szUrl;
    bt_port_t port;
    jfieldID notifHandleID = NULL;
    jfieldID pushHandleID  = NULL;

    KNI_StartHandles(3);
    KNI_DeclareHandle(thisHandle);
    KNI_DeclareHandle(urlHandle);
    KNI_DeclareHandle(classHandle);

    KNI_GetThisPointer(thisHandle);
    KNI_GetClassPointer(classHandle);

    GET_FIELDID(classHandle, "handle", "I", notifHandleID)
    GET_FIELDID(classHandle, "pushHandle", "I", pushHandleID)

    KNI_GetParameterAsObject(1, urlHandle);
    suiteId = KNI_GetParameterAsInt(2);

    wsUrl = midpNewString(urlHandle);
    szUrl = midpJcharsToChars(wsUrl);
    if (bt_push_parse_url(szUrl, &port, NULL) == JAVACALL_OK) {
        if (pushcheckout(szUrl, 0, (char*)midp_suiteid2chars(suiteId)) == -2) {
            KNI_ThrowNew(midpIOException, "Port already in use.");
        } else {
            javacall_handle handle;
            bt_pushid_t pushid = bt_push_checkout_server(&port, &handle, NULL);
            if (pushid != BT_INVALID_PUSH_HANDLE) {
                KNI_SetIntField(thisHandle, pushHandleID, (jint)pushid);
                KNI_SetIntField(thisHandle, notifHandleID, (jint)handle);
                retval = KNI_TRUE;
            }
        }
    }
    midpFree(szUrl);
    MIDP_FREE_STRING(wsUrl);
    KNI_EndHandles();
    KNI_ReturnBoolean(retval);
}
Example #3
0
/**
 * Prints a <tt>MidpString</tt>. A new line will be emitted after
 * <tt>mstr</tt>.  This output goes to the log in cases
 * were the log service defined REPORT_LEVEL <= LOG_INFORMATION
 *
 * @param mstr the <tt>MidpString</tt> to print
 */
void
printMidpStringImpl(MidpString mstr) {
    char* msg = NULL;  
    if (mstr.len <= 0) {
        REPORT_INFO(LC_MIDPSTRING, 
		    "printMidpString: Bad Length.");
        return;
    }
    if (mstr.len > 0) {
        msg = midpJcharsToChars(mstr);
        if (msg) {
	        REPORT_INFO1(LC_MIDPSTRING, "%s", msg);
            midpFree(msg);
        } else {
             REPORT_INFO(LC_MIDPSTRING, 
	        "printMidpString: can't convert from MidpString to char");

        }
    }
}
Example #4
0
/**
 * Checks out (takes ownership of) an active server connection maintained
 * by push subsystem.
 *
 * @param url URL used during registration of the push entry
 * @param suiteId suite id
 * @return true if the operation succeeds, false otherwise
 */
KNIEXPORT KNI_RETURNTYPE_BOOLEAN
Java_com_sun_midp_io_j2me_btspp_BTSPPNotifierImpl_pushCheckout(void) {
    jboolean retval = KNI_FALSE;
    SuiteIdType suiteId;
    MidpString wsUrl;
    char *szUrl;
    bt_port_t port;

    KNI_StartHandles(2);
    KNI_DeclareHandle(thisHandle);
    KNI_DeclareHandle(urlHandle);
    KNI_GetThisPointer(thisHandle);
    KNI_GetParameterAsObject(1, urlHandle);
    suiteId = KNI_GetParameterAsInt(2);

    wsUrl = midpNewString(urlHandle);
    szUrl = midpJcharsToChars(wsUrl);

    if (bt_push_parse_url(szUrl, &port, NULL) == BT_RESULT_SUCCESS) {
        if (pushcheckout(szUrl, 0, (char*)midp_suiteid2chars(suiteId)) == -2) {
            KNI_ThrowNew(midpIOException, "Port already in use.");
        } else {
            bt_handle_t handle;
            bt_pushid_t pushid = bt_push_checkout_server(&port, &handle, NULL);
            if (pushid != BT_INVALID_PUSH_HANDLE) {
                KNI_SetIntField(thisHandle, pushHandleID, (jint)pushid);
                KNI_SetIntField(thisHandle, notifHandleID, (jint)handle);
                retval = KNI_TRUE;
            }
        }
    }

    midpFree(szUrl);
    MIDP_FREE_STRING(wsUrl);
    KNI_EndHandles();
    KNI_ReturnBoolean(retval);
}