Skip to content

Commit f2550cb

Browse files
committed
fix error message for unavailable I2P server
Signed-off-by: R4SAS <[email protected]>
1 parent 7534860 commit f2550cb

File tree

6 files changed

+16
-2
lines changed

6 files changed

+16
-2
lines changed

Diff for: src/main/java/eu/siacs/conversations/entities/Account.java

+3
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ public enum State {
801801
INCOMPATIBLE_SERVER,
802802
INCOMPATIBLE_CLIENT,
803803
TOR_NOT_AVAILABLE,
804+
I2P_NOT_AVAILABLE,
804805
DOWNGRADE_ATTACK,
805806
SESSION_FAILURE,
806807
BIND_FAILURE,
@@ -876,6 +877,8 @@ public int getReadableId() {
876877
return R.string.account_status_incompatible_client;
877878
case TOR_NOT_AVAILABLE:
878879
return R.string.account_status_tor_unavailable;
880+
case I2P_NOT_AVAILABLE:
881+
return R.string.account_status_i2p_unavailable;
879882
case BIND_FAILURE:
880883
return R.string.account_status_bind_failure;
881884
case SESSION_FAILURE:

Diff for: src/main/java/eu/siacs/conversations/services/XmppConnectionService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ private synchronized void manageAccountConnectionStates(final String action, fin
941941

942942
private void handleOrbotStartedEvent() {
943943
for (final Account account : accounts) {
944-
if (account.getStatus() == Account.State.TOR_NOT_AVAILABLE) {
944+
if (account.getStatus() == Account.State.TOR_NOT_AVAILABLE || account.getStatus() == Account.State.I2P_NOT_AVAILABLE) {
945945
reconnectAccount(account, true, false);
946946
}
947947
}

Diff for: src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java

+5
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ public void onClick(final View v) {
175175

176176
XmppConnection connection = mAccount == null ? null : mAccount.getXmppConnection();
177177
final boolean startOrbot = mAccount != null && mAccount.getStatus() == Account.State.TOR_NOT_AVAILABLE;
178+
final boolean startI2P = mAccount != null && mAccount.getStatus() == Account.State.I2P_NOT_AVAILABLE;
178179
if (startOrbot) {
179180
if (TorServiceUtils.isOrbotInstalled(EditAccountActivity.this)) {
180181
TorServiceUtils.startOrbot(EditAccountActivity.this, REQUEST_ORBOT);
@@ -184,6 +185,10 @@ public void onClick(final View v) {
184185
return;
185186
}
186187

188+
if (startI2P) {
189+
return; // just exit
190+
}
191+
187192
if (inNeedOfSaslAccept()) {
188193
mAccount.resetPinnedMechanism();
189194
if (!xmppConnectionService.updateAccount(mAccount)) {

Diff for: src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,11 @@ protected void connect() {
510510
| SocksSocketFactory.HostNotFoundException e) {
511511
this.changeStatus(Account.State.SERVER_NOT_FOUND);
512512
} catch (final SocksSocketFactory.SocksProxyNotFoundException e) {
513-
this.changeStatus(Account.State.TOR_NOT_AVAILABLE);
513+
if (!account.isI2P()) {
514+
this.changeStatus(Account.State.TOR_NOT_AVAILABLE);
515+
} else {
516+
this.changeStatus(Account.State.I2P_NOT_AVAILABLE);
517+
}
514518
} catch (final IOException | XmlPullParserException e) {
515519
Log.d(Config.LOGTAG, account.getJid().asBareJid().toString() + ": " + e.getMessage());
516520
this.changeStatus(Account.State.OFFLINE);

Diff for: src/main/res/values-ru/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@
462462
<string name="download_failed_could_not_connect">Загрузка не удалась: не удалось подключиться к серверу</string>
463463
<string name="download_failed_could_not_write_file">Загрузка не удалась: ошибка записи файла</string>
464464
<string name="account_status_tor_unavailable">Сеть Tor недоступна</string>
465+
<string name="account_status_i2p_unavailable">Сеть I2P недоступна</string>
465466
<string name="account_status_bind_failure">Ошибка связывания</string>
466467
<string name="account_status_host_unknown">Сервер не ответственен за этот домен</string>
467468
<string name="server_info_broken">Повреждено</string>

Diff for: src/main/res/values/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@
470470
<string name="download_failed_could_not_write_file">Download failed: Could not write file</string>
471471
<string name="download_failed_invalid_file">Download failed: Invalid file</string>
472472
<string name="account_status_tor_unavailable">Tor network unavailable</string>
473+
<string name="account_status_i2p_unavailable">I2P network unavailable</string>
473474
<string name="account_status_bind_failure">Bind failure</string>
474475
<string name="account_status_host_unknown">The server is not responsible for this domain</string>
475476
<string name="server_info_broken">Broken</string>

0 commit comments

Comments
 (0)