mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-28 16:40:53 +01:00
Fetch setup instructions
This commit is contained in:
@@ -57,6 +57,7 @@ public class Provider {
|
||||
public int smtp_port;
|
||||
public boolean smtp_starttls;
|
||||
public UserType user = UserType.EMAIL;
|
||||
public StringBuilder documentation = null; // html
|
||||
|
||||
enum UserType {LOCAL, EMAIL}
|
||||
|
||||
@@ -75,25 +76,26 @@ public class Provider {
|
||||
int eventType = xml.getEventType();
|
||||
while (eventType != XmlPullParser.END_DOCUMENT) {
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if ("providers".equals(xml.getName()))
|
||||
String name = xml.getName();
|
||||
if ("providers".equals(name))
|
||||
result = new ArrayList<>();
|
||||
else if ("provider".equals(xml.getName())) {
|
||||
else if ("provider".equals(name)) {
|
||||
provider = new Provider();
|
||||
provider.name = xml.getAttributeValue(null, "name");
|
||||
provider.order = xml.getAttributeIntValue(null, "order", Integer.MAX_VALUE);
|
||||
provider.link = xml.getAttributeValue(null, "link");
|
||||
provider.type = xml.getAttributeValue(null, "type");
|
||||
provider.prefix = xml.getAttributeValue(null, "prefix");
|
||||
} else if ("imap".equals(xml.getName())) {
|
||||
} else if ("imap".equals(name)) {
|
||||
provider.imap_host = xml.getAttributeValue(null, "host");
|
||||
provider.imap_port = xml.getAttributeIntValue(null, "port", 0);
|
||||
provider.imap_starttls = xml.getAttributeBooleanValue(null, "starttls", false);
|
||||
} else if ("smtp".equals(xml.getName())) {
|
||||
} else if ("smtp".equals(name)) {
|
||||
provider.smtp_host = xml.getAttributeValue(null, "host");
|
||||
provider.smtp_port = xml.getAttributeIntValue(null, "port", 0);
|
||||
provider.smtp_starttls = xml.getAttributeBooleanValue(null, "starttls", false);
|
||||
} else
|
||||
throw new IllegalAccessException(xml.getName());
|
||||
throw new IllegalAccessException(name);
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
if ("provider".equals(xml.getName())) {
|
||||
result.add(provider);
|
||||
@@ -151,17 +153,36 @@ public class Provider {
|
||||
|
||||
boolean imap = false;
|
||||
boolean smtp = false;
|
||||
String href = null;
|
||||
String title = null;
|
||||
Provider provider = new Provider(domain);
|
||||
int eventType = xml.getEventType();
|
||||
while (eventType != XmlPullParser.END_DOCUMENT) {
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if ("incomingServer".equals(xml.getName()))
|
||||
String name = xml.getName();
|
||||
if ("incomingServer".equals(name)) {
|
||||
// <incomingServer type="imap">
|
||||
// <hostname>imap.gmail.com</hostname>
|
||||
// <port>993</port>
|
||||
// <socketType>SSL</socketType>
|
||||
// <username>%EMAILADDRESS%</username>
|
||||
// <authentication>OAuth2</authentication>
|
||||
// <authentication>password-cleartext</authentication>
|
||||
// </incomingServer>
|
||||
imap = "imap".equals(xml.getAttributeValue(null, "type"));
|
||||
|
||||
else if ("outgoingServer".equals(xml.getName()))
|
||||
} else if ("outgoingServer".equals(name)) {
|
||||
// <outgoingServer type="smtp">
|
||||
// <hostname>smtp.gmail.com</hostname>
|
||||
// <port>465</port>
|
||||
// <socketType>SSL</socketType>
|
||||
// <username>%EMAILADDRESS%</username>
|
||||
// <authentication>OAuth2</authentication>
|
||||
// <authentication>password-cleartext</authentication>
|
||||
// </outgoingServer>
|
||||
smtp = "smtp".equals(xml.getAttributeValue(null, "type"));
|
||||
|
||||
else if ("hostname".equals(xml.getName())) {
|
||||
} else if ("hostname".equals(name)) {
|
||||
eventType = xml.next();
|
||||
if (eventType == XmlPullParser.TEXT) {
|
||||
String host = xml.getText();
|
||||
@@ -173,7 +194,7 @@ public class Provider {
|
||||
}
|
||||
continue;
|
||||
|
||||
} else if ("port".equals(xml.getName())) {
|
||||
} else if ("port".equals(name)) {
|
||||
eventType = xml.next();
|
||||
if (eventType == XmlPullParser.TEXT) {
|
||||
String port = xml.getText();
|
||||
@@ -188,7 +209,7 @@ public class Provider {
|
||||
}
|
||||
continue;
|
||||
|
||||
} else if ("socketType".equals(xml.getName())) {
|
||||
} else if ("socketType".equals(name)) {
|
||||
eventType = xml.next();
|
||||
if (eventType == XmlPullParser.TEXT) {
|
||||
String socket = xml.getText();
|
||||
@@ -208,7 +229,7 @@ public class Provider {
|
||||
}
|
||||
continue;
|
||||
|
||||
} else if ("username".equals(xml.getName())) {
|
||||
} else if ("username".equals(name)) {
|
||||
eventType = xml.next();
|
||||
if (eventType == XmlPullParser.TEXT) {
|
||||
String username = xml.getText();
|
||||
@@ -222,13 +243,59 @@ public class Provider {
|
||||
}
|
||||
continue;
|
||||
|
||||
} else if ("enable".equals(name)) {
|
||||
// <enable visiturl="https://mail.google.com/mail/?ui=2&shva=1#settings/fwdandpop">
|
||||
// <instruction>You need to enable IMAP access</instruction>
|
||||
// </enable>
|
||||
href = xml.getAttributeValue(null, "visiturl");
|
||||
title = null;
|
||||
|
||||
} else if ("documentation".equals(name)) {
|
||||
// <documentation url="http://mail.google.com/support/bin/answer.py?answer=13273">
|
||||
// <descr>How to enable IMAP/POP3 in GMail</descr>
|
||||
// </documentation>
|
||||
href = xml.getAttributeValue(null, "url");
|
||||
title = null;
|
||||
|
||||
} else if ("instruction".equals(name) || "descr".equals(name)) {
|
||||
if (href != null) {
|
||||
eventType = xml.next();
|
||||
if (eventType == XmlPullParser.TEXT) {
|
||||
if (title == null)
|
||||
title = "";
|
||||
else
|
||||
title += "<br />";
|
||||
title += xml.getText();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
if ("incomingServer".equals(xml.getName()))
|
||||
String name = xml.getName();
|
||||
if ("incomingServer".equals(name))
|
||||
imap = false;
|
||||
else if ("outgoingServer".equals(xml.getName()))
|
||||
|
||||
else if ("outgoingServer".equals(name))
|
||||
smtp = false;
|
||||
|
||||
else if ("enable".equals(name) || "documentation".equals(name)) {
|
||||
if (href != null) {
|
||||
if (title == null)
|
||||
title = href;
|
||||
|
||||
if (provider.documentation == null)
|
||||
provider.documentation = new StringBuilder();
|
||||
else
|
||||
provider.documentation.append("<br /><br />");
|
||||
|
||||
provider.documentation
|
||||
.append("<a href=\"").append(href).append("\">").append(title).append("</a>");
|
||||
|
||||
href = null;
|
||||
title = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eventType = xml.next();
|
||||
|
||||
Reference in New Issue
Block a user