New Cwtch Library Integration
This commit is contained in:
parent
2c1347e50e
commit
1d6b533df3
|
@ -29,36 +29,35 @@ abstract class Cwtch {
|
||||||
void SendAppEvent(String jsonEvent);
|
void SendAppEvent(String jsonEvent);
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void AcceptContact(String profileOnion, String contactHandle);
|
void AcceptContact(String profileOnion, int contactHandle);
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void BlockContact(String profileOnion, String contactHandle);
|
void BlockContact(String profileOnion, int contactHandle);
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
Future<dynamic> GetMessage(String profile, String handle, int index);
|
Future<dynamic> GetMessage(String profile, int handle, int index);
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
Future<dynamic> GetMessageByContentHash(String profile, String handle, String contentHash);
|
Future<dynamic> GetMessageByContentHash(String profile, int handle, String contentHash);
|
||||||
// ignore: non_constant_identifier_names
|
|
||||||
void UpdateMessageFlags(String profile, String handle, int index, int flags);
|
|
||||||
// ignore: non_constant_identifier_names
|
|
||||||
void SendMessage(String profile, String handle, String message);
|
|
||||||
// ignore: non_constant_identifier_names
|
|
||||||
void SendInvitation(String profile, String handle, String target);
|
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void ShareFile(String profile, String handle, String filepath);
|
void SendMessage(String profile, int handle, String message);
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void DownloadFile(String profile, String handle, String filepath, String manifestpath, String filekey);
|
void SendInvitation(String profile, int handle, int target);
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void CreateDownloadableFile(String profile, String handle, String filenameSuggestion, String filekey);
|
void ShareFile(String profile, int handle, String filepath);
|
||||||
|
// ignore: non_constant_identifier_names
|
||||||
|
void DownloadFile(String profile, int handle, String filepath, String manifestpath, String filekey);
|
||||||
|
// ignore: non_constant_identifier_names
|
||||||
|
void CreateDownloadableFile(String profile, int handle, String filenameSuggestion, String filekey);
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void CheckDownloadStatus(String profile, String fileKey);
|
void CheckDownloadStatus(String profile, String fileKey);
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void VerifyOrResumeDownload(String profile, String handle, String filekey);
|
void VerifyOrResumeDownload(String profile, int handle, String filekey);
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void ArchiveConversation(String profile, String handle);
|
void ArchiveConversation(String profile, int handle);
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void DeleteContact(String profile, String handle);
|
void DeleteContact(String profile, int handle);
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void CreateGroup(String profile, String server, String groupName);
|
void CreateGroup(String profile, String server, String groupName);
|
||||||
|
@ -66,13 +65,11 @@ abstract class Cwtch {
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void ImportBundle(String profile, String bundle);
|
void ImportBundle(String profile, String bundle);
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void SetGroupAttribute(String profile, String groupHandle, String key, String value);
|
void RejectInvite(String profileOnion, int groupHandle);
|
||||||
// ignore: non_constant_identifier_names
|
|
||||||
void RejectInvite(String profileOnion, String groupHandle);
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void SetProfileAttribute(String profile, String key, String val);
|
void SetProfileAttribute(String profile, String key, String val);
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void SetContactAttribute(String profile, String contact, String key, String val);
|
void SetConversationAttribute(String profile, int contact, String key, String val);
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void LoadServers(String password);
|
void LoadServers(String password);
|
||||||
|
|
|
@ -34,6 +34,7 @@ class CwtchNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleMessage(String type, dynamic data) {
|
void handleMessage(String type, dynamic data) {
|
||||||
|
EnvironmentConfig.debugLog("NewEvent $type $data");
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "CwtchStarted":
|
case "CwtchStarted":
|
||||||
appState.SetCwtchInit();
|
appState.SetCwtchInit();
|
||||||
|
@ -42,12 +43,15 @@ class CwtchNotifier {
|
||||||
appState.SetAppError(data["Error"]);
|
appState.SetAppError(data["Error"]);
|
||||||
break;
|
break;
|
||||||
case "NewPeer":
|
case "NewPeer":
|
||||||
|
EnvironmentConfig.debugLog("NewPeer $data");
|
||||||
// if tag != v1-defaultPassword then it is either encrypted OR it is an unencrypted account created during pre-beta...
|
// if tag != v1-defaultPassword then it is either encrypted OR it is an unencrypted account created during pre-beta...
|
||||||
profileCN.add(data["Identity"], data["name"], data["picture"], data["ContactsJson"], data["ServerList"], data["Online"] == "true", data["tag"] != "v1-defaultPassword");
|
profileCN.add(data["Identity"], data["name"], data["picture"], data["ContactsJson"], data["ServerList"], data["Online"] == "true", data["tag"] != "v1-defaultPassword");
|
||||||
break;
|
break;
|
||||||
case "PeerCreated":
|
case "ContactCreated":
|
||||||
|
EnvironmentConfig.debugLog("NewServer $data");
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.add(ContactInfoState(
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.add(ContactInfoState(
|
||||||
data["ProfileOnion"],
|
data["ProfileOnion"],
|
||||||
|
data["ConversationID"],
|
||||||
data["RemotePeer"],
|
data["RemotePeer"],
|
||||||
nickname: data["nick"],
|
nickname: data["nick"],
|
||||||
status: data["status"],
|
status: data["status"],
|
||||||
|
@ -88,7 +92,7 @@ class CwtchNotifier {
|
||||||
status = serverInfoState.status;
|
status = serverInfoState.status;
|
||||||
}
|
}
|
||||||
if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"]) == null) {
|
if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"]) == null) {
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.add(ContactInfoState(data["ProfileOnion"], data["GroupID"],
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.add(ContactInfoState(data["ProfileOnion"], data["ConversationID"], data["GroupID"],
|
||||||
authorization: ContactAuthorization.approved,
|
authorization: ContactAuthorization.approved,
|
||||||
imagePath: data["PicturePath"],
|
imagePath: data["PicturePath"],
|
||||||
nickname: data["GroupName"],
|
nickname: data["GroupName"],
|
||||||
|
@ -111,13 +115,13 @@ class CwtchNotifier {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "DeleteContact":
|
case "DeleteContact":
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.removeContact(data["RemotePeer"]);
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.removeContact(data["ConversationID"]);
|
||||||
break;
|
break;
|
||||||
case "DeleteGroup":
|
case "DeleteGroup":
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.removeContact(data["GroupID"]);
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.removeContact(data["ConversationID"]);
|
||||||
break;
|
break;
|
||||||
case "PeerStateChange":
|
case "PeerStateChange":
|
||||||
ContactInfoState? contact = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"]);
|
ContactInfoState? contact = profileCN.getProfile(data["ProfileOnion"])?.contactList.findContact(data["RemotePeer"]);
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
if (data["ConnectionState"] != null) {
|
if (data["ConnectionState"] != null) {
|
||||||
contact.status = data["ConnectionState"];
|
contact.status = data["ConnectionState"];
|
||||||
|
@ -131,19 +135,20 @@ class CwtchNotifier {
|
||||||
break;
|
break;
|
||||||
case "NewMessageFromPeer":
|
case "NewMessageFromPeer":
|
||||||
notificationManager.notify("New Message From Peer!");
|
notificationManager.notify("New Message From Peer!");
|
||||||
if (appState.selectedProfile != data["ProfileOnion"] || appState.selectedConversation != data["RemotePeer"]) {
|
var identifier = int.parse(data["ConversationID"]);
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.unreadMessages++;
|
if (appState.selectedProfile != data["ProfileOnion"] || appState.selectedConversation != identifier) {
|
||||||
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.unreadMessages++;
|
||||||
} else {
|
} else {
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.newMarker++;
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.newMarker++;
|
||||||
}
|
}
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.totalMessages++;
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.totalMessages++;
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(data["RemotePeer"], DateTime.now());
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(identifier, DateTime.now());
|
||||||
|
|
||||||
// We only ever see messages from authenticated peers.
|
// We only ever see messages from authenticated peers.
|
||||||
// If the contact is marked as offline then override this - can happen when the contact is removed from the front
|
// If the contact is marked as offline then override this - can happen when the contact is removed from the front
|
||||||
// end during syncing.
|
// end during syncing.
|
||||||
if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.isOnline() == false) {
|
if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.isOnline() == false) {
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.status = "Authenticated";
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.status = "Authenticated";
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -151,10 +156,13 @@ class CwtchNotifier {
|
||||||
// We don't use these anymore, IndexedAcknowledgement is more suited to the UI front end...
|
// We don't use these anymore, IndexedAcknowledgement is more suited to the UI front end...
|
||||||
break;
|
break;
|
||||||
case "IndexedAcknowledgement":
|
case "IndexedAcknowledgement":
|
||||||
var idx = data["Index"];
|
var messageID = data["Index"];
|
||||||
|
var identifier = int.parse(data["ConversationID"]);
|
||||||
|
var idx = identifier.toString() + messageID;
|
||||||
|
|
||||||
// We return -1 for protocol message acks if there is no message
|
// We return -1 for protocol message acks if there is no message
|
||||||
if (idx == "-1") break;
|
if (idx == "-1") break;
|
||||||
var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.getMessageKey(idx);
|
var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.getMessageKey(idx);
|
||||||
if (key == null) break;
|
if (key == null) break;
|
||||||
try {
|
try {
|
||||||
var message = Provider.of<MessageMetadata>(key.currentContext!, listen: false);
|
var message = Provider.of<MessageMetadata>(key.currentContext!, listen: false);
|
||||||
|
@ -162,8 +170,8 @@ class CwtchNotifier {
|
||||||
// We only ever see acks from authenticated peers.
|
// We only ever see acks from authenticated peers.
|
||||||
// If the contact is marked as offline then override this - can happen when the contact is removed from the front
|
// If the contact is marked as offline then override this - can happen when the contact is removed from the front
|
||||||
// end during syncing.
|
// end during syncing.
|
||||||
if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.isOnline() == false) {
|
if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.isOnline() == false) {
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.status = "Authenticated";
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.status = "Authenticated";
|
||||||
}
|
}
|
||||||
message.ackd = true;
|
message.ackd = true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -172,19 +180,20 @@ class CwtchNotifier {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "NewMessageFromGroup":
|
case "NewMessageFromGroup":
|
||||||
|
var identifier = int.parse(data["ConversationID"]);
|
||||||
if (data["ProfileOnion"] != data["RemotePeer"]) {
|
if (data["ProfileOnion"] != data["RemotePeer"]) {
|
||||||
var idx = int.parse(data["Index"]);
|
var idx = int.parse(data["Index"]);
|
||||||
var currentTotal = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])!.totalMessages;
|
var currentTotal = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.totalMessages;
|
||||||
|
|
||||||
// Only bother to do anything if we know about the group and the provided index is greater than our current total...
|
// Only bother to do anything if we know about the group and the provided index is greater than our current total...
|
||||||
if (currentTotal != null && idx >= currentTotal) {
|
if (currentTotal != null && idx >= currentTotal) {
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])!.totalMessages = idx + 1;
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.totalMessages = idx + 1;
|
||||||
|
|
||||||
//if not currently open
|
//if not currently open
|
||||||
if (appState.selectedProfile != data["ProfileOnion"] || appState.selectedConversation != data["GroupID"]) {
|
if (appState.selectedProfile != data["ProfileOnion"] || appState.selectedConversation != identifier) {
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])!.unreadMessages++;
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.unreadMessages++;
|
||||||
} else {
|
} else {
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])!.newMarker++;
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.newMarker++;
|
||||||
}
|
}
|
||||||
|
|
||||||
var timestampSent = DateTime.tryParse(data['TimestampSent'])!;
|
var timestampSent = DateTime.tryParse(data['TimestampSent'])!;
|
||||||
|
@ -204,7 +213,7 @@ class CwtchNotifier {
|
||||||
} else {
|
} else {
|
||||||
// from me (already displayed - do not update counter)
|
// from me (already displayed - do not update counter)
|
||||||
var idx = data["Signature"];
|
var idx = data["Signature"];
|
||||||
var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])?.getMessageKey(idx);
|
var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)?.getMessageKey(idx);
|
||||||
if (key == null) break;
|
if (key == null) break;
|
||||||
try {
|
try {
|
||||||
var message = Provider.of<MessageMetadata>(key.currentContext!, listen: false);
|
var message = Provider.of<MessageMetadata>(key.currentContext!, listen: false);
|
||||||
|
@ -219,8 +228,8 @@ class CwtchNotifier {
|
||||||
var contactHandle = data["RemotePeer"];
|
var contactHandle = data["RemotePeer"];
|
||||||
if (contactHandle == null || contactHandle == "") contactHandle = data["GroupID"];
|
if (contactHandle == null || contactHandle == "") contactHandle = data["GroupID"];
|
||||||
var total = int.parse(data["Data"]);
|
var total = int.parse(data["Data"]);
|
||||||
if (total != profileCN.getProfile(data["Identity"])?.contactList.getContact(contactHandle)!.totalMessages) {
|
if (total != profileCN.getProfile(data["Identity"])?.contactList.findContact(contactHandle)!.totalMessages) {
|
||||||
profileCN.getProfile(data["Identity"])?.contactList.getContact(contactHandle)!.totalMessages = total;
|
profileCN.getProfile(data["Identity"])?.contactList.findContact(contactHandle)!.totalMessages = total;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "SendMessageToPeerError":
|
case "SendMessageToPeerError":
|
||||||
|
@ -228,7 +237,7 @@ class CwtchNotifier {
|
||||||
break;
|
break;
|
||||||
case "IndexedFailure":
|
case "IndexedFailure":
|
||||||
var idx = data["Index"];
|
var idx = data["Index"];
|
||||||
var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])?.getMessageKey(idx);
|
var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.findContact(data["RemotePeer"])?.getMessageKey(idx);
|
||||||
try {
|
try {
|
||||||
var message = Provider.of<MessageMetadata>(key!.currentContext!, listen: false);
|
var message = Provider.of<MessageMetadata>(key!.currentContext!, listen: false);
|
||||||
message.error = true;
|
message.error = true;
|
||||||
|
@ -240,7 +249,7 @@ class CwtchNotifier {
|
||||||
// from me (already displayed - do not update counter)
|
// from me (already displayed - do not update counter)
|
||||||
EnvironmentConfig.debugLog("SendMessageToGroupError");
|
EnvironmentConfig.debugLog("SendMessageToGroupError");
|
||||||
var idx = data["Signature"];
|
var idx = data["Signature"];
|
||||||
var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])!.getMessageKey(idx);
|
var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.findContact(data["GroupID"])!.getMessageKey(idx);
|
||||||
if (key == null) break;
|
if (key == null) break;
|
||||||
try {
|
try {
|
||||||
var message = Provider.of<MessageMetadata>(key.currentContext!, listen: false);
|
var message = Provider.of<MessageMetadata>(key.currentContext!, listen: false);
|
||||||
|
@ -298,8 +307,8 @@ class CwtchNotifier {
|
||||||
status = serverInfoState.status;
|
status = serverInfoState.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(groupInvite["GroupID"]) == null) {
|
if (profileCN.getProfile(data["ProfileOnion"])?.contactList.findContact(groupInvite["GroupID"]) == null) {
|
||||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.add(ContactInfoState(data["ProfileOnion"], groupInvite["GroupID"],
|
profileCN.getProfile(data["ProfileOnion"])?.contactList.add(ContactInfoState(data["ProfileOnion"], data["ConversationID"], groupInvite["GroupID"],
|
||||||
authorization: ContactAuthorization.approved,
|
authorization: ContactAuthorization.approved,
|
||||||
imagePath: data["PicturePath"],
|
imagePath: data["PicturePath"],
|
||||||
nickname: groupInvite["GroupName"],
|
nickname: groupInvite["GroupName"],
|
||||||
|
|
|
@ -36,8 +36,9 @@ typedef VoidFromStringStringStringFn = void Function(Pointer<Utf8>, int, Pointer
|
||||||
typedef void_from_string_string_string_string_function = Void Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32);
|
typedef void_from_string_string_string_string_function = Void Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32);
|
||||||
typedef VoidFromStringStringStringStringFn = void Function(Pointer<Utf8>, int, Pointer<Utf8>, int, Pointer<Utf8>, int, Pointer<Utf8>, int);
|
typedef VoidFromStringStringStringStringFn = void Function(Pointer<Utf8>, int, Pointer<Utf8>, int, Pointer<Utf8>, int, Pointer<Utf8>, int);
|
||||||
|
|
||||||
typedef void_from_string_string_string_string_string_function = Void Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32);
|
// DownloadFile
|
||||||
typedef VoidFromStringStringStringStringStringFn = void Function(Pointer<Utf8>, int, Pointer<Utf8>, int, Pointer<Utf8>, int, Pointer<Utf8>, int, Pointer<Utf8>, int);
|
typedef void_from_string_int_string_string_string_function = Void Function(Pointer<Utf8>, Int32, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32);
|
||||||
|
typedef VoidFromStringIntStringStringStringFn = void Function(Pointer<Utf8>, int, int, Pointer<Utf8>, int, Pointer<Utf8>, int, Pointer<Utf8>, int);
|
||||||
|
|
||||||
typedef void_from_string_string_int_int_function = Void Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Int64, Int64);
|
typedef void_from_string_string_int_int_function = Void Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Int64, Int64);
|
||||||
typedef VoidFromStringStringIntIntFn = void Function(Pointer<Utf8>, int, Pointer<Utf8>, int, int, int);
|
typedef VoidFromStringStringIntIntFn = void Function(Pointer<Utf8>, int, Pointer<Utf8>, int, int, int);
|
||||||
|
@ -51,6 +52,9 @@ typedef StringFn = void Function(Pointer<Utf8> dir, int);
|
||||||
typedef string_string_to_void_function = Void Function(Pointer<Utf8> str, Int32 length, Pointer<Utf8> str2, Int32 length2);
|
typedef string_string_to_void_function = Void Function(Pointer<Utf8> str, Int32 length, Pointer<Utf8> str2, Int32 length2);
|
||||||
typedef StringStringFn = void Function(Pointer<Utf8>, int, Pointer<Utf8>, int);
|
typedef StringStringFn = void Function(Pointer<Utf8>, int, Pointer<Utf8>, int);
|
||||||
|
|
||||||
|
typedef string_int_to_void_function = Void Function(Pointer<Utf8> str, Int32 length, Int32 handle);
|
||||||
|
typedef VoidFromStringIntFn = void Function(Pointer<Utf8>, int, int);
|
||||||
|
|
||||||
typedef get_json_blob_string_function = Pointer<Utf8> Function(Pointer<Utf8> str, Int32 length);
|
typedef get_json_blob_string_function = Pointer<Utf8> Function(Pointer<Utf8> str, Int32 length);
|
||||||
typedef GetJsonBlobStringFn = Pointer<Utf8> Function(Pointer<Utf8> str, int len);
|
typedef GetJsonBlobStringFn = Pointer<Utf8> Function(Pointer<Utf8> str, int len);
|
||||||
|
|
||||||
|
@ -58,10 +62,26 @@ typedef GetJsonBlobStringFn = Pointer<Utf8> Function(Pointer<Utf8> str, int len)
|
||||||
typedef get_json_blob_from_str_str_int_function = Pointer<Utf8> Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Int32);
|
typedef get_json_blob_from_str_str_int_function = Pointer<Utf8> Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Int32);
|
||||||
typedef GetJsonBlobFromStrStrIntFn = Pointer<Utf8> Function(Pointer<Utf8>, int, Pointer<Utf8>, int, int);
|
typedef GetJsonBlobFromStrStrIntFn = Pointer<Utf8> Function(Pointer<Utf8>, int, Pointer<Utf8>, int, int);
|
||||||
|
|
||||||
|
typedef get_json_blob_from_str_int_int_function = Pointer<Utf8> Function(Pointer<Utf8>, Int32, Int32, Int32);
|
||||||
|
typedef GetJsonBlobFromStrIntIntFn = Pointer<Utf8> Function(Pointer<Utf8>, int, int, int);
|
||||||
|
|
||||||
|
typedef get_json_blob_from_str_int_string_function = Pointer<Utf8> Function(Pointer<Utf8>, Int32, Int32, Pointer<Utf8>, Int32);
|
||||||
|
typedef GetJsonBlobFromStrIntStringFn = Pointer<Utf8> Function(Pointer<Utf8>, int, int, Pointer<Utf8>, int,);
|
||||||
|
|
||||||
// func c_GetMessagesByContentHash(profile_ptr *C.char, profile_len C.int, handle_ptr *C.char, handle_len C.int, contenthash_ptr *C.char, contenthash_len C.int) *C.char
|
// func c_GetMessagesByContentHash(profile_ptr *C.char, profile_len C.int, handle_ptr *C.char, handle_len C.int, contenthash_ptr *C.char, contenthash_len C.int) *C.char
|
||||||
typedef get_json_blob_from_str_str_str_function = Pointer<Utf8> Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32);
|
typedef get_json_blob_from_str_str_str_function = Pointer<Utf8> Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32);
|
||||||
typedef GetJsonBlobFromStrStrStrFn = Pointer<Utf8> Function(Pointer<Utf8>, int, Pointer<Utf8>, int, Pointer<Utf8>, int);
|
typedef GetJsonBlobFromStrStrStrFn = Pointer<Utf8> Function(Pointer<Utf8>, int, Pointer<Utf8>, int, Pointer<Utf8>, int);
|
||||||
|
|
||||||
|
typedef void_from_string_int_string_function = Void Function(Pointer<Utf8>, Int32, Int32, Pointer<Utf8>, Int32);
|
||||||
|
typedef VoidFromStringIntStringFn = void Function(Pointer<Utf8>, int, int, Pointer<Utf8>, int);
|
||||||
|
|
||||||
|
typedef void_from_string_int_string_string_function = Void Function(Pointer<Utf8>, Int32, Int32, Pointer<Utf8>, Int32, Pointer<Utf8>, Int32);
|
||||||
|
typedef VoidFromStringIntStringStringFn = void Function(Pointer<Utf8>, int, int, Pointer<Utf8>, int, Pointer<Utf8>, int);
|
||||||
|
|
||||||
|
typedef void_from_string_int_int_function =Void Function(Pointer<Utf8>, Int32, Int32, Int32);
|
||||||
|
typedef VoidFromStringIntIntFn = void Function(Pointer<Utf8>, int, int, int);
|
||||||
|
|
||||||
|
|
||||||
typedef appbus_events_function = Pointer<Utf8> Function();
|
typedef appbus_events_function = Pointer<Utf8> Function();
|
||||||
typedef AppbusEventsFn = Pointer<Utf8> Function();
|
typedef AppbusEventsFn = Pointer<Utf8> Function();
|
||||||
|
|
||||||
|
@ -266,17 +286,15 @@ class CwtchFfi implements Cwtch {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
Future<String> GetMessage(String profile, String handle, int index) async {
|
Future<String> GetMessage(String profile, int handle, int index) async {
|
||||||
var getMessageC = library.lookup<NativeFunction<get_json_blob_from_str_str_int_function>>("c_GetMessage");
|
var getMessageC = library.lookup<NativeFunction<get_json_blob_from_str_int_int_function>>("c_GetMessage");
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
final GetMessage = getMessageC.asFunction<GetJsonBlobFromStrStrIntFn>();
|
final GetMessage = getMessageC.asFunction<GetJsonBlobFromStrIntIntFn>();
|
||||||
final utf8profile = profile.toNativeUtf8();
|
final utf8profile = profile.toNativeUtf8();
|
||||||
final utf8handle = handle.toNativeUtf8();
|
Pointer<Utf8> jsonMessageBytes = GetMessage(utf8profile, utf8profile.length, handle, index);
|
||||||
Pointer<Utf8> jsonMessageBytes = GetMessage(utf8profile, utf8profile.length, utf8handle, utf8handle.length, index);
|
|
||||||
String jsonMessage = jsonMessageBytes.toDartString();
|
String jsonMessage = jsonMessageBytes.toDartString();
|
||||||
_UnsafeFreePointerAnyUseOfThisFunctionMustBeDoubleApproved(jsonMessageBytes);
|
_UnsafeFreePointerAnyUseOfThisFunctionMustBeDoubleApproved(jsonMessageBytes);
|
||||||
malloc.free(utf8profile);
|
malloc.free(utf8profile);
|
||||||
malloc.free(utf8handle);
|
|
||||||
return jsonMessage;
|
return jsonMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,89 +324,75 @@ class CwtchFfi implements Cwtch {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void AcceptContact(String profileOnion, String contactHandle) {
|
void AcceptContact(String profileOnion, int contactHandle) {
|
||||||
var acceptContact = library.lookup<NativeFunction<string_string_to_void_function>>("c_AcceptContact");
|
var acceptContact = library.lookup<NativeFunction<string_int_to_void_function>>("c_AcceptContact");
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
final AcceptContact = acceptContact.asFunction<VoidFromStringStringFn>();
|
final AcceptContact = acceptContact.asFunction<VoidFromStringIntFn>();
|
||||||
final u1 = profileOnion.toNativeUtf8();
|
final u1 = profileOnion.toNativeUtf8();
|
||||||
final u2 = contactHandle.toNativeUtf8();
|
AcceptContact(u1, u1.length, contactHandle);
|
||||||
AcceptContact(u1, u1.length, u2, u2.length);
|
|
||||||
malloc.free(u1);
|
malloc.free(u1);
|
||||||
malloc.free(u2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void BlockContact(String profileOnion, String contactHandle) {
|
void BlockContact(String profileOnion, int contactHandle) {
|
||||||
var blockContact = library.lookup<NativeFunction<string_string_to_void_function>>("c_BlockContact");
|
var blockContact = library.lookup<NativeFunction<string_int_to_void_function>>("c_BlockContact");
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
final BlockContact = blockContact.asFunction<VoidFromStringStringFn>();
|
final BlockContact = blockContact.asFunction<VoidFromStringIntFn>();
|
||||||
final u1 = profileOnion.toNativeUtf8();
|
final u1 = profileOnion.toNativeUtf8();
|
||||||
final u2 = contactHandle.toNativeUtf8();
|
BlockContact(u1, u1.length, contactHandle);
|
||||||
BlockContact(u1, u1.length, u2, u2.length);
|
|
||||||
malloc.free(u1);
|
malloc.free(u1);
|
||||||
malloc.free(u2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void SendMessage(String profileOnion, String contactHandle, String message) {
|
void SendMessage(String profileOnion, int contactHandle, String message) {
|
||||||
var sendMessage = library.lookup<NativeFunction<void_from_string_string_string_function>>("c_SendMessage");
|
var sendMessage = library.lookup<NativeFunction<void_from_string_int_string_function>>("c_SendMessage");
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
final SendMessage = sendMessage.asFunction<VoidFromStringStringStringFn>();
|
final SendMessage = sendMessage.asFunction<VoidFromStringIntStringFn>();
|
||||||
final u1 = profileOnion.toNativeUtf8();
|
final u1 = profileOnion.toNativeUtf8();
|
||||||
final u2 = contactHandle.toNativeUtf8();
|
|
||||||
final u3 = message.toNativeUtf8();
|
final u3 = message.toNativeUtf8();
|
||||||
SendMessage(u1, u1.length, u2, u2.length, u3, u3.length);
|
SendMessage(u1, u1.length, contactHandle, u3, u3.length);
|
||||||
malloc.free(u1);
|
malloc.free(u1);
|
||||||
malloc.free(u2);
|
|
||||||
malloc.free(u3);
|
malloc.free(u3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void SendInvitation(String profileOnion, String contactHandle, String target) {
|
void SendInvitation(String profileOnion, int contactHandle, int target) {
|
||||||
var sendInvitation = library.lookup<NativeFunction<void_from_string_string_string_function>>("c_SendInvitation");
|
var sendInvitation = library.lookup<NativeFunction<void_from_string_int_int_function>>("c_SendInvitation");
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
final SendInvitation = sendInvitation.asFunction<VoidFromStringStringStringFn>();
|
final SendInvitation = sendInvitation.asFunction<VoidFromStringIntIntFn>();
|
||||||
final u1 = profileOnion.toNativeUtf8();
|
final u1 = profileOnion.toNativeUtf8();
|
||||||
final u2 = contactHandle.toNativeUtf8();
|
SendInvitation(u1, u1.length, contactHandle, target);
|
||||||
final u3 = target.toNativeUtf8();
|
|
||||||
SendInvitation(u1, u1.length, u2, u2.length, u3, u3.length);
|
|
||||||
malloc.free(u1);
|
malloc.free(u1);
|
||||||
malloc.free(u2);
|
|
||||||
malloc.free(u3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void ShareFile(String profileOnion, String contactHandle, String filepath) {
|
void ShareFile(String profileOnion, int contactHandle, String filepath) {
|
||||||
var shareFile = library.lookup<NativeFunction<void_from_string_string_string_function>>("c_ShareFile");
|
var shareFile = library.lookup<NativeFunction<void_from_string_int_string_function>>("c_ShareFile");
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
final ShareFile = shareFile.asFunction<VoidFromStringStringStringFn>();
|
final ShareFile = shareFile.asFunction<VoidFromStringIntStringFn>();
|
||||||
final u1 = profileOnion.toNativeUtf8();
|
final u1 = profileOnion.toNativeUtf8();
|
||||||
final u2 = contactHandle.toNativeUtf8();
|
|
||||||
final u3 = filepath.toNativeUtf8();
|
final u3 = filepath.toNativeUtf8();
|
||||||
ShareFile(u1, u1.length, u2, u2.length, u3, u3.length);
|
ShareFile(u1, u1.length, contactHandle, u3, u3.length);
|
||||||
malloc.free(u1);
|
malloc.free(u1);
|
||||||
malloc.free(u2);
|
|
||||||
malloc.free(u3);
|
malloc.free(u3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void DownloadFile(String profileOnion, String contactHandle, String filepath, String manifestpath, String filekey) {
|
void DownloadFile(String profileOnion, int contactHandle, String filepath, String manifestpath, String filekey) {
|
||||||
var dlFile = library.lookup<NativeFunction<void_from_string_string_string_string_string_function>>("c_DownloadFile");
|
var dlFile = library.lookup<NativeFunction<void_from_string_int_string_string_string_function>>("c_DownloadFile");
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
final DownloadFile = dlFile.asFunction<VoidFromStringStringStringStringStringFn>();
|
final DownloadFile = dlFile.asFunction<VoidFromStringIntStringStringStringFn>();
|
||||||
final u1 = profileOnion.toNativeUtf8();
|
final u1 = profileOnion.toNativeUtf8();
|
||||||
final u2 = contactHandle.toNativeUtf8();
|
|
||||||
final u3 = filepath.toNativeUtf8();
|
final u3 = filepath.toNativeUtf8();
|
||||||
final u4 = manifestpath.toNativeUtf8();
|
final u4 = manifestpath.toNativeUtf8();
|
||||||
final u5 = filekey.toNativeUtf8();
|
final u5 = filekey.toNativeUtf8();
|
||||||
DownloadFile(u1, u1.length, u2, u2.length, u3, u3.length, u4, u4.length, u5, u5.length);
|
DownloadFile(u1, u1.length, contactHandle, u3, u3.length, u4, u4.length, u5, u5.length);
|
||||||
malloc.free(u1);
|
malloc.free(u1);
|
||||||
malloc.free(u2);
|
|
||||||
malloc.free(u3);
|
malloc.free(u3);
|
||||||
malloc.free(u4);
|
malloc.free(u4);
|
||||||
malloc.free(u5);
|
malloc.free(u5);
|
||||||
|
@ -396,7 +400,7 @@ class CwtchFfi implements Cwtch {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void CreateDownloadableFile(String profileOnion, String contactHandle, String filenameSuggestion, String filekey) {
|
void CreateDownloadableFile(String profileOnion, int contactHandle, String filenameSuggestion, String filekey) {
|
||||||
// android only - do nothing
|
// android only - do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,16 +419,14 @@ class CwtchFfi implements Cwtch {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void VerifyOrResumeDownload(String profileOnion, String contactHandle, String filekey) {
|
void VerifyOrResumeDownload(String profileOnion, int contactHandle, String filekey) {
|
||||||
var fn = library.lookup<NativeFunction<void_from_string_string_string_function>>("c_VerifyOrResumeDownload");
|
var fn = library.lookup<NativeFunction<void_from_string_int_string_function>>("c_VerifyOrResumeDownload");
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
final VerifyOrResumeDownload = fn.asFunction<VoidFromStringStringStringFn>();
|
final VerifyOrResumeDownload = fn.asFunction<VoidFromStringIntStringFn>();
|
||||||
final u1 = profileOnion.toNativeUtf8();
|
final u1 = profileOnion.toNativeUtf8();
|
||||||
final u2 = contactHandle.toNativeUtf8();
|
|
||||||
final u3 = filekey.toNativeUtf8();
|
final u3 = filekey.toNativeUtf8();
|
||||||
VerifyOrResumeDownload(u1, u1.length, u2, u2.length, u3, u3.length);
|
VerifyOrResumeDownload(u1, u1.length, contactHandle, u3, u3.length);
|
||||||
malloc.free(u1);
|
malloc.free(u1);
|
||||||
malloc.free(u2);
|
|
||||||
malloc.free(u3);
|
malloc.free(u3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,34 +453,16 @@ class CwtchFfi implements Cwtch {
|
||||||
malloc.free(u2);
|
malloc.free(u2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
// ignore: non_constant_identifier_names
|
|
||||||
void SetGroupAttribute(String profileOnion, String groupHandle, String key, String value) {
|
|
||||||
var setGroupAttribute = library.lookup<NativeFunction<void_from_string_string_string_string_function>>("c_SetGroupAttribute");
|
|
||||||
// ignore: non_constant_identifier_names
|
|
||||||
final SetGroupAttribute = setGroupAttribute.asFunction<VoidFromStringStringStringStringFn>();
|
|
||||||
final u1 = profileOnion.toNativeUtf8();
|
|
||||||
final u2 = groupHandle.toNativeUtf8();
|
|
||||||
final u3 = key.toNativeUtf8();
|
|
||||||
final u4 = value.toNativeUtf8();
|
|
||||||
SetGroupAttribute(u1, u1.length, u2, u2.length, u3, u3.length, u4, u4.length);
|
|
||||||
malloc.free(u1);
|
|
||||||
malloc.free(u2);
|
|
||||||
malloc.free(u3);
|
|
||||||
malloc.free(u4);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void RejectInvite(String profileOnion, String groupHandle) {
|
void RejectInvite(String profileOnion, int groupHandle) {
|
||||||
var rejectInvite = library.lookup<NativeFunction<string_string_to_void_function>>("c_RejectInvite");
|
var rejectInvite = library.lookup<NativeFunction<string_int_to_void_function>>("c_RejectInvite");
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
final RejectInvite = rejectInvite.asFunction<VoidFromStringStringFn>();
|
final RejectInvite = rejectInvite.asFunction<VoidFromStringIntFn>();
|
||||||
final u1 = profileOnion.toNativeUtf8();
|
final u1 = profileOnion.toNativeUtf8();
|
||||||
final u2 = groupHandle.toNativeUtf8();
|
RejectInvite(u1, u1.length, groupHandle);
|
||||||
RejectInvite(u1, u1.length, u2, u2.length);
|
|
||||||
malloc.free(u1);
|
malloc.free(u1);
|
||||||
malloc.free(u2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -499,42 +483,27 @@ class CwtchFfi implements Cwtch {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void ArchiveConversation(String profileOnion, String handle) {
|
void ArchiveConversation(String profileOnion, int handle) {
|
||||||
var archiveConversation = library.lookup<NativeFunction<string_string_to_void_function>>("c_ArchiveConversation");
|
var archiveConversation = library.lookup<NativeFunction<string_int_to_void_function>>("c_ArchiveConversation");
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
final ArchiveConversation = archiveConversation.asFunction<VoidFromStringStringFn>();
|
final ArchiveConversation = archiveConversation.asFunction<VoidFromStringIntFn>();
|
||||||
final u1 = profileOnion.toNativeUtf8();
|
final u1 = profileOnion.toNativeUtf8();
|
||||||
final u2 = handle.toNativeUtf8();
|
ArchiveConversation(u1, u1.length, handle);
|
||||||
ArchiveConversation(u1, u1.length, u2, u2.length);
|
|
||||||
malloc.free(u1);
|
malloc.free(u1);
|
||||||
malloc.free(u2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void DeleteContact(String profileOnion, String handle) {
|
void DeleteContact(String profileOnion, int handle) {
|
||||||
var deleteContact = library.lookup<NativeFunction<string_string_to_void_function>>("c_DeleteContact");
|
var deleteContact = library.lookup<NativeFunction<string_int_to_void_function>>("c_DeleteContact");
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
final DeleteContact = deleteContact.asFunction<VoidFromStringStringFn>();
|
final DeleteContact = deleteContact.asFunction<VoidFromStringIntFn>();
|
||||||
final u1 = profileOnion.toNativeUtf8();
|
final u1 = profileOnion.toNativeUtf8();
|
||||||
final u2 = handle.toNativeUtf8();
|
DeleteContact(u1, u1.length, handle);
|
||||||
DeleteContact(u1, u1.length, u2, u2.length);
|
|
||||||
malloc.free(u1);
|
malloc.free(u1);
|
||||||
malloc.free(u2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
// ignore: non_constant_identifier_names
|
|
||||||
void UpdateMessageFlags(String profile, String handle, int index, int flags) {
|
|
||||||
var updateMessageFlagsC = library.lookup<NativeFunction<void_from_string_string_int_int_function>>("c_UpdateMessageFlags");
|
|
||||||
// ignore: non_constant_identifier_names
|
|
||||||
final updateMessageFlags = updateMessageFlagsC.asFunction<VoidFromStringStringIntIntFn>();
|
|
||||||
final utf8profile = profile.toNativeUtf8();
|
|
||||||
final utf8handle = handle.toNativeUtf8();
|
|
||||||
updateMessageFlags(utf8profile, utf8profile.length, utf8handle, utf8handle.length, index, flags);
|
|
||||||
malloc.free(utf8profile);
|
|
||||||
malloc.free(utf8handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
|
@ -566,17 +535,15 @@ class CwtchFfi implements Cwtch {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void SetContactAttribute(String profile, String contact, String key, String val) {
|
void SetConversationAttribute(String profile, int contact, String key, String val) {
|
||||||
var setContactAttribute = library.lookup<NativeFunction<void_from_string_string_string_string_function>>("c_SetContactAttribute");
|
var setContactAttribute = library.lookup<NativeFunction<void_from_string_int_string_string_function>>("c_SetContactAttribute");
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
final SetContactAttribute = setContactAttribute.asFunction<VoidFromStringStringStringStringFn>();
|
final SetContactAttribute = setContactAttribute.asFunction<VoidFromStringIntStringStringFn>();
|
||||||
final u1 = profile.toNativeUtf8();
|
final u1 = profile.toNativeUtf8();
|
||||||
final u2 = contact.toNativeUtf8();
|
|
||||||
final u3 = key.toNativeUtf8();
|
final u3 = key.toNativeUtf8();
|
||||||
final u4 = key.toNativeUtf8();
|
final u4 = key.toNativeUtf8();
|
||||||
SetContactAttribute(u1, u1.length, u2, u2.length, u3, u3.length, u4, u4.length);
|
SetContactAttribute(u1, u1.length, contact, u3, u3.length, u4, u4.length);
|
||||||
malloc.free(u1);
|
malloc.free(u1);
|
||||||
malloc.free(u2);
|
|
||||||
malloc.free(u3);
|
malloc.free(u3);
|
||||||
malloc.free(u4);
|
malloc.free(u4);
|
||||||
}
|
}
|
||||||
|
@ -703,19 +670,17 @@ class CwtchFfi implements Cwtch {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
Future GetMessageByContentHash(String profile, String handle, String contentHash) async {
|
Future GetMessageByContentHash(String profile, int handle, String contentHash) async {
|
||||||
var getMessagesByContentHashC = library.lookup<NativeFunction<get_json_blob_from_str_str_str_function>>("c_GetMessagesByContentHash");
|
var getMessagesByContentHashC = library.lookup<NativeFunction<get_json_blob_from_str_int_string_function>>("c_GetMessagesByContentHash");
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
final GetMessagesByContentHash = getMessagesByContentHashC.asFunction<GetJsonBlobFromStrStrStrFn>();
|
final GetMessagesByContentHash = getMessagesByContentHashC.asFunction<GetJsonBlobFromStrIntStringFn>();
|
||||||
final utf8profile = profile.toNativeUtf8();
|
final utf8profile = profile.toNativeUtf8();
|
||||||
final utf8handle = handle.toNativeUtf8();
|
|
||||||
final utf8contentHash = contentHash.toNativeUtf8();
|
final utf8contentHash = contentHash.toNativeUtf8();
|
||||||
Pointer<Utf8> jsonMessageBytes = GetMessagesByContentHash(utf8profile, utf8profile.length, utf8handle, utf8handle.length, utf8contentHash, utf8contentHash.length);
|
Pointer<Utf8> jsonMessageBytes = GetMessagesByContentHash(utf8profile, utf8profile.length, handle, utf8contentHash, utf8contentHash.length);
|
||||||
String jsonMessage = jsonMessageBytes.toDartString();
|
String jsonMessage = jsonMessageBytes.toDartString();
|
||||||
|
|
||||||
_UnsafeFreePointerAnyUseOfThisFunctionMustBeDoubleApproved(jsonMessageBytes);
|
_UnsafeFreePointerAnyUseOfThisFunctionMustBeDoubleApproved(jsonMessageBytes);
|
||||||
malloc.free(utf8profile);
|
malloc.free(utf8profile);
|
||||||
malloc.free(utf8handle);
|
|
||||||
malloc.free(utf8contentHash);
|
malloc.free(utf8contentHash);
|
||||||
return jsonMessage;
|
return jsonMessage;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ class CwtchGomobile implements Cwtch {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
Future<dynamic> GetMessage(String profile, String handle, int index) {
|
Future<dynamic> GetMessage(String profile, int handle, int index) {
|
||||||
print("gomobile.dart GetMessage " + index.toString());
|
print("gomobile.dart GetMessage " + index.toString());
|
||||||
return cwtchPlatform.invokeMethod("GetMessage", {"profile": profile, "contact": handle, "index": index});
|
return cwtchPlatform.invokeMethod("GetMessage", {"profile": profile, "contact": handle, "index": index});
|
||||||
}
|
}
|
||||||
|
@ -109,42 +109,42 @@ class CwtchGomobile implements Cwtch {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void AcceptContact(String profileOnion, String contactHandle) {
|
void AcceptContact(String profileOnion, int contactHandle) {
|
||||||
cwtchPlatform.invokeMethod("AcceptContact", {"ProfileOnion": profileOnion, "handle": contactHandle});
|
cwtchPlatform.invokeMethod("AcceptContact", {"ProfileOnion": profileOnion, "handle": contactHandle});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void BlockContact(String profileOnion, String contactHandle) {
|
void BlockContact(String profileOnion, int contactHandle) {
|
||||||
cwtchPlatform.invokeMethod("BlockContact", {"ProfileOnion": profileOnion, "handle": contactHandle});
|
cwtchPlatform.invokeMethod("BlockContact", {"ProfileOnion": profileOnion, "handle": contactHandle});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void SendMessage(String profileOnion, String contactHandle, String message) {
|
void SendMessage(String profileOnion, int contactHandle, String message) {
|
||||||
cwtchPlatform.invokeMethod("SendMessage", {"ProfileOnion": profileOnion, "handle": contactHandle, "message": message});
|
cwtchPlatform.invokeMethod("SendMessage", {"ProfileOnion": profileOnion, "handle": contactHandle, "message": message});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void SendInvitation(String profileOnion, String contactHandle, String target) {
|
void SendInvitation(String profileOnion, int contactHandle, int target) {
|
||||||
cwtchPlatform.invokeMethod("SendInvitation", {"ProfileOnion": profileOnion, "handle": contactHandle, "target": target});
|
cwtchPlatform.invokeMethod("SendInvitation", {"ProfileOnion": profileOnion, "handle": contactHandle, "target": target});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void ShareFile(String profileOnion, String contactHandle, String filepath) {
|
void ShareFile(String profileOnion, int contactHandle, String filepath) {
|
||||||
cwtchPlatform.invokeMethod("ShareFile", {"ProfileOnion": profileOnion, "handle": contactHandle, "filepath": filepath});
|
cwtchPlatform.invokeMethod("ShareFile", {"ProfileOnion": profileOnion, "handle": contactHandle, "filepath": filepath});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void DownloadFile(String profileOnion, String contactHandle, String filepath, String manifestpath, String filekey) {
|
void DownloadFile(String profileOnion, int contactHandle, String filepath, String manifestpath, String filekey) {
|
||||||
cwtchPlatform.invokeMethod("DownloadFile", {"ProfileOnion": profileOnion, "handle": contactHandle, "filepath": filepath, "manifestpath": manifestpath, "filekey": filekey});
|
cwtchPlatform.invokeMethod("DownloadFile", {"ProfileOnion": profileOnion, "handle": contactHandle, "filepath": filepath, "manifestpath": manifestpath, "filekey": filekey});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void CreateDownloadableFile(String profileOnion, String contactHandle, String filenameSuggestion, String filekey) {
|
void CreateDownloadableFile(String profileOnion, int contactHandle, String filenameSuggestion, String filekey) {
|
||||||
cwtchPlatform.invokeMethod("CreateDownloadableFile", {"ProfileOnion": profileOnion, "handle": contactHandle, "filename": filenameSuggestion, "filekey": filekey});
|
cwtchPlatform.invokeMethod("CreateDownloadableFile", {"ProfileOnion": profileOnion, "handle": contactHandle, "filename": filenameSuggestion, "filekey": filekey});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ class CwtchGomobile implements Cwtch {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void VerifyOrResumeDownload(String profileOnion, String contactHandle, String filekey) {
|
void VerifyOrResumeDownload(String profileOnion, int contactHandle, String filekey) {
|
||||||
cwtchPlatform.invokeMethod("VerifyOrResumeDownload", {"ProfileOnion": profileOnion, "handle": contactHandle, "filekey": filekey});
|
cwtchPlatform.invokeMethod("VerifyOrResumeDownload", {"ProfileOnion": profileOnion, "handle": contactHandle, "filekey": filekey});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ class CwtchGomobile implements Cwtch {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void RejectInvite(String profileOnion, String groupHandle) {
|
void RejectInvite(String profileOnion, int groupHandle) {
|
||||||
cwtchPlatform.invokeMethod("RejectInvite", {"ProfileOnion": profileOnion, "groupHandle": groupHandle});
|
cwtchPlatform.invokeMethod("RejectInvite", {"ProfileOnion": profileOnion, "groupHandle": groupHandle});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,21 +191,16 @@ class CwtchGomobile implements Cwtch {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void DeleteContact(String profileOnion, String handle) {
|
void DeleteContact(String profileOnion, int handle) {
|
||||||
cwtchPlatform.invokeMethod("DeleteContact", {"ProfileOnion": profileOnion, "handle": handle});
|
cwtchPlatform.invokeMethod("DeleteContact", {"ProfileOnion": profileOnion, "handle": handle});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void ArchiveConversation(String profileOnion, String contactHandle) {
|
void ArchiveConversation(String profileOnion, int contactHandle) {
|
||||||
cwtchPlatform.invokeMethod("ArchiveConversation", {"ProfileOnion": profileOnion, "handle": contactHandle});
|
cwtchPlatform.invokeMethod("ArchiveConversation", {"ProfileOnion": profileOnion, "handle": contactHandle});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void UpdateMessageFlags(String profile, String handle, int index, int flags) {
|
|
||||||
print("gomobile.dart UpdateMessageFlags " + index.toString());
|
|
||||||
cwtchPlatform.invokeMethod("UpdateMessageFlags", {"profile": profile, "contact": handle, "midx": index, "flags": flags});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
|
@ -215,7 +210,7 @@ class CwtchGomobile implements Cwtch {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// ignore: non_constant_identifier_names
|
// ignore: non_constant_identifier_names
|
||||||
void SetContactAttribute(String profile, String contact, String key, String val) {
|
void SetConversationAttribute(String profile, int contact, String key, String val) {
|
||||||
cwtchPlatform.invokeMethod("SetContactAttribute", {"ProfileOnion": profile, "Contact": contact, "Key": key, "Val": val});
|
cwtchPlatform.invokeMethod("SetContactAttribute", {"ProfileOnion": profile, "Contact": contact, "Key": key, "Val": val});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,7 +275,7 @@ class CwtchGomobile implements Cwtch {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future GetMessageByContentHash(String profile, String handle, String contentHash) {
|
Future GetMessageByContentHash(String profile, int handle, String contentHash) {
|
||||||
return cwtchPlatform.invokeMethod("GetMessageByContentHash", {"profile": profile, "contact": handle, "contentHash": contentHash});
|
return cwtchPlatform.invokeMethod("GetMessageByContentHash", {"profile": profile, "contact": handle, "contentHash": contentHash});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class AppState extends ChangeNotifier {
|
||||||
bool cwtchIsClosing = false;
|
bool cwtchIsClosing = false;
|
||||||
String appError = "";
|
String appError = "";
|
||||||
String? _selectedProfile;
|
String? _selectedProfile;
|
||||||
String? _selectedConversation;
|
int? _selectedConversation;
|
||||||
int _initialScrollIndex = 0;
|
int _initialScrollIndex = 0;
|
||||||
int _hoveredIndex = -1;
|
int _hoveredIndex = -1;
|
||||||
int? _selectedIndex;
|
int? _selectedIndex;
|
||||||
|
@ -51,8 +51,8 @@ class AppState extends ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
String? get selectedConversation => _selectedConversation;
|
int? get selectedConversation => _selectedConversation;
|
||||||
set selectedConversation(String? newVal) {
|
set selectedConversation(int? newVal) {
|
||||||
this._selectedConversation = newVal;
|
this._selectedConversation = newVal;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
@ -172,8 +172,8 @@ class ContactListState extends ChangeNotifier {
|
||||||
//} </todo>
|
//} </todo>
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateLastMessageTime(String forOnion, DateTime newMessageTime) {
|
void updateLastMessageTime(int forIdentifier, DateTime newMessageTime) {
|
||||||
var contact = getContact(forOnion);
|
var contact = getContact(forIdentifier);
|
||||||
if (contact == null) return;
|
if (contact == null) return;
|
||||||
|
|
||||||
// Assert that the new time is after the current last message time AND that
|
// Assert that the new time is after the current last message time AND that
|
||||||
|
@ -191,18 +191,24 @@ class ContactListState extends ChangeNotifier {
|
||||||
|
|
||||||
List<ContactInfoState> get contacts => _contacts.sublist(0); //todo: copy?? dont want caller able to bypass changenotifier
|
List<ContactInfoState> get contacts => _contacts.sublist(0); //todo: copy?? dont want caller able to bypass changenotifier
|
||||||
|
|
||||||
ContactInfoState? getContact(String onion) {
|
ContactInfoState? getContact(int identifier) {
|
||||||
int idx = _contacts.indexWhere((element) => element.onion == onion);
|
int idx = _contacts.indexWhere((element) => element.identifier == identifier);
|
||||||
return idx >= 0 ? _contacts[idx] : null;
|
return idx >= 0 ? _contacts[idx] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeContact(String onion) {
|
void removeContact(int identifier) {
|
||||||
int idx = _contacts.indexWhere((element) => element.onion == onion);
|
int idx = _contacts.indexWhere((element) => element.identifier == identifier);
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
_contacts.removeAt(idx);
|
_contacts.removeAt(idx);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ContactInfoState? findContact(String byHandle) {
|
||||||
|
int idx = _contacts.indexWhere((element) => element.onion == byHandle);
|
||||||
|
return idx >= 0 ? _contacts[idx] : null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProfileInfoState extends ChangeNotifier {
|
class ProfileInfoState extends ChangeNotifier {
|
||||||
|
@ -238,7 +244,7 @@ class ProfileInfoState extends ChangeNotifier {
|
||||||
if (contactsJson != null && contactsJson != "" && contactsJson != "null") {
|
if (contactsJson != null && contactsJson != "" && contactsJson != "null") {
|
||||||
List<dynamic> contacts = jsonDecode(contactsJson);
|
List<dynamic> contacts = jsonDecode(contactsJson);
|
||||||
this._contacts.addAll(contacts.map((contact) {
|
this._contacts.addAll(contacts.map((contact) {
|
||||||
return ContactInfoState(this.onion, contact["onion"],
|
return ContactInfoState(this.onion, contact["identifier"], contact["onion"],
|
||||||
nickname: contact["name"],
|
nickname: contact["name"],
|
||||||
status: contact["status"],
|
status: contact["status"],
|
||||||
imagePath: contact["picture"],
|
imagePath: contact["picture"],
|
||||||
|
@ -254,7 +260,7 @@ class ProfileInfoState extends ChangeNotifier {
|
||||||
|
|
||||||
// dummy set to invoke sort-on-load
|
// dummy set to invoke sort-on-load
|
||||||
if (this._contacts.num > 0) {
|
if (this._contacts.num > 0) {
|
||||||
this._contacts.updateLastMessageTime(this._contacts._contacts.first.onion, this._contacts._contacts.first.lastMessageTime);
|
this._contacts.updateLastMessageTime(this._contacts._contacts.first.identifier, this._contacts._contacts.first.lastMessageTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,6 +347,7 @@ class ProfileInfoState extends ChangeNotifier {
|
||||||
} else {
|
} else {
|
||||||
this._contacts.add(ContactInfoState(
|
this._contacts.add(ContactInfoState(
|
||||||
this.onion,
|
this.onion,
|
||||||
|
contact["identifier"],
|
||||||
contact["onion"],
|
contact["onion"],
|
||||||
nickname: contact["name"],
|
nickname: contact["name"],
|
||||||
status: contact["status"],
|
status: contact["status"],
|
||||||
|
@ -496,6 +503,7 @@ ContactAuthorization stringToContactAuthorization(String authStr) {
|
||||||
|
|
||||||
class ContactInfoState extends ChangeNotifier {
|
class ContactInfoState extends ChangeNotifier {
|
||||||
final String profileOnion;
|
final String profileOnion;
|
||||||
|
final int identifier;
|
||||||
final String onion;
|
final String onion;
|
||||||
late String _nickname;
|
late String _nickname;
|
||||||
|
|
||||||
|
@ -515,7 +523,7 @@ class ContactInfoState extends ChangeNotifier {
|
||||||
String? _server;
|
String? _server;
|
||||||
late bool _archived;
|
late bool _archived;
|
||||||
|
|
||||||
ContactInfoState(this.profileOnion, this.onion,
|
ContactInfoState(this.profileOnion, this.identifier, this.onion,
|
||||||
{nickname = "",
|
{nickname = "",
|
||||||
isGroup = false,
|
isGroup = false,
|
||||||
authorization = ContactAuthorization.unknown,
|
authorization = ContactAuthorization.unknown,
|
||||||
|
|
|
@ -31,11 +31,11 @@ abstract class Message {
|
||||||
Widget getPreviewWidget(BuildContext context);
|
Widget getPreviewWidget(BuildContext context);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Message> messageHandler(BuildContext context, String profileOnion, String contactHandle, int index) {
|
Future<Message> messageHandler(BuildContext context, String profileOnion, int conversationIdentifier, int index) {
|
||||||
try {
|
try {
|
||||||
var rawMessageEnvelopeFuture = Provider.of<FlwtchState>(context, listen: false).cwtch.GetMessage(profileOnion, contactHandle, index);
|
var rawMessageEnvelopeFuture = Provider.of<FlwtchState>(context, listen: false).cwtch.GetMessage(profileOnion, conversationIdentifier, index);
|
||||||
return rawMessageEnvelopeFuture.then((dynamic rawMessageEnvelope) {
|
return rawMessageEnvelopeFuture.then((dynamic rawMessageEnvelope) {
|
||||||
var metadata = MessageMetadata(profileOnion, contactHandle, index, DateTime.now(), "", "", null, 0, false, true);
|
var metadata = MessageMetadata(profileOnion, conversationIdentifier, index, -1, DateTime.now(), "", "", null, 0, false, true);
|
||||||
try {
|
try {
|
||||||
dynamic messageWrapper = jsonDecode(rawMessageEnvelope);
|
dynamic messageWrapper = jsonDecode(rawMessageEnvelope);
|
||||||
// There are 2 conditions in which this error condition can be met:
|
// There are 2 conditions in which this error condition can be met:
|
||||||
|
@ -50,23 +50,20 @@ Future<Message> messageHandler(BuildContext context, String profileOnion, String
|
||||||
if (messageWrapper['Message'] == null || messageWrapper['Message'] == '' || messageWrapper['Message'] == '{}') {
|
if (messageWrapper['Message'] == null || messageWrapper['Message'] == '' || messageWrapper['Message'] == '{}') {
|
||||||
return Future.delayed(Duration(seconds: 2), () {
|
return Future.delayed(Duration(seconds: 2), () {
|
||||||
print("Tail recursive call to messageHandler called. This should be a rare event. If you see multiples of this log over a short period of time please log it as a bug.");
|
print("Tail recursive call to messageHandler called. This should be a rare event. If you see multiples of this log over a short period of time please log it as a bug.");
|
||||||
return messageHandler(context, profileOnion, contactHandle, index).then((value) => value);
|
return messageHandler(context, profileOnion, conversationIdentifier, index).then((value) => value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the initial metadata
|
// Construct the initial metadata
|
||||||
|
var messageID = messageWrapper['ID'];
|
||||||
var timestamp = DateTime.tryParse(messageWrapper['Timestamp'])!;
|
var timestamp = DateTime.tryParse(messageWrapper['Timestamp'])!;
|
||||||
var senderHandle = messageWrapper['PeerID'];
|
var senderHandle = messageWrapper['PeerID'];
|
||||||
var senderImage = messageWrapper['ContactImage'];
|
var senderImage = messageWrapper['ContactImage'];
|
||||||
var flags = int.parse(messageWrapper['Flags'].toString());
|
var flags = int.parse(messageWrapper['Flags'].toString());
|
||||||
var ackd = messageWrapper['Acknowledged'];
|
var ackd = messageWrapper['Acknowledged'];
|
||||||
var error = messageWrapper['Error'] != null;
|
var error = messageWrapper['Error'] != null;
|
||||||
String? signature;
|
var signature = messageWrapper['Signature'];
|
||||||
// If this is a group, store the signature
|
metadata = MessageMetadata(profileOnion, conversationIdentifier, index, messageID, timestamp, senderHandle, senderImage, signature, flags, ackd, error);
|
||||||
if (contactHandle.length == GroupConversationHandleLength) {
|
|
||||||
signature = messageWrapper['Signature'];
|
|
||||||
}
|
|
||||||
metadata = MessageMetadata(profileOnion, contactHandle, index, timestamp, senderHandle, senderImage, signature, flags, ackd, error);
|
|
||||||
|
|
||||||
dynamic message = jsonDecode(messageWrapper['Message']);
|
dynamic message = jsonDecode(messageWrapper['Message']);
|
||||||
var content = message['d'] as dynamic;
|
var content = message['d'] as dynamic;
|
||||||
|
@ -92,15 +89,16 @@ Future<Message> messageHandler(BuildContext context, String profileOnion, String
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Future.value(MalformedMessage(MessageMetadata(profileOnion, contactHandle, index, DateTime.now(), "", "", null, 0, false, true)));
|
return Future.value(MalformedMessage(MessageMetadata(profileOnion, conversationIdentifier, index, -1, DateTime.now(), "", "", null, 0, false, true)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MessageMetadata extends ChangeNotifier {
|
class MessageMetadata extends ChangeNotifier {
|
||||||
// meta-metadata
|
// meta-metadata
|
||||||
final String profileOnion;
|
final String profileOnion;
|
||||||
final String contactHandle;
|
final int conversationIdentifier;
|
||||||
final int messageIndex;
|
final int messageIndex;
|
||||||
|
final int messageID;
|
||||||
|
|
||||||
final DateTime timestamp;
|
final DateTime timestamp;
|
||||||
final String senderHandle;
|
final String senderHandle;
|
||||||
|
@ -129,5 +127,5 @@ class MessageMetadata extends ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageMetadata(this.profileOnion, this.contactHandle, this.messageIndex, this.timestamp, this.senderHandle, this.senderImage, this.signature, this._flags, this._ackd, this._error);
|
MessageMetadata(this.profileOnion, this.conversationIdentifier, this.messageIndex, this.messageID, this.timestamp, this.senderHandle, this.senderImage, this.signature, this._flags, this._ackd, this._error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ class FileMessage extends Message {
|
||||||
return ChangeNotifierProvider.value(
|
return ChangeNotifierProvider.value(
|
||||||
value: this.metadata,
|
value: this.metadata,
|
||||||
builder: (bcontext, child) {
|
builder: (bcontext, child) {
|
||||||
String idx = this.metadata.contactHandle + this.metadata.messageIndex.toString();
|
String idx = this.metadata.conversationIdentifier.toString() + this.metadata.messageID.toString();
|
||||||
dynamic shareObj = jsonDecode(this.content);
|
dynamic shareObj = jsonDecode(this.content);
|
||||||
if (shareObj == null) {
|
if (shareObj == null) {
|
||||||
return MessageRow(MalformedBubble());
|
return MessageRow(MalformedBubble());
|
||||||
|
|
|
@ -21,14 +21,14 @@ class InviteMessage extends Message {
|
||||||
return ChangeNotifierProvider.value(
|
return ChangeNotifierProvider.value(
|
||||||
value: this.metadata,
|
value: this.metadata,
|
||||||
builder: (bcontext, child) {
|
builder: (bcontext, child) {
|
||||||
String idx = this.metadata.contactHandle + this.metadata.messageIndex.toString();
|
String idx = this.metadata.conversationIdentifier.toString() + this.metadata.messageID.toString();
|
||||||
String inviteTarget;
|
String inviteTarget;
|
||||||
String inviteNick;
|
String inviteNick;
|
||||||
String invite = this.content;
|
String invite = this.content;
|
||||||
|
|
||||||
if (this.content.length == TorV3ContactHandleLength) {
|
if (this.content.length == TorV3ContactHandleLength) {
|
||||||
inviteTarget = this.content;
|
inviteTarget = this.content;
|
||||||
var targetContact = Provider.of<ProfileInfoState>(context).contactList.getContact(inviteTarget);
|
var targetContact = Provider.of<ProfileInfoState>(context).contactList.findContact(inviteTarget);
|
||||||
inviteNick = targetContact == null ? this.content : targetContact.nickname;
|
inviteNick = targetContact == null ? this.content : targetContact.nickname;
|
||||||
} else {
|
} else {
|
||||||
var parts = this.content.toString().split("||");
|
var parts = this.content.toString().split("||");
|
||||||
|
@ -54,7 +54,7 @@ class InviteMessage extends Message {
|
||||||
String invite = this.content;
|
String invite = this.content;
|
||||||
if (this.content.length == TorV3ContactHandleLength) {
|
if (this.content.length == TorV3ContactHandleLength) {
|
||||||
inviteTarget = this.content;
|
inviteTarget = this.content;
|
||||||
var targetContact = Provider.of<ProfileInfoState>(context).contactList.getContact(inviteTarget);
|
var targetContact = Provider.of<ProfileInfoState>(context).contactList.findContact(inviteTarget);
|
||||||
inviteNick = targetContact == null ? this.content : targetContact.nickname;
|
inviteNick = targetContact == null ? this.content : targetContact.nickname;
|
||||||
} else {
|
} else {
|
||||||
var parts = this.content.toString().split("||");
|
var parts = this.content.toString().split("||");
|
||||||
|
|
|
@ -70,7 +70,7 @@ class QuotedMessage extends Message {
|
||||||
return MalformedMessage(this.metadata).getWidget(context);
|
return MalformedMessage(this.metadata).getWidget(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
var quotedMessagePotentials = Provider.of<FlwtchState>(context).cwtch.GetMessageByContentHash(metadata.profileOnion, metadata.contactHandle, message["quotedHash"]);
|
var quotedMessagePotentials = Provider.of<FlwtchState>(context).cwtch.GetMessageByContentHash(metadata.profileOnion, metadata.conversationIdentifier, message["quotedHash"]);
|
||||||
int messageIndex = metadata.messageIndex;
|
int messageIndex = metadata.messageIndex;
|
||||||
Future<LocallyIndexedMessage?> quotedMessage = quotedMessagePotentials.then((matchingMessages) {
|
Future<LocallyIndexedMessage?> quotedMessage = quotedMessagePotentials.then((matchingMessages) {
|
||||||
if (matchingMessages == "[]") {
|
if (matchingMessages == "[]") {
|
||||||
|
@ -94,11 +94,11 @@ class QuotedMessage extends Message {
|
||||||
return ChangeNotifierProvider.value(
|
return ChangeNotifierProvider.value(
|
||||||
value: this.metadata,
|
value: this.metadata,
|
||||||
builder: (bcontext, child) {
|
builder: (bcontext, child) {
|
||||||
String idx = this.metadata.contactHandle + this.metadata.messageIndex.toString();
|
String idx = this.metadata.conversationIdentifier.toString() + this.metadata.messageID.toString();
|
||||||
return MessageRow(
|
return MessageRow(
|
||||||
QuotedMessageBubble(message["body"], quotedMessage.then((LocallyIndexedMessage? localIndex) {
|
QuotedMessageBubble(message["body"], quotedMessage.then((LocallyIndexedMessage? localIndex) {
|
||||||
if (localIndex != null) {
|
if (localIndex != null) {
|
||||||
return messageHandler(context, metadata.profileOnion, metadata.contactHandle, localIndex.index);
|
return messageHandler(context, metadata.profileOnion, metadata.conversationIdentifier, localIndex.index);
|
||||||
}
|
}
|
||||||
return MalformedMessage(this.metadata);
|
return MalformedMessage(this.metadata);
|
||||||
})),
|
})),
|
||||||
|
|
|
@ -32,7 +32,7 @@ class TextMessage extends Message {
|
||||||
return ChangeNotifierProvider.value(
|
return ChangeNotifierProvider.value(
|
||||||
value: this.metadata,
|
value: this.metadata,
|
||||||
builder: (bcontext, child) {
|
builder: (bcontext, child) {
|
||||||
String idx = this.metadata.contactHandle + this.metadata.messageIndex.toString();
|
String idx = this.metadata.conversationIdentifier.toString() + this.metadata.messageID.toString();
|
||||||
return MessageRow(MessageBubble(this.content), key: Provider.of<ContactInfoState>(bcontext).getMessageKey(idx));
|
return MessageRow(MessageBubble(this.content), key: Provider.of<ContactInfoState>(bcontext).getMessageKey(idx));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ class ContactsView extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
// selectConversation can be called from anywhere to set the active conversation
|
// selectConversation can be called from anywhere to set the active conversation
|
||||||
void selectConversation(BuildContext context, String handle) {
|
void selectConversation(BuildContext context, int handle) {
|
||||||
// requery instead of using contactinfostate directly because sometimes listview gets confused about data that resorts
|
// requery instead of using contactinfostate directly because sometimes listview gets confused about data that resorts
|
||||||
var initialIndex = Provider.of<ProfileInfoState>(context, listen: false).contactList.getContact(handle)!.unreadMessages;
|
var initialIndex = Provider.of<ProfileInfoState>(context, listen: false).contactList.getContact(handle)!.unreadMessages;
|
||||||
Provider.of<ProfileInfoState>(context, listen: false).contactList.getContact(handle)!.unreadMessages = 0;
|
Provider.of<ProfileInfoState>(context, listen: false).contactList.getContact(handle)!.unreadMessages = 0;
|
||||||
|
@ -36,7 +36,7 @@ void selectConversation(BuildContext context, String handle) {
|
||||||
if (Provider.of<Settings>(context, listen: false).uiColumns(isLandscape).length == 1) _pushMessageView(context, handle);
|
if (Provider.of<Settings>(context, listen: false).uiColumns(isLandscape).length == 1) _pushMessageView(context, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _pushMessageView(BuildContext context, String handle) {
|
void _pushMessageView(BuildContext context, int handle) {
|
||||||
var profileOnion = Provider.of<ProfileInfoState>(context, listen: false).onion;
|
var profileOnion = Provider.of<ProfileInfoState>(context, listen: false).onion;
|
||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
MaterialPageRoute<void>(
|
MaterialPageRoute<void>(
|
||||||
|
|
|
@ -34,8 +34,8 @@ class _DoubleColumnViewState extends State<DoubleColumnView> {
|
||||||
MultiProvider(providers: [
|
MultiProvider(providers: [
|
||||||
ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(context)),
|
ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(context)),
|
||||||
ChangeNotifierProvider.value(
|
ChangeNotifierProvider.value(
|
||||||
value: flwtch.selectedConversation != null ? Provider.of<ProfileInfoState>(context).contactList.getContact(flwtch.selectedConversation!)! : ContactInfoState("", "")),
|
value: flwtch.selectedConversation != null ? Provider.of<ProfileInfoState>(context).contactList.getContact(flwtch.selectedConversation!)! : ContactInfoState("", -1, "")),
|
||||||
], child: Container(key: Key(flwtch.selectedConversation??"never_this"), child: MessageView())),
|
], child: Container(key: Key(flwtch.selectedConversation!.toString()), child: MessageView())),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
|
@ -78,9 +78,9 @@ class _GroupSettingsViewState extends State<GroupSettingsView> {
|
||||||
readonly: false,
|
readonly: false,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
||||||
var handle = Provider.of<ContactInfoState>(context, listen: false).onion;
|
var handle = Provider.of<ContactInfoState>(context, listen: false).identifier;
|
||||||
Provider.of<ContactInfoState>(context, listen: false).nickname = ctrlrNick.text;
|
Provider.of<ContactInfoState>(context, listen: false).nickname = ctrlrNick.text;
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.SetGroupAttribute(profileOnion, handle, "local.name", ctrlrNick.text);
|
Provider.of<FlwtchState>(context, listen: false).cwtch.SetConversationAttribute(profileOnion, handle, "local.name", ctrlrNick.text);
|
||||||
// todo translations
|
// todo translations
|
||||||
final snackBar = SnackBar(content: Text("Group Nickname changed successfully"));
|
final snackBar = SnackBar(content: Text("Group Nickname changed successfully"));
|
||||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||||
|
@ -140,7 +140,7 @@ class _GroupSettingsViewState extends State<GroupSettingsView> {
|
||||||
child: ElevatedButton.icon(
|
child: ElevatedButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
||||||
var handle = Provider.of<ContactInfoState>(context, listen: false).onion;
|
var handle = Provider.of<ContactInfoState>(context, listen: false).identifier;
|
||||||
// locally update cache...
|
// locally update cache...
|
||||||
Provider.of<ContactInfoState>(context, listen: false).isArchived = true;
|
Provider.of<ContactInfoState>(context, listen: false).isArchived = true;
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.ArchiveConversation(profileOnion, handle);
|
Provider.of<FlwtchState>(context, listen: false).cwtch.ArchiveConversation(profileOnion, handle);
|
||||||
|
@ -195,7 +195,7 @@ class _GroupSettingsViewState extends State<GroupSettingsView> {
|
||||||
child: Text(AppLocalizations.of(context)!.yesLeave),
|
child: Text(AppLocalizations.of(context)!.yesLeave),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
||||||
var handle = Provider.of<ContactInfoState>(context, listen: false).onion;
|
var handle = Provider.of<ContactInfoState>(context, listen: false).identifier;
|
||||||
// locally update cache...
|
// locally update cache...
|
||||||
Provider.of<ContactInfoState>(context, listen: false).isArchived = true;
|
Provider.of<ContactInfoState>(context, listen: false).isArchived = true;
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.DeleteContact(profileOnion, handle);
|
Provider.of<FlwtchState>(context, listen: false).cwtch.DeleteContact(profileOnion, handle);
|
||||||
|
|
|
@ -33,7 +33,7 @@ class MessageView extends StatefulWidget {
|
||||||
class _MessageViewState extends State<MessageView> {
|
class _MessageViewState extends State<MessageView> {
|
||||||
final ctrlrCompose = TextEditingController();
|
final ctrlrCompose = TextEditingController();
|
||||||
final focusNode = FocusNode();
|
final focusNode = FocusNode();
|
||||||
String selectedContact = "";
|
int selectedContact = -1;
|
||||||
ItemPositionsListener scrollListener = ItemPositionsListener.create();
|
ItemPositionsListener scrollListener = ItemPositionsListener.create();
|
||||||
ItemScrollController scrollController = ItemScrollController();
|
ItemScrollController scrollController = ItemScrollController();
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ class _MessageViewState extends State<MessageView> {
|
||||||
ChatMessage cm = new ChatMessage(o: QuotedMessageOverlay, d: quotedMessage);
|
ChatMessage cm = new ChatMessage(o: QuotedMessageOverlay, d: quotedMessage);
|
||||||
Provider.of<FlwtchState>(context, listen: false)
|
Provider.of<FlwtchState>(context, listen: false)
|
||||||
.cwtch
|
.cwtch
|
||||||
.SendMessage(Provider.of<ContactInfoState>(context, listen: false).profileOnion, Provider.of<ContactInfoState>(context, listen: false).onion, jsonEncode(cm));
|
.SendMessage(Provider.of<ContactInfoState>(context, listen: false).profileOnion, Provider.of<ContactInfoState>(context, listen: false).identifier, jsonEncode(cm));
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
Provider.of<AppState>(context, listen: false).selectedIndex = null;
|
Provider.of<AppState>(context, listen: false).selectedIndex = null;
|
||||||
_sendMessageHelper();
|
_sendMessageHelper();
|
||||||
|
@ -189,7 +189,7 @@ class _MessageViewState extends State<MessageView> {
|
||||||
ChatMessage cm = new ChatMessage(o: TextMessageOverlay, d: ctrlrCompose.value.text);
|
ChatMessage cm = new ChatMessage(o: TextMessageOverlay, d: ctrlrCompose.value.text);
|
||||||
Provider.of<FlwtchState>(context, listen: false)
|
Provider.of<FlwtchState>(context, listen: false)
|
||||||
.cwtch
|
.cwtch
|
||||||
.SendMessage(Provider.of<ContactInfoState>(context, listen: false).profileOnion, Provider.of<ContactInfoState>(context, listen: false).onion, jsonEncode(cm));
|
.SendMessage(Provider.of<ContactInfoState>(context, listen: false).profileOnion, Provider.of<ContactInfoState>(context, listen: false).identifier, jsonEncode(cm));
|
||||||
_sendMessageHelper();
|
_sendMessageHelper();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,14 +198,14 @@ class _MessageViewState extends State<MessageView> {
|
||||||
void _sendInvitation([String? ignoredParam]) {
|
void _sendInvitation([String? ignoredParam]) {
|
||||||
Provider.of<FlwtchState>(context, listen: false)
|
Provider.of<FlwtchState>(context, listen: false)
|
||||||
.cwtch
|
.cwtch
|
||||||
.SendInvitation(Provider.of<ContactInfoState>(context, listen: false).profileOnion, Provider.of<ContactInfoState>(context, listen: false).onion, this.selectedContact);
|
.SendInvitation(Provider.of<ContactInfoState>(context, listen: false).profileOnion, Provider.of<ContactInfoState>(context, listen: false).identifier, this.selectedContact);
|
||||||
_sendMessageHelper();
|
_sendMessageHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _sendFile(String filePath) {
|
void _sendFile(String filePath) {
|
||||||
Provider.of<FlwtchState>(context, listen: false)
|
Provider.of<FlwtchState>(context, listen: false)
|
||||||
.cwtch
|
.cwtch
|
||||||
.ShareFile(Provider.of<ContactInfoState>(context, listen: false).profileOnion, Provider.of<ContactInfoState>(context, listen: false).onion, filePath);
|
.ShareFile(Provider.of<ContactInfoState>(context, listen: false).profileOnion, Provider.of<ContactInfoState>(context, listen: false).identifier, filePath);
|
||||||
_sendMessageHelper();
|
_sendMessageHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ class _MessageViewState extends State<MessageView> {
|
||||||
Provider.of<ContactInfoState>(context, listen: false).totalMessages++;
|
Provider.of<ContactInfoState>(context, listen: false).totalMessages++;
|
||||||
Provider.of<ContactInfoState>(context, listen: false).newMarker++;
|
Provider.of<ContactInfoState>(context, listen: false).newMarker++;
|
||||||
// Resort the contact list...
|
// Resort the contact list...
|
||||||
Provider.of<ProfileInfoState>(context, listen: false).contactList.updateLastMessageTime(Provider.of<ContactInfoState>(context, listen: false).onion, DateTime.now());
|
Provider.of<ProfileInfoState>(context, listen: false).contactList.updateLastMessageTime(Provider.of<ContactInfoState>(context, listen: false).identifier, DateTime.now());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ class _PeerSettingsViewState extends State<PeerSettingsView> {
|
||||||
child: ElevatedButton.icon(
|
child: ElevatedButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
||||||
var handle = Provider.of<ContactInfoState>(context, listen: false).onion;
|
var handle = Provider.of<ContactInfoState>(context, listen: false).identifier;
|
||||||
// locally update cache...
|
// locally update cache...
|
||||||
Provider.of<ContactInfoState>(context, listen: false).isArchived = true;
|
Provider.of<ContactInfoState>(context, listen: false).isArchived = true;
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.ArchiveConversation(profileOnion, handle);
|
Provider.of<FlwtchState>(context, listen: false).cwtch.ArchiveConversation(profileOnion, handle);
|
||||||
|
@ -239,7 +239,7 @@ class _PeerSettingsViewState extends State<PeerSettingsView> {
|
||||||
child: Text(AppLocalizations.of(context)!.yesLeave),
|
child: Text(AppLocalizations.of(context)!.yesLeave),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
var profileOnion = Provider.of<ContactInfoState>(context, listen: false).profileOnion;
|
||||||
var handle = Provider.of<ContactInfoState>(context, listen: false).onion;
|
var handle = Provider.of<ContactInfoState>(context, listen: false).identifier;
|
||||||
// locally update cache...
|
// locally update cache...
|
||||||
Provider.of<ContactInfoState>(context, listen: false).isArchived = true;
|
Provider.of<ContactInfoState>(context, listen: false).isArchived = true;
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.DeleteContact(profileOnion, handle);
|
Provider.of<FlwtchState>(context, listen: false).cwtch.DeleteContact(profileOnion, handle);
|
||||||
|
|
|
@ -105,7 +105,7 @@ class _ContactRowState extends State<ContactRow> {
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
selectConversation(context, contact.onion);
|
selectConversation(context, contact.identifier);
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -113,16 +113,16 @@ class _ContactRowState extends State<ContactRow> {
|
||||||
void _btnApprove() {
|
void _btnApprove() {
|
||||||
Provider.of<FlwtchState>(context, listen: false)
|
Provider.of<FlwtchState>(context, listen: false)
|
||||||
.cwtch
|
.cwtch
|
||||||
.AcceptContact(Provider.of<ContactInfoState>(context, listen: false).profileOnion, Provider.of<ContactInfoState>(context, listen: false).onion);
|
.AcceptContact(Provider.of<ContactInfoState>(context, listen: false).profileOnion, Provider.of<ContactInfoState>(context, listen: false).identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _btnReject() {
|
void _btnReject() {
|
||||||
ContactInfoState contact = Provider.of<ContactInfoState>(context, listen: false);
|
ContactInfoState contact = Provider.of<ContactInfoState>(context, listen: false);
|
||||||
if (contact.isGroup == true) {
|
if (contact.isGroup == true) {
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.RejectInvite(Provider.of<ContactInfoState>(context, listen: false).profileOnion, contact.onion);
|
Provider.of<FlwtchState>(context, listen: false).cwtch.RejectInvite(Provider.of<ContactInfoState>(context, listen: false).profileOnion, contact.identifier);
|
||||||
Provider.of<ProfileInfoState>(context, listen: false).removeContact(contact.onion);
|
Provider.of<ProfileInfoState>(context, listen: false).removeContact(contact.onion);
|
||||||
} else {
|
} else {
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.BlockContact(Provider.of<ContactInfoState>(context, listen: false).profileOnion, contact.onion);
|
Provider.of<FlwtchState>(context, listen: false).cwtch.BlockContact(Provider.of<ContactInfoState>(context, listen: false).profileOnion, contact.identifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
// If the sender is not us, then we want to give them a nickname...
|
// If the sender is not us, then we want to give them a nickname...
|
||||||
var senderDisplayStr = "";
|
var senderDisplayStr = "";
|
||||||
if (!fromMe) {
|
if (!fromMe) {
|
||||||
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.getContact(Provider.of<MessageMetadata>(context).senderHandle);
|
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle);
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
senderDisplayStr = contact.nickname;
|
senderDisplayStr = contact.nickname;
|
||||||
} else {
|
} else {
|
||||||
|
@ -152,9 +152,16 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
|
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
Provider.of<ProfileInfoState>(context, listen: false).downloadInit(widget.fileKey(), (widget.fileSize / 4096).ceil());
|
Provider.of<ProfileInfoState>(context, listen: false).downloadInit(widget.fileKey(), (widget.fileSize / 4096).ceil());
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.UpdateMessageFlags(profileOnion, contact, idx, Provider.of<MessageMetadata>(context, listen: false).flags | 0x02);
|
//Provider.of<FlwtchState>(context, listen: false).cwtch.UpdateMessageFlags(profileOnion, contact, idx, Provider.of<MessageMetadata>(context, listen: false).flags | 0x02);
|
||||||
Provider.of<MessageMetadata>(context, listen: false).flags |= 0x02;
|
Provider.of<MessageMetadata>(context, listen: false).flags |= 0x02;
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.CreateDownloadableFile(profileOnion, handle, widget.nameSuggestion, widget.fileKey());
|
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle);
|
||||||
|
if (contact != null) {
|
||||||
|
Provider
|
||||||
|
.of<FlwtchState>(context, listen: false)
|
||||||
|
.cwtch
|
||||||
|
.CreateDownloadableFile(
|
||||||
|
profileOnion, contact.identifier, widget.nameSuggestion, widget.fileKey());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
selectedFileName = await saveFile(
|
selectedFileName = await saveFile(
|
||||||
|
@ -165,9 +172,16 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
print("saving to " + file.path);
|
print("saving to " + file.path);
|
||||||
var manifestPath = file.path + ".manifest";
|
var manifestPath = file.path + ".manifest";
|
||||||
Provider.of<ProfileInfoState>(context, listen: false).downloadInit(widget.fileKey(), (widget.fileSize / 4096).ceil());
|
Provider.of<ProfileInfoState>(context, listen: false).downloadInit(widget.fileKey(), (widget.fileSize / 4096).ceil());
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.UpdateMessageFlags(profileOnion, contact, idx, Provider.of<MessageMetadata>(context, listen: false).flags | 0x02);
|
//Provider.of<FlwtchState>(context, listen: false).cwtch.UpdateMessageFlags(profileOnion, contact, idx, Provider.of<MessageMetadata>(context, listen: false).flags | 0x02);
|
||||||
Provider.of<MessageMetadata>(context, listen: false).flags |= 0x02;
|
Provider.of<MessageMetadata>(context, listen: false).flags |= 0x02;
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.DownloadFile(profileOnion, handle, file.path, manifestPath, widget.fileKey());
|
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle);
|
||||||
|
if (contact != null) {
|
||||||
|
Provider
|
||||||
|
.of<FlwtchState>(context, listen: false)
|
||||||
|
.cwtch
|
||||||
|
.DownloadFile(profileOnion, contact.identifier, file.path, manifestPath,
|
||||||
|
widget.fileKey());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(e);
|
print(e);
|
||||||
|
@ -177,7 +191,7 @@ class FileBubbleState extends State<FileBubble> {
|
||||||
|
|
||||||
void _btnResume() async {
|
void _btnResume() async {
|
||||||
var profileOnion = Provider.of<ProfileInfoState>(context, listen: false).onion;
|
var profileOnion = Provider.of<ProfileInfoState>(context, listen: false).onion;
|
||||||
var handle = Provider.of<MessageMetadata>(context, listen: false).senderHandle;
|
var handle = Provider.of<MessageMetadata>(context, listen: false).conversationIdentifier;
|
||||||
Provider.of<ProfileInfoState>(context, listen: false).downloadMarkResumed(widget.fileKey());
|
Provider.of<ProfileInfoState>(context, listen: false).downloadMarkResumed(widget.fileKey());
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.VerifyOrResumeDownload(profileOnion, handle, widget.fileKey());
|
Provider.of<FlwtchState>(context, listen: false).cwtch.VerifyOrResumeDownload(profileOnion, handle, widget.fileKey());
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ class InvitationBubbleState extends State<InvitationBubble> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var fromMe = Provider.of<MessageMetadata>(context).senderHandle == Provider.of<ProfileInfoState>(context).onion;
|
var fromMe = Provider.of<MessageMetadata>(context).senderHandle == Provider.of<ProfileInfoState>(context).onion;
|
||||||
var isGroup = widget.overlay == InviteGroupOverlay;
|
var isGroup = widget.overlay == InviteGroupOverlay;
|
||||||
isAccepted = Provider.of<ProfileInfoState>(context).contactList.getContact(widget.inviteTarget) != null;
|
isAccepted = Provider.of<ProfileInfoState>(context).contactList.findContact(widget.inviteTarget) != null;
|
||||||
var borderRadiousEh = 15.0;
|
var borderRadiousEh = 15.0;
|
||||||
var showGroupInvite = Provider.of<Settings>(context).isExperimentEnabled(TapirGroupsExperiment);
|
var showGroupInvite = Provider.of<Settings>(context).isExperimentEnabled(TapirGroupsExperiment);
|
||||||
rejected = Provider.of<MessageMetadata>(context).flags & 0x01 == 0x01;
|
rejected = Provider.of<MessageMetadata>(context).flags & 0x01 == 0x01;
|
||||||
|
@ -45,7 +45,7 @@ class InvitationBubbleState extends State<InvitationBubble> {
|
||||||
// If the sender is not us, then we want to give them a nickname...
|
// If the sender is not us, then we want to give them a nickname...
|
||||||
var senderDisplayStr = "";
|
var senderDisplayStr = "";
|
||||||
if (!fromMe) {
|
if (!fromMe) {
|
||||||
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.getContact(Provider.of<MessageMetadata>(context).senderHandle);
|
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle);
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
senderDisplayStr = contact.nickname;
|
senderDisplayStr = contact.nickname;
|
||||||
} else {
|
} else {
|
||||||
|
@ -69,7 +69,7 @@ class InvitationBubbleState extends State<InvitationBubble> {
|
||||||
? Text(AppLocalizations.of(context)!.groupInviteSettingsWarning)
|
? Text(AppLocalizations.of(context)!.groupInviteSettingsWarning)
|
||||||
: fromMe
|
: fromMe
|
||||||
? senderInviteChrome(
|
? senderInviteChrome(
|
||||||
AppLocalizations.of(context)!.sendAnInvitation, isGroup ? Provider.of<ProfileInfoState>(context).contactList.getContact(widget.inviteTarget)!.nickname : widget.inviteTarget)
|
AppLocalizations.of(context)!.sendAnInvitation, isGroup ? Provider.of<ProfileInfoState>(context).contactList.findContact(widget.inviteTarget)!.nickname : widget.inviteTarget)
|
||||||
: (inviteChrome(isGroup ? AppLocalizations.of(context)!.inviteToGroup : AppLocalizations.of(context)!.contactSuggestion, widget.inviteNick, widget.inviteTarget));
|
: (inviteChrome(isGroup ? AppLocalizations.of(context)!.inviteToGroup : AppLocalizations.of(context)!.contactSuggestion, widget.inviteNick, widget.inviteTarget));
|
||||||
|
|
||||||
Widget wdgDecorations;
|
Widget wdgDecorations;
|
||||||
|
@ -130,7 +130,7 @@ class InvitationBubbleState extends State<InvitationBubble> {
|
||||||
var profileOnion = Provider.of<ProfileInfoState>(context, listen: false).onion;
|
var profileOnion = Provider.of<ProfileInfoState>(context, listen: false).onion;
|
||||||
var contact = Provider.of<ContactInfoState>(context, listen: false).onion;
|
var contact = Provider.of<ContactInfoState>(context, listen: false).onion;
|
||||||
var idx = Provider.of<MessageMetadata>(context, listen: false).messageIndex;
|
var idx = Provider.of<MessageMetadata>(context, listen: false).messageIndex;
|
||||||
Provider.of<FlwtchState>(context, listen: false).cwtch.UpdateMessageFlags(profileOnion, contact, idx, Provider.of<MessageMetadata>(context, listen: false).flags | 0x01);
|
//Provider.of<FlwtchState>(context, listen: false).cwtch.UpdateMessageFlags(profileOnion, contact, idx, Provider.of<MessageMetadata>(context, listen: false).flags | 0x01);
|
||||||
Provider.of<MessageMetadata>(context, listen: false).flags |= 0x01;
|
Provider.of<MessageMetadata>(context, listen: false).flags |= 0x01;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class MessageBubbleState extends State<MessageBubble> {
|
||||||
// If the sender is not us, then we want to give them a nickname...
|
// If the sender is not us, then we want to give them a nickname...
|
||||||
var senderDisplayStr = "";
|
var senderDisplayStr = "";
|
||||||
if (!fromMe) {
|
if (!fromMe) {
|
||||||
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.getContact(Provider.of<MessageMetadata>(context).senderHandle);
|
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle);
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
senderDisplayStr = contact.nickname;
|
senderDisplayStr = contact.nickname;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -76,8 +76,8 @@ class _MessageListState extends State<MessageList> {
|
||||||
reverse: true, // NOTE: There seems to be a bug in flutter that corrects the mouse wheel scroll, but not the drag direction...
|
reverse: true, // NOTE: There seems to be a bug in flutter that corrects the mouse wheel scroll, but not the drag direction...
|
||||||
itemBuilder: (itemBuilderContext, index) {
|
itemBuilder: (itemBuilderContext, index) {
|
||||||
var profileOnion = Provider.of<ProfileInfoState>(outerContext, listen: false).onion;
|
var profileOnion = Provider.of<ProfileInfoState>(outerContext, listen: false).onion;
|
||||||
var contactHandle = Provider.of<ContactInfoState>(outerContext, listen: false).onion;
|
var contactHandle = Provider.of<ContactInfoState>(outerContext, listen: false).identifier;
|
||||||
var messageIndex = Provider.of<ContactInfoState>(outerContext).totalMessages - index - 1;
|
var messageIndex = index;
|
||||||
|
|
||||||
return FutureBuilder(
|
return FutureBuilder(
|
||||||
future: messageHandler(outerContext, profileOnion, contactHandle, messageIndex),
|
future: messageHandler(outerContext, profileOnion, contactHandle, messageIndex),
|
||||||
|
|
|
@ -48,8 +48,8 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var fromMe = Provider.of<MessageMetadata>(context).senderHandle == Provider.of<ProfileInfoState>(context).onion;
|
var fromMe = Provider.of<MessageMetadata>(context).senderHandle == Provider.of<ProfileInfoState>(context).onion;
|
||||||
var isContact = Provider.of<ProfileInfoState>(context).contactList.getContact(Provider.of<MessageMetadata>(context).senderHandle) != null;
|
var isContact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle) != null;
|
||||||
var isBlocked = isContact ? Provider.of<ProfileInfoState>(context).contactList.getContact(Provider.of<MessageMetadata>(context).senderHandle)!.isBlocked : false;
|
var isBlocked = isContact ? Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle)!.isBlocked : false;
|
||||||
var actualMessage = Flexible(flex: 3, fit: FlexFit.loose, child: widget.child);
|
var actualMessage = Flexible(flex: 3, fit: FlexFit.loose, child: widget.child);
|
||||||
|
|
||||||
_dragAffinity = fromMe ? Alignment.centerRight : Alignment.centerLeft;
|
_dragAffinity = fromMe ? Alignment.centerRight : Alignment.centerLeft;
|
||||||
|
@ -60,7 +60,7 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
|
||||||
|
|
||||||
var senderDisplayStr = "";
|
var senderDisplayStr = "";
|
||||||
if (!fromMe) {
|
if (!fromMe) {
|
||||||
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.getContact(Provider.of<MessageMetadata>(context).senderHandle);
|
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle);
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
senderDisplayStr = contact.nickname;
|
senderDisplayStr = contact.nickname;
|
||||||
} else {
|
} else {
|
||||||
|
@ -249,7 +249,7 @@ class MessageRowState extends State<MessageRow> with SingleTickerProviderStateMi
|
||||||
}
|
}
|
||||||
|
|
||||||
void _btnGoto() {
|
void _btnGoto() {
|
||||||
selectConversation(context, Provider.of<MessageMetadata>(context, listen: false).senderHandle);
|
selectConversation(context, Provider.of<MessageMetadata>(context, listen: false).conversationIdentifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _btnAdd() {
|
void _btnAdd() {
|
||||||
|
|
|
@ -34,7 +34,7 @@ class QuotedMessageBubbleState extends State<QuotedMessageBubble> {
|
||||||
// If the sender is not us, then we want to give them a nickname...
|
// If the sender is not us, then we want to give them a nickname...
|
||||||
var senderDisplayStr = "";
|
var senderDisplayStr = "";
|
||||||
if (!fromMe) {
|
if (!fromMe) {
|
||||||
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.getContact(Provider.of<MessageMetadata>(context).senderHandle);
|
ContactInfoState? contact = Provider.of<ProfileInfoState>(context).contactList.findContact(Provider.of<MessageMetadata>(context).senderHandle);
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
senderDisplayStr = contact.nickname;
|
senderDisplayStr = contact.nickname;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue