2024-11-26 08:38:12 -03:00
|
|
|
/*
|
2025-01-02 06:50:26 -03:00
|
|
|
* Copyright (c) 2025 Meshtastic LLC
|
2024-11-26 08:38:12 -03:00
|
|
|
*
|
|
|
|
|
* 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 <https://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-02-08 13:50:21 -08:00
|
|
|
package com.geeksville.mesh.database
|
|
|
|
|
|
|
|
|
|
import android.app.Application
|
2022-09-13 22:49:38 -03:00
|
|
|
import com.geeksville.mesh.database.dao.MeshLogDao
|
2023-09-05 08:19:26 -03:00
|
|
|
import com.geeksville.mesh.database.dao.NodeInfoDao
|
2022-09-14 01:54:13 -03:00
|
|
|
import com.geeksville.mesh.database.dao.PacketDao
|
2022-08-11 16:43:26 +01:00
|
|
|
import com.geeksville.mesh.database.dao.QuickChatActionDao
|
2022-02-08 13:50:21 -08:00
|
|
|
import dagger.Module
|
|
|
|
|
import dagger.Provides
|
|
|
|
|
import dagger.hilt.InstallIn
|
|
|
|
|
import dagger.hilt.components.SingletonComponent
|
2022-07-29 21:28:09 -03:00
|
|
|
import javax.inject.Singleton
|
2022-02-08 13:50:21 -08:00
|
|
|
|
|
|
|
|
@InstallIn(SingletonComponent::class)
|
|
|
|
|
@Module
|
|
|
|
|
class DatabaseModule {
|
|
|
|
|
@Provides
|
2022-07-29 21:28:09 -03:00
|
|
|
@Singleton
|
|
|
|
|
fun provideDatabase(app: Application): MeshtasticDatabase =
|
|
|
|
|
MeshtasticDatabase.getDatabase(app)
|
2022-02-08 13:50:21 -08:00
|
|
|
|
2023-09-05 08:19:26 -03:00
|
|
|
@Provides
|
|
|
|
|
fun provideNodeInfoDao(database: MeshtasticDatabase): NodeInfoDao {
|
|
|
|
|
return database.nodeInfoDao()
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-14 01:54:13 -03:00
|
|
|
@Provides
|
|
|
|
|
fun providePacketDao(database: MeshtasticDatabase): PacketDao {
|
|
|
|
|
return database.packetDao()
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-08 13:50:21 -08:00
|
|
|
@Provides
|
2022-09-13 22:49:38 -03:00
|
|
|
fun provideMeshLogDao(database: MeshtasticDatabase): MeshLogDao {
|
|
|
|
|
return database.meshLogDao()
|
2022-02-08 13:50:21 -08:00
|
|
|
}
|
2022-08-11 16:43:26 +01:00
|
|
|
|
|
|
|
|
@Provides
|
|
|
|
|
fun provideQuickChatActionDao(database: MeshtasticDatabase): QuickChatActionDao {
|
|
|
|
|
return database.quickChatActionDao()
|
|
|
|
|
}
|
2022-02-08 13:50:21 -08:00
|
|
|
}
|