app/src/main/java/com/geekorum/ttrss/sync/DatabaseService.kt
author Da Risk <da_risk@geekorum.com>
Sat, 11 May 2019 19:53:20 -0700
changeset 149 1e4bb9b9b86c
parent 137 5464f07a306c
child 150 c6077ce0d399
permissions -rw-r--r--
Synchronization: convert DAO to kotlin and use suspendable functions
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
137
5464f07a306c Update copyright headers for 2019
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
     1
/*
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     2
 * Geekttrss is a RSS feed reader application on the Android Platform.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     3
 *
137
5464f07a306c Update copyright headers for 2019
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
     4
 * Copyright (C) 2017-2019 by Frederic-Charles Barthelery.
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     5
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     6
 * This file is part of Geekttrss.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     7
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     8
 * Geekttrss is free software: you can redistribute it and/or modify
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     9
 * it under the terms of the GNU General Public License as published by
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    10
 * the Free Software Foundation, either version 3 of the License, or
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    11
 * (at your option) any later version.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    12
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    13
 * Geekttrss is distributed in the hope that it will be useful,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    16
 * GNU General Public License for more details.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    17
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    18
 * You should have received a copy of the GNU General Public License
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    19
 * along with Geekttrss.  If not, see <http://www.gnu.org/licenses/>.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    20
 */
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    21
package com.geekorum.ttrss.sync
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    22
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    23
import com.geekorum.ttrss.data.Article
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    24
import com.geekorum.ttrss.data.Category
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    25
import com.geekorum.ttrss.data.Feed
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    26
import com.geekorum.ttrss.data.Transaction
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    27
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    28
/**
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    29
 * Database access interface for the synchronization process.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    30
 */
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    31
interface DatabaseService {
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    32
    fun beginTransaction()
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    33
    fun endTransaction()
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    34
    fun setTransactionSuccessful()
149
1e4bb9b9b86c Synchronization: convert DAO to kotlin and use suspendable functions
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    35
    suspend fun <R> runInTransaction(block: suspend () -> R)
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    36
149
1e4bb9b9b86c Synchronization: convert DAO to kotlin and use suspendable functions
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    37
    suspend fun insertFeeds(feeds: List<Feed>)
1e4bb9b9b86c Synchronization: convert DAO to kotlin and use suspendable functions
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    38
    suspend fun deleteFeedsAndArticles(feeds: List<Feed>)
1e4bb9b9b86c Synchronization: convert DAO to kotlin and use suspendable functions
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    39
    suspend fun getFeeds(): List<Feed>
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    40
149
1e4bb9b9b86c Synchronization: convert DAO to kotlin and use suspendable functions
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    41
    suspend fun insertCategories(categories: List<Category>)
1e4bb9b9b86c Synchronization: convert DAO to kotlin and use suspendable functions
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    42
    suspend fun deleteCategories(categories: List<Category>)
1e4bb9b9b86c Synchronization: convert DAO to kotlin and use suspendable functions
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    43
    suspend fun getCategories(): List<Category>
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    44
149
1e4bb9b9b86c Synchronization: convert DAO to kotlin and use suspendable functions
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    45
    suspend fun getTransactions(): List<Transaction>
1e4bb9b9b86c Synchronization: convert DAO to kotlin and use suspendable functions
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    46
    suspend fun deleteTransaction(transaction: Transaction)
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    47
149
1e4bb9b9b86c Synchronization: convert DAO to kotlin and use suspendable functions
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    48
    suspend fun getArticle(id: Long): Article?
1e4bb9b9b86c Synchronization: convert DAO to kotlin and use suspendable functions
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    49
    suspend fun insertArticles(articles: List<Article>)
1e4bb9b9b86c Synchronization: convert DAO to kotlin and use suspendable functions
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    50
    suspend fun updateArticle(article: Article)
1e4bb9b9b86c Synchronization: convert DAO to kotlin and use suspendable functions
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    51
    suspend fun getLatestArticleId(): Long?
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    52
149
1e4bb9b9b86c Synchronization: convert DAO to kotlin and use suspendable functions
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    53
    suspend fun updateArticleMetadata(
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    54
        id: Long, unread: Boolean, transientUnread: Boolean, starred: Boolean,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    55
        published: Boolean, lastTimeUpdated: Long, isUpdated: Boolean)
137
5464f07a306c Update copyright headers for 2019
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
    56
}