adapt to case-changes for nsIMimeEmitter. Add some more debug to make it
authorAndrew Sutherland <asutherland@asutherland.org>
Fri, 17 Oct 2008 22:38:18 -0700
changeset 971 024bf69e79b64cbb992f1a2f9446c9171c8dc76c
parent 970 2c5e2d260836f0789d3f10bb6a297694086305b4
child 972 1936d4ec8044fd4cfdc636b43ec5e7488f86388c
child 976 7c775651aae3eae5df5106c3e8b09a9d311d7e6e
push idunknown
push userunknown
push dateunknown
adapt to case-changes for nsIMimeEmitter. Add some more debug to make it obvious that things are working.
components/jsmimeemitter.js
modules/indexer.js
--- a/components/jsmimeemitter.js
+++ b/components/jsmimeemitter.js
@@ -84,102 +84,101 @@ function MimeMessageEmitter() {
   this._curMsg = null;
   
   this._messageIndex = 0;
   this._allSubMessages = [];
 }
 
 MimeMessageEmitter.prototype = {
   classDescription: "JS Mime Message Emitter",
-  classID: Components.ID("{80578315-7021-40f9-9717-413cacf2fa7d}"),
-  contractID: "@mozilla.org/steeldestined/jsmimeemitter;1",
+  classID: Components.ID("{8cddbbbc-7ced-46b0-a936-8cddd1928c24}"),
+  contractID: "@mozilla.org/gloda/jsmimeemitter;1",
   
   _partRE: new RegExp("^[^?]+\?(?:[^&]+&)*part=([^&]+)(?:&[^&]+)*$"),
   
   _xpcom_categories: [{
     category: "mime-emitter",
     entry:
       "@mozilla.org/messenger/mimeemitter;1?type=application/x-js-mime-message",
   }],
   
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIMimeEmitter]),
 
-  Initialize: function mime_emitter_Initialize(aUrl, aChannel, aFormat) {
+  initialize: function mime_emitter_initialize(aUrl, aChannel, aFormat) {
     this._url = aUrl;
     this._curMsg = this._parentMsg = this._rootMsg = new this._mimeMsg.MimeMessage();
     
     this._mimeMsg.MsgHdrToMimeMessage.RESULT_RENDEVOUZ[aUrl.spec] =
       this._rootMsg;
     
     this._channel = aChannel;
   },
   
-  Complete: function mime_emitter_Complete() {
+  complete: function mime_emitter_complete() {
     // null out everything we can.  secretive cycles are eating us alive.
     this._url = null;
     this._channel = null;
     
     this._inputStream = null;
     this._outputStream = null;
     
     this._outputListener = null;
 
     this._curMsg = this._parentMsg = this._messageStack = this._rootMsg = null;
     this._messageIndex = null;
     this._allSubMessages = null;
   },
   
-  SetPipe: function mime_emitter_SetPipe(aInputStream, aOutputStream) {
+  setPipe: function mime_emitter_setPipe(aInputStream, aOutputStream) {
     this._inputStream = aInputStream;
     this._outputStream = aOutputStream;
   },
-  // can we use getters/setters to replace explicit functions on the interface?
-  SetOutputListener: function mime_emitter_SetOutputListener(aListener) {
+  set outputListener(aListener) {
     this._outputListener = aListener;
   },
-  GetOutputListener: function mime_emitter_GetOutputListener() {
+  get outputListener() {
     return this._outputListener;
   }, 
   
   // ----- Header Routines
-  StartHeader: function mime_emitter_StartHeader(aIsRootMailHeader,
+  startHeader: function mime_emitter_startHeader(aIsRootMailHeader,
       aIsHeaderOnly, aMsgID, aOutputCharset) {
     
     if (aIsRootMailHeader) {
-      this.UpdateCharacterSet(aOutputCharset);
+      this.updateCharacterSet(aOutputCharset);
       // nothing to do curMsg-wise, already initialized.
     }
     else {
       this._curMsg = new this._mimeMsg.MimeMessage();
       this._parentMsg.messages.push(this._curMsg);
       this._allSubMessages.push(this._curMsg);
     }
   },
-  AddHeaderField: function mime_emitter_AddHeaderField(aField, aValue) {
+  addHeaderField: function mime_emitter_addHeaderField(aField, aValue) {
     let lowerField = aField.toLowerCase();
     if (lowerField in this._curMsg.headers)
       this._curMsg.headers[lowerField].push(aValue);
     else
       this._curMsg.headers[lowerField] = [aValue];
   },
   addAllHeaders: function mime_emitter_addAllHeaders(aAllHeaders, aHeaderSize) {
     // This is called by the parsing code after the calls to AddHeaderField (or
     //  AddAttachmentField if the part is an attachment), and seems to serve
     //  a specialized, quasi-redundant purpose.  (nsMimeBaseEmitter creates a
     //  nsIMimeHeaders instance and hands it to the nsIMsgMailNewsUrl.)
     // nop
   },
-  WriteHTMLHeaders: function mime_emitter_WriteHTMLHeaders() {
+  writeHTMLHeaders: function mime_emitter_writeHTMLHeaders() {
     // It does't look like this should even be part of the interface; I think
     //  only the nsMimeHtmlDisplayEmitter::EndHeader call calls this signature.
     // nop
   },
-  EndHeader: function mime_emitter_EndHeader() {
+  endHeader: function mime_emitter_endHeader() {
   },
-  UpdateCharacterSet: function mime_emitter_UpdateCharacterSet(aCharset) {
+  updateCharacterSet: function mime_emitter_updateCharacterSet(aCharset) {
     // for non US-ASCII, ISO-8859-1, or UTF-8 charsets (case-insensitive),
     //  nsMimeBaseEmitter grabs the channel's content type, nukes the "charset="
     //  parameter if it exists, and tells the channel the updated content type
     //  and new character set.
     
     // Disabling for now; we get a NS_ERROR_NOT_IMPLEMENTED from the channel
     //  when we try and set the contentCharset... and I'm not totally up on the
     //  intent of why we were doing this in the first place.
@@ -241,17 +240,17 @@ MimeMessageEmitter.prototype = {
     }
   },
   
   // ----- Attachment Routines
   // The attachment processing happens after the initial streaming phase (during
   //  which time we receive the messages, both bodies and headers).  Our caller
   //  traverses the libmime child object hierarchy, emitting an attachment for
   //  each leaf object or sub-message.
-  StartAttachment: function mime_emitter_StartAttachment(aName, aContentType,
+  startAttachment: function mime_emitter_startAttachment(aName, aContentType,
       aUrl, aNotDownloaded) {
     
     // we need to strip our magic flags from the URL
     aURl = aUrl.replace("header=filter&emitter=js&", "");
     
     // the url should contain a part= piece that tells us the part name, which
     //  we then use to figure out where.
     let partMatch = this._partRE.exec(aUrl);
@@ -268,53 +267,53 @@ MimeMessageEmitter.prototype = {
       // create the attachment
       part = new this._mimeMsg.MimeMessageAttachment(partName,
           aName, aContentType, aUrl, aNotDownloaded);
     }
     
     this._putPart(part.partName.substring(2), "1",
                   part, this._rootMsg);
   },
-  AddAttachmentField: function mime_emitter_AddAttachmentField(aField, aValue) {
+  addAttachmentField: function mime_emitter_addAttachmentField(aField, aValue) {
     // this only gives us X-Mozilla-PartURL, which is the same as aUrl we
     //  already got previously, so need to do anything with this.
   },
-  EndAttachment: function mime_emitter_EndAttachment() {
+  endAttachment: function mime_emitter_endAttachment() {
     // don't need to do anything here, since we don't care about the headers.
   },
-  EndAllAttachments: function mime_emitter_EndAllAttachments() {
+  endAllAttachments: function mime_emitter_endAllAttachments() {
     // nop
   },
   
   // ----- Body Routines
-  StartBody: function mime_emitter_StartBody(aIsBodyOnly, aMsgID, aOutCharset) {
+  startBody: function mime_emitter_startBody(aIsBodyOnly, aMsgID, aOutCharset) {
     this._messageStack.push(this._curMsg);
     this._parentMsg = this._curMsg;
   },
   
-  WriteBody: function mime_emitter_WriteBody(aBuf, aSize, aOutAmountWritten) {
+  writeBody: function mime_emitter_writeBody(aBuf, aSize, aOutAmountWritten) {
     this._curMsg.body += aBuf;
   },
   
-  EndBody: function mime_emitter_EndBody() {
+  endBody: function mime_emitter_endBody() {
     this._messageStack.pop();
     this._parentMsg = this._messageStack[this._messageStack.length - 1];
   },
   
   // ----- Generic Write (confusing)
   // (binary data writing...)
-  Write: function mime_emitter_Write(aBuf, aSize, aOutAmountWritten) {
+  write: function mime_emitter_write(aBuf, aSize, aOutAmountWritten) {
     // we don't actually ever get called because we don't have the attachment
     //  binary payloads pass through us, but we do the following just in case
     //  we did get called (otherwise the caller gets mad and throws exceptions).
     aOutAmountWritten.value = aSize;
   },
   
   // (string writing)
-  UtilityWrite: function mime_emitter_UtilityWrite(aBuf) {
-    this.Write(aBuf, aBuf.length, {});
+  utilityWrite: function mime_emitter_utilityWrite(aBuf) {
+    this.write(aBuf, aBuf.length, {});
   },
 };
 
 var components = [MimeMessageEmitter];
 function NSGetModule(compMgr, fileSpec) {
   return XPCOMUtils.generateModule(components);
 }
--- a/modules/indexer.js
+++ b/modules/indexer.js
@@ -1855,16 +1855,20 @@ var GlodaIndexer = {
     this._log.debug("*** Indexing message: " + aMsgHdr.messageKey + " : " +
                     aMsgHdr.subject);
     MsgHdrToMimeMessage(aMsgHdr, this, this._indexMessageWithBody);
     return this.kWorkAsync;
   },
   
   _indexMessageWithBody: function gloda_index_indexMessageWithBody(
        aMsgHdr, aMimeMsg) {
+    if (aMimeMsg)
+      this._log.debug("  * Got Body! Length: " + aMimeMsg.body.length);
+    else
+      this._log.debug("  * Did not get body!");
 
     // -- Find/create the conversation the message belongs to.
     // Our invariant is that all messages that exist in the database belong to
     //  a conversation.
     
     // - See if any of the ancestors exist and have a conversationID...
     // (references are ordered from old [0] to new [n-1])
     let references = [aMsgHdr.getStringReference(i) for each