taler-code-examples

Reference examples (sample code)
Log | Files | Refs | README | LICENSE

AnastasisResults.kt (2286B)


      1 /*
      2  * This file is part of GNU Taler
      3  * (C) 2024 Taler Systems S.A.
      4  *
      5  * GNU Taler is free software; you can redistribute it and/or modify it under the
      6  * terms of the GNU General Public License as published by the Free Software
      7  * Foundation; either version 3, or (at your option) any later version.
      8  *
      9  * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
     10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11  * A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License along with
     14  * GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15  */
     16 
     17 package net.taler.anastasislib.model
     18 
     19 import android.net.Uri
     20 
     21 sealed class AnastasisBackupResult(
     22     open val resultCode: Int,
     23     open val message: String?,
     24 ) {
     25     data class Success(
     26         override val resultCode: Int,
     27         override val message: String? = null,
     28         val secretName: String,
     29         val expirationDateTime: String,
     30     ) : AnastasisBackupResult(resultCode, message)
     31 
     32     data class Error(
     33         override val resultCode: Int,
     34         override val message: String? = null,
     35     ) : AnastasisBackupResult(resultCode, message)
     36 }
     37 
     38 sealed class AnastasisRecoveryResult(
     39     open val resultCode: Int,
     40     open val message: String?,
     41 ) {
     42     data class Success(
     43         override val resultCode: Int,
     44         override val message: String? = null,
     45         val secretFileContentUri: Uri,
     46     ) : AnastasisRecoveryResult(resultCode, message)
     47 
     48     data class Error(
     49         override val resultCode: Int,
     50         override val message: String? = null,
     51     ) : AnastasisRecoveryResult(resultCode, message)
     52 }
     53 
     54 object AnastasisResultCode {
     55     /**
     56      * Similar to Activity.CANCELED.
     57      */
     58     const val ERROR_USER_ABORTED = 0
     59 
     60     /**
     61      * Invalid or missing data received from the caller app.
     62      */
     63     const val ERROR_INVALID_DATA = 1
     64 
     65     /**
     66      * Internal error in Anastasis.
     67      */
     68     const val ERROR_INTERNAL = 2
     69 
     70     /**
     71      * Secret not found.
     72      */
     73     const val SECRET_NOT_FOUND = 3
     74 
     75     /**
     76      * Backup success.
     77      */
     78     const val BACKUP_SUCCESS = 100
     79 
     80     /**
     81      * Recovery success.
     82      */
     83     const val RECOVERY_SUCCESS = 101
     84 }