diff --git a/briar-core/src/net/sf/briar/plugins/modem/CountryCodes.java b/briar-core/src/net/sf/briar/plugins/modem/CountryCodes.java index 9aff2db950e3fe2217718d76a017894f8df080ba..e1e66fffc457a46a4b639033ba54f0c8505c9691 100644 --- a/briar-core/src/net/sf/briar/plugins/modem/CountryCodes.java +++ b/briar-core/src/net/sf/briar/plugins/modem/CountryCodes.java @@ -254,8 +254,9 @@ class CountryCodes { for(Country c : COUNTRIES) COUNTRY_MAP.put(c.iso3166, c); } - static String translate(String number, String fromIso, String toIso) { - Country from = COUNTRY_MAP.get(fromIso), to = COUNTRY_MAP.get(toIso); + static String translate(String number, String callerIso, String calleeIso) { + Country from = COUNTRY_MAP.get(callerIso); + Country to = COUNTRY_MAP.get(calleeIso); if(from == null || to == null) return null; // Strip any prefixes and country codes from the number String plusCountryCode = "+" + to.countryCode; diff --git a/briar-core/src/net/sf/briar/plugins/modem/ModemPlugin.java b/briar-core/src/net/sf/briar/plugins/modem/ModemPlugin.java index 7cd0e0af07c0961abd3b1920ba1886d0a7364eee..f30c035bf54ca1e2bcc937ca64bb98611069c3dc 100644 --- a/briar-core/src/net/sf/briar/plugins/modem/ModemPlugin.java +++ b/briar-core/src/net/sf/briar/plugins/modem/ModemPlugin.java @@ -73,7 +73,7 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback { LOG.info("Trying to initialise modem on " + portName); modem = modemFactory.createModem(this, portName); try { - modem.start(); + if(!modem.start()) continue; if(LOG.isLoggable(INFO)) LOG.info("Initialised modem on " + portName); running = true; @@ -101,7 +101,7 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback { for(String portName : serialPortList.getPortNames()) { modem = modemFactory.createModem(this, portName); try { - modem.start(); + if(!modem.start()) continue; if(LOG.isLoggable(INFO)) LOG.info("Initialised modem on " + portName); return true; @@ -138,8 +138,8 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback { return; } // Get the ISO 3166 code for the caller's country - String fromIso = callback.getLocalProperties().get("iso3166"); - if(StringUtils.isNullOrEmpty(fromIso)) return; + String callerIso = callback.getLocalProperties().get("iso3166"); + if(StringUtils.isNullOrEmpty(callerIso)) return; // Call contacts one at a time in a random order Map<ContactId, TransportProperties> remote = callback.getRemoteProperties(); @@ -151,13 +151,13 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback { // Get the ISO 3166 code for the callee's country TransportProperties properties = remote.get(c); if(properties == null) continue; - String toIso = properties.get("iso3166"); - if(StringUtils.isNullOrEmpty(toIso)) continue; + String calleeIso = properties.get("iso3166"); + if(StringUtils.isNullOrEmpty(calleeIso)) continue; // Get the callee's phone number String number = properties.get("number"); if(StringUtils.isNullOrEmpty(number)) continue; // Convert the number into direct dialling form - number = CountryCodes.translate(number, fromIso, toIso); + number = CountryCodes.translate(number, callerIso, calleeIso); if(number == null) continue; // Dial the number try { @@ -165,7 +165,7 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback { } catch(IOException e) { if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e); if(resetModem()) continue; - else break; + break; } if(LOG.isLoggable(INFO)) LOG.info("Outgoing call connected"); ModemTransportConnection conn = new ModemTransportConnection();