Add a getSimilarLogs method to imILogger to enumerate all the logs in the same folder.
authorFlorian Quèze <florian@instantbird.org>
Mon, 12 Mar 2012 12:10:16 +0100
changeset 22186 f7caa93f74ca4d95412800222deecaceb9a2e048
parent 22185 8fa2710152f256e0a647446dd0e7dbce0d26ed40
child 22187 ed7b791a16c0c70bfa4b465826c2fdcd7ae4cfad
push id1225
push userflorian@queze.net
push dateSat, 11 Jan 2014 23:24:55 +0000
treeherdertry-comm-central@1d7aa08cb2d7 [default view] [failures only]
Add a getSimilarLogs method to imILogger to enumerate all the logs in the same folder.
chat/components/public/imILogger.idl
chat/components/src/logger.js
--- a/chat/components/public/imILogger.idl
+++ b/chat/components/public/imILogger.idl
@@ -78,9 +78,10 @@ interface imILog: nsISupports {
 [scriptable, uuid(ab38c01c-2245-4279-9437-1d6bcc69d556)]
 interface imILogger: nsISupports {
   imILog getLogFromFile(in nsIFile aFile);
   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
@@ -49,16 +49,19 @@ XPCOMUtils.defineLazyGetter(this, "logDi
 });
 
 const FileInputStream = CC("@mozilla.org/network/file-input-stream;1",
                            "nsIFileInputStream",
                            "init");
 const ConverterInputStream = CC("@mozilla.org/intl/converter-input-stream;1",
                                 "nsIConverterInputStream",
                                 "init");
+const LocalFile = CC("@mozilla.org/file/local;1",
+                     "nsILocalFile",
+                     "initWithPath");
 
 const kLineBreak = "@mozilla.org/windows-registry-key;1" in Cc ? "\r\n" : "\n";
 
 function getLogFolderForAccount(aAccount, aCreate)
 {
   let file = logDir.clone();
   function createIfNotExists(aFile) {
     if (aCreate && !aFile.exists())
@@ -450,16 +453,18 @@ Logger.prototype = {
     let name = aConversation.normalizedName;
     if (aConversation.isChat &&
         aConversation.account.protocol.id != "prpl-twitter")
       name += ".chat";
     return this._enumerateLogs(aConversation.account, name);
   },
   getSystemLogsForAccount: function logger_getSystemLogsForAccount(aAccount)
     this._enumerateLogs(aAccount, ".system"),
+  getSimilarLogs: function(aLog)
+    new LogEnumerator([new LocalFile(aLog.path).parent.directoryEntries]),
 
   observe: function logger_observe(aSubject, aTopic, aData) {
     switch (aTopic) {
     case "profile-after-change":
       Services.obs.addObserver(this, "final-ui-startup", false);
       break;
     case "final-ui-startup":
       Services.obs.removeObserver(this, "final-ui-startup");