commit 3b22e236d34e238fb87d231a0807d816711454ec Author: Klaus-Uwe Mitterer Date: Sun Jun 3 15:31:49 2018 +0200 Checking in ancient code diff --git a/META-INF/manifest.mf b/META-INF/manifest.mf new file mode 100644 index 0000000..ec8f124 --- /dev/null +++ b/META-INF/manifest.mf @@ -0,0 +1,83 @@ +Manifest-Version: 1.0 +Created-By: Signtool (signtool 1.3) +Comments: PLEASE DO NOT EDIT THIS FILE. YOU WILL BREAK IT. + +Name: chrome/locale/en-US/autovcard.dtd +Digest-Algorithms: MD5 SHA1 +MD5-Digest: 8uSpD+LJzjSszIGAJPsARQ== +SHA1-Digest: tuH/5ZLxvEj7MnUGmAEW0wLqkoI= + +Name: chrome/locale/de-DE/autovcard.dtd +Digest-Algorithms: MD5 SHA1 +MD5-Digest: nfcHPEF1RnPbHqn691dtcQ== +SHA1-Digest: AmwIerR6l6Cj/QQRztJRhIOgfHQ= + +Name: chrome/content/options.xul +Digest-Algorithms: MD5 SHA1 +MD5-Digest: RNJOcat//1Fk1bZ2Yy4xJQ== +SHA1-Digest: FJfmSWzTSF4wVY+Uxdp4uoEtAtg= + +Name: chrome/content/autovcard.js +Digest-Algorithms: MD5 SHA1 +MD5-Digest: y+tgc4CHRCG10jJj7XCpTA== +SHA1-Digest: bdr7ngeGONiEPoa8GG9FuHERN5w= + +Name: chrome/content/autovcard16_delete.png +Digest-Algorithms: MD5 SHA1 +MD5-Digest: T+qv3ppia/cSB6yCk1Wkpg== +SHA1-Digest: GSv3yiWraCzps3RQZEQll/nMy5Y= + +Name: chrome/content/autovcard16_attach.png +Digest-Algorithms: MD5 SHA1 +MD5-Digest: Bomb7Uy4jDL/HQuWfwzPvg== +SHA1-Digest: t1Yd3C0TRSF+KLaINEUzGaWqsh8= + +Name: chrome/content/autovcard24_attach.png +Digest-Algorithms: MD5 SHA1 +MD5-Digest: lVJNEB4tRD6sr9k0VICbRg== +SHA1-Digest: PQWWDSZGM4p/v9cCDivTxknw4nU= + +Name: chrome/content/autovcard.xul +Digest-Algorithms: MD5 SHA1 +MD5-Digest: bC9PLMmDNwHXIFgkeNLR9Q== +SHA1-Digest: UaMZFhCQaI4jfCIkz6huUzCVMpM= + +Name: chrome/content/autovcard24-disabled.png +Digest-Algorithms: MD5 SHA1 +MD5-Digest: J3HEEAzyF7aYCmZY6S55mQ== +SHA1-Digest: BBNlFk2McFpK/PyIQ3kLrpAeQ0Y= + +Name: chrome/content/dialog.xul +Digest-Algorithms: MD5 SHA1 +MD5-Digest: 4GSpavauFCbdkrS91684Hw== +SHA1-Digest: zWwdoBHzj0uIQI0bZFjqA1XURr4= + +Name: chrome/content/autovcard24_delete.png +Digest-Algorithms: MD5 SHA1 +MD5-Digest: KYj4QpvjI04j+4b/uvFs9Q== +SHA1-Digest: Ynp6lT5hawN0J6QB0nDB5j6I+1M= + +Name: chrome/content/autovcard.css +Digest-Algorithms: MD5 SHA1 +MD5-Digest: EPMi5MHutJP1Yc50LL6IwA== +SHA1-Digest: gGEHD+Ib6EjehgQpQtKMI8nGIws= + +Name: chrome/content/autovcard16-disabled.png +Digest-Algorithms: MD5 SHA1 +MD5-Digest: rk8UA+hKaYM+0k9DCDUtAQ== +SHA1-Digest: qtKw10i1fUOaRGkajHk5ZQRHa8c= + +Name: install.rdf +Digest-Algorithms: MD5 SHA1 +MD5-Digest: EaSH4ZrLgoe4A2CKWCh5jA== +SHA1-Digest: 23HhIt/isOLbIv3SZ+GlD5s40dk= + +Name: chrome.manifest +Digest-Algorithms: MD5 SHA1 +MD5-Digest: BGE83atWiPdtAZupowoq4Q== +SHA1-Digest: qDBeNo2zBa1JR7XZnUJhlkfWcQI= + +Name: defaults/preferences/prefs.js +Digest-Algorithms: MD5 SHA1 +MD5-Digest: L7XfiswIPPZKvRayRshw6g== +SHA1-Digest: f4kde1iPD3w1RqqSH9ktC7z4ito= diff --git a/META-INF/zigbert.rsa b/META-INF/zigbert.rsa new file mode 100644 index 0000000..10e3c38 Binary files /dev/null and b/META-INF/zigbert.rsa differ diff --git a/META-INF/zigbert.sf b/META-INF/zigbert.sf new file mode 100644 index 0000000..62d3068 --- /dev/null +++ b/META-INF/zigbert.sf @@ -0,0 +1,86 @@ +Signature-Version: 1.0 +Created-By: Signtool (signtool 1.3) +Comments: PLEASE DO NOT EDIT THIS FILE. YOU WILL BREAK IT. +Digest-Algorithms: MD5 SHA1 +MD5-Digest: f2XP9lsoHe04PBOvuFXL5g== +SHA1-Digest: 8RHZ0uUrxScBNJtHgI/t7stA9yA= + +Name: chrome/locale/en-US/autovcard.dtd +Digest-Algorithms: MD5 SHA1 +MD5-Digest: dvSC9Aq4GX7PyXhywsWVww== +SHA1-Digest: k3JeZhfpwAE/V/zTMoDKseE5e78= + +Name: chrome/locale/de-DE/autovcard.dtd +Digest-Algorithms: MD5 SHA1 +MD5-Digest: SN5kF2iwWJnQKT+AsEE0hg== +SHA1-Digest: m9f6DzQ2cK5x4aBhEEJGVN+OXV4= + +Name: chrome/content/options.xul +Digest-Algorithms: MD5 SHA1 +MD5-Digest: 2Ap9/IHYxAzfND9qn5Q+Hw== +SHA1-Digest: 9UBlBM6/3w2Hqxu8VorTL/bllFA= + +Name: chrome/content/autovcard.js +Digest-Algorithms: MD5 SHA1 +MD5-Digest: YOHsQQNOJ0ljcUR7OJpdVw== +SHA1-Digest: 1isfFf/REPW5URGZ1yY7aENIKZg= + +Name: chrome/content/autovcard16_delete.png +Digest-Algorithms: MD5 SHA1 +MD5-Digest: lgtR2KFT8dH3IdKSPCns2g== +SHA1-Digest: O/8Y1rong0eKfeSBt2gKXwjCuHg= + +Name: chrome/content/autovcard16_attach.png +Digest-Algorithms: MD5 SHA1 +MD5-Digest: 7s5Lz+tVR5lCpTz6HOBmMg== +SHA1-Digest: Sa8FIXwBOWdWDjDS9QHpJNCxG0k= + +Name: chrome/content/autovcard24_attach.png +Digest-Algorithms: MD5 SHA1 +MD5-Digest: 9yxQdAMOuavWjPtDn2KnHQ== +SHA1-Digest: mj95B7rhQl1FJK/PnIdkSoqne5o= + +Name: chrome/content/autovcard.xul +Digest-Algorithms: MD5 SHA1 +MD5-Digest: Gk9pplPvepXlaDCsSa7Cbg== +SHA1-Digest: SzGJH1NRwYm0W4yPZ141vroASh8= + +Name: chrome/content/autovcard24-disabled.png +Digest-Algorithms: MD5 SHA1 +MD5-Digest: FcfihevoqAsC3O7wobcV5w== +SHA1-Digest: KRiBED87GDuDZELz5YX5BT9w6+M= + +Name: chrome/content/dialog.xul +Digest-Algorithms: MD5 SHA1 +MD5-Digest: +C1gzv03kmC5Olp7dzp0rg== +SHA1-Digest: JkdHPnr95BwZhCp2Tt4b0QZADGk= + +Name: chrome/content/autovcard24_delete.png +Digest-Algorithms: MD5 SHA1 +MD5-Digest: 5fM4+fkMEZj4/4c1oBN3TQ== +SHA1-Digest: sXq9tVqEV6+Fmb1O0aONcySWhto= + +Name: chrome/content/autovcard.css +Digest-Algorithms: MD5 SHA1 +MD5-Digest: 2rUNcT7k5YRDn2nQudjtag== +SHA1-Digest: qrT1Qsjy2HV2bMZpybRVw+/kN4Q= + +Name: chrome/content/autovcard16-disabled.png +Digest-Algorithms: MD5 SHA1 +MD5-Digest: pWHD5rIUkNAvy4y4cETuAw== +SHA1-Digest: Y2iixVRiYqGQ8SfaoZXyDXLQrxo= + +Name: install.rdf +Digest-Algorithms: MD5 SHA1 +MD5-Digest: t0cKMmpf6y4i4q/av6X1KA== +SHA1-Digest: COIykYRtGh4066pyPybOVm2Vm1c= + +Name: chrome.manifest +Digest-Algorithms: MD5 SHA1 +MD5-Digest: rDHI6jN//zVwG1WVrIfvyA== +SHA1-Digest: tGli9tiMyc0TIkPFA9kvuMOHk88= + +Name: defaults/preferences/prefs.js +Digest-Algorithms: MD5 SHA1 +MD5-Digest: AmeSLhdYOebKMRerTpSnGg== +SHA1-Digest: r7G+SXlujfc31FbNab0PZpo8HMQ= diff --git a/chrome.manifest b/chrome.manifest new file mode 100644 index 0000000..dfead0e --- /dev/null +++ b/chrome.manifest @@ -0,0 +1,3 @@ +content autovcard chrome/content/ +locale autovcard en-US chrome/locale/en-US/ +overlay chrome://messenger/content/messengercompose/messengercompose.xul chrome://autovcard/content/autovcard.xul \ No newline at end of file diff --git a/chrome/content/autovcard.css b/chrome/content/autovcard.css new file mode 100644 index 0000000..e39090d --- /dev/null +++ b/chrome/content/autovcard.css @@ -0,0 +1,23 @@ +.autovcard_delete{ + list-style-image: url("chrome://autovcard/content/autovcard24_delete.png"); +} + +toolbar[iconsize="small"] .autovcard_delete{ + list-style-image: url("chrome://autovcard/content/autovcard16_delete.png"); +} + +.autovcard_attach{ + list-style-image: url("chrome://autovcard/content/autovcard24_attach.png"); +} + +toolbar[iconsize="small"] .autovcard_attach{ + list-style-image: url("chrome://autovcard/content/autovcard16_attach.png"); +} + +.autovcard_delete[disabled=true], .autovcard_attach[disabled=true]{ + list-style-image: url("chrome://autovcard/content/autovcard24-disabled.png"); +} + +toolbar[iconsize="small"] .autovcard_attach[disabled=true], toolbar[iconsize="small"] .autovcard_delete[disabled=true]{ + list-style-image: url("chrome://autovcard/content/autovcard16-disabled.png"); +} \ No newline at end of file diff --git a/chrome/content/autovcard.js b/chrome/content/autovcard.js new file mode 100644 index 0000000..5ec6472 --- /dev/null +++ b/chrome/content/autovcard.js @@ -0,0 +1,248 @@ +const Cc = Components.classes; +const Ci = Components.interfaces; +var autovcard = { + + db_connection: null, + + statement: null, + + to: "", + + to_row_id: 100, + + result: false, + + manually: false, + + init : function(){ + this.to = ""; + this.to_row_id = 100; + this.result = false; + this.manually = false; + gMsgCompose.QueryInterface(Ci.nsIMsgCompose).addMsgSendListener(this.send_listener); + this.find_to(); + this.db_init(); + this.check(); + }, + + nospace : function (str) { + var re = new RegExp(/^(\s|\u00A0)+/g); + return str.replace(re, ''); + }, + + check: function(){ + this.to = this.nospace(this.to); + if (this.to == ''){return}; + this.statement.params.parameter = this.to; + this.result=true; + this.statement.executeAsync({ + handleResult: function(aResultSet) { + var ok = false; + for (let row = aResultSet.getNextRow(); row; row = aResultSet.getNextRow()) { + let value = row.getResultByName("email"); + if (value == autovcard.to){ok = true;break}; + }; + if(ok){ + autovcard.manually = true; + autovcard.delete_vcard(); + }else{ + autovcard.manually = false; + autovcard.attach_vcard(); + } + }, + + handleError: function(aError) { + }, + + handleCompletion: function(aReason) { + autovcard.result=false; + } + }); + }, + + find_to: function(){ +// +// alert('tt'); + for (var i = 1; i < 100; i++) { + var totype = document.getElementById('addressCol1#'+i); + if(totype == null){ + this.to_row_id = 100; + this.to = ''; +//this.manually = false; + this.manually = false; +// +// alert('tt'); + this.delete_vcard(); + break; + }; + if((totype.value =='addr_to') && (document.getElementById('addressCol2#'+i).value != '')){ + if((this.to_row_id == i) && (this.to == this.nospace(document.getElementById('addressCol2#'+i).value))){ + break; + } + this.to_row_id = i; + this.to = document.getElementById('addressCol2#'+i).value; + this.check(); + break; + } + } + }, + + delete_vcard : function(){ + if(this.manually){ + document.getElementById("autovcard_button").setAttribute('label',document.getElementById("autovcard_button").getAttribute('label_attach')); + document.getElementById("autovcard_button").className =('toolbarbutton-1 autovcard_attach'); + document.getElementById("autovcard_button").setAttribute('disabled','false'); + }else{ + document.getElementById("autovcard_button").setAttribute('disabled','true'); + } + gMsgCompose.compFields.attachVCard = false; + document.getElementById("cmd_attachVCard").setAttribute('checked','false'); + }, + + attach_vcard : function(){ + document.getElementById("autovcard_button").setAttribute('label',document.getElementById("autovcard_button").getAttribute('label_delete')); + document.getElementById("autovcard_button").className =('toolbarbutton-1 autovcard_delete'); + document.getElementById("autovcard_button").setAttribute('disabled','false'); + gMsgCompose.compFields.attachVCard = true; + document.getElementById("cmd_attachVCard").setAttribute('checked','true'); + }, + + totype_changed : function(e){ + var id = e.target.parentNode.parentNode.id; + id = id.slice(id.lastIndexOf('#')+1); + if(e.target.value =='addr_to'){ + if ((id < this.to_row_id) && (document.getElementById('addressCol2#'+id).value != '')){ + this.to_row_id = id; + this.to = document.getElementById('addressCol2#'+id).value; + this.check(); + } + }else{ + if(id == this.to_row_id){ + this.find_to(); + } + } + }, + + to_changed : function(e){ + var id = e.target.id; + id = id.slice(id.lastIndexOf('#')+1); + if(document.getElementById('addressCol1#'+id).value =='addr_to'){ + if((id == this.to_row_id) && (e.target.value == '')){ + this.find_to(); + }else{ + if((id <= this.to_row_id) && (e.target.value != '')){ + this.to_row_id = id; + this.to = e.target.value; + this.check(); + } + } + } + }, + + send_listener : { + onStopSending: function(i, s, m, r){ + if(s == '0'){ + autovcard.to = autovcard.nospace(autovcard.to); + var statement = autovcard.db_connection.createStatement("INSERT INTO email VALUES(:parameter)"); + statement.params.parameter = autovcard.to; + try{ + statement.execute(); + } catch (e) {}; + }; + }, + onSendNotPerformed: function(){}, + onGetDraftFolderURI: function(){}, + onProgress: function(){}, + onStartSending: function(){}, + onStatus: function(){} + }, + + db_init: function() { + var dirService = Cc["@mozilla.org/file/directory_service;1"]. + getService(Ci.nsIProperties); + + var dbFile = dirService.get("ProfD", Ci.nsIFile); + dbFile.append("autovcard.sqlite"); + + var dbService = Cc["@mozilla.org/storage/service;1"]. + getService(Ci.mozIStorageService); + + var dbConnection; + + if (!dbFile.exists()) + dbConnection = this.db_create(dbService, dbFile); + else { + dbConnection = dbService.openDatabase(dbFile); + } + this.db_connection = dbConnection; + this.statement = this.db_connection.createStatement("SELECT * FROM email WHERE email = :parameter UNION SELECT 'empty'"); + }, + + db_create: function(aDBService, aDBFile) { + var dbConnection = aDBService.openDatabase(aDBFile); + dbConnection.createTable('email', "email TEXT PRIMARY KEY"); + return dbConnection; + }, + + add_note: function(){ + + + + if(document.getElementById("cmd_attachVCard").getAttribute('checked') =='true'){ + var comment; + if(this.manually){ + comment = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch("autovcard.label.options.").getCharPref("comment_manually"); + }else{ + comment = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch("autovcard.label.options.").getCharPref("comment"); + } + GetCurrentEditor().beginTransaction(); + GetCurrentEditor().endOfDocument(); + if (GetCurrentEditorType() == "textmail" || GetCurrentEditorType() == "text"){ + GetCurrentEditor().insertText(comment); + }else{ + GetCurrentEditor().insertHTML(comment.replace(/\n+/g,"
")); + } + GetCurrentEditor().endTransaction(); + } + + }, + + check_vcard: function(command,i){ + if (!i){ + this.find_to(); + setTimeout(function(){autovcard.check_vcard(command,1);},100); + return; + }; + if(this.result && i < 20){ + setTimeout(function(){autovcard.check_vcard(command,i++);},100); + return; + }; + if((document.getElementById("cmd_attachVCard").getAttribute('checked') =='true') && !gMsgCompose.identity.escapedVCard){ + var params = {vcard:null, out:null}; + window.openDialog("chrome://autovcard/content/dialog.xul", "", + "chrome, dialog, modal, resizable=yes,centerscreen", params).focus(); + + if (params.out == 'ok') { + gMsgCompose.identity.escapedVCard = params.vcard; + }else{ + this.manually = true; + this.delete_vcard(); + } + } + goDoCommand(command); + }, + + button_click: function(){ + this.manually = true; + if(document.getElementById("cmd_attachVCard").getAttribute('checked') =='true'){ + this.delete_vcard(); + }else{ + this.attach_vcard(); + } + + } + +}; + +window.addEventListener("compose-window-init", function(){autovcard.init();}, true); +window.addEventListener("compose-send-message", function(){autovcard.add_note();}, true); diff --git a/chrome/content/autovcard.xul b/chrome/content/autovcard.xul new file mode 100644 index 0000000..be478ab --- /dev/null +++ b/chrome/content/autovcard.xul @@ -0,0 +1,33 @@ + + + + + + + + + diff --git a/chrome/content/options.xul b/chrome/content/options.xul new file mode 100644 index 0000000..1ac3e7e --- /dev/null +++ b/chrome/content/options.xul @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/chrome/locale/de-DE/autovcard.dtd b/chrome/locale/de-DE/autovcard.dtd new file mode 100644 index 0000000..c50f132 --- /dev/null +++ b/chrome/locale/de-DE/autovcard.dtd @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/chrome/locale/en-US/autovcard.dtd b/chrome/locale/en-US/autovcard.dtd new file mode 100644 index 0000000..181213f --- /dev/null +++ b/chrome/locale/en-US/autovcard.dtd @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/defaults/preferences/prefs.js b/defaults/preferences/prefs.js new file mode 100644 index 0000000..87db853 --- /dev/null +++ b/defaults/preferences/prefs.js @@ -0,0 +1,10 @@ +pref("autovcard.label.options.comment", " +-- + +vCard attached automatically +"); +pref("autovcard.label.options.comment_manually", " +-- + +vCard attached +"); diff --git a/install.rdf b/install.rdf new file mode 100644 index 0000000..b68aed5 --- /dev/null +++ b/install.rdf @@ -0,0 +1,26 @@ + + + + autovcard@klaus-uwe.me + 2 + Auto vCard + 1.2 + Automatically attach vCard + chrome://autovcard/content/options.xul + Klaus-Uwe Mitterer + + + {3550f703-e582-4d05-9a08-453d09bdfdc6} + 3.0 + 10.* + + + + + de-DE + Auto vCard + Hängt automatisch eine vCard an + + + +