summaryrefslogtreecommitdiffstats
path: root/comm/chat/components/public/imILogger.idl
blob: fd8e632d5d29994e24e27970cda2ac0671de32e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* 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 "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 IMServices.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).

  Array<imIMessage> getMessages();
};

[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 {imILog[]}.

  // Get logs for a contact.
  jsval getLogsForContact(in imIContact aContact);
  // Get logs for a conversation.
  jsval getLogsForConversation(in prplIConversation aConversation);
  // Get logs that are from the same conversation.
  jsval getSimilarLogs(in imILog aLog);

  // 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);
};