mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 11:49:04 +01:00
Check the return value of Modem.start().
This commit is contained in:
@@ -254,8 +254,9 @@ class CountryCodes {
|
|||||||
for(Country c : COUNTRIES) COUNTRY_MAP.put(c.iso3166, c);
|
for(Country c : COUNTRIES) COUNTRY_MAP.put(c.iso3166, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String translate(String number, String fromIso, String toIso) {
|
static String translate(String number, String callerIso, String calleeIso) {
|
||||||
Country from = COUNTRY_MAP.get(fromIso), to = COUNTRY_MAP.get(toIso);
|
Country from = COUNTRY_MAP.get(callerIso);
|
||||||
|
Country to = COUNTRY_MAP.get(calleeIso);
|
||||||
if(from == null || to == null) return null;
|
if(from == null || to == null) return null;
|
||||||
// Strip any prefixes and country codes from the number
|
// Strip any prefixes and country codes from the number
|
||||||
String plusCountryCode = "+" + to.countryCode;
|
String plusCountryCode = "+" + to.countryCode;
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
|
|||||||
LOG.info("Trying to initialise modem on " + portName);
|
LOG.info("Trying to initialise modem on " + portName);
|
||||||
modem = modemFactory.createModem(this, portName);
|
modem = modemFactory.createModem(this, portName);
|
||||||
try {
|
try {
|
||||||
modem.start();
|
if(!modem.start()) continue;
|
||||||
if(LOG.isLoggable(INFO))
|
if(LOG.isLoggable(INFO))
|
||||||
LOG.info("Initialised modem on " + portName);
|
LOG.info("Initialised modem on " + portName);
|
||||||
running = true;
|
running = true;
|
||||||
@@ -101,7 +101,7 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
|
|||||||
for(String portName : serialPortList.getPortNames()) {
|
for(String portName : serialPortList.getPortNames()) {
|
||||||
modem = modemFactory.createModem(this, portName);
|
modem = modemFactory.createModem(this, portName);
|
||||||
try {
|
try {
|
||||||
modem.start();
|
if(!modem.start()) continue;
|
||||||
if(LOG.isLoggable(INFO))
|
if(LOG.isLoggable(INFO))
|
||||||
LOG.info("Initialised modem on " + portName);
|
LOG.info("Initialised modem on " + portName);
|
||||||
return true;
|
return true;
|
||||||
@@ -138,8 +138,8 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Get the ISO 3166 code for the caller's country
|
// Get the ISO 3166 code for the caller's country
|
||||||
String fromIso = callback.getLocalProperties().get("iso3166");
|
String callerIso = callback.getLocalProperties().get("iso3166");
|
||||||
if(StringUtils.isNullOrEmpty(fromIso)) return;
|
if(StringUtils.isNullOrEmpty(callerIso)) return;
|
||||||
// Call contacts one at a time in a random order
|
// Call contacts one at a time in a random order
|
||||||
Map<ContactId, TransportProperties> remote =
|
Map<ContactId, TransportProperties> remote =
|
||||||
callback.getRemoteProperties();
|
callback.getRemoteProperties();
|
||||||
@@ -151,13 +151,13 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
|
|||||||
// Get the ISO 3166 code for the callee's country
|
// Get the ISO 3166 code for the callee's country
|
||||||
TransportProperties properties = remote.get(c);
|
TransportProperties properties = remote.get(c);
|
||||||
if(properties == null) continue;
|
if(properties == null) continue;
|
||||||
String toIso = properties.get("iso3166");
|
String calleeIso = properties.get("iso3166");
|
||||||
if(StringUtils.isNullOrEmpty(toIso)) continue;
|
if(StringUtils.isNullOrEmpty(calleeIso)) continue;
|
||||||
// Get the callee's phone number
|
// Get the callee's phone number
|
||||||
String number = properties.get("number");
|
String number = properties.get("number");
|
||||||
if(StringUtils.isNullOrEmpty(number)) continue;
|
if(StringUtils.isNullOrEmpty(number)) continue;
|
||||||
// Convert the number into direct dialling form
|
// Convert the number into direct dialling form
|
||||||
number = CountryCodes.translate(number, fromIso, toIso);
|
number = CountryCodes.translate(number, callerIso, calleeIso);
|
||||||
if(number == null) continue;
|
if(number == null) continue;
|
||||||
// Dial the number
|
// Dial the number
|
||||||
try {
|
try {
|
||||||
@@ -165,7 +165,7 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
|
|||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
||||||
if(resetModem()) continue;
|
if(resetModem()) continue;
|
||||||
else break;
|
break;
|
||||||
}
|
}
|
||||||
if(LOG.isLoggable(INFO)) LOG.info("Outgoing call connected");
|
if(LOG.isLoggable(INFO)) LOG.info("Outgoing call connected");
|
||||||
ModemTransportConnection conn = new ModemTransportConnection();
|
ModemTransportConnection conn = new ModemTransportConnection();
|
||||||
|
|||||||
Reference in New Issue
Block a user