Changeset 9b501a


Ignore:
Timestamp:
Apr 17, 2008, 4:25:49 PM (14 years ago)
Author:
rene <rene@…>
Branches:
master
Children:
8f022f
Parents:
e97c30
Message:

implementation of storageExtras done. Cleanup required but should work.

Location:
chrome/content/v_identity
Files:
2 added
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • chrome/content/v_identity/vI_rdfDataEditor.js

    re97c30 r9b501a  
    2626    __rdfDatasource : null,
    2727   
    28     extras : new vI_storageExtras(resource, vI_rdfDatasource.__getRDFValue),
     28    storageExtras : null,
    2929
    3030    init : function() {
     
    6060        vI_smtpSelector.setMenuToKey(window.arguments[0]["smtpKey"])
    6161       
    62         vI_rdfDataEditor.extras.setEditorValues();
     62        vI_rdfDataEditor.storageExtras = new vI_storageExtras()
     63        vI_rdfDataEditor.storageExtras.setEditorValues();
     64        vI_storageExtrasHelper.hideUnusedEditorFields();
    6365    },
    6466   
     
    7577            vI_rdfDataEditor.__rdfDatasource.removeVIdentityFromRDF(window.arguments[0]["resource"])
    7678           
    77         vI_rdfDataEditor.extras.readEditorValues();
     79        vI_rdfDataEditor.storageExtras.readEditorValues();
    7880        vI_rdfDataEditor.__rdfDatasource.updateRDF(
    7981                document.getElementById("recipient").value,
     
    8284                document.getElementById("identity_list").selectedItem.getAttribute("value"),
    8385                document.getElementById("smtp_server_list").selectedItem.getAttribute("key"),
     86                vI_rdfDataEditor.storageExtras
    8487                )
    8588    },
  • chrome/content/v_identity/vI_rdfDataEditor.xul

    re97c30 r9b501a  
    3434
    3535<script type="application/x-javascript" src="chrome://v_identity/content/vI_rdfDataEditor.js" />
     36<script type="application/x-javascript" src="chrome://v_identity/content/vI_storageExtras.js" />
    3637<script type="application/x-javascript" src="chrome://v_identity/content/vI_helper.js" />
    3738<script type="application/x-javascript" src="chrome://v_identity/content/vI_smtpSelector.js" />
  • chrome/content/v_identity/vI_rdfDataTree.js

    re97c30 r9b501a  
    4848        vI_rdfDataTree.__getSMTPnames();
    4949        vI_rdfDataTree.__getIDnames();
     50        vI_storageExtrasHelper.hideUnusedTreeCols();
    5051        vI_rdfDataTree.loadTable();
    5152    },
     
    9394                idCol : idName,
    9495                idKey : values.id,
    95                 extras : values.extras,
    9696                resource : resource }
    9797       
     98        values.extras.addPrefs(pref);
    9899        vI_rdfDataTree.__idData.push(pref);
    99100    },
  • chrome/content/v_identity/vI_rdfDataTree.xul

    re97c30 r9b501a  
    4242<script type="application/x-javascript" src="chrome://v_identity/content/vI_helper.js" />
    4343<script type="application/x-javascript" src="chrome://v_identity/content/vI_rdfDatasource.js" />
     44<script type="application/x-javascript" src="chrome://v_identity/content/vI_storageExtras.js" />
    4445<script type="application/x-javascript" src="chrome://v_identity/content/vI_notificationBar.js"/>
    4546<script type="application/x-javascript" src="chrome://messenger/content/messengercompose/MsgComposeCommands.js"/>
     
    103104    persist="sortDirection sortResource" sortDirection="ascending" sortResource="recipientCol"
    104105    enableColumnDrag="true" context="configContext">
    105     <treecols>
     106    <treecols id="rdfDataTreeCols">
    106107        <treecol id="recipientCol" label="&vI_rdfDataTree.recipientColumn.label;" flex="10"
    107108            class="sortDirectionIndicator"
  • chrome/content/v_identity/vI_storageExtras.js

    re97c30 r9b501a  
    2222 * ***** END LICENSE BLOCK ***** */
    2323
    24 //~ vI_storageExtras = new __vI_storageExtras();
     24vI_storageExtrasHelper = {
     25    preferences : Components.classes["@mozilla.org/preferences-service;1"]
     26            .getService(Components.interfaces.nsIPrefService)
     27            .getBranch("extensions.virtualIdentity."),
     28   
     29    hideUnusedTreeCols : function() {
     30        var storageExtras = new vI_storageExtras();
     31        for( var i = 0; i < storageExtras.extras.length; i++ )
     32            if (!vI_storageExtrasHelper.preferences.getBoolPref(storageExtras.extras[i].option))
     33                document.getElementById(storageExtras.extras[i].field + "Col").setAttribute("hidden", "true");
     34    },
     35   
     36    hideUnusedEditorFields : function() {
     37        var storageExtras = new vI_storageExtras();
     38        var hide = (document.getElementById("vI_storageExtras_hideUnusedEditorFields").getAttribute("checked") == "true")
     39        for( var i = 0; i < storageExtras.extras.length; i++ )
     40            document.getElementById("vI_" + storageExtras.extras[i].option).setAttribute("hidden",
     41                hide && !vI_storageExtrasHelper.preferences.getBoolPref(storageExtras.extras[i].option))
     42    }
     43}
    2544
    2645function vI_storageExtras(callFunction, resource) {
    27     this.extras = [ new vI_storageExtras_returnReciept, new vI_storageExtras_characterEncoding ]
     46    this.extras = [
     47        new vI_storageExtras_checkbox(
     48            "reciept", "storageExtras_returnReciept", "returnReceiptMenu", null, null),
     49        new vI_storageExtras_characterEncoding(),
     50        new vI_storageExtras_msgFormat(),
     51        new vI_storageExtras_sMime_messageEncryption(),
     52        new vI_storageExtras_checkbox(
     53            "sMimeSig", "storageExtras_sMime_messageSignature", "menu_securitySign1",
     54                (typeof(setSecuritySettings)=="function")?setSecuritySettings:null, 1),
     55        new vI_storageExtras_checkbox(
     56            "PGPEnc", "storageExtras_openPGP_messageEncryption", "enigmail_encrypted_send",
     57                (typeof(enigSetMenuSettings)=="function")?enigSetMenuSettings:null, ''),
     58        new vI_storageExtras_checkbox(
     59            "PGPSig", "storageExtras_openPGP_messageSignature", "enigmail_signed_send",
     60                (typeof(enigSetMenuSettings)=="function")?enigSetMenuSettings:null, ''),
     61        new vI_storageExtras_checkbox(
     62            "PGPMIME", "storageExtras_openPGP_PGPMIME", "enigmail_sendPGPMime",
     63                (typeof(enigSetMenuSettings)=="function")?enigSetMenuSettings:null, '')]
    2864    if (callFunction) this.loopForRDF(callFunction, resource)
    2965}
     
    5692    },
    5793    setEditorValues : function() {
    58         for( var i = 0; i < this.extras.length; i++ )
     94        for( var i = 0; i < this.extras.length; i++ ) {
     95            this.extras[i].value = window.arguments[0][this.extras[i].field + "Col"]
    5996            this.extras[i].setEditorValue();
     97        }
    6098    },
    6199    readEditorValues : function() {
     
    63101            this.extras[i].readEditorValue();
    64102    },
    65 }
    66 
    67 function vI_storageExtras_returnReciept() { }
    68 vI_storageExtras_returnReciept.prototype = {
    69     value : null,
    70     field : "reciept",
    71     option : "storageExtras_returnReciept",
    72     // function to set or read the value from/to the MessageCompose Dialog
    73     setValue : function() {
    74         document.getElementById("returnReceiptMenu").setAttribute("checked", this.value)
    75     },
    76     readValue : function() {
    77         this.value = document.getElementById("returnReceiptMenu").getAttribute("checked");
    78     },
    79     // function to set or read the value from the rdfDataEditor
    80     setEditorValue : function() {
    81         alert("setEditorValue");
    82     },
    83     readEditorValue : function() {
    84         alert("readEditorValue");
    85     }
    86 }
    87 
     103    addPrefs : function(pref) {
     104        for( var i = 0; i < this.extras.length; i++ )
     105            pref[this.extras[i].field + "Col"] = this.extras[i].value;
     106    },
     107}
     108
     109function vI_storageExtras_characterEncoding_setMenuMark() {
     110    var maileditCharsetMenu = document.getElementById("maileditCharsetMenu")
     111    var value = maileditCharsetMenu.getAttribute("unmarkedValue")
     112    if (value) {
     113        var menuitem = document.getElementById(value);
     114        if (menuitem) menuitem.setAttribute('checked', 'true');
     115        maileditCharsetMenu.removeAttribute("unmarkedValue")
     116    }
     117}
    88118function vI_storageExtras_characterEncoding() { }
    89119vI_storageExtras_characterEncoding.prototype = {
     
    91121    field : "charEnc",
    92122    option : "storageExtras_characterEncoding",
    93     // function to set the value in the MessageCompose Dialog
    94     setValue : function() {
    95         alert("setValue")
    96     },
    97     // function to store the selection of MessageCompose Dialog into value
    98     readValue : function() {
    99         alert("readValue Charset (not implemented)")
    100     },
     123    // function to set or read the value from/to the MessageCompose Dialog
     124    setValue : function() {
     125        if (!this.value) return;
     126       
     127        var menuitem = document.getElementById(this.value);
     128        if (menuitem) menuitem.setAttribute('checked', 'true');
     129        else {  // set menumark later if menu is not ready yet
     130            var maileditCharsetMenu = document.getElementById("maileditCharsetMenu")
     131            maileditCharsetMenu.setAttribute("unmarkedValue", this.value)
     132            var onpopupshowing = maileditCharsetMenu.getAttribute("onpopupshowing")
     133            document.getElementById("maileditCharsetMenu").setAttribute("onpopupshowing",
     134                onpopupshowing + ";vI_storageExtras_characterEncoding_setMenuMark();")
     135        }
     136        gMsgCompose.compFields.characterSet = this.value;
     137        SetDocumentCharacterSet(this.value);
     138        vI_notificationBar.dump("## vI_storageExtras_characterEncoding setValue " + this.value + "\n");
     139    },
     140    readValue : function() {
     141        this.value = gMsgCompose.compFields.characterSet;
     142        if (gCharsetConvertManager) {
     143            var charsetAlias = gCharsetConvertManager.getCharsetAlias(this.value);
     144            if (charsetAlias == "us-ascii") this.value = "ISO-8859-1";   // no menu item for "us-ascii"
     145        }
     146        vI_notificationBar.dump("## vI_storageExtras_characterEncoding readValue " + this.value + "\n");
     147    },
     148    // function to set or read the value from the rdfDataEditor
    101149    setEditorValue : function() {
    102         alert("setEditorValue");
    103     },
    104     readEditorValue : function() {
    105         alert("readEditorValue");
    106     }
    107 }
     150        CreateMenu('mailedit');
     151        document.getElementById("maileditCharsetMenu").selectedItem = document.getElementById(this.value);
     152        vI_notificationBar.dump("## vI_storageExtras_characterEncoding setEditorValue " + this.value + "\n");
     153    },
     154    readEditorValue : function() {
     155        this.value = document.getElementById("maileditCharsetMenu").selectedItem.id
     156        vI_notificationBar.dump("## vI_storageExtras_characterEncoding readEditorValue " + this.value + "\n");
     157    }
     158}
     159
     160function vI_storageExtras_msgFormat() { }
     161vI_storageExtras_msgFormat.prototype = {
     162    value : null,
     163    field : "msgFormat",
     164    option : "storageExtras_messageFormat",
     165    // function to set or read the value from/to the MessageCompose Dialog
     166    setValue : function() {
     167        if (!this.value) return;
     168        vI_notificationBar.dump("## vI_storageExtras_msgFormat setValue " + this.value + "\n");
     169        document.getElementById(this.value).setAttribute("checked","true");
     170        OutputFormatMenuSelect(document.getElementById(this.value))
     171    },
     172    readValue : function() {
     173        switch (gSendFormat) {
     174            case nsIMsgCompSendFormat.AskUser: this.value = "format_auto"; break;
     175            case nsIMsgCompSendFormat.PlainText: this.value = "format_plain"; break;
     176            case nsIMsgCompSendFormat.HTML: this.value = "format_html"; break;
     177            case nsIMsgCompSendFormat.Both: this.value = "format_both"; break;
     178        }
     179        vI_notificationBar.dump("## vI_storageExtras_msgFormat readValue " + this.value + "\n");
     180    },
     181    // function to set or read the value from the rdfDataEditor
     182    setEditorValue : function() {
     183        //~ document.getElementById(this.value).setAttribute("checked","true");
     184        document.getElementById("outputFormatMenu").selectedItem = document.getElementById(this.value);
     185        vI_notificationBar.dump("## vI_storageExtras_characterEncoding setEditorValue " + this.value + "\n");
     186    },
     187    readEditorValue : function() {
     188        this.value = document.getElementById("outputFormatMenu").selectedItem.id
     189        vI_notificationBar.dump("## vI_storageExtras_characterEncoding readEditorValue " + this.value + "\n");
     190    }
     191}
     192
     193function vI_storageExtras_sMime_messageEncryption() { }
     194vI_storageExtras_sMime_messageEncryption.prototype = {
     195    value : null,
     196    field : "sMimeEnc",
     197    option : "storageExtras_sMime_messageEncryption",
     198    // function to set or read the value from/to the MessageCompose Dialog
     199    setValue : function() {
     200        vI_notificationBar.dump("## vI_storageExtras_sMime_messageEncryption setValue " + this.value + "\n");
     201        if (this.value == "true") var element = document.getElementById("menu_securityEncryptRequire1")
     202        else var element = document.getElementById("menu_securityNoEncryption1")
     203        element.setAttribute("checked", "true");
     204        element.doCommand();
     205    },
     206    readValue : function() {
     207        setSecuritySettings(1)
     208        this.value = (document.getElementById("menu_securityEncryptRequire1").getAttribute("checked") == "true")?"true":"false"
     209        vI_notificationBar.dump("## vI_storageExtras_sMime_messageEncryption readValue " + this.value + "\n");
     210    },
     211    // function to set or read the value from the rdfDataEditor
     212    setEditorValue : function() {
     213        document.getElementById("vI_" + this.option).setAttribute("checked", this.value) },
     214    readEditorValue : function() {
     215        var elementValue = document.getElementById("vI_" + this.option).getAttribute("checked");
     216        this.value = (elementValue == "true")?"true":"false"
     217    }
     218}
     219
     220function vI_storageExtras_checkbox(field, option, composeDialogElementID, updateFunction, updateFunctionParam1) {
     221    this.field = field;
     222    this.option = option;
     223    this.composeDialogElementID = composeDialogElementID;
     224    this.updateFunction = updateFunction;
     225    this.updateFunctionParam1 = updateFunctionParam1;
     226}
     227vI_storageExtras_checkbox.prototype = {
     228    value : null,
     229    field : null,
     230    option : null,
     231    composeDialogElementID : null,
     232    updateFunction : null, // some elements have to be updated before the can be read
     233    updateFunctionParam1 : null,
     234   
     235    // function to set or read the value from/to the MessageCompose Dialog
     236    setValue : function() {
     237        if (!this.value) return;
     238        var element = document.getElementById(this.composeDialogElementID);
     239        var elementValue =  element.getAttribute("checked");
     240        if ((elementValue == "true") != (this.value == "true")) {
     241            vI_notificationBar.dump("## vI_storageExtras_checkbox setValue " + this.composeDialogElementID + "=" +
     242                this.value + " (was: " + elementValue + ").\n");
     243            if (this.value == "true") element.setAttribute("checked","true");
     244            else element.removeAttribute("checked");
     245            element.doCommand();
     246        }
     247    },
     248    readValue : function() {
     249        if (this.updateFunction) this.updateFunction(this.updateFunctionParam1);
     250        var elementValue =  document.getElementById(this.composeDialogElementID).getAttribute("checked");
     251        this.value = ((elementValue=="true")?"true":"false")
     252        vI_notificationBar.dump("## vI_storageExtras_checkbox readValue " + this.composeDialogElementID + "=" +
     253            this.value + "\n");
     254
     255    },
     256    // function to set or read the value from the rdfDataEditor
     257    setEditorValue : function() {
     258        document.getElementById("vI_" + this.option).setAttribute("checked", this.value) },
     259    readEditorValue : function() {
     260        var elementValue = document.getElementById("vI_" + this.option).getAttribute("checked");
     261        this.value = (elementValue == "true")?"true":"false"
     262    }
     263}
  • chrome/content/v_identity/vI_upgrade.xul

    re97c30 r9b501a  
    4545<script type="application/x-javascript" src="chrome://v_identity/content/vI_notificationBar.js"/>
    4646<script type="application/x-javascript" src="chrome://v_identity/content/vI_rdfDatasource.js" />   
     47<script type="application/x-javascript" src="chrome://v_identity/content/vI_storageExtras.js" />
    4748<script type="application/x-javascript" src="chrome://v_identity/content/vI_htmlTextBox.js" />
    4849
  • chrome/content/v_identity/vI_upgradeOverlay.xul

    re97c30 r9b501a  
    3636    <script type="application/x-javascript" src="chrome://v_identity/content/vI_account.js" />
    3737    <script type="application/x-javascript" src="chrome://v_identity/content/vI_rdfDatasource.js" />
     38    <script type="application/x-javascript" src="chrome://v_identity/content/vI_storageExtras.js" />
    3839    <!-- following element just stores the Ext-Version, seamonkey has no extensionmanager -->
    3940    <vbox id="messagepanebox" >
Note: See TracChangeset for help on using the changeset viewer.