@@ -28,7 +28,7 @@ class ToxEventListener @Inject constructor(
private val messageRepository: MessageRepository,
private val userRepository: UserRepository,
private val notificationHelper: NotificationHelper
) : ToxCoreEventListener<Int> {
) : ToxCoreEventListener<Unit> {
private var contacts: List<Contact> = listOf()
var contactMapping: List<Pair<String, Int>> = listOf()
@@ -43,49 +43,49 @@ class ToxEventListener @Inject constructor(
return contacts.find { it.publicKey == publicKey }!!
}
override fun friendLosslessPacket(friendNumber: Int, data: ByteArray, state: Int?): Int {
return Log.e(TAG, "friendLosslessPacket")
override fun friendLosslessPacket(friendNumber: Int, data: ByteArray, state: Unit?) {
Log.e(TAG, "friendLosslessPacket")
}
override fun fileRecvControl(friendNumber: Int, fileNumber: Int, control: ToxFileControl, state: Int?): Int {
return Log.e(TAG, "fileRecvControl")
override fun fileRecvControl(friendNumber: Int, fileNumber: Int, control: ToxFileControl, state: Unit?) {
Log.e(TAG, "fileRecvControl")
}
override fun friendStatusMessage(friendNumber: Int, message: ByteArray, state: Int?): Int {
override fun friendStatusMessage(friendNumber: Int, message: ByteArray, state: Unit?) {
contactByFriendNumber(friendNumber).let {
contactRepository.update(it.apply { statusMessage = String(message) })
}
return Log.e(TAG, "friendStatusMessage")
Log.e(TAG, "friendStatusMessage")
}
override fun friendReadReceipt(friendNumber: Int, messageId: Int, state: Int?): Int {
return Log.e(TAG, "friendReadReceipt")
override fun friendReadReceipt(friendNumber: Int, messageId: Int, state: Unit?) {
Log.e(TAG, "friendReadReceipt")
}
override fun friendStatus(friendNumber: Int, toxStatus: ToxUserStatus, state: Int?): Int {
override fun friendStatus(friendNumber: Int, toxStatus: ToxUserStatus, state: Unit?) {
contactByFriendNumber(friendNumber).let {
contactRepository.update(it.apply { status = toxStatus.toUserStatus() })
}
return Log.e(TAG, "friendStatus")
Log.e(TAG, "friendStatus")
}
override fun friendConnectionStatus(friendNumber: Int, toxConnectionStatus: ToxConnection, state: Int?): Int {
override fun friendConnectionStatus(friendNumber: Int, toxConnectionStatus: ToxConnection, state: Unit?) {
contactByFriendNumber(friendNumber).let {
contactRepository.update(it.apply { connectionStatus = toxConnectionStatus.toConnectionStatus() })
}
return Log.e(TAG, "friendConnectionStatus")
Log.e(TAG, "friendConnectionStatus")
}
override fun friendRequest(publicKey: ByteArray, timeDelta: Int, message: ByteArray, state: Int?): Int {
override fun friendRequest(publicKey: ByteArray, timeDelta: Int, message: ByteArray, state: Unit?) {
FriendRequest(publicKey.bytesToHex(), String(message)).also {
friendRequestRepository.add(it)
notificationHelper.showFriendRequestNotification(it)
}
return Log.e(TAG, "friendRequest")
Log.e(TAG, "friendRequest")
}
override fun friendMessage(
@@ -93,8 +93,8 @@ class ToxEventListener @Inject constructor(
messageType: ToxMessageType,
timeDelta: Int,
message: ByteArray,
state: Int?
): Int {
state: Unit?
) {
contactByFriendNumber(friendNumber).let {
contactRepository.update(it.apply {
lastMessage = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(Date())
@@ -104,19 +104,19 @@ class ToxEventListener @Inject constructor(
notificationHelper.showMessageNotification(it, String(message))
}
return Log.e(TAG, "friendMessage")
Log.e(TAG, "friendMessage")
}
override fun friendName(friendNumber: Int, newName: ByteArray, state: Int?): Int {
override fun friendName(friendNumber: Int, newName: ByteArray, state: Unit?) {
contactByFriendNumber(friendNumber).let {
contactRepository.update(it.apply { name = String(newName) })
}
return Log.e(TAG, "friendName")
Log.e(TAG, "friendName")
}
override fun fileRecvChunk(friendNumber: Int, fileNumber: Int, position: Long, data: ByteArray, state: Int?): Int {
return Log.e(TAG, "fileRecvChunk")
override fun fileRecvChunk(friendNumber: Int, fileNumber: Int, position: Long, data: ByteArray, state: Unit?) {
Log.e(TAG, "fileRecvChunk")
}
override fun fileRecv(
@@ -125,29 +125,29 @@ class ToxEventListener @Inject constructor(
kind: Int,
fileSize: Long,
filename: ByteArray,
state: Int?
): Int {
return Log.e(TAG, "fileRecv")
state: Unit?
) {
Log.e(TAG, "fileRecv")
}
override fun friendLossyPacket(friendNumber: Int, data: ByteArray, state: Int?): Int {
return Log.e(TAG, "friendLossyPacket")
override fun friendLossyPacket(friendNumber: Int, data: ByteArray, state: Unit?) {
Log.e(TAG, "friendLossyPacket")
}
override fun selfConnectionStatus(connectionStatus: ToxConnection, state: Int?): Int {
override fun selfConnectionStatus(connectionStatus: ToxConnection, state: Unit?) {
userRepository.updateConnection(App.toxThread.publicKey, connectionStatus.toConnectionStatus())
return Log.e(TAG, "selfConnectionStatus $connectionStatus")
Log.e(TAG, "selfConnectionStatus $connectionStatus")
}
override fun friendTyping(friendNumber: Int, isTyping: Boolean, state: Int?): Int {
override fun friendTyping(friendNumber: Int, isTyping: Boolean, state: Unit?) {
contactByFriendNumber(friendNumber).let {
contactRepository.update(it.apply { typing = isTyping })
}
return Log.e(TAG, "friendTyping")
Log.e(TAG, "friendTyping")
}
override fun fileChunkRequest(friendNumber: Int, fileNumber: Int, position: Long, length: Int, state: Int?): Int {
return Log.e(TAG, "fileChunkRequest")
override fun fileChunkRequest(friendNumber: Int, fileNumber: Int, position: Long, length: Int, state: Unit?) {
Log.e(TAG, "fileChunkRequest")
}
}