|
@@ -49,38 +49,61 @@ if [ ! -f $USERS_FILE ]; then
|
49
|
49
|
exit 0
|
50
|
50
|
fi
|
51
|
51
|
|
52
|
|
-data=$(zenity --entry --title="Visit IPFS site" --text="Enter the username or Tox ID for the site you wish to visit")
|
53
|
|
-sel=$?
|
54
|
|
-case $sel in
|
|
52
|
+USERS_FILE_LINES=$(wc -l $USERS_FILE | awk -F ' ' '{print $1}')
|
|
53
|
+
|
|
54
|
+if [ $USERS_FILE_LINES -gt 200 ]; then
|
|
55
|
+ # If there are more than a Dunbar number of peers then ask for the peer name or ID
|
|
56
|
+ data=$(zenity --entry --title="Visit IPFS site" --text="Enter the username or Tox ID for the site you wish to visit")
|
|
57
|
+ sel=$?
|
|
58
|
+ case $sel in
|
55
|
59
|
0)
|
56
|
|
- TOX_USERNAME_OR_ID="$data"
|
57
|
|
- if [ ${#TOX_USERNAME_OR_ID} -gt 0 ]; then
|
58
|
|
- if ! grep -q "$TOX_USERNAME_OR_ID" $USERS_FILE; then
|
59
|
|
- TOX_ID="$TOX_USERNAME_OR_ID"
|
60
|
|
- else
|
61
|
|
- TOX_ID=$(cat "$USERS_FILE" | grep "$TOX_USERNAME_OR_ID" | head -n 1 | sed "s|$TOX_USERNAME_OR_ID ||g" | sed -e 's/^[[:space:]]*//')
|
62
|
|
- fi
|
|
60
|
+ TOX_USERNAME_OR_ID="$data"
|
|
61
|
+ if [ ${#TOX_USERNAME_OR_ID} -gt 0 ]; then
|
|
62
|
+ if ! grep -q "$TOX_USERNAME_OR_ID" $USERS_FILE; then
|
|
63
|
+ TOX_ID="$TOX_USERNAME_OR_ID"
|
|
64
|
+ else
|
|
65
|
+ TOX_ID=$(cat "$USERS_FILE" | grep "$TOX_USERNAME_OR_ID" | head -n 1 | sed "s|$TOX_USERNAME_OR_ID ||g" | sed -e 's/^[[:space:]]*//')
|
|
66
|
+ fi
|
63
|
67
|
|
64
|
|
- if [ ${#TOX_ID} -gt 5 ]; then
|
65
|
|
- if ! grep -q "$TOX_ID" $IPFS_USERS_FILE; then
|
66
|
|
- dialog --title $"Visit IPFS site" \
|
67
|
|
- --backtitle $"Freedombone mesh" \
|
68
|
|
- --msgbox $"An IPFS site was not found for the user '$TOX_USERNAME_OR_ID'" 8 60
|
69
|
|
- exit 3
|
70
|
|
- fi
|
71
|
|
- IPFS_FULL_URL=${IPFS_URL}/$(cat "$IPFS_USERS_FILE" | grep $TOX_ID | head -n 1 | awk -F ':' '{print $2}')
|
72
|
|
- clear
|
73
|
|
- echo $'Opening browser. Please wait...'
|
74
|
|
- pkill $BROWSER
|
75
|
|
- setsid sh -c "$BROWSER $BROWSER_OPTIONS $IPFS_FULL_URL$SUFFIX" > /dev/null 2>&1 < /dev/null &
|
|
68
|
+ if [ ${#TOX_ID} -gt 5 ]; then
|
|
69
|
+ if ! grep -q "$TOX_ID" $IPFS_USERS_FILE; then
|
|
70
|
+ zenity --info --title $"Visit a site" --text $"An IPFS site was not found for the user '$TOX_USERNAME_OR_ID'" --width 500
|
|
71
|
+ exit 3
|
|
72
|
+ fi
|
|
73
|
+ IPFS_FULL_URL=${IPFS_URL}/$(cat "$IPFS_USERS_FILE" | grep $TOX_ID | head -n 1 | awk -F ':' '{print $2}')
|
|
74
|
+ pkill $BROWSER
|
|
75
|
+ setsid sh -c "$BROWSER $BROWSER_OPTIONS $IPFS_FULL_URL$SUFFIX" > /dev/null 2>&1 < /dev/null &
|
76
|
76
|
|
77
|
|
- # Need to wait a while for the browser to begin opening
|
78
|
|
- sleep 3
|
79
|
|
- fi
|
80
|
|
- else
|
81
|
|
- exit 1
|
|
77
|
+ # Need to wait a while for the browser to begin opening
|
|
78
|
+ sleep 3
|
82
|
79
|
fi
|
83
|
|
- ;;
|
84
|
|
-esac
|
|
80
|
+ else
|
|
81
|
+ exit 1
|
|
82
|
+ fi
|
|
83
|
+ ;;
|
|
84
|
+ esac
|
|
85
|
+else
|
|
86
|
+ # If there are a relatively small number of users then choose from a list
|
|
87
|
+ TOX_ID=$(
|
|
88
|
+ cat $USERS_FILE | \
|
|
89
|
+ awk -F ' ' '{
|
|
90
|
+ for(i=1;i<=NF;i++){
|
|
91
|
+ print $i;
|
|
92
|
+ }
|
|
93
|
+}' | \
|
|
94
|
+ zenity --list \
|
|
95
|
+ --title='Visit the site of another user' \
|
|
96
|
+ --column='Username' --column='Tox ID' \
|
|
97
|
+ --print-column=2 --hide-column=2 --width=300 --height=400)
|
|
98
|
+ if [ ! $TOX_ID ]; then
|
|
99
|
+ exit 0
|
|
100
|
+ fi
|
|
101
|
+ IPFS_FULL_URL=${IPFS_URL}/$(cat "$IPFS_USERS_FILE" | grep $TOX_ID | head -n 1 | awk -F ':' '{print $2}')
|
|
102
|
+ pkill $BROWSER
|
|
103
|
+ setsid sh -c "$BROWSER $BROWSER_OPTIONS $IPFS_FULL_URL$SUFFIX" > /dev/null 2>&1 < /dev/null &
|
|
104
|
+
|
|
105
|
+ # Need to wait a while for the browser to begin opening
|
|
106
|
+ sleep 3
|
|
107
|
+fi
|
85
|
108
|
|
86
|
109
|
exit 0
|