public int IndexOf(Domain domain) { return List.IndexOf(domain); }
public Domain Add(Domain domain) { List.Add(domain); return domain; }
public void HandleData(string line) { if (ignoreinput) { return; } line = line.Replace("\t", " "); string scode = (line.IndexOf(" ") > 0) ? line.Substring(0, line.IndexOf(" ")) : line; int icode = 411; if (scode.IndexOf("-") != 3) { icode = Int32.Parse(scode); } switch (icode) { case 100: if (!loggedin) { Send("user " + username + "\r\n"); Send("pass " + password + "\r\n"); Send("postoffices\r\n"); loggedin = true; } break; case 200: if (watchforeof && line.StartsWith("200 EOF:")) { if (listpostoffices) { PostOfficesReceived.BeginInvoke(null, null, null, null); listpostoffices = false; } else if (listmailboxes) { MailBoxesReceived.BeginInvoke(this, null, null, null); listmailboxes = false; } else if (listdomains) { DomainsReceived.BeginInvoke(this, null, null, null); listdomains = false; } else if (listaddresses) { AddressesReceived.BeginInvoke(this, null, null, null); listaddresses = false; } watchforeof = false; } break; case 500: //if (listpostoffices) // Send("list detailed\r\n"); break; case 411: break; #region Mode 510 case 510: if (listpostoffices) { watchforeof = true; PostOffice po = new PostOffice(); line = line.Substring(line.IndexOf(" ") + 1).Trim(); string[] pa = line.Split(";".ToCharArray(), 5); for (int i = 0; i < pa.Length; i++) { line = pa[i]; switch (pa[i].Substring(0, ((pa[i].IndexOf(":") > 0)) ? pa[i].IndexOf(":") : pa[i].Length).Trim()) { case "ID": po.ID = line.Substring(line.IndexOf(":") + 1).Trim(); break; case "Default": po.IsDefault = (Int32.Parse(pa[i].Substring(pa[i].IndexOf(":") + 1).Trim()) == 1) ? true : false; break; case "Status": po.Status = Int32.Parse(pa[i].Substring(pa[i].IndexOf(":") + 1).Trim()); break; case "Description": po.Description = pa[i].Substring(pa[i].IndexOf(":") + 1).Trim(); break; default: if (i == 1) { po.Name = line.Substring(line.IndexOf("\\\\") + 2).Trim(); } break; } } if (postoffices.findByID(po.ID) == null) { postoffices.Add(po); } } break; #endregion #region Mode 610 case 610: if (listdomains) { string domainpostoffice = null; Domain d = new Domain(); line = line.Substring(line.IndexOf(" ") + 1).Trim(); string[] da = line.Split(";".ToCharArray(), 5); for (int i = 0; i < da.Length; i++) { switch (da[i].Substring(0, ((da[i].IndexOf(":") > 0)) ? da[i].IndexOf(":") : da[i].Length).Trim()) { case "ID": d.ID = da[i].Substring(da[i].IndexOf(":") + 1).Trim(); break; case "Status": d.Status = Int32.Parse(da[i].Substring(da[i].IndexOf(":") + 1).Trim()); break; case "Misc": d.Misc = da[i].Substring(da[i].IndexOf(":") + 1).Trim(); break; case "Description": d.Description = da[i].Substring(da[i].IndexOf(":") + 1).Trim(); break; default: if (i == 1) { line = da[i]; line = line.Substring(line.IndexOf("\\\\") + 2); domainpostoffice = line.Substring(0, line.LastIndexOf("\\")); d.Name = line.Substring(line.LastIndexOf("@") + 1).Trim(); } break; } } if (postoffices.findByName(domainpostoffice).Domains.findByID(d.ID) == null) { postoffices.findByName(domainpostoffice).Domains.Add(d); } } break; #endregion #region Mode 710 case 710: if (listmailboxes) { string mailboxpostoffice = ""; MailBox mb = new MailBox(); line = line.Substring(line.IndexOf(" ") + 1).Trim(); string[] mba = line.Split(";".ToCharArray(), 6); for (int i = 0; i < mba.Length; i++) { line = mba[i]; switch (mba[i].Substring(0, ((mba[i].IndexOf(":") > 0)) ? mba[i].IndexOf(":") : mba[i].Length).Trim()) { case "ID": mb.ID = mba[i].Substring(mba[i].IndexOf(":") + 1).Trim(); break; case "Quota": mb.Quota = Int32.Parse(mba[i].Substring(mba[i].IndexOf(":") + 1).Trim()); break; case "Status": mb.Status = Int32.Parse(mba[i].Substring(mba[i].IndexOf(":") + 1).Trim()); break; case "Misc": mb.Misc = mba[i].Substring(mba[i].IndexOf(":") + 1).Trim(); break; case "Description": mb.Description = mba[i].Substring(mba[i].IndexOf(":") + 1).Trim(); break; default: if (i == 1) { line = line.Substring(line.IndexOf("\\\\") + 2); mailboxpostoffice = line.Substring(0, line.IndexOf("\\")); mb.Name = line.Substring(line.LastIndexOf("\\") + 1).Trim(); } break; } } if (postoffices.findByName(mailboxpostoffice).MailBoxes.findByID(mb.ID) == null) { postoffices.findByName(mailboxpostoffice).MailBoxes.Add(mb); } } break; #endregion #region Mode 810 case 810: if (listaddresses) { Address a = new Address(); string addresspostofficename = String.Empty; string addressmailboxname = String.Empty; line = line.Substring(line.IndexOf(" ") + 1).Trim(); string[] aa = line.Split(";".ToCharArray(), 5); for (int i = 0; i < aa.Length; i++) { switch (aa[i].Substring(0, ((aa[i].IndexOf(":") > 0)) ? aa[i].IndexOf(":") : aa[i].Length).Trim()) { case "ID": a.ID = aa[i].Substring(aa[i].IndexOf(":") + 1).Trim(); break; case "Status": a.Status = Int32.Parse(aa[i].Substring(aa[i].IndexOf(":") + 1).Trim()); break; case "Misc": a.Misc = aa[i].Substring(aa[i].IndexOf(":") + 1).Trim(); break; case "SMS ID": a.SMSID = aa[i].Substring(aa[i].IndexOf(":") + 1).Trim(); break; default: if (i == 1) { line = aa[i].Trim(); a.Name = line.Substring(line.LastIndexOf("\\") + 1); line = line.Substring(0, line.LastIndexOf("\\")); addressmailboxname = line.Substring(line.LastIndexOf("\\") + 1); line = line.Substring(0, line.LastIndexOf("\\")); //line = line.Substring(line.IndexOf("\\")); addresspostofficename = line.Substring(2); } break; } } postoffices.findByName(addresspostofficename).MailBoxes.findByName(addressmailboxname).Addresses.Add(a); } break; #endregion case 900: break; default: break; } }
public Domain Add() { Domain domain = new Domain(); return Add(domain); }
public void HandleData(string line) { if (ignoreinput) return; line = line.Replace("\t", " "); string scode = (line.IndexOf(" ") > 0) ? line.Substring(0, line.IndexOf(" ")) : line; int icode = 411; if (scode.IndexOf("-") != 3) icode = Int32.Parse(scode); switch (icode) { case 100: if (!loggedin) { Send("user " + username + "\r\n"); Send("pass " + password + "\r\n"); Send("postoffices\r\n"); loggedin = true; } break; case 200: if (watchforeof && line.StartsWith("200 EOF:")) { if (listpostoffices) { PostOfficesReceived.BeginInvoke(null, null, null, null); listpostoffices = false; } else if (listmailboxes) { MailBoxesReceived.BeginInvoke(this, null, null, null); listmailboxes = false; } else if (listdomains) { DomainsReceived.BeginInvoke(this, null, null, null); listdomains = false; } else if (listaddresses) { AddressesReceived.BeginInvoke(this, null, null, null); listaddresses = false; } watchforeof = false; } break; case 500: //if (listpostoffices) // Send("list detailed\r\n"); break; case 411: break; #region Mode 510 case 510: if (listpostoffices) { watchforeof = true; PostOffice po = new PostOffice(); line = line.Substring(line.IndexOf(" ") + 1).Trim(); string[] pa = line.Split(";".ToCharArray(), 5); for (int i = 0; i < pa.Length; i++) { line = pa[i]; switch (pa[i].Substring(0, ((pa[i].IndexOf(":") > 0)) ? pa[i].IndexOf(":") : pa[i].Length).Trim()) { case "ID": po.ID = line.Substring(line.IndexOf(":") + 1).Trim(); break; case "Default": po.IsDefault = (Int32.Parse(pa[i].Substring(pa[i].IndexOf(":") + 1).Trim()) == 1) ? true : false; break; case "Status": po.Status = Int32.Parse(pa[i].Substring(pa[i].IndexOf(":") + 1).Trim()); break; case "Description": po.Description = pa[i].Substring(pa[i].IndexOf(":") + 1).Trim(); break; default: if (i == 1) { po.Name = line.Substring(line.IndexOf("\\\\") + 2).Trim(); } break; } } if (postoffices.findByID(po.ID) == null) { postoffices.Add(po); } } break; #endregion #region Mode 610 case 610: if (listdomains) { string domainpostoffice = null; Domain d = new Domain(); line = line.Substring(line.IndexOf(" ") + 1).Trim(); string[] da = line.Split(";".ToCharArray(), 5); for (int i = 0; i < da.Length; i++) { switch (da[i].Substring(0, ((da[i].IndexOf(":") > 0)) ? da[i].IndexOf(":") : da[i].Length).Trim()) { case "ID": d.ID = da[i].Substring(da[i].IndexOf(":") + 1).Trim(); break; case "Status": d.Status = Int32.Parse(da[i].Substring(da[i].IndexOf(":") + 1).Trim()); break; case "Misc": d.Misc = da[i].Substring(da[i].IndexOf(":") + 1).Trim(); break; case "Description": d.Description = da[i].Substring(da[i].IndexOf(":") + 1).Trim(); break; default: if (i == 1) { line = da[i]; line = line.Substring(line.IndexOf("\\\\") + 2); domainpostoffice = line.Substring(0, line.LastIndexOf("\\")); d.Name = line.Substring(line.LastIndexOf("@") + 1).Trim(); } break; } } if (postoffices.findByName(domainpostoffice).Domains.findByID(d.ID) == null) { postoffices.findByName(domainpostoffice).Domains.Add(d); } } break; #endregion #region Mode 710 case 710: if (listmailboxes) { string mailboxpostoffice = ""; MailBox mb = new MailBox(); line = line.Substring(line.IndexOf(" ") + 1).Trim(); string[] mba = line.Split(";".ToCharArray(), 6); for (int i = 0; i < mba.Length; i++) { line = mba[i]; switch (mba[i].Substring(0, ((mba[i].IndexOf(":") > 0)) ? mba[i].IndexOf(":") : mba[i].Length).Trim()) { case "ID": mb.ID = mba[i].Substring(mba[i].IndexOf(":") + 1).Trim(); break; case "Quota": mb.Quota = Int32.Parse(mba[i].Substring(mba[i].IndexOf(":") + 1).Trim()); break; case "Status": mb.Status = Int32.Parse(mba[i].Substring(mba[i].IndexOf(":") + 1).Trim()); break; case "Misc": mb.Misc = mba[i].Substring(mba[i].IndexOf(":") + 1).Trim(); break; case "Description": mb.Description = mba[i].Substring(mba[i].IndexOf(":") + 1).Trim(); break; default: if (i == 1) { line = line.Substring(line.IndexOf("\\\\") + 2); mailboxpostoffice = line.Substring(0, line.IndexOf("\\")); mb.Name = line.Substring(line.LastIndexOf("\\") + 1).Trim(); } break; } } if (postoffices.findByName(mailboxpostoffice).MailBoxes.findByID(mb.ID) == null) { postoffices.findByName(mailboxpostoffice).MailBoxes.Add(mb); } } break; #endregion #region Mode 810 case 810: if (listaddresses) { Address a = new Address(); string addresspostofficename= String.Empty; string addressmailboxname = String.Empty; line = line.Substring(line.IndexOf(" ") + 1).Trim(); string[] aa = line.Split(";".ToCharArray(), 5); for (int i = 0; i < aa.Length; i++) { switch (aa[i].Substring(0, ((aa[i].IndexOf(":") > 0)) ? aa[i].IndexOf(":") : aa[i].Length).Trim()) { case "ID": a.ID = aa[i].Substring(aa[i].IndexOf(":") + 1).Trim(); break; case "Status": a.Status = Int32.Parse(aa[i].Substring(aa[i].IndexOf(":") + 1).Trim()); break; case "Misc": a.Misc = aa[i].Substring(aa[i].IndexOf(":") + 1).Trim(); break; case "SMS ID": a.SMSID = aa[i].Substring(aa[i].IndexOf(":") + 1).Trim(); break; default: if (i == 1) { line = aa[i].Trim(); a.Name = line.Substring(line.LastIndexOf("\\") + 1); line = line.Substring(0, line.LastIndexOf("\\")); addressmailboxname = line.Substring(line.LastIndexOf("\\") + 1); line = line.Substring(0, line.LastIndexOf("\\")); //line = line.Substring(line.IndexOf("\\")); addresspostofficename = line.Substring(2); } break; } } postoffices.findByName(addresspostofficename).MailBoxes.findByName(addressmailboxname).Addresses.Add(a); } break; #endregion case 900: break; default: break; } }