diff --git a/lib/matrix_api/matrix_api.dart b/lib/matrix_api/matrix_api.dart index 569f161..ce528d2 100644 --- a/lib/matrix_api/matrix_api.dart +++ b/lib/matrix_api/matrix_api.dart @@ -88,9 +88,6 @@ class MatrixApi { /// timeout which is usually 30 seconds. int syncTimeoutSec; - /// Whether debug prints should be displayed. - final bool debug; - http.Client httpClient = http.Client(); bool get _testMode => @@ -101,7 +98,6 @@ class MatrixApi { MatrixApi({ this.homeserver, this.accessToken, - this.debug = false, http.Client httpClient, this.syncTimeoutSec = 30, }) { @@ -161,11 +157,6 @@ class MatrixApi { headers['Authorization'] = 'Bearer ${accessToken}'; } - if (debug) { - print( - '[REQUEST ${describeEnum(type)}] $action, Data: ${jsonEncode(data)}'); - } - http.Response resp; var jsonResp = {}; try { @@ -212,8 +203,6 @@ class MatrixApi { throw exception; } - - if (debug) print('[RESPONSE] ${jsonResp.toString()}'); _timeoutFactor = 1; } on TimeoutException catch (_) { _timeoutFactor *= 2; @@ -1300,7 +1289,6 @@ class MatrixApi { streamedRequest.contentLength = await file.length; streamedRequest.sink.add(file); streamedRequest.sink.close(); - if (debug) print('[UPLOADING] $fileName'); var streamedResponse = _testMode ? null : await streamedRequest.send(); Map jsonResponse = json.decode( String.fromCharCodes(_testMode diff --git a/lib/src/client.dart b/lib/src/client.dart index 9a0b591..8eb3907 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -81,14 +81,16 @@ class Client { /// - m.room.canonical_alias /// - m.room.tombstone /// - *some* m.room.member events, where needed - Client(this.clientName, - {this.debug = false, - this.database, - this.enableE2eeRecovery = false, - this.verificationMethods, - http.Client httpClient, - this.importantStateEvents, - this.pinUnreadRooms = false}) { + Client( + this.clientName, { + this.database, + this.enableE2eeRecovery = false, + this.verificationMethods, + http.Client httpClient, + this.importantStateEvents, + this.pinUnreadRooms = false, + @deprecated bool debug, + }) { verificationMethods ??= {}; importantStateEvents ??= {}; importantStateEvents.addAll([ @@ -100,17 +102,9 @@ class Client { EventTypes.RoomCanonicalAlias, EventTypes.RoomTombstone, ]); - api = MatrixApi(debug: debug, httpClient: httpClient); - onLoginStateChanged.stream.listen((loginState) { - if (debug) { - print('[LoginState]: ${loginState.toString()}'); - } - }); + api = MatrixApi(httpClient: httpClient); } - /// Whether debug prints should be displayed. - final bool debug; - /// The required name for this client. final String clientName; @@ -634,8 +628,8 @@ class Client { return; } - encryption = Encryption( - debug: debug, client: this, enableE2eeRecovery: enableE2eeRecovery); + encryption = + Encryption(client: this, enableE2eeRecovery: enableE2eeRecovery); await encryption.init(olmAccount); if (database != null) { diff --git a/lib/src/timeline.dart b/lib/src/timeline.dart index 5a38b39..042e811 100644 --- a/lib/src/timeline.dart +++ b/lib/src/timeline.dart @@ -263,10 +263,8 @@ class Timeline { } sortAndUpdate(); } catch (e, s) { - if (room.client.debug) { - print('[WARNING] (_handleEventUpdate) ${e.toString()}'); - print(s); - } + print('[WARNING] (_handleEventUpdate) ${e.toString()}'); + print(s); } } diff --git a/test/client_test.dart b/test/client_test.dart index 41a9fab..c970708 100644 --- a/test/client_test.dart +++ b/test/client_test.dart @@ -48,7 +48,7 @@ void main() { group('FluffyMatrix', () { /// Check if all Elements get created - matrix = Client('testclient', debug: true, httpClient: FakeMatrixApi()); + matrix = Client('testclient', httpClient: FakeMatrixApi()); roomUpdateListFuture = matrix.onRoomUpdate.stream.toList(); eventUpdateListFuture = matrix.onEvent.stream.toList(); @@ -322,7 +322,7 @@ void main() { }); test('Login', () async { - matrix = Client('testclient', debug: true, httpClient: FakeMatrixApi()); + matrix = Client('testclient', httpClient: FakeMatrixApi()); roomUpdateListFuture = matrix.onRoomUpdate.stream.toList(); eventUpdateListFuture = matrix.onEvent.stream.toList(); @@ -395,8 +395,7 @@ void main() { }); }); test('Test the fake store api', () async { - var client1 = - Client('testclient', debug: true, httpClient: FakeMatrixApi()); + var client1 = Client('testclient', httpClient: FakeMatrixApi()); client1.database = getDatabase(); client1.connect( @@ -413,8 +412,7 @@ void main() { expect(client1.isLogged(), true); expect(client1.rooms.length, 2); - var client2 = - Client('testclient', debug: true, httpClient: FakeMatrixApi()); + var client2 = Client('testclient', httpClient: FakeMatrixApi()); client2.database = client1.database; client2.connect(); diff --git a/test/encryption/encrypt_decrypt_to_device_test.dart b/test/encryption/encrypt_decrypt_to_device_test.dart index 5636e8b..a56adee 100644 --- a/test/encryption/encrypt_decrypt_to_device_test.dart +++ b/test/encryption/encrypt_decrypt_to_device_test.dart @@ -42,8 +42,7 @@ void main() { if (!olmEnabled) return; Client client; - var otherClient = - Client('othertestclient', debug: true, httpClient: FakeMatrixApi()); + var otherClient = Client('othertestclient', httpClient: FakeMatrixApi()); DeviceKeys device; Map payload; diff --git a/test/encryption/key_verification_test.dart b/test/encryption/key_verification_test.dart index 66ccdee..3216b8e 100644 --- a/test/encryption/key_verification_test.dart +++ b/test/encryption/key_verification_test.dart @@ -82,8 +82,7 @@ void main() { test('setupClient', () async { client1 = await getClient(); - client2 = - Client('othertestclient', debug: true, httpClient: FakeMatrixApi()); + client2 = Client('othertestclient', httpClient: FakeMatrixApi()); client2.database = client1.database; await client2.checkServer('https://fakeServer.notExisting'); client2.connect( diff --git a/test/event_test.dart b/test/event_test.dart index a151c4c..5fb041c 100644 --- a/test/event_test.dart +++ b/test/event_test.dart @@ -50,7 +50,7 @@ void main() { 'status': 2, 'content': contentJson, }; - var client = Client('testclient', debug: true, httpClient: FakeMatrixApi()); + var client = Client('testclient', httpClient: FakeMatrixApi()); var event = Event.fromJson( jsonObj, Room(id: '!localpart:server.abc', client: client)); @@ -211,8 +211,7 @@ void main() { ]; for (final testType in testTypes) { redactJsonObj['type'] = testType; - final room = - Room(id: '1234', client: Client('testclient', debug: true)); + final room = Room(id: '1234', client: Client('testclient')); final redactionEventJson = { 'content': {'reason': 'Spamming'}, 'event_id': '143273582443PhrSn:example.org', @@ -236,7 +235,7 @@ void main() { test('remove', () async { var event = Event.fromJson( - jsonObj, Room(id: '1234', client: Client('testclient', debug: true))); + jsonObj, Room(id: '1234', client: Client('testclient'))); final removed1 = await event.remove(); event.status = 0; final removed2 = await event.remove(); @@ -245,8 +244,7 @@ void main() { }); test('sendAgain', () async { - var matrix = - Client('testclient', debug: true, httpClient: FakeMatrixApi()); + var matrix = Client('testclient', httpClient: FakeMatrixApi()); await matrix.checkServer('https://fakeServer.notExisting'); await matrix.login('test', '1234'); @@ -262,8 +260,7 @@ void main() { }); test('requestKey', () async { - var matrix = - Client('testclient', debug: true, httpClient: FakeMatrixApi()); + var matrix = Client('testclient', httpClient: FakeMatrixApi()); await matrix.checkServer('https://fakeServer.notExisting'); await matrix.login('test', '1234'); @@ -310,8 +307,7 @@ void main() { expect(event.canRedact, true); }); test('getLocalizedBody', () async { - final matrix = - Client('testclient', debug: true, httpClient: FakeMatrixApi()); + final matrix = Client('testclient', httpClient: FakeMatrixApi()); final room = Room(id: '!1234:example.com', client: matrix); var event = Event.fromJson({ 'content': { diff --git a/test/fake_client.dart b/test/fake_client.dart index af2c39a..7b1a94a 100644 --- a/test/fake_client.dart +++ b/test/fake_client.dart @@ -29,7 +29,7 @@ const pickledOlmAccount = 'N2v1MkIFGcl0mQpo2OCwSopxPQJ0wnl7oe7PKiT4141AijfdTIhRu+ceXzXKy3Kr00nLqXtRv7kid6hU4a+V0rfJWLL0Y51+3Rp/ORDVnQy+SSeo6Fn4FHcXrxifJEJ0djla5u98fBcJ8BSkhIDmtXRPi5/oJAvpiYn+8zMjFHobOeZUAxYR0VfQ9JzSYBsSovoQ7uFkNks1M4EDUvHtuyg3RxViwdNxs3718fyAqQ/VSwbXsY0Nl+qQbF+nlVGHenGqk5SuNl1P6e1PzZxcR0IfXA94Xij1Ob5gDv5YH4UCn9wRMG0abZsQP0YzpDM0FLaHSCyo9i5JD/vMlhH+nZWrgAzPPCTNGYewNV8/h3c+VyJh8ZTx/fVi6Yq46Fv+27Ga2ETRZ3Qn+Oyx6dLBjnBZ9iUvIhqpe2XqaGA1PopOz8iDnaZitw'; Future getClient() async { - final client = Client('testclient', debug: true, httpClient: FakeMatrixApi()); + final client = Client('testclient', httpClient: FakeMatrixApi()); client.database = getDatabase(); await client.checkServer('https://fakeServer.notExisting'); final resp = await client.api.login( diff --git a/test/matrix_api_test.dart b/test/matrix_api_test.dart index 7ad8ded..5336cce 100644 --- a/test/matrix_api_test.dart +++ b/test/matrix_api_test.dart @@ -33,7 +33,6 @@ void main() { group('Matrix API', () { final matrixApi = MatrixApi( httpClient: FakeMatrixApi(), - debug: true, ); test('MatrixException test', () async { final exception = MatrixException.fromJson({ diff --git a/test/timeline_test.dart b/test/timeline_test.dart index f76eb6c..0725d19 100644 --- a/test/timeline_test.dart +++ b/test/timeline_test.dart @@ -33,7 +33,7 @@ void main() { var updateCount = 0; var insertList = []; - var client = Client('testclient', debug: true, httpClient: FakeMatrixApi()); + var client = Client('testclient', httpClient: FakeMatrixApi()); var room = Room( id: roomID, client: client, prev_batch: '1234', roomAccountData: {}); diff --git a/test/user_test.dart b/test/user_test.dart index 05e415b..35d35d6 100644 --- a/test/user_test.dart +++ b/test/user_test.dart @@ -27,7 +27,7 @@ import 'fake_matrix_api.dart'; void main() { /// All Tests related to the Event group('User', () { - var client = Client('testclient', debug: true, httpClient: FakeMatrixApi()); + var client = Client('testclient', httpClient: FakeMatrixApi()); final user1 = User( '@alice:example.com', membership: 'join', diff --git a/test_driver/famedlysdk_test.dart b/test_driver/famedlysdk_test.dart index 79cabfb..6b40f53 100644 --- a/test_driver/famedlysdk_test.dart +++ b/test_driver/famedlysdk_test.dart @@ -18,14 +18,14 @@ const String testMessage6 = 'Hello mars'; void test() async { print('++++ Login $testUserA ++++'); - var testClientA = Client('TestClientA', debug: false); + var testClientA = Client('TestClientA'); testClientA.database = getDatabase(); await testClientA.checkServer(homeserver); await testClientA.login(testUserA, testPasswordA); assert(testClientA.encryptionEnabled); print('++++ Login $testUserB ++++'); - var testClientB = Client('TestClientB', debug: false); + var testClientB = Client('TestClientB'); testClientB.database = getDatabase(); await testClientB.checkServer(homeserver); await testClientB.login(testUserB, testPasswordA); @@ -212,8 +212,7 @@ void test() async { "++++ ($testUserA) Received decrypted message: '${room.lastMessage}' ++++"); print('++++ Login $testUserB in another client ++++'); - var testClientC = - Client('TestClientC', debug: false, database: getDatabase()); + var testClientC = Client('TestClientC', database: getDatabase()); await testClientC.checkServer(homeserver); await testClientC.login(testUserB, testPasswordA); await Future.delayed(Duration(seconds: 3));