Commit 62900ddc authored by CardBook's avatar CardBook

version 34.2

parent 1cf5249f
......@@ -282,7 +282,7 @@ if ("undefined" == typeof(wdw_addressbooksAdd)) {
document.getElementById('remotePagePasswordLabel').disabled=true;
document.getElementById('remotePagePassword').disabled=true;
document.getElementById('remotePagePassword').setAttribute('required', 'false');
document.getElementById('remotePagePasswordCheckBox').disabled=true;
document.getElementById('remotePagePasswordCheckbox').disabled=true;
} else if (type == 'APPLE') {
document.getElementById('remotePageUriLabel').disabled=true;
document.getElementById('remotePageURI').disabled=true;
......@@ -290,7 +290,7 @@ if ("undefined" == typeof(wdw_addressbooksAdd)) {
document.getElementById('remotePagePasswordLabel').disabled=false;
document.getElementById('remotePagePassword').disabled=false;
document.getElementById('remotePagePassword').setAttribute('required', 'true');
document.getElementById('remotePagePasswordCheckBox').disabled=false;
document.getElementById('remotePagePasswordCheckbox').disabled=false;
} else {
document.getElementById('remotePageUriLabel').disabled=false;
document.getElementById('remotePageURI').disabled=false;
......@@ -298,7 +298,7 @@ if ("undefined" == typeof(wdw_addressbooksAdd)) {
document.getElementById('remotePagePasswordLabel').disabled=false;
document.getElementById('remotePagePassword').disabled=false;
document.getElementById('remotePagePassword').setAttribute('required', 'true');
document.getElementById('remotePagePasswordCheckBox').disabled=false;
document.getElementById('remotePagePasswordCheckbox').disabled=false;
}
wdw_addressbooksAdd.checklocationNetwork();
cardbookNotifications.setNotification("resultNotifications", "OK");
......@@ -765,29 +765,40 @@ if ("undefined" == typeof(wdw_addressbooksAdd)) {
}
},
sendRequestForFinds: function (aEmail) {
let domain = aEmail.split("@")[1];
sendRequestForFinds: function (aEmail, aDomain) {
let request = new XMLHttpRequest();
request.open('GET', wdw_addressbooksAdd.gAutoconfigURL + domain, true);
request.open('GET', wdw_addressbooksAdd.gAutoconfigURL + aDomain, true);
request.onreadystatechange = function() {
if (request.readyState == 4) {
let xmlParser = Components.classes["@mozilla.org/xmlextras/domparser;1"].createInstance(Components.interfaces.nsIDOMParser);
let responseXML = xmlParser.parseFromString(request.responseText, "text/xml");
let responseJSON = new XMLToJSONParser(responseXML);
if (responseJSON && responseJSON.clientConfig && responseJSON.clientConfig[0] && responseJSON.clientConfig[0].carddavProvider
&& responseJSON.clientConfig[0].carddavProvider[0]) {
let infos = responseJSON.clientConfig[0].carddavProvider[0];
if (!infos.carddavURL[0]) {
return;
}
let url = infos.carddavURL[0].replace("%EMAILADDRESS%", aEmail);
let password = "";
let foundLogins = Services.logins.findLogins({}, "smtp://smtp." + domain, "", "");
if (foundLogins.length > 0) {
password = foundLogins[0].password;
// Services.console.logStringMessage(wdw_cardbooklog.getTime() + " : " + aLogLine.toSource());
if (request.status > 199 && request.status < 400) {
try {
let xmlParser = Components.classes["@mozilla.org/xmlextras/domparser;1"].createInstance(Components.interfaces.nsIDOMParser);
let responseXML = xmlParser.parseFromString(request.responseText, "text/xml");
let responseJSON = new XMLToJSONParser(responseXML);
if (responseJSON && responseJSON.clientConfig && responseJSON.clientConfig[0] && responseJSON.clientConfig[0].carddavProvider
&& responseJSON.clientConfig[0].carddavProvider[0]) {
let infos = responseJSON.clientConfig[0].carddavProvider[0];
if (!infos.carddavURL[0]) {
return;
}
let url = infos.carddavURL[0].replace("%EMAILADDRESS%", aEmail);
let password = "";
let domain = aEmail.split("@")[1];
let foundLogins = Services.logins.findLogins({}, "smtp://smtp." + domain, "", "");
if (foundLogins.length > 0) {
password = foundLogins[0].password;
}
let vCardVersion = infos.vCardVersion[0] ? infos.vCardVersion[0] : "";
wdw_addressbooksAdd.createBoxesForFinds("CARDDAV", aEmail, password, vCardVersion, url, aEmail);
}
} catch(e) {}
} else {
// if file fastmail.fr is not found let's check for file fastmail
let domain = aDomain.split(".")[0];
if (domain != aDomain) {
wdw_addressbooksAdd.sendRequestForFinds(aEmail, domain);
}
let vCardVersion = infos.vCardVersion[0] ? infos.vCardVersion[0] : "";
wdw_addressbooksAdd.createBoxesForFinds("CARDDAV", aEmail, password, vCardVersion, url, aEmail);
}
}
};
......@@ -923,7 +934,8 @@ if ("undefined" == typeof(wdw_addressbooksAdd)) {
}
// then CARDDAV
if (!found) {
wdw_addressbooksAdd.sendRequestForFinds(email);
let domain = email.split("@")[1];
wdw_addressbooksAdd.sendRequestForFinds(email, domain);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment