Changeset bcf746


Ignore:
Timestamp:
Nov 18, 2011, 1:31:56 PM (8 years ago)
Author:
rene <rene@…>
Branches:
ng_0.9
Children:
dd1cbc
Parents:
a95a40
Message:

added new prefs module, not finished

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • content/bindings/vI_debugBox.xml

    ra95a40 rbcf746  
    1414      <constructor><![CDATA[
    1515        this.splitter = document.createElement("splitter");
    16         let prefroot = Components.classes["@mozilla.org/preferences-service;1"]
    17           .getService(Components.interfaces.nsIPrefService)
    18           .getBranch(null).QueryInterface(Components.interfaces.nsIPrefBranch2);
    19         prefroot.addObserver("extensions.virtualIdentity.debug_notification", this, false);
    20         this.observe();
     16        virtualIdentityExtension.vIprefs.addObserver("debug_notification", this.observe, this);
     17        this.observe(this);
    2118      ]]></constructor>
    2219      <destructor><![CDATA[
    23         let prefroot = Components.classes["@mozilla.org/preferences-service;1"]
    24           .getService(Components.interfaces.nsIPrefService)
    25           .getBranch(null).QueryInterface(Components.interfaces.nsIPrefBranch2);
    26         prefroot.removeObserver("extensions.virtualIdentity.debug_notification", this);
     20        virtualIdentityExtension.vIprefs.removeObserver("debug_notification", this.observe);
    2721      ]]></destructor>
    2822      <field name="_content">document.getAnonymousElementByAttribute(this, "anonid", "vI_debugBoxContent")</field>
    2923      <property name="splitter" />
    3024      <method name="observe">
     25        <parameter name="self" />
    3126        <body><![CDATA[
    32           this.clear();
    33           let showDebugArea = Components.classes["@mozilla.org/preferences-service;1"]
    34             .getService(Components.interfaces.nsIPrefService)
    35             .getBranch("extensions.virtualIdentity.")
    36             .getBoolPref("debug_notification");
    37           if (showDebugArea) {
    38             this.removeAttribute("hidden");
    39             this.parentNode.insertBefore(this.splitter, this);
     27          self.clear();
     28          if (virtualIdentityExtension.vIprefs.get("debug_notification")) {
     29            self.removeAttribute("hidden");
     30            self.parentNode.insertBefore(self.splitter, self);
    4031          }
    4132          else {
    42             this.setAttribute("hidden", "true");
     33            self.setAttribute("hidden", "true");
    4334            try {
    44               this.parentNode.removeChild(this.splitter);
     35              self.parentNode.removeChild(self.splitter);
    4536            } catch (e) { };
    4637          }
  • content/vI_getHeader.js

    ra95a40 rbcf746  
    145145   
    146146    init : function() {
    147       let self = this;
    148       vI.vIprefs.addObserver("smart_reply_headers", self.observe);
     147      vI.vIprefs.addObserver("smart_reply_headers", this.observe, this);
    149148    },
    150149   
     
    154153    },
    155154   
    156     observe: function(subject, topic, data) {
     155    observe: function(self, subject, topic, data) {
    157156        if (topic == "nsPref:changed") {
    158157            // remove (old) prepared headerArray
    159158            getHeader.headerToSearch = null;
    160            
    161             Log.debug("reload Message\n");
    162             MsgReload();
     159            ReloadMessage();
    163160        }
    164161    },
  • content/vI_statusmenu.js

    ra95a40 rbcf746  
    3939    objStatusText : null,
    4040   
    41     observe: function(subject, topic, data) {
     41    observe: function(self, subject, topic, data) {
    4242        switch (data) {
    4343            case "fcc_show_switch":
     
    8989   
    9090    addObserver: function() {
    91         vI.vIprefs.addObserver("fcc_show_switch", statusmenu, false);
    92         vI.vIprefs.addObserver("doFcc", statusmenu, false);
    93         vI.vIprefs.addObserver("storage", statusmenu, false);
    94         vI.vIprefs.addObserver("storage_show_switch", statusmenu, false);
    95         vI.vIprefs.addObserver("storage_show_baseID_switch", statusmenu, false);
    96         vI.vIprefs.addObserver("storage_show_SMTP_switch", statusmenu, false);
    97         vI.vIprefs.addObserver("storage_colorIndication", statusmenu, false);
    98         vI.vIprefs.addObserver("storage_storedefault", statusmenu, false);
    99         vI.vIprefs.addObserver("storage_store_base_id", statusmenu, false);
    100         vI.vIprefs.addObserver("storage_store_SMTP", statusmenu, false);
     91        vI.vIprefs.addObserver("fcc_show_switch", this.observe, this);
     92        vI.vIprefs.addObserver("doFcc", this.observe, this);
     93        vI.vIprefs.addObserver("storage", this.observe, this);
     94        vI.vIprefs.addObserver("storage_show_switch", this.observe, this);
     95        vI.vIprefs.addObserver("storage_show_baseID_switch", this.observe, this);
     96        vI.vIprefs.addObserver("storage_show_SMTP_switch", this.observe, this);
     97        vI.vIprefs.addObserver("storage_colorIndication", this.observe, this);
     98        vI.vIprefs.addObserver("storage_storedefault", this.observe, this);
     99        vI.vIprefs.addObserver("storage_store_base_id", this.observe, this);
     100        vI.vIprefs.addObserver("storage_store_SMTP", this.observe, this);
    101101    },
    102102   
    103103    removeObserver: function() {
    104         vI.vIprefs.removeObserver("fcc_show_switch", statusmenu);
    105         vI.vIprefs.removeObserver("doFcc", statusmenu);
    106         vI.vIprefs.removeObserver("storage", statusmenu);
    107         vI.vIprefs.removeObserver("storage_show_switch", statusmenu);
    108         vI.vIprefs.removeObserver("storage_show_baseID_switch", statusmenu);
    109         vI.vIprefs.removeObserver("storage_show_SMTP_switch", statusmenu);
    110         vI.vIprefs.removeObserver("storage_colorIndication", statusmenu);
    111         vI.vIprefs.removeObserver("storage_storedefault", statusmenu);
    112         vI.vIprefs.removeObserver("storage_store_base_id", statusmenu);
    113         vI.vIprefs.removeObserver("storage_store_SMTP", statusmenu);
     104        vI.vIprefs.removeObserver("fcc_show_switch", this.observe);
     105        vI.vIprefs.removeObserver("doFcc", this.observe);
     106        vI.vIprefs.removeObserver("storage", this.observe);
     107        vI.vIprefs.removeObserver("storage_show_switch", this.observe);
     108        vI.vIprefs.removeObserver("storage_show_baseID_switch", this.observe);
     109        vI.vIprefs.removeObserver("storage_show_SMTP_switch", this.observe);
     110        vI.vIprefs.removeObserver("storage_colorIndication", this.observe);
     111        vI.vIprefs.removeObserver("storage_storedefault", this.observe);
     112        vI.vIprefs.removeObserver("storage_store_base_id", this.observe);
     113        vI.vIprefs.removeObserver("storage_store_SMTP", this.observe);
    114114    },
    115115   
     
    129129
    130130        statusmenu.addObserver();
    131         statusmenu.observe(null, null, "fcc_show_switch");
    132         statusmenu.observe(null, null, "storage_show_switch");
    133         statusmenu.observe(null, null, "storage_show_baseID_switch");
    134         statusmenu.observe(null, null, "storage_show_SMTP_switch");
    135         statusmenu.observe(null, null, "storage_colorIndication");
    136         statusmenu.observe(null, null, "storage_store_base_id");
    137         statusmenu.observe(null, null, "storage_store_SMTP");
    138         statusmenu.observe(null, null, "storage_storedefault");
    139         statusmenu.observe(null, null, "storage");
     131        statusmenu.observe(this, null, null, "fcc_show_switch");
     132        statusmenu.observe(this, null, null, "storage_show_switch");
     133        statusmenu.observe(this, null, null, "storage_show_baseID_switch");
     134        statusmenu.observe(this, null, null, "storage_show_SMTP_switch");
     135        statusmenu.observe(this, null, null, "storage_colorIndication");
     136        statusmenu.observe(this, null, null, "storage_store_base_id");
     137        statusmenu.observe(this, null, null, "storage_store_SMTP");
     138        statusmenu.observe(this, null, null, "storage_storedefault");
     139        statusmenu.observe(this, null, null, "storage");
    140140    },
    141141   
  • modules/vI_account.js

    ra95a40 rbcf746  
    2727  "vIaccount_createAccount", "vIaccount_removeUsedVIAccount" ]
    2828
    29 Components.utils.import("resource://gre/modules/Services.jsm");
    30 Components.utils.import("resource://v_identity/vI_log.js");
    31 Components.utils.import("resource://v_identity/vI_identityData.js");
    32 Components.utils.import("resource://v_identity/vI_rdfDatasource.js");
     29const {classes: Cc, interfaces: Ci, utils: Cu, results : Cr} = Components;
     30
     31Cu.import("resource://gre/modules/Services.jsm");
     32Cu.import("resource://v_identity/vI_log.js");
     33Cu.import("resource://v_identity/vI_identityData.js");
     34Cu.import("resource://v_identity/vI_rdfDatasource.js");
     35Cu.import("resource://v_identity/vI_prefs.js");
    3336
    3437let Log = setupLogging("virtualIdentity.account");
     
    3740    var stringBundle = Services.strings.createBundle("chrome://v_identity/locale/v_identity.properties");
    3841   
    39     var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
    40         .getService(Components.interfaces.nsIPromptService);
    41    
    42     var prefs = Components.classes["@mozilla.org/preferences-service;1"]
    43             .getService(Components.interfaces.nsIPrefService)
    44             .getBranch("extensions.virtualIdentity.");
    45    
    46     var AccountManager = Components.classes["@mozilla.org/messenger/account-manager;1"]
    47             .getService(Components.interfaces.nsIMsgAccountManager);
     42    var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"]
     43        .getService(Ci.nsIPromptService);
     44   
     45    var AccountManager = Cc["@mozilla.org/messenger/account-manager;1"]
     46            .getService(Ci.nsIMsgAccountManager);
    4847           
    49     Log.debug("\nprepareSendMsg " + msgType + " " + Components.interfaces.nsIMsgCompDeliverMode.Now + "\n");
     48    Log.debug("\nprepareSendMsg " + msgType + " " + Ci.nsIMsgCompDeliverMode.Now + "\n");
    5049   
    5150    returnValue = {};
    5251   
    53     if (msgType == Components.interfaces.nsIMsgCompDeliverMode.Now) {
    54         if ( (vid && prefs.getBoolPref("warn_virtual") &&
     52    if (msgType == Ci.nsIMsgCompDeliverMode.Now) {
     53        if ( (vid && vIprefs.get("warn_virtual") &&
    5554            !(promptService.confirm(window,"Warning",
    5655                stringBundle.GetStringFromName("vident.sendVirtual.warning")))) ||
    57             (!vid && prefs.getBoolPref("warn_nonvirtual") &&
     56            (!vid && vIprefs.get("warn_nonvirtual") &&
    5857            !(promptService.confirm(window,"Warning",
    5958                stringBundle.GetStringFromName("vident.sendNonvirtual.warning")))) ) {
    6059            return { update : "abort", storedIdentity : null }; // completely abort sending
    6160        }
    62 //      if (prefs.getBoolPref("storage") &&
     61//      if (vIprefs.get("storage") &&
    6362//              (!vI.statusmenu || vI.statusmenu.objStorageSaveMenuItem.getAttribute("checked") == "true")) {
    64         if (prefs.getBoolPref("storage")) {
     63        if (vIprefs.get("storage")) {
    6564            var localeDatasourceAccess = new rdfDatasourceAccess();
    6665            var returnValue = localeDatasourceAccess.storeVIdentityToAllRecipients(identityData, recipients)
     
    108107    _baseIdentity : null,
    109108
    110     _AccountManager : Components.classes["@mozilla.org/messenger/account-manager;1"]
    111         .getService(Components.interfaces.nsIMsgAccountManager),
    112    
    113     _prefroot : Components.classes["@mozilla.org/preferences-service;1"]
    114         .getService(Components.interfaces.nsIPrefService)
    115         .getBranch(null),
    116 
    117     _pref : Components.classes["@mozilla.org/preferences-service;1"]
    118         .getService(Components.interfaces.nsIPrefService)
    119         .getBranch("extensions.virtualIdentity."),
    120    
    121     _unicodeConverter : Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
    122             .createInstance(Components.interfaces.nsIScriptableUnicodeConverter),
     109    _AccountManager : Cc["@mozilla.org/messenger/account-manager;1"]
     110        .getService(Ci.nsIMsgAccountManager),
     111   
     112    _unicodeConverter : Cc["@mozilla.org/intl/scriptableunicodeconverter"]
     113            .createInstance(Ci.nsIScriptableUnicodeConverter),
    123114   
    124115    _copyBoolAttribute : function(name) {
     
    143134
    144135    _copyPreferences : function() {
    145         if (account._pref.getBoolPref("copySMIMESettings")) {
     136        if (vIprefs.get("copySMIMESettings")) {
    146137            // SMIME settings
    147138            Log.debug("copy S/MIME settings\n")
     
    151142        }
    152143/*      seems not required, encryption happens before Virtual Identity account is created
    153         if (account._pref.getBoolPref("copyEnigmailSettings")) {
     144        if (vIprefs.get("copyEnigmailSettings")) {
    154145            // pgp/enigmail settings
    155146            Log.debug("copy PGP settings\n")
     
    164155            account._copyIntAttribute("defaultEncryptionPolicy");
    165156        }   */
    166         if (account._pref.getBoolPref("copyAttachVCardSettings")) {
     157        if (vIprefs.get("copyAttachVCardSettings")) {
    167158            // attach vcard
    168159            Log.debug("copy VCard settings\n")
     
    178169        while (dirEnumerator.hasMoreElements()) {
    179170            var maildir = dirEnumerator.getNext();
    180             maildir.QueryInterface(Components.interfaces.nsIFile);
     171            maildir.QueryInterface(Ci.nsIFile);
    181172            // recurse into all subdirectories
    182173            if (maildir.isDirectory() &&
     
    192183        Log.debug("checking for leftover VirtualIdentity directories ")
    193184
    194         var file = Components.classes["@mozilla.org/file/directory_service;1"]
    195         .getService(Components.interfaces.nsIProperties)
    196             .get("ProfD", Components.interfaces.nsIFile);
     185        var file = Cc["@mozilla.org/file/directory_service;1"]
     186        .getService(Ci.nsIProperties)
     187            .get("ProfD", Ci.nsIFile);
    197188       
    198189        var fileEnumerator = file.directoryEntries
    199190        while (fileEnumerator.hasMoreElements()) {
    200191            var dir = fileEnumerator.getNext()
    201             dir.QueryInterface(Components.interfaces.nsIFile);
     192            dir.QueryInterface(Ci.nsIFile);
    202193            if (dir.path.match(new RegExp("[/\\\\]Mail$","i"))) { // match Windows and Linux/Mac separators
    203194                var dirEnumerator = dir.directoryEntries
    204195                while (dirEnumerator.hasMoreElements()) {
    205196                    var maildir = dirEnumerator.getNext()
    206                     maildir.QueryInterface(Components.interfaces.nsIFile);
     197                    maildir.QueryInterface(Ci.nsIFile);
    207198                    // match Windows and Linux/Mac separators
    208199                    if (maildir.path.match(new RegExp("[/\\\\]virtualIdentity.*$","i"))) {
     
    224215        Log.debug("checking for leftover VirtualIdentity accounts ")
    225216        for (var i=0; i < account._AccountManager.accounts.Count(); i++) {
    226             var checkAccount = account._AccountManager.accounts.QueryElementAt(i, Components.interfaces.nsIMsgAccount);
     217            var checkAccount = account._AccountManager.accounts.QueryElementAt(i, Ci.nsIMsgAccount);
    227218            if (account.__isVIdentityAccount(checkAccount)) {
    228219                Log.debug(".")
     
    236227    __isVIdentityAccount : function(checkAccount) {
    237228        // check for new (post0.5.0) accounts,
    238         try {   account._prefroot.getBoolPref("mail.account." + checkAccount.key + ".vIdentity");
     229        try {   prefroot.getBoolPref("mail.account." + checkAccount.key + ".vIdentity");
    239230            return true;
    240231        } catch (e) { };
     
    265256        account._AccountManager.removeAccount(checkAccount);
    266257        // remove the additional tagging-pref
    267         try { account._prefroot.clearUserPref("mail.account." + key + ".vIdentity");    }
     258        try { prefroot.clearUserPref("mail.account." + key + ".vIdentity"); }
    268259        catch (e) { };
    269260    },
    270261   
    271262    removeUsedVIAccount : function() {
    272         var mailWindow = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService()
    273             .QueryInterface(Components.interfaces.nsIWindowMediator)
     263        var mailWindow = Cc["@mozilla.org/appshell/window-mediator;1"].getService()
     264            .QueryInterface(Ci.nsIWindowMediator)
    274265            .getMostRecentWindow("mail:3pane");
    275266        if (mailWindow) {               // it's not sure that we have an open 3-pane-window
     
    304295       
    305296        account._account = account._AccountManager.createAccount();
    306         account._prefroot.setBoolPref("mail.account." + account._account.key + ".vIdentity", true)
     297        prefroot.setBoolPref("mail.account." + account._account.key + ".vIdentity", true)
    307298        account._account.addIdentity(account._AccountManager.createIdentity());
    308299        // the new account uses the same incomingServer than the base one,
     
    311302        // the incomingServer has to be replaced before the account is removed, else it get removed ether
    312303        var servers = account._AccountManager.GetServersForIdentity(baseIdentity);
    313         var server = servers.QueryElementAt(0, Components.interfaces.nsIMsgIncomingServer);
     304        var server = servers.QueryElementAt(0, Ci.nsIMsgIncomingServer);
    314305        // we mark the server as invalid so that the account manager won't
    315306        // tell RDF about the new server - we don't need this server for long
     
    347338        try { doFcc = document.getElementById("fcc_switch").getAttribute("checked") } catch(e) { }
    348339        if (doFcc) {
    349             switch (account._pref.getCharPref("fccFolderPickerMode"))
     340            switch (vIprefs.get("fccFolderPickerMode"))
    350341            {
    351342                case "2"  :
     
    366357                Log.debug ("preparing Fcc --- use Virtual Identity Settings\n");
    367358                account._account.defaultIdentity.doFcc
    368                     = account._pref.getBoolPref("doFcc");
     359                    = vIprefs.get("doFcc");
    369360                account._account.defaultIdentity.fccFolder
    370                     = account._unicodeConverter.ConvertToUnicode(account._pref.getCharPref("fccFolder"));
     361                    = account._unicodeConverter.ConvertToUnicode(vIprefs.get("fccFolder"));
    371362                account._account.defaultIdentity.fccFolderPickerMode
    372                     = account._pref.getCharPref("fccFolderPickerMode");
    373                 account._account.defaultIdentity.fccReplyFollowsParent = account._pref.getBoolPref("fccReplyFollowsParent");
     363                    = vIprefs.get("fccFolderPickerMode");
     364                account._account.defaultIdentity.fccReplyFollowsParent = vIprefs.get("fccReplyFollowsParent");
    374365
    375366                break;
     
    383374            account._account.defaultIdentity.fccFolder + " fccFolderPickerMode " +
    384375            account._account.defaultIdentity.fccFolderPickerMode + "(" +
    385             account._pref.getCharPref("fccFolderPickerMode") + "))\n");
     376            vIprefs.get("fccFolderPickerMode") + "))\n");
    386377    },
    387378   
    388379    _setupDraft : function()    {
    389         switch (account._pref.getCharPref("draftFolderPickerMode"))
     380        switch (vIprefs.get("draftFolderPickerMode"))
    390381        {
    391382            case "2"  :
     
    402393            Log.debug ("preparing Draft --- use Virtual Identity Settings\n");
    403394            account._account.defaultIdentity.draftFolder
    404                 = account._unicodeConverter.ConvertToUnicode(account._pref.getCharPref("draftFolder"));
     395                = account._unicodeConverter.ConvertToUnicode(vIprefs.get("draftFolder"));
    405396            account._account.defaultIdentity.draftsFolderPickerMode
    406                 = account._pref.getCharPref("draftFolderPickerMode");
     397                = vIprefs.get("draftFolderPickerMode");
    407398            break;
    408399        }
     
    410401            account._account.defaultIdentity.draftFolder + " draftsFolderPickerMode " +
    411402            account._account.defaultIdentity.draftsFolderPickerMode + "(" +
    412             account._pref.getCharPref("draftFolderPickerMode") + "))\n");
     403            vIprefs.get("draftFolderPickerMode") + "))\n");
    413404    },
    414405   
    415406    _setupTemplates : function()    {
    416         switch (account._pref.getCharPref("stationeryFolderPickerMode"))
     407        switch (vIprefs.get("stationeryFolderPickerMode"))
    417408        {
    418409            case "2"  :
     
    429420            Log.debug ("preparing Templates --- use Virtual Identity Settings\n");
    430421            account._account.defaultIdentity.stationeryFolder
    431                 = account._unicodeConverter.ConvertToUnicode(account._pref.getCharPref("stationeryFolder"));
     422                = account._unicodeConverter.ConvertToUnicode(vIprefs.get("stationeryFolder"));
    432423            account._account.defaultIdentity.tmplFolderPickerMode
    433                 = account._pref.getCharPref("stationeryFolderPickerMode");
     424                = vIprefs.get("stationeryFolderPickerMode");
    434425            break;
    435426        }
     
    437428            account._account.defaultIdentity.stationeryFolder + " tmplFolderPickerMode " +
    438429            account._account.defaultIdentity.tmplFolderPickerMode + "(" +
    439             account._pref.getCharPref("stationeryFolderPickerMode") + "))\n");
     430            vIprefs.get("stationeryFolderPickerMode") + "))\n");
    440431    }
    441432}
  • modules/vI_prefs.js

    ra95a40 rbcf746  
    103103      Log.error(Colors.red, "XXXX not yet implemented clearUserPref!\n", Colors.default);
    104104    },
    105     addObserver: function(aPrefName, aFunction) {
    106       this._localObservers.push({ pref: aPrefName, observe: aFunction });
     105    addObserver: function(aPrefName, aFunction, aSelf) {
     106      this._localObservers.push({ pref: aPrefName, observe: aFunction, context: aSelf });
    107107    },
    108108    removeObserver: function(aPrefName, aFunction) {
     
    118118      this._retrievePref(aPrefName);
    119119      for each (let [, prefObserver] in Iterator(this._localObservers)) {
    120         if (prefObserver.pref == aPrefName)
    121           prefObserver.observe(subject, topic, aPrefName);
     120        if (prefObserver.pref == aPrefName) {
     121          Log.debug("found observer, calling : " + prefObserver.observe + "\n")
     122          prefObserver.observe(prefObserver.context, subject, topic, aPrefName);
     123          Log.debug("found observer, calling : " + prefObserver.observe + " done\n")
     124        }
    122125      }
    123126    }
Note: See TracChangeset for help on using the changeset viewer.