Commit ce453c5e authored by CardBook's avatar CardBook

initial commit

parent 8565c795
manifest components/cardbookAutocompleteSearch.manifest
content cardbook chrome/content/
locale cardbook cs chrome/locale/cs/
locale cardbook de chrome/locale/de/
locale cardbook en-US chrome/locale/en-US/
locale cardbook fr chrome/locale/fr/
locale cardbook hu chrome/locale/hu/
locale cardbook it chrome/locale/it/
locale cardbook nl chrome/locale/nl/
locale cardbook pl chrome/locale/pl/
locale cardbook pt-PT chrome/locale/pt-PT/
locale cardbook ru chrome/locale/ru/
skin cardbook classic/1.0 chrome/skin/
# support for customizing toolbars
style chrome://global/content/customizeToolbar.xul chrome://cardbook/skin/toolbarButton.css
style chrome://global/content/customizeToolbar.xul chrome://cardbook/skin/cardbookButtons.css
# support for CardBook, yellow stars, creation from emails, formatting email fields
overlay chrome://messenger/content/messenger.xul chrome://cardbook/content/ovl_cardbook.xul
overlay chrome://messenger/content/messenger.xul chrome://cardbook/content/ovl_cardbookContexts.xul
# support for CardBook menu in composition window
overlay chrome://messenger/content/messengercompose/messengercompose.xul chrome://cardbook/content/ovl_cardbookComposeMsg.xul
# support for collected mail
overlay chrome://messenger/content/messengercompose/messengercompose.xul chrome://cardbook/content/collected/ovl_collected.xul
# support for expanding list
overlay chrome://messenger/content/messengercompose/messengercompose.xul chrome://cardbook/content/lists/ovl_list.xul
# support for search engines
overlay chrome://messenger/content/messenger.xul chrome://cardbook/content/filters/ovl_filters.xul
# support for filter messages
overlay chrome://messenger/content/FilterEditor.xul chrome://cardbook/content/filters/ovl_filterEditor.xul
# support for Lightning attendees
overlay chrome://calendar/content/calendar-event-dialog-attendees.xul chrome://cardbook/content/lightning/ovl_lightningAttendees.xul
overlay chrome://lightning/content/lightning-menus.xul chrome://cardbook/content/lightning/ovl_lightningMenus.xul
# support for birthdays
overlay chrome://messenger/content/messenger.xul chrome://cardbook/content/birthdays/ovl_birthdays.xul
# support for importing attachments
overlay chrome://messenger/content/messenger.xul chrome://cardbook/content/attachments/ovl_attachments.xul
# support for attaching a vCard
overlay chrome://messenger/content/messengercompose/messengercompose.xul chrome://cardbook/content/attachvCard/ovl_attachvCard.xul
# support for CardBook Tab
overlay chrome://messenger/content/messenger.xul chrome://cardbook/content/ovl_cardbookTab.xul
# support for Contacts sidebar
overlay chrome://messenger/content/messengercompose/messengercompose.xul chrome://cardbook/content/contactsSidebar/ovl_cardbookContactsSidebarMain.xul
# support for the message window
overlay chrome://messenger/content/messageWindow.xul chrome://cardbook/content/ovl_cardbookContexts.xul
if ("undefined" == typeof(wdw_newGoogleToken)) {
var wdw_newGoogleToken = {
closeKO: function () {
Components.utils.import("chrome://cardbook/content/cardbookRepository.js");
cardbookRepository.cardbookGoogleRefreshTokenError[window.arguments[0].dirPrefId]++;
cardbookRepository.cardbookGoogleRefreshTokenResponse[window.arguments[0].dirPrefId]++;
cardbookRepository.cardbookServerSyncResponse[window.arguments[0].dirPrefId]++;
close();
}
};
};
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xul-overlay href="chrome://cardbook/content/ovl_cardbookStringBundle.xul"?>
<!DOCTYPE window SYSTEM "chrome://cardbook/locale/wdw_newGoogleToken.dtd">
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="wdw_newGoogleToken" title="&NewGoogleTokenTitle;"
persist="screenX screenY width height"
height="740px"
width="700px"
onclose="wdw_newGoogleToken.closeKO();">
<stringbundleset id="stringbundleset"/>
<script src="wdw_newGoogleToken.js"/>
<hbox flex="1">
<browser id="browser" src="" flex="1" type="content"/>
</hbox>
</window>
if ("undefined" == typeof(ovl_attachments)) {
var ovl_attachments = {
setCardBookMenus: function (aValue) {
document.getElementById('attachments1CardBookImport').disabled = aValue;
document.getElementById('attachments2CardBookImport').disabled = aValue;
document.getElementById('attachment1CardBookImport').disabled = aValue;
document.getElementById('attachment2CardBookImport').disabled = aValue;
if (!aValue) {
Components.utils.import("chrome://cardbook/content/cardbookRepository.js");
cardbookUtils.addToCardBookMenuSubMenu('attachments1CardBookImportPopup', ovl_attachments.importFileIntoCardBook);
cardbookUtils.addToCardBookMenuSubMenu('attachments2CardBookImportPopup', ovl_attachments.importFileIntoCardBook);
cardbookUtils.addToCardBookMenuSubMenu('attachment1CardBookImportPopup', ovl_attachments.importFileIntoCardBook);
cardbookUtils.addToCardBookMenuSubMenu('attachment2CardBookImportPopup', ovl_attachments.importFileIntoCardBook);
}
},
displayCardBookMenu: function() {
var disabled = true;
var attachmentList = document.getElementById('attachmentList');
var selectedAttachments = attachmentList.selectedItems;
if (selectedAttachments.length == 0) {
for (var i = 0; i < currentAttachments.length; i++) {
var attachment = currentAttachments[i];
var myFileArray = attachment.name.split(".");
var myExtension = myFileArray[myFileArray.length-1];
if (myExtension.toLowerCase() == "vcf") {
disabled = false;
break;
}
}
} else {
for (var i = 0; i < selectedAttachments.length; i++) {
var attachment = selectedAttachments[i].attachment;
var myFileArray = attachment.name.split(".");
var myExtension = myFileArray[myFileArray.length-1];
if (myExtension.toLowerCase() == "vcf") {
disabled = false;
break;
}
}
}
ovl_attachments.setCardBookMenus(disabled);
},
loadAttachment: function(aAttachment, aDirPrefId) {
var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://cardbook/content/cardbookSynchronization.js");
loader.loadSubScript("chrome://cardbook/content/cardbookUtils.js");
var myFileArray = aAttachment.name.split(".");
var myExtension = myFileArray[myFileArray.length-1];
if (myExtension.toLowerCase() == "vcf") {
var myFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("TmpD", Components.interfaces.nsIFile);
var myUuid = cardbookUtils.getUUID();
var myFileName = myUuid + ".vcf";
myFile.append(myFileName);
var listener_loadFile = {
mFile : myFile,
myDirPrefId : aDirPrefId,
OnStartRunningUrl: function (aUrl) {
wdw_cardbooklog.updateStatusProgressInformationWithDebug2("debug mode : start downloading attachment...");
},
OnStopRunningUrl: function (aUrl, aStatus) {
if (aStatus == 0) {
wdw_cardbooklog.updateStatusProgressInformationWithDebug2("debug mode : attachment successfully downloaded");
cardbookSynchronization.loadFile(this.mFile, this.myDirPrefId, "", "WINDOW", "");
} else {
wdw_cardbooklog.updateStatusProgressInformationWithDebug2("debug mode : attachment not successfully downloaded, status : " + aStatus);
}
if (this.mFile.exists() && this.mFile.isFile()) {
wdw_cardbooklog.updateStatusProgressInformationWithDebug2("debug mode : deleting file : " + this.mFile.path);
this.mFile.remove(true);
}
}
};
messenger.saveAttachmentToFile(myFile, aAttachment.url, aAttachment.uri, aAttachment.contentType, listener_loadFile);
}
},
importFileIntoCardBook: function(aDirPrefId) {
var attachmentList = document.getElementById('attachmentList');
var selectedAttachments = attachmentList.selectedItems;
if (selectedAttachments.length == 0) {
for (var i = 0; i < currentAttachments.length; i++) {
ovl_attachments.loadAttachment(currentAttachments[i], aDirPrefId);
}
} else {
for (var i = 0; i < selectedAttachments.length; i++) {
ovl_attachments.loadAttachment(selectedAttachments[i].attachment, aDirPrefId);
}
}
}
}
};
// for the displaying or not import into CardBook for all attachments
// onShowSaveAttachmentMenuMultiple
(function() {
// Keep a reference to the original function.
var _original = onShowSaveAttachmentMenuMultiple;
// Override a function.
onShowSaveAttachmentMenuMultiple = function() {
// Execute original function.
var rv = _original.apply(null, arguments);
ovl_attachments.displayCardBookMenu();
// return the original result
return rv;
};
})();
// for the displaying or not import into CardBook for one attachment
// onShowSaveAttachmentMenuSingle
(function() {
// Keep a reference to the original function.
var _original = onShowSaveAttachmentMenuSingle;
// Override a function.
onShowSaveAttachmentMenuSingle = function() {
// Execute original function.
var rv = _original.apply(null, arguments);
ovl_attachments.displayCardBookMenu();
// return the original result
return rv;
};
})();
// for the displaying or not import into CardBook for all attachments
// goUpdateAttachmentCommands
(function() {
// Keep a reference to the original function.
var _original = goUpdateAttachmentCommands;
// Override a function.
goUpdateAttachmentCommands = function() {
// Execute original function.
var rv = _original.apply(null, arguments);
ovl_attachments.displayCardBookMenu();
// return the original result
return rv;
};
})();
// for the displaying or not import into CardBook for one attachment
// onShowAttachmentItemContextMenu
(function() {
// Keep a reference to the original function.
var _original = onShowAttachmentItemContextMenu;
// Override a function.
onShowAttachmentItemContextMenu = function() {
// Execute original function.
var rv = _original.apply(null, arguments);
ovl_attachments.displayCardBookMenu();
// return the original result
return rv;
};
})();
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xul-overlay href="chrome://cardbook/content/ovl_cardbookStringBundle.xul"?>
<!DOCTYPE overlay SYSTEM "chrome://cardbook/locale/ovl_cardbook.dtd">
<overlay id="ovl_attachments"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<stringbundleset id="stringbundleset"/>
<script src="chrome://cardbook/content/cardbookUtils.js"/>
<script src="chrome://cardbook/content/wdw_log.js"/>
<script src="chrome://cardbook/content/attachments/ovl_attachments.js"/>
<menupopup id="attachmentSaveAllMultipleMenu" >
<menu id="attachments1CardBookImport" label="&addAllAttachementsToCardBookMenuLabel;" insertafter="button-saveAllAttachments">
<menupopup id="attachments1CardBookImportPopup"/>
</menu>
</menupopup>
<menupopup id="attachmentSaveAllSingleMenu" >
<menu id="attachment1CardBookImport" label="&addAttachementToCardBookMenuLabel;" insertafter="button-saveAttachment">
<menupopup id="attachment1CardBookImportPopup"/>
</menu>
</menupopup>
<menupopup id="attachmentListContext" >
<menu id="attachments2CardBookImport" label="&addAllAttachementsToCardBookMenuLabel;" insertafter="context-saveAllAttachments">
<menupopup id="attachments2CardBookImportPopup"/>
</menu>
</menupopup>
<menupopup id="attachmentItemContext" >
<menu id="attachment2CardBookImport" label="&addAttachementToCardBookMenuLabel;" insertafter="context-saveAttachment">
<menupopup id="attachment2CardBookImportPopup"/>
</menu>
</menupopup>
</overlay>
if ("undefined" == typeof(ovl_attachvCard)) {
var ovl_attachvCard = {
attachvCard: function () {
Components.utils.import("chrome://cardbook/content/cardbookRepository.js");
cardbookUtils.jsInclude(["chrome://cardbook/content/preferences/cardbookPreferences.js"]);
var cardbookPrefService = new cardbookPreferenceService();
var selected = document.getElementById("msgIdentity").selectedItem;
var key = selected.getAttribute("identitykey");
if (cardbookPrefService.getMailAccountEnabled(key)) {
var filename = cardbookPrefService.getMailAccountFileName(key)
if (filename != null && filename !== undefined && filename != "") {
var cardbookId = cardbookPrefService.getMailAccountDirPrefId(key)+"::"+cardbookPrefService.getMailAccountUid(key)
if (cardbookRepository.cardbookCards[cardbookId]) {
var myCard = cardbookRepository.cardbookCards[cardbookId];
var attachment = Components.classes["@mozilla.org/messengercompose/attachment;1"].createInstance(Components.interfaces.nsIMsgAttachment);
attachment.contentType = "text/vcard";
attachment.name = filename;
var myFile = cardbookUtils.getTempFile(filename);
if (myFile.exists() && myFile.isFile()) {
try {
myFile.remove(true);
} catch(e) {
cardbookUtils.formatStringForOutput("errorAttachingFile", [myFile.path, e], "Error");
return;
}
}
cardbookSynchronization.writeContentToFile(myFile.path, cardbookUtils.getvCardForEmail(myCard), "UTF8");
if (myFile.exists() && myFile.isFile()) {
attachment.url = "file:///" + myFile.path;
gMsgCompose.compFields.addAttachment(attachment);
} else {
cardbookUtils.formatStringForOutput("errorAttachingFile", [myFile.path], "Error");
}
}
}
}
}
}
};
window.addEventListener("compose-send-message", function(e) { ovl_attachvCard.attachvCard(e); }, true);
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE overlay>
<overlay id="ovl_attachvCard"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="chrome://cardbook/content/wdw_log.js"/>
<script src="chrome://cardbook/content/cardbookUtils.js"/>
<script src="chrome://cardbook/content/cardbookSynchronization.js"/>
<script src="chrome://cardbook/content/attachvCard/ovl_attachvCard.js"/>
</overlay>
if ("undefined" == typeof(cardbookAutocomplete)) {
var cardbookAutocomplete = {
iconRuleStrings: {},
celltextRuleStrings: {},
textRuleStrings: {},
defineMsgIconsRules: function () {
cardbookAutocomplete.iconRuleStrings["local"] = {};
cardbookAutocomplete.iconRuleStrings["local"]["LINUX"] = "treechildren::-moz-tree-image(local treecolAutoCompleteValue) {\
margin-inline-start: 3px;\
margin-inline-end: 2px;\
list-style-image: url('chrome://messenger/skin/icons/server.png');\
-moz-image-region: rect(0 48px 16px 32px);\
}";
cardbookAutocomplete.iconRuleStrings["local"]["WIN"] = "treechildren::-moz-tree-image(local treecolAutoCompleteValue) {\
margin-inline-start: 2px;\
margin-inline-end: 5px;\
list-style-image: url('chrome://messenger/skin/icons/server.png');\
-moz-image-region: rect(0 48px 16px 32px);\
}";
cardbookAutocomplete.iconRuleStrings["local"]["OSX"] = "treechildren::-moz-tree-image(local treecolAutoCompleteValue) {\
margin-top: 2px;\
margin-bottom: 2px;\
margin-inline-start: 4px;\
margin-inline-end: -1px;\
list-style-image: url('chrome://messenger/skin/icons/server.png');\
-moz-image-region: rect(0 48px 16px 32px);\
}";
cardbookAutocomplete.iconRuleStrings["remote"] = {};
cardbookAutocomplete.iconRuleStrings["remote"]["LINUX"] = "treechildren::-moz-tree-image(remote treecolAutoCompleteValue) {\
margin-inline-start: 3px;\
margin-inline-end: 2px;\
list-style-image: url('chrome://messenger/skin/addressbook/icons/remote-addrbook.png');\
}";
cardbookAutocomplete.iconRuleStrings["remote"]["WIN"] = "treechildren::-moz-tree-image(remote treecolAutoCompleteValue) {\
margin-inline-start: 2px;\
margin-inline-end: 5px;\
list-style-image: url('chrome://messenger/skin/addressbook/icons/remote-addrbook.png');\
}";
cardbookAutocomplete.iconRuleStrings["remote"]["OSX"] = "treechildren::-moz-tree-image(remote treecolAutoCompleteValue) {\
margin-top: 2px;\
margin-bottom: 2px;\
margin-inline-start: 4px;\
margin-inline-end: -1px;\
list-style-image: url('chrome://messenger/skin/addressbook/icons/remote-addrbook.png');\
}";
cardbookAutocomplete.iconRuleStrings["standard-abook"] = {};
cardbookAutocomplete.iconRuleStrings["standard-abook"]["LINUX"] = "treechildren::-moz-tree-image(standard-abook treecolAutoCompleteValue) {\
margin-inline-start: 3px;\
margin-inline-end: 2px;\
list-style-image: url('chrome://messenger/skin/addressbook/icons/addrbook.png');\
}";
cardbookAutocomplete.iconRuleStrings["standard-abook"]["WIN"] = "treechildren::-moz-tree-image(standard-abook treecolAutoCompleteValue) {\
margin-inline-start: 2px;\
margin-inline-end: 5px;\
list-style-image: url('chrome://messenger/skin/addressbook/icons/addrbook.png');\
}";
cardbookAutocomplete.iconRuleStrings["standard-abook"]["OSX"] = "treechildren::-moz-tree-image(standard-abook treecolAutoCompleteValue) {\
margin-top: 2px;\
margin-bottom: 2px;\
margin-inline-start: 4px;\
margin-inline-end: -1px;\
list-style-image: url('chrome://messenger/skin/addressbook/icons/addrbook.png');\
}";
},
createCssMsgIconsRules: function (aStyleSheet, aOSName) {
var ruleIndex = aStyleSheet.insertRule(cardbookAutocomplete.iconRuleStrings["local"][aOSName], aStyleSheet.cssRules.length);
var ruleIndex = aStyleSheet.insertRule(cardbookAutocomplete.iconRuleStrings["remote"][aOSName], aStyleSheet.cssRules.length);
var ruleIndex = aStyleSheet.insertRule(cardbookAutocomplete.iconRuleStrings["standard-abook"][aOSName], aStyleSheet.cssRules.length);
},
createCssMsgAccountRules: function (aStyleSheet, aStyle, aColor, aOSName) {
cardbookAutocomplete.celltextRuleStrings["LINUX"] = "treechildren::-moz-tree-cell-text(" + aStyle + ") {\
}";
cardbookAutocomplete.celltextRuleStrings["WIN"] = "treechildren::-moz-tree-cell-text(" + aStyle + ") {\
}";
cardbookAutocomplete.celltextRuleStrings["OSX"] = "treechildren::-moz-tree-cell-text(" + aStyle + ") {\
margin-top: 2px;\
margin-bottom: 2px;\
margin-inline-start: 15px;\
margin-inline-end: -3px;\
border: none;\
}";
cardbookAutocomplete.textRuleStrings["LINUX"] = "treechildren::-moz-tree-cell(" + aStyle + ") {\
background-color: " + aColor + ";\
}";
cardbookAutocomplete.textRuleStrings["WIN"] = "treechildren::-moz-tree-cell(" + aStyle + ") {\
background-color: " + aColor + ";\
}";
cardbookAutocomplete.textRuleStrings["OSX"] = "treechildren::-moz-tree-cell(" + aStyle + ") {\
background-color: " + aColor + ";\
}";
var ruleIndex = aStyleSheet.insertRule(cardbookAutocomplete.celltextRuleStrings[aOSName], aStyleSheet.cssRules.length);
var ruleIndex = aStyleSheet.insertRule(cardbookAutocomplete.textRuleStrings[aOSName], aStyleSheet.cssRules.length);
},
loadCssRules: function () {
try {
if (navigator.appVersion.indexOf("Win")!=-1) {
var OSName="WIN";
} else if (navigator.appVersion.indexOf("Mac")!=-1) {
var OSName="OSX";
} else {
var OSName="LINUX";
}
cardbookAutocomplete.defineMsgIconsRules();
Components.utils.import("chrome://cardbook/content/cardbookRepository.js");
for (var prop in document.styleSheets) {
var styleSheet = document.styleSheets[prop];
if (styleSheet.href == "chrome://cardbook/skin/cardbookAutocomplete.css") {
for (var i = 0; i < cardbookRepository.cardbookAccounts.length; i++) {
if (cardbookRepository.cardbookAccounts[i][1] && cardbookRepository.cardbookAccounts[i][5] && cardbookRepository.cardbookAccounts[i][6] != "SEARCH") {
var dirPrefId = cardbookRepository.cardbookAccounts[i][4];
var cardbookPrefService = new cardbookPreferenceService(dirPrefId);
var myColor = cardbookPrefService.getColor()
var myStyle = cardbookRepository.getIconType(cardbookRepository.cardbookAccounts[i][6]) + " color_" + dirPrefId;
cardbookAutocomplete.createCssMsgAccountRules(styleSheet, myStyle, myColor, OSName);
}
}
cardbookAutocomplete.createCssMsgIconsRules(styleSheet, OSName);
cardbookRepository.reloadCss(styleSheet.href);
}
}