const char* CJSScrollViewLayer::getImagePathToPlatform() { CCLog("LanguageUtil::getLanguageType()"); jobject activityObj = getActivityObject(); jstring imagePath = NULL; if (activityObj) { JniMethodInfo methodInfo; if (!JniHelper::getMethodInfo(methodInfo, JNI_METHOD_INFO, "getImagePath", "()Ljava/lang/String;")) { CCLog("%s %d: error to get methodInfo getImagePath", __FILE__, __LINE__); } else { imagePath = (jstring)methodInfo.env->CallObjectMethod(activityObj, methodInfo.methodID); CCLog("getImagePath() ok!! imagePath = %s", imagePath); return jstringToChar(methodInfo.env, imagePath); } } else { CCLog("%s %d: error to get activityObj", __FILE__, __LINE__); } return NULL; }
char *StringFieldAccessor( JNIEnv* env, jclass cls, const char *szFieldName, jobject obj ) { jfieldID field = env->GetFieldID( cls, szFieldName, "Ljava/lang/String;" ); if (!env->ExceptionOccurred()) { if ( field ) { jstring str = (jstring) env->GetObjectField( obj, field ); if( str ) { return jstringToChar( env, str ); } } } if (env->ExceptionOccurred()) { env->ExceptionDescribe(); env->ExceptionClear(); IwTrace(KIIP, ("One or more java fields could not be found")); } return NULL; }
jboolean proxy(JNIEnv* env, const jobject& jobj, const jstring& proxyStr, const int flags) { char* proxyAddressStr = jstringToChar(env, proxyStr); INTERNET_PER_CONN_OPTION_LIST options; BOOL bReturn; DWORD dwBufferSize = sizeof(options); options.dwSize = dwBufferSize; options.pszConnection = NULL;//connNameStr;//NULL == LAN options.dwOptionCount = 3; options.pOptions = new INTERNET_PER_CONN_OPTION[3]; if(!options.pOptions) return FALSE; options.pOptions[0].dwOption = INTERNET_PER_CONN_FLAGS; options.pOptions[0].Value.dwValue = flags; options.pOptions[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER; options.pOptions[1].Value.pszValue = proxyAddressStr; options.pOptions[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS; LPSTR loc = TEXT("local"); options.pOptions[2].Value.pszValue = loc; bReturn = InternetSetOption(NULL,INTERNET_OPTION_PER_CONNECTION_OPTION, &options, dwBufferSize); delete [] options.pOptions; InternetSetOption(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0); InternetSetOption(NULL, INTERNET_OPTION_REFRESH , NULL, 0); delete [] proxyAddressStr; return bReturn; }
extern "C" jstring JNICALL Java_com_iped_ipcam_gui_UdtTools_monitorSocket(JNIEnv *env, jobject thiz, jstring camId) { if (first) { LOGI("### UdtTools monitor_init!"); first = 0; monitor_init(0); } freeSocket(); LOGI("### start monitorSocke"); char* idTmp = jstringToChar(env,camId); id = idTmp; socket1 = monitor_socket_fusion(idTmp); while (1) { if(socket1 == NULL) { return env->NewStringUTF("fusion error"); } LOGI("### wait to connection."); stun_sleep_ms(100); if (socket_fusion_is_usable(socket1) || socket_fusion_is_done(socket1)) { break; } } if (socket_fusion_is_usable(socket1)) { LOGI("### connection success. %p", socket1); return getOK(env); } LOGI("### connection faliled."); return getError(env,socket1); }
extern "C" jint JNICALL Java_com_iped_ipcam_gui_UdtTools_recvCmdMsgById(JNIEnv *env, jobject thiz, jstring camId, jbyteArray buffer, jint bufferLength) { LOGI("### UdtTools start recv-Cmd-Msg-By-Id!"); char* idTmp = jstringToChar(env,camId); char * tmp = (char*)malloc(bufferLength); LOGI("### UdtTools wait for recv cmd ..."); int dataLength = 0; if(id != NULL && strcmp( idTmp, id )==0) { if (socket_fusion_is_usable(socket1)) { dataLength = socket_fusion_recvmsg(socket1, 0, tmp, bufferLength); } }else{ if (socket_fusion_is_usable(socket2)) { dataLength = socket_fusion_recvmsg(socket2, 0, tmp, bufferLength); } } if(dataLength < 0) { free(tmp); LOGE("### UdtTools recv error!"); return -1; } LOGI("### UdtTools recv data length= %d", dataLength); env->SetByteArrayRegion(buffer, 0, dataLength,(jbyte*) tmp); free(tmp); return dataLength; }
extern "C" jint JNICALL Java_com_iped_ipcam_gui_UdtTools_sendCmdMsgById(JNIEnv *env, jobject thiz, jstring camId, jstring cmdName, jint cmdNameLength) { char* tmp = jstringToChar(env,camId); LOGI("### UdtTools sendCmdMsgById -- %c,%p", id,socket1); char * cmd = jstringToChar(env,cmdName); int res = 0; if(id != NULL) { if(strcmp( tmp, id )==0) { if (socket_fusion_is_usable(socket1)) { if(socket1->is_old) { res = socket_fusion_sendmsg(socket1, 0, cmd, cmdNameLength+1); }else { res = socket_fusion_sendmsg(socket1, 0, cmd, cmdNameLength); } }else { res = -1; LOGI("### UdtTools send cmd socket1 is invalid! %p", socket1); } } else { if (socket_fusion_is_usable(socket2)) { if(socket2->is_old) { res = socket_fusion_sendmsg(socket2, 0, cmd, cmdNameLength+1); }else { res = socket_fusion_sendmsg(socket2, 0, cmd, cmdNameLength); } }else { res = -1; LOGI("### UdtTools send cmd socket2 is invalid! %p", socket2); } } } else { if (socket_fusion_is_usable(socket2)) { if(socket2->is_old) { res = socket_fusion_sendmsg(socket2, 0, cmd, cmdNameLength+1); }else { res = socket_fusion_sendmsg(socket2, 0, cmd, cmdNameLength); } }else { res = -1; LOGI("### UdtTools send cmd socket2 is invalid! %p", socket2); } } LOGI("### UdtTools send cmd name=%s, cmdNameLength %d, send msg length=%d", cmd,cmdNameLength,res); free(cmd); free(tmp); return res; }
void JNICALL s3eKiip_saveMomentCompletionCallback( JNIEnv* env, jobject obj, jobject param ) { s3eDebugOutputString("s3eKiip_saveMomentCompletionCallback: start"); const char* pItemData = jstringToChar( env, (jstring) param ); s3eEdkCallbacksEnqueue( S3E_EXT_KIIP_HASH, S3EKIIP_SAVE_MOMENT_COMPLETION, (void*)pItemData, 0 , NULL, false, &s3eKiip_ReleaseStringCallback, (void*)pItemData ); }
void JNICALL s3eKiip_swarmStartCallback( JNIEnv* env, jobject obj, jobject param ) { s3eDebugOutputString("s3eKiip_swarmStartCallback: start"); const char* pItemData = jstringToChar( env, (jstring) param ); s3eEdkCallbacksEnqueue( S3E_EXT_KIIP_HASH, S3EKIIP_SWARM_START, (void*)pItemData, 0 , NULL, false, &s3eKiip_ReleaseStringCallback, (void*)pItemData ); }
JNIEXPORT jboolean JNICALL Java_org_lantern_win_WinProxy_setPacFile(JNIEnv * env, jobject jobj, jstring proxyStr) { log_debug("Setting pac file"); char* proxyAddressStr = jstringToChar(env, proxyStr); if (sizeof(proxyAddressStr) == 0) { proxyAddressStr = NULL; } const jboolean returnVal = setPacFile(proxyAddressStr, PROXY_TYPE_AUTO_PROXY_URL); delete [] proxyAddressStr; return returnVal; }
extern "C" jstring JNICALL Java_com_iped_ipcam_gui_UdtTools_monitorCmdSocket(JNIEnv *env, jobject thiz, jstring camId,jstring rand) { LOGI("### start config monitorCmdSocket"); if (first) { LOGI("### UdtTools cmd monitor_init!"); first = 0; monitor_init(0); } char* idTmp = jstringToChar(env,camId); if(id == NULL || strcmp( idTmp, id )!=0) { socket2 = monitor_socket_fusion(idTmp); if(socket2 == NULL) { return env->NewStringUTF("cmd fusion error"); } while (1) { LOGI("### wait config to connection."); stun_sleep_ms(100); if (socket_fusion_is_usable(socket2) || socket_fusion_is_done(socket2)) { break; } } if (socket_fusion_is_usable(socket2)) { LOGI("### configf connection success.%p", socket2); return getOK(env); } } else { if(socket1 == NULL) { return env->NewStringUTF("fusion2 error"); } if (socket_fusion_is_usable(socket1)) { LOGI("### config connection success.%p", socket2); return getOK(env); } else { return Java_com_iped_ipcam_gui_UdtTools_monitorSocket(env, thiz,camId); } } LOGI("### config connection faliled."); return getError(env, socket2); }
extern "C" jint JNICALL Java_com_iped_ipcam_gui_UdtTools_sendCmdMsg(JNIEnv *env, jobject thiz, jstring cmdName, jint cmdNameLength) { LOGI("### UdtTools Start SendCmdMsg"); char * cmd = jstringToChar(env,cmdName); int res = 0; if (socket_fusion_is_usable(socket1)){ if(socket1->is_old) { res = socket_fusion_sendmsg(socket1, 0, cmd, cmdNameLength+1); } else { res = socket_fusion_sendmsg(socket1, 0, cmd, cmdNameLength); } } else { LOGE("### UdtTools sendCmdMsg socket is invalid!"); res =-1; } LOGI("### UdtTools End SendCmdMsg. send cmd name = %s send msg length = %d", cmd,res); free(cmd); return res; }