mirror of https://github.com/OpenVPN/openvpn-gui
Fix display of assigned IPs when IPv4 address is absent
- In tray info do not skip the address when v4 ip is absent - When combining two strings do not add the separator (comma) if either is empty. Signed-off-by: Selva Nair <selva.nair@gmail.com>pull/249/head
parent
3ba0615140
commit
b53c8a758e
8
misc.c
8
misc.c
|
@ -479,7 +479,7 @@ validate_input(const WCHAR *input, const WCHAR *exclude)
|
|||
return (wcspbrk(input, exclude) == NULL);
|
||||
}
|
||||
|
||||
/* Concatenate two wide strings with a separator */
|
||||
/* Concatenate two wide strings with a separator -- if either string is empty separator not added */
|
||||
void
|
||||
wcs_concat2(WCHAR *dest, int len, const WCHAR *src1, const WCHAR *src2, const WCHAR *sep)
|
||||
{
|
||||
|
@ -488,10 +488,12 @@ wcs_concat2(WCHAR *dest, int len, const WCHAR *src1, const WCHAR *src2, const WC
|
|||
if (!dest || len == 0)
|
||||
return;
|
||||
|
||||
if (src1 && src2 && src2[0])
|
||||
if (src1 && src2 && src1[0] && src2[0])
|
||||
n = swprintf(dest, len, L"%s%s%s", src1, sep, src2);
|
||||
else if (src1)
|
||||
else if (src1 && src1[0])
|
||||
n = swprintf(dest, len, L"%s", src1);
|
||||
else if (src2 && src2[0])
|
||||
n = swprintf(dest, len, L"%s", src2);
|
||||
|
||||
if (n < 0 || n >= len) /*swprintf failed */
|
||||
n = 0;
|
||||
|
|
12
tray.c
12
tray.c
|
@ -280,13 +280,11 @@ SetTrayIcon(conn_state_t state)
|
|||
_tcsncat(msg, LoadLocalizedString(IDS_TIP_CONNECTED_SINCE), _countof(msg) - _tcslen(msg) - 1);
|
||||
_tcsncat(msg, time, _countof(msg) - _tcslen(msg) - 1);
|
||||
|
||||
if ( _tcslen(c->ip) > 0) {
|
||||
/* concatenate ipv4 and ipv6 addresses into one string */
|
||||
WCHAR ip[64];
|
||||
wcs_concat2(ip, _countof(ip), c->ip, c->ipv6, L", ");
|
||||
WCHAR *assigned_ip = LoadLocalizedString(IDS_TIP_ASSIGNED_IP, ip);
|
||||
_tcsncat(msg, assigned_ip, _countof(msg) - _tcslen(msg) - 1);
|
||||
}
|
||||
/* concatenate ipv4 and ipv6 addresses into one string */
|
||||
WCHAR ip[64];
|
||||
wcs_concat2(ip, _countof(ip), c->ip, c->ipv6, L", ");
|
||||
WCHAR *assigned_ip = LoadLocalizedString(IDS_TIP_ASSIGNED_IP, ip);
|
||||
_tcsncat(msg, assigned_ip, _countof(msg) - _tcslen(msg) - 1);
|
||||
}
|
||||
|
||||
icon_id = ID_ICO_CONNECTING;
|
||||
|
|
Loading…
Reference in New Issue