From 28e52876063ef9854f45d398a33e8df53307da61 Mon Sep 17 00:00:00 2001 From: zoff99 Date: Sun, 10 Mar 2024 18:04:27 +0100 Subject: [PATCH] WIP: api function to get IP address and port of UDP connected friends --- jni-c-toxcore/jni-c-toxcore.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/jni-c-toxcore/jni-c-toxcore.c b/jni-c-toxcore/jni-c-toxcore.c index 56a883437..380442c26 100644 --- a/jni-c-toxcore/jni-c-toxcore.c +++ b/jni-c-toxcore/jni-c-toxcore.c @@ -4374,6 +4374,23 @@ Java_com_zoffcc_applications_trifa_MainActivity_tox_1friend_1get_1connection_1st return (jint)res; } +JNIEXPORT jstring JNICALL +Java_com_zoffcc_applications_trifa_MainActivity_tox_1friend_1get_1connection_1ip(JNIEnv *env, jobject thiz, + jlong friend_number) +{ + if(tox_global == NULL) + { + return NULL; + } + + const int max_length = 600; + char ip_str[max_length + 1]; + CLEAR(ip_str); + tox_friend_get_connection_ip(tox_global, (uint32_t)friend_number, (uint8_t *)ip_str); + jstring js1 = c_safe_string_from_java((char *)ip_str, max_length); + return js1; +} + JNIEXPORT jint JNICALL Java_com_zoffcc_applications_trifa_MainActivity_tox_1friend_1delete(JNIEnv *env, jobject thiz, jlong friend_number) {