@Override public Address getSingleAddress( AddressType t, Collection<Address> addresses, Location whoIsAsking) { if (addresses == null || addresses.size() == 0) { return null; } for (DnsProvider p : getProviders()) { Address rewrite = p.getAddress(this, t, addresses, whoIsAsking); if (rewrite != null) { return rewrite; } } Iterator<Address> i = addresses.iterator(); Address first = i.next(); if (addresses.size() == 1 || whoIsAsking == null) { return first; } // return the address local to who is asking if available Address a = first; while (a != null) { if (a.getAddress().equals(whoIsAsking.getAddress())) { return a; } a = (i.hasNext() ? i.next() : null); } // first is as good as any other return first; }
/** * Music on hold implementation requires that ~~mh~u calls are forwarded to Media Server. We are * adding the rule here. */ public List<DialingRule> getDialingRules(Location location) { MohAddressFactory factory = getAddressFactory(); Address mediaAddress = factory.getMediaAddress(location); if (mediaAddress == null) { return Collections.emptyList(); } DialingRule rule = new MohRule(mediaAddress.getAddress(), factory.getFilesMohUser()); return Collections.singletonList(rule); }
void write( Writer wtr, IvrSettings settings, Domain domain, Location location, String mwiAddresses, int mwiPort, Address restApi, Address adminApi, Address apacheApi, Address imApi, Address imbotApi, Address fsEvent) throws IOException { KeyValueConfiguration config = KeyValueConfiguration.equalsSeparated(wtr); config.writeSettings(settings.getSettings()); config.write("freeswitch.eventSocketPort", fsEvent.getPort()); // potential bug: name "operator" could be changed by admin. this should be configurable // and linked with vm dialing rule config.write("ivr.operatorAddr", "sip:operator@" + domain.getName()); // required services if (mwiAddresses == null) { throw new ConfigException("MWI feature needs to be enabled. No addresses found."); } config.write("ivr.mwiAddresses", mwiAddresses); config.write("ivr.mwiPort", mwiPort); if (adminApi == null) { throw new ConfigException("Admin feature needs to be enabled. No addresses found."); } config.write("ivr.configUrl", adminApi.toString()); if (apacheApi != null) { config.write("ivr.emailAddressUrl", apacheApi.toString()); } // optional services if (restApi != null) { config.write("ivr.3pccSecureUrl", restApi.toString()); config.write("ivr.callHistoryUrl", restApi.toString() + "/cdr/"); } if (imApi != null) { config.write("ivr.openfireHost", imApi.getAddress()); config.write("ivr.openfireXmlRpcPort", imApi.getPort()); } if (imbotApi != null) { config.write("ivr.sendIMUrl", imbotApi.toString()); } }