Skip to content

Commit

Permalink
chore: cleanup CoreLogicModule.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamadJaara committed Sep 19, 2023
1 parent 6e6aabc commit e24bf0a
Show file tree
Hide file tree
Showing 9 changed files with 1,066 additions and 820 deletions.
820 changes: 0 additions & 820 deletions app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt

Large diffs are not rendered by default.

179 changes: 179 additions & 0 deletions app/src/main/kotlin/com/wire/android/di/accountScoped/CallsModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
/*
* Wire
* Copyright (C) 2023 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.di.accountScoped

import com.wire.android.di.CurrentAccount
import com.wire.android.di.KaliumCoreLogic
import dagger.Module
import dagger.Provides
import com.wire.kalium.logic.CoreLogic
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.call.CallsScope
import com.wire.kalium.logic.feature.call.usecase.EndCallOnConversationChangeUseCase
import com.wire.kalium.logic.feature.call.usecase.EndCallUseCase
import com.wire.kalium.logic.feature.call.usecase.FlipToBackCameraUseCase
import com.wire.kalium.logic.feature.call.usecase.FlipToFrontCameraUseCase
import com.wire.kalium.logic.feature.call.usecase.GetAllCallsWithSortedParticipantsUseCase
import com.wire.kalium.logic.feature.call.usecase.MuteCallUseCase
import com.wire.kalium.logic.feature.call.usecase.ObserveEstablishedCallsUseCase
import com.wire.kalium.logic.feature.call.usecase.ObserveSpeakerUseCase
import com.wire.kalium.logic.feature.call.usecase.SetVideoPreviewUseCase
import com.wire.kalium.logic.feature.call.usecase.StartCallUseCase
import com.wire.kalium.logic.feature.call.usecase.TurnLoudSpeakerOffUseCase
import com.wire.kalium.logic.feature.call.usecase.TurnLoudSpeakerOnUseCase
import com.wire.kalium.logic.feature.call.usecase.UnMuteCallUseCase
import com.wire.kalium.logic.feature.call.usecase.UpdateVideoStateUseCase
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ViewModelComponent
import dagger.hilt.android.scopes.ViewModelScoped

@Module
@InstallIn(ViewModelComponent::class)
class CallsModule {

@ViewModelScoped
@Provides
fun providesCallsScope(
@KaliumCoreLogic coreLogic: CoreLogic,
@CurrentAccount currentAccount: UserId
): CallsScope = coreLogic.getSessionScope(currentAccount).calls

@ViewModelScoped
@Provides
fun provideGetIncomingCallsUseCase(callsScope: CallsScope) =
callsScope.getIncomingCalls

@ViewModelScoped
@Provides
fun provideRequestVideoStreamsUseCase(callsScope: CallsScope) =
callsScope.requestVideoStreams

@ViewModelScoped
@Provides
fun provideIsLastCallClosedUseCase(callsScope: CallsScope) =
callsScope.isLastCallClosed

@ViewModelScoped
@Provides
fun provideObserveOngoingCallsUseCase(callsScope: CallsScope) =
callsScope.observeOngoingCalls


@ViewModelScoped
@Provides
fun provideRejectCallUseCase(callsScope: CallsScope) =
callsScope.rejectCall

@ViewModelScoped
@Provides
fun provideAcceptCallUseCase(callsScope: CallsScope) =
callsScope.answerCall

@ViewModelScoped
@Provides
fun provideObserveCallByConversationIdUseCase(
callsScope: CallsScope
): GetAllCallsWithSortedParticipantsUseCase = callsScope.allCallsWithSortedParticipants

@ViewModelScoped
@Provides
fun provideOnGoingCallUseCase(
callsScope: CallsScope
): ObserveEstablishedCallsUseCase =
callsScope.establishedCall

@ViewModelScoped
@Provides
fun provideStartCallUseCase(callsScope: CallsScope): StartCallUseCase =
callsScope.startCall

@ViewModelScoped
@Provides
fun provideEndCallUseCase(callsScope: CallsScope): EndCallUseCase =
callsScope.endCall

@ViewModelScoped
@Provides
fun provideEndCallOnConversationChangeUseCase(
callsScope: CallsScope
): EndCallOnConversationChangeUseCase =
callsScope.endCallOnConversationChange

@ViewModelScoped
@Provides
fun provideMuteCallUseCase(callsScope: CallsScope): MuteCallUseCase =
callsScope.muteCall

@ViewModelScoped
@Provides
fun provideUnMuteCallUseCase(callsScope: CallsScope): UnMuteCallUseCase =
callsScope.unMuteCall

@ViewModelScoped
@Provides
fun provideSetVideoPreviewUseCase(
callsScope: CallsScope
): SetVideoPreviewUseCase = callsScope.setVideoPreview

@ViewModelScoped
@Provides
fun provideFlipToBackCameraUseCase(
callsScope: CallsScope
): FlipToBackCameraUseCase = callsScope.flipToBackCamera

@ViewModelScoped
@Provides
fun provideFlipToFrontCameraUseCase(
callsScope: CallsScope
): FlipToFrontCameraUseCase = callsScope.flipToFrontCamera

@ViewModelScoped
@Provides
fun turnLoudSpeakerOffUseCaseProvider(
callsScope: CallsScope
): TurnLoudSpeakerOffUseCase = callsScope.turnLoudSpeakerOff

@ViewModelScoped
@Provides
fun provideTurnLoudSpeakerOnUseCase(
callsScope: CallsScope
): TurnLoudSpeakerOnUseCase = callsScope.turnLoudSpeakerOn

@ViewModelScoped
@Provides
fun provideObserveSpeakerUseCase(
callsScope: CallsScope
): ObserveSpeakerUseCase = callsScope.observeSpeaker

@ViewModelScoped
@Provides
fun provideUpdateVideoStateUseCase(
callsScope: CallsScope
): UpdateVideoStateUseCase =
callsScope.updateVideoState

@ViewModelScoped
@Provides
fun provideIsCallRunningUseCase(callsScope: CallsScope) =
callsScope.isCallRunning

@ViewModelScoped
@Provides
fun provideIsEligibleToStartCall(callsScope: CallsScope) =
callsScope.isEligibleToStartCall
}
113 changes: 113 additions & 0 deletions app/src/main/kotlin/com/wire/android/di/accountScoped/ClientModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* Wire
* Copyright (C) 2023 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.di.accountScoped

import com.wire.android.di.ClientScopeProvider
import com.wire.android.di.CurrentAccount
import com.wire.android.di.KaliumCoreLogic
import com.wire.kalium.logic.CoreLogic
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.client.ClientFingerprintUseCase
import com.wire.kalium.logic.feature.client.ClientScope
import com.wire.kalium.logic.feature.client.DeleteClientUseCase
import com.wire.kalium.logic.feature.client.FetchSelfClientsFromRemoteUseCase
import com.wire.kalium.logic.feature.client.GetOrRegisterClientUseCase
import com.wire.kalium.logic.feature.client.NeedsToRegisterClientUseCase
import com.wire.kalium.logic.feature.client.ObserveClientDetailsUseCase
import com.wire.kalium.logic.feature.client.ObserveClientsByUserIdUseCase
import com.wire.kalium.logic.feature.client.ObserveCurrentClientIdUseCase
import com.wire.kalium.logic.feature.client.PersistOtherUserClientsUseCase
import com.wire.kalium.logic.feature.client.UpdateClientVerificationStatusUseCase
import com.wire.kalium.logic.feature.keypackage.MLSKeyPackageCountUseCase
import com.wire.kalium.logic.sync.slow.RestartSlowSyncProcessForRecoveryUseCase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ViewModelComponent
import dagger.hilt.android.scopes.ViewModelScoped

@Module
@InstallIn(ViewModelComponent::class)
class ClientModule {

@ViewModelScoped
@Provides
fun provideClientScopeProvider(
@KaliumCoreLogic coreLogic: CoreLogic,
@CurrentAccount currentAccount: UserId
): ClientScope = coreLogic.getSessionScope(currentAccount).client

@ViewModelScoped
@Provides
fun provideMlsKeyPackageCountUseCase(clientScope: ClientScope): MLSKeyPackageCountUseCase =
clientScope.mlsKeyPackageCountUseCase

@ViewModelScoped
@Provides
fun provideRestartSlowSyncProcessForRecoveryUseCase(clientScope: ClientScope): RestartSlowSyncProcessForRecoveryUseCase =
clientScope.restartSlowSyncProcessForRecoveryUseCase

@ViewModelScoped
@Provides
fun provideDeleteClientUseCase(clientScope: ClientScope): DeleteClientUseCase = clientScope.deleteClient

@ViewModelScoped
@Provides
fun provideGetOrRegisterClientUseCase(clientScope: ClientScope): GetOrRegisterClientUseCase =
clientScope.getOrRegister

@ViewModelScoped
@Provides
fun providePersistOtherUsersClients(clientScope: ClientScope): PersistOtherUserClientsUseCase =
clientScope.persistOtherUserClients

@ViewModelScoped
@Provides
fun provideGetOtherUsersClients(clientScope: ClientScope): ObserveClientsByUserIdUseCase =
clientScope.getOtherUserClients

@ViewModelScoped
@Provides
fun provideSelfClientsUseCase(clientScope: ClientScope): FetchSelfClientsFromRemoteUseCase =
clientScope.selfClients

@ViewModelScoped
@Provides
fun provideClientFingerPrintUseCase(clientScope: ClientScope): ClientFingerprintUseCase =
clientScope.remoteClientFingerPrint

@ViewModelScoped
@Provides
fun provideUpdateClientVerificationStatusUseCase(clientScope: ClientScope): UpdateClientVerificationStatusUseCase =
clientScope.updateClientVerificationStatus


@ViewModelScoped
@Provides
fun provideGetClientDetailsUseCase(clientScope: ClientScope): ObserveClientDetailsUseCase = clientScope.observeClientDetailsUseCase

@ViewModelScoped
@Provides
fun provideObserveCurrentClientUseCase(clientScope: ClientScope): ObserveCurrentClientIdUseCase =
clientScope.observeCurrentClientId

@ViewModelScoped
@Provides
fun provideNeedsToRegisterClientUseCase(clientScope: ClientScope): NeedsToRegisterClientUseCase =
clientScope.needsToRegisterClient
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Wire
* Copyright (C) 2023 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.di.accountScoped

import com.wire.android.di.CurrentAccount
import com.wire.android.di.KaliumCoreLogic
import com.wire.kalium.logic.CoreLogic
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.connection.ConnectionScope
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ViewModelComponent
import dagger.hilt.android.scopes.ViewModelScoped


@Module
@InstallIn(ViewModelComponent::class)
class ConnectionModule {

@ViewModelScoped
@Provides
fun provideConnectionScope(
@CurrentAccount currentAccount: UserId,
@KaliumCoreLogic coreLogic: CoreLogic
): ConnectionScope = coreLogic.getSessionScope(currentAccount).connection

@ViewModelScoped
@Provides
fun provideSendConnectionRequestUseCase(connectionScope: ConnectionScope) =
connectionScope.sendConnectionRequest

@ViewModelScoped
@Provides
fun provideCancelConnectionRequestUseCase(connectionScope: ConnectionScope) =
connectionScope.cancelConnectionRequest

@ViewModelScoped
@Provides
fun provideIgnoreConnectionRequestUseCase(connectionScope: ConnectionScope) =
connectionScope.ignoreConnectionRequest

@ViewModelScoped
@Provides
fun provideAcceptConnectionRequestUseCase(connectionScope: ConnectionScope) =
connectionScope.acceptConnectionRequest
}
Loading

0 comments on commit e24bf0a

Please sign in to comment.