Skip to content

Commit

Permalink
Merge branch 'master' into ec-3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Muthu Subramanian committed Aug 18, 2015
2 parents 62ebab7 + 7b19413 commit d610ffe
Show file tree
Hide file tree
Showing 21 changed files with 267 additions and 182 deletions.
3 changes: 3 additions & 0 deletions chrome/content/exchangeSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ exchExchangeSettings.prototype = {
this._document.getElementById("exchWebService-autoprocessingproperties-markeventtentative").checked = this.globalFunctions.safeGetBoolPref(exchWebServicesCalPrefs, "ecautoprocessingmarkeventtentative", false);

this._document.getElementById("exchWebService-syncMailItems-Interval").value = this.globalFunctions.safeGetIntPref(exchWebServicesCalPrefs, "syncMailItems.Interval", 15);
this._document.getElementById("exchWebService-syncMailItems-active").checked = this.globalFunctions.safeGetBoolPref(exchWebServicesCalPrefs, "mailsync.active",false);


if ( this.globalFunctions.safeGetCharPref(exchWebServicesCalPrefs, "ecFolderbase", "") == "calendar" ){
this._document.getElementById("mailItemsPropertiesTab").hidden = false;
Expand Down Expand Up @@ -333,6 +335,7 @@ exchExchangeSettings.prototype = {

if ( this.globalFunctions.safeGetCharPref(exchWebServicesCalPrefs, "ecFolderbase", "") == "calendar" ){
exchWebServicesCalPrefs.setIntPref("syncMailItems.Interval", this._document.getElementById("exchWebService-syncMailItems-Interval").value);
exchWebServicesCalPrefs.setBoolPref("mailsync.active", this._document.getElementById("exchWebService-syncMailItems-active").checked);
}

//exchWebServicesCalPrefs.setBoolPref("ecPollInbox", this._document.getElementById("exchWebService-poll-inbox").checked);
Expand Down
4 changes: 4 additions & 0 deletions chrome/content/exchangeSettings.xul
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@
increment="1" min="15" type="number" value="15" />
<separator />
</hbox>
<hbox>
<checkbox label="&label.syncmailitems.active;" id="exchWebService-syncMailItems-active"
disabled="false"/>
</hbox>
</vbox>
</groupbox>
</vbox>
Expand Down
10 changes: 8 additions & 2 deletions chrome/content/exchangeSettingsOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,17 @@ exchSettingsOverlay.prototype = {
exchWebServicesDoUserChanged: function _exchWebServicesDoUserChanged(aTextBox)
{
this.exchWebServicesgUser = aTextBox.value;
if (this.exchWebServicesgUser.indexOf("@") > -1) {
if ((this.exchWebServicesgUser.indexOf("@") > -1) || (this.exchWebServicesgUser.indexOf("\\") > -1) ){
this._document.getElementById("exchWebService_windowsdomain").disabled = true;
this._document.getElementById("exchWebService_windowsdomain").value = "";
//this._document.getElementById("exchWebService_windowsdomain").setAttribute("required", false);
this.exchWebServicesgDomain = "";

if(this.exchWebServicesgUser.indexOf("\\") > -1){
var newArray = this.exchWebServicesgUser.split("\\");
this.exchWebServicesgUser = newArray[1];
this.exchWebServicesgDomain = newArray[0];
}
}
else {
this._document.getElementById("exchWebService_windowsdomain").disabled = false;
Expand Down Expand Up @@ -308,7 +314,7 @@ exchSettingsOverlay.prototype = {

exchWebServicesGetUsername: function _exchWebServicesGetUsername()
{
if (this.exchWebServicesgUser.indexOf("@") > -1) {
if (this.exchWebServicesgUser.indexOf("@") > -1) {
return this.exchWebServicesgUser;
}
else {
Expand Down
191 changes: 106 additions & 85 deletions chrome/content/rtews.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Cu.import("resource://exchangecalendar/erSubscribe.js");
Cu.import("resource://exchangecalendar/erGetEvents.js");
Cu.import("resource://exchangecalendar/erFindItems.js");
Cu.import("resource://exchangecalendar/erUpdateItem.js");
Cu.import("resource://exchangecalendar/erUnsubscribe.js");

const eventTypes = ["NewMailEvent","ModifiedEvent","MovedEvent","CopiedEvent","CreatedEvent"];

Expand Down Expand Up @@ -202,14 +203,19 @@ rtews.Tags = {
function rtews(identity){
this.identity = identity;
// fixing bug #270

if( identity.domain){
this.user = identity.domain +"\\"+identity.username ;
}
else {
this.user = identity.username ;
}


if (identity.username.indexOf("@") > -1) {
this.user = identity.username ;
}
else {
if (identity.domain == "") {
this.user = identity.username ;
}
else {
this.user = identity.domain +"\\"+identity.username ;
}
}

this.mailbox = identity.email ;
this.serverUrl = identity.ewsUrl ;

Expand All @@ -229,17 +235,38 @@ function rtews(identity){
this.prefs = identity.prefs ;

if( this.prefs ){
this.pollOffset = this.globalFunctions.safeGetIntPref(this.prefs, "syncMailItems.Interval" ,15) * 1000 ;//time for getevents
this.pollOffset = this.globalFunctions.safeGetIntPref(this.prefs, "syncMailItems.Interval" ,15) * 1000 ;//time for getevents
this.loadBalancer = Cc["@1st-setup.nl/exchange/loadbalancer;1"]
.getService(Ci.mivExchangeLoadBalancer);
}
else{
this.prefs = null;
this.pollOffset = 15000;//time for getevents
this.pollOffset = 30000;//time for getevents
}

this.subscriptionTimeout = "1440";
}

rtews.prototype = {
/*
*use Calendar queue for xml request
*/
addToQueue: function _addToQueue(aRequest, aArgument, aCbOk, aCbError, aListener)
{
if ( mivFunctions.safeGetBoolPref(this.prefs, "mailsync.active", false) == false ){
exchangeGlobalFunction("Not adding to queue because we are disabled, " + this.serverUrl ,this.user);
this.Running = false;
return;
}
//if (!aArgument["ServerVersion"]) aArgument["ServerVersion"] = this.exchangeStatistics.getServerVersion(this.serverUrl);

this.loadBalancer.addToQueue({ calendar: this.prefs,
ecRequest:aRequest,
arguments: aArgument,
cbOk: aCbOk,
cbError: aCbError,
listener: aListener});
},
/*
* Gets the ItemId element from response of the FindItem SOAP request
*
Expand All @@ -248,7 +275,7 @@ rtews.prototype = {
exchangeGlobalFunction("Find all the folderd in msgfolderroot, " + this.serverUrl ,this.user);
//Call API
var self = this;
var tmpObject = new erFindInboxFolderRequest(
this.addToQueue( erFindInboxFolderRequest,
{user:this.user,
mailbox: this.mailbox,
serverUrl:this.serverUrl,
Expand All @@ -272,7 +299,7 @@ rtews.prototype = {
subscribe: function _subscribe(folders){
exchangeGlobalFunction("Trying to subscribe " ,this.user);
var self = this;
var tmpObject = new erSubscribeRequest(
this.addToQueue( erSubscribeRequest,
{user: this.user,
mailbox: this.mailbox,
serverUrl: this.serverUrl,
Expand All @@ -296,10 +323,10 @@ rtews.prototype = {
},

unsubscribe: function _unsubscribe(){
var that = this;
that.Running = true;
var tmpObject = new erUnsubscribeRequest(
exchangeGlobalFunction("Error occured Unsubscribing user.",this.user);
this.Running = false;
var that = this;
this.addToQueue( erUnsubscribeRequest,
{user: this.user,
mailbox: this.mailbox,
serverUrl: this.serverUrl,
Expand All @@ -312,13 +339,11 @@ rtews.prototype = {
},

unsubscribeOK: function _unsubscribeOK(erUnsubscribeRequest, aResp){
this.Running =false;
exchangeGlobalFunction("Unsubscribed user.",this.user);
},

unsubscribeError: function _unsubscribeError(erUnsubscribeRequest, aCode, aMsg){
this.Running =false;
exchangeGlobalFunction("unsubscribeError: "+ aMsg);
exchangeGlobalFunction("unsubscribeError: "+ aMsg);
},

poll: function _poll() {
Expand Down Expand Up @@ -440,7 +465,7 @@ rtews.prototype = {
getAndUpdateItems: function _getAndUpdateItems(aIds) {
exchangeGlobalFunction("Received request to update messages, total items to be requested - " + aIds.length, this.user);
var that = this;
var tmpObject = new erGetItemsRequest(
this.addToQueue( erGetItemsRequest,
{user: this.user,
mailbox: this.mailbox,
serverUrl: this.serverUrl,
Expand All @@ -456,7 +481,7 @@ rtews.prototype = {
this.Running = true;
var that = this;

var tmpObject = new erGetEventsRequest(
this.addToQueue( erGetEventsRequest,
{user: this.user,
mailbox: this.mailbox,
serverUrl: this.serverUrl,
Expand Down Expand Up @@ -680,7 +705,7 @@ rtews.prototype = {
continue;
}

var tmpObject = new erFindItemsRequest(
this.addToQueue( erFindItemsRequest,
{user: this.user,
mailbox: this.mailbox,
serverUrl: this.serverUrl,
Expand All @@ -695,7 +720,7 @@ rtews.prototype = {
}
else{
exchangeGlobalFunction("Syncing tags not finding any items in server for Ids. " + JSON.stringify(messageId), that.user);
}
}
},
function(erFindItemsRequest, aCode, aMsg) {
exchangeGlobalFunction("findItemsError: aCode:" + aCode + " aMsg: " + aMsg );
Expand Down Expand Up @@ -725,14 +750,17 @@ rtews.prototype = {
}
else{
exchangeGlobalFunction("Toggle tags not finding any items in server for Ids. " + JSON.stringify(messageId), that.user);
//when no mail item is find toggle tags locally
exchangeGlobalFunction("Update tags locally",that.user);
rtews.fallBackTagUpdate(msgHdr, identity, toggleType, categories, key, addKey);
}
}

function findItemsError(erFindItemsRequest, aCode, aMsg){
exchangeGlobalFunction("findItemsError: aCode:" + aCode + " aMsg: " + aMsg );
}
}

var tmpObject = new erFindItemsRequest(
this.addToQueue( erFindItemsRequest,
{user: this.user,
mailbox: this.mailbox,
serverUrl: this.serverUrl,
Expand Down Expand Up @@ -774,7 +802,8 @@ rtews.prototype = {

exchangeGlobalFunction("UpdateItem with changes " + changes, this.user);

var tmpObject = new erUpdateItemRequest({user: this.user,
this.addToQueue( erUpdateItemRequest,
{user: this.user,
mailbox: this.mailbox,
folderBase: this.folderBase,
serverUrl: this.serverUrl,
Expand Down Expand Up @@ -806,6 +835,18 @@ rtews.prototype = {
},
};


/*
* On remote fails
*/
rtews.fallBackTagUpdate = function(msgHdr, identity, toggleType, categories, key, addKey){
if (toggleType == "removeAll") {
rtews.removeAllMessageTagsPostEwsUpdate(msgHdr);
} else {
rtews.toggleMessageTagPostEwsUpdate(key, addKey, msgHdr);
}
};

/*
* Custom method for remove all tags menuitem
*/
Expand Down Expand Up @@ -923,12 +964,14 @@ rtews.addSyncMenu = function (menuPopup) {
*/
rtews.getIdentity = function(server) {
var ids = identities;
for (var x = 0, len = ids.length; x < len; x++) {
if (ids[x] && ids[x].enabled == true && ids[x].server == server) {
return ids[x];
}
if( ids ){
for (var x = 0, len = ids.length; x < len; x++) {
if (ids[x] && ids[x].enabled == true && ids[x].server == server) {
return ids[x];
}
}
}
return null;
return null;
};

//Get all the identities
Expand Down Expand Up @@ -1034,36 +1077,25 @@ function getAllAccounts(){
var identity = identities.queryElementAt(index, Ci.nsIMsgIdentity);
var calAccount = getCalendarPref(identity.email);
var enabled = false;
exchangeGlobalFunction("Account exists for email address - " + identity.email);
exchangeGlobalFunction("Account exists for email address - " + identity.email);

var details = null;
if(calAccount){
enabled = true;
details = {
"server":account.incomingServer.prettyName,
"serverURI":account.incomingServer.serverURI,
"email":calAccount.getCharPref("ecMailbox"),
"username":calAccount.getCharPref("ecUser"),
"name":identity.fullName,
"domain":calAccount.getCharPref("ecDomain"),
"enabled":enabled,
"ewsUrl":calAccount.getCharPref("ecServer"),
"prefs" : calAccount ,};
}
else{
details = {
"server":account.incomingServer.prettyName,
"serverURI":account.incomingServer.serverURI,
"email":null,
"username":null,
"name":identity.fullName,
"domain":null,
"enabled":enabled,
"ewsUrl":null,
"prefs" : null ,};
}

if( details.enabled == true){

if(calAccount && mivFunctions ){
enabled = mivFunctions.safeGetBoolPref(calAccount, "mailsync.active", false) ;
details = {
"server":account.incomingServer.prettyName,
"serverURI":account.incomingServer.serverURI,
"email":mivFunctions.safeGetCharPref(calAccount,"ecMailbox"),
"username":mivFunctions.safeGetCharPref(calAccount,"ecUser"),
"name":identity.fullName,
"domain":mivFunctions.safeGetCharPref(calAccount,"ecDomain"),
"enabled":enabled,
"ewsUrl":mivFunctions.safeGetCharPref(calAccount,"ecServer"),
"prefs" : calAccount ,
};
}
if( details.enabled == true){
_accounts.push(details);
}
}
Expand All @@ -1086,33 +1118,22 @@ function getAllAccounts(){
exchangeGlobalFunction("Account exists for email address - " + identity.email);

let details = null;
if(calAccount){
enabled = true;
details = {
"server":account.incomingServer.prettyName,
"serverURI":account.incomingServer.serverURI,
"email":calAccount.getCharPref("ecMailbox"),
"username":calAccount.getCharPref("ecUser"),
"name":identity.fullName,
"domain":calAccount.getCharPref("ecDomain"),
"enabled":enabled,
"ewsUrl":calAccount.getCharPref("ecServer"),
"prefs" : calAccount ,};
}
else{
details = {
"server":account.incomingServer.prettyName,
"serverURI":account.incomingServer.serverURI,
"email":null,
"username":null,
"name":identity.fullName,
"domain":null,
"enabled":enabled,
"ewsUrl":null,
"prefs" : null ,};
}

if( details.enabled == true ){
if(calAccount && mivFunctions ){
enabled = mivFunctions.safeGetBoolPref(calAccount, "mailsync.active", false) ;
details = {
"server":account.incomingServer.prettyName,
"serverURI":account.incomingServer.serverURI,
"email":mivFunctions.safeGetCharPref(calAccount,"ecMailbox"),
"username":mivFunctions.safeGetCharPref(calAccount,"ecUser"),
"name":identity.fullName,
"domain":mivFunctions.safeGetCharPref(calAccount,"ecDomain"),
"enabled":enabled,
"ewsUrl":mivFunctions.safeGetCharPref(calAccount,"ecServer"),
"prefs" : calAccount ,
};
}
if( details.enabled == true ){
_accounts.push(details);
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/ecExchangeRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ try {
}
}
else {
var rm = xml2json.XPath(aResp,"/s:Envelope/s:Body/*/m:ResponseMessages/*[@ResponseClass='Error']");
var rm = aResp.XPath("/s:Envelope/s:Body/*/m:ResponseMessages/*[@ResponseClass='Error']");
var result;
if (rm.length > 0) {
result = rm[0].getTagValue("m:MessageText").value+"("+rm[0].getTagValue("m:ResponseCode")+")";
Expand Down
Loading

0 comments on commit d610ffe

Please sign in to comment.