Commit bc8cecf4 authored by CardBook's avatar CardBook

version 28.3

parent f72576dd
......@@ -849,7 +849,7 @@ if ("undefined" == typeof(wdw_addressbooksAdd)) {
if (myFile.exists()) {
myFile.remove(true);
}
myFile.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 );
myFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420);
cardbookSynchronization.writeContentToFile(myFile.path, wdw_addressbooksAdd.gFinishParams[i].searchDef, "UTF8");
cardbookRepository.addAccountToRepository(wdw_addressbooksAdd.gFinishParams[i].dirPrefId, wdw_addressbooksAdd.gFinishParams[i].name, wdw_addressbooksAdd.gType, myFile.path, wdw_addressbooksAdd.gFinishParams[i].username, wdw_addressbooksAdd.gFinishParams[i].color,
wdw_addressbooksAdd.gFinishParams[i].enabled, true, wdw_addressbooksAdd.gFinishParams[i].vcard, false, null, null, wdw_addressbooksAdd.gFinishParams[i].DBcached, true, "60", true);
......@@ -904,7 +904,7 @@ if ("undefined" == typeof(wdw_addressbooksAdd)) {
if (myFile.exists()) {
myFile.remove(true);
}
myFile.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 );
myFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420);
}
var myMode = "WINDOW";
cardbookSynchronization.loadFile(myFile, wdw_addressbooksAdd.gFinishParams[i].dirPrefId, myMode, "NOIMPORTFILE", "");
......
......@@ -81,13 +81,12 @@ if ("undefined" == typeof(cardbookBirthdaysUtils)) {
var strBundle = document.getElementById("cardbook-strings");
var date_of_today = new Date();
for (var i = 0; i < cardbookBirthdaysUtils.lBirthdayList.length; i++) {
var ldaysUntilNextBirthday = cardbookBirthdaysUtils.lBirthdayList[i][0];
var lBirthdayName = cardbookBirthdaysUtils.lBirthdayList[i][1];
var lBirthdayAge = cardbookBirthdaysUtils.lBirthdayList[i][2];
var lBirthdayDate = new Date();
lBirthdayDate.setDate(date_of_today.getDate()+parseInt(ldaysUntilNextBirthday));
lBirthdayDate.setDate(date_of_today.getUTCDate()+parseInt(ldaysUntilNextBirthday));
// generate Date as Ical compatible text string
var lYear = lBirthdayDate.getFullYear();
......@@ -120,7 +119,8 @@ if ("undefined" == typeof(cardbookBirthdaysUtils)) {
var lBirthdayId = cardbookUtils.getUUID();
var leventEntryTitle = cardbookPreferences.getStringPref("extensions.cardbook.eventEntryTitle");
var lBirthdayTitle = leventEntryTitle.replace("%1$S", lBirthdayName).replace("%2$S",lBirthdayAge).replace("%3$S",lYear).replace("%S", lBirthdayName).replace("%S",lBirthdayAge);
var leventDate = cardbookDates.convertDateStringToDate(cardbookBirthdaysUtils.lBirthdayList[i][3], cardbookBirthdaysUtils.lBirthdayList[i][7]);
var lBirthdayTitle = leventEntryTitle.replace("%1$S", lBirthdayName).replace("%2$S",lBirthdayAge).replace("%3$S",leventDate.getFullYear()).replace("%S", lBirthdayName).replace("%S",lBirthdayAge);
// prepare Listener
var getListener = {
......@@ -165,8 +165,13 @@ if ("undefined" == typeof(cardbookBirthdaysUtils)) {
catch(e) {
Components.utils.import("resource://calendar/modules/calUtils.jsm");
}
startRange = cal.jsDateToDateTime(startRange);
endRange = cal.jsDateToDateTime(endRange);
if (cal.dtz) {
startRange = cal.dtz.jsDateToDateTime(startRange);
endRange = cal.dtz.jsDateToDateTime(endRange);
} else {
startRange = cal.jsDateToDateTime(startRange);
endRange = cal.jsDateToDateTime(endRange);
}
aCalendar1.getItems(calICalendar.ITEM_FILTER_TYPE_EVENT, 0, startRange, endRange, getListener);
}
},
......
......@@ -13,7 +13,7 @@ if ("undefined" == typeof(wdw_imageEdition)) {
if (aFile.exists()) {
aFile.remove(true);
}
aFile.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 );
aFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420);
var outStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
outStream.init(aFile, 0x04 | 0x08 | 0x20, -1, 0); // readwrite, create, truncate
var inputStream = aDataValue.QueryInterface(Components.interfaces.nsIInputStream)
......
......@@ -49,7 +49,7 @@ if ("undefined" == typeof(cardbookMailPopularity)) {
if (!cacheDir.exists()) {
// read and write permissions to owner and group, read-only for others.
cacheDir.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 );
cacheDir.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420);
}
if (cacheDir.exists()) {
var sortable = [];
......
......@@ -1484,6 +1484,35 @@ var cardbookRepository = {
}
},
deleteCard: function (aCard, aSource) {
try {
if (!cardbookPreferences.getReadOnly(aCard.dirPrefId)) {
var myDirPrefIdName = cardbookPreferences.getName(aCard.dirPrefId);
var myDirPrefIdType = cardbookPreferences.getType(aCard.dirPrefId);
if (myDirPrefIdType === "FILE") {
listOfFileToRewrite.push(aCard.dirPrefId);
cardbookRepository.removeCardFromRepository(aCard, false);
} else if (myDirPrefIdType === "CACHE" || myDirPrefIdType === "DIRECTORY" || myDirPrefIdType === "LOCALDB") {
cardbookRepository.removeCardFromRepository(aCard, true);
} else {
if (cardbookUtils.searchTagCreated(aCard)) {
cardbookRepository.removeCardFromRepository(aCard, true);
} else {
cardbookUtils.addTagDeleted(aCard);
cardbookRepository.addCardToCache(aCard, "WINDOW", cardbookUtils.getFileCacheNameFromCard(aCard));
cardbookRepository.removeCardFromRepository(aCard, false);
}
}
cardbookUtils.formatStringForOutput("cardDeletedOK", [myDirPrefIdName, aCard.fn]);
wdw_cardbooklog.addActivity("cardDeletedOK", [myDirPrefIdName, aCard.fn], "deleteMail");
cardbookUtils.notifyObservers(aSource);
}
}
catch (e) {
wdw_cardbooklog.updateStatusProgressInformation("cardbookRepository.deleteCard error : " + e, "Error");
}
},
deleteCards: function (aListOfCards, aSource) {
try {
Services.tm.currentThread.dispatch({ run: function() {
......
......@@ -2608,7 +2608,7 @@ if ("undefined" == typeof(cardbookSynchronization)) {
case "overwrite":
if (cardbookRepository.cardbookCards[myTargetPrefId+"::"+aNewCard.uid]) {
var myTargetCard = cardbookRepository.cardbookCards[myTargetPrefId+"::"+aNewCard.uid];
cardbookRepository.deleteCards([myTargetCard]);
cardbookRepository.deleteCard(myTargetCard);
}
cardbookRepository.saveCard(myNullCard, aNewCard, aSource);
break;
......@@ -2722,7 +2722,7 @@ if ("undefined" == typeof(cardbookSynchronization)) {
var myFile = myDirectory;
myFile.append(cardbookUtils.getFileNameForCard(aDirName, myCard.fn, myCard.uid));
if (myFile.exists() == false){
myFile.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 );
myFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420);
}
// then write the files one by one to avoid freeze
Services.tm.currentThread.dispatch({ run: function() {
......@@ -2742,7 +2742,7 @@ if ("undefined" == typeof(cardbookSynchronization)) {
myFile.initWithPath(aFileName);
if (myFile.exists() == false){
myFile.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 );
myFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420);
}
var outputStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
......
......@@ -572,6 +572,13 @@ if ("undefined" == typeof(cardbookUtils)) {
vCardData = this.appendToVcardData2(vCardData,"PRODID",false,vCard.prodid);
vCardData = this.appendToVcardData2(vCardData,"UID",false,vCard.uid);
vCardData = this.appendToVcardData2(vCardData,"CATEGORIES",false,this.unescapeArrayComma(this.escapeArrayComma(vCard.categories)).join(","));
// FN required
if (vCard.fn == "") {
vCardData = vCardData + "FN:" + "\r\n";
} else {
vCardData = this.appendToVcardData2(vCardData,"FN",false,this.escapeStrings(vCard.fn));
}
// N required in 3.0
if (vCard.version == "3.0") {
vCardData = this.appendToVcardData2(vCardData,"N",false,this.escapeStrings(vCard.lastname) + ";" + this.escapeStrings(vCard.firstname) + ";" +
this.escapeStrings(vCard.othername) + ";" + this.escapeStrings(vCard.prefixname) + ";" + this.escapeStrings(vCard.suffixname));
......@@ -579,7 +586,6 @@ if ("undefined" == typeof(cardbookUtils)) {
vCardData = this.appendToVcardData2(vCardData,"N",false,this.escapeStrings(vCard.lastname) + ";" + this.escapeStrings(vCard.firstname) + ";" +
this.escapeStrings(vCard.othername) + ";" + this.escapeStrings(vCard.prefixname) + ";" + this.escapeStrings(vCard.suffixname));
}
vCardData = this.appendToVcardData2(vCardData,"FN",false,this.escapeStrings(vCard.fn));
vCardData = this.appendToVcardData2(vCardData,"NICKNAME",false,this.escapeStrings(vCard.nickname));
vCardData = this.appendToVcardData2(vCardData,"SORT-STRING",false,vCard.sortstring);
vCardData = this.appendToVcardData2(vCardData,"BDAY",false,vCard.bday);
......
......@@ -7,9 +7,10 @@ if ("undefined" == typeof(cardbookWebDAV)) {
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
}
if (Services.vc.compare(Services.appinfo.version, "60.0") < 0) {
try {
Components.utils.importGlobalProperties(["XMLHttpRequest"]);
}
catch(e) {}
function XMLToJSONParser(doc) {
this._buildTree(doc);
......@@ -396,7 +397,7 @@ if ("undefined" == typeof(cardbookWebDAV)) {
return httpChannel;
},
sendHTTPRequest: function(method, body, headers, aCleanBody, aXhrOrig) {
sendHTTPRequest: function(method, body, headers, aCleanBody, aXhrOrig, aOverrideMime) {
try {
var xhr = this.makeHTTPRequest(method, body, headers, aCleanBody, aXhrOrig);
......@@ -421,6 +422,9 @@ if ("undefined" == typeof(cardbookWebDAV)) {
}
};
if (aOverrideMime) {
xhr.overrideMimeType('text/plain; charset=x-user-defined');
}
if (body) {
xhr.send(body);
} else {
......@@ -481,7 +485,7 @@ if ("undefined" == typeof(cardbookWebDAV)) {
if (parameters.accept !== null) {
headers.accept = parameters.accept;
}
this.sendHTTPRequest("GET", null, headers, "override");
this.sendHTTPRequest("GET", null, headers, null, null, true);
} else if (operation == "PUT") {
if ((this.etag != null && this.etag !== undefined && this.etag != "") && (this.etag != "0")) {
this.sendHTTPRequest(operation, parameters.data, { "content-type": parameters.contentType,
......
......@@ -470,7 +470,7 @@ if ("undefined" == typeof(wdw_csvTranslator)) {
saveTemplateNext: function (aFile) {
try {
if (!(aFile.exists())) {
aFile.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 );
aFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420);
}
var result = [];
......
......@@ -53,7 +53,7 @@ if ("undefined" == typeof(cardbookDuplicate)) {
if (!cacheDir.exists()) {
// read and write permissions to owner and group, read-only for others.
cacheDir.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 );
cacheDir.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420);
}
if (cacheDir.exists()) {
var myArray = [];
......
......@@ -94,7 +94,7 @@ if ("undefined" == typeof(ovl_synchro)) {
prefs.setCharPref("accountsShown", "all");
prefs.setCharPref("accountShown", "");
prefs.setCharPref("uncategorizedCards", "");
prefs.setCharPref("addonVersion", "28.2");
prefs.setCharPref("addonVersion", "28.3");
},
lEventTimerSync : { notify: function(lTimerSync) {
......
......@@ -120,6 +120,7 @@ if ("undefined" == typeof(wdw_cardbook)) {
wdw_cardbook.addTreeColumns();
wdw_cardbook.refreshAccountsInDirTree();
var accountShown = cardbookPreferences.getStringPref("extensions.cardbook.accountShown");
wdw_cardbook.currentAccountId = accountShown;
cardbookUtils.setColumnsStateForAccount(accountShown);
cardbookUtils.setSelectedAccount(accountShown, wdw_cardbook.currentFirstVisibleRow, wdw_cardbook.currentLastVisibleRow);
wdw_cardbook.refreshWindow();
......@@ -458,12 +459,13 @@ if ("undefined" == typeof(wdw_cardbook)) {
cardbookRepository.importConflictChoice = "duplicate";
cardbookRepository.importConflictChoicePersist = true;
var askUser = false;
var dataLength = listOfSelectedCard.length;
for (var i = 0; i < dataLength; i++) {
if (i == dataLength - 1) {
cardbookSynchronization.importCard(listOfSelectedCard[i], listOfSelectedCard[i].dirPrefId, false, "cardbook.cardAddedDirect");
cardbookSynchronization.importCard(listOfSelectedCard[i], listOfSelectedCard[i].dirPrefId, askUser, "cardbook.cardAddedDirect");
} else {
cardbookSynchronization.importCard(listOfSelectedCard[i], listOfSelectedCard[i].dirPrefId, false);
cardbookSynchronization.importCard(listOfSelectedCard[i], listOfSelectedCard[i].dirPrefId, askUser);
}
}
cardbookRepository.reWriteFiles(listOfFileToRewrite);
......@@ -618,7 +620,7 @@ if ("undefined" == typeof(wdw_cardbook)) {
exportCardsToFileNext: function (aFile, aListOfSelectedCard) {
try {
if (!(aFile.exists())) {
aFile.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 );
aFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420);
}
if (cardbookUtils.isFileAlreadyOpen(aFile.path)) {
......@@ -655,7 +657,7 @@ if ("undefined" == typeof(wdw_cardbook)) {
try {
if (aDirectory != null && aDirectory !== undefined && aDirectory != "") {
if (aDirectory.exists() == false){
aDirectory.create( Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o774 );
aDirectory.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0o774);
}
if (cardbookUtils.isDirectoryAlreadyOpen(aDirectory.path)) {
......@@ -842,6 +844,8 @@ if ("undefined" == typeof(wdw_cardbook)) {
if (myDirPrefIdType !== "SEARCH") {
if (myDirPrefIdEnabled) {
if (!myDirPrefIdReadOnly) {
cardbookRepository.importConflictChoicePersist = false;
cardbookRepository.importConflictChoice = "overwrite";
var dataArray = str.split("@@@@@");
if (dataArray.length) {
var dataLength = dataArray.length
......@@ -854,21 +858,16 @@ if ("undefined" == typeof(wdw_cardbook)) {
}
if (myDirPrefId == myCard.dirPrefId) {
if (myCategory != "" && myCard.categories.includes(myCategory)) {
cardbookRepository.importConflictChoicePersist = true;
cardbookRepository.importConflictChoice = "duplicate";
var askUser = false;
} else if (myCategory == "") {
cardbookRepository.importConflictChoicePersist = true;
cardbookRepository.importConflictChoice = "duplicate";
var askUser = false;
} else {
cardbookRepository.importConflictChoicePersist = true;
cardbookRepository.importConflictChoice = "update";
var askUser = false;
}
} else {
cardbookRepository.importConflictChoicePersist = false;
cardbookRepository.importConflictChoice = "overwrite";
var askUser = true;
}
// performance reason
......@@ -1450,6 +1449,8 @@ if ("undefined" == typeof(wdw_cardbook)) {
if (myDirPrefIdType !== "SEARCH") {
if (myDirPrefIdEnabled) {
if (!myDirPrefIdReadOnly) {
cardbookRepository.importConflictChoicePersist = false;
cardbookRepository.importConflictChoice = "overwrite";
aEvent.preventDefault();
var dataArray = aEvent.dataTransfer.getData("text/plain").split("@@@@@");
if (dataArray.length) {
......@@ -1463,13 +1464,10 @@ if ("undefined" == typeof(wdw_cardbook)) {
} else if (myCategory == "") {
continue;
} else {
cardbookRepository.importConflictChoicePersist = true;
cardbookRepository.importConflictChoice = "update";
var askUser = false;
}
} else {
cardbookRepository.importConflictChoicePersist = false;
cardbookRepository.importConflictChoice = "overwrite";
var askUser = true;
}
// performance reason
......@@ -1682,7 +1680,7 @@ if ("undefined" == typeof(wdw_cardbook)) {
if (myFile.exists()) {
myFile.remove(true);
}
myFile.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 );
myFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420);
cardbookSynchronization.writeContentToFile(myFile.path, aSearchDef, "UTF8");
cardbookUtils.formatStringForOutput("addressbookModified", [aName]);
wdw_cardbooklog.addActivity("addressbookModified", [aName], "editItem");
......
......@@ -6,7 +6,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>cardbook@vigneau.philippe</em:id>
<em:name>CardBook</em:name>
<em:version>28.2</em:version>
<em:version>28.3</em:version>
<em:type>2</em:type>
<em:description>vCard Address Book</em:description>
<em:creator>Philippe Vigneau</em:creator>
......
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