feat: Add more documentation
This commit is contained in:
parent
5bc1136ec0
commit
caf841c53e
@ -42,8 +42,14 @@ class OmemoManager {
|
|||||||
final Logger _log = Logger('OmemoManager');
|
final Logger _log = Logger('OmemoManager');
|
||||||
|
|
||||||
/// Functions for connecting with the OMEMO library
|
/// Functions for connecting with the OMEMO library
|
||||||
|
|
||||||
|
/// Send an empty OMEMO:2 message using the encrypted payload [result] to [recipientJid].
|
||||||
final Future<void> Function(EncryptionResult result, String recipientJid) sendEmptyOmemoMessage;
|
final Future<void> Function(EncryptionResult result, String recipientJid) sendEmptyOmemoMessage;
|
||||||
|
|
||||||
|
/// Fetch the list of device ids associated with [jid].
|
||||||
final Future<List<int>> Function(String jid) fetchDeviceList;
|
final Future<List<int>> Function(String jid) fetchDeviceList;
|
||||||
|
|
||||||
|
/// Fetch the device bundle for the device with id [id] of [jid]. If it cannot be fetched, return null.
|
||||||
final Future<OmemoBundle?> Function(String jid, int id) fetchDeviceBundle;
|
final Future<OmemoBundle?> Function(String jid, int id) fetchDeviceBundle;
|
||||||
|
|
||||||
/// Map bare JID to its known devices
|
/// Map bare JID to its known devices
|
||||||
@ -588,11 +594,16 @@ class OmemoManager {
|
|||||||
Future<void> ratchetAcknowledged(String jid, int deviceId, { bool enterCriticalSection = true }) async {
|
Future<void> ratchetAcknowledged(String jid, int deviceId, { bool enterCriticalSection = true }) async {
|
||||||
if (enterCriticalSection) await _enterRatchetCriticalSection(jid);
|
if (enterCriticalSection) await _enterRatchetCriticalSection(jid);
|
||||||
|
|
||||||
final ratchet = _ratchetMap[RatchetMapKey(jid, deviceId)]!
|
final key = RatchetMapKey(jid, deviceId);
|
||||||
|
if (_ratchetMap.containsKey(key)) {
|
||||||
|
final ratchet = _ratchetMap[key]!
|
||||||
..acknowledged = true;
|
..acknowledged = true;
|
||||||
|
|
||||||
// Commit it
|
// Commit it
|
||||||
_eventStreamController.add(RatchetModifiedEvent(jid, deviceId, ratchet, false));
|
_eventStreamController.add(RatchetModifiedEvent(jid, deviceId, ratchet, false));
|
||||||
|
} else {
|
||||||
|
_log.severe('Attempted to acknowledge ratchet ${key.toJsonKey()}, even though it does not exist');
|
||||||
|
}
|
||||||
|
|
||||||
if (enterCriticalSection) await _leaveRatchetCriticalSection(jid);
|
if (enterCriticalSection) await _leaveRatchetCriticalSection(jid);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'package:omemo_dart/src/omemo/encrypted_key.dart';
|
import 'package:omemo_dart/src/omemo/encrypted_key.dart';
|
||||||
|
|
||||||
|
/// Describes a stanza that was received by the underlying XMPP library.
|
||||||
class OmemoIncomingStanza {
|
class OmemoIncomingStanza {
|
||||||
const OmemoIncomingStanza(
|
const OmemoIncomingStanza(
|
||||||
this.bareSenderJid,
|
this.bareSenderJid,
|
||||||
@ -8,18 +9,33 @@ class OmemoIncomingStanza {
|
|||||||
this.keys,
|
this.keys,
|
||||||
this.payload,
|
this.payload,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// The bare JID of the sender of the stanza.
|
||||||
final String bareSenderJid;
|
final String bareSenderJid;
|
||||||
|
|
||||||
|
/// The device ID of the sender.
|
||||||
final int senderDeviceId;
|
final int senderDeviceId;
|
||||||
|
|
||||||
|
/// The timestamp when the stanza was received.
|
||||||
final int timestamp;
|
final int timestamp;
|
||||||
|
|
||||||
|
/// The included encrypted keys
|
||||||
final List<EncryptedKey> keys;
|
final List<EncryptedKey> keys;
|
||||||
|
|
||||||
|
/// The string payload included in the <encrypted /> element.
|
||||||
final String payload;
|
final String payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Describes a stanza that is to be sent out
|
||||||
class OmemoOutgoingStanza {
|
class OmemoOutgoingStanza {
|
||||||
const OmemoOutgoingStanza(
|
const OmemoOutgoingStanza(
|
||||||
this.recipientJids,
|
this.recipientJids,
|
||||||
this.payload,
|
this.payload,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// The JIDs the stanza will be sent to.
|
||||||
final List<String> recipientJids;
|
final List<String> recipientJids;
|
||||||
|
|
||||||
|
/// The serialised XML data that should be encrypted.
|
||||||
final String payload;
|
final String payload;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user