Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show friends push url in contactlist #190

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static String get_relay_for_friend(String friend_pubkey)
}
}

static String get_pushurl_for_friend(String friend_pubkey)
public static String get_pushurl_for_friend(String friend_pubkey)
{
String ret = null;

Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ val GROUP_PEER_HEIGHT = 33.dp
val SETTINGS_HEADER_SIZE = 56.dp
val CONTACT_COLUMN_WIDTH = 230.dp
const val CONTACT_COLUMN_CONTACTNAME_LEN_THRESHOLD = 13
const val PUSHURL_SHOW_LEN_THRESHOLD = 60
val GROUPS_COLUMN_WIDTH = 190.dp
const val GROUPS_COLUMN_GROUPNAME_LEN_THRESHOLD = 13
val GROUP_PEER_COLUMN_WIDTH = 165.dp
Expand Down
9 changes: 9 additions & 0 deletions src/main/kotlin/com/zoffcc/applications/trifa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import com.zoffcc.applications.trifa.HelperMessage.update_message_in_db_read_rcv
import com.zoffcc.applications.trifa.HelperMessage.update_single_message_from_ftid
import com.zoffcc.applications.trifa.HelperMessage.update_single_message_from_messge_id
import com.zoffcc.applications.trifa.HelperRelay.get_own_relay_pubkey
import com.zoffcc.applications.trifa.HelperRelay.get_pushurl_for_friend
import com.zoffcc.applications.trifa.HelperRelay.have_own_relay
import com.zoffcc.applications.trifa.HelperRelay.invite_to_all_groups_own_relay
import com.zoffcc.applications.trifa.HelperRelay.is_any_relay
Expand Down Expand Up @@ -1465,9 +1466,11 @@ class MainActivity
val friend_pubkey = tox_friend_get_public_key(friend_number)!!
val is_relay = is_any_relay(friend_pubkey)
val ip_addr_str = get_friend_ip_str(friend_number)
val push_url = get_pushurl_for_friend(friend_pubkey)
contactstore.update(item = ContactItem(name = friend_name!!,
isConnected = tox_friend_get_connection_status(friend_number), pubkey = friend_pubkey,
ip_addr = ip_addr_str,
push_url = push_url,
is_relay = is_relay))
} catch (_: Exception)
{
Expand All @@ -1488,10 +1491,12 @@ class MainActivity
val friend_pubkey = tox_friend_get_public_key(friend_number)!!
val is_relay = is_any_relay(friend_pubkey)
val ip_addr_str = get_friend_ip_str(friend_number)
val push_url = get_pushurl_for_friend(friend_pubkey)
contactstore.update(item = ContactItem(name = fname,
isConnected = tox_friend_get_connection_status(friend_number),
pubkey = friend_pubkey,
ip_addr = ip_addr_str,
push_url = push_url,
is_relay = is_relay))
} catch (_: Exception)
{
Expand Down Expand Up @@ -1533,6 +1538,7 @@ class MainActivity
contactstore.add(item = ContactItem(name = "Relay #" + relay_pubkey.uppercase().take(6),
isConnected = 0,
pubkey = relay_pubkey.uppercase(),
push_url = "",
is_relay = true))
} catch (_: Exception)
{
Expand Down Expand Up @@ -1587,10 +1593,12 @@ class MainActivity
val friend_pubkey = tox_friend_get_public_key(friend_number)!!
val is_relay = is_any_relay(friend_pubkey)
val ip_addr_str = get_friend_ip_str(friend_number)
val push_url = get_pushurl_for_friend(friend_pubkey)
contactstore.update(item = ContactItem(name = fname,
isConnected = tox_friend_get_connection_status(friend_number),
pubkey = friend_pubkey,
ip_addr = ip_addr_str,
push_url = push_url,
is_relay = is_relay))
} catch (_: Exception)
{
Expand Down Expand Up @@ -1774,6 +1782,7 @@ class MainActivity
contactstore.add(item = ContactItem(name = "new Friend #" + new_friendnumber,
isConnected = 0,
pubkey = friend_public_key!!,
push_url = "",
is_relay = false))
} catch (_: Exception)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,7 @@ class TrifaToxService
contactstore.add(item = ContactItem(name = fname,
isConnected = 0,
pubkey = tox_friend_get_public_key(it)!!,
push_url = f.push_url,
is_relay = f.is_relay))
} catch (_: Exception)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ data class ContactItem(
val name: String,
val isConnected: Int,
val pubkey: String,
val push_url: String? = "",
val is_relay: Boolean,
var ip_addr: String = ""
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.briarproject.briar.desktop.contact

import CONTACT_COLUMN_CONTACTNAME_LEN_THRESHOLD
import PUSHURL_SHOW_LEN_THRESHOLD
import androidx.compose.desktop.ui.tooling.preview.Preview
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
Expand Down Expand Up @@ -112,6 +113,8 @@ private fun ContactItemViewInfo(contactItem: ContactItem) = Column(
var name_style = if (show_name.length > CONTACT_COLUMN_CONTACTNAME_LEN_THRESHOLD)
MaterialTheme.typography.body1.copy(fontSize = 13.sp, lineHeight = TextUnit.Unspecified) else MaterialTheme.typography.body1.copy(lineHeight = TextUnit.Unspecified)
val friend_relay = get_relay_for_friend(contactItem.pubkey.toUpperCase())
var pushurl_str = if (contactItem.push_url.isNullOrEmpty()) "" else ("\n" + "Push URL: " + contactItem.push_url)
pushurl_str = if (pushurl_str.length > PUSHURL_SHOW_LEN_THRESHOLD) (pushurl_str.take(PUSHURL_SHOW_LEN_THRESHOLD) + "...") else pushurl_str
val relay_str = if (friend_relay.isNullOrEmpty()) "" else ("\n" + "Relay (ToxProxy): " + friend_relay)
val ip_addr_str = contactItem.ip_addr
// Log.i(TAG, "ContactItemViewInfo: ip_addr_str=" + ip_addr_str + " name=" + show_name)
Expand All @@ -123,7 +126,7 @@ private fun ContactItemViewInfo(contactItem: ContactItem) = Column(
MaterialTheme.typography.body1.copy(fontSize = 12.sp, lineHeight = TextUnit.Unspecified) else MaterialTheme.typography.body1.copy(lineHeight = TextUnit.Unspecified)
}
Tooltip(text = "Name: " + tooltip_name + "\n" +
"Pubkey: " + contactItem.pubkey + relay_str + "\n" +
"Pubkey: " + contactItem.pubkey + relay_str + pushurl_str + "\n" +
"IP: " + ip_addr_str) {
Column() {
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ fun ContactList(
contactstore.remove(item = ContactItem(name = "",
isConnected = 0,
is_relay = false,
push_url = "",
pubkey = item.pubkey))
GlobalScope.launch(Dispatchers.IO) {
if (is_any_relay(item.pubkey))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ fun AddFriend() = Box {
contactstore.add(item = ContactItem(name = "new Friend #" + friendnum,
isConnected = 0,
pubkey = friend_pubkey!!,
push_url = "",
is_relay = false))
} catch (_: Exception)
{
Expand Down
Loading