logging prune

This commit is contained in:
erinn 2021-06-24 22:18:01 -07:00
parent c9ee0a4473
commit 1b25dda075
3 changed files with 9 additions and 14 deletions

View File

@ -57,7 +57,6 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
Log.i("FlwtchWorker.kt", "startCwtch success, starting coroutine AppbusEvent loop...") Log.i("FlwtchWorker.kt", "startCwtch success, starting coroutine AppbusEvent loop...")
while(true) { while(true) {
Log.i("FlwtchWorker.kt", "while(true)getAppbusEvent()")
val evt = MainActivity.AppbusEvent(Cwtch.getAppBusEvent()) val evt = MainActivity.AppbusEvent(Cwtch.getAppBusEvent())
if (evt.EventType == "NewMessageFromPeer" || evt.EventType == "NewMessageFromGroup") { if (evt.EventType == "NewMessageFromPeer" || evt.EventType == "NewMessageFromGroup") {
val data = JSONObject(evt.Data) val data = JSONObject(evt.Data)
@ -119,7 +118,6 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) :
val profile = (a.get("profile") as? String) ?: "" val profile = (a.get("profile") as? String) ?: ""
val handle = (a.get("contact") as? String) ?: "" val handle = (a.get("contact") as? String) ?: ""
val indexI = a.getInt("index") val indexI = a.getInt("index")
Log.i("FlwtchWorker.kt", "indexI = $indexI")
return Result.success(Data.Builder().putString("result", Cwtch.getMessage(profile, handle, indexI.toLong())).build()) return Result.success(Data.Builder().putString("result", Cwtch.getMessage(profile, handle, indexI.toLong())).build())
} }
"UpdateMessageFlags" -> { "UpdateMessageFlags" -> {

View File

@ -150,7 +150,7 @@ class CwtchNotifier {
profileCN.getProfile(data["Identity"])?.contactList.getContact(contactHandle)!.totalMessages = int.parse(data["Data"]); profileCN.getProfile(data["Identity"])?.contactList.getContact(contactHandle)!.totalMessages = int.parse(data["Data"]);
break; break;
case "IndexedFailure": case "IndexedFailure":
print("IndexedFailure: $data"); print("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.getContact(data["RemotePeer"])!.getMessageKey(idx);
try { try {
@ -162,7 +162,7 @@ class CwtchNotifier {
break; break;
case "SendMessageToGroupError": case "SendMessageToGroupError":
// from me (already displayed - do not update counter) // from me (already displayed - do not update counter)
print("SendMessageToGroupError: $data"); print("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.getContact(data["GroupID"])!.getMessageKey(idx);
if (key == null) break; if (key == null) break;
@ -190,7 +190,7 @@ class CwtchNotifier {
if (data["Key"] == "public.name") { if (data["Key"] == "public.name") {
profileCN.getProfile(data["ProfileOnion"])?.nickname = data["Data"]; profileCN.getProfile(data["ProfileOnion"])?.nickname = data["Data"];
} else { } else {
print("unhandled set attribute event: $type $data"); print("unhandled set attribute event: ${data['Key']}");
} }
break; break;
case "NetworkError": case "NetworkError":
@ -209,18 +209,16 @@ class CwtchNotifier {
profileCN.getProfile(data["ProfileOnion"])?.replaceServers(data["ServerList"]); profileCN.getProfile(data["ProfileOnion"])?.replaceServers(data["ServerList"]);
break; break;
case "NewGroup": case "NewGroup":
print("new group: $data"); print("new group");
String invite = data["GroupInvite"].toString(); String invite = data["GroupInvite"].toString();
if (invite.startsWith("torv3")) { if (invite.startsWith("torv3")) {
String inviteJson = new String.fromCharCodes(base64Decode(invite.substring(5))); String inviteJson = new String.fromCharCodes(base64Decode(invite.substring(5)));
dynamic groupInvite = jsonDecode(inviteJson); dynamic groupInvite = jsonDecode(inviteJson);
print("group invite: $groupInvite");
// Retrieve Server Status from Cache... // Retrieve Server Status from Cache...
String status = ""; String status = "";
ServerInfoState? serverInfoState = profileCN.getProfile(data["ProfileOnion"])!.serverList.getServer(groupInvite["ServerHost"]); ServerInfoState? serverInfoState = profileCN.getProfile(data["ProfileOnion"])!.serverList.getServer(groupInvite["ServerHost"]);
if (serverInfoState != null) { if (serverInfoState != null) {
print("Got server status: " + serverInfoState.status);
status = serverInfoState.status; status = serverInfoState.status;
} }
@ -238,13 +236,12 @@ class CwtchNotifier {
} }
break; break;
case "AcceptGroupInvite": case "AcceptGroupInvite":
print("accept group invite: $data"); print("accept group invite");
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])!.isInvitation = false; profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])!.isInvitation = false;
profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(data["GroupID"], DateTime.now()); profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(data["GroupID"], DateTime.now());
break; break;
case "ServerStateChange": case "ServerStateChange":
print("server state change: $data");
// Update the Server Cache // Update the Server Cache
profileCN.getProfile(data["ProfileOnion"])?.updateServerStatusCache(data["GroupServer"], data["ConnectionState"]); profileCN.getProfile(data["ProfileOnion"])?.updateServerStatusCache(data["GroupServer"], data["ConnectionState"]);
profileCN.getProfile(data["ProfileOnion"])?.contactList.contacts.forEach((contact) { profileCN.getProfile(data["ProfileOnion"])?.contactList.contacts.forEach((contact) {
@ -260,7 +257,7 @@ class CwtchNotifier {
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])!.nickname = data["Data"]; profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])!.nickname = data["Data"];
} }
} else { } else {
print("unhandled set group attribute event: $type $data"); print("unhandled set group attribute event: ${data['Key']}");
} }
break; break;
case "NewRetValMessageFromPeer": case "NewRetValMessageFromPeer":
@ -270,11 +267,11 @@ class CwtchNotifier {
profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.nickname = data["Data"]; profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.nickname = data["Data"];
} }
} else { } else {
print("unhandled peer attribute event: $type $data"); print("unhandled peer attribute event: ${data['Path']}");
} }
break; break;
default: default:
print("unhandled event: $type $data"); print("unhandled event: $type");
} }
} }
} }

View File

@ -227,7 +227,7 @@ class ProfileInfoState extends ChangeNotifier {
// Parse out the server list json into our server info state struct... // Parse out the server list json into our server info state struct...
void replaceServers(String serversJson) { void replaceServers(String serversJson) {
if (serversJson != "" && serversJson != "null") { if (serversJson != "" && serversJson != "null") {
print("got servers $serversJson"); print("got serversJson");
List<dynamic> servers = jsonDecode(serversJson); List<dynamic> servers = jsonDecode(serversJson);
this._servers.replace(servers.map((server) { this._servers.replace(servers.map((server) {
// TODO Keys... // TODO Keys...