⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 feeditem.js

📁 现在很火的邮件客户端软件thunderbird的源码
💻 JS
📖 第 1 页 / 共 2 页
字号:
      debug(this.identity + " not stored (folder didn't exist)");      return false;    }    var ds = getItemsDS(server);    var itemURI = this.itemUniqueURI;    var itemResource = rdf.GetResource(itemURI);    var downloaded = ds.GetTarget(itemResource, FZ_STORED, true);    // Backward compatibility: we might have stored this item before isStoredWithId    // has been turned on for RSS 2.0 (bug 354345). Check whether this item has been    // stored with its URL.    if (!downloaded && itemURI != this.mURL)    {      itemResource = rdf.GetResource(this.mURL);      downloaded = ds.GetTarget(itemResource, FZ_STORED, true);    }    if (!downloaded || downloaded.QueryInterface(Components.interfaces.nsIRDFLiteral).Value == "false")     {      // HACK ALERT: before we give up, try to work around an entity escaping bug in RDF      // See Bug #258465 for more details      itemURI = itemURI.replace(/&lt;/g, '<');      itemURI = itemURI.replace(/&gt;/g, '>');      itemURI = itemURI.replace(/&quot;/g, '"');      itemURI = itemURI.replace(/&amp;/g, '&');           debug('Failed to find item, trying entity replacement version: '  + itemURI);      itemResource = rdf.GetResource(itemURI);      downloaded = ds.GetTarget(itemResource, FZ_STORED, true);      if (downloaded)      {         debug(this.identity + " not stored");        return true;      }      debug(this.identity + " not stored");      return false;    }    else     {      debug(this.identity + " stored");      return true;    }  },  markValid: function()   {    debug("validating " + this.mURL);    var ds = getItemsDS(this.feed.server);    var itemURI = this.itemUniqueURI;    var resource = rdf.GetResource(itemURI);        // Backward compatibility: we might have stored this item before isStoredWithId    // has been turned on for RSS 2.0 (bug 354345). Check whether this item has been    // stored with its URL.    if (!ds.GetTarget(resource, FZ_STORED, true) && itemURI != this.mURL)      resource = rdf.GetResource(this.mURL);    if (!ds.HasAssertion(resource, FZ_FEED, rdf.GetResource(this.feed.url), true))      ds.Assert(resource, FZ_FEED, rdf.GetResource(this.feed.url), true);        if (ds.hasArcOut(resource, FZ_VALID))     {      var currentValue = ds.GetTarget(resource, FZ_VALID, true);      ds.Change(resource, FZ_VALID, currentValue, RDF_LITERAL_TRUE);    }    else       ds.Assert(resource, FZ_VALID, RDF_LITERAL_TRUE, true);  },  markStored: function()   {    var ds = getItemsDS(this.feed.server);    var itemURI = this.itemUniqueURI;    var resource = rdf.GetResource(itemURI);       if (!ds.HasAssertion(resource, FZ_FEED, rdf.GetResource(this.feed.url), true))      ds.Assert(resource, FZ_FEED, rdf.GetResource(this.feed.url), true);        var currentValue;    if (ds.hasArcOut(resource, FZ_STORED))     {      currentValue = ds.GetTarget(resource, FZ_STORED, true);      ds.Change(resource, FZ_STORED, currentValue, RDF_LITERAL_TRUE);    }    else       ds.Assert(resource, FZ_STORED, RDF_LITERAL_TRUE, true);  },  mimeEncodeSubject: function(aSubject, aCharset)  {      // get the mime header encoder service    var mimeEncoder = Components.classes["@mozilla.org/messenger/mimeconverter;1"].getService(Components.interfaces.nsIMimeConverter);    // this routine sometimes throws exceptions for mis-encoded data so wrap it     // with a try catch for now..    var newSubject;    try     {      newSubject = mimeEncoder.encodeMimePartIIStr(this.mUnicodeConverter.ConvertFromUnicode(aSubject), false, aCharset, 9, 72);    }    catch (ex)     {       newSubject = aSubject;     }    return newSubject;  },   writeToFolder: function()   {    debug(this.identity + " writing to message folder" + this.feed.name + "\n");      var server = this.feed.server;    this.mUnicodeConverter.charset = this.characterSet;    // If the sender isn't a valid email address, quote it so it looks nicer.    if (this.author && this.author.indexOf('@') == -1)      this.author = '<' + this.author + '>';    // Convert the title to UTF-16 before performing our HTML entity replacement    // reg expressions.    var title = this.title;     // the subject may contain HTML entities.    // Convert these to their unencoded state. i.e. &amp; becomes '&'    title = title.replace(/&lt;/g, '<');    title = title.replace(/&gt;/g, '>');    title = title.replace(/&quot;/g, '"');    title = title.replace(/&amp;/g, '&');      // Compress white space in the subject to make it look better.    title = title.replace(/[\t\r\n]+/g, " ");    this.title = this.mimeEncodeSubject(title, this.characterSet);    // If the date looks like it's in W3C-DTF format, convert it into    // an IETF standard date.  Otherwise assume it's in IETF format.    if (this.mDate.search(/^\d\d\d\d/) != -1)      this.mDate = W3CToIETFDate(this.mDate);    // Escape occurrences of "From " at the beginning of lines of content    // per the mbox standard, since "From " denotes a new message, and add    // a line break so we know the last line has one.    this.content = this.content.replace(/([\r\n]+)(>*From )/g, "$1>$2");    this.content += "\n";    // The opening line of the message, mandated by standards to start with    // "From ".  It's useful to construct this separately because we not only    // need to write it into the message, we also need to use it to calculate    // the offset of the X-Mozilla-Status lines from the front of the message    // for the statusOffset property of the DB header object.    var openingLine = 'From - ' + this.mDate + '\n';    var source =      openingLine +      'X-Mozilla-Status: 0000\n' +      'X-Mozilla-Status2: 00000000\n' +      'X-Mozilla-Keys:                                                                                \n' +      'Date: ' + this.mDate + '\n' +      'Message-Id: <' + this.messageID + '>\n' +      'From: ' + this.author + '\n' +      'MIME-Version: 1.0\n' +      'Subject: ' + this.title + '\n' +      'Content-Transfer-Encoding: 8bit\n' +      'Content-Base: ' + this.mURL + '\n';    if (this.enclosure && this.enclosure.mFileName)    {      var boundaryID = source.length + this.enclosure.mLength;      source += 'Content-Type: multipart/mixed;\n boundary="' + ENCLOSURE_HEADER_BOUNDARY_PREFIX + boundaryID + '"' + '\n\n' +                'This is a multi-part message in MIME format.\n' + ENCLOSURE_BOUNDARY_PREFIX + boundaryID + '\n' +                'Content-Type: text/html; charset=' + this.characterSet + '\n' +                'Content-Transfer-Encoding: 8bit\n' +                 this.content;      source += this.enclosure.convertToAttachment(boundaryID);    }    else    {      source += 'Content-Type: text/html; charset=' + this.characterSet + '\n' +                '\n' + this.content;                   }    debug(this.identity + " is " + source.length + " characters long");    // Get the folder and database storing the feed's messages and headers.    folder = this.feed.folder.QueryInterface(Components.interfaces.nsIMsgLocalMailFolder);    var msgFolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder);    msgFolder.gettingNewMessages = true;    // source is a unicode string, we want to save a char * string in the original charset. So convert back    folder.addMessage(this.mUnicodeConverter.ConvertFromUnicode(source));    msgFolder.gettingNewMessages = false;    this.markStored();  }};// A feed enclosure is to RSS what an attachment is for e-mail. We make enclosures look// like attachments in the UI.function FeedEnclosure(aURL, aContentType, aLength) {  this.mURL = aURL;  this.mContentType = aContentType;  this.mLength = aLength;  // generate a fileName from the URL  if (this.mURL)  {    var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);    var enclosureURL  = ioService.newURI(this.mURL, null, null).QueryInterface(Components.interfaces.nsIURL);    if (enclosureURL)      this.mFileName = enclosureURL.fileName;  }}FeedEnclosure.prototype = {  mURL: "",  mContentType: "",  mLength: 0,  mFileName: "",  // returns a string that looks like an e-mail attachment  // which represents the enclosure.  convertToAttachment: function(aBoundaryID)  {    return '\n' +                  ENCLOSURE_BOUNDARY_PREFIX + aBoundaryID + '\n' +                  'Content-Type: ' + this.mContentType + '; name="' + this.mFileName + '"\n' +                   'X-Mozilla-External-Attachment-URL: ' + this.mURL + '\n' +                  'Content-Disposition: attachment; filename="' + this.mFileName + '"\n\n' +                   'This MIME attachment is stored separately from the message.\n' +                  ENCLOSURE_BOUNDARY_PREFIX + aBoundaryID + '--' + '\n';  }};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -