Bug 740499 - IM conversations aren't indexed in gloda on the fly, r=asuth, clokep.
authorFlorian Quèze <florian@queze.net>
Sat, 14 Jul 2012 15:39:04 +0200
changeset 22360 03219882360fa5329df23f67e768aab10076b1f6
parent 22359 dcafe050d0c579710b8f2547cba9705568e9b607
child 22361 71f2f9886b5ca4bdf9d1a1da7b2e2d893722582f
push id1225
push userflorian@queze.net
push dateSat, 11 Jan 2014 23:24:55 +0000
treeherdertry-comm-central@1d7aa08cb2d7 [default view] [failures only]
reviewersasuth, clokep
bugs740499
Bug 740499 - IM conversations aren't indexed in gloda on the fly, r=asuth, clokep.
chat/components/public/imILogger.idl
chat/components/src/logger.js
--- a/chat/components/public/imILogger.idl
+++ b/chat/components/public/imILogger.idl
@@ -40,15 +40,16 @@ interface imILog: nsISupports {
   readonly attribute AUTF8String format;
   // Will return null if the log format isn't json.
   imILogConversation getConversation();
 };
 
 [scriptable, uuid(ab38c01c-2245-4279-9437-1d6bcc69d556)]
 interface imILogger: nsISupports {
   imILog getLogFromFile(in nsIFile aFile);
+  nsIFile getLogFileForOngoingConversation(in prplIConversation aConversation);
   nsISimpleEnumerator getLogsForAccountBuddy(in imIAccountBuddy aAccountBuddy);
   nsISimpleEnumerator getLogsForBuddy(in imIBuddy aBuddy);
   nsISimpleEnumerator getLogsForContact(in imIContact aContact);
   nsISimpleEnumerator getLogsForConversation(in prplIConversation aConversation);
   nsISimpleEnumerator getSystemLogsForAccount(in imIAccount aAccount);
   nsISimpleEnumerator getSimilarLogs(in imILog aLog);
 };
--- a/chat/components/src/logger.js
+++ b/chat/components/src/logger.js
@@ -64,28 +64,30 @@ function getNewLogFileName(aFormat)
 
 /* Conversation logs stuff */
 function ConversationLog(aConversation)
 {
   this._conv = aConversation;
 }
 ConversationLog.prototype = {
   _log: null,
+  file: null,
   format: "txt",
   _init: function cl_init() {
     let file = getLogFolderForAccount(this._conv.account, true);
     let name = this._conv.normalizedName;
     if (this._conv.isChat && this._conv.account.protocol.id != "prpl-twitter")
       name += ".chat";
     file.append(name);
     if (!file.exists())
       file.create(Ci.nsIFile.DIRECTORY_TYPE, 0777);
     if (Services.prefs.getCharPref("purple.logging.format") == "json")
       this.format = "json";
     file.append(getNewLogFileName(this.format));
+    this.file = file;
     let os = Cc["@mozilla.org/network/file-output-stream;1"].
              createInstance(Ci.nsIFileOutputStream);
     const PR_WRITE_ONLY   = 0x02;
     const PR_CREATE_FILE  = 0x08;
     const PR_APPEND       = 0x10;
     os.init(file, PR_WRITE_ONLY | PR_CREATE_FILE | PR_APPEND, 0666, 0);
     // just to be really sure everything is in UTF8
     let converter = Cc["@mozilla.org/intl/converter-output-stream;1"].
@@ -171,21 +173,23 @@ ConversationLog.prototype = {
     }
     this._log.writeString(line + kLineBreak);
   },
 
   close: function cl_close() {
     if (this._log) {
       this._log.close();
       this._log = null;
+      this.file = null;
     }
   }
 };
 
 const dummyConversationLog = {
+  file: null,
   logMessage: function() {},
   close: function() {}
 };
 
 var gConversationLogs = { };
 function getLogForConversation(aConversation)
 {
   let id = aConversation.id;
@@ -387,16 +391,18 @@ Logger.prototype = {
     let file = getLogFolderForAccount(aAccount);
     file.append(aNormalizedName);
     if (!file.exists())
       return EmptyEnumerator;
 
     return new LogEnumerator([file.directoryEntries]);
   },
   getLogFromFile: function logger_getLogFromFile(aFile) new Log(aFile),
+  getLogFileForOngoingConversation: function logger_getLogFileForOngoingConversation(aConversation)
+    getLogForConversation(aConversation).file,
   getLogsForContact: function logger_getLogsForContact(aContact) {
     let entries = [];
     aContact.getBuddies().forEach(function (aBuddy) {
       aBuddy.getAccountBuddies().forEach(function (aAccountBuddy) {
         let file = getLogFolderForAccount(aAccountBuddy.account);
         file.append(aAccountBuddy.normalizedName);
         if (file.exists())
           entries.push(file.directoryEntries);