/* * 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); }
/** * 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); }