diff --git a/LIBCWTCH-GO.version b/LIBCWTCH-GO.version index cbba9836..e715548d 100644 --- a/LIBCWTCH-GO.version +++ b/LIBCWTCH-GO.version @@ -1 +1 @@ -v0.0.2-108-g3964348-2021-06-24-17-42 \ No newline at end of file +v1.0.0-5-g2bf1adb-2021-06-25-05-26 \ No newline at end of file diff --git a/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt b/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt index 3936ecc1..08d60cc8 100644 --- a/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt +++ b/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt @@ -57,7 +57,6 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) : Log.i("FlwtchWorker.kt", "startCwtch success, starting coroutine AppbusEvent loop...") while(true) { - Log.i("FlwtchWorker.kt", "while(true)getAppbusEvent()") val evt = MainActivity.AppbusEvent(Cwtch.getAppBusEvent()) if (evt.EventType == "NewMessageFromPeer" || evt.EventType == "NewMessageFromGroup") { val data = JSONObject(evt.Data) @@ -119,7 +118,6 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) : val profile = (a.get("profile") as? String) ?: "" val handle = (a.get("contact") as? String) ?: "" 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()) } "UpdateMessageFlags" -> { diff --git a/lib/config.dart b/lib/config.dart index 7d0c4b8d..ea9faaef 100644 --- a/lib/config.dart +++ b/lib/config.dart @@ -3,4 +3,10 @@ const dev_version = "development"; class EnvironmentConfig { static const BUILD_VER = String.fromEnvironment('BUILD_VER', defaultValue: dev_version); static const BUILD_DATE = String.fromEnvironment('BUILD_DATE', defaultValue: "now"); + + static void debugLog(String log) { + if (EnvironmentConfig.BUILD_VER == dev_version) { + print(log); + } + } } diff --git a/lib/cwtch/cwtchNotifier.dart b/lib/cwtch/cwtchNotifier.dart index ce52a441..a6e15b91 100644 --- a/lib/cwtch/cwtchNotifier.dart +++ b/lib/cwtch/cwtchNotifier.dart @@ -5,6 +5,7 @@ import 'package:provider/provider.dart'; import 'package:cwtch/torstatus.dart'; +import '../config.dart'; import '../errorHandler.dart'; import '../model.dart'; import '../settings.dart'; @@ -150,7 +151,7 @@ class CwtchNotifier { profileCN.getProfile(data["Identity"])?.contactList.getContact(contactHandle)!.totalMessages = int.parse(data["Data"]); break; case "IndexedFailure": - print("IndexedFailure: $data"); + EnvironmentConfig.debugLog("IndexedFailure"); var idx = data["Index"]; var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.getMessageKey(idx); try { @@ -162,7 +163,7 @@ class CwtchNotifier { break; case "SendMessageToGroupError": // from me (already displayed - do not update counter) - print("SendMessageToGroupError: $data"); + EnvironmentConfig.debugLog("SendMessageToGroupError"); var idx = data["Signature"]; var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])!.getMessageKey(idx); if (key == null) break; @@ -175,7 +176,7 @@ class CwtchNotifier { } break; case "AppError": - print("New App Error: $data"); + EnvironmentConfig.debugLog("New App Error: $data"); // special case for delete error (todo: standardize cwtch errors) if (data["Error"] == "Password did not match") { error.handleUpdate("deleteprofile.error"); @@ -190,7 +191,7 @@ class CwtchNotifier { if (data["Key"] == "public.name") { profileCN.getProfile(data["ProfileOnion"])?.nickname = data["Data"]; } else { - print("unhandled set attribute event: $type $data"); + EnvironmentConfig.debugLog("unhandled set attribute event: ${data['Key']}"); } break; case "NetworkError": @@ -198,29 +199,27 @@ class CwtchNotifier { profileCN.getProfile(data["ProfileOnion"])?.isOnline = isOnline; break; case "ACNStatus": - print("acn status: $data"); + EnvironmentConfig.debugLog("acn status: $data"); torStatus.handleUpdate(int.parse(data["Progress"]), data["Status"]); break; case "ACNVersion": - print("acn version: $data"); + EnvironmentConfig.debugLog("acn version: $data"); torStatus.updateVersion(data["Data"]); break; case "UpdateServerInfo": profileCN.getProfile(data["ProfileOnion"])?.replaceServers(data["ServerList"]); break; case "NewGroup": - print("new group: $data"); + EnvironmentConfig.debugLog("new group"); String invite = data["GroupInvite"].toString(); if (invite.startsWith("torv3")) { String inviteJson = new String.fromCharCodes(base64Decode(invite.substring(5))); dynamic groupInvite = jsonDecode(inviteJson); - print("group invite: $groupInvite"); // Retrieve Server Status from Cache... String status = ""; ServerInfoState? serverInfoState = profileCN.getProfile(data["ProfileOnion"])!.serverList.getServer(groupInvite["ServerHost"]); if (serverInfoState != null) { - print("Got server status: " + serverInfoState.status); status = serverInfoState.status; } @@ -238,13 +237,12 @@ class CwtchNotifier { } break; case "AcceptGroupInvite": - print("accept group invite: $data"); + EnvironmentConfig.debugLog("accept group invite"); profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])!.isInvitation = false; profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(data["GroupID"], DateTime.now()); break; case "ServerStateChange": - print("server state change: $data"); // Update the Server Cache profileCN.getProfile(data["ProfileOnion"])?.updateServerStatusCache(data["GroupServer"], data["ConnectionState"]); profileCN.getProfile(data["ProfileOnion"])?.contactList.contacts.forEach((contact) { @@ -260,7 +258,7 @@ class CwtchNotifier { profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])!.nickname = data["Data"]; } } else { - print("unhandled set group attribute event: $type $data"); + EnvironmentConfig.debugLog("unhandled set group attribute event: ${data['Key']}"); } break; case "NewRetValMessageFromPeer": @@ -270,11 +268,11 @@ class CwtchNotifier { profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.nickname = data["Data"]; } } else { - print("unhandled peer attribute event: $type $data"); + EnvironmentConfig.debugLog("unhandled peer attribute event: ${data['Path']}"); } break; default: - print("unhandled event: $type $data"); + EnvironmentConfig.debugLog("unhandled event: $type"); } } } diff --git a/lib/model.dart b/lib/model.dart index 4fdeb076..32dbb485 100644 --- a/lib/model.dart +++ b/lib/model.dart @@ -227,7 +227,6 @@ class ProfileInfoState extends ChangeNotifier { // Parse out the server list json into our server info state struct... void replaceServers(String serversJson) { if (serversJson != "" && serversJson != "null") { - print("got servers $serversJson"); List servers = jsonDecode(serversJson); this._servers.replace(servers.map((server) { // TODO Keys...