public void Add(string folder,bool selectable)
{
if(m_RefName.Length > 0){
// Check if starts with reference name
if(!folder.ToLower().StartsWith(m_RefName.ToLower())){
return;
}
}
// !!! This row probably can be removed, regex below handles it.
// REMOVE ME:
// Eg. "INBOX", exact mailbox wanted.
if(m_Mailbox.IndexOf("*") == -1 && m_Mailbox.IndexOf("%") == -1 && m_Mailbox.ToLower() != folder.ToLower()){
return;
}
// Mailbox wildchar handling.
// * - ALL
// % - won't take sub folders, only current
// * *mailbox* *mailbox% *mailbox mailbox* mailbox%
// convert IMAP pattern into regex pattern
// escape everything fishy, then convert * -> .* and % to [^/]* (ie anything other than a separator)
string rePattern = "^" + m_RefName + Regex.Replace(m_Mailbox, "([^a-zA-Z0-9*% ])","\\$1").Replace("*", ".*").Replace("%","[^/]*") + "$";
if(Regex.IsMatch(folder,rePattern,RegexOptions.IgnoreCase)){
m_Mailboxes.Add(new IMAP_Folder(folder,selectable));
return;
}
}