-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
843 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,5 +45,6 @@ app.*.map.json | |
/android/app/release | ||
|
||
# Generated files | ||
**/generated/* | ||
*.freezed.dart | ||
*.g.dart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
final class ApiException<T extends Enum> implements Exception { | ||
final T error; | ||
|
||
const ApiException(this.error); | ||
|
||
@override | ||
String toString() { | ||
return 'ApiException: $error'; | ||
} | ||
} | ||
|
||
abstract class Tox { | ||
String get address; | ||
|
||
bool get isAlive; | ||
|
||
int get iterationInterval; | ||
|
||
set name(String value); | ||
|
||
set statusMessage(String value); | ||
|
||
void addTcpRelay(String host, int port, String publicKey); | ||
|
||
void bootstrap(String host, int port, String publicKey); | ||
|
||
List<String> iterate(); | ||
|
||
void kill(); | ||
} | ||
|
||
final class ToxConstants { | ||
final int addressSize; | ||
final int conferenceIdSize; | ||
final int fileIdLength; | ||
final int groupChatIdSize; | ||
final int groupMaxCustomLosslessPacketLength; | ||
final int groupMaxCustomLossyPacketLength; | ||
final int groupMaxGroupNameLength; | ||
final int groupMaxMessageLength; | ||
final int groupMaxPartLength; | ||
final int groupMaxPasswordSize; | ||
final int groupMaxTopicLength; | ||
final int groupPeerPublicKeySize; | ||
final int hashLength; | ||
final int maxCustomPacketSize; | ||
final int maxFilenameLength; | ||
final int maxFriendRequestLength; | ||
final int maxHostnameLength; | ||
final int maxMessageLength; | ||
final int maxNameLength; | ||
final int maxStatusMessageLength; | ||
final int nospamSize; | ||
final int publicKeySize; | ||
final int secretKeySize; | ||
|
||
const ToxConstants({ | ||
required this.addressSize, | ||
required this.conferenceIdSize, | ||
required this.fileIdLength, | ||
required this.groupChatIdSize, | ||
required this.groupMaxCustomLosslessPacketLength, | ||
required this.groupMaxCustomLossyPacketLength, | ||
required this.groupMaxGroupNameLength, | ||
required this.groupMaxMessageLength, | ||
required this.groupMaxPartLength, | ||
required this.groupMaxPasswordSize, | ||
required this.groupMaxTopicLength, | ||
required this.groupPeerPublicKeySize, | ||
required this.hashLength, | ||
required this.maxCustomPacketSize, | ||
required this.maxFilenameLength, | ||
required this.maxFriendRequestLength, | ||
required this.maxHostnameLength, | ||
required this.maxMessageLength, | ||
required this.maxNameLength, | ||
required this.maxStatusMessageLength, | ||
required this.nospamSize, | ||
required this.publicKeySize, | ||
required this.secretKeySize, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
final class ToxOptions { | ||
final bool ipv6Enabled; | ||
final bool udpEnabled; | ||
final bool localDiscoveryEnabled; | ||
|
||
const ToxOptions({ | ||
this.ipv6Enabled = true, | ||
this.udpEnabled = true, | ||
this.localDiscoveryEnabled = true, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export 'tox_constants.native.dart' | ||
if (dart.library.html) 'tox_constants.web.dart' | ||
if (dart.library.js) 'tox_constants.web.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:btox/api/toxcore/tox.dart'; | ||
import 'package:btox/ffi/generated/toxcore.native.dart'; | ||
|
||
ToxConstants toxcoreConstants(ToxFfi ffi) => ToxConstants( | ||
addressSize: ffi.tox_address_size(), | ||
conferenceIdSize: ffi.tox_conference_id_size(), | ||
fileIdLength: ffi.tox_file_id_length(), | ||
groupChatIdSize: ffi.tox_group_chat_id_size(), | ||
groupMaxCustomLosslessPacketLength: | ||
ffi.tox_group_max_custom_lossless_packet_length(), | ||
groupMaxCustomLossyPacketLength: | ||
ffi.tox_group_max_custom_lossy_packet_length(), | ||
groupMaxGroupNameLength: ffi.tox_group_max_group_name_length(), | ||
groupMaxMessageLength: ffi.tox_group_max_message_length(), | ||
groupMaxPartLength: ffi.tox_group_max_part_length(), | ||
groupMaxPasswordSize: ffi.tox_group_max_password_size(), | ||
groupMaxTopicLength: ffi.tox_group_max_topic_length(), | ||
groupPeerPublicKeySize: ffi.tox_group_peer_public_key_size(), | ||
hashLength: ffi.tox_hash_length(), | ||
maxCustomPacketSize: ffi.tox_max_custom_packet_size(), | ||
maxFilenameLength: ffi.tox_max_filename_length(), | ||
maxFriendRequestLength: ffi.tox_max_friend_request_length(), | ||
maxHostnameLength: ffi.tox_max_hostname_length(), | ||
maxMessageLength: ffi.tox_max_message_length(), | ||
maxNameLength: ffi.tox_max_name_length(), | ||
maxStatusMessageLength: ffi.tox_max_status_message_length(), | ||
nospamSize: ffi.tox_nospam_size(), | ||
publicKeySize: ffi.tox_public_key_size(), | ||
secretKeySize: ffi.tox_secret_key_size(), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'package:btox/api/toxcore/tox.dart'; | ||
import 'package:btox/ffi/tox_ffi.web.dart'; | ||
|
||
ToxConstants toxcoreConstants(ToxFfi ffi) => const ToxConstants( | ||
addressSize: 38, | ||
conferenceIdSize: 32, | ||
fileIdLength: 32, | ||
groupChatIdSize: 32, | ||
groupMaxCustomLosslessPacketLength: 1373, | ||
groupMaxCustomLossyPacketLength: 1373, | ||
groupMaxGroupNameLength: 48, | ||
groupMaxMessageLength: 1372, | ||
groupMaxPartLength: 128, | ||
groupMaxPasswordSize: 32, | ||
groupMaxTopicLength: 512, | ||
groupPeerPublicKeySize: 32, | ||
hashLength: 32, | ||
maxCustomPacketSize: 1373, | ||
maxFilenameLength: 255, | ||
maxFriendRequestLength: 921, | ||
maxHostnameLength: 255, | ||
maxMessageLength: 1372, | ||
maxNameLength: 128, | ||
maxStatusMessageLength: 1007, | ||
nospamSize: 4, | ||
publicKeySize: 32, | ||
secretKeySize: 32, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export 'tox_ffi.native.dart' | ||
if (dart.library.html) 'tox_ffi.web.dart' | ||
if (dart.library.js) 'tox_ffi.web.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'dart:ffi'; | ||
import 'dart:io'; | ||
|
||
import 'package:btox/ffi/generated/toxcore.native.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
export 'package:btox/ffi/generated/toxcore.native.dart' show ToxFfi; | ||
|
||
part 'tox_ffi.native.g.dart'; | ||
|
||
@riverpod | ||
ToxFfi toxFfi(Ref ref) { | ||
if (Platform.isAndroid) { | ||
return ToxFfi(DynamicLibrary.open('libtoxcore.so')); | ||
} | ||
return ToxFfi(DynamicLibrary.process()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:riverpod_annotation/riverpod_annotation.dart'; | ||
|
||
part 'tox_ffi.web.g.dart'; | ||
|
||
final class ToxFfi { | ||
const ToxFfi(); | ||
} | ||
|
||
@riverpod | ||
ToxFfi toxFfi(Ref ref) { | ||
return const ToxFfi(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export 'toxcore.native.dart' | ||
if (dart.library.html) 'toxcore.web.dart' | ||
if (dart.library.js) 'toxcore.web.dart'; |
Oops, something went wrong.