mirror of
https://github.com/micahflee/TM-SGNL-Android.git
synced 2025-08-04 19:08:33 +00:00
MOD - move recorder file to filer and delete call link recorded file if present
This commit is contained in:
parent
7360634b96
commit
746b6fcd8b
7 changed files with 42 additions and 15 deletions
Binary file not shown.
Binary file not shown.
|
@ -27,18 +27,18 @@ class SignalArchiveMessageConverter(
|
|||
}
|
||||
|
||||
fun convert(message: MessageRecord?, accountPhoneNumber: String?, isDeleted: Boolean = false): ArchiveMessage? {
|
||||
return convert(message, accountPhoneNumber, isDeleted, null, false)
|
||||
return convert(message, accountPhoneNumber, isDeleted, null)
|
||||
}
|
||||
|
||||
fun convertCall(message: MessageRecord?, accountPhoneNumber: String?, startedAt: Long?, isAdHocCall: Boolean): ArchiveMessage? {
|
||||
return convert(message, accountPhoneNumber, false, startedAt, isAdHocCall)
|
||||
fun convertCall(message: MessageRecord?, accountPhoneNumber: String?, startedAt: Long?): ArchiveMessage? {
|
||||
return convert(message, accountPhoneNumber, false, startedAt)
|
||||
}
|
||||
|
||||
private fun convert(message: MessageRecord?, accountPhoneNumber: String?, isDeleted: Boolean, startedAt: Long?, isAdHocCall: Boolean): ArchiveMessage? {
|
||||
private fun convert(message: MessageRecord?, accountPhoneNumber: String?, isDeleted: Boolean, startedAt: Long?): ArchiveMessage? {
|
||||
if (message == null)
|
||||
return null
|
||||
|
||||
val type = getTransportType(message, isAdHocCall) ?: return null
|
||||
val type = getTransportType(message) ?: return null
|
||||
val sender = recipientConverter.convertSenderRecipient(message)
|
||||
val receivers = recipientConverter.convertReceiverRecipients(message)
|
||||
return ArchiveMessage(
|
||||
|
@ -63,9 +63,7 @@ class SignalArchiveMessageConverter(
|
|||
)
|
||||
}
|
||||
|
||||
private fun getTransportType(message: MessageRecord, isAdHocCall: Boolean): ArchiveMessageType? {
|
||||
if (isAdHocCall)
|
||||
return ArchiveMessageType.Unknown
|
||||
private fun getTransportType(message: MessageRecord): ArchiveMessageType? {
|
||||
if (message.isCallMessage())
|
||||
return ArchiveMessageType.Call
|
||||
return if (message.isSmsMessage()) ArchiveMessageType.Sms else if (message.isMultimediaMessage()) ArchiveMessageType.Mms else null
|
||||
|
|
|
@ -40,9 +40,9 @@ class TeleMessageTable(
|
|||
return getMessages(ids).use { reader -> reader.mapNotNull { converter.convert(it, accountPhoneNumber) } }
|
||||
}
|
||||
|
||||
fun onSubmitCall(call: CallTable.Call, startedAt: Long?, isAdHocCall: Boolean) {
|
||||
fun onSubmitCall(call: CallTable.Call, startedAt: Long?) {
|
||||
val message = getMessageRecordOrNull(call.messageId ?: return)?.withCall(call)
|
||||
val archiveMessage = converter.convertCall(message, getAccountPhoneNumber(), startedAt, isAdHocCall) ?: return
|
||||
val archiveMessage = converter.convertCall(message, getAccountPhoneNumber(), startedAt) ?: return
|
||||
messageStoreObserver.afterMessageStateChanged(archiveMessage)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.archiver.device
|
|||
import android.app.Application
|
||||
import com.tm.logger.Log
|
||||
import org.archiver.data.TeleMessageTable
|
||||
import org.archiver.di.TeleMessageApplicationDependencyProvider.Companion.getSdkModule
|
||||
import org.signal.ringrtc.CallId
|
||||
import org.signal.ringrtc.CallManager.CallEvent
|
||||
import org.signal.ringrtc.GroupCall
|
||||
|
@ -18,6 +19,8 @@ class TeleMessageSignalCallManager(
|
|||
|
||||
private var callInfoState: CallInfoState? = null
|
||||
|
||||
private val sdkModule by lazy { application.getSdkModule(requireNotNull(SignalDatabase.instance)) }
|
||||
|
||||
override fun postStateUpdate(state: WebRtcServiceState) {
|
||||
val callId = state.callInfoState.getCallId()
|
||||
Log.d(TAG, "postStateUpdate - callId: $callId")
|
||||
|
@ -41,7 +44,12 @@ class TeleMessageSignalCallManager(
|
|||
this.callInfoState = null
|
||||
val callConnectedTime = callInfoState.callConnectedTime.takeIf { it > 0 }
|
||||
val call = callInfoState.call() ?: return
|
||||
(SignalDatabase.messages as TeleMessageTable).onSubmitCall(call, callConnectedTime, callInfoState.callRecipient.isCallLink)
|
||||
val isAdHocCall = callInfoState.callRecipient.isCallLink
|
||||
if (isAdHocCall) {
|
||||
sdkModule.filer.findCallRecording(call.callId.toString())?.apply { if (exists()) delete() }
|
||||
return
|
||||
}
|
||||
(SignalDatabase.messages as TeleMessageTable).onSubmitCall(call, callConnectedTime)
|
||||
}
|
||||
|
||||
private fun CallInfoState.getCallId(): CallId? {
|
||||
|
|
|
@ -6,9 +6,17 @@
|
|||
package org.archiver.di
|
||||
|
||||
import android.app.Application
|
||||
import com.tm.androidcopysdk.AndroidCopySDK
|
||||
import com.tm.androidcopysdk.DataGrabber
|
||||
import com.tm.androidcopysdk.api.IArchiveDatabase
|
||||
import com.tm.androidcopysdk.api.IMessageStoreObserver
|
||||
import com.tm.androidcopysdk.api.SdkModule
|
||||
import com.tm.androidcopysdk.database.DefaultArchiveDatabase
|
||||
import com.tm.androidcopysdk.device.DefaultMessageStoreObserver
|
||||
import org.archiver.device.TeleMessageSignalCallManager
|
||||
import org.archiver.model.SignalArchiveType
|
||||
import org.archiver.model.SignalFiler
|
||||
import org.tm.archive.database.SignalDatabase
|
||||
import org.tm.archive.dependencies.ApplicationDependencyProvider
|
||||
import org.tm.archive.service.webrtc.SignalCallManager
|
||||
|
||||
|
@ -22,6 +30,21 @@ class TeleMessageApplicationDependencyProvider(
|
|||
}
|
||||
|
||||
companion object {
|
||||
|
||||
private var sdkModule: SdkModule<Long>? = null
|
||||
|
||||
val messageStoreObserver: IMessageStoreObserver<Long> by lazy { DefaultMessageStoreObserver.getInstance() }
|
||||
|
||||
fun Application.getSdkModule(database: SignalDatabase): SdkModule<Long> {
|
||||
var sdkModule = sdkModule
|
||||
if (sdkModule == null) {
|
||||
val sdk = AndroidCopySDK.getInstance(applicationContext)
|
||||
val archiveDatabase: IArchiveDatabase = DefaultArchiveDatabase(this, SignalArchiveType.coreValues())
|
||||
val filer = SignalFiler(applicationContext, database.attachmentTable)
|
||||
sdkModule = SdkModule(sdk, DataGrabber.getInstance(applicationContext), database, archiveDatabase, filer)
|
||||
TeleMessageApplicationDependencyProvider.sdkModule = sdkModule
|
||||
}
|
||||
return sdkModule
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ import org.archiver.ArchiveConstants
|
|||
import org.archiver.ArchiveLogger
|
||||
import org.archiver.device.CallManagerRecordingDelegate
|
||||
import org.archiver.di.TeleMessageApplicationDependencyProvider
|
||||
import org.archiver.di.TeleMessageApplicationDependencyProvider.Companion.getSdkModule
|
||||
import org.archiver.model.SignalArchiveType
|
||||
import org.archiver.model.SignalFiler
|
||||
import org.signal.ringrtc.CallManager
|
||||
|
@ -44,11 +45,8 @@ class TeleMessageSignalApplication : ApplicationContext() {
|
|||
}
|
||||
|
||||
private fun initializeSdk() {
|
||||
val sdk = AndroidCopySDK.getInstance(applicationContext)
|
||||
val database = SignalDatabase.instance ?: return
|
||||
val archiveDatabase: IArchiveDatabase = DefaultArchiveDatabase(this, SignalArchiveType.coreValues())
|
||||
val filer = SignalFiler(applicationContext, database.attachmentTable)
|
||||
val module = SdkModule(sdk, DataGrabber.getInstance(applicationContext), database, archiveDatabase, filer)
|
||||
val module = getSdkModule(database)
|
||||
val messageObserver = TeleMessageApplicationDependencyProvider.messageStoreObserver
|
||||
messageObserver.addProcessor(ArchiveMessagesProcessor(module))
|
||||
messageObserver.addProcessor(SendSignatureProcessor(module))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue