Allow globals in the providers.xml
There are two ways globals can be specified. There can be only one global character ['*'] and/or multiple wildcard characters ['?']. The global will match zero or more characters. The wildcard will match any character. bug 4090086 Change-Id: I07e3edebd1fe989094c68cf047ce5bc9fb91aba0
This commit is contained in:
parent
566c4f9117
commit
5e4f1c3872
@ -75,21 +75,44 @@
|
|||||||
"smtp+tls+trustallcerts". This should only used when necessary, as it
|
"smtp+tls+trustallcerts". This should only used when necessary, as it
|
||||||
could allow a spoofed server to intercept password and mail.
|
could allow a spoofed server to intercept password and mail.
|
||||||
|
|
||||||
The URIs should be full templates for connection, including a port if
|
The URIs must contain all of the information to make a connection,
|
||||||
the service uses a non-default port. The default ports are as follows:
|
including a port if the service uses a non-default port. The default
|
||||||
|
ports are as follows:
|
||||||
imap 143 pop3 110 smtp 587
|
imap 143 pop3 110 smtp 587
|
||||||
imap+tls+ 143 pop3+tls+ 110 smtp+tls+ 587
|
imap+tls+ 143 pop3+tls+ 110 smtp+tls+ 587
|
||||||
imap+ssl+ 993 pop3+ssl+ 995 smtp+ssl+ 465
|
imap+ssl+ 993 pop3+ssl+ 995 smtp+ssl+ 465
|
||||||
|
|
||||||
|
==== DOMAIN PATTERNS ====
|
||||||
|
|
||||||
|
Often times a hosting company will have multiple mail server addresses. Often
|
||||||
|
times used for load balancing or based upon geographical boundaries. In these
|
||||||
|
cases, it would be unwieldy to maintain a list of 2-dozen providers that all
|
||||||
|
point the essentially the same mail server. To alleviate this, domains may
|
||||||
|
contain pattern matching characters that can be used to match user entered
|
||||||
|
domains without knowing the exact domain.
|
||||||
|
|
||||||
|
The domain attribute may specify a most one global character - a '*'. The
|
||||||
|
global character matches zero or more characters. This is a very greedy wild
|
||||||
|
card and may lead to unexpected matches.
|
||||||
|
|
||||||
|
The alternate is the wild card character - a '?'. The wide card character
|
||||||
|
matches any single character. This is very useful when the number of characters
|
||||||
|
is know (such as the country code in the domain).
|
||||||
|
|
||||||
|
==== TEMPLATES ====
|
||||||
|
|
||||||
|
Both the username and uri attributes (for both incoming and outgoing elements)
|
||||||
|
are templates.
|
||||||
|
|
||||||
The username attribute is used to supply a template for the username
|
The username attribute is used to supply a template for the username
|
||||||
that will be presented to the server. This username is built from a
|
that will be presented to the server. This username is built from a
|
||||||
set of variables that are substituted with parts of the user
|
set of variables that are substituted with parts of the user specified
|
||||||
specified email address.
|
email address.
|
||||||
|
|
||||||
Valid substitution values for the username attribute are:
|
Valid substitution values for all templates are:
|
||||||
$email - the email address the user entered
|
$email - the email address the user entered
|
||||||
$user - the value before the @ sign in the email address the user entered
|
$user - the string before the @ sign in the email address the user entered
|
||||||
$domain - the value after the @ signin the email address the user entered
|
$domain - the string after the @ sign in the email address the user entered
|
||||||
|
|
||||||
The username attribute MUST be specified for the incoming element, so the POP3 or IMAP
|
The username attribute MUST be specified for the incoming element, so the POP3 or IMAP
|
||||||
server can identify the mailbox to be opened.
|
server can identify the mailbox to be opened.
|
||||||
@ -357,99 +380,11 @@
|
|||||||
</provider>
|
</provider>
|
||||||
|
|
||||||
<!-- Yahoo! country-specific email domains -->
|
<!-- Yahoo! country-specific email domains -->
|
||||||
<provider id="yahoo-ar" label="Yahoo! Argentina" domain="yahoo.com.ar">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-y7" label="Yahoo!7" domain="y7mail.com">
|
<provider id="yahoo-y7" label="Yahoo!7" domain="y7mail.com">
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
||||||
</provider>
|
</provider>
|
||||||
<provider id="yahoo-au" label="Yahoo! Australia" domain="yahoo.com.au">
|
<provider id="kimo" label="Yahoo! Taiwan" domain="kimo.com">
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-bg" label="Yahoo! Bulgaria" domain="yahoo.bg">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-br" label="Yahoo! Brazil" domain="yahoo.com.br">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-ca" label="Yahoo! Canada" domain="yahoo.ca">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-cl" label="Yahoo! Cote d'Ivoire" domain="yahoo.cl">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-com-cn" label="Yahoo! China" domain="yahoo.com.cn">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-cn" label="Yahoo! China" domain="yahoo.cn">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-co" label="Yahoo! Colombia" domain="yahoo.com.co">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-cz" label="Yahoo! Czech Republic" domain="yahoo.cz">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-de" label="Yahoo! Germany" domain="yahoo.de">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-dk" label="Yahoo! Denmark" domain="yahoo.dk">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-ec" label="Yahoo! Ecuador" domain="yahoo.com.ec">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-ee" label="Yahoo! Estonia" domain="yahoo.ee">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-es" label="Yahoo! Spain" domain="yahoo.es">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-fr" label="Yahoo! France" domain="yahoo.fr">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-gr" label="Yahoo! Greece" domain="yahoo.gr">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-hk" label="Yahoo! Hong Kong" domain="yahoo.com.hk">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-hu" label="Yahoo! Hungary" domain="yahoo.hu">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-id" label="Yahoo! Indonesia" domain="yahoo.co.id">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-ie" label="Yahoo! Ireland" domain="yahoo.ie">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-in" label="Yahoo! India" domain="yahoo.in">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-it" label="Yahoo! Italy" domain="yahoo.it">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
||||||
</provider>
|
</provider>
|
||||||
@ -463,107 +398,15 @@
|
|||||||
<incoming uri="pop3+ssl+://android.pop.mail.yahoo.co.jp" username="$user" />
|
<incoming uri="pop3+ssl+://android.pop.mail.yahoo.co.jp" username="$user" />
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.co.jp" username="$user" />
|
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.co.jp" username="$user" />
|
||||||
</provider>
|
</provider>
|
||||||
<provider id="yahoo-kr" label="Yahoo! Republic of Korea" domain="yahoo.co.kr">
|
<provider id="yahoo-com-XX" label="Country specific Yahoo!" domain="yahoo.com.??">
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
||||||
</provider>
|
</provider>
|
||||||
<provider id="yahoo-lt" label="Yahoo! Lithuania" domain="yahoo.lt">
|
<provider id="yahoo-co-XX" label="Country specific Yahoo!" domain="yahoo.co.??">
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
||||||
</provider>
|
</provider>
|
||||||
<provider id="yahoo-lv" label="Yahoo! Latvia" domain="yahoo.lv">
|
<provider id="yahoo-XX" label="Country specific Yahoo!" domain="yahoo.??">
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-mx" label="Yahoo! Mexico" domain="yahoo.com.mx">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-my" label="Yahoo! Malaysia" domain="yahoo.com.my">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-ng" label="Yahoo! Nigeria" domain="yahoo.com.ng">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-no" label="Yahoo! Norway" domain="yahoo.no">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-nz" label="Yahoo! New Zealand" domain="yahoo.co.nz">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-pe" label="Yahoo! Peru" domain="yahoo.com.pe">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-ph" label="Yahoo! Philippines" domain="yahoo.com.ph">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-pk" label="Yahoo! Pakistan" domain="yahoo.com.pk">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-pl" label="Yahoo! Poland" domain="yahoo.pl">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-ru" label="Yahoo! Russia" domain="yahoo.ru">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-ro" label="Yahoo! Romania" domain="yahoo.ro">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-se" label="Yahoo! Sweden" domain="yahoo.se">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-sg" label="Yahoo! Singapore" domain="yahoo.com.sg">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-th" label="Yahoo! Thailand" domain="yahoo.co.th">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-tr" label="Yahoo! Turkey" domain="yahoo.com.tr">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="kimo" label="Yahoo! Taiwan" domain="kimo.com">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-tw" label="Yahoo! Taiwan" domain="yahoo.com.tw">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-ua" label="Yahoo! Ukraine" domain="yahoo.ua">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-uk" label="Yahoo! UK" domain="yahoo.co.uk">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-ve" label="Yahoo! Venezuela" domain="yahoo.com.ve">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-vn" label="Yahoo! Vietnam" domain="yahoo.com.vn">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="yahoo-za" label="Yahoo! South Africa" domain="yahoo.co.za">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
|
||||||
</provider>
|
|
||||||
<provider id="xtra" label="Yahoo! Xtra" domain="xtra.co.nz">
|
|
||||||
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
<incoming uri="imap+ssl+://android.imap.mail.yahoo.com" username="$email" />
|
||||||
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
<outgoing uri="smtp+ssl+://android.smtp.mail.yahoo.com" username="$email" />
|
||||||
</provider>
|
</provider>
|
||||||
|
@ -31,9 +31,15 @@ import android.util.Log;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class AccountSettingsUtils {
|
public class AccountSettingsUtils {
|
||||||
|
|
||||||
|
/** Pattern to match globals in the domain */
|
||||||
|
private final static Pattern DOMAIN_GLOB_PATTERN = Pattern.compile("\\*");
|
||||||
|
/** Will match any, single character */
|
||||||
|
private final static char WILD_CHARACTER = '?';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commits the UI-related settings of an account to the provider. This is static so that it
|
* Commits the UI-related settings of an account to the provider. This is static so that it
|
||||||
* can be used by the various account activities. If the account has never been saved, this
|
* can be used by the various account activities. If the account has never been saved, this
|
||||||
@ -149,32 +155,34 @@ public class AccountSettingsUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compares the two strings. glob may have at most a single global character ('*') that
|
* Returns if the string <code>s1</code> matches the string <code>s2</code>. The string
|
||||||
* will match any number of characters in the input string.
|
* <code>s2</code> may contain any number of wildcards -- a '?' character -- and/or a
|
||||||
* @return true if the strings match. otherwise, false.
|
* single global character -- a '*' character. Wildcards match any, single character
|
||||||
* @throws IllegalArgumentException if the strings are null or glob has multiple globals.
|
* while a global character matches zero or more characters.
|
||||||
|
* @throws IllegalArgumentException if either string is null or <code>s2</code> has
|
||||||
|
* multiple globals.
|
||||||
*/
|
*/
|
||||||
/*package*/ static boolean globMatchIgnoreCase(String in, String glob)
|
/*package*/ static boolean globMatchIgnoreCase(String s1, String s2)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
if (in == null || glob == null) {
|
if (s1 == null || s2 == null) {
|
||||||
throw new IllegalArgumentException("one or both strings are null");
|
throw new IllegalArgumentException("one or both strings are null");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle the possible global in the domain name
|
// Handle the possible global in the domain name
|
||||||
String[] globParts = glob.split("\\*");
|
String[] globParts = DOMAIN_GLOB_PATTERN.split(s2);
|
||||||
String inLower = in.toLowerCase();
|
|
||||||
switch (globParts.length) {
|
switch (globParts.length) {
|
||||||
case 1:
|
case 1:
|
||||||
// No globals; test for simple equality
|
// No globals; test for simple equality
|
||||||
if (!inLower.equals(globParts[0].toLowerCase())) {
|
if (!wildEqualsIgnoreCase(s1, globParts[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// Global; test the front & end parts of the domain
|
// Global; test the front & end parts of the domain
|
||||||
String d1 = globParts[0].toLowerCase();
|
String d1 = globParts[0];
|
||||||
String d2 = globParts[1].toLowerCase();
|
String d2 = globParts[1];
|
||||||
if (!inLower.startsWith(d1) || !inLower.substring(d1.length()).endsWith(d2)) {
|
if (!wildStartsWithIgnoreCase(s1, d1) ||
|
||||||
|
!wildEndsWithIgnoreCase(s1.substring(d1.length()), d2)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -184,6 +192,62 @@ public class AccountSettingsUtils {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if the string <code>s1</code> equals the string <code>s2</code>. The string
|
||||||
|
* <code>s2</code> may contain zero or more wildcards -- a '?' character.
|
||||||
|
* @throws IllegalArgumentException if the strings are null.
|
||||||
|
*/
|
||||||
|
/*package*/ static boolean wildEqualsIgnoreCase(String s1, String s2)
|
||||||
|
throws IllegalArgumentException {
|
||||||
|
if (s1 == null || s2 == null) {
|
||||||
|
throw new IllegalArgumentException("one or both strings are null");
|
||||||
|
}
|
||||||
|
if (s1.length() != s2.length()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
char[] charArray1 = s1.toLowerCase().toCharArray();
|
||||||
|
char[] charArray2 = s2.toLowerCase().toCharArray();
|
||||||
|
for (int i = 0; i < charArray2.length; i++) {
|
||||||
|
if (charArray2[i] == WILD_CHARACTER || charArray1[i] == charArray2[i]) continue;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if the string <code>s1</code> starts with the string <code>s2</code>. The string
|
||||||
|
* <code>s2</code> may contain zero or more wildcards -- a '?' character.
|
||||||
|
* @throws IllegalArgumentException if the strings are null.
|
||||||
|
*/
|
||||||
|
/*package*/ static boolean wildStartsWithIgnoreCase(String s1, String s2)
|
||||||
|
throws IllegalArgumentException {
|
||||||
|
if (s1 == null || s2 == null) {
|
||||||
|
throw new IllegalArgumentException("one or both strings are null");
|
||||||
|
}
|
||||||
|
if (s1.length() < s2.length()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
s1 = s1.substring(0, s2.length());
|
||||||
|
return wildEqualsIgnoreCase(s1, s2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if the string <code>s1</code> ends with the string <code>s2</code>. The string
|
||||||
|
* <code>s2</code> may contain zero or more wildcards -- a '?' character.
|
||||||
|
* @throws IllegalArgumentException if the strings are null.
|
||||||
|
*/
|
||||||
|
/*package*/ static boolean wildEndsWithIgnoreCase(String s1, String s2)
|
||||||
|
throws IllegalArgumentException {
|
||||||
|
if (s1 == null || s2 == null) {
|
||||||
|
throw new IllegalArgumentException("one or both strings are null");
|
||||||
|
}
|
||||||
|
if (s1.length() < s2.length()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
s1 = s1.substring(s1.length() - s2.length(), s1.length());
|
||||||
|
return wildEqualsIgnoreCase(s1, s2);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to get the given attribute as a String resource first, and if it fails
|
* Attempts to get the given attribute as a String resource first, and if it fails
|
||||||
* returns the attribute as a simple String value.
|
* returns the attribute as a simple String value.
|
||||||
@ -216,6 +280,12 @@ public class AccountSettingsUtils {
|
|||||||
public String outgoingUri;
|
public String outgoingUri;
|
||||||
public String outgoingUsername;
|
public String outgoingUsername;
|
||||||
public String note;
|
public String note;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expands templates in all of the provider fields that support them. Currently,
|
||||||
|
* templates are used in 4 fields -- incoming and outgoing URI and user name.
|
||||||
|
* @param email user-specified data used to replace template values
|
||||||
|
*/
|
||||||
public void expandTemplates(String email) {
|
public void expandTemplates(String email) {
|
||||||
String[] emailParts = email.split("@");
|
String[] emailParts = email.split("@");
|
||||||
String user = emailParts[0];
|
String user = emailParts[0];
|
||||||
@ -225,6 +295,11 @@ public class AccountSettingsUtils {
|
|||||||
outgoingUri = expandTemplate(outgoingUriTemplate, email, user);
|
outgoingUri = expandTemplate(outgoingUriTemplate, email, user);
|
||||||
outgoingUsername = expandTemplate(outgoingUsernameTemplate, email, user);
|
outgoingUsername = expandTemplate(outgoingUsernameTemplate, email, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces all parameterized values in the given template. The values replaced are
|
||||||
|
* $domain, $user and $email.
|
||||||
|
*/
|
||||||
private String expandTemplate(String template, String email, String user) {
|
private String expandTemplate(String template, String email, String user) {
|
||||||
String returnString = template;
|
String returnString = template;
|
||||||
returnString = returnString.replaceAll("\\$email", email);
|
returnString = returnString.replaceAll("\\$email", email);
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
<incoming uri="pop3://pop-server.firstonewins.com" username="$email" />
|
<incoming uri="pop3://pop-server.firstonewins.com" username="$email" />
|
||||||
<outgoing uri="smtp://mobile-smtp.roadrunner.com" username="$email" />
|
<outgoing uri="smtp://mobile-smtp.roadrunner.com" username="$email" />
|
||||||
</provider>
|
</provider>
|
||||||
<provider id="rr-global" label="RoadRunner" domain="*.rr.com">
|
<provider id="rr-global" label="RoadRunner" domain="*.rr.???">
|
||||||
<incoming uri="pop3://pop-server.$domain" username="$email" />
|
<incoming uri="pop3://pop-server.$domain" username="$email" />
|
||||||
<outgoing uri="smtp://mobile-smtp.roadrunner.com" username="$email" />
|
<outgoing uri="smtp://mobile-smtp.roadrunner.com" username="$email" />
|
||||||
</provider>
|
</provider>
|
||||||
|
@ -99,9 +99,40 @@ public class AccountSettingsUtilsTests extends AndroidTestCase {
|
|||||||
assertNull(testProvider);
|
assertNull(testProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGlobMatchIgnoreCase() {
|
public void testGlobEndsWithIgnoreCase() {
|
||||||
boolean testMatch;
|
assertTrue(AccountSettingsUtils.wildEndsWithIgnoreCase(
|
||||||
|
"yahoo.com.tw", ".??"));
|
||||||
|
assertTrue(AccountSettingsUtils.wildEndsWithIgnoreCase(
|
||||||
|
"abcd", "a??d"));
|
||||||
|
assertFalse(AccountSettingsUtils.wildEndsWithIgnoreCase(
|
||||||
|
"yahoo.com.tw.foo.com", ".??"));
|
||||||
|
assertFalse(AccountSettingsUtils.wildEndsWithIgnoreCase(
|
||||||
|
"abc", "a??d"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGlobStartsWithIgnoreCase() {
|
||||||
|
assertTrue(AccountSettingsUtils.wildStartsWithIgnoreCase(
|
||||||
|
"tw.yahoo.com", "??."));
|
||||||
|
assertTrue(AccountSettingsUtils.wildStartsWithIgnoreCase(
|
||||||
|
"abcdxyz", "a??d"));
|
||||||
|
assertFalse(AccountSettingsUtils.wildStartsWithIgnoreCase(
|
||||||
|
"abc", "a??d"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGlobEqualsIgnoreCase() {
|
||||||
|
assertTrue(AccountSettingsUtils.wildEqualsIgnoreCase(
|
||||||
|
"tw.yahoo.com", "??.yahoo.com"));
|
||||||
|
assertTrue(AccountSettingsUtils.wildEqualsIgnoreCase(
|
||||||
|
"yahoo.com.tw", "yahoo.com.??"));
|
||||||
|
assertTrue(AccountSettingsUtils.wildEqualsIgnoreCase(
|
||||||
|
"abcdxyz", "a??dxyz"));
|
||||||
|
assertFalse(AccountSettingsUtils.wildEqualsIgnoreCase(
|
||||||
|
"abc", "a??d"));
|
||||||
|
assertFalse(AccountSettingsUtils.wildEqualsIgnoreCase(
|
||||||
|
"abccxyz", "a??d"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testGlobMatchIgnoreCase() {
|
||||||
assertTrue(AccountSettingsUtils.globMatchIgnoreCase(
|
assertTrue(AccountSettingsUtils.globMatchIgnoreCase(
|
||||||
"mail.yahoo.com", "mail*yahoo.com"));
|
"mail.yahoo.com", "mail*yahoo.com"));
|
||||||
assertTrue(AccountSettingsUtils.globMatchIgnoreCase(
|
assertTrue(AccountSettingsUtils.globMatchIgnoreCase(
|
||||||
|
Loading…
Reference in New Issue
Block a user