diff options
author | Iván Ávalos <avalos@disroot.org> | 2023-01-27 10:52:39 -0600 |
---|---|---|
committer | Torsten Grote <t@grobox.de> | 2023-02-22 08:33:24 -0300 |
commit | b76b00114d92a4e547503c9c2b3416c9b164db55 (patch) | |
tree | c29c0adad6358a72c318b095933c123d55333302 /wallet/src/main/java | |
parent | 5f7e7ac2913de385bd03f0fa67974865d10188b3 (diff) | |
download | taler-android-b76b00114d92a4e547503c9c2b3416c9b164db55.tar.gz taler-android-b76b00114d92a4e547503c9c2b3416c9b164db55.tar.bz2 taler-android-b76b00114d92a4e547503c9c2b3416c9b164db55.zip |
[wallet] TalerWalletCore now pulled from Maven
Diffstat (limited to 'wallet/src/main/java')
3 files changed, 13 insertions, 81 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/backend/TalerWalletCore.kt b/wallet/src/main/java/net/taler/wallet/backend/TalerWalletCore.kt deleted file mode 100644 index 65ad58b..0000000 --- a/wallet/src/main/java/net/taler/wallet/backend/TalerWalletCore.kt +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of GNU Taler - * (C) 2023 Taler Systems S.A. - * - * GNU Taler 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, or (at your option) any later version. - * - * GNU Taler 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 - * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -/* - * This file is part of GNU Taler - * (C) 2023 Taler Systems S.A. - * - * GNU Taler 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, or (at your option) any later version. - * - * GNU Taler 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 - * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> - */ - -package net.taler.wallet.backend - -import com.sun.jna.Callback -import com.sun.jna.Library -import com.sun.jna.Native -import com.sun.jna.Pointer - -interface TalerWalletCore: Library { - companion object { - val INSTANCE: TalerWalletCore by lazy { - Native.load("talerwalletcore", TalerWalletCore::class.java) - } - } - - interface TALER_WALLET_MessageHandlerFn: Callback { - fun invoke(handler_p: Pointer, message: String) - } - - interface TALER_LogFn: Callback { - fun invoke(cls: Pointer, stream: Int, msg: String) - } - - fun TALER_WALLET_create(): Pointer - fun TALER_WALLET_set_message_handler(twi: Pointer, handler_f: TALER_WALLET_MessageHandlerFn, handler_p: Pointer) - fun TALER_WALLET_send_request(twi: Pointer, request: String): Int - fun TALER_WALLET_run(twi: Pointer): Int - fun TALER_WALLET_join(twi: Pointer) - fun TALER_start_redirect_std(logfn: TALER_LogFn, cls: Pointer) -}
\ No newline at end of file diff --git a/wallet/src/main/java/net/taler/wallet/backend/WalletBackendService.kt b/wallet/src/main/java/net/taler/wallet/backend/WalletBackendService.kt index 7b93a21..a14fbf9 100644 --- a/wallet/src/main/java/net/taler/wallet/backend/WalletBackendService.kt +++ b/wallet/src/main/java/net/taler/wallet/backend/WalletBackendService.kt @@ -25,7 +25,7 @@ import android.os.Message import android.os.Messenger import android.os.RemoteException import android.util.Log -import com.sun.jna.Pointer +import net.taler.qtart.TalerWalletCore import net.taler.wallet.HostCardEmulatorService import org.json.JSONObject import java.lang.ref.WeakReference @@ -45,8 +45,7 @@ class WalletBackendService : Service() { */ private val messenger: Messenger = Messenger(IncomingHandler(this)) - private lateinit var walletCore: TalerWalletCore - private lateinit var instance: Pointer + private val walletCore = TalerWalletCore() private var initialized = false @@ -59,19 +58,13 @@ class WalletBackendService : Service() { override fun onCreate() { Log.i(TAG, "onCreate in wallet backend service") - walletCore = TalerWalletCore.INSTANCE - instance = walletCore.TALER_WALLET_create() - walletCore.TALER_WALLET_set_message_handler(instance, object: TalerWalletCore.TALER_WALLET_MessageHandlerFn { - override fun invoke(handler_p: Pointer, message: String) { - this@WalletBackendService.handleAkonoMessage(message) - } - }, instance) - walletCore.TALER_start_redirect_std(object: TalerWalletCore.TALER_LogFn { - override fun invoke(cls: Pointer, stream: Int, msg: String) { - Log.d(TAG, "wallet log: $msg") - } - }, instance) - walletCore.TALER_WALLET_run(instance) + walletCore.setMessageHandler { + this@WalletBackendService.handleAkonoMessage(it) + } + walletCore.setStdoutHandler { + Log.d(TAG, "wallet log: $it") + } + walletCore.run() sendInitMessage() // runIntegrationTest() super.onCreate() @@ -84,7 +77,7 @@ class WalletBackendService : Service() { msg.put("args", args) args.put("persistentStoragePath", "${application.filesDir}/$WALLET_DB") Log.d(TAG, "init message: ${msg.toString(2)}") - walletCore.TALER_WALLET_send_request(instance, msg.toString()) + walletCore.sendRequest(msg.toString()) } /** @@ -102,7 +95,7 @@ class WalletBackendService : Service() { args.put("merchantBaseUrl", "https://backend.demo.taler.net/") args.put("merchantAuthToken", "secret-token:sandbox") Log.d(TAG, "integration test message: ${msg.toString(2)}") - walletCore.TALER_WALLET_send_request(instance, msg.toString()) + walletCore.sendRequest(msg.toString()) } /** @@ -142,7 +135,7 @@ class WalletBackendService : Service() { request.put("operation", operation) request.put("id", serviceRequestID) request.put("args", argsObj) - svc.walletCore.TALER_WALLET_send_request(svc.instance, request.toString(2)) + svc.walletCore.sendRequest(request.toString()) Log.i( TAG, "mapping service request ID $serviceRequestID to client request ID $clientRequestID" diff --git a/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt b/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt index 8bb0a4a..11c252b 100644 --- a/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/settings/SettingsFragment.kt @@ -28,10 +28,10 @@ import com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_SHORT import com.google.android.material.snackbar.Snackbar import net.taler.common.showError import net.taler.common.toRelativeTime +import net.taler.qtart.BuildConfig.WALLET_CORE_VERSION import net.taler.wallet.BuildConfig.FLAVOR import net.taler.wallet.BuildConfig.VERSION_CODE import net.taler.wallet.BuildConfig.VERSION_NAME -import net.taler.wallet.BuildConfig.WALLET_CORE_VERSION import net.taler.wallet.MainViewModel import net.taler.wallet.R import net.taler.wallet.withdraw.WithdrawTestStatus |