This is just some static backup of the original site, don't expect every link to work!

Ignore:
Timestamp:
Sep 9, 2018, 2:36:02 AM (4 years ago)
Author:
rene <rene@…>
Branches:
ng_0.9
Children:
c5860f
Parents:
bc6c6b
Message:

removed everything related to smtp-storage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/vI_identityData.js

    rbc6c6b r85fa10  
    4444Components.utils.import("resource://v_identity/identityDataExtras/PGPMIME.js");
    4545
    46 function identityData(currentWindow, email, fullName, id, smtp, extras, sideDescription, existingID) {
     46ChromeUtils.import("resource:///modules/mailServices.js");
     47
     48function identityData(currentWindow, email, fullName, id, extras, sideDescription, existingID) {
    4749  this._currentWindow = currentWindow;
    4850  this._email = email ? email : "";
     
    5052  this._fullName = fullName ? fullName : "";
    5153  this.id = new idObj(id);
    52   this.smtp = new smtpObj(smtp);
    5354  if (extras) this.extras = extras;
    5455  else this.extras = new identityDataExtras(currentWindow);
     
    5859      fullName: {},
    5960      email: {},
    60       smtp: {},
    6161      id: {},
    6262      extras: {}
     
    7676  _currentWindow: null,
    7777  id: null,
    78   smtp: null,
    7978  extras: null,
    8079  sideDescription: null,
     
    139138    return this.__makeHtml(this.id.value);
    140139  },
    141   get smtpHtml() {
    142     return this.__makeHtml(this.smtp.value);
    143   },
    144140  get fullNameHtml() {
    145141    return this.__makeHtml(this.fullName);
     
    155151    return this.stringBundle.GetStringFromName("vident.identityData.baseID")
    156152  },
    157   get smtpLabel() {
    158     return this.stringBundle.GetStringFromName("vident.identityData.SMTP")
    159   },
    160153  get fullNameLabel() {
    161154    return this.stringBundle.GetStringFromName("vident.identityData.Name")
     
    167160  // creates an Duplicate of the current IdentityData, cause usually we are working with a pointer
    168161  getDuplicate: function () {
    169     return new identityData(this._currentWindow, this.email, this.fullName, this.id.key, this.smtp.key, this.extras ? this.extras.getDuplicate() : null,
     162    return new identityData(this._currentWindow, this.email, this.fullName, this.id.key, this.extras ? this.extras.getDuplicate() : null,
    170163      this.sideDescription, this.existingID);
    171164  },
     
    178171    if (identityData.id.key)
    179172      this.id.key = identityData.id.key;
    180     if (identityData.smtp.key)
    181       this.smtp.key = identityData.smtp.key;
    182173    if (identityData.sideDescription)
    183174      this.sideDescription = identityData.sideDescription;
     
    191182    this.fullName = identityData.fullName;
    192183    this.id.key = identityData.id.key;
    193     this.smtp.key = identityData.smtp.key;
    194184    this.sideDescription = identityData.sideDescription;
    195185    if (this.extras) this.extras.copy(identityData.extras);
     
    200190  isExistingIdentity: function (ignoreFullNameWhileComparing) {
    201191    Log.debug("isExistingIdentity: ignoreFullNameWhileComparing='" + ignoreFullNameWhileComparing + "'");
    202     //      Log.debug("base: fullName.toLowerCase()='" + this.fullName + "' email.toLowerCase()='" + this.email + "' smtp='" + this.smtp.key + "'");
     192    //      Log.debug("base: fullName.toLowerCase()='" + this.fullName + "' email.toLowerCase()='" + this.email + "'");
    203193
    204194    var ignoreFullNameMatchKey = null;
     
    213203      for (let i = 0; i < identities.length; i++) {
    214204        let identity = identities[i];
    215         //              Log.debug("comp: fullName.toLowerCase()='" + identity.fullName.toLowerCase() + "' email.toLowerCase()='" + identity.email.toLowerCase() + "' smtp='" + identity.smtpServerKey + "'");
     205        //              Log.debug("comp: fullName.toLowerCase()='" + identity.fullName.toLowerCase() + "' email.toLowerCase()='" + identity.email.toLowerCase() + "'");
    216206        var email = this.email ? this.email : ""; // might be null if no identity is set
    217207        var idEmail = identity.email ? identity.email : ""; // might be null if no identity is set
    218         if ((email.toLowerCase() == idEmail.toLowerCase()) &&
    219           this.smtp.equal(new smtpObj(identity.smtpServerKey))) {
     208        if (email.toLowerCase() == idEmail.toLowerCase()) {
    220209          // if fullName matches, than this is a final match
    221210          if (this.fullName.toLowerCase() == identity.fullName.toLowerCase()) {
     
    288277    }
    289278
    290     this.comp.equals.smtp = this.smtp.equal(compareIdentityData.smtp);
    291279    this.comp.equals.id = this.id.equal(compareIdentityData.id);
    292280    this.comp.equals.extras = this.extras ? this.extras.equal(compareIdentityData.extras) : true;
    293281
    294     return (this.comp.equals.fullName && this.comp.equals.email && this.comp.equals.smtp && this.comp.equals.id && this.comp.equals.extras);
     282    return (this.comp.equals.fullName && this.comp.equals.email && this.comp.equals.id && this.comp.equals.extras);
    295283  },
    296284
     
    307295
    308296  getCompareMatrix: function () {
    309     const Items = Array("fullName", "email", "smtp", "id");
     297    const Items = Array("fullName", "email", "id");
    310298    var string = "";
    311299    var saveBaseId = vIprefs.get("storage_store_base_id");
    312     var saveSMTP = vIprefs.get("storage_store_SMTP");
    313300    for (let item of Items) {
    314301      var classEqual = (this.comp.equals[item]) ? "equal" : "unequal";
    315       var classIgnore = (((!saveBaseId) && (item == "id")) || ((!saveSMTP) && (item == "smtp"))) ? " ignoreValues" : ""
     302      var classIgnore = ((!saveBaseId) && (item == "id")) ? " ignoreValues" : ""
    316303      string += "<tr>" +
    317304        "<td class='col1 " + classEqual + "'>" + this[item + "Label"] + "</td>" +
     
    325312
    326313  getMatrix: function () {
    327     const Items = Array("smtp", "id");
    328314    var string = "";
    329     for (var item of Items) if (this[item + "Html"])
    330         string += "<tr><td class='col1'>" + this[item + "Label"] + ":</td>" +
    331         "<td class='col2'>" + this[item + "Html"] + "</td></tr>"
     315    if (this["idHtml"])
     316        string = "<tr><td class='col1'>" + this["idLabel"] + ":</td>" +
     317        "<td class='col2'>" + this["idHtml"] + "</td></tr>"
    332318    string += this.extras ? this.extras.getMatrix() : "";
    333319    return string;
     
    363349      if (this.identityDataCollection[index].email == identityData.email &&
    364350        (!this.identityDataCollection[index].id.key || !identityData.id.key ||
    365           (this.identityDataCollection[index].id.key == identityData.id.key &&
    366             this.identityDataCollection[index].smtp.key == identityData.smtp.key))) {
     351          this.identityDataCollection[index].id.key == identityData.id.key)) {
    367352        // found, so check if we can use the Name of the new field
    368353        if (this.identityDataCollection[index].fullName == "" && identityData.fullName != "") {
     
    370355          Log.debug("added fullName '" + identityData.fullName + "' to stored email '" + this.identityDataCollection[index].email + "'")
    371356        }
    372         // check if id_key, smtp_key or extras can be used
     357        // check if id_key or extras can be used
    373358        // only try this once, for the first Identity where id is set)
    374359        if (!this.identityDataCollection[index].id.key && identityData.id.key) {
    375360          this.identityDataCollection[index].id.key = identityData.id.key;
    376           this.identityDataCollection[index].smtp.key = identityData.smtp.key;
    377361          this.identityDataCollection[index].extras = identityData.extras;
    378           Log.debug("added id '" + identityData.id.value + "' smtp '" + identityData.smtp.value + "' (+extras) to stored email '" + this.identityDataCollection[index].email + "'")
     362          Log.debug("added id '" + identityData.id.value + "' (+extras) to stored email '" + this.identityDataCollection[index].email + "'")
    379363        }
    380364        return;
     
    393377  }
    394378};
    395 
    396 function smtpObj(key) {
    397   this._key = key;
    398   this.DEFAULT_TAG = Components.classes["@mozilla.org/intl/stringbundle;1"]
    399     .getService(Components.interfaces.nsIStringBundleService)
    400     .createBundle("chrome://messenger/locale/messenger.properties").
    401   GetStringFromName("defaultServerTag");
    402 }
    403 smtpObj.prototype = {
    404   DEFAULT_TAG: null,
    405   _key: null,
    406   _value: null,
    407 
    408   set key(key) {
    409     this._key = key;
    410     this._value = null;
    411   },
    412   get key() {
    413     var dummy = this.value; // just to be sure key is adapted if SMTP is not available
    414     return this._key
    415   },
    416   get keyNice() { // the same as key but with "" for DEFAULT_SMTP_TAG
    417     if (this.key == DEFAULT_SMTP_TAG) return ""; // this is the key used for default server
    418     return this.key
    419   },
    420   get value() {
    421     if (this._value == null) {
    422       this._value = "";
    423       if (this._key == null || this._key == "") this._key = DEFAULT_SMTP_TAG;
    424       if (this._key == DEFAULT_SMTP_TAG) this._value = this.DEFAULT_TAG;
    425       else if (!this._key) this._value = null;
    426       else if (this._key) {
    427         var servers, smtpService = Components.classes["@mozilla.org/messengercompose/smtp;1"]
    428           .getService(Components.interfaces.nsISmtpService);
    429         // check for new https://hg.mozilla.org/comm-central/rev/fab9e5145cd4 smtpService
    430         if (typeof (smtpService.servers) == "object") servers = smtpService.servers;
    431         else servers = smtpService.smtpServers;
    432 
    433         while (servers && servers.hasMoreElements()) {
    434           var server = servers.getNext();
    435           if (server instanceof Components.interfaces.nsISmtpServer &&
    436             !server.redirectorType && this._key == server.key) {
    437             this._value = server.description ? server.description : server.hostname;
    438             break;
    439           }
    440         }
    441       }
    442     }
    443     if (!this._value) this._key = NO_SMTP_TAG; // if non-existant SMTP handle like non available
    444     return this._value;
    445   },
    446   equal: function (compareSmtpObj) {
    447     if (this.key == NO_SMTP_TAG || compareSmtpObj.key == NO_SMTP_TAG) return true;
    448     if (this.keyNice != compareSmtpObj.keyNice) {
    449       //       Log.debug("smtp not equal ('" + this.keyNice + "' != '" + compareSmtpObj.keyNice + "')");
    450     }
    451     return (this.keyNice == compareSmtpObj.keyNice);
    452   },
    453   hasNoDefinedSMTP: function () {
    454     return (this.key == NO_SMTP_TAG);
    455   }
    456 }
    457379
    458380function idObj(key) {
     
    502424    return this._value;
    503425  },
     426
     427  get smtpServerKey() {
     428    if (!this.key)
     429      return null;
     430    var AccountManager = Components.classes["@mozilla.org/messenger/account-manager;1"]
     431          .getService(Components.interfaces.nsIMsgAccountManager);
     432
     433    var identity = AccountManager.getIdentity(this.key);
     434    if (identity) {
     435      if (identity.smtpServerKey)
     436        return identity.smtpServerKey;
     437      else
     438        return MailServices.smtp.defaultServer.key
     439    }
     440    return null;
     441  },
     442 
     443  get smtpServerName() {
     444    if (!this.smtpServerKey)
     445      return null;
     446    var servers = MailServices.smtp.servers;
     447
     448    var smtpName;
     449    while (servers && servers.hasMoreElements()) {
     450      var server = servers.getNext();
     451      if (server instanceof Components.interfaces.nsISmtpServer &&
     452        !server.redirectorType && this.smtpServerKey == server.key) {
     453        smtpName = server.description ? server.description : server.hostname;
     454        break;
     455      }
     456    }
     457    return smtpName;
     458  },
     459 
    504460  equal: function (compareIdObj) {
    505461    if (!this.key || !compareIdObj.key) return true;
Note: See TracChangeset for help on using the changeset viewer.