Skip to content

Commit

Permalink
Fixes bug 330 and bug 340
Browse files Browse the repository at this point in the history
Signed-off-by: Michel <[email protected]>
  • Loading branch information
1stsetup committed Jul 15, 2013
1 parent 8d621ea commit eb8dcc9
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 106 deletions.
116 changes: 25 additions & 91 deletions components/ecExchangeRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,92 +345,6 @@ catch(err) {
if (this.debug) this.logInfo(": ExchangeRequest.loadend :"+evt.type+", readyState:"+xmlReq.readyState+", status:"+xmlReq.status);
if (this.debug) this.logInfo(": ExchangeRequest.loadend :"+xmlReq.responseText,2);

//this.exchangeStatistics.addDataRead(this.currentUrl, xmlReq.responseText.length);

if (xmlReq.readyState != 4) {

if (this.tryNextURL()) return;

if (this.debug) this.logInfo("readyState < 4. THIS SHOULD NEVER HAPPEN. PLEASE REPORT.");
this.fail(this.ER_ERROR_OPEN_FAILED,"Ready state != 4, readyState:"+xmlReq.readyState);
return;
}

if (this.isHTTPRedirect(evt)) {
return;
}

if (this.isHTTPError()) {
return;
}

var xml = xmlReq.responseText; // bug 270553

// Removed following as this is no longer a problem as we are not using E4X anymore.
// xml = xml.replace(/&#x10;/g, ""); // BUG 61 remove hexadecimal code 0x10. It will fail in xml conversion.

try {
var newXML = new mivIxml2jxon('', 0, null);
}
catch(exc) { if (this.debug) this.logInfo("createInstance error:"+exc);}

try {
newXML.addNameSpace("s", nsSoapStr);
newXML.addNameSpace("m", nsMessagesStr);
newXML.addNameSpace("t", nsTypesStr);
newXML.addNameSpace("a1", nsAutodiscoverResponseStr1);
newXML.addNameSpace("a2", nsAutodiscoverResponseStr2);
var d=new Date();var time1=d.getTime();
newXML.processXMLString(xml, 0, null);
var d=new Date();var time2=d.getTime();
}
catch(exc) { if (this.debug) this.logInfo("processXMLString error:"+exc.name+", "+exc.message+"\n"+xml);}

// dump("StringSize:"+xml.length+", xmlSize:"+newXML.getSize()+"\n");

this.mAuthFail = 0;
this.mRunning = false;

if (this.mCbOk) {
// Try to get server version and store it.
try {
let serverVersion = newXML.XPath("/s:Header/ServerVersionInfo");
if ((serverVersion.length > 0) && (serverVersion[0].getAttribute("Version") != "")) {
this.exchangeStatistics.setServerVersion(this.currentUrl, serverVersion[0].getAttribute("Version"));
}
/* else {
var header = newXML.XPath("/s:Header");
if (header.length > 0) {
dump(" @@@ We have not found serverVersion:"+header[0]+"\n");
}
else {
dump(" !!! Could not find header.\n");
}
}*/
serverVersion[0] = null;
serverVersion = null;
}
catch(err) { }

this.retryCount = 0;

if (exchWebService.prePasswords[this.mArgument.user+"@"+this.currentUrl]) {
exchWebService.prePasswords[this.mArgument.user+"@"+this.currentUrl].tryCount = 0;
}

var d=new Date();var time3=d.getTime();
try {
this.mCbOk(this, newXML);
}catch(err) { dump("onloadend: err:"+err+"\n");}
var d=new Date();var time4=d.getTime();
this.originalReq = null;
}

//dump(" stat: time1:"+(time2-time1)+", time2:"+(time4-time3)+"\n");
newXML = null;

this.observerService.notifyObservers(this._notificationCallbacks, "onExchangeConnectionOk", this.currentUrl);

},

progress: function _progress(evt)
Expand All @@ -443,6 +357,7 @@ var d=new Date();var time4=d.getTime();
let xmlReq = this.mXmlReq;

if (this.debug) this.logInfo(": ExchangeRequest.error :"+evt.type+", readyState:"+xmlReq.readyState+", status:"+xmlReq.status+", lastStatus:"+this._notificationCallbacks.lastStatus);
if (this.debug) this.logInfo(": ExchangeRequest.error :"+xmlReq.responseText,2);

if ((!this.shutdown) && (xmlReq.readyState == 4) && (xmlReq.status == 0)) {
this.logInfo(": ExchangeRequest.error : badCert going to check if it is a cert problem.");
Expand Down Expand Up @@ -669,12 +584,16 @@ catch(err){
let xmlReq = this.mXmlReq;

if (this.debug) this.logInfo(": ExchangeRequest.onLoad :"+evt.type+", readyState:"+xmlReq.readyState+", status:"+xmlReq.status);
// if (this.debug) this.logInfo(": ExchangeRequest.onLoad :"+xmlReq.responseText,2);
if (this.debug) this.logInfo(": ExchangeRequest.onLoad :"+xmlReq.responseText,2);

//this.exchangeStatistics.addDataRead(this.currentUrl, xmlReq.responseText.length);

/* if (xmlReq.readyState != 4) {
if (xmlReq.readyState != 4) {

//if (this.tryNextURL()) return;

if (this.debug) this.logInfo("readyState < 4. THIS SHOULD NEVER HAPPEN. PLEASE REPORT.");
this.fail(this.ER_ERROR_OPEN_FAILED,"Ready state != 4, readyState:"+xmlReq.readyState);
return;
}

Expand Down Expand Up @@ -702,7 +621,9 @@ catch(err){
newXML.addNameSpace("t", nsTypesStr);
newXML.addNameSpace("a1", nsAutodiscoverResponseStr1);
newXML.addNameSpace("a2", nsAutodiscoverResponseStr2);
var d=new Date();var time1=d.getTime();
newXML.processXMLString(xml, 0, null);
var d=new Date();var time2=d.getTime();
}
catch(exc) { if (this.debug) this.logInfo("processXMLString error:"+exc.name+", "+exc.message+"\n"+xml);}

Expand All @@ -714,10 +635,19 @@ catch(err){
if (this.mCbOk) {
// Try to get server version and store it.
try {
let serverVersion = newXML.XPath("/s:Header/t:ServerVersionInfo");
let serverVersion = newXML.XPath("/s:Header/ServerVersionInfo");
if ((serverVersion.length > 0) && (serverVersion[0].getAttribute("Version") != "")) {
this.exchangeStatistics.setServerVersion(this.currentUrl, serverVersion[0].getAttribute("Version"));
this.exchangeStatistics.setServerVersion(this.currentUrl, serverVersion[0].getAttribute("Version"), serverVersion[0].getAttribute("MajorVersion"), serverVersion[0].getAttribute("MinorVersion"));
}
/* else {
var header = newXML.XPath("/s:Header");
if (header.length > 0) {
dump(" @@@ We have not found serverVersion:"+header[0]+"\n");
}
else {
dump(" !!! Could not find header.\n");
}
}*/
serverVersion[0] = null;
serverVersion = null;
}
Expand All @@ -729,14 +659,18 @@ catch(err){
exchWebService.prePasswords[this.mArgument.user+"@"+this.currentUrl].tryCount = 0;
}

var d=new Date();var time3=d.getTime();
try {
this.mCbOk(this, newXML);
}catch(err) { dump("onload: err:"+err+"\n");}
var d=new Date();var time4=d.getTime();
this.originalReq = null;
}

//dump(" stat: time1:"+(time2-time1)+", time2:"+(time4-time3)+"\n");
newXML = null;

this.observerService.notifyObservers(this._notificationCallbacks, "onExchangeConnectionOk", this.currentUrl);
*/
},

retryCurrentUrl: function()
Expand Down
25 changes: 13 additions & 12 deletions interfaces/exchangeCalendar/mivExchangeCalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7213,13 +7213,7 @@ return;
}
}

if (!this.prefServerVersion) {
this.prefServerVersion = this.globalFunctions.safeGetCharPref(this.prefs,"lastServerVersion", null);
}
if (this.prefServerVersion) {
if (this.debug) this.logInfo("Restored prefServerVersion from prefs.js:"+this.prefServerVersion);
this.exchangeStatistics.setServerVersion(this.serverUrl, this.prefServerVersion);
}
this.setServerVersion();

if (this.isOffline) return;

Expand Down Expand Up @@ -7429,6 +7423,8 @@ return;
this.prefs.setCharPref("folderProperties", this.folderProperties.toString());

this.prefs.setCharPref("lastServerVersion", this.exchangeStatistics.getServerVersion(this.serverUrl));
this.prefs.setCharPref("lastMajorVersion", this.exchangeStatistics.getMajorVersion(this.serverUrl));
this.prefs.setCharPref("lastMinorVersion", this.exchangeStatistics.getMinorVersion(this.serverUrl));

this.folderIsNotAvailable = true;

Expand Down Expand Up @@ -7548,15 +7544,20 @@ return;
null);
},

getTimeZones: function _getTimeZones()
setServerVersion: function _setServerVersion()
{
if (!this.prefServerVersion) {
this.prefServerVersion = this.globalFunctions.safeGetCharPref(this.prefs,"lastServerVersion", null);
}
this.prefServerVersion = this.globalFunctions.safeGetCharPref(this.prefs,"lastServerVersion", null);
this.prefMajorVersion = this.globalFunctions.safeGetCharPref(this.prefs,"lastMajorVersion", null);
this.prefMinorVersion = this.globalFunctions.safeGetCharPref(this.prefs,"lastMinorVersion", null);
if (this.prefServerVersion) {
if (this.debug) this.logInfo("Restored prefServerVersion from prefs.js:"+this.prefServerVersion);
this.exchangeStatistics.setServerVersion(this.serverUrl, this.prefServerVersion);
this.exchangeStatistics.setServerVersion(this.serverUrl, this.prefServerVersion, this.prefMajorVersion, this.prefMinorVersion);
}
},

getTimeZones: function _getTimeZones()
{
this.setServerVersion();

this.timeZones.addURL(this.serverUrl, this.user, this);
},
Expand Down
4 changes: 3 additions & 1 deletion interfaces/exchangeStatistics/mivExchangeStatistics.idl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
interface mivExchangeStatistics : nsISupports
{

void setServerVersion(in AUTF8String aURL, in AUTF8String aVersion);
void setServerVersion(in AUTF8String aURL, in AUTF8String aVersion, in unsigned long long aMajorVersion, in unsigned long long aMinorVersion);
AUTF8String getServerVersion([optional] in AUTF8String aURL);
unsigned long long getMajorVersion([optional] in AUTF8String aURL);
unsigned long long getMinorVersion([optional] in AUTF8String aURL);

void getURLList(out uint32_t count, [array,size_is(count),retval] out string aURLStr);
void addDataRead(in AUTF8String aURL, in unsigned long long aSize);
Expand Down
44 changes: 42 additions & 2 deletions interfaces/exchangeStatistics/mivExchangeStatistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Cu.import("resource://gre/modules/Services.jsm");

function mivExchangeStatistics() {
this.serverVersions = {};
this.majorVersions = {};
this.minorVersions = {};

this.globalFunctions = Cc["@1st-setup.nl/global/functions;1"]
.getService(Ci.mivFunctions);
Expand Down Expand Up @@ -78,9 +80,29 @@ mivExchangeStatistics.prototype = {
},
// External methods

setServerVersion: function _setServerVersion(aURL, aVersion)
setServerVersion: function _setServerVersion(aURL, aVersion, aMajorVersion, aMinorVersion)
{
this.serverVersions[aURL] = aVersion;
if (aMajorVersion == 15) {
this.serverVersions[aURL] = "Exchange2013";
if (aMinorVersion > 0) this.serverVersions[aURL] = this.serverVersions[aURL] + "_SP" + aMinorVersion;
}
else {
if (aMajorVersion == 14) {
this.serverVersions[aURL] = "Exchange2010";
if (aMinorVersion > 0) this.serverVersions[aURL] = this.serverVersions[aURL] + "_SP" + aMinorVersion;
}
else {
if (aMajorVersion == 8) {
this.serverVersions[aURL] = "Exchange2007";
if (aMinorVersion > 0) this.serverVersions[aURL] = this.serverVersions[aURL] + "_SP" + aMinorVersion;
}
else {
this.serverVersions[aURL] = aVersion;
}
}
}
this.majorVersions[aURL] = aMajorVersion;
this.minorVersions[aURL] = aMinorVersion;
},

getServerVersion: function _getServerVersion(aURL)
Expand All @@ -92,6 +114,24 @@ mivExchangeStatistics.prototype = {
return "Exchange2007_SP1";
},

getMajorVersion: function _getMajorVersion(aURL)
{
if ((aURL) && (this.majorVersions[aURL])) {
return this.majorVersions[aURL];
}

return 8;
},

getMinorVersion: function _getMinorVersion(aURL)
{
if ((aURL) && (this.minorVersions[aURL])) {
return this.minorVersions[aURL];
}

return 1;
},

getURLList: function _getURLList(aCount)
{
var result = new Array();
Expand Down
Binary file modified interfaces/exchangeStatistics/mivExchangeStatistics.xpt
Binary file not shown.

0 comments on commit eb8dcc9

Please sign in to comment.