From fe0675ddd3a36ba4ab587bf53aecf2797aa532e5 Mon Sep 17 00:00:00 2001 From: "yying.jin" Date: Wed, 4 Nov 2026 15:30:03 +0800 Subject: [PATCH 1/3] [in_app_purchase] Migrate from platform channels to Dart FFI Replace the MethodChannel transport with dart:ffi bindings generated by the pigeon C++ FFI generator (git ref 1e63f1b5), following the video_player migration in #1207. - Generate the C++ FFI bindings (messages_ffi.{h,cc}), the Dart FFI bindings (messages.g.ffi.dart), and the ffigen config from pigeons/messages.dart - Marshal every FFI entry point onto the platform thread's GLib main context via a MainContextDispatcher, preserving the thread affinity the messenger-based implementation provided - Register the FFI API at plugin construction and tear it down in Dispose() - Add an integration test that round-trips sync and async FFI calls - Bump version to 0.2.0 Co-Authored-By: Cline SR --- packages/in_app_purchase/CHANGELOG.md | 3 +- packages/in_app_purchase/README.md | 2 +- .../in_app_purchase_test.dart | 57 + .../in_app_purchase/lib/src/messages.g.dart | 983 +++++++--- .../lib/src/messages.g.ffi.dart | 191 ++ .../in_app_purchase/pigeons/messages.dart | 27 +- packages/in_app_purchase/pubspec.yaml | 10 +- .../tizen/src/in_app_purchase_tizen_plugin.cc | 76 +- .../in_app_purchase/tizen/src/messages.cc | 1632 ++++++++++++----- packages/in_app_purchase/tizen/src/messages.h | 370 ++-- .../in_app_purchase/tizen/src/messages_ffi.cc | 476 +++++ .../in_app_purchase/tizen/src/messages_ffi.h | 88 + .../tool/pigeon/messages_ffigen_config.yaml | 19 + 13 files changed, 3108 insertions(+), 826 deletions(-) create mode 100644 packages/in_app_purchase/lib/src/messages.g.ffi.dart create mode 100644 packages/in_app_purchase/tizen/src/messages_ffi.cc create mode 100644 packages/in_app_purchase/tizen/src/messages_ffi.h create mode 100644 packages/in_app_purchase/tool/pigeon/messages_ffigen_config.yaml diff --git a/packages/in_app_purchase/CHANGELOG.md b/packages/in_app_purchase/CHANGELOG.md index 28a2d4ee4..f5046e7b5 100644 --- a/packages/in_app_purchase/CHANGELOG.md +++ b/packages/in_app_purchase/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 0.2.0 +* Migrate from platform channels to Dart FFI using the pigeon C++ FFI generator (git ref 1e63f1b5). * Apply clang-format-16 formatting. ## 0.1.9 diff --git a/packages/in_app_purchase/README.md b/packages/in_app_purchase/README.md index 879bba61f..1fa09e2c2 100644 --- a/packages/in_app_purchase/README.md +++ b/packages/in_app_purchase/README.md @@ -35,7 +35,7 @@ This package is not an _endorsed_ implementation of `in_app_purchase`. Therefore ```yaml dependencies: in_app_purchase: ^3.3.0 - in_app_purchase_tizen: ^0.1.9 + in_app_purchase_tizen: ^0.2.0 ``` Then you can import `in_app_purchase` and `in_app_purchase_tizen` in your Dart code: diff --git a/packages/in_app_purchase/example/integration_test/in_app_purchase_test.dart b/packages/in_app_purchase/example/integration_test/in_app_purchase_test.dart index 7a6f2cd7a..f5970c1d2 100644 --- a/packages/in_app_purchase/example/integration_test/in_app_purchase_test.dart +++ b/packages/in_app_purchase/example/integration_test/in_app_purchase_test.dart @@ -2,8 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:async'; + import 'package:flutter_test/flutter_test.dart'; import 'package:in_app_purchase/in_app_purchase.dart'; +import 'package:in_app_purchase_tizen/in_app_purchase_tizen.dart'; import 'package:integration_test/integration_test.dart'; void main() { @@ -13,4 +16,58 @@ void main() { final InAppPurchase iapInstance = InAppPurchase.instance; expect(iapInstance, isNotNull); }); + + test('FFI host API smoke test', () async { + final InAppPurchase iap = InAppPurchase.instance; + final InAppPurchaseTizenPlatformAddition addition = + iap.getPlatformAddition(); + addition.setRequestParameters( + appId: 'test', + pageSize: 15, + pageNum: 1, + securityKey: 'test', + ); + + Object? asyncError; + bool? available; + try { + available = await iap.isAvailable().timeout(const Duration(seconds: 15)); + } catch (error) { + asyncError = error; + } + expect( + asyncError, + isNot(isA()), + reason: 'isAvailable() never completed: FFI reply never arrived', + ); + final asyncErrorText = '$asyncError'; + expect(asyncErrorText, isNot(contains('Failed to lookup symbol'))); + expect(asyncErrorText, isNot(contains('has not been set up'))); + expect(asyncErrorText, isNot(contains('BinaryMessenger is not supported'))); + if (available == null && asyncError == null) { + fail('isAvailable() produced neither a value nor an error'); + } + + Object? queryError; + ProductDetailsResponse? response; + try { + response = await iap + .queryProductDetails({}) + .timeout(const Duration(seconds: 30)); + } catch (error) { + queryError = error; + } + expect( + queryError, + isNot(isA()), + reason: 'queryProductDetails() never completed: FFI reply never arrived', + ); + final queryErrorText = '$queryError'; + expect(queryErrorText, isNot(contains('Failed to lookup symbol'))); + expect(queryErrorText, isNot(contains('has not been set up'))); + expect(queryErrorText, isNot(contains('BinaryMessenger is not supported'))); + if (response == null && queryError == null) { + fail('queryProductDetails() produced neither a value nor an error'); + } + }); } diff --git a/packages/in_app_purchase/lib/src/messages.g.dart b/packages/in_app_purchase/lib/src/messages.g.dart index 65a263b7a..cd5946d2b 100644 --- a/packages/in_app_purchase/lib/src/messages.g.dart +++ b/packages/in_app_purchase/lib/src/messages.g.dart @@ -1,20 +1,233 @@ -// Autogenerated from Pigeon (v22.7.4), do not edit directly. +// Autogenerated from Pigeon (v29.0.11), do not edit directly. // See also: https://pub.dev/packages/pigeon -// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers +// ignore_for_file: unused_import, unused_shown_name +// ignore_for_file: type=lint +import 'dart:ffi' as ffi; import 'dart:async'; -import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; +import 'dart:io' show File, Platform; +import 'dart:typed_data' show ByteData, Float64List, Int32List, Int64List, Uint8List; -import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; +import 'package:ffi/ffi.dart' as pkg_ffi; import 'package:flutter/services.dart'; +import 'package:meta/meta.dart' show immutable, protected, visibleForTesting; +import 'messages.g.ffi.dart' as pigeon_ffi; + +Object? _extractReplyValueOrThrow( + List? replyList, + String channelName, { + required bool isNullValid, +}) { + if (replyList == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel: "$channelName".', + ); + } else if (replyList.length > 1) { + throw PlatformException( + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], + ); + } else if (!isNullValid && (replyList.isNotEmpty && replyList[0] == null)) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } + return replyList.firstOrNull; +} + + +ffi.Pointer _encodeFfiRequest(ByteData? message) { + if (message == null) { + return ffi.nullptr; + } + final Uint8List bytes = message.buffer.asUint8List(message.offsetInBytes, message.lengthInBytes); + final ffi.Pointer data = pkg_ffi.calloc(bytes.length); + data.asTypedList(bytes.length).setAll(0, bytes); + final ffi.Pointer buffer = + pkg_ffi.calloc(); + buffer.ref.data = data; + buffer.ref.length = bytes.length; + return buffer; +} -PlatformException _createConnectionError(String channelName) { - return PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel: "$channelName".', - ); +void _freeFfiRequest(ffi.Pointer buffer) { + if (buffer == ffi.nullptr) { + return; + } + pkg_ffi.calloc.free(buffer.ref.data); + pkg_ffi.calloc.free(buffer); } +List? _decodeFfiReply( + MessageCodec codec, + ffi.Pointer buffer, +) { + if (buffer == ffi.nullptr || buffer.ref.data == ffi.nullptr) { + return null; + } + final Uint8List bytes = Uint8List.fromList(buffer.ref.data.asTypedList(buffer.ref.length)); + return codec.decodeMessage(ByteData.sublistView(bytes)) as List?; +} + +ffi.DynamicLibrary _openPigeonNativeLibrary() { + try { + return (() { + final String libraryPath = File('/proc/self/maps') + .readAsLinesSync() + .map((String line) { + final int index = line.indexOf('/'); + return index == -1 ? '' : line.substring(index); + }) + .firstWhere( + (String path) => path.endsWith('/libflutter_plugins.so'), + ); + return ffi.DynamicLibrary.open(libraryPath); +})(); + } catch (error) { + throw StateError( + 'Pigeon FFI: failed to open the native library. The plugin shared ' + 'library may not be loaded yet. Avoid constructing FFI bindings ' + 'during plugin registration; construct them lazily on first use. ' + 'Original error: $error'); + } +} + +late final ffi.DynamicLibrary _pigeonNativeLibrary = _openPigeonNativeLibrary(); + +ffi.Pointer _pigeonFfiLookup(String symbolName) { + return _pigeonNativeLibrary.lookup(symbolName); +} + +final pigeon_ffi.InAppPurchaseTizenFfiBindings _pigeonVar_defaultFfiBindings = + pigeon_ffi.InAppPurchaseTizenFfiBindings.fromLookup(_pigeonFfiLookup); + +typedef _PigeonFfiReplyCallbackNative = ffi.Void Function( + ffi.Int64 replyId, + ffi.Pointer reply, +); + +class _PigeonFfiAsyncReply { + _PigeonFfiAsyncReply({ + required this.ffiBindings, + required this.codec, + required this.channelName, + required this.isNullValid, + required this.complete, + required this.completeError, + }); + + final pigeon_ffi.InAppPurchaseTizenFfiBindings ffiBindings; + final MessageCodec codec; + final String channelName; + final bool isNullValid; + final void Function(Object? value) complete; + final void Function(Object error, StackTrace stackTrace) completeError; +} + +final Map _pigeonFfiAsyncReplies = + {}; +int _pigeonNextFfiAsyncReplyId = 1; + +final ffi.NativeCallable<_PigeonFfiReplyCallbackNative> _pigeonFfiReplyCallback = + ffi.NativeCallable<_PigeonFfiReplyCallbackNative>.listener(_handlePigeonFfiReply) + ..keepIsolateAlive = false; + +// Cache the callback for reuse; only unfinished requests keep the isolate alive. +void _updatePigeonFfiReplyCallbackKeepAlive() { + _pigeonFfiReplyCallback.keepIsolateAlive = _pigeonFfiAsyncReplies.isNotEmpty; +} + +void _handlePigeonFfiReply( + int replyId, + ffi.Pointer reply, +) { + final _PigeonFfiAsyncReply? asyncReply = _pigeonFfiAsyncReplies.remove(replyId); + try { + if (asyncReply != null) { + final List? replyList = _decodeFfiReply(asyncReply.codec, reply); + final Object? replyValue = _extractReplyValueOrThrow( + replyList, + asyncReply.channelName, + isNullValid: asyncReply.isNullValid, + ); + asyncReply.complete(replyValue); + } + } catch (error, stackTrace) { + asyncReply?.completeError(error, stackTrace); + } finally { + if (reply != ffi.nullptr) { + (asyncReply?.ffiBindings ?? _pigeonVar_defaultFfiBindings).pigeon_free_buffer(reply); + } + _updatePigeonFfiReplyCallbackKeepAlive(); + } +} + +bool _deepEquals(Object? a, Object? b) { + if (identical(a, b)) { + return true; + } + if (a is double && b is double) { + if (a.isNaN && b.isNaN) { + return true; + } + return a == b; + } + if (a is List && b is List) { + return a.length == b.length && + a.indexed + .every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1])); + } + if (a is Map && b is Map) { + if (a.length != b.length) { + return false; + } + for (final MapEntry entryA in a.entries) { + bool found = false; + for (final MapEntry entryB in b.entries) { + if (_deepEquals(entryA.key, entryB.key)) { + if (_deepEquals(entryA.value, entryB.value)) { + found = true; + break; + } else { + return false; + } + } + } + if (!found) { + return false; + } + } + return true; + } + return a == b; +} + +int _deepHash(Object? value) { + if (value is List) { + return Object.hashAll(value.map(_deepHash)); + } + if (value is Map) { + int result = 0; + for (final MapEntry entry in value.entries) { + result += (_deepHash(entry.key) * 31) ^ _deepHash(entry.value); + } + return result; + } + if (value is double && value.isNaN) { + // Normalize NaN to a consistent hash. + return 0x7FF8000000000000.hashCode; + } + if (value is double && value == 0.0) { + // Normalize -0.0 to 0.0 so they have the same hash code. + return 0.0.hashCode; + } + return value.hashCode; +} + + /// Dart wrapper around [`ProductsListApiResult`] in (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). /// /// Defines a dictionary for product list data returned by the getProductsList API. @@ -47,10 +260,19 @@ class ProductsListApiResult { /// ItemDetails in JSON format List?> itemDetails; - Object encode() { - return [cpStatus, cpResult, totalCount, checkValue, itemDetails]; + List _toList() { + return [ + cpStatus, + cpResult, + totalCount, + checkValue, + itemDetails, + ]; } + Object encode() { + return _toList(); } + static ProductsListApiResult decode(Object result) { result as List; return ProductsListApiResult( @@ -58,9 +280,30 @@ class ProductsListApiResult { cpResult: result[1] as String?, totalCount: result[2]! as int, checkValue: result[3]! as String, - itemDetails: (result[4] as List?)!.cast?>(), + itemDetails: (result[4]! as List).cast?>(), ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! ProductsListApiResult || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(cpStatus, other.cpStatus) && _deepEquals(cpResult, other.cpResult) && _deepEquals(totalCount, other.totalCount) && _deepEquals(checkValue, other.checkValue) && _deepEquals(itemDetails, other.itemDetails); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => _deepHash([runtimeType, ..._toList()]); + + @override + String toString() { + return 'ProductsListApiResult(cpStatus: $cpStatus, cpResult: $cpResult, totalCount: $totalCount, checkValue: $checkValue, itemDetails: $itemDetails)'; + } } /// Dart wrapper around [`GetUserPurchaseListAPIResult`] in (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). @@ -94,10 +337,19 @@ class GetUserPurchaseListAPIResult { /// InvoiceDetailsin JSON format. List?> invoiceDetails; - Object encode() { - return [cpStatus, cpResult, totalCount, checkValue, invoiceDetails]; + List _toList() { + return [ + cpStatus, + cpResult, + totalCount, + checkValue, + invoiceDetails, + ]; } + Object encode() { + return _toList(); } + static GetUserPurchaseListAPIResult decode(Object result) { result as List; return GetUserPurchaseListAPIResult( @@ -105,16 +357,40 @@ class GetUserPurchaseListAPIResult { cpResult: result[1] as String?, totalCount: result[2]! as int, checkValue: result[3]! as String, - invoiceDetails: (result[4] as List?)!.cast?>(), + invoiceDetails: (result[4]! as List).cast?>(), ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! GetUserPurchaseListAPIResult || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(cpStatus, other.cpStatus) && _deepEquals(cpResult, other.cpResult) && _deepEquals(totalCount, other.totalCount) && _deepEquals(checkValue, other.checkValue) && _deepEquals(invoiceDetails, other.invoiceDetails); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => _deepHash([runtimeType, ..._toList()]); + + @override + String toString() { + return 'GetUserPurchaseListAPIResult(cpStatus: $cpStatus, cpResult: $cpResult, totalCount: $totalCount, checkValue: $checkValue, invoiceDetails: $invoiceDetails)'; + } } /// Dart wrapper around [`BillingBuyData`](https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html#BillingBuyData). /// /// Defines the payment result and information. class BillingBuyData { - BillingBuyData({required this.payResult, required this.payDetails}); + BillingBuyData({ + required this.payResult, + required this.payDetails, + }); /// The payment result String payResult; @@ -122,17 +398,44 @@ class BillingBuyData { /// The payment information. It is same with paymentDetails param of buyItem. Map payDetails; - Object encode() { - return [payResult, payDetails]; + List _toList() { + return [ + payResult, + payDetails, + ]; } + Object encode() { + return _toList(); } + static BillingBuyData decode(Object result) { result as List; return BillingBuyData( payResult: result[0]! as String, - payDetails: (result[1] as Map?)!.cast(), + payDetails: (result[1]! as Map).cast(), ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! BillingBuyData || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(payResult, other.payResult) && _deepEquals(payDetails, other.payDetails); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => _deepHash([runtimeType, ..._toList()]); + + @override + String toString() { + return 'BillingBuyData(payResult: $payResult, payDetails: $payDetails)'; + } } /// Dart wrapper around [`VerifyInvoiceAPIResult`] in (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). @@ -159,10 +462,18 @@ class VerifyInvoiceAPIResult { /// Invoice ID that you want to verify whether a purchase was successful. String invoiceId; - Object encode() { - return [cpStatus, cpResult, appId, invoiceId]; + List _toList() { + return [ + cpStatus, + cpResult, + appId, + invoiceId, + ]; } + Object encode() { + return _toList(); } + static VerifyInvoiceAPIResult decode(Object result) { result as List; return VerifyInvoiceAPIResult( @@ -172,6 +483,27 @@ class VerifyInvoiceAPIResult { invoiceId: result[3]! as String, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! VerifyInvoiceAPIResult || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(cpStatus, other.cpStatus) && _deepEquals(cpResult, other.cpResult) && _deepEquals(appId, other.appId) && _deepEquals(invoiceId, other.invoiceId); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => _deepHash([runtimeType, ..._toList()]); + + @override + String toString() { + return 'VerifyInvoiceAPIResult(cpStatus: $cpStatus, cpResult: $cpResult, appId: $appId, invoiceId: $invoiceId)'; + } } /// Dart wrapper around [`ServiceAvailableAPIResult`] in (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). @@ -179,7 +511,11 @@ class VerifyInvoiceAPIResult { /// Defines a dictionary for data returned by the IsServiceAvailable API. /// This only can be used in [BillingManager.isAvailable]. class ServiceAvailableAPIResult { - ServiceAvailableAPIResult({required this.status, required this.result, required this.serviceYn}); + ServiceAvailableAPIResult({ + required this.status, + required this.result, + required this.serviceYn, + }); /// The result code of connecting to billing server. /// Returns "100000" on success and other codes on failure. @@ -193,10 +529,17 @@ class ServiceAvailableAPIResult { /// It will be null, if disconnect to billing server. String serviceYn; - Object encode() { - return [status, result, serviceYn]; + List _toList() { + return [ + status, + result, + serviceYn, + ]; } + Object encode() { + return _toList(); } + static ServiceAvailableAPIResult decode(Object result) { result as List; return ServiceAvailableAPIResult( @@ -205,6 +548,27 @@ class ServiceAvailableAPIResult { serviceYn: result[2]! as String, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! ServiceAvailableAPIResult || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(status, other.status) && _deepEquals(result, other.result) && _deepEquals(serviceYn, other.serviceYn); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => _deepHash([runtimeType, ..._toList()]); + + @override + String toString() { + return 'ServiceAvailableAPIResult(status: $status, result: $result, serviceYn: $serviceYn)'; + } } class ProductMessage { @@ -233,10 +597,19 @@ class ProductMessage { /// It is a Base64 hash generated by applying the HMAC SHA256 algorithm on a concatenated string of parameters using the DPI security key. String checkValue; - Object encode() { - return [appId, countryCode, pageSize, pageNum, checkValue]; + List _toList() { + return [ + appId, + countryCode, + pageSize, + pageNum, + checkValue, + ]; } + Object encode() { + return _toList(); } + static ProductMessage decode(Object result) { result as List; return ProductMessage( @@ -247,6 +620,27 @@ class ProductMessage { checkValue: result[4]! as String, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! ProductMessage || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(appId, other.appId) && _deepEquals(countryCode, other.countryCode) && _deepEquals(pageSize, other.pageSize) && _deepEquals(pageNum, other.pageNum) && _deepEquals(checkValue, other.checkValue); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => _deepHash([runtimeType, ..._toList()]); + + @override + String toString() { + return 'ProductMessage(appId: $appId, countryCode: $countryCode, pageSize: $pageSize, pageNum: $pageNum, checkValue: $checkValue)'; + } } class PurchaseMessage { @@ -274,10 +668,19 @@ class PurchaseMessage { /// ItemType, MUST use 2 as value ("all items") String checkValue; - Object encode() { - return [appId, customId, countryCode, pageNum, checkValue]; + List _toList() { + return [ + appId, + customId, + countryCode, + pageNum, + checkValue, + ]; } + Object encode() { + return _toList(); } + static PurchaseMessage decode(Object result) { result as List; return PurchaseMessage( @@ -288,6 +691,27 @@ class PurchaseMessage { checkValue: result[4]! as String, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! PurchaseMessage || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(appId, other.appId) && _deepEquals(customId, other.customId) && _deepEquals(countryCode, other.countryCode) && _deepEquals(pageNum, other.pageNum) && _deepEquals(checkValue, other.checkValue); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => _deepHash([runtimeType, ..._toList()]); + + @override + String toString() { + return 'PurchaseMessage(appId: $appId, customId: $customId, countryCode: $countryCode, pageNum: $pageNum, checkValue: $checkValue)'; + } } class OrderDetails { @@ -309,10 +733,19 @@ class OrderDetails { String orderCustomId; - Object encode() { - return [orderItemId, orderTitle, orderTotal, orderCurrencyId, orderCustomId]; + List _toList() { + return [ + orderItemId, + orderTitle, + orderTotal, + orderCurrencyId, + orderCustomId, + ]; } + Object encode() { + return _toList(); } + static OrderDetails decode(Object result) { result as List; return OrderDetails( @@ -323,10 +756,34 @@ class OrderDetails { orderCustomId: result[4]! as String, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! OrderDetails || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(orderItemId, other.orderItemId) && _deepEquals(orderTitle, other.orderTitle) && _deepEquals(orderTotal, other.orderTotal) && _deepEquals(orderCurrencyId, other.orderCurrencyId) && _deepEquals(orderCustomId, other.orderCustomId); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => _deepHash([runtimeType, ..._toList()]); + + @override + String toString() { + return 'OrderDetails(orderItemId: $orderItemId, orderTitle: $orderTitle, orderTotal: $orderTotal, orderCurrencyId: $orderCurrencyId, orderCustomId: $orderCustomId)'; + } } class BuyInfoMessage { - BuyInfoMessage({required this.appId, required this.payDetials}); + BuyInfoMessage({ + required this.appId, + required this.payDetials, + }); /// Application ID. String appId; @@ -334,13 +791,43 @@ class BuyInfoMessage { /// Payment parameters. OrderDetails payDetials; - Object encode() { - return [appId, payDetials]; + List _toList() { + return [ + appId, + payDetials, + ]; } + Object encode() { + return _toList(); } + static BuyInfoMessage decode(Object result) { result as List; - return BuyInfoMessage(appId: result[0]! as String, payDetials: result[1]! as OrderDetails); + return BuyInfoMessage( + appId: result[0]! as String, + payDetials: result[1]! as OrderDetails, + ); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! BuyInfoMessage || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(appId, other.appId) && _deepEquals(payDetials, other.payDetials); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => _deepHash([runtimeType, ..._toList()]); + + @override + String toString() { + return 'BuyInfoMessage(appId: $appId, payDetials: $payDetials)'; } } @@ -364,10 +851,18 @@ class InvoiceMessage { /// TV country code. String countryCode; - Object encode() { - return [appId, customId, invoiceId, countryCode]; + List _toList() { + return [ + appId, + customId, + invoiceId, + countryCode, + ]; } + Object encode() { + return _toList(); } + static InvoiceMessage decode(Object result) { result as List; return InvoiceMessage( @@ -377,8 +872,30 @@ class InvoiceMessage { countryCode: result[3]! as String, ); } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! InvoiceMessage || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(appId, other.appId) && _deepEquals(customId, other.customId) && _deepEquals(invoiceId, other.invoiceId) && _deepEquals(countryCode, other.countryCode); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => _deepHash([runtimeType, ..._toList()]); + + @override + String toString() { + return 'InvoiceMessage(appId: $appId, customId: $customId, invoiceId: $invoiceId, countryCode: $countryCode)'; + } } + class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -386,34 +903,34 @@ class _PigeonCodec extends StandardMessageCodec { if (value is int) { buffer.putUint8(4); buffer.putInt64(value); - } else if (value is ProductsListApiResult) { + } else if (value is ProductsListApiResult) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else if (value is GetUserPurchaseListAPIResult) { + } else if (value is GetUserPurchaseListAPIResult) { buffer.putUint8(130); writeValue(buffer, value.encode()); - } else if (value is BillingBuyData) { + } else if (value is BillingBuyData) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else if (value is VerifyInvoiceAPIResult) { + } else if (value is VerifyInvoiceAPIResult) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else if (value is ServiceAvailableAPIResult) { + } else if (value is ServiceAvailableAPIResult) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else if (value is ProductMessage) { + } else if (value is ProductMessage) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else if (value is PurchaseMessage) { + } else if (value is PurchaseMessage) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is OrderDetails) { + } else if (value is OrderDetails) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is BuyInfoMessage) { + } else if (value is BuyInfoMessage) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is InvoiceMessage) { + } else if (value is InvoiceMessage) { buffer.putUint8(138); writeValue(buffer, value.encode()); } else { @@ -451,216 +968,258 @@ class _PigeonCodec extends StandardMessageCodec { } class InAppPurchaseApi { - /// Constructor for [InAppPurchaseApi]. The [binaryMessenger] named argument is - /// available for dependency injection. If it is left null, the default - /// BinaryMessenger will be used which routes to the host platform. - InAppPurchaseApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) - : pigeonVar_binaryMessenger = binaryMessenger, - pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty - ? '.$messageChannelSuffix' - : ''; - final BinaryMessenger? pigeonVar_binaryMessenger; + /// Constructor for [InAppPurchaseApi]. + InAppPurchaseApi({ + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + pigeon_ffi.InAppPurchaseTizenFfiBindings? ffiBindings, + }) : pigeonVar_ffiBindings = ffiBindings ?? _pigeonVar_defaultFfiBindings { + if (binaryMessenger != null) { + throw ArgumentError.value(binaryMessenger, 'binaryMessenger', 'BinaryMessenger is not supported by FFI HostApi.'); + } + if (messageChannelSuffix.isNotEmpty) { + throw ArgumentError.value(messageChannelSuffix, 'messageChannelSuffix', 'messageChannelSuffix is not supported by FFI HostApi.'); + } + } - static const MessageCodec pigeonChannelCodec = _PigeonCodec(); + static final pigeon_ffi.InAppPurchaseTizenFfiBindings _pigeonVar_defaultFfiBindings = + pigeon_ffi.InAppPurchaseTizenFfiBindings.fromLookup(_pigeonFfiLookup); - final String pigeonVar_messageChannelSuffix; + final pigeon_ffi.InAppPurchaseTizenFfiBindings pigeonVar_ffiBindings; + + static const MessageCodec pigeonChannelCodec = _PigeonCodec(); /// Retrieves the list of products registered on the Billing (DPI) server. Future getProductsList(ProductMessage product) async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.getProductsList$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, + final ByteData? pigeonVar_requestMessage = pigeonChannelCodec.encodeMessage([product]); + final ffi.Pointer pigeonVar_request = _encodeFfiRequest(pigeonVar_requestMessage); + final String pigeonVar_channelName = 'pigeon_in_app_purchase_api_get_products_list'; + final Completer pigeonVar_completer = Completer(); + final int pigeonVar_replyId = _pigeonNextFfiAsyncReplyId++; + _pigeonFfiAsyncReplies[pigeonVar_replyId] = _PigeonFfiAsyncReply( + ffiBindings: pigeonVar_ffiBindings, + codec: pigeonChannelCodec, + channelName: pigeonVar_channelName, + isNullValid: false, + complete: (Object? pigeonVar_replyValue) { + pigeonVar_completer.complete(pigeonVar_replyValue! as ProductsListApiResult); + }, + completeError: (Object error, StackTrace stackTrace) { + pigeonVar_completer.completeError(error, stackTrace); + }, ); - final List? pigeonVar_replyList = - await pigeonVar_channel.send([product]) as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', + try { + _updatePigeonFfiReplyCallbackKeepAlive(); + pigeonVar_ffiBindings.pigeon_in_app_purchase_api_get_products_list( + pigeonVar_request, + pigeonVar_replyId, + _pigeonFfiReplyCallback.nativeFunction, ); - } else { - return (pigeonVar_replyList[0] as ProductsListApiResult?)!; + } catch (error, stackTrace) { + _pigeonFfiAsyncReplies.remove(pigeonVar_replyId); + if (!pigeonVar_completer.isCompleted) { + pigeonVar_completer.completeError(error, stackTrace); + } + } finally { + _freeFfiRequest(pigeonVar_request); + _updatePigeonFfiReplyCallbackKeepAlive(); } + return await pigeonVar_completer.future; } /// Retrieves the user's purchase list. Future getUserPurchaseList(PurchaseMessage purchase) async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.getUserPurchaseList$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, + final ByteData? pigeonVar_requestMessage = pigeonChannelCodec.encodeMessage([purchase]); + final ffi.Pointer pigeonVar_request = _encodeFfiRequest(pigeonVar_requestMessage); + final String pigeonVar_channelName = 'pigeon_in_app_purchase_api_get_user_purchase_list'; + final Completer pigeonVar_completer = Completer(); + final int pigeonVar_replyId = _pigeonNextFfiAsyncReplyId++; + _pigeonFfiAsyncReplies[pigeonVar_replyId] = _PigeonFfiAsyncReply( + ffiBindings: pigeonVar_ffiBindings, + codec: pigeonChannelCodec, + channelName: pigeonVar_channelName, + isNullValid: false, + complete: (Object? pigeonVar_replyValue) { + pigeonVar_completer.complete(pigeonVar_replyValue! as GetUserPurchaseListAPIResult); + }, + completeError: (Object error, StackTrace stackTrace) { + pigeonVar_completer.completeError(error, stackTrace); + }, ); - final List? pigeonVar_replyList = - await pigeonVar_channel.send([purchase]) as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], + try { + _updatePigeonFfiReplyCallbackKeepAlive(); + pigeonVar_ffiBindings.pigeon_in_app_purchase_api_get_user_purchase_list( + pigeonVar_request, + pigeonVar_replyId, + _pigeonFfiReplyCallback.nativeFunction, ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as GetUserPurchaseListAPIResult?)!; + } catch (error, stackTrace) { + _pigeonFfiAsyncReplies.remove(pigeonVar_replyId); + if (!pigeonVar_completer.isCompleted) { + pigeonVar_completer.completeError(error, stackTrace); + } + } finally { + _freeFfiRequest(pigeonVar_request); + _updatePigeonFfiReplyCallbackKeepAlive(); } + return await pigeonVar_completer.future; } /// Enables implementing the Samsung Checkout Client module within the application. /// After authenticating the purchase information through the application, the user can proceed to purchase payment. Future buyItem(BuyInfoMessage buyInfo) async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.buyItem$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, + final ByteData? pigeonVar_requestMessage = pigeonChannelCodec.encodeMessage([buyInfo]); + final ffi.Pointer pigeonVar_request = _encodeFfiRequest(pigeonVar_requestMessage); + final String pigeonVar_channelName = 'pigeon_in_app_purchase_api_buy_item'; + final Completer pigeonVar_completer = Completer(); + final int pigeonVar_replyId = _pigeonNextFfiAsyncReplyId++; + _pigeonFfiAsyncReplies[pigeonVar_replyId] = _PigeonFfiAsyncReply( + ffiBindings: pigeonVar_ffiBindings, + codec: pigeonChannelCodec, + channelName: pigeonVar_channelName, + isNullValid: false, + complete: (Object? pigeonVar_replyValue) { + pigeonVar_completer.complete(pigeonVar_replyValue! as BillingBuyData); + }, + completeError: (Object error, StackTrace stackTrace) { + pigeonVar_completer.completeError(error, stackTrace); + }, ); - final List? pigeonVar_replyList = - await pigeonVar_channel.send([buyInfo]) as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', + try { + _updatePigeonFfiReplyCallbackKeepAlive(); + pigeonVar_ffiBindings.pigeon_in_app_purchase_api_buy_item( + pigeonVar_request, + pigeonVar_replyId, + _pigeonFfiReplyCallback.nativeFunction, ); - } else { - return (pigeonVar_replyList[0] as BillingBuyData?)!; + } catch (error, stackTrace) { + _pigeonFfiAsyncReplies.remove(pigeonVar_replyId); + if (!pigeonVar_completer.isCompleted) { + pigeonVar_completer.completeError(error, stackTrace); + } + } finally { + _freeFfiRequest(pigeonVar_request); + _updatePigeonFfiReplyCallbackKeepAlive(); } + return await pigeonVar_completer.future; } /// Checks whether a purchase, corresponding to a specific "InvoiceID", was successful. Future verifyInvoice(InvoiceMessage invoice) async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.verifyInvoice$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, + final ByteData? pigeonVar_requestMessage = pigeonChannelCodec.encodeMessage([invoice]); + final ffi.Pointer pigeonVar_request = _encodeFfiRequest(pigeonVar_requestMessage); + final String pigeonVar_channelName = 'pigeon_in_app_purchase_api_verify_invoice'; + final Completer pigeonVar_completer = Completer(); + final int pigeonVar_replyId = _pigeonNextFfiAsyncReplyId++; + _pigeonFfiAsyncReplies[pigeonVar_replyId] = _PigeonFfiAsyncReply( + ffiBindings: pigeonVar_ffiBindings, + codec: pigeonChannelCodec, + channelName: pigeonVar_channelName, + isNullValid: false, + complete: (Object? pigeonVar_replyValue) { + pigeonVar_completer.complete(pigeonVar_replyValue! as VerifyInvoiceAPIResult); + }, + completeError: (Object error, StackTrace stackTrace) { + pigeonVar_completer.completeError(error, stackTrace); + }, ); - final List? pigeonVar_replyList = - await pigeonVar_channel.send([invoice]) as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', + try { + _updatePigeonFfiReplyCallbackKeepAlive(); + pigeonVar_ffiBindings.pigeon_in_app_purchase_api_verify_invoice( + pigeonVar_request, + pigeonVar_replyId, + _pigeonFfiReplyCallback.nativeFunction, ); - } else { - return (pigeonVar_replyList[0] as VerifyInvoiceAPIResult?)!; + } catch (error, stackTrace) { + _pigeonFfiAsyncReplies.remove(pigeonVar_replyId); + if (!pigeonVar_completer.isCompleted) { + pigeonVar_completer.completeError(error, stackTrace); + } + } finally { + _freeFfiRequest(pigeonVar_request); + _updatePigeonFfiReplyCallbackKeepAlive(); } + return await pigeonVar_completer.future; } /// Checks whether the Billing server is available. Future isServiceAvailable() async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.isServiceAvailable$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, + final ffi.Pointer pigeonVar_request = ffi.nullptr; + final String pigeonVar_channelName = 'pigeon_in_app_purchase_api_is_service_available'; + final Completer pigeonVar_completer = Completer(); + final int pigeonVar_replyId = _pigeonNextFfiAsyncReplyId++; + _pigeonFfiAsyncReplies[pigeonVar_replyId] = _PigeonFfiAsyncReply( + ffiBindings: pigeonVar_ffiBindings, + codec: pigeonChannelCodec, + channelName: pigeonVar_channelName, + isNullValid: false, + complete: (Object? pigeonVar_replyValue) { + pigeonVar_completer.complete(pigeonVar_replyValue! as bool); + }, + completeError: (Object error, StackTrace stackTrace) { + pigeonVar_completer.completeError(error, stackTrace); + }, ); - final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', + try { + _updatePigeonFfiReplyCallbackKeepAlive(); + pigeonVar_ffiBindings.pigeon_in_app_purchase_api_is_service_available( + pigeonVar_request, + pigeonVar_replyId, + _pigeonFfiReplyCallback.nativeFunction, ); - } else { - return (pigeonVar_replyList[0] as bool?)!; + } catch (error, stackTrace) { + _pigeonFfiAsyncReplies.remove(pigeonVar_replyId); + if (!pigeonVar_completer.isCompleted) { + pigeonVar_completer.completeError(error, stackTrace); + } + } finally { + _freeFfiRequest(pigeonVar_request); + _updatePigeonFfiReplyCallbackKeepAlive(); } + return await pigeonVar_completer.future; } Future getCustomId() async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.getCustomId$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as String?)!; + final ffi.Pointer pigeonVar_request = ffi.nullptr; + final String pigeonVar_channelName = 'pigeon_in_app_purchase_api_get_custom_id'; + ffi.Pointer pigeonVar_response = ffi.nullptr; + try { + pigeonVar_response = pigeonVar_ffiBindings.pigeon_in_app_purchase_api_get_custom_id(pigeonVar_request); + final List? pigeonVar_replyList = _decodeFfiReply(pigeonChannelCodec, pigeonVar_response); + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + ; + return pigeonVar_replyValue! as String; + } finally { + _freeFfiRequest(pigeonVar_request); + if (pigeonVar_response != ffi.nullptr) { + pigeonVar_ffiBindings.pigeon_free_buffer(pigeonVar_response); + } } } Future getCountryCode() async { - final String pigeonVar_channelName = - 'dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.getCountryCode$pigeonVar_messageChannelSuffix'; - final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as String?)!; + final ffi.Pointer pigeonVar_request = ffi.nullptr; + final String pigeonVar_channelName = 'pigeon_in_app_purchase_api_get_country_code'; + ffi.Pointer pigeonVar_response = ffi.nullptr; + try { + pigeonVar_response = pigeonVar_ffiBindings.pigeon_in_app_purchase_api_get_country_code(pigeonVar_request); + final List? pigeonVar_replyList = _decodeFfiReply(pigeonChannelCodec, pigeonVar_response); + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + ; + return pigeonVar_replyValue! as String; + } finally { + _freeFfiRequest(pigeonVar_request); + if (pigeonVar_response != ffi.nullptr) { + pigeonVar_ffiBindings.pigeon_free_buffer(pigeonVar_response); + } } } } diff --git a/packages/in_app_purchase/lib/src/messages.g.ffi.dart b/packages/in_app_purchase/lib/src/messages.g.ffi.dart new file mode 100644 index 000000000..b71960c20 --- /dev/null +++ b/packages/in_app_purchase/lib/src/messages.g.ffi.dart @@ -0,0 +1,191 @@ +// AUTO GENERATED FILE, DO NOT EDIT. +// +// Generated by `package:ffigen`. +// ignore_for_file: type=lint, unused_import, unused_element, deprecated_member_use_from_same_package +import 'dart:ffi' as ffi; + +/// Generated bindings for Pigeon C++ FFI APIs. +class InAppPurchaseTizenFfiBindings { + /// Holds the symbol lookup function. + final ffi.Pointer Function(String symbolName) _lookup; + + /// The symbols are looked up in [dynamicLibrary]. + InAppPurchaseTizenFfiBindings(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; + + /// The symbols are looked up with [lookup]. + InAppPurchaseTizenFfiBindings.fromLookup( + ffi.Pointer Function(String symbolName) lookup, + ) : _lookup = lookup; + + void pigeon_free_buffer(ffi.Pointer buffer) { + return _pigeon_free_buffer(buffer); + } + + late final _pigeon_free_bufferPtr = + _lookup)>>( + 'pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_free_buffer', + ); + late final _pigeon_free_buffer = _pigeon_free_bufferPtr + .asFunction)>(); + + void pigeon_in_app_purchase_api_buy_item( + ffi.Pointer request, + int reply_id, + PigeonFfiReplyCallback on_reply, + ) { + return _pigeon_in_app_purchase_api_buy_item(request, reply_id, on_reply); + } + + late final _pigeon_in_app_purchase_api_buy_itemPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int64, PigeonFfiReplyCallback) + > + >( + 'pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_buy_item', + ); + late final _pigeon_in_app_purchase_api_buy_item = _pigeon_in_app_purchase_api_buy_itemPtr + .asFunction, int, PigeonFfiReplyCallback)>(); + + ffi.Pointer pigeon_in_app_purchase_api_get_country_code( + ffi.Pointer request, + ) { + return _pigeon_in_app_purchase_api_get_country_code(request); + } + + late final _pigeon_in_app_purchase_api_get_country_codePtr = + _lookup< + ffi.NativeFunction Function(ffi.Pointer)> + >( + 'pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_country_code', + ); + late final _pigeon_in_app_purchase_api_get_country_code = + _pigeon_in_app_purchase_api_get_country_codePtr + .asFunction Function(ffi.Pointer)>(); + + ffi.Pointer pigeon_in_app_purchase_api_get_custom_id( + ffi.Pointer request, + ) { + return _pigeon_in_app_purchase_api_get_custom_id(request); + } + + late final _pigeon_in_app_purchase_api_get_custom_idPtr = + _lookup< + ffi.NativeFunction Function(ffi.Pointer)> + >( + 'pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_custom_id', + ); + late final _pigeon_in_app_purchase_api_get_custom_id = + _pigeon_in_app_purchase_api_get_custom_idPtr + .asFunction Function(ffi.Pointer)>(); + + void pigeon_in_app_purchase_api_get_products_list( + ffi.Pointer request, + int reply_id, + PigeonFfiReplyCallback on_reply, + ) { + return _pigeon_in_app_purchase_api_get_products_list(request, reply_id, on_reply); + } + + late final _pigeon_in_app_purchase_api_get_products_listPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int64, PigeonFfiReplyCallback) + > + >( + 'pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_products_list', + ); + late final _pigeon_in_app_purchase_api_get_products_list = + _pigeon_in_app_purchase_api_get_products_listPtr + .asFunction, int, PigeonFfiReplyCallback)>(); + + void pigeon_in_app_purchase_api_get_user_purchase_list( + ffi.Pointer request, + int reply_id, + PigeonFfiReplyCallback on_reply, + ) { + return _pigeon_in_app_purchase_api_get_user_purchase_list(request, reply_id, on_reply); + } + + late final _pigeon_in_app_purchase_api_get_user_purchase_listPtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int64, PigeonFfiReplyCallback) + > + >( + 'pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_user_purchase_list', + ); + late final _pigeon_in_app_purchase_api_get_user_purchase_list = + _pigeon_in_app_purchase_api_get_user_purchase_listPtr + .asFunction, int, PigeonFfiReplyCallback)>(); + + void pigeon_in_app_purchase_api_is_service_available( + ffi.Pointer request, + int reply_id, + PigeonFfiReplyCallback on_reply, + ) { + return _pigeon_in_app_purchase_api_is_service_available(request, reply_id, on_reply); + } + + late final _pigeon_in_app_purchase_api_is_service_availablePtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int64, PigeonFfiReplyCallback) + > + >( + 'pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_is_service_available', + ); + late final _pigeon_in_app_purchase_api_is_service_available = + _pigeon_in_app_purchase_api_is_service_availablePtr + .asFunction, int, PigeonFfiReplyCallback)>(); + + void pigeon_in_app_purchase_api_verify_invoice( + ffi.Pointer request, + int reply_id, + PigeonFfiReplyCallback on_reply, + ) { + return _pigeon_in_app_purchase_api_verify_invoice(request, reply_id, on_reply); + } + + late final _pigeon_in_app_purchase_api_verify_invoicePtr = + _lookup< + ffi.NativeFunction< + ffi.Void Function(ffi.Pointer, ffi.Int64, PigeonFfiReplyCallback) + > + >( + 'pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_verify_invoice', + ); + late final _pigeon_in_app_purchase_api_verify_invoice = + _pigeon_in_app_purchase_api_verify_invoicePtr + .asFunction, int, PigeonFfiReplyCallback)>(); +} + +final class PigeonFfiBuffer extends ffi.Struct { + external ffi.Pointer data; + + @ffi.Size() + external int length; + + static ffi.Pointer $allocate( + ffi.Allocator $allocator, { + required ffi.Pointer data, + required int length, + }) => $allocator() + ..ref.data = data + ..ref.length = length; +} + +typedef PigeonFfiDoneCallback = ffi.Pointer>; +typedef PigeonFfiDoneCallbackFunction = ffi.Void Function(ffi.Int64 sink_id); +typedef DartPigeonFfiDoneCallbackFunction = void Function(int sink_id); +typedef PigeonFfiEventCallback = ffi.Pointer>; +typedef PigeonFfiEventCallbackFunction = + ffi.Void Function(ffi.Int64 sink_id, ffi.Pointer event); +typedef DartPigeonFfiEventCallbackFunction = + void Function(int sink_id, ffi.Pointer event); +typedef PigeonFfiReplyCallback = ffi.Pointer>; +typedef PigeonFfiReplyCallbackFunction = + ffi.Void Function(ffi.Int64 reply_id, ffi.Pointer reply); +typedef DartPigeonFfiReplyCallbackFunction = + void Function(int reply_id, ffi.Pointer reply); diff --git a/packages/in_app_purchase/pigeons/messages.dart b/packages/in_app_purchase/pigeons/messages.dart index a0fd77175..b6ff7dee8 100644 --- a/packages/in_app_purchase/pigeons/messages.dart +++ b/packages/in_app_purchase/pigeons/messages.dart @@ -7,9 +7,34 @@ import 'package:pigeon/pigeon.dart'; @ConfigurePigeon( PigeonOptions( dartOut: 'lib/src/messages.g.dart', - cppOptions: CppOptions(namespace: 'in_app_purchase_tizen'), + dartFfiOut: 'lib/src/messages.g.ffi.dart', + configDirectory: 'tool/pigeon', + dartOptions: DartOptions( + ffiOptions: DartFfiOptions( + bindingClassName: 'InAppPurchaseTizenFfiBindings', + nativeLibraryExpression: r''' +(() { + final String libraryPath = File('/proc/self/maps') + .readAsLinesSync() + .map((String line) { + final int index = line.indexOf('/'); + return index == -1 ? '' : line.substring(index); + }) + .firstWhere( + (String path) => path.endsWith('/libflutter_plugins.so'), + ); + return ffi.DynamicLibrary.open(libraryPath); +})()''', + ), + ), + cppOptions: CppOptions( + namespace: 'in_app_purchase_tizen', + useStdVisit: false, + ), cppHeaderOut: 'tizen/src/messages.h', cppSourceOut: 'tizen/src/messages.cc', + cppFfiHeaderOut: 'tizen/src/messages_ffi.h', + cppFfiSourceOut: 'tizen/src/messages_ffi.cc', ), ) /// Dart wrapper around [`ProductsListApiResult`] in (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). diff --git a/packages/in_app_purchase/pubspec.yaml b/packages/in_app_purchase/pubspec.yaml index 94b873174..0843a6bc2 100644 --- a/packages/in_app_purchase/pubspec.yaml +++ b/packages/in_app_purchase/pubspec.yaml @@ -2,7 +2,7 @@ name: in_app_purchase_tizen description: Tizen implementation of the in_app_purchase plugin for Samsung Smart TV. homepage: https://github.com/flutter-tizen/plugins repository: https://github.com/flutter-tizen/plugins/tree/main/packages/in_app_purchase -version: 0.1.9 +version: 0.2.0 environment: sdk: ^3.10.0 @@ -19,10 +19,16 @@ flutter: dependencies: crypto: ^3.0.2 + ffi: ^2.0.0 flutter: sdk: flutter in_app_purchase_platform_interface: ^1.4.0 dev_dependencies: build_runner: ^2.0.0 - pigeon: ^22.4.2 + ffigen: ^22.0.0 + pigeon: + git: + url: https://github.com/gin7773/flutter-packages.git + ref: 1e63f1b5852a868d1b072de460752fe95e724600 + path: packages/pigeon diff --git a/packages/in_app_purchase/tizen/src/in_app_purchase_tizen_plugin.cc b/packages/in_app_purchase/tizen/src/in_app_purchase_tizen_plugin.cc index 75e80aa40..a77d8cdf8 100644 --- a/packages/in_app_purchase/tizen/src/in_app_purchase_tizen_plugin.cc +++ b/packages/in_app_purchase/tizen/src/in_app_purchase_tizen_plugin.cc @@ -4,21 +4,84 @@ #include "in_app_purchase_tizen_plugin.h" -#include #include -#include +#include +#include +#include #include +#include #include +#include #include "billing_manager.h" #include "log.h" #include "messages.h" +#include "messages_ffi.h" #include "rapidjson/stringbuffer.h" #include "rapidjson/writer.h" namespace in_app_purchase_tizen { +namespace { + +class MainContextDispatcher : public PigeonFfiSyncDispatcher { + public: + MainContextDispatcher() + : thread_id_(std::this_thread::get_id()), + main_context_(g_main_context_ref_thread_default()) {} + + ~MainContextDispatcher() override { g_main_context_unref(main_context_); } + + PigeonFfiBuffer *RunSync(std::function task) override { + if (std::this_thread::get_id() == thread_id_) { + return task(); + } + + struct TaskState { + std::function task; + PigeonFfiBuffer *result = nullptr; + std::mutex mutex; + std::condition_variable condition; + bool done = false; + }; + TaskState state{std::move(task)}; + GSource *source = g_idle_source_new(); + g_source_set_priority(source, G_PRIORITY_DEFAULT); + g_source_set_callback( + source, + [](gpointer data) -> gboolean { + auto *state = static_cast(data); + PigeonFfiBuffer *result = state->task(); + { + std::lock_guard lock(state->mutex); + state->result = result; + state->done = true; + state->condition.notify_one(); + } + return G_SOURCE_REMOVE; + }, + &state, nullptr); + g_source_attach(source, main_context_); + g_source_unref(source); + + std::unique_lock lock(state.mutex); + state.condition.wait(lock, [&state] { return state.done; }); + return state.result; + } + + private: + std::thread::id thread_id_; + GMainContext *main_context_; +}; + +MainContextDispatcher *GetMainContextDispatcher() { + static MainContextDispatcher *dispatcher = new MainContextDispatcher(); + return dispatcher; +} + +} // namespace + class InAppPurchaseTizenPlugin : public flutter::Plugin, public InAppPurchaseApi { public: @@ -52,12 +115,15 @@ class InAppPurchaseTizenPlugin : public flutter::Plugin, }; InAppPurchaseTizenPlugin::InAppPurchaseTizenPlugin( - flutter::PluginRegistrar *plugin_registrar) { + flutter::PluginRegistrar * /*plugin_registrar*/) { billing_ = std::make_unique(); - InAppPurchaseTizenPlugin::SetUp(plugin_registrar->messenger(), this); + SetUpInAppPurchaseApiFfi(this, GetMainContextDispatcher()); } -void InAppPurchaseTizenPlugin::Dispose() { billing_ = nullptr; } +void InAppPurchaseTizenPlugin::Dispose() { + TearDownInAppPurchaseApiFfi(); + billing_ = nullptr; +} void InAppPurchaseTizenPlugin::RegisterWithRegistrar( flutter::PluginRegistrar *plugin_registrar) { diff --git a/packages/in_app_purchase/tizen/src/messages.cc b/packages/in_app_purchase/tizen/src/messages.cc index 9c04a6f2f..c4df78806 100644 --- a/packages/in_app_purchase/tizen/src/messages.cc +++ b/packages/in_app_purchase/tizen/src/messages.cc @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v22.7.4), do not edit directly. +// Autogenerated from Pigeon (v29.0.11), do not edit directly. // See also: https://pub.dev/packages/pigeon #undef _HAS_EXCEPTIONS @@ -10,16 +10,19 @@ #include #include +#include +#include #include #include +#include #include namespace in_app_purchase_tizen { -using flutter::BasicMessageChannel; -using flutter::CustomEncodableValue; -using flutter::EncodableList; -using flutter::EncodableMap; -using flutter::EncodableValue; +using ::flutter::BasicMessageChannel; +using ::flutter::CustomEncodableValue; +using ::flutter::EncodableList; +using ::flutter::EncodableMap; +using ::flutter::EncodableValue; FlutterError CreateConnectionError(const std::string channel_name) { return FlutterError( @@ -28,28 +31,351 @@ FlutterError CreateConnectionError(const std::string channel_name) { EncodableValue("")); } +namespace { +template +bool PigeonInternalDeepEquals(const T& a, const T& b); + +bool PigeonInternalDeepEquals(const double& a, const double& b); + +template +bool PigeonInternalDeepEquals(const std::vector& a, const std::vector& b); + +template +bool PigeonInternalDeepEquals(const std::map& a, const std::map& b); + +template +bool PigeonInternalDeepEquals(const std::optional& a, const std::optional& b); + +template +bool PigeonInternalDeepEquals(const std::unique_ptr& a, const std::unique_ptr& b); + +bool PigeonInternalDeepEquals(const ::flutter::EncodableValue& a, const ::flutter::EncodableValue& b); + +template +bool PigeonInternalDeepEquals(const T& a, const T& b) { + return a == b; +} + +template +bool PigeonInternalDeepEquals(const std::vector& a, const std::vector& b) { + if (a.size() != b.size()) { + return false; + } + for (size_t i = 0; i < a.size(); ++i) { + if (!PigeonInternalDeepEquals(a[i], b[i])) { + return false; + } + } + return true; +} + +template +bool PigeonInternalDeepEquals(const std::map& a, const std::map& b) { + if (a.size() != b.size()) { + return false; + } + for (const auto& kv : a) { + bool found = false; + for (const auto& b_kv : b) { + if (PigeonInternalDeepEquals(kv.first, b_kv.first)) { + if (PigeonInternalDeepEquals(kv.second, b_kv.second)) { + found = true; + break; + } else { + return false; + } + } + } + if (!found) { + return false; + } + } + return true; +} + +bool PigeonInternalDeepEquals(const double& a, const double& b) { + // Normalize -0.0 to 0.0 and handle NaN equality. + return (a == b) || (std::isnan(a) && std::isnan(b)); +} + +template +bool PigeonInternalDeepEquals(const std::optional& a, const std::optional& b) { + if (!a && !b) { + return true; + } + if (!a || !b) { + return false; + } + return PigeonInternalDeepEquals(*a, *b); +} + +template +bool PigeonInternalDeepEquals(const std::unique_ptr& a, const std::unique_ptr& b) { + if (a.get() == b.get()) { + return true; + } + if (!a || !b) { + return false; + } + return PigeonInternalDeepEquals(*a, *b); +} + +bool PigeonInternalDeepEquals(const ::flutter::EncodableValue& a, const ::flutter::EncodableValue& b) { + if (a.index() != b.index()) { + return false; + } + if (const double* da = std::get_if(&a)) { + return PigeonInternalDeepEquals(*da, std::get(b)); + } else if (const ::flutter::EncodableList* la = std::get_if<::flutter::EncodableList>(&a)) { + return PigeonInternalDeepEquals(*la, std::get<::flutter::EncodableList>(b)); + } else if (const ::flutter::EncodableMap* ma = std::get_if<::flutter::EncodableMap>(&a)) { + return PigeonInternalDeepEquals(*ma, std::get<::flutter::EncodableMap>(b)); + } + return a == b; +} + +template +size_t PigeonInternalDeepHash(const T& v); + +size_t PigeonInternalDeepHash(const double& v); + +template +size_t PigeonInternalDeepHash(const std::vector& v); + +template +size_t PigeonInternalDeepHash(const std::map& v); + +template +size_t PigeonInternalDeepHash(const std::optional& v); + +template +size_t PigeonInternalDeepHash(const std::unique_ptr& v); + +size_t PigeonInternalDeepHash(const ::flutter::EncodableValue& v); + +template +size_t PigeonInternalDeepHash(const T& v) { + return std::hash()(v); +} + +template +size_t PigeonInternalDeepHash(const std::vector& v) { + size_t result = 1; + for (const auto& item : v) { + result = result * 31 + PigeonInternalDeepHash(item); + } + return result; +} + +template +size_t PigeonInternalDeepHash(const std::map& v) { + size_t result = 0; + for (const auto& kv : v) { + result += ((PigeonInternalDeepHash(kv.first) * 31) ^ PigeonInternalDeepHash(kv.second)); + } + return result; +} + +size_t PigeonInternalDeepHash(const double& v) { + if (std::isnan(v)) { + // Normalize NaN to a consistent hash. + return std::hash()(std::numeric_limits::quiet_NaN()); + } + if (v == 0.0) { + // Normalize -0.0 to 0.0 so they have the same hash code. + return std::hash()(0.0); + } + return std::hash()(v); +} + +template +size_t PigeonInternalDeepHash(const std::optional& v) { + return v ? PigeonInternalDeepHash(*v) : 0; +} + +template +size_t PigeonInternalDeepHash(const std::unique_ptr& v) { + return v ? PigeonInternalDeepHash(*v) : 0; +} + + +size_t PigeonInternalDeepHash(const ::flutter::EncodableValue& v) { + size_t result = v.index(); + if (const bool* bv = std::get_if(&v)) { + result = result * 31 + PigeonInternalDeepHash(*bv); + } else if (const int32_t* iv = std::get_if(&v)) { + result = result * 31 + PigeonInternalDeepHash(*iv); + } else if (const int64_t* lv = std::get_if(&v)) { + result = result * 31 + PigeonInternalDeepHash(*lv); + } else if (const double* dv = std::get_if(&v)) { + result = result * 31 + PigeonInternalDeepHash(*dv); + } else if (const std::string* sv = std::get_if(&v)) { + result = result * 31 + PigeonInternalDeepHash(*sv); + } else if (const std::vector* bv = std::get_if>(&v)) { + result = result * 31 + PigeonInternalDeepHash(*bv); + } else if (const std::vector* iv = std::get_if>(&v)) { + result = result * 31 + PigeonInternalDeepHash(*iv); + } else if (const std::vector* lv = std::get_if>(&v)) { + result = result * 31 + PigeonInternalDeepHash(*lv); + } else if (const std::vector* fv = std::get_if>(&v)) { + result = result * 31 + PigeonInternalDeepHash(*fv); + } else if (const std::vector* dv = std::get_if>(&v)) { + result = result * 31 + PigeonInternalDeepHash(*dv); + } else if (const ::flutter::EncodableList* lv = + std::get_if<::flutter::EncodableList>(&v)) { + result = result * 31 + PigeonInternalDeepHash(*lv); + } else if (const ::flutter::EncodableMap* mv = + std::get_if<::flutter::EncodableMap>(&v)) { + result = result * 31 + PigeonInternalDeepHash(*mv); + } + return result; +} + +template +std::string PigeonInternalToString(const T& v); + +std::string PigeonInternalToString(const bool& v); + +template +std::string PigeonInternalToString(const std::vector& v); + +template +std::string PigeonInternalToString(const std::map& v); + +template +std::string PigeonInternalToString(const std::optional& v); + +template +std::string PigeonInternalToString(const std::unique_ptr& v); + +std::string PigeonInternalToString(const ::flutter::EncodableValue& v); + +template +std::string PigeonInternalToString(const T& v) { + std::stringstream ss; + if constexpr (std::is_enum_v) { + ss << static_cast(v); + } else { + ss << v; + } + return ss.str(); +} + +std::string PigeonInternalToString(const bool& v) { + return v ? "true" : "false"; +} + +template +std::string PigeonInternalToString(const std::vector& v) { + std::stringstream ss; + ss << "["; + for (size_t i = 0; i < v.size(); ++i) { + if (i > 0) { + ss << ", "; + } + ss << PigeonInternalToString(v[i]); + } + ss << "]"; + return ss.str(); +} + +template +std::string PigeonInternalToString(const std::map& v) { + std::stringstream ss; + ss << "{"; + bool first = true; + for (const auto& kv : v) { + if (!first) { + ss << ", "; + } + first = false; + ss << PigeonInternalToString(kv.first) << ": " << PigeonInternalToString(kv.second); + } + ss << "}"; + return ss.str(); +} + +template +std::string PigeonInternalToString(const std::optional& v) { + return v ? PigeonInternalToString(*v) : "null"; +} + +template +std::string PigeonInternalToString(const std::unique_ptr& v) { + return v ? PigeonInternalToString(*v) : "null"; +} + + +std::string PigeonInternalToString(const ::flutter::EncodableValue& v) { + if (std::get_if(&v)) { + return "null"; + } + if (const bool* bv = std::get_if(&v)) { + return PigeonInternalToString(*bv); + } + if (const int32_t* iv = std::get_if(&v)) { + return PigeonInternalToString(*iv); + } + if (const int64_t* lv = std::get_if(&v)) { + return PigeonInternalToString(*lv); + } + if (const double* dv = std::get_if(&v)) { + return PigeonInternalToString(*dv); + } + if (const std::string* sv = std::get_if(&v)) { + return "\"" + *sv + "\""; + } + if (const std::vector* bv = std::get_if>(&v)) { + return PigeonInternalToString(*bv); + } + if (const std::vector* iv = std::get_if>(&v)) { + return PigeonInternalToString(*iv); + } + if (const std::vector* lv = std::get_if>(&v)) { + return PigeonInternalToString(*lv); + } + if (const std::vector* fv = std::get_if>(&v)) { + return PigeonInternalToString(*fv); + } + if (const std::vector* dv = std::get_if>(&v)) { + return PigeonInternalToString(*dv); + } + if (const ::flutter::EncodableList* lv = std::get_if<::flutter::EncodableList>(&v)) { + return PigeonInternalToString(*lv); + } + if (const ::flutter::EncodableMap* mv = std::get_if<::flutter::EncodableMap>(&v)) { + return PigeonInternalToString(*mv); + } + if (std::get_if<::flutter::CustomEncodableValue>(&v)) { + return "[custom]"; + } + return ""; +} + +} // namespace // ProductsListApiResult -ProductsListApiResult::ProductsListApiResult(const std::string& cp_status, - int64_t total_count, - const std::string& check_value, - const EncodableList& item_details) - : cp_status_(cp_status), - total_count_(total_count), - check_value_(check_value), - item_details_(item_details) {} - -ProductsListApiResult::ProductsListApiResult(const std::string& cp_status, - const std::string* cp_result, - int64_t total_count, - const std::string& check_value, - const EncodableList& item_details) - : cp_status_(cp_status), - cp_result_(cp_result ? std::optional(*cp_result) - : std::nullopt), - total_count_(total_count), - check_value_(check_value), - item_details_(item_details) {} +ProductsListApiResult::ProductsListApiResult( + const std::string& cp_status, + int64_t total_count, + const std::string& check_value, + const EncodableList& item_details) + : cp_status_(cp_status), + total_count_(total_count), + check_value_(check_value), + item_details_(item_details) {} + +ProductsListApiResult::ProductsListApiResult( + const std::string& cp_status, + const std::string* cp_result, + int64_t total_count, + const std::string& check_value, + const EncodableList& item_details) + : cp_status_(cp_status), + cp_result_(cp_result ? std::optional(*cp_result) : std::nullopt), + total_count_(total_count), + check_value_(check_value), + item_details_(item_details) {} const std::string& ProductsListApiResult::cp_status() const { return cp_status_; @@ -59,25 +385,29 @@ void ProductsListApiResult::set_cp_status(std::string_view value_arg) { cp_status_ = value_arg; } + const std::string* ProductsListApiResult::cp_result() const { return cp_result_ ? &(*cp_result_) : nullptr; } void ProductsListApiResult::set_cp_result(const std::string_view* value_arg) { - cp_result_ = - value_arg ? std::optional(*value_arg) : std::nullopt; + cp_result_ = value_arg ? std::optional(*value_arg) : std::nullopt; } void ProductsListApiResult::set_cp_result(std::string_view value_arg) { cp_result_ = value_arg; } -int64_t ProductsListApiResult::total_count() const { return total_count_; } + +int64_t ProductsListApiResult::total_count() const { + return total_count_; +} void ProductsListApiResult::set_total_count(int64_t value_arg) { total_count_ = value_arg; } + const std::string& ProductsListApiResult::check_value() const { return check_value_; } @@ -86,6 +416,7 @@ void ProductsListApiResult::set_check_value(std::string_view value_arg) { check_value_ = value_arg; } + const EncodableList& ProductsListApiResult::item_details() const { return item_details_; } @@ -94,6 +425,7 @@ void ProductsListApiResult::set_item_details(const EncodableList& value_arg) { item_details_ = value_arg; } + EncodableList ProductsListApiResult::ToEncodableList() const { EncodableList list; list.reserve(5); @@ -105,11 +437,12 @@ EncodableList ProductsListApiResult::ToEncodableList() const { return list; } -ProductsListApiResult ProductsListApiResult::FromEncodableList( - const EncodableList& list) { +ProductsListApiResult ProductsListApiResult::FromEncodableList(const EncodableList& list) { ProductsListApiResult decoded( - std::get(list[0]), std::get(list[2]), - std::get(list[3]), std::get(list[4])); + std::get(list[0]), + std::get(list[2]), + std::get(list[3]), + std::get(list[4])); auto& encodable_cp_result = list[1]; if (!encodable_cp_result.IsNull()) { decoded.set_cp_result(std::get(encodable_cp_result)); @@ -117,26 +450,74 @@ ProductsListApiResult ProductsListApiResult::FromEncodableList( return decoded; } +bool ProductsListApiResult::operator==(const ProductsListApiResult& other) const { + return PigeonInternalDeepEquals(cp_status_, other.cp_status_) && PigeonInternalDeepEquals(cp_result_, other.cp_result_) && PigeonInternalDeepEquals(total_count_, other.total_count_) && PigeonInternalDeepEquals(check_value_, other.check_value_) && PigeonInternalDeepEquals(item_details_, other.item_details_); +} + +bool ProductsListApiResult::operator!=(const ProductsListApiResult& other) const { + return !(*this == other); +} + +size_t ProductsListApiResult::Hash() const { + size_t result = 1; + result = result * 31 + PigeonInternalDeepHash(cp_status_); + result = result * 31 + PigeonInternalDeepHash(cp_result_); + result = result * 31 + PigeonInternalDeepHash(total_count_); + result = result * 31 + PigeonInternalDeepHash(check_value_); + result = result * 31 + PigeonInternalDeepHash(item_details_); + return result; +} + +std::ostream& operator<<( + std::ostream& os, + const ProductsListApiResult& obj) { + os << "ProductsListApiResult("; + os << "cp_status: "; + os << PigeonInternalToString(obj.cp_status_); + os << ", cp_result: "; + if (obj.cp_result_) { + os << PigeonInternalToString(*obj.cp_result_); + } + else { + os << "null"; + } + os << ", total_count: "; + os << PigeonInternalToString(obj.total_count_); + os << ", check_value: "; + os << PigeonInternalToString(obj.check_value_); + os << ", item_details: "; + os << PigeonInternalToString(obj.item_details_); + os << ")"; + return os; +} + +size_t PigeonInternalDeepHash(const ProductsListApiResult& v) { + return v.Hash(); +} + // GetUserPurchaseListAPIResult GetUserPurchaseListAPIResult::GetUserPurchaseListAPIResult( - const std::string& cp_status, int64_t total_count, - const std::string& check_value, const EncodableList& invoice_details) - : cp_status_(cp_status), - total_count_(total_count), - check_value_(check_value), - invoice_details_(invoice_details) {} + const std::string& cp_status, + int64_t total_count, + const std::string& check_value, + const EncodableList& invoice_details) + : cp_status_(cp_status), + total_count_(total_count), + check_value_(check_value), + invoice_details_(invoice_details) {} GetUserPurchaseListAPIResult::GetUserPurchaseListAPIResult( - const std::string& cp_status, const std::string* cp_result, - int64_t total_count, const std::string& check_value, - const EncodableList& invoice_details) - : cp_status_(cp_status), - cp_result_(cp_result ? std::optional(*cp_result) - : std::nullopt), - total_count_(total_count), - check_value_(check_value), - invoice_details_(invoice_details) {} + const std::string& cp_status, + const std::string* cp_result, + int64_t total_count, + const std::string& check_value, + const EncodableList& invoice_details) + : cp_status_(cp_status), + cp_result_(cp_result ? std::optional(*cp_result) : std::nullopt), + total_count_(total_count), + check_value_(check_value), + invoice_details_(invoice_details) {} const std::string& GetUserPurchaseListAPIResult::cp_status() const { return cp_status_; @@ -146,20 +527,20 @@ void GetUserPurchaseListAPIResult::set_cp_status(std::string_view value_arg) { cp_status_ = value_arg; } + const std::string* GetUserPurchaseListAPIResult::cp_result() const { return cp_result_ ? &(*cp_result_) : nullptr; } -void GetUserPurchaseListAPIResult::set_cp_result( - const std::string_view* value_arg) { - cp_result_ = - value_arg ? std::optional(*value_arg) : std::nullopt; +void GetUserPurchaseListAPIResult::set_cp_result(const std::string_view* value_arg) { + cp_result_ = value_arg ? std::optional(*value_arg) : std::nullopt; } void GetUserPurchaseListAPIResult::set_cp_result(std::string_view value_arg) { cp_result_ = value_arg; } + int64_t GetUserPurchaseListAPIResult::total_count() const { return total_count_; } @@ -168,6 +549,7 @@ void GetUserPurchaseListAPIResult::set_total_count(int64_t value_arg) { total_count_ = value_arg; } + const std::string& GetUserPurchaseListAPIResult::check_value() const { return check_value_; } @@ -176,15 +558,16 @@ void GetUserPurchaseListAPIResult::set_check_value(std::string_view value_arg) { check_value_ = value_arg; } + const EncodableList& GetUserPurchaseListAPIResult::invoice_details() const { return invoice_details_; } -void GetUserPurchaseListAPIResult::set_invoice_details( - const EncodableList& value_arg) { +void GetUserPurchaseListAPIResult::set_invoice_details(const EncodableList& value_arg) { invoice_details_ = value_arg; } + EncodableList GetUserPurchaseListAPIResult::ToEncodableList() const { EncodableList list; list.reserve(5); @@ -196,11 +579,12 @@ EncodableList GetUserPurchaseListAPIResult::ToEncodableList() const { return list; } -GetUserPurchaseListAPIResult GetUserPurchaseListAPIResult::FromEncodableList( - const EncodableList& list) { +GetUserPurchaseListAPIResult GetUserPurchaseListAPIResult::FromEncodableList(const EncodableList& list) { GetUserPurchaseListAPIResult decoded( - std::get(list[0]), std::get(list[2]), - std::get(list[3]), std::get(list[4])); + std::get(list[0]), + std::get(list[2]), + std::get(list[3]), + std::get(list[4])); auto& encodable_cp_result = list[1]; if (!encodable_cp_result.IsNull()) { decoded.set_cp_result(std::get(encodable_cp_result)); @@ -208,24 +592,77 @@ GetUserPurchaseListAPIResult GetUserPurchaseListAPIResult::FromEncodableList( return decoded; } +bool GetUserPurchaseListAPIResult::operator==(const GetUserPurchaseListAPIResult& other) const { + return PigeonInternalDeepEquals(cp_status_, other.cp_status_) && PigeonInternalDeepEquals(cp_result_, other.cp_result_) && PigeonInternalDeepEquals(total_count_, other.total_count_) && PigeonInternalDeepEquals(check_value_, other.check_value_) && PigeonInternalDeepEquals(invoice_details_, other.invoice_details_); +} + +bool GetUserPurchaseListAPIResult::operator!=(const GetUserPurchaseListAPIResult& other) const { + return !(*this == other); +} + +size_t GetUserPurchaseListAPIResult::Hash() const { + size_t result = 1; + result = result * 31 + PigeonInternalDeepHash(cp_status_); + result = result * 31 + PigeonInternalDeepHash(cp_result_); + result = result * 31 + PigeonInternalDeepHash(total_count_); + result = result * 31 + PigeonInternalDeepHash(check_value_); + result = result * 31 + PigeonInternalDeepHash(invoice_details_); + return result; +} + +std::ostream& operator<<( + std::ostream& os, + const GetUserPurchaseListAPIResult& obj) { + os << "GetUserPurchaseListAPIResult("; + os << "cp_status: "; + os << PigeonInternalToString(obj.cp_status_); + os << ", cp_result: "; + if (obj.cp_result_) { + os << PigeonInternalToString(*obj.cp_result_); + } + else { + os << "null"; + } + os << ", total_count: "; + os << PigeonInternalToString(obj.total_count_); + os << ", check_value: "; + os << PigeonInternalToString(obj.check_value_); + os << ", invoice_details: "; + os << PigeonInternalToString(obj.invoice_details_); + os << ")"; + return os; +} + +size_t PigeonInternalDeepHash(const GetUserPurchaseListAPIResult& v) { + return v.Hash(); +} + // BillingBuyData -BillingBuyData::BillingBuyData(const std::string& pay_result, - const EncodableMap& pay_details) - : pay_result_(pay_result), pay_details_(pay_details) {} +BillingBuyData::BillingBuyData( + const std::string& pay_result, + const EncodableMap& pay_details) + : pay_result_(pay_result), + pay_details_(pay_details) {} -const std::string& BillingBuyData::pay_result() const { return pay_result_; } +const std::string& BillingBuyData::pay_result() const { + return pay_result_; +} void BillingBuyData::set_pay_result(std::string_view value_arg) { pay_result_ = value_arg; } -const EncodableMap& BillingBuyData::pay_details() const { return pay_details_; } + +const EncodableMap& BillingBuyData::pay_details() const { + return pay_details_; +} void BillingBuyData::set_pay_details(const EncodableMap& value_arg) { pay_details_ = value_arg; } + EncodableList BillingBuyData::ToEncodableList() const { EncodableList list; list.reserve(2); @@ -235,27 +672,62 @@ EncodableList BillingBuyData::ToEncodableList() const { } BillingBuyData BillingBuyData::FromEncodableList(const EncodableList& list) { - BillingBuyData decoded(std::get(list[0]), - std::get(list[1])); + BillingBuyData decoded( + std::get(list[0]), + std::get(list[1])); return decoded; } +bool BillingBuyData::operator==(const BillingBuyData& other) const { + return PigeonInternalDeepEquals(pay_result_, other.pay_result_) && PigeonInternalDeepEquals(pay_details_, other.pay_details_); +} + +bool BillingBuyData::operator!=(const BillingBuyData& other) const { + return !(*this == other); +} + +size_t BillingBuyData::Hash() const { + size_t result = 1; + result = result * 31 + PigeonInternalDeepHash(pay_result_); + result = result * 31 + PigeonInternalDeepHash(pay_details_); + return result; +} + +std::ostream& operator<<( + std::ostream& os, + const BillingBuyData& obj) { + os << "BillingBuyData("; + os << "pay_result: "; + os << PigeonInternalToString(obj.pay_result_); + os << ", pay_details: "; + os << PigeonInternalToString(obj.pay_details_); + os << ")"; + return os; +} + +size_t PigeonInternalDeepHash(const BillingBuyData& v) { + return v.Hash(); +} + // VerifyInvoiceAPIResult -VerifyInvoiceAPIResult::VerifyInvoiceAPIResult(const std::string& cp_status, - const std::string& app_id, - const std::string& invoice_id) - : cp_status_(cp_status), app_id_(app_id), invoice_id_(invoice_id) {} - -VerifyInvoiceAPIResult::VerifyInvoiceAPIResult(const std::string& cp_status, - const std::string* cp_result, - const std::string& app_id, - const std::string& invoice_id) - : cp_status_(cp_status), - cp_result_(cp_result ? std::optional(*cp_result) - : std::nullopt), - app_id_(app_id), - invoice_id_(invoice_id) {} +VerifyInvoiceAPIResult::VerifyInvoiceAPIResult( + const std::string& cp_status, + const std::string& app_id, + const std::string& invoice_id) + : cp_status_(cp_status), + app_id_(app_id), + invoice_id_(invoice_id) {} + +VerifyInvoiceAPIResult::VerifyInvoiceAPIResult( + const std::string& cp_status, + const std::string* cp_result, + const std::string& app_id, + const std::string& invoice_id) + : cp_status_(cp_status), + cp_result_(cp_result ? std::optional(*cp_result) : std::nullopt), + app_id_(app_id), + invoice_id_(invoice_id) {} const std::string& VerifyInvoiceAPIResult::cp_status() const { return cp_status_; @@ -265,25 +737,29 @@ void VerifyInvoiceAPIResult::set_cp_status(std::string_view value_arg) { cp_status_ = value_arg; } + const std::string* VerifyInvoiceAPIResult::cp_result() const { return cp_result_ ? &(*cp_result_) : nullptr; } void VerifyInvoiceAPIResult::set_cp_result(const std::string_view* value_arg) { - cp_result_ = - value_arg ? std::optional(*value_arg) : std::nullopt; + cp_result_ = value_arg ? std::optional(*value_arg) : std::nullopt; } void VerifyInvoiceAPIResult::set_cp_result(std::string_view value_arg) { cp_result_ = value_arg; } -const std::string& VerifyInvoiceAPIResult::app_id() const { return app_id_; } + +const std::string& VerifyInvoiceAPIResult::app_id() const { + return app_id_; +} void VerifyInvoiceAPIResult::set_app_id(std::string_view value_arg) { app_id_ = value_arg; } + const std::string& VerifyInvoiceAPIResult::invoice_id() const { return invoice_id_; } @@ -292,6 +768,7 @@ void VerifyInvoiceAPIResult::set_invoice_id(std::string_view value_arg) { invoice_id_ = value_arg; } + EncodableList VerifyInvoiceAPIResult::ToEncodableList() const { EncodableList list; list.reserve(4); @@ -302,11 +779,11 @@ EncodableList VerifyInvoiceAPIResult::ToEncodableList() const { return list; } -VerifyInvoiceAPIResult VerifyInvoiceAPIResult::FromEncodableList( - const EncodableList& list) { - VerifyInvoiceAPIResult decoded(std::get(list[0]), - std::get(list[2]), - std::get(list[3])); +VerifyInvoiceAPIResult VerifyInvoiceAPIResult::FromEncodableList(const EncodableList& list) { + VerifyInvoiceAPIResult decoded( + std::get(list[0]), + std::get(list[2]), + std::get(list[3])); auto& encodable_cp_result = list[1]; if (!encodable_cp_result.IsNull()) { decoded.set_cp_result(std::get(encodable_cp_result)); @@ -314,25 +791,76 @@ VerifyInvoiceAPIResult VerifyInvoiceAPIResult::FromEncodableList( return decoded; } +bool VerifyInvoiceAPIResult::operator==(const VerifyInvoiceAPIResult& other) const { + return PigeonInternalDeepEquals(cp_status_, other.cp_status_) && PigeonInternalDeepEquals(cp_result_, other.cp_result_) && PigeonInternalDeepEquals(app_id_, other.app_id_) && PigeonInternalDeepEquals(invoice_id_, other.invoice_id_); +} + +bool VerifyInvoiceAPIResult::operator!=(const VerifyInvoiceAPIResult& other) const { + return !(*this == other); +} + +size_t VerifyInvoiceAPIResult::Hash() const { + size_t result = 1; + result = result * 31 + PigeonInternalDeepHash(cp_status_); + result = result * 31 + PigeonInternalDeepHash(cp_result_); + result = result * 31 + PigeonInternalDeepHash(app_id_); + result = result * 31 + PigeonInternalDeepHash(invoice_id_); + return result; +} + +std::ostream& operator<<( + std::ostream& os, + const VerifyInvoiceAPIResult& obj) { + os << "VerifyInvoiceAPIResult("; + os << "cp_status: "; + os << PigeonInternalToString(obj.cp_status_); + os << ", cp_result: "; + if (obj.cp_result_) { + os << PigeonInternalToString(*obj.cp_result_); + } + else { + os << "null"; + } + os << ", app_id: "; + os << PigeonInternalToString(obj.app_id_); + os << ", invoice_id: "; + os << PigeonInternalToString(obj.invoice_id_); + os << ")"; + return os; +} + +size_t PigeonInternalDeepHash(const VerifyInvoiceAPIResult& v) { + return v.Hash(); +} + // ServiceAvailableAPIResult ServiceAvailableAPIResult::ServiceAvailableAPIResult( - const std::string& status, const std::string& result, - const std::string& service_yn) - : status_(status), result_(result), service_yn_(service_yn) {} + const std::string& status, + const std::string& result, + const std::string& service_yn) + : status_(status), + result_(result), + service_yn_(service_yn) {} -const std::string& ServiceAvailableAPIResult::status() const { return status_; } +const std::string& ServiceAvailableAPIResult::status() const { + return status_; +} void ServiceAvailableAPIResult::set_status(std::string_view value_arg) { status_ = value_arg; } -const std::string& ServiceAvailableAPIResult::result() const { return result_; } + +const std::string& ServiceAvailableAPIResult::result() const { + return result_; +} void ServiceAvailableAPIResult::set_result(std::string_view value_arg) { result_ = value_arg; } + const std::string& ServiceAvailableAPIResult::service_yn() const { return service_yn_; } @@ -341,6 +869,7 @@ void ServiceAvailableAPIResult::set_service_yn(std::string_view value_arg) { service_yn_ = value_arg; } + EncodableList ServiceAvailableAPIResult::ToEncodableList() const { EncodableList list; list.reserve(3); @@ -350,32 +879,71 @@ EncodableList ServiceAvailableAPIResult::ToEncodableList() const { return list; } -ServiceAvailableAPIResult ServiceAvailableAPIResult::FromEncodableList( - const EncodableList& list) { - ServiceAvailableAPIResult decoded(std::get(list[0]), - std::get(list[1]), - std::get(list[2])); +ServiceAvailableAPIResult ServiceAvailableAPIResult::FromEncodableList(const EncodableList& list) { + ServiceAvailableAPIResult decoded( + std::get(list[0]), + std::get(list[1]), + std::get(list[2])); return decoded; } +bool ServiceAvailableAPIResult::operator==(const ServiceAvailableAPIResult& other) const { + return PigeonInternalDeepEquals(status_, other.status_) && PigeonInternalDeepEquals(result_, other.result_) && PigeonInternalDeepEquals(service_yn_, other.service_yn_); +} + +bool ServiceAvailableAPIResult::operator!=(const ServiceAvailableAPIResult& other) const { + return !(*this == other); +} + +size_t ServiceAvailableAPIResult::Hash() const { + size_t result = 1; + result = result * 31 + PigeonInternalDeepHash(status_); + result = result * 31 + PigeonInternalDeepHash(result_); + result = result * 31 + PigeonInternalDeepHash(service_yn_); + return result; +} + +std::ostream& operator<<( + std::ostream& os, + const ServiceAvailableAPIResult& obj) { + os << "ServiceAvailableAPIResult("; + os << "status: "; + os << PigeonInternalToString(obj.status_); + os << ", result: "; + os << PigeonInternalToString(obj.result_); + os << ", service_yn: "; + os << PigeonInternalToString(obj.service_yn_); + os << ")"; + return os; +} + +size_t PigeonInternalDeepHash(const ServiceAvailableAPIResult& v) { + return v.Hash(); +} + // ProductMessage -ProductMessage::ProductMessage(const std::string& app_id, - const std::string& country_code, - int64_t page_size, int64_t page_num, - const std::string& check_value) - : app_id_(app_id), - country_code_(country_code), - page_size_(page_size), - page_num_(page_num), - check_value_(check_value) {} +ProductMessage::ProductMessage( + const std::string& app_id, + const std::string& country_code, + int64_t page_size, + int64_t page_num, + const std::string& check_value) + : app_id_(app_id), + country_code_(country_code), + page_size_(page_size), + page_num_(page_num), + check_value_(check_value) {} -const std::string& ProductMessage::app_id() const { return app_id_; } +const std::string& ProductMessage::app_id() const { + return app_id_; +} void ProductMessage::set_app_id(std::string_view value_arg) { app_id_ = value_arg; } + const std::string& ProductMessage::country_code() const { return country_code_; } @@ -384,22 +952,34 @@ void ProductMessage::set_country_code(std::string_view value_arg) { country_code_ = value_arg; } -int64_t ProductMessage::page_size() const { return page_size_; } + +int64_t ProductMessage::page_size() const { + return page_size_; +} void ProductMessage::set_page_size(int64_t value_arg) { page_size_ = value_arg; } -int64_t ProductMessage::page_num() const { return page_num_; } -void ProductMessage::set_page_num(int64_t value_arg) { page_num_ = value_arg; } +int64_t ProductMessage::page_num() const { + return page_num_; +} + +void ProductMessage::set_page_num(int64_t value_arg) { + page_num_ = value_arg; +} -const std::string& ProductMessage::check_value() const { return check_value_; } + +const std::string& ProductMessage::check_value() const { + return check_value_; +} void ProductMessage::set_check_value(std::string_view value_arg) { check_value_ = value_arg; } + EncodableList ProductMessage::ToEncodableList() const { EncodableList list; list.reserve(5); @@ -412,38 +992,87 @@ EncodableList ProductMessage::ToEncodableList() const { } ProductMessage ProductMessage::FromEncodableList(const EncodableList& list) { - ProductMessage decoded(std::get(list[0]), - std::get(list[1]), - std::get(list[2]), std::get(list[3]), - std::get(list[4])); + ProductMessage decoded( + std::get(list[0]), + std::get(list[1]), + std::get(list[2]), + std::get(list[3]), + std::get(list[4])); return decoded; } +bool ProductMessage::operator==(const ProductMessage& other) const { + return PigeonInternalDeepEquals(app_id_, other.app_id_) && PigeonInternalDeepEquals(country_code_, other.country_code_) && PigeonInternalDeepEquals(page_size_, other.page_size_) && PigeonInternalDeepEquals(page_num_, other.page_num_) && PigeonInternalDeepEquals(check_value_, other.check_value_); +} + +bool ProductMessage::operator!=(const ProductMessage& other) const { + return !(*this == other); +} + +size_t ProductMessage::Hash() const { + size_t result = 1; + result = result * 31 + PigeonInternalDeepHash(app_id_); + result = result * 31 + PigeonInternalDeepHash(country_code_); + result = result * 31 + PigeonInternalDeepHash(page_size_); + result = result * 31 + PigeonInternalDeepHash(page_num_); + result = result * 31 + PigeonInternalDeepHash(check_value_); + return result; +} + +std::ostream& operator<<( + std::ostream& os, + const ProductMessage& obj) { + os << "ProductMessage("; + os << "app_id: "; + os << PigeonInternalToString(obj.app_id_); + os << ", country_code: "; + os << PigeonInternalToString(obj.country_code_); + os << ", page_size: "; + os << PigeonInternalToString(obj.page_size_); + os << ", page_num: "; + os << PigeonInternalToString(obj.page_num_); + os << ", check_value: "; + os << PigeonInternalToString(obj.check_value_); + os << ")"; + return os; +} + +size_t PigeonInternalDeepHash(const ProductMessage& v) { + return v.Hash(); +} + // PurchaseMessage -PurchaseMessage::PurchaseMessage(const std::string& app_id, - const std::string& custom_id, - const std::string& country_code, - int64_t page_num, - const std::string& check_value) - : app_id_(app_id), - custom_id_(custom_id), - country_code_(country_code), - page_num_(page_num), - check_value_(check_value) {} +PurchaseMessage::PurchaseMessage( + const std::string& app_id, + const std::string& custom_id, + const std::string& country_code, + int64_t page_num, + const std::string& check_value) + : app_id_(app_id), + custom_id_(custom_id), + country_code_(country_code), + page_num_(page_num), + check_value_(check_value) {} -const std::string& PurchaseMessage::app_id() const { return app_id_; } +const std::string& PurchaseMessage::app_id() const { + return app_id_; +} void PurchaseMessage::set_app_id(std::string_view value_arg) { app_id_ = value_arg; } -const std::string& PurchaseMessage::custom_id() const { return custom_id_; } + +const std::string& PurchaseMessage::custom_id() const { + return custom_id_; +} void PurchaseMessage::set_custom_id(std::string_view value_arg) { custom_id_ = value_arg; } + const std::string& PurchaseMessage::country_code() const { return country_code_; } @@ -452,16 +1081,25 @@ void PurchaseMessage::set_country_code(std::string_view value_arg) { country_code_ = value_arg; } -int64_t PurchaseMessage::page_num() const { return page_num_; } -void PurchaseMessage::set_page_num(int64_t value_arg) { page_num_ = value_arg; } +int64_t PurchaseMessage::page_num() const { + return page_num_; +} + +void PurchaseMessage::set_page_num(int64_t value_arg) { + page_num_ = value_arg; +} -const std::string& PurchaseMessage::check_value() const { return check_value_; } + +const std::string& PurchaseMessage::check_value() const { + return check_value_; +} void PurchaseMessage::set_check_value(std::string_view value_arg) { check_value_ = value_arg; } + EncodableList PurchaseMessage::ToEncodableList() const { EncodableList list; list.reserve(5); @@ -475,24 +1113,67 @@ EncodableList PurchaseMessage::ToEncodableList() const { PurchaseMessage PurchaseMessage::FromEncodableList(const EncodableList& list) { PurchaseMessage decoded( - std::get(list[0]), std::get(list[1]), - std::get(list[2]), std::get(list[3]), - std::get(list[4])); + std::get(list[0]), + std::get(list[1]), + std::get(list[2]), + std::get(list[3]), + std::get(list[4])); return decoded; } +bool PurchaseMessage::operator==(const PurchaseMessage& other) const { + return PigeonInternalDeepEquals(app_id_, other.app_id_) && PigeonInternalDeepEquals(custom_id_, other.custom_id_) && PigeonInternalDeepEquals(country_code_, other.country_code_) && PigeonInternalDeepEquals(page_num_, other.page_num_) && PigeonInternalDeepEquals(check_value_, other.check_value_); +} + +bool PurchaseMessage::operator!=(const PurchaseMessage& other) const { + return !(*this == other); +} + +size_t PurchaseMessage::Hash() const { + size_t result = 1; + result = result * 31 + PigeonInternalDeepHash(app_id_); + result = result * 31 + PigeonInternalDeepHash(custom_id_); + result = result * 31 + PigeonInternalDeepHash(country_code_); + result = result * 31 + PigeonInternalDeepHash(page_num_); + result = result * 31 + PigeonInternalDeepHash(check_value_); + return result; +} + +std::ostream& operator<<( + std::ostream& os, + const PurchaseMessage& obj) { + os << "PurchaseMessage("; + os << "app_id: "; + os << PigeonInternalToString(obj.app_id_); + os << ", custom_id: "; + os << PigeonInternalToString(obj.custom_id_); + os << ", country_code: "; + os << PigeonInternalToString(obj.country_code_); + os << ", page_num: "; + os << PigeonInternalToString(obj.page_num_); + os << ", check_value: "; + os << PigeonInternalToString(obj.check_value_); + os << ")"; + return os; +} + +size_t PigeonInternalDeepHash(const PurchaseMessage& v) { + return v.Hash(); +} + // OrderDetails -OrderDetails::OrderDetails(const std::string& order_item_id, - const std::string& order_title, - const std::string& order_total, - const std::string& order_currency_id, - const std::string& order_custom_id) - : order_item_id_(order_item_id), - order_title_(order_title), - order_total_(order_total), - order_currency_id_(order_currency_id), - order_custom_id_(order_custom_id) {} +OrderDetails::OrderDetails( + const std::string& order_item_id, + const std::string& order_title, + const std::string& order_total, + const std::string& order_currency_id, + const std::string& order_custom_id) + : order_item_id_(order_item_id), + order_title_(order_title), + order_total_(order_total), + order_currency_id_(order_currency_id), + order_custom_id_(order_custom_id) {} const std::string& OrderDetails::order_item_id() const { return order_item_id_; @@ -502,18 +1183,25 @@ void OrderDetails::set_order_item_id(std::string_view value_arg) { order_item_id_ = value_arg; } -const std::string& OrderDetails::order_title() const { return order_title_; } + +const std::string& OrderDetails::order_title() const { + return order_title_; +} void OrderDetails::set_order_title(std::string_view value_arg) { order_title_ = value_arg; } -const std::string& OrderDetails::order_total() const { return order_total_; } + +const std::string& OrderDetails::order_total() const { + return order_total_; +} void OrderDetails::set_order_total(std::string_view value_arg) { order_total_ = value_arg; } + const std::string& OrderDetails::order_currency_id() const { return order_currency_id_; } @@ -522,6 +1210,7 @@ void OrderDetails::set_order_currency_id(std::string_view value_arg) { order_currency_id_ = value_arg; } + const std::string& OrderDetails::order_custom_id() const { return order_custom_id_; } @@ -530,6 +1219,7 @@ void OrderDetails::set_order_custom_id(std::string_view value_arg) { order_custom_id_ = value_arg; } + EncodableList OrderDetails::ToEncodableList() const { EncodableList list; list.reserve(5); @@ -543,22 +1233,65 @@ EncodableList OrderDetails::ToEncodableList() const { OrderDetails OrderDetails::FromEncodableList(const EncodableList& list) { OrderDetails decoded( - std::get(list[0]), std::get(list[1]), - std::get(list[2]), std::get(list[3]), - std::get(list[4])); + std::get(list[0]), + std::get(list[1]), + std::get(list[2]), + std::get(list[3]), + std::get(list[4])); return decoded; } +bool OrderDetails::operator==(const OrderDetails& other) const { + return PigeonInternalDeepEquals(order_item_id_, other.order_item_id_) && PigeonInternalDeepEquals(order_title_, other.order_title_) && PigeonInternalDeepEquals(order_total_, other.order_total_) && PigeonInternalDeepEquals(order_currency_id_, other.order_currency_id_) && PigeonInternalDeepEquals(order_custom_id_, other.order_custom_id_); +} + +bool OrderDetails::operator!=(const OrderDetails& other) const { + return !(*this == other); +} + +size_t OrderDetails::Hash() const { + size_t result = 1; + result = result * 31 + PigeonInternalDeepHash(order_item_id_); + result = result * 31 + PigeonInternalDeepHash(order_title_); + result = result * 31 + PigeonInternalDeepHash(order_total_); + result = result * 31 + PigeonInternalDeepHash(order_currency_id_); + result = result * 31 + PigeonInternalDeepHash(order_custom_id_); + return result; +} + +std::ostream& operator<<( + std::ostream& os, + const OrderDetails& obj) { + os << "OrderDetails("; + os << "order_item_id: "; + os << PigeonInternalToString(obj.order_item_id_); + os << ", order_title: "; + os << PigeonInternalToString(obj.order_title_); + os << ", order_total: "; + os << PigeonInternalToString(obj.order_total_); + os << ", order_currency_id: "; + os << PigeonInternalToString(obj.order_currency_id_); + os << ", order_custom_id: "; + os << PigeonInternalToString(obj.order_custom_id_); + os << ")"; + return os; +} + +size_t PigeonInternalDeepHash(const OrderDetails& v) { + return v.Hash(); +} + // BuyInfoMessage -BuyInfoMessage::BuyInfoMessage(const std::string& app_id, - const OrderDetails& pay_detials) - : app_id_(app_id), - pay_detials_(std::make_unique(pay_detials)) {} +BuyInfoMessage::BuyInfoMessage( + const std::string& app_id, + const OrderDetails& pay_detials) + : app_id_(app_id), + pay_detials_(std::make_unique(pay_detials)) {} BuyInfoMessage::BuyInfoMessage(const BuyInfoMessage& other) - : app_id_(other.app_id_), - pay_detials_(std::make_unique(*other.pay_detials_)) {} + : app_id_(other.app_id_), + pay_detials_(std::make_unique(*other.pay_detials_)) {} BuyInfoMessage& BuyInfoMessage::operator=(const BuyInfoMessage& other) { app_id_ = other.app_id_; @@ -566,12 +1299,15 @@ BuyInfoMessage& BuyInfoMessage::operator=(const BuyInfoMessage& other) { return *this; } -const std::string& BuyInfoMessage::app_id() const { return app_id_; } +const std::string& BuyInfoMessage::app_id() const { + return app_id_; +} void BuyInfoMessage::set_app_id(std::string_view value_arg) { app_id_ = value_arg; } + const OrderDetails& BuyInfoMessage::pay_detials() const { return *pay_detials_; } @@ -580,6 +1316,7 @@ void BuyInfoMessage::set_pay_detials(const OrderDetails& value_arg) { pay_detials_ = std::make_unique(value_arg); } + EncodableList BuyInfoMessage::ToEncodableList() const { EncodableList list; list.reserve(2); @@ -589,41 +1326,82 @@ EncodableList BuyInfoMessage::ToEncodableList() const { } BuyInfoMessage BuyInfoMessage::FromEncodableList(const EncodableList& list) { - BuyInfoMessage decoded(std::get(list[0]), - std::any_cast( - std::get(list[1]))); + BuyInfoMessage decoded( + std::get(list[0]), + std::any_cast(std::get(list[1]))); return decoded; } +bool BuyInfoMessage::operator==(const BuyInfoMessage& other) const { + return PigeonInternalDeepEquals(app_id_, other.app_id_) && PigeonInternalDeepEquals(pay_detials_, other.pay_detials_); +} + +bool BuyInfoMessage::operator!=(const BuyInfoMessage& other) const { + return !(*this == other); +} + +size_t BuyInfoMessage::Hash() const { + size_t result = 1; + result = result * 31 + PigeonInternalDeepHash(app_id_); + result = result * 31 + PigeonInternalDeepHash(pay_detials_); + return result; +} + +std::ostream& operator<<( + std::ostream& os, + const BuyInfoMessage& obj) { + os << "BuyInfoMessage("; + os << "app_id: "; + os << PigeonInternalToString(obj.app_id_); + os << ", pay_detials: "; + os << *obj.pay_detials_; + os << ")"; + return os; +} + +size_t PigeonInternalDeepHash(const BuyInfoMessage& v) { + return v.Hash(); +} + // InvoiceMessage -InvoiceMessage::InvoiceMessage(const std::string& app_id, - const std::string& custom_id, - const std::string& invoice_id, - const std::string& country_code) - : app_id_(app_id), - custom_id_(custom_id), - invoice_id_(invoice_id), - country_code_(country_code) {} +InvoiceMessage::InvoiceMessage( + const std::string& app_id, + const std::string& custom_id, + const std::string& invoice_id, + const std::string& country_code) + : app_id_(app_id), + custom_id_(custom_id), + invoice_id_(invoice_id), + country_code_(country_code) {} -const std::string& InvoiceMessage::app_id() const { return app_id_; } +const std::string& InvoiceMessage::app_id() const { + return app_id_; +} void InvoiceMessage::set_app_id(std::string_view value_arg) { app_id_ = value_arg; } -const std::string& InvoiceMessage::custom_id() const { return custom_id_; } + +const std::string& InvoiceMessage::custom_id() const { + return custom_id_; +} void InvoiceMessage::set_custom_id(std::string_view value_arg) { custom_id_ = value_arg; } -const std::string& InvoiceMessage::invoice_id() const { return invoice_id_; } + +const std::string& InvoiceMessage::invoice_id() const { + return invoice_id_; +} void InvoiceMessage::set_invoice_id(std::string_view value_arg) { invoice_id_ = value_arg; } + const std::string& InvoiceMessage::country_code() const { return country_code_; } @@ -632,6 +1410,7 @@ void InvoiceMessage::set_country_code(std::string_view value_arg) { country_code_ = value_arg; } + EncodableList InvoiceMessage::ToEncodableList() const { EncodableList list; list.reserve(4); @@ -644,404 +1423,343 @@ EncodableList InvoiceMessage::ToEncodableList() const { InvoiceMessage InvoiceMessage::FromEncodableList(const EncodableList& list) { InvoiceMessage decoded( - std::get(list[0]), std::get(list[1]), - std::get(list[2]), std::get(list[3])); + std::get(list[0]), + std::get(list[1]), + std::get(list[2]), + std::get(list[3])); return decoded; } +bool InvoiceMessage::operator==(const InvoiceMessage& other) const { + return PigeonInternalDeepEquals(app_id_, other.app_id_) && PigeonInternalDeepEquals(custom_id_, other.custom_id_) && PigeonInternalDeepEquals(invoice_id_, other.invoice_id_) && PigeonInternalDeepEquals(country_code_, other.country_code_); +} + +bool InvoiceMessage::operator!=(const InvoiceMessage& other) const { + return !(*this == other); +} + +size_t InvoiceMessage::Hash() const { + size_t result = 1; + result = result * 31 + PigeonInternalDeepHash(app_id_); + result = result * 31 + PigeonInternalDeepHash(custom_id_); + result = result * 31 + PigeonInternalDeepHash(invoice_id_); + result = result * 31 + PigeonInternalDeepHash(country_code_); + return result; +} + +std::ostream& operator<<( + std::ostream& os, + const InvoiceMessage& obj) { + os << "InvoiceMessage("; + os << "app_id: "; + os << PigeonInternalToString(obj.app_id_); + os << ", custom_id: "; + os << PigeonInternalToString(obj.custom_id_); + os << ", invoice_id: "; + os << PigeonInternalToString(obj.invoice_id_); + os << ", country_code: "; + os << PigeonInternalToString(obj.country_code_); + os << ")"; + return os; +} + +size_t PigeonInternalDeepHash(const InvoiceMessage& v) { + return v.Hash(); +} + + PigeonInternalCodecSerializer::PigeonInternalCodecSerializer() {} EncodableValue PigeonInternalCodecSerializer::ReadValueOfType( - uint8_t type, flutter::ByteStreamReader* stream) const { + uint8_t type, + ::flutter::ByteStreamReader* stream) const { switch (type) { case 129: { - return CustomEncodableValue(ProductsListApiResult::FromEncodableList( - std::get(ReadValue(stream)))); - } + return CustomEncodableValue(ProductsListApiResult::FromEncodableList(std::get(ReadValue(stream)))); + } case 130: { - return CustomEncodableValue( - GetUserPurchaseListAPIResult::FromEncodableList( - std::get(ReadValue(stream)))); - } + return CustomEncodableValue(GetUserPurchaseListAPIResult::FromEncodableList(std::get(ReadValue(stream)))); + } case 131: { - return CustomEncodableValue(BillingBuyData::FromEncodableList( - std::get(ReadValue(stream)))); - } + return CustomEncodableValue(BillingBuyData::FromEncodableList(std::get(ReadValue(stream)))); + } case 132: { - return CustomEncodableValue(VerifyInvoiceAPIResult::FromEncodableList( - std::get(ReadValue(stream)))); - } + return CustomEncodableValue(VerifyInvoiceAPIResult::FromEncodableList(std::get(ReadValue(stream)))); + } case 133: { - return CustomEncodableValue(ServiceAvailableAPIResult::FromEncodableList( - std::get(ReadValue(stream)))); - } + return CustomEncodableValue(ServiceAvailableAPIResult::FromEncodableList(std::get(ReadValue(stream)))); + } case 134: { - return CustomEncodableValue(ProductMessage::FromEncodableList( - std::get(ReadValue(stream)))); - } + return CustomEncodableValue(ProductMessage::FromEncodableList(std::get(ReadValue(stream)))); + } case 135: { - return CustomEncodableValue(PurchaseMessage::FromEncodableList( - std::get(ReadValue(stream)))); - } + return CustomEncodableValue(PurchaseMessage::FromEncodableList(std::get(ReadValue(stream)))); + } case 136: { - return CustomEncodableValue(OrderDetails::FromEncodableList( - std::get(ReadValue(stream)))); - } + return CustomEncodableValue(OrderDetails::FromEncodableList(std::get(ReadValue(stream)))); + } case 137: { - return CustomEncodableValue(BuyInfoMessage::FromEncodableList( - std::get(ReadValue(stream)))); - } + return CustomEncodableValue(BuyInfoMessage::FromEncodableList(std::get(ReadValue(stream)))); + } case 138: { - return CustomEncodableValue(InvoiceMessage::FromEncodableList( - std::get(ReadValue(stream)))); - } + return CustomEncodableValue(InvoiceMessage::FromEncodableList(std::get(ReadValue(stream)))); + } default: - return flutter::StandardCodecSerializer::ReadValueOfType(type, stream); - } + return ::flutter::StandardCodecSerializer::ReadValueOfType(type, stream); + } } void PigeonInternalCodecSerializer::WriteValue( - const EncodableValue& value, flutter::ByteStreamWriter* stream) const { - if (const CustomEncodableValue* custom_value = - std::get_if(&value)) { + const EncodableValue& value, + ::flutter::ByteStreamWriter* stream) const { + if (const CustomEncodableValue* custom_value = std::get_if(&value)) { if (custom_value->type() == typeid(ProductsListApiResult)) { stream->WriteByte(129); - WriteValue( - EncodableValue(std::any_cast(*custom_value) - .ToEncodableList()), - stream); + WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); return; } if (custom_value->type() == typeid(GetUserPurchaseListAPIResult)) { stream->WriteByte(130); - WriteValue(EncodableValue( - std::any_cast(*custom_value) - .ToEncodableList()), - stream); + WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); return; } if (custom_value->type() == typeid(BillingBuyData)) { stream->WriteByte(131); - WriteValue( - EncodableValue( - std::any_cast(*custom_value).ToEncodableList()), - stream); + WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); return; } if (custom_value->type() == typeid(VerifyInvoiceAPIResult)) { stream->WriteByte(132); - WriteValue( - EncodableValue(std::any_cast(*custom_value) - .ToEncodableList()), - stream); + WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); return; } if (custom_value->type() == typeid(ServiceAvailableAPIResult)) { stream->WriteByte(133); - WriteValue( - EncodableValue(std::any_cast(*custom_value) - .ToEncodableList()), - stream); + WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); return; } if (custom_value->type() == typeid(ProductMessage)) { stream->WriteByte(134); - WriteValue( - EncodableValue( - std::any_cast(*custom_value).ToEncodableList()), - stream); + WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); return; } if (custom_value->type() == typeid(PurchaseMessage)) { stream->WriteByte(135); - WriteValue( - EncodableValue( - std::any_cast(*custom_value).ToEncodableList()), - stream); + WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); return; } if (custom_value->type() == typeid(OrderDetails)) { stream->WriteByte(136); - WriteValue( - EncodableValue( - std::any_cast(*custom_value).ToEncodableList()), - stream); + WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); return; } if (custom_value->type() == typeid(BuyInfoMessage)) { stream->WriteByte(137); - WriteValue( - EncodableValue( - std::any_cast(*custom_value).ToEncodableList()), - stream); + WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); return; } if (custom_value->type() == typeid(InvoiceMessage)) { stream->WriteByte(138); - WriteValue( - EncodableValue( - std::any_cast(*custom_value).ToEncodableList()), - stream); + WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); return; } } - flutter::StandardCodecSerializer::WriteValue(value, stream); + ::flutter::StandardCodecSerializer::WriteValue(value, stream); } /// The codec used by InAppPurchaseApi. -const flutter::StandardMessageCodec& InAppPurchaseApi::GetCodec() { - return flutter::StandardMessageCodec::GetInstance( - &PigeonInternalCodecSerializer::GetInstance()); +const ::flutter::StandardMessageCodec& InAppPurchaseApi::GetCodec() { + return ::flutter::StandardMessageCodec::GetInstance(&PigeonInternalCodecSerializer::GetInstance()); } -// Sets up an instance of `InAppPurchaseApi` to handle messages through the -// `binary_messenger`. -void InAppPurchaseApi::SetUp(flutter::BinaryMessenger* binary_messenger, - InAppPurchaseApi* api) { +// Sets up an instance of `InAppPurchaseApi` to handle messages through the `binary_messenger`. +void InAppPurchaseApi::SetUp( + ::flutter::BinaryMessenger* binary_messenger, + InAppPurchaseApi* api) { InAppPurchaseApi::SetUp(binary_messenger, api, ""); } -void InAppPurchaseApi::SetUp(flutter::BinaryMessenger* binary_messenger, - InAppPurchaseApi* api, - const std::string& message_channel_suffix) { - const std::string prepended_suffix = - message_channel_suffix.length() > 0 - ? std::string(".") + message_channel_suffix - : ""; +void InAppPurchaseApi::SetUp( + ::flutter::BinaryMessenger* binary_messenger, + InAppPurchaseApi* api, + const std::string& message_channel_suffix) { + const std::string prepended_suffix = message_channel_suffix.length() > 0 ? std::string(".") + message_channel_suffix : ""; { - BasicMessageChannel<> channel(binary_messenger, - "dev.flutter.pigeon.in_app_purchase_tizen." - "InAppPurchaseApi.getProductsList" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.getProductsList" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_product_arg = args.at(0); - if (encodable_product_arg.IsNull()) { - reply(WrapError("product_arg unexpectedly null.")); - return; - } - const auto& product_arg = std::any_cast( - std::get(encodable_product_arg)); - api->GetProductsList( - product_arg, - [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; - wrapped.push_back( - CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_product_arg = args.at(0); + if (encodable_product_arg.IsNull()) { + reply(WrapError("product_arg unexpectedly null.")); + return; + } + const auto& product_arg = std::any_cast(std::get(encodable_product_arg)); + api->GetProductsList(product_arg, [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; } + EncodableList wrapped; + wrapped.push_back(CustomEncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel(binary_messenger, - "dev.flutter.pigeon.in_app_purchase_tizen." - "InAppPurchaseApi.getUserPurchaseList" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.getUserPurchaseList" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_purchase_arg = args.at(0); - if (encodable_purchase_arg.IsNull()) { - reply(WrapError("purchase_arg unexpectedly null.")); - return; - } - const auto& purchase_arg = std::any_cast( - std::get(encodable_purchase_arg)); - api->GetUserPurchaseList( - purchase_arg, - [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; - wrapped.push_back( - CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_purchase_arg = args.at(0); + if (encodable_purchase_arg.IsNull()) { + reply(WrapError("purchase_arg unexpectedly null.")); + return; + } + const auto& purchase_arg = std::any_cast(std::get(encodable_purchase_arg)); + api->GetUserPurchaseList(purchase_arg, [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; } + EncodableList wrapped; + wrapped.push_back(CustomEncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel( - binary_messenger, - "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.buyItem" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.buyItem" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_buy_info_arg = args.at(0); - if (encodable_buy_info_arg.IsNull()) { - reply(WrapError("buy_info_arg unexpectedly null.")); - return; - } - const auto& buy_info_arg = std::any_cast( - std::get(encodable_buy_info_arg)); - api->BuyItem( - buy_info_arg, [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; - wrapped.push_back( - CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_buy_info_arg = args.at(0); + if (encodable_buy_info_arg.IsNull()) { + reply(WrapError("buy_info_arg unexpectedly null.")); + return; + } + const auto& buy_info_arg = std::any_cast(std::get(encodable_buy_info_arg)); + api->BuyItem(buy_info_arg, [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; } + EncodableList wrapped; + wrapped.push_back(CustomEncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel(binary_messenger, - "dev.flutter.pigeon.in_app_purchase_tizen." - "InAppPurchaseApi.verifyInvoice" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.verifyInvoice" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_invoice_arg = args.at(0); - if (encodable_invoice_arg.IsNull()) { - reply(WrapError("invoice_arg unexpectedly null.")); - return; - } - const auto& invoice_arg = std::any_cast( - std::get(encodable_invoice_arg)); - api->VerifyInvoice( - invoice_arg, - [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; - wrapped.push_back( - CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_invoice_arg = args.at(0); + if (encodable_invoice_arg.IsNull()) { + reply(WrapError("invoice_arg unexpectedly null.")); + return; + } + const auto& invoice_arg = std::any_cast(std::get(encodable_invoice_arg)); + api->VerifyInvoice(invoice_arg, [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; } + EncodableList wrapped; + wrapped.push_back(CustomEncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel(binary_messenger, - "dev.flutter.pigeon.in_app_purchase_tizen." - "InAppPurchaseApi.isServiceAvailable" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.isServiceAvailable" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - api->IsServiceAvailable([reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; - wrapped.push_back( - EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); - }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); + channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) { + try { + api->IsServiceAvailable([reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; } + EncodableList wrapped; + wrapped.push_back(EncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel(binary_messenger, - "dev.flutter.pigeon.in_app_purchase_tizen." - "InAppPurchaseApi.getCustomId" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.getCustomId" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - ErrorOr output = api->GetCustomId(); - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); + channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) { + try { + ErrorOr output = api->GetCustomId(); + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel(binary_messenger, - "dev.flutter.pigeon.in_app_purchase_tizen." - "InAppPurchaseApi.getCountryCode" + - prepended_suffix, - &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.getCountryCode" + prepended_suffix, &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler( - [api](const EncodableValue& message, - const flutter::MessageReply& reply) { - try { - ErrorOr output = api->GetCountryCode(); - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); + channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) { + try { + ErrorOr output = api->GetCountryCode(); + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } @@ -1049,15 +1767,19 @@ void InAppPurchaseApi::SetUp(flutter::BinaryMessenger* binary_messenger, } EncodableValue InAppPurchaseApi::WrapError(std::string_view error_message) { - return EncodableValue( - EncodableList{EncodableValue(std::string(error_message)), - EncodableValue("Error"), EncodableValue()}); + return EncodableValue(EncodableList{ + EncodableValue(std::string(error_message)), + EncodableValue("Error"), + EncodableValue() + }); } EncodableValue InAppPurchaseApi::WrapError(const FlutterError& error) { - return EncodableValue(EncodableList{EncodableValue(error.code()), - EncodableValue(error.message()), - error.details()}); + return EncodableValue(EncodableList{ + EncodableValue(error.code()), + EncodableValue(error.message()), + error.details() + }); } } // namespace in_app_purchase_tizen diff --git a/packages/in_app_purchase/tizen/src/messages.h b/packages/in_app_purchase/tizen/src/messages.h index 6b894f3a7..00f2da770 100644 --- a/packages/in_app_purchase/tizen/src/messages.h +++ b/packages/in_app_purchase/tizen/src/messages.h @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v22.7.4), do not edit directly. +// Autogenerated from Pigeon (v29.0.11), do not edit directly. // See also: https://pub.dev/packages/pigeon #ifndef PIGEON_MESSAGES_H_ @@ -10,33 +10,34 @@ #include #include +#include #include namespace in_app_purchase_tizen { + // Generated class from Pigeon. class FlutterError { public: - explicit FlutterError(const std::string& code) : code_(code) {} + explicit FlutterError(const std::string& code) + : code_(code) {} explicit FlutterError(const std::string& code, const std::string& message) - : code_(code), message_(message) {} - explicit FlutterError(const std::string& code, const std::string& message, - const flutter::EncodableValue& details) - : code_(code), message_(message), details_(details) {} + : code_(code), message_(message) {} + explicit FlutterError(const std::string& code, const std::string& message, const ::flutter::EncodableValue& details) + : code_(code), message_(message), details_(details) {} const std::string& code() const { return code_; } const std::string& message() const { return message_; } - const flutter::EncodableValue& details() const { return details_; } + const ::flutter::EncodableValue& details() const { return details_; } private: std::string code_; std::string message_; - flutter::EncodableValue details_; + ::flutter::EncodableValue details_; }; -template -class ErrorOr { +template class ErrorOr { public: ErrorOr(const T& rhs) : v_(rhs) {} ErrorOr(const T&& rhs) : v_(std::move(rhs)) {} @@ -55,27 +56,30 @@ class ErrorOr { std::variant v_; }; -// Dart wrapper around [`ProductsListApiResult`] in -// (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). + + +// Dart wrapper around [`ProductsListApiResult`] in (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). // -// Defines a dictionary for product list data returned by the getProductsList -// API. This only can be used in [BillingManager.requestProducts]. +// Defines a dictionary for product list data returned by the getProductsList API. +// This only can be used in [BillingManager.requestProducts]. // // Generated class from Pigeon that represents data sent in messages. class ProductsListApiResult { public: // Constructs an object setting all non-nullable fields. - explicit ProductsListApiResult(const std::string& cp_status, - int64_t total_count, - const std::string& check_value, - const flutter::EncodableList& item_details); + explicit ProductsListApiResult( + const std::string& cp_status, + int64_t total_count, + const std::string& check_value, + const ::flutter::EncodableList& item_details); // Constructs an object setting all fields. - explicit ProductsListApiResult(const std::string& cp_status, - const std::string* cp_result, - int64_t total_count, - const std::string& check_value, - const flutter::EncodableList& item_details); + explicit ProductsListApiResult( + const std::string& cp_status, + const std::string* cp_result, + int64_t total_count, + const std::string& check_value, + const ::flutter::EncodableList& item_details); // DPI result code. // Returns "100000" on success and other codes on failure. @@ -99,24 +103,29 @@ class ProductsListApiResult { void set_check_value(std::string_view value_arg); // ItemDetails in JSON format - const flutter::EncodableList& item_details() const; - void set_item_details(const flutter::EncodableList& value_arg); - + const ::flutter::EncodableList& item_details() const; + void set_item_details(const ::flutter::EncodableList& value_arg); + + bool operator==(const ProductsListApiResult& other) const; + bool operator!=(const ProductsListApiResult& other) const; + /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + size_t Hash() const; + /// Stream output operator for formatted string representation. + friend std::ostream& operator<<(std::ostream& os, const ProductsListApiResult& obj); private: - static ProductsListApiResult FromEncodableList( - const flutter::EncodableList& list); - flutter::EncodableList ToEncodableList() const; + static ProductsListApiResult FromEncodableList(const ::flutter::EncodableList& list); + ::flutter::EncodableList ToEncodableList() const; friend class InAppPurchaseApi; friend class PigeonInternalCodecSerializer; std::string cp_status_; std::optional cp_result_; int64_t total_count_; std::string check_value_; - flutter::EncodableList item_details_; + ::flutter::EncodableList item_details_; }; -// Dart wrapper around [`GetUserPurchaseListAPIResult`] in -// (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). + +// Dart wrapper around [`GetUserPurchaseListAPIResult`] in (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). // // Defines a dictionary for data returned by the getUserPurchaseList API. // This only can be used in [BillingManager.requestPurchases] @@ -126,18 +135,20 @@ class GetUserPurchaseListAPIResult { public: // Constructs an object setting all non-nullable fields. explicit GetUserPurchaseListAPIResult( - const std::string& cp_status, int64_t total_count, - const std::string& check_value, - const flutter::EncodableList& invoice_details); + const std::string& cp_status, + int64_t total_count, + const std::string& check_value, + const ::flutter::EncodableList& invoice_details); // Constructs an object setting all fields. explicit GetUserPurchaseListAPIResult( - const std::string& cp_status, const std::string* cp_result, - int64_t total_count, const std::string& check_value, - const flutter::EncodableList& invoice_details); + const std::string& cp_status, + const std::string* cp_result, + int64_t total_count, + const std::string& check_value, + const ::flutter::EncodableList& invoice_details); - // It returns "100000" in success and other codes in failure. Refer to DPI - // Error Code. + // It returns "100000" in success and other codes in failure. Refer to DPI Error Code. const std::string& cp_status() const; void set_cp_status(std::string_view value_arg); @@ -158,24 +169,29 @@ class GetUserPurchaseListAPIResult { void set_check_value(std::string_view value_arg); // InvoiceDetailsin JSON format. - const flutter::EncodableList& invoice_details() const; - void set_invoice_details(const flutter::EncodableList& value_arg); - + const ::flutter::EncodableList& invoice_details() const; + void set_invoice_details(const ::flutter::EncodableList& value_arg); + + bool operator==(const GetUserPurchaseListAPIResult& other) const; + bool operator!=(const GetUserPurchaseListAPIResult& other) const; + /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + size_t Hash() const; + /// Stream output operator for formatted string representation. + friend std::ostream& operator<<(std::ostream& os, const GetUserPurchaseListAPIResult& obj); private: - static GetUserPurchaseListAPIResult FromEncodableList( - const flutter::EncodableList& list); - flutter::EncodableList ToEncodableList() const; + static GetUserPurchaseListAPIResult FromEncodableList(const ::flutter::EncodableList& list); + ::flutter::EncodableList ToEncodableList() const; friend class InAppPurchaseApi; friend class PigeonInternalCodecSerializer; std::string cp_status_; std::optional cp_result_; int64_t total_count_; std::string check_value_; - flutter::EncodableList invoice_details_; + ::flutter::EncodableList invoice_details_; }; -// Dart wrapper around -// [`BillingBuyData`](https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html#BillingBuyData). + +// Dart wrapper around [`BillingBuyData`](https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html#BillingBuyData). // // Defines the payment result and information. // @@ -183,28 +199,35 @@ class GetUserPurchaseListAPIResult { class BillingBuyData { public: // Constructs an object setting all fields. - explicit BillingBuyData(const std::string& pay_result, - const flutter::EncodableMap& pay_details); + explicit BillingBuyData( + const std::string& pay_result, + const ::flutter::EncodableMap& pay_details); // The payment result const std::string& pay_result() const; void set_pay_result(std::string_view value_arg); // The payment information. It is same with paymentDetails param of buyItem. - const flutter::EncodableMap& pay_details() const; - void set_pay_details(const flutter::EncodableMap& value_arg); - + const ::flutter::EncodableMap& pay_details() const; + void set_pay_details(const ::flutter::EncodableMap& value_arg); + + bool operator==(const BillingBuyData& other) const; + bool operator!=(const BillingBuyData& other) const; + /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + size_t Hash() const; + /// Stream output operator for formatted string representation. + friend std::ostream& operator<<(std::ostream& os, const BillingBuyData& obj); private: - static BillingBuyData FromEncodableList(const flutter::EncodableList& list); - flutter::EncodableList ToEncodableList() const; + static BillingBuyData FromEncodableList(const ::flutter::EncodableList& list); + ::flutter::EncodableList ToEncodableList() const; friend class InAppPurchaseApi; friend class PigeonInternalCodecSerializer; std::string pay_result_; - flutter::EncodableMap pay_details_; + ::flutter::EncodableMap pay_details_; }; -// Dart wrapper around [`VerifyInvoiceAPIResult`] in -// (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). + +// Dart wrapper around [`VerifyInvoiceAPIResult`] in (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). // // This only can be used in [BillingManager.verifyInvoice]. // @@ -212,15 +235,17 @@ class BillingBuyData { class VerifyInvoiceAPIResult { public: // Constructs an object setting all non-nullable fields. - explicit VerifyInvoiceAPIResult(const std::string& cp_status, - const std::string& app_id, - const std::string& invoice_id); + explicit VerifyInvoiceAPIResult( + const std::string& cp_status, + const std::string& app_id, + const std::string& invoice_id); // Constructs an object setting all fields. - explicit VerifyInvoiceAPIResult(const std::string& cp_status, - const std::string* cp_result, - const std::string& app_id, - const std::string& invoice_id); + explicit VerifyInvoiceAPIResult( + const std::string& cp_status, + const std::string* cp_result, + const std::string& app_id, + const std::string& invoice_id); // DPI result code. Returns "100000" on success and other codes on failure. const std::string& cp_status() const; @@ -240,10 +265,15 @@ class VerifyInvoiceAPIResult { const std::string& invoice_id() const; void set_invoice_id(std::string_view value_arg); + bool operator==(const VerifyInvoiceAPIResult& other) const; + bool operator!=(const VerifyInvoiceAPIResult& other) const; + /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + size_t Hash() const; + /// Stream output operator for formatted string representation. + friend std::ostream& operator<<(std::ostream& os, const VerifyInvoiceAPIResult& obj); private: - static VerifyInvoiceAPIResult FromEncodableList( - const flutter::EncodableList& list); - flutter::EncodableList ToEncodableList() const; + static VerifyInvoiceAPIResult FromEncodableList(const ::flutter::EncodableList& list); + ::flutter::EncodableList ToEncodableList() const; friend class InAppPurchaseApi; friend class PigeonInternalCodecSerializer; std::string cp_status_; @@ -252,8 +282,8 @@ class VerifyInvoiceAPIResult { std::string invoice_id_; }; -// Dart wrapper around [`ServiceAvailableAPIResult`] in -// (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). + +// Dart wrapper around [`ServiceAvailableAPIResult`] in (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). // // Defines a dictionary for data returned by the IsServiceAvailable API. // This only can be used in [BillingManager.isAvailable]. @@ -262,9 +292,10 @@ class VerifyInvoiceAPIResult { class ServiceAvailableAPIResult { public: // Constructs an object setting all fields. - explicit ServiceAvailableAPIResult(const std::string& status, - const std::string& result, - const std::string& service_yn); + explicit ServiceAvailableAPIResult( + const std::string& status, + const std::string& result, + const std::string& service_yn); // The result code of connecting to billing server. // Returns "100000" on success and other codes on failure. @@ -281,10 +312,15 @@ class ServiceAvailableAPIResult { const std::string& service_yn() const; void set_service_yn(std::string_view value_arg); + bool operator==(const ServiceAvailableAPIResult& other) const; + bool operator!=(const ServiceAvailableAPIResult& other) const; + /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + size_t Hash() const; + /// Stream output operator for formatted string representation. + friend std::ostream& operator<<(std::ostream& os, const ServiceAvailableAPIResult& obj); private: - static ServiceAvailableAPIResult FromEncodableList( - const flutter::EncodableList& list); - flutter::EncodableList ToEncodableList() const; + static ServiceAvailableAPIResult FromEncodableList(const ::flutter::EncodableList& list); + ::flutter::EncodableList ToEncodableList() const; friend class InAppPurchaseApi; friend class PigeonInternalCodecSerializer; std::string status_; @@ -292,13 +328,17 @@ class ServiceAvailableAPIResult { std::string service_yn_; }; + // Generated class from Pigeon that represents data sent in messages. class ProductMessage { public: // Constructs an object setting all fields. - explicit ProductMessage(const std::string& app_id, - const std::string& country_code, int64_t page_size, - int64_t page_num, const std::string& check_value); + explicit ProductMessage( + const std::string& app_id, + const std::string& country_code, + int64_t page_size, + int64_t page_num, + const std::string& check_value); // Application ID. const std::string& app_id() const; @@ -318,14 +358,19 @@ class ProductMessage { // Security check value. Required parameters = "appId" + "countryCode". // The check value is used by the DPI service to verify API requests. - // It is a Base64 hash generated by applying the HMAC SHA256 algorithm on a - // concatenated string of parameters using the DPI security key. + // It is a Base64 hash generated by applying the HMAC SHA256 algorithm on a concatenated string of parameters using the DPI security key. const std::string& check_value() const; void set_check_value(std::string_view value_arg); + bool operator==(const ProductMessage& other) const; + bool operator!=(const ProductMessage& other) const; + /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + size_t Hash() const; + /// Stream output operator for formatted string representation. + friend std::ostream& operator<<(std::ostream& os, const ProductMessage& obj); private: - static ProductMessage FromEncodableList(const flutter::EncodableList& list); - flutter::EncodableList ToEncodableList() const; + static ProductMessage FromEncodableList(const ::flutter::EncodableList& list); + ::flutter::EncodableList ToEncodableList() const; friend class InAppPurchaseApi; friend class PigeonInternalCodecSerializer; std::string app_id_; @@ -335,21 +380,23 @@ class ProductMessage { std::string check_value_; }; + // Generated class from Pigeon that represents data sent in messages. class PurchaseMessage { public: // Constructs an object setting all fields. - explicit PurchaseMessage(const std::string& app_id, - const std::string& custom_id, - const std::string& country_code, int64_t page_num, - const std::string& check_value); + explicit PurchaseMessage( + const std::string& app_id, + const std::string& custom_id, + const std::string& country_code, + int64_t page_num, + const std::string& check_value); // Application ID. const std::string& app_id() const; void set_app_id(std::string_view value_arg); - // Same value as "OrderCustomID" parameter for the BuyItem API (Samsung - // Account UID) + // Same value as "OrderCustomID" parameter for the BuyItem API (Samsung Account UID) const std::string& custom_id() const; void set_custom_id(std::string_view value_arg); @@ -361,15 +408,20 @@ class PurchaseMessage { int64_t page_num() const; void set_page_num(int64_t value_arg); - // Security check value. Required parameters = "appId" + "customId" + - // "countryCode" + "ItemType" + "pageNumber". ItemType, MUST use 2 as value - // ("all items") + // Security check value. Required parameters = "appId" + "customId" + "countryCode" + "ItemType" + "pageNumber". + // ItemType, MUST use 2 as value ("all items") const std::string& check_value() const; void set_check_value(std::string_view value_arg); + bool operator==(const PurchaseMessage& other) const; + bool operator!=(const PurchaseMessage& other) const; + /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + size_t Hash() const; + /// Stream output operator for formatted string representation. + friend std::ostream& operator<<(std::ostream& os, const PurchaseMessage& obj); private: - static PurchaseMessage FromEncodableList(const flutter::EncodableList& list); - flutter::EncodableList ToEncodableList() const; + static PurchaseMessage FromEncodableList(const ::flutter::EncodableList& list); + ::flutter::EncodableList ToEncodableList() const; friend class InAppPurchaseApi; friend class PigeonInternalCodecSerializer; std::string app_id_; @@ -379,15 +431,17 @@ class PurchaseMessage { std::string check_value_; }; + // Generated class from Pigeon that represents data sent in messages. class OrderDetails { public: // Constructs an object setting all fields. - explicit OrderDetails(const std::string& order_item_id, - const std::string& order_title, - const std::string& order_total, - const std::string& order_currency_id, - const std::string& order_custom_id); + explicit OrderDetails( + const std::string& order_item_id, + const std::string& order_title, + const std::string& order_total, + const std::string& order_currency_id, + const std::string& order_custom_id); const std::string& order_item_id() const; void set_order_item_id(std::string_view value_arg); @@ -404,9 +458,15 @@ class OrderDetails { const std::string& order_custom_id() const; void set_order_custom_id(std::string_view value_arg); + bool operator==(const OrderDetails& other) const; + bool operator!=(const OrderDetails& other) const; + /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + size_t Hash() const; + /// Stream output operator for formatted string representation. + friend std::ostream& operator<<(std::ostream& os, const OrderDetails& obj); private: - static OrderDetails FromEncodableList(const flutter::EncodableList& list); - flutter::EncodableList ToEncodableList() const; + static OrderDetails FromEncodableList(const ::flutter::EncodableList& list); + ::flutter::EncodableList ToEncodableList() const; friend class BuyInfoMessage; friend class InAppPurchaseApi; friend class PigeonInternalCodecSerializer; @@ -417,12 +477,14 @@ class OrderDetails { std::string order_custom_id_; }; + // Generated class from Pigeon that represents data sent in messages. class BuyInfoMessage { public: // Constructs an object setting all fields. - explicit BuyInfoMessage(const std::string& app_id, - const OrderDetails& pay_detials); + explicit BuyInfoMessage( + const std::string& app_id, + const OrderDetails& pay_detials); ~BuyInfoMessage() = default; BuyInfoMessage(const BuyInfoMessage& other); @@ -437,30 +499,37 @@ class BuyInfoMessage { const OrderDetails& pay_detials() const; void set_pay_detials(const OrderDetails& value_arg); + bool operator==(const BuyInfoMessage& other) const; + bool operator!=(const BuyInfoMessage& other) const; + /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + size_t Hash() const; + /// Stream output operator for formatted string representation. + friend std::ostream& operator<<(std::ostream& os, const BuyInfoMessage& obj); private: - static BuyInfoMessage FromEncodableList(const flutter::EncodableList& list); - flutter::EncodableList ToEncodableList() const; + static BuyInfoMessage FromEncodableList(const ::flutter::EncodableList& list); + ::flutter::EncodableList ToEncodableList() const; friend class InAppPurchaseApi; friend class PigeonInternalCodecSerializer; std::string app_id_; std::unique_ptr pay_detials_; }; + // Generated class from Pigeon that represents data sent in messages. class InvoiceMessage { public: // Constructs an object setting all fields. - explicit InvoiceMessage(const std::string& app_id, - const std::string& custom_id, - const std::string& invoice_id, - const std::string& country_code); + explicit InvoiceMessage( + const std::string& app_id, + const std::string& custom_id, + const std::string& invoice_id, + const std::string& country_code); // Application ID. const std::string& app_id() const; void set_app_id(std::string_view value_arg); - // Same value as "OrderCustomID" parameter for the BuyItem API (Samsung - // Account UID). + // Same value as "OrderCustomID" parameter for the BuyItem API (Samsung Account UID). const std::string& custom_id() const; void set_custom_id(std::string_view value_arg); @@ -472,9 +541,15 @@ class InvoiceMessage { const std::string& country_code() const; void set_country_code(std::string_view value_arg); + bool operator==(const InvoiceMessage& other) const; + bool operator!=(const InvoiceMessage& other) const; + /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + size_t Hash() const; + /// Stream output operator for formatted string representation. + friend std::ostream& operator<<(std::ostream& os, const InvoiceMessage& obj); private: - static InvoiceMessage FromEncodableList(const flutter::EncodableList& list); - flutter::EncodableList ToEncodableList() const; + static InvoiceMessage FromEncodableList(const ::flutter::EncodableList& list); + ::flutter::EncodableList ToEncodableList() const; friend class InAppPurchaseApi; friend class PigeonInternalCodecSerializer; std::string app_id_; @@ -483,7 +558,8 @@ class InvoiceMessage { std::string country_code_; }; -class PigeonInternalCodecSerializer : public flutter::StandardCodecSerializer { + +class PigeonInternalCodecSerializer : public ::flutter::StandardCodecSerializer { public: PigeonInternalCodecSerializer(); inline static PigeonInternalCodecSerializer& GetInstance() { @@ -491,16 +567,16 @@ class PigeonInternalCodecSerializer : public flutter::StandardCodecSerializer { return sInstance; } - void WriteValue(const flutter::EncodableValue& value, - flutter::ByteStreamWriter* stream) const override; - + void WriteValue( + const ::flutter::EncodableValue& value, + ::flutter::ByteStreamWriter* stream) const override; protected: - flutter::EncodableValue ReadValueOfType( - uint8_t type, flutter::ByteStreamReader* stream) const override; + ::flutter::EncodableValue ReadValueOfType( + uint8_t type, + ::flutter::ByteStreamReader* stream) const override; }; -// Generated interface from Pigeon that represents a handler of messages from -// Flutter. +// Generated interface from Pigeon that represents a handler of messages from Flutter. class InAppPurchaseApi { public: InAppPurchaseApi(const InAppPurchaseApi&) = delete; @@ -508,42 +584,38 @@ class InAppPurchaseApi { virtual ~InAppPurchaseApi() {} // Retrieves the list of products registered on the Billing (DPI) server. virtual void GetProductsList( - const ProductMessage& product, - std::function reply)> result) = 0; + const ProductMessage& product, + std::function reply)> result) = 0; // Retrieves the user's purchase list. virtual void GetUserPurchaseList( - const PurchaseMessage& purchase, - std::function reply)> - result) = 0; - // Enables implementing the Samsung Checkout Client module within the - // application. After authenticating the purchase information through the - // application, the user can proceed to purchase payment. + const PurchaseMessage& purchase, + std::function reply)> result) = 0; + // Enables implementing the Samsung Checkout Client module within the application. + // After authenticating the purchase information through the application, the user can proceed to purchase payment. virtual void BuyItem( - const BuyInfoMessage& buy_info, - std::function reply)> result) = 0; - // Checks whether a purchase, corresponding to a specific "InvoiceID", was - // successful. + const BuyInfoMessage& buy_info, + std::function reply)> result) = 0; + // Checks whether a purchase, corresponding to a specific "InvoiceID", was successful. virtual void VerifyInvoice( - const InvoiceMessage& invoice, - std::function reply)> result) = 0; + const InvoiceMessage& invoice, + std::function reply)> result) = 0; // Checks whether the Billing server is available. - virtual void IsServiceAvailable( - std::function reply)> result) = 0; + virtual void IsServiceAvailable(std::function reply)> result) = 0; virtual ErrorOr GetCustomId() = 0; virtual ErrorOr GetCountryCode() = 0; // The codec used by InAppPurchaseApi. - static const flutter::StandardMessageCodec& GetCodec(); - // Sets up an instance of `InAppPurchaseApi` to handle messages through the - // `binary_messenger`. - static void SetUp(flutter::BinaryMessenger* binary_messenger, - InAppPurchaseApi* api); - static void SetUp(flutter::BinaryMessenger* binary_messenger, - InAppPurchaseApi* api, - const std::string& message_channel_suffix); - static flutter::EncodableValue WrapError(std::string_view error_message); - static flutter::EncodableValue WrapError(const FlutterError& error); - + static const ::flutter::StandardMessageCodec& GetCodec(); + // Sets up an instance of `InAppPurchaseApi` to handle messages through the `binary_messenger`. + static void SetUp( + ::flutter::BinaryMessenger* binary_messenger, + InAppPurchaseApi* api); + static void SetUp( + ::flutter::BinaryMessenger* binary_messenger, + InAppPurchaseApi* api, + const std::string& message_channel_suffix); + static ::flutter::EncodableValue WrapError(std::string_view error_message); + static ::flutter::EncodableValue WrapError(const FlutterError& error); protected: InAppPurchaseApi() = default; }; diff --git a/packages/in_app_purchase/tizen/src/messages_ffi.cc b/packages/in_app_purchase/tizen/src/messages_ffi.cc new file mode 100644 index 000000000..501befbe1 --- /dev/null +++ b/packages/in_app_purchase/tizen/src/messages_ffi.cc @@ -0,0 +1,476 @@ +// Autogenerated from Pigeon (v29.0.11), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +#include "messages_ffi.h" + +#include +#include +#include +#include +#include +#include +#include + +namespace { + PigeonFfiBuffer* PigeonFfiMakeBuffer(const std::vector& message) { + auto* buffer = new PigeonFfiBuffer(); + buffer->length = message.size(); + buffer->data = nullptr; + if (!message.empty()) { + buffer->data = new uint8_t[message.size()]; + std::memcpy(buffer->data, message.data(), message.size()); + } + return buffer; + } + + PigeonFfiBuffer* PigeonFfiEncodeMessage( + const ::flutter::StandardMessageCodec& codec, + const ::flutter::EncodableValue& value) { + std::unique_ptr> message = codec.EncodeMessage(value); + return PigeonFfiMakeBuffer(*message); + } + + PigeonFfiBuffer* PigeonFfiEncodeError( + const ::flutter::StandardMessageCodec& codec, + const ::flutter::EncodableValue& error) { + return PigeonFfiEncodeMessage(codec, error); + } + + PigeonFfiBuffer* PigeonFfiEncodeErrorMessage( + const ::flutter::StandardMessageCodec& codec, + const std::string& message) { + return PigeonFfiEncodeError( + codec, + ::flutter::EncodableValue(::flutter::EncodableList{ + ::flutter::EncodableValue("error"), + ::flutter::EncodableValue(message), + ::flutter::EncodableValue()})); + } + + void PigeonFfiSendReply( + int64_t reply_id, + PigeonFfiReplyCallback on_reply, + PigeonFfiBuffer* reply) { + if (on_reply == nullptr) { + pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_free_buffer(reply); + return; + } + on_reply(reply_id, reply); + } + +} // namespace + +void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_free_buffer(PigeonFfiBuffer* buffer) { + if (buffer == nullptr) { + return; + } + delete[] buffer->data; + delete buffer; +} + +namespace in_app_purchase_tizen { + +namespace { + InAppPurchaseApi* g_in_app_purchase_api_api = nullptr; + PigeonFfiSyncDispatcher* g_in_app_purchase_api_dispatcher = nullptr; +} // namespace + +void SetUpInAppPurchaseApiFfi( + InAppPurchaseApi* api, + PigeonFfiSyncDispatcher* dispatcher) { + if (g_in_app_purchase_api_api != nullptr) { + std::fprintf(stderr, "[pigeon] SetUpInAppPurchaseApiFfi() called more than once. Pigeon C++ FFI registration is process-global and supports only one Flutter engine per process; calls from previously registered engines will be routed to the most recently registered implementation.\n"); + } + g_in_app_purchase_api_api = api; + g_in_app_purchase_api_dispatcher = dispatcher; +} + +void TearDownInAppPurchaseApiFfi() { + g_in_app_purchase_api_api = nullptr; + g_in_app_purchase_api_dispatcher = nullptr; +} + +void PigeonInAppPurchaseApiGetProductsListFfi( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (g_in_app_purchase_api_api == nullptr) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up."))); + return; + } + try { + if (request == nullptr || request->data == nullptr) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Request buffer is null."))); + return; + } + std::unique_ptr<::flutter::EncodableValue> message = codec.DecodeMessage(request->data, request->length); + if (!message) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Unable to decode request."))); + return; + } + const auto* args = std::get_if<::flutter::EncodableList>(message.get()); + if (args == nullptr || args->size() != 1) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Unexpected request arguments."))); + return; + } + const auto& encodable_product_arg = args->at(0); + if (encodable_product_arg.IsNull()) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("product_arg unexpectedly null."))); + return; + } + const auto& product_arg = std::any_cast(std::get<::flutter::CustomEncodableValue>(encodable_product_arg)); + g_in_app_purchase_api_api->GetProductsList( + product_arg, + [reply_id, on_reply](ErrorOr&& output) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (output.has_error()) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(output.error()))); + return; + } + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeMessage(codec, ::flutter::EncodableValue(::flutter::EncodableList{::flutter::CustomEncodableValue(output.value())}))); + }); + } catch (const std::exception& exception) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(exception.what()))); + } +} + +void PigeonInAppPurchaseApiGetProductsListFfiDispatch( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + if (g_in_app_purchase_api_dispatcher != nullptr) { + PigeonFfiBuffer* dispatch_error = g_in_app_purchase_api_dispatcher->RunSync([=]() { + PigeonInAppPurchaseApiGetProductsListFfi(request, reply_id, on_reply); + return static_cast(nullptr); + }); + if (dispatch_error != nullptr) { + PigeonFfiSendReply(reply_id, on_reply, dispatch_error); + } + return; + } + PigeonInAppPurchaseApiGetProductsListFfi(request, reply_id, on_reply); +} + +void PigeonInAppPurchaseApiGetUserPurchaseListFfi( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (g_in_app_purchase_api_api == nullptr) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up."))); + return; + } + try { + if (request == nullptr || request->data == nullptr) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Request buffer is null."))); + return; + } + std::unique_ptr<::flutter::EncodableValue> message = codec.DecodeMessage(request->data, request->length); + if (!message) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Unable to decode request."))); + return; + } + const auto* args = std::get_if<::flutter::EncodableList>(message.get()); + if (args == nullptr || args->size() != 1) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Unexpected request arguments."))); + return; + } + const auto& encodable_purchase_arg = args->at(0); + if (encodable_purchase_arg.IsNull()) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("purchase_arg unexpectedly null."))); + return; + } + const auto& purchase_arg = std::any_cast(std::get<::flutter::CustomEncodableValue>(encodable_purchase_arg)); + g_in_app_purchase_api_api->GetUserPurchaseList( + purchase_arg, + [reply_id, on_reply](ErrorOr&& output) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (output.has_error()) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(output.error()))); + return; + } + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeMessage(codec, ::flutter::EncodableValue(::flutter::EncodableList{::flutter::CustomEncodableValue(output.value())}))); + }); + } catch (const std::exception& exception) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(exception.what()))); + } +} + +void PigeonInAppPurchaseApiGetUserPurchaseListFfiDispatch( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + if (g_in_app_purchase_api_dispatcher != nullptr) { + PigeonFfiBuffer* dispatch_error = g_in_app_purchase_api_dispatcher->RunSync([=]() { + PigeonInAppPurchaseApiGetUserPurchaseListFfi(request, reply_id, on_reply); + return static_cast(nullptr); + }); + if (dispatch_error != nullptr) { + PigeonFfiSendReply(reply_id, on_reply, dispatch_error); + } + return; + } + PigeonInAppPurchaseApiGetUserPurchaseListFfi(request, reply_id, on_reply); +} + +void PigeonInAppPurchaseApiBuyItemFfi( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (g_in_app_purchase_api_api == nullptr) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up."))); + return; + } + try { + if (request == nullptr || request->data == nullptr) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Request buffer is null."))); + return; + } + std::unique_ptr<::flutter::EncodableValue> message = codec.DecodeMessage(request->data, request->length); + if (!message) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Unable to decode request."))); + return; + } + const auto* args = std::get_if<::flutter::EncodableList>(message.get()); + if (args == nullptr || args->size() != 1) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Unexpected request arguments."))); + return; + } + const auto& encodable_buy_info_arg = args->at(0); + if (encodable_buy_info_arg.IsNull()) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("buy_info_arg unexpectedly null."))); + return; + } + const auto& buy_info_arg = std::any_cast(std::get<::flutter::CustomEncodableValue>(encodable_buy_info_arg)); + g_in_app_purchase_api_api->BuyItem( + buy_info_arg, + [reply_id, on_reply](ErrorOr&& output) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (output.has_error()) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(output.error()))); + return; + } + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeMessage(codec, ::flutter::EncodableValue(::flutter::EncodableList{::flutter::CustomEncodableValue(output.value())}))); + }); + } catch (const std::exception& exception) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(exception.what()))); + } +} + +void PigeonInAppPurchaseApiBuyItemFfiDispatch( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + if (g_in_app_purchase_api_dispatcher != nullptr) { + PigeonFfiBuffer* dispatch_error = g_in_app_purchase_api_dispatcher->RunSync([=]() { + PigeonInAppPurchaseApiBuyItemFfi(request, reply_id, on_reply); + return static_cast(nullptr); + }); + if (dispatch_error != nullptr) { + PigeonFfiSendReply(reply_id, on_reply, dispatch_error); + } + return; + } + PigeonInAppPurchaseApiBuyItemFfi(request, reply_id, on_reply); +} + +void PigeonInAppPurchaseApiVerifyInvoiceFfi( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (g_in_app_purchase_api_api == nullptr) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up."))); + return; + } + try { + if (request == nullptr || request->data == nullptr) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Request buffer is null."))); + return; + } + std::unique_ptr<::flutter::EncodableValue> message = codec.DecodeMessage(request->data, request->length); + if (!message) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Unable to decode request."))); + return; + } + const auto* args = std::get_if<::flutter::EncodableList>(message.get()); + if (args == nullptr || args->size() != 1) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Unexpected request arguments."))); + return; + } + const auto& encodable_invoice_arg = args->at(0); + if (encodable_invoice_arg.IsNull()) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("invoice_arg unexpectedly null."))); + return; + } + const auto& invoice_arg = std::any_cast(std::get<::flutter::CustomEncodableValue>(encodable_invoice_arg)); + g_in_app_purchase_api_api->VerifyInvoice( + invoice_arg, + [reply_id, on_reply](ErrorOr&& output) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (output.has_error()) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(output.error()))); + return; + } + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeMessage(codec, ::flutter::EncodableValue(::flutter::EncodableList{::flutter::CustomEncodableValue(output.value())}))); + }); + } catch (const std::exception& exception) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(exception.what()))); + } +} + +void PigeonInAppPurchaseApiVerifyInvoiceFfiDispatch( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + if (g_in_app_purchase_api_dispatcher != nullptr) { + PigeonFfiBuffer* dispatch_error = g_in_app_purchase_api_dispatcher->RunSync([=]() { + PigeonInAppPurchaseApiVerifyInvoiceFfi(request, reply_id, on_reply); + return static_cast(nullptr); + }); + if (dispatch_error != nullptr) { + PigeonFfiSendReply(reply_id, on_reply, dispatch_error); + } + return; + } + PigeonInAppPurchaseApiVerifyInvoiceFfi(request, reply_id, on_reply); +} + +void PigeonInAppPurchaseApiIsServiceAvailableFfi( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (g_in_app_purchase_api_api == nullptr) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up."))); + return; + } + try { + g_in_app_purchase_api_api->IsServiceAvailable( + [reply_id, on_reply](ErrorOr&& output) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (output.has_error()) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(output.error()))); + return; + } + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeMessage(codec, ::flutter::EncodableValue(::flutter::EncodableList{::flutter::EncodableValue(output.value())}))); + }); + } catch (const std::exception& exception) { + PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(exception.what()))); + } +} + +void PigeonInAppPurchaseApiIsServiceAvailableFfiDispatch( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + if (g_in_app_purchase_api_dispatcher != nullptr) { + PigeonFfiBuffer* dispatch_error = g_in_app_purchase_api_dispatcher->RunSync([=]() { + PigeonInAppPurchaseApiIsServiceAvailableFfi(request, reply_id, on_reply); + return static_cast(nullptr); + }); + if (dispatch_error != nullptr) { + PigeonFfiSendReply(reply_id, on_reply, dispatch_error); + } + return; + } + PigeonInAppPurchaseApiIsServiceAvailableFfi(request, reply_id, on_reply); +} + +PigeonFfiBuffer* PigeonInAppPurchaseApiGetCustomIdFfi(PigeonFfiBuffer* request) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (g_in_app_purchase_api_api == nullptr) { + return PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up.")); + } + try { + ErrorOr output = g_in_app_purchase_api_api->GetCustomId(); + if (output.has_error()) { + return PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(output.error())); + } + return PigeonFfiEncodeMessage(codec, ::flutter::EncodableValue(::flutter::EncodableList{::flutter::EncodableValue(output.value())})); + } catch (const std::exception& exception) { + return PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(exception.what())); + } +} + +PigeonFfiBuffer* PigeonInAppPurchaseApiGetCustomIdFfiDispatch(PigeonFfiBuffer* request) { + if (g_in_app_purchase_api_dispatcher != nullptr) { + return g_in_app_purchase_api_dispatcher->RunSync([request]() { + return PigeonInAppPurchaseApiGetCustomIdFfi(request); + }); + } + return PigeonInAppPurchaseApiGetCustomIdFfi(request); +} + +PigeonFfiBuffer* PigeonInAppPurchaseApiGetCountryCodeFfi(PigeonFfiBuffer* request) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (g_in_app_purchase_api_api == nullptr) { + return PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up.")); + } + try { + ErrorOr output = g_in_app_purchase_api_api->GetCountryCode(); + if (output.has_error()) { + return PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(output.error())); + } + return PigeonFfiEncodeMessage(codec, ::flutter::EncodableValue(::flutter::EncodableList{::flutter::EncodableValue(output.value())})); + } catch (const std::exception& exception) { + return PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(exception.what())); + } +} + +PigeonFfiBuffer* PigeonInAppPurchaseApiGetCountryCodeFfiDispatch(PigeonFfiBuffer* request) { + if (g_in_app_purchase_api_dispatcher != nullptr) { + return g_in_app_purchase_api_dispatcher->RunSync([request]() { + return PigeonInAppPurchaseApiGetCountryCodeFfi(request); + }); + } + return PigeonInAppPurchaseApiGetCountryCodeFfi(request); +} + +} // namespace in_app_purchase_tizen + +extern "C" void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_products_list( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + in_app_purchase_tizen::PigeonInAppPurchaseApiGetProductsListFfiDispatch(request, reply_id, on_reply); +} + +extern "C" void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_user_purchase_list( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + in_app_purchase_tizen::PigeonInAppPurchaseApiGetUserPurchaseListFfiDispatch(request, reply_id, on_reply); +} + +extern "C" void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_buy_item( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + in_app_purchase_tizen::PigeonInAppPurchaseApiBuyItemFfiDispatch(request, reply_id, on_reply); +} + +extern "C" void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_verify_invoice( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + in_app_purchase_tizen::PigeonInAppPurchaseApiVerifyInvoiceFfiDispatch(request, reply_id, on_reply); +} + +extern "C" void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_is_service_available( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + in_app_purchase_tizen::PigeonInAppPurchaseApiIsServiceAvailableFfiDispatch(request, reply_id, on_reply); +} + +extern "C" PigeonFfiBuffer* pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_custom_id(PigeonFfiBuffer* request) { + return in_app_purchase_tizen::PigeonInAppPurchaseApiGetCustomIdFfiDispatch(request); +} + +extern "C" PigeonFfiBuffer* pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_country_code(PigeonFfiBuffer* request) { + return in_app_purchase_tizen::PigeonInAppPurchaseApiGetCountryCodeFfiDispatch(request); +} + diff --git a/packages/in_app_purchase/tizen/src/messages_ffi.h b/packages/in_app_purchase/tizen/src/messages_ffi.h new file mode 100644 index 000000000..b04d159b1 --- /dev/null +++ b/packages/in_app_purchase/tizen/src/messages_ffi.h @@ -0,0 +1,88 @@ +// Autogenerated from Pigeon (v29.0.11), do not edit directly. +// See also: https://pub.dev/packages/pigeon + +#ifndef PIGEON_IN_X5F_APP_X5F_PURCHASE_X5F_TIZEN_TIZEN_X2F_SRC_X2F_MESSAGES_X5F_FFI_X2E_H_HEADER_ +#define PIGEON_IN_X5F_APP_X5F_PURCHASE_X5F_TIZEN_TIZEN_X2F_SRC_X2F_MESSAGES_X5F_FFI_X2E_H_HEADER_ + +#include +#include + +#ifdef __cplusplus +#include +#include +#include +#include +#include +#include "messages.h" +#endif + +#if defined(_WIN32) +#define PIGEON_FFI_EXPORT __declspec(dllexport) +#else +#define PIGEON_FFI_EXPORT __attribute__((visibility("default"))) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef PIGEON_FFI_ABI_TYPES_ +#define PIGEON_FFI_ABI_TYPES_ +typedef struct PigeonFfiBuffer { + uint8_t* data; + size_t length; +} PigeonFfiBuffer; + +typedef void (*PigeonFfiReplyCallback)(int64_t reply_id, PigeonFfiBuffer* reply); +typedef void (*PigeonFfiEventCallback)(int64_t sink_id, PigeonFfiBuffer* event); +typedef void (*PigeonFfiDoneCallback)(int64_t sink_id); +#endif // PIGEON_FFI_ABI_TYPES_ + +// Frees a buffer returned by a generated FFI function. +PIGEON_FFI_EXPORT void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_free_buffer(PigeonFfiBuffer* buffer); +// The caller owns request; free returned buffers with pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_free_buffer. +PIGEON_FFI_EXPORT void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_products_list( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply); +PIGEON_FFI_EXPORT void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_user_purchase_list( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply); +PIGEON_FFI_EXPORT void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_buy_item( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply); +PIGEON_FFI_EXPORT void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_verify_invoice( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply); +PIGEON_FFI_EXPORT void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_is_service_available( + PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply); +PIGEON_FFI_EXPORT PigeonFfiBuffer* pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_custom_id(PigeonFfiBuffer* request); +PIGEON_FFI_EXPORT PigeonFfiBuffer* pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_country_code(PigeonFfiBuffer* request); + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +namespace in_app_purchase_tizen { + class PigeonFfiSyncDispatcher { + public: + virtual ~PigeonFfiSyncDispatcher() = default; + virtual ::PigeonFfiBuffer* RunSync( + std::function<::PigeonFfiBuffer*()> task) = 0; + }; + + + void SetUpInAppPurchaseApiFfi( + InAppPurchaseApi* api, + PigeonFfiSyncDispatcher* dispatcher = nullptr); + void TearDownInAppPurchaseApiFfi(); +} // namespace in_app_purchase_tizen +#endif + +#endif // PIGEON_IN_X5F_APP_X5F_PURCHASE_X5F_TIZEN_TIZEN_X2F_SRC_X2F_MESSAGES_X5F_FFI_X2E_H_HEADER_ diff --git a/packages/in_app_purchase/tool/pigeon/messages_ffigen_config.yaml b/packages/in_app_purchase/tool/pigeon/messages_ffigen_config.yaml new file mode 100644 index 000000000..721d857b8 --- /dev/null +++ b/packages/in_app_purchase/tool/pigeon/messages_ffigen_config.yaml @@ -0,0 +1,19 @@ +# Autogenerated from Pigeon (v29.0.11), do not edit directly. +# See also: https://pub.dev/packages/pigeon + +name: 'InAppPurchaseTizenFfiBindings' +description: 'Generated bindings for Pigeon C++ FFI APIs.' +output: '../../lib/src/messages.g.ffi.dart' +headers: + entry-points: + - '../../tizen/src/messages_ffi.h' + include-directives: + - '**/messages_ffi.h' +functions: + include: + - 'pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_.*' + rename: + 'pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_(.*)': 'pigeon_$1' +structs: + include: + - 'PigeonFfiBuffer' From 80f0056498b18fb5e4292b436232568f501585dc Mon Sep 17 00:00:00 2001 From: "yying.jin" Date: Thu, 5 Nov 2026 15:45:30 +0800 Subject: [PATCH 2/3] [in_app_purchase] Reset pending FFI replies when the Dart plugin registers After a hot restart the old isolate is destroyed while native reply callbacks survive in BillingManager. A late billing response would then invoke a NativeCallable of the dead isolate and can crash the process. Add an initialize() host API that resets pending BillingManager callbacks, and call it from register() in the root isolate so stale replies are invalidated as soon as the new isolate registers the plugin, before any new request is made. Co-Authored-By: Cline SR --- .../in_app_purchase_test.dart | 15 +- .../lib/src/billing_manager.dart | 5 + .../src/in_app_purchase_tizen_platform.dart | 4 + .../in_app_purchase/lib/src/messages.g.dart | 343 ++--- .../lib/src/messages.g.ffi.dart | 15 + .../in_app_purchase/pigeons/messages.dart | 7 +- .../tizen/src/billing_manager.cc | 9 + .../tizen/src/billing_manager.h | 1 + .../tizen/src/in_app_purchase_tizen_plugin.cc | 6 + .../in_app_purchase/tizen/src/messages.cc | 1158 +++++++++-------- packages/in_app_purchase/tizen/src/messages.h | 296 +++-- .../in_app_purchase/tizen/src/messages_ffi.cc | 631 +++++---- .../in_app_purchase/tizen/src/messages_ffi.h | 82 +- 13 files changed, 1434 insertions(+), 1138 deletions(-) diff --git a/packages/in_app_purchase/example/integration_test/in_app_purchase_test.dart b/packages/in_app_purchase/example/integration_test/in_app_purchase_test.dart index f5970c1d2..257f5bb89 100644 --- a/packages/in_app_purchase/example/integration_test/in_app_purchase_test.dart +++ b/packages/in_app_purchase/example/integration_test/in_app_purchase_test.dart @@ -19,14 +19,9 @@ void main() { test('FFI host API smoke test', () async { final InAppPurchase iap = InAppPurchase.instance; - final InAppPurchaseTizenPlatformAddition addition = - iap.getPlatformAddition(); - addition.setRequestParameters( - appId: 'test', - pageSize: 15, - pageNum: 1, - securityKey: 'test', - ); + final InAppPurchaseTizenPlatformAddition addition = iap + .getPlatformAddition(); + addition.setRequestParameters(appId: 'test', pageSize: 15, pageNum: 1, securityKey: 'test'); Object? asyncError; bool? available; @@ -51,9 +46,7 @@ void main() { Object? queryError; ProductDetailsResponse? response; try { - response = await iap - .queryProductDetails({}) - .timeout(const Duration(seconds: 30)); + response = await iap.queryProductDetails({}).timeout(const Duration(seconds: 30)); } catch (error) { queryError = error; } diff --git a/packages/in_app_purchase/lib/src/billing_manager.dart b/packages/in_app_purchase/lib/src/billing_manager.dart index ffe0d5c2c..aded93d1e 100644 --- a/packages/in_app_purchase/lib/src/billing_manager.dart +++ b/packages/in_app_purchase/lib/src/billing_manager.dart @@ -38,6 +38,11 @@ class BillingManager { /// Interface for calling host-side code. final InAppPurchaseApi _hostApi; + /// Resets pending native replies left over from a previous Dart isolate. + void initialize() { + _hostApi.initialize(); + } + /// get country code Future getCountryCode() async { return _hostApi.getCountryCode(); diff --git a/packages/in_app_purchase/lib/src/in_app_purchase_tizen_platform.dart b/packages/in_app_purchase/lib/src/in_app_purchase_tizen_platform.dart index 7d94dc1af..64829344d 100644 --- a/packages/in_app_purchase/lib/src/in_app_purchase_tizen_platform.dart +++ b/packages/in_app_purchase/lib/src/in_app_purchase_tizen_platform.dart @@ -34,6 +34,10 @@ class InAppPurchaseTizenPlatform extends InAppPurchasePlatform { // Register the platform-specific implementation of the idiomatic // InAppPurchase API. InAppPurchasePlatform.instance = InAppPurchaseTizenPlatform(); + + if (RootIsolateToken.instance != null) { + billingManager.initialize(); + } } static final StreamController> _purchaseUpdatedController = diff --git a/packages/in_app_purchase/lib/src/messages.g.dart b/packages/in_app_purchase/lib/src/messages.g.dart index cd5946d2b..fde539078 100644 --- a/packages/in_app_purchase/lib/src/messages.g.dart +++ b/packages/in_app_purchase/lib/src/messages.g.dart @@ -14,9 +14,9 @@ import 'package:meta/meta.dart' show immutable, protected, visibleForTesting; import 'messages.g.ffi.dart' as pigeon_ffi; Object? _extractReplyValueOrThrow( - List? replyList, - String channelName, { - required bool isNullValid, + List? replyList, + String channelName, { + required bool isNullValid, }) { if (replyList == null) { throw PlatformException( @@ -38,7 +38,6 @@ Object? _extractReplyValueOrThrow( return replyList.firstOrNull; } - ffi.Pointer _encodeFfiRequest(ByteData? message) { if (message == null) { return ffi.nullptr; @@ -46,8 +45,8 @@ ffi.Pointer _encodeFfiRequest(ByteData? message) { final Uint8List bytes = message.buffer.asUint8List(message.offsetInBytes, message.lengthInBytes); final ffi.Pointer data = pkg_ffi.calloc(bytes.length); data.asTypedList(bytes.length).setAll(0, bytes); - final ffi.Pointer buffer = - pkg_ffi.calloc(); + final ffi.Pointer buffer = pkg_ffi + .calloc(); buffer.ref.data = data; buffer.ref.length = bytes.length; return buffer; @@ -62,8 +61,8 @@ void _freeFfiRequest(ffi.Pointer buffer) { } List? _decodeFfiReply( - MessageCodec codec, - ffi.Pointer buffer, + MessageCodec codec, + ffi.Pointer buffer, ) { if (buffer == ffi.nullptr || buffer.ref.data == ffi.nullptr) { return null; @@ -75,23 +74,22 @@ List? _decodeFfiReply( ffi.DynamicLibrary _openPigeonNativeLibrary() { try { return (() { - final String libraryPath = File('/proc/self/maps') - .readAsLinesSync() - .map((String line) { - final int index = line.indexOf('/'); - return index == -1 ? '' : line.substring(index); - }) - .firstWhere( - (String path) => path.endsWith('/libflutter_plugins.so'), - ); - return ffi.DynamicLibrary.open(libraryPath); -})(); + final String libraryPath = File('/proc/self/maps') + .readAsLinesSync() + .map((String line) { + final int index = line.indexOf('/'); + return index == -1 ? '' : line.substring(index); + }) + .firstWhere((String path) => path.endsWith('/libflutter_plugins.so')); + return ffi.DynamicLibrary.open(libraryPath); + })(); } catch (error) { throw StateError( - 'Pigeon FFI: failed to open the native library. The plugin shared ' - 'library may not be loaded yet. Avoid constructing FFI bindings ' - 'during plugin registration; construct them lazily on first use. ' - 'Original error: $error'); + 'Pigeon FFI: failed to open the native library. The plugin shared ' + 'library may not be loaded yet. Avoid constructing FFI bindings ' + 'during plugin registration; construct them lazily on first use. ' + 'Original error: $error', + ); } } @@ -104,10 +102,8 @@ ffi.Pointer _pigeonFfiLookup(String symbolName) { final pigeon_ffi.InAppPurchaseTizenFfiBindings _pigeonVar_defaultFfiBindings = pigeon_ffi.InAppPurchaseTizenFfiBindings.fromLookup(_pigeonFfiLookup); -typedef _PigeonFfiReplyCallbackNative = ffi.Void Function( - ffi.Int64 replyId, - ffi.Pointer reply, -); +typedef _PigeonFfiReplyCallbackNative = + ffi.Void Function(ffi.Int64 replyId, ffi.Pointer reply); class _PigeonFfiAsyncReply { _PigeonFfiAsyncReply({ @@ -127,8 +123,7 @@ class _PigeonFfiAsyncReply { final void Function(Object error, StackTrace stackTrace) completeError; } -final Map _pigeonFfiAsyncReplies = - {}; +final Map _pigeonFfiAsyncReplies = {}; int _pigeonNextFfiAsyncReplyId = 1; final ffi.NativeCallable<_PigeonFfiReplyCallbackNative> _pigeonFfiReplyCallback = @@ -140,10 +135,7 @@ void _updatePigeonFfiReplyCallbackKeepAlive() { _pigeonFfiReplyCallback.keepIsolateAlive = _pigeonFfiAsyncReplies.isNotEmpty; } -void _handlePigeonFfiReply( - int replyId, - ffi.Pointer reply, -) { +void _handlePigeonFfiReply(int replyId, ffi.Pointer reply) { final _PigeonFfiAsyncReply? asyncReply = _pigeonFfiAsyncReplies.remove(replyId); try { if (asyncReply != null) { @@ -177,8 +169,7 @@ bool _deepEquals(Object? a, Object? b) { } if (a is List && b is List) { return a.length == b.length && - a.indexed - .every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1])); + a.indexed.every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1])); } if (a is Map && b is Map) { if (a.length != b.length) { @@ -227,7 +218,6 @@ int _deepHash(Object? value) { return value.hashCode; } - /// Dart wrapper around [`ProductsListApiResult`] in (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). /// /// Defines a dictionary for product list data returned by the getProductsList API. @@ -261,17 +251,12 @@ class ProductsListApiResult { List?> itemDetails; List _toList() { - return [ - cpStatus, - cpResult, - totalCount, - checkValue, - itemDetails, - ]; + return [cpStatus, cpResult, totalCount, checkValue, itemDetails]; } Object encode() { - return _toList(); } + return _toList(); + } static ProductsListApiResult decode(Object result) { result as List; @@ -293,7 +278,11 @@ class ProductsListApiResult { if (identical(this, other)) { return true; } - return _deepEquals(cpStatus, other.cpStatus) && _deepEquals(cpResult, other.cpResult) && _deepEquals(totalCount, other.totalCount) && _deepEquals(checkValue, other.checkValue) && _deepEquals(itemDetails, other.itemDetails); + return _deepEquals(cpStatus, other.cpStatus) && + _deepEquals(cpResult, other.cpResult) && + _deepEquals(totalCount, other.totalCount) && + _deepEquals(checkValue, other.checkValue) && + _deepEquals(itemDetails, other.itemDetails); } @override @@ -338,17 +327,12 @@ class GetUserPurchaseListAPIResult { List?> invoiceDetails; List _toList() { - return [ - cpStatus, - cpResult, - totalCount, - checkValue, - invoiceDetails, - ]; + return [cpStatus, cpResult, totalCount, checkValue, invoiceDetails]; } Object encode() { - return _toList(); } + return _toList(); + } static GetUserPurchaseListAPIResult decode(Object result) { result as List; @@ -370,7 +354,11 @@ class GetUserPurchaseListAPIResult { if (identical(this, other)) { return true; } - return _deepEquals(cpStatus, other.cpStatus) && _deepEquals(cpResult, other.cpResult) && _deepEquals(totalCount, other.totalCount) && _deepEquals(checkValue, other.checkValue) && _deepEquals(invoiceDetails, other.invoiceDetails); + return _deepEquals(cpStatus, other.cpStatus) && + _deepEquals(cpResult, other.cpResult) && + _deepEquals(totalCount, other.totalCount) && + _deepEquals(checkValue, other.checkValue) && + _deepEquals(invoiceDetails, other.invoiceDetails); } @override @@ -387,10 +375,7 @@ class GetUserPurchaseListAPIResult { /// /// Defines the payment result and information. class BillingBuyData { - BillingBuyData({ - required this.payResult, - required this.payDetails, - }); + BillingBuyData({required this.payResult, required this.payDetails}); /// The payment result String payResult; @@ -399,14 +384,12 @@ class BillingBuyData { Map payDetails; List _toList() { - return [ - payResult, - payDetails, - ]; + return [payResult, payDetails]; } Object encode() { - return _toList(); } + return _toList(); + } static BillingBuyData decode(Object result) { result as List; @@ -463,16 +446,12 @@ class VerifyInvoiceAPIResult { String invoiceId; List _toList() { - return [ - cpStatus, - cpResult, - appId, - invoiceId, - ]; + return [cpStatus, cpResult, appId, invoiceId]; } Object encode() { - return _toList(); } + return _toList(); + } static VerifyInvoiceAPIResult decode(Object result) { result as List; @@ -493,7 +472,10 @@ class VerifyInvoiceAPIResult { if (identical(this, other)) { return true; } - return _deepEquals(cpStatus, other.cpStatus) && _deepEquals(cpResult, other.cpResult) && _deepEquals(appId, other.appId) && _deepEquals(invoiceId, other.invoiceId); + return _deepEquals(cpStatus, other.cpStatus) && + _deepEquals(cpResult, other.cpResult) && + _deepEquals(appId, other.appId) && + _deepEquals(invoiceId, other.invoiceId); } @override @@ -511,11 +493,7 @@ class VerifyInvoiceAPIResult { /// Defines a dictionary for data returned by the IsServiceAvailable API. /// This only can be used in [BillingManager.isAvailable]. class ServiceAvailableAPIResult { - ServiceAvailableAPIResult({ - required this.status, - required this.result, - required this.serviceYn, - }); + ServiceAvailableAPIResult({required this.status, required this.result, required this.serviceYn}); /// The result code of connecting to billing server. /// Returns "100000" on success and other codes on failure. @@ -530,15 +508,12 @@ class ServiceAvailableAPIResult { String serviceYn; List _toList() { - return [ - status, - result, - serviceYn, - ]; + return [status, result, serviceYn]; } Object encode() { - return _toList(); } + return _toList(); + } static ServiceAvailableAPIResult decode(Object result) { result as List; @@ -558,7 +533,9 @@ class ServiceAvailableAPIResult { if (identical(this, other)) { return true; } - return _deepEquals(status, other.status) && _deepEquals(result, other.result) && _deepEquals(serviceYn, other.serviceYn); + return _deepEquals(status, other.status) && + _deepEquals(result, other.result) && + _deepEquals(serviceYn, other.serviceYn); } @override @@ -598,17 +575,12 @@ class ProductMessage { String checkValue; List _toList() { - return [ - appId, - countryCode, - pageSize, - pageNum, - checkValue, - ]; + return [appId, countryCode, pageSize, pageNum, checkValue]; } Object encode() { - return _toList(); } + return _toList(); + } static ProductMessage decode(Object result) { result as List; @@ -630,7 +602,11 @@ class ProductMessage { if (identical(this, other)) { return true; } - return _deepEquals(appId, other.appId) && _deepEquals(countryCode, other.countryCode) && _deepEquals(pageSize, other.pageSize) && _deepEquals(pageNum, other.pageNum) && _deepEquals(checkValue, other.checkValue); + return _deepEquals(appId, other.appId) && + _deepEquals(countryCode, other.countryCode) && + _deepEquals(pageSize, other.pageSize) && + _deepEquals(pageNum, other.pageNum) && + _deepEquals(checkValue, other.checkValue); } @override @@ -669,17 +645,12 @@ class PurchaseMessage { String checkValue; List _toList() { - return [ - appId, - customId, - countryCode, - pageNum, - checkValue, - ]; + return [appId, customId, countryCode, pageNum, checkValue]; } Object encode() { - return _toList(); } + return _toList(); + } static PurchaseMessage decode(Object result) { result as List; @@ -701,7 +672,11 @@ class PurchaseMessage { if (identical(this, other)) { return true; } - return _deepEquals(appId, other.appId) && _deepEquals(customId, other.customId) && _deepEquals(countryCode, other.countryCode) && _deepEquals(pageNum, other.pageNum) && _deepEquals(checkValue, other.checkValue); + return _deepEquals(appId, other.appId) && + _deepEquals(customId, other.customId) && + _deepEquals(countryCode, other.countryCode) && + _deepEquals(pageNum, other.pageNum) && + _deepEquals(checkValue, other.checkValue); } @override @@ -734,17 +709,12 @@ class OrderDetails { String orderCustomId; List _toList() { - return [ - orderItemId, - orderTitle, - orderTotal, - orderCurrencyId, - orderCustomId, - ]; + return [orderItemId, orderTitle, orderTotal, orderCurrencyId, orderCustomId]; } Object encode() { - return _toList(); } + return _toList(); + } static OrderDetails decode(Object result) { result as List; @@ -766,7 +736,11 @@ class OrderDetails { if (identical(this, other)) { return true; } - return _deepEquals(orderItemId, other.orderItemId) && _deepEquals(orderTitle, other.orderTitle) && _deepEquals(orderTotal, other.orderTotal) && _deepEquals(orderCurrencyId, other.orderCurrencyId) && _deepEquals(orderCustomId, other.orderCustomId); + return _deepEquals(orderItemId, other.orderItemId) && + _deepEquals(orderTitle, other.orderTitle) && + _deepEquals(orderTotal, other.orderTotal) && + _deepEquals(orderCurrencyId, other.orderCurrencyId) && + _deepEquals(orderCustomId, other.orderCustomId); } @override @@ -780,10 +754,7 @@ class OrderDetails { } class BuyInfoMessage { - BuyInfoMessage({ - required this.appId, - required this.payDetials, - }); + BuyInfoMessage({required this.appId, required this.payDetials}); /// Application ID. String appId; @@ -792,21 +763,16 @@ class BuyInfoMessage { OrderDetails payDetials; List _toList() { - return [ - appId, - payDetials, - ]; + return [appId, payDetials]; } Object encode() { - return _toList(); } + return _toList(); + } static BuyInfoMessage decode(Object result) { result as List; - return BuyInfoMessage( - appId: result[0]! as String, - payDetials: result[1]! as OrderDetails, - ); + return BuyInfoMessage(appId: result[0]! as String, payDetials: result[1]! as OrderDetails); } @override @@ -852,16 +818,12 @@ class InvoiceMessage { String countryCode; List _toList() { - return [ - appId, - customId, - invoiceId, - countryCode, - ]; + return [appId, customId, invoiceId, countryCode]; } Object encode() { - return _toList(); } + return _toList(); + } static InvoiceMessage decode(Object result) { result as List; @@ -882,7 +844,10 @@ class InvoiceMessage { if (identical(this, other)) { return true; } - return _deepEquals(appId, other.appId) && _deepEquals(customId, other.customId) && _deepEquals(invoiceId, other.invoiceId) && _deepEquals(countryCode, other.countryCode); + return _deepEquals(appId, other.appId) && + _deepEquals(customId, other.customId) && + _deepEquals(invoiceId, other.invoiceId) && + _deepEquals(countryCode, other.countryCode); } @override @@ -895,7 +860,6 @@ class InvoiceMessage { } } - class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -903,34 +867,34 @@ class _PigeonCodec extends StandardMessageCodec { if (value is int) { buffer.putUint8(4); buffer.putInt64(value); - } else if (value is ProductsListApiResult) { + } else if (value is ProductsListApiResult) { buffer.putUint8(129); writeValue(buffer, value.encode()); - } else if (value is GetUserPurchaseListAPIResult) { + } else if (value is GetUserPurchaseListAPIResult) { buffer.putUint8(130); writeValue(buffer, value.encode()); - } else if (value is BillingBuyData) { + } else if (value is BillingBuyData) { buffer.putUint8(131); writeValue(buffer, value.encode()); - } else if (value is VerifyInvoiceAPIResult) { + } else if (value is VerifyInvoiceAPIResult) { buffer.putUint8(132); writeValue(buffer, value.encode()); - } else if (value is ServiceAvailableAPIResult) { + } else if (value is ServiceAvailableAPIResult) { buffer.putUint8(133); writeValue(buffer, value.encode()); - } else if (value is ProductMessage) { + } else if (value is ProductMessage) { buffer.putUint8(134); writeValue(buffer, value.encode()); - } else if (value is PurchaseMessage) { + } else if (value is PurchaseMessage) { buffer.putUint8(135); writeValue(buffer, value.encode()); - } else if (value is OrderDetails) { + } else if (value is OrderDetails) { buffer.putUint8(136); writeValue(buffer, value.encode()); - } else if (value is BuyInfoMessage) { + } else if (value is BuyInfoMessage) { buffer.putUint8(137); writeValue(buffer, value.encode()); - } else if (value is InvoiceMessage) { + } else if (value is InvoiceMessage) { buffer.putUint8(138); writeValue(buffer, value.encode()); } else { @@ -975,10 +939,18 @@ class InAppPurchaseApi { pigeon_ffi.InAppPurchaseTizenFfiBindings? ffiBindings, }) : pigeonVar_ffiBindings = ffiBindings ?? _pigeonVar_defaultFfiBindings { if (binaryMessenger != null) { - throw ArgumentError.value(binaryMessenger, 'binaryMessenger', 'BinaryMessenger is not supported by FFI HostApi.'); + throw ArgumentError.value( + binaryMessenger, + 'binaryMessenger', + 'BinaryMessenger is not supported by FFI HostApi.', + ); } if (messageChannelSuffix.isNotEmpty) { - throw ArgumentError.value(messageChannelSuffix, 'messageChannelSuffix', 'messageChannelSuffix is not supported by FFI HostApi.'); + throw ArgumentError.value( + messageChannelSuffix, + 'messageChannelSuffix', + 'messageChannelSuffix is not supported by FFI HostApi.', + ); } } @@ -989,10 +961,33 @@ class InAppPurchaseApi { static const MessageCodec pigeonChannelCodec = _PigeonCodec(); + Future initialize() async { + final ffi.Pointer pigeonVar_request = ffi.nullptr; + final String pigeonVar_channelName = 'pigeon_in_app_purchase_api_initialize'; + ffi.Pointer pigeonVar_response = ffi.nullptr; + try { + pigeonVar_response = pigeonVar_ffiBindings.pigeon_in_app_purchase_api_initialize( + pigeonVar_request, + ); + final List? pigeonVar_replyList = _decodeFfiReply( + pigeonChannelCodec, + pigeonVar_response, + ); + _extractReplyValueOrThrow(pigeonVar_replyList, pigeonVar_channelName, isNullValid: true); + } finally { + _freeFfiRequest(pigeonVar_request); + if (pigeonVar_response != ffi.nullptr) { + pigeonVar_ffiBindings.pigeon_free_buffer(pigeonVar_response); + } + } + } + /// Retrieves the list of products registered on the Billing (DPI) server. Future getProductsList(ProductMessage product) async { final ByteData? pigeonVar_requestMessage = pigeonChannelCodec.encodeMessage([product]); - final ffi.Pointer pigeonVar_request = _encodeFfiRequest(pigeonVar_requestMessage); + final ffi.Pointer pigeonVar_request = _encodeFfiRequest( + pigeonVar_requestMessage, + ); final String pigeonVar_channelName = 'pigeon_in_app_purchase_api_get_products_list'; final Completer pigeonVar_completer = Completer(); final int pigeonVar_replyId = _pigeonNextFfiAsyncReplyId++; @@ -1029,10 +1024,15 @@ class InAppPurchaseApi { /// Retrieves the user's purchase list. Future getUserPurchaseList(PurchaseMessage purchase) async { - final ByteData? pigeonVar_requestMessage = pigeonChannelCodec.encodeMessage([purchase]); - final ffi.Pointer pigeonVar_request = _encodeFfiRequest(pigeonVar_requestMessage); + final ByteData? pigeonVar_requestMessage = pigeonChannelCodec.encodeMessage([ + purchase, + ]); + final ffi.Pointer pigeonVar_request = _encodeFfiRequest( + pigeonVar_requestMessage, + ); final String pigeonVar_channelName = 'pigeon_in_app_purchase_api_get_user_purchase_list'; - final Completer pigeonVar_completer = Completer(); + final Completer pigeonVar_completer = + Completer(); final int pigeonVar_replyId = _pigeonNextFfiAsyncReplyId++; _pigeonFfiAsyncReplies[pigeonVar_replyId] = _PigeonFfiAsyncReply( ffiBindings: pigeonVar_ffiBindings, @@ -1069,7 +1069,9 @@ class InAppPurchaseApi { /// After authenticating the purchase information through the application, the user can proceed to purchase payment. Future buyItem(BuyInfoMessage buyInfo) async { final ByteData? pigeonVar_requestMessage = pigeonChannelCodec.encodeMessage([buyInfo]); - final ffi.Pointer pigeonVar_request = _encodeFfiRequest(pigeonVar_requestMessage); + final ffi.Pointer pigeonVar_request = _encodeFfiRequest( + pigeonVar_requestMessage, + ); final String pigeonVar_channelName = 'pigeon_in_app_purchase_api_buy_item'; final Completer pigeonVar_completer = Completer(); final int pigeonVar_replyId = _pigeonNextFfiAsyncReplyId++; @@ -1107,9 +1109,12 @@ class InAppPurchaseApi { /// Checks whether a purchase, corresponding to a specific "InvoiceID", was successful. Future verifyInvoice(InvoiceMessage invoice) async { final ByteData? pigeonVar_requestMessage = pigeonChannelCodec.encodeMessage([invoice]); - final ffi.Pointer pigeonVar_request = _encodeFfiRequest(pigeonVar_requestMessage); + final ffi.Pointer pigeonVar_request = _encodeFfiRequest( + pigeonVar_requestMessage, + ); final String pigeonVar_channelName = 'pigeon_in_app_purchase_api_verify_invoice'; - final Completer pigeonVar_completer = Completer(); + final Completer pigeonVar_completer = + Completer(); final int pigeonVar_replyId = _pigeonNextFfiAsyncReplyId++; _pigeonFfiAsyncReplies[pigeonVar_replyId] = _PigeonFfiAsyncReply( ffiBindings: pigeonVar_ffiBindings, @@ -1184,14 +1189,18 @@ class InAppPurchaseApi { final String pigeonVar_channelName = 'pigeon_in_app_purchase_api_get_custom_id'; ffi.Pointer pigeonVar_response = ffi.nullptr; try { - pigeonVar_response = pigeonVar_ffiBindings.pigeon_in_app_purchase_api_get_custom_id(pigeonVar_request); - final List? pigeonVar_replyList = _decodeFfiReply(pigeonChannelCodec, pigeonVar_response); + pigeonVar_response = pigeonVar_ffiBindings.pigeon_in_app_purchase_api_get_custom_id( + pigeonVar_request, + ); + final List? pigeonVar_replyList = _decodeFfiReply( + pigeonChannelCodec, + pigeonVar_response, + ); final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); return pigeonVar_replyValue! as String; } finally { _freeFfiRequest(pigeonVar_request); @@ -1206,14 +1215,18 @@ class InAppPurchaseApi { final String pigeonVar_channelName = 'pigeon_in_app_purchase_api_get_country_code'; ffi.Pointer pigeonVar_response = ffi.nullptr; try { - pigeonVar_response = pigeonVar_ffiBindings.pigeon_in_app_purchase_api_get_country_code(pigeonVar_request); - final List? pigeonVar_replyList = _decodeFfiReply(pigeonChannelCodec, pigeonVar_response); + pigeonVar_response = pigeonVar_ffiBindings.pigeon_in_app_purchase_api_get_country_code( + pigeonVar_request, + ); + final List? pigeonVar_replyList = _decodeFfiReply( + pigeonChannelCodec, + pigeonVar_response, + ); final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); return pigeonVar_replyValue! as String; } finally { _freeFfiRequest(pigeonVar_request); diff --git a/packages/in_app_purchase/lib/src/messages.g.ffi.dart b/packages/in_app_purchase/lib/src/messages.g.ffi.dart index b71960c20..5e58c30d9 100644 --- a/packages/in_app_purchase/lib/src/messages.g.ffi.dart +++ b/packages/in_app_purchase/lib/src/messages.g.ffi.dart @@ -120,6 +120,21 @@ class InAppPurchaseTizenFfiBindings { _pigeon_in_app_purchase_api_get_user_purchase_listPtr .asFunction, int, PigeonFfiReplyCallback)>(); + ffi.Pointer pigeon_in_app_purchase_api_initialize( + ffi.Pointer request, + ) { + return _pigeon_in_app_purchase_api_initialize(request); + } + + late final _pigeon_in_app_purchase_api_initializePtr = + _lookup< + ffi.NativeFunction Function(ffi.Pointer)> + >( + 'pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_initialize', + ); + late final _pigeon_in_app_purchase_api_initialize = _pigeon_in_app_purchase_api_initializePtr + .asFunction Function(ffi.Pointer)>(); + void pigeon_in_app_purchase_api_is_service_available( ffi.Pointer request, int reply_id, diff --git a/packages/in_app_purchase/pigeons/messages.dart b/packages/in_app_purchase/pigeons/messages.dart index b6ff7dee8..73a390e29 100644 --- a/packages/in_app_purchase/pigeons/messages.dart +++ b/packages/in_app_purchase/pigeons/messages.dart @@ -27,10 +27,7 @@ import 'package:pigeon/pigeon.dart'; })()''', ), ), - cppOptions: CppOptions( - namespace: 'in_app_purchase_tizen', - useStdVisit: false, - ), + cppOptions: CppOptions(namespace: 'in_app_purchase_tizen', useStdVisit: false), cppHeaderOut: 'tizen/src/messages.h', cppSourceOut: 'tizen/src/messages.cc', cppFfiHeaderOut: 'tizen/src/messages_ffi.h', @@ -270,6 +267,8 @@ class InvoiceMessage { @HostApi() abstract class InAppPurchaseApi { + void initialize(); + /// Retrieves the list of products registered on the Billing (DPI) server. @async ProductsListApiResult getProductsList(ProductMessage product); diff --git a/packages/in_app_purchase/tizen/src/billing_manager.cc b/packages/in_app_purchase/tizen/src/billing_manager.cc index 5c574ebcd..2a10d9137 100644 --- a/packages/in_app_purchase/tizen/src/billing_manager.cc +++ b/packages/in_app_purchase/tizen/src/billing_manager.cc @@ -166,6 +166,15 @@ bool BillingManager::VerifyInvoice( return true; } +void BillingManager::ResetPendingCallbacks() { + std::lock_guard lock(mutex_); + is_available_callback_ = nullptr; + buy_item_callback_ = nullptr; + get_product_list_callback_ = nullptr; + get_purchase_list_callback_ = nullptr; + verify_invoice_callback_ = nullptr; +} + void BillingManager::OnAvailable(const char *detail_result, void *user_data) { LOG_INFO("[BillingManager] Billing server detail_result: %s", detail_result); diff --git a/packages/in_app_purchase/tizen/src/billing_manager.h b/packages/in_app_purchase/tizen/src/billing_manager.h index a0a9f94e7..092cd0f16 100644 --- a/packages/in_app_purchase/tizen/src/billing_manager.h +++ b/packages/in_app_purchase/tizen/src/billing_manager.h @@ -73,6 +73,7 @@ class BillingManager { bool VerifyInvoice(const char *app_id, const char *custom_id, const char *invoice_id, const char *country_code, FunctionResult result); + void ResetPendingCallbacks(); std::optional GetCustomId(); std::optional GetCountryCode(); diff --git a/packages/in_app_purchase/tizen/src/in_app_purchase_tizen_plugin.cc b/packages/in_app_purchase/tizen/src/in_app_purchase_tizen_plugin.cc index a77d8cdf8..0be59cbc6 100644 --- a/packages/in_app_purchase/tizen/src/in_app_purchase_tizen_plugin.cc +++ b/packages/in_app_purchase/tizen/src/in_app_purchase_tizen_plugin.cc @@ -90,6 +90,7 @@ class InAppPurchaseTizenPlugin : public flutter::Plugin, InAppPurchaseTizenPlugin(flutter::PluginRegistrar *plugin_registrar); virtual ~InAppPurchaseTizenPlugin() { Dispose(); } + std::optional Initialize() override; void GetProductsList(const ProductMessage &product, std::function reply)> result) override; @@ -131,6 +132,11 @@ void InAppPurchaseTizenPlugin::RegisterWithRegistrar( plugin_registrar->AddPlugin(std::move(plugin)); } +std::optional InAppPurchaseTizenPlugin::Initialize() { + billing_->ResetPendingCallbacks(); + return std::nullopt; +} + void InAppPurchaseTizenPlugin::GetProductsList( const ProductMessage &product, std::function reply)> result) { diff --git a/packages/in_app_purchase/tizen/src/messages.cc b/packages/in_app_purchase/tizen/src/messages.cc index c4df78806..371efb5c9 100644 --- a/packages/in_app_purchase/tizen/src/messages.cc +++ b/packages/in_app_purchase/tizen/src/messages.cc @@ -32,32 +32,36 @@ FlutterError CreateConnectionError(const std::string channel_name) { } namespace { -template +template bool PigeonInternalDeepEquals(const T& a, const T& b); bool PigeonInternalDeepEquals(const double& a, const double& b); -template +template bool PigeonInternalDeepEquals(const std::vector& a, const std::vector& b); -template +template bool PigeonInternalDeepEquals(const std::map& a, const std::map& b); -template -bool PigeonInternalDeepEquals(const std::optional& a, const std::optional& b); +template +bool PigeonInternalDeepEquals(const std::optional& a, + const std::optional& b); -template -bool PigeonInternalDeepEquals(const std::unique_ptr& a, const std::unique_ptr& b); +template +bool PigeonInternalDeepEquals(const std::unique_ptr& a, + const std::unique_ptr& b); -bool PigeonInternalDeepEquals(const ::flutter::EncodableValue& a, const ::flutter::EncodableValue& b); +bool PigeonInternalDeepEquals(const ::flutter::EncodableValue& a, + const ::flutter::EncodableValue& b); -template +template bool PigeonInternalDeepEquals(const T& a, const T& b) { return a == b; } -template -bool PigeonInternalDeepEquals(const std::vector& a, const std::vector& b) { +template +bool PigeonInternalDeepEquals(const std::vector& a, + const std::vector& b) { if (a.size() != b.size()) { return false; } @@ -70,7 +74,8 @@ bool PigeonInternalDeepEquals(const std::vector& a, const std::vector& b) } template -bool PigeonInternalDeepEquals(const std::map& a, const std::map& b) { +bool PigeonInternalDeepEquals(const std::map& a, + const std::map& b) { if (a.size() != b.size()) { return false; } @@ -98,8 +103,9 @@ bool PigeonInternalDeepEquals(const double& a, const double& b) { return (a == b) || (std::isnan(a) && std::isnan(b)); } -template -bool PigeonInternalDeepEquals(const std::optional& a, const std::optional& b) { +template +bool PigeonInternalDeepEquals(const std::optional& a, + const std::optional& b) { if (!a && !b) { return true; } @@ -109,8 +115,9 @@ bool PigeonInternalDeepEquals(const std::optional& a, const std::optional& return PigeonInternalDeepEquals(*a, *b); } -template -bool PigeonInternalDeepEquals(const std::unique_ptr& a, const std::unique_ptr& b) { +template +bool PigeonInternalDeepEquals(const std::unique_ptr& a, + const std::unique_ptr& b) { if (a.get() == b.get()) { return true; } @@ -120,15 +127,18 @@ bool PigeonInternalDeepEquals(const std::unique_ptr& a, const std::unique_ptr return PigeonInternalDeepEquals(*a, *b); } -bool PigeonInternalDeepEquals(const ::flutter::EncodableValue& a, const ::flutter::EncodableValue& b) { +bool PigeonInternalDeepEquals(const ::flutter::EncodableValue& a, + const ::flutter::EncodableValue& b) { if (a.index() != b.index()) { return false; } if (const double* da = std::get_if(&a)) { return PigeonInternalDeepEquals(*da, std::get(b)); - } else if (const ::flutter::EncodableList* la = std::get_if<::flutter::EncodableList>(&a)) { + } else if (const ::flutter::EncodableList* la = + std::get_if<::flutter::EncodableList>(&a)) { return PigeonInternalDeepEquals(*la, std::get<::flutter::EncodableList>(b)); - } else if (const ::flutter::EncodableMap* ma = std::get_if<::flutter::EncodableMap>(&a)) { + } else if (const ::flutter::EncodableMap* ma = + std::get_if<::flutter::EncodableMap>(&a)) { return PigeonInternalDeepEquals(*ma, std::get<::flutter::EncodableMap>(b)); } return a == b; @@ -171,7 +181,8 @@ template size_t PigeonInternalDeepHash(const std::map& v) { size_t result = 0; for (const auto& kv : v) { - result += ((PigeonInternalDeepHash(kv.first) * 31) ^ PigeonInternalDeepHash(kv.second)); + result += ((PigeonInternalDeepHash(kv.first) * 31) ^ + PigeonInternalDeepHash(kv.second)); } return result; } @@ -198,7 +209,6 @@ size_t PigeonInternalDeepHash(const std::unique_ptr& v) { return v ? PigeonInternalDeepHash(*v) : 0; } - size_t PigeonInternalDeepHash(const ::flutter::EncodableValue& v) { size_t result = v.index(); if (const bool* bv = std::get_if(&v)) { @@ -211,15 +221,20 @@ size_t PigeonInternalDeepHash(const ::flutter::EncodableValue& v) { result = result * 31 + PigeonInternalDeepHash(*dv); } else if (const std::string* sv = std::get_if(&v)) { result = result * 31 + PigeonInternalDeepHash(*sv); - } else if (const std::vector* bv = std::get_if>(&v)) { + } else if (const std::vector* bv = + std::get_if>(&v)) { result = result * 31 + PigeonInternalDeepHash(*bv); - } else if (const std::vector* iv = std::get_if>(&v)) { + } else if (const std::vector* iv = + std::get_if>(&v)) { result = result * 31 + PigeonInternalDeepHash(*iv); - } else if (const std::vector* lv = std::get_if>(&v)) { + } else if (const std::vector* lv = + std::get_if>(&v)) { result = result * 31 + PigeonInternalDeepHash(*lv); - } else if (const std::vector* fv = std::get_if>(&v)) { + } else if (const std::vector* fv = + std::get_if>(&v)) { result = result * 31 + PigeonInternalDeepHash(*fv); - } else if (const std::vector* dv = std::get_if>(&v)) { + } else if (const std::vector* dv = + std::get_if>(&v)) { result = result * 31 + PigeonInternalDeepHash(*dv); } else if (const ::flutter::EncodableList* lv = std::get_if<::flutter::EncodableList>(&v)) { @@ -289,7 +304,8 @@ std::string PigeonInternalToString(const std::map& v) { ss << ", "; } first = false; - ss << PigeonInternalToString(kv.first) << ": " << PigeonInternalToString(kv.second); + ss << PigeonInternalToString(kv.first) << ": " + << PigeonInternalToString(kv.second); } ss << "}"; return ss.str(); @@ -305,7 +321,6 @@ std::string PigeonInternalToString(const std::unique_ptr& v) { return v ? PigeonInternalToString(*v) : "null"; } - std::string PigeonInternalToString(const ::flutter::EncodableValue& v) { if (std::get_if(&v)) { return "null"; @@ -340,10 +355,12 @@ std::string PigeonInternalToString(const ::flutter::EncodableValue& v) { if (const std::vector* dv = std::get_if>(&v)) { return PigeonInternalToString(*dv); } - if (const ::flutter::EncodableList* lv = std::get_if<::flutter::EncodableList>(&v)) { + if (const ::flutter::EncodableList* lv = + std::get_if<::flutter::EncodableList>(&v)) { return PigeonInternalToString(*lv); } - if (const ::flutter::EncodableMap* mv = std::get_if<::flutter::EncodableMap>(&v)) { + if (const ::flutter::EncodableMap* mv = + std::get_if<::flutter::EncodableMap>(&v)) { return PigeonInternalToString(*mv); } if (std::get_if<::flutter::CustomEncodableValue>(&v)) { @@ -355,27 +372,26 @@ std::string PigeonInternalToString(const ::flutter::EncodableValue& v) { } // namespace // ProductsListApiResult -ProductsListApiResult::ProductsListApiResult( - const std::string& cp_status, - int64_t total_count, - const std::string& check_value, - const EncodableList& item_details) - : cp_status_(cp_status), - total_count_(total_count), - check_value_(check_value), - item_details_(item_details) {} - -ProductsListApiResult::ProductsListApiResult( - const std::string& cp_status, - const std::string* cp_result, - int64_t total_count, - const std::string& check_value, - const EncodableList& item_details) - : cp_status_(cp_status), - cp_result_(cp_result ? std::optional(*cp_result) : std::nullopt), - total_count_(total_count), - check_value_(check_value), - item_details_(item_details) {} +ProductsListApiResult::ProductsListApiResult(const std::string& cp_status, + int64_t total_count, + const std::string& check_value, + const EncodableList& item_details) + : cp_status_(cp_status), + total_count_(total_count), + check_value_(check_value), + item_details_(item_details) {} + +ProductsListApiResult::ProductsListApiResult(const std::string& cp_status, + const std::string* cp_result, + int64_t total_count, + const std::string& check_value, + const EncodableList& item_details) + : cp_status_(cp_status), + cp_result_(cp_result ? std::optional(*cp_result) + : std::nullopt), + total_count_(total_count), + check_value_(check_value), + item_details_(item_details) {} const std::string& ProductsListApiResult::cp_status() const { return cp_status_; @@ -385,29 +401,25 @@ void ProductsListApiResult::set_cp_status(std::string_view value_arg) { cp_status_ = value_arg; } - const std::string* ProductsListApiResult::cp_result() const { return cp_result_ ? &(*cp_result_) : nullptr; } void ProductsListApiResult::set_cp_result(const std::string_view* value_arg) { - cp_result_ = value_arg ? std::optional(*value_arg) : std::nullopt; + cp_result_ = + value_arg ? std::optional(*value_arg) : std::nullopt; } void ProductsListApiResult::set_cp_result(std::string_view value_arg) { cp_result_ = value_arg; } - -int64_t ProductsListApiResult::total_count() const { - return total_count_; -} +int64_t ProductsListApiResult::total_count() const { return total_count_; } void ProductsListApiResult::set_total_count(int64_t value_arg) { total_count_ = value_arg; } - const std::string& ProductsListApiResult::check_value() const { return check_value_; } @@ -416,7 +428,6 @@ void ProductsListApiResult::set_check_value(std::string_view value_arg) { check_value_ = value_arg; } - const EncodableList& ProductsListApiResult::item_details() const { return item_details_; } @@ -425,7 +436,6 @@ void ProductsListApiResult::set_item_details(const EncodableList& value_arg) { item_details_ = value_arg; } - EncodableList ProductsListApiResult::ToEncodableList() const { EncodableList list; list.reserve(5); @@ -437,12 +447,11 @@ EncodableList ProductsListApiResult::ToEncodableList() const { return list; } -ProductsListApiResult ProductsListApiResult::FromEncodableList(const EncodableList& list) { +ProductsListApiResult ProductsListApiResult::FromEncodableList( + const EncodableList& list) { ProductsListApiResult decoded( - std::get(list[0]), - std::get(list[2]), - std::get(list[3]), - std::get(list[4])); + std::get(list[0]), std::get(list[2]), + std::get(list[3]), std::get(list[4])); auto& encodable_cp_result = list[1]; if (!encodable_cp_result.IsNull()) { decoded.set_cp_result(std::get(encodable_cp_result)); @@ -450,11 +459,17 @@ ProductsListApiResult ProductsListApiResult::FromEncodableList(const EncodableLi return decoded; } -bool ProductsListApiResult::operator==(const ProductsListApiResult& other) const { - return PigeonInternalDeepEquals(cp_status_, other.cp_status_) && PigeonInternalDeepEquals(cp_result_, other.cp_result_) && PigeonInternalDeepEquals(total_count_, other.total_count_) && PigeonInternalDeepEquals(check_value_, other.check_value_) && PigeonInternalDeepEquals(item_details_, other.item_details_); +bool ProductsListApiResult::operator==( + const ProductsListApiResult& other) const { + return PigeonInternalDeepEquals(cp_status_, other.cp_status_) && + PigeonInternalDeepEquals(cp_result_, other.cp_result_) && + PigeonInternalDeepEquals(total_count_, other.total_count_) && + PigeonInternalDeepEquals(check_value_, other.check_value_) && + PigeonInternalDeepEquals(item_details_, other.item_details_); } -bool ProductsListApiResult::operator!=(const ProductsListApiResult& other) const { +bool ProductsListApiResult::operator!=( + const ProductsListApiResult& other) const { return !(*this == other); } @@ -468,17 +483,14 @@ size_t ProductsListApiResult::Hash() const { return result; } -std::ostream& operator<<( - std::ostream& os, - const ProductsListApiResult& obj) { +std::ostream& operator<<(std::ostream& os, const ProductsListApiResult& obj) { os << "ProductsListApiResult("; os << "cp_status: "; os << PigeonInternalToString(obj.cp_status_); os << ", cp_result: "; if (obj.cp_result_) { os << PigeonInternalToString(*obj.cp_result_); - } - else { + } else { os << "null"; } os << ", total_count: "; @@ -498,26 +510,23 @@ size_t PigeonInternalDeepHash(const ProductsListApiResult& v) { // GetUserPurchaseListAPIResult GetUserPurchaseListAPIResult::GetUserPurchaseListAPIResult( - const std::string& cp_status, - int64_t total_count, - const std::string& check_value, - const EncodableList& invoice_details) - : cp_status_(cp_status), - total_count_(total_count), - check_value_(check_value), - invoice_details_(invoice_details) {} + const std::string& cp_status, int64_t total_count, + const std::string& check_value, const EncodableList& invoice_details) + : cp_status_(cp_status), + total_count_(total_count), + check_value_(check_value), + invoice_details_(invoice_details) {} GetUserPurchaseListAPIResult::GetUserPurchaseListAPIResult( - const std::string& cp_status, - const std::string* cp_result, - int64_t total_count, - const std::string& check_value, - const EncodableList& invoice_details) - : cp_status_(cp_status), - cp_result_(cp_result ? std::optional(*cp_result) : std::nullopt), - total_count_(total_count), - check_value_(check_value), - invoice_details_(invoice_details) {} + const std::string& cp_status, const std::string* cp_result, + int64_t total_count, const std::string& check_value, + const EncodableList& invoice_details) + : cp_status_(cp_status), + cp_result_(cp_result ? std::optional(*cp_result) + : std::nullopt), + total_count_(total_count), + check_value_(check_value), + invoice_details_(invoice_details) {} const std::string& GetUserPurchaseListAPIResult::cp_status() const { return cp_status_; @@ -527,20 +536,20 @@ void GetUserPurchaseListAPIResult::set_cp_status(std::string_view value_arg) { cp_status_ = value_arg; } - const std::string* GetUserPurchaseListAPIResult::cp_result() const { return cp_result_ ? &(*cp_result_) : nullptr; } -void GetUserPurchaseListAPIResult::set_cp_result(const std::string_view* value_arg) { - cp_result_ = value_arg ? std::optional(*value_arg) : std::nullopt; +void GetUserPurchaseListAPIResult::set_cp_result( + const std::string_view* value_arg) { + cp_result_ = + value_arg ? std::optional(*value_arg) : std::nullopt; } void GetUserPurchaseListAPIResult::set_cp_result(std::string_view value_arg) { cp_result_ = value_arg; } - int64_t GetUserPurchaseListAPIResult::total_count() const { return total_count_; } @@ -549,7 +558,6 @@ void GetUserPurchaseListAPIResult::set_total_count(int64_t value_arg) { total_count_ = value_arg; } - const std::string& GetUserPurchaseListAPIResult::check_value() const { return check_value_; } @@ -558,16 +566,15 @@ void GetUserPurchaseListAPIResult::set_check_value(std::string_view value_arg) { check_value_ = value_arg; } - const EncodableList& GetUserPurchaseListAPIResult::invoice_details() const { return invoice_details_; } -void GetUserPurchaseListAPIResult::set_invoice_details(const EncodableList& value_arg) { +void GetUserPurchaseListAPIResult::set_invoice_details( + const EncodableList& value_arg) { invoice_details_ = value_arg; } - EncodableList GetUserPurchaseListAPIResult::ToEncodableList() const { EncodableList list; list.reserve(5); @@ -579,12 +586,11 @@ EncodableList GetUserPurchaseListAPIResult::ToEncodableList() const { return list; } -GetUserPurchaseListAPIResult GetUserPurchaseListAPIResult::FromEncodableList(const EncodableList& list) { +GetUserPurchaseListAPIResult GetUserPurchaseListAPIResult::FromEncodableList( + const EncodableList& list) { GetUserPurchaseListAPIResult decoded( - std::get(list[0]), - std::get(list[2]), - std::get(list[3]), - std::get(list[4])); + std::get(list[0]), std::get(list[2]), + std::get(list[3]), std::get(list[4])); auto& encodable_cp_result = list[1]; if (!encodable_cp_result.IsNull()) { decoded.set_cp_result(std::get(encodable_cp_result)); @@ -592,11 +598,17 @@ GetUserPurchaseListAPIResult GetUserPurchaseListAPIResult::FromEncodableList(con return decoded; } -bool GetUserPurchaseListAPIResult::operator==(const GetUserPurchaseListAPIResult& other) const { - return PigeonInternalDeepEquals(cp_status_, other.cp_status_) && PigeonInternalDeepEquals(cp_result_, other.cp_result_) && PigeonInternalDeepEquals(total_count_, other.total_count_) && PigeonInternalDeepEquals(check_value_, other.check_value_) && PigeonInternalDeepEquals(invoice_details_, other.invoice_details_); +bool GetUserPurchaseListAPIResult::operator==( + const GetUserPurchaseListAPIResult& other) const { + return PigeonInternalDeepEquals(cp_status_, other.cp_status_) && + PigeonInternalDeepEquals(cp_result_, other.cp_result_) && + PigeonInternalDeepEquals(total_count_, other.total_count_) && + PigeonInternalDeepEquals(check_value_, other.check_value_) && + PigeonInternalDeepEquals(invoice_details_, other.invoice_details_); } -bool GetUserPurchaseListAPIResult::operator!=(const GetUserPurchaseListAPIResult& other) const { +bool GetUserPurchaseListAPIResult::operator!=( + const GetUserPurchaseListAPIResult& other) const { return !(*this == other); } @@ -610,17 +622,15 @@ size_t GetUserPurchaseListAPIResult::Hash() const { return result; } -std::ostream& operator<<( - std::ostream& os, - const GetUserPurchaseListAPIResult& obj) { +std::ostream& operator<<(std::ostream& os, + const GetUserPurchaseListAPIResult& obj) { os << "GetUserPurchaseListAPIResult("; os << "cp_status: "; os << PigeonInternalToString(obj.cp_status_); os << ", cp_result: "; if (obj.cp_result_) { os << PigeonInternalToString(*obj.cp_result_); - } - else { + } else { os << "null"; } os << ", total_count: "; @@ -639,30 +649,22 @@ size_t PigeonInternalDeepHash(const GetUserPurchaseListAPIResult& v) { // BillingBuyData -BillingBuyData::BillingBuyData( - const std::string& pay_result, - const EncodableMap& pay_details) - : pay_result_(pay_result), - pay_details_(pay_details) {} +BillingBuyData::BillingBuyData(const std::string& pay_result, + const EncodableMap& pay_details) + : pay_result_(pay_result), pay_details_(pay_details) {} -const std::string& BillingBuyData::pay_result() const { - return pay_result_; -} +const std::string& BillingBuyData::pay_result() const { return pay_result_; } void BillingBuyData::set_pay_result(std::string_view value_arg) { pay_result_ = value_arg; } - -const EncodableMap& BillingBuyData::pay_details() const { - return pay_details_; -} +const EncodableMap& BillingBuyData::pay_details() const { return pay_details_; } void BillingBuyData::set_pay_details(const EncodableMap& value_arg) { pay_details_ = value_arg; } - EncodableList BillingBuyData::ToEncodableList() const { EncodableList list; list.reserve(2); @@ -672,14 +674,14 @@ EncodableList BillingBuyData::ToEncodableList() const { } BillingBuyData BillingBuyData::FromEncodableList(const EncodableList& list) { - BillingBuyData decoded( - std::get(list[0]), - std::get(list[1])); + BillingBuyData decoded(std::get(list[0]), + std::get(list[1])); return decoded; } bool BillingBuyData::operator==(const BillingBuyData& other) const { - return PigeonInternalDeepEquals(pay_result_, other.pay_result_) && PigeonInternalDeepEquals(pay_details_, other.pay_details_); + return PigeonInternalDeepEquals(pay_result_, other.pay_result_) && + PigeonInternalDeepEquals(pay_details_, other.pay_details_); } bool BillingBuyData::operator!=(const BillingBuyData& other) const { @@ -693,9 +695,7 @@ size_t BillingBuyData::Hash() const { return result; } -std::ostream& operator<<( - std::ostream& os, - const BillingBuyData& obj) { +std::ostream& operator<<(std::ostream& os, const BillingBuyData& obj) { os << "BillingBuyData("; os << "pay_result: "; os << PigeonInternalToString(obj.pay_result_); @@ -705,29 +705,24 @@ std::ostream& operator<<( return os; } -size_t PigeonInternalDeepHash(const BillingBuyData& v) { - return v.Hash(); -} +size_t PigeonInternalDeepHash(const BillingBuyData& v) { return v.Hash(); } // VerifyInvoiceAPIResult -VerifyInvoiceAPIResult::VerifyInvoiceAPIResult( - const std::string& cp_status, - const std::string& app_id, - const std::string& invoice_id) - : cp_status_(cp_status), - app_id_(app_id), - invoice_id_(invoice_id) {} - -VerifyInvoiceAPIResult::VerifyInvoiceAPIResult( - const std::string& cp_status, - const std::string* cp_result, - const std::string& app_id, - const std::string& invoice_id) - : cp_status_(cp_status), - cp_result_(cp_result ? std::optional(*cp_result) : std::nullopt), - app_id_(app_id), - invoice_id_(invoice_id) {} +VerifyInvoiceAPIResult::VerifyInvoiceAPIResult(const std::string& cp_status, + const std::string& app_id, + const std::string& invoice_id) + : cp_status_(cp_status), app_id_(app_id), invoice_id_(invoice_id) {} + +VerifyInvoiceAPIResult::VerifyInvoiceAPIResult(const std::string& cp_status, + const std::string* cp_result, + const std::string& app_id, + const std::string& invoice_id) + : cp_status_(cp_status), + cp_result_(cp_result ? std::optional(*cp_result) + : std::nullopt), + app_id_(app_id), + invoice_id_(invoice_id) {} const std::string& VerifyInvoiceAPIResult::cp_status() const { return cp_status_; @@ -737,29 +732,25 @@ void VerifyInvoiceAPIResult::set_cp_status(std::string_view value_arg) { cp_status_ = value_arg; } - const std::string* VerifyInvoiceAPIResult::cp_result() const { return cp_result_ ? &(*cp_result_) : nullptr; } void VerifyInvoiceAPIResult::set_cp_result(const std::string_view* value_arg) { - cp_result_ = value_arg ? std::optional(*value_arg) : std::nullopt; + cp_result_ = + value_arg ? std::optional(*value_arg) : std::nullopt; } void VerifyInvoiceAPIResult::set_cp_result(std::string_view value_arg) { cp_result_ = value_arg; } - -const std::string& VerifyInvoiceAPIResult::app_id() const { - return app_id_; -} +const std::string& VerifyInvoiceAPIResult::app_id() const { return app_id_; } void VerifyInvoiceAPIResult::set_app_id(std::string_view value_arg) { app_id_ = value_arg; } - const std::string& VerifyInvoiceAPIResult::invoice_id() const { return invoice_id_; } @@ -768,7 +759,6 @@ void VerifyInvoiceAPIResult::set_invoice_id(std::string_view value_arg) { invoice_id_ = value_arg; } - EncodableList VerifyInvoiceAPIResult::ToEncodableList() const { EncodableList list; list.reserve(4); @@ -779,11 +769,11 @@ EncodableList VerifyInvoiceAPIResult::ToEncodableList() const { return list; } -VerifyInvoiceAPIResult VerifyInvoiceAPIResult::FromEncodableList(const EncodableList& list) { - VerifyInvoiceAPIResult decoded( - std::get(list[0]), - std::get(list[2]), - std::get(list[3])); +VerifyInvoiceAPIResult VerifyInvoiceAPIResult::FromEncodableList( + const EncodableList& list) { + VerifyInvoiceAPIResult decoded(std::get(list[0]), + std::get(list[2]), + std::get(list[3])); auto& encodable_cp_result = list[1]; if (!encodable_cp_result.IsNull()) { decoded.set_cp_result(std::get(encodable_cp_result)); @@ -791,11 +781,16 @@ VerifyInvoiceAPIResult VerifyInvoiceAPIResult::FromEncodableList(const Encodable return decoded; } -bool VerifyInvoiceAPIResult::operator==(const VerifyInvoiceAPIResult& other) const { - return PigeonInternalDeepEquals(cp_status_, other.cp_status_) && PigeonInternalDeepEquals(cp_result_, other.cp_result_) && PigeonInternalDeepEquals(app_id_, other.app_id_) && PigeonInternalDeepEquals(invoice_id_, other.invoice_id_); +bool VerifyInvoiceAPIResult::operator==( + const VerifyInvoiceAPIResult& other) const { + return PigeonInternalDeepEquals(cp_status_, other.cp_status_) && + PigeonInternalDeepEquals(cp_result_, other.cp_result_) && + PigeonInternalDeepEquals(app_id_, other.app_id_) && + PigeonInternalDeepEquals(invoice_id_, other.invoice_id_); } -bool VerifyInvoiceAPIResult::operator!=(const VerifyInvoiceAPIResult& other) const { +bool VerifyInvoiceAPIResult::operator!=( + const VerifyInvoiceAPIResult& other) const { return !(*this == other); } @@ -808,17 +803,14 @@ size_t VerifyInvoiceAPIResult::Hash() const { return result; } -std::ostream& operator<<( - std::ostream& os, - const VerifyInvoiceAPIResult& obj) { +std::ostream& operator<<(std::ostream& os, const VerifyInvoiceAPIResult& obj) { os << "VerifyInvoiceAPIResult("; os << "cp_status: "; os << PigeonInternalToString(obj.cp_status_); os << ", cp_result: "; if (obj.cp_result_) { os << PigeonInternalToString(*obj.cp_result_); - } - else { + } else { os << "null"; } os << ", app_id: "; @@ -836,31 +828,22 @@ size_t PigeonInternalDeepHash(const VerifyInvoiceAPIResult& v) { // ServiceAvailableAPIResult ServiceAvailableAPIResult::ServiceAvailableAPIResult( - const std::string& status, - const std::string& result, - const std::string& service_yn) - : status_(status), - result_(result), - service_yn_(service_yn) {} + const std::string& status, const std::string& result, + const std::string& service_yn) + : status_(status), result_(result), service_yn_(service_yn) {} -const std::string& ServiceAvailableAPIResult::status() const { - return status_; -} +const std::string& ServiceAvailableAPIResult::status() const { return status_; } void ServiceAvailableAPIResult::set_status(std::string_view value_arg) { status_ = value_arg; } - -const std::string& ServiceAvailableAPIResult::result() const { - return result_; -} +const std::string& ServiceAvailableAPIResult::result() const { return result_; } void ServiceAvailableAPIResult::set_result(std::string_view value_arg) { result_ = value_arg; } - const std::string& ServiceAvailableAPIResult::service_yn() const { return service_yn_; } @@ -869,7 +852,6 @@ void ServiceAvailableAPIResult::set_service_yn(std::string_view value_arg) { service_yn_ = value_arg; } - EncodableList ServiceAvailableAPIResult::ToEncodableList() const { EncodableList list; list.reserve(3); @@ -879,19 +861,23 @@ EncodableList ServiceAvailableAPIResult::ToEncodableList() const { return list; } -ServiceAvailableAPIResult ServiceAvailableAPIResult::FromEncodableList(const EncodableList& list) { - ServiceAvailableAPIResult decoded( - std::get(list[0]), - std::get(list[1]), - std::get(list[2])); +ServiceAvailableAPIResult ServiceAvailableAPIResult::FromEncodableList( + const EncodableList& list) { + ServiceAvailableAPIResult decoded(std::get(list[0]), + std::get(list[1]), + std::get(list[2])); return decoded; } -bool ServiceAvailableAPIResult::operator==(const ServiceAvailableAPIResult& other) const { - return PigeonInternalDeepEquals(status_, other.status_) && PigeonInternalDeepEquals(result_, other.result_) && PigeonInternalDeepEquals(service_yn_, other.service_yn_); +bool ServiceAvailableAPIResult::operator==( + const ServiceAvailableAPIResult& other) const { + return PigeonInternalDeepEquals(status_, other.status_) && + PigeonInternalDeepEquals(result_, other.result_) && + PigeonInternalDeepEquals(service_yn_, other.service_yn_); } -bool ServiceAvailableAPIResult::operator!=(const ServiceAvailableAPIResult& other) const { +bool ServiceAvailableAPIResult::operator!=( + const ServiceAvailableAPIResult& other) const { return !(*this == other); } @@ -903,9 +889,8 @@ size_t ServiceAvailableAPIResult::Hash() const { return result; } -std::ostream& operator<<( - std::ostream& os, - const ServiceAvailableAPIResult& obj) { +std::ostream& operator<<(std::ostream& os, + const ServiceAvailableAPIResult& obj) { os << "ServiceAvailableAPIResult("; os << "status: "; os << PigeonInternalToString(obj.status_); @@ -923,27 +908,22 @@ size_t PigeonInternalDeepHash(const ServiceAvailableAPIResult& v) { // ProductMessage -ProductMessage::ProductMessage( - const std::string& app_id, - const std::string& country_code, - int64_t page_size, - int64_t page_num, - const std::string& check_value) - : app_id_(app_id), - country_code_(country_code), - page_size_(page_size), - page_num_(page_num), - check_value_(check_value) {} +ProductMessage::ProductMessage(const std::string& app_id, + const std::string& country_code, + int64_t page_size, int64_t page_num, + const std::string& check_value) + : app_id_(app_id), + country_code_(country_code), + page_size_(page_size), + page_num_(page_num), + check_value_(check_value) {} -const std::string& ProductMessage::app_id() const { - return app_id_; -} +const std::string& ProductMessage::app_id() const { return app_id_; } void ProductMessage::set_app_id(std::string_view value_arg) { app_id_ = value_arg; } - const std::string& ProductMessage::country_code() const { return country_code_; } @@ -952,34 +932,22 @@ void ProductMessage::set_country_code(std::string_view value_arg) { country_code_ = value_arg; } - -int64_t ProductMessage::page_size() const { - return page_size_; -} +int64_t ProductMessage::page_size() const { return page_size_; } void ProductMessage::set_page_size(int64_t value_arg) { page_size_ = value_arg; } +int64_t ProductMessage::page_num() const { return page_num_; } -int64_t ProductMessage::page_num() const { - return page_num_; -} - -void ProductMessage::set_page_num(int64_t value_arg) { - page_num_ = value_arg; -} - +void ProductMessage::set_page_num(int64_t value_arg) { page_num_ = value_arg; } -const std::string& ProductMessage::check_value() const { - return check_value_; -} +const std::string& ProductMessage::check_value() const { return check_value_; } void ProductMessage::set_check_value(std::string_view value_arg) { check_value_ = value_arg; } - EncodableList ProductMessage::ToEncodableList() const { EncodableList list; list.reserve(5); @@ -992,17 +960,19 @@ EncodableList ProductMessage::ToEncodableList() const { } ProductMessage ProductMessage::FromEncodableList(const EncodableList& list) { - ProductMessage decoded( - std::get(list[0]), - std::get(list[1]), - std::get(list[2]), - std::get(list[3]), - std::get(list[4])); + ProductMessage decoded(std::get(list[0]), + std::get(list[1]), + std::get(list[2]), std::get(list[3]), + std::get(list[4])); return decoded; } bool ProductMessage::operator==(const ProductMessage& other) const { - return PigeonInternalDeepEquals(app_id_, other.app_id_) && PigeonInternalDeepEquals(country_code_, other.country_code_) && PigeonInternalDeepEquals(page_size_, other.page_size_) && PigeonInternalDeepEquals(page_num_, other.page_num_) && PigeonInternalDeepEquals(check_value_, other.check_value_); + return PigeonInternalDeepEquals(app_id_, other.app_id_) && + PigeonInternalDeepEquals(country_code_, other.country_code_) && + PigeonInternalDeepEquals(page_size_, other.page_size_) && + PigeonInternalDeepEquals(page_num_, other.page_num_) && + PigeonInternalDeepEquals(check_value_, other.check_value_); } bool ProductMessage::operator!=(const ProductMessage& other) const { @@ -1019,9 +989,7 @@ size_t ProductMessage::Hash() const { return result; } -std::ostream& operator<<( - std::ostream& os, - const ProductMessage& obj) { +std::ostream& operator<<(std::ostream& os, const ProductMessage& obj) { os << "ProductMessage("; os << "app_id: "; os << PigeonInternalToString(obj.app_id_); @@ -1037,42 +1005,33 @@ std::ostream& operator<<( return os; } -size_t PigeonInternalDeepHash(const ProductMessage& v) { - return v.Hash(); -} +size_t PigeonInternalDeepHash(const ProductMessage& v) { return v.Hash(); } // PurchaseMessage -PurchaseMessage::PurchaseMessage( - const std::string& app_id, - const std::string& custom_id, - const std::string& country_code, - int64_t page_num, - const std::string& check_value) - : app_id_(app_id), - custom_id_(custom_id), - country_code_(country_code), - page_num_(page_num), - check_value_(check_value) {} +PurchaseMessage::PurchaseMessage(const std::string& app_id, + const std::string& custom_id, + const std::string& country_code, + int64_t page_num, + const std::string& check_value) + : app_id_(app_id), + custom_id_(custom_id), + country_code_(country_code), + page_num_(page_num), + check_value_(check_value) {} -const std::string& PurchaseMessage::app_id() const { - return app_id_; -} +const std::string& PurchaseMessage::app_id() const { return app_id_; } void PurchaseMessage::set_app_id(std::string_view value_arg) { app_id_ = value_arg; } - -const std::string& PurchaseMessage::custom_id() const { - return custom_id_; -} +const std::string& PurchaseMessage::custom_id() const { return custom_id_; } void PurchaseMessage::set_custom_id(std::string_view value_arg) { custom_id_ = value_arg; } - const std::string& PurchaseMessage::country_code() const { return country_code_; } @@ -1081,25 +1040,16 @@ void PurchaseMessage::set_country_code(std::string_view value_arg) { country_code_ = value_arg; } +int64_t PurchaseMessage::page_num() const { return page_num_; } -int64_t PurchaseMessage::page_num() const { - return page_num_; -} - -void PurchaseMessage::set_page_num(int64_t value_arg) { - page_num_ = value_arg; -} - +void PurchaseMessage::set_page_num(int64_t value_arg) { page_num_ = value_arg; } -const std::string& PurchaseMessage::check_value() const { - return check_value_; -} +const std::string& PurchaseMessage::check_value() const { return check_value_; } void PurchaseMessage::set_check_value(std::string_view value_arg) { check_value_ = value_arg; } - EncodableList PurchaseMessage::ToEncodableList() const { EncodableList list; list.reserve(5); @@ -1113,16 +1063,18 @@ EncodableList PurchaseMessage::ToEncodableList() const { PurchaseMessage PurchaseMessage::FromEncodableList(const EncodableList& list) { PurchaseMessage decoded( - std::get(list[0]), - std::get(list[1]), - std::get(list[2]), - std::get(list[3]), - std::get(list[4])); + std::get(list[0]), std::get(list[1]), + std::get(list[2]), std::get(list[3]), + std::get(list[4])); return decoded; } bool PurchaseMessage::operator==(const PurchaseMessage& other) const { - return PigeonInternalDeepEquals(app_id_, other.app_id_) && PigeonInternalDeepEquals(custom_id_, other.custom_id_) && PigeonInternalDeepEquals(country_code_, other.country_code_) && PigeonInternalDeepEquals(page_num_, other.page_num_) && PigeonInternalDeepEquals(check_value_, other.check_value_); + return PigeonInternalDeepEquals(app_id_, other.app_id_) && + PigeonInternalDeepEquals(custom_id_, other.custom_id_) && + PigeonInternalDeepEquals(country_code_, other.country_code_) && + PigeonInternalDeepEquals(page_num_, other.page_num_) && + PigeonInternalDeepEquals(check_value_, other.check_value_); } bool PurchaseMessage::operator!=(const PurchaseMessage& other) const { @@ -1139,9 +1091,7 @@ size_t PurchaseMessage::Hash() const { return result; } -std::ostream& operator<<( - std::ostream& os, - const PurchaseMessage& obj) { +std::ostream& operator<<(std::ostream& os, const PurchaseMessage& obj) { os << "PurchaseMessage("; os << "app_id: "; os << PigeonInternalToString(obj.app_id_); @@ -1157,23 +1107,20 @@ std::ostream& operator<<( return os; } -size_t PigeonInternalDeepHash(const PurchaseMessage& v) { - return v.Hash(); -} +size_t PigeonInternalDeepHash(const PurchaseMessage& v) { return v.Hash(); } // OrderDetails -OrderDetails::OrderDetails( - const std::string& order_item_id, - const std::string& order_title, - const std::string& order_total, - const std::string& order_currency_id, - const std::string& order_custom_id) - : order_item_id_(order_item_id), - order_title_(order_title), - order_total_(order_total), - order_currency_id_(order_currency_id), - order_custom_id_(order_custom_id) {} +OrderDetails::OrderDetails(const std::string& order_item_id, + const std::string& order_title, + const std::string& order_total, + const std::string& order_currency_id, + const std::string& order_custom_id) + : order_item_id_(order_item_id), + order_title_(order_title), + order_total_(order_total), + order_currency_id_(order_currency_id), + order_custom_id_(order_custom_id) {} const std::string& OrderDetails::order_item_id() const { return order_item_id_; @@ -1183,25 +1130,18 @@ void OrderDetails::set_order_item_id(std::string_view value_arg) { order_item_id_ = value_arg; } - -const std::string& OrderDetails::order_title() const { - return order_title_; -} +const std::string& OrderDetails::order_title() const { return order_title_; } void OrderDetails::set_order_title(std::string_view value_arg) { order_title_ = value_arg; } - -const std::string& OrderDetails::order_total() const { - return order_total_; -} +const std::string& OrderDetails::order_total() const { return order_total_; } void OrderDetails::set_order_total(std::string_view value_arg) { order_total_ = value_arg; } - const std::string& OrderDetails::order_currency_id() const { return order_currency_id_; } @@ -1210,7 +1150,6 @@ void OrderDetails::set_order_currency_id(std::string_view value_arg) { order_currency_id_ = value_arg; } - const std::string& OrderDetails::order_custom_id() const { return order_custom_id_; } @@ -1219,7 +1158,6 @@ void OrderDetails::set_order_custom_id(std::string_view value_arg) { order_custom_id_ = value_arg; } - EncodableList OrderDetails::ToEncodableList() const { EncodableList list; list.reserve(5); @@ -1233,16 +1171,19 @@ EncodableList OrderDetails::ToEncodableList() const { OrderDetails OrderDetails::FromEncodableList(const EncodableList& list) { OrderDetails decoded( - std::get(list[0]), - std::get(list[1]), - std::get(list[2]), - std::get(list[3]), - std::get(list[4])); + std::get(list[0]), std::get(list[1]), + std::get(list[2]), std::get(list[3]), + std::get(list[4])); return decoded; } bool OrderDetails::operator==(const OrderDetails& other) const { - return PigeonInternalDeepEquals(order_item_id_, other.order_item_id_) && PigeonInternalDeepEquals(order_title_, other.order_title_) && PigeonInternalDeepEquals(order_total_, other.order_total_) && PigeonInternalDeepEquals(order_currency_id_, other.order_currency_id_) && PigeonInternalDeepEquals(order_custom_id_, other.order_custom_id_); + return PigeonInternalDeepEquals(order_item_id_, other.order_item_id_) && + PigeonInternalDeepEquals(order_title_, other.order_title_) && + PigeonInternalDeepEquals(order_total_, other.order_total_) && + PigeonInternalDeepEquals(order_currency_id_, + other.order_currency_id_) && + PigeonInternalDeepEquals(order_custom_id_, other.order_custom_id_); } bool OrderDetails::operator!=(const OrderDetails& other) const { @@ -1259,9 +1200,7 @@ size_t OrderDetails::Hash() const { return result; } -std::ostream& operator<<( - std::ostream& os, - const OrderDetails& obj) { +std::ostream& operator<<(std::ostream& os, const OrderDetails& obj) { os << "OrderDetails("; os << "order_item_id: "; os << PigeonInternalToString(obj.order_item_id_); @@ -1277,21 +1216,18 @@ std::ostream& operator<<( return os; } -size_t PigeonInternalDeepHash(const OrderDetails& v) { - return v.Hash(); -} +size_t PigeonInternalDeepHash(const OrderDetails& v) { return v.Hash(); } // BuyInfoMessage -BuyInfoMessage::BuyInfoMessage( - const std::string& app_id, - const OrderDetails& pay_detials) - : app_id_(app_id), - pay_detials_(std::make_unique(pay_detials)) {} +BuyInfoMessage::BuyInfoMessage(const std::string& app_id, + const OrderDetails& pay_detials) + : app_id_(app_id), + pay_detials_(std::make_unique(pay_detials)) {} BuyInfoMessage::BuyInfoMessage(const BuyInfoMessage& other) - : app_id_(other.app_id_), - pay_detials_(std::make_unique(*other.pay_detials_)) {} + : app_id_(other.app_id_), + pay_detials_(std::make_unique(*other.pay_detials_)) {} BuyInfoMessage& BuyInfoMessage::operator=(const BuyInfoMessage& other) { app_id_ = other.app_id_; @@ -1299,15 +1235,12 @@ BuyInfoMessage& BuyInfoMessage::operator=(const BuyInfoMessage& other) { return *this; } -const std::string& BuyInfoMessage::app_id() const { - return app_id_; -} +const std::string& BuyInfoMessage::app_id() const { return app_id_; } void BuyInfoMessage::set_app_id(std::string_view value_arg) { app_id_ = value_arg; } - const OrderDetails& BuyInfoMessage::pay_detials() const { return *pay_detials_; } @@ -1316,7 +1249,6 @@ void BuyInfoMessage::set_pay_detials(const OrderDetails& value_arg) { pay_detials_ = std::make_unique(value_arg); } - EncodableList BuyInfoMessage::ToEncodableList() const { EncodableList list; list.reserve(2); @@ -1326,14 +1258,15 @@ EncodableList BuyInfoMessage::ToEncodableList() const { } BuyInfoMessage BuyInfoMessage::FromEncodableList(const EncodableList& list) { - BuyInfoMessage decoded( - std::get(list[0]), - std::any_cast(std::get(list[1]))); + BuyInfoMessage decoded(std::get(list[0]), + std::any_cast( + std::get(list[1]))); return decoded; } bool BuyInfoMessage::operator==(const BuyInfoMessage& other) const { - return PigeonInternalDeepEquals(app_id_, other.app_id_) && PigeonInternalDeepEquals(pay_detials_, other.pay_detials_); + return PigeonInternalDeepEquals(app_id_, other.app_id_) && + PigeonInternalDeepEquals(pay_detials_, other.pay_detials_); } bool BuyInfoMessage::operator!=(const BuyInfoMessage& other) const { @@ -1347,9 +1280,7 @@ size_t BuyInfoMessage::Hash() const { return result; } -std::ostream& operator<<( - std::ostream& os, - const BuyInfoMessage& obj) { +std::ostream& operator<<(std::ostream& os, const BuyInfoMessage& obj) { os << "BuyInfoMessage("; os << "app_id: "; os << PigeonInternalToString(obj.app_id_); @@ -1359,49 +1290,37 @@ std::ostream& operator<<( return os; } -size_t PigeonInternalDeepHash(const BuyInfoMessage& v) { - return v.Hash(); -} +size_t PigeonInternalDeepHash(const BuyInfoMessage& v) { return v.Hash(); } // InvoiceMessage -InvoiceMessage::InvoiceMessage( - const std::string& app_id, - const std::string& custom_id, - const std::string& invoice_id, - const std::string& country_code) - : app_id_(app_id), - custom_id_(custom_id), - invoice_id_(invoice_id), - country_code_(country_code) {} +InvoiceMessage::InvoiceMessage(const std::string& app_id, + const std::string& custom_id, + const std::string& invoice_id, + const std::string& country_code) + : app_id_(app_id), + custom_id_(custom_id), + invoice_id_(invoice_id), + country_code_(country_code) {} -const std::string& InvoiceMessage::app_id() const { - return app_id_; -} +const std::string& InvoiceMessage::app_id() const { return app_id_; } void InvoiceMessage::set_app_id(std::string_view value_arg) { app_id_ = value_arg; } - -const std::string& InvoiceMessage::custom_id() const { - return custom_id_; -} +const std::string& InvoiceMessage::custom_id() const { return custom_id_; } void InvoiceMessage::set_custom_id(std::string_view value_arg) { custom_id_ = value_arg; } - -const std::string& InvoiceMessage::invoice_id() const { - return invoice_id_; -} +const std::string& InvoiceMessage::invoice_id() const { return invoice_id_; } void InvoiceMessage::set_invoice_id(std::string_view value_arg) { invoice_id_ = value_arg; } - const std::string& InvoiceMessage::country_code() const { return country_code_; } @@ -1410,7 +1329,6 @@ void InvoiceMessage::set_country_code(std::string_view value_arg) { country_code_ = value_arg; } - EncodableList InvoiceMessage::ToEncodableList() const { EncodableList list; list.reserve(4); @@ -1423,15 +1341,16 @@ EncodableList InvoiceMessage::ToEncodableList() const { InvoiceMessage InvoiceMessage::FromEncodableList(const EncodableList& list) { InvoiceMessage decoded( - std::get(list[0]), - std::get(list[1]), - std::get(list[2]), - std::get(list[3])); + std::get(list[0]), std::get(list[1]), + std::get(list[2]), std::get(list[3])); return decoded; } bool InvoiceMessage::operator==(const InvoiceMessage& other) const { - return PigeonInternalDeepEquals(app_id_, other.app_id_) && PigeonInternalDeepEquals(custom_id_, other.custom_id_) && PigeonInternalDeepEquals(invoice_id_, other.invoice_id_) && PigeonInternalDeepEquals(country_code_, other.country_code_); + return PigeonInternalDeepEquals(app_id_, other.app_id_) && + PigeonInternalDeepEquals(custom_id_, other.custom_id_) && + PigeonInternalDeepEquals(invoice_id_, other.invoice_id_) && + PigeonInternalDeepEquals(country_code_, other.country_code_); } bool InvoiceMessage::operator!=(const InvoiceMessage& other) const { @@ -1447,9 +1366,7 @@ size_t InvoiceMessage::Hash() const { return result; } -std::ostream& operator<<( - std::ostream& os, - const InvoiceMessage& obj) { +std::ostream& operator<<(std::ostream& os, const InvoiceMessage& obj) { os << "InvoiceMessage("; os << "app_id: "; os << PigeonInternalToString(obj.app_id_); @@ -1463,104 +1380,141 @@ std::ostream& operator<<( return os; } -size_t PigeonInternalDeepHash(const InvoiceMessage& v) { - return v.Hash(); -} - +size_t PigeonInternalDeepHash(const InvoiceMessage& v) { return v.Hash(); } PigeonInternalCodecSerializer::PigeonInternalCodecSerializer() {} EncodableValue PigeonInternalCodecSerializer::ReadValueOfType( - uint8_t type, - ::flutter::ByteStreamReader* stream) const { + uint8_t type, ::flutter::ByteStreamReader* stream) const { switch (type) { case 129: { - return CustomEncodableValue(ProductsListApiResult::FromEncodableList(std::get(ReadValue(stream)))); - } + return CustomEncodableValue(ProductsListApiResult::FromEncodableList( + std::get(ReadValue(stream)))); + } case 130: { - return CustomEncodableValue(GetUserPurchaseListAPIResult::FromEncodableList(std::get(ReadValue(stream)))); - } + return CustomEncodableValue( + GetUserPurchaseListAPIResult::FromEncodableList( + std::get(ReadValue(stream)))); + } case 131: { - return CustomEncodableValue(BillingBuyData::FromEncodableList(std::get(ReadValue(stream)))); - } + return CustomEncodableValue(BillingBuyData::FromEncodableList( + std::get(ReadValue(stream)))); + } case 132: { - return CustomEncodableValue(VerifyInvoiceAPIResult::FromEncodableList(std::get(ReadValue(stream)))); - } + return CustomEncodableValue(VerifyInvoiceAPIResult::FromEncodableList( + std::get(ReadValue(stream)))); + } case 133: { - return CustomEncodableValue(ServiceAvailableAPIResult::FromEncodableList(std::get(ReadValue(stream)))); - } + return CustomEncodableValue(ServiceAvailableAPIResult::FromEncodableList( + std::get(ReadValue(stream)))); + } case 134: { - return CustomEncodableValue(ProductMessage::FromEncodableList(std::get(ReadValue(stream)))); - } + return CustomEncodableValue(ProductMessage::FromEncodableList( + std::get(ReadValue(stream)))); + } case 135: { - return CustomEncodableValue(PurchaseMessage::FromEncodableList(std::get(ReadValue(stream)))); - } + return CustomEncodableValue(PurchaseMessage::FromEncodableList( + std::get(ReadValue(stream)))); + } case 136: { - return CustomEncodableValue(OrderDetails::FromEncodableList(std::get(ReadValue(stream)))); - } + return CustomEncodableValue(OrderDetails::FromEncodableList( + std::get(ReadValue(stream)))); + } case 137: { - return CustomEncodableValue(BuyInfoMessage::FromEncodableList(std::get(ReadValue(stream)))); - } + return CustomEncodableValue(BuyInfoMessage::FromEncodableList( + std::get(ReadValue(stream)))); + } case 138: { - return CustomEncodableValue(InvoiceMessage::FromEncodableList(std::get(ReadValue(stream)))); - } + return CustomEncodableValue(InvoiceMessage::FromEncodableList( + std::get(ReadValue(stream)))); + } default: return ::flutter::StandardCodecSerializer::ReadValueOfType(type, stream); - } + } } void PigeonInternalCodecSerializer::WriteValue( - const EncodableValue& value, - ::flutter::ByteStreamWriter* stream) const { - if (const CustomEncodableValue* custom_value = std::get_if(&value)) { + const EncodableValue& value, ::flutter::ByteStreamWriter* stream) const { + if (const CustomEncodableValue* custom_value = + std::get_if(&value)) { if (custom_value->type() == typeid(ProductsListApiResult)) { stream->WriteByte(129); - WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); + WriteValue( + EncodableValue(std::any_cast(*custom_value) + .ToEncodableList()), + stream); return; } if (custom_value->type() == typeid(GetUserPurchaseListAPIResult)) { stream->WriteByte(130); - WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); + WriteValue(EncodableValue( + std::any_cast(*custom_value) + .ToEncodableList()), + stream); return; } if (custom_value->type() == typeid(BillingBuyData)) { stream->WriteByte(131); - WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); + WriteValue( + EncodableValue( + std::any_cast(*custom_value).ToEncodableList()), + stream); return; } if (custom_value->type() == typeid(VerifyInvoiceAPIResult)) { stream->WriteByte(132); - WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); + WriteValue( + EncodableValue(std::any_cast(*custom_value) + .ToEncodableList()), + stream); return; } if (custom_value->type() == typeid(ServiceAvailableAPIResult)) { stream->WriteByte(133); - WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); + WriteValue( + EncodableValue(std::any_cast(*custom_value) + .ToEncodableList()), + stream); return; } if (custom_value->type() == typeid(ProductMessage)) { stream->WriteByte(134); - WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); + WriteValue( + EncodableValue( + std::any_cast(*custom_value).ToEncodableList()), + stream); return; } if (custom_value->type() == typeid(PurchaseMessage)) { stream->WriteByte(135); - WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); + WriteValue( + EncodableValue( + std::any_cast(*custom_value).ToEncodableList()), + stream); return; } if (custom_value->type() == typeid(OrderDetails)) { stream->WriteByte(136); - WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); + WriteValue( + EncodableValue( + std::any_cast(*custom_value).ToEncodableList()), + stream); return; } if (custom_value->type() == typeid(BuyInfoMessage)) { stream->WriteByte(137); - WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); + WriteValue( + EncodableValue( + std::any_cast(*custom_value).ToEncodableList()), + stream); return; } if (custom_value->type() == typeid(InvoiceMessage)) { stream->WriteByte(138); - WriteValue(EncodableValue(std::any_cast(*custom_value).ToEncodableList()), stream); + WriteValue( + EncodableValue( + std::any_cast(*custom_value).ToEncodableList()), + stream); return; } } @@ -1569,197 +1523,285 @@ void PigeonInternalCodecSerializer::WriteValue( /// The codec used by InAppPurchaseApi. const ::flutter::StandardMessageCodec& InAppPurchaseApi::GetCodec() { - return ::flutter::StandardMessageCodec::GetInstance(&PigeonInternalCodecSerializer::GetInstance()); + return ::flutter::StandardMessageCodec::GetInstance( + &PigeonInternalCodecSerializer::GetInstance()); } -// Sets up an instance of `InAppPurchaseApi` to handle messages through the `binary_messenger`. -void InAppPurchaseApi::SetUp( - ::flutter::BinaryMessenger* binary_messenger, - InAppPurchaseApi* api) { +// Sets up an instance of `InAppPurchaseApi` to handle messages through the +// `binary_messenger`. +void InAppPurchaseApi::SetUp(::flutter::BinaryMessenger* binary_messenger, + InAppPurchaseApi* api) { InAppPurchaseApi::SetUp(binary_messenger, api, ""); } -void InAppPurchaseApi::SetUp( - ::flutter::BinaryMessenger* binary_messenger, - InAppPurchaseApi* api, - const std::string& message_channel_suffix) { - const std::string prepended_suffix = message_channel_suffix.length() > 0 ? std::string(".") + message_channel_suffix : ""; +void InAppPurchaseApi::SetUp(::flutter::BinaryMessenger* binary_messenger, + InAppPurchaseApi* api, + const std::string& message_channel_suffix) { + const std::string prepended_suffix = + message_channel_suffix.length() > 0 + ? std::string(".") + message_channel_suffix + : ""; { - BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.getProductsList" + prepended_suffix, &GetCodec()); + BasicMessageChannel<> channel( + binary_messenger, + "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.initialize" + + prepended_suffix, + &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_product_arg = args.at(0); - if (encodable_product_arg.IsNull()) { - reply(WrapError("product_arg unexpectedly null.")); - return; - } - const auto& product_arg = std::any_cast(std::get(encodable_product_arg)); - api->GetProductsList(product_arg, [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; + channel.SetMessageHandler( + [api](const EncodableValue& message, + const ::flutter::MessageReply& reply) { + try { + std::optional output = api->Initialize(); + if (output.has_value()) { + reply(WrapError(output.value())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue()); + reply(EncodableValue(std::move(wrapped))); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); } - EncodableList wrapped; - wrapped.push_back(CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.getUserPurchaseList" + prepended_suffix, &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, + "dev.flutter.pigeon.in_app_purchase_tizen." + "InAppPurchaseApi.getProductsList" + + prepended_suffix, + &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_purchase_arg = args.at(0); - if (encodable_purchase_arg.IsNull()) { - reply(WrapError("purchase_arg unexpectedly null.")); - return; - } - const auto& purchase_arg = std::any_cast(std::get(encodable_purchase_arg)); - api->GetUserPurchaseList(purchase_arg, [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; + channel.SetMessageHandler( + [api](const EncodableValue& message, + const ::flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_product_arg = args.at(0); + if (encodable_product_arg.IsNull()) { + reply(WrapError("product_arg unexpectedly null.")); + return; + } + const auto& product_arg = std::any_cast( + std::get(encodable_product_arg)); + api->GetProductsList( + product_arg, + [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back( + CustomEncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); } - EncodableList wrapped; - wrapped.push_back(CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.buyItem" + prepended_suffix, &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, + "dev.flutter.pigeon.in_app_purchase_tizen." + "InAppPurchaseApi.getUserPurchaseList" + + prepended_suffix, + &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_buy_info_arg = args.at(0); - if (encodable_buy_info_arg.IsNull()) { - reply(WrapError("buy_info_arg unexpectedly null.")); - return; - } - const auto& buy_info_arg = std::any_cast(std::get(encodable_buy_info_arg)); - api->BuyItem(buy_info_arg, [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; + channel.SetMessageHandler( + [api](const EncodableValue& message, + const ::flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_purchase_arg = args.at(0); + if (encodable_purchase_arg.IsNull()) { + reply(WrapError("purchase_arg unexpectedly null.")); + return; + } + const auto& purchase_arg = std::any_cast( + std::get(encodable_purchase_arg)); + api->GetUserPurchaseList( + purchase_arg, + [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back( + CustomEncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); } - EncodableList wrapped; - wrapped.push_back(CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.verifyInvoice" + prepended_suffix, &GetCodec()); + BasicMessageChannel<> channel( + binary_messenger, + "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.buyItem" + + prepended_suffix, + &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) { - try { - const auto& args = std::get(message); - const auto& encodable_invoice_arg = args.at(0); - if (encodable_invoice_arg.IsNull()) { - reply(WrapError("invoice_arg unexpectedly null.")); - return; - } - const auto& invoice_arg = std::any_cast(std::get(encodable_invoice_arg)); - api->VerifyInvoice(invoice_arg, [reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; + channel.SetMessageHandler( + [api](const EncodableValue& message, + const ::flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_buy_info_arg = args.at(0); + if (encodable_buy_info_arg.IsNull()) { + reply(WrapError("buy_info_arg unexpectedly null.")); + return; + } + const auto& buy_info_arg = std::any_cast( + std::get(encodable_buy_info_arg)); + api->BuyItem( + buy_info_arg, [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back( + CustomEncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); } - EncodableList wrapped; - wrapped.push_back(CustomEncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.isServiceAvailable" + prepended_suffix, &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, + "dev.flutter.pigeon.in_app_purchase_tizen." + "InAppPurchaseApi.verifyInvoice" + + prepended_suffix, + &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) { - try { - api->IsServiceAvailable([reply](ErrorOr&& output) { - if (output.has_error()) { - reply(WrapError(output.error())); - return; + channel.SetMessageHandler( + [api](const EncodableValue& message, + const ::flutter::MessageReply& reply) { + try { + const auto& args = std::get(message); + const auto& encodable_invoice_arg = args.at(0); + if (encodable_invoice_arg.IsNull()) { + reply(WrapError("invoice_arg unexpectedly null.")); + return; + } + const auto& invoice_arg = std::any_cast( + std::get(encodable_invoice_arg)); + api->VerifyInvoice( + invoice_arg, + [reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back( + CustomEncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); }); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.getCustomId" + prepended_suffix, &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, + "dev.flutter.pigeon.in_app_purchase_tizen." + "InAppPurchaseApi.isServiceAvailable" + + prepended_suffix, + &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) { - try { - ErrorOr output = api->GetCustomId(); - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); + channel.SetMessageHandler( + [api](const EncodableValue& message, + const ::flutter::MessageReply& reply) { + try { + api->IsServiceAvailable([reply](ErrorOr&& output) { + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back( + EncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + }); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } } { - BasicMessageChannel<> channel(binary_messenger, "dev.flutter.pigeon.in_app_purchase_tizen.InAppPurchaseApi.getCountryCode" + prepended_suffix, &GetCodec()); + BasicMessageChannel<> channel(binary_messenger, + "dev.flutter.pigeon.in_app_purchase_tizen." + "InAppPurchaseApi.getCustomId" + + prepended_suffix, + &GetCodec()); if (api != nullptr) { - channel.SetMessageHandler([api](const EncodableValue& message, const ::flutter::MessageReply& reply) { - try { - ErrorOr output = api->GetCountryCode(); - if (output.has_error()) { - reply(WrapError(output.error())); - return; - } - EncodableList wrapped; - wrapped.push_back(EncodableValue(std::move(output).TakeValue())); - reply(EncodableValue(std::move(wrapped))); - } catch (const std::exception& exception) { - reply(WrapError(exception.what())); - } - }); + channel.SetMessageHandler( + [api](const EncodableValue& message, + const ::flutter::MessageReply& reply) { + try { + ErrorOr output = api->GetCustomId(); + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); + } else { + channel.SetMessageHandler(nullptr); + } + } + { + BasicMessageChannel<> channel(binary_messenger, + "dev.flutter.pigeon.in_app_purchase_tizen." + "InAppPurchaseApi.getCountryCode" + + prepended_suffix, + &GetCodec()); + if (api != nullptr) { + channel.SetMessageHandler( + [api](const EncodableValue& message, + const ::flutter::MessageReply& reply) { + try { + ErrorOr output = api->GetCountryCode(); + if (output.has_error()) { + reply(WrapError(output.error())); + return; + } + EncodableList wrapped; + wrapped.push_back(EncodableValue(std::move(output).TakeValue())); + reply(EncodableValue(std::move(wrapped))); + } catch (const std::exception& exception) { + reply(WrapError(exception.what())); + } + }); } else { channel.SetMessageHandler(nullptr); } @@ -1767,19 +1809,15 @@ void InAppPurchaseApi::SetUp( } EncodableValue InAppPurchaseApi::WrapError(std::string_view error_message) { - return EncodableValue(EncodableList{ - EncodableValue(std::string(error_message)), - EncodableValue("Error"), - EncodableValue() - }); + return EncodableValue( + EncodableList{EncodableValue(std::string(error_message)), + EncodableValue("Error"), EncodableValue()}); } EncodableValue InAppPurchaseApi::WrapError(const FlutterError& error) { - return EncodableValue(EncodableList{ - EncodableValue(error.code()), - EncodableValue(error.message()), - error.details() - }); + return EncodableValue(EncodableList{EncodableValue(error.code()), + EncodableValue(error.message()), + error.details()}); } } // namespace in_app_purchase_tizen diff --git a/packages/in_app_purchase/tizen/src/messages.h b/packages/in_app_purchase/tizen/src/messages.h index 00f2da770..08e8f6cd1 100644 --- a/packages/in_app_purchase/tizen/src/messages.h +++ b/packages/in_app_purchase/tizen/src/messages.h @@ -15,17 +15,16 @@ namespace in_app_purchase_tizen { - // Generated class from Pigeon. class FlutterError { public: - explicit FlutterError(const std::string& code) - : code_(code) {} + explicit FlutterError(const std::string& code) : code_(code) {} explicit FlutterError(const std::string& code, const std::string& message) - : code_(code), message_(message) {} - explicit FlutterError(const std::string& code, const std::string& message, const ::flutter::EncodableValue& details) - : code_(code), message_(message), details_(details) {} + : code_(code), message_(message) {} + explicit FlutterError(const std::string& code, const std::string& message, + const ::flutter::EncodableValue& details) + : code_(code), message_(message), details_(details) {} const std::string& code() const { return code_; } const std::string& message() const { return message_; } @@ -37,7 +36,8 @@ class FlutterError { ::flutter::EncodableValue details_; }; -template class ErrorOr { +template +class ErrorOr { public: ErrorOr(const T& rhs) : v_(rhs) {} ErrorOr(const T&& rhs) : v_(std::move(rhs)) {} @@ -56,30 +56,27 @@ template class ErrorOr { std::variant v_; }; - - -// Dart wrapper around [`ProductsListApiResult`] in (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). +// Dart wrapper around [`ProductsListApiResult`] in +// (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). // -// Defines a dictionary for product list data returned by the getProductsList API. -// This only can be used in [BillingManager.requestProducts]. +// Defines a dictionary for product list data returned by the getProductsList +// API. This only can be used in [BillingManager.requestProducts]. // // Generated class from Pigeon that represents data sent in messages. class ProductsListApiResult { public: // Constructs an object setting all non-nullable fields. - explicit ProductsListApiResult( - const std::string& cp_status, - int64_t total_count, - const std::string& check_value, - const ::flutter::EncodableList& item_details); + explicit ProductsListApiResult(const std::string& cp_status, + int64_t total_count, + const std::string& check_value, + const ::flutter::EncodableList& item_details); // Constructs an object setting all fields. - explicit ProductsListApiResult( - const std::string& cp_status, - const std::string* cp_result, - int64_t total_count, - const std::string& check_value, - const ::flutter::EncodableList& item_details); + explicit ProductsListApiResult(const std::string& cp_status, + const std::string* cp_result, + int64_t total_count, + const std::string& check_value, + const ::flutter::EncodableList& item_details); // DPI result code. // Returns "100000" on success and other codes on failure. @@ -108,12 +105,16 @@ class ProductsListApiResult { bool operator==(const ProductsListApiResult& other) const; bool operator!=(const ProductsListApiResult& other) const; - /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + /// Returns a hash code value for the object. This method is supported for the + /// benefit of hash tables. size_t Hash() const; /// Stream output operator for formatted string representation. - friend std::ostream& operator<<(std::ostream& os, const ProductsListApiResult& obj); + friend std::ostream& operator<<(std::ostream& os, + const ProductsListApiResult& obj); + private: - static ProductsListApiResult FromEncodableList(const ::flutter::EncodableList& list); + static ProductsListApiResult FromEncodableList( + const ::flutter::EncodableList& list); ::flutter::EncodableList ToEncodableList() const; friend class InAppPurchaseApi; friend class PigeonInternalCodecSerializer; @@ -124,8 +125,8 @@ class ProductsListApiResult { ::flutter::EncodableList item_details_; }; - -// Dart wrapper around [`GetUserPurchaseListAPIResult`] in (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). +// Dart wrapper around [`GetUserPurchaseListAPIResult`] in +// (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). // // Defines a dictionary for data returned by the getUserPurchaseList API. // This only can be used in [BillingManager.requestPurchases] @@ -135,20 +136,18 @@ class GetUserPurchaseListAPIResult { public: // Constructs an object setting all non-nullable fields. explicit GetUserPurchaseListAPIResult( - const std::string& cp_status, - int64_t total_count, - const std::string& check_value, - const ::flutter::EncodableList& invoice_details); + const std::string& cp_status, int64_t total_count, + const std::string& check_value, + const ::flutter::EncodableList& invoice_details); // Constructs an object setting all fields. explicit GetUserPurchaseListAPIResult( - const std::string& cp_status, - const std::string* cp_result, - int64_t total_count, - const std::string& check_value, - const ::flutter::EncodableList& invoice_details); + const std::string& cp_status, const std::string* cp_result, + int64_t total_count, const std::string& check_value, + const ::flutter::EncodableList& invoice_details); - // It returns "100000" in success and other codes in failure. Refer to DPI Error Code. + // It returns "100000" in success and other codes in failure. Refer to DPI + // Error Code. const std::string& cp_status() const; void set_cp_status(std::string_view value_arg); @@ -174,12 +173,16 @@ class GetUserPurchaseListAPIResult { bool operator==(const GetUserPurchaseListAPIResult& other) const; bool operator!=(const GetUserPurchaseListAPIResult& other) const; - /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + /// Returns a hash code value for the object. This method is supported for the + /// benefit of hash tables. size_t Hash() const; /// Stream output operator for formatted string representation. - friend std::ostream& operator<<(std::ostream& os, const GetUserPurchaseListAPIResult& obj); + friend std::ostream& operator<<(std::ostream& os, + const GetUserPurchaseListAPIResult& obj); + private: - static GetUserPurchaseListAPIResult FromEncodableList(const ::flutter::EncodableList& list); + static GetUserPurchaseListAPIResult FromEncodableList( + const ::flutter::EncodableList& list); ::flutter::EncodableList ToEncodableList() const; friend class InAppPurchaseApi; friend class PigeonInternalCodecSerializer; @@ -190,8 +193,8 @@ class GetUserPurchaseListAPIResult { ::flutter::EncodableList invoice_details_; }; - -// Dart wrapper around [`BillingBuyData`](https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html#BillingBuyData). +// Dart wrapper around +// [`BillingBuyData`](https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html#BillingBuyData). // // Defines the payment result and information. // @@ -199,9 +202,8 @@ class GetUserPurchaseListAPIResult { class BillingBuyData { public: // Constructs an object setting all fields. - explicit BillingBuyData( - const std::string& pay_result, - const ::flutter::EncodableMap& pay_details); + explicit BillingBuyData(const std::string& pay_result, + const ::flutter::EncodableMap& pay_details); // The payment result const std::string& pay_result() const; @@ -213,10 +215,12 @@ class BillingBuyData { bool operator==(const BillingBuyData& other) const; bool operator!=(const BillingBuyData& other) const; - /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + /// Returns a hash code value for the object. This method is supported for the + /// benefit of hash tables. size_t Hash() const; /// Stream output operator for formatted string representation. friend std::ostream& operator<<(std::ostream& os, const BillingBuyData& obj); + private: static BillingBuyData FromEncodableList(const ::flutter::EncodableList& list); ::flutter::EncodableList ToEncodableList() const; @@ -226,8 +230,8 @@ class BillingBuyData { ::flutter::EncodableMap pay_details_; }; - -// Dart wrapper around [`VerifyInvoiceAPIResult`] in (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). +// Dart wrapper around [`VerifyInvoiceAPIResult`] in +// (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). // // This only can be used in [BillingManager.verifyInvoice]. // @@ -235,17 +239,15 @@ class BillingBuyData { class VerifyInvoiceAPIResult { public: // Constructs an object setting all non-nullable fields. - explicit VerifyInvoiceAPIResult( - const std::string& cp_status, - const std::string& app_id, - const std::string& invoice_id); + explicit VerifyInvoiceAPIResult(const std::string& cp_status, + const std::string& app_id, + const std::string& invoice_id); // Constructs an object setting all fields. - explicit VerifyInvoiceAPIResult( - const std::string& cp_status, - const std::string* cp_result, - const std::string& app_id, - const std::string& invoice_id); + explicit VerifyInvoiceAPIResult(const std::string& cp_status, + const std::string* cp_result, + const std::string& app_id, + const std::string& invoice_id); // DPI result code. Returns "100000" on success and other codes on failure. const std::string& cp_status() const; @@ -267,12 +269,16 @@ class VerifyInvoiceAPIResult { bool operator==(const VerifyInvoiceAPIResult& other) const; bool operator!=(const VerifyInvoiceAPIResult& other) const; - /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + /// Returns a hash code value for the object. This method is supported for the + /// benefit of hash tables. size_t Hash() const; /// Stream output operator for formatted string representation. - friend std::ostream& operator<<(std::ostream& os, const VerifyInvoiceAPIResult& obj); + friend std::ostream& operator<<(std::ostream& os, + const VerifyInvoiceAPIResult& obj); + private: - static VerifyInvoiceAPIResult FromEncodableList(const ::flutter::EncodableList& list); + static VerifyInvoiceAPIResult FromEncodableList( + const ::flutter::EncodableList& list); ::flutter::EncodableList ToEncodableList() const; friend class InAppPurchaseApi; friend class PigeonInternalCodecSerializer; @@ -282,8 +288,8 @@ class VerifyInvoiceAPIResult { std::string invoice_id_; }; - -// Dart wrapper around [`ServiceAvailableAPIResult`] in (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). +// Dart wrapper around [`ServiceAvailableAPIResult`] in +// (https://developer.samsung.com/smarttv/develop/api-references/samsung-product-api-references/billing-api.html). // // Defines a dictionary for data returned by the IsServiceAvailable API. // This only can be used in [BillingManager.isAvailable]. @@ -292,10 +298,9 @@ class VerifyInvoiceAPIResult { class ServiceAvailableAPIResult { public: // Constructs an object setting all fields. - explicit ServiceAvailableAPIResult( - const std::string& status, - const std::string& result, - const std::string& service_yn); + explicit ServiceAvailableAPIResult(const std::string& status, + const std::string& result, + const std::string& service_yn); // The result code of connecting to billing server. // Returns "100000" on success and other codes on failure. @@ -314,12 +319,16 @@ class ServiceAvailableAPIResult { bool operator==(const ServiceAvailableAPIResult& other) const; bool operator!=(const ServiceAvailableAPIResult& other) const; - /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + /// Returns a hash code value for the object. This method is supported for the + /// benefit of hash tables. size_t Hash() const; /// Stream output operator for formatted string representation. - friend std::ostream& operator<<(std::ostream& os, const ServiceAvailableAPIResult& obj); + friend std::ostream& operator<<(std::ostream& os, + const ServiceAvailableAPIResult& obj); + private: - static ServiceAvailableAPIResult FromEncodableList(const ::flutter::EncodableList& list); + static ServiceAvailableAPIResult FromEncodableList( + const ::flutter::EncodableList& list); ::flutter::EncodableList ToEncodableList() const; friend class InAppPurchaseApi; friend class PigeonInternalCodecSerializer; @@ -328,17 +337,13 @@ class ServiceAvailableAPIResult { std::string service_yn_; }; - // Generated class from Pigeon that represents data sent in messages. class ProductMessage { public: // Constructs an object setting all fields. - explicit ProductMessage( - const std::string& app_id, - const std::string& country_code, - int64_t page_size, - int64_t page_num, - const std::string& check_value); + explicit ProductMessage(const std::string& app_id, + const std::string& country_code, int64_t page_size, + int64_t page_num, const std::string& check_value); // Application ID. const std::string& app_id() const; @@ -358,16 +363,19 @@ class ProductMessage { // Security check value. Required parameters = "appId" + "countryCode". // The check value is used by the DPI service to verify API requests. - // It is a Base64 hash generated by applying the HMAC SHA256 algorithm on a concatenated string of parameters using the DPI security key. + // It is a Base64 hash generated by applying the HMAC SHA256 algorithm on a + // concatenated string of parameters using the DPI security key. const std::string& check_value() const; void set_check_value(std::string_view value_arg); bool operator==(const ProductMessage& other) const; bool operator!=(const ProductMessage& other) const; - /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + /// Returns a hash code value for the object. This method is supported for the + /// benefit of hash tables. size_t Hash() const; /// Stream output operator for formatted string representation. friend std::ostream& operator<<(std::ostream& os, const ProductMessage& obj); + private: static ProductMessage FromEncodableList(const ::flutter::EncodableList& list); ::flutter::EncodableList ToEncodableList() const; @@ -380,23 +388,21 @@ class ProductMessage { std::string check_value_; }; - // Generated class from Pigeon that represents data sent in messages. class PurchaseMessage { public: // Constructs an object setting all fields. - explicit PurchaseMessage( - const std::string& app_id, - const std::string& custom_id, - const std::string& country_code, - int64_t page_num, - const std::string& check_value); + explicit PurchaseMessage(const std::string& app_id, + const std::string& custom_id, + const std::string& country_code, int64_t page_num, + const std::string& check_value); // Application ID. const std::string& app_id() const; void set_app_id(std::string_view value_arg); - // Same value as "OrderCustomID" parameter for the BuyItem API (Samsung Account UID) + // Same value as "OrderCustomID" parameter for the BuyItem API (Samsung + // Account UID) const std::string& custom_id() const; void set_custom_id(std::string_view value_arg); @@ -408,19 +414,23 @@ class PurchaseMessage { int64_t page_num() const; void set_page_num(int64_t value_arg); - // Security check value. Required parameters = "appId" + "customId" + "countryCode" + "ItemType" + "pageNumber". - // ItemType, MUST use 2 as value ("all items") + // Security check value. Required parameters = "appId" + "customId" + + // "countryCode" + "ItemType" + "pageNumber". ItemType, MUST use 2 as value + // ("all items") const std::string& check_value() const; void set_check_value(std::string_view value_arg); bool operator==(const PurchaseMessage& other) const; bool operator!=(const PurchaseMessage& other) const; - /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + /// Returns a hash code value for the object. This method is supported for the + /// benefit of hash tables. size_t Hash() const; /// Stream output operator for formatted string representation. friend std::ostream& operator<<(std::ostream& os, const PurchaseMessage& obj); + private: - static PurchaseMessage FromEncodableList(const ::flutter::EncodableList& list); + static PurchaseMessage FromEncodableList( + const ::flutter::EncodableList& list); ::flutter::EncodableList ToEncodableList() const; friend class InAppPurchaseApi; friend class PigeonInternalCodecSerializer; @@ -431,17 +441,15 @@ class PurchaseMessage { std::string check_value_; }; - // Generated class from Pigeon that represents data sent in messages. class OrderDetails { public: // Constructs an object setting all fields. - explicit OrderDetails( - const std::string& order_item_id, - const std::string& order_title, - const std::string& order_total, - const std::string& order_currency_id, - const std::string& order_custom_id); + explicit OrderDetails(const std::string& order_item_id, + const std::string& order_title, + const std::string& order_total, + const std::string& order_currency_id, + const std::string& order_custom_id); const std::string& order_item_id() const; void set_order_item_id(std::string_view value_arg); @@ -460,10 +468,12 @@ class OrderDetails { bool operator==(const OrderDetails& other) const; bool operator!=(const OrderDetails& other) const; - /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + /// Returns a hash code value for the object. This method is supported for the + /// benefit of hash tables. size_t Hash() const; /// Stream output operator for formatted string representation. friend std::ostream& operator<<(std::ostream& os, const OrderDetails& obj); + private: static OrderDetails FromEncodableList(const ::flutter::EncodableList& list); ::flutter::EncodableList ToEncodableList() const; @@ -477,14 +487,12 @@ class OrderDetails { std::string order_custom_id_; }; - // Generated class from Pigeon that represents data sent in messages. class BuyInfoMessage { public: // Constructs an object setting all fields. - explicit BuyInfoMessage( - const std::string& app_id, - const OrderDetails& pay_detials); + explicit BuyInfoMessage(const std::string& app_id, + const OrderDetails& pay_detials); ~BuyInfoMessage() = default; BuyInfoMessage(const BuyInfoMessage& other); @@ -501,10 +509,12 @@ class BuyInfoMessage { bool operator==(const BuyInfoMessage& other) const; bool operator!=(const BuyInfoMessage& other) const; - /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + /// Returns a hash code value for the object. This method is supported for the + /// benefit of hash tables. size_t Hash() const; /// Stream output operator for formatted string representation. friend std::ostream& operator<<(std::ostream& os, const BuyInfoMessage& obj); + private: static BuyInfoMessage FromEncodableList(const ::flutter::EncodableList& list); ::flutter::EncodableList ToEncodableList() const; @@ -514,22 +524,21 @@ class BuyInfoMessage { std::unique_ptr pay_detials_; }; - // Generated class from Pigeon that represents data sent in messages. class InvoiceMessage { public: // Constructs an object setting all fields. - explicit InvoiceMessage( - const std::string& app_id, - const std::string& custom_id, - const std::string& invoice_id, - const std::string& country_code); + explicit InvoiceMessage(const std::string& app_id, + const std::string& custom_id, + const std::string& invoice_id, + const std::string& country_code); // Application ID. const std::string& app_id() const; void set_app_id(std::string_view value_arg); - // Same value as "OrderCustomID" parameter for the BuyItem API (Samsung Account UID). + // Same value as "OrderCustomID" parameter for the BuyItem API (Samsung + // Account UID). const std::string& custom_id() const; void set_custom_id(std::string_view value_arg); @@ -543,10 +552,12 @@ class InvoiceMessage { bool operator==(const InvoiceMessage& other) const; bool operator!=(const InvoiceMessage& other) const; - /// Returns a hash code value for the object. This method is supported for the benefit of hash tables. + /// Returns a hash code value for the object. This method is supported for the + /// benefit of hash tables. size_t Hash() const; /// Stream output operator for formatted string representation. friend std::ostream& operator<<(std::ostream& os, const InvoiceMessage& obj); + private: static InvoiceMessage FromEncodableList(const ::flutter::EncodableList& list); ::flutter::EncodableList ToEncodableList() const; @@ -558,8 +569,8 @@ class InvoiceMessage { std::string country_code_; }; - -class PigeonInternalCodecSerializer : public ::flutter::StandardCodecSerializer { +class PigeonInternalCodecSerializer + : public ::flutter::StandardCodecSerializer { public: PigeonInternalCodecSerializer(); inline static PigeonInternalCodecSerializer& GetInstance() { @@ -567,55 +578,60 @@ class PigeonInternalCodecSerializer : public ::flutter::StandardCodecSerializer return sInstance; } - void WriteValue( - const ::flutter::EncodableValue& value, - ::flutter::ByteStreamWriter* stream) const override; + void WriteValue(const ::flutter::EncodableValue& value, + ::flutter::ByteStreamWriter* stream) const override; + protected: ::flutter::EncodableValue ReadValueOfType( - uint8_t type, - ::flutter::ByteStreamReader* stream) const override; + uint8_t type, ::flutter::ByteStreamReader* stream) const override; }; -// Generated interface from Pigeon that represents a handler of messages from Flutter. +// Generated interface from Pigeon that represents a handler of messages from +// Flutter. class InAppPurchaseApi { public: InAppPurchaseApi(const InAppPurchaseApi&) = delete; InAppPurchaseApi& operator=(const InAppPurchaseApi&) = delete; virtual ~InAppPurchaseApi() {} + virtual std::optional Initialize() = 0; // Retrieves the list of products registered on the Billing (DPI) server. virtual void GetProductsList( - const ProductMessage& product, - std::function reply)> result) = 0; + const ProductMessage& product, + std::function reply)> result) = 0; // Retrieves the user's purchase list. virtual void GetUserPurchaseList( - const PurchaseMessage& purchase, - std::function reply)> result) = 0; - // Enables implementing the Samsung Checkout Client module within the application. - // After authenticating the purchase information through the application, the user can proceed to purchase payment. + const PurchaseMessage& purchase, + std::function reply)> + result) = 0; + // Enables implementing the Samsung Checkout Client module within the + // application. After authenticating the purchase information through the + // application, the user can proceed to purchase payment. virtual void BuyItem( - const BuyInfoMessage& buy_info, - std::function reply)> result) = 0; - // Checks whether a purchase, corresponding to a specific "InvoiceID", was successful. + const BuyInfoMessage& buy_info, + std::function reply)> result) = 0; + // Checks whether a purchase, corresponding to a specific "InvoiceID", was + // successful. virtual void VerifyInvoice( - const InvoiceMessage& invoice, - std::function reply)> result) = 0; + const InvoiceMessage& invoice, + std::function reply)> result) = 0; // Checks whether the Billing server is available. - virtual void IsServiceAvailable(std::function reply)> result) = 0; + virtual void IsServiceAvailable( + std::function reply)> result) = 0; virtual ErrorOr GetCustomId() = 0; virtual ErrorOr GetCountryCode() = 0; // The codec used by InAppPurchaseApi. static const ::flutter::StandardMessageCodec& GetCodec(); - // Sets up an instance of `InAppPurchaseApi` to handle messages through the `binary_messenger`. - static void SetUp( - ::flutter::BinaryMessenger* binary_messenger, - InAppPurchaseApi* api); - static void SetUp( - ::flutter::BinaryMessenger* binary_messenger, - InAppPurchaseApi* api, - const std::string& message_channel_suffix); + // Sets up an instance of `InAppPurchaseApi` to handle messages through the + // `binary_messenger`. + static void SetUp(::flutter::BinaryMessenger* binary_messenger, + InAppPurchaseApi* api); + static void SetUp(::flutter::BinaryMessenger* binary_messenger, + InAppPurchaseApi* api, + const std::string& message_channel_suffix); static ::flutter::EncodableValue WrapError(std::string_view error_message); static ::flutter::EncodableValue WrapError(const FlutterError& error); + protected: InAppPurchaseApi() = default; }; diff --git a/packages/in_app_purchase/tizen/src/messages_ffi.cc b/packages/in_app_purchase/tizen/src/messages_ffi.cc index 501befbe1..f77425912 100644 --- a/packages/in_app_purchase/tizen/src/messages_ffi.cc +++ b/packages/in_app_purchase/tizen/src/messages_ffi.cc @@ -12,55 +12,53 @@ #include namespace { - PigeonFfiBuffer* PigeonFfiMakeBuffer(const std::vector& message) { - auto* buffer = new PigeonFfiBuffer(); - buffer->length = message.size(); - buffer->data = nullptr; - if (!message.empty()) { - buffer->data = new uint8_t[message.size()]; - std::memcpy(buffer->data, message.data(), message.size()); - } - return buffer; +PigeonFfiBuffer* PigeonFfiMakeBuffer(const std::vector& message) { + auto* buffer = new PigeonFfiBuffer(); + buffer->length = message.size(); + buffer->data = nullptr; + if (!message.empty()) { + buffer->data = new uint8_t[message.size()]; + std::memcpy(buffer->data, message.data(), message.size()); } + return buffer; +} - PigeonFfiBuffer* PigeonFfiEncodeMessage( - const ::flutter::StandardMessageCodec& codec, - const ::flutter::EncodableValue& value) { - std::unique_ptr> message = codec.EncodeMessage(value); - return PigeonFfiMakeBuffer(*message); - } +PigeonFfiBuffer* PigeonFfiEncodeMessage( + const ::flutter::StandardMessageCodec& codec, + const ::flutter::EncodableValue& value) { + std::unique_ptr> message = codec.EncodeMessage(value); + return PigeonFfiMakeBuffer(*message); +} - PigeonFfiBuffer* PigeonFfiEncodeError( - const ::flutter::StandardMessageCodec& codec, - const ::flutter::EncodableValue& error) { - return PigeonFfiEncodeMessage(codec, error); - } +PigeonFfiBuffer* PigeonFfiEncodeError( + const ::flutter::StandardMessageCodec& codec, + const ::flutter::EncodableValue& error) { + return PigeonFfiEncodeMessage(codec, error); +} - PigeonFfiBuffer* PigeonFfiEncodeErrorMessage( - const ::flutter::StandardMessageCodec& codec, - const std::string& message) { - return PigeonFfiEncodeError( - codec, - ::flutter::EncodableValue(::flutter::EncodableList{ - ::flutter::EncodableValue("error"), - ::flutter::EncodableValue(message), - ::flutter::EncodableValue()})); - } +PigeonFfiBuffer* PigeonFfiEncodeErrorMessage( + const ::flutter::StandardMessageCodec& codec, const std::string& message) { + return PigeonFfiEncodeError( + codec, + ::flutter::EncodableValue(::flutter::EncodableList{ + ::flutter::EncodableValue("error"), + ::flutter::EncodableValue(message), ::flutter::EncodableValue()})); +} - void PigeonFfiSendReply( - int64_t reply_id, - PigeonFfiReplyCallback on_reply, - PigeonFfiBuffer* reply) { - if (on_reply == nullptr) { - pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_free_buffer(reply); - return; - } - on_reply(reply_id, reply); +void PigeonFfiSendReply(int64_t reply_id, PigeonFfiReplyCallback on_reply, + PigeonFfiBuffer* reply) { + if (on_reply == nullptr) { + pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_free_buffer( + reply); + return; } + on_reply(reply_id, reply); +} } // namespace -void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_free_buffer(PigeonFfiBuffer* buffer) { +void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_free_buffer( + PigeonFfiBuffer* buffer) { if (buffer == nullptr) { return; } @@ -71,15 +69,19 @@ void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi namespace in_app_purchase_tizen { namespace { - InAppPurchaseApi* g_in_app_purchase_api_api = nullptr; - PigeonFfiSyncDispatcher* g_in_app_purchase_api_dispatcher = nullptr; +InAppPurchaseApi* g_in_app_purchase_api_api = nullptr; +PigeonFfiSyncDispatcher* g_in_app_purchase_api_dispatcher = nullptr; } // namespace -void SetUpInAppPurchaseApiFfi( - InAppPurchaseApi* api, - PigeonFfiSyncDispatcher* dispatcher) { +void SetUpInAppPurchaseApiFfi(InAppPurchaseApi* api, + PigeonFfiSyncDispatcher* dispatcher) { if (g_in_app_purchase_api_api != nullptr) { - std::fprintf(stderr, "[pigeon] SetUpInAppPurchaseApiFfi() called more than once. Pigeon C++ FFI registration is process-global and supports only one Flutter engine per process; calls from previously registered engines will be routed to the most recently registered implementation.\n"); + std::fprintf( + stderr, + "[pigeon] SetUpInAppPurchaseApiFfi() called more than once. Pigeon C++ " + "FFI registration is process-global and supports only one Flutter " + "engine per process; calls from previously registered engines will be " + "routed to the most recently registered implementation.\n"); } g_in_app_purchase_api_api = api; g_in_app_purchase_api_dispatcher = dispatcher; @@ -90,60 +92,119 @@ void TearDownInAppPurchaseApiFfi() { g_in_app_purchase_api_dispatcher = nullptr; } -void PigeonInAppPurchaseApiGetProductsListFfi( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply) { +PigeonFfiBuffer* PigeonInAppPurchaseApiInitializeFfi(PigeonFfiBuffer* request) { const auto& codec = InAppPurchaseApi::GetCodec(); if (g_in_app_purchase_api_api == nullptr) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up."))); + return PigeonFfiEncodeError( + codec, + InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up.")); + } + try { + std::optional output = + g_in_app_purchase_api_api->Initialize(); + if (output.has_value()) { + return PigeonFfiEncodeError(codec, + InAppPurchaseApi::WrapError(output.value())); + } + return PigeonFfiEncodeMessage( + codec, ::flutter::EncodableValue( + ::flutter::EncodableList{::flutter::EncodableValue()})); + } catch (const std::exception& exception) { + return PigeonFfiEncodeError(codec, + InAppPurchaseApi::WrapError(exception.what())); + } +} + +PigeonFfiBuffer* PigeonInAppPurchaseApiInitializeFfiDispatch( + PigeonFfiBuffer* request) { + if (g_in_app_purchase_api_dispatcher != nullptr) { + return g_in_app_purchase_api_dispatcher->RunSync( + [request]() { return PigeonInAppPurchaseApiInitializeFfi(request); }); + } + return PigeonInAppPurchaseApiInitializeFfi(request); +} + +void PigeonInAppPurchaseApiGetProductsListFfi(PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (g_in_app_purchase_api_api == nullptr) { + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError(codec, + InAppPurchaseApi::WrapError( + "InAppPurchaseApi has not been set up."))); return; } try { if (request == nullptr || request->data == nullptr) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Request buffer is null."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError( + codec, InAppPurchaseApi::WrapError("Request buffer is null."))); return; } - std::unique_ptr<::flutter::EncodableValue> message = codec.DecodeMessage(request->data, request->length); + std::unique_ptr<::flutter::EncodableValue> message = + codec.DecodeMessage(request->data, request->length); if (!message) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Unable to decode request."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError( + codec, InAppPurchaseApi::WrapError("Unable to decode request."))); return; } const auto* args = std::get_if<::flutter::EncodableList>(message.get()); if (args == nullptr || args->size() != 1) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Unexpected request arguments."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError( + "Unexpected request arguments."))); return; } const auto& encodable_product_arg = args->at(0); if (encodable_product_arg.IsNull()) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("product_arg unexpectedly null."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError( + "product_arg unexpectedly null."))); return; } - const auto& product_arg = std::any_cast(std::get<::flutter::CustomEncodableValue>(encodable_product_arg)); + const auto& product_arg = std::any_cast( + std::get<::flutter::CustomEncodableValue>(encodable_product_arg)); g_in_app_purchase_api_api->GetProductsList( - product_arg, - [reply_id, on_reply](ErrorOr&& output) { - const auto& codec = InAppPurchaseApi::GetCodec(); - if (output.has_error()) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(output.error()))); - return; - } - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeMessage(codec, ::flutter::EncodableValue(::flutter::EncodableList{::flutter::CustomEncodableValue(output.value())}))); - }); + product_arg, + [reply_id, on_reply](ErrorOr&& output) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (output.has_error()) { + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError( + codec, InAppPurchaseApi::WrapError(output.error()))); + return; + } + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeMessage( + codec, + ::flutter::EncodableValue(::flutter::EncodableList{ + ::flutter::CustomEncodableValue(output.value())}))); + }); } catch (const std::exception& exception) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(exception.what()))); + PigeonFfiSendReply(reply_id, on_reply, + PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError( + exception.what()))); } } void PigeonInAppPurchaseApiGetProductsListFfiDispatch( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply) { + PigeonFfiBuffer* request, int64_t reply_id, + PigeonFfiReplyCallback on_reply) { if (g_in_app_purchase_api_dispatcher != nullptr) { - PigeonFfiBuffer* dispatch_error = g_in_app_purchase_api_dispatcher->RunSync([=]() { - PigeonInAppPurchaseApiGetProductsListFfi(request, reply_id, on_reply); - return static_cast(nullptr); - }); + PigeonFfiBuffer* dispatch_error = + g_in_app_purchase_api_dispatcher->RunSync([=]() { + PigeonInAppPurchaseApiGetProductsListFfi(request, reply_id, on_reply); + return static_cast(nullptr); + }); if (dispatch_error != nullptr) { PigeonFfiSendReply(reply_id, on_reply, dispatch_error); } @@ -153,59 +214,87 @@ void PigeonInAppPurchaseApiGetProductsListFfiDispatch( } void PigeonInAppPurchaseApiGetUserPurchaseListFfi( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply) { + PigeonFfiBuffer* request, int64_t reply_id, + PigeonFfiReplyCallback on_reply) { const auto& codec = InAppPurchaseApi::GetCodec(); if (g_in_app_purchase_api_api == nullptr) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError(codec, + InAppPurchaseApi::WrapError( + "InAppPurchaseApi has not been set up."))); return; } try { if (request == nullptr || request->data == nullptr) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Request buffer is null."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError( + codec, InAppPurchaseApi::WrapError("Request buffer is null."))); return; } - std::unique_ptr<::flutter::EncodableValue> message = codec.DecodeMessage(request->data, request->length); + std::unique_ptr<::flutter::EncodableValue> message = + codec.DecodeMessage(request->data, request->length); if (!message) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Unable to decode request."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError( + codec, InAppPurchaseApi::WrapError("Unable to decode request."))); return; } const auto* args = std::get_if<::flutter::EncodableList>(message.get()); if (args == nullptr || args->size() != 1) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Unexpected request arguments."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError( + "Unexpected request arguments."))); return; } const auto& encodable_purchase_arg = args->at(0); if (encodable_purchase_arg.IsNull()) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("purchase_arg unexpectedly null."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError( + "purchase_arg unexpectedly null."))); return; } - const auto& purchase_arg = std::any_cast(std::get<::flutter::CustomEncodableValue>(encodable_purchase_arg)); + const auto& purchase_arg = std::any_cast( + std::get<::flutter::CustomEncodableValue>(encodable_purchase_arg)); g_in_app_purchase_api_api->GetUserPurchaseList( - purchase_arg, - [reply_id, on_reply](ErrorOr&& output) { - const auto& codec = InAppPurchaseApi::GetCodec(); - if (output.has_error()) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(output.error()))); - return; - } - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeMessage(codec, ::flutter::EncodableValue(::flutter::EncodableList{::flutter::CustomEncodableValue(output.value())}))); - }); + purchase_arg, + [reply_id, on_reply](ErrorOr&& output) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (output.has_error()) { + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError( + codec, InAppPurchaseApi::WrapError(output.error()))); + return; + } + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeMessage( + codec, + ::flutter::EncodableValue(::flutter::EncodableList{ + ::flutter::CustomEncodableValue(output.value())}))); + }); } catch (const std::exception& exception) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(exception.what()))); + PigeonFfiSendReply(reply_id, on_reply, + PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError( + exception.what()))); } } void PigeonInAppPurchaseApiGetUserPurchaseListFfiDispatch( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply) { + PigeonFfiBuffer* request, int64_t reply_id, + PigeonFfiReplyCallback on_reply) { if (g_in_app_purchase_api_dispatcher != nullptr) { - PigeonFfiBuffer* dispatch_error = g_in_app_purchase_api_dispatcher->RunSync([=]() { - PigeonInAppPurchaseApiGetUserPurchaseListFfi(request, reply_id, on_reply); - return static_cast(nullptr); - }); + PigeonFfiBuffer* dispatch_error = + g_in_app_purchase_api_dispatcher->RunSync([=]() { + PigeonInAppPurchaseApiGetUserPurchaseListFfi(request, reply_id, + on_reply); + return static_cast(nullptr); + }); if (dispatch_error != nullptr) { PigeonFfiSendReply(reply_id, on_reply, dispatch_error); } @@ -214,60 +303,86 @@ void PigeonInAppPurchaseApiGetUserPurchaseListFfiDispatch( PigeonInAppPurchaseApiGetUserPurchaseListFfi(request, reply_id, on_reply); } -void PigeonInAppPurchaseApiBuyItemFfi( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply) { +void PigeonInAppPurchaseApiBuyItemFfi(PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { const auto& codec = InAppPurchaseApi::GetCodec(); if (g_in_app_purchase_api_api == nullptr) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError(codec, + InAppPurchaseApi::WrapError( + "InAppPurchaseApi has not been set up."))); return; } try { if (request == nullptr || request->data == nullptr) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Request buffer is null."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError( + codec, InAppPurchaseApi::WrapError("Request buffer is null."))); return; } - std::unique_ptr<::flutter::EncodableValue> message = codec.DecodeMessage(request->data, request->length); + std::unique_ptr<::flutter::EncodableValue> message = + codec.DecodeMessage(request->data, request->length); if (!message) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Unable to decode request."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError( + codec, InAppPurchaseApi::WrapError("Unable to decode request."))); return; } const auto* args = std::get_if<::flutter::EncodableList>(message.get()); if (args == nullptr || args->size() != 1) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Unexpected request arguments."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError( + "Unexpected request arguments."))); return; } const auto& encodable_buy_info_arg = args->at(0); if (encodable_buy_info_arg.IsNull()) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("buy_info_arg unexpectedly null."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError( + "buy_info_arg unexpectedly null."))); return; } - const auto& buy_info_arg = std::any_cast(std::get<::flutter::CustomEncodableValue>(encodable_buy_info_arg)); + const auto& buy_info_arg = std::any_cast( + std::get<::flutter::CustomEncodableValue>(encodable_buy_info_arg)); g_in_app_purchase_api_api->BuyItem( - buy_info_arg, - [reply_id, on_reply](ErrorOr&& output) { - const auto& codec = InAppPurchaseApi::GetCodec(); - if (output.has_error()) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(output.error()))); - return; - } - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeMessage(codec, ::flutter::EncodableValue(::flutter::EncodableList{::flutter::CustomEncodableValue(output.value())}))); - }); + buy_info_arg, [reply_id, on_reply](ErrorOr&& output) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (output.has_error()) { + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError( + codec, InAppPurchaseApi::WrapError(output.error()))); + return; + } + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeMessage( + codec, + ::flutter::EncodableValue(::flutter::EncodableList{ + ::flutter::CustomEncodableValue(output.value())}))); + }); } catch (const std::exception& exception) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(exception.what()))); + PigeonFfiSendReply(reply_id, on_reply, + PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError( + exception.what()))); } } -void PigeonInAppPurchaseApiBuyItemFfiDispatch( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply) { +void PigeonInAppPurchaseApiBuyItemFfiDispatch(PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { if (g_in_app_purchase_api_dispatcher != nullptr) { - PigeonFfiBuffer* dispatch_error = g_in_app_purchase_api_dispatcher->RunSync([=]() { - PigeonInAppPurchaseApiBuyItemFfi(request, reply_id, on_reply); - return static_cast(nullptr); - }); + PigeonFfiBuffer* dispatch_error = + g_in_app_purchase_api_dispatcher->RunSync([=]() { + PigeonInAppPurchaseApiBuyItemFfi(request, reply_id, on_reply); + return static_cast(nullptr); + }); if (dispatch_error != nullptr) { PigeonFfiSendReply(reply_id, on_reply, dispatch_error); } @@ -276,60 +391,87 @@ void PigeonInAppPurchaseApiBuyItemFfiDispatch( PigeonInAppPurchaseApiBuyItemFfi(request, reply_id, on_reply); } -void PigeonInAppPurchaseApiVerifyInvoiceFfi( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply) { +void PigeonInAppPurchaseApiVerifyInvoiceFfi(PigeonFfiBuffer* request, + int64_t reply_id, + PigeonFfiReplyCallback on_reply) { const auto& codec = InAppPurchaseApi::GetCodec(); if (g_in_app_purchase_api_api == nullptr) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError(codec, + InAppPurchaseApi::WrapError( + "InAppPurchaseApi has not been set up."))); return; } try { if (request == nullptr || request->data == nullptr) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Request buffer is null."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError( + codec, InAppPurchaseApi::WrapError("Request buffer is null."))); return; } - std::unique_ptr<::flutter::EncodableValue> message = codec.DecodeMessage(request->data, request->length); + std::unique_ptr<::flutter::EncodableValue> message = + codec.DecodeMessage(request->data, request->length); if (!message) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Unable to decode request."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError( + codec, InAppPurchaseApi::WrapError("Unable to decode request."))); return; } const auto* args = std::get_if<::flutter::EncodableList>(message.get()); if (args == nullptr || args->size() != 1) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("Unexpected request arguments."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError( + "Unexpected request arguments."))); return; } const auto& encodable_invoice_arg = args->at(0); if (encodable_invoice_arg.IsNull()) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("invoice_arg unexpectedly null."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError( + "invoice_arg unexpectedly null."))); return; } - const auto& invoice_arg = std::any_cast(std::get<::flutter::CustomEncodableValue>(encodable_invoice_arg)); + const auto& invoice_arg = std::any_cast( + std::get<::flutter::CustomEncodableValue>(encodable_invoice_arg)); g_in_app_purchase_api_api->VerifyInvoice( - invoice_arg, - [reply_id, on_reply](ErrorOr&& output) { - const auto& codec = InAppPurchaseApi::GetCodec(); - if (output.has_error()) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(output.error()))); - return; - } - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeMessage(codec, ::flutter::EncodableValue(::flutter::EncodableList{::flutter::CustomEncodableValue(output.value())}))); - }); + invoice_arg, + [reply_id, on_reply](ErrorOr&& output) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (output.has_error()) { + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError( + codec, InAppPurchaseApi::WrapError(output.error()))); + return; + } + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeMessage( + codec, + ::flutter::EncodableValue(::flutter::EncodableList{ + ::flutter::CustomEncodableValue(output.value())}))); + }); } catch (const std::exception& exception) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(exception.what()))); + PigeonFfiSendReply(reply_id, on_reply, + PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError( + exception.what()))); } } void PigeonInAppPurchaseApiVerifyInvoiceFfiDispatch( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply) { + PigeonFfiBuffer* request, int64_t reply_id, + PigeonFfiReplyCallback on_reply) { if (g_in_app_purchase_api_dispatcher != nullptr) { - PigeonFfiBuffer* dispatch_error = g_in_app_purchase_api_dispatcher->RunSync([=]() { - PigeonInAppPurchaseApiVerifyInvoiceFfi(request, reply_id, on_reply); - return static_cast(nullptr); - }); + PigeonFfiBuffer* dispatch_error = + g_in_app_purchase_api_dispatcher->RunSync([=]() { + PigeonInAppPurchaseApiVerifyInvoiceFfi(request, reply_id, on_reply); + return static_cast(nullptr); + }); if (dispatch_error != nullptr) { PigeonFfiSendReply(reply_id, on_reply, dispatch_error); } @@ -339,38 +481,51 @@ void PigeonInAppPurchaseApiVerifyInvoiceFfiDispatch( } void PigeonInAppPurchaseApiIsServiceAvailableFfi( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply) { + PigeonFfiBuffer* request, int64_t reply_id, + PigeonFfiReplyCallback on_reply) { const auto& codec = InAppPurchaseApi::GetCodec(); if (g_in_app_purchase_api_api == nullptr) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up."))); + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError(codec, + InAppPurchaseApi::WrapError( + "InAppPurchaseApi has not been set up."))); return; } try { g_in_app_purchase_api_api->IsServiceAvailable( - [reply_id, on_reply](ErrorOr&& output) { - const auto& codec = InAppPurchaseApi::GetCodec(); - if (output.has_error()) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(output.error()))); - return; - } - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeMessage(codec, ::flutter::EncodableValue(::flutter::EncodableList{::flutter::EncodableValue(output.value())}))); - }); + [reply_id, on_reply](ErrorOr&& output) { + const auto& codec = InAppPurchaseApi::GetCodec(); + if (output.has_error()) { + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeError( + codec, InAppPurchaseApi::WrapError(output.error()))); + return; + } + PigeonFfiSendReply( + reply_id, on_reply, + PigeonFfiEncodeMessage( + codec, ::flutter::EncodableValue(::flutter::EncodableList{ + ::flutter::EncodableValue(output.value())}))); + }); } catch (const std::exception& exception) { - PigeonFfiSendReply(reply_id, on_reply, PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(exception.what()))); + PigeonFfiSendReply(reply_id, on_reply, + PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError( + exception.what()))); } } void PigeonInAppPurchaseApiIsServiceAvailableFfiDispatch( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply) { + PigeonFfiBuffer* request, int64_t reply_id, + PigeonFfiReplyCallback on_reply) { if (g_in_app_purchase_api_dispatcher != nullptr) { - PigeonFfiBuffer* dispatch_error = g_in_app_purchase_api_dispatcher->RunSync([=]() { - PigeonInAppPurchaseApiIsServiceAvailableFfi(request, reply_id, on_reply); - return static_cast(nullptr); - }); + PigeonFfiBuffer* dispatch_error = + g_in_app_purchase_api_dispatcher->RunSync([=]() { + PigeonInAppPurchaseApiIsServiceAvailableFfi(request, reply_id, + on_reply); + return static_cast(nullptr); + }); if (dispatch_error != nullptr) { PigeonFfiSendReply(reply_id, on_reply, dispatch_error); } @@ -379,48 +534,63 @@ void PigeonInAppPurchaseApiIsServiceAvailableFfiDispatch( PigeonInAppPurchaseApiIsServiceAvailableFfi(request, reply_id, on_reply); } -PigeonFfiBuffer* PigeonInAppPurchaseApiGetCustomIdFfi(PigeonFfiBuffer* request) { +PigeonFfiBuffer* PigeonInAppPurchaseApiGetCustomIdFfi( + PigeonFfiBuffer* request) { const auto& codec = InAppPurchaseApi::GetCodec(); if (g_in_app_purchase_api_api == nullptr) { - return PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up.")); + return PigeonFfiEncodeError( + codec, + InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up.")); } try { ErrorOr output = g_in_app_purchase_api_api->GetCustomId(); if (output.has_error()) { - return PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(output.error())); + return PigeonFfiEncodeError(codec, + InAppPurchaseApi::WrapError(output.error())); } - return PigeonFfiEncodeMessage(codec, ::flutter::EncodableValue(::flutter::EncodableList{::flutter::EncodableValue(output.value())})); + return PigeonFfiEncodeMessage( + codec, ::flutter::EncodableValue(::flutter::EncodableList{ + ::flutter::EncodableValue(output.value())})); } catch (const std::exception& exception) { - return PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(exception.what())); + return PigeonFfiEncodeError(codec, + InAppPurchaseApi::WrapError(exception.what())); } } -PigeonFfiBuffer* PigeonInAppPurchaseApiGetCustomIdFfiDispatch(PigeonFfiBuffer* request) { +PigeonFfiBuffer* PigeonInAppPurchaseApiGetCustomIdFfiDispatch( + PigeonFfiBuffer* request) { if (g_in_app_purchase_api_dispatcher != nullptr) { - return g_in_app_purchase_api_dispatcher->RunSync([request]() { - return PigeonInAppPurchaseApiGetCustomIdFfi(request); - }); + return g_in_app_purchase_api_dispatcher->RunSync( + [request]() { return PigeonInAppPurchaseApiGetCustomIdFfi(request); }); } return PigeonInAppPurchaseApiGetCustomIdFfi(request); } -PigeonFfiBuffer* PigeonInAppPurchaseApiGetCountryCodeFfi(PigeonFfiBuffer* request) { +PigeonFfiBuffer* PigeonInAppPurchaseApiGetCountryCodeFfi( + PigeonFfiBuffer* request) { const auto& codec = InAppPurchaseApi::GetCodec(); if (g_in_app_purchase_api_api == nullptr) { - return PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up.")); + return PigeonFfiEncodeError( + codec, + InAppPurchaseApi::WrapError("InAppPurchaseApi has not been set up.")); } try { ErrorOr output = g_in_app_purchase_api_api->GetCountryCode(); if (output.has_error()) { - return PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(output.error())); + return PigeonFfiEncodeError(codec, + InAppPurchaseApi::WrapError(output.error())); } - return PigeonFfiEncodeMessage(codec, ::flutter::EncodableValue(::flutter::EncodableList{::flutter::EncodableValue(output.value())})); + return PigeonFfiEncodeMessage( + codec, ::flutter::EncodableValue(::flutter::EncodableList{ + ::flutter::EncodableValue(output.value())})); } catch (const std::exception& exception) { - return PigeonFfiEncodeError(codec, InAppPurchaseApi::WrapError(exception.what())); + return PigeonFfiEncodeError(codec, + InAppPurchaseApi::WrapError(exception.what())); } } -PigeonFfiBuffer* PigeonInAppPurchaseApiGetCountryCodeFfiDispatch(PigeonFfiBuffer* request) { +PigeonFfiBuffer* PigeonInAppPurchaseApiGetCountryCodeFfiDispatch( + PigeonFfiBuffer* request) { if (g_in_app_purchase_api_dispatcher != nullptr) { return g_in_app_purchase_api_dispatcher->RunSync([request]() { return PigeonInAppPurchaseApiGetCountryCodeFfi(request); @@ -431,46 +601,63 @@ PigeonFfiBuffer* PigeonInAppPurchaseApiGetCountryCodeFfiDispatch(PigeonFfiBuffer } // namespace in_app_purchase_tizen -extern "C" void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_products_list( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply) { - in_app_purchase_tizen::PigeonInAppPurchaseApiGetProductsListFfiDispatch(request, reply_id, on_reply); +extern "C" PigeonFfiBuffer* +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_initialize( + PigeonFfiBuffer* request) { + return in_app_purchase_tizen::PigeonInAppPurchaseApiInitializeFfiDispatch( + request); } -extern "C" void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_user_purchase_list( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply) { - in_app_purchase_tizen::PigeonInAppPurchaseApiGetUserPurchaseListFfiDispatch(request, reply_id, on_reply); +extern "C" void +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_products_list( + PigeonFfiBuffer* request, int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + in_app_purchase_tizen::PigeonInAppPurchaseApiGetProductsListFfiDispatch( + request, reply_id, on_reply); } -extern "C" void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_buy_item( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply) { - in_app_purchase_tizen::PigeonInAppPurchaseApiBuyItemFfiDispatch(request, reply_id, on_reply); +extern "C" void +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_user_purchase_list( + PigeonFfiBuffer* request, int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + in_app_purchase_tizen::PigeonInAppPurchaseApiGetUserPurchaseListFfiDispatch( + request, reply_id, on_reply); } -extern "C" void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_verify_invoice( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply) { - in_app_purchase_tizen::PigeonInAppPurchaseApiVerifyInvoiceFfiDispatch(request, reply_id, on_reply); +extern "C" void +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_buy_item( + PigeonFfiBuffer* request, int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + in_app_purchase_tizen::PigeonInAppPurchaseApiBuyItemFfiDispatch( + request, reply_id, on_reply); } -extern "C" void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_is_service_available( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply) { - in_app_purchase_tizen::PigeonInAppPurchaseApiIsServiceAvailableFfiDispatch(request, reply_id, on_reply); +extern "C" void +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_verify_invoice( + PigeonFfiBuffer* request, int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + in_app_purchase_tizen::PigeonInAppPurchaseApiVerifyInvoiceFfiDispatch( + request, reply_id, on_reply); } -extern "C" PigeonFfiBuffer* pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_custom_id(PigeonFfiBuffer* request) { - return in_app_purchase_tizen::PigeonInAppPurchaseApiGetCustomIdFfiDispatch(request); +extern "C" void +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_is_service_available( + PigeonFfiBuffer* request, int64_t reply_id, + PigeonFfiReplyCallback on_reply) { + in_app_purchase_tizen::PigeonInAppPurchaseApiIsServiceAvailableFfiDispatch( + request, reply_id, on_reply); } -extern "C" PigeonFfiBuffer* pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_country_code(PigeonFfiBuffer* request) { - return in_app_purchase_tizen::PigeonInAppPurchaseApiGetCountryCodeFfiDispatch(request); +extern "C" PigeonFfiBuffer* +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_custom_id( + PigeonFfiBuffer* request) { + return in_app_purchase_tizen::PigeonInAppPurchaseApiGetCustomIdFfiDispatch( + request); } +extern "C" PigeonFfiBuffer* +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_country_code( + PigeonFfiBuffer* request) { + return in_app_purchase_tizen::PigeonInAppPurchaseApiGetCountryCodeFfiDispatch( + request); +} diff --git a/packages/in_app_purchase/tizen/src/messages_ffi.h b/packages/in_app_purchase/tizen/src/messages_ffi.h index b04d159b1..c9ac31ef4 100644 --- a/packages/in_app_purchase/tizen/src/messages_ffi.h +++ b/packages/in_app_purchase/tizen/src/messages_ffi.h @@ -13,6 +13,7 @@ #include #include #include + #include "messages.h" #endif @@ -33,36 +34,47 @@ typedef struct PigeonFfiBuffer { size_t length; } PigeonFfiBuffer; -typedef void (*PigeonFfiReplyCallback)(int64_t reply_id, PigeonFfiBuffer* reply); +typedef void (*PigeonFfiReplyCallback)(int64_t reply_id, + PigeonFfiBuffer* reply); typedef void (*PigeonFfiEventCallback)(int64_t sink_id, PigeonFfiBuffer* event); typedef void (*PigeonFfiDoneCallback)(int64_t sink_id); #endif // PIGEON_FFI_ABI_TYPES_ // Frees a buffer returned by a generated FFI function. -PIGEON_FFI_EXPORT void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_free_buffer(PigeonFfiBuffer* buffer); -// The caller owns request; free returned buffers with pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_free_buffer. -PIGEON_FFI_EXPORT void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_products_list( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply); -PIGEON_FFI_EXPORT void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_user_purchase_list( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply); -PIGEON_FFI_EXPORT void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_buy_item( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply); -PIGEON_FFI_EXPORT void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_verify_invoice( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply); -PIGEON_FFI_EXPORT void pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_is_service_available( - PigeonFfiBuffer* request, - int64_t reply_id, - PigeonFfiReplyCallback on_reply); -PIGEON_FFI_EXPORT PigeonFfiBuffer* pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_custom_id(PigeonFfiBuffer* request); -PIGEON_FFI_EXPORT PigeonFfiBuffer* pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_country_code(PigeonFfiBuffer* request); +PIGEON_FFI_EXPORT void +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_free_buffer( + PigeonFfiBuffer* buffer); +// The caller owns request; free returned buffers with +// pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_free_buffer. +PIGEON_FFI_EXPORT PigeonFfiBuffer* +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_initialize( + PigeonFfiBuffer* request); +PIGEON_FFI_EXPORT void +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_products_list( + PigeonFfiBuffer* request, int64_t reply_id, + PigeonFfiReplyCallback on_reply); +PIGEON_FFI_EXPORT void +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_user_purchase_list( + PigeonFfiBuffer* request, int64_t reply_id, + PigeonFfiReplyCallback on_reply); +PIGEON_FFI_EXPORT void +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_buy_item( + PigeonFfiBuffer* request, int64_t reply_id, + PigeonFfiReplyCallback on_reply); +PIGEON_FFI_EXPORT void +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_verify_invoice( + PigeonFfiBuffer* request, int64_t reply_id, + PigeonFfiReplyCallback on_reply); +PIGEON_FFI_EXPORT void +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_is_service_available( + PigeonFfiBuffer* request, int64_t reply_id, + PigeonFfiReplyCallback on_reply); +PIGEON_FFI_EXPORT PigeonFfiBuffer* +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_custom_id( + PigeonFfiBuffer* request); +PIGEON_FFI_EXPORT PigeonFfiBuffer* +pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tizen_x2f_src_x2f_messages_x5f_ffi_x2e_h_in_app_purchase_api_get_country_code( + PigeonFfiBuffer* request); #ifdef __cplusplus } @@ -70,18 +82,16 @@ PIGEON_FFI_EXPORT PigeonFfiBuffer* pigeon_in_x5f_app_x5f_purchase_x5f_tizen_tize #ifdef __cplusplus namespace in_app_purchase_tizen { - class PigeonFfiSyncDispatcher { - public: - virtual ~PigeonFfiSyncDispatcher() = default; - virtual ::PigeonFfiBuffer* RunSync( - std::function<::PigeonFfiBuffer*()> task) = 0; - }; - +class PigeonFfiSyncDispatcher { + public: + virtual ~PigeonFfiSyncDispatcher() = default; + virtual ::PigeonFfiBuffer* RunSync( + std::function<::PigeonFfiBuffer*()> task) = 0; +}; - void SetUpInAppPurchaseApiFfi( - InAppPurchaseApi* api, - PigeonFfiSyncDispatcher* dispatcher = nullptr); - void TearDownInAppPurchaseApiFfi(); +void SetUpInAppPurchaseApiFfi(InAppPurchaseApi* api, + PigeonFfiSyncDispatcher* dispatcher = nullptr); +void TearDownInAppPurchaseApiFfi(); } // namespace in_app_purchase_tizen #endif From 3c3ad96cc0f026895e5c99292832c9e4517f3482 Mon Sep 17 00:00:00 2001 From: "yying.jin" Date: Thu, 5 Nov 2026 17:04:02 +0800 Subject: [PATCH 3/3] [in_app_purchase] Fix publish dry-run and null-callback crash on stale replies - Add meta to dependencies: pigeon v29 generates an import of package:meta in messages.g.dart, and pub publish --dry-run requires every imported package to be declared. - Change the null-callback branches of the billing reply handlers to log instead of invoking the empty std::function, which throws std::bad_function_call and terminates the process when a stale reply arrives after initialize() has reset the pending callbacks. Co-Authored-By: Cline SR --- packages/in_app_purchase/pubspec.yaml | 1 + .../in_app_purchase/tizen/src/billing_manager.cc | 15 +++++---------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/in_app_purchase/pubspec.yaml b/packages/in_app_purchase/pubspec.yaml index 0843a6bc2..00672ad95 100644 --- a/packages/in_app_purchase/pubspec.yaml +++ b/packages/in_app_purchase/pubspec.yaml @@ -23,6 +23,7 @@ dependencies: flutter: sdk: flutter in_app_purchase_platform_interface: ^1.4.0 + meta: ^1.8.0 dev_dependencies: build_runner: ^2.0.0 diff --git a/packages/in_app_purchase/tizen/src/billing_manager.cc b/packages/in_app_purchase/tizen/src/billing_manager.cc index 2a10d9137..87dc432bc 100644 --- a/packages/in_app_purchase/tizen/src/billing_manager.cc +++ b/packages/in_app_purchase/tizen/src/billing_manager.cc @@ -196,8 +196,7 @@ void BillingManager::OnAvailable(const char *detail_result, void *user_data) { else self->is_available_callback_(false); } else { - self->is_available_callback_( - FlutterError("Invalid argument", "is_available_callback_ is null !")); + LOG_ERROR("[BillingManager] is_available_callback_ is null !"); } self->is_available_callback_ = nullptr; } @@ -267,8 +266,7 @@ void BillingManager::OnProducts(const char *detail_result, void *user_data) { check_value, item_details); self->get_product_list_callback_(products_list); } else { - self->get_product_list_callback_(FlutterError( - "Invalid argument", "get_product_list_callback_ is null !")); + LOG_ERROR("[BillingManager] get_product_list_callback_ is null !"); } self->get_product_list_callback_ = nullptr; } @@ -365,8 +363,7 @@ void BillingManager::OnPurchase(const char *detail_result, void *user_data) { cp_status, &cp_result, total_count, check_value, invoice_details); self->get_purchase_list_callback_(purchase_list); } else { - self->get_purchase_list_callback_(FlutterError( - "Invalid argument", "get_purchase_list_callback_ is null !")); + LOG_ERROR("[BillingManager] get_purchase_list_callback_ is null !"); } self->get_purchase_list_callback_ = nullptr; } @@ -410,8 +407,7 @@ bool BillingManager::OnBuyItem(const char *pay_result, const char *detail_info, BillingBuyData buy_data(pay_res, pay_details); self->buy_item_callback_(buy_data); } else { - self->buy_item_callback_( - FlutterError("Invalid argument", "buy_item_callback_ is null !")); + LOG_ERROR("[BillingManager] buy_item_callback_ is null !"); } self->buy_item_callback_ = nullptr; return true; @@ -442,8 +438,7 @@ void BillingManager::OnVerify(const char *detail_result, void *user_data) { invoice_id); self->verify_invoice_callback_(verify_invoice); } else { - self->verify_invoice_callback_( - FlutterError("Invalid argument", "verify_invoice_callback_ is null !")); + LOG_ERROR("[BillingManager] verify_invoice_callback_ is null !"); } self->verify_invoice_callback_ = nullptr; }