chat/components/public/imILogger.idl
author Philipp Kewisch <mozilla@kewis.ch>
Sun, 14 Jan 2018 13:03:57 +0100
changeset 58730 07e9ccb0dc2714f6f387efec1ccddc83fd4a5fb4
parent 46925 b0e38b2324c339f3e765ab8f63acabf10cbaaa73
child 78827 a3a6442dde2fa53d263a561a8dc4845718f14318
permissions -rw-r--r--
Bug 1429452 - Add Persian language to Thunderbird nightly build. r=tomprince MozReview-Commit-ID: DD7O9R2yAl3

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"
#include "nsISimpleEnumerator.idl"
#include "nsIFile.idl"

interface imIAccount;
interface prplIAccountBuddy;
interface imIBuddy;
interface imIContact;
interface imIMessage;
interface prplIConversation;

[scriptable, uuid(7771402c-ff55-41f5-86b4-59b93f9b0693)]
interface imILogConversation: nsISupports {
  readonly attribute AUTF8String title;
  readonly attribute AUTF8String name;
  // Value in microseconds.
  readonly attribute PRTime startDate;

  // Simplified account implementation:
  //  - alias will always be empty
  //  - name (always the normalizedName)
  //  - statusInfo will return Services.core.globalUserStatus
  //  - protocol will only contain a "name" attribute, with the prpl's normalized name.
  // Other methods/attributes aren't implemented.
  readonly attribute imIAccount account;

  readonly attribute boolean isChat; // always false (compatibility with prplIConversation).
  readonly attribute prplIAccountBuddy buddy; // always null (compatibility with prplIConvIM).

  void getMessages([optional] out unsigned long messageCount,
                   [retval, array, size_is(messageCount)] out imIMessage messages);

  // Callers that process the messages asynchronously should use the enumerator
  // instead of the array version of the getMessages* methods to avoid paying
  // up front the cost of xpconnect wrapping all message objects.
  nsISimpleEnumerator getMessagesEnumerator([optional] out unsigned long messageCount);
};

[scriptable, uuid(27712ece-ad2c-4504-87d5-9e2c16d40fef)]
interface imILog: nsISupports {
  readonly attribute AUTF8String path;
  // Value in seconds.
  readonly attribute PRTime time;
  readonly attribute AUTF8String format;
  // Returns a promise that resolves to an imILogConversation instance, or null
  // if the log format isn't JSON.
  jsval getConversation();
};

[scriptable, function, uuid(2ab5f8ac-4b89-4954-9a4a-7c167f1e3b0d)]
interface imIProcessLogsCallback: nsISupports {
  // The callback can return a promise. If it does, then it will not be called
  // on the next log until this promise resolves. If it throws (or rejects),
  // iteration will stop.
  jsval processLog(in AUTF8String aLogPath);
};

[scriptable, uuid(7e2476dc-8199-4454-9661-b78ee73fa49e)]
interface imILogger: nsISupports {
  // Returns a promise that resolves to an imILog instance.
  jsval getLogFromFile(in AUTF8String aFilePath, [optional] in boolean aGroupByDay);
  // Returns a promise that resolves to the log file paths if a log writer
  // exists for the conversation, or null otherwise. The promise resolves
  // after any pending I/O operations on the files complete.
  jsval getLogPathsForConversation(in prplIConversation aConversation);

  // Below methods return promises that resolve to nsISimpleEnumerator instances.

  // Get logs for a username that may not be in the contact list.
  jsval getLogsForAccountAndName(in imIAccount aAccount,
                                 in AUTF8String aNormalizedName,
                                 [optional] in boolean aGroupByDay);

  jsval getLogsForAccountBuddy(in prplIAccountBuddy aAccountBuddy,
                               [optional] in boolean aGroupByDay);
  jsval getLogsForBuddy(in imIBuddy aBuddy,
                        [optional] in boolean aGroupByDay);
  jsval getLogsForContact(in imIContact aContact,
                          [optional] in boolean aGroupByDay);

  jsval getLogsForConversation(in prplIConversation aConversation,
                               [optional] in boolean aGroupByDay);
  jsval getSystemLogsForAccount(in imIAccount aAccount);
  jsval getSimilarLogs(in imILog aLog,
                       [optional] in boolean aGroupByDay);

  // Asynchronously iterates through log folders for all prpls and accounts and
  // invokes the callback on every log file. Returns a promise that resolves when
  // iteration is complete. If the callback returns a promise, iteration pauses
  // until the promise resolves. If the callback throws (or rejects), iteration
  // will stop and the returned promise will reject with the same error.
  jsval forEach(in imIProcessLogsCallback aCallback);

  // Returns the folder storing all logs for aAccount.
  AUTF8String getLogFolderPathForAccount(in imIAccount aAccount);

  // Removes the folder storing all logs for aAccount.
  // Be sure the account is disconnected before using this.
  jsval deleteLogFolderForAccount(in imIAccount aAccount);
};