From 76c48bb06a170aeb0caea296b8149233051556ac Mon Sep 17 00:00:00 2001 From: Jason Elie Bou Kheir <5115126+jasonboukheir@users.noreply.github.com> Date: Wed, 13 Sep 2023 23:20:03 -0700 Subject: [PATCH] refactor: :fire: remove WalletConnect support from this SDK WalletConnect is outside the scope of this SDK, and it's causing issues in other parts of the SDK. BREAKING CHANGE: WalletConnect is no longer supported. All related samples have been removed. --- .docfx/manual/toc.yml | 4 - Algorand.Unity.Package/.vscode/settings.json | 3 +- .../Assets/TestDocsCompile/WalletConnect.cs | 49 - .../TestDocsCompile/WalletConnect.cs.meta | 11 - .../Assets/TestWalletConnectV2.meta | 8 - .../Assets/TestWalletConnectV2/Scripts.meta | 8 - .../Scripts/TestWalletConnectV2.asmdef | 29 - .../Scripts/TestWalletConnectV2.asmdef.meta | 7 - .../Scripts/WalletConnectClient.cs | 182 --- .../Scripts/WalletConnectClient.cs.meta | 11 - .../TestWalletConnectV2/WalletConnectV2.unity | 3 - .../WalletConnectV2.unity.meta | 7 - Algorand.Unity.Package/upm.code-workspace | 1 - README.md | 40 +- Runtime/Algorand.Unity.JsonRpc.meta | 8 - .../Algorand.Unity.JsonRpc.asmdef | 21 - .../Algorand.Unity.JsonRpc.asmdef.meta | 7 - .../Formatters.gen.meta | 8 - .../JsonRpcError.Formatters.gen.cs | 29 - .../JsonRpcError.Formatters.gen.cs.meta | 11 - .../JsonRpcRequest.Formatters.gen.cs | 46 - .../JsonRpcRequest.Formatters.gen.cs.meta | 11 - .../JsonRpcResponse.Formatters.gen.cs | 29 - .../JsonRpcResponse.Formatters.gen.cs.meta | 11 - .../Algorand.Unity.JsonRpc/JsonRpcError.cs | 48 - .../JsonRpcError.cs.meta | 3 - .../Algorand.Unity.JsonRpc/JsonRpcEvent.cs | 11 - .../JsonRpcEvent.cs.meta | 3 - .../JsonRpcEventType.cs | 12 - .../JsonRpcEventType.cs.meta | 3 - .../Algorand.Unity.JsonRpc/JsonRpcRequest.cs | 93 -- .../JsonRpcRequest.cs.meta | 3 - .../Algorand.Unity.JsonRpc/JsonRpcResponse.cs | 70 - .../JsonRpcResponse.cs.meta | 3 - Runtime/Algorand.Unity.QrCode.meta | 8 - .../Algorand.Unity.QrCode.asmdef | 16 - .../Algorand.Unity.QrCode.asmdef.meta | 7 - .../Algorand.Unity.QrCode/QrCodeUtility.cs | 55 - .../QrCodeUtility.cs.meta | 11 - .../Algorand.Unity.WalletConnect.Core.meta | 8 - .../Algorand.Unity.WalletConnect.Core.asmdef | 27 - ...orand.Unity.WalletConnect.Core.asmdef.meta | 7 - .../ClientOptions.cs | 60 - .../ClientOptions.cs.meta | 3 - .../Crypto.meta | 8 - .../Crypto/Envelope.cs | 40 - .../Crypto/Envelope.cs.meta | 11 - .../Crypto/EnvelopeType.cs | 48 - .../Crypto/EnvelopeType.cs.meta | 11 - .../Crypto/Jwt.meta | 3 - .../Crypto/Jwt/JwtHeader.cs | 39 - .../Crypto/Jwt/JwtHeader.cs.meta | 3 - .../Crypto/Jwt/JwtIssuer.cs | 56 - .../Crypto/Jwt/JwtIssuer.cs.meta | 3 - .../Crypto/Jwt/JwtPayload.cs | 60 - .../Crypto/Jwt/JwtPayload.cs.meta | 3 - .../Crypto/Jwt/JwtUrl.cs | 80 - .../Crypto/Jwt/JwtUrl.cs.meta | 3 - .../Formatters.gen.meta | 8 - .../Formatters.gen/Error.Formatters.gen.cs | 29 - .../Error.Formatters.gen.cs.meta | 11 - .../ErrorResponse.Formatters.gen.cs | 29 - .../ErrorResponse.Formatters.gen.cs.meta | 11 - .../FetchMessagesPayload.Formatters.gen.cs | 46 - ...etchMessagesPayload.Formatters.gen.cs.meta | 11 - .../JwtHeader.Formatters.gen.cs | 29 - .../JwtHeader.Formatters.gen.cs.meta | 11 - .../JwtIssuer.Formatters.gen.cs | 29 - .../JwtIssuer.Formatters.gen.cs.meta | 11 - .../JwtPayload.Formatters.gen.cs | 29 - .../JwtPayload.Formatters.gen.cs.meta | 11 - .../Formatters.gen/Metadata.Formatters.gen.cs | 41 - .../Metadata.Formatters.gen.cs.meta | 11 - .../Namespace.Formatters.gen.cs | 29 - .../Namespace.Formatters.gen.cs.meta | 11 - .../OptionalNamespaces.Formatters.gen.cs | 29 - .../OptionalNamespaces.Formatters.gen.cs.meta | 11 - .../Participant.Formatters.gen.cs | 29 - .../Participant.Formatters.gen.cs.meta | 11 - .../ProtocolOptions.Formatters.gen.cs | 29 - .../ProtocolOptions.Formatters.gen.cs.meta | 11 - .../PublishPayload.Formatters.gen.cs | 46 - .../PublishPayload.Formatters.gen.cs.meta | 11 - .../ReceivedMessage.Formatters.gen.cs | 29 - .../ReceivedMessage.Formatters.gen.cs.meta | 11 - .../RequiredNamespaces.Formatters.gen.cs | 29 - .../RequiredNamespaces.Formatters.gen.cs.meta | 11 - .../SessionProperties.Formatters.gen.cs | 29 - .../SessionProperties.Formatters.gen.cs.meta | 11 - .../SessionProposePayload.Formatters.gen.cs | 46 - ...ssionProposePayload.Formatters.gen.cs.meta | 11 - .../SubscribePayload.Formatters.gen.cs | 46 - .../SubscribePayload.Formatters.gen.cs.meta | 11 - .../SubscriptionPayload.Formatters.gen.cs | 46 - ...SubscriptionPayload.Formatters.gen.cs.meta | 11 - .../Formatters.gen/Topic.Formatters.gen.cs | 29 - .../Topic.Formatters.gen.cs.meta | 11 - .../UnsubscribePayload.Formatters.gen.cs | 46 - .../UnsubscribePayload.Formatters.gen.cs.meta | 11 - .../Pairing.meta | 8 - .../Pairing/Error.cs | 37 - .../Pairing/Error.cs.meta | 3 - .../Pairing/ErrorResponse.cs | 37 - .../Pairing/ErrorResponse.cs.meta | 3 - .../Pairing/Metadata.cs | 109 -- .../Pairing/Metadata.cs.meta | 3 - .../Pairing/PairingErrorCode.cs | 11 - .../Pairing/PairingErrorCode.cs.meta | 3 - .../Pairing/PairingMethods.cs | 94 -- .../Pairing/PairingMethods.cs.meta | 11 - .../Pairing/PairingUri.cs | 64 - .../Pairing/PairingUri.cs.meta | 11 - .../Pairing/Payloads.meta | 8 - .../Pairing/Payloads/Namespace.cs | 54 - .../Pairing/Payloads/Namespace.cs.meta | 11 - .../Pairing/Payloads/OptionalNamespaces.cs | 17 - .../Payloads/OptionalNamespaces.cs.meta | 11 - .../Pairing/Payloads/Participant.cs | 36 - .../Pairing/Payloads/Participant.cs.meta | 11 - .../Pairing/Payloads/RequiredNamespaces.cs | 28 - .../Payloads/RequiredNamespaces.cs.meta | 11 - .../Pairing/Payloads/SessionProperties.cs | 17 - .../Payloads/SessionProperties.cs.meta | 11 - .../Pairing/Payloads/SessionProposePayload.cs | 111 -- .../Payloads/SessionProposePayload.cs.meta | 11 - .../Pairing/ProtocolOptions.cs | 36 - .../Pairing/ProtocolOptions.cs.meta | 11 - .../Pairing/ProtocolType.cs | 29 - .../Pairing/ProtocolType.cs.meta | 3 - .../Pairing/SymKey.cs | 72 - .../Pairing/SymKey.cs.meta | 11 - .../Relay.meta | 8 - .../Relay/MessageId.cs | 30 - .../Relay/MessageId.cs.meta | 3 - .../Relay/Payloads.meta | 8 - .../Relay/Payloads/FetchMessagesPayload.cs | 72 - .../Payloads/FetchMessagesPayload.cs.meta | 11 - .../Relay/Payloads/PublishPayload.cs | 97 -- .../Relay/Payloads/PublishPayload.cs.meta | 11 - .../Relay/Payloads/ReceivedMessage.cs | 59 - .../Relay/Payloads/ReceivedMessage.cs.meta | 11 - .../Relay/Payloads/SubscribePayload.cs | 65 - .../Relay/Payloads/SubscribePayload.cs.meta | 11 - .../Relay/Payloads/SubscriptionPayload.cs | 74 - .../Payloads/SubscriptionPayload.cs.meta | 11 - .../Relay/Payloads/UnsubscribePayload.cs | 74 - .../Relay/Payloads/UnsubscribePayload.cs.meta | 11 - .../Relay/RelayClient.cs | 189 --- .../Relay/RelayClient.cs.meta | 11 - .../Relay/RpcId.cs | 33 - .../Relay/RpcId.cs.meta | 11 - .../Relay/Topic.cs | 108 -- .../Relay/Topic.cs.meta | 11 - .../Relay/UserAgent.cs | 30 - .../Relay/UserAgent.cs.meta | 11 - .../TimeToLive.cs | 24 - .../TimeToLive.cs.meta | 3 - .../Algorand.Unity.WalletConnect.Sign.meta | 8 - .../Algorand.Unity.WalletConnect.Sign.asmdef | 21 - ...orand.Unity.WalletConnect.Sign.asmdef.meta | 7 - .../WalletConnectSignError.cs | 49 - .../WalletConnectSignError.cs.meta | 11 - Runtime/Algorand.Unity.WalletConnect.meta | 8 - .../Algorand.Unity.WalletConnect.asmdef | 26 - .../Algorand.Unity.WalletConnect.asmdef.meta | 7 - .../AlgorandWalletConnectSession.cs | 299 ---- .../AlgorandWalletConnectSession.cs.meta | 11 - .../Algorand.Unity.WalletConnect/AppEntry.cs | 163 -- .../AppEntry.cs.meta | 11 - .../Algorand.Unity.WalletConnect/Crypto.meta | 8 - .../Crypto/AesCipher.cs | 64 - .../Crypto/AesCipher.cs.meta | 11 - .../Formatters.gen.meta | 8 - .../ClientMeta.Formatters.gen.cs | 29 - .../ClientMeta.Formatters.gen.cs.meta | 11 - .../EncryptedPayload.Formatters.gen.cs | 29 - .../EncryptedPayload.Formatters.gen.cs.meta | 11 - .../JsonRpcError.Formatters.gen.cs | 29 - .../JsonRpcError.Formatters.gen.cs.meta | 11 - .../JsonRpcRequest.Formatters.gen.cs | 29 - .../JsonRpcRequest.Formatters.gen.cs.meta | 11 - .../JsonRpcResponse.Formatters.gen.cs | 29 - .../JsonRpcResponse.Formatters.gen.cs.meta | 11 - .../MultisigMetadata.Formatters.gen.cs | 29 - .../MultisigMetadata.Formatters.gen.cs.meta | 11 - .../NetworkMessage.Formatters.gen.cs | 29 - .../NetworkMessage.Formatters.gen.cs.meta | 11 - .../SignTxnsError.Formatters.gen.cs | 29 - .../SignTxnsError.Formatters.gen.cs.meta | 11 - .../SignTxnsOpts.Formatters.gen.cs | 29 - .../SignTxnsOpts.Formatters.gen.cs.meta | 11 - ...WalletConnectSessionData.Formatters.gen.cs | 29 - ...tConnectSessionData.Formatters.gen.cs.meta | 11 - ...letConnectSessionRequest.Formatters.gen.cs | 29 - ...nnectSessionRequest.Formatters.gen.cs.meta | 11 - .../WalletTransaction.Formatters.gen.cs | 29 - .../WalletTransaction.Formatters.gen.cs.meta | 11 - .../HandshakeUrl.cs | 36 - .../HandshakeUrl.cs.meta | 11 - .../IWalletConnectAccount.cs | 62 - .../IWalletConnectAccount.cs.meta | 11 - .../IWalletConnectSession.cs | 76 - .../IWalletConnectSession.cs.meta | 11 - .../Algorand.Unity.WalletConnect/JsonRpc.cs | 26 - .../JsonRpc.cs.meta | 11 - .../JsonRpcClient.cs | 209 --- .../JsonRpcClient.cs.meta | 11 - .../Algorand.Unity.WalletConnect/Models.meta | 8 - .../Models/ClientMeta.cs | 31 - .../Models/ClientMeta.cs.meta | 11 - .../Models/EncryptedPayload.cs | 56 - .../Models/EncryptedPayload.cs.meta | 11 - .../Models/JsonRpcError.cs | 44 - .../Models/JsonRpcError.cs.meta | 11 - .../Models/JsonRpcRequest.cs | 61 - .../Models/JsonRpcRequest.cs.meta | 11 - .../Models/JsonRpcResponse.cs | 70 - .../Models/JsonRpcResponse.cs.meta | 11 - .../Models/MultisigMetadata.cs | 65 - .../Models/MultisigMetadata.cs.meta | 11 - .../Models/NetworkMessage.cs | 59 - .../Models/NetworkMessage.cs.meta | 11 - .../Models/SessionData.cs | 114 -- .../Models/SessionData.cs.meta | 11 - .../Models/SignTxnsError.cs | 107 -- .../Models/SignTxnsError.cs.meta | 11 - .../Models/SignTxnsOpts.cs | 24 - .../Models/SignTxnsOpts.cs.meta | 11 - .../Models/WalletConnectRpc.cs | 122 -- .../Models/WalletConnectRpc.cs.meta | 11 - .../Models/WalletConnectSessionData.cs | 34 - .../Models/WalletConnectSessionData.cs.meta | 11 - .../Models/WalletConnectSessionRequest.cs | 26 - .../WalletConnectSessionRequest.cs.meta | 11 - .../Models/WalletTransaction.cs | 88 -- .../Models/WalletTransaction.cs.meta | 11 - .../SessionStatus.cs | 10 - .../SessionStatus.cs.meta | 11 - .../Algorand.Unity.WalletConnect/Utils.meta | 8 - .../Utils/DefaultBridge.cs | 24 - .../Utils/DefaultBridge.cs.meta | 11 - .../Utils/RpcPayload.cs | 16 - .../Utils/RpcPayload.cs.meta | 11 - .../WalletConnectAccount.cs | 180 --- .../WalletConnectAccount.cs.meta | 11 - .../WalletConnectSessionEvents.cs | 13 - .../WalletConnectSessionEvents.cs.meta | 11 - .../WalletRegistry.cs | 100 -- .../WalletRegistry.cs.meta | 11 - .../WebSocketExtensions.cs | 64 - .../WebSocketExtensions.cs.meta | 11 - Runtime/Algorand.Unity.WebSocket.meta | 8 - .../Algorand.Unity.WebSocket.asmdef | 16 - .../Algorand.Unity.WebSocket.asmdef.meta | 7 - .../IWebSocketClient.cs | 26 - .../IWebSocketClient.cs.meta | 11 - .../JSWebSocketClient.cs | 112 -- .../JSWebSocketClient.cs.meta | 11 - .../JSWebSocketClient.jslib | 139 -- .../JSWebSocketClient.jslib.meta | 32 - Runtime/Algorand.Unity.WebSocket/LICENSE.md | 9 - .../Algorand.Unity.WebSocket/LICENSE.md.meta | 7 - .../NativeWebSocketClient.cs | 211 --- .../NativeWebSocketClient.cs.meta | 11 - Runtime/Algorand.Unity.WebSocket/README.md | 9 - .../Algorand.Unity.WebSocket/README.md.meta | 7 - .../WebSocketClientFactory.cs | 78 - .../WebSocketClientFactory.cs.meta | 11 - .../WebSocketEvent.cs | 20 - .../WebSocketEvent.cs.meta | 11 - Runtime/zxing.unity.meta | 8 - Runtime/zxing.unity/LICENSE.md | 13 - Runtime/zxing.unity/LICENSE.md.meta | 7 - Runtime/zxing.unity/README.md | 4 - Runtime/zxing.unity/README.md.meta | 7 - Runtime/zxing.unity/Source.meta | 8 - Runtime/zxing.unity/Source/lib.meta | 8 - .../zxing.unity/Source/lib/BarcodeFormat.cs | 95 -- .../Source/lib/BarcodeFormat.cs.meta | 11 - .../Source/lib/BarcodeWriter.Color32.cs | 32 - .../Source/lib/BarcodeWriter.Color32.cs.meta | 11 - .../Source/lib/BarcodeWriter.PixelData.cs | 34 - .../lib/BarcodeWriter.PixelData.cs.meta | 11 - .../Source/lib/BarcodeWriter.SvgImage.cs | 34 - .../Source/lib/BarcodeWriter.SvgImage.cs.meta | 11 - .../Source/lib/BarcodeWriterCustom.cs | 71 - .../Source/lib/BarcodeWriterCustom.cs.meta | 11 - .../Source/lib/BarcodeWriterGeneric.cs | 85 - .../Source/lib/BarcodeWriterGeneric.cs.meta | 11 - .../Source/lib/BaseLuminanceSource.cs | 228 --- .../Source/lib/BaseLuminanceSource.cs.meta | 11 - Runtime/zxing.unity/Source/lib/Binarizer.cs | 104 -- .../zxing.unity/Source/lib/Binarizer.cs.meta | 11 - .../zxing.unity/Source/lib/BinaryBitmap.cs | 182 --- .../Source/lib/BinaryBitmap.cs.meta | 11 - .../zxing.unity/Source/lib/DecodeHintType.cs | 131 -- .../Source/lib/DecodeHintType.cs.meta | 11 - Runtime/zxing.unity/Source/lib/Dimension.cs | 93 -- .../zxing.unity/Source/lib/Dimension.cs.meta | 11 - .../zxing.unity/Source/lib/EncodeHintType.cs | 189 --- .../Source/lib/EncodeHintType.cs.meta | 11 - .../Source/lib/IBarcodeWriter.Color32.cs | 35 - .../Source/lib/IBarcodeWriter.Color32.cs.meta | 11 - .../Source/lib/IBarcodeWriter.PixelData.cs | 37 - .../lib/IBarcodeWriter.PixelData.cs.meta | 11 - .../Source/lib/IBarcodeWriter.SvgImage.cs | 37 - .../lib/IBarcodeWriter.SvgImage.cs.meta | 11 - .../zxing.unity/Source/lib/IBarcodeWriter.cs | 50 - .../Source/lib/IBarcodeWriter.cs.meta | 11 - .../Source/lib/IBarcodeWriterCustom.cs | 47 - .../Source/lib/IBarcodeWriterCustom.cs.meta | 11 - .../Source/lib/IBarcodeWriterGeneric.cs | 50 - .../Source/lib/IBarcodeWriterGeneric.cs.meta | 11 - .../Source/lib/InvertedLuminanceSource.cs | 154 -- .../lib/InvertedLuminanceSource.cs.meta | 11 - .../zxing.unity/Source/lib/LuminanceSource.cs | 207 --- .../Source/lib/LuminanceSource.cs.meta | 11 - .../Source/lib/PlanarYUVLuminanceSource.cs | 267 ---- .../lib/PlanarYUVLuminanceSource.cs.meta | 11 - .../Source/lib/RGBLuminanceSource.cs | 380 ----- .../Source/lib/RGBLuminanceSource.cs.meta | 11 - Runtime/zxing.unity/Source/lib/Result.cs | 198 --- Runtime/zxing.unity/Source/lib/Result.cs.meta | 11 - .../Source/lib/ResultMetadataType.cs | 108 -- .../Source/lib/ResultMetadataType.cs.meta | 11 - Runtime/zxing.unity/Source/lib/ResultPoint.cs | 196 --- .../Source/lib/ResultPoint.cs.meta | 11 - .../Source/lib/ResultPointCallback.cs | 26 - .../Source/lib/ResultPointCallback.cs.meta | 11 - .../zxing.unity/Source/lib/SupportClass.cs | 185 --- .../Source/lib/SupportClass.cs.meta | 11 - Runtime/zxing.unity/Source/lib/Writer.cs | 51 - Runtime/zxing.unity/Source/lib/Writer.cs.meta | 11 - .../zxing.unity/Source/lib/WriterException.cs | 55 - .../Source/lib/WriterException.cs.meta | 11 - Runtime/zxing.unity/Source/lib/common.meta | 8 - .../Source/lib/common/BigInteger.meta | 8 - .../lib/common/BigInteger/Base10BigInteger.cs | 766 --------- .../BigInteger/Base10BigInteger.cs.meta | 11 - .../lib/common/BigInteger/BigInteger.cs | 1377 ----------------- .../lib/common/BigInteger/BigInteger.cs.meta | 11 - .../common/BigInteger/BigIntegerException.cs | 22 - .../BigInteger/BigIntegerException.cs.meta | 11 - .../Source/lib/common/BigInteger/Sign.cs | 9 - .../Source/lib/common/BigInteger/Sign.cs.meta | 11 - .../zxing.unity/Source/lib/common/BitArray.cs | 494 ------ .../Source/lib/common/BitArray.cs.meta | 11 - .../Source/lib/common/BitMatrix.cs | 695 --------- .../Source/lib/common/BitMatrix.cs.meta | 11 - .../Source/lib/common/BitSource.cs | 124 -- .../Source/lib/common/BitSource.cs.meta | 11 - .../Source/lib/common/CharacterSetECI.cs | 204 --- .../Source/lib/common/CharacterSetECI.cs.meta | 11 - .../Source/lib/common/DecoderResult.cs | 194 --- .../Source/lib/common/DecoderResult.cs.meta | 11 - .../Source/lib/common/DecodingOptions.cs | 545 ------- .../Source/lib/common/DecodingOptions.cs.meta | 11 - .../Source/lib/common/DefaultGridSampler.cs | 122 -- .../lib/common/DefaultGridSampler.cs.meta | 11 - .../Source/lib/common/DetectorResult.cs | 47 - .../Source/lib/common/DetectorResult.cs.meta | 11 - Runtime/zxing.unity/Source/lib/common/ECI.cs | 54 - .../zxing.unity/Source/lib/common/ECI.cs.meta | 11 - .../Source/lib/common/EncodingOptions.cs | 139 -- .../Source/lib/common/EncodingOptions.cs.meta | 11 - .../lib/common/GlobalHistogramBinarizer.cs | 260 ---- .../common/GlobalHistogramBinarizer.cs.meta | 11 - .../Source/lib/common/GridSampler.cs | 204 --- .../Source/lib/common/GridSampler.cs.meta | 11 - .../Source/lib/common/HybridBinarizer.cs | 298 ---- .../Source/lib/common/HybridBinarizer.cs.meta | 11 - .../Source/lib/common/PerspectiveTransform.cs | 203 --- .../lib/common/PerspectiveTransform.cs.meta | 11 - .../Source/lib/common/StringUtils.cs | 335 ---- .../Source/lib/common/StringUtils.cs.meta | 11 - .../Source/lib/common/detector.meta | 8 - .../Source/lib/common/detector/MathUtils.cs | 87 -- .../lib/common/detector/MathUtils.cs.meta | 11 - .../detector/MonochromeRectangleDetector.cs | 256 --- .../MonochromeRectangleDetector.cs.meta | 11 - .../common/detector/WhiteRectangleDetector.cs | 406 ----- .../detector/WhiteRectangleDetector.cs.meta | 11 - .../Source/lib/common/reedsolomon.meta | 8 - .../lib/common/reedsolomon/GenericGF.cs | 234 --- .../lib/common/reedsolomon/GenericGF.cs.meta | 11 - .../lib/common/reedsolomon/GenericGFPoly.cs | 342 ---- .../common/reedsolomon/GenericGFPoly.cs.meta | 11 - .../common/reedsolomon/ReedSolomonDecoder.cs | 231 --- .../reedsolomon/ReedSolomonDecoder.cs.meta | 11 - .../common/reedsolomon/ReedSolomonEncoder.cs | 93 -- .../reedsolomon/ReedSolomonEncoder.cs.meta | 11 - Runtime/zxing.unity/Source/lib/qrcode.meta | 8 - .../Source/lib/qrcode/QRCodeWriter.cs | 168 -- .../Source/lib/qrcode/QRCodeWriter.cs.meta | 11 - .../Source/lib/qrcode/decoder.meta | 8 - .../lib/qrcode/decoder/BitMatrixParser.cs | 279 ---- .../qrcode/decoder/BitMatrixParser.cs.meta | 11 - .../Source/lib/qrcode/decoder/DataBlock.cs | 146 -- .../lib/qrcode/decoder/DataBlock.cs.meta | 11 - .../Source/lib/qrcode/decoder/DataMask.cs | 73 - .../lib/qrcode/decoder/DataMask.cs.meta | 11 - .../qrcode/decoder/DecodedBitStreamParser.cs | 474 ------ .../decoder/DecodedBitStreamParser.cs.meta | 11 - .../Source/lib/qrcode/decoder/Decoder.cs | 186 --- .../Source/lib/qrcode/decoder/Decoder.cs.meta | 11 - .../qrcode/decoder/ErrorCorrectionLevel.cs | 109 -- .../decoder/ErrorCorrectionLevel.cs.meta | 11 - .../lib/qrcode/decoder/FormatInformation.cs | 197 --- .../qrcode/decoder/FormatInformation.cs.meta | 11 - .../Source/lib/qrcode/decoder/Mode.cs | 214 --- .../Source/lib/qrcode/decoder/Mode.cs.meta | 11 - .../qrcode/decoder/QRCodeDecoderMetaData.cs | 60 - .../decoder/QRCodeDecoderMetaData.cs.meta | 11 - .../Source/lib/qrcode/decoder/Version.cs | 684 -------- .../Source/lib/qrcode/decoder/Version.cs.meta | 11 - .../Source/lib/qrcode/detector.meta | 8 - .../lib/qrcode/detector/AlignmentPattern.cs | 68 - .../qrcode/detector/AlignmentPattern.cs.meta | 11 - .../qrcode/detector/AlignmentPatternFinder.cs | 324 ---- .../detector/AlignmentPatternFinder.cs.meta | 11 - .../Source/lib/qrcode/detector/Detector.cs | 434 ------ .../lib/qrcode/detector/Detector.cs.meta | 11 - .../lib/qrcode/detector/FinderPattern.cs | 100 -- .../lib/qrcode/detector/FinderPattern.cs.meta | 11 - .../qrcode/detector/FinderPatternFinder.cs | 883 ----------- .../detector/FinderPatternFinder.cs.meta | 11 - .../lib/qrcode/detector/FinderPatternInfo.cs | 74 - .../qrcode/detector/FinderPatternInfo.cs.meta | 11 - .../Source/lib/qrcode/encoder.meta | 8 - .../Source/lib/qrcode/encoder/BlockPair.cs | 40 - .../lib/qrcode/encoder/BlockPair.cs.meta | 11 - .../Source/lib/qrcode/encoder/ByteMatrix.cs | 150 -- .../lib/qrcode/encoder/ByteMatrix.cs.meta | 11 - .../Source/lib/qrcode/encoder/Encoder.cs | 807 ---------- .../Source/lib/qrcode/encoder/Encoder.cs.meta | 11 - .../Source/lib/qrcode/encoder/MaskUtil.cs | 285 ---- .../lib/qrcode/encoder/MaskUtil.cs.meta | 11 - .../Source/lib/qrcode/encoder/MatrixUtil.cs | 603 -------- .../lib/qrcode/encoder/MatrixUtil.cs.meta | 11 - .../lib/qrcode/encoder/MinimalEncoder.cs | 932 ----------- .../lib/qrcode/encoder/MinimalEncoder.cs.meta | 11 - .../Source/lib/qrcode/encoder/QRCode.cs | 125 -- .../Source/lib/qrcode/encoder/QRCode.cs.meta | 11 - .../qrcode/encoder/QrCodeEncodingOptions.cs | 163 -- .../encoder/QrCodeEncodingOptions.cs.meta | 11 - Runtime/zxing.unity/Source/lib/renderer.meta | 8 - .../Source/lib/renderer/IBarcodeRenderer.cs | 54 - .../lib/renderer/IBarcodeRenderer.cs.meta | 11 - .../Source/lib/renderer/PixelData.Color32.cs | 50 - .../lib/renderer/PixelData.Color32.cs.meta | 11 - .../Source/lib/renderer/PixelData.cs | 44 - .../Source/lib/renderer/PixelData.cs.meta | 11 - .../Source/lib/renderer/PixelDataRenderer.cs | 152 -- .../lib/renderer/PixelDataRenderer.cs.meta | 11 - .../Source/lib/renderer/SVGRenderer.cs | 351 ----- .../Source/lib/renderer/SVGRenderer.cs.meta | 11 - Runtime/zxing.unity/Source/lib/unity.meta | 8 - .../lib/unity/Color32LuminanceSource.cs | 85 - .../lib/unity/Color32LuminanceSource.cs.meta | 11 - .../Source/lib/unity/Color32Renderer.cs | 115 -- .../Source/lib/unity/Color32Renderer.cs.meta | 11 - Runtime/zxing.unity/zxing.unity.asmdef | 14 - Runtime/zxing.unity/zxing.unity.asmdef.meta | 7 - Samples~/EditorWallets.meta | 8 - Samples~/EditorWallets/Editor.meta | 8 - ....Unity.Samples.EditorWallets.Editor.asmdef | 22 - ...y.Samples.EditorWallets.Editor.asmdef.meta | 7 - Samples~/EditorWallets/Editor/UI.meta | 8 - .../UI/WalletConnectAccountEditorWindow.uxml | 27 - ...WalletConnectAccountEditorWindow.uxml.meta | 10 - .../Editor/VisualElementExtensions.cs | 14 - .../Editor/VisualElementExtensions.cs.meta | 11 - .../WalletConnectAccountEditorWindow.cs | 211 --- .../WalletConnectAccountEditorWindow.cs.meta | 15 - .../WalletConnectAccountObjectEditor.cs | 68 - .../WalletConnectAccountObjectEditor.cs.meta | 11 - Samples~/EditorWallets/README.md | 4 - Samples~/EditorWallets/README.md.meta | 7 - Samples~/EditorWallets/Runtime.meta | 8 - ...lgorand.Unity.Samples.EditorWallets.asmdef | 18 - ...nd.Unity.Samples.EditorWallets.asmdef.meta | 7 - .../Runtime/AsyncSignerAccountObject.cs | 13 - .../Runtime/AsyncSignerAccountObject.cs.meta | 11 - .../Runtime/BaseAccountObject.cs | 11 - .../Runtime/BaseAccountObject.cs.meta | 11 - .../Runtime/WalletConnectAccountObject.cs | 67 - .../WalletConnectAccountObject.cs.meta | 11 - Samples~/WalletConnect.meta | 8 - ...lgorand.Unity.Samples.WalletConnect.asmdef | 18 - ...nd.Unity.Samples.WalletConnect.asmdef.meta | 7 - Samples~/WalletConnect/WalletConnectCanvas.cs | 61 - .../WalletConnect/WalletConnectCanvas.cs.meta | 11 - .../WalletConnect/WalletConnectDemo.unity | 3 - .../WalletConnectDemo.unity.meta | 7 - .../WalletConnect/WalletConnectManager.cs | 202 --- .../WalletConnectManager.cs.meta | 11 - .../Algorand.Unity.WalletConnect.Tests.meta | 8 - .../Algorand.Unity.WalletConnect.Tests.asmdef | 31 - ...rand.Unity.WalletConnect.Tests.asmdef.meta | 7 - .../AppEntryTest.cs | 23 - .../AppEntryTest.cs.meta | 11 - .../NetworkMessageTest.cs | 27 - .../NetworkMessageTest.cs.meta | 11 - .../WalletConnectPokeTest.cs | 71 - .../WalletConnectPokeTest.cs.meta | 11 - docs/TableOfContents.md | 2 - .../creating_asas_in_editor.md | 2 +- .../getting_started/your_first_transaction.md | 3 - docs/integration_with_the_dotnet_sdk.md | 47 - docs/walletconnect.md | 157 -- package.json | 12 +- 511 files changed, 4 insertions(+), 30091 deletions(-) delete mode 100644 Algorand.Unity.Package/Assets/TestDocsCompile/WalletConnect.cs delete mode 100644 Algorand.Unity.Package/Assets/TestDocsCompile/WalletConnect.cs.meta delete mode 100644 Algorand.Unity.Package/Assets/TestWalletConnectV2.meta delete mode 100644 Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts.meta delete mode 100644 Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts/TestWalletConnectV2.asmdef delete mode 100644 Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts/TestWalletConnectV2.asmdef.meta delete mode 100644 Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts/WalletConnectClient.cs delete mode 100644 Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts/WalletConnectClient.cs.meta delete mode 100644 Algorand.Unity.Package/Assets/TestWalletConnectV2/WalletConnectV2.unity delete mode 100644 Algorand.Unity.Package/Assets/TestWalletConnectV2/WalletConnectV2.unity.meta delete mode 100644 Runtime/Algorand.Unity.JsonRpc.meta delete mode 100644 Runtime/Algorand.Unity.JsonRpc/Algorand.Unity.JsonRpc.asmdef delete mode 100644 Runtime/Algorand.Unity.JsonRpc/Algorand.Unity.JsonRpc.asmdef.meta delete mode 100644 Runtime/Algorand.Unity.JsonRpc/Formatters.gen.meta delete mode 100644 Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcError.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcError.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcRequest.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcRequest.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcResponse.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcResponse.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.JsonRpc/JsonRpcError.cs delete mode 100644 Runtime/Algorand.Unity.JsonRpc/JsonRpcError.cs.meta delete mode 100644 Runtime/Algorand.Unity.JsonRpc/JsonRpcEvent.cs delete mode 100644 Runtime/Algorand.Unity.JsonRpc/JsonRpcEvent.cs.meta delete mode 100644 Runtime/Algorand.Unity.JsonRpc/JsonRpcEventType.cs delete mode 100644 Runtime/Algorand.Unity.JsonRpc/JsonRpcEventType.cs.meta delete mode 100644 Runtime/Algorand.Unity.JsonRpc/JsonRpcRequest.cs delete mode 100644 Runtime/Algorand.Unity.JsonRpc/JsonRpcRequest.cs.meta delete mode 100644 Runtime/Algorand.Unity.JsonRpc/JsonRpcResponse.cs delete mode 100644 Runtime/Algorand.Unity.JsonRpc/JsonRpcResponse.cs.meta delete mode 100644 Runtime/Algorand.Unity.QrCode.meta delete mode 100644 Runtime/Algorand.Unity.QrCode/Algorand.Unity.QrCode.asmdef delete mode 100644 Runtime/Algorand.Unity.QrCode/Algorand.Unity.QrCode.asmdef.meta delete mode 100644 Runtime/Algorand.Unity.QrCode/QrCodeUtility.cs delete mode 100644 Runtime/Algorand.Unity.QrCode/QrCodeUtility.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Algorand.Unity.WalletConnect.Core.asmdef delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Algorand.Unity.WalletConnect.Core.asmdef.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/ClientOptions.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/ClientOptions.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Crypto.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Envelope.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Envelope.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Crypto/EnvelopeType.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Crypto/EnvelopeType.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtHeader.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtHeader.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtIssuer.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtIssuer.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtPayload.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtPayload.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtUrl.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtUrl.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Error.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Error.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ErrorResponse.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ErrorResponse.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/FetchMessagesPayload.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/FetchMessagesPayload.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtHeader.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtHeader.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtIssuer.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtIssuer.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtPayload.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtPayload.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Metadata.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Metadata.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Namespace.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Namespace.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/OptionalNamespaces.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/OptionalNamespaces.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Participant.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Participant.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ProtocolOptions.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ProtocolOptions.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/PublishPayload.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/PublishPayload.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ReceivedMessage.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ReceivedMessage.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/RequiredNamespaces.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/RequiredNamespaces.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SessionProperties.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SessionProperties.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SessionProposePayload.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SessionProposePayload.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SubscribePayload.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SubscribePayload.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SubscriptionPayload.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SubscriptionPayload.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Topic.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Topic.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/UnsubscribePayload.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/UnsubscribePayload.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Error.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Error.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ErrorResponse.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ErrorResponse.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Metadata.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Metadata.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingErrorCode.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingErrorCode.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingMethods.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingMethods.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingUri.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingUri.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/Namespace.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/Namespace.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/OptionalNamespaces.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/OptionalNamespaces.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/Participant.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/Participant.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/RequiredNamespaces.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/RequiredNamespaces.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/SessionProperties.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/SessionProperties.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/SessionProposePayload.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/SessionProposePayload.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ProtocolOptions.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ProtocolOptions.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ProtocolType.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ProtocolType.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/SymKey.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Pairing/SymKey.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/MessageId.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/MessageId.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/FetchMessagesPayload.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/FetchMessagesPayload.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/PublishPayload.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/PublishPayload.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/ReceivedMessage.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/ReceivedMessage.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/SubscribePayload.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/SubscribePayload.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/SubscriptionPayload.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/SubscriptionPayload.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/UnsubscribePayload.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/UnsubscribePayload.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/RelayClient.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/RelayClient.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/RpcId.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/RpcId.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/Topic.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/Topic.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/UserAgent.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/Relay/UserAgent.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/TimeToLive.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Core/TimeToLive.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Sign.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Sign/Algorand.Unity.WalletConnect.Sign.asmdef delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Sign/Algorand.Unity.WalletConnect.Sign.asmdef.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Sign/WalletConnectSignError.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect.Sign/WalletConnectSignError.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Algorand.Unity.WalletConnect.asmdef delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Algorand.Unity.WalletConnect.asmdef.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/AlgorandWalletConnectSession.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/AlgorandWalletConnectSession.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/AppEntry.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/AppEntry.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Crypto.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Crypto/AesCipher.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Crypto/AesCipher.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/ClientMeta.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/ClientMeta.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/EncryptedPayload.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/EncryptedPayload.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcError.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcError.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcRequest.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcRequest.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcResponse.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcResponse.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/MultisigMetadata.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/MultisigMetadata.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/NetworkMessage.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/NetworkMessage.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/SignTxnsError.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/SignTxnsError.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/SignTxnsOpts.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/SignTxnsOpts.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletConnectSessionData.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletConnectSessionData.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletConnectSessionRequest.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletConnectSessionRequest.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletTransaction.Formatters.gen.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletTransaction.Formatters.gen.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/HandshakeUrl.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/HandshakeUrl.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/IWalletConnectAccount.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/IWalletConnectAccount.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/IWalletConnectSession.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/IWalletConnectSession.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/JsonRpc.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/JsonRpc.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/JsonRpcClient.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/JsonRpcClient.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/ClientMeta.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/ClientMeta.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/EncryptedPayload.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/EncryptedPayload.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcError.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcError.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcRequest.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcRequest.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcResponse.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcResponse.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/MultisigMetadata.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/MultisigMetadata.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/NetworkMessage.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/NetworkMessage.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/SessionData.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/SessionData.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/SignTxnsError.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/SignTxnsError.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/SignTxnsOpts.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/SignTxnsOpts.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectRpc.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectRpc.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectSessionData.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectSessionData.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectSessionRequest.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectSessionRequest.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/WalletTransaction.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Models/WalletTransaction.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/SessionStatus.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/SessionStatus.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Utils.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Utils/DefaultBridge.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Utils/DefaultBridge.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Utils/RpcPayload.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/Utils/RpcPayload.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/WalletConnectAccount.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/WalletConnectAccount.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/WalletConnectSessionEvents.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/WalletConnectSessionEvents.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/WalletRegistry.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/WalletRegistry.cs.meta delete mode 100644 Runtime/Algorand.Unity.WalletConnect/WebSocketExtensions.cs delete mode 100644 Runtime/Algorand.Unity.WalletConnect/WebSocketExtensions.cs.meta delete mode 100644 Runtime/Algorand.Unity.WebSocket.meta delete mode 100644 Runtime/Algorand.Unity.WebSocket/Algorand.Unity.WebSocket.asmdef delete mode 100644 Runtime/Algorand.Unity.WebSocket/Algorand.Unity.WebSocket.asmdef.meta delete mode 100644 Runtime/Algorand.Unity.WebSocket/IWebSocketClient.cs delete mode 100644 Runtime/Algorand.Unity.WebSocket/IWebSocketClient.cs.meta delete mode 100644 Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.cs delete mode 100644 Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.cs.meta delete mode 100644 Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.jslib delete mode 100644 Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.jslib.meta delete mode 100644 Runtime/Algorand.Unity.WebSocket/LICENSE.md delete mode 100644 Runtime/Algorand.Unity.WebSocket/LICENSE.md.meta delete mode 100644 Runtime/Algorand.Unity.WebSocket/NativeWebSocketClient.cs delete mode 100644 Runtime/Algorand.Unity.WebSocket/NativeWebSocketClient.cs.meta delete mode 100644 Runtime/Algorand.Unity.WebSocket/README.md delete mode 100644 Runtime/Algorand.Unity.WebSocket/README.md.meta delete mode 100644 Runtime/Algorand.Unity.WebSocket/WebSocketClientFactory.cs delete mode 100644 Runtime/Algorand.Unity.WebSocket/WebSocketClientFactory.cs.meta delete mode 100644 Runtime/Algorand.Unity.WebSocket/WebSocketEvent.cs delete mode 100644 Runtime/Algorand.Unity.WebSocket/WebSocketEvent.cs.meta delete mode 100644 Runtime/zxing.unity.meta delete mode 100644 Runtime/zxing.unity/LICENSE.md delete mode 100644 Runtime/zxing.unity/LICENSE.md.meta delete mode 100644 Runtime/zxing.unity/README.md delete mode 100644 Runtime/zxing.unity/README.md.meta delete mode 100644 Runtime/zxing.unity/Source.meta delete mode 100644 Runtime/zxing.unity/Source/lib.meta delete mode 100644 Runtime/zxing.unity/Source/lib/BarcodeFormat.cs delete mode 100644 Runtime/zxing.unity/Source/lib/BarcodeFormat.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/BarcodeWriter.Color32.cs delete mode 100644 Runtime/zxing.unity/Source/lib/BarcodeWriter.Color32.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/BarcodeWriter.PixelData.cs delete mode 100644 Runtime/zxing.unity/Source/lib/BarcodeWriter.PixelData.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/BarcodeWriter.SvgImage.cs delete mode 100644 Runtime/zxing.unity/Source/lib/BarcodeWriter.SvgImage.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/BarcodeWriterCustom.cs delete mode 100644 Runtime/zxing.unity/Source/lib/BarcodeWriterCustom.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/BarcodeWriterGeneric.cs delete mode 100644 Runtime/zxing.unity/Source/lib/BarcodeWriterGeneric.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/BaseLuminanceSource.cs delete mode 100644 Runtime/zxing.unity/Source/lib/BaseLuminanceSource.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/Binarizer.cs delete mode 100644 Runtime/zxing.unity/Source/lib/Binarizer.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/BinaryBitmap.cs delete mode 100644 Runtime/zxing.unity/Source/lib/BinaryBitmap.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/DecodeHintType.cs delete mode 100644 Runtime/zxing.unity/Source/lib/DecodeHintType.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/Dimension.cs delete mode 100644 Runtime/zxing.unity/Source/lib/Dimension.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/EncodeHintType.cs delete mode 100644 Runtime/zxing.unity/Source/lib/EncodeHintType.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/IBarcodeWriter.Color32.cs delete mode 100644 Runtime/zxing.unity/Source/lib/IBarcodeWriter.Color32.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/IBarcodeWriter.PixelData.cs delete mode 100644 Runtime/zxing.unity/Source/lib/IBarcodeWriter.PixelData.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/IBarcodeWriter.SvgImage.cs delete mode 100644 Runtime/zxing.unity/Source/lib/IBarcodeWriter.SvgImage.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/IBarcodeWriter.cs delete mode 100644 Runtime/zxing.unity/Source/lib/IBarcodeWriter.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/IBarcodeWriterCustom.cs delete mode 100644 Runtime/zxing.unity/Source/lib/IBarcodeWriterCustom.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/IBarcodeWriterGeneric.cs delete mode 100644 Runtime/zxing.unity/Source/lib/IBarcodeWriterGeneric.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/InvertedLuminanceSource.cs delete mode 100644 Runtime/zxing.unity/Source/lib/InvertedLuminanceSource.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/LuminanceSource.cs delete mode 100644 Runtime/zxing.unity/Source/lib/LuminanceSource.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/PlanarYUVLuminanceSource.cs delete mode 100644 Runtime/zxing.unity/Source/lib/PlanarYUVLuminanceSource.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/RGBLuminanceSource.cs delete mode 100644 Runtime/zxing.unity/Source/lib/RGBLuminanceSource.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/Result.cs delete mode 100644 Runtime/zxing.unity/Source/lib/Result.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/ResultMetadataType.cs delete mode 100644 Runtime/zxing.unity/Source/lib/ResultMetadataType.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/ResultPoint.cs delete mode 100644 Runtime/zxing.unity/Source/lib/ResultPoint.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/ResultPointCallback.cs delete mode 100644 Runtime/zxing.unity/Source/lib/ResultPointCallback.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/SupportClass.cs delete mode 100644 Runtime/zxing.unity/Source/lib/SupportClass.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/Writer.cs delete mode 100644 Runtime/zxing.unity/Source/lib/Writer.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/WriterException.cs delete mode 100644 Runtime/zxing.unity/Source/lib/WriterException.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/BigInteger.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/BigInteger/Base10BigInteger.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/BigInteger/Base10BigInteger.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/BigInteger/BigInteger.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/BigInteger/BigInteger.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/BigInteger/BigIntegerException.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/BigInteger/BigIntegerException.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/BigInteger/Sign.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/BigInteger/Sign.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/BitArray.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/BitArray.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/BitMatrix.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/BitMatrix.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/BitSource.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/BitSource.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/CharacterSetECI.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/CharacterSetECI.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/DecoderResult.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/DecoderResult.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/DecodingOptions.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/DecodingOptions.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/DefaultGridSampler.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/DefaultGridSampler.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/DetectorResult.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/DetectorResult.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/ECI.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/ECI.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/EncodingOptions.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/EncodingOptions.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/GlobalHistogramBinarizer.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/GlobalHistogramBinarizer.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/GridSampler.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/GridSampler.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/HybridBinarizer.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/HybridBinarizer.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/PerspectiveTransform.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/PerspectiveTransform.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/StringUtils.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/StringUtils.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/detector.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/detector/MathUtils.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/detector/MathUtils.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/detector/MonochromeRectangleDetector.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/detector/MonochromeRectangleDetector.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/detector/WhiteRectangleDetector.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/detector/WhiteRectangleDetector.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/reedsolomon.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/reedsolomon/GenericGF.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/reedsolomon/GenericGF.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/reedsolomon/GenericGFPoly.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/reedsolomon/GenericGFPoly.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/reedsolomon/ReedSolomonDecoder.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/reedsolomon/ReedSolomonDecoder.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/common/reedsolomon/ReedSolomonEncoder.cs delete mode 100644 Runtime/zxing.unity/Source/lib/common/reedsolomon/ReedSolomonEncoder.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/QRCodeWriter.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/QRCodeWriter.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/BitMatrixParser.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/BitMatrixParser.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/DataBlock.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/DataBlock.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/DataMask.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/DataMask.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/DecodedBitStreamParser.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/DecodedBitStreamParser.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/Decoder.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/Decoder.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/ErrorCorrectionLevel.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/ErrorCorrectionLevel.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/FormatInformation.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/FormatInformation.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/Mode.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/Mode.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/QRCodeDecoderMetaData.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/QRCodeDecoderMetaData.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/Version.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/decoder/Version.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/detector.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/detector/AlignmentPattern.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/detector/AlignmentPattern.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/detector/AlignmentPatternFinder.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/detector/AlignmentPatternFinder.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/detector/Detector.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/detector/Detector.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPattern.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPattern.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPatternFinder.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPatternFinder.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPatternInfo.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPatternInfo.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder/BlockPair.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder/BlockPair.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder/ByteMatrix.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder/ByteMatrix.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder/Encoder.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder/Encoder.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder/MaskUtil.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder/MaskUtil.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder/MatrixUtil.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder/MatrixUtil.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder/MinimalEncoder.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder/MinimalEncoder.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder/QRCode.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder/QRCode.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder/QrCodeEncodingOptions.cs delete mode 100644 Runtime/zxing.unity/Source/lib/qrcode/encoder/QrCodeEncodingOptions.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/renderer.meta delete mode 100644 Runtime/zxing.unity/Source/lib/renderer/IBarcodeRenderer.cs delete mode 100644 Runtime/zxing.unity/Source/lib/renderer/IBarcodeRenderer.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/renderer/PixelData.Color32.cs delete mode 100644 Runtime/zxing.unity/Source/lib/renderer/PixelData.Color32.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/renderer/PixelData.cs delete mode 100644 Runtime/zxing.unity/Source/lib/renderer/PixelData.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/renderer/PixelDataRenderer.cs delete mode 100644 Runtime/zxing.unity/Source/lib/renderer/PixelDataRenderer.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/renderer/SVGRenderer.cs delete mode 100644 Runtime/zxing.unity/Source/lib/renderer/SVGRenderer.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/unity.meta delete mode 100644 Runtime/zxing.unity/Source/lib/unity/Color32LuminanceSource.cs delete mode 100644 Runtime/zxing.unity/Source/lib/unity/Color32LuminanceSource.cs.meta delete mode 100644 Runtime/zxing.unity/Source/lib/unity/Color32Renderer.cs delete mode 100644 Runtime/zxing.unity/Source/lib/unity/Color32Renderer.cs.meta delete mode 100644 Runtime/zxing.unity/zxing.unity.asmdef delete mode 100644 Runtime/zxing.unity/zxing.unity.asmdef.meta delete mode 100644 Samples~/EditorWallets.meta delete mode 100644 Samples~/EditorWallets/Editor.meta delete mode 100644 Samples~/EditorWallets/Editor/Algorand.Unity.Samples.EditorWallets.Editor.asmdef delete mode 100644 Samples~/EditorWallets/Editor/Algorand.Unity.Samples.EditorWallets.Editor.asmdef.meta delete mode 100644 Samples~/EditorWallets/Editor/UI.meta delete mode 100644 Samples~/EditorWallets/Editor/UI/WalletConnectAccountEditorWindow.uxml delete mode 100644 Samples~/EditorWallets/Editor/UI/WalletConnectAccountEditorWindow.uxml.meta delete mode 100644 Samples~/EditorWallets/Editor/VisualElementExtensions.cs delete mode 100644 Samples~/EditorWallets/Editor/VisualElementExtensions.cs.meta delete mode 100644 Samples~/EditorWallets/Editor/WalletConnectAccountEditorWindow.cs delete mode 100644 Samples~/EditorWallets/Editor/WalletConnectAccountEditorWindow.cs.meta delete mode 100644 Samples~/EditorWallets/Editor/WalletConnectAccountObjectEditor.cs delete mode 100644 Samples~/EditorWallets/Editor/WalletConnectAccountObjectEditor.cs.meta delete mode 100644 Samples~/EditorWallets/README.md delete mode 100644 Samples~/EditorWallets/README.md.meta delete mode 100644 Samples~/EditorWallets/Runtime.meta delete mode 100644 Samples~/EditorWallets/Runtime/Algorand.Unity.Samples.EditorWallets.asmdef delete mode 100644 Samples~/EditorWallets/Runtime/Algorand.Unity.Samples.EditorWallets.asmdef.meta delete mode 100644 Samples~/EditorWallets/Runtime/AsyncSignerAccountObject.cs delete mode 100644 Samples~/EditorWallets/Runtime/AsyncSignerAccountObject.cs.meta delete mode 100644 Samples~/EditorWallets/Runtime/BaseAccountObject.cs delete mode 100644 Samples~/EditorWallets/Runtime/BaseAccountObject.cs.meta delete mode 100644 Samples~/EditorWallets/Runtime/WalletConnectAccountObject.cs delete mode 100644 Samples~/EditorWallets/Runtime/WalletConnectAccountObject.cs.meta delete mode 100644 Samples~/WalletConnect.meta delete mode 100644 Samples~/WalletConnect/Algorand.Unity.Samples.WalletConnect.asmdef delete mode 100644 Samples~/WalletConnect/Algorand.Unity.Samples.WalletConnect.asmdef.meta delete mode 100644 Samples~/WalletConnect/WalletConnectCanvas.cs delete mode 100644 Samples~/WalletConnect/WalletConnectCanvas.cs.meta delete mode 100644 Samples~/WalletConnect/WalletConnectDemo.unity delete mode 100644 Samples~/WalletConnect/WalletConnectDemo.unity.meta delete mode 100644 Samples~/WalletConnect/WalletConnectManager.cs delete mode 100644 Samples~/WalletConnect/WalletConnectManager.cs.meta delete mode 100644 Tests/Runtime/Algorand.Unity.WalletConnect.Tests.meta delete mode 100644 Tests/Runtime/Algorand.Unity.WalletConnect.Tests/Algorand.Unity.WalletConnect.Tests.asmdef delete mode 100644 Tests/Runtime/Algorand.Unity.WalletConnect.Tests/Algorand.Unity.WalletConnect.Tests.asmdef.meta delete mode 100644 Tests/Runtime/Algorand.Unity.WalletConnect.Tests/AppEntryTest.cs delete mode 100644 Tests/Runtime/Algorand.Unity.WalletConnect.Tests/AppEntryTest.cs.meta delete mode 100644 Tests/Runtime/Algorand.Unity.WalletConnect.Tests/NetworkMessageTest.cs delete mode 100644 Tests/Runtime/Algorand.Unity.WalletConnect.Tests/NetworkMessageTest.cs.meta delete mode 100644 Tests/Runtime/Algorand.Unity.WalletConnect.Tests/WalletConnectPokeTest.cs delete mode 100644 Tests/Runtime/Algorand.Unity.WalletConnect.Tests/WalletConnectPokeTest.cs.meta delete mode 100644 docs/integration_with_the_dotnet_sdk.md delete mode 100644 docs/walletconnect.md diff --git a/.docfx/manual/toc.yml b/.docfx/manual/toc.yml index acf72d6ce..0aabfaa92 100644 --- a/.docfx/manual/toc.yml +++ b/.docfx/manual/toc.yml @@ -10,9 +10,5 @@ items: - name: Creating ASAs in the Editor href: ../../docs/algorand_standard_assets/creating_asas_in_editor.md -- name: WalletConnect - href: ../../docs/walletconnect.md -- name: Integration with the .NET SDK - href: ../../docs/integration_with_the_dotnet_sdk.md - name: Troubleshooting href: ../../docs/troubleshooting.md diff --git a/Algorand.Unity.Package/.vscode/settings.json b/Algorand.Unity.Package/.vscode/settings.json index 64cc7b048..01eae18b9 100644 --- a/Algorand.Unity.Package/.vscode/settings.json +++ b/Algorand.Unity.Package/.vscode/settings.json @@ -56,7 +56,6 @@ "upm", "dependencies", "developer", - "walletconnect", "asset-store", "algod", "kmd", @@ -69,4 +68,4 @@ "abi" ], "dotnet.defaultSolution": "Algorand.Unity.Package.sln" -} \ No newline at end of file +} diff --git a/Algorand.Unity.Package/Assets/TestDocsCompile/WalletConnect.cs b/Algorand.Unity.Package/Assets/TestDocsCompile/WalletConnect.cs deleted file mode 100644 index 12a390131..000000000 --- a/Algorand.Unity.Package/Assets/TestDocsCompile/WalletConnect.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Algorand.Unity; -using Algorand.Unity.WalletConnect; -using UnityEngine; - -public static class WalletConnectTest -{ - public static async void Main() - { - // 1. Create the session and show the user the QR Code - var dappMeta = new ClientMeta - { - Name = "", - Description = "", - Url = "", - IconUrls = new[] - { - "", "" - } - }; - var session = new AlgorandWalletConnectSession(dappMeta); - await session.Connect(); - // session is in no connection status - Debug.Assert(session.ConnectionStatus == SessionStatus.NoWalletConnected); - - var handshake = session.RequestWalletConnection(); - // session should now be in connecting status - Debug.Assert(session.ConnectionStatus == SessionStatus.RequestingWalletConnection); - - // show the user a QR Code - Texture2D qrCode = handshake.ToQrCodeTexture(); - // OR launch a supported wallet app - WalletRegistry.PeraWallet.LaunchForConnect(handshake); - - // 2. Wait for user to approve the connection - await session.WaitForWalletApproval(); - // session is now connected - Debug.Assert(session.ConnectionStatus == SessionStatus.WalletConnected); - - // 3. Send transactions to sign - var someTxnToSign = Transaction.Payment(default, default, default, default); - someTxnToSign.Sender = session.Accounts[0]; - var walletTransaction = WalletTransaction.New(someTxnToSign); - // In the case you used a QR Code, you can await immediately. - var signingTransactions = session.SignTransactions(new[] { walletTransaction }); - // If you are using Mobile Linking, you need to launch the app - WalletRegistry.PeraWallet.LaunchForSigning(); - var (signErr, signedTxns) = await signingTransactions; - } -} diff --git a/Algorand.Unity.Package/Assets/TestDocsCompile/WalletConnect.cs.meta b/Algorand.Unity.Package/Assets/TestDocsCompile/WalletConnect.cs.meta deleted file mode 100644 index 5a414643a..000000000 --- a/Algorand.Unity.Package/Assets/TestDocsCompile/WalletConnect.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 356846b78dd094794958ad15e34e29f8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Algorand.Unity.Package/Assets/TestWalletConnectV2.meta b/Algorand.Unity.Package/Assets/TestWalletConnectV2.meta deleted file mode 100644 index 82895cdaf..000000000 --- a/Algorand.Unity.Package/Assets/TestWalletConnectV2.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 57ae49c2d5d36447eaee04151a797596 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts.meta b/Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts.meta deleted file mode 100644 index 4f13ec4a8..000000000 --- a/Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7d0aa0af6c26b49febde186866835a5d -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts/TestWalletConnectV2.asmdef b/Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts/TestWalletConnectV2.asmdef deleted file mode 100644 index 5e5fad715..000000000 --- a/Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts/TestWalletConnectV2.asmdef +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "WalletConnectV2", - "rootNamespace": "WalletConnectV2", - "references": [ - "GUID:45ab5c0c2cb4a0e4ba897b731349c490", - "GUID:f8b80ea32105bf74aa022a9a7e066bc1", - "GUID:9f8c967ec86c9324c9b2928ff73b4cf1", - "GUID:2ee6601452ca245499e63674423f6541", - "GUID:70d524b45145c40acbd35603c8e43743", - "GUID:427b0dd64d04a4a02b8413b20fc93483", - "GUID:b0f3d95fe85d1421d9ef3667cce886bb", - "GUID:8dadf2ce3ffc34301a9f6d2e747938f6", - "GUID:3593772e9e2814b759387539d266dc24", - "GUID:96a3d11394a174143976db8839772a1a", - "GUID:05e3a0220cef448b5bedf723e2dd99f4", - "GUID:e0cd26848372d4e5c891c569017e11f1", - "GUID:d8b63aba1907145bea998dd612889d6b", - "GUID:2665a8d13d1b3f18800f46e256720795" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts/TestWalletConnectV2.asmdef.meta b/Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts/TestWalletConnectV2.asmdef.meta deleted file mode 100644 index af0f15b80..000000000 --- a/Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts/TestWalletConnectV2.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 1e3a2c4b1633a4bfab00216fd5bb0012 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts/WalletConnectClient.cs b/Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts/WalletConnectClient.cs deleted file mode 100644 index 6ca77bedb..000000000 --- a/Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts/WalletConnectClient.cs +++ /dev/null @@ -1,182 +0,0 @@ -using UnityEngine; -using Algorand.Unity.WalletConnect.Core; -using System.Collections; -using Algorand.Unity.JsonRpc; -using UnityEngine.UI; -using Algorand.Unity.QrCode; -using Unity.Collections.LowLevel.Unsafe; -using Algorand.Unity.Crypto; -using Crypto = Algorand.Unity.Crypto; -using Algorand.Unity; -using Unity.Collections; -using Algorand.Unity.Collections; -using System; -using Algorand.Unity.LowLevel; - -namespace WalletConnectV2 -{ - public class WalletConnectClient : MonoBehaviour - { - public Image qrCodeImage; - - public string relayUrl = "wss://relay.walletconnect.org"; - public string projectId = "da87b3345726d69030aa66218202ec19"; - public UserAgent userAgent = new UserAgent - { - protocol = "wc", - version = "2", - sdkVersion = "5.0.0-exp.1" - }; - - public Metadata clientMetadata = new Metadata - { - Description = "test app", - Url = "https://github.com/careboo/unity-algorand-sdk", - Icons = new[] { - "https://media.githubusercontent.com/media/CareBoo/unity-algorand-sdk/main/docs/images/logo_256.png", - "https://media.githubusercontent.com/media/CareBoo/unity-algorand-sdk/main/docs/images/logo_256.png", - "https://media.githubusercontent.com/media/CareBoo/unity-algorand-sdk/main/docs/images/logo_256.png" - }, - Name = "Algorand SDK for Unity" - }; - - IEnumerator Start() - { - var relayClient = new RelayClient(relayUrl, projectId, userAgent); - relayClient.Connect(); - - var msg = relayClient.Poll(); - while (msg.Type == JsonRpcEventType.Nothing) - { - yield return null; - msg = relayClient.Poll(); - } - - switch (msg.Type) - { - case JsonRpcEventType.Open: - Debug.Log("Got open"); - break; - case JsonRpcEventType.Close: - Debug.LogError($"Got close with reason: {msg.Reason}"); - yield break; - case JsonRpcEventType.Error: - Debug.LogError($"Got error with message: {msg.Error}"); - yield break; - default: - Debug.LogError($"Got unexpected message type: {msg.Type}"); - yield break; - } - - var pairingMethods = new PairingMethods - { - signMethods = new[] { "wc_sessionPropose", "algo_signTxn" } - }; - var pairingUri = new PairingUri(pairingMethods); - var pairingUriString = pairingUri.ToString(); - Debug.Log(pairingUriString); - qrCodeImage.sprite = QrCodeUtility.GenerateSprite(pairingUriString); - - var topic = pairingUri.topic; - var key = UnsafeUtility.As(ref pairingUri.symKey); - var nonce = Crypto.Random.Bytes(); - - var (publicKey, secretKey) = X25519.Keygen(); - Span publicKeyHex = stackalloc char[X25519.PublicKey.Size * 2]; - var hexError = HexConverter.ToHex(publicKey.AsReadOnlySpan(), publicKeyHex, out _); - if (hexError > 0) throw new Exception($"Failed to convert public key to hex: {hexError}"); - - var proposer = new Participant - { - PublicKey = publicKeyHex.ToString(), - Metadata = clientMetadata - }; - - var sessionProposeRequest = new SessionProposeRequestPayload(proposer); - - var request = new JsonRpcRequest - { - Id = RpcId.GenerateId(), - JsonRpc = "2.0", - Method = "wc_sessionPropose", - Params = sessionProposeRequest - }; - - string message; - using (var requestJson = AlgoApiSerializer.SerializeJson(request, Allocator.Temp)) - using (var encryptedEnvelope = Envelope.EncryptType0(requestJson.AsArray().AsReadOnlySpan(), key, nonce, Allocator.Temp)) - { - message = Convert.ToBase64String(encryptedEnvelope.ToArray()); - } - ulong ttl = 5 * 60; - var sessionProposeRelayId = relayClient.Publish(topic, message, 1101, ttl); - - var expiry = (ulong)DateTimeOffset.UtcNow.ToUnixTimeSeconds() + ttl; - - do - { - yield return null; - msg = relayClient.Poll(); - } - while (msg.Type == JsonRpcEventType.Nothing); - - switch (msg.Type) - { - case JsonRpcEventType.Response when msg.Response.Id == sessionProposeRelayId: - Debug.Log($"Got publish response: {AlgoApiSerializer.SerializeJson(msg.Response)}"); - break; - case JsonRpcEventType.Response: - Debug.LogError($"Got response with unexpected id: {AlgoApiSerializer.SerializeJson(msg.Response)}"); - yield break; - default: - Debug.LogError($"Got unexpected message type: {msg.Type}"); - yield break; - } - - var subscribeId = relayClient.Subscribe(topic); - - do - { - yield return null; - msg = relayClient.Poll(); - } - while (msg.Type == JsonRpcEventType.Nothing); - - switch (msg.Type) - { - case JsonRpcEventType.Response when msg.Response.Id == subscribeId: - Debug.Log($"Got subscription response: {AlgoApiSerializer.SerializeJson(msg.Response)}"); - break; - - default: - Debug.LogError($"Got unexpected message type: {msg.Type}"); - yield break; - } - - do - { - yield return null; - if ((ulong)DateTimeOffset.UtcNow.ToUnixTimeSeconds() >= expiry) - { - Debug.LogError("Session proposal expired"); - yield break; - } - msg = relayClient.Poll(); - } - while (msg.Type == JsonRpcEventType.Nothing); - - switch (msg.Type) - { - case JsonRpcEventType.Request: - Debug.Log($"Got request: {AlgoApiSerializer.SerializeJson(msg.Request)}"); - break; - case JsonRpcEventType.Response: - Debug.Log($"Got response: {AlgoApiSerializer.SerializeJson(msg.Response)}"); - break; - default: - Debug.LogError($"Got unexpected message type: {msg.Type}"); - yield break; - } - } - } -} diff --git a/Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts/WalletConnectClient.cs.meta b/Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts/WalletConnectClient.cs.meta deleted file mode 100644 index dd9ff73e4..000000000 --- a/Algorand.Unity.Package/Assets/TestWalletConnectV2/Scripts/WalletConnectClient.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9aab9e8f046734044b5ee2d08f15dba2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Algorand.Unity.Package/Assets/TestWalletConnectV2/WalletConnectV2.unity b/Algorand.Unity.Package/Assets/TestWalletConnectV2/WalletConnectV2.unity deleted file mode 100644 index fc3fb7fde..000000000 --- a/Algorand.Unity.Package/Assets/TestWalletConnectV2/WalletConnectV2.unity +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:18e2882854641774e97da2dfad11de63688b59137e87543e631e356310780db6 -size 19124 diff --git a/Algorand.Unity.Package/Assets/TestWalletConnectV2/WalletConnectV2.unity.meta b/Algorand.Unity.Package/Assets/TestWalletConnectV2/WalletConnectV2.unity.meta deleted file mode 100644 index ecbbb358d..000000000 --- a/Algorand.Unity.Package/Assets/TestWalletConnectV2/WalletConnectV2.unity.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: dd035a978824449368de6d6994c0913c -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Algorand.Unity.Package/upm.code-workspace b/Algorand.Unity.Package/upm.code-workspace index f2ead3832..25e08a51b 100644 --- a/Algorand.Unity.Package/upm.code-workspace +++ b/Algorand.Unity.Package/upm.code-workspace @@ -14,7 +14,6 @@ "upm", "dependencies", "developer", - "walletconnect", "asset-store", "algod", "kmd", diff --git a/README.md b/README.md index a90211953..59e7047d7 100755 --- a/README.md +++ b/README.md @@ -24,8 +24,7 @@ Algorand SDK for Unity Integrate your game with [Algorand](https://www.algorand.com/), a Pure Proof-of-Stake blockchain overseen by the Algorand Foundation. -Create and sign Algorand transactions, use Algorand's [REST APIs](https://developer.algorand.org/docs/rest-apis/restendpoints/), -and connect to any Algorand wallet supporting [WalletConnect](https://developer.algorand.org/docs/get-details/walletconnect/). +Create Algorand transactions, Algorand accounts, and use Algorand's [REST APIs](https://developer.algorand.org/docs/rest-apis/restendpoints/). ## Table of Contents @@ -35,9 +34,7 @@ and connect to any Algorand wallet supporting [WalletConnect](https://developer. - [Make a payment transaction](#make-a-payment-transaction) - [Sign the transaction with an account](#sign-the-transaction-with-an-account) - [Sign the transaction with `kmd`](#sign-the-transaction-with-kmd) - - [Sign the transaction with WalletConnect](#sign-the-transaction-with-walletconnect) - [Send the signed transaction](#send-the-signed-transaction) - - [Initiate a WalletConnect session and generate a QR Code](#initiate-a-walletconnect-session-and-generate-a-qr-code) - [Installation](#installation) - [Open UPM](#open-upm) - [Manually Adding UPM Scopes](#manually-adding-upm-scopes) @@ -90,46 +87,12 @@ var walletToken = await kmd.InitWalletHandleToken("", ""); ``` -#### Sign the transaction with WalletConnect: - -```csharp -using Algorand.Unity.WalletConnect; - -SavedSession savedSession = [...]; -var session = new AlgorandWalletConnectSession(savedSession); -var walletTransaction = WalletTransaction.New(paymentTxn); -var signedTxns = await session.SignTransactions(new[] { walletTransaction }); -var signedTxn = signedTxns[0]; -``` - #### Send the signed transaction: ```csharp await algod.SendTransaction(signedTxn); ``` -### Initiate a WalletConnect session and generate a QR Code: - -```csharp -using Algorand.Unity; -using Algorand.Unity.WalletConnect; -using UnityEngine; - -var dappMeta = new ClientMeta -{ - Name = "", - Description = "", - Url = "", - IconUrls = new[] - { - "", "" - } -}; -var session = new AlgorandWalletConnectSession(dappMeta); -var handshake = await session.StartConnection(); -Texture2D qrCode = handshake.ToQrCodeTexture(); -``` - ## Installation ### Open UPM @@ -164,5 +127,4 @@ Docs for this version were generated at https://careboo.github.io/unity-algorand Some of the samples are built on WebGL and hosted on GitHub Pages. -- [WalletConnect](https://careboo.github.io/unity-algorand-sdk/walletconnect) - [ABI](https://careboo.github.io/unity-algorand-sdk/abi) diff --git a/Runtime/Algorand.Unity.JsonRpc.meta b/Runtime/Algorand.Unity.JsonRpc.meta deleted file mode 100644 index d3357f4b8..000000000 --- a/Runtime/Algorand.Unity.JsonRpc.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 1b88ca37d0fe242dcb72736af77fec0c -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.JsonRpc/Algorand.Unity.JsonRpc.asmdef b/Runtime/Algorand.Unity.JsonRpc/Algorand.Unity.JsonRpc.asmdef deleted file mode 100644 index 9622b5cbd..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/Algorand.Unity.JsonRpc.asmdef +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "Algorand.Unity.JsonRpc", - "rootNamespace": "Algorand.Unity.JsonRpc", - "references": [ - "GUID:8dadf2ce3ffc34301a9f6d2e747938f6", - "GUID:45ab5c0c2cb4a0e4ba897b731349c490", - "GUID:427b0dd64d04a4a02b8413b20fc93483", - "GUID:2ee6601452ca245499e63674423f6541", - "GUID:9f8c967ec86c9324c9b2928ff73b4cf1", - "GUID:e0cd26848372d4e5c891c569017e11f1" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": false, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.JsonRpc/Algorand.Unity.JsonRpc.asmdef.meta b/Runtime/Algorand.Unity.JsonRpc/Algorand.Unity.JsonRpc.asmdef.meta deleted file mode 100644 index 440e0b544..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/Algorand.Unity.JsonRpc.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 3593772e9e2814b759387539d266dc24 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.JsonRpc/Formatters.gen.meta b/Runtime/Algorand.Unity.JsonRpc/Formatters.gen.meta deleted file mode 100644 index e7f45d060..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/Formatters.gen.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ac10f1db1eba34713af1c8ce1b207301 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcError.Formatters.gen.cs b/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcError.Formatters.gen.cs deleted file mode 100644 index a9a6191e4..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcError.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.JsonRpc -{ - - - public partial struct JsonRpcError - { - - private static bool @__generated__IsValid = JsonRpcError.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("code", (Algorand.Unity.JsonRpc.JsonRpcError x) => x.Code, (ref Algorand.Unity.JsonRpc.JsonRpcError x, System.Int32 value) => x.Code = value).Assign("message", (Algorand.Unity.JsonRpc.JsonRpcError x) => x.Message, (ref Algorand.Unity.JsonRpc.JsonRpcError x, System.String value) => x.Message = value, Algorand.Unity.StringComparer.Instance).Assign("data", (Algorand.Unity.JsonRpc.JsonRpcError x) => x.Data, (ref Algorand.Unity.JsonRpc.JsonRpcError x, Algorand.Unity.AlgoApiObject value) => x.Data = value)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcError.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcError.Formatters.gen.cs.meta deleted file mode 100644 index 25a0343b4..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcError.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9dc366a7225514409b93304e7b3833c9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcRequest.Formatters.gen.cs b/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcRequest.Formatters.gen.cs deleted file mode 100644 index 545f9ec99..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcRequest.Formatters.gen.cs +++ /dev/null @@ -1,46 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.JsonRpc -{ - - - public partial struct JsonRpcRequest - { - - private static bool @__generated__IsValid = JsonRpcRequest.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(true).Assign("id", (Algorand.Unity.JsonRpc.JsonRpcRequest x) => x.Id, (ref Algorand.Unity.JsonRpc.JsonRpcRequest x, Algorand.Unity.Optional value) => x.Id = value).Assign("jsonrpc", (Algorand.Unity.JsonRpc.JsonRpcRequest x) => x.JsonRpc, (ref Algorand.Unity.JsonRpc.JsonRpcRequest x, System.String value) => x.JsonRpc = value, Algorand.Unity.StringComparer.Instance).Assign("method", (Algorand.Unity.JsonRpc.JsonRpcRequest x) => x.Method, (ref Algorand.Unity.JsonRpc.JsonRpcRequest x, System.String value) => x.Method = value, Algorand.Unity.StringComparer.Instance).Assign("params", (Algorand.Unity.JsonRpc.JsonRpcRequest x) => x.Params, (ref Algorand.Unity.JsonRpc.JsonRpcRequest x, Algorand.Unity.AlgoApiObject value) => x.Params = value)); - return true; - } - } -} - -namespace Algorand.Unity.JsonRpc -{ - - - public partial struct JsonRpcRequest - { - - private static bool @__generated__IsValid = JsonRpcRequest.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add>(new Algorand.Unity.AlgoApiObjectFormatter>(true).Assign("id", (Algorand.Unity.JsonRpc.JsonRpcRequest x) => x.Id, (ref Algorand.Unity.JsonRpc.JsonRpcRequest x, Algorand.Unity.Optional value) => x.Id = value).Assign("jsonrpc", (Algorand.Unity.JsonRpc.JsonRpcRequest x) => x.JsonRpc, (ref Algorand.Unity.JsonRpc.JsonRpcRequest x, System.String value) => x.JsonRpc = value, Algorand.Unity.StringComparer.Instance).Assign("method", (Algorand.Unity.JsonRpc.JsonRpcRequest x) => x.Method, (ref Algorand.Unity.JsonRpc.JsonRpcRequest x, System.String value) => x.Method = value, Algorand.Unity.StringComparer.Instance).Assign("params", (Algorand.Unity.JsonRpc.JsonRpcRequest x) => x.Params, (ref Algorand.Unity.JsonRpc.JsonRpcRequest x, T value) => x.Params = value)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcRequest.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcRequest.Formatters.gen.cs.meta deleted file mode 100644 index ecfb73fb6..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcRequest.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: abf4fa3fa56554db8be76aa793e1b860 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcResponse.Formatters.gen.cs b/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcResponse.Formatters.gen.cs deleted file mode 100644 index d7f2efdae..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcResponse.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.JsonRpc -{ - - - public partial struct JsonRpcResponse - { - - private static bool @__generated__IsValid = JsonRpcResponse.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(true).Assign("id", (Algorand.Unity.JsonRpc.JsonRpcResponse x) => x.Id, (ref Algorand.Unity.JsonRpc.JsonRpcResponse x, Algorand.Unity.Optional value) => x.Id = value).Assign("jsonrpc", (Algorand.Unity.JsonRpc.JsonRpcResponse x) => x.JsonRpc, (ref Algorand.Unity.JsonRpc.JsonRpcResponse x, System.String value) => x.JsonRpc = value, Algorand.Unity.StringComparer.Instance).Assign("result", (Algorand.Unity.JsonRpc.JsonRpcResponse x) => x.Result, (ref Algorand.Unity.JsonRpc.JsonRpcResponse x, Algorand.Unity.AlgoApiObject value) => x.Result = value).Assign("error", (Algorand.Unity.JsonRpc.JsonRpcResponse x) => x.Error, (ref Algorand.Unity.JsonRpc.JsonRpcResponse x, Algorand.Unity.JsonRpc.JsonRpcError value) => x.Error = value)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcResponse.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcResponse.Formatters.gen.cs.meta deleted file mode 100644 index e75c5947e..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/Formatters.gen/JsonRpcResponse.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c831a5b0f35b94588a06685e297df73b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.JsonRpc/JsonRpcError.cs b/Runtime/Algorand.Unity.JsonRpc/JsonRpcError.cs deleted file mode 100644 index ac222764a..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/JsonRpcError.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; - -namespace Algorand.Unity.JsonRpc -{ - public interface IJsonRpcError - { - /// - /// A String providing a short description of the error. - /// - string Message { get; set; } - - /// - /// A Number that indicates the error type that occurred. - /// - int Code { get; set; } - - /// - /// A Primitive or Structured value that contains additional information about the error. - /// - AlgoApiObject Data { get; set; } - } - - [AlgoApiObject] - public partial struct JsonRpcError - : IEquatable - , IJsonRpcError - { - public bool Equals(JsonRpcError other) - { - return Code == other.Code - && StringComparer.Equals(Message, other.Message) - && Data.Equals(other.Data) - ; - } - - /// - [AlgoApiField("code")] - public int Code { get; set; } - - /// - [AlgoApiField("message")] - public string Message { get; set; } - - /// - [AlgoApiField("data")] - public AlgoApiObject Data { get; set; } - } -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.JsonRpc/JsonRpcError.cs.meta b/Runtime/Algorand.Unity.JsonRpc/JsonRpcError.cs.meta deleted file mode 100644 index 2fec567c7..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/JsonRpcError.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: f42d27b45e534842b3220117a712409b -timeCreated: 1690902692 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.JsonRpc/JsonRpcEvent.cs b/Runtime/Algorand.Unity.JsonRpc/JsonRpcEvent.cs deleted file mode 100644 index 99249b32c..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/JsonRpcEvent.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Algorand.Unity.JsonRpc -{ - public struct JsonRpcEvent - { - public JsonRpcEventType Type { get; set; } - public JsonRpcRequest Request { get; set; } - public JsonRpcResponse Response { get; set; } - public string Error { get; set; } - public string Reason { get; set; } - } -} diff --git a/Runtime/Algorand.Unity.JsonRpc/JsonRpcEvent.cs.meta b/Runtime/Algorand.Unity.JsonRpc/JsonRpcEvent.cs.meta deleted file mode 100644 index ea7d5cd2c..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/JsonRpcEvent.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 439b40a7057c466e9bafc5863039da74 -timeCreated: 1690902812 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.JsonRpc/JsonRpcEventType.cs b/Runtime/Algorand.Unity.JsonRpc/JsonRpcEventType.cs deleted file mode 100644 index 37897732c..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/JsonRpcEventType.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace Algorand.Unity.JsonRpc -{ - public enum JsonRpcEventType - { - Nothing, - Open, - Request, - Response, - Error, - Close - } -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.JsonRpc/JsonRpcEventType.cs.meta b/Runtime/Algorand.Unity.JsonRpc/JsonRpcEventType.cs.meta deleted file mode 100644 index d5e4dca99..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/JsonRpcEventType.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: f5757c77396c4900a0e7385b3a8ccede -timeCreated: 1690902826 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.JsonRpc/JsonRpcRequest.cs b/Runtime/Algorand.Unity.JsonRpc/JsonRpcRequest.cs deleted file mode 100644 index de3519853..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/JsonRpcRequest.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; - -namespace Algorand.Unity.JsonRpc -{ - public interface IJsonRpcRequest : IJsonRpcRequest - { - /// - /// Parameters for this request. - /// - T Params { get; set; } - } - - public interface IJsonRpcRequest - { - /// - /// The id of this request. Used to keep track of the correct response. - /// - Optional Id { get; set; } - - /// - /// The JsonRpc version of this request. - /// - string JsonRpc { get; set; } - - /// - /// The method name to call in this request. - /// - string Method { get; set; } - } - - [AlgoApiObject(IsStrict = true)] - public partial struct JsonRpcRequest - : IJsonRpcRequest - , IEquatable - { - public bool Equals(JsonRpcRequest other) - { - return Params.Equals(other.Params) - && Id.Equals(other.Id) - && StringComparer.Equals(JsonRpc, other.JsonRpc) - && StringComparer.Equals(Method, other.Method) - ; - } - - /// - [AlgoApiField("id")] - public Optional Id { get; set; } - - /// - [AlgoApiField("jsonrpc")] - public string JsonRpc { get; set; } - - /// - [AlgoApiField("method")] - public string Method { get; set; } - - /// - [AlgoApiField("params")] - public AlgoApiObject Params { get; set; } - } - - [AlgoApiObject(IsStrict = true)] - public partial struct JsonRpcRequest - : IJsonRpcRequest - , IEquatable> - where T : IEquatable - { - public bool Equals(JsonRpcRequest other) - { - return Params.Equals(other.Params) - && Id.Equals(other.Id) - && StringComparer.Equals(JsonRpc, other.JsonRpc) - && StringComparer.Equals(Method, other.Method) - ; - } - - /// - [AlgoApiField("id")] - public Optional Id { get; set; } - - /// - [AlgoApiField("jsonrpc")] - public string JsonRpc { get; set; } - - /// - [AlgoApiField("method")] - public string Method { get; set; } - - /// - [AlgoApiField("params")] - public T Params { get; set; } - } -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.JsonRpc/JsonRpcRequest.cs.meta b/Runtime/Algorand.Unity.JsonRpc/JsonRpcRequest.cs.meta deleted file mode 100644 index 01bb9780b..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/JsonRpcRequest.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 2cebeb17f603451da15b8043614b17f9 -timeCreated: 1690558461 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.JsonRpc/JsonRpcResponse.cs b/Runtime/Algorand.Unity.JsonRpc/JsonRpcResponse.cs deleted file mode 100644 index d714f250b..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/JsonRpcResponse.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; - -namespace Algorand.Unity.JsonRpc -{ - public interface IJsonRpcResponse : IJsonRpcResponse - { - /// - /// The result of the corresponding . - /// - T Result { get; set; } - } - - public interface IJsonRpcResponse - { - /// - /// The Id of the response. - /// It should be the same as the ID of the corresponding . - /// - Optional Id { get; set; } - - /// - /// The JsonRpc version. - /// - string JsonRpc { get; set; } - - /// - /// An error object if an error occurred. - /// - JsonRpcError Error { get; set; } - - /// - /// Returns true if this is an error response. - /// - bool IsError { get; } - } - - [AlgoApiObject(IsStrict = true)] - public partial struct JsonRpcResponse - : IJsonRpcResponse - , IEquatable - { - public bool Equals(JsonRpcResponse other) - { - return Result.Equals(other.Result) - && Id.Equals(other.Id) - && StringComparer.Equals(JsonRpc, other.JsonRpc) - && Error.Equals(other.Error) - ; - } - - /// - [AlgoApiField("id")] - public Optional Id { get; set; } - - /// - [AlgoApiField("jsonrpc")] - public string JsonRpc { get; set; } - - /// - [AlgoApiField("result")] - public AlgoApiObject Result { get; set; } - - /// - [AlgoApiField("error")] - public JsonRpcError Error { get; set; } - - /// - public bool IsError => !Error.Equals(default); - } -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.JsonRpc/JsonRpcResponse.cs.meta b/Runtime/Algorand.Unity.JsonRpc/JsonRpcResponse.cs.meta deleted file mode 100644 index 2149d0f04..000000000 --- a/Runtime/Algorand.Unity.JsonRpc/JsonRpcResponse.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: e149b3eb14e14ab99911d6a3ec465719 -timeCreated: 1690558469 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.QrCode.meta b/Runtime/Algorand.Unity.QrCode.meta deleted file mode 100644 index 7d8a780b1..000000000 --- a/Runtime/Algorand.Unity.QrCode.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f0ad7ff2f6e1f4d68b9cc2d57cdd99b2 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.QrCode/Algorand.Unity.QrCode.asmdef b/Runtime/Algorand.Unity.QrCode/Algorand.Unity.QrCode.asmdef deleted file mode 100644 index c4649a7e4..000000000 --- a/Runtime/Algorand.Unity.QrCode/Algorand.Unity.QrCode.asmdef +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "Algorand.Unity.QrCode", - "rootNamespace": "", - "references": [ - "GUID:153e18e942e4f45e68257b49629df380" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": false, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} diff --git a/Runtime/Algorand.Unity.QrCode/Algorand.Unity.QrCode.asmdef.meta b/Runtime/Algorand.Unity.QrCode/Algorand.Unity.QrCode.asmdef.meta deleted file mode 100644 index 6b6fcba6d..000000000 --- a/Runtime/Algorand.Unity.QrCode/Algorand.Unity.QrCode.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 05e3a0220cef448b5bedf723e2dd99f4 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.QrCode/QrCodeUtility.cs b/Runtime/Algorand.Unity.QrCode/QrCodeUtility.cs deleted file mode 100644 index d673cbd27..000000000 --- a/Runtime/Algorand.Unity.QrCode/QrCodeUtility.cs +++ /dev/null @@ -1,55 +0,0 @@ -using UnityEngine; -using ZXing; -using ZXing.QrCode; - -namespace Algorand.Unity.QrCode -{ - public static class QrCodeUtility - { - /// - /// Generates a 256x256 QR-Code - /// - /// The text to use to generate the QR-Code - /// A with width=256 and height=256. - public static Texture2D GenerateTexture(string text) - { - var encoded = new Texture2D(256, 256); - var color32 = Encode(text, encoded.width, encoded.height); - encoded.SetPixels32(color32); - encoded.Apply(); - return encoded; - } - - /// - /// Generates a 256x256 QR-Code - /// - /// The text to use to generate the QR-Code - /// A with width=256 and height=256. - public static Sprite GenerateSprite(string text) - { - var texture = GenerateTexture(text); - return Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero); - } - - /// - /// Generates a QR-Code with specified width/height. - /// - /// The text to encode - /// The width in pixels - /// The height in pixels - /// A flat array of the generated pixels. - public static Color32[] Encode(string textForEncoding, int width, int height) - { - var writer = new BarcodeWriter - { - Format = BarcodeFormat.QR_CODE, - Options = new QrCodeEncodingOptions - { - Height = height, - Width = width - } - }; - return writer.Write(textForEncoding); - } - } -} diff --git a/Runtime/Algorand.Unity.QrCode/QrCodeUtility.cs.meta b/Runtime/Algorand.Unity.QrCode/QrCodeUtility.cs.meta deleted file mode 100644 index d12f6e9b9..000000000 --- a/Runtime/Algorand.Unity.QrCode/QrCodeUtility.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ac9902f21923d4a0d8bf17bd644eaefb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core.meta b/Runtime/Algorand.Unity.WalletConnect.Core.meta deleted file mode 100644 index 8b88a8bad..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 07fa8e84e0a584a45ae3088ad29ab8ab -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Algorand.Unity.WalletConnect.Core.asmdef b/Runtime/Algorand.Unity.WalletConnect.Core/Algorand.Unity.WalletConnect.Core.asmdef deleted file mode 100644 index 527a62db4..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Algorand.Unity.WalletConnect.Core.asmdef +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "Algorand.Unity.WalletConnect.Core", - "rootNamespace": "Algorand.Unity.WalletConnect.Core", - "references": [ - "GUID:45ab5c0c2cb4a0e4ba897b731349c490", - "GUID:f8b80ea32105bf74aa022a9a7e066bc1", - "GUID:9f8c967ec86c9324c9b2928ff73b4cf1", - "GUID:e0cd26848372d4e5c891c569017e11f1", - "GUID:f51ebe6a0ceec4240a699833d6309b23", - "GUID:3593772e9e2814b759387539d266dc24", - "GUID:8dadf2ce3ffc34301a9f6d2e747938f6", - "GUID:70d524b45145c40acbd35603c8e43743", - "GUID:2ee6601452ca245499e63674423f6541", - "GUID:427b0dd64d04a4a02b8413b20fc93483", - "GUID:b0f3d95fe85d1421d9ef3667cce886bb", - "GUID:d8b63aba1907145bea998dd612889d6b" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": true, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": false, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Algorand.Unity.WalletConnect.Core.asmdef.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Algorand.Unity.WalletConnect.Core.asmdef.meta deleted file mode 100644 index 471022666..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Algorand.Unity.WalletConnect.Core.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 96a3d11394a174143976db8839772a1a -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/ClientOptions.cs b/Runtime/Algorand.Unity.WalletConnect.Core/ClientOptions.cs deleted file mode 100644 index b9affc680..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/ClientOptions.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - [Serializable] - public struct ClientOptions : ISerializationCallbackReceiver - { - [SerializeField] - private string projectId; - - [SerializeField] - private string name; - - [SerializeField] - private string relayUrl; - - [SerializeField] - private string baseContext; - - [SerializeField] - [HideInInspector] - private string connectionUrl; - - public ClientOptions( - string projectId, - string name, - string relayUrl = default, - string baseContext = default - ) - { - this.projectId = projectId; - this.name = name; - this.relayUrl = string.IsNullOrEmpty(relayUrl) - ? "wss://relay.walletconnect.org" - : relayUrl; - this.baseContext = string.IsNullOrEmpty(baseContext) - ? $"{name}-client" - : baseContext; - connectionUrl = $"{relayUrl}/?projectId={projectId}"; - } - - public string ProjectId => projectId; - public string Name => name; - public string RelayUrl => relayUrl; - public string BaseContext => baseContext; - public string ConnectionUrl => connectionUrl; - - void ISerializationCallbackReceiver.OnBeforeSerialize() - { - if (string.IsNullOrEmpty(relayUrl)) relayUrl = "wss://relay.walletconnect.org"; - if (string.IsNullOrEmpty(baseContext)) baseContext = $"{name}-client"; - connectionUrl = $"{relayUrl}/?projectId={projectId}"; - } - - void ISerializationCallbackReceiver.OnAfterDeserialize() - { - } - } -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/ClientOptions.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/ClientOptions.cs.meta deleted file mode 100644 index eff5bf3b9..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/ClientOptions.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: c603abae74154527bcda2344a1276e5c -timeCreated: 1690773800 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Crypto.meta deleted file mode 100644 index a16767a32..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ad2fe09d5ed8b4d06a7b5ec9cd76fc4b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Envelope.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Envelope.cs deleted file mode 100644 index 7814412fc..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Envelope.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using Algorand.Unity.Crypto; -using Unity.Collections; -using Algorand.Unity.LowLevel; - -namespace Algorand.Unity.WalletConnect.Core -{ - public static class Envelope - { - public static NativeArray EncryptType0( - ReadOnlySpan message, - ChaCha20Poly1305.Key key, - ChaCha20Poly1305.Nonce iv, - Allocator allocator - ) - { - var envelope = new NativeArray( - 1 + ChaCha20Poly1305.Nonce.SizeBytes + message.Length + ChaCha20Poly1305.AuthTag.Size, - allocator, - NativeArrayOptions.UninitializedMemory); - - var offset = 0; - envelope[offset] = (byte)EnvelopeType.Type0; - offset += sizeof(byte); - - var ivSlice = envelope.AsSpan().Slice(offset, ChaCha20Poly1305.Nonce.SizeBytes); - iv.CopyTo(ref ivSlice); - offset += ChaCha20Poly1305.Nonce.SizeBytes; - - var cipherTextSlice = envelope.AsSpan().Slice(offset, message.Length + ChaCha20Poly1305.AuthTag.Size); - var error = ChaCha20Poly1305.Encrypt(cipherTextSlice, message, key, iv); - if (error > 0) - { - throw new Exception($"ChaCha20 Encryption error: {error}"); - } - - return envelope; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Envelope.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Envelope.cs.meta deleted file mode 100644 index 05365515b..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Envelope.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b132f918a8e884f4ab23382f44bcd1c2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/EnvelopeType.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/EnvelopeType.cs deleted file mode 100644 index 1a3989bf1..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/EnvelopeType.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace Algorand.Unity.WalletConnect.Core -{ - public enum EnvelopeType : byte - { - /// - /// - /// Used when peers agreed on symmetric key and both are able to seal and open the sealbox. - /// - /// algo: ChaCha20-Poly1305 - /// - /// structure: - /// - /// tp - type byte (1 byte) = 0 - /// iv - initialization vector (12 bytes) - /// ct - ciphertext (N bytes) - /// tag - authentication tag (16 bytes) - /// sb - sealbox: ct + tag - /// - /// - /// Serialized Envelope: tp + iv + sb - /// https://docs.walletconnect.com/2.0/specs/clients/core/crypto/crypto-envelopes#type-0-envelope - /// - Type0 = 0, - - /// - /// - /// Used by client that is able to seal the message but it's peer is unable to open the sealbox as it is missing - /// public key for Diffie Hellman key agreement. After deriving symmetric key using pk and private key associated - /// with the topic the envelope has been received on both peers are able to seal and open the sealbox. - /// - /// algo: ChaCha20-Poly1305 - /// - /// structure: - /// - /// tp - type byte (1 byte) = 1 - /// pk - public key (32 bytes) - /// iv - initialization vector (12 bytes) - /// ct - ciphertext (N bytes) - /// tag - authentication tag (16 bytes) - /// sb - sealbox: ct + tag - /// - /// - /// Serialized Type 1 Envelope: tp + pk + iv + sb - /// https://docs.walletconnect.com/2.0/specs/clients/core/crypto/crypto-envelopes#type-1-envelope - /// - Type1 = 1 - } -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/EnvelopeType.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/EnvelopeType.cs.meta deleted file mode 100644 index 062f19dca..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/EnvelopeType.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 908cfd46f0baf4d599a8b992c8cc1103 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt.meta deleted file mode 100644 index 635e5bf42..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 8c96fd89e2e84a83a2d72ec1d0d9ca56 -timeCreated: 1693191616 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtHeader.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtHeader.cs deleted file mode 100644 index 11d49d0d2..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtHeader.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using UnityEngine; -using UnityEngine.Serialization; - -namespace Algorand.Unity.WalletConnect.Core -{ - [Serializable] - [AlgoApiObject] - public partial struct JwtHeader - { - [FormerlySerializedAs("signingAlgorithm")] - [SerializeField] - private string alg; - - [FormerlySerializedAs("tokenType")] - [SerializeField] - private string typ; - - /// - /// The signing algorithm used for this JWT. - /// - [AlgoApiField("alg")] - public string SigningAlgorithm - { - get => alg; - set => alg = value; - } - - /// - /// Type of this token, usually "JWT". - /// - [AlgoApiField("typ")] - public string TokenType - { - get => typ; - set => typ = value; - } - } -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtHeader.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtHeader.cs.meta deleted file mode 100644 index a81c1d173..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtHeader.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 65042298f0b34b6897db7a95fbe9f5d8 -timeCreated: 1693191643 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtIssuer.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtIssuer.cs deleted file mode 100644 index a2d8ab1a2..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtIssuer.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using Algorand.Unity.Crypto; -using Algorand.Unity.LowLevel; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - [Serializable] - [AlgoApiObject] - public partial struct JwtIssuer - { - [SerializeField] - private Ed25519.PublicKey publicKey; - - public Ed25519.PublicKey PublicKey - { - get => publicKey; - set => publicKey = value; - } - - public string Encode() - { - Span headerAndKey = stackalloc byte[Multicodec.HeaderBase58.Length + Ed25519.PublicKey.SizeBytes]; - Multicodec.HeaderBase58.CopyTo(headerAndKey); - var keyPart = headerAndKey.Slice(Multicodec.HeaderBase58.Length); - publicKey.CopyTo(ref keyPart); - return - $"{Did.Prefix}{Did.Delimiter}{Did.Method}{Did.Delimiter}" + - $"{Multicodec.Base}{Base58.Encode(headerAndKey)}"; - } - - public static class Did - { - public const string Delimiter = ":"; - public const string Prefix = "did"; - public const string Method = "key"; - } - - public static class Multicodec - { - public const string Header = "K36"; - public const string Base = "z"; - - public static class HeaderBase58 - { - public const int Length = 2; - - public static void CopyTo(Span destination) - { - destination[0] = 0xed; - destination[1] = 0x01; - } - } - } - } -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtIssuer.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtIssuer.cs.meta deleted file mode 100644 index 15ef3d221..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtIssuer.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 99380eb68ef7448e8244dce4b28724ec -timeCreated: 1693192994 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtPayload.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtPayload.cs deleted file mode 100644 index 0ce84d717..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtPayload.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - [Serializable] - [AlgoApiObject] - public partial struct JwtPayload - { - [SerializeField] - private string iss; - - [SerializeField] - private string sub; - - [SerializeField] - private string aud; - - [SerializeField] - private long iat; - - [SerializeField] - private long exp; - - [AlgoApiField("iss")] - public string Issuer - { - get => iss; - set => iss = value; - } - - [AlgoApiField("sub")] - public string Subject - { - get => sub; - set => sub = value; - } - - [AlgoApiField("aud")] - public string Audience - { - get => aud; - set => aud = value; - } - - [AlgoApiField("iat")] - public long IssuedAt - { - get => iat; - set => iat = value; - } - - [AlgoApiField("exp")] - public long Expiration - { - get => exp; - set => exp = value; - } - } -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtPayload.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtPayload.cs.meta deleted file mode 100644 index 60fc4ce50..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtPayload.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 0955a64874ef405eb0c3d73e515e5c98 -timeCreated: 1693191993 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtUrl.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtUrl.cs deleted file mode 100644 index d85901977..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtUrl.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System; -using Algorand.Unity.Crypto; -using Algorand.Unity.LowLevel; -using Algorand.Unity.Collections; -using Unity.Collections; -using Random = Algorand.Unity.Crypto.Random; - -namespace Algorand.Unity.WalletConnect.Core -{ - public static class JwtUrl - { - public static string JsonEncode(T data) - { - using var json = AlgoApiSerializer.SerializeJson(data, Allocator.Temp); - var utf8Bytes = json.AsArray(); - return Base64Url.Encode(utf8Bytes.AsReadOnlySpan()); - } - - public static string SignJwt(string audience, Ed25519.Seed seed) - { - var issuedAt = ((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds(); - return SignJwt(audience, seed, issuedAt); - } - - public static string SignJwt(string audience, Ed25519.Seed seed, long issuedAt) - { - Span subjectBytes = stackalloc byte[32]; - Random.Randomize(subjectBytes); - - Span subjectHex = stackalloc char[64]; - HexConverter.ToHex(subjectBytes, subjectHex, out _); - return SignJwt(audience, seed, issuedAt, subjectHex.ToString()); - } - - public static string SignJwt(string audience, Ed25519.Seed seed, long issuedAt, string subject) - { - using var keyPair = seed.ToKeyPair(); - const int timeToLive = 24 * 60 * 60; - var issuer = new JwtIssuer { PublicKey = keyPair.PublicKey }; - - var header = new JwtHeader - { - SigningAlgorithm = "EdDSA", - TokenType = "JWT" - }; - - var payload = new JwtPayload - { - Issuer = issuer.Encode(), - Subject = subject, - Audience = audience, - IssuedAt = issuedAt, - Expiration = issuedAt + timeToLive - }; - - return SignJwt(header, payload, keyPair.SecretKey); - } - - public static string SignJwt(JwtHeader header, JwtPayload payload, Ed25519.SecretKeyHandle signer) - { - var encodedHeader = JsonEncode(header); - var encodedPayload = JsonEncode(payload); - - var jwt = new NativeText(Allocator.Temp); - using var defer = jwt; - - jwt.Append(encodedHeader); - jwt.Append('.'); - jwt.Append(encodedPayload); - - var signature = signer.Sign(jwt.AsArray().AsSpan()); - var encodedSignature = Base64Url.Encode(signature.AsReadOnlySpan()); - - jwt.Append('.'); - jwt.Append(encodedSignature); - - return jwt.ToString(); - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtUrl.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtUrl.cs.meta deleted file mode 100644 index de0cfd3aa..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Crypto/Jwt/JwtUrl.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: f82a2672142944c2972731e691422dc3 -timeCreated: 1693195074 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen.meta deleted file mode 100644 index fc21b09e8..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 148c6f551b66349f5baeed22201d564d -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Error.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Error.Formatters.gen.cs deleted file mode 100644 index 6c9182e5a..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Error.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct Error - { - - private static bool @__generated__IsValid = Error.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("code", (Algorand.Unity.WalletConnect.Core.Error x) => x.Code, (ref Algorand.Unity.WalletConnect.Core.Error x, System.Int32 value) => x.Code = value).Assign("message", (Algorand.Unity.WalletConnect.Core.Error x) => x.Message, (ref Algorand.Unity.WalletConnect.Core.Error x, System.String value) => x.Message = value, Algorand.Unity.StringComparer.Instance)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Error.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Error.Formatters.gen.cs.meta deleted file mode 100644 index d301681df..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Error.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5352ef6c2e79640a6aabd38452158d33 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ErrorResponse.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ErrorResponse.Formatters.gen.cs deleted file mode 100644 index 6be123aa4..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ErrorResponse.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct ErrorResponse - { - - private static bool @__generated__IsValid = ErrorResponse.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("id", (Algorand.Unity.WalletConnect.Core.ErrorResponse x) => x.Id, (ref Algorand.Unity.WalletConnect.Core.ErrorResponse x, System.Int32 value) => x.Id = value).Assign("error", (Algorand.Unity.WalletConnect.Core.ErrorResponse x) => x.Error, (ref Algorand.Unity.WalletConnect.Core.ErrorResponse x, Algorand.Unity.WalletConnect.Core.Error value) => x.Error = value)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ErrorResponse.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ErrorResponse.Formatters.gen.cs.meta deleted file mode 100644 index 185531638..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ErrorResponse.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 67e73144d0a6d4b75a75b9f428bf9077 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/FetchMessagesPayload.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/FetchMessagesPayload.Formatters.gen.cs deleted file mode 100644 index 1eeed76a9..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/FetchMessagesPayload.Formatters.gen.cs +++ /dev/null @@ -1,46 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct FetchMessagesRequestPayload - { - - private static bool @__generated__IsValid = FetchMessagesRequestPayload.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("topic", (Algorand.Unity.WalletConnect.Core.FetchMessagesRequestPayload x) => x.Topic, (ref Algorand.Unity.WalletConnect.Core.FetchMessagesRequestPayload x, Algorand.Unity.WalletConnect.Core.Topic value) => x.Topic = value)); - return true; - } - } -} - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct FetchMessagesResponsePayload - { - - private static bool @__generated__IsValid = FetchMessagesResponsePayload.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("messages", (Algorand.Unity.WalletConnect.Core.FetchMessagesResponsePayload x) => x.Messages, (ref Algorand.Unity.WalletConnect.Core.FetchMessagesResponsePayload x, Algorand.Unity.WalletConnect.Core.ReceivedMessage[] value) => x.Messages = value, Algorand.Unity.ArrayComparer.Instance).Assign("hasMore", (Algorand.Unity.WalletConnect.Core.FetchMessagesResponsePayload x) => x.HasMore, (ref Algorand.Unity.WalletConnect.Core.FetchMessagesResponsePayload x, System.Boolean value) => x.HasMore = value)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/FetchMessagesPayload.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/FetchMessagesPayload.Formatters.gen.cs.meta deleted file mode 100644 index e39a09761..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/FetchMessagesPayload.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d052198f2994f4677bfe904ad5493e53 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtHeader.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtHeader.Formatters.gen.cs deleted file mode 100644 index daf15c83d..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtHeader.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct JwtHeader - { - - private static bool @__generated__IsValid = JwtHeader.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("alg", (Algorand.Unity.WalletConnect.Core.JwtHeader x) => x.SigningAlgorithm, (ref Algorand.Unity.WalletConnect.Core.JwtHeader x, System.String value) => x.SigningAlgorithm = value, Algorand.Unity.StringComparer.Instance).Assign("typ", (Algorand.Unity.WalletConnect.Core.JwtHeader x) => x.TokenType, (ref Algorand.Unity.WalletConnect.Core.JwtHeader x, System.String value) => x.TokenType = value, Algorand.Unity.StringComparer.Instance)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtHeader.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtHeader.Formatters.gen.cs.meta deleted file mode 100644 index 9136ced31..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtHeader.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 70456c8a147c54a39bc1b7ea9b766fc3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtIssuer.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtIssuer.Formatters.gen.cs deleted file mode 100644 index 6d221f7aa..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtIssuer.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct JwtIssuer - { - - private static bool @__generated__IsValid = JwtIssuer.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtIssuer.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtIssuer.Formatters.gen.cs.meta deleted file mode 100644 index 259ef642e..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtIssuer.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e0838a5ae7894407aa6d6919f961db4e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtPayload.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtPayload.Formatters.gen.cs deleted file mode 100644 index 36b9f9be3..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtPayload.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct JwtPayload - { - - private static bool @__generated__IsValid = JwtPayload.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("iss", (Algorand.Unity.WalletConnect.Core.JwtPayload x) => x.Issuer, (ref Algorand.Unity.WalletConnect.Core.JwtPayload x, System.String value) => x.Issuer = value, Algorand.Unity.StringComparer.Instance).Assign("sub", (Algorand.Unity.WalletConnect.Core.JwtPayload x) => x.Subject, (ref Algorand.Unity.WalletConnect.Core.JwtPayload x, System.String value) => x.Subject = value, Algorand.Unity.StringComparer.Instance).Assign("aud", (Algorand.Unity.WalletConnect.Core.JwtPayload x) => x.Audience, (ref Algorand.Unity.WalletConnect.Core.JwtPayload x, System.String value) => x.Audience = value, Algorand.Unity.StringComparer.Instance).Assign("iat", (Algorand.Unity.WalletConnect.Core.JwtPayload x) => x.IssuedAt, (ref Algorand.Unity.WalletConnect.Core.JwtPayload x, System.Int64 value) => x.IssuedAt = value).Assign("exp", (Algorand.Unity.WalletConnect.Core.JwtPayload x) => x.Expiration, (ref Algorand.Unity.WalletConnect.Core.JwtPayload x, System.Int64 value) => x.Expiration = value)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtPayload.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtPayload.Formatters.gen.cs.meta deleted file mode 100644 index f0f9f68d0..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/JwtPayload.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 30fbad1ab43f8421489a7b7ae30ee116 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Metadata.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Metadata.Formatters.gen.cs deleted file mode 100644 index c594a4735..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Metadata.Formatters.gen.cs +++ /dev/null @@ -1,41 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct Metadata - { - - private static bool @__generated__IsValid = Metadata.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("name", (Algorand.Unity.WalletConnect.Core.Metadata x) => x.Name, (ref Algorand.Unity.WalletConnect.Core.Metadata x, System.String value) => x.Name = value, Algorand.Unity.StringComparer.Instance).Assign("description", (Algorand.Unity.WalletConnect.Core.Metadata x) => x.Description, (ref Algorand.Unity.WalletConnect.Core.Metadata x, System.String value) => x.Description = value, Algorand.Unity.StringComparer.Instance).Assign("url", (Algorand.Unity.WalletConnect.Core.Metadata x) => x.Url, (ref Algorand.Unity.WalletConnect.Core.Metadata x, System.String value) => x.Url = value, Algorand.Unity.StringComparer.Instance).Assign("icons", (Algorand.Unity.WalletConnect.Core.Metadata x) => x.Icons, (ref Algorand.Unity.WalletConnect.Core.Metadata x, System.String[] value) => x.Icons = value, Algorand.Unity.ArrayComparer.Instance).Assign("verifyUrl", (Algorand.Unity.WalletConnect.Core.Metadata x) => x.VerifyUrl, (ref Algorand.Unity.WalletConnect.Core.Metadata x, System.String value) => x.VerifyUrl = value, Algorand.Unity.StringComparer.Instance).Assign("redirect", (Algorand.Unity.WalletConnect.Core.Metadata x) => x.Redirect, (ref Algorand.Unity.WalletConnect.Core.Metadata x, Algorand.Unity.Optional value) => x.Redirect = value)); - return true; - } - - public partial struct RedirectData - { - - private static bool @__generated__IsValid = RedirectData.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("native", (Algorand.Unity.WalletConnect.Core.Metadata.RedirectData x) => x.Native, (ref Algorand.Unity.WalletConnect.Core.Metadata.RedirectData x, System.String value) => x.Native = value, Algorand.Unity.StringComparer.Instance).Assign("universal", (Algorand.Unity.WalletConnect.Core.Metadata.RedirectData x) => x.Universal, (ref Algorand.Unity.WalletConnect.Core.Metadata.RedirectData x, System.String value) => x.Universal = value, Algorand.Unity.StringComparer.Instance)); - return true; - } - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Metadata.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Metadata.Formatters.gen.cs.meta deleted file mode 100644 index 1507a4043..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Metadata.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c4a3b264eec9149d1bd8b59d3efc8a7b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Namespace.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Namespace.Formatters.gen.cs deleted file mode 100644 index d17abeede..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Namespace.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct Namespace - { - - private static bool @__generated__IsValid = Namespace.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("chains", (Algorand.Unity.WalletConnect.Core.Namespace x) => x.Chains, (ref Algorand.Unity.WalletConnect.Core.Namespace x, System.String[] value) => x.Chains = value, Algorand.Unity.ArrayComparer.Instance).Assign("methods", (Algorand.Unity.WalletConnect.Core.Namespace x) => x.Methods, (ref Algorand.Unity.WalletConnect.Core.Namespace x, System.String[] value) => x.Methods = value, Algorand.Unity.ArrayComparer.Instance).Assign("events", (Algorand.Unity.WalletConnect.Core.Namespace x) => x.Events, (ref Algorand.Unity.WalletConnect.Core.Namespace x, System.String[] value) => x.Events = value, Algorand.Unity.ArrayComparer.Instance)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Namespace.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Namespace.Formatters.gen.cs.meta deleted file mode 100644 index 26e7a742f..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Namespace.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e121ddd53fdcd480c814727e9a5992bd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/OptionalNamespaces.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/OptionalNamespaces.Formatters.gen.cs deleted file mode 100644 index 31ac9b470..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/OptionalNamespaces.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct OptionalNamespaces - { - - private static bool @__generated__IsValid = OptionalNamespaces.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/OptionalNamespaces.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/OptionalNamespaces.Formatters.gen.cs.meta deleted file mode 100644 index 1ed994b0f..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/OptionalNamespaces.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f6c844618b48948048884935a1566723 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Participant.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Participant.Formatters.gen.cs deleted file mode 100644 index c0752a964..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Participant.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct Participant - { - - private static bool @__generated__IsValid = Participant.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("publicKey", (Algorand.Unity.WalletConnect.Core.Participant x) => x.PublicKey, (ref Algorand.Unity.WalletConnect.Core.Participant x, System.String value) => x.PublicKey = value, Algorand.Unity.StringComparer.Instance).Assign("metadata", (Algorand.Unity.WalletConnect.Core.Participant x) => x.Metadata, (ref Algorand.Unity.WalletConnect.Core.Participant x, Algorand.Unity.WalletConnect.Core.Metadata value) => x.Metadata = value)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Participant.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Participant.Formatters.gen.cs.meta deleted file mode 100644 index 5008f6d62..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Participant.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 232ffd7ed68954936a793c5db8204338 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ProtocolOptions.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ProtocolOptions.Formatters.gen.cs deleted file mode 100644 index 0c670b90e..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ProtocolOptions.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct ProtocolOptions - { - - private static bool @__generated__IsValid = ProtocolOptions.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("protocol", (Algorand.Unity.WalletConnect.Core.ProtocolOptions x) => x.Protocol, (ref Algorand.Unity.WalletConnect.Core.ProtocolOptions x, System.String value) => x.Protocol = value, Algorand.Unity.StringComparer.Instance).Assign("data", (Algorand.Unity.WalletConnect.Core.ProtocolOptions x) => x.Data, (ref Algorand.Unity.WalletConnect.Core.ProtocolOptions x, System.String value) => x.Data = value, Algorand.Unity.StringComparer.Instance)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ProtocolOptions.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ProtocolOptions.Formatters.gen.cs.meta deleted file mode 100644 index 4af3aea02..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ProtocolOptions.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ddaed03c4825d40aab508dc85b1e1a73 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/PublishPayload.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/PublishPayload.Formatters.gen.cs deleted file mode 100644 index c5dc8b5e2..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/PublishPayload.Formatters.gen.cs +++ /dev/null @@ -1,46 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct PublishRequestPayload - { - - private static bool @__generated__IsValid = PublishRequestPayload.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("topic", (Algorand.Unity.WalletConnect.Core.PublishRequestPayload x) => x.Topic, (ref Algorand.Unity.WalletConnect.Core.PublishRequestPayload x, Algorand.Unity.WalletConnect.Core.Topic value) => x.Topic = value).Assign("message", (Algorand.Unity.WalletConnect.Core.PublishRequestPayload x) => x.Message, (ref Algorand.Unity.WalletConnect.Core.PublishRequestPayload x, System.String value) => x.Message = value, Algorand.Unity.StringComparer.Instance).Assign("ttl", (Algorand.Unity.WalletConnect.Core.PublishRequestPayload x) => x.TimeToLive, (ref Algorand.Unity.WalletConnect.Core.PublishRequestPayload x, System.UInt64 value) => x.TimeToLive = value).Assign("tag", (Algorand.Unity.WalletConnect.Core.PublishRequestPayload x) => x.Tag, (ref Algorand.Unity.WalletConnect.Core.PublishRequestPayload x, System.UInt64 value) => x.Tag = value)); - return true; - } - } -} - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct PublishResponsePayload - { - - private static bool @__generated__IsValid = PublishResponsePayload.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.WrappedValueFormatter()); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/PublishPayload.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/PublishPayload.Formatters.gen.cs.meta deleted file mode 100644 index dc04dc3a1..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/PublishPayload.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 63587489990654cd79e015a50daa18c0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ReceivedMessage.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ReceivedMessage.Formatters.gen.cs deleted file mode 100644 index 44ad7e8fd..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ReceivedMessage.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct ReceivedMessage - { - - private static bool @__generated__IsValid = ReceivedMessage.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("topic", (Algorand.Unity.WalletConnect.Core.ReceivedMessage x) => x.Topic, (ref Algorand.Unity.WalletConnect.Core.ReceivedMessage x, Algorand.Unity.WalletConnect.Core.Topic value) => x.Topic = value).Assign("message", (Algorand.Unity.WalletConnect.Core.ReceivedMessage x) => x.Message, (ref Algorand.Unity.WalletConnect.Core.ReceivedMessage x, System.String value) => x.Message = value, Algorand.Unity.StringComparer.Instance).Assign("publishedAt", (Algorand.Unity.WalletConnect.Core.ReceivedMessage x) => x.PublishedAt, (ref Algorand.Unity.WalletConnect.Core.ReceivedMessage x, System.UInt64 value) => x.PublishedAt = value).Assign("tag", (Algorand.Unity.WalletConnect.Core.ReceivedMessage x) => x.Tag, (ref Algorand.Unity.WalletConnect.Core.ReceivedMessage x, System.UInt64 value) => x.Tag = value)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ReceivedMessage.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ReceivedMessage.Formatters.gen.cs.meta deleted file mode 100644 index 6673b8866..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/ReceivedMessage.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0bc07ad1117e541a4a47de92e63dacaa -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/RequiredNamespaces.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/RequiredNamespaces.Formatters.gen.cs deleted file mode 100644 index f9452fd20..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/RequiredNamespaces.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct RequiredNamespaces - { - - private static bool @__generated__IsValid = RequiredNamespaces.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("algorand", (Algorand.Unity.WalletConnect.Core.RequiredNamespaces x) => x.AlgorandNamespace, (ref Algorand.Unity.WalletConnect.Core.RequiredNamespaces x, Algorand.Unity.WalletConnect.Core.Namespace value) => x.AlgorandNamespace = value)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/RequiredNamespaces.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/RequiredNamespaces.Formatters.gen.cs.meta deleted file mode 100644 index 5a1b1f281..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/RequiredNamespaces.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: edddad5c4c6a14163bfbf470a6ec1d8a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SessionProperties.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SessionProperties.Formatters.gen.cs deleted file mode 100644 index f08ac3459..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SessionProperties.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct SessionProperties - { - - private static bool @__generated__IsValid = SessionProperties.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SessionProperties.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SessionProperties.Formatters.gen.cs.meta deleted file mode 100644 index 873b0e542..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SessionProperties.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: eb25dba6696bb464ab0f1e2e0d32afc0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SessionProposePayload.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SessionProposePayload.Formatters.gen.cs deleted file mode 100644 index a59c56a18..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SessionProposePayload.Formatters.gen.cs +++ /dev/null @@ -1,46 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct SessionProposeRequestPayload - { - - private static bool @__generated__IsValid = SessionProposeRequestPayload.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("relays", (Algorand.Unity.WalletConnect.Core.SessionProposeRequestPayload x) => x.Relays, (ref Algorand.Unity.WalletConnect.Core.SessionProposeRequestPayload x, Algorand.Unity.WalletConnect.Core.ProtocolOptions[] value) => x.Relays = value, Algorand.Unity.ArrayComparer.Instance).Assign("requiredNamespaces", (Algorand.Unity.WalletConnect.Core.SessionProposeRequestPayload x) => x.RequiredNamespaces, (ref Algorand.Unity.WalletConnect.Core.SessionProposeRequestPayload x, Algorand.Unity.WalletConnect.Core.RequiredNamespaces value) => x.RequiredNamespaces = value).Assign("optionalNamespaces", (Algorand.Unity.WalletConnect.Core.SessionProposeRequestPayload x) => x.OptionalNamespaces, (ref Algorand.Unity.WalletConnect.Core.SessionProposeRequestPayload x, Algorand.Unity.WalletConnect.Core.OptionalNamespaces value) => x.OptionalNamespaces = value).Assign("session", (Algorand.Unity.WalletConnect.Core.SessionProposeRequestPayload x) => x.SessionProperties, (ref Algorand.Unity.WalletConnect.Core.SessionProposeRequestPayload x, Algorand.Unity.WalletConnect.Core.SessionProperties value) => x.SessionProperties = value).Assign("proposer", (Algorand.Unity.WalletConnect.Core.SessionProposeRequestPayload x) => x.Proposer, (ref Algorand.Unity.WalletConnect.Core.SessionProposeRequestPayload x, Algorand.Unity.WalletConnect.Core.Participant value) => x.Proposer = value)); - return true; - } - } -} - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct SessionProposeResponsePayload - { - - private static bool @__generated__IsValid = SessionProposeResponsePayload.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("relay", (Algorand.Unity.WalletConnect.Core.SessionProposeResponsePayload x) => x.Relay, (ref Algorand.Unity.WalletConnect.Core.SessionProposeResponsePayload x, Algorand.Unity.WalletConnect.Core.ProtocolOptions value) => x.Relay = value).Assign("responderPublicKey", (Algorand.Unity.WalletConnect.Core.SessionProposeResponsePayload x) => x.ResponderPublicKey, (ref Algorand.Unity.WalletConnect.Core.SessionProposeResponsePayload x, System.String value) => x.ResponderPublicKey = value, Algorand.Unity.StringComparer.Instance)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SessionProposePayload.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SessionProposePayload.Formatters.gen.cs.meta deleted file mode 100644 index 1fd033368..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SessionProposePayload.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 30b8d36e73e4b4478baa6060333f2942 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SubscribePayload.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SubscribePayload.Formatters.gen.cs deleted file mode 100644 index b434f8247..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SubscribePayload.Formatters.gen.cs +++ /dev/null @@ -1,46 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct SubscribeRequestPayload - { - - private static bool @__generated__IsValid = SubscribeRequestPayload.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("topic", (Algorand.Unity.WalletConnect.Core.SubscribeRequestPayload x) => x.Topic, (ref Algorand.Unity.WalletConnect.Core.SubscribeRequestPayload x, Algorand.Unity.WalletConnect.Core.Topic value) => x.Topic = value)); - return true; - } - } -} - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct SubscribeResponsePayload - { - - private static bool @__generated__IsValid = SubscribeResponsePayload.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.WrappedValueFormatter()); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SubscribePayload.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SubscribePayload.Formatters.gen.cs.meta deleted file mode 100644 index d3f4a7234..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SubscribePayload.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 76ad5763e9f1b49fb9f4f321e9c339a2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SubscriptionPayload.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SubscriptionPayload.Formatters.gen.cs deleted file mode 100644 index 553477a56..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SubscriptionPayload.Formatters.gen.cs +++ /dev/null @@ -1,46 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct SubscriptionRequestPayload - { - - private static bool @__generated__IsValid = SubscriptionRequestPayload.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("id", (Algorand.Unity.WalletConnect.Core.SubscriptionRequestPayload x) => x.Id, (ref Algorand.Unity.WalletConnect.Core.SubscriptionRequestPayload x, System.String value) => x.Id = value, Algorand.Unity.StringComparer.Instance).Assign("data", (Algorand.Unity.WalletConnect.Core.SubscriptionRequestPayload x) => x.Data, (ref Algorand.Unity.WalletConnect.Core.SubscriptionRequestPayload x, Algorand.Unity.WalletConnect.Core.ReceivedMessage value) => x.Data = value)); - return true; - } - } -} - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct SubscriptionResponsePayload - { - - private static bool @__generated__IsValid = SubscriptionResponsePayload.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.WrappedValueFormatter()); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SubscriptionPayload.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SubscriptionPayload.Formatters.gen.cs.meta deleted file mode 100644 index 4943d7af6..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/SubscriptionPayload.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 832ada82f90b0446eb8f194d300e3fef -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Topic.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Topic.Formatters.gen.cs deleted file mode 100644 index 0abf3f9bf..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Topic.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct Topic - { - - private static bool @__generated__IsValid = Topic.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.WalletConnect.Core.Topic.TopicFormatter()); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Topic.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Topic.Formatters.gen.cs.meta deleted file mode 100644 index 161843ea3..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/Topic.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f12ec1753f4b14b8ab9299dbad8bce41 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/UnsubscribePayload.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/UnsubscribePayload.Formatters.gen.cs deleted file mode 100644 index afdee9279..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/UnsubscribePayload.Formatters.gen.cs +++ /dev/null @@ -1,46 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct UnsubscribeRequestPayload - { - - private static bool @__generated__IsValid = UnsubscribeRequestPayload.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("topic", (Algorand.Unity.WalletConnect.Core.UnsubscribeRequestPayload x) => x.Topic, (ref Algorand.Unity.WalletConnect.Core.UnsubscribeRequestPayload x, Algorand.Unity.WalletConnect.Core.Topic value) => x.Topic = value).Assign("id", (Algorand.Unity.WalletConnect.Core.UnsubscribeRequestPayload x) => x.Id, (ref Algorand.Unity.WalletConnect.Core.UnsubscribeRequestPayload x, System.String value) => x.Id = value, Algorand.Unity.StringComparer.Instance)); - return true; - } - } -} - -namespace Algorand.Unity.WalletConnect.Core -{ - - - public partial struct UnsubscribeResponsePayload - { - - private static bool @__generated__IsValid = UnsubscribeResponsePayload.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.WrappedValueFormatter()); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/UnsubscribePayload.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/UnsubscribePayload.Formatters.gen.cs.meta deleted file mode 100644 index 8311572a2..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Formatters.gen/UnsubscribePayload.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f864a12780e96413fb4b8c3e4435ea19 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing.meta deleted file mode 100644 index bdcd925ec..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9d35f3bd5b48e4d52b827fffe461cb2b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Error.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Error.cs deleted file mode 100644 index b3e851c4b..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Error.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - [AlgoApiObject] - [Serializable] - public partial struct Error : IEquatable - { - [SerializeField] - private int code; - - [SerializeField] - private string message; - - [AlgoApiField("code")] - public int Code - { - get => code; - set => code = value; - } - - [AlgoApiField("message")] - public string Message - { - get => message; - set => message = value; - } - - public bool Equals(Error other) - { - return Code.Equals(other.Code) - && StringComparer.Equals(Message, other.Message) - ; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Error.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Error.cs.meta deleted file mode 100644 index af0e0f9c0..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Error.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 2f00fcb445e143f8921712e016611728 -timeCreated: 1690050294 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ErrorResponse.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ErrorResponse.cs deleted file mode 100644 index f58ce9757..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ErrorResponse.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - [AlgoApiObject] - [Serializable] - public partial struct ErrorResponse : IEquatable - { - [SerializeField] - private int id; - - [SerializeField] - private Error error; - - [AlgoApiField("id")] - public int Id - { - get => id; - set => id = value; - } - - [AlgoApiField("error")] - public Error Error - { - get => error; - set => error = value; - } - - public bool Equals(ErrorResponse other) - { - return Id.Equals(other.Id) - && Error.Equals(other.Error) - ; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ErrorResponse.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ErrorResponse.cs.meta deleted file mode 100644 index f5bbc062b..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ErrorResponse.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 1c46d4390dff47fbbdb0861fdccd42d4 -timeCreated: 1690050320 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Metadata.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Metadata.cs deleted file mode 100644 index 63d7eef59..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Metadata.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - [AlgoApiObject] - [Serializable] - public partial struct Metadata : IEquatable - { - [SerializeField] - private string name; - - [SerializeField] - private string description; - - [SerializeField] - private string url; - - [SerializeField] - private string[] icons; - - [SerializeField] - private string verifyUrl; - - [SerializeField] - private Optional redirect; - - [AlgoApiField("name")] - public string Name - { - get => name; - set => name = value; - } - - [AlgoApiField("description")] - public string Description - { - get => description; - set => description = value; - } - - [AlgoApiField("url")] - public string Url - { - get => url; - set => url = value; - } - - [AlgoApiField("icons")] - public string[] Icons - { - get => icons; - set => icons = value; - } - - [AlgoApiField("verifyUrl")] - public string VerifyUrl - { - get => verifyUrl; - set => verifyUrl = value; - } - - [AlgoApiField("redirect")] - public Optional Redirect - { - get => redirect; - set => redirect = value; - } - - public bool Equals(Metadata other) - { - return StringComparer.Equals(name, other.name) - && StringComparer.Equals(url, other.url) - ; - } - - [AlgoApiObject] - [Serializable] - public partial struct RedirectData : IEquatable - { - [SerializeField] - private string native; - - [SerializeField] - private string universal; - - [AlgoApiField("native")] - public string Native - { - get => native; - set => native = value; - } - - [AlgoApiField("universal")] - public string Universal - { - get => universal; - set => universal = value; - } - - public bool Equals(RedirectData other) - { - return string.Equals(native, other.native) - && string.Equals(universal, other.universal) - ; - } - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Metadata.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Metadata.cs.meta deleted file mode 100644 index 8604bd633..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Metadata.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 0605756a7f634220938903151a7694f1 -timeCreated: 1690049675 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingErrorCode.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingErrorCode.cs deleted file mode 100644 index 7c66fbcdb..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingErrorCode.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Algorand.Unity.WalletConnect.Core -{ - public enum PairingErrorCode - { - // INVALID - MethodUnsupported = 10001, - - // REASON - UserDisconnected = 6000 - } -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingErrorCode.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingErrorCode.cs.meta deleted file mode 100644 index e3b43f43c..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingErrorCode.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 7a78a25d98554a7fb0933a5ee58d498a -timeCreated: 1690050365 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingMethods.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingMethods.cs deleted file mode 100644 index 6f9314fc3..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingMethods.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using Unity.Collections; - -namespace Algorand.Unity.WalletConnect.Core -{ - [Serializable] - public struct PairingMethods : IEquatable - { - public string[] signMethods; - public string[] authMethods; - public string[] chatMethods; - public string[] pushMethods; - - public string[] this[int index] - { - get => this[(ProtocolType)index]; - set => this[(ProtocolType)index] = value; - } - - public string[] this[ProtocolType protocolType] - { - get => protocolType switch - { - ProtocolType.Sign => signMethods, - ProtocolType.Auth => authMethods, - ProtocolType.Chat => chatMethods, - ProtocolType.Push => pushMethods, - _ => throw new ArgumentOutOfRangeException(nameof(protocolType), protocolType, null) - }; - set - { - switch (protocolType) - { - case ProtocolType.Sign: - signMethods = value; - break; - case ProtocolType.Auth: - authMethods = value; - break; - case ProtocolType.Chat: - chatMethods = value; - break; - case ProtocolType.Push: - pushMethods = value; - break; - default: - throw new ArgumentOutOfRangeException(nameof(protocolType), protocolType, null); - } - } - } - - public FormatError AppendToString(ref TFixedString text) - where TFixedString : struct, IUTF8Bytes, INativeList - { - FormatError error = default; - var startLength = text.Length; - for (var i = 0; i < (int)ProtocolType.Count; i++) - { - var methods = this[i]; - if (methods == null || methods.Length == 0) - continue; - if (text.Length > startLength) - error |= text.Append(','); - error |= text.Append('['); - error |= text.Append(methods[0]); - for (var j = 1; j < methods.Length; j++) - { - error |= text.Append(','); - error |= text.Append(methods[j]); - } - error |= text.Append(']'); - } - - return error; - } - - public bool Equals(PairingMethods other) - { - return ArrayComparer.Equals(signMethods, other.signMethods) && - ArrayComparer.Equals(authMethods, other.authMethods) && - ArrayComparer.Equals(chatMethods, other.chatMethods) && - ArrayComparer.Equals(pushMethods, other.pushMethods); - } - - public override string ToString() - { - var s = new NativeText(Allocator.Temp); - using var deferDispose = s; - AppendToString(ref s); - - return s.ToString(); - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingMethods.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingMethods.cs.meta deleted file mode 100644 index cf5378b79..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingMethods.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c2b811ab623694ec29e66ce24bb7ef73 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingUri.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingUri.cs deleted file mode 100644 index 0b199c75b..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingUri.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using Algorand.Unity.LowLevel; -using Unity.Collections; -using Unity.Collections.LowLevel.Unsafe; - -namespace Algorand.Unity.WalletConnect.Core -{ - /// - ///
- /// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1328.md - ///
- /// https://specs.walletconnect.com/2.0/specs/clients/core/pairing/pairing-uri - ///
- /// The WalletConnect pairing URL. This was a handshake url in v1. - ///
- [Serializable] - public struct PairingUri - { - public Topic topic; - public byte version; - public PairingMethods methods; - public SymKey symKey; - public ProtocolOptions relay; - - public PairingUri(PairingMethods methods) - { - version = 2; - this.methods = methods; - symKey = SymKey.Random(); - var sha256Hash = Crypto.Sha256.Hash(symKey.AsReadOnlySpan()); - topic = UnsafeUtility.As(ref sha256Hash); - relay = new ProtocolOptions { Protocol = "irn" }; - } - - public override string ToString() - { - var s = new NativeText(Allocator.Temp); - using var deferredDispose = s; - s.Append("wc:"); - s.Append(topic.ToFixedString()); - s.Append('@'); - s.Append(version); - s.Append('?'); - s.Append("symKey="); - s.Append(symKey.ToFixedString()); - if (!methods.Equals(default)) - { - s.Append('&'); - s.Append("methods="); - methods.AppendToString(ref s); - } - s.Append('&'); - s.Append("relay-protocol="); - s.Append(relay.Protocol); - if (!string.IsNullOrEmpty(relay.Data)) - { - s.Append('&'); - s.Append("relay-data="); - s.Append(relay.Data); - } - return s.ToString(); - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingUri.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingUri.cs.meta deleted file mode 100644 index 4b2c32508..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/PairingUri.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b9524aeb9390c4d4a858ff04088b7044 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads.meta deleted file mode 100644 index 099795118..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 1d756bce7a1a1411082ae0976a7a89d9 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/Namespace.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/Namespace.cs deleted file mode 100644 index 338b1c672..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/Namespace.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - [AlgoApiObject] - [Serializable] - public partial struct Namespace : IEquatable - { - [SerializeField] - private string[] chains; - - [SerializeField] - private string[] methods; - - [SerializeField] - private string[] events; - - [AlgoApiField("chains")] - public string[] Chains - { - get => chains; - set => chains = value; - } - - [AlgoApiField("methods")] - public string[] Methods - { - get => methods; - set => methods = value; - } - - [AlgoApiField("events")] - public string[] Events - { - get => events; - set => events = value; - } - - public bool Equals(Namespace other) - { - return ArrayComparer.Equals(Chains, other.Chains) - && ArrayComparer.Equals(Methods, other.Methods) - && ArrayComparer.Equals(Events, other.Events); - } - - public static readonly Namespace AlgorandNamespace = new Namespace - { - chains = new[] { "algorand:SGO1GKSzyE7IEPItTxCByw9x8FmnrCDe" }, - methods = new[] { "algo_signTxn" }, - events = new[] { "chainChanged", "accountsChanged" } - }; - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/Namespace.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/Namespace.cs.meta deleted file mode 100644 index 129bdc0e3..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/Namespace.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ce3ab307a7e124e128e7e6135d8866e9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/OptionalNamespaces.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/OptionalNamespaces.cs deleted file mode 100644 index 5d100dd19..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/OptionalNamespaces.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect.Core -{ - /// - /// Hardcoded to be empty, for Algorand. - /// - [AlgoApiObject] - [Serializable] - public partial struct OptionalNamespaces : IEquatable - { - public bool Equals(OptionalNamespaces other) - { - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/OptionalNamespaces.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/OptionalNamespaces.cs.meta deleted file mode 100644 index 5ed8fd416..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/OptionalNamespaces.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bd6707e66d315419796f15f12517597f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/Participant.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/Participant.cs deleted file mode 100644 index 05daa7fcb..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/Participant.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - [AlgoApiObject] - [Serializable] - public partial struct Participant : IEquatable - { - [SerializeField] - private string publicKey; - - [SerializeField] - private Metadata metadata; - - [AlgoApiField("publicKey")] - public string PublicKey - { - get => publicKey; - set => publicKey = value; - } - - [AlgoApiField("metadata")] - public Metadata Metadata - { - get => metadata; - set => metadata = value; - } - - public bool Equals(Participant other) - { - return StringComparer.Equals(PublicKey, other.PublicKey) - && Metadata.Equals(other.Metadata); - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/Participant.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/Participant.cs.meta deleted file mode 100644 index c24a0faed..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/Participant.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a36431d45cabe44eda456942dfc64b13 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/RequiredNamespaces.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/RequiredNamespaces.cs deleted file mode 100644 index a22a1f1b1..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/RequiredNamespaces.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - /// - /// Hard-coded to Algorand. - /// - [AlgoApiObject] - [Serializable] - public partial struct RequiredNamespaces : IEquatable - { - [SerializeField] - private Namespace algorand; - - [AlgoApiField("algorand")] - public Namespace AlgorandNamespace - { - get => algorand; - set => algorand = value; - } - - public bool Equals(RequiredNamespaces other) - { - return AlgorandNamespace.Equals(other.AlgorandNamespace); - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/RequiredNamespaces.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/RequiredNamespaces.cs.meta deleted file mode 100644 index 249067db4..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/RequiredNamespaces.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b6c6fbf33c0654b149fefac8f5905fe1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/SessionProperties.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/SessionProperties.cs deleted file mode 100644 index fcd5f4646..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/SessionProperties.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect.Core -{ - /// - /// Hardcoded to be empty, for Algorand. - /// - [AlgoApiObject] - [Serializable] - public partial struct SessionProperties : IEquatable - { - public bool Equals(SessionProperties other) - { - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/SessionProperties.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/SessionProperties.cs.meta deleted file mode 100644 index 14a930129..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/SessionProperties.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d7f2448d203da4fafa286d72dc83381e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/SessionProposePayload.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/SessionProposePayload.cs deleted file mode 100644 index 469bb5c44..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/SessionProposePayload.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - [AlgoApiObject] - [Serializable] - public partial struct SessionProposeRequestPayload : IEquatable - { - [SerializeField] - private ProtocolOptions[] relays; - - [SerializeField] - private RequiredNamespaces requiredNamespaces; - - [SerializeField] - private OptionalNamespaces optionalNamespaces; - - [SerializeField] - private SessionProperties sessionProperties; - - [SerializeField] - private Participant proposer; - - [AlgoApiField("relays")] - public ProtocolOptions[] Relays - { - get => relays; - set => relays = value; - } - - [AlgoApiField("requiredNamespaces")] - public RequiredNamespaces RequiredNamespaces - { - get => requiredNamespaces; - set => requiredNamespaces = value; - } - - [AlgoApiField("optionalNamespaces")] - public OptionalNamespaces OptionalNamespaces - { - get => optionalNamespaces; - set => optionalNamespaces = value; - } - - [AlgoApiField("session")] - public SessionProperties SessionProperties - { - get => sessionProperties; - set => sessionProperties = value; - } - - [AlgoApiField("proposer")] - public Participant Proposer - { - get => proposer; - set => proposer = value; - } - - public SessionProposeRequestPayload( - Participant proposer - ) - { - relays = new[] { new ProtocolOptions { Protocol = "irn" } }; - requiredNamespaces = new RequiredNamespaces { AlgorandNamespace = Namespace.AlgorandNamespace }; - optionalNamespaces = default; - sessionProperties = default; - this.proposer = proposer; - } - - public bool Equals(SessionProposeRequestPayload other) - { - return ArrayComparer.Equals(Relays, other.Relays) - && RequiredNamespaces.Equals(other.RequiredNamespaces) - && OptionalNamespaces.Equals(other.OptionalNamespaces) - && SessionProperties.Equals(other.SessionProperties) - && Proposer.Equals(other.Proposer); - } - } - - [AlgoApiObject] - [Serializable] - public partial struct SessionProposeResponsePayload : IEquatable - { - [SerializeField] - private ProtocolOptions relay; - - [SerializeField] - private string responderPublicKey; - - [AlgoApiField("relay")] - public ProtocolOptions Relay - { - get => relay; - set => relay = value; - } - - [AlgoApiField("responderPublicKey")] - public string ResponderPublicKey - { - get => responderPublicKey; - set => responderPublicKey = value; - } - - public bool Equals(SessionProposeResponsePayload other) - { - return Relay.Equals(other.Relay) - && StringComparer.Equals(ResponderPublicKey, other.ResponderPublicKey); - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/SessionProposePayload.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/SessionProposePayload.cs.meta deleted file mode 100644 index 1c48d5d82..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/Payloads/SessionProposePayload.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2d7fce1295099471585ea598e8ebe387 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ProtocolOptions.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ProtocolOptions.cs deleted file mode 100644 index 6316c69f7..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ProtocolOptions.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - [AlgoApiObject] - [Serializable] - public partial struct ProtocolOptions : IEquatable - { - [SerializeField] - private string protocol; - - [SerializeField] - private string data; - - [AlgoApiField("protocol")] - public string Protocol - { - get => protocol; - set => protocol = value; - } - - [AlgoApiField("data")] - public string Data - { - get => data; - set => data = value; - } - - public bool Equals(ProtocolOptions other) - { - return StringComparer.Equals(Protocol, other.Protocol) - && StringComparer.Equals(Data, other.Data); - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ProtocolOptions.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ProtocolOptions.cs.meta deleted file mode 100644 index 9b2975fcf..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ProtocolOptions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b49b2127c112646168069840054de8bd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ProtocolType.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ProtocolType.cs deleted file mode 100644 index 9ca66d6d5..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ProtocolType.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Unity.Collections; - -namespace Algorand.Unity.WalletConnect.Core -{ - public enum ProtocolType - { - Sign, - Auth, - Chat, - Push, - Count - } - - public static class ProtocolTypeExtensions - { - public static readonly FixedString32Bytes[] ProtocolTypeStrings = new FixedString32Bytes[(int)ProtocolType.Count] - { - "sign", - "auth", - "chat", - "push" - }; - - public static FixedString32Bytes ToFixedString(this ProtocolType protocolType) - { - return ProtocolTypeStrings[(int)protocolType]; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ProtocolType.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ProtocolType.cs.meta deleted file mode 100644 index d199c7087..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/ProtocolType.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 7d5627dd3e7b42eb8501c4b420a08f85 -timeCreated: 1690050094 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/SymKey.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/SymKey.cs deleted file mode 100644 index 6bbe80114..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/SymKey.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Algorand.Unity.LowLevel; -using Unity.Collections; - -namespace Algorand.Unity.WalletConnect.Core -{ - [Serializable] - [StructLayout(LayoutKind.Sequential, Size = 32)] - public unsafe struct SymKey : IByteArray - { - public fixed byte bytes[32]; - - public int Length => 32; - - public byte this[int index] { get => this.GetByteAt(index); set => this.SetByteAt(index, value); } - - public override string ToString() - { - Span output = stackalloc char[64]; - fixed (byte* ptr = bytes) - { - var byteSpan = new ReadOnlySpan(ptr, 32); - HexConverter.ToHex(byteSpan, output, out _); - } - return output.ToString(); - } - - public FixedString128Bytes ToFixedString() - { - var output = default(FixedString128Bytes); - - fixed (byte* ptr = bytes) - { - var byteSpan = new ReadOnlySpan(ptr, 32); - var error = HexConverter.ToHex(byteSpan, ref output); - if (error > 0) - { - throw new FormatException(error.ToString()); - } - } - - return output; - } - - public static SymKey Random() - { - return Crypto.Random.Bytes(); - } - - public static SymKey FromString(TFixedString fixedString) - where TFixedString : struct, INativeList, IUTF8Bytes - { - var output = default(SymKey); - var outputSpan = new Span(output.bytes, 32); - var error = HexConverter.FromHex(fixedString, outputSpan, out _); - if (error > 0) - { - throw new FormatException(error.ToString()); - } - return output; - } - - public void* GetUnsafePtr() - { - fixed (byte* ptr = bytes) - { - return ptr; - } - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/SymKey.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/SymKey.cs.meta deleted file mode 100644 index 5b4d7a753..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Pairing/SymKey.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6a165a1d889a14a25b30b70c031b7b8d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Relay.meta deleted file mode 100644 index f58663d8c..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 02d26915d12604e9692f44fb7cb3e83f -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/MessageId.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/MessageId.cs deleted file mode 100644 index 0f8d00686..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/MessageId.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using Algorand.Unity.LowLevel; -using Algorand.Unity.Crypto; -using Algorand.Unity.Collections; -using Unity.Collections; -using Unity.Collections.LowLevel.Unsafe; - -namespace Algorand.Unity.WalletConnect.Core -{ - /// - /// Sha 256 hash of the message. - /// - [Serializable] - public struct MessageId - { - public FixedBytes32 bytes; - - public MessageId(string message) - { - var utf8 = new NativeText(message, Allocator.Temp); - var hash = Sha512.Hash256Truncated(utf8.AsArray().AsReadOnly()); - bytes = UnsafeUtility.As(ref hash); - } - - public static MessageId FromMessage(string message) - { - return new MessageId(message); - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/MessageId.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/MessageId.cs.meta deleted file mode 100644 index 5bb8e6b7d..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/MessageId.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 142c4f685a844740997313f5aa9b409c -timeCreated: 1690298822 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads.meta deleted file mode 100644 index 55750e408..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 54446c9588c444812a3e8e21a70e48df -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/FetchMessagesPayload.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/FetchMessagesPayload.cs deleted file mode 100644 index 7dddeea5a..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/FetchMessagesPayload.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - /// - /// Used when a client wants to fetch all undelivered messages matching a single topic before subscribing. - ///
- /// https://docs.walletconnect.com/2.0/specs/servers/relay/relay-server-rpc#fetch-messsages-payload - ///
- /// - /// Response will include a flag hasMore. If true, the consumer should fetch again to get the rest of the messages. If false, then all messages have been delivered. - /// - [AlgoApiObject] - [Serializable] - public partial struct FetchMessagesRequestPayload : IEquatable - { - [SerializeField] - private Topic topic; - - [AlgoApiField("topic")] - public Topic Topic - { - get => topic; - set => topic = value; - } - - public bool Equals(FetchMessagesRequestPayload other) - { - return Topic.Equals(other.Topic); - } - } - - /// - /// Used when a client wants to fetch all undelivered messages matching a single topic before subscribing. - ///
- /// https://docs.walletconnect.com/2.0/specs/servers/relay/relay-server-rpc#fetch-messsages-payload - ///
- /// - /// Response will include a flag hasMore. If true, the consumer should fetch again to get the rest of the messages. If false, then all messages have been delivered. - /// - [AlgoApiObject] - [Serializable] - public partial struct FetchMessagesResponsePayload : IEquatable - { - [SerializeField] - private ReceivedMessage[] messages; - - [SerializeField] - bool hasMore; - - [AlgoApiField("messages")] - public ReceivedMessage[] Messages - { - get => messages; - set => messages = value; - } - - [AlgoApiField("hasMore")] - public bool HasMore - { - get => hasMore; - set => hasMore = value; - } - - public bool Equals(FetchMessagesResponsePayload other) - { - return ArrayComparer.Equals(Messages, other.Messages) - && HasMore.Equals(other.HasMore); - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/FetchMessagesPayload.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/FetchMessagesPayload.cs.meta deleted file mode 100644 index 035b4cc83..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/FetchMessagesPayload.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 160acb2cdb694462cbae402f7b3382a6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/PublishPayload.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/PublishPayload.cs deleted file mode 100644 index 9d13a747f..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/PublishPayload.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - /// - /// Used when a client publishes a message to a server. - ///
- /// https://docs.walletconnect.com/2.0/specs/servers/relay/relay-server-rpc#publish-payload - ///
- [AlgoApiObject] - [Serializable] - public partial struct PublishRequestPayload : IEquatable - { - [SerializeField] - private Topic topic; - - [SerializeField] - private string message; - - [SerializeField] - private ulong timeToLive; - - [SerializeField] - private ulong tag; - - [AlgoApiField("topic")] - public Topic Topic - { - get => topic; - set => topic = value; - } - - [AlgoApiField("message")] - public string Message - { - get => message; - set => message = value; - } - - [AlgoApiField("ttl")] - public ulong TimeToLive - { - get => timeToLive; - set => timeToLive = value; - } - - [AlgoApiField("tag")] - public ulong Tag - { - get => tag; - set => tag = value; - } - - public bool Equals(PublishRequestPayload other) - { - return Topic.Equals(other.Topic) - && StringComparer.Equals(Message, other.Message) - && TimeToLive.Equals(other.TimeToLive) - && Tag.Equals(other.Tag) - ; - } - } - - /// - /// Used when a client publishes a message to a server. - ///
- /// https://docs.walletconnect.com/2.0/specs/servers/relay/relay-server-rpc#publish-payload - ///
- [Serializable] - [AlgoApiFormatter(typeof(WrappedValueFormatter))] - public partial struct PublishResponsePayload - : IEquatable - , IWrappedValue - { - [SerializeField] - private bool value; - - public bool WrappedValue { get => value; set => this.value = value; } - - public bool Equals(PublishResponsePayload other) - { - return value == other.value; - } - - public static implicit operator bool(PublishResponsePayload publishResponsePayload) - { - return publishResponsePayload.value; - } - - public static implicit operator PublishResponsePayload(bool value) - { - return new PublishResponsePayload { value = value }; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/PublishPayload.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/PublishPayload.cs.meta deleted file mode 100644 index 6ecec352d..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/PublishPayload.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b9af37dec59f24230a8ae0866b774a00 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/ReceivedMessage.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/ReceivedMessage.cs deleted file mode 100644 index b7414ebf0..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/ReceivedMessage.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - [AlgoApiObject] - [Serializable] - public partial struct ReceivedMessage : IEquatable - { - [SerializeField] - private Topic topic; - - [SerializeField] - private string message; - - [SerializeField] - private ulong publishedAt; - - [SerializeField] - private ulong tag; - - [AlgoApiField("topic")] - public Topic Topic - { - get => topic; - set => topic = value; - } - - [AlgoApiField("message")] - public string Message - { - get => message; - set => message = value; - } - - [AlgoApiField("publishedAt")] - public ulong PublishedAt - { - get => publishedAt; - set => publishedAt = value; - } - - [AlgoApiField("tag")] - public ulong Tag - { - get => tag; - set => tag = value; - } - - public bool Equals(ReceivedMessage other) - { - return Topic.Equals(other.Topic) - && StringComparer.Equals(Message, other.Message) - && PublishedAt.Equals(other.PublishedAt) - && Tag.Equals(other.Tag) - ; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/ReceivedMessage.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/ReceivedMessage.cs.meta deleted file mode 100644 index b5915445e..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/ReceivedMessage.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e8fcad8652dc947d781a5aafff12414f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/SubscribePayload.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/SubscribePayload.cs deleted file mode 100644 index 1f1be3a12..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/SubscribePayload.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - /// - /// Used when a client subscribes a given topic. - ///
- /// https://docs.walletconnect.com/2.0/specs/servers/relay/relay-server-rpc#subscribe-payload - ///
- [AlgoApiObject] - [Serializable] - public partial struct SubscribeRequestPayload : IEquatable - { - [SerializeField] - private Topic topic; - - [AlgoApiField("topic")] - public Topic Topic - { - get => topic; - set => topic = value; - } - - public bool Equals(SubscribeRequestPayload other) - { - return Topic.Equals(other.Topic); - } - } - - /// - /// Used when a client subscribes a given topic. - ///
- /// https://docs.walletconnect.com/2.0/specs/servers/relay/relay-server-rpc#subscribe-payload - ///
- [Serializable] - [AlgoApiFormatter(typeof(WrappedValueFormatter))] - public partial struct SubscribeResponsePayload - : IEquatable - , IWrappedValue - { - [SerializeField] - private string value; - - public string WrappedValue { get => value; set => this.value = value; } - - public string SubscriptionId { get => value; set => this.value = value; } - - public bool Equals(SubscribeResponsePayload other) - { - return StringComparer.Equals(value, other.value); - } - - public static implicit operator string(SubscribeResponsePayload payload) - { - return payload.value; - } - - public static implicit operator SubscribeResponsePayload(string value) - { - return new SubscribeResponsePayload { value = value }; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/SubscribePayload.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/SubscribePayload.cs.meta deleted file mode 100644 index 9caa91f23..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/SubscribePayload.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 91d5e233e2f274014bd4fc1c4e9f2d54 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/SubscriptionPayload.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/SubscriptionPayload.cs deleted file mode 100644 index a141029e8..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/SubscriptionPayload.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - /// - /// Used when a server sends a subscription message to a client. - ///
- /// https://docs.walletconnect.com/2.0/specs/servers/relay/relay-server-rpc#subscription-payload - ///
- [AlgoApiObject] - [Serializable] - public partial struct SubscriptionRequestPayload : IEquatable - { - [SerializeField] - private string id; - - [SerializeField] - private ReceivedMessage data; - - [AlgoApiField("id")] - public string Id - { - get => id; - set => id = value; - } - - [AlgoApiField("data")] - public ReceivedMessage Data - { - get => data; - set => data = value; - } - - public bool Equals(SubscriptionRequestPayload other) - { - return StringComparer.Equals(Id, other.Id) - && Data.Equals(other.Data) - ; - } - } - - /// - /// Used when a server sends a subscription message to a client. - ///
- /// https://docs.walletconnect.com/2.0/specs/servers/relay/relay-server-rpc#subscription-payload - ///
- [Serializable] - [AlgoApiFormatter(typeof(WrappedValueFormatter))] - public partial struct SubscriptionResponsePayload - : IEquatable - , IWrappedValue - { - [SerializeField] - private bool value; - - public bool WrappedValue { get => value; set => this.value = value; } - - public bool Equals(SubscriptionResponsePayload other) - { - return value == other.value; - } - - public static implicit operator bool(SubscriptionResponsePayload payload) - { - return payload.value; - } - - public static implicit operator SubscriptionResponsePayload(bool value) - { - return new SubscriptionResponsePayload { value = value }; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/SubscriptionPayload.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/SubscriptionPayload.cs.meta deleted file mode 100644 index d77bb9bfd..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/SubscriptionPayload.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 72e3d1058ca3c4d6ebe76c17219d1bfd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/UnsubscribePayload.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/UnsubscribePayload.cs deleted file mode 100644 index 6f72a0491..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/UnsubscribePayload.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect.Core -{ - /// - /// Used when a client unsubscribes a given topic. - ///
- /// https://docs.walletconnect.com/2.0/specs/servers/relay/relay-server-rpc#unsubscribe-payload - ///
- [AlgoApiObject] - [Serializable] - public partial struct UnsubscribeRequestPayload : IEquatable - { - [SerializeField] - private Topic topic; - - [SerializeField] - private string id; - - [AlgoApiField("topic")] - public Topic Topic - { - get => topic; - set => topic = value; - } - - [AlgoApiField("id")] - public string Id - { - get => id; - set => id = value; - } - - public bool Equals(UnsubscribeRequestPayload other) - { - return Topic.Equals(other.Topic) - && StringComparer.Equals(Id, other.Id) - ; - } - } - - /// - /// Used when a client unsubscribes a given topic. - ///
- /// https://docs.walletconnect.com/2.0/specs/servers/relay/relay-server-rpc#unsubscribe-payload - ///
- [Serializable] - [AlgoApiFormatter(typeof(WrappedValueFormatter))] - public partial struct UnsubscribeResponsePayload - : IEquatable - , IWrappedValue - { - [SerializeField] - private bool value; - - public bool WrappedValue { get => value; set => this.value = value; } - - public bool Equals(UnsubscribeResponsePayload other) - { - return value == other.value; - } - - public static implicit operator bool(UnsubscribeResponsePayload payload) - { - return payload.value; - } - - public static implicit operator UnsubscribeResponsePayload(bool value) - { - return new UnsubscribeResponsePayload { value = value }; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/UnsubscribePayload.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/UnsubscribePayload.cs.meta deleted file mode 100644 index 848aff8ee..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Payloads/UnsubscribePayload.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0187a132666ef4271903b80f713566f0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/RelayClient.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/RelayClient.cs deleted file mode 100644 index e16ab75bf..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/RelayClient.cs +++ /dev/null @@ -1,189 +0,0 @@ -using System.Net.WebSockets; -using Algorand.Unity.Collections; -using Algorand.Unity.JsonRpc; -using Algorand.Unity.WebSocket; -using Unity.Collections; -using UnityEngine.Networking; - -namespace Algorand.Unity.WalletConnect.Core -{ - /// - /// Wrapper around that implements the WalletConnect Relay Protocol. - /// - public struct RelayClient - { - public const ulong DefaultTimeToLive = 60 * 60 * 24; - - public readonly IWebSocketClient ws; - - public RelayClient(IWebSocketClient webSocket) - { - ws = webSocket; - } - - public RelayClient( - string relayUrl, - string projectId, - UserAgent userAgent) - { - var seed = Crypto.Random.Bytes(); - var auth = JwtUrl.SignJwt(relayUrl, seed); - auth = UnityWebRequest.EscapeURL(auth); - var ua = userAgent.ToString(); - ua = UnityWebRequest.EscapeURL(ua); - - var url = $"{relayUrl}?auth={auth}&projectId={projectId}&ua={ua}"; - ws = WebSocketClientFactory.Create(url); - } - - /// - /// Connects to the relay. - /// - public void Connect() - { - ws.Connect(); - } - - /// - /// Closes the connection to the relay. - /// - /// - /// - public void Close(WebSocketCloseStatus code = WebSocketCloseStatus.NormalClosure, string reason = null) - { - ws.Close(code, reason); - } - - public JsonRpcEvent Poll() - { - var wsEvent = ws.Poll(); - switch (wsEvent.Type) - { - case WebSocketEvent.WebSocketEventType.Close: - return new JsonRpcEvent - { - Type = JsonRpcEventType.Close, - Reason = wsEvent.Reason - }; - case WebSocketEvent.WebSocketEventType.Error: - return new JsonRpcEvent - { - Type = JsonRpcEventType.Error, - Error = wsEvent.Error - }; - case WebSocketEvent.WebSocketEventType.Open: - return new JsonRpcEvent - { - Type = JsonRpcEventType.Open - }; - case WebSocketEvent.WebSocketEventType.Payload: - var json = wsEvent.Payload; - var eitherRequestOrResponse = AlgoApiSerializer.DeserializeJson>(json); - if (eitherRequestOrResponse.TryGetValue1(out var request)) - return new JsonRpcEvent - { - Type = JsonRpcEventType.Request, - Request = request - }; - else if (eitherRequestOrResponse.TryGetValue2(out var response)) - return new JsonRpcEvent - { - Type = JsonRpcEventType.Response, - Response = response - }; - return new JsonRpcEvent - { - Type = JsonRpcEventType.Error, - Error = "Could not deserialize payload" - }; - case WebSocketEvent.WebSocketEventType.Nothing: - return new JsonRpcEvent - { - Type = JsonRpcEventType.Nothing - }; - default: - return new JsonRpcEvent - { - Type = JsonRpcEventType.Error, - Error = $"Unknown WebSocketEvent type: {wsEvent.Type}" - }; - } - } - - public ulong Publish(Topic topic, string message, ulong tag, ulong timeToLive = DefaultTimeToLive) - { - var request = new PublishRequestPayload - { - Topic = topic, - Message = message, - TimeToLive = timeToLive, - Tag = tag - }; - var jsonRpc = new JsonRpcRequest - { - Id = RpcId.GenerateId(), - JsonRpc = "2.0", - Method = "irn_publish", - Params = request - }; - using var json = AlgoApiSerializer.SerializeJson(jsonRpc, Allocator.Temp); - ws.Send(json.AsArray().AsSpan()); - return jsonRpc.Id; - } - - public ulong Subscribe(Topic topic) - { - var request = new SubscribeRequestPayload - { - Topic = topic - }; - var jsonRpc = new JsonRpcRequest - { - Id = RpcId.GenerateId(), - JsonRpc = "2.0", - Method = "irn_subscribe", - Params = request - }; - using var json = AlgoApiSerializer.SerializeJson(jsonRpc, Allocator.Temp); - ws.Send(json.AsArray().AsSpan()); - return jsonRpc.Id; - } - - public ulong Unsubscribe(Topic topic, string id) - { - var request = new UnsubscribeRequestPayload - { - Topic = topic, - Id = id - }; - var jsonRpc = new JsonRpcRequest - { - Id = RpcId.GenerateId(), - JsonRpc = "2.0", - Method = "irn_unsubscribe", - Params = request - }; - using var json = AlgoApiSerializer.SerializeJson(jsonRpc, Allocator.Temp); - ws.Send(json.AsArray().AsSpan()); - return jsonRpc.Id; - } - - public ulong FetchMessages(Topic topic) - { - var request = new FetchMessagesRequestPayload - { - Topic = topic - }; - var jsonRpc = new JsonRpcRequest - { - Id = RpcId.GenerateId(), - JsonRpc = "2.0", - Method = "irn_fetchMessages", - Params = request - }; - using var json = AlgoApiSerializer.SerializeJson(jsonRpc, Allocator.Temp); - ws.Send(json.AsArray().AsSpan()); - return jsonRpc.Id; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/RelayClient.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/RelayClient.cs.meta deleted file mode 100644 index 8b1578d14..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/RelayClient.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0d39df872e4a64de8b8b186459975365 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/RpcId.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/RpcId.cs deleted file mode 100644 index 7077a5567..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/RpcId.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect.Core -{ - public static class RpcId - { - public const int DefaultEntropyPower = 10 * 10 * 10 * 10 * 10 * 10; - - public static ulong GenerateId(byte entropyDigits = 6) - { - ulong entropyPower = IPow(10, entropyDigits); - var entropy = Crypto.Random.Bytes(); - var timestampEpoch = (ulong)((DateTimeOffset)DateTime.UtcNow).ToUnixTimeMilliseconds(); - return entropy % entropyPower - + timestampEpoch * entropyPower; - } - - private static ulong IPow(ulong x, byte exp) - { - var result = 1UL; - while (exp > 0) - { - if ((exp & 1) != 0) - { - result *= x; - } - exp >>= 1; - result *= result; - } - return result; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/RpcId.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/RpcId.cs.meta deleted file mode 100644 index 4a658ece5..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/RpcId.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5c5188635b20e4cfabd1ec216f58a5f3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Topic.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Topic.cs deleted file mode 100644 index 258fb0c4b..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Topic.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Algorand.Unity.Json; -using Algorand.Unity.LowLevel; -using Algorand.Unity.MessagePack; -using Unity.Collections; - -namespace Algorand.Unity.WalletConnect.Core -{ - /// - /// 32 byte random id for a walletconnect topic. - /// - [AlgoApiFormatter(typeof(TopicFormatter))] - [StructLayout(LayoutKind.Sequential, Size = 32)] - public unsafe partial struct Topic - : IEquatable - , IByteArray - { - public fixed byte bytes[32]; - - public int Length => 32; - - public byte this[int index] { get => this.GetByteAt(index); set => this.SetByteAt(index, value); } - - public override string ToString() - { - Span output = stackalloc char[64]; - fixed (byte* ptr = bytes) - { - var byteSpan = new ReadOnlySpan(ptr, 32); - HexConverter.ToHex(byteSpan, output, out _); - } - return output.ToString(); - } - - public FixedString128Bytes ToFixedString() - { - var output = default(FixedString128Bytes); - - fixed (byte* ptr = bytes) - { - var byteSpan = new ReadOnlySpan(ptr, 32); - var error = HexConverter.ToHex(byteSpan, ref output); - if (error > 0) - { - throw new FormatException(error.ToString()); - } - } - - return output; - } - - public static Topic Random() - { - return Crypto.Random.Bytes(); - } - - public unsafe static Topic FromString(TFixedString fixedString) - where TFixedString : struct, INativeList, IUTF8Bytes - { - var result = default(Topic); - var resultSpan = new Span(result.bytes, 32); - var error = HexConverter.FromHex(fixedString, resultSpan, out _); - if (error > 0) - { - throw new FormatException($"Invalid hex string: {fixedString}"); - } - return result; - } - - public bool Equals(Topic other) - { - return ByteArray.Equals(this, other); - } - - public void* GetUnsafePtr() - { - fixed (byte* ptr = bytes) return ptr; - } - - public class TopicFormatter : IAlgoApiFormatter - { - public Topic Deserialize(ref JsonReader reader) - { - var s = AlgoApiFormatterCache.Formatter.Deserialize(ref reader); - return FromString(s); - } - - public Topic Deserialize(ref MessagePackReader reader) - { - var s = AlgoApiFormatterCache.Formatter.Deserialize(ref reader); - return FromString(s); - } - - public void Serialize(ref JsonWriter writer, Topic value) - { - var s = value.ToFixedString(); - AlgoApiFormatterCache.Formatter.Serialize(ref writer, s); - } - - public void Serialize(ref MessagePackWriter writer, Topic value) - { - var s = value.ToFixedString(); - AlgoApiFormatterCache.Formatter.Serialize(ref writer, s); - } - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Topic.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Topic.cs.meta deleted file mode 100644 index 8d0247ce9..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/Topic.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0129b3168deda45e9b331d4dc74fa384 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/UserAgent.cs b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/UserAgent.cs deleted file mode 100644 index 88aaab58e..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/UserAgent.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect.Core -{ - [Serializable] - public partial struct UserAgent - { - public string protocol; - public string version; - public string sdkVersion; - - public static UserAgent Default => new() - { - protocol = "wc", - version = "2", - sdkVersion = "4.2.0-exp.1" - }; - - public override readonly string ToString() - { - var os = Environment.OSVersion.Platform.ToString(); - var osVersion = Environment.OSVersion.Version.ToString(); - - var environment = $"WalletConnectSharpv2:{Environment.Version}"; - var sdkType = "unity-algorand"; - - return $"{protocol}-{version}/{sdkType}-{sdkVersion}/{os}-{osVersion}/{environment}"; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/UserAgent.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/Relay/UserAgent.cs.meta deleted file mode 100644 index 07736f784..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/Relay/UserAgent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1b2ac06742aaf463d995c421c473f14c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/TimeToLive.cs b/Runtime/Algorand.Unity.WalletConnect.Core/TimeToLive.cs deleted file mode 100644 index 652415869..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/TimeToLive.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect.Core -{ - public static class TimeToLive - { - public static long Now => ((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds(); - - public static bool IsExpired(long expiry) - { - return Now >= expiry; - } - - public static long GetExpiry(long seconds) - { - return Now + seconds; - } - - public static long GetExpiry(long seconds, DateTime now) - { - return ((DateTimeOffset)now).ToUnixTimeSeconds() + seconds; - } - } -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Core/TimeToLive.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Core/TimeToLive.cs.meta deleted file mode 100644 index 5bb61a9e6..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Core/TimeToLive.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 022f5af9cf1c4aa4a4a1b8a9a97a007c -timeCreated: 1690779645 \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Sign.meta b/Runtime/Algorand.Unity.WalletConnect.Sign.meta deleted file mode 100644 index a369d5271..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Sign.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: bb4f0729b6f1049a3b7abadf894e6531 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Sign/Algorand.Unity.WalletConnect.Sign.asmdef b/Runtime/Algorand.Unity.WalletConnect.Sign/Algorand.Unity.WalletConnect.Sign.asmdef deleted file mode 100644 index 699e59e96..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Sign/Algorand.Unity.WalletConnect.Sign.asmdef +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "Algorand.Unity.WalletConnect.Sign", - "rootNamespace": "Algorand.Unity.WalletConnect.Sign", - "references": [ - "GUID:45ab5c0c2cb4a0e4ba897b731349c490", - "GUID:f8b80ea32105bf74aa022a9a7e066bc1", - "GUID:9f8c967ec86c9324c9b2928ff73b4cf1", - "GUID:f51ebe6a0ceec4240a699833d6309b23", - "GUID:96a3d11394a174143976db8839772a1a", - "GUID:3593772e9e2814b759387539d266dc24" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Sign/Algorand.Unity.WalletConnect.Sign.asmdef.meta b/Runtime/Algorand.Unity.WalletConnect.Sign/Algorand.Unity.WalletConnect.Sign.asmdef.meta deleted file mode 100644 index debfe4b61..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Sign/Algorand.Unity.WalletConnect.Sign.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 70929ab3109ec4ddcacc8ca540efbbe2 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.Sign/WalletConnectSignError.cs b/Runtime/Algorand.Unity.WalletConnect.Sign/WalletConnectSignError.cs deleted file mode 100644 index 9198ed201..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Sign/WalletConnectSignError.cs +++ /dev/null @@ -1,49 +0,0 @@ -namespace Algorand.Unity.WalletConnect.Sign -{ - /// - /// Error codes for WalletConnect Sign APIs. - /// https://docs.walletconnect.com/2.0/specs/clients/sign/error-codes - /// - public enum WalletConnectSignError - { - None = 0, - - // INVALID - InvalidMethod = 1001, - InvalidEvent = 1002, - InvalidUpdateRequest = 1003, - InvalidExtendRequest = 1004, - InvalidSessionSettleRequest = 1005, - - // UNAUTHORIZED - UnauthorizedMethod = 3001, - UnauthorizedEvent = 3002, - UnauthorizedUpdateRequest = 3003, - UnauthorizedExtendRequest = 3004, - UnauthorizedChain = 3005, - - // EIP-1193 - UserRejectedRequest = 4001, - - // REJECTED (CAIP-25) - UserRejected = 5000, - UserRejectedChains = 5001, - UserRejectedMethods = 5002, - UserRejectedEvents = 5003, - UnsupportedChains = 5100, - UnsupportedMethods = 5101, - UnsupportedEvents = 5102, - UnsupportedAccounts = 5103, - UnsupportedNamespaceKey = 5104, - - // REASON - UserDisconnected = 6000, - - // FAILURE - SessionSettlementFailed = 7000, - NoSessionForTopic = 7001, - - // SESSION REQUEST - SessionRequestExpired = 8000 - } -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect.Sign/WalletConnectSignError.cs.meta b/Runtime/Algorand.Unity.WalletConnect.Sign/WalletConnectSignError.cs.meta deleted file mode 100644 index 5824cd96f..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.Sign/WalletConnectSignError.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c4a43730fc17c404493843dd9ff82eff -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect.meta b/Runtime/Algorand.Unity.WalletConnect.meta deleted file mode 100644 index b5f40b73a..000000000 --- a/Runtime/Algorand.Unity.WalletConnect.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3173a7c0168984cf9b4dfb1ae786066d -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Algorand.Unity.WalletConnect.asmdef b/Runtime/Algorand.Unity.WalletConnect/Algorand.Unity.WalletConnect.asmdef deleted file mode 100644 index 7fccf3db3..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Algorand.Unity.WalletConnect.asmdef +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "Algorand.Unity.WalletConnect", - "rootNamespace": "Algorand.Unity.WalletConnect", - "references": [ - "GUID:45ab5c0c2cb4a0e4ba897b731349c490", - "GUID:f51ebe6a0ceec4240a699833d6309b23", - "GUID:9f8c967ec86c9324c9b2928ff73b4cf1", - "GUID:f8b80ea32105bf74aa022a9a7e066bc1", - "GUID:e0cd26848372d4e5c891c569017e11f1", - "GUID:8dadf2ce3ffc34301a9f6d2e747938f6", - "GUID:05e3a0220cef448b5bedf723e2dd99f4", - "GUID:2ee6601452ca245499e63674423f6541", - "GUID:427b0dd64d04a4a02b8413b20fc93483", - "GUID:70d524b45145c40acbd35603c8e43743", - "GUID:d8b63aba1907145bea998dd612889d6b" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": true, - "overrideReferences": true, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect/Algorand.Unity.WalletConnect.asmdef.meta b/Runtime/Algorand.Unity.WalletConnect/Algorand.Unity.WalletConnect.asmdef.meta deleted file mode 100644 index 6ae8aaced..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Algorand.Unity.WalletConnect.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 7d7102a6f2a084a30ad9e7734dd7ec17 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/AlgorandWalletConnectSession.cs b/Runtime/Algorand.Unity.WalletConnect/AlgorandWalletConnectSession.cs deleted file mode 100644 index 4efac98cc..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/AlgorandWalletConnectSession.cs +++ /dev/null @@ -1,299 +0,0 @@ -using System; -using System.Threading; -using Cysharp.Threading.Tasks; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect -{ - public class AlgorandWalletConnectSession - : IActiveWalletConnectSession - { - private SessionData sessionData; - - private JsonRpcClient rpc; - - private UniTask listeningForApproval; - - /// - public event Action OnSessionConnect; - - /// - public event Action OnSessionDisconnect; - - /// - public event Action OnSessionUpdate; - - /// - public Address[] Accounts => sessionData.Accounts; - - /// - public string Version => "1"; - - public SessionStatus ConnectionStatus { get; private set; } - - /// - public int ChainId => sessionData.ChainId; - - /// - public ulong HandshakeId => sessionData.HandshakeId; - - /// - public int NetworkId => sessionData.NetworkId; - - /// - public string PeerId => sessionData.PeerId; - - /// - public string ClientId => sessionData.ClientId; - - /// - public string BridgeUrl => sessionData.BridgeUrl; - - /// - public Hex Key => sessionData.Key; - - /// - public ClientMeta DappMeta => sessionData.DappMeta; - - /// - public ClientMeta WalletMeta => sessionData.WalletMeta; - - /// - /// The current handshake topic if this session is handshaking. - /// - public string HandshakeTopic { get; protected set; } - - /// - /// Create a new session. - /// - /// The metadata of the Dapp. - /// An optional WalletConnect bridgeurl. e.g. https://bridge.walletconnect.org - public AlgorandWalletConnectSession(ClientMeta clientMeta, string bridgeUrl = null) - { - sessionData = SessionData.InitSession( - clientMeta, - bridgeUrl - ); - rpc = new JsonRpcClient(sessionData.BridgeUrl.Replace("http", "ws"), sessionData.Key); - } - - /// - /// Continue an existing session. - /// - /// A previously existing session. - public AlgorandWalletConnectSession(SessionData sessionData) - { - if (string.IsNullOrEmpty(sessionData.BridgeUrl)) - throw new ArgumentException("BridgeUrl must not be empty", nameof(sessionData)); - if (string.IsNullOrEmpty(sessionData.DappMeta.Url)) - throw new ArgumentException("DappMeta.Url must not be empty", nameof(sessionData)); - if (string.IsNullOrEmpty(sessionData.DappMeta.Name)) - throw new ArgumentException("DappMeta.Name must not be empty", nameof(sessionData)); - if (sessionData.Key.Data == null) - throw new ArgumentException("Key must not be empty", nameof(sessionData)); - if (sessionData.Key.Data.Length != 32) - throw new ArgumentException("Key must be 32 bytes long", nameof(sessionData)); - this.sessionData = sessionData; - rpc = new JsonRpcClient(this.sessionData.BridgeUrl.Replace("http", "ws"), this.sessionData.Key); - } - - public void Dispose() - { - rpc?.Dispose(); - rpc = null; - } - - /// - /// Save the current session's state. - /// - /// A that can be used for continuing an existing session later. - public SessionData Save() - { - return sessionData; - } - - /// - /// Connect to WalletConnect Bridge and begin listening for messages. - /// - /// - /// - public async UniTask Connect(CancellationToken cancellationToken = default) - { - if (ConnectionStatus != SessionStatus.None) - throw new InvalidOperationException($"Session connection status is {ConnectionStatus}"); - - rpc.OnSocketClosed += HandleSocketClosed; - rpc.OnRequestReceived += HandleJsonRpcRequestReceived; - await rpc.Connect(ClientId, cancellationToken); - if (!string.IsNullOrEmpty(PeerId)) - { - ConnectionStatus = SessionStatus.WalletConnected; - OnSessionConnect?.Invoke(this); - } - else if (HandshakeId != default) - { - ConnectionStatus = SessionStatus.RequestingWalletConnection; - listeningForApproval = rpc.ListenForResponse(HandshakeId); - } - else - { - ConnectionStatus = SessionStatus.NoWalletConnected; - } - } - - /// - /// Start the handshake process for a new WalletConnect session. - /// - /// A WalletConnect Standard URI format (EIP-1328) used for handshaking. - public HandshakeUrl RequestWalletConnection() - { - switch (ConnectionStatus) - { - case SessionStatus.NoWalletConnected: - sessionData.HandshakeId = WalletConnectRpc.GetRandomId(); - HandshakeTopic = Guid.NewGuid().ToString(); - var request = WalletConnectRpc.SessionRequest( - peerId: ClientId, - peerMeta: DappMeta, - id: HandshakeId - ); - listeningForApproval = rpc.Send(request, HandshakeTopic); - ConnectionStatus = SessionStatus.RequestingWalletConnection; - break; - case SessionStatus.RequestingWalletConnection: - break; - default: - throw new InvalidOperationException($"Session connection status is {ConnectionStatus}"); - } - - return new HandshakeUrl(HandshakeTopic, Version, BridgeUrl, Key); - } - - /// - /// Wait for an approval response from the handshake. - /// - /// - /// An optional that can be used for things like timeouts. - /// - public async UniTask WaitForWalletApproval(CancellationToken cancellationToken = default) - { - if (ConnectionStatus != SessionStatus.RequestingWalletConnection) - throw new InvalidOperationException($"Session connection status is {ConnectionStatus}"); - - var handshakeResponse = await listeningForApproval; - var sessionData = - AlgoApiSerializer.DeserializeJson(handshakeResponse.Result.Json); - UpdateSession(sessionData); - HandshakeTopic = null; - ConnectionStatus = SessionStatus.WalletConnected; - OnSessionConnect?.Invoke(this); - } - - /// - /// Disconnect from a or session. - /// - /// An optional reason to inform the web socket client. - public void DisconnectWallet(string reason = default) - { - rpc.Disconnect(reason); - ConnectionStatus = SessionStatus.None; - sessionData = SessionData.InitSession(sessionData.DappMeta, sessionData.BridgeUrl); - OnSessionDisconnect?.Invoke(reason); - } - - /// - /// Sign a group of transactions. - /// - /// Optional sign transaction options. - /// - /// Optional cancellation token used for interrupting this request. - /// It's recommended to use for UniTask. - /// https://github.com/Cysharp/UniTask#timeout-handling - /// - /// - /// The atomic transaction group of [1,16] transactions. Contains information about how to sign - /// each transaction, and which ones to sign. - /// - /// - /// Either the result of the request or a if the request was invalid. - /// - /// The result is an array of the same length as the number of transactions provided in - /// . - /// - /// For every index in this result, the value is - /// - /// null if the wallet was not requested to sign this transaction - /// the canonical message pack encoding of the signed transaction - /// - /// - public async UniTask> SignTransactions( - WalletTransaction[] transactions, - SignTxnsOpts options = default, - CancellationToken cancellationToken = default - ) - { - if (ConnectionStatus != SessionStatus.WalletConnected) - throw new InvalidOperationException($"Session connection status is {ConnectionStatus}"); - - var isNetworkAgnostic = ChainId == WalletConnectRpc.Algorand.ChainId; - if (!isNetworkAgnostic && WalletConnectRpc.Algorand.GetNetworkFromChainId(ChainId) == AlgorandNetwork.None) - throw new InvalidOperationException( - $"Wallet does not have Algorand as the active chain. Active chain id is: {ChainId}."); - - var request = WalletConnectRpc.Algorand.SignTransactions(transactions, options); - var response = await rpc.Send(request, PeerId, cancellationToken); - if (response.IsError) - return (SignTxnsError)response.Error; - return AlgoApiSerializer.DeserializeJson(response.Result.Json); - } - - private void HandleSocketClosed(string reason) - { - OnSessionDisconnect?.Invoke(reason); - } - - private void HandleJsonRpcRequestReceived(JsonRpcRequest request) - { - switch (request.Method) - { - case WalletConnectRpc.SessionUpdateMethod: - if (request.Params == null || request.Params.Length != 1) - throw new NotSupportedException( - $"The JsonRpcRequest method \"{WalletConnectRpc.SessionUpdateMethod}\" only supports params of length 1."); - var sessonUpdate = - AlgoApiSerializer.DeserializeJson(request.Params[0].Json); - UpdateSession(sessonUpdate); - OnSessionUpdate?.Invoke(sessonUpdate); - break; - default: - throw new NotSupportedException($"The JsonRpcRequest method \"{request.Method}\" is not supported"); - } - } - - private void UpdateSession(WalletConnectSessionData sessionData) - { - if (!sessionData.IsApproved) - { - DisconnectWallet("Session no longer approved."); - return; - } - - switch (sessionData.ChainId) - { - case WalletConnectRpc.Algorand.TestNetChainId: - case WalletConnectRpc.Algorand.BetaNetChainId: - case WalletConnectRpc.Algorand.MainNetChainId: - case WalletConnectRpc.Algorand.ChainId: - break; - default: - DisconnectWallet($"Invalid chain id: {sessionData.ChainId}"); - return; - } - - this.sessionData.PeerId = sessionData.PeerId; - this.sessionData.WalletMeta = sessionData.PeerMeta; - this.sessionData.ChainId = sessionData.ChainId; - this.sessionData.Accounts = sessionData.Accounts; - } - } -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect/AlgorandWalletConnectSession.cs.meta b/Runtime/Algorand.Unity.WalletConnect/AlgorandWalletConnectSession.cs.meta deleted file mode 100644 index 6c2c50d42..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/AlgorandWalletConnectSession.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a3e8dceaf4dd9406cb4e8972fd97a8ed -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/AppEntry.cs b/Runtime/Algorand.Unity.WalletConnect/AppEntry.cs deleted file mode 100644 index 73e0cc25f..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/AppEntry.cs +++ /dev/null @@ -1,163 +0,0 @@ -using System; -using UnityEngine; -using UnityEngine.Networking; - -namespace Algorand.Unity.WalletConnect -{ - /// - /// Contains information about an app that supports WalletConnect - /// - [Serializable] - public class AppEntry - { - /// - /// Unique id of this app - /// - public string Id; - - /// - /// Name of this app. - /// - public string Name; - - /// - /// Homepage for this app. - /// - public string HomePage; - - /// - /// This App's supported blockchains - /// - public string[] Chains; - - /// - /// A unique id for this App's image, useful for caching. - /// - public string ImageId; - - /// - /// ImageUrls for downloading this App's image. - /// - public ImageUrls ImageUrl; - - /// - /// The locations of this app on available platforms. - /// - public AppUrls App; - - /// - /// Contains information about ios native and universal linking. - /// - public AppLinkingScheme Mobile; - - /// - /// Contains information about native and universal linking on desktop. - /// - public AppLinkingScheme Desktop; - - /// - /// Additional Metadata that can be useful when showing the app. - /// - public AppMetadata Metadata; - - /// - /// Launch this app natively to approve a WalletConnect session. - /// - /// The handshake used for the session. - public void LaunchForConnect(HandshakeUrl handshake) => - LaunchApp(handshake.Url); - - /// - /// Launch this app natively to allow users to approve a signing request from a - /// WalletConnect session. - /// - /// The WalletConnect version of your session. - public void LaunchForSigning(string walletConnectVersion = "1") => - LaunchApp($"wc:00e46b69-d0cc-4b3e-b6a2-cee442f97188@{walletConnectVersion}"); - - private void LaunchApp(string url) - { - var deepLinkUrl = FormatUrlForDeepLink(url); - UnityEngine.Application.OpenURL(deepLinkUrl); - } - - public string FormatUrlForDeepLink(string url) - { -#if UNITY_IPHONE && !UNITY_EDITOR - return FormatUrlForDeepLinkIos(url); -#else - return url; -#endif - } - - public string FormatUrlForDeepLinkIos(string url) - { - url = UnityWebRequest.EscapeURL(url); - if (!string.IsNullOrEmpty(Mobile.Universal)) - { - return $"{Mobile.Universal}/wc?uri={url}"; - } - else if (!string.IsNullOrEmpty(Mobile.Native)) - { - return $"{Mobile.Native}//wc?uri={url}"; - } - else - { - return ""; - } - } - - [Serializable] - public struct ImageUrls - { - public string Small; - public string Medium; - public string Large; - } - - [Serializable] - public struct AppUrls - { - public string Browser; - public string Ios; - public string Android; - public string Mac; - public string Windows; - public string Linux; - } - - [Serializable] - public struct AppLinkingScheme - { - /// - /// The prefix used when using a native link. - /// - public string Native; - - /// - /// The url used when using a universal link. - /// - public string Universal; - } - - [Serializable] - public struct AppMetadata - { - /// - /// A short name of this app if it has one -- useful on smaller screens. - /// - public string ShortName; - - /// - /// Primary and secondary colors of this App. - /// - public AppColors Colors; - - public struct AppColors - { - public Color Primary; - public Color Secondary; - } - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/AppEntry.cs.meta b/Runtime/Algorand.Unity.WalletConnect/AppEntry.cs.meta deleted file mode 100644 index b2b1f6e8a..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/AppEntry.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0591c676c7ab545ae92e2b7006eb82c2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Crypto.meta b/Runtime/Algorand.Unity.WalletConnect/Crypto.meta deleted file mode 100644 index 4015032f1..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Crypto.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8ba1785d3b197462a89e288a10ea35b0 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Crypto/AesCipher.cs b/Runtime/Algorand.Unity.WalletConnect/Crypto/AesCipher.cs deleted file mode 100644 index 0fd6e5ed5..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Crypto/AesCipher.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.IO; -using System.Security.Cryptography; - -namespace Algorand.Unity.WalletConnect -{ - public static class AesCipher - { - public static EncryptedPayload EncryptWithKey(byte[] key, byte[] data) - { - var encryptedPayload = Encrypt(key, data); - encryptedPayload.Signature = encryptedPayload.Sign(key); - return encryptedPayload; - } - - public static byte[] DecryptWithKey(byte[] key, EncryptedPayload encryptedData) - { - encryptedData.ValidateHmac(key); - - using var cipher = CreateCipher(); - cipher.Key = key; - cipher.IV = encryptedData.Iv; - var decryptor = cipher.CreateDecryptor(cipher.Key, cipher.IV); - - using var encryptedStream = new MemoryStream(encryptedData.Data); - using var decryptedStream = new MemoryStream(); - using var cs = new CryptoStream(encryptedStream, decryptor, CryptoStreamMode.Read); - cs.CopyTo(decryptedStream); - cs.Flush(); - var result = decryptedStream.ToArray(); - return result; - } - - private static EncryptedPayload Encrypt(byte[] key, byte[] data) - { - using var ms = new MemoryStream(); - using var cipher = CreateCipher(); - - byte[] iv = cipher.IV; - var encryptor = cipher.CreateEncryptor(key, iv); - - Encrypt(data, ms, encryptor); - - var encryptedData = ms.ToArray(); - - return (iv, encryptedData); - } - - private static AesManaged CreateCipher() - { - return new AesManaged() - { - Mode = CipherMode.CBC, - Padding = PaddingMode.PKCS7, - KeySize = 256 - }; - } - - private static void Encrypt(byte[] data, MemoryStream ms, ICryptoTransform encryptor) - { - using var cs = new CryptoStream(ms, encryptor, CryptoStreamMode.Write); - cs.Write(data, 0, data.Length); - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Crypto/AesCipher.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Crypto/AesCipher.cs.meta deleted file mode 100644 index 5a90212a2..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Crypto/AesCipher.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c514f8e4dfdcd415b8316b0f48c289bb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen.meta b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen.meta deleted file mode 100644 index a6c36a951..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2e7b8e94d7cf54e239d2a88b97e5797f -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/ClientMeta.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/ClientMeta.Formatters.gen.cs deleted file mode 100644 index 7bbe7fffc..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/ClientMeta.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect -{ - - - public partial struct ClientMeta - { - - private static bool @__generated__IsValid = ClientMeta.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("description", (Algorand.Unity.WalletConnect.ClientMeta x) => x.Description, (ref Algorand.Unity.WalletConnect.ClientMeta x, System.String value) => x.Description = value, Algorand.Unity.StringComparer.Instance).Assign("url", (Algorand.Unity.WalletConnect.ClientMeta x) => x.Url, (ref Algorand.Unity.WalletConnect.ClientMeta x, System.String value) => x.Url = value, Algorand.Unity.StringComparer.Instance).Assign("icons", (Algorand.Unity.WalletConnect.ClientMeta x) => x.IconUrls, (ref Algorand.Unity.WalletConnect.ClientMeta x, System.String[] value) => x.IconUrls = value, Algorand.Unity.ArrayComparer.Instance).Assign("name", (Algorand.Unity.WalletConnect.ClientMeta x) => x.Name, (ref Algorand.Unity.WalletConnect.ClientMeta x, System.String value) => x.Name = value, Algorand.Unity.StringComparer.Instance)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/ClientMeta.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/ClientMeta.Formatters.gen.cs.meta deleted file mode 100644 index 72caf2635..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/ClientMeta.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b3c2cbf4164954ee88000fd2c6172651 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/EncryptedPayload.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/EncryptedPayload.Formatters.gen.cs deleted file mode 100644 index df533438b..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/EncryptedPayload.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect -{ - - - public partial struct EncryptedPayload - { - - private static bool @__generated__IsValid = EncryptedPayload.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("iv", (Algorand.Unity.WalletConnect.EncryptedPayload x) => x.Iv, (ref Algorand.Unity.WalletConnect.EncryptedPayload x, Algorand.Unity.Hex value) => x.Iv = value).Assign("hmac", (Algorand.Unity.WalletConnect.EncryptedPayload x) => x.Signature, (ref Algorand.Unity.WalletConnect.EncryptedPayload x, Algorand.Unity.Hex value) => x.Signature = value).Assign("data", (Algorand.Unity.WalletConnect.EncryptedPayload x) => x.Data, (ref Algorand.Unity.WalletConnect.EncryptedPayload x, Algorand.Unity.Hex value) => x.Data = value)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/EncryptedPayload.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/EncryptedPayload.Formatters.gen.cs.meta deleted file mode 100644 index 5d6f1abee..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/EncryptedPayload.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3d97c1d2b7d584d72afd650e7d974e2e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcError.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcError.Formatters.gen.cs deleted file mode 100644 index c1a4a556d..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcError.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect -{ - - - public partial struct JsonRpcError - { - - private static bool @__generated__IsValid = JsonRpcError.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("code", (Algorand.Unity.WalletConnect.JsonRpcError x) => x.Code, (ref Algorand.Unity.WalletConnect.JsonRpcError x, System.Int32 value) => x.Code = value).Assign("message", (Algorand.Unity.WalletConnect.JsonRpcError x) => x.Message, (ref Algorand.Unity.WalletConnect.JsonRpcError x, System.String value) => x.Message = value, Algorand.Unity.StringComparer.Instance).Assign("data", (Algorand.Unity.WalletConnect.JsonRpcError x) => x.Data, (ref Algorand.Unity.WalletConnect.JsonRpcError x, Algorand.Unity.AlgoApiObject value) => x.Data = value)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcError.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcError.Formatters.gen.cs.meta deleted file mode 100644 index 58e1c852e..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcError.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a3cbe196f6dcb4629969f9c7ac735035 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcRequest.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcRequest.Formatters.gen.cs deleted file mode 100644 index cac080177..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcRequest.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect -{ - - - public partial struct JsonRpcRequest - { - - private static bool @__generated__IsValid = JsonRpcRequest.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(true).Assign("id", (Algorand.Unity.WalletConnect.JsonRpcRequest x) => x.Id, (ref Algorand.Unity.WalletConnect.JsonRpcRequest x, Algorand.Unity.Optional value) => x.Id = value).Assign("jsonrpc", (Algorand.Unity.WalletConnect.JsonRpcRequest x) => x.JsonRpc, (ref Algorand.Unity.WalletConnect.JsonRpcRequest x, System.String value) => x.JsonRpc = value, Algorand.Unity.StringComparer.Instance).Assign("method", (Algorand.Unity.WalletConnect.JsonRpcRequest x) => x.Method, (ref Algorand.Unity.WalletConnect.JsonRpcRequest x, System.String value) => x.Method = value, Algorand.Unity.StringComparer.Instance).Assign("params", (Algorand.Unity.WalletConnect.JsonRpcRequest x) => x.Params, (ref Algorand.Unity.WalletConnect.JsonRpcRequest x, Algorand.Unity.AlgoApiObject[] value) => x.Params = value, Algorand.Unity.ArrayComparer.Instance)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcRequest.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcRequest.Formatters.gen.cs.meta deleted file mode 100644 index f4c381b51..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcRequest.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b712ba3d6d0ba4d5bbcea250e3694783 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcResponse.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcResponse.Formatters.gen.cs deleted file mode 100644 index f72fbf16a..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcResponse.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect -{ - - - public partial struct JsonRpcResponse - { - - private static bool @__generated__IsValid = JsonRpcResponse.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(true).Assign("id", (Algorand.Unity.WalletConnect.JsonRpcResponse x) => x.Id, (ref Algorand.Unity.WalletConnect.JsonRpcResponse x, Algorand.Unity.Optional value) => x.Id = value).Assign("jsonrpc", (Algorand.Unity.WalletConnect.JsonRpcResponse x) => x.JsonRpc, (ref Algorand.Unity.WalletConnect.JsonRpcResponse x, System.String value) => x.JsonRpc = value, Algorand.Unity.StringComparer.Instance).Assign("result", (Algorand.Unity.WalletConnect.JsonRpcResponse x) => x.Result, (ref Algorand.Unity.WalletConnect.JsonRpcResponse x, Algorand.Unity.AlgoApiObject value) => x.Result = value).Assign("error", (Algorand.Unity.WalletConnect.JsonRpcResponse x) => x.Error, (ref Algorand.Unity.WalletConnect.JsonRpcResponse x, Algorand.Unity.WalletConnect.JsonRpcError value) => x.Error = value)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcResponse.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcResponse.Formatters.gen.cs.meta deleted file mode 100644 index e451ee62a..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/JsonRpcResponse.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 526c73f7f7f244f28a0c2795fdc37acd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/MultisigMetadata.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/MultisigMetadata.Formatters.gen.cs deleted file mode 100644 index 647f7be22..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/MultisigMetadata.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect -{ - - - public partial struct MultisigMetadata - { - - private static bool @__generated__IsValid = MultisigMetadata.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("version", (Algorand.Unity.WalletConnect.MultisigMetadata x) => x.Version, (ref Algorand.Unity.WalletConnect.MultisigMetadata x, System.Byte value) => x.Version = value).Assign("threshold", (Algorand.Unity.WalletConnect.MultisigMetadata x) => x.Threshold, (ref Algorand.Unity.WalletConnect.MultisigMetadata x, System.Byte value) => x.Threshold = value).Assign("addrs", (Algorand.Unity.WalletConnect.MultisigMetadata x) => x.Addresses, (ref Algorand.Unity.WalletConnect.MultisigMetadata x, Algorand.Unity.Address[] value) => x.Addresses = value, Algorand.Unity.ArrayComparer.Instance)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/MultisigMetadata.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/MultisigMetadata.Formatters.gen.cs.meta deleted file mode 100644 index 96f0dd876..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/MultisigMetadata.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f263cd5cc3f274f7a8baf522644c25c1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/NetworkMessage.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/NetworkMessage.Formatters.gen.cs deleted file mode 100644 index 8eb7b7f9e..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/NetworkMessage.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect -{ - - - public partial struct NetworkMessage - { - - private static bool @__generated__IsValid = NetworkMessage.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("topic", (Algorand.Unity.WalletConnect.NetworkMessage x) => x.Topic, (ref Algorand.Unity.WalletConnect.NetworkMessage x, System.String value) => x.Topic = value, Algorand.Unity.StringComparer.Instance).Assign("type", (Algorand.Unity.WalletConnect.NetworkMessage x) => x.Type, (ref Algorand.Unity.WalletConnect.NetworkMessage x, System.String value) => x.Type = value, Algorand.Unity.StringComparer.Instance).Assign("payload", (Algorand.Unity.WalletConnect.NetworkMessage x) => x.Payload, (ref Algorand.Unity.WalletConnect.NetworkMessage x, System.String value) => x.Payload = value, Algorand.Unity.StringComparer.Instance).Assign("silent", (Algorand.Unity.WalletConnect.NetworkMessage x) => x.IsSilent, (ref Algorand.Unity.WalletConnect.NetworkMessage x, Algorand.Unity.Optional value) => x.IsSilent = value)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/NetworkMessage.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/NetworkMessage.Formatters.gen.cs.meta deleted file mode 100644 index 6615a7133..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/NetworkMessage.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 14f84f6cb3982456b9eb9ee6e259a72b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/SignTxnsError.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/SignTxnsError.Formatters.gen.cs deleted file mode 100644 index ec1bba2d7..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/SignTxnsError.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect -{ - - - public partial struct SignTxnsError - { - - private static bool @__generated__IsValid = SignTxnsError.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("message", (Algorand.Unity.WalletConnect.SignTxnsError x) => x.Message, (ref Algorand.Unity.WalletConnect.SignTxnsError x, System.String value) => x.Message = value, Algorand.Unity.StringComparer.Instance).Assign("code", (Algorand.Unity.WalletConnect.SignTxnsError x) => x.Code, (ref Algorand.Unity.WalletConnect.SignTxnsError x, System.Int32 value) => x.Code = value).Assign("data", (Algorand.Unity.WalletConnect.SignTxnsError x) => x.Data, (ref Algorand.Unity.WalletConnect.SignTxnsError x, Algorand.Unity.AlgoApiObject value) => x.Data = value)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/SignTxnsError.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/SignTxnsError.Formatters.gen.cs.meta deleted file mode 100644 index 5c5fede24..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/SignTxnsError.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5abb5b74778274a16bfc5a5ed4b54a8d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/SignTxnsOpts.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/SignTxnsOpts.Formatters.gen.cs deleted file mode 100644 index 6afb303af..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/SignTxnsOpts.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect -{ - - - public partial struct SignTxnsOpts - { - - private static bool @__generated__IsValid = SignTxnsOpts.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("message", (Algorand.Unity.WalletConnect.SignTxnsOpts x) => x.Message, (ref Algorand.Unity.WalletConnect.SignTxnsOpts x, System.String value) => x.Message = value, Algorand.Unity.StringComparer.Instance)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/SignTxnsOpts.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/SignTxnsOpts.Formatters.gen.cs.meta deleted file mode 100644 index 845bacf05..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/SignTxnsOpts.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4ca09d18a4f7c4180be5bf371c238dc0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletConnectSessionData.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletConnectSessionData.Formatters.gen.cs deleted file mode 100644 index c1293f3f1..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletConnectSessionData.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect -{ - - - public partial struct WalletConnectSessionData - { - - private static bool @__generated__IsValid = WalletConnectSessionData.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("peerId", (Algorand.Unity.WalletConnect.WalletConnectSessionData x) => x.PeerId, (ref Algorand.Unity.WalletConnect.WalletConnectSessionData x, System.String value) => x.PeerId = value, Algorand.Unity.StringComparer.Instance).Assign("peerMeta", (Algorand.Unity.WalletConnect.WalletConnectSessionData x) => x.PeerMeta, (ref Algorand.Unity.WalletConnect.WalletConnectSessionData x, Algorand.Unity.WalletConnect.ClientMeta value) => x.PeerMeta = value).Assign("approved", (Algorand.Unity.WalletConnect.WalletConnectSessionData x) => x.IsApproved, (ref Algorand.Unity.WalletConnect.WalletConnectSessionData x, System.Boolean value) => x.IsApproved = value).Assign("chainId", (Algorand.Unity.WalletConnect.WalletConnectSessionData x) => x.ChainId, (ref Algorand.Unity.WalletConnect.WalletConnectSessionData x, System.Int32 value) => x.ChainId = value).Assign("accounts", (Algorand.Unity.WalletConnect.WalletConnectSessionData x) => x.Accounts, (ref Algorand.Unity.WalletConnect.WalletConnectSessionData x, Algorand.Unity.Address[] value) => x.Accounts = value, Algorand.Unity.ArrayComparer.Instance)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletConnectSessionData.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletConnectSessionData.Formatters.gen.cs.meta deleted file mode 100644 index cce066ad1..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletConnectSessionData.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5e8deb94d08b441ad8463ae917b290ba -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletConnectSessionRequest.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletConnectSessionRequest.Formatters.gen.cs deleted file mode 100644 index 6200eada3..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletConnectSessionRequest.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect -{ - - - public partial struct WalletConnectSessionRequest - { - - private static bool @__generated__IsValid = WalletConnectSessionRequest.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("peerId", (Algorand.Unity.WalletConnect.WalletConnectSessionRequest x) => x.PeerId, (ref Algorand.Unity.WalletConnect.WalletConnectSessionRequest x, System.String value) => x.PeerId = value, Algorand.Unity.StringComparer.Instance).Assign("peerMeta", (Algorand.Unity.WalletConnect.WalletConnectSessionRequest x) => x.PeerMeta, (ref Algorand.Unity.WalletConnect.WalletConnectSessionRequest x, Algorand.Unity.WalletConnect.ClientMeta value) => x.PeerMeta = value).Assign("chainId", (Algorand.Unity.WalletConnect.WalletConnectSessionRequest x) => x.ChainId, (ref Algorand.Unity.WalletConnect.WalletConnectSessionRequest x, Algorand.Unity.Optional value) => x.ChainId = value)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletConnectSessionRequest.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletConnectSessionRequest.Formatters.gen.cs.meta deleted file mode 100644 index cb9abaeeb..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletConnectSessionRequest.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1e763a709fec6492688bc2bf614d4463 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletTransaction.Formatters.gen.cs b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletTransaction.Formatters.gen.cs deleted file mode 100644 index 58f76a7cb..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletTransaction.Formatters.gen.cs +++ /dev/null @@ -1,29 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -using UnityCollections = Unity.Collections; - - -namespace Algorand.Unity.WalletConnect -{ - - - public partial struct WalletTransaction - { - - private static bool @__generated__IsValid = WalletTransaction.@__generated__InitializeAlgoApiFormatters(); - - private static bool @__generated__InitializeAlgoApiFormatters() - { - Algorand.Unity.AlgoApiFormatterLookup.Add(new Algorand.Unity.AlgoApiObjectFormatter(false).Assign("txn", (Algorand.Unity.WalletConnect.WalletTransaction x) => x.Txn, (ref Algorand.Unity.WalletConnect.WalletTransaction x, System.Byte[] value) => x.Txn = value, Algorand.Unity.ArrayComparer.Instance).Assign("message", (Algorand.Unity.WalletConnect.WalletTransaction x) => x.Message, (ref Algorand.Unity.WalletConnect.WalletTransaction x, System.String value) => x.Message = value, Algorand.Unity.StringComparer.Instance).Assign("authAddr", (Algorand.Unity.WalletConnect.WalletTransaction x) => x.AuthAddr, (ref Algorand.Unity.WalletConnect.WalletTransaction x, Algorand.Unity.Address value) => x.AuthAddr = value).Assign("msig", (Algorand.Unity.WalletConnect.WalletTransaction x) => x.Msig, (ref Algorand.Unity.WalletConnect.WalletTransaction x, Algorand.Unity.WalletConnect.MultisigMetadata value) => x.Msig = value).Assign("signers", (Algorand.Unity.WalletConnect.WalletTransaction x) => x.Signers, (ref Algorand.Unity.WalletConnect.WalletTransaction x, Algorand.Unity.Address[] value) => x.Signers = value, Algorand.Unity.ArrayComparer.Instance)); - return true; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletTransaction.Formatters.gen.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletTransaction.Formatters.gen.cs.meta deleted file mode 100644 index 94a0982e2..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Formatters.gen/WalletTransaction.Formatters.gen.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 851a37202403c4843a914f25ecce17f7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/HandshakeUrl.cs b/Runtime/Algorand.Unity.WalletConnect/HandshakeUrl.cs deleted file mode 100644 index 2eeb2297d..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/HandshakeUrl.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Algorand.Unity.QrCode; -using UnityEngine; -using UnityEngine.Networking; - -namespace Algorand.Unity.WalletConnect -{ - /// - /// An HTTP-escaped Url for initiating the walletconnect connection. - /// - /// - /// Can be converted into a QrCode or used to deeplink on mobile to - /// supported wallets. - /// - public readonly struct HandshakeUrl - { - private readonly string url; - - public string Url => url; - - public HandshakeUrl( - string topic, - string version, - string bridgeUrl, - Hex key - ) - { - var escapedBridgeUrl = UnityWebRequest.EscapeURL(bridgeUrl); - url = $"wc:{topic}@{version}?bridge={escapedBridgeUrl}&key={key}&algorand=true"; - } - - public Texture2D ToQrCodeTexture() - { - return QrCodeUtility.GenerateTexture(url); - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/HandshakeUrl.cs.meta b/Runtime/Algorand.Unity.WalletConnect/HandshakeUrl.cs.meta deleted file mode 100644 index ef7bcd877..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/HandshakeUrl.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 692ee024ae12a4518966c5a9ebbcb5f5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/IWalletConnectAccount.cs b/Runtime/Algorand.Unity.WalletConnect/IWalletConnectAccount.cs deleted file mode 100644 index 31b556ec7..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/IWalletConnectAccount.cs +++ /dev/null @@ -1,62 +0,0 @@ -using Cysharp.Threading.Tasks; - -namespace Algorand.Unity.WalletConnect -{ - public interface IWalletConnectAccount - : IAsyncAccountSigner - { - /// - /// The status of the current wallet connected. - /// - SessionStatus ConnectionStatus { get; } - - /// - /// Stored data regarding the session. - /// - SessionData SessionData { get; } - - /// - /// The WalletConnect bridge url to connect to. - /// - string BridgeUrl { get; set; } - - /// - /// The client information provided in this Dapp. - /// - ClientMeta DappMeta { get; set; } - - /// - /// Start the WalletConnect session. - /// - UniTask BeginSession(); - - /// - /// End the current WalletConnect session, closing the websocket. - /// - /// - /// Does not forget the wallet connection, and it can be resumed using . - /// - void EndSession(); - - /// - /// Re-initializes session data, keeping the BridgeUrl and the DappMeta, but regenerating other fields. - /// - void ResetSessionData(); - - /// - /// Requests a handshake to connect to a new Wallet. - /// - HandshakeUrl RequestWalletConnection(); - - /// - /// Wait for the handshake to be approved. - /// - UniTask WaitForWalletApproval(); - - /// - /// Disconnect and forget the wallet connection. If you want to close the session without - /// forgetting the wallet, use . - /// - void DisconnectWallet(string reason = default); - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/IWalletConnectAccount.cs.meta b/Runtime/Algorand.Unity.WalletConnect/IWalletConnectAccount.cs.meta deleted file mode 100644 index af2e67d6d..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/IWalletConnectAccount.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 50988ee760adb4cf9b3d6b999084294c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/IWalletConnectSession.cs b/Runtime/Algorand.Unity.WalletConnect/IWalletConnectSession.cs deleted file mode 100644 index 0fbc78cc5..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/IWalletConnectSession.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect -{ - public interface IActiveWalletConnectSession : IWalletConnectSessionData, IDisposable - where TSession : IActiveWalletConnectSession - { - /// - /// Occurs when handshake succeeds and wallet is connected. - /// - event Action OnSessionConnect; - - /// - /// Occurs when wallet no longer approves connection. - /// - event Action OnSessionDisconnect; - - /// - /// Occurs when wallet updates addresses or metadata information. - /// - event Action OnSessionUpdate; - } - - public interface IWalletConnectSessionData - { - /// - /// The UUID of this client. - /// - string ClientId { get; } - - /// - /// The bridge used to communicate with the session. - /// - string BridgeUrl { get; } - - /// - /// The key used to encrypt/decrypt the payloads. - /// - Hex Key { get; } - - /// - /// The UUID of the connecting peer. - /// - string PeerId { get; } - - /// - /// - /// - ulong HandshakeId { get; } - - /// - /// The ID of the network connected (test, beta, main, ...) - /// - int NetworkId { get; } - - /// - /// The accounts that the Wallet manages. - /// - Address[] Accounts { get; } - - /// - /// The Identifier of the blockchain connected. - /// - int ChainId { get; } - - /// - /// Meta information about the Dapp connected in this session. - /// - ClientMeta DappMeta { get; } - - /// - /// Meta information about the Wallet connected in this session. - /// - ClientMeta WalletMeta { get; } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/IWalletConnectSession.cs.meta b/Runtime/Algorand.Unity.WalletConnect/IWalletConnectSession.cs.meta deleted file mode 100644 index 3431895e8..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/IWalletConnectSession.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4b6d30c455d014c3d9181f30c3c964a1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/JsonRpc.cs b/Runtime/Algorand.Unity.WalletConnect/JsonRpc.cs deleted file mode 100644 index ba23bdcd6..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/JsonRpc.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Algorand.Unity.Collections; -using Algorand.Unity.WebSocket; -using Unity.Collections; - -namespace Algorand.Unity.WalletConnect -{ - public static class JsonRpc - { - public static NetworkMessage ToNetworkMessage(this T request, Hex encryptionKey, string topic) - where T : IJsonRpcRequest - { - using var requestJson = AlgoApiSerializer.SerializeJson(request, Allocator.Temp); - var payloadData = requestJson.AsArray().ToArray(); - var encryptedPayload = AesCipher.EncryptWithKey(encryptionKey, payloadData); - return NetworkMessage.PublishToTopic(encryptedPayload, topic); - } - - public static Either ReadJsonRpcPayload(this WebSocketEvent response, Hex encryptionKey) - { - var networkMessage = AlgoApiSerializer.DeserializeJson(response.Payload); - var encryptedPayload = AlgoApiSerializer.DeserializeJson(networkMessage.Payload); - var responseData = AesCipher.DecryptWithKey(encryptionKey, encryptedPayload); - return AlgoApiSerializer.DeserializeJson>(responseData); - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/JsonRpc.cs.meta b/Runtime/Algorand.Unity.WalletConnect/JsonRpc.cs.meta deleted file mode 100644 index f21661905..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/JsonRpc.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 41af7c763bc144587999a2f1b2206b14 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/JsonRpcClient.cs b/Runtime/Algorand.Unity.WalletConnect/JsonRpcClient.cs deleted file mode 100644 index a00e62594..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/JsonRpcClient.cs +++ /dev/null @@ -1,209 +0,0 @@ -using System; -using System.Net.WebSockets; -using System.Threading; -using Algorand.Unity.Json; -using Algorand.Unity.WebSocket; -using Cysharp.Threading.Tasks; -using UnityEngine; -using static Algorand.Unity.WebSocket.WebSocketEvent; - -namespace Algorand.Unity.WalletConnect -{ - /// - /// Wrapper class around for making and receiving Json RPC messages. - /// - public class JsonRpcClient - : IDisposable - { - private IWebSocketClient webSocketClient; - - private Hex key; - - private CancellationTokenSource connectionCancellation; - - public event Action OnRequestReceived; - - public event Action OnResponseReceived; - - public event Action OnSocketClosed; - - /// - /// Start a client for handling JsonRpcEvents via websockets - /// - /// url to connect to the websocket server - /// The key to use to encrypt and decrypt payloads - public JsonRpcClient(string url, Hex key) - { - webSocketClient = WebSocketClientFactory.Create(url); - this.key = key; - } - - /// - /// Connect to the Json RPC Server and begin listening for messages. - /// - /// The websocket topic to connect to. - /// An optional timeout to cancel the connection early. - /// An optional cancellation to stop the connection early. - public async UniTask Connect( - string clientId, - CancellationToken cancellationToken = default - ) - { - webSocketClient.Connect(); - await webSocketClient.PollUntilOpen(cancellationToken); - var msg = NetworkMessage.SubscribeToTopic(clientId); - webSocketClient.Send(msg); - connectionCancellation = new CancellationTokenSource(); - PollJsonRpcMessages(connectionCancellation.Token).Forget(); - } - - /// - /// Disconnect from a currently connected Json RPC server. - /// - public void Disconnect(string reason = default) - { - CheckConnected(); - - connectionCancellation?.Cancel(); - connectionCancellation = null; - - webSocketClient.Close(reason: reason); - } - - /// - /// Send a Json RPC Request to the server and listen for a response. - /// - /// The JsonRpcRequest to send. - /// The peer to receive the request. - /// An optional cancellationToken to stop listening for a response. - /// The type of the request. - /// A response from this request. - public async UniTask Send( - TJsonRpcRequest request, - string peerId, - CancellationToken cancellationToken = default - ) - where TJsonRpcRequest : IJsonRpcRequest - { - SendAndForget(request, peerId); - return await ListenForResponse(request.Id, cancellationToken); - } - - /// - /// Send a Json RPC Request to the server without listening for a response. - /// - /// The JsonRpcRequest to send. - /// The peer to receive the request. - /// The type of the request. - public void SendAndForget( - TJsonRpcRequest request, - string peerId - ) - where TJsonRpcRequest : IJsonRpcRequest - { - CheckConnected(); - - var msg = NetworkMessage.PublishToTopicEncrypted(request, key, peerId); - webSocketClient.Send(msg); - } - - /// - /// Listen for a response given an id. - /// - /// The id of the expected response. - /// An optional cancellation token for cancelling early. - /// A Response matching the given is - public async UniTask ListenForResponse( - ulong id, - CancellationToken cancellationToken = default - ) - { - var cancellation = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, connectionCancellation.Token); - Optional matchingResponse = default; - void onResponseReceived(JsonRpcResponse response) - { - if (response.Id != id) - return; - - matchingResponse = response; - OnResponseReceived -= onResponseReceived; - } - OnResponseReceived += onResponseReceived; - while (!matchingResponse.HasValue) - await UniTask.Yield(cancellation.Token); - - return matchingResponse; - } - - public void Dispose() - { - connectionCancellation?.Cancel(); - connectionCancellation = null; - - if (webSocketClient != null && webSocketClient.ReadyState == WebSocketState.Open) - { - webSocketClient.Close(reason: "session being disposed"); - } - - webSocketClient = null; - } - - private void CheckConnected() - { - if (webSocketClient == null) - { - throw new InvalidOperationException($"{nameof(JsonRpcClient)}.{nameof(webSocketClient)} is null. Can't connect."); - } - - var readyState = webSocketClient.ReadyState; - if (readyState != WebSocketState.Open && readyState != WebSocketState.Connecting) - { - throw new InvalidOperationException($"{nameof(JsonRpcClient)} is not open. Current state: {readyState}"); - } - } - - private async UniTaskVoid PollJsonRpcMessages(CancellationToken cancellationToken) - { - try - { - while (true) - { - var evt = await webSocketClient.PollUntilEvent(cancellationToken); - switch (evt.Type) - { - case WebSocketEventType.Payload: - try - { - var responseOrRequest = evt.ReadJsonRpcPayload(key); - if (responseOrRequest.TryGetValue1(out var response) && OnResponseReceived != null) - OnResponseReceived(response); - else if (responseOrRequest.TryGetValue2(out var request) && OnRequestReceived != null) - OnRequestReceived(request); - } - catch (AggregateException ex) - { - foreach (var inner in ex.InnerExceptions) - Debug.LogWarning(inner.ToString()); - throw; - } - catch (JsonReadException ex) - { - Debug.LogWarning($"Response from JsonRpcServer was not Json:\n\"{System.Text.Encoding.UTF8.GetString(evt.Payload)}\"\nError:\n{ex}"); - } - break; - case WebSocketEventType.Error: - Debug.LogWarning(evt.Error); - break; - case WebSocketEventType.Close: - if (OnSocketClosed != null) - OnSocketClosed(evt.Reason); - return; - } - } - } - catch (OperationCanceledException) - { - } - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/JsonRpcClient.cs.meta b/Runtime/Algorand.Unity.WalletConnect/JsonRpcClient.cs.meta deleted file mode 100644 index 72634e5b6..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/JsonRpcClient.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7856e69ad1d3d44869af778f9ae1d0a6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Models.meta b/Runtime/Algorand.Unity.WalletConnect/Models.meta deleted file mode 100644 index ed867c7ba..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a7a9a62eead6941cf9957fd95a0e04df -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/ClientMeta.cs b/Runtime/Algorand.Unity.WalletConnect/Models/ClientMeta.cs deleted file mode 100644 index bf6bb0e4e..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/ClientMeta.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect -{ - [Serializable] - [AlgoApiObject] - public partial struct ClientMeta - : IEquatable - { - [AlgoApiField("description")] - public string Description; - - [AlgoApiField("url")] - public string Url; - - [AlgoApiField("icons")] - public string[] IconUrls; - - [AlgoApiField("name")] - public string Name; - - public bool Equals(ClientMeta other) - { - return StringComparer.Equals(Description, other.Description) - && StringComparer.Equals(Url, other.Url) - && ArrayComparer.Equals(IconUrls, other.IconUrls) - && StringComparer.Equals(Name, other.Name) - ; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/ClientMeta.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Models/ClientMeta.cs.meta deleted file mode 100644 index 527f61feb..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/ClientMeta.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 83514c66658f54f5f92898e514f9918a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/EncryptedPayload.cs b/Runtime/Algorand.Unity.WalletConnect/Models/EncryptedPayload.cs deleted file mode 100644 index 786f3d7fd..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/EncryptedPayload.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using System.IO; -using System.Security.Cryptography; - -namespace Algorand.Unity.WalletConnect -{ - [AlgoApiObject] - public partial struct EncryptedPayload - { - [AlgoApiField("iv")] - public Hex Iv; - - [AlgoApiField("hmac")] - public Hex Signature; - - [AlgoApiField("data")] - public Hex Data; - - public byte[] Sign(byte[] key) - { - if (Iv.Data == null || Data.Data == null || key == null) - return null; - - using var hmac = new HMACSHA256(key); - hmac.Initialize(); - - byte[] toSign = GetSignData(); - - return hmac.ComputeHash(toSign); - } - - public void ValidateHmac(byte[] key) - { - var computedHmac = Sign(key); - if (!Signature.Equals(computedHmac)) - throw new InvalidDataException("HMAC given does not match the HMAC computed with key"); - } - - public static implicit operator EncryptedPayload((byte[] iv, byte[] encryptedData) encryptResult) - { - return new EncryptedPayload - { - Iv = encryptResult.iv, - Data = encryptResult.encryptedData - }; - } - - private byte[] GetSignData() - { - var result = new byte[Iv.Data.Length + Data.Data.Length]; - Buffer.BlockCopy(Data, 0, result, 0, Data.Data.Length); - Buffer.BlockCopy(Iv, 0, result, Data.Data.Length, Iv.Data.Length); - return result; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/EncryptedPayload.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Models/EncryptedPayload.cs.meta deleted file mode 100644 index c89a767fd..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/EncryptedPayload.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b7d38b317383342f8a9828798f1ab65d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcError.cs b/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcError.cs deleted file mode 100644 index 689a8aff2..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcError.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect -{ - public interface IJsonRpcError - { - /// - /// A String providing a short description of the error. - /// - string Message { get; set; } - - /// - /// A Number that indicates the error type that occurred. - /// - int Code { get; set; } - - /// - /// A Primitive or Structured value that contains additional information about the error. - /// - AlgoApiObject Data { get; set; } - } - - [AlgoApiObject] - public partial struct JsonRpcError - : IEquatable - { - [AlgoApiField("code")] - public int Code { get; set; } - - [AlgoApiField("message")] - public string Message { get; set; } - - [AlgoApiField("data")] - public AlgoApiObject Data { get; set; } - - public bool Equals(JsonRpcError other) - { - return Code == other.Code - && StringComparer.Equals(Message, other.Message) - && Data.Equals(other.Data) - ; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcError.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcError.cs.meta deleted file mode 100644 index 741c44b05..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcError.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 83307e186e2d94468befc7089addcf9e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcRequest.cs b/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcRequest.cs deleted file mode 100644 index 7356d87cf..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcRequest.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect -{ - public interface IJsonRpcRequest : IJsonRpcRequest - { - /// - /// Parameters for this request. - /// - T Params { get; set; } - } - - public interface IJsonRpcRequest - { - /// - /// The id of this request. Used to keep track of the correct response. - /// - Optional Id { get; set; } - - /// - /// The JsonRpc version of this request. - /// - string JsonRpc { get; set; } - - /// - /// The method name to call in this request. - /// - string Method { get; set; } - } - - [AlgoApiObject(IsStrict = true)] - public partial struct JsonRpcRequest - : IJsonRpcRequest - , IEquatable - { - /// - [AlgoApiField("id")] - public Optional Id { get; set; } - - /// - [AlgoApiField("jsonrpc")] - public string JsonRpc { get; set; } - - /// - [AlgoApiField("method")] - public string Method { get; set; } - - /// - [AlgoApiField("params")] - public AlgoApiObject[] Params { get; set; } - - public bool Equals(JsonRpcRequest other) - { - return ArrayComparer.Equals(Params, other.Params) - && Id.Equals(other.Id) - && StringComparer.Equals(JsonRpc, other.JsonRpc) - && StringComparer.Equals(Method, other.Method) - ; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcRequest.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcRequest.cs.meta deleted file mode 100644 index d9e440156..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcRequest.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f660ac516351b48e6bd3bec1b050dd51 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcResponse.cs b/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcResponse.cs deleted file mode 100644 index aabd534f4..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcResponse.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect -{ - public interface IJsonRpcResponse : IJsonRpcResponse - { - /// - /// The result of the corresponding . - /// - T Result { get; set; } - } - - public interface IJsonRpcResponse - { - /// - /// The Id of the response. - /// It should be the same as the ID of the corresponding . - /// - Optional Id { get; set; } - - /// - /// The JsonRpc version. - /// - string JsonRpc { get; set; } - - /// - /// An error object if an error occurred. - /// - JsonRpcError Error { get; set; } - - /// - /// Returns true if this is an error response. - /// - bool IsError { get; } - } - - [AlgoApiObject(IsStrict = true)] - public partial struct JsonRpcResponse - : IJsonRpcResponse - , IEquatable - { - /// - [AlgoApiField("id")] - public Optional Id { get; set; } - - /// - [AlgoApiField("jsonrpc")] - public string JsonRpc { get; set; } - - /// - [AlgoApiField("result")] - public AlgoApiObject Result { get; set; } - - /// - [AlgoApiField("error")] - public JsonRpcError Error { get; set; } - - /// - public bool IsError => !Error.Equals(default); - - public bool Equals(JsonRpcResponse other) - { - return Result.Equals(other.Result) - && Id.Equals(other.Id) - && StringComparer.Equals(JsonRpc, other.JsonRpc) - && Error.Equals(other.Error) - ; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcResponse.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcResponse.cs.meta deleted file mode 100644 index fefb48783..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/JsonRpcResponse.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4add35faac77f407e9639e6c9707a7e0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/MultisigMetadata.cs b/Runtime/Algorand.Unity.WalletConnect/Models/MultisigMetadata.cs deleted file mode 100644 index 47be5c48f..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/MultisigMetadata.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect -{ - /// - /// This struct represents metadata required for signing transactions sent by - /// multisig accounts via WalletConnect. See for more information. - /// - [AlgoApiObject] - public partial struct MultisigMetadata - : IEquatable - { - /// - /// Version of the multisig. - /// - [AlgoApiField("version")] - public byte Version; - - /// - /// Number of signatures required for valid transaction. - /// - [AlgoApiField("threshold")] - public byte Threshold; - - /// - /// The signers of this multisig. - /// - [AlgoApiField("addrs")] - public Address[] Addresses; - - public bool Equals(MultisigMetadata other) - { - return Version.Equals(other.Version) - && Threshold.Equals(other.Threshold) - && ArrayComparer.Equals(Addresses, other.Addresses) - ; - } - - public static implicit operator MultisigMetadata(MultisigSig msig) - { - var addresses = new Address[msig.Subsigs.Length]; - for (var i = 0; i < addresses.Length; i++) - addresses[i] = msig.Subsigs[i].PublicKey; - return new MultisigMetadata - { - Version = msig.Version, - Threshold = msig.Threshold, - Addresses = addresses - }; - } - - public static implicit operator MultisigSig(MultisigMetadata msigMeta) - { - var subsigs = new MultisigSig.Subsig[msigMeta.Addresses.Length]; - for (var i = 0; i < subsigs.Length; i++) - subsigs[i] = new MultisigSig.Subsig { PublicKey = msigMeta.Addresses[i] }; - return new MultisigSig - { - Version = msigMeta.Version, - Threshold = msigMeta.Threshold, - Subsigs = subsigs - }; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/MultisigMetadata.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Models/MultisigMetadata.cs.meta deleted file mode 100644 index d0c3109d1..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/MultisigMetadata.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 784cfdd1bca154419b2d1d1cb5c84525 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/NetworkMessage.cs b/Runtime/Algorand.Unity.WalletConnect/Models/NetworkMessage.cs deleted file mode 100644 index cd2edc291..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/NetworkMessage.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using Unity.Collections; -using Algorand.Unity.Collections; - -namespace Algorand.Unity.WalletConnect -{ - [AlgoApiObject] - public partial struct NetworkMessage - : IEquatable - { - [AlgoApiField("topic")] - public string Topic; - - [AlgoApiField("type")] - public string Type; - - [AlgoApiField("payload")] - public string Payload; - - [AlgoApiField("silent")] - public Optional IsSilent; - - public bool Equals(NetworkMessage other) - { - return StringComparer.Equals(Topic, other.Topic) - && StringComparer.Equals(Type, other.Type) - && Payload.Equals(other.Payload) - ; - } - - public static NetworkMessage SubscribeToTopic(string topic) - { - return new NetworkMessage - { - Topic = topic, - Type = "sub", - Payload = "" - }; - } - - public static NetworkMessage PublishToTopic(T payload, string topic) - { - var payloadJson = AlgoApiSerializer.SerializeJson(payload); - return new NetworkMessage - { - Topic = topic, - Type = "pub", - Payload = payloadJson - }; - } - - public static NetworkMessage PublishToTopicEncrypted(T payload, Hex encryptionKey, string topic) - { - using var payloadJson = AlgoApiSerializer.SerializeJson(payload, Allocator.Temp); - var encryptedPayload = AesCipher.EncryptWithKey(encryptionKey, payloadJson.ToByteArray()); - return PublishToTopic(encryptedPayload, topic); - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/NetworkMessage.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Models/NetworkMessage.cs.meta deleted file mode 100644 index d92da1814..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/NetworkMessage.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: de09c443742d54fdab5112817c4c34cd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/SessionData.cs b/Runtime/Algorand.Unity.WalletConnect/Models/SessionData.cs deleted file mode 100644 index a7f2eb4c3..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/SessionData.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using Algorand.Unity.LowLevel; -using Unity.Collections; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect -{ - [Serializable] - public struct SessionData : IWalletConnectSessionData - { - [SerializeField] private string clientId; - - [SerializeField] private string bridgeUrl; - - [SerializeField] private Hex key; - - [SerializeField] private string peerId; - - [SerializeField] private ulong handshakeId; - - [SerializeField] private int networkId; - - [SerializeField] private Address[] accounts; - - [SerializeField] private int chainId; - - [SerializeField] private ClientMeta dappMeta; - - [SerializeField] private ClientMeta walletMeta; - - public string ClientId - { - get => clientId; - set => clientId = value; - } - - public string BridgeUrl - { - get => bridgeUrl; - set => bridgeUrl = value; - } - - public Hex Key - { - get => key; - set => key = value; - } - - public string PeerId - { - get => peerId; - set => peerId = value; - } - - public ulong HandshakeId - { - get => handshakeId; - set => handshakeId = value; - } - - public int NetworkId - { - get => networkId; - set => networkId = value; - } - - public Address[] Accounts - { - get => accounts; - set => accounts = value; - } - - public int ChainId - { - get => chainId; - set => chainId = value; - } - - public ClientMeta DappMeta - { - get => dappMeta; - set => dappMeta = value; - } - - public ClientMeta WalletMeta - { - get => walletMeta; - set => walletMeta = value; - } - - public SessionData Reinitialize() - { - return InitSession(dappMeta, bridgeUrl); - } - - public static SessionData InitSession(ClientMeta dappMeta, string bridgeUrl) - { - return new SessionData - { - ClientId = Guid.NewGuid().ToString(), - BridgeUrl = string.IsNullOrEmpty(bridgeUrl) ? DefaultBridge.GetRandomBridgeUrl() : bridgeUrl, - Key = GenKey(), - DappMeta = dappMeta - }; - } - - public static Hex GenKey() - { - using var secret = new NativeByteArray(32, Allocator.Temp); - Crypto.Random.Randomize(secret); - return secret.ToArray(); - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/SessionData.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Models/SessionData.cs.meta deleted file mode 100644 index 58a50fa71..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/SessionData.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5282837db71c843cb9934f62fd4c8d1e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/SignTxnsError.cs b/Runtime/Algorand.Unity.WalletConnect/Models/SignTxnsError.cs deleted file mode 100644 index 747a15c1b..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/SignTxnsError.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect -{ - /// - /// Error obtained from a - /// - [AlgoApiObject] - public partial struct SignTxnsError - : IJsonRpcError - , IEquatable - { - [AlgoApiField("message")] - public string Message { get; set; } - - /// - /// The integer error code of the error. - /// - [AlgoApiField("code")] - public int Code { get; set; } - - /// - /// Any other useful information about the error. - /// - [AlgoApiField("data")] - public AlgoApiObject Data { get; set; } - - public override string ToString() - { - return $"{Code} {ErrorCode}: {Message}"; - } - - /// - /// The standard error code parsed from . - /// - /// - /// cast to if known, else . - /// - public SignTxnsErrorCode ErrorCode => Enum.IsDefined(typeof(SignTxnsErrorCode), Code) - ? (SignTxnsErrorCode)Code - : SignTxnsErrorCode.Unknown - ; - - public bool Equals(SignTxnsError other) - { - throw new NotImplementedException(); - } - - public static implicit operator bool(SignTxnsError err) - { - return err.Message != null; - } - - public static implicit operator string(SignTxnsError err) - { - return err.ToString(); - } - - public static implicit operator SignTxnsError(JsonRpcError err) - { - return new SignTxnsError - { - Message = err.Message, - Code = err.Code, - Data = err.Data - }; - } - } - - public enum SignTxnsErrorCode - { - /// - /// Represents an unknown error code. - /// - Unknown = 0, - - /// - /// The user rejected the request. - /// - UserRejectedRequest = 4001, - - /// - /// The requested operation and/or account has not been authorized by the user. - /// - Unauthorized = 4000, - - /// - /// The wallet does not support the requested operation. - /// - UnsupportedOperation = 4200, - - /// - /// The wallet does not support signing that many transactions at a time. - /// - TooManyTransactions = 4201, - - /// - /// The wallet was not initialized properly beforehand. - /// - UninitializedWallet = 4202, - - /// - /// The input provided is invalid. - /// - InvalidInput = 4300 - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/SignTxnsError.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Models/SignTxnsError.cs.meta deleted file mode 100644 index 67cfe45bc..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/SignTxnsError.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d768cec965ff548df8f9a5553d02be34 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/SignTxnsOpts.cs b/Runtime/Algorand.Unity.WalletConnect/Models/SignTxnsOpts.cs deleted file mode 100644 index cd8a6c283..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/SignTxnsOpts.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect -{ - /// - /// Options for an . - /// - [AlgoApiObject] - public partial struct SignTxnsOpts - : IEquatable - { - /// - /// An optional message describing the group of transactions - /// in the . - /// - [AlgoApiField("message")] - public string Message; - - public bool Equals(SignTxnsOpts other) - { - return StringComparer.Equals(Message, other.Message); - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/SignTxnsOpts.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Models/SignTxnsOpts.cs.meta deleted file mode 100644 index afa21c793..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/SignTxnsOpts.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fdde3e9902e71405093869e04e1b565d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectRpc.cs b/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectRpc.cs deleted file mode 100644 index 7ac9a5b59..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectRpc.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System; -using Random = Algorand.Unity.Crypto.Random; - -namespace Algorand.Unity.WalletConnect -{ - public static class WalletConnectRpc - { - private const string jsonRpcVersion = "2.0"; - - public const string SessionUpdateMethod = "wc_sessionUpdate"; - - /// - /// Utility function for building a used to start a new WalletConnect session. - /// - /// The UUID of the client. - /// The metadata of the client. - /// The id of the blockchain this request is for. - /// A that can be used to start a new WalletConnect session. - public static JsonRpcRequest SessionRequest(string peerId, ClientMeta peerMeta, Optional chainId = default, - ulong id = default) - { - var sessionRequest = new WalletConnectSessionRequest - { - PeerId = peerId, - PeerMeta = peerMeta, - ChainId = chainId - }; - return SessionRequest(sessionRequest, id); - } - - /// - /// Utility function for building a used to start a new WalletConnect session. - /// - /// Parameters required to create the request. - /// A that can be used to start a new WalletConnect session. - public static JsonRpcRequest SessionRequest(WalletConnectSessionRequest sessionRequest, ulong id = default) - { - const string method = "wc_sessionRequest"; - var requestParams = new AlgoApiObject[] - { - AlgoApiSerializer.SerializeJson(sessionRequest) - }; - return new JsonRpcRequest - { - Id = id > 0 ? id : GetRandomId(), - JsonRpc = jsonRpcVersion, - Method = method, - Params = requestParams - }; - } - - /// - /// Gets a random, valid JsonRpcRequest id. - /// - /// a in the range [1, ] - public static ulong GetRandomId() - { - ulong x = 0; - while (x == 0) - x = Random.Bytes(); - return x; - } - - public static class Algorand - { - public const int ChainId = 4160; - - public const int MainNetChainId = 416001; - - public const int TestNetChainId = 416002; - - public const int BetaNetChainId = 416003; - - public static AlgorandNetwork GetNetworkFromChainId(int chainId) - { - switch (chainId) - { - case MainNetChainId: return AlgorandNetwork.MainNet; - case TestNetChainId: return AlgorandNetwork.TestNet; - case BetaNetChainId: return AlgorandNetwork.BetaNet; - default: return AlgorandNetwork.None; - } - } - - /// - /// Builds a used for signing transactions. - /// - /// - /// The atomic transaction group of [1,16] transactions. Contains information about how to sign - /// each transaction, and which ones to sign. - /// - /// - /// Optional options for signing the transactions, e.g. adding a message to the transaction group. - /// - /// A used for signing Algorand transactions. - public static JsonRpcRequest SignTransactions(WalletTransaction[] transactions, - SignTxnsOpts options = default) - { - if (transactions == null) - throw new ArgumentNullException(nameof(transactions)); - if (transactions.Length < 1 || transactions.Length > 16) - throw new ArgumentException($"must have [1,16] transactions, instead it was {transactions.Length}", - nameof(transactions)); - - const string method = "algo_signTxn"; - var requestParams = options.Equals(default) - ? new AlgoApiObject[] { AlgoApiSerializer.SerializeJson(transactions) } - : new AlgoApiObject[] - { AlgoApiSerializer.SerializeJson(transactions), AlgoApiSerializer.SerializeJson(options) } - ; - - return new JsonRpcRequest - { - Id = GetRandomId(), - JsonRpc = jsonRpcVersion, - Method = method, - Params = requestParams - }; - } - } - } -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectRpc.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectRpc.cs.meta deleted file mode 100644 index 1acc3f5ed..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectRpc.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 64b9c2ec32f9348ee9c214ae85413e63 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectSessionData.cs b/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectSessionData.cs deleted file mode 100644 index 3366fe09c..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectSessionData.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect -{ - [AlgoApiObject] - public partial struct WalletConnectSessionData - : IEquatable - { - [AlgoApiField("peerId")] - public string PeerId; - - [AlgoApiField("peerMeta")] - public ClientMeta PeerMeta; - - [AlgoApiField("approved")] - public bool IsApproved; - - [AlgoApiField("chainId")] - public int ChainId; - - [AlgoApiField("accounts")] - public Address[] Accounts; - - public bool Equals(WalletConnectSessionData other) - { - return StringComparer.Equals(PeerId, other.PeerId) - && PeerMeta.Equals(other.PeerMeta) - && IsApproved.Equals(other.IsApproved) - && ChainId.Equals(other.ChainId) - && ArrayComparer.Equals(Accounts, other.Accounts) - ; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectSessionData.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectSessionData.cs.meta deleted file mode 100644 index f845f9b26..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectSessionData.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 83f6bc948b890436389df3ece4990fef -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectSessionRequest.cs b/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectSessionRequest.cs deleted file mode 100644 index 1a80be355..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectSessionRequest.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect -{ - [AlgoApiObject] - public partial struct WalletConnectSessionRequest - : IEquatable - { - [AlgoApiField("peerId")] - public string PeerId; - - [AlgoApiField("peerMeta")] - public ClientMeta PeerMeta; - - [AlgoApiField("chainId")] - public Optional ChainId; - - public bool Equals(WalletConnectSessionRequest other) - { - return StringComparer.Equals(PeerId, other.PeerId) - && PeerMeta.Equals(other.PeerMeta) - && ChainId.Equals(other.ChainId) - ; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectSessionRequest.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectSessionRequest.cs.meta deleted file mode 100644 index 2b6617f49..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/WalletConnectSessionRequest.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 84270edb103dd48a68bbf6109fe64bae -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/WalletTransaction.cs b/Runtime/Algorand.Unity.WalletConnect/Models/WalletTransaction.cs deleted file mode 100644 index db7c2af6e..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/WalletTransaction.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect -{ - /// - /// A struct representing the serialized data for a WalletConnect Transaction - /// - /// see https://developer.algorand.org/docs/get-details/walletconnect/walletconnect-schema/ - /// - [AlgoApiObject] - public partial struct WalletTransaction - : IEquatable - { - /// - /// A transaction in canonical messagepack format. - /// - /// - /// Does not contain the txn prefix that is used when signing a transaction. - /// See for serializing the transaction. - /// - [AlgoApiField("txn")] - public byte[] Txn; - - /// - /// Optional message explaining the reason of the transaction. - /// - [AlgoApiField("message")] - public string Message; - - /// - /// Optional used to sign the transaction when - /// the account is rekeyed. Also called the signor/sgnr. - /// - [AlgoApiField("authAddr")] - public Address AuthAddr; - - /// - /// Optional multisig metadata used to sign the transaction. - /// - [AlgoApiField("msig")] - public MultisigMetadata Msig; - - /// - /// Optional list of addresses that must sign the transactions. - /// - [AlgoApiField("signers")] - public Address[] Signers; - - /// - /// Serialize a transaction and prepare it for WalletConnect. - /// - /// The transaction to prepare. - /// Optional message explaining the reason of the transaction. - /// Optional used to sign the transaction when the account is rekeyed. Also called the signor/sgnr. - /// Optional multisig metadata used to sign the transaction. - /// Optional list of addresses that must sign the transactions. - /// The transaction type. - /// A transaction struct usable with WalletConnect. See - public static WalletTransaction New( - T txn, - string message = default, - Address authAddr = default, - MultisigMetadata msig = default, - Address[] signers = default - ) - where T : ITransaction - { - return new WalletTransaction - { - Txn = AlgoApiSerializer.SerializeMessagePack(txn), - Message = message, - AuthAddr = authAddr, - Msig = msig, - Signers = signers - }; - } - - public bool Equals(WalletTransaction other) - { - return ArrayComparer.Equals(Txn, other.Txn) - && AuthAddr.Equals(other.AuthAddr) - && Msig.Equals(other.Msig) - && ArrayComparer.Equals(Signers, other.Signers) - && StringComparer.Equals(Message, other.Message) - ; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Models/WalletTransaction.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Models/WalletTransaction.cs.meta deleted file mode 100644 index a5a418d92..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Models/WalletTransaction.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bdfaf06f8d45d443086affff3d5ae222 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/SessionStatus.cs b/Runtime/Algorand.Unity.WalletConnect/SessionStatus.cs deleted file mode 100644 index 843978896..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/SessionStatus.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Algorand.Unity.WalletConnect -{ - public enum SessionStatus - { - None, - NoWalletConnected, - RequestingWalletConnection, - WalletConnected - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/SessionStatus.cs.meta b/Runtime/Algorand.Unity.WalletConnect/SessionStatus.cs.meta deleted file mode 100644 index 2063c0355..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/SessionStatus.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 52a9fb8bdc44045d48863cffe5340940 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Utils.meta b/Runtime/Algorand.Unity.WalletConnect/Utils.meta deleted file mode 100644 index 63f79192c..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Utils.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9d323cbfc1ba94111a99cd68369b3401 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Utils/DefaultBridge.cs b/Runtime/Algorand.Unity.WalletConnect/Utils/DefaultBridge.cs deleted file mode 100644 index c13b47dfc..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Utils/DefaultBridge.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Linq; - -namespace Algorand.Unity.WalletConnect -{ - public static class DefaultBridge - { - public const string Domain = "walletconnect.org"; - - public static readonly string[] BridgeUrls = Enumerable.Empty() - .Append("bridge") - .Concat("abcdefghijklmnopqrstuvwxyz0123456789".Select(c => $"{c}.bridge")) - .Select(x => $"https://{x}.{Domain}") - .ToArray() - ; - - public static string MainBridge = BridgeUrls[0]; - - public static string GetRandomBridgeUrl() - { - var randomIndex = UnityEngine.Random.Range(0, BridgeUrls.Length); - return BridgeUrls[randomIndex]; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Utils/DefaultBridge.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Utils/DefaultBridge.cs.meta deleted file mode 100644 index 22fe2c2c6..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Utils/DefaultBridge.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: aa9df67f82d3946928b1a37207da8290 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/Utils/RpcPayload.cs b/Runtime/Algorand.Unity.WalletConnect/Utils/RpcPayload.cs deleted file mode 100644 index 57009cfd0..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Utils/RpcPayload.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace Algorand.Unity.WalletConnect -{ - public static class RpcPayload - { - public const int IdRandomPartSize = 1000; - - public static long GenerateId() - { - var datePart = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() * IdRandomPartSize; - var randomPart = UnityEngine.Random.Range(0, IdRandomPartSize); - return datePart + randomPart; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/Utils/RpcPayload.cs.meta b/Runtime/Algorand.Unity.WalletConnect/Utils/RpcPayload.cs.meta deleted file mode 100644 index 3d071fae4..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/Utils/RpcPayload.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bca105f83c0a644858f6fceb429a8f92 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/WalletConnectAccount.cs b/Runtime/Algorand.Unity.WalletConnect/WalletConnectAccount.cs deleted file mode 100644 index 57545ea53..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/WalletConnectAccount.cs +++ /dev/null @@ -1,180 +0,0 @@ -using System; -using System.Threading; -using Cysharp.Threading.Tasks; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect -{ - [Serializable] - public class WalletConnectAccount - : IWalletConnectAccount - { - [SerializeField] private SessionData sessionData; - - private AlgorandWalletConnectSession session; - - private CancellationTokenSource sessionCancellation; - - private bool beginningSession; - - /// - public Address Address => sessionData.Accounts?[0] ?? Address.Empty; - - /// - public SessionStatus ConnectionStatus => session?.ConnectionStatus ?? default; - - /// - public SessionData SessionData - { - get => sessionData; - set => sessionData = value; - } - - /// - public string BridgeUrl - { - get => sessionData.BridgeUrl; - set => sessionData.BridgeUrl = value; - } - - /// - public ClientMeta DappMeta - { - get => sessionData.DappMeta; - set => sessionData.DappMeta = value; - } - - ~WalletConnectAccount() - { - EndSession(); - } - - /// - public async UniTask BeginSession() - { - if (beginningSession) - { - while (beginningSession) - { - await UniTask.Yield(); - await UniTask.NextFrame(); - return; - } - } - beginningSession = true; - try - { - sessionCancellation = new CancellationTokenSource(); - if (SessionData.Key.Data == null) - SessionData = SessionData.InitSession(DappMeta, BridgeUrl); - session = new AlgorandWalletConnectSession(SessionData); - session.OnSessionDisconnect += OnSessionDisconnect; - await session.Connect(sessionCancellation.Token); - sessionData = session.Save(); - } - finally - { - beginningSession = false; - } - } - - /// - public void EndSession() - { - if (sessionCancellation != null) - { - sessionCancellation.Cancel(); - sessionCancellation = null; - } - if (session == null) - { - return; - } - sessionData = session.Save(); - session.Dispose(); - session = null; - } - - /// - public void ResetSessionData() - { - sessionData = SessionData.InitSession(sessionData.DappMeta, sessionData.BridgeUrl); - } - - /// - public HandshakeUrl RequestWalletConnection() - { - CheckSession(); - var handshake = session.RequestWalletConnection(); - sessionData = session.Save(); - return handshake; - } - - /// - public async UniTask WaitForWalletApproval() - { - CheckSession(); - await session.WaitForWalletApproval(sessionCancellation.Token); - sessionData = session.Save(); - } - - /// - public void DisconnectWallet(string reason = default) - { - CheckSession(); - session.DisconnectWallet(reason); - } - - /// - public async UniTask[]> SignTxnsAsync( - T[] txns, - TxnIndices txnsToSign, - CancellationToken cancellationToken = default - ) - where T : ITransaction, IEquatable - { - if (txns == null) - throw new ArgumentNullException(nameof(txns)); - - if (txns.Length == 0 || txns.Length > 16) - throw new ArgumentException("Must have 1-16 transactions", nameof(txns)); - - if (ConnectionStatus == SessionStatus.None) - await BeginSession(); - - var cancellation = CancellationTokenSource.CreateLinkedTokenSource(sessionCancellation.Token, cancellationToken); - var walletTxns = new WalletTransaction[txns.Length]; - var accounts = SessionData.Accounts ?? Array.Empty
(); - for (var i = 0; i < txns.Length; i++) - { - var signers = txnsToSign.ContainsIndex(i) - ? accounts - : Array.Empty
(); - walletTxns[i] = WalletTransaction.New( - txns[i], - signers: signers - ); - } - - var (error, signed) = await session.SignTransactions(walletTxns, cancellationToken: cancellation.Token); - if (error) - throw new Exception(error.ToString()); - - var result = new SignedTxn[signed.Length]; - for (var i = 0; i < signed.Length; i++) - result[i] = AlgoApiSerializer.DeserializeMessagePack>(signed[i]); - return result; - } - - private void CheckSession() - { - if (session == null) - throw new NullReferenceException("Session has not been initialized! Please call " + nameof(BeginSession) + " first."); - } - - private void OnSessionDisconnect(string reason) - { - sessionData = session.Save(); - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/WalletConnectAccount.cs.meta b/Runtime/Algorand.Unity.WalletConnect/WalletConnectAccount.cs.meta deleted file mode 100644 index 4a100c4e7..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/WalletConnectAccount.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0c1426aa02cb1462cb7f3b001c526cd7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/WalletConnectSessionEvents.cs b/Runtime/Algorand.Unity.WalletConnect/WalletConnectSessionEvents.cs deleted file mode 100644 index cf8a6382d..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/WalletConnectSessionEvents.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using UnityEngine.Events; - -namespace Algorand.Unity.WalletConnect -{ - [Serializable] - public class WalletConnectSessionEvents - { - public UnityEvent OnSessionConnect = new UnityEvent(); - public UnityEvent OnSessionDisconnect = new UnityEvent(); - public UnityEvent OnSessionUpdate = new UnityEvent(); - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/WalletConnectSessionEvents.cs.meta b/Runtime/Algorand.Unity.WalletConnect/WalletConnectSessionEvents.cs.meta deleted file mode 100644 index 4021cccf0..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/WalletConnectSessionEvents.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e3cb3ff8e023b406faf9987593db7642 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/WalletRegistry.cs b/Runtime/Algorand.Unity.WalletConnect/WalletRegistry.cs deleted file mode 100644 index f1f347863..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/WalletRegistry.cs +++ /dev/null @@ -1,100 +0,0 @@ -using System.Linq; -using UnityEngine; - -namespace Algorand.Unity.WalletConnect -{ - public static class WalletRegistry - { - /// - /// The official wallet from the Algorand Foundation. - /// - public static readonly AppEntry PeraWallet = new AppEntry - { - Id = "23138217b046ae8d9d07e62b3337fb288c4445f92f64be067809cd0a8f9454b9", - Name = "Pera Wallet", - HomePage = "https://perawallet.app", - Chains = new[] - { - "algorand", - }, - ImageId = "1765f9aa-f99e-414e-826b-6b570d480999", - ImageUrl = new AppEntry.ImageUrls - { - Small = "https://algorand-app.s3.amazonaws.com/app-icons/Pera-walletconnect-128.png", - Medium = "https://algorand-app.s3.amazonaws.com/app-icons/Pera-walletconnect-128.png", - Large = "https://algorand-app.s3.amazonaws.com/app-icons/Pera-walletconnect-128.png", - }, - App = new AppEntry.AppUrls - { - Browser = "", - Ios = "https://apps.apple.com/us/app/algorand-wallet/id1459898525", - Android = "https://play.google.com/store/apps/details?id=com.algorand.android", - Mac = "", - Windows = "", - Linux = "", - }, - Mobile = new AppEntry.AppLinkingScheme - { - Native = "algorand-wc:", - Universal = "", - }, - Desktop = new AppEntry.AppLinkingScheme - { - Native = "", - Universal = "", - }, - Metadata = new AppEntry.AppMetadata - { - ShortName = "Pera Wallet", - Colors = new AppEntry.AppMetadata.AppColors - { - Primary = new Color(255, 238, 85), - Secondary = default - } - }, - }; - - /// - /// All supported Algorand Wallet apps. - /// See if you'd like to get apps for current platform only. - /// - /// that can be used to launch apps on native device. - public static readonly AppEntry[] SupportedWallets = new[] - { - PeraWallet, - }; - - /// - /// Supported Algorand Wallet apps for the current unity platform. - /// - /// that can be used to launch apps on native device. - public static readonly AppEntry[] SupportedWalletsForCurrentPlatform = -#if UNITY_ANDROID - WalletRegistry.SupportedWallets - .Where(wallet => !string.IsNullOrEmpty(wallet.App.Android)) - .ToArray(); -#elif UNITY_IPHONE - WalletRegistry.SupportedWallets - .Where(wallet => !string.IsNullOrEmpty(wallet.App.Ios)) - .ToArray(); -#elif UNITY_STANDALONE_OSX - WalletRegistry.SupportedWallets - .Where(wallet => !string.IsNullOrEmpty(wallet.App.Mac)) - .ToArray(); -#elif UNITY_STANDALONE_WIN - WalletRegistry.SupportedWallets - .Where(wallet => !string.IsNullOrEmpty(wallet.App.Windows)) - .ToArray(); -#elif UNITY_STANDALONE_LINUX - WalletRegistry.SupportedWallets - .Where(wallet => !string.IsNullOrEmpty(wallet.App.Linux)) - .ToArray(); -#elif UNITY_WEBGL - WalletRegistry.SupportedWallets - .Where(wallet => !string.IsNullOrEmpty(wallet.App.Browser)) - .ToArray(); -#else - new AppEntry[0]; -#endif - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/WalletRegistry.cs.meta b/Runtime/Algorand.Unity.WalletConnect/WalletRegistry.cs.meta deleted file mode 100644 index 334e89433..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/WalletRegistry.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 51fdd2ee81e0946c988821eeca1cba8a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WalletConnect/WebSocketExtensions.cs b/Runtime/Algorand.Unity.WalletConnect/WebSocketExtensions.cs deleted file mode 100644 index 307a00513..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/WebSocketExtensions.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Threading; -using Algorand.Unity.Collections; -using Algorand.Unity.WebSocket; -using Cysharp.Threading.Tasks; -using Unity.Collections; -using static Algorand.Unity.WebSocket.WebSocketEvent; - -namespace Algorand.Unity.WalletConnect -{ - public static class WebSocketExtensions - { - public static void Send(this IWebSocketClient client, NetworkMessage networkMessage) - { - using var networkMessageData = AlgoApiSerializer.SerializeJson(networkMessage, Allocator.Temp); - var networkMessageArraySegment = new ArraySegment(networkMessageData.AsArray().ToArray()); - client.Send(networkMessageArraySegment); - } - - public static UniTask PollUntilOpen( - this IWebSocketClient client, - CancellationToken cancellationToken = default - ) => client.PollUntilEvent(WebSocketEventType.Open, cancellationToken); - - public static UniTask PollUntilPayload( - this IWebSocketClient client, - CancellationToken cancellationToken = default - ) => client.PollUntilEvent(WebSocketEventType.Payload, cancellationToken); - - public static async UniTask PollUntilEvent( - this IWebSocketClient client, - WebSocketEventType expectedEventType, - CancellationToken cancellationToken = default - ) - { - var evt = await client.PollUntilEvent(cancellationToken); - if (evt.Type == WebSocketEventType.Error) - throw new Exception($"Got error web socket event: {evt.Error}"); - if (evt.Type == WebSocketEventType.Close) - throw new Exception($"Got web socket closed event with reason: {evt.Reason}"); - if (evt.Type != expectedEventType) - throw new InvalidOperationException($"Got unexpected event type {evt.Type}"); - return evt; - } - - public static async UniTask PollUntilEvent( - this IWebSocketClient client, - CancellationToken cancellationToken = default - ) - { - if (cancellationToken.IsCancellationRequested) - throw new OperationCanceledException(); - if (client == null) - throw new ArgumentNullException(nameof(client)); - WebSocketEvent evt = client.Poll(); - while (evt.Type == WebSocketEventType.Nothing) - { - await UniTask.Yield(cancellationToken); - evt = client.Poll(); - } - return evt; - } - } -} diff --git a/Runtime/Algorand.Unity.WalletConnect/WebSocketExtensions.cs.meta b/Runtime/Algorand.Unity.WalletConnect/WebSocketExtensions.cs.meta deleted file mode 100644 index 2d14cbcc0..000000000 --- a/Runtime/Algorand.Unity.WalletConnect/WebSocketExtensions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 821b08d74018d46fab6f3fe870e8d132 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WebSocket.meta b/Runtime/Algorand.Unity.WebSocket.meta deleted file mode 100644 index ad9ca6e10..000000000 --- a/Runtime/Algorand.Unity.WebSocket.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 62cd3cb8d76c44600bbec2b6335c0fec -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WebSocket/Algorand.Unity.WebSocket.asmdef b/Runtime/Algorand.Unity.WebSocket/Algorand.Unity.WebSocket.asmdef deleted file mode 100644 index 4291f4d10..000000000 --- a/Runtime/Algorand.Unity.WebSocket/Algorand.Unity.WebSocket.asmdef +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "Algorand.Unity.WebSocket", - "rootNamespace": "", - "references": [ - "GUID:f51ebe6a0ceec4240a699833d6309b23" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": false, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Runtime/Algorand.Unity.WebSocket/Algorand.Unity.WebSocket.asmdef.meta b/Runtime/Algorand.Unity.WebSocket/Algorand.Unity.WebSocket.asmdef.meta deleted file mode 100644 index 1dfec63f1..000000000 --- a/Runtime/Algorand.Unity.WebSocket/Algorand.Unity.WebSocket.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 8dadf2ce3ffc34301a9f6d2e747938f6 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WebSocket/IWebSocketClient.cs b/Runtime/Algorand.Unity.WebSocket/IWebSocketClient.cs deleted file mode 100644 index d3fd50b6d..000000000 --- a/Runtime/Algorand.Unity.WebSocket/IWebSocketClient.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net.WebSockets; - -namespace Algorand.Unity.WebSocket -{ - public interface IWebSocketClient - { - Queue EventQueue { get; } - - WebSocketState ReadyState { get; } - - void Connect(); - void Close(WebSocketCloseStatus code = WebSocketCloseStatus.NormalClosure, string reason = null); - void Send(ArraySegment data); - WebSocketEvent Poll(); - } - - public static class WebSocketExtensions - { - public static void Send(this IWebSocketClient client, ReadOnlySpan data) - { - client.Send(new ArraySegment(data.ToArray())); - } - } -} diff --git a/Runtime/Algorand.Unity.WebSocket/IWebSocketClient.cs.meta b/Runtime/Algorand.Unity.WebSocket/IWebSocketClient.cs.meta deleted file mode 100644 index 1caa725e7..000000000 --- a/Runtime/Algorand.Unity.WebSocket/IWebSocketClient.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: dd01e3476e1bb4e71a997d61113d0baa -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.cs b/Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.cs deleted file mode 100644 index 9c9e109a7..000000000 --- a/Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.cs +++ /dev/null @@ -1,112 +0,0 @@ -#if UNITY_WEBGL && !UNITY_EDITOR -using System; -using System.Collections.Generic; -using System.Net.WebSockets; -using System.Runtime.InteropServices; - -namespace Algorand.Unity.WebSocket -{ - public class JSWebSocketClient : IWebSocketClient - { - public Queue EventQueue { get; } = new Queue(); - - [DllImport("__Internal")] - internal static extern void _Connect(); - - [DllImport("__Internal")] - internal static extern void _Close(WebSocketCloseStatus code = WebSocketCloseStatus.NormalClosure, string reason = null); - - [DllImport("__Internal")] - internal static extern void _Send(byte[] data, int offset, int count); - - [DllImport("__Internal")] - internal static extern WebSocketState _GetState(); - - public ulong WaitTime => 0; - - public WebSocketState ReadyState => _GetState(); - - public void Connect() - { - _Connect(); - } - - public void Close(WebSocketCloseStatus code = WebSocketCloseStatus.NormalClosure, string reason = null) - { - _Close(code, reason); - } - - public void Send(ArraySegment data) - { - _Send(data.Array, data.Offset, data.Count); - } - - public WebSocketEvent Poll() - { - if (EventQueue.Count > 0) - { - return EventQueue.Dequeue(); - } - else - { - return new WebSocketEvent - { - ClientId = 0, - Payload = null, - Type = WebSocketEvent.WebSocketEventType.Nothing, - Error = null, - Reason = null - }; - } - } - - public void OnOpen() - { - EventQueue.Enqueue(new WebSocketEvent - { - ClientId = 0, - Payload = null, - Type = WebSocketEvent.WebSocketEventType.Open, - Error = null, - Reason = null - }); - } - - public void OnMessage(ArraySegment data) - { - EventQueue.Enqueue(new WebSocketEvent - { - ClientId = 0, - Payload = data.Array, - Type = WebSocketEvent.WebSocketEventType.Payload, - Error = null, - Reason = null - }); - } - - public void OnError(string error) - { - EventQueue.Enqueue(new WebSocketEvent - { - ClientId = 0, - Payload = null, - Type = WebSocketEvent.WebSocketEventType.Error, - Error = error, - Reason = null - }); - } - - public void OnClose(WebSocketCloseStatus code) - { - EventQueue.Enqueue(new WebSocketEvent - { - ClientId = 0, - Payload = null, - Type = WebSocketEvent.WebSocketEventType.Close, - Error = null, - Reason = code.ToString() - }); - } - } -} -#endif diff --git a/Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.cs.meta b/Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.cs.meta deleted file mode 100644 index edbb54d53..000000000 --- a/Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 223a6991681334755a7ea96a12d4a2d6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.jslib b/Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.jslib deleted file mode 100644 index c34407e38..000000000 --- a/Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.jslib +++ /dev/null @@ -1,139 +0,0 @@ -var LibraryWebSocket = { - $state: { - url: null, - ws: null, - debug: true, - onOpen: null, - onMessage: null, - onError: null, - onClose: null, - }, - - _SetUrl: function (urlPointer) { - state.url = UTF8ToString(urlPointer); - }, - - _SetOnOpen: function (callback) { - state.onOpen = callback; - }, - - _SetOnMessage: function (callback) { - state.onMessage = callback; - }, - - _SetOnError: function (callback) { - state.onError = callback; - }, - - _SetOnClose: function (callback) { - state.onClose = callback; - }, - - _Connect: function () { - state.ws = new WebSocket(state.url); - state.ws.binaryType = "arraybuffer"; - - state.ws.onopen = function () { - if (state.debug) { - console.log("[Algorand.Unity.WebSocket] Connected."); - } - - if (state.onOpen) { - Module.dynCall_v(state.onOpen); - } - }; - - state.ws.onmessage = function (ev) { - if (state.debug) { - console.log("[Algorand.Unity.WebSocket] Received message:", ev.data); - } - - if (!state.onMessage) { - return; - } - - if (ev.data instanceof ArrayBuffer) { - var dataBuffer = new Uint8Array(ev.data); - - var buffer = _malloc(dataBuffer.length); - HEAPU8.set(dataBuffer, buffer); - - try { - Module.dynCall_vii(state.onMessage, buffer, dataBuffer.length); - } finally { - _free(buffer); - } - } - - if (typeof ev.data === "string") { - var dataBytes = lengthBytesUTF8(ev.data); - var bufferSize = dataBytes + 1; - var dataBuffer = _malloc(bufferSize); - stringToUTF8(ev.data, dataBuffer, bufferSize); - - try { - Module.dynCall_vii(state.onMessage, dataBuffer, dataBytes); - } finally { - _free(dataBuffer); - } - } - }; - - state.ws.onerror = function (ev) { - if (state.debug) { - console.log("[Algorand.Unity.WebSocket] Error occured."); - } - - if (state.onError) { - var msg = "WebSocket error."; - var msgBytes = lengthBytesUTF8(msg); - var msgBuffer = _malloc(msgBytes + 1); - stringToUTF8(msg, msgBuffer, msgBytes); - - try { - Module.dynCall_vi(state.onError, msgBuffer); - } finally { - _free(msgBuffer); - } - } - }; - - state.ws.onclose = function (ev) { - if (state.debug) { - console.log("[Algorand.Unity.WebSocket] Closed."); - } - - if (state.onClose) { - Module.dynCall_vi(state.onClose, ev.code); - } - }; - }, - - _Close: function (code, reasonPointer) { - if (!state.ws) return -3; - if (state.ws.readyState === 2) return -4; - if (state.ws.readyState === 3) return -5; - - var reason = reasonPointer ? UTF8ToString(reasonPointer) : undefined; - - try { - state.ws.close(code, reason); - } catch (err) { - return -7; - } - }, - - _Send: function (bufferPtr, offset, count) { - if (!state.ws) return -3; - if (state.ws.readyState !== 1) return -6; - - state.ws.send(HEAPU8.buffer.slice(bufferPtr + offset, bufferPtr + count - offset)); - }, - - _GetState: function () { - return state.ws ? state.ws.readyState : 3; - }, -}; - -autoAddDeps(LibraryWebSocket, "$state"); -mergeInto(LibraryManager.library, LibraryWebSocket); diff --git a/Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.jslib.meta b/Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.jslib.meta deleted file mode 100644 index 40edcdf7d..000000000 --- a/Runtime/Algorand.Unity.WebSocket/JSWebSocketClient.jslib.meta +++ /dev/null @@ -1,32 +0,0 @@ -fileFormatVersion: 2 -guid: a60399a913b0546b38ed36f1596899a8 -PluginImporter: - externalObjects: {} - serializedVersion: 2 - iconMap: {} - executionOrder: {} - defineConstraints: [] - isPreloaded: 0 - isOverridable: 1 - isExplicitlyReferenced: 0 - validateReferences: 1 - platformData: - - first: - Any: - second: - enabled: 0 - settings: {} - - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - - first: - WebGL: WebGL - second: - enabled: 1 - settings: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WebSocket/LICENSE.md b/Runtime/Algorand.Unity.WebSocket/LICENSE.md deleted file mode 100644 index a5eb17139..000000000 --- a/Runtime/Algorand.Unity.WebSocket/LICENSE.md +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) 2021 Unity Technologies - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Runtime/Algorand.Unity.WebSocket/LICENSE.md.meta b/Runtime/Algorand.Unity.WebSocket/LICENSE.md.meta deleted file mode 100644 index 93e3fdee8..000000000 --- a/Runtime/Algorand.Unity.WebSocket/LICENSE.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 716c858ca66874beabc5eb693f89d4b1 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WebSocket/NativeWebSocketClient.cs b/Runtime/Algorand.Unity.WebSocket/NativeWebSocketClient.cs deleted file mode 100644 index 9967d4856..000000000 --- a/Runtime/Algorand.Unity.WebSocket/NativeWebSocketClient.cs +++ /dev/null @@ -1,211 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Net.WebSockets; -using System.Threading; -using Cysharp.Threading.Tasks; - -namespace Algorand.Unity.WebSocket -{ - public class NativeWebSocketClient : IWebSocketClient - { - private static readonly object ConnectionLock = new object(); - - private ClientWebSocket Connection; - private readonly Uri uri; - private readonly ArraySegment buffer; - public Queue EventQueue { get; } = new Queue(); - - public WebSocketState ReadyState => Connection?.State ?? WebSocketState.Closed; - - public NativeWebSocketClient(string url) - { - uri = new Uri(url); - Connection = new ClientWebSocket(); - Connection.Options.KeepAliveInterval = TimeSpan.Zero; - buffer = System.Net.WebSockets.WebSocket.CreateClientBuffer(8 * 1024, 8 * 1024); - } - - public void Connect() - { - if (ReadyState == WebSocketState.Open) - { - throw new InvalidOperationException("Socket is already open"); - } - - if (ReadyState == WebSocketState.CloseSent) - { - throw new InvalidOperationException("Socket is closing"); - } - - try - { - ConnectAsync().Forget(); - } - catch (Exception e) - { - throw new WebSocketException("Connection failed", e); - } - } - - private async UniTaskVoid ConnectAsync() - { - await Connection.ConnectAsync(uri, CancellationToken.None); - OnOpen(); - try - { - while (true) - { - using var ms = new MemoryStream(); - WebSocketReceiveResult result; - do - { - result = await Connection.ReceiveAsync(buffer, CancellationToken.None); - ms.Write(buffer.Array, buffer.Offset, result.Count); - } while (!result.EndOfMessage); - - ms.Seek(0, SeekOrigin.Begin); - - if (Connection.CloseStatus.HasValue || result.CloseStatus.HasValue) - { - OnClose(); - break; - } - - var payload = ms.ToArray(); - OnMessage(payload); - } - } - catch (Exception e) - { - OnError(e.Message); - } - } - - public void Close(WebSocketCloseStatus code = WebSocketCloseStatus.NormalClosure, string reason = null) - { - if (ReadyState == WebSocketState.CloseSent) - { - throw new InvalidOperationException("Socket is already closing"); - } - - if (ReadyState == WebSocketState.Closed) - { - throw new InvalidOperationException("Socket is already closed"); - } - - CloseAsync(code, reason).Forget(); - } - - private async UniTaskVoid CloseAsync(WebSocketCloseStatus code, string reason) - { - try - { - await Connection.CloseAsync(code, reason, default); - } - catch (Exception e) - { - OnError(e.Message); - } - } - - public void Send(ArraySegment data) - { - if (ReadyState != WebSocketState.Open) - { - throw new WebSocketException("Socket is not open"); - } - - SendAsync(data).Forget(); - } - - private async UniTaskVoid SendAsync(ArraySegment data) - { - try - { - await Connection.SendAsync(data, WebSocketMessageType.Binary, true, CancellationToken.None); - } - catch (Exception e) - { - OnError(e.Message); - } - } - - public WebSocketEvent Poll() - { - lock (ConnectionLock) - { - return EventQueue.Count > 0 - ? EventQueue.Dequeue() - : new WebSocketEvent - { - ClientId = 0, - Payload = null, - Type = WebSocketEvent.WebSocketEventType.Nothing, - Error = null, - Reason = null - }; - } - } - - private void OnOpen() - { - lock (ConnectionLock) - { - EventQueue.Enqueue(new WebSocketEvent - { - ClientId = 0, - Payload = null, - Type = WebSocketEvent.WebSocketEventType.Open, - Error = null, - Reason = null - }); - } - } - - private void OnClose() - { - lock (ConnectionLock) - { - EventQueue.Enqueue(new WebSocketEvent - { - ClientId = 0, - Payload = null, - Type = WebSocketEvent.WebSocketEventType.Close, - Error = null, - Reason = Connection.CloseStatusDescription - }); - } - } - - private void OnError(string message) - { - lock (ConnectionLock) - { - EventQueue.Enqueue(new WebSocketEvent - { - ClientId = 0, - Payload = null, - Type = WebSocketEvent.WebSocketEventType.Error, - Error = message, - Reason = null, - }); - } - } - - private void OnMessage(byte[] payload) - { - lock (ConnectionLock) - { - EventQueue.Enqueue(new WebSocketEvent - { - ClientId = 0, - Payload = payload, - Type = WebSocketEvent.WebSocketEventType.Payload, - Error = null, - Reason = null, - }); - } - } - } -} diff --git a/Runtime/Algorand.Unity.WebSocket/NativeWebSocketClient.cs.meta b/Runtime/Algorand.Unity.WebSocket/NativeWebSocketClient.cs.meta deleted file mode 100644 index c5b192dad..000000000 --- a/Runtime/Algorand.Unity.WebSocket/NativeWebSocketClient.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 13f45e1a0557745f7ade82de7a38b53d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WebSocket/README.md b/Runtime/Algorand.Unity.WebSocket/README.md deleted file mode 100644 index 3c6d65bd9..000000000 --- a/Runtime/Algorand.Unity.WebSocket/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Algorand.Unity.WebSocket - -Cloned and modified from [Unity's multiplayer-community-contributions repository](https://github.com/Unity-Technologies/multiplayer-community-contributions). - -## Modifications: - -- Removed the files that rely on the Netcode for GameObjects package. -- Generated new .meta files to prevent errors on .unitypackage import. -- Changed the namespace to `Algorand.Unity.WebSocket` to avoid confusion when used in conjunction with Netcode transports. diff --git a/Runtime/Algorand.Unity.WebSocket/README.md.meta b/Runtime/Algorand.Unity.WebSocket/README.md.meta deleted file mode 100644 index 861f293e9..000000000 --- a/Runtime/Algorand.Unity.WebSocket/README.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 1714abd84eb5d4220922126e51315b4c -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WebSocket/WebSocketClientFactory.cs b/Runtime/Algorand.Unity.WebSocket/WebSocketClientFactory.cs deleted file mode 100644 index 935b6a70e..000000000 --- a/Runtime/Algorand.Unity.WebSocket/WebSocketClientFactory.cs +++ /dev/null @@ -1,78 +0,0 @@ -#if UNITY_WEBGL && !UNITY_EDITOR -using System; -using System.Runtime.InteropServices; -using System.Net.WebSockets; -using AOT; -using UnityEngine; -#endif - -namespace Algorand.Unity.WebSocket -{ - public class WebSocketClientFactory - { -#if UNITY_WEBGL && !UNITY_EDITOR - public static JSWebSocketClient Client = new JSWebSocketClient(); - - internal delegate void OnOpenCallback(); - internal delegate void OnMessageCallback(IntPtr messagePointer, int messageSize); - internal delegate void OnErrorCallback(IntPtr errorPointer); - internal delegate void OnCloseCallback(int closeCode); - - [DllImport("__Internal")] - internal static extern void _SetUrl(string url); - [DllImport("__Internal")] - internal static extern void _SetOnOpen(OnOpenCallback callback); - [DllImport("__Internal")] - internal static extern void _SetOnMessage(OnMessageCallback callback); - [DllImport("__Internal")] - internal static extern void _SetOnError(OnErrorCallback callback); - [DllImport("__Internal")] - internal static extern void _SetOnClose(OnCloseCallback callback); - - [MonoPInvokeCallback(typeof(OnOpenCallback))] - internal static void OnOpenEvent() - { - Client.OnOpen(); - } - - [MonoPInvokeCallback(typeof(OnMessageCallback))] - internal static void OnMessageEvent(IntPtr payloadPointer, int length) - { - var buffer = new byte[length]; - - Marshal.Copy(payloadPointer, buffer, 0, length); - Client.OnMessage(new ArraySegment(buffer, 0, length)); - } - - [MonoPInvokeCallback(typeof(OnErrorCallback))] - internal static void OnErrorEvent(IntPtr errorPointer) - { - string errorMessage = Marshal.PtrToStringAuto(errorPointer); - Client.OnError(errorMessage); - } - - [MonoPInvokeCallback(typeof(OnCloseCallback))] - internal static void OnCloseEvent(int disconnectCode) - { - WebSocketCloseStatus code = (WebSocketCloseStatus)disconnectCode; - - Client.OnClose(code); - } -#endif - - public static IWebSocketClient Create(string url) - { -#if UNITY_WEBGL && !UNITY_EDITOR - _SetUrl(url); - _SetOnOpen(OnOpenEvent); - _SetOnMessage(OnMessageEvent); - _SetOnError(OnErrorEvent); - _SetOnClose(OnCloseEvent); - - return Client; -#else - return new NativeWebSocketClient(url); -#endif - } - } -} diff --git a/Runtime/Algorand.Unity.WebSocket/WebSocketClientFactory.cs.meta b/Runtime/Algorand.Unity.WebSocket/WebSocketClientFactory.cs.meta deleted file mode 100644 index 92d6d17d2..000000000 --- a/Runtime/Algorand.Unity.WebSocket/WebSocketClientFactory.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8312fb35aa62b48ffbacd385ff5f25ef -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Algorand.Unity.WebSocket/WebSocketEvent.cs b/Runtime/Algorand.Unity.WebSocket/WebSocketEvent.cs deleted file mode 100644 index 244a7818f..000000000 --- a/Runtime/Algorand.Unity.WebSocket/WebSocketEvent.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Algorand.Unity.WebSocket -{ - public struct WebSocketEvent - { - public enum WebSocketEventType - { - Nothing, - Open, - Close, - Payload, - Error, - } - - public WebSocketEventType Type; - public ulong ClientId; - public byte[] Payload; - public string Error; - public string Reason; - } -} diff --git a/Runtime/Algorand.Unity.WebSocket/WebSocketEvent.cs.meta b/Runtime/Algorand.Unity.WebSocket/WebSocketEvent.cs.meta deleted file mode 100644 index 3be3494ce..000000000 --- a/Runtime/Algorand.Unity.WebSocket/WebSocketEvent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4359e5f45dd9746b081e6c501b4f5e2c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity.meta b/Runtime/zxing.unity.meta deleted file mode 100644 index 66f810931..000000000 --- a/Runtime/zxing.unity.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 28eca8175204c4207b47e4fbd0c2abcf -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/LICENSE.md b/Runtime/zxing.unity/LICENSE.md deleted file mode 100644 index 77b0952ed..000000000 --- a/Runtime/zxing.unity/LICENSE.md +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2013-2022 micjahn - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. diff --git a/Runtime/zxing.unity/LICENSE.md.meta b/Runtime/zxing.unity/LICENSE.md.meta deleted file mode 100644 index 380e8370e..000000000 --- a/Runtime/zxing.unity/LICENSE.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: eebb6d2212e0e462aaad23b9c77d5bf8 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/README.md b/Runtime/zxing.unity/README.md deleted file mode 100644 index b1550ed51..000000000 --- a/Runtime/zxing.unity/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# ZXing.NET - -This is source code cloned from the [ZXing.NET repository](https://github.com/micjahn/ZXing.Net). -The source code has been trimmed to include only the files that pertain to the Unity build. diff --git a/Runtime/zxing.unity/README.md.meta b/Runtime/zxing.unity/README.md.meta deleted file mode 100644 index 86232cba9..000000000 --- a/Runtime/zxing.unity/README.md.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 906b861f7db994c55ad50a1c169c5881 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source.meta b/Runtime/zxing.unity/Source.meta deleted file mode 100644 index ae4ff32cb..000000000 --- a/Runtime/zxing.unity/Source.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4e288357d441d4130ae5365e0e12ff66 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib.meta b/Runtime/zxing.unity/Source/lib.meta deleted file mode 100644 index c1ca3378c..000000000 --- a/Runtime/zxing.unity/Source/lib.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 26e76b296e6924183bfdd32513c9b6d7 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/BarcodeFormat.cs b/Runtime/zxing.unity/Source/lib/BarcodeFormat.cs deleted file mode 100644 index 59f31954a..000000000 --- a/Runtime/zxing.unity/Source/lib/BarcodeFormat.cs +++ /dev/null @@ -1,95 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -namespace ZXing -{ - /// - /// Enumerates barcode formats known to this package. - /// - /// Sean Owen - [System.Flags] - public enum BarcodeFormat - { - /// Aztec 2D barcode format. - AZTEC = 1, - - /// CODABAR 1D format. - CODABAR = 2, - - /// Code 39 1D format. - CODE_39 = 4, - - /// Code 93 1D format. - CODE_93 = 8, - - /// Code 128 1D format. - CODE_128 = 16, - - /// Data Matrix 2D barcode format. - DATA_MATRIX = 32, - - /// EAN-8 1D format. - EAN_8 = 64, - - /// EAN-13 1D format. - EAN_13 = 128, - - /// ITF (Interleaved Two of Five) 1D format. - ITF = 256, - - /// MaxiCode 2D barcode format. - MAXICODE = 512, - - /// PDF417 format. - PDF_417 = 1024, - - /// QR Code 2D barcode format. - QR_CODE = 2048, - - /// RSS 14 - RSS_14 = 4096, - - /// RSS EXPANDED - RSS_EXPANDED = 8192, - - /// UPC-A 1D format. - UPC_A = 16384, - - /// UPC-E 1D format. - UPC_E = 32768, - - /// UPC/EAN extension format. Not a stand-alone format. - UPC_EAN_EXTENSION = 65536, - - /// MSI - MSI = 131072, - - /// Plessey - PLESSEY = 262144, - - /// Intelligent Mail barcode - IMB = 524288, - - /// Pharmacode format. - PHARMA_CODE = 1048576, - - /// - /// UPC_A | UPC_E | EAN_13 | EAN_8 | CODABAR | CODE_39 | CODE_93 | CODE_128 | ITF | RSS_14 | RSS_EXPANDED - /// without MSI (to many false-positives) and IMB (not enough tested, and it looks more like a 2D) - /// - All_1D = UPC_A | UPC_E | EAN_13 | EAN_8 | CODABAR | CODE_39 | CODE_93 | CODE_128 | ITF | RSS_14 | RSS_EXPANDED - } -} diff --git a/Runtime/zxing.unity/Source/lib/BarcodeFormat.cs.meta b/Runtime/zxing.unity/Source/lib/BarcodeFormat.cs.meta deleted file mode 100644 index 0e7467d3a..000000000 --- a/Runtime/zxing.unity/Source/lib/BarcodeFormat.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: deba27f26d6ba4967aa38665cf4b66ff -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/BarcodeWriter.Color32.cs b/Runtime/zxing.unity/Source/lib/BarcodeWriter.Color32.cs deleted file mode 100644 index 529275a7f..000000000 --- a/Runtime/zxing.unity/Source/lib/BarcodeWriter.Color32.cs +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace ZXing -{ - /// - /// A smart class to encode some content to a barcode image - /// - public class BarcodeWriter : BarcodeWriter, IBarcodeWriter - { - /// - /// Initializes a new instance of the class. - /// - public BarcodeWriter() - { - Renderer = new Color32Renderer(); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/BarcodeWriter.Color32.cs.meta b/Runtime/zxing.unity/Source/lib/BarcodeWriter.Color32.cs.meta deleted file mode 100644 index d2012342b..000000000 --- a/Runtime/zxing.unity/Source/lib/BarcodeWriter.Color32.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5b816ba7abb30469ba05cdbb3be91710 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/BarcodeWriter.PixelData.cs b/Runtime/zxing.unity/Source/lib/BarcodeWriter.PixelData.cs deleted file mode 100644 index 28efd1321..000000000 --- a/Runtime/zxing.unity/Source/lib/BarcodeWriter.PixelData.cs +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using ZXing.Rendering; - -namespace ZXing -{ - /// - /// A smart class to encode some content to raw pixel data - /// - public class BarcodeWriterPixelData : BarcodeWriter, IBarcodeWriterPixelData - { - /// - /// Initializes a new instance of the class. - /// - public BarcodeWriterPixelData() - { - Renderer = new PixelDataRenderer(); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/BarcodeWriter.PixelData.cs.meta b/Runtime/zxing.unity/Source/lib/BarcodeWriter.PixelData.cs.meta deleted file mode 100644 index 3f9257b13..000000000 --- a/Runtime/zxing.unity/Source/lib/BarcodeWriter.PixelData.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a5dc21d8d13194f5a9a70cce5f040573 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/BarcodeWriter.SvgImage.cs b/Runtime/zxing.unity/Source/lib/BarcodeWriter.SvgImage.cs deleted file mode 100644 index 6fa6e6fb9..000000000 --- a/Runtime/zxing.unity/Source/lib/BarcodeWriter.SvgImage.cs +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using ZXing.Rendering; - -namespace ZXing -{ - /// - /// A smart class to encode some content to a svg barcode image - /// - public class BarcodeWriterSvg : BarcodeWriter, IBarcodeWriterSvg - { - /// - /// Initializes a new instance of the class. - /// - public BarcodeWriterSvg() - { - Renderer = new SvgRenderer(); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/BarcodeWriter.SvgImage.cs.meta b/Runtime/zxing.unity/Source/lib/BarcodeWriter.SvgImage.cs.meta deleted file mode 100644 index 0902f7837..000000000 --- a/Runtime/zxing.unity/Source/lib/BarcodeWriter.SvgImage.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6918086f2c4134c6f9483147c65831b0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/BarcodeWriterCustom.cs b/Runtime/zxing.unity/Source/lib/BarcodeWriterCustom.cs deleted file mode 100644 index b225c02cc..000000000 --- a/Runtime/zxing.unity/Source/lib/BarcodeWriterCustom.cs +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; - -using ZXing.Common; -using ZXing.Rendering; - -namespace ZXing -{ - /// - /// A base class for specific barcode writers with specific formats of barcode images. - /// - /// The type of the output. - public class BarcodeWriter : BarcodeWriterGeneric, IBarcodeWriter - { - /// - /// Gets or sets the renderer which should be used to render the encoded BitMatrix. - /// - public IBarcodeRenderer Renderer { get; set; } - - /// - /// Encodes the specified contents and returns a rendered instance of the barcode. - /// For rendering the instance of the property Renderer is used and has to be set before - /// calling that method. - /// - /// The contents. - /// - public TOutput Write(string contents) - { - if (Renderer == null) - { - throw new InvalidOperationException("You have to set a renderer instance."); - } - - var matrix = Encode(contents); - - return Renderer.Render(matrix, Format, contents, Options); - } - - /// - /// Returns a rendered instance of the barcode which is given by a BitMatrix. - /// For rendering the instance of the property Renderer is used and has to be set before - /// calling that method. - /// - /// The matrix. - /// - public TOutput Write(BitMatrix matrix) - { - if (Renderer == null) - { - throw new InvalidOperationException("You have to set a renderer instance."); - } - - return Renderer.Render(matrix, Format, null, Options); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/BarcodeWriterCustom.cs.meta b/Runtime/zxing.unity/Source/lib/BarcodeWriterCustom.cs.meta deleted file mode 100644 index 2ec9e3661..000000000 --- a/Runtime/zxing.unity/Source/lib/BarcodeWriterCustom.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: dbf54dc578ad04740b9f7d434a707517 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/BarcodeWriterGeneric.cs b/Runtime/zxing.unity/Source/lib/BarcodeWriterGeneric.cs deleted file mode 100644 index 774ddc4ab..000000000 --- a/Runtime/zxing.unity/Source/lib/BarcodeWriterGeneric.cs +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using ZXing.Common; -using ZXing.QrCode; - -namespace ZXing -{ - /// - /// A base class for specific barcode writers with specific formats of barcode images. - /// - public class BarcodeWriterGeneric : IBarcodeWriterGeneric - { - private EncodingOptions options; - - /// - /// Gets or sets the barcode format. - /// The value is only suitable if the MultiFormatWriter is used. - /// - public BarcodeFormat Format { get; set; } - - /// - /// Gets or sets the options container for the encoding and renderer process. - /// - public EncodingOptions Options - { - get - { - return (options ?? (options = new EncodingOptions { Height = 100, Width = 100 })); - } - set - { - options = value; - } - } - - /// - /// Gets or sets the writer which encodes the content to a BitMatrix. - /// If no value is set the MultiFormatWriter is used. - /// - public Writer Encoder { get; set; } - - /// - /// - /// - public BarcodeWriterGeneric() - { - } - - /// - /// - /// - /// - public BarcodeWriterGeneric(Writer encoder) - { - Encoder = encoder; - } - - /// - /// Encodes the specified contents and returns a BitMatrix array. - /// That array has to be rendered manually or with a IBarcodeRenderer. - /// - /// The contents. - /// - public BitMatrix Encode(string contents) - { - var encoder = Encoder ?? new QRCodeWriter(); - var currentOptions = Options; - return encoder.encode(contents, Format, currentOptions.Width, currentOptions.Height, currentOptions.Hints); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/BarcodeWriterGeneric.cs.meta b/Runtime/zxing.unity/Source/lib/BarcodeWriterGeneric.cs.meta deleted file mode 100644 index 2c2ff8d65..000000000 --- a/Runtime/zxing.unity/Source/lib/BarcodeWriterGeneric.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: dfd6119794a68434194704d5147df69a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/BaseLuminanceSource.cs b/Runtime/zxing.unity/Source/lib/BaseLuminanceSource.cs deleted file mode 100644 index 02df21e1e..000000000 --- a/Runtime/zxing.unity/Source/lib/BaseLuminanceSource.cs +++ /dev/null @@ -1,228 +0,0 @@ -/* -* Copyright 2012 ZXing.Net authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; - -namespace ZXing -{ - /// - /// The base class for luminance sources which supports - /// cropping and rotating based upon the luminance values. - /// - public abstract class BaseLuminanceSource : LuminanceSource - { - // the following channel weights give nearly the same - // gray scale picture as the java version with BufferedImage.TYPE_BYTE_GRAY - // they are used in sub classes for luminance / gray scale calculation - /// - /// weight of the red channel for calculating a gray scale image - /// - protected const int RChannelWeight = 19562; - /// - /// weight of the green channel for calculating a gray scale image - /// - protected const int GChannelWeight = 38550; - /// - /// weight of the blue channel for calculating a gray scale image - /// - protected const int BChannelWeight = 7424; - /// - /// numbers of bits which for right shifting - /// - protected const int ChannelWeight = 16; - - /// - /// - /// - protected byte[] luminances; - - /// - /// Initializes a new instance of the class. - /// - /// The width. - /// The height. - protected BaseLuminanceSource(int width, int height) - : base(width, height) - { - luminances = new byte[width * height]; - } - - /// - /// Initializes a new instance of the class. - /// - /// The luminance array. - /// The width. - /// The height. - protected BaseLuminanceSource(byte[] luminanceArray, int width, int height) - : base(width, height) - { - luminances = new byte[width * height]; - Buffer.BlockCopy(luminanceArray, 0, luminances, 0, width * height); - } - - /// - /// Fetches one row of luminance data from the underlying platform's bitmap. Values range from - /// 0 (black) to 255 (white). It is preferable for implementations of this method - /// to only fetch this row rather than the whole image, since no 2D Readers may be installed and - /// getMatrix() may never be called. - /// - /// The row to fetch, 0 <= y < Height. - /// An optional preallocated array. If null or too small, it will be ignored. - /// Always use the returned object, and ignore the .length of the array. - /// - /// An array containing the luminance data. - /// - override public byte[] getRow(int y, byte[] row) - { - int width = Width; - if (row == null || row.Length < width) - { - row = new byte[width]; - } - for (int i = 0; i < width; i++) - row[i] = luminances[y * width + i]; - return row; - } - - /// - /// gets the luminance matrix - /// - public override byte[] Matrix - { - get { return luminances; } - } - - /// - /// Returns a new object with rotated image data by 90 degrees counterclockwise. - /// Only callable if {@link #isRotateSupported()} is true. - /// - /// - /// A rotated version of this object. - /// - public override LuminanceSource rotateCounterClockwise() - { - var rotatedLuminances = new byte[Width * Height]; - var newWidth = Height; - var newHeight = Width; - var localLuminances = Matrix; - for (var yold = 0; yold < Height; yold++) - { - for (var xold = 0; xold < Width; xold++) - { - var ynew = newHeight - xold - 1; - var xnew = yold; - rotatedLuminances[ynew * newWidth + xnew] = localLuminances[yold * Width + xold]; - } - } - return CreateLuminanceSource(rotatedLuminances, newWidth, newHeight); - } - - /// - /// TODO: not implemented yet - /// - /// - /// A rotated version of this object. - /// - public override LuminanceSource rotateCounterClockwise45() - { - // TODO: implement a good 45 degrees rotation without lost of information - return base.rotateCounterClockwise45(); - } - - /// - /// - /// Whether this subclass supports counter-clockwise rotation. - public override bool RotateSupported - { - get - { - return true; - } - } - - /// - /// Returns a new object with cropped image data. Implementations may keep a reference to the - /// original data rather than a copy. Only callable if CropSupported is true. - /// - /// The left coordinate, 0 <= left < Width. - /// The top coordinate, 0 <= top <= Height. - /// The width of the rectangle to crop. - /// The height of the rectangle to crop. - /// - /// A cropped version of this object. - /// - public override LuminanceSource crop(int left, int top, int width, int height) - { - if (left + width > Width || top + height > Height) - { - throw new ArgumentException("Crop rectangle does not fit within image data."); - } - var croppedLuminances = new byte[width * height]; - var oldLuminances = Matrix; - var oldWidth = Width; - var oldRightBound = left + width; - var oldBottomBound = top + height; - for (int yold = top, ynew = 0; yold < oldBottomBound; yold++, ynew++) - { - for (int xold = left, xnew = 0; xold < oldRightBound; xold++, xnew++) - { - croppedLuminances[ynew * width + xnew] = oldLuminances[yold * oldWidth + xold]; - } - } - return CreateLuminanceSource(croppedLuminances, width, height); - } - - /// - /// - /// Whether this subclass supports cropping. - public override bool CropSupported - { - get - { - return true; - } - } - - /// - /// - /// Whether this subclass supports invertion. - public override bool InversionSupported - { - get - { - return true; - } - } - - /// - /// Inverts the luminance values (newValue = 255 - oldValue) - /// - public override LuminanceSource invert() - { - return new InvertedLuminanceSource(this); - } - - /// - /// Should create a new luminance source with the right class type. - /// The method is used in methods crop and rotate. - /// - /// The new luminances. - /// The width. - /// The height. - /// - protected abstract LuminanceSource CreateLuminanceSource(byte[] newLuminances, int width, int height); - } -} diff --git a/Runtime/zxing.unity/Source/lib/BaseLuminanceSource.cs.meta b/Runtime/zxing.unity/Source/lib/BaseLuminanceSource.cs.meta deleted file mode 100644 index b2aa480f2..000000000 --- a/Runtime/zxing.unity/Source/lib/BaseLuminanceSource.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a742eb430a20a43e8ac72ad72deb6088 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/Binarizer.cs b/Runtime/zxing.unity/Source/lib/Binarizer.cs deleted file mode 100644 index ef5c9d78f..000000000 --- a/Runtime/zxing.unity/Source/lib/Binarizer.cs +++ /dev/null @@ -1,104 +0,0 @@ -/* -* Copyright 2009 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; - -using ZXing.Common; - -namespace ZXing -{ - /// This class hierarchy provides a set of methods to convert luminance data to 1 bit data. - /// It allows the algorithm to vary polymorphically, for example allowing a very expensive - /// thresholding technique for servers and a fast one for mobile. It also permits the implementation - /// to vary, e.g. a JNI version for Android and a Java fallback version for other platforms. - /// - /// dswitkin@google.com (Daniel Switkin) - /// - public abstract class Binarizer - { - private readonly LuminanceSource source; - - /// - /// Initializes a new instance of the class. - /// - /// The source. - protected internal Binarizer(LuminanceSource source) - { - if (source == null) - { - throw new ArgumentException("Source must be non-null."); - } - this.source = source; - } - - /// - /// Gets the luminance source object. - /// - virtual public LuminanceSource LuminanceSource - { - get - { - return source; - } - } - - /// Converts one row of luminance data to 1 bit data. May actually do the conversion, or return - /// cached data. Callers should assume this method is expensive and call it as seldom as possible. - /// This method is intended for decoding 1D barcodes and may choose to apply sharpening. - /// For callers which only examine one row of pixels at a time, the same BitArray should be reused - /// and passed in with each call for performance. However it is legal to keep more than one row - /// at a time if needed. - /// - /// The row to fetch, which must be in [0, bitmap height) - /// An optional preallocated array. If null or too small, it will be ignored. - /// If used, the Binarizer will call BitArray.clear(). Always use the returned object. - /// - /// The array of bits for this row (true means black). - public abstract BitArray getBlackRow(int y, BitArray row); - - /// Converts a 2D array of luminance data to 1 bit data. As above, assume this method is expensive - /// and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or - /// may not apply sharpening. Therefore, a row from this matrix may not be identical to one - /// fetched using getBlackRow(), so don't mix and match between them. - /// - /// The 2D array of bits for the image (true means black). - public abstract BitMatrix BlackMatrix { get; } - - /// Creates a new object with the same type as this Binarizer implementation, but with pristine - /// state. This is needed because Binarizer implementations may be stateful, e.g. keeping a cache - /// of 1 bit data. See Effective Java for why we can't use Java's clone() method. - /// - /// The LuminanceSource this Binarizer will operate on. - /// A new concrete Binarizer implementation object. - public abstract Binarizer createBinarizer(LuminanceSource source); - - /// - /// Gets the width of the luminance source object. - /// - public int Width - { - get { return source.Width; } - } - - /// - /// Gets the height of the luminance source object. - /// - public int Height - { - get { return source.Height; } - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/Binarizer.cs.meta b/Runtime/zxing.unity/Source/lib/Binarizer.cs.meta deleted file mode 100644 index 5d71ebbda..000000000 --- a/Runtime/zxing.unity/Source/lib/Binarizer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2103e1642091d4b858734f4f8ce8f2b0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/BinaryBitmap.cs b/Runtime/zxing.unity/Source/lib/BinaryBitmap.cs deleted file mode 100644 index 55b179e0b..000000000 --- a/Runtime/zxing.unity/Source/lib/BinaryBitmap.cs +++ /dev/null @@ -1,182 +0,0 @@ -/* -* Copyright 2009 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using ZXing.Common; - -namespace ZXing -{ - /// - /// This class is the core bitmap class used by ZXing to represent 1 bit data. Reader objects - /// accept a BinaryBitmap and attempt to decode it. - /// - /// dswitkin@google.com (Daniel Switkin) - public sealed class BinaryBitmap - { - private readonly Binarizer binarizer; - private BitMatrix matrix; - - /// - /// - /// - /// - public BinaryBitmap(Binarizer binarizer) - { - if (binarizer == null) - { - throw new ArgumentException("Binarizer must be non-null."); - } - this.binarizer = binarizer; - } - - internal BinaryBitmap(BitMatrix matrix) - { - if (matrix == null) - { - throw new ArgumentException("matrix must be non-null."); - } - this.matrix = matrix; - } - - /// - /// The width of the bitmap. - /// - public int Width - { - get - { - return binarizer.Width; - } - } - - /// - /// The height of the bitmap. - /// - public int Height - { - get - { - return binarizer.Height; - } - } - - /// - /// Converts one row of luminance data to 1 bit data. May actually do the conversion, or return - /// cached data. Callers should assume this method is expensive and call it as seldom as possible. - /// This method is intended for decoding 1D barcodes and may choose to apply sharpening. - /// - /// The row to fetch, which must be in [0, bitmap height). - /// An optional preallocated array. If null or too small, it will be ignored. - /// If used, the Binarizer will call BitArray.clear(). Always use the returned object. - /// - /// The array of bits for this row (true means black). - public BitArray getBlackRow(int y, BitArray row) - { - return binarizer.getBlackRow(y, row); - } - - /// - /// Converts a 2D array of luminance data to 1 bit. As above, assume this method is expensive - /// and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or - /// may not apply sharpening. Therefore, a row from this matrix may not be identical to one - /// fetched using getBlackRow(), so don't mix and match between them. - /// - /// The 2D array of bits for the image (true means black). - public BitMatrix BlackMatrix - { - get - { - // The matrix is created on demand the first time it is requested, then cached. There are two - // reasons for this: - // 1. This work will never be done if the caller only installs 1D Reader objects, or if a - // 1D Reader finds a barcode before the 2D Readers run. - // 2. This work will only be done once even if the caller installs multiple 2D Readers. - return matrix ?? (matrix = binarizer.BlackMatrix); - } - } - - /// - /// Whether this bitmap can be cropped. - /// - public bool CropSupported - { - get - { - return binarizer.LuminanceSource.CropSupported; - } - } - - /// - /// Returns a new object with cropped image data. Implementations may keep a reference to the - /// original data rather than a copy. Only callable if isCropSupported() is true. - /// - /// The left coordinate, which must be in [0, Width) - /// The top coordinate, which must be in [0, Height) - /// The width of the rectangle to crop. - /// The height of the rectangle to crop. - /// A cropped version of this object. - public BinaryBitmap crop(int left, int top, int width, int height) - { - var newSource = binarizer.LuminanceSource.crop(left, top, width, height); - return new BinaryBitmap(binarizer.createBinarizer(newSource)); - } - - /// - /// Whether this bitmap supports counter-clockwise rotation. - /// - public bool RotateSupported - { - get - { - return binarizer.LuminanceSource.RotateSupported; - } - } - - /// - /// Returns a new object with rotated image data by 90 degrees counterclockwise. - /// Only callable if is true. - /// - /// A rotated version of this object. - public BinaryBitmap rotateCounterClockwise() - { - var newSource = binarizer.LuminanceSource.rotateCounterClockwise(); - return new BinaryBitmap(binarizer.createBinarizer(newSource)); - } - - /// - /// Returns a new object with rotated image data by 45 degrees counterclockwise. - /// Only callable if is true. - /// - /// A rotated version of this object. - public BinaryBitmap rotateCounterClockwise45() - { - LuminanceSource newSource = binarizer.LuminanceSource.rotateCounterClockwise45(); - return new BinaryBitmap(binarizer.createBinarizer(newSource)); - } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - var blackMatrix = BlackMatrix; - return blackMatrix != null ? blackMatrix.ToString() : String.Empty; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/BinaryBitmap.cs.meta b/Runtime/zxing.unity/Source/lib/BinaryBitmap.cs.meta deleted file mode 100644 index 1a7ac105d..000000000 --- a/Runtime/zxing.unity/Source/lib/BinaryBitmap.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 77e91404b2b5245569e3a4e2626078de -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/DecodeHintType.cs b/Runtime/zxing.unity/Source/lib/DecodeHintType.cs deleted file mode 100644 index cd7111566..000000000 --- a/Runtime/zxing.unity/Source/lib/DecodeHintType.cs +++ /dev/null @@ -1,131 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Collections.Generic; - -namespace ZXing -{ - /// - /// Encapsulates a type of hint that a caller may pass to a barcode reader to help it - /// more quickly or accurately decode it. It is up to implementations to decide what, - /// if anything, to do with the information that is supplied. - /// - /// - /// Sean Owen - /// dswitkin@google.com (Daniel Switkin) - public enum DecodeHintType - { - /// - /// Unspecified, application-specific hint. Maps to an unspecified . - /// - OTHER, - - /// - /// Image is a pure monochrome image of a barcode. Doesn't matter what it maps to; - /// use = true. - /// - PURE_BARCODE, - - /// - /// Image is known to be of one of a few possible formats. - /// Maps to a of s. - /// - POSSIBLE_FORMATS, - - /// - /// Spend more time to try to find a barcode; optimize for accuracy, not speed. - /// Doesn't matter what it maps to; use = true. - /// - TRY_HARDER, - - /// - /// Specifies what character encoding to use when decoding, where applicable (type String) - /// - CHARACTER_SET, - - /// - /// Allowed lengths of encoded data -- reject anything else. Maps to an int[]. - /// - ALLOWED_LENGTHS, - - /// - /// Assume Code 39 codes employ a check digit. Maps to . - /// - ASSUME_CODE_39_CHECK_DIGIT, - - /// - /// The caller needs to be notified via callback when a possible - /// is found. Maps to a . - /// - NEED_RESULT_POINT_CALLBACK, - - /// - /// Assume MSI codes employ a check digit. Maps to . - /// - ASSUME_MSI_CHECK_DIGIT, - - /// - /// if Code39 could be detected try to use extended mode for full ASCII character set - /// Maps to . - /// - USE_CODE_39_EXTENDED_MODE, - - /// - /// Don't fail if a Code39 is detected but can't be decoded in extended mode. - /// Return the raw Code39 result instead. Maps to . - /// - RELAXED_CODE_39_EXTENDED_MODE, - - /// - /// 1D readers supporting rotation with TRY_HARDER enabled. - /// But BarcodeReader class can do auto-rotating for 1D and 2D codes. - /// Enabling that option prevents 1D readers doing double rotation. - /// BarcodeReader enables that option automatically if "global" auto-rotation is enabled. - /// Maps to . - /// - TRY_HARDER_WITHOUT_ROTATION, - - /// - /// Assume the barcode is being processed as a GS1 barcode, and modify behavior as needed. - /// For example this affects FNC1 handling for Code 128 (aka GS1-128). Doesn't matter what it maps to; - /// use . - /// - ASSUME_GS1, - - /// - /// If true, return the start and end digits in a Codabar barcode instead of stripping them. They - /// are alpha, whereas the rest are numeric. By default, they are stripped, but this causes them - /// to not be. Doesn't matter what it maps to; use . - /// - RETURN_CODABAR_START_END, - - /// - /// Allowed extension lengths for EAN or UPC barcodes. Other formats will ignore this. - /// Maps to an int[] of the allowed extension lengths, for example [2], [5], or [2, 5]. - /// If it is optional to have an extension, do not set this hint. If this is set, - /// and a UPC or EAN barcode is found but an extension is not, then no result will be returned - /// at all. - /// - ALLOWED_EAN_EXTENSIONS, - - /// - /// If true, also tries to decode as inverted image. All configured decoders are simply called a - /// second time with an inverted image. Doesn't matter what it maps to; use {@link Boolean#TRUE}. - /// - ALSO_INVERTED - } -} diff --git a/Runtime/zxing.unity/Source/lib/DecodeHintType.cs.meta b/Runtime/zxing.unity/Source/lib/DecodeHintType.cs.meta deleted file mode 100644 index 38edc836a..000000000 --- a/Runtime/zxing.unity/Source/lib/DecodeHintType.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 58688a125548d4196ae80f8eabc7f2a8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/Dimension.cs b/Runtime/zxing.unity/Source/lib/Dimension.cs deleted file mode 100644 index 003ebdd09..000000000 --- a/Runtime/zxing.unity/Source/lib/Dimension.cs +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; - -namespace ZXing -{ - /// - /// Simply encapsulates a width and height. - /// - public sealed class Dimension - { - private readonly int width; - private readonly int height; - - /// - /// initializing constructor - /// - /// - /// - public Dimension(int width, int height) - { - if (width < 0 || height < 0) - { - throw new ArgumentException(); - } - this.width = width; - this.height = height; - } - - /// - /// the width - /// - public int Width - { - get { return width; } - } - - /// - /// the height - /// - public int Height - { - get { return height; } - } - - /// - /// - /// - /// - /// - public override bool Equals(Object other) - { - if (other is Dimension) - { - var d = (Dimension)other; - return width == d.width && height == d.height; - } - return false; - } - - /// - /// - /// - /// - public override int GetHashCode() - { - return width * 32713 + height; - } - - /// - /// - /// - /// - public override String ToString() - { - return width + "x" + height; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/Dimension.cs.meta b/Runtime/zxing.unity/Source/lib/Dimension.cs.meta deleted file mode 100644 index 6919ad6f1..000000000 --- a/Runtime/zxing.unity/Source/lib/Dimension.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 32585a3a4bb3b46b689f29f4612ada41 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/EncodeHintType.cs b/Runtime/zxing.unity/Source/lib/EncodeHintType.cs deleted file mode 100644 index 7ea3261b9..000000000 --- a/Runtime/zxing.unity/Source/lib/EncodeHintType.cs +++ /dev/null @@ -1,189 +0,0 @@ -/* -* Copyright 2008 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -namespace ZXing -{ - /// - /// These are a set of hints that you may pass to Writers to specify their behavior. - /// - /// dswitkin@google.com (Daniel Switkin) - public enum EncodeHintType - { - /// - /// Specifies the width of the barcode image - /// type: - /// - WIDTH, - - /// - /// Specifies the height of the barcode image - /// type: - /// - HEIGHT, - - /// - /// Don't put the content string into the output image. - /// type: - /// - PURE_BARCODE, - - /// - /// Specifies what degree of error correction to use, for example in QR Codes. - /// Type depends on the encoder. For example for QR codes it's type - /// - /// For Aztec it is of type , representing the minimal percentage of error correction words. - /// In all cases, it can also be a representation of the desired value as well. - /// Note: an Aztec symbol should have a minimum of 25% EC words. - /// For PDF417 it is of type or (between 0 and 8), - /// - ERROR_CORRECTION, - - /// - /// Specifies what character encoding to use where applicable. - /// type: - /// - CHARACTER_SET, - - /// - /// Specifies margin, in pixels, to use when generating the barcode. The meaning can vary - /// by format; for example it controls margin before and after the barcode horizontally for - /// most 1D formats. - /// type: , or representation of the integer value - /// - MARGIN, - - /// - /// Specifies the aspect ratio to use. Default is 4. - /// type: , or 1-4. - /// - PDF417_ASPECT_RATIO, - - /// - /// Specifies the desired aspect ratio (number of columns / number of rows) of the output image. Default is 3. - /// type: . - /// - PDF417_IMAGE_ASPECT_RATIO, - - /// - /// Specifies whether to use compact mode for PDF417 - /// type: , or "true" or "false" - /// value - /// - PDF417_COMPACT, - - /// - /// Specifies what compaction mode to use for PDF417. - /// type: or value of one of its - /// enum values - /// - PDF417_COMPACTION, - - /// - /// Specifies the minimum and maximum number of rows and columns for PDF417. - /// type: - /// - PDF417_DIMENSIONS, - - /// - /// The Specifies that the PDF417 will contain macro metadata. - /// type: - /// - PDF417_MACRO_META_DATA, - - /// - /// Don't append ECI segment. - /// That is against the specification of QR Code but some - /// readers have problems if the charset is switched from - /// ISO-8859-1 (default) to UTF-8 with the necessary ECI segment. - /// If you set the property to true you can use UTF-8 encoding - /// and the ECI segment is omitted. - /// type: - /// - DISABLE_ECI, - - /// - /// Specifies the matrix shape for Data Matrix (type ) - /// - DATA_MATRIX_SHAPE, - - /// - /// Specifies a minimum barcode size (type ). Only applicable to Data Matrix now. - /// - MIN_SIZE, - - /// - /// Specifies a maximum barcode size (type ). Only applicable to Data Matrix now. - /// - MAX_SIZE, - - /// - /// if true, don't switch to codeset C for numbers - /// - CODE128_FORCE_CODESET_B, - - /// - /// Specifies the default encodation for Data Matrix (type ) - /// Make sure that the content fits into the encodation value, otherwise there will be an exception thrown. - /// standard value: Encodation.ASCII - /// - DATA_MATRIX_DEFAULT_ENCODATION, - - /// - /// Specifies the required number of layers for an Aztec code. - /// A negative number (-1, -2, -3, -4) specifies a compact Aztec code - /// 0 indicates to use the minimum number of layers (the default) - /// A positive number (1, 2, .. 32) specifies a normal (non-compact) Aztec code - /// type: , or representation of the integer value - /// - AZTEC_LAYERS, - - /// - /// Specifies the exact version of QR code to be encoded. - /// (Type , or representation of the integer value). - /// - QR_VERSION, - - /// - /// Specifies whether the data should be encoded to the GS1 standard - /// type: , or "true" or "false" - /// value - /// - GS1_FORMAT, - - /// - /// Specifies the QR code mask pattern to be used. Allowed values are - /// 0..QRCode.NUM_MASK_PATTERNS-1. By default the code will automatically select - /// the optimal mask pattern. - /// (Type , or representation of the integer value). - /// - QR_MASK_PATTERN, - - /// - /// Forces which encoding will be used. Currently only used for Code-128 code sets (Type ). Valid values are "A", "B", "C". - /// see also CODE128_FORCE_CODESET_B - /// - FORCE_CODE_SET, - - /// - /// Specifies whether to use compact mode for QR code (type , or "true" or "false" - /// Please note that when compaction is performed, the most compact character encoding is chosen - /// for characters in the input that are not in the ISO-8859-1 character set. Based on experience, - /// some scanners do not support encodings like cp-1256 (Arabic). In such cases the encoding can - /// be forced to UTF-8 by means of the encoding hint. - /// - QR_COMPACT, - } -} diff --git a/Runtime/zxing.unity/Source/lib/EncodeHintType.cs.meta b/Runtime/zxing.unity/Source/lib/EncodeHintType.cs.meta deleted file mode 100644 index d2776a973..000000000 --- a/Runtime/zxing.unity/Source/lib/EncodeHintType.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 43aef46c4d44147ed9a49f0e1770b984 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/IBarcodeWriter.Color32.cs b/Runtime/zxing.unity/Source/lib/IBarcodeWriter.Color32.cs deleted file mode 100644 index 7dab4fd4a..000000000 --- a/Runtime/zxing.unity/Source/lib/IBarcodeWriter.Color32.cs +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using ZXing.Common; - -namespace ZXing -{ - /// - /// Interface for a smart class to encode some content into a barcode - /// - public partial interface IBarcodeWriter - { - /// - /// Creates a visual representation of the contents - /// - UnityEngine.Color32[] Write(string contents); - /// - /// Returns a rendered instance of the barcode which is given by a BitMatrix. - /// - UnityEngine.Color32[] Write(BitMatrix matrix); - } -} diff --git a/Runtime/zxing.unity/Source/lib/IBarcodeWriter.Color32.cs.meta b/Runtime/zxing.unity/Source/lib/IBarcodeWriter.Color32.cs.meta deleted file mode 100644 index 1290dbb27..000000000 --- a/Runtime/zxing.unity/Source/lib/IBarcodeWriter.Color32.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7b899d43436a045e88d6f3e4ba1114cf -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/IBarcodeWriter.PixelData.cs b/Runtime/zxing.unity/Source/lib/IBarcodeWriter.PixelData.cs deleted file mode 100644 index 16544d3aa..000000000 --- a/Runtime/zxing.unity/Source/lib/IBarcodeWriter.PixelData.cs +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using ZXing.Common; -using ZXing.Rendering; - -namespace ZXing -{ - /// - /// Interface for a smart class to encode some content into a barcode - /// - public partial interface IBarcodeWriterPixelData - { - /// - /// Creates a visual representation of the contents - /// - PixelData Write(string contents); - - /// - /// Returns a rendered instance of the barcode which is given by a BitMatrix. - /// - PixelData Write(BitMatrix matrix); - } -} diff --git a/Runtime/zxing.unity/Source/lib/IBarcodeWriter.PixelData.cs.meta b/Runtime/zxing.unity/Source/lib/IBarcodeWriter.PixelData.cs.meta deleted file mode 100644 index 16bab4ce6..000000000 --- a/Runtime/zxing.unity/Source/lib/IBarcodeWriter.PixelData.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a0e73807d90a54dc3b753531f5ffb1f4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/IBarcodeWriter.SvgImage.cs b/Runtime/zxing.unity/Source/lib/IBarcodeWriter.SvgImage.cs deleted file mode 100644 index c2a903852..000000000 --- a/Runtime/zxing.unity/Source/lib/IBarcodeWriter.SvgImage.cs +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using ZXing.Common; -using ZXing.Rendering; - -namespace ZXing -{ - /// - /// Interface for a smart class to encode some content into a barcode - /// - public partial interface IBarcodeWriterSvg - { - /// - /// Creates a visual representation of the contents - /// - SvgRenderer.SvgImage Write(string contents); - - /// - /// Returns a rendered instance of the barcode which is given by a BitMatrix. - /// - SvgRenderer.SvgImage Write(BitMatrix matrix); - } -} diff --git a/Runtime/zxing.unity/Source/lib/IBarcodeWriter.SvgImage.cs.meta b/Runtime/zxing.unity/Source/lib/IBarcodeWriter.SvgImage.cs.meta deleted file mode 100644 index 6ba2faa61..000000000 --- a/Runtime/zxing.unity/Source/lib/IBarcodeWriter.SvgImage.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9da9817a5b5e84b1e8a6aa9d8d4c97c7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/IBarcodeWriter.cs b/Runtime/zxing.unity/Source/lib/IBarcodeWriter.cs deleted file mode 100644 index 042abd752..000000000 --- a/Runtime/zxing.unity/Source/lib/IBarcodeWriter.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using ZXing.Common; - -namespace ZXing -{ - /// - /// Interface for a smart class to encode some content into a barcode - /// - public partial interface IBarcodeWriter - { - /// - /// Get or sets the barcode format which should be generated - /// (only suitable if MultiFormatWriter is used for property Encoder which is the default) - /// - BarcodeFormat Format { get; set; } - - /// - /// Gets or sets the options container for the encoding and renderer process. - /// - EncodingOptions Options { get; set; } - - /// - /// Gets or sets the writer which encodes the content to a BitMatrix. - /// If no value is set the MultiFormatWriter is used. - /// - Writer Encoder { get; set; } - - /// - /// Encodes the specified contents. - /// - /// The contents. - /// - BitMatrix Encode(string contents); - } -} diff --git a/Runtime/zxing.unity/Source/lib/IBarcodeWriter.cs.meta b/Runtime/zxing.unity/Source/lib/IBarcodeWriter.cs.meta deleted file mode 100644 index 5cb1a886f..000000000 --- a/Runtime/zxing.unity/Source/lib/IBarcodeWriter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5fc9fcb5a088448bba2a74ac4d744dcb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/IBarcodeWriterCustom.cs b/Runtime/zxing.unity/Source/lib/IBarcodeWriterCustom.cs deleted file mode 100644 index 9dd11013d..000000000 --- a/Runtime/zxing.unity/Source/lib/IBarcodeWriterCustom.cs +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using ZXing.Common; - -namespace ZXing -{ -#if !(WINDOWS_PHONE || WindowsCE) - /// - /// Interface for a smart class to encode some content into a barcode - /// - public partial interface IBarcodeWriter -#else - /// - /// Interface for a smart class to encode some content into a barcode - /// - public interface IBarcodeWriter -#endif - { - /// - /// Creates a visual representation of the contents - /// - /// The contents. - /// - TOutput Write(string contents); - - /// - /// Returns a rendered instance of the barcode which is given by a BitMatrix. - /// - /// The matrix. - /// - TOutput Write(BitMatrix matrix); - } -} diff --git a/Runtime/zxing.unity/Source/lib/IBarcodeWriterCustom.cs.meta b/Runtime/zxing.unity/Source/lib/IBarcodeWriterCustom.cs.meta deleted file mode 100644 index e519d6003..000000000 --- a/Runtime/zxing.unity/Source/lib/IBarcodeWriterCustom.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 56b69d620595a4755ab7f42952b5e54f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/IBarcodeWriterGeneric.cs b/Runtime/zxing.unity/Source/lib/IBarcodeWriterGeneric.cs deleted file mode 100644 index 95ab28eb2..000000000 --- a/Runtime/zxing.unity/Source/lib/IBarcodeWriterGeneric.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using ZXing.Common; - -namespace ZXing -{ - /// - /// Interface for a smart class to encode some content into a barcode - /// - public interface IBarcodeWriterGeneric - { - /// - /// Get or sets the barcode format which should be generated - /// (only suitable if MultiFormatWriter is used for property Encoder which is the default) - /// - BarcodeFormat Format { get; set; } - - /// - /// Gets or sets the options container for the encoding and renderer process. - /// - EncodingOptions Options { get; set; } - - /// - /// Gets or sets the writer which encodes the content to a BitMatrix. - /// If no value is set the MultiFormatWriter is used. - /// - Writer Encoder { get; set; } - - /// - /// Encodes the specified contents. - /// - /// The contents. - /// - BitMatrix Encode(string contents); - } -} diff --git a/Runtime/zxing.unity/Source/lib/IBarcodeWriterGeneric.cs.meta b/Runtime/zxing.unity/Source/lib/IBarcodeWriterGeneric.cs.meta deleted file mode 100644 index 279a7192e..000000000 --- a/Runtime/zxing.unity/Source/lib/IBarcodeWriterGeneric.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 45043f4a8e05446e78d359883fc6d332 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/InvertedLuminanceSource.cs b/Runtime/zxing.unity/Source/lib/InvertedLuminanceSource.cs deleted file mode 100644 index a819367c7..000000000 --- a/Runtime/zxing.unity/Source/lib/InvertedLuminanceSource.cs +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace ZXing -{ - /// - /// A wrapper implementation of {@link LuminanceSource} which inverts the luminances it returns -- black becomes - /// white and vice versa, and each value becomes (255-value). - /// - /// Sean Owen - public sealed class InvertedLuminanceSource : LuminanceSource - { - private readonly LuminanceSource @delegate; - private byte[] invertedMatrix; - - /// - /// Initializes a new instance of the class. - /// - /// The @delegate. - public InvertedLuminanceSource(LuminanceSource @delegate) - : base(@delegate.Width, @delegate.Height) - { - this.@delegate = @delegate; - } - - /// - /// Fetches one row of luminance data from the underlying platform's bitmap. Values range from - /// 0 (black) to 255 (white). Because Java does not have an unsigned byte type, callers will have - /// to bitwise and with 0xff for each value. It is preferable for implementations of this method - /// to only fetch this row rather than the whole image, since no 2D Readers may be installed and - /// getMatrix() may never be called. - /// - /// The row to fetch, 0 <= y < Height. - /// An optional preallocated array. If null or too small, it will be ignored. - /// Always use the returned object, and ignore the .length of the array. - /// - /// An array containing the luminance data. - /// - override public byte[] getRow(int y, byte[] row) - { - row = @delegate.getRow(y, row); - int width = Width; - for (int i = 0; i < width; i++) - { - row[i] = (byte)(255 - (row[i] & 0xFF)); - } - return row; - } - - /// - /// Fetches luminance data for the underlying bitmap. Values should be fetched using: - /// int luminance = array[y * width + x] & 0xff; - /// - /// A row-major 2D array of luminance values. Do not use result.length as it may be - /// larger than width * height bytes on some platforms. Do not modify the contents - /// of the result. - /// - override public byte[] Matrix - { - get - { - if (invertedMatrix == null) - { - byte[] matrix = @delegate.Matrix; - int length = Width * Height; - invertedMatrix = new byte[length]; - for (int i = 0; i < length; i++) - { - invertedMatrix[i] = (byte)(255 - (matrix[i] & 0xFF)); - } - } - return invertedMatrix; - } - } - - /// - /// - /// Whether this subclass supports cropping. - override public bool CropSupported - { - get { return @delegate.CropSupported; } - } - - /// - /// Returns a new object with cropped image data. Implementations may keep a reference to the - /// original data rather than a copy. Only callable if CropSupported is true. - /// - /// The left coordinate, 0 <= left < Width. - /// The top coordinate, 0 <= top <= Height. - /// The width of the rectangle to crop. - /// The height of the rectangle to crop. - /// - /// A cropped version of this object. - /// - override public LuminanceSource crop(int left, int top, int width, int height) - { - return new InvertedLuminanceSource(@delegate.crop(left, top, width, height)); - } - - /// - /// - /// Whether this subclass supports counter-clockwise rotation. - override public bool RotateSupported - { - get { return @delegate.RotateSupported; } - } - - /// - /// Inverts this instance. - /// - /// original delegate {@link LuminanceSource} since invert undoes itself - override public LuminanceSource invert() - { - return @delegate; - } - - /// - /// Returns a new object with rotated image data by 90 degrees counterclockwise. - /// Only callable if {@link #isRotateSupported()} is true. - /// - /// - /// A rotated version of this object. - /// - override public LuminanceSource rotateCounterClockwise() - { - return new InvertedLuminanceSource(@delegate.rotateCounterClockwise()); - } - - /// - /// Returns a new object with rotated image data by 45 degrees counterclockwise. - /// Only callable if {@link #isRotateSupported()} is true. - /// - /// - /// A rotated version of this object. - /// - override public LuminanceSource rotateCounterClockwise45() - { - return new InvertedLuminanceSource(@delegate.rotateCounterClockwise45()); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/InvertedLuminanceSource.cs.meta b/Runtime/zxing.unity/Source/lib/InvertedLuminanceSource.cs.meta deleted file mode 100644 index 176a4629d..000000000 --- a/Runtime/zxing.unity/Source/lib/InvertedLuminanceSource.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: afbf3669ab74f4db188668261aabaa6b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/LuminanceSource.cs b/Runtime/zxing.unity/Source/lib/LuminanceSource.cs deleted file mode 100644 index 791a143e2..000000000 --- a/Runtime/zxing.unity/Source/lib/LuminanceSource.cs +++ /dev/null @@ -1,207 +0,0 @@ -/* -* Copyright 2009 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Text; - -namespace ZXing -{ - /// - /// The purpose of this class hierarchy is to abstract different bitmap implementations across - /// platforms into a standard interface for requesting greyscale luminance values. The interface - /// only provides immutable methods; therefore crop and rotation create copies. This is to ensure - /// that one Reader does not modify the original luminance source and leave it in an unknown state - /// for other Readers in the chain. - /// - /// dswitkin@google.com (Daniel Switkin) - public abstract class LuminanceSource - { - private int width; - private int height; - - /// - /// initializing constructor - /// - /// - /// - protected LuminanceSource(int width, int height) - { - this.width = width; - this.height = height; - } - - /// - /// Fetches one row of luminance data from the underlying platform's bitmap. Values range from - /// 0 (black) to 255 (white). Because Java does not have an unsigned byte type, callers will have - /// to bitwise and with 0xff for each value. It is preferable for implementations of this method - /// to only fetch this row rather than the whole image, since no 2D Readers may be installed and - /// getMatrix() may never be called. - /// - /// The row to fetch, which must be in [0, bitmap height) - /// An optional preallocated array. If null or too small, it will be ignored. - /// Always use the returned object, and ignore the .length of the array. - /// - /// An array containing the luminance data. - public abstract byte[] getRow(int y, byte[] row); - - /// - /// Fetches luminance data for the underlying bitmap. Values should be fetched using: - /// int luminance = array[y * width + x] & 0xff - /// - /// - /// A row-major 2D array of luminance values. Do not use result.length as it may be - /// larger than width * height bytes on some platforms. Do not modify the contents - /// of the result. - /// - public abstract byte[] Matrix { get; } - - /// The width of the bitmap. - public virtual int Width - { - get - { - return width; - } - protected set - { - width = value; - } - } - - /// The height of the bitmap. - public virtual int Height - { - get - { - return height; - } - protected set - { - height = value; - } - } - - /// Whether this subclass supports cropping. - public virtual bool CropSupported - { - get - { - return false; - } - } - - /// - /// Returns a new object with cropped image data. Implementations may keep a reference to the - /// original data rather than a copy. Only callable if CropSupported is true. - /// - /// The left coordinate, which must be in [0, Width) - /// The top coordinate, which must be in [0, Height) - /// The width of the rectangle to crop. - /// The height of the rectangle to crop. - /// A cropped version of this object. - public virtual LuminanceSource crop(int left, int top, int width, int height) - { - throw new NotSupportedException("This luminance source does not support cropping."); - } - - /// Whether this subclass supports counter-clockwise rotation. - public virtual bool RotateSupported - { - get - { - return false; - } - } - - /// - /// Returns a new object with rotated image data by 90 degrees counterclockwise. - /// Only callable if is true. - /// - /// A rotated version of this object. - public virtual LuminanceSource rotateCounterClockwise() - { - throw new NotSupportedException("This luminance source does not support rotation."); - } - - /// - /// Returns a new object with rotated image data by 45 degrees counterclockwise. - /// Only callable if is true. - /// - /// A rotated version of this object. - public virtual LuminanceSource rotateCounterClockwise45() - { - throw new NotSupportedException("This luminance source does not support rotation by 45 degrees."); - } - - /// - /// - /// Whether this subclass supports invertion. - public virtual bool InversionSupported - { - get - { - return false; - } - } - - /// - /// inverts the luminance values, not supported here. has to implemented in sub classes - /// - /// - public virtual LuminanceSource invert() - { - throw new NotSupportedException("This luminance source does not support inversion."); - } - - /// - /// - /// - /// - public override String ToString() - { - var row = new byte[width]; - var result = new StringBuilder(height * (width + 1)); - for (int y = 0; y < height; y++) - { - row = getRow(y, row); - for (int x = 0; x < width; x++) - { - int luminance = row[x] & 0xFF; - char c; - if (luminance < 0x40) - { - c = '#'; - } - else if (luminance < 0x80) - { - c = '+'; - } - else if (luminance < 0xC0) - { - c = '.'; - } - else - { - c = ' '; - } - result.Append(c); - } - result.Append('\n'); - } - return result.ToString(); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/LuminanceSource.cs.meta b/Runtime/zxing.unity/Source/lib/LuminanceSource.cs.meta deleted file mode 100644 index 6cdc669dc..000000000 --- a/Runtime/zxing.unity/Source/lib/LuminanceSource.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e573e6f6c33e94b67bf8648cf681e94f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/PlanarYUVLuminanceSource.cs b/Runtime/zxing.unity/Source/lib/PlanarYUVLuminanceSource.cs deleted file mode 100644 index f2bd8c51c..000000000 --- a/Runtime/zxing.unity/Source/lib/PlanarYUVLuminanceSource.cs +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright 2009 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; - -namespace ZXing -{ - /// - /// This object extends LuminanceSource around an array of YUV data returned from the camera driver, - /// with the option to crop to a rectangle within the full data. This can be used to exclude - /// superfluous pixels around the perimeter and speed up decoding. - /// It works for any pixel format where the Y channel is planar and appears first, including - /// YCbCr_420_SP and YCbCr_422_SP. - /// @author dswitkin@google.com (Daniel Switkin) - /// - public sealed class PlanarYUVLuminanceSource : BaseLuminanceSource - { - private const int THUMBNAIL_SCALE_FACTOR = 2; - - private readonly byte[] yuvData; - private readonly int dataWidth; - private readonly int dataHeight; - private readonly int left; - private readonly int top; - - /// - /// Initializes a new instance of the class. - /// - /// The yuv data. - /// Width of the data. - /// Height of the data. - /// The left. - /// The top. - /// The width. - /// The height. - /// if set to true [reverse horiz]. - public PlanarYUVLuminanceSource(byte[] yuvData, - int dataWidth, - int dataHeight, - int left, - int top, - int width, - int height, - bool reverseHoriz) - : base(width, height) - { - if (left + width > dataWidth || top + height > dataHeight) - { - throw new ArgumentException("Crop rectangle does not fit within image data."); - } - - this.yuvData = yuvData; - this.dataWidth = dataWidth; - this.dataHeight = dataHeight; - this.left = left; - this.top = top; - if (reverseHoriz) - { - reverseHorizontal(width, height); - } - } - - /// - /// Initializes a new instance of the class. - /// - /// The luminances. - /// The width. - /// The height. - private PlanarYUVLuminanceSource(byte[] luminances, int width, int height) - : base(width, height) - { - yuvData = luminances; - this.luminances = luminances; - dataWidth = width; - dataHeight = height; - left = 0; - top = 0; - } - - /// - /// Fetches one row of luminance data from the underlying platform's bitmap. Values range from - /// 0 (black) to 255 (white). Because Java does not have an unsigned byte type, callers will have - /// to bitwise and with 0xff for each value. It is preferable for implementations of this method - /// to only fetch this row rather than the whole image, since no 2D Readers may be installed and - /// getMatrix() may never be called. - /// - /// The row to fetch, 0 <= y < Height. - /// An optional preallocated array. If null or too small, it will be ignored. - /// Always use the returned object, and ignore the .length of the array. - /// - /// An array containing the luminance data. - /// - override public byte[] getRow(int y, byte[] row) - { - if (y < 0 || y >= Height) - { - throw new ArgumentException("Requested row is outside the image: " + y); - } - int width = Width; - if (row == null || row.Length < width) - { - row = new byte[width]; - } - int offset = (y + top) * dataWidth + left; - Array.Copy(yuvData, offset, row, 0, width); - return row; - } - - /// - /// - /// - override public byte[] Matrix - { - get - { - int width = Width; - int height = Height; - - // If the caller asks for the entire underlying image, save the copy and give them the - // original data. The docs specifically warn that result.length must be ignored. - if (width == dataWidth && height == dataHeight) - { - return yuvData; - } - - int area = width * height; - byte[] matrix = new byte[area]; - int inputOffset = top * dataWidth + left; - - // If the width matches the full width of the underlying data, perform a single copy. - if (width == dataWidth) - { - Array.Copy(yuvData, inputOffset, matrix, 0, area); - return matrix; - } - - // Otherwise copy one cropped row at a time. - byte[] yuv = yuvData; - for (int y = 0; y < height; y++) - { - int outputOffset = y * width; - Array.Copy(yuvData, inputOffset, matrix, outputOffset, width); - inputOffset += dataWidth; - } - return matrix; - } - } - - /// - /// - /// Whether this subclass supports cropping. - override public bool CropSupported - { - get { return true; } - } - - /// - /// Returns a new object with cropped image data. Implementations may keep a reference to the - /// original data rather than a copy. Only callable if CropSupported is true. - /// - /// The left coordinate, 0 <= left < Width. - /// The top coordinate, 0 <= top <= Height. - /// The width of the rectangle to crop. - /// The height of the rectangle to crop. - /// - /// A cropped version of this object. - /// - override public LuminanceSource crop(int left, int top, int width, int height) - { - return new PlanarYUVLuminanceSource(yuvData, - dataWidth, - dataHeight, - this.left + left, - this.top + top, - width, - height, - false); - } - - /// - /// Renders the cropped greyscale bitmap. - /// - /// - public int[] renderThumbnail() - { - int width = Width / THUMBNAIL_SCALE_FACTOR; - int height = Height / THUMBNAIL_SCALE_FACTOR; - int[] pixels = new int[width * height]; - byte[] yuv = yuvData; - int inputOffset = top * dataWidth + left; - - for (int y = 0; y < height; y++) - { - int outputOffset = y * width; - for (int x = 0; x < width; x++) - { - int grey = yuv[inputOffset + x * THUMBNAIL_SCALE_FACTOR] & 0xff; - pixels[outputOffset + x] = ((0x00FF0000 << 8) | (grey * 0x00010101)); - } - inputOffset += dataWidth * THUMBNAIL_SCALE_FACTOR; - } - return pixels; - } - - /// - /// width of image from {@link #renderThumbnail()} - /// - public int ThumbnailWidth - { - get - { - return Width / THUMBNAIL_SCALE_FACTOR; - } - } - - /// - /// height of image from {@link #renderThumbnail()} - /// - public int ThumbnailHeight - { - get - { - return Height / THUMBNAIL_SCALE_FACTOR; - } - } - - private void reverseHorizontal(int width, int height) - { - byte[] yuvData = this.yuvData; - for (int y = 0, rowStart = top * dataWidth + left; y < height; y++, rowStart += dataWidth) - { - int middle = rowStart + width / 2; - for (int x1 = rowStart, x2 = rowStart + width - 1; x1 < middle; x1++, x2--) - { - byte temp = yuvData[x1]; - yuvData[x1] = yuvData[x2]; - yuvData[x2] = temp; - } - } - } - - /// - /// creates a new instance - /// - /// - /// - /// - /// - protected override LuminanceSource CreateLuminanceSource(byte[] newLuminances, int width, int height) - { - return new PlanarYUVLuminanceSource(newLuminances, width, height); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/PlanarYUVLuminanceSource.cs.meta b/Runtime/zxing.unity/Source/lib/PlanarYUVLuminanceSource.cs.meta deleted file mode 100644 index e3ca5623f..000000000 --- a/Runtime/zxing.unity/Source/lib/PlanarYUVLuminanceSource.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 37aa1d05c61e44f93acd32e75a630b81 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/RGBLuminanceSource.cs b/Runtime/zxing.unity/Source/lib/RGBLuminanceSource.cs deleted file mode 100644 index e2b197b41..000000000 --- a/Runtime/zxing.unity/Source/lib/RGBLuminanceSource.cs +++ /dev/null @@ -1,380 +0,0 @@ -/* -* Copyright 2012 ZXing.Net authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; - -namespace ZXing -{ - /// - /// Luminance source class which support different formats of images. - /// - public partial class RGBLuminanceSource : BaseLuminanceSource - { - /// - /// enumeration of supported bitmap format which the RGBLuminanceSource can process - /// - public enum BitmapFormat - { - /// - /// format of the byte[] isn't known. RGBLuminanceSource tries to determine the best possible value - /// - Unknown, - /// - /// grayscale array, the byte array is a luminance array with 1 byte per pixel - /// - Gray8, - /// - /// grayscale array, the byte array is a luminance array with 2 bytes per pixel - /// - Gray16, - /// - /// 3 bytes per pixel with the channels red, green and blue - /// - RGB24, - /// - /// 4 bytes per pixel with the channels red, green and blue - /// - RGB32, - /// - /// 4 bytes per pixel with the channels alpha, red, green and blue - /// - ARGB32, - /// - /// 3 bytes per pixel with the channels blue, green and red - /// - BGR24, - /// - /// 4 bytes per pixel with the channels blue, green and red - /// - BGR32, - /// - /// 4 bytes per pixel with the channels blue, green, red and alpha - /// - BGRA32, - /// - /// 2 bytes per pixel, 5 bit red, 6 bits green and 5 bits blue - /// - RGB565, - /// - /// 4 bytes per pixel with the channels red, green, blue and alpha - /// - RGBA32, - /// - /// 4 bytes for two pixels, UYVY formatted - /// - UYVY, - /// - /// 4 bytes for two pixels, YUYV formatted - /// - YUYV - } - - /// - /// Initializes a new instance of the class. - /// - /// The width. - /// The height. - protected RGBLuminanceSource(int width, int height) - : base(width, height) - { - } - - /// - /// Initializes a new instance of the class. - /// It supports a byte array with 3 bytes per pixel (RGB24). - /// - /// The RGB raw bytes. - /// The width. - /// The height. - public RGBLuminanceSource(byte[] rgbRawBytes, int width, int height) - : this(rgbRawBytes, width, height, BitmapFormat.RGB24) - { - } - - /// - /// Initializes a new instance of the class. - /// It supports a byte array with 1 byte per pixel (Gray8). - /// That means the whole array consists of the luminance values (grayscale). - /// - /// The luminance array. - /// The width. - /// The height. - /// if set to true [is8 bit]. - [Obsolete("Use RGBLuminanceSource(luminanceArray, width, height, BitmapFormat.Gray8)")] - public RGBLuminanceSource(byte[] luminanceArray, int width, int height, bool is8Bit) - : this(luminanceArray, width, height, BitmapFormat.Gray8) - { - } - - /// - /// Initializes a new instance of the class. - /// It supports a byte array with 3 bytes per pixel (RGB24). - /// - /// The RGB raw bytes. - /// The width. - /// The height. - /// The bitmap format. - public RGBLuminanceSource(byte[] rgbRawBytes, int width, int height, BitmapFormat bitmapFormat) - : base(width, height) - { - CalculateLuminance(rgbRawBytes, bitmapFormat); - } - - /// - /// Should create a new luminance source with the right class type. - /// The method is used in methods crop and rotate. - /// - /// The new luminances. - /// The width. - /// The height. - /// - protected override LuminanceSource CreateLuminanceSource(byte[] newLuminances, int width, int height) - { - return new RGBLuminanceSource(width, height) { luminances = newLuminances }; - } - - private static BitmapFormat DetermineBitmapFormat(byte[] rgbRawBytes, int width, int height) - { - var square = width * height; - var byteperpixel = rgbRawBytes.Length / square; - - switch (byteperpixel) - { - case 1: - return BitmapFormat.Gray8; - case 2: - return BitmapFormat.RGB565; - case 3: - return BitmapFormat.RGB24; - case 4: - return BitmapFormat.RGB32; - default: - throw new ArgumentException("The bitmap format could not be determined. Please specify the correct value."); - } - } - - /// - /// calculates the luminance values for the given byte array and bitmap format - /// - /// - /// - protected void CalculateLuminance(byte[] rgbRawBytes, BitmapFormat bitmapFormat) - { - if (bitmapFormat == BitmapFormat.Unknown) - { - bitmapFormat = DetermineBitmapFormat(rgbRawBytes, Width, Height); - } - switch (bitmapFormat) - { - case BitmapFormat.Gray8: - Buffer.BlockCopy(rgbRawBytes, 0, luminances, 0, rgbRawBytes.Length < luminances.Length ? rgbRawBytes.Length : luminances.Length); - break; - case BitmapFormat.Gray16: - CalculateLuminanceGray16(rgbRawBytes); - break; - case BitmapFormat.RGB24: - CalculateLuminanceRGB24(rgbRawBytes); - break; - case BitmapFormat.BGR24: - CalculateLuminanceBGR24(rgbRawBytes); - break; - case BitmapFormat.RGB32: - CalculateLuminanceRGB32(rgbRawBytes); - break; - case BitmapFormat.BGR32: - CalculateLuminanceBGR32(rgbRawBytes); - break; - case BitmapFormat.RGBA32: - CalculateLuminanceRGBA32(rgbRawBytes); - break; - case BitmapFormat.ARGB32: - CalculateLuminanceARGB32(rgbRawBytes); - break; - case BitmapFormat.BGRA32: - CalculateLuminanceBGRA32(rgbRawBytes); - break; - case BitmapFormat.RGB565: - CalculateLuminanceRGB565(rgbRawBytes); - break; - case BitmapFormat.UYVY: - CalculateLuminanceUYVY(rgbRawBytes); - break; - case BitmapFormat.YUYV: - CalculateLuminanceYUYV(rgbRawBytes); - break; - default: - throw new ArgumentException("The bitmap format isn't supported.", bitmapFormat.ToString()); - } - } - - private void CalculateLuminanceRGB565(byte[] rgb565RawData) - { - var luminanceIndex = 0; - for (var index = 0; index < rgb565RawData.Length && luminanceIndex < luminances.Length; index += 2, luminanceIndex++) - { - var byte1 = rgb565RawData[index]; - var byte2 = rgb565RawData[index + 1]; - - var b5 = byte1 & 0x1F; - var g5 = (((byte1 & 0xE0) >> 5) | ((byte2 & 0x03) << 3)) & 0x1F; - var r5 = (byte2 >> 2) & 0x1F; - var r8 = (r5 * 527 + 23) >> 6; - var g8 = (g5 * 527 + 23) >> 6; - var b8 = (b5 * 527 + 23) >> 6; - - // cheap, not fully accurate conversion - //var pixel = (byte2 << 8) | byte1; - //b8 = (((pixel) & 0x001F) << 3); - //g8 = (((pixel) & 0x07E0) >> 2) & 0xFF; - //r8 = (((pixel) & 0xF800) >> 8); - - luminances[luminanceIndex] = (byte)((RChannelWeight * r8 + GChannelWeight * g8 + BChannelWeight * b8) >> ChannelWeight); - } - } - - private void CalculateLuminanceRGB24(byte[] rgbRawBytes) - { - for (int rgbIndex = 0, luminanceIndex = 0; rgbIndex < rgbRawBytes.Length && luminanceIndex < luminances.Length; luminanceIndex++) - { - // Calculate luminance cheaply, favoring green. - int r = rgbRawBytes[rgbIndex++]; - int g = rgbRawBytes[rgbIndex++]; - int b = rgbRawBytes[rgbIndex++]; - luminances[luminanceIndex] = (byte)((RChannelWeight * r + GChannelWeight * g + BChannelWeight * b) >> ChannelWeight); - } - } - - private void CalculateLuminanceBGR24(byte[] rgbRawBytes) - { - for (int rgbIndex = 0, luminanceIndex = 0; rgbIndex < rgbRawBytes.Length && luminanceIndex < luminances.Length; luminanceIndex++) - { - // Calculate luminance cheaply, favoring green. - int b = rgbRawBytes[rgbIndex++]; - int g = rgbRawBytes[rgbIndex++]; - int r = rgbRawBytes[rgbIndex++]; - luminances[luminanceIndex] = (byte)((RChannelWeight * r + GChannelWeight * g + BChannelWeight * b) >> ChannelWeight); - } - } - - private void CalculateLuminanceRGB32(byte[] rgbRawBytes) - { - for (int rgbIndex = 0, luminanceIndex = 0; rgbIndex < rgbRawBytes.Length && luminanceIndex < luminances.Length; luminanceIndex++) - { - // Calculate luminance cheaply, favoring green. - int r = rgbRawBytes[rgbIndex++]; - int g = rgbRawBytes[rgbIndex++]; - int b = rgbRawBytes[rgbIndex++]; - rgbIndex++; - luminances[luminanceIndex] = (byte)((RChannelWeight * r + GChannelWeight * g + BChannelWeight * b) >> ChannelWeight); - } - } - - private void CalculateLuminanceBGR32(byte[] rgbRawBytes) - { - for (int rgbIndex = 0, luminanceIndex = 0; rgbIndex < rgbRawBytes.Length && luminanceIndex < luminances.Length; luminanceIndex++) - { - // Calculate luminance cheaply, favoring green. - int b = rgbRawBytes[rgbIndex++]; - int g = rgbRawBytes[rgbIndex++]; - int r = rgbRawBytes[rgbIndex++]; - rgbIndex++; - luminances[luminanceIndex] = (byte)((RChannelWeight * r + GChannelWeight * g + BChannelWeight * b) >> ChannelWeight); - } - } - - private void CalculateLuminanceBGRA32(byte[] rgbRawBytes) - { - for (int rgbIndex = 0, luminanceIndex = 0; rgbIndex < rgbRawBytes.Length && luminanceIndex < luminances.Length; luminanceIndex++) - { - // Calculate luminance cheaply, favoring green. - var b = rgbRawBytes[rgbIndex++]; - var g = rgbRawBytes[rgbIndex++]; - var r = rgbRawBytes[rgbIndex++]; - var alpha = rgbRawBytes[rgbIndex++]; - var luminance = (byte)((RChannelWeight * r + GChannelWeight * g + BChannelWeight * b) >> ChannelWeight); - luminances[luminanceIndex] = (byte)(((luminance * alpha) >> 8) + (255 * (255 - alpha) >> 8)); - } - } - - private void CalculateLuminanceRGBA32(byte[] rgbRawBytes) - { - for (int rgbIndex = 0, luminanceIndex = 0; rgbIndex < rgbRawBytes.Length && luminanceIndex < luminances.Length; luminanceIndex++) - { - // Calculate luminance cheaply, favoring green. - var r = rgbRawBytes[rgbIndex++]; - var g = rgbRawBytes[rgbIndex++]; - var b = rgbRawBytes[rgbIndex++]; - var alpha = rgbRawBytes[rgbIndex++]; - var luminance = (byte)((RChannelWeight * r + GChannelWeight * g + BChannelWeight * b) >> ChannelWeight); - luminances[luminanceIndex] = (byte)(((luminance * alpha) >> 8) + (255 * (255 - alpha) >> 8)); - } - } - - private void CalculateLuminanceARGB32(byte[] rgbRawBytes) - { - for (int rgbIndex = 0, luminanceIndex = 0; rgbIndex < rgbRawBytes.Length && luminanceIndex < luminances.Length; luminanceIndex++) - { - // Calculate luminance cheaply, favoring green. - var alpha = rgbRawBytes[rgbIndex++]; - var r = rgbRawBytes[rgbIndex++]; - var g = rgbRawBytes[rgbIndex++]; - var b = rgbRawBytes[rgbIndex++]; - var luminance = (byte)((RChannelWeight * r + GChannelWeight * g + BChannelWeight * b) >> ChannelWeight); - luminances[luminanceIndex] = (byte)(((luminance * alpha) >> 8) + (255 * (255 - alpha) >> 8)); - } - } - - private void CalculateLuminanceUYVY(byte[] uyvyRawBytes) - { - // start by 1, jump over first U byte - for (int uyvyIndex = 1, luminanceIndex = 0; uyvyIndex < uyvyRawBytes.Length - 3 && luminanceIndex < luminances.Length;) - { - byte y1 = uyvyRawBytes[uyvyIndex]; - uyvyIndex += 2; // jump from 1 to 3 (from Y1 over to Y2) - byte y2 = uyvyRawBytes[uyvyIndex]; - uyvyIndex += 2; // jump from 3 to 5 - - luminances[luminanceIndex++] = y1; - luminances[luminanceIndex++] = y2; - } - } - - private void CalculateLuminanceYUYV(byte[] yuyvRawBytes) - { - // start by 0 not by 1 like UYUV - for (int yuyvIndex = 0, luminanceIndex = 0; yuyvIndex < yuyvRawBytes.Length - 3 && luminanceIndex < luminances.Length;) - { - byte y1 = yuyvRawBytes[yuyvIndex]; - yuyvIndex += 2; // jump from 0 to 2 (from Y1 over over to Y2) - byte y2 = yuyvRawBytes[yuyvIndex]; - yuyvIndex += 2; // jump from 2 to 4 - - luminances[luminanceIndex++] = y1; - luminances[luminanceIndex++] = y2; - } - } - - private void CalculateLuminanceGray16(byte[] gray16RawBytes) - { - for (int grayIndex = 0, luminanceIndex = 0; grayIndex < gray16RawBytes.Length && luminanceIndex < luminances.Length; grayIndex += 2, luminanceIndex++) - { - byte gray8 = gray16RawBytes[grayIndex]; - - luminances[luminanceIndex] = gray8; - } - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/RGBLuminanceSource.cs.meta b/Runtime/zxing.unity/Source/lib/RGBLuminanceSource.cs.meta deleted file mode 100644 index dda7ad2b4..000000000 --- a/Runtime/zxing.unity/Source/lib/RGBLuminanceSource.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4ebd373c7fed6441fb2d1a4ec0195cbc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/Result.cs b/Runtime/zxing.unity/Source/lib/Result.cs deleted file mode 100644 index a5c437784..000000000 --- a/Runtime/zxing.unity/Source/lib/Result.cs +++ /dev/null @@ -1,198 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Collections.Generic; - -namespace ZXing -{ - /// - /// Encapsulates the result of decoding a barcode within an image. - /// - public sealed class Result - { - /// raw text encoded by the barcode, if applicable, otherwise null - public String Text { get; private set; } - - /// raw bytes encoded by the barcode, if applicable, otherwise null - public byte[] RawBytes { get; private set; } - - /// - /// points related to the barcode in the image. These are typically points - /// identifying finder patterns or the corners of the barcode. The exact meaning is - /// specific to the type of barcode that was decoded. - /// - public ResultPoint[] ResultPoints { get; private set; } - - /// {@link BarcodeFormat} representing the format of the barcode that was decoded - public BarcodeFormat BarcodeFormat { get; private set; } - - /// - /// {@link Hashtable} mapping {@link ResultMetadataType} keys to values. May be - /// null. This contains optional metadata about what was detected about the barcode, - /// like orientation. - /// - public IDictionary ResultMetadata { get; private set; } - - /// - /// Gets the timestamp. - /// - public long Timestamp { get; private set; } - - /// - /// how many bits of are valid; typically 8 times its length - /// - public int NumBits { get; private set; } - - /// - /// Initializes a new instance of the class. - /// - /// The text. - /// The raw bytes. - /// The result points. - /// The format. - public Result(String text, - byte[] rawBytes, - ResultPoint[] resultPoints, - BarcodeFormat format) - : this(text, rawBytes, rawBytes == null ? 0 : 8 * rawBytes.Length, resultPoints, format, DateTime.Now.Ticks) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The text. - /// The raw bytes. - /// - /// The result points. - /// The format. - public Result(String text, - byte[] rawBytes, - int numBits, - ResultPoint[] resultPoints, - BarcodeFormat format) - : this(text, rawBytes, numBits, resultPoints, format, DateTime.Now.Ticks) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The text. - /// The raw bytes. - /// The result points. - /// The format. - /// The timestamp. - public Result(String text, byte[] rawBytes, ResultPoint[] resultPoints, BarcodeFormat format, long timestamp) - : this(text, rawBytes, rawBytes == null ? 0 : 8 * rawBytes.Length, resultPoints, format, timestamp) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The text. - /// The raw bytes. - /// - /// The result points. - /// The format. - /// The timestamp. - public Result(String text, byte[] rawBytes, int numBits, ResultPoint[] resultPoints, BarcodeFormat format, long timestamp) - { - if (text == null && rawBytes == null) - { - throw new ArgumentException("Text and bytes are null"); - } - Text = text; - RawBytes = rawBytes; - NumBits = numBits; - ResultPoints = resultPoints; - BarcodeFormat = format; - ResultMetadata = null; - Timestamp = timestamp; - } - - /// - /// Adds one metadata to the result - /// - /// The type. - /// The value. - public void putMetadata(ResultMetadataType type, Object value) - { - if (ResultMetadata == null) - { - ResultMetadata = new Dictionary(); - } - ResultMetadata[type] = value; - } - - /// - /// Adds a list of metadata to the result - /// - /// The metadata. - public void putAllMetadata(IDictionary metadata) - { - if (metadata != null) - { - if (ResultMetadata == null) - { - ResultMetadata = metadata; - } - else - { - foreach (var entry in metadata) - ResultMetadata[entry.Key] = entry.Value; - } - } - } - - /// - /// Adds the result points. - /// - /// The new points. - public void addResultPoints(ResultPoint[] newPoints) - { - var oldPoints = ResultPoints; - if (oldPoints == null) - { - ResultPoints = newPoints; - } - else if (newPoints != null && newPoints.Length > 0) - { - var allPoints = new ResultPoint[oldPoints.Length + newPoints.Length]; - Array.Copy(oldPoints, 0, allPoints, 0, oldPoints.Length); - Array.Copy(newPoints, 0, allPoints, oldPoints.Length, newPoints.Length); - ResultPoints = allPoints; - } - } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override String ToString() - { - if (Text == null) - { - return "[" + RawBytes.Length + " bytes]"; - } - return Text; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/Result.cs.meta b/Runtime/zxing.unity/Source/lib/Result.cs.meta deleted file mode 100644 index def682a90..000000000 --- a/Runtime/zxing.unity/Source/lib/Result.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f3e0d759a952a463f90fea2d70751107 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/ResultMetadataType.cs b/Runtime/zxing.unity/Source/lib/ResultMetadataType.cs deleted file mode 100644 index fda10c61b..000000000 --- a/Runtime/zxing.unity/Source/lib/ResultMetadataType.cs +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace ZXing -{ - /// - /// Represents some type of metadata about the result of the decoding that the decoder - /// wishes to communicate back to the caller. - /// - /// Sean Owen - public enum ResultMetadataType - { - /// - /// Unspecified, application-specific metadata. Maps to an unspecified {@link Object}. - /// - OTHER, - - /// - /// Denotes the likely approximate orientation of the barcode in the image. This value - /// is given as degrees rotated clockwise from the normal, upright orientation. - /// For example a 1D barcode which was found by reading top-to-bottom would be - /// said to have orientation "90". This key maps to an {@link Integer} whose - /// value is in the range [0,360). - /// - ORIENTATION, - - /// - ///

2D barcode formats typically encode text, but allow for a sort of 'byte mode' - /// which is sometimes used to encode binary data. While {@link Result} makes available - /// the complete raw bytes in the barcode for these formats, it does not offer the bytes - /// from the byte segments alone.

- ///

This maps to a {@link java.util.List} of byte arrays corresponding to the - /// raw bytes in the byte segments in the barcode, in order.

- ///
- BYTE_SEGMENTS, - - /// - /// Error correction level used, if applicable. The value type depends on the - /// format, but is typically a String. - /// - ERROR_CORRECTION_LEVEL, - - /// - /// For some periodicals, indicates the issue number as an {@link Integer}. - /// - ISSUE_NUMBER, - - /// - /// For some products, indicates the suggested retail price in the barcode as a - /// formatted {@link String}. - /// - SUGGESTED_PRICE, - - /// - /// For some products, the possible country of manufacture as a {@link String} denoting the - /// ISO country code. Some map to multiple possible countries, like "US/CA". - /// - POSSIBLE_COUNTRY, - - /// - /// For some products, the extension text - /// - UPC_EAN_EXTENSION, - - /// - /// If the code format supports structured append and - /// the current scanned code is part of one then the - /// sequence number is given with it. - /// - STRUCTURED_APPEND_SEQUENCE, - - /// - /// If the code format supports structured append and - /// the current scanned code is part of one then the - /// parity is given with it. - /// - STRUCTURED_APPEND_PARITY, - - /// - /// PDF417-specific metadata - /// - PDF417_EXTRA_METADATA, - - /// - /// Aztec-specific metadata - /// - AZTEC_EXTRA_METADATA, - - /// - /// Barcode Symbology Identifier. - /// Note: According to the GS1 specification the identifier may have to replace a leading FNC1/GS character when prepending to the barcode content. - /// - SYMBOLOGY_IDENTIFIER - } -} diff --git a/Runtime/zxing.unity/Source/lib/ResultMetadataType.cs.meta b/Runtime/zxing.unity/Source/lib/ResultMetadataType.cs.meta deleted file mode 100644 index 91a413a7d..000000000 --- a/Runtime/zxing.unity/Source/lib/ResultMetadataType.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 167d4702f66da4330a40bdfc83d9e19f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/ResultPoint.cs b/Runtime/zxing.unity/Source/lib/ResultPoint.cs deleted file mode 100644 index d2e1ea330..000000000 --- a/Runtime/zxing.unity/Source/lib/ResultPoint.cs +++ /dev/null @@ -1,196 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; - -using ZXing.Common.Detector; - -namespace ZXing -{ - /// - /// Encapsulates a point of interest in an image containing a barcode. Typically, this - /// would be the location of a finder pattern or the corner of the barcode, for example. - /// - /// Sean Owen - public class ResultPoint - { - private readonly float x; - private readonly float y; - private readonly byte[] bytesX; - private readonly byte[] bytesY; - private String toString; - - /// - /// Initializes a new instance of the class. - /// - public ResultPoint() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The x. - /// The y. - public ResultPoint(float x, float y) - { - this.x = x; - this.y = y; - // calculate only once for GetHashCode - bytesX = BitConverter.GetBytes(x); - bytesY = BitConverter.GetBytes(y); - } - - /// - /// Gets the X. - /// - virtual public float X - { - get - { - return x; - } - } - - /// - /// Gets the Y. - /// - virtual public float Y - { - get - { - return y; - } - } - - /// - /// Determines whether the specified is equal to this instance. - /// - /// The to compare with this instance. - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - public override bool Equals(Object other) - { - var otherPoint = other as ResultPoint; - if (otherPoint == null) - return false; - return x == otherPoint.x && y == otherPoint.y; - } - - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - /// - public override int GetHashCode() - { - return 31 * ((bytesX[0] << 24) + (bytesX[1] << 16) + (bytesX[2] << 8) + bytesX[3]) + - (bytesY[0] << 24) + (bytesY[1] << 16) + (bytesY[2] << 8) + bytesY[3]; - } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override String ToString() - { - if (toString == null) - { - var result = new System.Text.StringBuilder(25); - result.AppendFormat(System.Globalization.CultureInfo.CurrentUICulture, "({0}, {1})", x, y); - toString = result.ToString(); - } - return toString; - } - - /// - /// Orders an array of three ResultPoints in an order [A,B,C] such that AB is less than AC and - /// BC is less than AC and the angle between BC and BA is less than 180 degrees. - /// - /// array of three to order - public static void orderBestPatterns(ResultPoint[] patterns) - { - // Find distances between pattern centers - float zeroOneDistance = distance(patterns[0], patterns[1]); - float oneTwoDistance = distance(patterns[1], patterns[2]); - float zeroTwoDistance = distance(patterns[0], patterns[2]); - - ResultPoint pointA, pointB, pointC; - // Assume one closest to other two is B; A and C will just be guesses at first - if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) - { - pointB = patterns[0]; - pointA = patterns[1]; - pointC = patterns[2]; - } - else if (zeroTwoDistance >= oneTwoDistance && zeroTwoDistance >= zeroOneDistance) - { - pointB = patterns[1]; - pointA = patterns[0]; - pointC = patterns[2]; - } - else - { - pointB = patterns[2]; - pointA = patterns[0]; - pointC = patterns[1]; - } - - // Use cross product to figure out whether A and C are correct or flipped. - // This asks whether BC x BA has a positive z component, which is the arrangement - // we want for A, B, C. If it's negative, then we've got it flipped around and - // should swap A and C. - if (crossProductZ(pointA, pointB, pointC) < 0.0f) - { - ResultPoint temp = pointA; - pointA = pointC; - pointC = temp; - } - - patterns[0] = pointA; - patterns[1] = pointB; - patterns[2] = pointC; - } - - - /// - /// calculates the distance between two points - /// - /// first pattern - /// second pattern - /// - /// distance between two points - /// - public static float distance(ResultPoint pattern1, ResultPoint pattern2) - { - return MathUtils.distance(pattern1.x, pattern1.y, pattern2.x, pattern2.y); - } - - /// - /// Returns the z component of the cross product between vectors BC and BA. - /// - private static float crossProductZ(ResultPoint pointA, ResultPoint pointB, ResultPoint pointC) - { - float bX = pointB.x; - float bY = pointB.y; - return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX)); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/ResultPoint.cs.meta b/Runtime/zxing.unity/Source/lib/ResultPoint.cs.meta deleted file mode 100644 index 56851427c..000000000 --- a/Runtime/zxing.unity/Source/lib/ResultPoint.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 369e14706d58a4a289b917395c4dec8e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/ResultPointCallback.cs b/Runtime/zxing.unity/Source/lib/ResultPointCallback.cs deleted file mode 100644 index a70f34be2..000000000 --- a/Runtime/zxing.unity/Source/lib/ResultPointCallback.cs +++ /dev/null @@ -1,26 +0,0 @@ -/* -* Copyright 2009 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -namespace ZXing -{ - /// Callback which is invoked when a possible result point (significant - /// point in the barcode image such as a corner) is found. - /// - /// - /// - /// - public delegate void ResultPointCallback(ResultPoint point); -} diff --git a/Runtime/zxing.unity/Source/lib/ResultPointCallback.cs.meta b/Runtime/zxing.unity/Source/lib/ResultPointCallback.cs.meta deleted file mode 100644 index 8daee6400..000000000 --- a/Runtime/zxing.unity/Source/lib/ResultPointCallback.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fe019ba36a44f4ca39f35886e763e393 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/SupportClass.cs b/Runtime/zxing.unity/Source/lib/SupportClass.cs deleted file mode 100644 index 84b765406..000000000 --- a/Runtime/zxing.unity/Source/lib/SupportClass.cs +++ /dev/null @@ -1,185 +0,0 @@ -// -// In order to convert some functionality to Visual C#, the Java Language Conversion Assistant -// creates "support classes" that duplicate the original functionality. -// -// Support classes replicate the functionality of the original code, but in some cases they are -// substantially different architecturally. Although every effort is made to preserve the -// original architecture of the application in the converted project, the user should be aware that -// the primary goal of these support classes is to replicate functionality, and that at times -// the architecture of the resulting solution may differ somewhat. -// - -using System; -using System.Collections.Generic; -using System.Text; - -namespace ZXing -{ - /// - /// Contains conversion support elements such as classes, interfaces and static methods. - /// - public static class SupportClass - { - /*******************************/ - /// - /// Copies an array of chars obtained from a String into a specified array of chars - /// - /// The String to get the chars from - /// Position of the String to start getting the chars - /// Position of the String to end getting the chars - /// Array to return the chars - /// Position of the destination array of chars to start storing the chars - /// An array of chars - public static void GetCharsFromString(System.String sourceString, int sourceStart, int sourceEnd, char[] destinationArray, int destinationStart) - { - int sourceCounter = sourceStart; - int destinationCounter = destinationStart; - while (sourceCounter < sourceEnd) - { - destinationArray[destinationCounter] = (char)sourceString[sourceCounter]; - sourceCounter++; - destinationCounter++; - } - } - - /*******************************/ - /// - /// Sets the capacity for the specified List - /// - /// The List which capacity will be set - /// The new capacity value - public static void SetCapacity(System.Collections.Generic.IList vector, int newCapacity) where T : new() - { - while (newCapacity > vector.Count) - vector.Add(new T()); - while (newCapacity < vector.Count) - vector.RemoveAt(vector.Count - 1); - } - - /// - /// Converts a string-Collection to an array - /// - /// The strings. - /// - public static String[] toStringArray(ICollection strings) - { - var result = new String[strings.Count]; - strings.CopyTo(result, 0); - return result; - } - - /// - /// Joins all elements to one string. - /// - /// - /// The separator. - /// The values. - /// - public static string Join(string separator, IEnumerable values) - { - var builder = new StringBuilder(); - separator = separator ?? String.Empty; - if (values != null) - { - foreach (var value in values) - { - builder.Append(value); - builder.Append(separator); - } - if (builder.Length > 0) - builder.Length -= separator.Length; - } - - return builder.ToString(); - } - - /// - /// Fills the specified array. - /// (can't use extension method because of .Net 2.0 support) - /// - /// - /// The array. - /// The value. - public static void Fill(T[] array, T value) - { - for (int i = 0; i < array.Length; i++) - { - array[i] = value; - } - } - - /// - /// Fills the specified array. - /// (can't use extension method because of .Net 2.0 support) - /// - /// - /// The array. - /// The start index. - /// The end index. - /// The value. - public static void Fill(T[] array, int startIndex, int endIndex, T value) - { - for (int i = startIndex; i < endIndex; i++) - { - array[i] = value; - } - } - - /// - /// - /// - /// - /// - public static string ToBinaryString(int x) - { - char[] bits = new char[32]; - int i = 0; - - while (x != 0) - { - bits[i++] = (x & 1) == 1 ? '1' : '0'; - x >>= 1; - } - - Array.Reverse(bits, 0, i); - return new string(bits); - } - - /// - /// - /// - /// - /// - public static int bitCount(int n) - { - int ret = 0; - while (n != 0) - { - n &= (n - 1); - ret++; - } - return ret; - } - - /// - /// Savely gets the value of a decoding hint - /// if hints is null the default is returned - /// - /// - /// The hints. - /// Type of the hint. - /// The @default. - /// - public static T GetValue(IDictionary hints, DecodeHintType hintType, T @default) - { - // can't use extension method because of .Net 2.0 support - - if (hints == null) - return @default; - if (!hints.ContainsKey(hintType)) - return @default; - - return (T)hints[hintType]; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/SupportClass.cs.meta b/Runtime/zxing.unity/Source/lib/SupportClass.cs.meta deleted file mode 100644 index 1f68dd58c..000000000 --- a/Runtime/zxing.unity/Source/lib/SupportClass.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d944016f3514d4ac787b2fd2134c5541 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/Writer.cs b/Runtime/zxing.unity/Source/lib/Writer.cs deleted file mode 100644 index ebd5bbb9f..000000000 --- a/Runtime/zxing.unity/Source/lib/Writer.cs +++ /dev/null @@ -1,51 +0,0 @@ -/* -* Copyright 2008 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Collections.Generic; -using ZXing.Common; - -namespace ZXing -{ - /// The base class for all objects which encode/generate a barcode image. - /// - /// - /// dswitkin@google.com (Daniel Switkin) - /// - /// www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source - /// - public interface Writer - { - /// - /// Encode a barcode using the default settings. - /// - /// The contents to encode in the barcode - /// The barcode format to generate - /// The preferred width in pixels - /// The preferred height in pixels - /// The generated barcode as a Matrix of unsigned bytes (0 == black, 255 == white) - BitMatrix encode(System.String contents, BarcodeFormat format, int width, int height); - - /// - /// The contents to encode in the barcode - /// The barcode format to generate - /// The preferred width in pixels - /// The preferred height in pixels - /// Additional parameters to supply to the encoder - /// The generated barcode as a Matrix of unsigned bytes (0 == black, 255 == white) - BitMatrix encode(String contents, BarcodeFormat format, int width, int height, IDictionary hints); - } -} diff --git a/Runtime/zxing.unity/Source/lib/Writer.cs.meta b/Runtime/zxing.unity/Source/lib/Writer.cs.meta deleted file mode 100644 index 304e64768..000000000 --- a/Runtime/zxing.unity/Source/lib/Writer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 36f3ac35b93304084a563884c511494c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/WriterException.cs b/Runtime/zxing.unity/Source/lib/WriterException.cs deleted file mode 100644 index 90a8c3c93..000000000 --- a/Runtime/zxing.unity/Source/lib/WriterException.cs +++ /dev/null @@ -1,55 +0,0 @@ -/* -* Copyright 2008 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; - -namespace ZXing -{ - /// - /// A base class which covers the range of exceptions which may occur when encoding a barcode using - /// the Writer framework. - /// - /// dswitkin@google.com (Daniel Switkin) - [Serializable] - public sealed class WriterException : Exception - { - /// - /// Initializes a new instance of the class. - /// - public WriterException() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The message. - public WriterException(String message) - : base(message) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The message. - /// The inner exc. - public WriterException(String message, Exception innerExc) - : base(message, innerExc) - { - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/WriterException.cs.meta b/Runtime/zxing.unity/Source/lib/WriterException.cs.meta deleted file mode 100644 index 5c308e183..000000000 --- a/Runtime/zxing.unity/Source/lib/WriterException.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c95f9db4d15234ea9ae9df8f8a3b54ed -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common.meta b/Runtime/zxing.unity/Source/lib/common.meta deleted file mode 100644 index 26b5ce5ab..000000000 --- a/Runtime/zxing.unity/Source/lib/common.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: adc1518d890614b558e6ab7918c639e7 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/BigInteger.meta b/Runtime/zxing.unity/Source/lib/common/BigInteger.meta deleted file mode 100644 index bd0f2f75f..000000000 --- a/Runtime/zxing.unity/Source/lib/common/BigInteger.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6b9ed39ad661b4cf6acc19d103bb25cf -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/BigInteger/Base10BigInteger.cs b/Runtime/zxing.unity/Source/lib/common/BigInteger/Base10BigInteger.cs deleted file mode 100644 index 82301aa04..000000000 --- a/Runtime/zxing.unity/Source/lib/common/BigInteger/Base10BigInteger.cs +++ /dev/null @@ -1,766 +0,0 @@ -using System; -using System.Text; - - -namespace BigIntegerLibrary -{ - - /// - /// Integer inefficiently represented internally using base-10 digits, in order to allow a - /// visual representation as a base-10 string. Only for internal use. - /// - internal sealed class Base10BigInteger - { - - #region Fields - - /// - /// 10 numeration base for string representation, very inefficient for computations. - /// - private const long NumberBase = 10; - - /// - /// Maximum size for numbers is up to 10240 binary digits or approximately (safe to use) 3000 decimal digits. - /// The maximum size is, in fact, double the previously specified amount, in order to accommodate operations' - /// overflow. - /// - private const int MaxSize = BigInteger.MaxSize * 5; - - - /// Integer constants - private static readonly Base10BigInteger Zero = new Base10BigInteger(); - private static readonly Base10BigInteger One = new Base10BigInteger(1); - - - /// - /// The array of digits of the number. - /// - private DigitContainer digits; - - /// - /// The actual number of digits of the number. - /// - private int size; - - /// - /// The number sign. - /// - private Sign sign; - - - #endregion - - - #region Internal Fields - - - /// - /// Sets the number sign. - /// - internal Sign NumberSign - { - set { sign = value; } - } - - - #endregion - - - #region Constructors - - - /// - /// Default constructor, intializing the Base10BigInteger with zero. - /// - public Base10BigInteger() - { - digits = new DigitContainer(); - size = 1; - digits[size] = 0; - sign = Sign.Positive; - } - - /// - /// Constructor creating a new Base10BigInteger as a conversion of a regular base-10 long. - /// - /// The base-10 long to be converted - public Base10BigInteger(long n) - { - digits = new DigitContainer(); - sign = Sign.Positive; - - if (n == 0) - { - size = 1; - digits[size] = 0; - } - - else - { - if (n < 0) - { - n = -n; - sign = Sign.Negative; - } - - size = 0; - while (n > 0) - { - digits[size] = n % NumberBase; - n /= NumberBase; - size++; - } - } - } - - /// - /// Constructor creating a new Base10BigInteger as a copy of an existing Base10BigInteger. - /// - /// The Base10BigInteger to be copied - public Base10BigInteger(Base10BigInteger n) - { - digits = new DigitContainer(); - size = n.size; - sign = n.sign; - - for (int i = 0; i < n.size; i++) - digits[i] = n.digits[i]; - } - - - #endregion - - - #region Public Methods - - - /// - /// Determines whether the specified Base10BigInteger is equal to the current Base10BigInteger. - /// - /// The Base10BigInteger to compare with the current Base10BigInteger - /// True if the specified Base10BigInteger is equal to the current Base10BigInteger, - /// false otherwise - public bool Equals(Base10BigInteger other) - { - if (sign != other.sign) - return false; - if (size != other.size) - return false; - - for (int i = 0; i < size; i++) - if (digits[i] != other.digits[i]) - return false; - - return true; - } - - /// - /// Determines whether the specified System.Object is equal to the current Base10BigInteger. - /// - /// The System.Object to compare with the current Base10BigInteger - /// True if the specified System.Object is equal to the current Base10BigInteger, - /// false otherwise - public override bool Equals(object o) - { - if ((o is Base10BigInteger) == false) - return false; - - return Equals((Base10BigInteger)o); - } - - /// - /// Serves as a hash function for the Base10BigInteger type. - /// - /// A hash code for the current Base10BigInteger - public override int GetHashCode() - { - int result = 0; - - for (int i = 0; i < size; i++) - result = result + (int)digits[i]; - - return result; - } - - /// - /// String representation of the current Base10BigInteger, converted to its base-10 representation. - /// - /// The string representation of the current Base10BigInteger - public override string ToString() - { - StringBuilder output; - - if (sign == Sign.Negative) - { - output = new StringBuilder(size + 1); - output.Append('-'); - } - - else - output = new StringBuilder(size); - - for (int i = size - 1; i >= 0; i--) - output.Append(digits[i]); - - return output.ToString(); - } - - /// - /// Base10BigInteger inverse with respect to addition. - /// - /// The Base10BigInteger whose opposite is to be computed - /// The Base10BigInteger inverse with respect to addition - public static Base10BigInteger Opposite(Base10BigInteger n) - { - Base10BigInteger res = new Base10BigInteger(n); - - if (res != Zero) - { - if (res.sign == Sign.Positive) - res.sign = Sign.Negative; - else - res.sign = Sign.Positive; - } - - return res; - } - - /// - /// Greater test between two Base10BigIntegers. - /// - /// The 1st Base10BigInteger - /// The 2nd Base10BigInteger - /// True if a > b, false otherwise - public static bool Greater(Base10BigInteger a, Base10BigInteger b) - { - if (a.sign != b.sign) - { - if ((a.sign == Sign.Negative) && (b.sign == Sign.Positive)) - return false; - - if ((a.sign == Sign.Positive) && (b.sign == Sign.Negative)) - return true; - } - - else - { - if (a.sign == Sign.Positive) - { - if (a.size > b.size) - return true; - if (a.size < b.size) - return false; - for (int i = (a.size) - 1; i >= 0; i--) - if (a.digits[i] > b.digits[i]) - return true; - else if (a.digits[i] < b.digits[i]) - return false; - } - - else - { - if (a.size < b.size) - return true; - if (a.size > b.size) - return false; - for (int i = (a.size) - 1; i >= 0; i--) - if (a.digits[i] < b.digits[i]) - return true; - else if (a.digits[i] > b.digits[i]) - return false; - } - } - - return false; - } - - /// - /// Greater or equal test between two Base10BigIntegers. - /// - /// The 1st Base10BigInteger - /// The 2nd Base10BigInteger - /// True if a >= b, false otherwise - public static bool GreaterOrEqual(Base10BigInteger a, Base10BigInteger b) - { - return Greater(a, b) || Equals(a, b); - } - - /// - /// Smaller test between two Base10BigIntegers. - /// - /// The 1st Base10BigInteger - /// The 2nd Base10BigInteger - /// True if a < b, false otherwise - public static bool Smaller(Base10BigInteger a, Base10BigInteger b) - { - return !GreaterOrEqual(a, b); - } - - /// - /// Smaller or equal test between two Base10BigIntegers. - /// - /// The 1st Base10BigInteger - /// The 2nd Base10BigInteger - /// True if a <= b, false otherwise - public static bool SmallerOrEqual(Base10BigInteger a, Base10BigInteger b) - { - return !Greater(a, b); - } - - /// - /// Computes the absolute value of a Base10BigInteger. - /// - /// The Base10BigInteger whose absolute value is to be computed - /// The absolute value of the given BigInteger - public static Base10BigInteger Abs(Base10BigInteger n) - { - Base10BigInteger res = new Base10BigInteger(n); - res.sign = Sign.Positive; - return res; - } - - /// - /// Addition operation of two Base10BigIntegers. - /// - /// The 1st Base10BigInteger - /// The 2nd Base10BigInteger - /// The Base10BigInteger result of the addition - public static Base10BigInteger Addition(Base10BigInteger a, Base10BigInteger b) - { - Base10BigInteger res = null; - - if ((a.sign == Sign.Positive) && (b.sign == Sign.Positive)) - { - if (a >= b) - res = Add(a, b); - else - res = Add(b, a); - - res.sign = Sign.Positive; - } - - if ((a.sign == Sign.Negative) && (b.sign == Sign.Negative)) - { - if (a <= b) - res = Add(-a, -b); - else - res = Add(-b, -a); - - res.sign = Sign.Negative; - } - - if ((a.sign == Sign.Positive) && (b.sign == Sign.Negative)) - { - if (a >= (-b)) - { - res = Subtract(a, -b); - res.sign = Sign.Positive; - } - else - { - res = Subtract(-b, a); - res.sign = Sign.Negative; - } - } - - if ((a.sign == Sign.Negative) && (b.sign == Sign.Positive)) - { - if ((-a) <= b) - { - res = Subtract(b, -a); - res.sign = Sign.Positive; - } - else - { - res = Subtract(-a, b); - res.sign = Sign.Negative; - } - } - - return res; - } - - /// - /// Subtraction operation of two Base10BigIntegers. - /// - /// The 1st Base10BigInteger - /// The 2nd Base10BigInteger - /// The Base10BigInteger result of the subtraction - public static Base10BigInteger Subtraction(Base10BigInteger a, Base10BigInteger b) - { - Base10BigInteger res = null; - - if ((a.sign == Sign.Positive) && (b.sign == Sign.Positive)) - { - if (a >= b) - { - res = Subtract(a, b); - res.sign = Sign.Positive; - } - else - { - res = Subtract(b, a); - res.sign = Sign.Negative; - } - } - - if ((a.sign == Sign.Negative) && (b.sign == Sign.Negative)) - { - if (a <= b) - { - res = Subtract(-a, -b); - res.sign = Sign.Negative; - } - else - { - res = Subtract(-b, -a); - res.sign = Sign.Positive; - } - } - - if ((a.sign == Sign.Positive) && (b.sign == Sign.Negative)) - { - if (a >= (-b)) - res = Add(a, -b); - else - res = Add(-b, a); - - res.sign = Sign.Positive; - } - - if ((a.sign == Sign.Negative) && (b.sign == Sign.Positive)) - { - if ((-a) >= b) - res = Add(-a, b); - else - res = Add(b, -a); - - res.sign = Sign.Negative; - } - - return res; - } - - /// - /// Multiplication operation of two Base10BigIntegers. - /// - /// The 1st Base10BigInteger - /// The 2nd Base10BigInteger - /// The Base10BigInteger result of the multiplication - public static Base10BigInteger Multiplication(Base10BigInteger a, Base10BigInteger b) - { - if ((a == Zero) || (b == Zero)) - return Zero; - - Base10BigInteger res = Multiply(Abs(a), Abs(b)); - if (a.sign == b.sign) - res.sign = Sign.Positive; - else - res.sign = Sign.Negative; - - return res; - } - - - #endregion - - - #region Overloaded Operators - - - /// - /// Implicit conversion operator from long to Base10BigInteger. - /// - /// The long to be converted to a Base10BigInteger - /// The Base10BigInteger converted from the given long - public static implicit operator Base10BigInteger(long n) - { - return new Base10BigInteger(n); - } - - /// - /// Equality test between two Base10BigIntegers. - /// - /// The 1st Base10BigInteger - /// The 2nd Base10BigInteger - /// True if a == b, false otherwise - public static bool operator ==(Base10BigInteger a, Base10BigInteger b) - { - return Equals(a, b); - } - - /// - /// Inequality test between two Base10BigIntegers. - /// - /// The 1st Base10BigInteger - /// The 2nd Base10BigInteger - /// True if a != b, false otherwise - public static bool operator !=(Base10BigInteger a, Base10BigInteger b) - { - return !Equals(a, b); - } - - /// - /// Greater test between two Base10BigIntegers. - /// - /// The 1st Base10BigInteger - /// The 2nd Base10BigInteger - /// True if a > b, false otherwise - public static bool operator >(Base10BigInteger a, Base10BigInteger b) - { - return Greater(a, b); - } - - /// - /// Smaller test between two Base10BigIntegers. - /// - /// The 1st Base10BigInteger - /// The 2nd Base10BigInteger - /// True if a < b, false otherwise - public static bool operator <(Base10BigInteger a, Base10BigInteger b) - { - return Smaller(a, b); - } - - /// - /// Greater or equal test between two Base10BigIntegers. - /// - /// The 1st Base10BigInteger - /// The 2nd Base10BigInteger - /// True if a >= b, false otherwise - public static bool operator >=(Base10BigInteger a, Base10BigInteger b) - { - return GreaterOrEqual(a, b); - } - - /// - /// Smaller or equal test between two Base10BigIntegers. - /// - /// The 1st Base10BigInteger - /// The 2nd Base10BigInteger - /// True if a <= b, false otherwise - public static bool operator <=(Base10BigInteger a, Base10BigInteger b) - { - return SmallerOrEqual(a, b); - } - - /// - /// Base10BigInteger inverse with respect to addition. - /// - /// The Base10BigInteger whose opposite is to be computed - /// The Base10BigInteger inverse with respect to addition - public static Base10BigInteger operator -(Base10BigInteger n) - { - return Opposite(n); - } - - /// - /// Addition operation of two Base10BigIntegers. - /// - /// The 1st Base10BigInteger - /// The 2nd Base10BigInteger - /// The Base10BigInteger result of the addition - public static Base10BigInteger operator +(Base10BigInteger a, Base10BigInteger b) - { - return Addition(a, b); - } - - /// - /// Subtraction operation of two Base10BigIntegers. - /// - /// The 1st Base10BigInteger - /// The 2nd Base10BigInteger - /// The Base10BigInteger result of the subtraction - public static Base10BigInteger operator -(Base10BigInteger a, Base10BigInteger b) - { - return Subtraction(a, b); - } - - /// - /// Multiplication operation of two Base10BigIntegers. - /// - /// The 1st Base10BigInteger - /// The 2nd Base10BigInteger - /// The Base10BigInteger result of the multiplication - public static Base10BigInteger operator *(Base10BigInteger a, Base10BigInteger b) - { - return Multiplication(a, b); - } - - /// - /// Incremetation by one operation of a Base10BigInteger. - /// - /// The Base10BigInteger to be incremented by one - /// The Base10BigInteger result of incrementing by one - public static Base10BigInteger operator ++(Base10BigInteger n) - { - Base10BigInteger res = n + One; - return res; - } - - /// - /// Decremetation by one operation of a Base10BigInteger. - /// - /// The Base10BigInteger to be decremented by one - /// The Base10BigInteger result of decrementing by one - public static Base10BigInteger operator --(Base10BigInteger n) - { - Base10BigInteger res = n - One; - return res; - } - - - #endregion - - - #region Private Methods - - - /// - /// Adds two BigNumbers a and b, where a >= b, a, b non-negative. - /// - private static Base10BigInteger Add(Base10BigInteger a, Base10BigInteger b) - { - Base10BigInteger res = new Base10BigInteger(a); - long trans = 0, temp; - int i; - - for (i = 0; i < b.size; i++) - { - temp = res.digits[i] + b.digits[i] + trans; - res.digits[i] = temp % NumberBase; - trans = temp / NumberBase; - } - - for (i = b.size; ((i < a.size) && (trans > 0)); i++) - { - temp = res.digits[i] + trans; - res.digits[i] = temp % NumberBase; - trans = temp / NumberBase; - } - - if (trans > 0) - { - res.digits[res.size] = trans % NumberBase; - res.size++; - trans /= NumberBase; - } - - return res; - } - - /// - /// Subtracts the Base10BigInteger b from the Base10BigInteger a, where a >= b, a, b non-negative. - /// - private static Base10BigInteger Subtract(Base10BigInteger a, Base10BigInteger b) - { - Base10BigInteger res = new Base10BigInteger(a); - int i; - long temp, trans = 0; - bool reducible = true; - - for (i = 0; i < b.size; i++) - { - temp = res.digits[i] - b.digits[i] - trans; - if (temp < 0) - { - trans = 1; - temp += NumberBase; - } - else trans = 0; - res.digits[i] = temp; - } - - for (i = b.size; ((i < a.size) && (trans > 0)); i++) - { - temp = res.digits[i] - trans; - if (temp < 0) - { - trans = 1; - temp += NumberBase; - } - else trans = 0; - res.digits[i] = temp; - } - - while ((res.size - 1 > 0) && (reducible == true)) - { - if (res.digits[res.size - 1] == 0) - res.size--; - else reducible = false; - } - - return res; - } - - /// - /// Multiplies two Base10BigIntegers. - /// - private static Base10BigInteger Multiply(Base10BigInteger a, Base10BigInteger b) - { - int i, j; - long temp, trans = 0; - - Base10BigInteger res = new Base10BigInteger(); - res.size = a.size + b.size - 1; - for (i = 0; i < res.size + 1; i++) - res.digits[i] = 0; - - for (i = 0; i < a.size; i++) - if (a.digits[i] != 0) - for (j = 0; j < b.size; j++) - if (b.digits[j] != 0) - res.digits[i + j] += a.digits[i] * b.digits[j]; - - for (i = 0; i < res.size; i++) - { - temp = res.digits[i] + trans; - res.digits[i] = temp % NumberBase; - trans = temp / NumberBase; - } - - if (trans > 0) - { - res.digits[res.size] = trans % NumberBase; - res.size++; - trans /= NumberBase; - } - - return res; - } - - - #endregion - - - - private class DigitContainer - { - private readonly long[][] digits; - private const int ChunkSize = 32; - private const int ChunkSizeDivisionShift = 5; - private const int ChunkCount = Base10BigInteger.MaxSize >> ChunkSizeDivisionShift; - - public DigitContainer() - { - digits = new long[ChunkCount][]; - } - - public long this[int index] - { - get - { - var chunkIndex = index >> ChunkSizeDivisionShift; - var chunk = digits[chunkIndex]; - return chunk == null ? 0 : chunk[index % ChunkSize]; - } - set - { - var chunkIndex = index >> ChunkSizeDivisionShift; - var chunk = digits[chunkIndex] ?? (digits[chunkIndex] = new long[ChunkSize]); - chunk[index % ChunkSize] = value; - } - } - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/BigInteger/Base10BigInteger.cs.meta b/Runtime/zxing.unity/Source/lib/common/BigInteger/Base10BigInteger.cs.meta deleted file mode 100644 index fa18b7664..000000000 --- a/Runtime/zxing.unity/Source/lib/common/BigInteger/Base10BigInteger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a1264f47fbe6f4943a03c7d207b8dabe -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/BigInteger/BigInteger.cs b/Runtime/zxing.unity/Source/lib/common/BigInteger/BigInteger.cs deleted file mode 100644 index 6e79a2383..000000000 --- a/Runtime/zxing.unity/Source/lib/common/BigInteger/BigInteger.cs +++ /dev/null @@ -1,1377 +0,0 @@ -using System; -#if !(WindowsCE || PORTABLE || NETSTANDARD1_0) -using System.Runtime.Serialization; -#endif -#if !(WINDOWS_PHONE || SILVERLIGHT4 || SILVERLIGHT5 || WindowsCE || PORTABLE || NETSTANDARD1_0) -using System.Runtime.Serialization.Formatters; -#endif -#if !(PORTABLE || NETSTANDARD1_0) -using System.Security.Permissions; -#endif -using System.Text; - - -namespace BigIntegerLibrary -{ - - /// - /// .NET 2.0 class for handling of very large integers, up to 10240 binary digits or - /// approximately (safe to use) 3000 decimal digits. - /// -#if WindowsCE - [Serializable] - internal sealed class BigInteger : -#elif !(WINDOWS_PHONE || SILVERLIGHT4 || SILVERLIGHT5 || MONOTOUCH || MONOANDROID || PORTABLE || NETSTANDARD1_0) - [Serializable] - internal sealed class BigInteger : ISerializable, -#else - internal sealed class BigInteger : -#endif - IEquatable, IComparable, IComparable - { - - #region Fields - - /// - /// 2^16 numeration base for internal computations, in order to benefit the most from the - /// 32 bit (or 64 bit) integer processor registers. - /// - private const long NumberBase = 65536; - - /// - /// Maximum size for numbers is up to 10240 binary digits or approximately (safe to use) 3000 decimal digits. - /// The maximum size is, in fact, double the previously specified amount, in order to accommodate operations's - /// overflow. - /// - internal const int MaxSize = 2 * 640; - - /// - /// Ratio for the convertion of a BigInteger's size to a binary digits size. - /// - private const int RatioToBinaryDigits = 16; - - - /// Integer constants - public static readonly BigInteger Zero = new BigInteger(); - public static readonly BigInteger One = new BigInteger(1); - public static readonly BigInteger Two = new BigInteger(2); - public static readonly BigInteger Ten = new BigInteger(10); - - - /// - /// The array of digits of the number. - /// - private DigitContainer digits; - - /// - /// The actual number of digits of the number. - /// - private int size; - - /// - /// The number sign. - /// - private Sign sign; - - #endregion - - - #region Constructors - - - /// - /// Default constructor, intializing the BigInteger with zero. - /// - public BigInteger() - { - digits = new DigitContainer(); - size = 1; - digits[size] = 0; - sign = Sign.Positive; - } - - /// - /// Constructor creating a new BigInteger as a conversion of a regular base-10 long. - /// - /// The base-10 long to be converted - public BigInteger(long n) - { - digits = new DigitContainer(); - sign = Sign.Positive; - - if (n == 0) - { - size = 1; - digits[size] = 0; - } - - else - { - if (n < 0) - { - n = -n; - sign = Sign.Negative; - } - - size = 0; - while (n > 0) - { - digits[size] = n % NumberBase; - n /= NumberBase; - size++; - } - } - } - - /// - /// Constructor creating a new BigInteger as a copy of an existing BigInteger. - /// - /// The BigInteger to be copied - public BigInteger(BigInteger n) - { - digits = new DigitContainer(); - size = n.size; - sign = n.sign; - - for (int i = 0; i < n.size; i++) - digits[i] = n.digits[i]; - } - - /// - /// Constructor creating a BigInteger instance out of a base-10 formatted string. - /// - /// The base-10 formatted string. - /// Invalid numeric string exception - public BigInteger(string numberString) - { - BigInteger number = new BigInteger(); - Sign numberSign = Sign.Positive; - int i; - - for (i = 0; i < numberString.Length; i++) - { - if ((numberString[i] < '0') || (numberString[i] > '9')) - { - if ((i == 0) && (numberString[i] == '-')) - numberSign = Sign.Negative; - else - throw new BigIntegerException("Invalid numeric string.", null); - } - - else - number = number * Ten + long.Parse(numberString[i].ToString()); - } - - sign = numberSign; - - digits = new DigitContainer(); - size = number.size; - for (i = 0; i < number.size; i++) - digits[i] = number.digits[i]; - } - - /// - /// Constructor creating a positive BigInteger by extracting it's digits from a given byte array. - /// - /// The byte array - /// The byte array's content exceeds the maximum size of a BigInteger - /// exception - public BigInteger(byte[] byteArray) - { - if (byteArray.Length / 4 > MaxSize) - throw new BigIntegerException("The byte array's content exceeds the maximum size of a BigInteger.", null); - - digits = new DigitContainer(); - sign = Sign.Positive; - - for (int i = 0; i < byteArray.Length; i += 2) - { - int currentDigit = (int)byteArray[i]; - if (i + 1 < byteArray.Length) - { - currentDigit <<= 8; - currentDigit += (int)byteArray[i + 1]; - } - - digits[size++] = (long)currentDigit; - } - - bool reducible = true; - while ((size - 1 > 0) && (reducible == true)) - { - if (digits[size - 1] == 0) - size--; - else reducible = false; - } - } - -#if !(WINDOWS_PHONE || SILVERLIGHT4 || SILVERLIGHT5 || WindowsCE || PORTABLE || NETSTANDARD1_0) - /// - /// Constructor deserializing a BigInteger. - /// - private BigInteger(SerializationInfo info, StreamingContext context) - { - bool signValue = (bool)info.GetValue("sign", typeof(bool)); - if (signValue == true) - sign = Sign.Positive; - else - sign = Sign.Negative; - - size = (int)info.GetValue("size", typeof(short)); - digits = new DigitContainer(); - - int i; - for (i = 0; i < size; i++) - digits[i] = (long)(info.GetValue(string.Format("{0}{1}", "d_", i.ToString()), - typeof(ushort))); - } -#endif - - - #endregion - - - #region Public Methods - -#if !(WINDOWS_PHONE || SILVERLIGHT4 || SILVERLIGHT5 || WindowsCE || MONOTOUCH || MONOANDROID || PORTABLE || NETSTANDARD1_0) - /// - /// BigInteger serializing method, which should not be called manually. - /// - /// Serialization information object - /// Streaming context object - /// Public access - [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)] - public void GetObjectData(SerializationInfo info, StreamingContext context) - { - if (sign == Sign.Positive) - info.AddValue("sign", true); - else - info.AddValue("sign", false); - - info.AddValue("size", (short)size); - - for (int i = 0; i < size; i++) - info.AddValue(string.Format("{0}{1}", "d_", i.ToString()), (ushort)digits[i]); - } -#endif - - /// - /// Determines whether the specified BigInteger is equal to the current BigInteger. - /// - /// The BigInteger to compare with the current BigInteger - /// True if the specified BigInteger is equal to the current BigInteger, - /// false otherwise - public bool Equals(BigInteger other) - { - if (sign != other.sign) - return false; - if (size != other.size) - return false; - - for (int i = 0; i < size; i++) - if (digits[i] != other.digits[i]) - return false; - - return true; - } - - /// - /// Determines whether the specified System.Object is equal to the current BigInteger. - /// - /// The System.Object to compare with the current BigInteger - /// True if the specified System.Object is equal to the current BigInteger, - /// false otherwise - public override bool Equals(object o) - { - if ((o is BigInteger) == false) - return false; - - return Equals((BigInteger)o); - } - - /// - /// Serves as a hash function for the BigInteger type. - /// - /// A hash code for the current BigInteger - public override int GetHashCode() - { - int result = 0; - - for (int i = 0; i < size; i++) - result = result + (int)digits[i]; - - return result; - } - - /// - /// String representation of the current BigInteger, converted to its base-10 representation. - /// - /// The string representation of the current BigInteger - public override string ToString() - { - Base10BigInteger res = new Base10BigInteger(); - Base10BigInteger currentPower = new Base10BigInteger(1); - - for (int i = 0; i < size; i++) - { - res += digits[i] * currentPower; - currentPower *= NumberBase; - } - - res.NumberSign = sign; - - return res.ToString(); - } - - /// - /// Parses the number given by a string - /// - /// the number as a string - /// - public static BigInteger Parse(string str) - { - return new BigInteger(str); - } - - /// - /// Compares this instance to a specified BigInteger. - /// - /// The BigInteger to compare this instance with - /// -1 if the current instance is smaller than the given BigInteger, - /// 0 if the two are equal, 1 otherwise - public int CompareTo(BigInteger other) - { - if (Greater(this, other) == true) - return 1; - else if (Equals(this, other) == true) - return 0; - else - return -1; - } - - /// - /// Compares this instance to a specified object. - /// - /// The object to compare this instance with - /// -1 if the current instance is smaller than the given object, - /// 0 if the two are equal, 1 otherwise - /// obj is not a BigInteger exception - public int CompareTo(object obj) - { - if ((obj is BigInteger) == false) - throw new ArgumentException("obj is not a BigInteger."); - - return CompareTo((BigInteger)obj); - } - - /// - /// Returns a BigInteger's size in binary digits. - /// - /// The BigInteger whose size in binary digits is to be determined - /// The BigInteger's size in binary digits - public static int SizeInBinaryDigits(BigInteger n) - { - return n.size * RatioToBinaryDigits; - } - - /// - /// BigInteger inverse with respect to addition. - /// - /// The BigInteger whose opposite is to be computed - /// The BigInteger inverse with respect to addition - public static BigInteger Opposite(BigInteger n) - { - BigInteger res = new BigInteger(n); - - if (res != Zero) - { - if (res.sign == Sign.Positive) - res.sign = Sign.Negative; - else - res.sign = Sign.Positive; - } - - return res; - } - - /// - /// Greater test between two BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// True if a > b, false otherwise - public static bool Greater(BigInteger a, BigInteger b) - { - if (a.sign != b.sign) - { - if ((a.sign == Sign.Negative) && (b.sign == Sign.Positive)) - return false; - - if ((a.sign == Sign.Positive) && (b.sign == Sign.Negative)) - return true; - } - - else - { - if (a.sign == Sign.Positive) - { - if (a.size > b.size) - return true; - if (a.size < b.size) - return false; - for (int i = (a.size) - 1; i >= 0; i--) - if (a.digits[i] > b.digits[i]) - return true; - else if (a.digits[i] < b.digits[i]) - return false; - } - - else - { - if (a.size < b.size) - return true; - if (a.size > b.size) - return false; - for (int i = (a.size) - 1; i >= 0; i--) - if (a.digits[i] < b.digits[i]) - return true; - else if (a.digits[i] > b.digits[i]) - return false; - } - } - - return false; - } - - /// - /// Greater or equal test between two BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// True if a >= b, false otherwise - public static bool GreaterOrEqual(BigInteger a, BigInteger b) - { - return Greater(a, b) || Equals(a, b); - } - - /// - /// Smaller test between two BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// True if a < b, false otherwise - public static bool Smaller(BigInteger a, BigInteger b) - { - return !GreaterOrEqual(a, b); - } - - /// - /// Smaller or equal test between two BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// True if a <= b, false otherwise - public static bool SmallerOrEqual(BigInteger a, BigInteger b) - { - return !Greater(a, b); - } - - /// - /// Computes the absolute value of a BigInteger. - /// - /// The BigInteger whose absolute value is to be computed - /// The absolute value of the given BigInteger - public static BigInteger Abs(BigInteger n) - { - BigInteger res = new BigInteger(n); - res.sign = Sign.Positive; - return res; - } - - /// - /// Addition operation of two BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// The BigInteger result of the addition - public static BigInteger Addition(BigInteger a, BigInteger b) - { - BigInteger res = null; - - if ((a.sign == Sign.Positive) && (b.sign == Sign.Positive)) - { - if (a >= b) - res = Add(a, b); - else - res = Add(b, a); - - res.sign = Sign.Positive; - } - - if ((a.sign == Sign.Negative) && (b.sign == Sign.Negative)) - { - if (a <= b) - res = Add(-a, -b); - else - res = Add(-b, -a); - - res.sign = Sign.Negative; - } - - if ((a.sign == Sign.Positive) && (b.sign == Sign.Negative)) - { - if (a >= (-b)) - { - res = Subtract(a, -b); - res.sign = Sign.Positive; - } - else - { - res = Subtract(-b, a); - res.sign = Sign.Negative; - } - } - - if ((a.sign == Sign.Negative) && (b.sign == Sign.Positive)) - { - if ((-a) <= b) - { - res = Subtract(b, -a); - res.sign = Sign.Positive; - } - else - { - res = Subtract(-a, b); - res.sign = Sign.Negative; - } - } - - return res; - } - - /// - /// Subtraction operation of two BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// The BigInteger result of the subtraction - public static BigInteger Subtraction(BigInteger a, BigInteger b) - { - BigInteger res = null; - - if ((a.sign == Sign.Positive) && (b.sign == Sign.Positive)) - { - if (a >= b) - { - res = Subtract(a, b); - res.sign = Sign.Positive; - } - else - { - res = Subtract(b, a); - res.sign = Sign.Negative; - } - } - - if ((a.sign == Sign.Negative) && (b.sign == Sign.Negative)) - { - if (a <= b) - { - res = Subtract(-a, -b); - res.sign = Sign.Negative; - } - else - { - res = Subtract(-b, -a); - res.sign = Sign.Positive; - } - } - - if ((a.sign == Sign.Positive) && (b.sign == Sign.Negative)) - { - if (a >= (-b)) - res = Add(a, -b); - else - res = Add(-b, a); - - res.sign = Sign.Positive; - } - - if ((a.sign == Sign.Negative) && (b.sign == Sign.Positive)) - { - if ((-a) >= b) - res = Add(-a, b); - else - res = Add(b, -a); - - res.sign = Sign.Negative; - } - - return res; - } - - /// - /// Multiplication operation of two BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// The BigInteger result of the multiplication - public static BigInteger Multiplication(BigInteger a, BigInteger b) - { - if ((a == Zero) || (b == Zero)) - return Zero; - - BigInteger res = Multiply(Abs(a), Abs(b)); - if (a.sign == b.sign) - res.sign = Sign.Positive; - else - res.sign = Sign.Negative; - - return res; - } - - /// - /// Division operation of two BigIntegers a and b, b != 0. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// The BigInteger result of the division - /// Cannot divide by zero exception - public static BigInteger Division(BigInteger a, BigInteger b) - { - if (b == Zero) - throw new BigIntegerException("Cannot divide by zero.", new DivideByZeroException()); - - if (a == Zero) - return Zero; - if (Abs(a) < Abs(b)) - return Zero; - - BigInteger res; - if (b.size == 1) - res = DivideByOneDigitNumber(Abs(a), b.digits[0]); - else - res = DivideByBigNumber(Abs(a), Abs(b)); - - if (a.sign == b.sign) - res.sign = Sign.Positive; - else - res.sign = Sign.Negative; - - return res; - } - - /// - /// Modulo operation of two BigIntegers a and b, b != 0. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// The BigInteger result of the modulo - /// Cannot divide by zero exception - public static BigInteger Modulo(BigInteger a, BigInteger b) - { - if (b == Zero) - throw new BigIntegerException("Cannot divide by zero.", new DivideByZeroException()); - - BigInteger res; - - if (Abs(a) < Abs(b)) - { - res = new BigInteger(a); - return res; - } - else - res = a - ((a / b) * b); - - return res; - } - - /// - /// Returns the power of a BigInteger base to a non-negative exponent by using the - /// fast exponentiation algorithm (right to left binary exponentiation). - /// - /// The BigInteger base - /// The non-negative exponent - /// The power of the BigInteger base to the non-negative exponent - /// Cannot raise a BigInteger to a negative power exception. - public static BigInteger Power(BigInteger a, int exponent) - { - if (exponent < 0) - throw new BigIntegerException("Cannot raise an BigInteger to a negative power.", null); - - if (a == Zero) - return new BigInteger(); - - BigInteger res = new BigInteger(1); - if (exponent == 0) - return res; - - BigInteger factor = new BigInteger(a); - - while (exponent > 0) - { - if (exponent % 2 == 1) - res *= factor; - - exponent /= 2; - - if (exponent > 0) - factor *= factor; - } - - return res; - } - - /// - /// Integer square root of the given BigInteger using Newton's numeric method. - /// - /// The BigInteger whose integer square root is to be computed - /// The integer square root of the given BigInteger - /// Cannot compute the integer square root of a negative number exception - public static BigInteger IntegerSqrt(BigInteger n) - { - if (n.sign == Sign.Negative) - throw new BigIntegerException("Cannot compute the integer square root of a negative number.", - null); - - BigInteger oldValue = new BigInteger(0); - BigInteger newValue = new BigInteger(n); - - while (BigInteger.Abs(newValue - oldValue) >= One) - { - oldValue = newValue; - newValue = (oldValue + (n / oldValue)) / Two; - } - - return newValue; - } - - /// - /// Euclidean algorithm for computing the greatest common divisor of two non-negative BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// The greatest common divisor of the two given BigIntegers - /// Cannot compute the Gcd of negative BigIntegers exception - public static BigInteger Gcd(BigInteger a, BigInteger b) - { - if ((a.sign == Sign.Negative) || (b.sign == Sign.Negative)) - throw new BigIntegerException("Cannot compute the Gcd of negative BigIntegers.", null); - - BigInteger r; - - while (b > Zero) - { - r = a % b; - a = b; - b = r; - } - - return a; - } - - /// - /// Extended Euclidian Gcd algorithm, returning the greatest common divisor of two non-negative BigIntegers, - /// while also providing u and v, where: a*u + b*v = gcd(a,b). - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// Output BigInteger parameter, where a*u + b*v = gcd(a,b) - /// Output BigInteger parameter, where a*u + b*v = gcd(a,b) - /// The greatest common divisor of the two given BigIntegers - /// Cannot compute the Gcd of negative BigIntegers exception - public static BigInteger ExtendedEuclidGcd(BigInteger a, BigInteger b, - out BigInteger u, out BigInteger v) - { - if ((a.sign == Sign.Negative) || (b.sign == Sign.Negative)) - throw new BigIntegerException("Cannot compute the Gcd of negative BigIntegers.", null); - - BigInteger u1 = new BigInteger(); - BigInteger u2 = new BigInteger(1); - BigInteger v1 = new BigInteger(1); - BigInteger v2 = new BigInteger(); - BigInteger q, r; - - u = new BigInteger(); - v = new BigInteger(); - - while (b > Zero) - { - q = a / b; - r = a - q * b; - u = u2 - q * u1; - v = v2 - q * v1; - - a = new BigInteger(b); - b = new BigInteger(r); - u2 = new BigInteger(u1); - u1 = new BigInteger(u); - v2 = new BigInteger(v1); - v1 = new BigInteger(v); - u = new BigInteger(u2); - v = new BigInteger(v2); - } - - return a; - } - - /// - /// Computes the modular inverse of a given BigInteger. - /// - /// The non-zero BigInteger whose inverse is to be computed - /// The BigInteger modulus, which must be greater than or equal to 2 - /// The BigInteger equal to a^(-1) mod n - /// Invalid number or modulus exception - public static BigInteger ModularInverse(BigInteger a, BigInteger n) - { - if (n < Two) - throw new BigIntegerException("Cannot perform a modulo operation against a BigInteger less than 2.", null); - - if (Abs(a) >= n) - a %= n; - if (a.sign == Sign.Negative) - a += n; - - if (a == Zero) - throw new BigIntegerException("Cannot obtain the modular inverse of 0.", null); - - if (Gcd(a, n) != One) - throw new BigIntegerException("Cannot obtain the modular inverse of a number that is not coprime with the modulus.", null); - - BigInteger u, v; - ExtendedEuclidGcd(n, a, out u, out v); - if (v.sign == Sign.Negative) - v += n; - - return v; - } - - /// - /// Returns the power of a BigInteger to a non-negative exponent modulo n, by using the - /// fast exponentiation algorithm (right to left binary exponentiation) and modulo optimizations. - /// - /// The BigInteger base - /// The non-negative exponent - /// The modulus, which must be greater than or equal to 2 - /// The power of the BigInteger to the non-negative exponent - /// Invalid exponent or modulus exception - public static BigInteger ModularExponentiation(BigInteger a, BigInteger exponent, BigInteger n) - { - if (exponent < 0) - throw new BigIntegerException("Cannot raise a BigInteger to a negative power.", null); - - if (n < Two) - throw new BigIntegerException("Cannot perform a modulo operation against a BigInteger less than 2.", null); - - if (Abs(a) >= n) - a %= n; - if (a.sign == Sign.Negative) - a += n; - - if (a == Zero) - return new BigInteger(); - - BigInteger res = new BigInteger(1); - BigInteger factor = new BigInteger(a); - - while (exponent > Zero) - { - if (exponent % Two == One) - res = (res * factor) % n; - exponent /= Two; - factor = (factor * factor) % n; - } - - return res; - } - /* - /// - /// Tests whether the number provided is a prime. - /// - /// The number to be tested for primality - /// True, if the number given is a prime, false, otherwise - /// Primality is not defined for negative numbers exception - public static bool IsPrime(BigInteger number) - { - if (number.sign == Sign.Negative) - throw new BigIntegerException("Primality is not defined for negative numbers.", null); - - return PrimalityTester.IsPrime(number); - } - */ - - #endregion - - - #region Overloaded Operators - - - /// - /// Implicit conversion operator from long to BigInteger. - /// - /// The long to be converted to a BigInteger - /// The BigInteger converted from the given long - public static implicit operator BigInteger(long n) - { - return new BigInteger(n); - } - - /// - /// Implicit conversion operator from int to BigInteger. - /// - /// The int to be converted to a BigInteger - /// The BigInteger converted from the given int - public static implicit operator BigInteger(int n) - { - return new BigInteger(n); - } - - public static explicit operator int(BigInteger value) - { - long result = 0; - for (var index = value.size - 1; index >= 0; index--) - { - result *= NumberBase; - result += value.digits[index]; - } - - return value.sign == Sign.Negative ? -1 * (int)result : (int)result; - } - - public static explicit operator ulong(BigInteger value) - { - ulong result = 0; - for (var index = value.size - 1; index >= 0; index--) - { - result *= NumberBase; - result += (ulong)value.digits[index]; - } - - return result; - } - - /// - /// Equality test between two BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// True if a == b, false otherwise - public static bool operator ==(BigInteger a, BigInteger b) - { - return Equals(a, b); - } - - /// - /// Inequality test between two BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// True if a != b, false otherwise - public static bool operator !=(BigInteger a, BigInteger b) - { - return !Equals(a, b); - } - - /// - /// Greater test between two BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// True if a > b, false otherwise - public static bool operator >(BigInteger a, BigInteger b) - { - return Greater(a, b); - } - - /// - /// Smaller test between two BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// True if a < b, false otherwise - public static bool operator <(BigInteger a, BigInteger b) - { - return Smaller(a, b); - } - - /// - /// Greater or equal test between two BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// True if a >= b, false otherwise - public static bool operator >=(BigInteger a, BigInteger b) - { - return GreaterOrEqual(a, b); - } - - /// - /// Smaller or equal test between two BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// True if a <= b, false otherwise - public static bool operator <=(BigInteger a, BigInteger b) - { - return SmallerOrEqual(a, b); - } - - /// - /// BigInteger inverse with respect to addition. - /// - /// The BigInteger whose opposite is to be computed - /// The BigInteger inverse with respect to addition - public static BigInteger operator -(BigInteger n) - { - return Opposite(n); - } - - /// - /// Addition operation of two BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// The BigInteger result of the addition - public static BigInteger operator +(BigInteger a, BigInteger b) - { - return Addition(a, b); - } - - /// - /// Subtraction operation of two BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// The BigInteger result of the subtraction - public static BigInteger operator -(BigInteger a, BigInteger b) - { - return Subtraction(a, b); - } - - /// - /// Multiplication operation of two BigIntegers. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// The BigInteger result of the multiplication - public static BigInteger operator *(BigInteger a, BigInteger b) - { - return Multiplication(a, b); - } - - /// - /// Division operation of two BigIntegers a and b, b != 0. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// The BigInteger result of the division - /// Cannot divide by zero exception - public static BigInteger operator /(BigInteger a, BigInteger b) - { - return Division(a, b); - } - - /// - /// Modulo operation of two BigIntegers a and b, b != 0. - /// - /// The 1st BigInteger - /// The 2nd BigInteger - /// The BigInteger result of the modulo - /// Cannot divide by zero exception - public static BigInteger operator %(BigInteger a, BigInteger b) - { - return Modulo(a, b); - } - - /// - /// Incremetation by one operation of a BigInteger. - /// - /// The BigInteger to be incremented by one - /// The BigInteger result of incrementing by one - public static BigInteger operator ++(BigInteger n) - { - BigInteger res = n + One; - return res; - } - - /// - /// Decremetation by one operation of a BigInteger. - /// - /// The BigInteger to be decremented by one - /// The BigInteger result of decrementing by one - public static BigInteger operator --(BigInteger n) - { - BigInteger res = n - One; - return res; - } - - - #endregion - - - #region Private Methods - - - /// - /// Adds two BigNumbers a and b, where a >= b, a, b non-negative. - /// - private static BigInteger Add(BigInteger a, BigInteger b) - { - BigInteger res = new BigInteger(a); - long trans = 0, temp; - int i; - - for (i = 0; i < b.size; i++) - { - temp = res.digits[i] + b.digits[i] + trans; - res.digits[i] = temp % NumberBase; - trans = temp / NumberBase; - } - - for (i = b.size; ((i < a.size) && (trans > 0)); i++) - { - temp = res.digits[i] + trans; - res.digits[i] = temp % NumberBase; - trans = temp / NumberBase; - } - - if (trans > 0) - { - res.digits[res.size] = trans % NumberBase; - res.size++; - trans /= NumberBase; - } - - return res; - } - - /// - /// Subtracts the BigInteger b from the BigInteger a, where a >= b, a, b non-negative. - /// - private static BigInteger Subtract(BigInteger a, BigInteger b) - { - BigInteger res = new BigInteger(a); - int i; - long temp, trans = 0; - bool reducible = true; - - for (i = 0; i < b.size; i++) - { - temp = res.digits[i] - b.digits[i] - trans; - if (temp < 0) - { - trans = 1; - temp += NumberBase; - } - else trans = 0; - res.digits[i] = temp; - } - - for (i = b.size; ((i < a.size) && (trans > 0)); i++) - { - temp = res.digits[i] - trans; - if (temp < 0) - { - trans = 1; - temp += NumberBase; - } - else trans = 0; - res.digits[i] = temp; - } - - while ((res.size - 1 > 0) && (reducible == true)) - { - if (res.digits[res.size - 1] == 0) - res.size--; - else reducible = false; - } - - return res; - } - - /// - /// Multiplies two BigIntegers. - /// - private static BigInteger Multiply(BigInteger a, BigInteger b) - { - int i, j; - long temp, trans = 0; - - BigInteger res = new BigInteger(); - res.size = a.size + b.size - 1; - for (i = 0; i < res.size + 1; i++) - res.digits[i] = 0; - - for (i = 0; i < a.size; i++) - if (a.digits[i] != 0) - for (j = 0; j < b.size; j++) - if (b.digits[j] != 0) - res.digits[i + j] += a.digits[i] * b.digits[j]; - - for (i = 0; i < res.size; i++) - { - temp = res.digits[i] + trans; - res.digits[i] = temp % NumberBase; - trans = temp / NumberBase; - } - - if (trans > 0) - { - res.digits[res.size] = trans % NumberBase; - res.size++; - trans /= NumberBase; - } - - return res; - } - - /// - /// Divides a BigInteger by a one-digit int. - /// - private static BigInteger DivideByOneDigitNumber(BigInteger a, long b) - { - BigInteger res = new BigInteger(); - int i = a.size - 1; - long temp; - - res.size = a.size; - temp = a.digits[i]; - - while (i >= 0) - { - res.digits[i] = temp / b; - temp %= b; - i--; - - if (i >= 0) - temp = temp * NumberBase + a.digits[i]; - } - - if ((res.digits[res.size - 1] == 0) && (res.size != 1)) - res.size--; - - return res; - } - - /// - /// Divides a BigInteger by another BigInteger. - /// - private static BigInteger DivideByBigNumber(BigInteger a, BigInteger b) - { - int k, n = a.size, m = b.size; - long f, qt; - BigInteger d, dq, q, r; - - f = NumberBase / (b.digits[m - 1] + 1); - q = new BigInteger(); - r = a * f; - d = b * f; - - for (k = n - m; k >= 0; k--) - { - qt = Trial(r, d, k, m); - dq = d * qt; - - if (DivideByBigNumberSmaller(r, dq, k, m)) - { - qt--; - dq = d * qt; - } - - q.digits[k] = qt; - Difference(r, dq, k, m); - } - - q.size = n - m + 1; - if ((q.size != 1) && (q.digits[q.size - 1] == 0)) - q.size--; - - return q; - } - - /// - /// DivideByBigNumber auxiliary method. - /// - private static bool DivideByBigNumberSmaller(BigInteger r, BigInteger dq, int k, int m) - { - int i = m, j = 0; - - while (i != j) - { - if (r.digits[i + k] != dq.digits[i]) - j = i; - else i--; - } - - if (r.digits[i + k] < dq.digits[i]) - return true; - else - return false; - } - - /// - /// DivideByBigNumber auxilary method. - /// - private static void Difference(BigInteger r, BigInteger dq, int k, int m) - { - int i; - long borrow = 0, diff; - - for (i = 0; i <= m; i++) - { - diff = r.digits[i + k] - dq.digits[i] - borrow + NumberBase; - r.digits[i + k] = diff % NumberBase; - borrow = 1 - diff / NumberBase; - } - } - - /// - /// DivideByBigNumber auxilary method. - /// - private static long Trial(BigInteger r, BigInteger d, int k, int m) - { - int km = k + m; - - var r3 = (r.digits[km] * NumberBase + r.digits[km - 1]) * NumberBase + r.digits[km - 2]; - var d2 = d.digits[m - 1] * NumberBase + d.digits[m - 2]; - var res = r3 / d2; - if (res < NumberBase - 1) - return (int)res; - else - return NumberBase - 1; - } - - - #endregion - - - private class DigitContainer - { - private readonly long[][] digits; - private const int ChunkSize = 16; - private const int ChunkSizeDivisionShift = 4; - private const int ChunkCount = BigInteger.MaxSize >> ChunkSizeDivisionShift; - - public DigitContainer() - { - digits = new long[ChunkCount][]; - } - - public long this[int index] - { - get - { - var chunkIndex = index >> ChunkSizeDivisionShift; - var chunk = digits[chunkIndex]; - return chunk == null ? 0 : chunk[index % ChunkSize]; - } - set - { - var chunkIndex = index >> ChunkSizeDivisionShift; - var chunk = digits[chunkIndex] ?? (digits[chunkIndex] = new long[ChunkSize]); - chunk[index % ChunkSize] = value; - } - } - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/BigInteger/BigInteger.cs.meta b/Runtime/zxing.unity/Source/lib/common/BigInteger/BigInteger.cs.meta deleted file mode 100644 index f1250fc27..000000000 --- a/Runtime/zxing.unity/Source/lib/common/BigInteger/BigInteger.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c429b394c490142a0bf6e733d2859c3f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/BigInteger/BigIntegerException.cs b/Runtime/zxing.unity/Source/lib/common/BigInteger/BigIntegerException.cs deleted file mode 100644 index 1708ee91d..000000000 --- a/Runtime/zxing.unity/Source/lib/common/BigInteger/BigIntegerException.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using ZXing; - -namespace BigIntegerLibrary -{ - /// - /// BigInteger-related exception class. - /// - [Serializable] - public sealed class BigIntegerException : Exception - { - /// - /// BigIntegerException constructor. - /// - /// The exception message - /// The inner exception - public BigIntegerException(string message, Exception innerException) - : base(message, innerException) - { - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/BigInteger/BigIntegerException.cs.meta b/Runtime/zxing.unity/Source/lib/common/BigInteger/BigIntegerException.cs.meta deleted file mode 100644 index d40a6cb2b..000000000 --- a/Runtime/zxing.unity/Source/lib/common/BigInteger/BigIntegerException.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 45914b2fff13446bb9e6096251570780 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/BigInteger/Sign.cs b/Runtime/zxing.unity/Source/lib/common/BigInteger/Sign.cs deleted file mode 100644 index 2bedb9f14..000000000 --- a/Runtime/zxing.unity/Source/lib/common/BigInteger/Sign.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace BigIntegerLibrary -{ - - /// - /// The number's sign, where Positive also stands for the number zero. - /// - internal enum Sign { Positive, Negative }; - -} diff --git a/Runtime/zxing.unity/Source/lib/common/BigInteger/Sign.cs.meta b/Runtime/zxing.unity/Source/lib/common/BigInteger/Sign.cs.meta deleted file mode 100644 index c5ee257ba..000000000 --- a/Runtime/zxing.unity/Source/lib/common/BigInteger/Sign.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ceaad9cc25cca49a5ba7892caa68b74a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/BitArray.cs b/Runtime/zxing.unity/Source/lib/common/BitArray.cs deleted file mode 100644 index c5063dd40..000000000 --- a/Runtime/zxing.unity/Source/lib/common/BitArray.cs +++ /dev/null @@ -1,494 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; - -namespace ZXing.Common -{ - /// - /// A simple, fast array of bits, represented compactly by an array of ints internally. - /// - /// Sean Owen - public sealed class BitArray - { - private int[] bits; - private int size; - - /// - /// size of the array, number of elements - /// - public int Size - { - get - { - return size; - } - } - - /// - /// size of the array in bytes - /// - public int SizeInBytes - { - get - { - return (size + 7) >> 3; - } - } - - /// - /// index accessor - /// - /// - /// - public bool this[int i] - { - get - { - return (bits[i >> 5] & (1 << (i & 0x1F))) != 0; - } - set - { - if (value) - bits[i >> 5] |= 1 << (i & 0x1F); - } - } - - /// - /// default constructor - /// - public BitArray() - { - this.size = 0; - this.bits = new int[1]; - } - - /// - /// initializing constructor - /// - /// desired size of the array - public BitArray(int size) - { - if (size < 1) - { - throw new ArgumentException("size must be at least 1"); - } - this.size = size; - this.bits = makeArray(size); - } - - // For testing only - private BitArray(int[] bits, int size) - { - this.bits = bits; - this.size = size; - } - - private void ensureCapacity(int size) - { - if (size > bits.Length << 5) - { - int[] newBits = makeArray(size); - System.Array.Copy(bits, 0, newBits, 0, bits.Length); - bits = newBits; - } - } - - /// - /// Flips bit i. - /// - /// bit to set - /// - public void flip(int i) - { - bits[i >> 5] ^= 1 << (i & 0x1F); - } - - private static int numberOfTrailingZeros(int num) - { - var index = (-num & num) % 37; - if (index < 0) - index *= -1; - return _lookup[index]; - } - - private static readonly int[] _lookup = - { - 32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 24, 30, 28, 11, 0, 13, 4, 7, 17, - 0, 25, 22, 31, 15, 29, 10, 12, 6, 0, 21, 14, 9, 5, 20, 8, 19, 18 - }; - - /// - /// Gets the next set. - /// - /// first bit to check - /// index of first bit that is set, starting from the given index, or size if none are set - /// at or beyond this given index - public int getNextSet(int from) - { - if (from >= size) - { - return size; - } - int bitsOffset = from >> 5; - int currentBits = bits[bitsOffset]; - // mask off lesser bits first - currentBits &= -(1 << (from & 0x1F)); - while (currentBits == 0) - { - if (++bitsOffset == bits.Length) - { - return size; - } - currentBits = bits[bitsOffset]; - } - int result = (bitsOffset << 5) + numberOfTrailingZeros(currentBits); - return result > size ? size : result; - } - - /// - /// see getNextSet(int) - /// - /// index to start looking for unset bit - /// index of next unset bit, or if none are unset until the end - public int getNextUnset(int from) - { - if (from >= size) - { - return size; - } - int bitsOffset = from >> 5; - int currentBits = ~bits[bitsOffset]; - // mask off lesser bits first - currentBits &= -(1 << (from & 0x1F)); - while (currentBits == 0) - { - if (++bitsOffset == bits.Length) - { - return size; - } - currentBits = ~bits[bitsOffset]; - } - int result = (bitsOffset << 5) + numberOfTrailingZeros(currentBits); - return result > size ? size : result; - } - - /// Sets a block of 32 bits, starting at bit i. - /// - /// - /// first bit to set - /// - /// the new value of the next 32 bits. Note again that the least-significant bit - /// corresponds to bit i, the next-least-significant to i+1, and so on. - /// - public void setBulk(int i, int newBits) - { - bits[i >> 5] = newBits; - } - - /// - /// Sets a range of bits. - /// - /// start of range, inclusive. - /// end of range, exclusive - public void setRange(int start, int end) - { - if (end < start || start < 0 || end > size) - { - throw new ArgumentException(); - } - if (end == start) - { - return; - } - end--; // will be easier to treat this as the last actually set bit -- inclusive - int firstInt = start >> 5; - int lastInt = end >> 5; - for (int i = firstInt; i <= lastInt; i++) - { - int firstBit = i > firstInt ? 0 : start & 0x1F; - int lastBit = i < lastInt ? 31 : end & 0x1F; - // Ones from firstBit to lastBit, inclusive - int mask = (2 << lastBit) - (1 << firstBit); - bits[i] |= mask; - } - } - - /// Clears all bits (sets to false). - public void clear() - { - int max = bits.Length; - for (int i = 0; i < max; i++) - { - bits[i] = 0; - } - } - - /// Efficient method to check if a range of bits is set, or not set. - /// - /// - /// start of range, inclusive. - /// - /// end of range, exclusive - /// - /// if true, checks that bits in range are set, otherwise checks that they are not set - /// - /// true iff all bits are set or not set in range, according to value argument - /// if end is less than start or the range is not contained in the array - public bool isRange(int start, int end, bool value) - { - if (end < start || start < 0 || end > size) - { - throw new ArgumentException(); - } - if (end == start) - { - return true; // empty range matches - } - end--; // will be easier to treat this as the last actually set bit -- inclusive - int firstInt = start >> 5; - int lastInt = end >> 5; - for (int i = firstInt; i <= lastInt; i++) - { - int firstBit = i > firstInt ? 0 : start & 0x1F; - int lastBit = i < lastInt ? 31 : end & 0x1F; - // Ones from firstBit to lastBit, inclusive - int mask = (2 << lastBit) - (1 << firstBit); - - // Return false if we're looking for 1s and the masked bits[i] isn't all 1s (that is, - // equals the mask, or we're looking for 0s and the masked portion is not all 0s - if ((bits[i] & mask) != (value ? mask : 0)) - { - return false; - } - } - return true; - } - - /// - /// Appends the bit. - /// - /// The bit. - public void appendBit(bool bit) - { - ensureCapacity(size + 1); - if (bit) - { - bits[size >> 5] |= 1 << (size & 0x1F); - } - size++; - } - - /// underlying array of ints. The first element holds the first 32 bits, and the least - /// significant bit is bit 0. - /// - public int[] Array - { - get { return bits; } - } - - /// - /// Appends the least-significant bits, from value, in order from most-significant to - /// least-significant. For example, appending 6 bits from 0x000001E will append the bits - /// 0, 1, 1, 1, 1, 0 in that order. - /// - /// containing bits to append - /// bits from value to append - public void appendBits(int value, int numBits) - { - if (numBits < 0 || numBits > 32) - { - throw new ArgumentException("Num bits must be between 0 and 32"); - } - int nextSize = size; - ensureCapacity(nextSize + numBits); - for (int numBitsLeft = numBits - 1; numBitsLeft >= 0; numBitsLeft--) - { - if ((value & (1 << numBitsLeft)) != 0) - { - bits[nextSize / 32] |= 1 << (nextSize & 0x1F); - } - nextSize++; - } - size = nextSize; - } - - /// - /// adds the array to the end - /// - /// - public void appendBitArray(BitArray other) - { - int otherSize = other.size; - ensureCapacity(size + otherSize); - for (int i = 0; i < otherSize; i++) - { - appendBit(other[i]); - } - } - - /// - /// XOR operation - /// - /// - public void xor(BitArray other) - { - if (size != other.size) - { - throw new ArgumentException("Sizes don't match"); - } - for (int i = 0; i < bits.Length; i++) - { - // The last int could be incomplete (i.e. not have 32 bits in - // it) but there is no problem since 0 XOR 0 == 0. - bits[i] ^= other.bits[i]; - } - } - - /// - /// converts to bytes. - /// - /// first bit to start writing - /// array to write into. Bytes are written most-significant byte first. This is the opposite - /// of the internal representation, which is exposed by BitArray - /// position in array to start writing - /// how many bytes to write - public void toBytes(int bitOffset, byte[] array, int offset, int numBytes) - { - for (int i = 0; i < numBytes; i++) - { - int theByte = 0; - for (int j = 0; j < 8; j++) - { - if (this[bitOffset]) - { - theByte |= 1 << (7 - j); - } - bitOffset++; - } - array[offset + i] = (byte)theByte; - } - } - - /// Reverses all bits in the array. - public void reverse() - { - var newBits = new int[bits.Length]; - // reverse all int's first - var len = ((size - 1) >> 5); - var oldBitsLen = len + 1; - for (var i = 0; i < oldBitsLen; i++) - { - var x = (long)bits[i]; - x = ((x >> 1) & 0x55555555u) | ((x & 0x55555555u) << 1); - x = ((x >> 2) & 0x33333333u) | ((x & 0x33333333u) << 2); - x = ((x >> 4) & 0x0f0f0f0fu) | ((x & 0x0f0f0f0fu) << 4); - x = ((x >> 8) & 0x00ff00ffu) | ((x & 0x00ff00ffu) << 8); - x = ((x >> 16) & 0x0000ffffu) | ((x & 0x0000ffffu) << 16); - newBits[len - i] = (int)x; - } - // now correct the int's if the bit size isn't a multiple of 32 - if (size != oldBitsLen * 32) - { - var leftOffset = oldBitsLen * 32 - size; - var currentInt = ((int)((uint)newBits[0] >> leftOffset)); // (newBits[0] >>> leftOffset); - for (var i = 1; i < oldBitsLen; i++) - { - var nextInt = newBits[i]; - currentInt |= nextInt << (32 - leftOffset); - newBits[i - 1] = currentInt; - currentInt = ((int)((uint)nextInt >> leftOffset)); // (nextInt >>> leftOffset); - } - newBits[oldBitsLen - 1] = currentInt; - } - bits = newBits; - } - - private static int[] makeArray(int size) - { - return new int[(size + 31) >> 5]; - } - - /// - /// Determines whether the specified is equal to this instance. - /// - /// The to compare with this instance. - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - public override bool Equals(Object o) - { - var other = o as BitArray; - if (other == null) - return false; - if (size != other.size) - return false; - for (var index = 0; index < bits.Length; index++) - { - if (bits[index] != other.bits[index]) - return false; - } - return true; - } - - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - /// - public override int GetHashCode() - { - var hash = size; - foreach (var bit in bits) - { - hash = 31 * hash + bit.GetHashCode(); - } - return hash; - } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override String ToString() - { - var result = new System.Text.StringBuilder(size + (size / 8) + 1); - for (int i = 0; i < size; i++) - { - if ((i & 0x07) == 0) - { - result.Append(' '); - } - result.Append(this[i] ? 'X' : '.'); - } - return result.ToString(); - } - - /// - /// Erstellt ein neues Objekt, das eine Kopie der aktuellen Instanz darstellt. - /// - /// - /// Ein neues Objekt, das eine Kopie dieser Instanz darstellt. - /// - public object Clone() - { - return new BitArray((int[])bits.Clone(), size); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/BitArray.cs.meta b/Runtime/zxing.unity/Source/lib/common/BitArray.cs.meta deleted file mode 100644 index 226cac12f..000000000 --- a/Runtime/zxing.unity/Source/lib/common/BitArray.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 24f08c95d7c8d475b963a8cb9e793920 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/BitMatrix.cs b/Runtime/zxing.unity/Source/lib/common/BitMatrix.cs deleted file mode 100644 index 67a620764..000000000 --- a/Runtime/zxing.unity/Source/lib/common/BitMatrix.cs +++ /dev/null @@ -1,695 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Text; - -namespace ZXing.Common -{ - /// - ///

Represents a 2D matrix of bits. In function arguments below, and throughout the common - /// module, x is the column position, and y is the row position. The ordering is always x, y. - /// The origin is at the top-left.

- ///

Internally the bits are represented in a 1-D array of 32-bit ints. However, each row begins - /// with a new int. This is done intentionally so that we can copy out a row into a BitArray very - /// efficiently.

- ///

The ordering of bits is row-major. Within each int, the least significant bits are used first, - /// meaning they represent lower x values. This is compatible with BitArray's implementation.

- ///
- /// Sean Owen - /// dswitkin@google.com (Daniel Switkin) - public sealed partial class BitMatrix - { - private int width; - private int height; - private int rowSize; - private int[] bits; - - /// The width of the matrix - /// - public int Width - { - get { return width; } - } - - /// The height of the matrix - /// - public int Height - { - get { return height; } - } - - /// This method is for compatibility with older code. It's only logical to call if the matrix - /// is square, so I'm throwing if that's not the case. - /// - /// - /// row/column dimension of this matrix - /// - public int Dimension - { - get - { - if (width != height) - { - throw new ArgumentException("Can't call Dimension on a non-square matrix"); - } - return width; - } - - } - - /// - /// The rowsize of the matrix - /// - public int RowSize - { - get { return rowSize; } - } - - /// - /// Creates an empty square . - /// - /// height and width - public BitMatrix(int dimension) - : this(dimension, dimension) - { - } - - /// - /// Creates an empty square . - /// - /// bit matrix width - /// bit matrix height - public BitMatrix(int width, int height) - { - if (width < 1 || height < 1) - { - throw new System.ArgumentException("Both dimensions must be greater than 0"); - } - this.width = width; - this.height = height; - this.rowSize = (width + 31) >> 5; - bits = new int[rowSize * height]; - } - - internal BitMatrix(int width, int height, int rowSize, int[] bits) - { - this.width = width; - this.height = height; - this.rowSize = rowSize; - this.bits = bits; - } - - internal BitMatrix(int width, int height, int[] bits) - { - this.width = width; - this.height = height; - this.rowSize = (width + 31) >> 5; - this.bits = bits; - } - - /// - /// Interprets a 2D array of booleans as a , where "true" means an "on" bit. - /// - /// bits of the image, as a row-major 2D array. Elements are arrays representing rows - /// representation of image - public static BitMatrix parse(bool[][] image) - { - var height = image.Length; - var width = image[0].Length; - var bits = new BitMatrix(width, height); - for (var i = 0; i < height; i++) - { - var imageI = image[i]; - for (var j = 0; j < width; j++) - { - bits[j, i] = imageI[j]; - } - } - return bits; - } - - /// - /// parse the string representation to a bitmatrix - /// - /// - /// - /// - /// - public static BitMatrix parse(String stringRepresentation, String setString, String unsetString) - { - if (stringRepresentation == null) - { - throw new ArgumentException(); - } - - bool[] bits = new bool[stringRepresentation.Length]; - int bitsPos = 0; - int rowStartPos = 0; - int rowLength = -1; - int nRows = 0; - int pos = 0; - while (pos < stringRepresentation.Length) - { - if (stringRepresentation.Substring(pos, 1).Equals("\n") || - stringRepresentation.Substring(pos, 1).Equals("\r")) - { - if (bitsPos > rowStartPos) - { - if (rowLength == -1) - { - rowLength = bitsPos - rowStartPos; - } - else if (bitsPos - rowStartPos != rowLength) - { - throw new ArgumentException("row lengths do not match"); - } - rowStartPos = bitsPos; - nRows++; - } - pos++; - } - else if (stringRepresentation.Substring(pos, setString.Length).Equals(setString)) - { - pos += setString.Length; - bits[bitsPos] = true; - bitsPos++; - } - else if (stringRepresentation.Substring(pos, unsetString.Length).Equals(unsetString)) - { - pos += unsetString.Length; - bits[bitsPos] = false; - bitsPos++; - } - else - { - throw new ArgumentException("illegal character encountered: " + stringRepresentation.Substring(pos)); - } - } - - // no EOL at end? - if (bitsPos > rowStartPos) - { - if (rowLength == -1) - { - rowLength = bitsPos - rowStartPos; - } - else if (bitsPos - rowStartPos != rowLength) - { - throw new ArgumentException("row lengths do not match"); - } - nRows++; - } - - BitMatrix matrix = new BitMatrix(rowLength, nRows); - for (int i = 0; i < bitsPos; i++) - { - if (bits[i]) - { - matrix[i % rowLength, i / rowLength] = true; - } - } - return matrix; - } - - ///

Gets the requested bit, where true means black.

- /// - ///
- /// The horizontal component (i.e. which column) - /// - /// The vertical component (i.e. which row) - /// - /// value of given bit in matrix - /// - public bool this[int x, int y] - { - get - { - int offset = y * rowSize + (x >> 5); - return (((int)((uint)(bits[offset]) >> (x & 0x1f))) & 1) != 0; - } - set - { - if (value) - { - int offset = y * rowSize + (x >> 5); - bits[offset] |= 1 << (x & 0x1f); - } - else - { - int offset = y * rowSize + (x / 32); - bits[offset] &= ~(1 << (x & 0x1f)); - } - } - } - - /// - ///

Flips the given bit.

- ///
- /// The horizontal component (i.e. which column) - /// The vertical component (i.e. which row) - public void flip(int x, int y) - { - int offset = y * rowSize + (x >> 5); - bits[offset] ^= 1 << (x & 0x1f); - } - - /// - ///

Flips every bit in the matrix.

- ///
- public void flip() - { - int max = bits.Length; - for (int i = 0; i < max; i++) - { - bits[i] = ~bits[i]; - } - } - - /// - /// flip all of the bits, if shouldBeFlipped is true for the coordinates - /// - /// should return true, if the bit at a given coordinate should be flipped - public void flipWhen(Func shouldBeFlipped) - { - for (var y = 0; y < height; y++) - { - for (var x = 0; x < width; x++) - { - if (shouldBeFlipped(y, x)) - { - int offset = y * rowSize + (x >> 5); - bits[offset] ^= 1 << (x & 0x1f); - } - } - } - } - - /// - /// Exclusive-or (XOR): Flip the bit in this {@code BitMatrix} if the corresponding - /// mask bit is set. - /// - /// The mask. - public void xor(BitMatrix mask) - { - if (width != mask.Width || height != mask.Height || rowSize != mask.RowSize) - { - throw new ArgumentException("input matrix dimensions do not match"); - } - var rowArray = new BitArray(width); - for (int y = 0; y < height; y++) - { - int offset = y * rowSize; - int[] row = mask.getRow(y, rowArray).Array; - for (int x = 0; x < rowSize; x++) - { - bits[offset + x] ^= row[x]; - } - } - } - - /// Clears all bits (sets to false). - public void clear() - { - int max = bits.Length; - for (int i = 0; i < max; i++) - { - bits[i] = 0; - } - } - - ///

Sets a square region of the bit matrix to true.

- /// - ///
- /// The horizontal position to begin at (inclusive) - /// - /// The vertical position to begin at (inclusive) - /// - /// The width of the region - /// - /// The height of the region - /// - public void setRegion(int left, int top, int width, int height) - { - if (top < 0 || left < 0) - { - throw new System.ArgumentException("Left and top must be nonnegative"); - } - if (height < 1 || width < 1) - { - throw new System.ArgumentException("Height and width must be at least 1"); - } - int right = left + width; - int bottom = top + height; - if (bottom > this.height || right > this.width) - { - throw new System.ArgumentException("The region must fit inside the matrix"); - } - for (int y = top; y < bottom; y++) - { - int offset = y * rowSize; - for (int x = left; x < right; x++) - { - bits[offset + (x >> 5)] |= 1 << (x & 0x1f); - } - } - } - - /// A fast method to retrieve one row of data from the matrix as a BitArray. - /// - /// - /// The row to retrieve - /// - /// An optional caller-allocated BitArray, will be allocated if null or too small - /// - /// The resulting BitArray - this reference should always be used even when passing - /// your own row - /// - public BitArray getRow(int y, BitArray row) - { - if (row == null || row.Size < width) - { - row = new BitArray(width); - } - else - { - row.clear(); - } - int offset = y * rowSize; - for (int x = 0; x < rowSize; x++) - { - row.setBulk(x << 5, bits[offset + x]); - } - return row; - } - - /// - /// Sets the row. - /// - /// row to set - /// {@link BitArray} to copy from - public void setRow(int y, BitArray row) - { - Array.Copy(row.Array, 0, bits, y * rowSize, rowSize); - } - - /// - /// Modifies this {@code BitMatrix} to represent the same but rotated 180 degrees - /// - public void rotate180() - { - var topRow = new BitArray(width); - var bottomRow = new BitArray(width); - int maxHeight = (height + 1) / 2; - for (int i = 0; i < maxHeight; i++) - { - topRow = getRow(i, topRow); - int bottomRowIndex = height - 1 - i; - bottomRow = getRow(bottomRowIndex, bottomRow); - topRow.reverse(); - bottomRow.reverse(); - setRow(i, bottomRow); - setRow(bottomRowIndex, topRow); - } - } - - /// - /// Modifies this {@code BitMatrix} to represent the same but rotated 90 degrees counterclockwise - /// - public void rotate90() - { - int newWidth = height; - int newHeight = width; - int newRowSize = (newWidth + 31) / 32; - int[] newBits = new int[newRowSize * newHeight]; - - for (int y = 0; y < height; y++) - { - for (int x = 0; x < width; x++) - { - int offset = y * rowSize + (x / 32); - if ((((int)(((uint)bits[offset]) >> (x & 0x1f))) & 1) != 0) - { - int newOffset = (newHeight - 1 - x) * newRowSize + (y / 32); - newBits[newOffset] |= 1 << (y & 0x1f); - } - } - } - width = newWidth; - height = newHeight; - rowSize = newRowSize; - bits = newBits; - } - - /// - /// This is useful in detecting the enclosing rectangle of a 'pure' barcode. - /// - /// {left,top,width,height} enclosing rectangle of all 1 bits, or null if it is all white - public int[] getEnclosingRectangle() - { - int left = width; - int top = height; - int right = -1; - int bottom = -1; - - for (int y = 0; y < height; y++) - { - for (int x32 = 0; x32 < rowSize; x32++) - { - int theBits = bits[y * rowSize + x32]; - if (theBits != 0) - { - if (y < top) - { - top = y; - } - if (y > bottom) - { - bottom = y; - } - if (x32 * 32 < left) - { - int bit = 0; - while ((theBits << (31 - bit)) == 0) - { - bit++; - } - if ((x32 * 32 + bit) < left) - { - left = x32 * 32 + bit; - } - } - if (x32 * 32 + 31 > right) - { - int bit = 31; - while (((int)((uint)theBits >> bit)) == 0) // (theBits >>> bit) - { - bit--; - } - if ((x32 * 32 + bit) > right) - { - right = x32 * 32 + bit; - } - } - } - } - } - - if (right < left || bottom < top) - { - return null; - } - - return new[] { left, top, right - left + 1, bottom - top + 1 }; - } - - /// - /// This is useful in detecting a corner of a 'pure' barcode. - /// - /// {x,y} coordinate of top-left-most 1 bit, or null if it is all white - public int[] getTopLeftOnBit() - { - int bitsOffset = 0; - while (bitsOffset < bits.Length && bits[bitsOffset] == 0) - { - bitsOffset++; - } - if (bitsOffset == bits.Length) - { - return null; - } - int y = bitsOffset / rowSize; - int x = (bitsOffset % rowSize) << 5; - - int theBits = bits[bitsOffset]; - int bit = 0; - while ((theBits << (31 - bit)) == 0) - { - bit++; - } - x += bit; - return new[] { x, y }; - } - - /// - /// bottom right - /// - /// - public int[] getBottomRightOnBit() - { - int bitsOffset = bits.Length - 1; - while (bitsOffset >= 0 && bits[bitsOffset] == 0) - { - bitsOffset--; - } - if (bitsOffset < 0) - { - return null; - } - - int y = bitsOffset / rowSize; - int x = (bitsOffset % rowSize) << 5; - - int theBits = bits[bitsOffset]; - int bit = 31; - - while (((int)((uint)theBits >> bit)) == 0) // (theBits >>> bit) - { - bit--; - } - x += bit; - - return new int[] { x, y }; - } - - /// - /// Determines whether the specified is equal to this instance. - /// - /// The to compare with this instance. - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - public override bool Equals(object obj) - { - if (!(obj is BitMatrix)) - { - return false; - } - var other = (BitMatrix)obj; - if (width != other.width || height != other.height || - rowSize != other.rowSize || bits.Length != other.bits.Length) - { - return false; - } - for (int i = 0; i < bits.Length; i++) - { - if (bits[i] != other.bits[i]) - { - return false; - } - } - return true; - } - - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - /// - public override int GetHashCode() - { - int hash = width; - hash = 31 * hash + width; - hash = 31 * hash + height; - hash = 31 * hash + rowSize; - foreach (var bit in bits) - { - hash = 31 * hash + bit.GetHashCode(); - } - return hash; - } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override String ToString() - { -#if WindowsCE - return ToString("X ", " ", "\r\n"); -#else - return ToString("X ", " ", Environment.NewLine); -#endif - } - - /// - /// Returns a that represents this instance. - /// - /// The set string. - /// The unset string. - /// - /// A that represents this instance. - /// - public String ToString(String setString, String unsetString) - { -#if WindowsCE - return buildToString(setString, unsetString, "\r\n"); -#else - return buildToString(setString, unsetString, Environment.NewLine); -#endif - } - - /// - /// Returns a that represents this instance. - /// - /// The set string. - /// The unset string. - /// The line separator. - /// - /// A that represents this instance. - /// - public String ToString(String setString, String unsetString, String lineSeparator) - { - return buildToString(setString, unsetString, lineSeparator); - } - - private String buildToString(String setString, String unsetString, String lineSeparator) - { - var result = new StringBuilder(height * (width + 1)); - for (int y = 0; y < height; y++) - { - for (int x = 0; x < width; x++) - { - result.Append(this[x, y] ? setString : unsetString); - } - result.Append(lineSeparator); - } - return result.ToString(); - } - - /// - /// Clones this instance. - /// - /// - public object Clone() - { - return new BitMatrix(width, height, rowSize, (int[])bits.Clone()); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/BitMatrix.cs.meta b/Runtime/zxing.unity/Source/lib/common/BitMatrix.cs.meta deleted file mode 100644 index dcd89c468..000000000 --- a/Runtime/zxing.unity/Source/lib/common/BitMatrix.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a3995033140c6481bbe2d942adcf1429 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/BitSource.cs b/Runtime/zxing.unity/Source/lib/common/BitSource.cs deleted file mode 100644 index 356fb37fd..000000000 --- a/Runtime/zxing.unity/Source/lib/common/BitSource.cs +++ /dev/null @@ -1,124 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; - -namespace ZXing.Common -{ - ///

This provides an easy abstraction to read bits at a time from a sequence of bytes, where the - /// number of bits read is not often a multiple of 8.

- /// - ///

This class is thread-safe but not reentrant. Unless the caller modifies the bytes array - /// it passed in, in which case all bets are off.

- /// - ///
- /// Sean Owen - /// - /// www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source - /// - public sealed class BitSource - { - private readonly byte[] bytes; - private int byteOffset; - private int bitOffset; - - /// bytes from which this will read bits. Bits will be read from the first byte first. - /// Bits are read within a byte from most-significant to least-significant bit. - /// - public BitSource(byte[] bytes) - { - this.bytes = bytes; - } - - /// - /// index of next bit in current byte which would be read by the next call to {@link #readBits(int)}. - /// - public int BitOffset - { - get { return bitOffset; } - } - - /// - /// index of next byte in input byte array which would be read by the next call to {@link #readBits(int)}. - /// - public int ByteOffset - { - get { return byteOffset; } - } - - /// number of bits to read - /// - /// int representing the bits read. The bits will appear as the least-significant - /// bits of the int - /// - /// if numBits isn't in [1,32] or more than is available - public int readBits(int numBits) - { - if (numBits < 1 || numBits > 32 || numBits > available()) - { - throw new ArgumentException(numBits.ToString(), "numBits"); - } - - int result = 0; - - // First, read remainder from current byte - if (bitOffset > 0) - { - int bitsLeft = 8 - bitOffset; - int toRead = numBits < bitsLeft ? numBits : bitsLeft; - int bitsToNotRead = bitsLeft - toRead; - int mask = (0xFF >> (8 - toRead)) << bitsToNotRead; - result = (bytes[byteOffset] & mask) >> bitsToNotRead; - numBits -= toRead; - bitOffset += toRead; - if (bitOffset == 8) - { - bitOffset = 0; - byteOffset++; - } - } - - // Next read whole bytes - if (numBits > 0) - { - while (numBits >= 8) - { - result = (result << 8) | (bytes[byteOffset] & 0xFF); - byteOffset++; - numBits -= 8; - } - - // Finally read a partial byte - if (numBits > 0) - { - int bitsToNotRead = 8 - numBits; - int mask = (0xFF >> bitsToNotRead) << bitsToNotRead; - result = (result << numBits) | ((bytes[byteOffset] & mask) >> bitsToNotRead); - bitOffset += numBits; - } - } - - return result; - } - - /// number of bits that can be read successfully - /// - public int available() - { - return 8 * (bytes.Length - byteOffset) - bitOffset; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/BitSource.cs.meta b/Runtime/zxing.unity/Source/lib/common/BitSource.cs.meta deleted file mode 100644 index 0682272aa..000000000 --- a/Runtime/zxing.unity/Source/lib/common/BitSource.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 63784ef3ed9604cb4a98942df0c8ab3b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/CharacterSetECI.cs b/Runtime/zxing.unity/Source/lib/common/CharacterSetECI.cs deleted file mode 100644 index f4a0f53c8..000000000 --- a/Runtime/zxing.unity/Source/lib/common/CharacterSetECI.cs +++ /dev/null @@ -1,204 +0,0 @@ -/* -* Copyright 2008 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Collections.Generic; - -namespace ZXing.Common -{ - /// Encapsulates a Character Set ECI, according to "Extended Channel Interpretations" 5.3.1.1 - /// of ISO 18004. - /// - /// - /// Sean Owen - public sealed class CharacterSetECI : ECI - { - internal static readonly IDictionary VALUE_TO_ECI; - internal static readonly IDictionary NAME_TO_ECI; - - private readonly String encodingName; - /// - /// encoding name - /// - public String EncodingName - { - get - { - return encodingName; - } - - } - - static CharacterSetECI() - { - VALUE_TO_ECI = new Dictionary(); - NAME_TO_ECI = new Dictionary(); - // TODO figure out if these values are even right! - addCharacterSet(0, "CP437"); - addCharacterSet(1, new[] { "ISO-8859-1", "ISO8859_1" }); - addCharacterSet(2, "CP437"); - addCharacterSet(3, new[] { "ISO-8859-1", "ISO8859_1" }); - addCharacterSet(4, new[] { "ISO-8859-2", "ISO8859_2" }); - addCharacterSet(5, new[] { "ISO-8859-3", "ISO8859_3" }); - addCharacterSet(6, new[] { "ISO-8859-4", "ISO8859_4" }); - addCharacterSet(7, new[] { "ISO-8859-5", "ISO8859_5" }); - addCharacterSet(8, new[] { "ISO-8859-6", "ISO8859_6" }); - addCharacterSet(9, new[] { "ISO-8859-7", "ISO8859_7" }); - addCharacterSet(10, new[] { "ISO-8859-8", "ISO8859_8" }); - addCharacterSet(11, new[] { "ISO-8859-9", "ISO8859_9" }); - addCharacterSet(12, new[] { "ISO-8859-4", "ISO-8859-10", "ISO8859_10" }); // use ISO-8859-4 because ISO-8859-16 isn't supported - addCharacterSet(13, new[] { "ISO-8859-11", "ISO8859_11" }); - addCharacterSet(15, new[] { "ISO-8859-13", "ISO8859_13" }); - addCharacterSet(16, new[] { "ISO-8859-1", "ISO-8859-14", "ISO8859_14" }); // use ISO-8859-1 because ISO-8859-16 isn't supported - addCharacterSet(17, new[] { "ISO-8859-15", "ISO8859_15" }); - addCharacterSet(18, new[] { "ISO-8859-3", "ISO-8859-16", "ISO8859_16" }); // use ISO-8859-3 because ISO-8859-16 isn't supported - addCharacterSet(20, new[] { "SJIS", "SHIFT_JIS", "ISO-2022-JP" }); - addCharacterSet(21, new[] { "WINDOWS-1250", "CP1250" }); - addCharacterSet(22, new[] { "WINDOWS-1251", "CP1251" }); - addCharacterSet(23, new[] { "WINDOWS-1252", "CP1252" }); - addCharacterSet(24, new[] { "WINDOWS-1256", "CP1256" }); - addCharacterSet(25, new[] { "UTF-16BE", "UNICODEBIG" }); - addCharacterSet(26, new[] { "UTF-8", "UTF8" }); - addCharacterSet(27, "US-ASCII"); - addCharacterSet(170, "US-ASCII"); - addCharacterSet(28, "BIG5"); - addCharacterSet(29, new[] { "GB18030", "GB2312", "EUC_CN", "GBK" }); - addCharacterSet(30, new[] { "EUC-KR", "EUC_KR" }); - } - - private CharacterSetECI(int value, String encodingName) - : base(value) - { - this.encodingName = encodingName; - } - - private static void addCharacterSet(int value, String encodingName) - { - var eci = new CharacterSetECI(value, encodingName); - VALUE_TO_ECI[value] = eci; // can't use valueOf - NAME_TO_ECI[encodingName] = eci; - } - - private static void addCharacterSet(int value, String[] encodingNames) - { - var eci = new CharacterSetECI(value, encodingNames[0]); - VALUE_TO_ECI[value] = eci; // can't use valueOf - foreach (string t in encodingNames) - { - NAME_TO_ECI[t] = eci; - } - } - - /// character set ECI value - /// representing ECI of given value, or null if it is legal but unsupported - public static CharacterSetECI getCharacterSetECIByValue(int value) - { - if (!VALUE_TO_ECI.ContainsKey(value)) - return null; - return VALUE_TO_ECI[value]; - } - - /// character set ECI encoding name - /// representing ECI for character encoding, or null if it is legal but unsupported - public static CharacterSetECI getCharacterSetECIByName(String name) - { - var upperName = name.ToUpper(); - if (!NAME_TO_ECI.ContainsKey(upperName)) - return null; - return NAME_TO_ECI[upperName]; - } - - /// - /// - /// encoding - /// CharacterSetECI representing ECI for character encoding, or null if it is legal but unsupported - public static CharacterSetECI getCharacterSetECI(System.Text.Encoding encoding) - { - var name = encoding.WebName.ToUpper(); - if (!NAME_TO_ECI.ContainsKey(name)) - return null; - return NAME_TO_ECI[name]; - } - - /// - /// returns the encoding object fo the specified charset - /// - /// - /// - public static System.Text.Encoding getEncoding(CharacterSetECI charsetECI) - { - if (charsetECI == null) - return null; - return getEncoding(charsetECI.EncodingName); - } - - /// - /// returns the encoding object fo the specified name - /// - /// - /// - public static System.Text.Encoding getEncoding(string encodingName) - { - System.Text.Encoding encoding = null; - - try - { - encoding = System.Text.Encoding.GetEncoding(encodingName); - } -#if (WINDOWS_PHONE70 || WINDOWS_PHONE71 || SILVERLIGHT4 || SILVERLIGHT5 || NETFX_CORE || NETSTANDARD || MONOANDROID || MONOTOUCH) - catch (ArgumentException) - { - try - { - // Silverlight only supports a limited number of character sets, trying fallback to UTF-8 - encoding = System.Text.Encoding.GetEncoding(StringUtils.UTF8); - } - catch (Exception) - { - } - } -#endif -#if WindowsCE - catch (PlatformNotSupportedException) - { - try - { - // WindowsCE doesn't support all encodings. But it is device depended. - // So we try here the some different ones - if (encodingName == StringUtils.ISO88591) - { - encoding = System.Text.Encoding.GetEncoding(1252); - } - else - { - encoding = System.Text.Encoding.GetEncoding(StringUtils.UTF8); - } - } - catch (Exception) - { - } - } -#endif - catch (Exception) - { - return null; - } - - return encoding; - } - - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/CharacterSetECI.cs.meta b/Runtime/zxing.unity/Source/lib/common/CharacterSetECI.cs.meta deleted file mode 100644 index 043b47dfc..000000000 --- a/Runtime/zxing.unity/Source/lib/common/CharacterSetECI.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9f3f5f1efc4a8431bb3b83c06e74e746 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/DecoderResult.cs b/Runtime/zxing.unity/Source/lib/common/DecoderResult.cs deleted file mode 100644 index 97e1bf664..000000000 --- a/Runtime/zxing.unity/Source/lib/common/DecoderResult.cs +++ /dev/null @@ -1,194 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Collections.Generic; - -namespace ZXing.Common -{ - /// - /// Encapsulates the result of decoding a matrix of bits. This typically - /// applies to 2D barcode formats. For now it contains the raw bytes obtained, - /// as well as a String interpretation of those bytes, if applicable. - /// Sean Owen - /// - public sealed class DecoderResult - { - /// - /// raw bytes representing the result, or null if not applicable - /// - public byte[] RawBytes { get; private set; } - - /// - /// how many bits of are valid; typically 8 times its length - /// - public int NumBits { get; private set; } - - /// - /// text representation of the result - /// - public String Text { get; private set; } - - /// - /// list of byte segments in the result, or null if not applicable - /// - public IList ByteSegments { get; private set; } - - /// - /// name of error correction level used, or null if not applicable - /// - public String ECLevel { get; private set; } - - /// - /// gets a value which describe if structure append data was found - /// - public bool StructuredAppend - { - get { return StructuredAppendParity >= 0 && StructuredAppendSequenceNumber >= 0; } - } - - /// - /// number of errors corrected, or null if not applicable - /// - public int ErrorsCorrected { get; set; } - - /// - /// gives the sequence number of the result if structured append was found - /// - public int StructuredAppendSequenceNumber { get; private set; } - - /// - /// number of erasures corrected, or null if not applicable - /// - public int Erasures { get; set; } - - /// - /// gives the parity information if structured append was found - /// - public int StructuredAppendParity { get; private set; } - - /// - /// Miscellanseous data value for the various decoders - /// - /// The other. - public object Other { get; set; } - - /// - /// gives the symbology identifier - /// - public int SymbologyModifier { get; set; } - - /// - /// initializing constructor - /// - /// - /// - /// - /// - public DecoderResult(byte[] rawBytes, String text, List byteSegments, String ecLevel) - : this(rawBytes, text, byteSegments, ecLevel, -1, -1, 0) - { - - } - - /// - /// initializing constructor - /// - /// - /// - /// - /// - /// - public DecoderResult(byte[] rawBytes, String text, IList byteSegments, String ecLevel, int symbologyModifier) - : this(rawBytes, text, byteSegments, ecLevel, -1, -1, symbologyModifier) - { - } - /// - /// initializing constructor - /// - /// - /// - /// - /// - /// - /// - public DecoderResult(byte[] rawBytes, - String text, - List byteSegments, - String ecLevel, - int saSequence, - int saParity) - : this(rawBytes, text, byteSegments, ecLevel, saSequence, saParity, 0) - { - - } - - /// - /// initializing constructor - /// - /// - /// - /// - /// - /// - /// - /// - public DecoderResult(byte[] rawBytes, String text, IList byteSegments, String ecLevel, int saSequence, int saParity, int symbologyModifier) - : this(rawBytes, rawBytes == null ? 0 : 8 * rawBytes.Length, text, byteSegments, ecLevel, saSequence, saParity, symbologyModifier) - { - } - - /// - /// initializing constructor - /// - /// - /// - /// - /// - /// - public DecoderResult(byte[] rawBytes, int numBits, String text, IList byteSegments, String ecLevel) - : this(rawBytes, numBits, text, byteSegments, ecLevel, -1, -1, 0) - { - } - - /// - /// initializing constructor - /// - /// - /// - /// - /// - /// - /// - /// - /// - public DecoderResult(byte[] rawBytes, int numBits, String text, IList byteSegments, String ecLevel, int saSequence, int saParity, int symbologyModifier) - { - if (rawBytes == null && text == null) - { - throw new ArgumentException(); - } - RawBytes = rawBytes; - NumBits = numBits; - Text = text; - ByteSegments = byteSegments; - ECLevel = ecLevel; - StructuredAppendParity = saParity; - StructuredAppendSequenceNumber = saSequence; - SymbologyModifier = symbologyModifier; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/DecoderResult.cs.meta b/Runtime/zxing.unity/Source/lib/common/DecoderResult.cs.meta deleted file mode 100644 index 3a612ceb4..000000000 --- a/Runtime/zxing.unity/Source/lib/common/DecoderResult.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: aa8f8613a3c2949d6ad2104a5bc5b116 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/DecodingOptions.cs b/Runtime/zxing.unity/Source/lib/common/DecodingOptions.cs deleted file mode 100644 index aebfeeed7..000000000 --- a/Runtime/zxing.unity/Source/lib/common/DecodingOptions.cs +++ /dev/null @@ -1,545 +0,0 @@ -/* - * Copyright 2013 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel; - -namespace ZXing.Common -{ - /// - /// Defines an container for encoder options - /// - [Serializable] - public class DecodingOptions - { - /// - /// Gets the data container for all options - /// - public IDictionary Hints { get; private set; } - - /// - /// event is raised when a value is changed - /// - [field: NonSerialized] - public event Action ValueChanged; - - /// - /// Gets or sets a flag which cause a deeper look into the bitmap - /// - /// - /// true if [try harder]; otherwise, false. - /// - public bool TryHarder - { - get - { - if (Hints.ContainsKey(DecodeHintType.TRY_HARDER)) - return (bool)Hints[DecodeHintType.TRY_HARDER]; - return false; - } - set - { - if (value) - { - Hints[DecodeHintType.TRY_HARDER] = true; - } - else - { - if (Hints.ContainsKey(DecodeHintType.TRY_HARDER)) - { - Hints.Remove(DecodeHintType.TRY_HARDER); - } - } - } - } - - /// - /// Gets or sets a value indicating whether the image should be automatically inverted - /// if no result is found in the original image. - /// ATTENTION: Please be carefully because it slows down the decoding process if it is used - /// - /// - /// true if image should be inverted; otherwise, false. - /// - public bool TryInverted - { - get - { - if (Hints.ContainsKey(DecodeHintType.ALSO_INVERTED)) - return (bool)Hints[DecodeHintType.ALSO_INVERTED]; - return false; - } - set - { - if (value) - { - Hints[DecodeHintType.ALSO_INVERTED] = true; - } - else - { - if (Hints.ContainsKey(DecodeHintType.ALSO_INVERTED)) - { - Hints.Remove(DecodeHintType.ALSO_INVERTED); - } - } - } - } - - /// - /// Image is a pure monochrome image of a barcode. - /// - /// - /// true if monochrome image of a barcode; otherwise, false. - /// - public bool PureBarcode - { - get - { - if (Hints.ContainsKey(DecodeHintType.PURE_BARCODE)) - return (bool)Hints[DecodeHintType.PURE_BARCODE]; - return false; - } - set - { - if (value) - { - Hints[DecodeHintType.PURE_BARCODE] = true; - } - else - { - if (Hints.ContainsKey(DecodeHintType.PURE_BARCODE)) - { - Hints.Remove(DecodeHintType.PURE_BARCODE); - } - } - } - } - - /// - /// Specifies what character encoding to use when decoding, where applicable (type String) - /// - /// - /// The character set. - /// - public string CharacterSet - { - get - { - if (Hints.ContainsKey(DecodeHintType.CHARACTER_SET)) - return (string)Hints[DecodeHintType.CHARACTER_SET]; - return null; - } - set - { - if (value != null) - { - Hints[DecodeHintType.CHARACTER_SET] = value; - } - else - { - if (Hints.ContainsKey(DecodeHintType.CHARACTER_SET)) - { - Hints.Remove(DecodeHintType.CHARACTER_SET); - } - } - } - } - - /// - /// Image is known to be of one of a few possible formats. - /// Maps to a {@link java.util.List} of {@link BarcodeFormat}s. - /// - /// - /// The possible formats. - /// - public IList PossibleFormats - { - get - { - if (Hints.ContainsKey(DecodeHintType.POSSIBLE_FORMATS)) - return (IList)Hints[DecodeHintType.POSSIBLE_FORMATS]; - return null; - } - set - { - if (value != null) - { - Hints[DecodeHintType.POSSIBLE_FORMATS] = value; - } - else - { - if (Hints.ContainsKey(DecodeHintType.POSSIBLE_FORMATS)) - { - Hints.Remove(DecodeHintType.POSSIBLE_FORMATS); - } - } - } - } - - /// - /// if Code39 could be detected try to use extended mode for full ASCII character set - /// - public bool UseCode39ExtendedMode - { - get - { - if (Hints.ContainsKey(DecodeHintType.USE_CODE_39_EXTENDED_MODE)) - return (bool)Hints[DecodeHintType.USE_CODE_39_EXTENDED_MODE]; - return false; - } - set - { - // don't remove the hint. Otherwise it would not be possible to override the default behaviour of the Code39 reader - Hints[DecodeHintType.USE_CODE_39_EXTENDED_MODE] = value; - } - } - - /// - /// Don't fail if a Code39 is detected but can't be decoded in extended mode. - /// Return the raw Code39 result instead. Maps to . - /// - public bool UseCode39RelaxedExtendedMode - { - get - { - if (Hints.ContainsKey(DecodeHintType.RELAXED_CODE_39_EXTENDED_MODE)) - return (bool)Hints[DecodeHintType.RELAXED_CODE_39_EXTENDED_MODE]; - return false; - } - set - { - if (value) - { - Hints[DecodeHintType.RELAXED_CODE_39_EXTENDED_MODE] = true; - } - else - { - if (Hints.ContainsKey(DecodeHintType.RELAXED_CODE_39_EXTENDED_MODE)) - { - Hints.Remove(DecodeHintType.RELAXED_CODE_39_EXTENDED_MODE); - } - } - } - } - - /// - /// Assume Code 39 codes employ a check digit. Maps to . - /// - /// - /// true if it should assume a Code 39 check digit; otherwise, false. - /// - public bool AssumeCode39CheckDigit - { - get - { - if (Hints.ContainsKey(DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT)) - return (bool)Hints[DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT]; - return false; - } - set - { - if (value) - { - Hints[DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT] = true; - } - else - { - if (Hints.ContainsKey(DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT)) - { - Hints.Remove(DecodeHintType.ASSUME_CODE_39_CHECK_DIGIT); - } - } - } - } - - /// - /// If true, return the start and end digits in a Codabar barcode instead of stripping them. They - /// are alpha, whereas the rest are numeric. By default, they are stripped, but this causes them - /// to not be. Doesn't matter what it maps to; use . - /// - public bool ReturnCodabarStartEnd - { - get - { - if (Hints.ContainsKey(DecodeHintType.RETURN_CODABAR_START_END)) - return (bool)Hints[DecodeHintType.RETURN_CODABAR_START_END]; - return false; - } - set - { - if (value) - { - Hints[DecodeHintType.RETURN_CODABAR_START_END] = true; - } - else - { - if (Hints.ContainsKey(DecodeHintType.RETURN_CODABAR_START_END)) - { - Hints.Remove(DecodeHintType.RETURN_CODABAR_START_END); - } - } - } - } - - /// - /// Assume the barcode is being processed as a GS1 barcode, and modify behavior as needed. - /// For example this affects FNC1 handling for Code 128 (aka GS1-128). - /// - /// - /// true if it should assume GS1; otherwise, false. - /// - public bool AssumeGS1 - { - get - { - if (Hints.ContainsKey(DecodeHintType.ASSUME_GS1)) - return (bool)Hints[DecodeHintType.ASSUME_GS1]; - return false; - } - set - { - if (value) - { - Hints[DecodeHintType.ASSUME_GS1] = true; - } - else - { - if (Hints.ContainsKey(DecodeHintType.ASSUME_GS1)) - { - Hints.Remove(DecodeHintType.ASSUME_GS1); - } - } - } - } - - /// - /// Assume MSI codes employ a check digit. Maps to . - /// - /// - /// true if it should assume a MSI check digit; otherwise, false. - /// - public bool AssumeMSICheckDigit - { - get - { - if (Hints.ContainsKey(DecodeHintType.ASSUME_MSI_CHECK_DIGIT)) - return (bool)Hints[DecodeHintType.ASSUME_MSI_CHECK_DIGIT]; - return false; - } - set - { - if (value) - { - Hints[DecodeHintType.ASSUME_MSI_CHECK_DIGIT] = true; - } - else - { - if (Hints.ContainsKey(DecodeHintType.ASSUME_MSI_CHECK_DIGIT)) - { - Hints.Remove(DecodeHintType.ASSUME_MSI_CHECK_DIGIT); - } - } - } - } - - /// - /// Allowed lengths of encoded data -- reject anything else. Maps to an int[]. - /// - public int[] AllowedLengths - { - get - { - if (Hints.ContainsKey(DecodeHintType.ALLOWED_LENGTHS)) - return (int[])Hints[DecodeHintType.ALLOWED_LENGTHS]; - return null; - } - set - { - if (value != null && value.Length > 0) - { - Hints[DecodeHintType.ALLOWED_LENGTHS] = value; - } - else - { - if (Hints.ContainsKey(DecodeHintType.ALLOWED_LENGTHS)) - { - Hints.Remove(DecodeHintType.ALLOWED_LENGTHS); - } - } - } - } - - /// - /// Allowed extension lengths for EAN or UPC barcodes. Other formats will ignore this. - /// Maps to an int[] of the allowed extension lengths, for example [2], [5], or [2, 5]. - /// If it is optional to have an extension, do not set this hint. If this is set, - /// and a UPC or EAN barcode is found but an extension is not, then no result will be returned - /// at all. - /// - public int[] AllowedEANExtensions - { - get - { - if (Hints.ContainsKey(DecodeHintType.ALLOWED_EAN_EXTENSIONS)) - return (int[])Hints[DecodeHintType.ALLOWED_EAN_EXTENSIONS]; - return null; - } - set - { - if (value != null && value.Length > 0) - { - Hints[DecodeHintType.ALLOWED_EAN_EXTENSIONS] = value; - } - else - { - if (Hints.ContainsKey(DecodeHintType.ALLOWED_EAN_EXTENSIONS)) - { - Hints.Remove(DecodeHintType.ALLOWED_EAN_EXTENSIONS); - } - } - } - } - - /// - /// Initializes a new instance of the class. - /// - public DecodingOptions() - { - var hints = new ChangeNotifyDictionary(); - Hints = hints; - UseCode39ExtendedMode = true; - UseCode39RelaxedExtendedMode = true; - hints.ValueChanged += (o, args) => { if (ValueChanged != null) ValueChanged(this, EventArgs.Empty); }; - } - - [Serializable] - private class ChangeNotifyDictionary : IDictionary - { - private readonly IDictionary values; - - [field: NonSerialized] - public event Action ValueChanged; - - public ChangeNotifyDictionary() - { - values = new Dictionary(); - } - - private void OnValueChanged() - { - if (ValueChanged != null) - ValueChanged(this, EventArgs.Empty); - } - - public void Add(TKey key, TValue value) - { - values.Add(key, value); - OnValueChanged(); - } - - public bool ContainsKey(TKey key) - { - return values.ContainsKey(key); - } - - public ICollection Keys - { - get { return values.Keys; } - } - - public bool Remove(TKey key) - { - var result = values.Remove(key); - OnValueChanged(); - return result; - } - - public bool TryGetValue(TKey key, out TValue value) - { - return values.TryGetValue(key, out value); - } - - public ICollection Values - { - get { return values.Values; } - } - - public TValue this[TKey key] - { - get - { - return values[key]; - } - set - { - values[key] = value; - OnValueChanged(); - } - } - - public void Add(KeyValuePair item) - { - values.Add(item); - OnValueChanged(); - } - - public void Clear() - { - values.Clear(); - OnValueChanged(); - } - - public bool Contains(KeyValuePair item) - { - return values.Contains(item); - } - - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { - values.CopyTo(array, arrayIndex); - } - - public int Count - { - get { return values.Count; } - } - - public bool IsReadOnly - { - get { return values.IsReadOnly; } - } - - public bool Remove(KeyValuePair item) - { - var result = values.Remove(item); - OnValueChanged(); - - return result; - } - - public IEnumerator> GetEnumerator() - { - return values.GetEnumerator(); - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return ((System.Collections.IEnumerable)values).GetEnumerator(); - } - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/DecodingOptions.cs.meta b/Runtime/zxing.unity/Source/lib/common/DecodingOptions.cs.meta deleted file mode 100644 index 942019fca..000000000 --- a/Runtime/zxing.unity/Source/lib/common/DecodingOptions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6bb8f0886114a41b4b705b48bef142a7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/DefaultGridSampler.cs b/Runtime/zxing.unity/Source/lib/common/DefaultGridSampler.cs deleted file mode 100644 index 979dd0520..000000000 --- a/Runtime/zxing.unity/Source/lib/common/DefaultGridSampler.cs +++ /dev/null @@ -1,122 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -namespace ZXing.Common -{ - - /// Sean Owen - /// - /// www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source - /// - public sealed class DefaultGridSampler : GridSampler - { - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public override BitMatrix sampleGrid(BitMatrix image, int dimensionX, int dimensionY, float p1ToX, float p1ToY, float p2ToX, float p2ToY, float p3ToX, float p3ToY, float p4ToX, float p4ToY, float p1FromX, float p1FromY, float p2FromX, float p2FromY, float p3FromX, float p3FromY, float p4FromX, float p4FromY) - { - PerspectiveTransform transform = PerspectiveTransform.quadrilateralToQuadrilateral( - p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, - p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY); - return sampleGrid(image, dimensionX, dimensionY, transform); - } - - /// - /// - /// - /// - /// - /// - /// - public override BitMatrix sampleGrid(BitMatrix image, int dimensionX, int dimensionY, PerspectiveTransform transform) - { - if (dimensionX <= 0 || dimensionY <= 0) - { - return null; - } - BitMatrix bits = new BitMatrix(dimensionX, dimensionY); - float[] points = new float[dimensionX << 1]; - for (int y = 0; y < dimensionY; y++) - { - int max = points.Length; - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - float iValue = (float)y + 0.5f; - for (int x = 0; x < max; x += 2) - { - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - points[x] = (float)(x >> 1) + 0.5f; - points[x + 1] = iValue; - } - transform.transformPoints(points); - // Quick check to see if points transformed to something inside the image; - // sufficient to check the endpoints - if (!checkAndNudgePoints(image, points)) - return null; - try - { - var imageWidth = image.Width; - var imageHeight = image.Height; - - for (int x = 0; x < max; x += 2) - { - var imagex = (int)points[x]; - var imagey = (int)points[x + 1]; - - if (imagex < 0 || imagex >= imageWidth || imagey < 0 || imagey >= imageHeight) - { - return null; - } - - bits[x >> 1, y] = image[imagex, imagey]; - } - } - catch (System.IndexOutOfRangeException) - { - // java version: - // - // This feels wrong, but, sometimes if the finder patterns are misidentified, the resulting - // transform gets "twisted" such that it maps a straight line of points to a set of points - // whose endpoints are in bounds, but others are not. There is probably some mathematical - // way to detect this about the transformation that I don't know yet. - // This results in an ugly runtime exception despite our clever checks above -- can't have - // that. We could check each point's coordinates but that feels duplicative. We settle for - // catching and wrapping ArrayIndexOutOfBoundsException. - return null; - } - } - return bits; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/DefaultGridSampler.cs.meta b/Runtime/zxing.unity/Source/lib/common/DefaultGridSampler.cs.meta deleted file mode 100644 index bb47feedc..000000000 --- a/Runtime/zxing.unity/Source/lib/common/DefaultGridSampler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ffa5020b7edd642c98ccd1ace3607047 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/DetectorResult.cs b/Runtime/zxing.unity/Source/lib/common/DetectorResult.cs deleted file mode 100644 index ff9c99673..000000000 --- a/Runtime/zxing.unity/Source/lib/common/DetectorResult.cs +++ /dev/null @@ -1,47 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -namespace ZXing.Common -{ - /// - ///

Encapsulates the result of detecting a barcode in an image. This includes the raw - /// matrix of black/white pixels corresponding to the barcode, and possibly points of interest - /// in the image, like the location of finder patterns or corners of the barcode in the image.

- ///
- /// Sean Owen - public class DetectorResult - { - /// - /// the detected bits - /// - public BitMatrix Bits { get; private set; } - /// - /// the pixel points where the result is found - /// - public ResultPoint[] Points { get; private set; } - - /// - /// initializing constructor - /// - /// - /// - public DetectorResult(BitMatrix bits, ResultPoint[] points) - { - Bits = bits; - Points = points; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/DetectorResult.cs.meta b/Runtime/zxing.unity/Source/lib/common/DetectorResult.cs.meta deleted file mode 100644 index db474e553..000000000 --- a/Runtime/zxing.unity/Source/lib/common/DetectorResult.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 63b442b730f3f47458c9117105648dce -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/ECI.cs b/Runtime/zxing.unity/Source/lib/common/ECI.cs deleted file mode 100644 index d126e2e65..000000000 --- a/Runtime/zxing.unity/Source/lib/common/ECI.cs +++ /dev/null @@ -1,54 +0,0 @@ -/* -* Copyright 2008 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -namespace ZXing.Common -{ - - /// - /// Superclass of classes encapsulating types ECIs, according to "Extended Channel Interpretations" - /// 5.3 of ISO 18004. - /// - /// Sean Owen - public abstract class ECI - { - /// - /// the ECI value - /// - public virtual int Value { get; private set; } - - internal ECI(int val) - { - Value = val; - } - - /// ECI value - /// representing ECI of given value, or null if it is legal but unsupported - /// ArgumentException if ECI value is invalid - public static ECI getECIByValue(int val) - { - if (val < 0 || val > 999999) - { - throw new System.ArgumentException("Bad ECI value: " + val); - } - if (val < 900) - { - // Character set ECIs use 000000 - 000899 - return CharacterSetECI.getCharacterSetECIByValue(val); - } - return null; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/ECI.cs.meta b/Runtime/zxing.unity/Source/lib/common/ECI.cs.meta deleted file mode 100644 index 0fda14846..000000000 --- a/Runtime/zxing.unity/Source/lib/common/ECI.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8922e11b06be04499a96c50e4afb4372 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/EncodingOptions.cs b/Runtime/zxing.unity/Source/lib/common/EncodingOptions.cs deleted file mode 100644 index 37fed5ece..000000000 --- a/Runtime/zxing.unity/Source/lib/common/EncodingOptions.cs +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; - -namespace ZXing.Common -{ - /// - /// Defines an container for encoder options - /// - [Serializable] - public class EncodingOptions - { - /// - /// Gets the data container for all options - /// - public IDictionary Hints { get; private set; } - - /// - /// Specifies the height of the barcode image - /// - public int Height - { - get - { - if (Hints.ContainsKey(EncodeHintType.HEIGHT)) - { - return (int)Hints[EncodeHintType.HEIGHT]; - } - return 0; - } - set - { - Hints[EncodeHintType.HEIGHT] = value; - } - } - - /// - /// Specifies the width of the barcode image - /// - public int Width - { - get - { - if (Hints.ContainsKey(EncodeHintType.WIDTH)) - { - return (int)Hints[EncodeHintType.WIDTH]; - } - return 0; - } - set - { - Hints[EncodeHintType.WIDTH] = value; - } - } - - /// - /// Don't put the content string into the output image. - /// - public bool PureBarcode - { - get - { - if (Hints.ContainsKey(EncodeHintType.PURE_BARCODE)) - { - return (bool)Hints[EncodeHintType.PURE_BARCODE]; - } - return false; - } - set - { - Hints[EncodeHintType.PURE_BARCODE] = value; - } - } - - /// - /// Specifies margin, in pixels, to use when generating the barcode. The meaning can vary - /// by format; for example it controls margin before and after the barcode horizontally for - /// most 1D formats. - /// - public int Margin - { - get - { - if (Hints.ContainsKey(EncodeHintType.MARGIN)) - { - return (int)Hints[EncodeHintType.MARGIN]; - } - return 0; - } - set - { - Hints[EncodeHintType.MARGIN] = value; - } - } - - /// - /// Specifies whether the data should be encoded to the GS1 standard; - /// FNC1 character is added in front of the data - /// - public bool GS1Format - { - get - { - if (Hints.ContainsKey(EncodeHintType.GS1_FORMAT)) - { - return (bool)Hints[EncodeHintType.GS1_FORMAT]; - } - return false; - } - set - { - Hints[EncodeHintType.GS1_FORMAT] = value; - } - } - - /// - /// Initializes a new instance of the class. - /// - public EncodingOptions() - { - Hints = new Dictionary(); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/EncodingOptions.cs.meta b/Runtime/zxing.unity/Source/lib/common/EncodingOptions.cs.meta deleted file mode 100644 index a2b42efe8..000000000 --- a/Runtime/zxing.unity/Source/lib/common/EncodingOptions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4e7211d3dec514f0295fd75d48ee4814 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/GlobalHistogramBinarizer.cs b/Runtime/zxing.unity/Source/lib/common/GlobalHistogramBinarizer.cs deleted file mode 100644 index 0ba572414..000000000 --- a/Runtime/zxing.unity/Source/lib/common/GlobalHistogramBinarizer.cs +++ /dev/null @@ -1,260 +0,0 @@ -/* -* Copyright 2009 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -namespace ZXing.Common -{ - /// This Binarizer implementation uses the old ZXing global histogram approach. It is suitable - /// for low-end mobile devices which don't have enough CPU or memory to use a local thresholding - /// algorithm. However, because it picks a global black point, it cannot handle difficult shadows - /// and gradients. - /// - /// Faster mobile devices and all desktop applications should probably use HybridBinarizer instead. - /// - /// dswitkin@google.com (Daniel Switkin) - /// Sean Owen - /// - public class GlobalHistogramBinarizer : Binarizer - { - private const int LUMINANCE_BITS = 5; - private const int LUMINANCE_SHIFT = 8 - LUMINANCE_BITS; - private const int LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS; - private static readonly byte[] EMPTY = new byte[0]; - - private byte[] luminances; - private readonly int[] buckets; - - /// - /// Initializes a new instance of the class. - /// - /// The source. - public GlobalHistogramBinarizer(LuminanceSource source) - : base(source) - { - luminances = EMPTY; - buckets = new int[LUMINANCE_BUCKETS]; - } - - /// - /// Applies simple sharpening to the row data to improve performance of the 1D Readers. - /// - /// - /// - /// - public override BitArray getBlackRow(int y, BitArray row) - { - LuminanceSource source = LuminanceSource; - int width = source.Width; - if (row == null || row.Size < width) - { - row = new BitArray(width); - } - else - { - row.clear(); - } - - initArrays(width); - byte[] localLuminances = source.getRow(y, luminances); - int[] localBuckets = buckets; - for (int x = 0; x < width; x++) - { - localBuckets[(localLuminances[x] & 0xff) >> LUMINANCE_SHIFT]++; - } - int blackPoint; - if (!estimateBlackPoint(localBuckets, out blackPoint)) - return null; - - if (width < 3) - { - // Special case for very small images - for (int x = 0; x < width; x++) - { - if ((localLuminances[x] & 0xff) < blackPoint) - { - row[x] = true; - } - } - } - else - { - int left = localLuminances[0] & 0xff; - int center = localLuminances[1] & 0xff; - for (int x = 1; x < width - 1; x++) - { - int right = localLuminances[x + 1] & 0xff; - // A simple -1 4 -1 box filter with a weight of 2. - // ((center << 2) - left - right) >> 1 - if (((center * 4) - left - right) / 2 < blackPoint) - { - row[x] = true; - } - left = center; - center = right; - } - } - - return row; - } - - /// - /// Does not sharpen the data, as this call is intended to only be used by 2D Readers. - /// - public override BitMatrix BlackMatrix - { - get - { - LuminanceSource source = LuminanceSource; - byte[] localLuminances; - - int width = source.Width; - int height = source.Height; - BitMatrix matrix = new BitMatrix(width, height); - - // Quickly calculates the histogram by sampling four rows from the image. This proved to be - // more robust on the blackbox tests than sampling a diagonal as we used to do. - initArrays(width); - int[] localBuckets = buckets; - for (int y = 1; y < 5; y++) - { - int row = height * y / 5; - localLuminances = source.getRow(row, luminances); - int right = (width << 2) / 5; - for (int x = width / 5; x < right; x++) - { - int pixel = localLuminances[x] & 0xff; - localBuckets[pixel >> LUMINANCE_SHIFT]++; - } - } - int blackPoint; - if (!estimateBlackPoint(localBuckets, out blackPoint)) - return new BitMatrix(1, 1); - - // We delay reading the entire image luminance until the black point estimation succeeds. - // Although we end up reading four rows twice, it is consistent with our motto of - // "fail quickly" which is necessary for continuous scanning. - localLuminances = source.Matrix; - for (int y = 0; y < height; y++) - { - int offset = y * width; - for (int x = 0; x < width; x++) - { - int pixel = localLuminances[offset + x] & 0xff; - matrix[x, y] = (pixel < blackPoint); - } - } - - return matrix; - } - } - - /// - /// Creates a new object with the same type as this Binarizer implementation, but with pristine - /// state. This is needed because Binarizer implementations may be stateful, e.g. keeping a cache - /// of 1 bit data. See Effective Java for why we can't use Java's clone() method. - /// - /// The LuminanceSource this Binarizer will operate on. - /// - /// A new concrete Binarizer implementation object. - /// - public override Binarizer createBinarizer(LuminanceSource source) - { - return new GlobalHistogramBinarizer(source); - } - - private void initArrays(int luminanceSize) - { - if (luminances.Length < luminanceSize) - { - luminances = new byte[luminanceSize]; - } - for (int x = 0; x < LUMINANCE_BUCKETS; x++) - { - buckets[x] = 0; - } - } - - private static bool estimateBlackPoint(int[] buckets, out int blackPoint) - { - blackPoint = 0; - // Find the tallest peak in the histogram. - int numBuckets = buckets.Length; - int maxBucketCount = 0; - int firstPeak = 0; - int firstPeakSize = 0; - for (int x = 0; x < numBuckets; x++) - { - if (buckets[x] > firstPeakSize) - { - firstPeak = x; - firstPeakSize = buckets[x]; - } - if (buckets[x] > maxBucketCount) - { - maxBucketCount = buckets[x]; - } - } - - // Find the second-tallest peak which is somewhat far from the tallest peak. - int secondPeak = 0; - int secondPeakScore = 0; - for (int x = 0; x < numBuckets; x++) - { - int distanceToBiggest = x - firstPeak; - // Encourage more distant second peaks by multiplying by square of distance. - int score = buckets[x] * distanceToBiggest * distanceToBiggest; - if (score > secondPeakScore) - { - secondPeak = x; - secondPeakScore = score; - } - } - - // Make sure firstPeak corresponds to the black peak. - if (firstPeak > secondPeak) - { - int temp = firstPeak; - firstPeak = secondPeak; - secondPeak = temp; - } - - // If there is too little contrast in the image to pick a meaningful black point, throw rather - // than waste time trying to decode the image, and risk false positives. - // TODO: It might be worth comparing the brightest and darkest pixels seen, rather than the - // two peaks, to determine the contrast. - if (secondPeak - firstPeak <= numBuckets >> 4) - { - return false; - } - - // Find a valley between them that is low and closer to the white peak. - int bestValley = secondPeak - 1; - int bestValleyScore = -1; - for (int x = secondPeak - 1; x > firstPeak; x--) - { - int fromFirst = x - firstPeak; - int score = fromFirst * fromFirst * (secondPeak - x) * (maxBucketCount - buckets[x]); - if (score > bestValleyScore) - { - bestValley = x; - bestValleyScore = score; - } - } - - blackPoint = bestValley << LUMINANCE_SHIFT; - return true; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/GlobalHistogramBinarizer.cs.meta b/Runtime/zxing.unity/Source/lib/common/GlobalHistogramBinarizer.cs.meta deleted file mode 100644 index 6834957fa..000000000 --- a/Runtime/zxing.unity/Source/lib/common/GlobalHistogramBinarizer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 34203587abbfc45949243a3a9923ce57 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/GridSampler.cs b/Runtime/zxing.unity/Source/lib/common/GridSampler.cs deleted file mode 100644 index 49fc0c6b2..000000000 --- a/Runtime/zxing.unity/Source/lib/common/GridSampler.cs +++ /dev/null @@ -1,204 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -namespace ZXing.Common -{ - /// Implementations of this class can, given locations of finder patterns for a QR code in an - /// image, sample the right points in the image to reconstruct the QR code, accounting for - /// perspective distortion. It is abstracted since it is relatively expensive and should be allowed - /// to take advantage of platform-specific optimized implementations, like Sun's Java Advanced - /// Imaging library, but which may not be available in other environments such as J2ME, and vice - /// versa. - /// - /// The implementation used can be controlled by calling {@link #setGridSampler(GridSampler)} - /// with an instance of a class which implements this interface. - /// - /// Sean Owen - public abstract class GridSampler - { - /// the current implementation of - /// - public static GridSampler Instance - { - get - { - return gridSampler; - } - - } - - private static GridSampler gridSampler = new DefaultGridSampler(); - - /// Sets the implementation of used by the library. One global - /// instance is stored, which may sound problematic. But, the implementation provided - /// ought to be appropriate for the entire platform, and all uses of this library - /// in the whole lifetime of the JVM. For instance, an Android activity can swap in - /// an implementation that takes advantage of native platform libraries. - /// - /// The platform-specific object to install. - public static void setGridSampler(GridSampler newGridSampler) - { - if (newGridSampler == null) - { - throw new System.ArgumentException(); - } - gridSampler = newGridSampler; - } - - /// - ///

Samples an image for a square matrix of bits of the given dimension. This is used to extract - /// the black/white modules of a 2D barcode like a QR Code found in an image. Because this barcode - /// may be rotated or perspective-distorted, the caller supplies four points in the source image - /// that define known points in the barcode, so that the image may be sampled appropriately.

- ///

The last eight "from" parameters are four X/Y coordinate pairs of locations of points in - /// the image that define some significant points in the image to be sample. For example, - /// these may be the location of finder pattern in a QR Code.

- ///

The first eight "to" parameters are four X/Y coordinate pairs measured in the destination - /// , from the top left, where the known points in the image given by the "from" - /// parameters map to.

- ///

These 16 parameters define the transformation needed to sample the image.

- ///
- /// image to sample - /// The dimension X. - /// The dimension Y. - /// The p1 preimage X. - /// The p1 preimage Y. - /// The p2 preimage X. - /// The p2 preimage Y. - /// The p3 preimage X. - /// The p3 preimage Y. - /// The p4 preimage X. - /// The p4 preimage Y. - /// The p1 image X. - /// The p1 image Y. - /// The p2 image X. - /// The p2 image Y. - /// The p3 image X. - /// The p3 image Y. - /// The p4 image X. - /// The p4 image Y. - /// - /// representing a grid of points sampled from the image within a region - /// defined by the "from" parameters - /// - /// ReaderException if image can't be sampled, for example, if the transformation defined - public abstract BitMatrix sampleGrid(BitMatrix image, int dimensionX, int dimensionY, float p1ToX, float p1ToY, float p2ToX, float p2ToY, float p3ToX, float p3ToY, float p4ToX, float p4ToY, float p1FromX, float p1FromY, float p2FromX, float p2FromY, float p3FromX, float p3FromY, float p4FromX, float p4FromY); - - /// - /// - /// - /// - /// - /// - /// - /// - public virtual BitMatrix sampleGrid(BitMatrix image, int dimensionX, int dimensionY, PerspectiveTransform transform) - { - throw new System.NotSupportedException(); - } - - - ///

Checks a set of points that have been transformed to sample points on an image against - /// the image's dimensions to see if the point are even within the image.

- /// - ///

This method will actually "nudge" the endpoints back onto the image if they are found to be - /// barely (less than 1 pixel) off the image. This accounts for imperfect detection of finder - /// patterns in an image where the QR Code runs all the way to the image border.

- /// - ///

For efficiency, the method will check points from either end of the line until one is found - /// to be within the image. Because the set of points are assumed to be linear, this is valid.

- /// - ///
- /// image into which the points should map - /// - /// actual points in x1,y1,...,xn,yn form - /// - protected internal static bool checkAndNudgePoints(BitMatrix image, float[] points) - { - int width = image.Width; - int height = image.Height; - // Check and nudge points from start until we see some that are OK: - bool nudged = true; - int maxOffset = points.Length - 1; // points.length must be even - for (int offset = 0; offset < maxOffset && nudged; offset += 2) - { - int x = (int)points[offset]; - int y = (int)points[offset + 1]; - if (x < -1 || x > width || y < -1 || y > height) - { - return false; - } - nudged = false; - if (x == -1) - { - points[offset] = 0.0f; - nudged = true; - } - else if (x == width) - { - points[offset] = width - 1; - nudged = true; - } - if (y == -1) - { - points[offset + 1] = 0.0f; - nudged = true; - } - else if (y == height) - { - points[offset + 1] = height - 1; - nudged = true; - } - } - // Check and nudge points from end: - nudged = true; - for (int offset = points.Length - 2; offset >= 0 && nudged; offset -= 2) - { - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - int x = (int)points[offset]; - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - int y = (int)points[offset + 1]; - if (x < -1 || x > width || y < -1 || y > height) - { - return false; - } - nudged = false; - if (x == -1) - { - points[offset] = 0.0f; - nudged = true; - } - else if (x == width) - { - points[offset] = width - 1; - nudged = true; - } - if (y == -1) - { - points[offset + 1] = 0.0f; - nudged = true; - } - else if (y == height) - { - points[offset + 1] = height - 1; - nudged = true; - } - } - - return true; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/GridSampler.cs.meta b/Runtime/zxing.unity/Source/lib/common/GridSampler.cs.meta deleted file mode 100644 index ff6b7946e..000000000 --- a/Runtime/zxing.unity/Source/lib/common/GridSampler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: cbc75771256c9454fae193d7c9778890 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/HybridBinarizer.cs b/Runtime/zxing.unity/Source/lib/common/HybridBinarizer.cs deleted file mode 100644 index 08650a809..000000000 --- a/Runtime/zxing.unity/Source/lib/common/HybridBinarizer.cs +++ /dev/null @@ -1,298 +0,0 @@ -/* -* Copyright 2009 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -namespace ZXing.Common -{ - /// This class implements a local thresholding algorithm, which while slower than the - /// GlobalHistogramBinarizer, is fairly efficient for what it does. It is designed for - /// high frequency images of barcodes with black data on white backgrounds. For this application, - /// it does a much better job than a global blackpoint with severe shadows and gradients. - /// However it tends to produce artifacts on lower frequency images and is therefore not - /// a good general purpose binarizer for uses outside ZXing. - /// - /// This class extends GlobalHistogramBinarizer, using the older histogram approach for 1D readers, - /// and the newer local approach for 2D readers. 1D decoding using a per-row histogram is already - /// inherently local, and only fails for horizontal gradients. We can revisit that problem later, - /// but for now it was not a win to use local blocks for 1D. - /// - /// This Binarizer is the default for the unit tests and the recommended class for library users. - /// dswitkin@google.com (Daniel Switkin) - /// - public sealed class HybridBinarizer : GlobalHistogramBinarizer - { - /// - /// gives the black matrix - /// - public override BitMatrix BlackMatrix - { - get - { - binarizeEntireImage(); - return matrix; - } - } - - // This class uses 5x5 blocks to compute local luminance, where each block is 8x8 pixels. - // So this is the smallest dimension in each axis we can accept. - private const int BLOCK_SIZE_POWER = 3; - private const int BLOCK_SIZE = 1 << BLOCK_SIZE_POWER; // ...0100...00 - private const int BLOCK_SIZE_MASK = BLOCK_SIZE - 1; // ...0011...11 - private const int MINIMUM_DIMENSION = 40; - private const int MIN_DYNAMIC_RANGE = 24; - - private BitMatrix matrix = null; - - /// - /// initializing constructor - /// - /// - public HybridBinarizer(LuminanceSource source) - : base(source) - { - } - - /// - /// creates a new instance - /// - /// - /// - public override Binarizer createBinarizer(LuminanceSource source) - { - return new HybridBinarizer(source); - } - - /// - /// Calculates the final BitMatrix once for all requests. This could be called once from the - /// constructor instead, but there are some advantages to doing it lazily, such as making - /// profiling easier, and not doing heavy lifting when callers don't expect it. - /// - private void binarizeEntireImage() - { - if (matrix == null) - { - LuminanceSource source = LuminanceSource; - int width = source.Width; - int height = source.Height; - if (width >= MINIMUM_DIMENSION && height >= MINIMUM_DIMENSION) - { - byte[] luminances = source.Matrix; - - int subWidth = width >> BLOCK_SIZE_POWER; - if ((width & BLOCK_SIZE_MASK) != 0) - { - subWidth++; - } - int subHeight = height >> BLOCK_SIZE_POWER; - if ((height & BLOCK_SIZE_MASK) != 0) - { - subHeight++; - } - int[][] blackPoints = calculateBlackPoints(luminances, subWidth, subHeight, width, height); - - var newMatrix = new BitMatrix(width, height); - calculateThresholdForBlock(luminances, subWidth, subHeight, width, height, blackPoints, newMatrix); - matrix = newMatrix; - } - else - { - // If the image is too small, fall back to the global histogram approach. - matrix = base.BlackMatrix; - } - } - } - - /// - /// For each 8x8 block in the image, calculate the average black point using a 5x5 grid - /// of the blocks around it. Also handles the corner cases (fractional blocks are computed based - /// on the last 8 pixels in the row/column which are also used in the previous block). - /// - /// The luminances. - /// Width of the sub. - /// Height of the sub. - /// The width. - /// The height. - /// The black points. - /// The matrix. - private static void calculateThresholdForBlock(byte[] luminances, int subWidth, int subHeight, int width, int height, int[][] blackPoints, BitMatrix matrix) - { - int maxYOffset = height - BLOCK_SIZE; - int maxXOffset = width - BLOCK_SIZE; - - for (int y = 0; y < subHeight; y++) - { - int yoffset = y << BLOCK_SIZE_POWER; - if (yoffset > maxYOffset) - { - yoffset = maxYOffset; - } - int top = cap(y, subHeight - 3); - for (int x = 0; x < subWidth; x++) - { - int xoffset = x << BLOCK_SIZE_POWER; - if (xoffset > maxXOffset) - { - xoffset = maxXOffset; - } - int left = cap(x, subWidth - 3); - int sum = 0; - for (int z = -2; z <= 2; z++) - { - int[] blackRow = blackPoints[top + z]; - sum += blackRow[left - 2]; - sum += blackRow[left - 1]; - sum += blackRow[left]; - sum += blackRow[left + 1]; - sum += blackRow[left + 2]; - } - int average = sum / 25; - thresholdBlock(luminances, xoffset, yoffset, average, width, matrix); - } - } - } - - private static int cap(int value, int max) - { - return value < 2 ? 2 : value > max ? max : value; - } - - /// - /// Applies a single threshold to an 8x8 block of pixels. - /// - /// The luminances. - /// The xoffset. - /// The yoffset. - /// The threshold. - /// The stride. - /// The matrix. - private static void thresholdBlock(byte[] luminances, int xoffset, int yoffset, int threshold, int stride, BitMatrix matrix) - { - int offset = (yoffset * stride) + xoffset; - for (int y = 0; y < BLOCK_SIZE; y++, offset += stride) - { - for (int x = 0; x < BLOCK_SIZE; x++) - { - int pixel = luminances[offset + x] & 0xff; - // Comparison needs to be <= so that black == 0 pixels are black even if the threshold is 0. - matrix[xoffset + x, yoffset + y] = (pixel <= threshold); - } - } - } - - /// - /// Calculates a single black point for each 8x8 block of pixels and saves it away. - /// See the following thread for a discussion of this algorithm: - /// http://groups.google.com/group/zxing/browse_thread/thread/d06efa2c35a7ddc0 - /// - /// The luminances. - /// Width of the sub. - /// Height of the sub. - /// The width. - /// The height. - /// - private static int[][] calculateBlackPoints(byte[] luminances, int subWidth, int subHeight, int width, int height) - { - int maxYOffset = height - BLOCK_SIZE; - int maxXOffset = width - BLOCK_SIZE; - int[][] blackPoints = new int[subHeight][]; - for (int i = 0; i < subHeight; i++) - { - blackPoints[i] = new int[subWidth]; - } - - for (int y = 0; y < subHeight; y++) - { - int yoffset = y << BLOCK_SIZE_POWER; - if (yoffset > maxYOffset) - { - yoffset = maxYOffset; - } - var blackPointsY = blackPoints[y]; - var blackPointsY1 = y > 0 ? blackPoints[y - 1] : null; - for (int x = 0; x < subWidth; x++) - { - int xoffset = x << BLOCK_SIZE_POWER; - if (xoffset > maxXOffset) - { - xoffset = maxXOffset; - } - int sum = 0; - int min = 0xFF; - int max = 0; - for (int yy = 0, offset = yoffset * width + xoffset; yy < BLOCK_SIZE; yy++, offset += width) - { - for (int xx = 0; xx < BLOCK_SIZE; xx++) - { - int pixel = luminances[offset + xx] & 0xFF; - // still looking for good contrast - sum += pixel; - if (pixel < min) - { - min = pixel; - } - if (pixel > max) - { - max = pixel; - } - } - // short-circuit min/max tests once dynamic range is met - if (max - min > MIN_DYNAMIC_RANGE) - { - // finish the rest of the rows quickly - for (yy++, offset += width; yy < BLOCK_SIZE; yy++, offset += width) - { - for (int xx = 0; xx < BLOCK_SIZE; xx++) - { - sum += luminances[offset + xx] & 0xFF; - } - } - } - } - - // The default estimate is the average of the values in the block. - int average = sum >> (BLOCK_SIZE_POWER * 2); - if (max - min <= MIN_DYNAMIC_RANGE) - { - // If variation within the block is low, assume this is a block with only light or only - // dark pixels. In that case we do not want to use the average, as it would divide this - // low contrast area into black and white pixels, essentially creating data out of noise. - // - // The default assumption is that the block is light/background. Since no estimate for - // the level of dark pixels exists locally, use half the min for the block. - average = min >> 1; - - if (blackPointsY1 != null && x > 0) - { - // Correct the "white background" assumption for blocks that have neighbors by comparing - // the pixels in this block to the previously calculated black points. This is based on - // the fact that dark barcode symbology is always surrounded by some amount of light - // background for which reasonable black point estimates were made. The bp estimated at - // the boundaries is used for the interior. - - // The (min < bp) is arbitrary but works better than other heuristics that were tried. - int averageNeighborBlackPoint = (blackPointsY1[x] + (2 * blackPointsY[x - 1]) + blackPointsY1[x - 1]) >> 2; - if (min < averageNeighborBlackPoint) - { - average = averageNeighborBlackPoint; - } - } - } - blackPointsY[x] = average; - } - } - return blackPoints; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/HybridBinarizer.cs.meta b/Runtime/zxing.unity/Source/lib/common/HybridBinarizer.cs.meta deleted file mode 100644 index 00a83b3f8..000000000 --- a/Runtime/zxing.unity/Source/lib/common/HybridBinarizer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1486db2bedae04006875945ac288d1d9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/PerspectiveTransform.cs b/Runtime/zxing.unity/Source/lib/common/PerspectiveTransform.cs deleted file mode 100644 index 01f3cc81b..000000000 --- a/Runtime/zxing.unity/Source/lib/common/PerspectiveTransform.cs +++ /dev/null @@ -1,203 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -namespace ZXing.Common -{ - ///

This class implements a perspective transform in two dimensions. Given four source and four - /// destination points, it will compute the transformation implied between them. The code is based - /// directly upon section 3.4.2 of George Wolberg's "Digital Image Warping"; see pages 54-56.

- ///
- /// Sean Owen - public sealed class PerspectiveTransform - { - private float a11; - private float a12; - private float a13; - private float a21; - private float a22; - private float a23; - private float a31; - private float a32; - private float a33; - - private PerspectiveTransform(float a11, float a21, float a31, float a12, float a22, float a32, float a13, float a23, float a33) - { - this.a11 = a11; - this.a12 = a12; - this.a13 = a13; - this.a21 = a21; - this.a22 = a22; - this.a23 = a23; - this.a31 = a31; - this.a32 = a32; - this.a33 = a33; - } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public static PerspectiveTransform quadrilateralToQuadrilateral(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, float x0p, float y0p, float x1p, float y1p, float x2p, float y2p, float x3p, float y3p) - { - - PerspectiveTransform qToS = quadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3); - PerspectiveTransform sToQ = squareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p); - return sToQ.times(qToS); - } - - /// - /// - /// - /// - public void transformPoints(float[] points) - { - float a11 = this.a11; - float a12 = this.a12; - float a13 = this.a13; - float a21 = this.a21; - float a22 = this.a22; - float a23 = this.a23; - float a31 = this.a31; - float a32 = this.a32; - float a33 = this.a33; - int maxI = points.Length - 1; // points.length must be even - for (int i = 0; i < maxI; i += 2) - { - float x = points[i]; - float y = points[i + 1]; - float denominator = a13 * x + a23 * y + a33; - points[i] = (a11 * x + a21 * y + a31) / denominator; - points[i + 1] = (a12 * x + a22 * y + a32) / denominator; - } - } - - /// Convenience method, not optimized for performance. - public void transformPoints(float[] xValues, float[] yValues) - { - int n = xValues.Length; - for (int i = 0; i < n; i++) - { - float x = xValues[i]; - float y = yValues[i]; - float denominator = a13 * x + a23 * y + a33; - xValues[i] = (a11 * x + a21 * y + a31) / denominator; - yValues[i] = (a12 * x + a22 * y + a32) / denominator; - } - } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public static PerspectiveTransform squareToQuadrilateral(float x0, float y0, - float x1, float y1, - float x2, float y2, - float x3, float y3) - { - float dx3 = x0 - x1 + x2 - x3; - float dy3 = y0 - y1 + y2 - y3; - if (dx3 == 0.0f && dy3 == 0.0f) - { - // Affine - return new PerspectiveTransform(x1 - x0, x2 - x1, x0, - y1 - y0, y2 - y1, y0, - 0.0f, 0.0f, 1.0f); - } - else - { - float dx1 = x1 - x2; - float dx2 = x3 - x2; - float dy1 = y1 - y2; - float dy2 = y3 - y2; - float denominator = dx1 * dy2 - dx2 * dy1; - float a13 = (dx3 * dy2 - dx2 * dy3) / denominator; - float a23 = (dx1 * dy3 - dx3 * dy1) / denominator; - return new PerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, - y1 - y0 + a13 * y1, y3 - y0 + a23 * y3, y0, - a13, a23, 1.0f); - } - } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public static PerspectiveTransform quadrilateralToSquare(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) - { - // Here, the adjoint serves as the inverse: - return squareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3).buildAdjoint(); - } - - internal PerspectiveTransform buildAdjoint() - { - // Adjoint is the transpose of the cofactor matrix: - return new PerspectiveTransform(a22 * a33 - a23 * a32, - a23 * a31 - a21 * a33, - a21 * a32 - a22 * a31, - a13 * a32 - a12 * a33, - a11 * a33 - a13 * a31, - a12 * a31 - a11 * a32, - a12 * a23 - a13 * a22, - a13 * a21 - a11 * a23, - a11 * a22 - a12 * a21); - } - - internal PerspectiveTransform times(PerspectiveTransform other) - { - return new PerspectiveTransform(a11 * other.a11 + a21 * other.a12 + a31 * other.a13, - a11 * other.a21 + a21 * other.a22 + a31 * other.a23, - a11 * other.a31 + a21 * other.a32 + a31 * other.a33, - a12 * other.a11 + a22 * other.a12 + a32 * other.a13, - a12 * other.a21 + a22 * other.a22 + a32 * other.a23, - a12 * other.a31 + a22 * other.a32 + a32 * other.a33, - a13 * other.a11 + a23 * other.a12 + a33 * other.a13, - a13 * other.a21 + a23 * other.a22 + a33 * other.a23, - a13 * other.a31 + a23 * other.a32 + a33 * other.a33); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/PerspectiveTransform.cs.meta b/Runtime/zxing.unity/Source/lib/common/PerspectiveTransform.cs.meta deleted file mode 100644 index 7d3451c97..000000000 --- a/Runtime/zxing.unity/Source/lib/common/PerspectiveTransform.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8f2c75ef22d334b249d4733a13b23da6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/StringUtils.cs b/Runtime/zxing.unity/Source/lib/common/StringUtils.cs deleted file mode 100644 index eaa8dc7a8..000000000 --- a/Runtime/zxing.unity/Source/lib/common/StringUtils.cs +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; -using System.Text; - -namespace ZXing.Common -{ - /// - /// Common string-related functions. - /// - /// Sean Owen - /// Alex Dupre - public static class StringUtils - { - /// - /// default encoding of the current platform (name) - /// - public static readonly String PLATFORM_DEFAULT_ENCODING; - /// - /// default encoding of the current platform (type) - /// - public static readonly Encoding PLATFORM_DEFAULT_ENCODING_T; - /// - /// Shift JIS encoding if available - /// - public static readonly Encoding SHIFT_JIS_ENCODING; - /// - /// GB 2312 encoding if available - /// - public static readonly Encoding GB2312_ENCODING; - /// - /// ECU JP encoding if available - /// - public static readonly Encoding EUC_JP_ENCODING; - /// - /// ISO8859-1 encoding if available - /// - public static readonly Encoding ISO88591_ENCODING; - private static readonly bool ASSUME_SHIFT_JIS; - - // Retained for ABI compatibility with earlier versions - /// - /// SJIS - /// - public const String SHIFT_JIS = "SJIS"; - /// - /// GB2312 - /// - public const String GB2312 = "GB2312"; - /// - /// EUC-JP - /// - public const String EUC_JP = "EUC-JP"; - /// - /// UTF-8 - /// - public const String UTF8 = "UTF-8"; - /// - /// ISO-8859-1 - /// - public const String ISO88591 = "ISO-8859-1"; - - static StringUtils() - { -#if (WINDOWS_PHONE || SILVERLIGHT4 || SILVERLIGHT5 || NETFX_CORE || PORTABLE || NETSTANDARD) - PLATFORM_DEFAULT_ENCODING = UTF8; - PLATFORM_DEFAULT_ENCODING_T = Encoding.UTF8; -#else - PLATFORM_DEFAULT_ENCODING = Encoding.Default.WebName.ToUpper(); - PLATFORM_DEFAULT_ENCODING_T = Encoding.Default; -#endif - SHIFT_JIS_ENCODING = CharacterSetECI.getEncoding(SHIFT_JIS); - GB2312_ENCODING = CharacterSetECI.getEncoding(GB2312); - EUC_JP_ENCODING = CharacterSetECI.getEncoding(EUC_JP); - ISO88591_ENCODING = CharacterSetECI.getEncoding(ISO88591); - ASSUME_SHIFT_JIS = - PLATFORM_DEFAULT_ENCODING_T.Equals(SHIFT_JIS_ENCODING) || - PLATFORM_DEFAULT_ENCODING_T.Equals(EUC_JP_ENCODING); - } - - /// - /// Guesses the encoding. - /// - /// bytes encoding a string, whose encoding should be guessed - /// decode hints if applicable - /// name of guessed encoding; at the moment will only guess one of: - /// "SJIS", "UTF8", "ISO8859_1", or the platform default encoding if none - /// of these can possibly be correct - public static String guessEncoding(byte[] bytes, IDictionary hints) - { - var c = guessCharset(bytes, hints); - if (c == SHIFT_JIS_ENCODING && SHIFT_JIS_ENCODING != null) - { - return "SJIS"; - } - return c.WebName.ToUpper(); - } - - /// - /// bytes encoding a string, whose encoding should be guessed - /// decode hints if applicable - /// Charset of guessed encoding; at the moment will only guess one of: - /// {@link #SHIFT_JIS_CHARSET}, {@link StandardCharsets#UTF_8}, - /// {@link StandardCharsets#ISO_8859_1}, {@link StandardCharsets#UTF_16}, - /// or the platform default encoding if - /// none of these can possibly be correct - public static Encoding guessCharset(byte[] bytes, IDictionary hints) - { - if (hints != null && hints.ContainsKey(DecodeHintType.CHARACTER_SET)) - { - String characterSet = (String)hints[DecodeHintType.CHARACTER_SET]; - if (characterSet != null) - { - var encoding = CharacterSetECI.getEncoding(characterSet); - if (encoding != null) - return encoding; - } - } - - // First try UTF-16, assuming anything with its BOM is UTF-16 - if (bytes.Length > 2 && - ((bytes[0] == (byte)0xFE && bytes[1] == (byte)0xFF) || - (bytes[0] == (byte)0xFF && bytes[1] == (byte)0xFE))) - { - return Encoding.Unicode; - } - - // For now, merely tries to distinguish ISO-8859-1, UTF-8 and Shift_JIS, - // which should be by far the most common encodings. - int length = bytes.Length; - bool canBeISO88591 = true; - bool canBeShiftJIS = true; - bool canBeUTF8 = true; - int utf8BytesLeft = 0; - int utf2BytesChars = 0; - int utf3BytesChars = 0; - int utf4BytesChars = 0; - int sjisBytesLeft = 0; - int sjisKatakanaChars = 0; - int sjisCurKatakanaWordLength = 0; - int sjisCurDoubleBytesWordLength = 0; - int sjisMaxKatakanaWordLength = 0; - int sjisMaxDoubleBytesWordLength = 0; - int isoHighOther = 0; - - bool utf8bom = bytes.Length > 3 && - bytes[0] == 0xEF && - bytes[1] == 0xBB && - bytes[2] == 0xBF; - - for (int i = 0; - i < length && (canBeISO88591 || canBeShiftJIS || canBeUTF8); - i++) - { - - int value = bytes[i] & 0xFF; - - // UTF-8 stuff - if (canBeUTF8) - { - if (utf8BytesLeft > 0) - { - if ((value & 0x80) == 0) - { - canBeUTF8 = false; - } - else - { - utf8BytesLeft--; - } - } - else if ((value & 0x80) != 0) - { - if ((value & 0x40) == 0) - { - canBeUTF8 = false; - } - else - { - utf8BytesLeft++; - if ((value & 0x20) == 0) - { - utf2BytesChars++; - } - else - { - utf8BytesLeft++; - if ((value & 0x10) == 0) - { - utf3BytesChars++; - } - else - { - utf8BytesLeft++; - if ((value & 0x08) == 0) - { - utf4BytesChars++; - } - else - { - canBeUTF8 = false; - } - } - } - } - } - } - - // ISO-8859-1 stuff - if (canBeISO88591) - { - if (value > 0x7F && value < 0xA0) - { - canBeISO88591 = false; - } - else if (value > 0x9F) - { - if (value < 0xC0 || value == 0xD7 || value == 0xF7) - { - isoHighOther++; - } - } - } - - // Shift_JIS stuff - if (canBeShiftJIS) - { - if (sjisBytesLeft > 0) - { - if (value < 0x40 || value == 0x7F || value > 0xFC) - { - canBeShiftJIS = false; - } - else - { - sjisBytesLeft--; - } - } - else if (value == 0x80 || value == 0xA0 || value > 0xEF) - { - canBeShiftJIS = false; - } - else if (value > 0xA0 && value < 0xE0) - { - sjisKatakanaChars++; - sjisCurDoubleBytesWordLength = 0; - sjisCurKatakanaWordLength++; - if (sjisCurKatakanaWordLength > sjisMaxKatakanaWordLength) - { - sjisMaxKatakanaWordLength = sjisCurKatakanaWordLength; - } - } - else if (value > 0x7F) - { - sjisBytesLeft++; - //sjisDoubleBytesChars++; - sjisCurKatakanaWordLength = 0; - sjisCurDoubleBytesWordLength++; - if (sjisCurDoubleBytesWordLength > sjisMaxDoubleBytesWordLength) - { - sjisMaxDoubleBytesWordLength = sjisCurDoubleBytesWordLength; - } - } - else - { - //sjisLowChars++; - sjisCurKatakanaWordLength = 0; - sjisCurDoubleBytesWordLength = 0; - } - } - } - - if (canBeUTF8 && utf8BytesLeft > 0) - { - canBeUTF8 = false; - } - if (canBeShiftJIS && sjisBytesLeft > 0) - { - canBeShiftJIS = false; - } - - // Easy -- if there is BOM or at least 1 valid not-single byte character (and no evidence it can't be UTF-8), done - if (canBeUTF8 && (utf8bom || utf2BytesChars + utf3BytesChars + utf4BytesChars > 0)) - { - return Encoding.UTF8; - } - // Easy -- if assuming Shift_JIS or >= 3 valid consecutive not-ascii characters (and no evidence it can't be), done - if (canBeShiftJIS && (ASSUME_SHIFT_JIS || sjisMaxKatakanaWordLength >= 3 || sjisMaxDoubleBytesWordLength >= 3) && SHIFT_JIS_ENCODING != null) - { - return SHIFT_JIS_ENCODING; - } - // Distinguishing Shift_JIS and ISO-8859-1 can be a little tough for short words. The crude heuristic is: - // - If we saw - // - only two consecutive katakana chars in the whole text, or - // - at least 10% of bytes that could be "upper" not-alphanumeric Latin1, - // - then we conclude Shift_JIS, else ISO-8859-1 - if (canBeISO88591 && canBeShiftJIS && ISO88591_ENCODING != null && SHIFT_JIS_ENCODING != null) - { - return (sjisMaxKatakanaWordLength == 2 && sjisKatakanaChars == 2) || isoHighOther * 10 >= length - ? SHIFT_JIS_ENCODING : ISO88591_ENCODING; - } - - // Otherwise, try in order ISO-8859-1, Shift JIS, UTF-8 and fall back to default platform encoding - if (canBeISO88591 && ISO88591_ENCODING != null) - { - return ISO88591_ENCODING; - } - if (canBeShiftJIS && SHIFT_JIS_ENCODING != null) - { - return SHIFT_JIS_ENCODING; - } - if (canBeUTF8) - { - return Encoding.UTF8; - } - // Otherwise, we take a wild guess with platform encoding - return PLATFORM_DEFAULT_ENCODING_T; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/StringUtils.cs.meta b/Runtime/zxing.unity/Source/lib/common/StringUtils.cs.meta deleted file mode 100644 index 3370a68a2..000000000 --- a/Runtime/zxing.unity/Source/lib/common/StringUtils.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 09fe10672c8994ff88d197cb6c7d7a05 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/detector.meta b/Runtime/zxing.unity/Source/lib/common/detector.meta deleted file mode 100644 index 673521c70..000000000 --- a/Runtime/zxing.unity/Source/lib/common/detector.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 401f342df0db44dc19b95e4635c6cdfe -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/detector/MathUtils.cs b/Runtime/zxing.unity/Source/lib/common/detector/MathUtils.cs deleted file mode 100644 index d6810d812..000000000 --- a/Runtime/zxing.unity/Source/lib/common/detector/MathUtils.cs +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; - -namespace ZXing.Common.Detector -{ - /// - /// General math-related and numeric utility functions. - /// - public static class MathUtils - { - /// - /// Ends up being a bit faster than {@link Math#round(float)}. This merely rounds its - /// argument to the nearest int, where x.5 rounds up to x+1. Semantics of this shortcut - /// differ slightly from {@link Math#round(float)} in that half rounds down for negative - /// values. -2.5 rounds to -3, not -2. For purposes here it makes no difference. - /// - /// real value to round - /// nearest int - public static int round(float d) - { - if (float.IsNaN(d)) - return 0; - if (float.IsPositiveInfinity(d)) - return int.MaxValue; - return (int)(d + (d < 0.0f ? -0.5f : 0.5f)); - } - - /// - /// - /// - /// - /// - /// - /// - /// Euclidean distance between points A and B - public static float distance(float aX, float aY, float bX, float bY) - { - double xDiff = aX - bX; - double yDiff = aY - bY; - return (float)Math.Sqrt(xDiff * xDiff + yDiff * yDiff); - } - - /// - /// - /// - /// - /// - /// - /// - /// Euclidean distance between points A and B - public static float distance(int aX, int aY, int bX, int bY) - { - double xDiff = aX - bX; - double yDiff = aY - bY; - return (float)Math.Sqrt(xDiff * xDiff + yDiff * yDiff); - } - - /// - /// - /// values to sum - /// sum of values in array - public static int sum(int[] array) - { - int count = 0; - foreach (int a in array) - { - count += a; - } - return count; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/detector/MathUtils.cs.meta b/Runtime/zxing.unity/Source/lib/common/detector/MathUtils.cs.meta deleted file mode 100644 index 7a5841ee6..000000000 --- a/Runtime/zxing.unity/Source/lib/common/detector/MathUtils.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9848b258d93104957b3ea2bfae50275c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/detector/MonochromeRectangleDetector.cs b/Runtime/zxing.unity/Source/lib/common/detector/MonochromeRectangleDetector.cs deleted file mode 100644 index 2b3057844..000000000 --- a/Runtime/zxing.unity/Source/lib/common/detector/MonochromeRectangleDetector.cs +++ /dev/null @@ -1,256 +0,0 @@ -/* -* Copyright 2009 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; - -namespace ZXing.Common.Detector -{ - ///

A somewhat generic detector that looks for a barcode-like rectangular region within an image. - /// It looks within a mostly white region of an image for a region of black and white, but mostly - /// black. It returns the four corners of the region, as best it can determine.

- /// - ///
- /// Sean Owen - [Obsolete] - public sealed class MonochromeRectangleDetector - { - private const int MAX_MODULES = 32; - - private readonly BitMatrix image; - - /// - /// initializing constructor - /// - /// - public MonochromeRectangleDetector(BitMatrix image) - { - this.image = image; - } - - /// - ///

Detects a rectangular region of black and white -- mostly black -- with a region of mostly - /// white, in an image.

- ///
- /// [] describing the corners of the rectangular region. The first and - /// last points are opposed on the diagonal, as are the second and third. The first point will be - /// the topmost point and the last, the bottommost. The second point will be leftmost and the - /// third, the rightmost - /// - public ResultPoint[] detect() - { - int height = image.Height; - int width = image.Width; - int halfHeight = height >> 1; - int halfWidth = width >> 1; - int deltaY = System.Math.Max(1, height / (MAX_MODULES << 3)); - int deltaX = System.Math.Max(1, width / (MAX_MODULES << 3)); - - int top = 0; - int bottom = height; - int left = 0; - int right = width; - ResultPoint pointA = findCornerFromCenter(halfWidth, 0, left, right, halfHeight, -deltaY, top, bottom, halfWidth >> 1); - if (pointA == null) - return null; - top = (int)pointA.Y - 1; - ResultPoint pointB = findCornerFromCenter(halfWidth, -deltaX, left, right, halfHeight, 0, top, bottom, halfHeight >> 1); - if (pointB == null) - return null; - left = (int)pointB.X - 1; - ResultPoint pointC = findCornerFromCenter(halfWidth, deltaX, left, right, halfHeight, 0, top, bottom, halfHeight >> 1); - if (pointC == null) - return null; - right = (int)pointC.X + 1; - ResultPoint pointD = findCornerFromCenter(halfWidth, 0, left, right, halfHeight, deltaY, top, bottom, halfWidth >> 1); - if (pointD == null) - return null; - bottom = (int)pointD.Y + 1; - - // Go try to find point A again with better information -- might have been off at first. - pointA = findCornerFromCenter(halfWidth, 0, left, right, halfHeight, -deltaY, top, bottom, halfWidth >> 2); - if (pointA == null) - return null; - - return new ResultPoint[] { pointA, pointB, pointC, pointD }; - } - - /// Attempts to locate a corner of the barcode by scanning up, down, left or right from a center - /// point which should be within the barcode. - /// - /// - /// center's x component (horizontal) - /// - /// same as deltaY but change in x per step instead - /// - /// minimum value of x - /// - /// maximum value of x - /// - /// center's y component (vertical) - /// - /// change in y per step. If scanning up this is negative; down, positive; - /// left or right, 0 - /// - /// minimum value of y to search through (meaningless when di == 0) - /// - /// maximum value of y - /// - /// maximum run of white pixels that can still be considered to be within - /// the barcode - /// - /// a encapsulating the corner that was found - /// - private ResultPoint findCornerFromCenter(int centerX, int deltaX, int left, int right, int centerY, int deltaY, int top, int bottom, int maxWhiteRun) - { - int[] lastRange = null; - for (int y = centerY, x = centerX; y < bottom && y >= top && x < right && x >= left; y += deltaY, x += deltaX) - { - int[] range; - if (deltaX == 0) - { - // horizontal slices, up and down - range = blackWhiteRange(y, maxWhiteRun, left, right, true); - } - else - { - // vertical slices, left and right - range = blackWhiteRange(x, maxWhiteRun, top, bottom, false); - } - if (range == null) - { - if (lastRange == null) - { - return null; - } - // lastRange was found - if (deltaX == 0) - { - int lastY = y - deltaY; - if (lastRange[0] < centerX) - { - if (lastRange[1] > centerX) - { - // straddle, choose one or the other based on direction - return new ResultPoint(lastRange[deltaY > 0 ? 0 : 1], lastY); - } - return new ResultPoint(lastRange[0], lastY); - } - else - { - return new ResultPoint(lastRange[1], lastY); - } - } - else - { - int lastX = x - deltaX; - if (lastRange[0] < centerY) - { - if (lastRange[1] > centerY) - { - return new ResultPoint(lastX, lastRange[deltaX < 0 ? 0 : 1]); - } - return new ResultPoint(lastX, lastRange[0]); - } - else - { - return new ResultPoint(lastX, lastRange[1]); - } - } - } - lastRange = range; - } - return null; - } - - /// Computes the start and end of a region of pixels, either horizontally or vertically, that could - /// be part of a Data Matrix barcode. - /// - /// - /// if scanning horizontally, this is the row (the fixed vertical location) - /// where we are scanning. If scanning vertically it's the column, the fixed horizontal location - /// - /// largest run of white pixels that can still be considered part of the - /// barcode region - /// - /// minimum pixel location, horizontally or vertically, to consider - /// - /// maximum pixel location, horizontally or vertically, to consider - /// - /// if true, we're scanning left-right, instead of up-down - /// - /// int[] with start and end of found range, or null if no such range is found - /// (e.g. only white was found) - /// - private int[] blackWhiteRange(int fixedDimension, int maxWhiteRun, int minDim, int maxDim, bool horizontal) - { - int center = (minDim + maxDim) >> 1; - - // Scan left/up first - int start = center; - while (start >= minDim) - { - if (horizontal ? image[start, fixedDimension] : image[fixedDimension, start]) - { - start--; - } - else - { - int whiteRunStart = start; - do - { - start--; - } - while (start >= minDim && !(horizontal ? image[start, fixedDimension] : image[fixedDimension, start])); - int whiteRunSize = whiteRunStart - start; - if (start < minDim || whiteRunSize > maxWhiteRun) - { - start = whiteRunStart; - break; - } - } - } - start++; - - // Then try right/down - int end = center; - while (end < maxDim) - { - if (horizontal ? image[end, fixedDimension] : image[fixedDimension, end]) - { - end++; - } - else - { - int whiteRunStart = end; - do - { - end++; - } - while (end < maxDim && !(horizontal ? image[end, fixedDimension] : image[fixedDimension, end])); - int whiteRunSize = end - whiteRunStart; - if (end >= maxDim || whiteRunSize > maxWhiteRun) - { - end = whiteRunStart; - break; - } - } - } - end--; - - return end > start ? new int[] { start, end } : null; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/detector/MonochromeRectangleDetector.cs.meta b/Runtime/zxing.unity/Source/lib/common/detector/MonochromeRectangleDetector.cs.meta deleted file mode 100644 index ba986a40d..000000000 --- a/Runtime/zxing.unity/Source/lib/common/detector/MonochromeRectangleDetector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7f428fcaed7394a6ea11727e79fcf398 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/detector/WhiteRectangleDetector.cs b/Runtime/zxing.unity/Source/lib/common/detector/WhiteRectangleDetector.cs deleted file mode 100644 index 73de5c21e..000000000 --- a/Runtime/zxing.unity/Source/lib/common/detector/WhiteRectangleDetector.cs +++ /dev/null @@ -1,406 +0,0 @@ -/* - * Copyright 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; - -namespace ZXing.Common.Detector -{ - /// - /// Detects a candidate barcode-like rectangular region within an image. It - /// starts around the center of the image, increases the size of the candidate - /// region until it finds a white rectangular region. By keeping track of the - /// last black points it encountered, it determines the corners of the barcode. - /// - /// David Olivier - public sealed class WhiteRectangleDetector - { - private const int INIT_SIZE = 10; - private const int CORR = 1; - - private readonly BitMatrix image; - private readonly int height; - private readonly int width; - private readonly int leftInit; - private readonly int rightInit; - private readonly int downInit; - private readonly int upInit; - - /// - /// Creates a WhiteRectangleDetector instance - /// - /// The image. - /// null, if image is too small, otherwise a WhiteRectangleDetector instance - public static WhiteRectangleDetector Create(BitMatrix image) - { - if (image == null) - return null; - - var instance = new WhiteRectangleDetector(image); - - if (instance.upInit < 0 || instance.leftInit < 0 || instance.downInit >= instance.height || instance.rightInit >= instance.width) - { - return null; - } - - return instance; - } - - /// - /// Creates a WhiteRectangleDetector instance - /// - /// barcode image to find a rectangle in - /// initial size of search area around center - /// x position of search center - /// y position of search center - /// - /// null, if image is too small, otherwise a WhiteRectangleDetector instance - /// - public static WhiteRectangleDetector Create(BitMatrix image, int initSize, int x, int y) - { - var instance = new WhiteRectangleDetector(image, initSize, x, y); - - if (instance.upInit < 0 || instance.leftInit < 0 || instance.downInit >= instance.height || instance.rightInit >= instance.width) - { - return null; - } - - return instance; - } - - - /// - /// Initializes a new instance of the class. - /// - /// The image. - /// if image is too small - internal WhiteRectangleDetector(BitMatrix image) - : this(image, INIT_SIZE, image.Width / 2, image.Height / 2) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The image. - /// Size of the init. - /// The x. - /// The y. - internal WhiteRectangleDetector(BitMatrix image, int initSize, int x, int y) - { - this.image = image; - height = image.Height; - width = image.Width; - int halfsize = initSize / 2; - leftInit = x - halfsize; - rightInit = x + halfsize; - upInit = y - halfsize; - downInit = y + halfsize; - } - - /// - /// Detects a candidate barcode-like rectangular region within an image. It - /// starts around the center of the image, increases the size of the candidate - /// region until it finds a white rectangular region. - /// - /// [] describing the corners of the rectangular - /// region. The first and last points are opposed on the diagonal, as - /// are the second and third. The first point will be the topmost - /// point and the last, the bottommost. The second point will be - /// leftmost and the third, the rightmost - public ResultPoint[] detect() - { - int left = leftInit; - int right = rightInit; - int up = upInit; - int down = downInit; - bool sizeExceeded = false; - bool aBlackPointFoundOnBorder = true; - - bool atLeastOneBlackPointFoundOnRight = false; - bool atLeastOneBlackPointFoundOnBottom = false; - bool atLeastOneBlackPointFoundOnLeft = false; - bool atLeastOneBlackPointFoundOnTop = false; - - while (aBlackPointFoundOnBorder) - { - - aBlackPointFoundOnBorder = false; - - // ..... - // . | - // ..... - bool rightBorderNotWhite = true; - while ((rightBorderNotWhite || !atLeastOneBlackPointFoundOnRight) && right < width) - { - rightBorderNotWhite = containsBlackPoint(up, down, right, false); - if (rightBorderNotWhite) - { - right++; - aBlackPointFoundOnBorder = true; - atLeastOneBlackPointFoundOnRight = true; - } - else if (!atLeastOneBlackPointFoundOnRight) - { - right++; - } - } - - if (right >= width) - { - sizeExceeded = true; - break; - } - - // ..... - // . . - // .___. - bool bottomBorderNotWhite = true; - while ((bottomBorderNotWhite || !atLeastOneBlackPointFoundOnBottom) && down < height) - { - bottomBorderNotWhite = containsBlackPoint(left, right, down, true); - if (bottomBorderNotWhite) - { - down++; - aBlackPointFoundOnBorder = true; - atLeastOneBlackPointFoundOnBottom = true; - } - else if (!atLeastOneBlackPointFoundOnBottom) - { - down++; - } - } - - if (down >= height) - { - sizeExceeded = true; - break; - } - - // ..... - // | . - // ..... - bool leftBorderNotWhite = true; - while ((leftBorderNotWhite || !atLeastOneBlackPointFoundOnLeft) && left >= 0) - { - leftBorderNotWhite = containsBlackPoint(up, down, left, false); - if (leftBorderNotWhite) - { - left--; - aBlackPointFoundOnBorder = true; - atLeastOneBlackPointFoundOnLeft = true; - } - else if (!atLeastOneBlackPointFoundOnLeft) - { - left--; - } - } - - if (left < 0) - { - sizeExceeded = true; - break; - } - - // .___. - // . . - // ..... - bool topBorderNotWhite = true; - while ((topBorderNotWhite || !atLeastOneBlackPointFoundOnTop) && up >= 0) - { - topBorderNotWhite = containsBlackPoint(left, right, up, true); - if (topBorderNotWhite) - { - up--; - aBlackPointFoundOnBorder = true; - atLeastOneBlackPointFoundOnTop = true; - } - else if (!atLeastOneBlackPointFoundOnTop) - { - up--; - } - } - - if (up < 0) - { - sizeExceeded = true; - break; - } - } - - if (!sizeExceeded) - { - - int maxSize = right - left; - - ResultPoint z = null; - for (int i = 1; z == null && i < maxSize; i++) - { - z = getBlackPointOnSegment(left, down - i, left + i, down); - } - - if (z == null) - { - return null; - } - - ResultPoint t = null; - //go down right - for (int i = 1; t == null && i < maxSize; i++) - { - t = getBlackPointOnSegment(left, up + i, left + i, up); - } - - if (t == null) - { - return null; - } - - ResultPoint x = null; - //go down left - for (int i = 1; x == null && i < maxSize; i++) - { - x = getBlackPointOnSegment(right, up + i, right - i, up); - } - - if (x == null) - { - return null; - } - - ResultPoint y = null; - //go up left - for (int i = 1; y == null && i < maxSize; i++) - { - y = getBlackPointOnSegment(right, down - i, right - i, down); - } - - if (y == null) - { - return null; - } - - return centerEdges(y, z, x, t); - } - return null; - } - - private ResultPoint getBlackPointOnSegment(float aX, float aY, float bX, float bY) - { - int dist = MathUtils.round(MathUtils.distance(aX, aY, bX, bY)); - float xStep = (bX - aX) / dist; - float yStep = (bY - aY) / dist; - - for (int i = 0; i < dist; i++) - { - int x = MathUtils.round(aX + i * xStep); - int y = MathUtils.round(aY + i * yStep); - if (image[x, y]) - { - return new ResultPoint(x, y); - } - } - return null; - } - - /// - /// recenters the points of a constant distance towards the center - /// - /// bottom most point - /// left most point - /// right most point - /// top most point - /// [] describing the corners of the rectangular - /// region. The first and last points are opposed on the diagonal, as - /// are the second and third. The first point will be the topmost - /// point and the last, the bottommost. The second point will be - /// leftmost and the third, the rightmost - private ResultPoint[] centerEdges(ResultPoint y, ResultPoint z, - ResultPoint x, ResultPoint t) - { - // - // t t - // z x - // x OR z - // y y - // - - float yi = y.X; - float yj = y.Y; - float zi = z.X; - float zj = z.Y; - float xi = x.X; - float xj = x.Y; - float ti = t.X; - float tj = t.Y; - - if (yi < width / 2.0f) - { - return new[] - { - new ResultPoint(ti - CORR, tj + CORR), - new ResultPoint(zi + CORR, zj + CORR), - new ResultPoint(xi - CORR, xj - CORR), - new ResultPoint(yi + CORR, yj - CORR) - }; - } - else - { - return new[] - { - new ResultPoint(ti + CORR, tj + CORR), - new ResultPoint(zi + CORR, zj - CORR), - new ResultPoint(xi - CORR, xj + CORR), - new ResultPoint(yi - CORR, yj - CORR) - }; - } - } - - /// - /// Determines whether a segment contains a black point - /// - /// min value of the scanned coordinate - /// max value of the scanned coordinate - /// value of fixed coordinate - /// set to true if scan must be horizontal, false if vertical - /// - /// true if a black point has been found, else false. - /// - private bool containsBlackPoint(int a, int b, int @fixed, bool horizontal) - { - if (horizontal) - { - for (int x = a; x <= b; x++) - { - if (image[x, @fixed]) - { - return true; - } - } - } - else - { - for (int y = a; y <= b; y++) - { - if (image[@fixed, y]) - { - return true; - } - } - } - return false; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/detector/WhiteRectangleDetector.cs.meta b/Runtime/zxing.unity/Source/lib/common/detector/WhiteRectangleDetector.cs.meta deleted file mode 100644 index 85f57c786..000000000 --- a/Runtime/zxing.unity/Source/lib/common/detector/WhiteRectangleDetector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c4bf23248eb7046dbae1a4b034c8eb1d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/reedsolomon.meta b/Runtime/zxing.unity/Source/lib/common/reedsolomon.meta deleted file mode 100644 index af9929ac7..000000000 --- a/Runtime/zxing.unity/Source/lib/common/reedsolomon.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 541e10fbc137142eb8ca9c751efa693e -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/reedsolomon/GenericGF.cs b/Runtime/zxing.unity/Source/lib/common/reedsolomon/GenericGF.cs deleted file mode 100644 index 362cf3c03..000000000 --- a/Runtime/zxing.unity/Source/lib/common/reedsolomon/GenericGF.cs +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; - -namespace ZXing.Common.ReedSolomon -{ - /// - ///

This class contains utility methods for performing mathematical operations over - /// the Galois Fields. Operations use a given primitive polynomial in calculations.

- ///

Throughout this package, elements of the GF are represented as an {@code int} - /// for convenience and speed (but at the cost of memory). - ///

- ///
- /// Sean Owen - public sealed class GenericGF - { - /// - /// Aztec data 12 - /// - public static GenericGF AZTEC_DATA_12 = new GenericGF(0x1069, 4096, 1); // x^12 + x^6 + x^5 + x^3 + 1 - /// - /// Aztec data 10 - /// - public static GenericGF AZTEC_DATA_10 = new GenericGF(0x409, 1024, 1); // x^10 + x^3 + 1 - /// - /// Aztec data 6 - /// - public static GenericGF AZTEC_DATA_6 = new GenericGF(0x43, 64, 1); // x^6 + x + 1 - /// - /// Aztec param - /// - public static GenericGF AZTEC_PARAM = new GenericGF(0x13, 16, 1); // x^4 + x + 1 - /// - /// QR Code - /// - public static GenericGF QR_CODE_FIELD_256 = new GenericGF(0x011D, 256, 0); // x^8 + x^4 + x^3 + x^2 + 1 - /// - /// Data Matrix - /// - public static GenericGF DATA_MATRIX_FIELD_256 = new GenericGF(0x012D, 256, 1); // x^8 + x^5 + x^3 + x^2 + 1 - /// - /// Aztec data 8 - /// - public static GenericGF AZTEC_DATA_8 = DATA_MATRIX_FIELD_256; - /// - /// Maxicode - /// - public static GenericGF MAXICODE_FIELD_64 = AZTEC_DATA_6; - - private readonly int[] expTable; - private readonly int[] logTable; - private readonly GenericGFPoly zero; - private readonly GenericGFPoly one; - private readonly int size; - private readonly int primitive; - private readonly int generatorBase; - - /// - /// Create a representation of GF(size) using the given primitive polynomial. - /// - /// irreducible polynomial whose coefficients are represented by - /// * the bits of an int, where the least-significant bit represents the constant - /// * coefficient - /// the size of the field - /// the factor b in the generator polynomial can be 0- or 1-based - /// * (g(x) = (x+a^b)(x+a^(b+1))...(x+a^(b+2t-1))). - /// * In most cases it should be 1, but for QR code it is 0. - public GenericGF(int primitive, int size, int genBase) - { - this.primitive = primitive; - this.size = size; - this.generatorBase = genBase; - - expTable = new int[size]; - logTable = new int[size]; - int x = 1; - for (int i = 0; i < size; i++) - { - expTable[i] = x; - x <<= 1; // x = x * 2; we're assuming the generator alpha is 2 - if (x >= size) - { - x ^= primitive; - x &= size - 1; - } - } - for (int i = 0; i < size - 1; i++) - { - logTable[expTable[i]] = i; - } - // logTable[0] == 0 but this should never be used - zero = new GenericGFPoly(this, new int[] { 0 }); - one = new GenericGFPoly(this, new int[] { 1 }); - } - - internal GenericGFPoly Zero - { - get - { - return zero; - } - } - - internal GenericGFPoly One - { - get - { - return one; - } - } - - /// - /// Builds the monomial. - /// - /// The degree. - /// The coefficient. - /// the monomial representing coefficient * x^degree - internal GenericGFPoly buildMonomial(int degree, int coefficient) - { - if (degree < 0) - { - throw new ArgumentException(); - } - if (coefficient == 0) - { - return zero; - } - int[] coefficients = new int[degree + 1]; - coefficients[0] = coefficient; - return new GenericGFPoly(this, coefficients); - } - - /// - /// Implements both addition and subtraction -- they are the same in GF(size). - /// - /// sum/difference of a and b - internal static int addOrSubtract(int a, int b) - { - return a ^ b; - } - - /// - /// Exps the specified a. - /// - /// 2 to the power of a in GF(size) - internal int exp(int a) - { - return expTable[a]; - } - - /// - /// Logs the specified a. - /// - /// A. - /// base 2 log of a in GF(size) - internal int log(int a) - { - if (a == 0) - { - throw new ArgumentException(); - } - return logTable[a]; - } - - /// - /// Inverses the specified a. - /// - /// multiplicative inverse of a - internal int inverse(int a) - { - if (a == 0) - { - throw new ArithmeticException(); - } - return expTable[size - logTable[a] - 1]; - } - - /// - /// Multiplies the specified a with b. - /// - /// A. - /// The b. - /// product of a and b in GF(size) - internal int multiply(int a, int b) - { - if (a == 0 || b == 0) - { - return 0; - } - return expTable[(logTable[a] + logTable[b]) % (size - 1)]; - } - - /// - /// Gets the size. - /// - public int Size - { - get { return size; } - } - - /// - /// Gets the generator base. - /// - public int GeneratorBase - { - get { return generatorBase; } - } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override String ToString() - { - return "GF(0x" + primitive.ToString("X") + ',' + size + ')'; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/reedsolomon/GenericGF.cs.meta b/Runtime/zxing.unity/Source/lib/common/reedsolomon/GenericGF.cs.meta deleted file mode 100644 index 89daa5f78..000000000 --- a/Runtime/zxing.unity/Source/lib/common/reedsolomon/GenericGF.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5cfd1545bbc414310a9ddc6ac9b37dbf -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/reedsolomon/GenericGFPoly.cs b/Runtime/zxing.unity/Source/lib/common/reedsolomon/GenericGFPoly.cs deleted file mode 100644 index 79fb2fd10..000000000 --- a/Runtime/zxing.unity/Source/lib/common/reedsolomon/GenericGFPoly.cs +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Text; - -namespace ZXing.Common.ReedSolomon -{ - /// - ///

Represents a polynomial whose coefficients are elements of a GF. - /// Instances of this class are immutable.

- ///

Much credit is due to William Rucklidge since portions of this code are an indirect - /// port of his C++ Reed-Solomon implementation.

- ///
- /// Sean Owen - internal sealed class GenericGFPoly - { - private readonly GenericGF field; - private readonly int[] coefficients; - - /// - /// Initializes a new instance of the class. - /// - /// the {@link GenericGF} instance representing the field to use - /// to perform computations - /// coefficients as ints representing elements of GF(size), arranged - /// from most significant (highest-power term) coefficient to least significant - /// if argument is null or empty, - /// or if leading coefficient is 0 and this is not a - /// constant polynomial (that is, it is not the monomial "0") - internal GenericGFPoly(GenericGF field, int[] coefficients) - { - if (coefficients.Length == 0) - { - throw new ArgumentException(); - } - this.field = field; - int coefficientsLength = coefficients.Length; - if (coefficientsLength > 1 && coefficients[0] == 0) - { - // Leading term must be non-zero for anything except the constant polynomial "0" - int firstNonZero = 1; - while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0) - { - firstNonZero++; - } - if (firstNonZero == coefficientsLength) - { - this.coefficients = new int[] { 0 }; - } - else - { - this.coefficients = new int[coefficientsLength - firstNonZero]; - Array.Copy(coefficients, - firstNonZero, - this.coefficients, - 0, - this.coefficients.Length); - } - } - else - { - this.coefficients = coefficients; - } - } - - internal int[] Coefficients - { - get { return coefficients; } - } - - /// - /// degree of this polynomial - /// - internal int Degree - { - get - { - return coefficients.Length - 1; - } - } - - /// - /// Gets a value indicating whether this is zero. - /// - /// true iff this polynomial is the monomial "0" - internal bool isZero - { - get { return coefficients[0] == 0; } - } - - /// - /// coefficient of x^degree term in this polynomial - /// - /// The degree. - /// coefficient of x^degree term in this polynomial - internal int getCoefficient(int degree) - { - return coefficients[coefficients.Length - 1 - degree]; - } - - /// - /// evaluation of this polynomial at a given point - /// - /// A. - /// evaluation of this polynomial at a given point - internal int evaluateAt(int a) - { - int result = 0; - if (a == 0) - { - // Just return the x^0 coefficient - return getCoefficient(0); - } - if (a == 1) - { - // Just the sum of the coefficients - foreach (var coefficient in coefficients) - { - result = GenericGF.addOrSubtract(result, coefficient); - } - return result; - } - result = coefficients[0]; - int size = coefficients.Length; - for (int i = 1; i < size; i++) - { - result = GenericGF.addOrSubtract(field.multiply(a, result), coefficients[i]); - } - return result; - } - - internal GenericGFPoly addOrSubtract(GenericGFPoly other) - { - if (!field.Equals(other.field)) - { - throw new ArgumentException("GenericGFPolys do not have same GenericGF field"); - } - if (isZero) - { - return other; - } - if (other.isZero) - { - return this; - } - - int[] smallerCoefficients = this.coefficients; - int[] largerCoefficients = other.coefficients; - if (smallerCoefficients.Length > largerCoefficients.Length) - { - int[] temp = smallerCoefficients; - smallerCoefficients = largerCoefficients; - largerCoefficients = temp; - } - int[] sumDiff = new int[largerCoefficients.Length]; - int lengthDiff = largerCoefficients.Length - smallerCoefficients.Length; - // Copy high-order terms only found in higher-degree polynomial's coefficients - Array.Copy(largerCoefficients, 0, sumDiff, 0, lengthDiff); - - for (int i = lengthDiff; i < largerCoefficients.Length; i++) - { - sumDiff[i] = GenericGF.addOrSubtract(smallerCoefficients[i - lengthDiff], largerCoefficients[i]); - } - - return new GenericGFPoly(field, sumDiff); - } - - internal GenericGFPoly multiply(GenericGFPoly other) - { - if (!field.Equals(other.field)) - { - throw new ArgumentException("GenericGFPolys do not have same GenericGF field"); - } - if (isZero || other.isZero) - { - return field.Zero; - } - int[] aCoefficients = this.coefficients; - int aLength = aCoefficients.Length; - int[] bCoefficients = other.coefficients; - int bLength = bCoefficients.Length; - int[] product = new int[aLength + bLength - 1]; - for (int i = 0; i < aLength; i++) - { - int aCoeff = aCoefficients[i]; - for (int j = 0; j < bLength; j++) - { - product[i + j] = GenericGF.addOrSubtract(product[i + j], - field.multiply(aCoeff, bCoefficients[j])); - } - } - return new GenericGFPoly(field, product); - } - - internal GenericGFPoly multiply(int scalar) - { - if (scalar == 0) - { - return field.Zero; - } - if (scalar == 1) - { - return this; - } - int size = coefficients.Length; - int[] product = new int[size]; - for (int i = 0; i < size; i++) - { - product[i] = field.multiply(coefficients[i], scalar); - } - return new GenericGFPoly(field, product); - } - - internal GenericGFPoly multiplyByMonomial(int degree, int coefficient) - { - if (degree < 0) - { - throw new ArgumentException(); - } - if (coefficient == 0) - { - return field.Zero; - } - int size = coefficients.Length; - int[] product = new int[size + degree]; - for (int i = 0; i < size; i++) - { - product[i] = field.multiply(coefficients[i], coefficient); - } - return new GenericGFPoly(field, product); - } - - internal GenericGFPoly[] divide(GenericGFPoly other) - { - if (!field.Equals(other.field)) - { - throw new ArgumentException("GenericGFPolys do not have same GenericGF field"); - } - if (other.isZero) - { - throw new ArgumentException("Divide by 0"); - } - - GenericGFPoly quotient = field.Zero; - GenericGFPoly remainder = this; - - int denominatorLeadingTerm = other.getCoefficient(other.Degree); - int inverseDenominatorLeadingTerm = field.inverse(denominatorLeadingTerm); - - while (remainder.Degree >= other.Degree && !remainder.isZero) - { - int degreeDifference = remainder.Degree - other.Degree; - int scale = field.multiply(remainder.getCoefficient(remainder.Degree), inverseDenominatorLeadingTerm); - GenericGFPoly term = other.multiplyByMonomial(degreeDifference, scale); - GenericGFPoly iterationQuotient = field.buildMonomial(degreeDifference, scale); - quotient = quotient.addOrSubtract(iterationQuotient); - remainder = remainder.addOrSubtract(term); - } - - return new GenericGFPoly[] { quotient, remainder }; - } - - public override String ToString() - { - if (isZero) - { - return "0"; - } - StringBuilder result = new StringBuilder(8 * Degree); - for (int degree = Degree; degree >= 0; degree--) - { - int coefficient = getCoefficient(degree); - if (coefficient != 0) - { - if (coefficient < 0) - { - if (degree == Degree) - { - result.Append("-"); - } - else - { - result.Append(" - "); - } - coefficient = -coefficient; - } - else - { - if (result.Length > 0) - { - result.Append(" + "); - } - } - if (degree == 0 || coefficient != 1) - { - int alphaPower = field.log(coefficient); - if (alphaPower == 0) - { - result.Append('1'); - } - else if (alphaPower == 1) - { - result.Append('a'); - } - else - { - result.Append("a^"); - result.Append(alphaPower); - } - } - if (degree != 0) - { - if (degree == 1) - { - result.Append('x'); - } - else - { - result.Append("x^"); - result.Append(degree); - } - } - } - } - return result.ToString(); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/reedsolomon/GenericGFPoly.cs.meta b/Runtime/zxing.unity/Source/lib/common/reedsolomon/GenericGFPoly.cs.meta deleted file mode 100644 index 7e001ec11..000000000 --- a/Runtime/zxing.unity/Source/lib/common/reedsolomon/GenericGFPoly.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 218c0919f92474737b2099c7ace5ad5d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/reedsolomon/ReedSolomonDecoder.cs b/Runtime/zxing.unity/Source/lib/common/reedsolomon/ReedSolomonDecoder.cs deleted file mode 100644 index 824e7c2ec..000000000 --- a/Runtime/zxing.unity/Source/lib/common/reedsolomon/ReedSolomonDecoder.cs +++ /dev/null @@ -1,231 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -namespace ZXing.Common.ReedSolomon -{ - ///

Implements Reed-Solomon decoding, as the name implies.

- /// - ///

The algorithm will not be explained here, but the following references were helpful - /// in creating this implementation:

- /// - /// - /// - ///

Much credit is due to William Rucklidge since portions of this code are an indirect - /// port of his C++ Reed-Solomon implementation.

- /// - ///
- /// Sean Owen - /// William Rucklidge - /// sanfordsquires - public sealed class ReedSolomonDecoder - { - private readonly GenericGF field; - - /// - /// constructor - /// - /// - public ReedSolomonDecoder(GenericGF field) - { - this.field = field; - } - - /// - ///

Decodes given set of received codewords, which include both data and error-correction - /// codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place, - /// in the input.

- ///
- /// data and error-correction codewords - /// number of error-correction codewords available - /// false: decoding fails - public bool decode(int[] received, int twoS) - { - var poly = new GenericGFPoly(field, received); - var syndromeCoefficients = new int[twoS]; - var noError = true; - for (var i = 0; i < twoS; i++) - { - var eval = poly.evaluateAt(field.exp(i + field.GeneratorBase)); - syndromeCoefficients[syndromeCoefficients.Length - 1 - i] = eval; - if (eval != 0) - { - noError = false; - } - } - if (noError) - { - return true; - } - var syndrome = new GenericGFPoly(field, syndromeCoefficients); - - var sigmaOmega = runEuclideanAlgorithm(field.buildMonomial(twoS, 1), syndrome, twoS); - if (sigmaOmega == null) - return false; - - var sigma = sigmaOmega[0]; - var errorLocations = findErrorLocations(sigma); - if (errorLocations == null) - return false; - - var omega = sigmaOmega[1]; - var errorMagnitudes = findErrorMagnitudes(omega, errorLocations); - for (var i = 0; i < errorLocations.Length; i++) - { - var position = received.Length - 1 - field.log(errorLocations[i]); - if (position < 0) - { - // throw new ReedSolomonException("Bad error location"); - return false; - } - received[position] = GenericGF.addOrSubtract(received[position], errorMagnitudes[i]); - } - - return true; - } - - internal GenericGFPoly[] runEuclideanAlgorithm(GenericGFPoly a, GenericGFPoly b, int R) - { - // Assume a's degree is >= b's - if (a.Degree < b.Degree) - { - GenericGFPoly temp = a; - a = b; - b = temp; - } - - GenericGFPoly rLast = a; - GenericGFPoly r = b; - GenericGFPoly tLast = field.Zero; - GenericGFPoly t = field.One; - - // Run Euclidean algorithm until r's degree is less than R/2 - while (2 * r.Degree >= R) - { - GenericGFPoly rLastLast = rLast; - GenericGFPoly tLastLast = tLast; - rLast = r; - tLast = t; - - // Divide rLastLast by rLast, with quotient in q and remainder in r - if (rLast.isZero) - { - // Oops, Euclidean algorithm already terminated? - // throw new ReedSolomonException("r_{i-1} was zero"); - return null; - } - r = rLastLast; - GenericGFPoly q = field.Zero; - int denominatorLeadingTerm = rLast.getCoefficient(rLast.Degree); - int dltInverse = field.inverse(denominatorLeadingTerm); - while (r.Degree >= rLast.Degree && !r.isZero) - { - int degreeDiff = r.Degree - rLast.Degree; - int scale = field.multiply(r.getCoefficient(r.Degree), dltInverse); - q = q.addOrSubtract(field.buildMonomial(degreeDiff, scale)); - r = r.addOrSubtract(rLast.multiplyByMonomial(degreeDiff, scale)); - } - - t = q.multiply(tLast).addOrSubtract(tLastLast); - - if (r.Degree >= rLast.Degree) - { - // throw new IllegalStateException("Division algorithm failed to reduce polynomial? " + "r: " + r + ", rLast: " + rLast); - return null; - } - } - - int sigmaTildeAtZero = t.getCoefficient(0); - if (sigmaTildeAtZero == 0) - { - // throw new ReedSolomonException("sigmaTilde(0) was zero"); - return null; - } - - int inverse = field.inverse(sigmaTildeAtZero); - GenericGFPoly sigma = t.multiply(inverse); - GenericGFPoly omega = r.multiply(inverse); - return new GenericGFPoly[] { sigma, omega }; - } - - private int[] findErrorLocations(GenericGFPoly errorLocator) - { - // This is a direct application of Chien's search - int numErrors = errorLocator.Degree; - if (numErrors == 1) - { - // shortcut - return new int[] { errorLocator.getCoefficient(1) }; - } - int[] result = new int[numErrors]; - int e = 0; - for (int i = 1; i < field.Size && e < numErrors; i++) - { - if (errorLocator.evaluateAt(i) == 0) - { - result[e] = field.inverse(i); - e++; - } - } - if (e != numErrors) - { - // throw new ReedSolomonException("Error locator degree does not match number of roots"); - return null; - } - return result; - } - - private int[] findErrorMagnitudes(GenericGFPoly errorEvaluator, int[] errorLocations) - { - // This is directly applying Forney's Formula - int s = errorLocations.Length; - int[] result = new int[s]; - for (int i = 0; i < s; i++) - { - int xiInverse = field.inverse(errorLocations[i]); - int denominator = 1; - for (int j = 0; j < s; j++) - { - if (i != j) - { - //denominator = field.multiply(denominator, - // GenericGF.addOrSubtract(1, field.multiply(errorLocations[j], xiInverse))); - // Above should work but fails on some Apple and Linux JDKs due to a Hotspot bug. - // Below is a funny-looking workaround from Steven Parkes - int term = field.multiply(errorLocations[j], xiInverse); - int termPlus1 = (term & 0x1) == 0 ? term | 1 : term & ~1; - denominator = field.multiply(denominator, termPlus1); - - // removed in java version, not sure if this is right - // denominator = field.multiply(denominator, GenericGF.addOrSubtract(1, field.multiply(errorLocations[j], xiInverse))); - } - } - result[i] = field.multiply(errorEvaluator.evaluateAt(xiInverse), field.inverse(denominator)); - if (field.GeneratorBase != 0) - { - result[i] = field.multiply(result[i], xiInverse); - } - } - return result; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/reedsolomon/ReedSolomonDecoder.cs.meta b/Runtime/zxing.unity/Source/lib/common/reedsolomon/ReedSolomonDecoder.cs.meta deleted file mode 100644 index 951749cac..000000000 --- a/Runtime/zxing.unity/Source/lib/common/reedsolomon/ReedSolomonDecoder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 93ede1aada6324f059bbd7db5f4bac0f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/common/reedsolomon/ReedSolomonEncoder.cs b/Runtime/zxing.unity/Source/lib/common/reedsolomon/ReedSolomonEncoder.cs deleted file mode 100644 index 08c2a8a44..000000000 --- a/Runtime/zxing.unity/Source/lib/common/reedsolomon/ReedSolomonEncoder.cs +++ /dev/null @@ -1,93 +0,0 @@ -/* -* Copyright 2008 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Collections.Generic; - -namespace ZXing.Common.ReedSolomon -{ - /// - /// Implements Reed-Solomon encoding, as the name implies. - /// - /// Sean Owen - /// William Rucklidge - public sealed class ReedSolomonEncoder - { - private readonly GenericGF field; - private readonly IList cachedGenerators; - - /// - /// constructor - /// - /// - public ReedSolomonEncoder(GenericGF field) - { - this.field = field; - this.cachedGenerators = new List(); - cachedGenerators.Add(new GenericGFPoly(field, new int[] { 1 })); - } - - private GenericGFPoly buildGenerator(int degree) - { - if (degree >= cachedGenerators.Count) - { - var lastGenerator = cachedGenerators[cachedGenerators.Count - 1]; - for (int d = cachedGenerators.Count; d <= degree; d++) - { - var nextGenerator = lastGenerator.multiply(new GenericGFPoly(field, new int[] { 1, field.exp(d - 1 + field.GeneratorBase) })); - cachedGenerators.Add(nextGenerator); - lastGenerator = nextGenerator; - } - } - return cachedGenerators[degree]; - } - - /// - /// encodes - /// - /// - /// - public void encode(int[] toEncode, int ecBytes) - { - if (ecBytes == 0) - { - throw new ArgumentException("No error correction bytes"); - } - var dataBytes = toEncode.Length - ecBytes; - if (dataBytes <= 0) - { - throw new ArgumentException("No data bytes provided"); - } - - var generator = buildGenerator(ecBytes); - var infoCoefficients = new int[dataBytes]; - Array.Copy(toEncode, 0, infoCoefficients, 0, dataBytes); - - var info = new GenericGFPoly(field, infoCoefficients); - info = info.multiplyByMonomial(ecBytes, 1); - - var remainder = info.divide(generator)[1]; - var coefficients = remainder.Coefficients; - var numZeroCoefficients = ecBytes - coefficients.Length; - for (var i = 0; i < numZeroCoefficients; i++) - { - toEncode[dataBytes + i] = 0; - } - - Array.Copy(coefficients, 0, toEncode, dataBytes + numZeroCoefficients, coefficients.Length); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/common/reedsolomon/ReedSolomonEncoder.cs.meta b/Runtime/zxing.unity/Source/lib/common/reedsolomon/ReedSolomonEncoder.cs.meta deleted file mode 100644 index bfee2ac03..000000000 --- a/Runtime/zxing.unity/Source/lib/common/reedsolomon/ReedSolomonEncoder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 29f51639aa2804a39b71fb1fc0927769 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode.meta b/Runtime/zxing.unity/Source/lib/qrcode.meta deleted file mode 100644 index a13c8de4d..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 1a1ac8c3bdf9b4c028be4071ea4ac21a -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/QRCodeWriter.cs b/Runtime/zxing.unity/Source/lib/qrcode/QRCodeWriter.cs deleted file mode 100644 index 3e6267647..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/QRCodeWriter.cs +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Collections.Generic; - -using ZXing.Common; -using ZXing.QrCode.Internal; - -namespace ZXing.QrCode -{ - /// - /// This object renders a QR Code as a BitMatrix 2D array of greyscale values. - /// - /// dswitkin@google.com (Daniel Switkin) - /// - public sealed class QRCodeWriter : Writer - { - private const int QUIET_ZONE_SIZE = 4; - - /// - /// Encode a barcode using the default settings. - /// - /// The contents to encode in the barcode - /// The barcode format to generate - /// The preferred width in pixels - /// The preferred height in pixels - /// - /// The generated barcode as a Matrix of unsigned bytes (0 == black, 255 == white) - /// - public BitMatrix encode(String contents, BarcodeFormat format, int width, int height) - { - return encode(contents, format, width, height, null); - } - - /// - /// - /// The contents to encode in the barcode - /// The barcode format to generate - /// The preferred width in pixels - /// The preferred height in pixels - /// Additional parameters to supply to the encoder - /// - /// The generated barcode as a Matrix of unsigned bytes (0 == black, 255 == white) - /// - public BitMatrix encode(String contents, - BarcodeFormat format, - int width, - int height, - IDictionary hints) - { - if (String.IsNullOrEmpty(contents)) - { - throw new ArgumentException("Found empty contents"); - } - - if (format != BarcodeFormat.QR_CODE) - { - throw new ArgumentException("Can only encode QR_CODE, but got " + format); - } - - if (width < 0 || height < 0) - { - throw new ArgumentException("Requested dimensions are too small: " + width + 'x' + height); - } - - var errorCorrectionLevel = ErrorCorrectionLevel.L; - int quietZone = QUIET_ZONE_SIZE; - if (hints != null) - { - if (hints.ContainsKey(EncodeHintType.ERROR_CORRECTION)) - { - var requestedECLevel = hints[EncodeHintType.ERROR_CORRECTION]; - if (requestedECLevel != null) - { - errorCorrectionLevel = requestedECLevel as ErrorCorrectionLevel; - if (errorCorrectionLevel == null) - { - switch (requestedECLevel.ToString().ToUpper()) - { - case "L": - errorCorrectionLevel = ErrorCorrectionLevel.L; - break; - case "M": - errorCorrectionLevel = ErrorCorrectionLevel.M; - break; - case "Q": - errorCorrectionLevel = ErrorCorrectionLevel.Q; - break; - case "H": - errorCorrectionLevel = ErrorCorrectionLevel.H; - break; - default: - errorCorrectionLevel = ErrorCorrectionLevel.L; - break; - } - } - } - } - if (hints.ContainsKey(EncodeHintType.MARGIN)) - { - var quietZoneInt = hints[EncodeHintType.MARGIN]; - if (quietZoneInt != null) - { - quietZone = Convert.ToInt32(quietZoneInt.ToString()); - } - } - } - - var code = Encoder.encode(contents, errorCorrectionLevel, hints); - return renderResult(code, width, height, quietZone); - } - - // Note that the input matrix uses 0 == white, 1 == black, while the output matrix uses - // 0 == black, 255 == white (i.e. an 8 bit greyscale bitmap). - private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone) - { - var input = code.Matrix; - if (input == null) - { - throw new InvalidOperationException(); - } - int inputWidth = input.Width; - int inputHeight = input.Height; - int qrWidth = inputWidth + (quietZone << 1); - int qrHeight = inputHeight + (quietZone << 1); - int outputWidth = Math.Max(width, qrWidth); - int outputHeight = Math.Max(height, qrHeight); - - int multiple = Math.Min(outputWidth / qrWidth, outputHeight / qrHeight); - // Padding includes both the quiet zone and the extra white pixels to accommodate the requested - // dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone. - // If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will - // handle all the padding from 100x100 (the actual QR) up to 200x160. - int leftPadding = (outputWidth - (inputWidth * multiple)) / 2; - int topPadding = (outputHeight - (inputHeight * multiple)) / 2; - - var output = new BitMatrix(outputWidth, outputHeight); - - for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) - { - // Write the contents of this row of the barcode - for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) - { - if (input[inputX, inputY] == 1) - { - output.setRegion(outputX, outputY, multiple, multiple); - } - } - } - - return output; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/QRCodeWriter.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/QRCodeWriter.cs.meta deleted file mode 100644 index 495581365..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/QRCodeWriter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2ee3a948ed9bb4d84bee4f2cf72b8d83 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder.meta b/Runtime/zxing.unity/Source/lib/qrcode/decoder.meta deleted file mode 100644 index 230c14f86..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: caaaef42687be41e5b9f6735f23313a6 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/BitMatrixParser.cs b/Runtime/zxing.unity/Source/lib/qrcode/decoder/BitMatrixParser.cs deleted file mode 100644 index 792c1cfec..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/BitMatrixParser.cs +++ /dev/null @@ -1,279 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using ZXing.Common; - -namespace ZXing.QrCode.Internal -{ - /// Sean Owen - internal sealed class BitMatrixParser - { - private readonly BitMatrix bitMatrix; - private Version parsedVersion; - private FormatInformation parsedFormatInfo; - private bool mirrored; - - /// {@link BitMatrix} to parse - /// ReaderException if dimension is not >= 21 and 1 mod 4 - internal static BitMatrixParser createBitMatrixParser(BitMatrix bitMatrix) - { - int dimension = bitMatrix.Height; - if (dimension < 21 || (dimension & 0x03) != 1) - { - return null; - } - return new BitMatrixParser(bitMatrix); - } - - private BitMatrixParser(BitMatrix bitMatrix) - { - // Should only be called from createBitMatrixParser with the important checks before - this.bitMatrix = bitMatrix; - } - - ///

Reads format information from one of its two locations within the QR Code.

- /// - ///
- /// {@link FormatInformation} encapsulating the QR Code's format info - /// - /// ReaderException if both format information locations cannot be parsed as - /// the valid encoding of format information - /// - internal FormatInformation readFormatInformation() - { - if (parsedFormatInfo != null) - { - return parsedFormatInfo; - } - - // Read top-left format info bits - int formatInfoBits1 = 0; - for (int i = 0; i < 6; i++) - { - formatInfoBits1 = copyBit(i, 8, formatInfoBits1); - } - // .. and skip a bit in the timing pattern ... - formatInfoBits1 = copyBit(7, 8, formatInfoBits1); - formatInfoBits1 = copyBit(8, 8, formatInfoBits1); - formatInfoBits1 = copyBit(8, 7, formatInfoBits1); - // .. and skip a bit in the timing pattern ... - for (int j = 5; j >= 0; j--) - { - formatInfoBits1 = copyBit(8, j, formatInfoBits1); - } - // Read the top-right/bottom-left pattern too - int dimension = bitMatrix.Height; - int formatInfoBits2 = 0; - int jMin = dimension - 7; - for (int j = dimension - 1; j >= jMin; j--) - { - formatInfoBits2 = copyBit(8, j, formatInfoBits2); - } - for (int i = dimension - 8; i < dimension; i++) - { - formatInfoBits2 = copyBit(i, 8, formatInfoBits2); - } - - parsedFormatInfo = FormatInformation.decodeFormatInformation(formatInfoBits1, formatInfoBits2); - if (parsedFormatInfo != null) - { - return parsedFormatInfo; - } - return null; - } - - ///

Reads version information from one of its two locations within the QR Code.

- /// - ///
- /// {@link Version} encapsulating the QR Code's version - /// - /// ReaderException if both version information locations cannot be parsed as - /// the valid encoding of version information - /// - internal Version readVersion() - { - if (parsedVersion != null) - { - return parsedVersion; - } - - int dimension = bitMatrix.Height; - - int provisionalVersion = (dimension - 17) >> 2; - if (provisionalVersion <= 6) - { - return Version.getVersionForNumber(provisionalVersion); - } - - // Read top-right version info: 3 wide by 6 tall - int versionBits = 0; - int ijMin = dimension - 11; - for (int j = 5; j >= 0; j--) - { - for (int i = dimension - 9; i >= ijMin; i--) - { - versionBits = copyBit(i, j, versionBits); - } - } - - parsedVersion = Version.decodeVersionInformation(versionBits); - if (parsedVersion != null && parsedVersion.DimensionForVersion == dimension) - { - return parsedVersion; - } - - // Hmm, failed. Try bottom left: 6 wide by 3 tall - versionBits = 0; - for (int i = 5; i >= 0; i--) - { - for (int j = dimension - 9; j >= ijMin; j--) - { - versionBits = copyBit(i, j, versionBits); - } - } - - parsedVersion = Version.decodeVersionInformation(versionBits); - if (parsedVersion != null && parsedVersion.DimensionForVersion == dimension) - { - return parsedVersion; - } - return null; - } - - private int copyBit(int i, int j, int versionBits) - { - bool bit = mirrored ? bitMatrix[j, i] : bitMatrix[i, j]; - return bit ? (versionBits << 1) | 0x1 : versionBits << 1; - } - - ///

Reads the bits in the {@link BitMatrix} representing the finder pattern in the - /// correct order in order to reconstruct the codewords bytes contained within the - /// QR Code.

- /// - ///
- /// bytes encoded within the QR Code - /// - /// ReaderException if the exact number of bytes expected is not read - internal byte[] readCodewords() - { - FormatInformation formatInfo = readFormatInformation(); - if (formatInfo == null) - return null; - Version version = readVersion(); - if (version == null) - return null; - - // Get the data mask for the format used in this QR Code. This will exclude - // some bits from reading as we wind through the bit matrix. - int dimension = bitMatrix.Height; - DataMask.unmaskBitMatrix(formatInfo.DataMask, bitMatrix, dimension); - - BitMatrix functionPattern = version.buildFunctionPattern(); - - bool readingUp = true; - byte[] result = new byte[version.TotalCodewords]; - int resultOffset = 0; - int currentByte = 0; - int bitsRead = 0; - // Read columns in pairs, from right to left - for (int j = dimension - 1; j > 0; j -= 2) - { - if (j == 6) - { - // Skip whole column with vertical alignment pattern; - // saves time and makes the other code proceed more cleanly - j--; - } - // Read alternatingly from bottom to top then top to bottom - for (int count = 0; count < dimension; count++) - { - int i = readingUp ? dimension - 1 - count : count; - for (int col = 0; col < 2; col++) - { - // Ignore bits covered by the function pattern - if (!functionPattern[j - col, i]) - { - // Read a bit - bitsRead++; - currentByte <<= 1; - if (bitMatrix[j - col, i]) - { - currentByte |= 1; - } - // If we've made a whole byte, save it off - if (bitsRead == 8) - { - result[resultOffset++] = (byte)currentByte; - bitsRead = 0; - currentByte = 0; - } - } - } - } - readingUp ^= true; // readingUp = !readingUp; // switch directions - } - if (resultOffset != version.TotalCodewords) - { - return null; - } - return result; - } - - /** - * Revert the mask removal done while reading the code words. The bit matrix should revert to its original state. - */ - internal void remask() - { - if (parsedFormatInfo == null) - { - return; // We have no format information, and have no data mask - } - int dimension = bitMatrix.Height; - DataMask.unmaskBitMatrix(parsedFormatInfo.DataMask, bitMatrix, dimension); - } - - /** - * Prepare the parser for a mirrored operation. - * This flag has effect only on the {@link #readFormatInformation()} and the - * {@link #readVersion()}. Before proceeding with {@link #readCodewords()} the - * {@link #mirror()} method should be called. - * - * @param mirror Whether to read version and format information mirrored. - */ - internal void setMirror(bool mirror) - { - parsedVersion = null; - parsedFormatInfo = null; - mirrored = mirror; - } - - /** Mirror the bit matrix in order to attempt a second reading. */ - internal void mirror() - { - for (int x = 0; x < bitMatrix.Width; x++) - { - for (int y = x + 1; y < bitMatrix.Height; y++) - { - if (bitMatrix[x, y] != bitMatrix[y, x]) - { - bitMatrix.flip(y, x); - bitMatrix.flip(x, y); - } - } - } - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/BitMatrixParser.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/decoder/BitMatrixParser.cs.meta deleted file mode 100644 index 88d5be8fc..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/BitMatrixParser.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5c40f81bcb4454a32b8a2f06247f05a9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/DataBlock.cs b/Runtime/zxing.unity/Source/lib/qrcode/decoder/DataBlock.cs deleted file mode 100644 index 3bed570bf..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/DataBlock.cs +++ /dev/null @@ -1,146 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -namespace ZXing.QrCode.Internal -{ - ///

Encapsulates a block of data within a QR Code. QR Codes may split their data into - /// multiple blocks, each of which is a unit of data and error-correction codewords. Each - /// is represented by an instance of this class.

- /// - ///
- /// Sean Owen - /// - /// www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source - /// - internal sealed class DataBlock - { - private readonly int numDataCodewords; - private readonly byte[] codewords; - - private DataBlock(int numDataCodewords, byte[] codewords) - { - this.numDataCodewords = numDataCodewords; - this.codewords = codewords; - } - - ///

When QR Codes use multiple data blocks, they are actually interleaved. - /// That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This - /// method will separate the data into original blocks.

- /// - ///
- /// bytes as read directly from the QR Code - /// - /// version of the QR Code - /// - /// error-correction level of the QR Code - /// - /// {@link DataBlock}s containing original bytes, "de-interleaved" from representation in the - /// QR Code - /// - internal static DataBlock[] getDataBlocks(byte[] rawCodewords, Version version, ErrorCorrectionLevel ecLevel) - { - - if (rawCodewords.Length != version.TotalCodewords) - { - throw new System.ArgumentException(); - } - - // Figure out the number and size of data blocks used by this version and - // error correction level - Version.ECBlocks ecBlocks = version.getECBlocksForLevel(ecLevel); - - // First count the total number of data blocks - int totalBlocks = 0; - Version.ECB[] ecBlockArray = ecBlocks.getECBlocks(); - foreach (var ecBlock in ecBlockArray) - { - totalBlocks += ecBlock.Count; - } - - // Now establish DataBlocks of the appropriate size and number of data codewords - DataBlock[] result = new DataBlock[totalBlocks]; - int numResultBlocks = 0; - foreach (var ecBlock in ecBlockArray) - { - for (int i = 0; i < ecBlock.Count; i++) - { - int numDataCodewords = ecBlock.DataCodewords; - int numBlockCodewords = ecBlocks.ECCodewordsPerBlock + numDataCodewords; - result[numResultBlocks++] = new DataBlock(numDataCodewords, new byte[numBlockCodewords]); - } - } - - // All blocks have the same amount of data, except that the last n - // (where n may be 0) have 1 more byte. Figure out where these start. - int shorterBlocksTotalCodewords = result[0].codewords.Length; - int longerBlocksStartAt = result.Length - 1; - while (longerBlocksStartAt >= 0) - { - int numCodewords = result[longerBlocksStartAt].codewords.Length; - if (numCodewords == shorterBlocksTotalCodewords) - { - break; - } - longerBlocksStartAt--; - } - longerBlocksStartAt++; - - int shorterBlocksNumDataCodewords = shorterBlocksTotalCodewords - ecBlocks.ECCodewordsPerBlock; - // The last elements of result may be 1 element longer; - // first fill out as many elements as all of them have - int rawCodewordsOffset = 0; - for (int i = 0; i < shorterBlocksNumDataCodewords; i++) - { - for (int j = 0; j < numResultBlocks; j++) - { - result[j].codewords[i] = rawCodewords[rawCodewordsOffset++]; - } - } - // Fill out the last data block in the longer ones - for (int j = longerBlocksStartAt; j < numResultBlocks; j++) - { - result[j].codewords[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++]; - } - // Now add in error correction blocks - int max = result[0].codewords.Length; - for (int i = shorterBlocksNumDataCodewords; i < max; i++) - { - for (int j = 0; j < numResultBlocks; j++) - { - int iOffset = j < longerBlocksStartAt ? i : i + 1; - result[j].codewords[iOffset] = rawCodewords[rawCodewordsOffset++]; - } - } - return result; - } - - internal int NumDataCodewords - { - get - { - return numDataCodewords; - } - } - - internal byte[] Codewords - { - get - { - return codewords; - } - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/DataBlock.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/decoder/DataBlock.cs.meta deleted file mode 100644 index 1cbabdfdf..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/DataBlock.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 32f08a4833fe64c74967e2a451b5e83b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/DataMask.cs b/Runtime/zxing.unity/Source/lib/qrcode/decoder/DataMask.cs deleted file mode 100644 index 5fef1ff1f..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/DataMask.cs +++ /dev/null @@ -1,73 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -using System; - -using ZXing.Common; - -namespace ZXing.QrCode.Internal -{ - ///

Encapsulates data masks for the data bits in a QR code, per ISO 18004:2006 6.8. Implementations - /// of this class can un-mask a raw BitMatrix. For simplicity, they will unmask the entire BitMatrix, - /// including areas used for finder patterns, timing patterns, etc. These areas should be unused - /// after the point they are unmasked anyway.

- /// - ///

Note that the diagram in section 6.8.1 is misleading since it indicates that i is column position - /// and j is row position. In fact, as the text says, i is row position and j is column position.

- /// - ///
- /// Sean Owen - internal static class DataMask - { - /// See ISO 18004:2006 6.8.1 - private static readonly Func[] DATA_MASKS = new Func[] - { - // 000: mask bits for which (x + y) mod 2 == 0 - new Func((i, j) => ((i + j) & 0x01) == 0), - // 001: mask bits for which x mod 2 == 0 - new Func((i, j) => (i & 0x01) == 0), - // 010: mask bits for which y mod 3 == 0 - new Func((i, j) => j % 3 == 0), - // 011: mask bits for which (x + y) mod 3 == 0 - new Func((i, j) => (i + j) % 3 == 0), - // 100: mask bits for which (x/2 + y/3) mod 2 == 0 - new Func((i, j) => ((((int)((uint)i >> 1)) + (j / 3)) & 0x01) == 0), - // 101: mask bits for which xy mod 2 + xy mod 3 == 0, equivalently, such that xy mod 6 == 0 - new Func((i, j) => (i * j) % 6 == 0), - // 110: mask bits for which (xy mod 2 + xy mod 3) mod 2 == 0, equivalently, such that xy mod 6 < 3 - new Func((i, j) => ((i * j) % 6) < 3), - // 111: mask bits for which ((x+y)mod 2 + xy mod 3) mod 2 == 0, equivalently, such that (x + y + xy mod 3) mod 2 == 0 - new Func((i, j) => ((i + j + ((i * j) % 3)) & 0x01) == 0), - }; - - ///

Implementations of this method reverse the data masking process applied to a QR Code and - /// make its bits ready to read.

- ///
- /// - /// representation of QR Code bits - /// dimension of QR Code, represented by bits, being unmasked - internal static void unmaskBitMatrix(int reference, BitMatrix bits, int dimension) - { - if (reference < 0 || reference > 7) - { - throw new System.ArgumentException(); - } - - var isMasked = DATA_MASKS[reference]; - - bits.flipWhen(isMasked); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/DataMask.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/decoder/DataMask.cs.meta deleted file mode 100644 index a1b575bb6..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/DataMask.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c4cc02569589a4e0695eb5789b7b2da7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/DecodedBitStreamParser.cs b/Runtime/zxing.unity/Source/lib/qrcode/decoder/DecodedBitStreamParser.cs deleted file mode 100644 index 9a45826e5..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/DecodedBitStreamParser.cs +++ /dev/null @@ -1,474 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Collections.Generic; -using System.Text; - -using ZXing.Common; - -namespace ZXing.QrCode.Internal -{ - ///

QR Codes can encode text as bits in one of several modes, and can use multiple modes - /// in one QR Code. This class decodes the bits back into text.

- /// - ///

See ISO 18004:2006, 6.4.3 - 6.4.7

- /// Sean Owen - ///
- internal static class DecodedBitStreamParser - { - /// - /// See ISO 18004:2006, 6.4.4 Table 5 - /// - private static readonly char[] ALPHANUMERIC_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:".ToCharArray(); - private const int GB2312_SUBSET = 1; - - internal static DecoderResult decode(byte[] bytes, - Version version, - ErrorCorrectionLevel ecLevel, - IDictionary hints) - { - var bits = new BitSource(bytes); - var result = new StringBuilder(50); - var byteSegments = new List(1); - var symbolSequence = -1; - var parityData = -1; - int symbologyModifier; - - try - { - CharacterSetECI currentCharacterSetECI = null; - bool fc1InEffect = false; - bool hasFNC1first = false; - bool hasFNC1second = false; - Mode mode; - do - { - // While still another segment to read... - if (bits.available() < 4) - { - // OK, assume we're done. Really, a TERMINATOR mode should have been recorded here - mode = Mode.TERMINATOR; - } - else - { - try - { - mode = Mode.forBits(bits.readBits(4)); // mode is encoded by 4 bits - } - catch (ArgumentException) - { - return null; - } - } - switch (mode.Name) - { - case Mode.Names.TERMINATOR: - break; - case Mode.Names.FNC1_FIRST_POSITION: - hasFNC1first = true; // symbology detection - // We do little with FNC1 except alter the parsed result a bit according to the spec - fc1InEffect = true; - break; - case Mode.Names.FNC1_SECOND_POSITION: - hasFNC1second = true; // symbology detection - // We do little with FNC1 except alter the parsed result a bit according to the spec - fc1InEffect = true; - break; - case Mode.Names.STRUCTURED_APPEND: - if (bits.available() < 16) - { - return null; - } - // not really supported; but sequence number and parity is added later to the result metadata - // Read next 8 bits (symbol sequence #) and 8 bits (parity data), then continue - symbolSequence = bits.readBits(8); - parityData = bits.readBits(8); - break; - case Mode.Names.ECI: - // Count doesn't apply to ECI - int value = parseECIValue(bits); - currentCharacterSetECI = CharacterSetECI.getCharacterSetECIByValue(value); - if (currentCharacterSetECI == null) - { - return null; - } - break; - case Mode.Names.HANZI: - // First handle Hanzi mode which does not start with character count - //chinese mode contains a sub set indicator right after mode indicator - int subset = bits.readBits(4); - int countHanzi = bits.readBits(mode.getCharacterCountBits(version)); - if (subset == GB2312_SUBSET) - { - if (!decodeHanziSegment(bits, result, countHanzi)) - return null; - } - break; - default: - // "Normal" QR code modes: - // How many characters will follow, encoded in this mode? - int count = bits.readBits(mode.getCharacterCountBits(version)); - switch (mode.Name) - { - case Mode.Names.NUMERIC: - if (!decodeNumericSegment(bits, result, count)) - return null; - break; - case Mode.Names.ALPHANUMERIC: - if (!decodeAlphanumericSegment(bits, result, count, fc1InEffect)) - return null; - break; - case Mode.Names.BYTE: - if (!decodeByteSegment(bits, result, count, currentCharacterSetECI, byteSegments, hints)) - return null; - break; - case Mode.Names.KANJI: - if (!decodeKanjiSegment(bits, result, count)) - return null; - break; - default: - return null; - } - break; - } - } while (mode != Mode.TERMINATOR); - - if (currentCharacterSetECI != null) - { - if (hasFNC1first) - { - symbologyModifier = 4; - } - else if (hasFNC1second) - { - symbologyModifier = 6; - } - else - { - symbologyModifier = 2; - } - } - else - { - if (hasFNC1first) - { - symbologyModifier = 3; - } - else if (hasFNC1second) - { - symbologyModifier = 5; - } - else - { - symbologyModifier = 1; - } - } - } - catch (ArgumentException) - { - // from readBits() calls - return null; - } - - return new DecoderResult(bytes, - result.ToString(), - byteSegments.Count == 0 ? null : byteSegments, - ecLevel == null ? null : ecLevel.ToString(), - symbolSequence, parityData, symbologyModifier); - } - - /// - /// See specification GBT 18284-2000 - /// - /// The bits. - /// The result. - /// The count. - /// - private static bool decodeHanziSegment(BitSource bits, - StringBuilder result, - int count) - { - // Don't crash trying to read more bits than we have available. - if (count * 13 > bits.available()) - { - return false; - } - - // Each character will require 2 bytes. Read the characters as 2-byte pairs - // and decode as GB2312 afterwards - byte[] buffer = new byte[2 * count]; - int offset = 0; - while (count > 0) - { - // Each 13 bits encodes a 2-byte character - int twoBytes = bits.readBits(13); - int assembledTwoBytes = ((twoBytes / 0x060) << 8) | (twoBytes % 0x060); - if (assembledTwoBytes < 0x00A00) - { - // In the 0xA1A1 to 0xAAFE range - assembledTwoBytes += 0x0A1A1; - } - else - { - // In the 0xB0A1 to 0xFAFE range - assembledTwoBytes += 0x0A6A1; - } - buffer[offset] = (byte)((assembledTwoBytes >> 8) & 0xFF); - buffer[offset + 1] = (byte)(assembledTwoBytes & 0xFF); - offset += 2; - count--; - } - - var encoding = StringUtils.GB2312_ENCODING; - if (encoding == null) - encoding = StringUtils.PLATFORM_DEFAULT_ENCODING_T; - - result.Append(encoding.GetString(buffer, 0, buffer.Length)); - - return true; - } - - private static bool decodeKanjiSegment(BitSource bits, - StringBuilder result, - int count) - { - // Don't crash trying to read more bits than we have available. - if (count * 13 > bits.available()) - { - return false; - } - - // Each character will require 2 bytes. Read the characters as 2-byte pairs - // and decode as Shift_JIS afterwards - byte[] buffer = new byte[2 * count]; - int offset = 0; - while (count > 0) - { - // Each 13 bits encodes a 2-byte character - int twoBytes = bits.readBits(13); - int assembledTwoBytes = ((twoBytes / 0x0C0) << 8) | (twoBytes % 0x0C0); - if (assembledTwoBytes < 0x01F00) - { - // In the 0x8140 to 0x9FFC range - assembledTwoBytes += 0x08140; - } - else - { - // In the 0xE040 to 0xEBBF range - assembledTwoBytes += 0x0C140; - } - buffer[offset] = (byte)(assembledTwoBytes >> 8); - buffer[offset + 1] = (byte)assembledTwoBytes; - offset += 2; - count--; - } - // Shift_JIS may not be supported in some environments: - var encoding = StringUtils.SHIFT_JIS_ENCODING; - if (encoding == null) - encoding = StringUtils.PLATFORM_DEFAULT_ENCODING_T; - - result.Append(encoding.GetString(buffer, 0, buffer.Length)); - - return true; - } - - private static bool decodeByteSegment(BitSource bits, - StringBuilder result, - int count, - CharacterSetECI currentCharacterSetECI, - IList byteSegments, - IDictionary hints) - { - // Don't crash trying to read more bits than we have available. - if (count << 3 > bits.available()) - { - return false; - } - - byte[] readBytes = new byte[count]; - for (int i = 0; i < count; i++) - { - readBytes[i] = (byte)bits.readBits(8); - } - Encoding encoding; - if (currentCharacterSetECI == null) - { - // The spec isn't clear on this mode; see - // section 6.4.5: t does not say which encoding to assuming - // upon decoding. I have seen ISO-8859-1 used as well as - // Shift_JIS -- without anything like an ECI designator to - // give a hint. - encoding = StringUtils.guessCharset(readBytes, hints); - } - else - { - encoding = CharacterSetECI.getEncoding(currentCharacterSetECI.EncodingName); - } - if (encoding == null) - { - encoding = StringUtils.PLATFORM_DEFAULT_ENCODING_T; - } - result.Append(encoding.GetString(readBytes, 0, readBytes.Length)); - - byteSegments.Add(readBytes); - - return true; - } - - private static char toAlphaNumericChar(int value) - { - if (value >= ALPHANUMERIC_CHARS.Length) - { - throw new FormatException(); - } - return ALPHANUMERIC_CHARS[value]; - } - - private static bool decodeAlphanumericSegment(BitSource bits, - StringBuilder result, - int count, - bool fc1InEffect) - { - // Read two characters at a time - int start = result.Length; - while (count > 1) - { - if (bits.available() < 11) - { - return false; - } - int nextTwoCharsBits = bits.readBits(11); - result.Append(toAlphaNumericChar(nextTwoCharsBits / 45)); - result.Append(toAlphaNumericChar(nextTwoCharsBits % 45)); - count -= 2; - } - if (count == 1) - { - // special case: one character left - if (bits.available() < 6) - { - return false; - } - result.Append(toAlphaNumericChar(bits.readBits(6))); - } - - // See section 6.4.8.1, 6.4.8.2 - if (fc1InEffect) - { - // We need to massage the result a bit if in an FNC1 mode: - for (int i = start; i < result.Length; i++) - { - if (result[i] == '%') - { - if (i < result.Length - 1 && result[i + 1] == '%') - { - // %% is rendered as % - result.Remove(i + 1, 1); - } - else - { - // In alpha mode, % should be converted to FNC1 separator 0x1D - result.Remove(i, 1); - result.Insert(i, new[] { (char)0x1D }); - } - } - } - } - - return true; - } - - private static bool decodeNumericSegment(BitSource bits, - StringBuilder result, - int count) - { - // Read three digits at a time - while (count >= 3) - { - // Each 10 bits encodes three digits - if (bits.available() < 10) - { - return false; - } - int threeDigitsBits = bits.readBits(10); - if (threeDigitsBits >= 1000) - { - return false; - } - result.Append(toAlphaNumericChar(threeDigitsBits / 100)); - result.Append(toAlphaNumericChar((threeDigitsBits / 10) % 10)); - result.Append(toAlphaNumericChar(threeDigitsBits % 10)); - - count -= 3; - } - if (count == 2) - { - // Two digits left over to read, encoded in 7 bits - if (bits.available() < 7) - { - return false; - } - int twoDigitsBits = bits.readBits(7); - if (twoDigitsBits >= 100) - { - return false; - } - result.Append(toAlphaNumericChar(twoDigitsBits / 10)); - result.Append(toAlphaNumericChar(twoDigitsBits % 10)); - } - else if (count == 1) - { - // One digit left over to read - if (bits.available() < 4) - { - return false; - } - int digitBits = bits.readBits(4); - if (digitBits >= 10) - { - return false; - } - result.Append(toAlphaNumericChar(digitBits)); - } - - return true; - } - - private static int parseECIValue(BitSource bits) - { - int firstByte = bits.readBits(8); - if ((firstByte & 0x80) == 0) - { - // just one byte - return firstByte & 0x7F; - } - if ((firstByte & 0xC0) == 0x80) - { - // two bytes - int secondByte = bits.readBits(8); - return ((firstByte & 0x3F) << 8) | secondByte; - } - if ((firstByte & 0xE0) == 0xC0) - { - // three bytes - int secondThirdBytes = bits.readBits(16); - return ((firstByte & 0x1F) << 16) | secondThirdBytes; - } - throw new ArgumentException("Bad ECI bits starting with byte " + firstByte); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/DecodedBitStreamParser.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/decoder/DecodedBitStreamParser.cs.meta deleted file mode 100644 index 3b90d55e2..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/DecodedBitStreamParser.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2c03b24547e004ead90a31358241edcf -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/Decoder.cs b/Runtime/zxing.unity/Source/lib/qrcode/decoder/Decoder.cs deleted file mode 100644 index 5b2c76bc1..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/Decoder.cs +++ /dev/null @@ -1,186 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System.Collections.Generic; - -using ZXing.Common; -using ZXing.Common.ReedSolomon; - -namespace ZXing.QrCode.Internal -{ - /// - ///

The main class which implements QR Code decoding -- as opposed to locating and extracting - /// the QR Code from an image.

- ///
- /// - /// Sean Owen - /// - public sealed class Decoder - { - private readonly ReedSolomonDecoder rsDecoder; - - /// - /// Initializes a new instance of the class. - /// - public Decoder() - { - rsDecoder = new ReedSolomonDecoder(GenericGF.QR_CODE_FIELD_256); - } - - /// - ///

Convenience method that can decode a QR Code represented as a 2D array of booleans. - /// "true" is taken to mean a black module.

- ///
- /// booleans representing white/black QR Code modules - /// decoding hints that should be used to influence decoding - /// - /// text and bytes encoded within the QR Code - /// - public DecoderResult decode(bool[][] image, IDictionary hints) - { - return decode(BitMatrix.parse(image), hints); - } - - /// - ///

Decodes a QR Code represented as a {@link BitMatrix}. A 1 or "true" is taken to mean a black module.

- ///
- /// booleans representing white/black QR Code modules - /// decoding hints that should be used to influence decoding - /// - /// text and bytes encoded within the QR Code - /// - public DecoderResult decode(BitMatrix bits, IDictionary hints) - { - // Construct a parser and read version, error-correction level - var parser = BitMatrixParser.createBitMatrixParser(bits); - if (parser == null) - return null; - - var result = decode(parser, hints); - if (result == null) - { - // Revert the bit matrix - parser.remask(); - - // Will be attempting a mirrored reading of the version and format info. - parser.setMirror(true); - - // Preemptively read the version. - var version = parser.readVersion(); - if (version == null) - return null; - - // Preemptively read the format information. - var formatinfo = parser.readFormatInformation(); - if (formatinfo == null) - return null; - - /* - * Since we're here, this means we have successfully detected some kind - * of version and format information when mirrored. This is a good sign, - * that the QR code may be mirrored, and we should try once more with a - * mirrored content. - */ - // Prepare for a mirrored reading. - parser.mirror(); - - result = decode(parser, hints); - - if (result != null) - { - // Success! Notify the caller that the code was mirrored. - result.Other = new QRCodeDecoderMetaData(true); - } - } - - return result; - } - - private DecoderResult decode(BitMatrixParser parser, IDictionary hints) - { - Version version = parser.readVersion(); - if (version == null) - return null; - var formatinfo = parser.readFormatInformation(); - if (formatinfo == null) - return null; - ErrorCorrectionLevel ecLevel = formatinfo.ErrorCorrectionLevel; - - // Read codewords - byte[] codewords = parser.readCodewords(); - if (codewords == null) - return null; - // Separate into data blocks - DataBlock[] dataBlocks = DataBlock.getDataBlocks(codewords, version, ecLevel); - - // Count total number of data bytes - int totalBytes = 0; - foreach (var dataBlock in dataBlocks) - { - totalBytes += dataBlock.NumDataCodewords; - } - byte[] resultBytes = new byte[totalBytes]; - int resultOffset = 0; - - // Error-correct and copy data blocks together into a stream of bytes - foreach (var dataBlock in dataBlocks) - { - byte[] codewordBytes = dataBlock.Codewords; - int numDataCodewords = dataBlock.NumDataCodewords; - if (!correctErrors(codewordBytes, numDataCodewords)) - return null; - for (int i = 0; i < numDataCodewords; i++) - { - resultBytes[resultOffset++] = codewordBytes[i]; - } - } - - // Decode the contents of that stream of bytes - return DecodedBitStreamParser.decode(resultBytes, version, ecLevel, hints); - } - - /// - ///

Given data and error-correction codewords received, possibly corrupted by errors, attempts to - /// correct the errors in-place using Reed-Solomon error correction.

- ///
- /// data and error correction codewords - /// number of codewords that are data bytes - /// - private bool correctErrors(byte[] codewordBytes, int numDataCodewords) - { - int numCodewords = codewordBytes.Length; - // First read into an array of ints - int[] codewordsInts = new int[numCodewords]; - for (int i = 0; i < numCodewords; i++) - { - codewordsInts[i] = codewordBytes[i] & 0xFF; - } - int numECCodewords = codewordBytes.Length - numDataCodewords; - - if (!rsDecoder.decode(codewordsInts, numECCodewords)) - return false; - - // Copy back into array of bytes -- only need to worry about the bytes that were data - // We don't care about errors in the error-correction codewords - for (int i = 0; i < numDataCodewords; i++) - { - codewordBytes[i] = (byte)codewordsInts[i]; - } - - return true; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/Decoder.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/decoder/Decoder.cs.meta deleted file mode 100644 index c787b7432..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/Decoder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0b7ef0f6af7264083a6443cead8168a8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/ErrorCorrectionLevel.cs b/Runtime/zxing.unity/Source/lib/qrcode/decoder/ErrorCorrectionLevel.cs deleted file mode 100644 index be8613e6c..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/ErrorCorrectionLevel.cs +++ /dev/null @@ -1,109 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; - -namespace ZXing.QrCode.Internal -{ - /// - ///

See ISO 18004:2006, 6.5.1. This enum encapsulates the four error correction levels - /// defined by the QR code standard.

- ///
- /// Sean Owen - public sealed class ErrorCorrectionLevel - { - /// L = ~7% correction - public static readonly ErrorCorrectionLevel L = new ErrorCorrectionLevel(0, 0x01, "L"); - /// M = ~15% correction - public static readonly ErrorCorrectionLevel M = new ErrorCorrectionLevel(1, 0x00, "M"); - /// Q = ~25% correction - public static readonly ErrorCorrectionLevel Q = new ErrorCorrectionLevel(2, 0x03, "Q"); - /// H = ~30% correction - public static readonly ErrorCorrectionLevel H = new ErrorCorrectionLevel(3, 0x02, "H"); - - private static readonly ErrorCorrectionLevel[] FOR_BITS = new[] { M, L, H, Q }; - - private readonly int bits; - - private ErrorCorrectionLevel(int ordinal, int bits, String name) - { - this.ordinal_Renamed_Field = ordinal; - this.bits = bits; - this.name = name; - } - - /// - /// Gets the bits. - /// - public int Bits - { - get - { - return bits; - } - } - - /// - /// Gets the name. - /// - public String Name - { - get - { - return name; - } - } - - private readonly int ordinal_Renamed_Field; - private readonly String name; - - /// - /// Ordinals this instance. - /// - /// - public int ordinal() - { - return ordinal_Renamed_Field; - } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override String ToString() - { - return name; - } - - /// - /// Fors the bits. - /// - /// int containing the two bits encoding a QR Code's error correction level - /// - /// representing the encoded error correction level - /// - public static ErrorCorrectionLevel forBits(int bits) - { - if (bits < 0 || bits >= FOR_BITS.Length) - { - throw new ArgumentException(); - } - return FOR_BITS[bits]; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/ErrorCorrectionLevel.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/decoder/ErrorCorrectionLevel.cs.meta deleted file mode 100644 index 2639ba286..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/ErrorCorrectionLevel.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f9439194f73a24aa9889d3f67a0bff58 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/FormatInformation.cs b/Runtime/zxing.unity/Source/lib/qrcode/decoder/FormatInformation.cs deleted file mode 100644 index 6a7e6fc72..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/FormatInformation.cs +++ /dev/null @@ -1,197 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; - -namespace ZXing.QrCode.Internal -{ - - ///

Encapsulates a QR Code's format information, including the data mask used and - /// error correction level.

- /// - ///
- /// Sean Owen - /// - /// www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source - /// - /// - /// - /// - /// - internal sealed class FormatInformation - { - private const int FORMAT_INFO_MASK_QR = 0x5412; - - /// See ISO 18004:2006, Annex C, Table C.1 - private static readonly int[][] FORMAT_INFO_DECODE_LOOKUP = new int[][] - { - new [] { 0x5412, 0x00 }, - new [] { 0x5125, 0x01 }, - new [] { 0x5E7C, 0x02 }, - new [] { 0x5B4B, 0x03 }, - new [] { 0x45F9, 0x04 }, - new [] { 0x40CE, 0x05 }, - new [] { 0x4F97, 0x06 }, - new [] { 0x4AA0, 0x07 }, - new [] { 0x77C4, 0x08 }, - new [] { 0x72F3, 0x09 }, - new [] { 0x7DAA, 0x0A }, - new [] { 0x789D, 0x0B }, - new [] { 0x662F, 0x0C }, - new [] { 0x6318, 0x0D }, - new [] { 0x6C41, 0x0E }, - new [] { 0x6976, 0x0F }, - new [] { 0x1689, 0x10 }, - new [] { 0x13BE, 0x11 }, - new [] { 0x1CE7, 0x12 }, - new [] { 0x19D0, 0x13 }, - new [] { 0x0762, 0x14 }, - new [] { 0x0255, 0x15 }, - new [] { 0x0D0C, 0x16 }, - new [] { 0x083B, 0x17 }, - new [] { 0x355F, 0x18 }, - new [] { 0x3068, 0x19 }, - new [] { 0x3F31, 0x1A }, - new [] { 0x3A06, 0x1B }, - new [] { 0x24B4, 0x1C }, - new [] { 0x2183, 0x1D }, - new [] { 0x2EDA, 0x1E }, - new [] { 0x2BED, 0x1F } - }; - - /// Offset i holds the number of 1 bits in the binary representation of i - private static readonly int[] BITS_SET_IN_HALF_BYTE = new[] - { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; - - private readonly ErrorCorrectionLevel errorCorrectionLevel; - private readonly byte dataMask; - - private FormatInformation(int formatInfo) - { - // Bits 3,4 - errorCorrectionLevel = ErrorCorrectionLevel.forBits((formatInfo >> 3) & 0x03); - // Bottom 3 bits - dataMask = (byte)(formatInfo & 0x07); - } - - internal static int numBitsDiffering(int a, int b) - { - a ^= b; // a now has a 1 bit exactly where its bit differs with b's - // Count bits set quickly with a series of lookups: - return BITS_SET_IN_HALF_BYTE[a & 0x0F] + - BITS_SET_IN_HALF_BYTE[((int)((uint)a >> 4)) & 0x0F] + - BITS_SET_IN_HALF_BYTE[((int)((uint)a >> 8)) & 0x0F] + - BITS_SET_IN_HALF_BYTE[((int)((uint)a >> 12)) & 0x0F] + - BITS_SET_IN_HALF_BYTE[((int)((uint)a >> 16)) & 0x0F] + - BITS_SET_IN_HALF_BYTE[((int)((uint)a >> 20)) & 0x0F] + - BITS_SET_IN_HALF_BYTE[((int)((uint)a >> 24)) & 0x0F] + - BITS_SET_IN_HALF_BYTE[((int)((uint)a >> 28)) & 0x0F]; - } - - /// - /// Decodes the format information. - /// - /// format info indicator, with mask still applied - /// The masked format info2. - /// - /// information about the format it specifies, or null - /// if doesn't seem to match any known pattern - /// - internal static FormatInformation decodeFormatInformation(int maskedFormatInfo1, int maskedFormatInfo2) - { - FormatInformation formatInfo = doDecodeFormatInformation(maskedFormatInfo1, maskedFormatInfo2); - if (formatInfo != null) - { - return formatInfo; - } - // Should return null, but, some QR codes apparently - // do not mask this info. Try again by actually masking the pattern - // first - return doDecodeFormatInformation(maskedFormatInfo1 ^ FORMAT_INFO_MASK_QR, - maskedFormatInfo2 ^ FORMAT_INFO_MASK_QR); - } - - private static FormatInformation doDecodeFormatInformation(int maskedFormatInfo1, int maskedFormatInfo2) - { - // Find the int in FORMAT_INFO_DECODE_LOOKUP with fewest bits differing - int bestDifference = Int32.MaxValue; - int bestFormatInfo = 0; - foreach (var decodeInfo in FORMAT_INFO_DECODE_LOOKUP) - { - int targetInfo = decodeInfo[0]; - if (targetInfo == maskedFormatInfo1 || targetInfo == maskedFormatInfo2) - { - // Found an exact match - return new FormatInformation(decodeInfo[1]); - } - int bitsDifference = numBitsDiffering(maskedFormatInfo1, targetInfo); - if (bitsDifference < bestDifference) - { - bestFormatInfo = decodeInfo[1]; - bestDifference = bitsDifference; - } - if (maskedFormatInfo1 != maskedFormatInfo2) - { - // also try the other option - bitsDifference = numBitsDiffering(maskedFormatInfo2, targetInfo); - if (bitsDifference < bestDifference) - { - bestFormatInfo = decodeInfo[1]; - bestDifference = bitsDifference; - } - } - } - // Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits - // differing means we found a match - if (bestDifference <= 3) - { - return new FormatInformation(bestFormatInfo); - } - return null; - } - - internal ErrorCorrectionLevel ErrorCorrectionLevel - { - get - { - return errorCorrectionLevel; - } - } - - internal byte DataMask - { - get - { - return dataMask; - } - } - - public override int GetHashCode() - { - return (errorCorrectionLevel.ordinal() << 3) | dataMask; - } - - public override bool Equals(Object o) - { - if (!(o is FormatInformation)) - { - return false; - } - var other = (FormatInformation)o; - return errorCorrectionLevel == other.errorCorrectionLevel && dataMask == other.dataMask; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/FormatInformation.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/decoder/FormatInformation.cs.meta deleted file mode 100644 index 11da535aa..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/FormatInformation.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1b45c09079f5847eba412f57f53c55e0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/Mode.cs b/Runtime/zxing.unity/Source/lib/qrcode/decoder/Mode.cs deleted file mode 100644 index f267c510f..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/Mode.cs +++ /dev/null @@ -1,214 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; - -namespace ZXing.QrCode.Internal -{ - /// - ///

See ISO 18004:2006, 6.4.1, Tables 2 and 3. This enum encapsulates the various modes in which - /// data can be encoded to bits in the QR code standard.

- ///
- /// Sean Owen - public sealed class Mode - { - /// - /// Gets the name. - /// - public Names Name { get; private set; } - - /// - /// enumeration for encoding modes - /// - public enum Names - { - /// - /// - /// - TERMINATOR, - /// - /// numeric encoding - /// - NUMERIC, - /// - /// alpha-numeric encoding - /// - ALPHANUMERIC, - /// - /// structured append - /// - STRUCTURED_APPEND, - /// - /// byte mode encoding - /// - BYTE, - /// - /// ECI segment - /// - ECI, - /// - /// Kanji mode - /// - KANJI, - /// - /// FNC1 char, first position - /// - FNC1_FIRST_POSITION, - /// - /// FNC1 char, second position - /// - FNC1_SECOND_POSITION, - /// - /// Hanzi mode - /// - HANZI - } - - // No, we can't use an enum here. J2ME doesn't support it. - - /// - /// Not really a mode... - /// - public static readonly Mode TERMINATOR = new Mode(new int[] { 0, 0, 0 }, 0x00, Names.TERMINATOR); - /// - /// - /// - public static readonly Mode NUMERIC = new Mode(new int[] { 10, 12, 14 }, 0x01, Names.NUMERIC); - /// - /// - /// - public static readonly Mode ALPHANUMERIC = new Mode(new int[] { 9, 11, 13 }, 0x02, Names.ALPHANUMERIC); - /// - /// Not supported - /// - public static readonly Mode STRUCTURED_APPEND = new Mode(new int[] { 0, 0, 0 }, 0x03, Names.STRUCTURED_APPEND); - /// - /// - /// - public static readonly Mode BYTE = new Mode(new int[] { 8, 16, 16 }, 0x04, Names.BYTE); - /// - /// character counts don't apply - /// - public static readonly Mode ECI = new Mode(new int[] { 0, 0, 0 }, 0x07, Names.ECI); - /// - /// - /// - public static readonly Mode KANJI = new Mode(new int[] { 8, 10, 12 }, 0x08, Names.KANJI); - /// - /// - /// - public static readonly Mode FNC1_FIRST_POSITION = new Mode(new int[] { 0, 0, 0 }, 0x05, Names.FNC1_FIRST_POSITION); - /// - /// - /// - public static readonly Mode FNC1_SECOND_POSITION = new Mode(new int[] { 0, 0, 0 }, 0x09, Names.FNC1_SECOND_POSITION); - /// - /// See GBT 18284-2000; "Hanzi" is a transliteration of this mode name. - /// - public static readonly Mode HANZI = new Mode(new int[] { 8, 10, 12 }, 0x0D, Names.HANZI); - - private readonly int[] characterCountBitsForVersions; - - private Mode(int[] characterCountBitsForVersions, int bits, Names name) - { - this.characterCountBitsForVersions = characterCountBitsForVersions; - Bits = bits; - Name = name; - } - - /// - /// Fors the bits. - /// - /// four bits encoding a QR Code data mode - /// - /// encoded by these bits - /// - /// if bits do not correspond to a known mode - public static Mode forBits(int bits) - { - switch (bits) - { - case 0x0: - return TERMINATOR; - case 0x1: - return NUMERIC; - case 0x2: - return ALPHANUMERIC; - case 0x3: - return STRUCTURED_APPEND; - case 0x4: - return BYTE; - case 0x5: - return FNC1_FIRST_POSITION; - case 0x7: - return ECI; - case 0x8: - return KANJI; - case 0x9: - return FNC1_SECOND_POSITION; - case 0xD: - // 0xD is defined in GBT 18284-2000, may not be supported in foreign country - return HANZI; - default: - throw new ArgumentException(); - } - } - - /// version in question - /// - /// number of bits used, in this QR Code symbol {@link Version}, to encode the - /// count of characters that will follow encoded in this {@link Mode} - /// - public int getCharacterCountBits(Version version) - { - if (characterCountBitsForVersions == null) - { - throw new ArgumentException("Character count doesn't apply to this mode"); - } - int number = version.VersionNumber; - int offset; - if (number <= 9) - { - offset = 0; - } - else if (number <= 26) - { - offset = 1; - } - else - { - offset = 2; - } - return characterCountBitsForVersions[offset]; - } - - /// - /// Gets the bits. - /// - public int Bits { get; private set; } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override String ToString() - { - return Name.ToString(); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/Mode.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/decoder/Mode.cs.meta deleted file mode 100644 index 869772be2..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/Mode.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 761f7a29c35124374b6ba75e087143d2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/QRCodeDecoderMetaData.cs b/Runtime/zxing.unity/Source/lib/qrcode/decoder/QRCodeDecoderMetaData.cs deleted file mode 100644 index e88589fc5..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/QRCodeDecoderMetaData.cs +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2013 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace ZXing.QrCode.Internal -{ - /// - /// Meta-data container for QR Code decoding. Instances of this class may be used to convey information back to the - /// decoding caller. Callers are expected to process this. - /// - public sealed class QRCodeDecoderMetaData - { - private readonly bool mirrored; - - /// - /// Initializes a new instance of the class. - /// - /// if set to true [mirrored]. - public QRCodeDecoderMetaData(bool mirrored) - { - this.mirrored = mirrored; - } - - /// - /// true if the QR Code was mirrored. - /// - public bool IsMirrored - { - get { return mirrored; } - } - - /// - /// Apply the result points' order correction due to mirroring. - /// - /// Array of points to apply mirror correction to. - public void applyMirroredCorrection(ResultPoint[] points) - { - if (!mirrored || points == null || points.Length < 3) - { - return; - } - ResultPoint bottomLeft = points[0]; - points[0] = points[2]; - points[2] = bottomLeft; - // No need to 'fix' top-left and alignment pattern. - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/QRCodeDecoderMetaData.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/decoder/QRCodeDecoderMetaData.cs.meta deleted file mode 100644 index 5d1700b25..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/QRCodeDecoderMetaData.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d86606e18f28340bcb223bf0eaac6619 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/Version.cs b/Runtime/zxing.unity/Source/lib/qrcode/decoder/Version.cs deleted file mode 100644 index 059498140..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/Version.cs +++ /dev/null @@ -1,684 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; - -using ZXing.Common; - -namespace ZXing.QrCode.Internal -{ - /// - /// See ISO 18004:2006 Annex D - /// - /// Sean Owen - public sealed class Version - { - /// See ISO 18004:2006 Annex D. - /// Element i represents the raw version bits that specify version i + 7 - /// - private static readonly int[] VERSION_DECODE_INFO = new[] - { - 0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, - 0x0C762, 0x0D847, 0x0E60D, 0x0F928, 0x10B78, - 0x1145D, 0x12A17, 0x13532, 0x149A6, 0x15683, - 0x168C9, 0x177EC, 0x18EC4, 0x191E1, 0x1AFAB, - 0x1B08E, 0x1CC1A, 0x1D33F, 0x1ED75, 0x1F250, - 0x209D5, 0x216F0, 0x228BA, 0x2379F, 0x24B0B, - 0x2542E, 0x26A64, 0x27541, 0x28C69 - }; - - private static readonly Version[] VERSIONS = buildVersions(); - - private readonly int versionNumber; - private readonly int[] alignmentPatternCenters; - private readonly ECBlocks[] ecBlocks; - private readonly int totalCodewords; - - private Version(int versionNumber, int[] alignmentPatternCenters, params ECBlocks[] ecBlocks) - { - this.versionNumber = versionNumber; - this.alignmentPatternCenters = alignmentPatternCenters; - this.ecBlocks = ecBlocks; - int total = 0; - int ecCodewords = ecBlocks[0].ECCodewordsPerBlock; - ECB[] ecbArray = ecBlocks[0].getECBlocks(); - foreach (var ecBlock in ecbArray) - { - total += ecBlock.Count * (ecBlock.DataCodewords + ecCodewords); - } - this.totalCodewords = total; - } - - /// - /// Gets the version number. - /// - public int VersionNumber - { - get - { - return versionNumber; - } - - } - - /// - /// Gets the alignment pattern centers. - /// - public int[] AlignmentPatternCenters - { - get - { - return alignmentPatternCenters; - } - - } - - /// - /// Gets the total codewords. - /// - public int TotalCodewords - { - get - { - return totalCodewords; - } - - } - - /// - /// Gets the dimension for version. - /// - public int DimensionForVersion - { - get - { - return 17 + 4 * versionNumber; - } - - } - - /// - /// Gets the EC blocks for level. - /// - /// The ec level. - /// - public ECBlocks getECBlocksForLevel(ErrorCorrectionLevel ecLevel) - { - return ecBlocks[ecLevel.ordinal()]; - } - - ///

Deduces version information purely from QR Code dimensions.

- /// - ///
- /// dimension in modules - /// - /// for a QR Code of that dimension or null - public static Version getProvisionalVersionForDimension(int dimension) - { - if (dimension % 4 != 1) - { - return null; - } - try - { - return getVersionForNumber((dimension - 17) >> 2); - } - catch (ArgumentException) - { - return null; - } - } - - /// - /// Gets the version for number. - /// - /// The version number. - /// - public static Version getVersionForNumber(int versionNumber) - { - if (versionNumber < 1 || versionNumber > 40) - { - throw new ArgumentException(); - } - return VERSIONS[versionNumber - 1]; - } - - internal static Version decodeVersionInformation(int versionBits) - { - int bestDifference = Int32.MaxValue; - int bestVersion = 0; - for (int i = 0; i < VERSION_DECODE_INFO.Length; i++) - { - int targetVersion = VERSION_DECODE_INFO[i]; - // Do the version info bits match exactly? done. - if (targetVersion == versionBits) - { - return getVersionForNumber(i + 7); - } - // Otherwise see if this is the closest to a real version info bit string - // we have seen so far - int bitsDifference = FormatInformation.numBitsDiffering(versionBits, targetVersion); - if (bitsDifference < bestDifference) - { - bestVersion = i + 7; - bestDifference = bitsDifference; - } - } - // We can tolerate up to 3 bits of error since no two version info codewords will - // differ in less than 8 bits. - if (bestDifference <= 3) - { - return getVersionForNumber(bestVersion); - } - // If we didn't find a close enough match, fail - return null; - } - - /// See ISO 18004:2006 Annex E - internal BitMatrix buildFunctionPattern() - { - int dimension = DimensionForVersion; - BitMatrix bitMatrix = new BitMatrix(dimension); - - // Top left finder pattern + separator + format - bitMatrix.setRegion(0, 0, 9, 9); - // Top right finder pattern + separator + format - bitMatrix.setRegion(dimension - 8, 0, 8, 9); - // Bottom left finder pattern + separator + format - bitMatrix.setRegion(0, dimension - 8, 9, 8); - - // Alignment patterns - int max = alignmentPatternCenters.Length; - for (int x = 0; x < max; x++) - { - int i = alignmentPatternCenters[x] - 2; - for (int y = 0; y < max; y++) - { - if ((x != 0 || (y != 0 && y != max - 1)) && (x != max - 1 || y != 0)) - { - bitMatrix.setRegion(alignmentPatternCenters[y] - 2, i, 5, 5); - } - // else no o alignment patterns near the three finder patterns - } - } - - // Vertical timing pattern - bitMatrix.setRegion(6, 9, 1, dimension - 17); - // Horizontal timing pattern - bitMatrix.setRegion(9, 6, dimension - 17, 1); - - if (versionNumber > 6) - { - // Version info, top right - bitMatrix.setRegion(dimension - 11, 0, 3, 6); - // Version info, bottom left - bitMatrix.setRegion(0, dimension - 11, 6, 3); - } - - return bitMatrix; - } - - ///

Encapsulates a set of error-correction blocks in one symbol version. Most versions will - /// use blocks of differing sizes within one version, so, this encapsulates the parameters for - /// each set of blocks. It also holds the number of error-correction codewords per block since it - /// will be the same across all blocks within one version.

- ///
- public sealed class ECBlocks - { - private readonly int ecCodewordsPerBlock; - private readonly ECB[] ecBlocks; - - internal ECBlocks(int ecCodewordsPerBlock, params ECB[] ecBlocks) - { - this.ecCodewordsPerBlock = ecCodewordsPerBlock; - this.ecBlocks = ecBlocks; - } - - /// - /// Gets the EC codewords per block. - /// - public int ECCodewordsPerBlock - { - get - { - return ecCodewordsPerBlock; - } - } - - /// - /// Gets the num blocks. - /// - public int NumBlocks - { - get - { - int total = 0; - foreach (var ecBlock in ecBlocks) - { - total += ecBlock.Count; - } - return total; - } - } - - /// - /// Gets the total EC codewords. - /// - public int TotalECCodewords - { - get - { - return ecCodewordsPerBlock * NumBlocks; - } - } - - /// - /// Gets the EC blocks. - /// - /// - public ECB[] getECBlocks() - { - return ecBlocks; - } - } - - ///

Encapsulates the parameters for one error-correction block in one symbol version. - /// This includes the number of data codewords, and the number of times a block with these - /// parameters is used consecutively in the QR code version's format.

- ///
- public sealed class ECB - { - private readonly int count; - private readonly int dataCodewords; - - internal ECB(int count, int dataCodewords) - { - this.count = count; - this.dataCodewords = dataCodewords; - } - - /// - /// Gets the count. - /// - public int Count - { - get - { - return count; - } - - } - /// - /// Gets the data codewords. - /// - public int DataCodewords - { - get - { - return dataCodewords; - } - - } - } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override String ToString() - { - return Convert.ToString(versionNumber); - } - - /// See ISO 18004:2006 6.5.1 Table 9 - private static Version[] buildVersions() - { - return new Version[] - { - new Version(1, new int[] {}, - new ECBlocks(7, new ECB(1, 19)), - new ECBlocks(10, new ECB(1, 16)), - new ECBlocks(13, new ECB(1, 13)), - new ECBlocks(17, new ECB(1, 9))), - new Version(2, new int[] {6, 18}, - new ECBlocks(10, new ECB(1, 34)), - new ECBlocks(16, new ECB(1, 28)), - new ECBlocks(22, new ECB(1, 22)), - new ECBlocks(28, new ECB(1, 16))), - new Version(3, new int[] {6, 22}, - new ECBlocks(15, new ECB(1, 55)), - new ECBlocks(26, new ECB(1, 44)), - new ECBlocks(18, new ECB(2, 17)), - new ECBlocks(22, new ECB(2, 13))), - new Version(4, new int[] {6, 26}, - new ECBlocks(20, new ECB(1, 80)), - new ECBlocks(18, new ECB(2, 32)), - new ECBlocks(26, new ECB(2, 24)), - new ECBlocks(16, new ECB(4, 9))), - new Version(5, new int[] {6, 30}, - new ECBlocks(26, new ECB(1, 108)), - new ECBlocks(24, new ECB(2, 43)), - new ECBlocks(18, new ECB(2, 15), - new ECB(2, 16)), - new ECBlocks(22, new ECB(2, 11), - new ECB(2, 12))), - new Version(6, new int[] {6, 34}, - new ECBlocks(18, new ECB(2, 68)), - new ECBlocks(16, new ECB(4, 27)), - new ECBlocks(24, new ECB(4, 19)), - new ECBlocks(28, new ECB(4, 15))), - new Version(7, new int[] {6, 22, 38}, - new ECBlocks(20, new ECB(2, 78)), - new ECBlocks(18, new ECB(4, 31)), - new ECBlocks(18, new ECB(2, 14), - new ECB(4, 15)), - new ECBlocks(26, new ECB(4, 13), - new ECB(1, 14))), - new Version(8, new int[] {6, 24, 42}, - new ECBlocks(24, new ECB(2, 97)), - new ECBlocks(22, new ECB(2, 38), - new ECB(2, 39)), - new ECBlocks(22, new ECB(4, 18), - new ECB(2, 19)), - new ECBlocks(26, new ECB(4, 14), - new ECB(2, 15))), - new Version(9, new int[] {6, 26, 46}, - new ECBlocks(30, new ECB(2, 116)), - new ECBlocks(22, new ECB(3, 36), - new ECB(2, 37)), - new ECBlocks(20, new ECB(4, 16), - new ECB(4, 17)), - new ECBlocks(24, new ECB(4, 12), - new ECB(4, 13))), - new Version(10, new int[] {6, 28, 50}, - new ECBlocks(18, new ECB(2, 68), - new ECB(2, 69)), - new ECBlocks(26, new ECB(4, 43), - new ECB(1, 44)), - new ECBlocks(24, new ECB(6, 19), - new ECB(2, 20)), - new ECBlocks(28, new ECB(6, 15), - new ECB(2, 16))), - new Version(11, new int[] {6, 30, 54}, - new ECBlocks(20, new ECB(4, 81)), - new ECBlocks(30, new ECB(1, 50), - new ECB(4, 51)), - new ECBlocks(28, new ECB(4, 22), - new ECB(4, 23)), - new ECBlocks(24, new ECB(3, 12), - new ECB(8, 13))), - new Version(12, new int[] {6, 32, 58}, - new ECBlocks(24, new ECB(2, 92), - new ECB(2, 93)), - new ECBlocks(22, new ECB(6, 36), - new ECB(2, 37)), - new ECBlocks(26, new ECB(4, 20), - new ECB(6, 21)), - new ECBlocks(28, new ECB(7, 14), - new ECB(4, 15))), - new Version(13, new int[] {6, 34, 62}, - new ECBlocks(26, new ECB(4, 107)), - new ECBlocks(22, new ECB(8, 37), - new ECB(1, 38)), - new ECBlocks(24, new ECB(8, 20), - new ECB(4, 21)), - new ECBlocks(22, new ECB(12, 11), - new ECB(4, 12))), - new Version(14, new int[] {6, 26, 46, 66}, - new ECBlocks(30, new ECB(3, 115), - new ECB(1, 116)), - new ECBlocks(24, new ECB(4, 40), - new ECB(5, 41)), - new ECBlocks(20, new ECB(11, 16), - new ECB(5, 17)), - new ECBlocks(24, new ECB(11, 12), - new ECB(5, 13))), - new Version(15, new int[] {6, 26, 48, 70}, - new ECBlocks(22, new ECB(5, 87), - new ECB(1, 88)), - new ECBlocks(24, new ECB(5, 41), - new ECB(5, 42)), - new ECBlocks(30, new ECB(5, 24), - new ECB(7, 25)), - new ECBlocks(24, new ECB(11, 12), - new ECB(7, 13))), - new Version(16, new int[] {6, 26, 50, 74}, - new ECBlocks(24, new ECB(5, 98), - new ECB(1, 99)), - new ECBlocks(28, new ECB(7, 45), - new ECB(3, 46)), - new ECBlocks(24, new ECB(15, 19), - new ECB(2, 20)), - new ECBlocks(30, new ECB(3, 15), - new ECB(13, 16))), - new Version(17, new int[] {6, 30, 54, 78}, - new ECBlocks(28, new ECB(1, 107), - new ECB(5, 108)), - new ECBlocks(28, new ECB(10, 46), - new ECB(1, 47)), - new ECBlocks(28, new ECB(1, 22), - new ECB(15, 23)), - new ECBlocks(28, new ECB(2, 14), - new ECB(17, 15))), - new Version(18, new int[] {6, 30, 56, 82}, - new ECBlocks(30, new ECB(5, 120), - new ECB(1, 121)), - new ECBlocks(26, new ECB(9, 43), - new ECB(4, 44)), - new ECBlocks(28, new ECB(17, 22), - new ECB(1, 23)), - new ECBlocks(28, new ECB(2, 14), - new ECB(19, 15))), - new Version(19, new int[] {6, 30, 58, 86}, - new ECBlocks(28, new ECB(3, 113), - new ECB(4, 114)), - new ECBlocks(26, new ECB(3, 44), - new ECB(11, 45)), - new ECBlocks(26, new ECB(17, 21), - new ECB(4, 22)), - new ECBlocks(26, new ECB(9, 13), - new ECB(16, 14))), - new Version(20, new int[] {6, 34, 62, 90}, - new ECBlocks(28, new ECB(3, 107), - new ECB(5, 108)), - new ECBlocks(26, new ECB(3, 41), - new ECB(13, 42)), - new ECBlocks(30, new ECB(15, 24), - new ECB(5, 25)), - new ECBlocks(28, new ECB(15, 15), - new ECB(10, 16))), - new Version(21, new int[] {6, 28, 50, 72, 94}, - new ECBlocks(28, new ECB(4, 116), - new ECB(4, 117)), - new ECBlocks(26, new ECB(17, 42)), - new ECBlocks(28, new ECB(17, 22), - new ECB(6, 23)), - new ECBlocks(30, new ECB(19, 16), - new ECB(6, 17))), - new Version(22, new int[] {6, 26, 50, 74, 98}, - new ECBlocks(28, new ECB(2, 111), - new ECB(7, 112)), - new ECBlocks(28, new ECB(17, 46)), - new ECBlocks(30, new ECB(7, 24), - new ECB(16, 25)), - new ECBlocks(24, new ECB(34, 13))), - new Version(23, new int[] {6, 30, 54, 78, 102}, - new ECBlocks(30, new ECB(4, 121), - new ECB(5, 122)), - new ECBlocks(28, new ECB(4, 47), - new ECB(14, 48)), - new ECBlocks(30, new ECB(11, 24), - new ECB(14, 25)), - new ECBlocks(30, new ECB(16, 15), - new ECB(14, 16))), - new Version(24, new int[] {6, 28, 54, 80, 106}, - new ECBlocks(30, new ECB(6, 117), - new ECB(4, 118)), - new ECBlocks(28, new ECB(6, 45), - new ECB(14, 46)), - new ECBlocks(30, new ECB(11, 24), - new ECB(16, 25)), - new ECBlocks(30, new ECB(30, 16), - new ECB(2, 17))), - new Version(25, new int[] {6, 32, 58, 84, 110}, - new ECBlocks(26, new ECB(8, 106), - new ECB(4, 107)), - new ECBlocks(28, new ECB(8, 47), - new ECB(13, 48)), - new ECBlocks(30, new ECB(7, 24), - new ECB(22, 25)), - new ECBlocks(30, new ECB(22, 15), - new ECB(13, 16))), - new Version(26, new int[] {6, 30, 58, 86, 114}, - new ECBlocks(28, new ECB(10, 114), - new ECB(2, 115)), - new ECBlocks(28, new ECB(19, 46), - new ECB(4, 47)), - new ECBlocks(28, new ECB(28, 22), - new ECB(6, 23)), - new ECBlocks(30, new ECB(33, 16), - new ECB(4, 17))), - new Version(27, new int[] {6, 34, 62, 90, 118}, - new ECBlocks(30, new ECB(8, 122), - new ECB(4, 123)), - new ECBlocks(28, new ECB(22, 45), - new ECB(3, 46)), - new ECBlocks(30, new ECB(8, 23), - new ECB(26, 24)), - new ECBlocks(30, new ECB(12, 15), - new ECB(28, 16))), - new Version(28, new int[] {6, 26, 50, 74, 98, 122}, - new ECBlocks(30, new ECB(3, 117), - new ECB(10, 118)), - new ECBlocks(28, new ECB(3, 45), - new ECB(23, 46)), - new ECBlocks(30, new ECB(4, 24), - new ECB(31, 25)), - new ECBlocks(30, new ECB(11, 15), - new ECB(31, 16))), - new Version(29, new int[] {6, 30, 54, 78, 102, 126}, - new ECBlocks(30, new ECB(7, 116), - new ECB(7, 117)), - new ECBlocks(28, new ECB(21, 45), - new ECB(7, 46)), - new ECBlocks(30, new ECB(1, 23), - new ECB(37, 24)), - new ECBlocks(30, new ECB(19, 15), - new ECB(26, 16))), - new Version(30, new int[] {6, 26, 52, 78, 104, 130}, - new ECBlocks(30, new ECB(5, 115), - new ECB(10, 116)), - new ECBlocks(28, new ECB(19, 47), - new ECB(10, 48)), - new ECBlocks(30, new ECB(15, 24), - new ECB(25, 25)), - new ECBlocks(30, new ECB(23, 15), - new ECB(25, 16))), - new Version(31, new int[] {6, 30, 56, 82, 108, 134}, - new ECBlocks(30, new ECB(13, 115), - new ECB(3, 116)), - new ECBlocks(28, new ECB(2, 46), - new ECB(29, 47)), - new ECBlocks(30, new ECB(42, 24), - new ECB(1, 25)), - new ECBlocks(30, new ECB(23, 15), - new ECB(28, 16))), - new Version(32, new int[] {6, 34, 60, 86, 112, 138}, - new ECBlocks(30, new ECB(17, 115)), - new ECBlocks(28, new ECB(10, 46), - new ECB(23, 47)), - new ECBlocks(30, new ECB(10, 24), - new ECB(35, 25)), - new ECBlocks(30, new ECB(19, 15), - new ECB(35, 16))), - new Version(33, new int[] {6, 30, 58, 86, 114, 142}, - new ECBlocks(30, new ECB(17, 115), - new ECB(1, 116)), - new ECBlocks(28, new ECB(14, 46), - new ECB(21, 47)), - new ECBlocks(30, new ECB(29, 24), - new ECB(19, 25)), - new ECBlocks(30, new ECB(11, 15), - new ECB(46, 16))), - new Version(34, new int[] {6, 34, 62, 90, 118, 146}, - new ECBlocks(30, new ECB(13, 115), - new ECB(6, 116)), - new ECBlocks(28, new ECB(14, 46), - new ECB(23, 47)), - new ECBlocks(30, new ECB(44, 24), - new ECB(7, 25)), - new ECBlocks(30, new ECB(59, 16), - new ECB(1, 17))), - new Version(35, new int[] {6, 30, 54, 78, 102, 126, 150}, - new ECBlocks(30, new ECB(12, 121), - new ECB(7, 122)), - new ECBlocks(28, new ECB(12, 47), - new ECB(26, 48)), - new ECBlocks(30, new ECB(39, 24), - new ECB(14, 25)), - new ECBlocks(30, new ECB(22, 15), - new ECB(41, 16))), - new Version(36, new int[] {6, 24, 50, 76, 102, 128, 154}, - new ECBlocks(30, new ECB(6, 121), - new ECB(14, 122)), - new ECBlocks(28, new ECB(6, 47), - new ECB(34, 48)), - new ECBlocks(30, new ECB(46, 24), - new ECB(10, 25)), - new ECBlocks(30, new ECB(2, 15), - new ECB(64, 16))), - new Version(37, new int[] {6, 28, 54, 80, 106, 132, 158}, - new ECBlocks(30, new ECB(17, 122), - new ECB(4, 123)), - new ECBlocks(28, new ECB(29, 46), - new ECB(14, 47)), - new ECBlocks(30, new ECB(49, 24), - new ECB(10, 25)), - new ECBlocks(30, new ECB(24, 15), - new ECB(46, 16))), - new Version(38, new int[] {6, 32, 58, 84, 110, 136, 162}, - new ECBlocks(30, new ECB(4, 122), - new ECB(18, 123)), - new ECBlocks(28, new ECB(13, 46), - new ECB(32, 47)), - new ECBlocks(30, new ECB(48, 24), - new ECB(14, 25)), - new ECBlocks(30, new ECB(42, 15), - new ECB(32, 16))), - new Version(39, new int[] {6, 26, 54, 82, 110, 138, 166}, - new ECBlocks(30, new ECB(20, 117), - new ECB(4, 118)), - new ECBlocks(28, new ECB(40, 47), - new ECB(7, 48)), - new ECBlocks(30, new ECB(43, 24), - new ECB(22, 25)), - new ECBlocks(30, new ECB(10, 15), - new ECB(67, 16))), - new Version(40, new int[] {6, 30, 58, 86, 114, 142, 170}, - new ECBlocks(30, new ECB(19, 118), - new ECB(6, 119)), - new ECBlocks(28, new ECB(18, 47), - new ECB(31, 48)), - new ECBlocks(30, new ECB(34, 24), - new ECB(34, 25)), - new ECBlocks(30, new ECB(20, 15), - new ECB(61, 16))) - }; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/decoder/Version.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/decoder/Version.cs.meta deleted file mode 100644 index 1e727d260..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/decoder/Version.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 56747d531a4044d3e9f5500c5db733bb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/detector.meta b/Runtime/zxing.unity/Source/lib/qrcode/detector.meta deleted file mode 100644 index 210336ced..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/detector.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: dd6942497538b4ad1af9eec676392d92 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/detector/AlignmentPattern.cs b/Runtime/zxing.unity/Source/lib/qrcode/detector/AlignmentPattern.cs deleted file mode 100644 index 2b7d44199..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/detector/AlignmentPattern.cs +++ /dev/null @@ -1,68 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; - -namespace ZXing.QrCode.Internal -{ - ///

Encapsulates an alignment pattern, which are the smaller square patterns found in - /// all but the simplest QR Codes.

- /// - ///
- /// Sean Owen - /// - /// www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source - /// - public sealed class AlignmentPattern : ResultPoint - { - private float estimatedModuleSize; - - internal AlignmentPattern(float posX, float posY, float estimatedModuleSize) - : base(posX, posY) - { - this.estimatedModuleSize = estimatedModuleSize; - } - - ///

Determines if this alignment pattern "about equals" an alignment pattern at the stated - /// position and size -- meaning, it is at nearly the same center with nearly the same size.

- ///
- internal bool aboutEquals(float moduleSize, float i, float j) - { - if (Math.Abs(i - Y) <= moduleSize && Math.Abs(j - X) <= moduleSize) - { - float moduleSizeDiff = Math.Abs(moduleSize - estimatedModuleSize); - return moduleSizeDiff <= 1.0f || moduleSizeDiff <= estimatedModuleSize; - } - return false; - } - - /// - /// Combines this object's current estimate of a finder pattern position and module size - /// with a new estimate. It returns a new {@code FinderPattern} containing an average of the two. - /// - /// The i. - /// The j. - /// New size of the module. - /// - internal AlignmentPattern combineEstimate(float i, float j, float newModuleSize) - { - float combinedX = (X + j) / 2.0f; - float combinedY = (Y + i) / 2.0f; - float combinedModuleSize = (estimatedModuleSize + newModuleSize) / 2.0f; - return new AlignmentPattern(combinedX, combinedY, combinedModuleSize); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/detector/AlignmentPattern.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/detector/AlignmentPattern.cs.meta deleted file mode 100644 index 5ac4d0f77..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/detector/AlignmentPattern.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 59cf858cadc0c40ee83465218ee0fd2e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/detector/AlignmentPatternFinder.cs b/Runtime/zxing.unity/Source/lib/qrcode/detector/AlignmentPatternFinder.cs deleted file mode 100644 index 7a6de8dbb..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/detector/AlignmentPatternFinder.cs +++ /dev/null @@ -1,324 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Collections.Generic; - -using ZXing.Common; - -namespace ZXing.QrCode.Internal -{ - ///

This class attempts to find alignment patterns in a QR Code. Alignment patterns look like finder - /// patterns but are smaller and appear at regular intervals throughout the image.

- /// - ///

At the moment this only looks for the bottom-right alignment pattern.

- /// - ///

This is mostly a simplified copy of {@link FinderPatternFinder}. It is copied, - /// pasted and stripped down here for maximum performance but does unfortunately duplicate - /// some code.

- /// - ///

This class is thread-safe but not reentrant. Each thread must allocate its own object.

- /// - ///
- /// Sean Owen - /// - /// www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source - /// - internal sealed class AlignmentPatternFinder - { - private readonly BitMatrix image; - private readonly IList possibleCenters; - private readonly int startX; - private readonly int startY; - private readonly int width; - private readonly int height; - private readonly float moduleSize; - private readonly int[] crossCheckStateCount; - private readonly ResultPointCallback resultPointCallback; - - ///

Creates a finder that will look in a portion of the whole image.

- /// - ///
- /// image to search - /// - /// left column from which to start searching - /// - /// top row from which to start searching - /// - /// width of region to search - /// - /// height of region to search - /// - /// estimated module size so far - /// - /// callback function which is called, when a result point is found - internal AlignmentPatternFinder(BitMatrix image, int startX, int startY, int width, int height, float moduleSize, ResultPointCallback resultPointCallback) - { - this.image = image; - this.possibleCenters = new List(5); - this.startX = startX; - this.startY = startY; - this.width = width; - this.height = height; - this.moduleSize = moduleSize; - this.crossCheckStateCount = new int[3]; - this.resultPointCallback = resultPointCallback; - } - - ///

This method attempts to find the bottom-right alignment pattern in the image. It is a bit messy since - /// it's pretty performance-critical and so is written to be fast foremost.

- /// - ///
- /// if found - internal AlignmentPattern find() - { - int startX = this.startX; - int height = this.height; - int maxJ = startX + width; - int middleI = startY + (height >> 1); - // We are looking for black/white/black modules in 1:1:1 ratio; - // this tracks the number of black/white/black modules seen so far - int[] stateCount = new int[3]; - for (int iGen = 0; iGen < height; iGen++) - { - // Search from middle outwards - int i = middleI + ((iGen & 0x01) == 0 ? ((iGen + 1) >> 1) : -((iGen + 1) >> 1)); - stateCount[0] = 0; - stateCount[1] = 0; - stateCount[2] = 0; - int j = startX; - // Burn off leading white pixels before anything else; if we start in the middle of - // a white run, it doesn't make sense to count its length, since we don't know if the - // white run continued to the left of the start point - while (j < maxJ && !image[j, i]) - { - j++; - } - int currentState = 0; - while (j < maxJ) - { - if (image[j, i]) - { - // Black pixel - if (currentState == 1) - { - // Counting black pixels - stateCount[1]++; - } - else - { - // Counting white pixels - if (currentState == 2) - { - // A winner? - if (foundPatternCross(stateCount)) - { - // Yes - AlignmentPattern confirmed = handlePossibleCenter(stateCount, i, j); - if (confirmed != null) - { - return confirmed; - } - } - stateCount[0] = stateCount[2]; - stateCount[1] = 1; - stateCount[2] = 0; - currentState = 1; - } - else - { - stateCount[++currentState]++; - } - } - } - else - { - // White pixel - if (currentState == 1) - { - // Counting black pixels - currentState++; - } - stateCount[currentState]++; - } - j++; - } - if (foundPatternCross(stateCount)) - { - AlignmentPattern confirmed = handlePossibleCenter(stateCount, i, maxJ); - if (confirmed != null) - { - return confirmed; - } - } - } - - // Hmm, nothing we saw was observed and confirmed twice. If we had - // any guess at all, return it. - if (possibleCenters.Count != 0) - { - return possibleCenters[0]; - } - - return null; - } - - /// Given a count of black/white/black pixels just seen and an end position, - /// figures the location of the center of this black/white/black run. - /// - private static float? centerFromEnd(int[] stateCount, int end) - { - var result = (end - stateCount[2]) - stateCount[1] / 2.0f; - if (Single.IsNaN(result)) - return null; - return result; - } - - /// count of black/white/black pixels just read - /// - /// true iff the proportions of the counts is close enough to the 1/1/1 ratios - /// used by alignment patterns to be considered a match - /// - private bool foundPatternCross(int[] stateCount) - { - float maxVariance = moduleSize / 2.0f; - for (int i = 0; i < 3; i++) - { - if (Math.Abs(moduleSize - stateCount[i]) >= maxVariance) - { - return false; - } - } - return true; - } - - /// - ///

After a horizontal scan finds a potential alignment pattern, this method - /// "cross-checks" by scanning down vertically through the center of the possible - /// alignment pattern to see if the same proportion is detected.

- ///
- /// row where an alignment pattern was detected - /// center of the section that appears to cross an alignment pattern - /// maximum reasonable number of modules that should be - /// observed in any reading state, based on the results of the horizontal scan - /// The original state count total. - /// - /// vertical center of alignment pattern, or null if not found - /// - private float? crossCheckVertical(int startI, int centerJ, int maxCount, int originalStateCountTotal) - { - int maxI = image.Height; - int[] stateCount = crossCheckStateCount; - stateCount[0] = 0; - stateCount[1] = 0; - stateCount[2] = 0; - - // Start counting up from center - int i = startI; - while (i >= 0 && image[centerJ, i] && stateCount[1] <= maxCount) - { - stateCount[1]++; - i--; - } - // If already too many modules in this state or ran off the edge: - if (i < 0 || stateCount[1] > maxCount) - { - return null; - } - while (i >= 0 && !image[centerJ, i] && stateCount[0] <= maxCount) - { - stateCount[0]++; - i--; - } - if (stateCount[0] > maxCount) - { - return null; - } - - // Now also count down from center - i = startI + 1; - while (i < maxI && image[centerJ, i] && stateCount[1] <= maxCount) - { - stateCount[1]++; - i++; - } - if (i == maxI || stateCount[1] > maxCount) - { - return null; - } - while (i < maxI && !image[centerJ, i] && stateCount[2] <= maxCount) - { - stateCount[2]++; - i++; - } - if (stateCount[2] > maxCount) - { - return null; - } - - int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; - if (5 * Math.Abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) - { - return null; - } - - return foundPatternCross(stateCount) ? centerFromEnd(stateCount, i) : null; - } - - ///

This is called when a horizontal scan finds a possible alignment pattern. It will - /// cross check with a vertical scan, and if successful, will see if this pattern had been - /// found on a previous horizontal scan. If so, we consider it confirmed and conclude we have - /// found the alignment pattern.

- /// - ///
- /// reading state module counts from horizontal scan - /// - /// row where alignment pattern may be found - /// - /// end of possible alignment pattern in row - /// - /// {@link AlignmentPattern} if we have found the same pattern twice, or null if not - /// - private AlignmentPattern handlePossibleCenter(int[] stateCount, int i, int j) - { - int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2]; - float? centerJ = centerFromEnd(stateCount, j); - if (centerJ == null) - return null; - float? centerI = crossCheckVertical(i, (int)centerJ, 2 * stateCount[1], stateCountTotal); - if (centerI != null) - { - float estimatedModuleSize = (stateCount[0] + stateCount[1] + stateCount[2]) / 3.0f; - foreach (var center in possibleCenters) - { - // Look for about the same center and module size: - if (center.aboutEquals(estimatedModuleSize, centerI.Value, centerJ.Value)) - { - return center.combineEstimate(centerI.Value, centerJ.Value, estimatedModuleSize); - } - } - // Hadn't found this before; save it - var point = new AlignmentPattern(centerJ.Value, centerI.Value, estimatedModuleSize); - possibleCenters.Add(point); - if (resultPointCallback != null) - { - resultPointCallback(point); - } - } - return null; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/detector/AlignmentPatternFinder.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/detector/AlignmentPatternFinder.cs.meta deleted file mode 100644 index cf8b141cc..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/detector/AlignmentPatternFinder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 34ea05b3fb7ae4d2a8379ea70270ce87 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/detector/Detector.cs b/Runtime/zxing.unity/Source/lib/qrcode/detector/Detector.cs deleted file mode 100644 index 0c811f453..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/detector/Detector.cs +++ /dev/null @@ -1,434 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Collections.Generic; - -using ZXing.Common; -using ZXing.Common.Detector; - -namespace ZXing.QrCode.Internal -{ - /// - ///

Encapsulates logic that can detect a QR Code in an image, even if the QR Code - /// is rotated or skewed, or partially obscured.

- ///
- /// Sean Owen - public class Detector - { - private readonly BitMatrix image; - private ResultPointCallback resultPointCallback; - - /// - /// Initializes a new instance of the class. - /// - /// The image. - public Detector(BitMatrix image) - { - this.image = image; - } - - /// - /// Gets the image. - /// - virtual protected internal BitMatrix Image - { - get - { - return image; - } - } - - /// - /// Gets the result point callback. - /// - virtual protected internal ResultPointCallback ResultPointCallback - { - get - { - return resultPointCallback; - } - } - - /// - ///

Detects a QR Code in an image.

- ///
- /// - /// encapsulating results of detecting a QR Code - /// - public virtual DetectorResult detect() - { - return detect(null); - } - - /// - ///

Detects a QR Code in an image.

- ///
- /// optional hints to detector - /// - /// encapsulating results of detecting a QR Code - /// - public virtual DetectorResult detect(IDictionary hints) - { - resultPointCallback = hints == null || !hints.ContainsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK) ? null : (ResultPointCallback)hints[DecodeHintType.NEED_RESULT_POINT_CALLBACK]; - - FinderPatternFinder finder = new FinderPatternFinder(image, resultPointCallback); - FinderPatternInfo info = finder.find(hints); - if (info == null) - return null; - - return processFinderPatternInfo(info); - } - - /// - /// Processes the finder pattern info. - /// - /// The info. - /// - protected internal virtual DetectorResult processFinderPatternInfo(FinderPatternInfo info) - { - FinderPattern topLeft = info.TopLeft; - FinderPattern topRight = info.TopRight; - FinderPattern bottomLeft = info.BottomLeft; - - float moduleSize = calculateModuleSize(topLeft, topRight, bottomLeft); - if (moduleSize < 1.0f) - { - return null; - } - int dimension; - if (!computeDimension(topLeft, topRight, bottomLeft, moduleSize, out dimension)) - return null; - Internal.Version provisionalVersion = Internal.Version.getProvisionalVersionForDimension(dimension); - if (provisionalVersion == null) - return null; - int modulesBetweenFPCenters = provisionalVersion.DimensionForVersion - 7; - - AlignmentPattern alignmentPattern = null; - // Anything above version 1 has an alignment pattern - if (provisionalVersion.AlignmentPatternCenters.Length > 0) - { - - // Guess where a "bottom right" finder pattern would have been - float bottomRightX = topRight.X - topLeft.X + bottomLeft.X; - float bottomRightY = topRight.Y - topLeft.Y + bottomLeft.Y; - - // Estimate that alignment pattern is closer by 3 modules - // from "bottom right" to known top left location - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - float correctionToTopLeft = 1.0f - 3.0f / (float)modulesBetweenFPCenters; - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - int estAlignmentX = (int)(topLeft.X + correctionToTopLeft * (bottomRightX - topLeft.X)); - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - int estAlignmentY = (int)(topLeft.Y + correctionToTopLeft * (bottomRightY - topLeft.Y)); - - // Kind of arbitrary -- expand search radius before giving up - for (int i = 4; i <= 16; i <<= 1) - { - alignmentPattern = findAlignmentInRegion(moduleSize, estAlignmentX, estAlignmentY, (float)i); - if (alignmentPattern == null) - continue; - break; - } - // If we didn't find alignment pattern... well try anyway without it - } - - PerspectiveTransform transform = createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension); - - BitMatrix bits = sampleGrid(image, transform, dimension); - if (bits == null) - return null; - - ResultPoint[] points; - if (alignmentPattern == null) - { - points = new ResultPoint[] { bottomLeft, topLeft, topRight }; - } - else - { - points = new ResultPoint[] { bottomLeft, topLeft, topRight, alignmentPattern }; - } - return new DetectorResult(bits, points); - } - - private static PerspectiveTransform createTransform(ResultPoint topLeft, ResultPoint topRight, ResultPoint bottomLeft, ResultPoint alignmentPattern, int dimension) - { - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - float dimMinusThree = (float)dimension - 3.5f; - float bottomRightX; - float bottomRightY; - float sourceBottomRightX; - float sourceBottomRightY; - if (alignmentPattern != null) - { - bottomRightX = alignmentPattern.X; - bottomRightY = alignmentPattern.Y; - sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3.0f; - } - else - { - // Don't have an alignment pattern, just make up the bottom-right point - bottomRightX = (topRight.X - topLeft.X) + bottomLeft.X; - bottomRightY = (topRight.Y - topLeft.Y) + bottomLeft.Y; - sourceBottomRightX = sourceBottomRightY = dimMinusThree; - } - - return PerspectiveTransform.quadrilateralToQuadrilateral( - 3.5f, - 3.5f, - dimMinusThree, - 3.5f, - sourceBottomRightX, - sourceBottomRightY, - 3.5f, - dimMinusThree, - topLeft.X, - topLeft.Y, - topRight.X, - topRight.Y, - bottomRightX, - bottomRightY, - bottomLeft.X, - bottomLeft.Y); - } - - private static BitMatrix sampleGrid(BitMatrix image, PerspectiveTransform transform, int dimension) - { - GridSampler sampler = GridSampler.Instance; - return sampler.sampleGrid(image, dimension, dimension, transform); - } - - ///

Computes the dimension (number of modules on a size) of the QR Code based on the position - /// of the finder patterns and estimated module size.

- ///
- private static bool computeDimension(ResultPoint topLeft, ResultPoint topRight, ResultPoint bottomLeft, float moduleSize, out int dimension) - { - int tltrCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, topRight) / moduleSize); - int tlblCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, bottomLeft) / moduleSize); - dimension = ((tltrCentersDimension + tlblCentersDimension) >> 1) + 7; - switch (dimension & 0x03) - { - // mod 4 - case 0: - dimension++; - break; - // 1? do nothing - case 2: - dimension--; - break; - case 3: - return true; - } - return true; - } - - /// - ///

Computes an average estimated module size based on estimated derived from the positions - /// of the three finder patterns.

- ///
- /// detected top-left finder pattern center - /// detected top-right finder pattern center - /// detected bottom-left finder pattern center - /// estimated module size - protected internal virtual float calculateModuleSize(ResultPoint topLeft, ResultPoint topRight, ResultPoint bottomLeft) - { - // Take the average - return (calculateModuleSizeOneWay(topLeft, topRight) + calculateModuleSizeOneWay(topLeft, bottomLeft)) / 2.0f; - } - - ///

Estimates module size based on two finder patterns -- it uses - /// {@link #sizeOfBlackWhiteBlackRunBothWays(int, int, int, int)} to figure the - /// width of each, measuring along the axis between their centers.

- ///
- private float calculateModuleSizeOneWay(ResultPoint pattern, ResultPoint otherPattern) - { - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - float moduleSizeEst1 = sizeOfBlackWhiteBlackRunBothWays((int)pattern.X, (int)pattern.Y, (int)otherPattern.X, (int)otherPattern.Y); - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - float moduleSizeEst2 = sizeOfBlackWhiteBlackRunBothWays((int)otherPattern.X, (int)otherPattern.Y, (int)pattern.X, (int)pattern.Y); - if (Single.IsNaN(moduleSizeEst1)) - { - return moduleSizeEst2 / 7.0f; - } - if (Single.IsNaN(moduleSizeEst2)) - { - return moduleSizeEst1 / 7.0f; - } - // Average them, and divide by 7 since we've counted the width of 3 black modules, - // and 1 white and 1 black module on either side. Ergo, divide sum by 14. - return (moduleSizeEst1 + moduleSizeEst2) / 14.0f; - } - - /// See {@link #sizeOfBlackWhiteBlackRun(int, int, int, int)}; computes the total width of - /// a finder pattern by looking for a black-white-black run from the center in the direction - /// of another point (another finder pattern center), and in the opposite direction too. - /// - private float sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX, int toY) - { - - float result = sizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY); - - // Now count other way -- don't run off image though of course - float scale = 1.0f; - int otherToX = fromX - (toX - fromX); - if (otherToX < 0) - { - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - scale = (float)fromX / (float)(fromX - otherToX); - otherToX = 0; - } - else if (otherToX >= image.Width) - { - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - scale = (float)(image.Width - 1 - fromX) / (float)(otherToX - fromX); - otherToX = image.Width - 1; - } - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - int otherToY = (int)(fromY - (toY - fromY) * scale); - - scale = 1.0f; - if (otherToY < 0) - { - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - scale = (float)fromY / (float)(fromY - otherToY); - otherToY = 0; - } - else if (otherToY >= image.Height) - { - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - scale = (float)(image.Height - 1 - fromY) / (float)(otherToY - fromY); - otherToY = image.Height - 1; - } - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - otherToX = (int)(fromX + (otherToX - fromX) * scale); - - result += sizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY); - return result - 1.0f; // -1 because we counted the middle pixel twice - } - - ///

This method traces a line from a point in the image, in the direction towards another point. - /// It begins in a black region, and keeps going until it finds white, then black, then white again. - /// It reports the distance from the start to this point.

- /// - ///

This is used when figuring out how wide a finder pattern is, when the finder pattern - /// may be skewed or rotated.

- ///
- private float sizeOfBlackWhiteBlackRun(int fromX, int fromY, int toX, int toY) - { - // Mild variant of Bresenham's algorithm; - // see http://en.wikipedia.org/wiki/Bresenham's_line_algorithm - bool steep = Math.Abs(toY - fromY) > Math.Abs(toX - fromX); - if (steep) - { - int temp = fromX; - fromX = fromY; - fromY = temp; - temp = toX; - toX = toY; - toY = temp; - } - - int dx = Math.Abs(toX - fromX); - int dy = Math.Abs(toY - fromY); - int error = -dx >> 1; - int xstep = fromX < toX ? 1 : -1; - int ystep = fromY < toY ? 1 : -1; - - // In black pixels, looking for white, first or second time. - int state = 0; - // Loop up until x == toX, but not beyond - int xLimit = toX + xstep; - for (int x = fromX, y = fromY; x != xLimit; x += xstep) - { - int realX = steep ? y : x; - int realY = steep ? x : y; - - // Does current pixel mean we have moved white to black or vice versa? - // Scanning black in state 0,2 and white in state 1, so if we find the wrong - // color, advance to next state or end if we are in state 2 already - if ((state == 1) == image[realX, realY]) - { - if (state == 2) - { - return MathUtils.distance(x, y, fromX, fromY); - } - state++; - } - error += dy; - if (error > 0) - { - if (y == toY) - { - - - break; - } - y += ystep; - error -= dx; - } - } - // Found black-white-black; give the benefit of the doubt that the next pixel outside the image - // is "white" so this last point at (toX+xStep,toY) is the right ending. This is really a - // small approximation; (toX+xStep,toY+yStep) might be really correct. Ignore this. - if (state == 2) - { - return MathUtils.distance(toX + xstep, toY, fromX, fromY); - } - // else we didn't find even black-white-black; no estimate is really possible - return Single.NaN; - - } - - /// - ///

Attempts to locate an alignment pattern in a limited region of the image, which is - /// guessed to contain it. This method uses {@link AlignmentPattern}.

- ///
- /// estimated module size so far - /// x coordinate of center of area probably containing alignment pattern - /// y coordinate of above - /// number of pixels in all directions to search from the center - /// - /// if found, or null otherwise - /// - protected AlignmentPattern findAlignmentInRegion(float overallEstModuleSize, int estAlignmentX, int estAlignmentY, float allowanceFactor) - { - // Look for an alignment pattern (3 modules in size) around where it - // should be - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - int allowance = (int)(allowanceFactor * overallEstModuleSize); - int alignmentAreaLeftX = Math.Max(0, estAlignmentX - allowance); - int alignmentAreaRightX = Math.Min(image.Width - 1, estAlignmentX + allowance); - if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) - { - return null; - } - - int alignmentAreaTopY = Math.Max(0, estAlignmentY - allowance); - int alignmentAreaBottomY = Math.Min(image.Height - 1, estAlignmentY + allowance); - - var alignmentFinder = new AlignmentPatternFinder( - image, - alignmentAreaLeftX, - alignmentAreaTopY, - alignmentAreaRightX - alignmentAreaLeftX, - alignmentAreaBottomY - alignmentAreaTopY, - overallEstModuleSize, - resultPointCallback); - - return alignmentFinder.find(); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/detector/Detector.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/detector/Detector.cs.meta deleted file mode 100644 index 581df9623..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/detector/Detector.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a60caaace953249c199c78e0cef60ff7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPattern.cs b/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPattern.cs deleted file mode 100644 index e62745925..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPattern.cs +++ /dev/null @@ -1,100 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; - -namespace ZXing.QrCode.Internal -{ - /// - ///

Encapsulates a finder pattern, which are the three square patterns found in - /// the corners of QR Codes. It also encapsulates a count of similar finder patterns, - /// as a convenience to the finder's bookkeeping.

- ///
- /// Sean Owen - public sealed class FinderPattern : ResultPoint - { - private readonly float estimatedModuleSize; - private int count; - - internal FinderPattern(float posX, float posY, float estimatedModuleSize) - : this(posX, posY, estimatedModuleSize, 1) - { - this.estimatedModuleSize = estimatedModuleSize; - this.count = 1; - } - - internal FinderPattern(float posX, float posY, float estimatedModuleSize, int count) - : base(posX, posY) - { - this.estimatedModuleSize = estimatedModuleSize; - this.count = count; - } - - /// - /// Gets the size of the estimated module. - /// - /// - /// The size of the estimated module. - /// - public float EstimatedModuleSize - { - get - { - return estimatedModuleSize; - } - } - - internal int Count - { - get - { - return count; - } - } - - ///

Determines if this finder pattern "about equals" a finder pattern at the stated - /// position and size -- meaning, it is at nearly the same center with nearly the same size.

- ///
- internal bool aboutEquals(float moduleSize, float i, float j) - { - if (Math.Abs(i - Y) <= moduleSize && Math.Abs(j - X) <= moduleSize) - { - float moduleSizeDiff = Math.Abs(moduleSize - estimatedModuleSize); - return moduleSizeDiff <= 1.0f || moduleSizeDiff <= estimatedModuleSize; - - } - return false; - } - - /// - /// Combines this object's current estimate of a finder pattern position and module size - /// with a new estimate. It returns a new {@code FinderPattern} containing a weighted average - /// based on count. - /// - /// The i. - /// The j. - /// New size of the module. - /// - internal FinderPattern combineEstimate(float i, float j, float newModuleSize) - { - int combinedCount = count + 1; - float combinedX = (count * X + j) / combinedCount; - float combinedY = (count * Y + i) / combinedCount; - float combinedModuleSize = (count * estimatedModuleSize + newModuleSize) / combinedCount; - return new FinderPattern(combinedX, combinedY, combinedModuleSize, combinedCount); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPattern.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPattern.cs.meta deleted file mode 100644 index 941207f04..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPattern.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7528bc3ccd6e240c8b50e7ad20b50a1c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPatternFinder.cs b/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPatternFinder.cs deleted file mode 100644 index 36ea98cf5..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPatternFinder.cs +++ /dev/null @@ -1,883 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Collections.Generic; - -using ZXing.Common; - -namespace ZXing.QrCode.Internal -{ - /// - ///

This class attempts to find finder patterns in a QR Code. Finder patterns are the square - /// markers at three corners of a QR Code.

- /// - ///

This class is thread-safe but not reentrant. Each thread must allocate its own object.

- ///
- /// Sean Owen - public class FinderPatternFinder - { - private const int CENTER_QUORUM = 2; - private static readonly EstimatedModuleComparator moduleComparator = new EstimatedModuleComparator(); - /// - /// 1 pixel/module times 3 modules/center - /// - protected internal const int MIN_SKIP = 3; - - /// - /// support up to version 20 for mobile clients - /// - protected internal const int MAX_MODULES = 97; - - private const int INTEGER_MATH_SHIFT = 8; - - private readonly BitMatrix image; - private readonly List possibleCenters; - private bool hasSkipped; - private readonly int[] crossCheckStateCount; - private readonly ResultPointCallback resultPointCallback; - - /// - ///

Creates a finder that will search the image for three finder patterns.

- ///
- /// image to search - public FinderPatternFinder(BitMatrix image) - : this(image, null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The image. - /// The result point callback. - public FinderPatternFinder(BitMatrix image, ResultPointCallback resultPointCallback) - { - this.image = image; - this.possibleCenters = new List(); - this.crossCheckStateCount = new int[5]; - this.resultPointCallback = resultPointCallback; - } - - /// - /// Gets the image. - /// - protected internal virtual BitMatrix Image - { - get { return image; } - } - - /// - /// Gets the possible centers. - /// - protected internal virtual List PossibleCenters - { - get { return possibleCenters; } - } - - internal virtual FinderPatternInfo find(IDictionary hints) - { - bool tryHarder = hints != null && hints.ContainsKey(DecodeHintType.TRY_HARDER); - int maxI = image.Height; - int maxJ = image.Width; - // We are looking for black/white/black/white/black modules in - // 1:1:3:1:1 ratio; this tracks the number of such modules seen so far - - // Let's assume that the maximum version QR Code we support takes up 1/4 the height of the - // image, and then account for the center being 3 modules in size. This gives the smallest - // number of pixels the center could be, so skip this often. When trying harder, look for all - // QR versions regardless of how dense they are. - int iSkip = (3 * maxI) / (4 * MAX_MODULES); - if (iSkip < MIN_SKIP || tryHarder) - { - iSkip = MIN_SKIP; - } - - bool done = false; - int[] stateCount = new int[5]; - for (int i = iSkip - 1; i < maxI && !done; i += iSkip) - { - // Get a row of black/white values - doClearCounts(stateCount); - int currentState = 0; - for (int j = 0; j < maxJ; j++) - { - if (image[j, i]) - { - // Black pixel - if ((currentState & 1) == 1) - { - // Counting white pixels - currentState++; - } - stateCount[currentState]++; - } - else - { - // White pixel - if ((currentState & 1) == 0) - { - // Counting black pixels - if (currentState == 4) - { - // A winner? - if (foundPatternCross(stateCount)) - { - // Yes - bool confirmed = handlePossibleCenter(stateCount, i, j); - if (confirmed) - { - // Start examining every other line. Checking each line turned out to be too - // expensive and didn't improve performance. - iSkip = 2; - if (hasSkipped) - { - done = haveMultiplyConfirmedCenters(); - } - else - { - int rowSkip = findRowSkip(); - if (rowSkip > stateCount[2]) - { - // Skip rows between row of lower confirmed center - // and top of presumed third confirmed center - // but back up a bit to get a full chance of detecting - // it, entire width of center of finder pattern - - // Skip by rowSkip, but back off by stateCount[2] (size of last center - // of pattern we saw) to be conservative, and also back off by iSkip which - // is about to be re-added - i += rowSkip - stateCount[2] - iSkip; - j = maxJ - 1; - } - } - } - else - { - doShiftCounts2(stateCount); - currentState = 3; - continue; - } - // Clear state to start looking again - currentState = 0; - doClearCounts(stateCount); - } - else - { - // No, shift counts back by two - doShiftCounts2(stateCount); - currentState = 3; - } - } - else - { - stateCount[++currentState]++; - } - } - else - { - // Counting white pixels - stateCount[currentState]++; - } - } - } - if (foundPatternCross(stateCount)) - { - bool confirmed = handlePossibleCenter(stateCount, i, maxJ); - if (confirmed) - { - iSkip = stateCount[0]; - if (hasSkipped) - { - // Found a third one - done = haveMultiplyConfirmedCenters(); - } - } - } - } - - FinderPattern[] patternInfo = selectBestPatterns(); - if (patternInfo == null) - return null; - - ResultPoint.orderBestPatterns(patternInfo); - - return new FinderPatternInfo(patternInfo); - } - - /// Given a count of black/white/black/white/black pixels just seen and an end position, - /// figures the location of the center of this run. - /// - private static float? centerFromEnd(int[] stateCount, int end) - { - var result = (end - stateCount[4] - stateCount[3]) - stateCount[2] / 2.0f; - if (Single.IsNaN(result)) - return null; - return result; - } - - /// count of black/white/black/white/black pixels just read - /// - /// true iff the proportions of the counts is close enough to the 1/1/3/1/1 ratios - /// used by finder patterns to be considered a match - /// - protected internal static bool foundPatternCross(int[] stateCount) - { - int totalModuleSize = 0; - for (int i = 0; i < 5; i++) - { - int count = stateCount[i]; - if (count == 0) - { - return false; - } - totalModuleSize += count; - } - if (totalModuleSize < 7) - { - return false; - } - int moduleSize = (totalModuleSize << INTEGER_MATH_SHIFT) / 7; - int maxVariance = moduleSize / 2; - // Allow less than 50% variance from 1-1-3-1-1 proportions - return Math.Abs(moduleSize - (stateCount[0] << INTEGER_MATH_SHIFT)) < maxVariance && - Math.Abs(moduleSize - (stateCount[1] << INTEGER_MATH_SHIFT)) < maxVariance && - Math.Abs(3 * moduleSize - (stateCount[2] << INTEGER_MATH_SHIFT)) < 3 * maxVariance && - Math.Abs(moduleSize - (stateCount[3] << INTEGER_MATH_SHIFT)) < maxVariance && - Math.Abs(moduleSize - (stateCount[4] << INTEGER_MATH_SHIFT)) < maxVariance; - } - - /// - /// - /// count of black/white/black/white/black pixels just read - /// true if the proportions of the counts is close enough to the 1/1/3/1/1 ratios - /// by finder patterns to be considered a match - protected static bool foundPatternDiagonal(int[] stateCount) - { - int totalModuleSize = 0; - for (int i = 0; i < 5; i++) - { - int count = stateCount[i]; - if (count == 0) - { - return false; - } - totalModuleSize += count; - } - if (totalModuleSize < 7) - { - return false; - } - float moduleSize = totalModuleSize / 7.0f; - float maxVariance = moduleSize / 1.333f; - // Allow less than 75% variance from 1-1-3-1-1 proportions - return - Math.Abs(moduleSize - stateCount[0]) < maxVariance && - Math.Abs(moduleSize - stateCount[1]) < maxVariance && - Math.Abs(3.0f * moduleSize - stateCount[2]) < 3 * maxVariance && - Math.Abs(moduleSize - stateCount[3]) < maxVariance && - Math.Abs(moduleSize - stateCount[4]) < maxVariance; - } - - private int[] CrossCheckStateCount - { - get - { - doClearCounts(crossCheckStateCount); - return crossCheckStateCount; - } - } - - /// - /// sets everything to 0 - /// - /// - [Obsolete] - protected void clearCounts(int[] counts) - { - doClearCounts(counts); - } - - /// - /// shifts left by 2 index - /// - /// - [Obsolete] - protected void shiftCounts2(int[] stateCount) - { - doShiftCounts2(stateCount); - } - - /// - /// sets everything to 0 - /// - /// - protected static void doClearCounts(int[] counts) - { - SupportClass.Fill(counts, 0); - } - - /// - /// shifts left by 2 index - /// - /// - protected static void doShiftCounts2(int[] stateCount) - { - stateCount[0] = stateCount[2]; - stateCount[1] = stateCount[3]; - stateCount[2] = stateCount[4]; - stateCount[3] = 1; - stateCount[4] = 0; - } - - /// - /// After a vertical and horizontal scan finds a potential finder pattern, this method - /// "cross-cross-cross-checks" by scanning down diagonally through the center of the possible - /// finder pattern to see if the same proportion is detected. - /// - /// row where a finder pattern was detected - /// center of the section that appears to cross a finder pattern - /// true if proportions are withing expected limits - private bool crossCheckDiagonal(int centerI, int centerJ) - { - int[] stateCount = CrossCheckStateCount; - - // Start counting up, left from center finding black center mass - int i = 0; - while (centerI >= i && centerJ >= i && image[centerJ - i, centerI - i]) - { - stateCount[2]++; - i++; - } - if (stateCount[2] == 0) - { - return false; - } - - // Continue up, left finding white space - while (centerI >= i && centerJ >= i && !image[centerJ - i, centerI - i]) - { - stateCount[1]++; - i++; - } - if (stateCount[1] == 0) - { - return false; - } - - // Continue up, left finding black border - while (centerI >= i && centerJ >= i && image[centerJ - i, centerI - i]) - { - stateCount[0]++; - i++; - } - if (stateCount[0] == 0) - { - return false; - } - - int maxI = image.Height; - int maxJ = image.Width; - - // Now also count down, right from center - i = 1; - while (centerI + i < maxI && centerJ + i < maxJ && image[centerJ + i, centerI + i]) - { - stateCount[2]++; - i++; - } - - while (centerI + i < maxI && centerJ + i < maxJ && !image[centerJ + i, centerI + i]) - { - stateCount[3]++; - i++; - } - if (stateCount[3] == 0) - { - return false; - } - - while (centerI + i < maxI && centerJ + i < maxJ && image[centerJ + i, centerI + i]) - { - stateCount[4]++; - i++; - } - if (stateCount[4] == 0) - { - return false; - } - - return foundPatternDiagonal(stateCount); - } - - /// - ///

After a horizontal scan finds a potential finder pattern, this method - /// "cross-checks" by scanning down vertically through the center of the possible - /// finder pattern to see if the same proportion is detected.

- ///
- /// row where a finder pattern was detected - /// center of the section that appears to cross a finder pattern - /// maximum reasonable number of modules that should be - /// observed in any reading state, based on the results of the horizontal scan - /// The original state count total. - /// - /// vertical center of finder pattern, or null if not found - /// - private float? crossCheckVertical(int startI, int centerJ, int maxCount, int originalStateCountTotal) - { - int maxI = image.Height; - int[] stateCount = CrossCheckStateCount; - - // Start counting up from center - int i = startI; - while (i >= 0 && image[centerJ, i]) - { - stateCount[2]++; - i--; - } - if (i < 0) - { - return null; - } - while (i >= 0 && !image[centerJ, i] && stateCount[1] <= maxCount) - { - stateCount[1]++; - i--; - } - // If already too many modules in this state or ran off the edge: - if (i < 0 || stateCount[1] > maxCount) - { - return null; - } - while (i >= 0 && image[centerJ, i] && stateCount[0] <= maxCount) - { - stateCount[0]++; - i--; - } - if (stateCount[0] > maxCount) - { - return null; - } - - // Now also count down from center - i = startI + 1; - while (i < maxI && image[centerJ, i]) - { - stateCount[2]++; - i++; - } - if (i == maxI) - { - return null; - } - while (i < maxI && !image[centerJ, i] && stateCount[3] < maxCount) - { - stateCount[3]++; - i++; - } - if (i == maxI || stateCount[3] >= maxCount) - { - return null; - } - while (i < maxI && image[centerJ, i] && stateCount[4] < maxCount) - { - stateCount[4]++; - i++; - } - if (stateCount[4] >= maxCount) - { - return null; - } - - // If we found a finder-pattern-like section, but its size is more than 40% different than - // the original, assume it's a false positive - int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4]; - if (5 * Math.Abs(stateCountTotal - originalStateCountTotal) >= 2 * originalStateCountTotal) - { - return null; - } - - return foundPatternCross(stateCount) ? centerFromEnd(stateCount, i) : null; - } - - ///

Like {@link #crossCheckVertical(int, int, int, int)}, and in fact is basically identical, - /// except it reads horizontally instead of vertically. This is used to cross-cross - /// check a vertical cross check and locate the real center of the alignment pattern.

- ///
- private float? crossCheckHorizontal(int startJ, int centerI, int maxCount, int originalStateCountTotal) - { - int maxJ = image.Width; - int[] stateCount = CrossCheckStateCount; - - int j = startJ; - while (j >= 0 && image[j, centerI]) - { - stateCount[2]++; - j--; - } - if (j < 0) - { - return null; - } - while (j >= 0 && !image[j, centerI] && stateCount[1] <= maxCount) - { - stateCount[1]++; - j--; - } - if (j < 0 || stateCount[1] > maxCount) - { - return null; - } - while (j >= 0 && image[j, centerI] && stateCount[0] <= maxCount) - { - stateCount[0]++; - j--; - } - if (stateCount[0] > maxCount) - { - return null; - } - - j = startJ + 1; - while (j < maxJ && image[j, centerI]) - { - stateCount[2]++; - j++; - } - if (j == maxJ) - { - return null; - } - while (j < maxJ && !image[j, centerI] && stateCount[3] < maxCount) - { - stateCount[3]++; - j++; - } - if (j == maxJ || stateCount[3] >= maxCount) - { - return null; - } - while (j < maxJ && image[j, centerI] && stateCount[4] < maxCount) - { - stateCount[4]++; - j++; - } - if (stateCount[4] >= maxCount) - { - return null; - } - - // If we found a finder-pattern-like section, but its size is significantly different than - // the original, assume it's a false positive - int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4]; - if (5 * Math.Abs(stateCountTotal - originalStateCountTotal) >= originalStateCountTotal) - { - return null; - } - - return foundPatternCross(stateCount) ? centerFromEnd(stateCount, j) : null; - } - - /// - /// @see #handlePossibleCenter(int[], int, int) - /// - /// reading state module counts from horizontal scan - /// row where finder pattern may be found - /// end of possible finder pattern in row - /// ignored - /// true if a finder pattern candidate was found this time - [Obsolete("only exists for backwards compatibility")] - protected bool handlePossibleCenter(int[] stateCount, int i, int j, bool pureBarcode) - { - return handlePossibleCenter(stateCount, i, j); - } - - /// - ///

This is called when a horizontal scan finds a possible alignment pattern. It will - /// cross check with a vertical scan, and if successful, will, ah, cross-cross-check - /// with another horizontal scan. This is needed primarily to locate the real horizontal - /// center of the pattern in cases of extreme skew. - /// And then we cross-cross-cross check with another diagonal scan.

- /// If that succeeds the finder pattern location is added to a list that tracks - /// the number of times each location has been nearly-matched as a finder pattern. - /// Each additional find is more evidence that the location is in fact a finder - /// pattern center - ///
- /// reading state module counts from horizontal scan - /// row where finder pattern may be found - /// end of possible finder pattern in row - /// - /// true if a finder pattern candidate was found this time - /// - protected bool handlePossibleCenter(int[] stateCount, int i, int j) - { - int stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + - stateCount[4]; - float? centerJ = centerFromEnd(stateCount, j); - if (centerJ == null) - return false; - float? centerI = crossCheckVertical(i, (int)centerJ.Value, stateCount[2], stateCountTotal); - if (centerI != null) - { - // Re-cross check - centerJ = crossCheckHorizontal((int)centerJ.Value, (int)centerI.Value, stateCount[2], stateCountTotal); - if (centerJ != null && crossCheckDiagonal((int)centerI, (int)centerJ)) - { - float estimatedModuleSize = stateCountTotal / 7.0f; - bool found = false; - for (int index = 0; index < possibleCenters.Count; index++) - { - var center = possibleCenters[index]; - // Look for about the same center and module size: - if (center.aboutEquals(estimatedModuleSize, centerI.Value, centerJ.Value)) - { - possibleCenters.RemoveAt(index); - possibleCenters.Insert(index, center.combineEstimate(centerI.Value, centerJ.Value, estimatedModuleSize)); - - found = true; - break; - } - } - if (!found) - { - var point = new FinderPattern(centerJ.Value, centerI.Value, estimatedModuleSize); - - possibleCenters.Add(point); - if (resultPointCallback != null) - { - - resultPointCallback(point); - } - } - return true; - } - } - return false; - } - - /// number of rows we could safely skip during scanning, based on the first - /// two finder patterns that have been located. In some cases their position will - /// allow us to infer that the third pattern must lie below a certain point farther - /// down in the image. - /// - private int findRowSkip() - { - int max = possibleCenters.Count; - if (max <= 1) - { - return 0; - } - ResultPoint firstConfirmedCenter = null; - foreach (var center in possibleCenters) - { - if (center.Count >= CENTER_QUORUM) - { - if (firstConfirmedCenter == null) - { - firstConfirmedCenter = center; - } - else - { - // We have two confirmed centers - // How far down can we skip before resuming looking for the next - // pattern? In the worst case, only the difference between the - // difference in the x / y coordinates of the two centers. - // This is the case where you find top left last. - hasSkipped = true; - //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" - return (int)(Math.Abs(firstConfirmedCenter.X - center.X) - Math.Abs(firstConfirmedCenter.Y - center.Y)) / 2; - } - } - } - return 0; - } - - /// true iff we have found at least 3 finder patterns that have been detected - /// at least {@link #CENTER_QUORUM} times each, and, the estimated module size of the - /// candidates is "pretty similar" - /// - private bool haveMultiplyConfirmedCenters() - { - int confirmedCount = 0; - float totalModuleSize = 0.0f; - int max = possibleCenters.Count; - foreach (var pattern in possibleCenters) - { - if (pattern.Count >= CENTER_QUORUM) - { - confirmedCount++; - totalModuleSize += pattern.EstimatedModuleSize; - } - } - if (confirmedCount < 3) - { - return false; - } - // OK, we have at least 3 confirmed centers, but, it's possible that one is a "false positive" - // and that we need to keep looking. We detect this by asking if the estimated module sizes - // vary too much. We arbitrarily say that when the total deviation from average exceeds - // 5% of the total module size estimates, it's too much. - float average = totalModuleSize / max; - float totalDeviation = 0.0f; - for (int i = 0; i < max; i++) - { - var pattern = possibleCenters[i]; - totalDeviation += Math.Abs(pattern.EstimatedModuleSize - average); - } - return totalDeviation <= 0.05f * totalModuleSize; - } - - /// - /// Get square of distance between a and b. - /// - /// - /// - /// - private static double squaredDistance(FinderPattern a, FinderPattern b) - { - double x = a.X - b.X; - double y = a.Y - b.Y; - return x * x + y * y; - } - - /// the 3 best {@link FinderPattern}s from our list of candidates. The "best" are - /// those have similar module size and form a shape closer to a isosceles right triangle. - /// - private FinderPattern[] selectBestPatterns() - { - int startSize = possibleCenters.Count; - if (startSize < 3) - { - // Couldn't find enough finder patterns - return null; - } - - possibleCenters.Sort(moduleComparator); - - double distortion = Double.MaxValue; - FinderPattern[] bestPatterns = new FinderPattern[3]; - - for (int i = 0; i < possibleCenters.Count - 2; i++) - { - FinderPattern fpi = possibleCenters[i]; - float minModuleSize = fpi.EstimatedModuleSize; - - for (int j = i + 1; j < possibleCenters.Count - 1; j++) - { - FinderPattern fpj = possibleCenters[j]; - double squares0 = squaredDistance(fpi, fpj); - - for (int k = j + 1; k < possibleCenters.Count; k++) - { - FinderPattern fpk = possibleCenters[k]; - float maxModuleSize = fpk.EstimatedModuleSize; - if (maxModuleSize > minModuleSize * 1.4f) - { - // module size is not similar - continue; - } - - var a = squares0; - var b = squaredDistance(fpj, fpk); - var c = squaredDistance(fpi, fpk); - - // sorts ascending - inlined - if (a < b) - { - if (b > c) - { - if (a < c) - { - var temp = b; - b = c; - c = temp; - } - else - { - var temp = a; - a = c; - c = b; - b = temp; - } - } - } - else - { - if (b < c) - { - if (a < c) - { - var temp = a; - a = b; - b = temp; - } - else - { - var temp = a; - a = b; - b = c; - c = temp; - } - } - else - { - var temp = a; - a = c; - c = temp; - } - } - - // a^2 + b^2 = c^2 (Pythagorean theorem), and a = b (isosceles triangle). - // Since any right triangle satisfies the formula c^2 - b^2 - a^2 = 0, - // we need to check both two equal sides separately. - // The value of |c^2 - 2 * b^2| + |c^2 - 2 * a^2| increases as dissimilarity - // from isosceles right triangle. - double d = Math.Abs(c - 2 * b) + Math.Abs(c - 2 * a); - if (d < distortion) - { - distortion = d; - bestPatterns[0] = fpi; - bestPatterns[1] = fpj; - bestPatterns[2] = fpk; - } - } - } - } - - if (distortion == Double.MaxValue) - { - return null; - } - - return bestPatterns; - } - - /// - /// Orders by {@link FinderPatternFinder#getEstimatedModuleSize()} - /// - private sealed class EstimatedModuleComparator : IComparer - { - public int Compare(FinderPattern center1, FinderPattern center2) - { - if (center1.EstimatedModuleSize == center2.EstimatedModuleSize) - return 0; - if (center1.EstimatedModuleSize < center2.EstimatedModuleSize) - return -1; - return 1; - } - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPatternFinder.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPatternFinder.cs.meta deleted file mode 100644 index 5f5bab3ad..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPatternFinder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: eade8c40cd5c24d1f9e17b0eab3b3f74 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPatternInfo.cs b/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPatternInfo.cs deleted file mode 100644 index 6265961ac..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPatternInfo.cs +++ /dev/null @@ -1,74 +0,0 @@ -/* -* Copyright 2007 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -namespace ZXing.QrCode.Internal -{ - /// - ///

Encapsulates information about finder patterns in an image, including the location of - /// the three finder patterns, and their estimated module size.

- ///
- /// Sean Owen - public sealed class FinderPatternInfo - { - private readonly FinderPattern bottomLeft; - private readonly FinderPattern topLeft; - private readonly FinderPattern topRight; - - /// - /// Initializes a new instance of the class. - /// - /// The pattern centers. - public FinderPatternInfo(FinderPattern[] patternCenters) - { - this.bottomLeft = patternCenters[0]; - this.topLeft = patternCenters[1]; - this.topRight = patternCenters[2]; - } - - /// - /// Gets the bottom left. - /// - public FinderPattern BottomLeft - { - get - { - return bottomLeft; - } - } - - /// - /// Gets the top left. - /// - public FinderPattern TopLeft - { - get - { - return topLeft; - } - } - - /// - /// Gets the top right. - /// - public FinderPattern TopRight - { - get - { - return topRight; - } - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPatternInfo.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPatternInfo.cs.meta deleted file mode 100644 index 18f1abba2..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/detector/FinderPatternInfo.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e694cd65922eb446b907fb148eaf2758 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder.meta b/Runtime/zxing.unity/Source/lib/qrcode/encoder.meta deleted file mode 100644 index 7cddffb19..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: bca801e61a8aa4b0f92d79c606eb1f92 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder/BlockPair.cs b/Runtime/zxing.unity/Source/lib/qrcode/encoder/BlockPair.cs deleted file mode 100644 index 94271c772..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder/BlockPair.cs +++ /dev/null @@ -1,40 +0,0 @@ -/* -* Copyright 2008 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -namespace ZXing.QrCode.Internal -{ - internal sealed class BlockPair - { - private readonly byte[] dataBytes; - private readonly byte[] errorCorrectionBytes; - - public BlockPair(byte[] data, byte[] errorCorrection) - { - dataBytes = data; - errorCorrectionBytes = errorCorrection; - } - - public byte[] DataBytes - { - get { return dataBytes; } - } - - public byte[] ErrorCorrectionBytes - { - get { return errorCorrectionBytes; } - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder/BlockPair.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/encoder/BlockPair.cs.meta deleted file mode 100644 index dd13a2bfb..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder/BlockPair.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7b1ce09c4e8c346d295942289bb66ecc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder/ByteMatrix.cs b/Runtime/zxing.unity/Source/lib/qrcode/encoder/ByteMatrix.cs deleted file mode 100644 index aa8b8bb26..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder/ByteMatrix.cs +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Text; - -namespace ZXing.QrCode.Internal -{ - /// - /// JAVAPORT: The original code was a 2D array of ints, but since it only ever gets assigned - /// 0, 1 and 2 I'm going to use less memory and go with bytes. - /// - /// dswitkin@google.com (Daniel Switkin) - public sealed class ByteMatrix - { - private readonly byte[][] bytes; - private readonly int width; - private readonly int height; - - /// - /// Initializes a new instance of the class. - /// - /// The width. - /// The height. - public ByteMatrix(int width, int height) - { - bytes = new byte[height][]; - for (var i = 0; i < height; i++) - bytes[i] = new byte[width]; - this.width = width; - this.height = height; - } - - /// - /// Gets the height. - /// - public int Height - { - get { return height; } - } - - /// - /// Gets the width. - /// - public int Width - { - get { return width; } - } - - /// - /// Gets or sets the with the specified x. - /// - public int this[int x, int y] - { - get { return bytes[y][x]; } - set { bytes[y][x] = (byte)value; } - } - - /// - /// an internal representation as bytes, in row-major order. array[y][x] represents point (x,y) - /// - public byte[][] Array - { - get { return bytes; } - } - - /// - /// Sets the specified x. - /// - /// The x. - /// The y. - /// The value. - public void set(int x, int y, byte value) - { - bytes[y][x] = value; - } - - /// - /// Sets the specified x. - /// - /// The x. - /// The y. - /// if set to true [value]. - public void set(int x, int y, bool value) - { - bytes[y][x] = (byte)(value ? 1 : 0); - } - - /// - /// Clears the specified value. - /// - /// The value. - public void clear(byte value) - { - for (int y = 0; y < height; ++y) - { - var bytesY = bytes[y]; - for (int x = 0; x < width; ++x) - { - bytesY[x] = value; - } - } - } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - override public String ToString() - { - var result = new StringBuilder(2 * width * height + 2); - for (int y = 0; y < height; ++y) - { - var bytesY = bytes[y]; - for (int x = 0; x < width; ++x) - { - switch (bytesY[x]) - { - case 0: - result.Append(" 0"); - break; - case 1: - result.Append(" 1"); - break; - default: - result.Append(" "); - break; - } - } - result.Append('\n'); - } - return result.ToString(); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder/ByteMatrix.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/encoder/ByteMatrix.cs.meta deleted file mode 100644 index 542cda821..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder/ByteMatrix.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4bc405a072c67430aa0a268b6b55c22f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder/Encoder.cs b/Runtime/zxing.unity/Source/lib/qrcode/encoder/Encoder.cs deleted file mode 100644 index c05a16bc2..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder/Encoder.cs +++ /dev/null @@ -1,807 +0,0 @@ -/* -* Copyright 2008 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Collections.Generic; -using System.Text; - -using ZXing.Common; -using ZXing.Common.ReedSolomon; - -namespace ZXing.QrCode.Internal -{ - /// - /// - /// satorux@google.com (Satoru Takabayashi) - creator - /// dswitkin@google.com (Daniel Switkin) - ported from C++ - public static class Encoder - { - - // The original table is defined in the table 5 of JISX0510:2004 (p.19). - private static readonly int[] ALPHANUMERIC_TABLE = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x00-0x0f - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0x10-0x1f - 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, // 0x20-0x2f - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, // 0x30-0x3f - -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, // 0x40-0x4f - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, // 0x50-0x5f - }; - - internal static Encoding DEFAULT_BYTE_MODE_ENCODING = StringUtils.ISO88591_ENCODING; - - // The mask penalty calculation is complicated. See Table 21 of JISX0510:2004 (p.45) for details. - // Basically it applies four rules and summate all penalties. - private static int calculateMaskPenalty(ByteMatrix matrix) - { - return MaskUtil.applyMaskPenaltyRule1(matrix) - + MaskUtil.applyMaskPenaltyRule2(matrix) - + MaskUtil.applyMaskPenaltyRule3(matrix) - + MaskUtil.applyMaskPenaltyRule4(matrix); - } - - /// - /// Encode "bytes" with the error correction level "ecLevel". The encoding mode will be chosen - /// internally by chooseMode(). On success, store the result in "qrCode". - /// We recommend you to use QRCode.EC_LEVEL_L (the lowest level) for - /// "getECLevel" since our primary use is to show QR code on desktop screens. We don't need very - /// strong error correction for this purpose. - /// Note that there is no way to encode bytes in MODE_KANJI. We might want to add EncodeWithMode() - /// with which clients can specify the encoding mode. For now, we don't need the functionality. - /// - /// text to encode - /// error correction level to use - /// representing the encoded QR code - public static QRCode encode(String content, ErrorCorrectionLevel ecLevel) - { - return encode(content, ecLevel, null); - } - - /// - /// Encodes the specified content. - /// - /// The content. - /// The ec level. - /// The hints. - /// - public static QRCode encode(String content, - ErrorCorrectionLevel ecLevel, - IDictionary hints) - { - Version version; - BitArray headerAndDataBits; - Mode mode; - - var hasGS1FormatHint = hints != null && hints.ContainsKey(EncodeHintType.GS1_FORMAT) - && hints[EncodeHintType.GS1_FORMAT] != null && Convert.ToBoolean(hints[EncodeHintType.GS1_FORMAT].ToString()); - var hasCompactionHint = hints != null && hints.ContainsKey(EncodeHintType.QR_COMPACT) - && hints[EncodeHintType.QR_COMPACT] != null && Convert.ToBoolean(hints[EncodeHintType.QR_COMPACT].ToString()); - - // Determine what character encoding has been specified by the caller, if any - bool hasEncodingHint = hints != null && hints.ContainsKey(EncodeHintType.CHARACTER_SET); - -#if !SILVERLIGHT || WINDOWS_PHONE - var encoding = DEFAULT_BYTE_MODE_ENCODING; - var encodingName = hasEncodingHint ? (String)hints[EncodeHintType.CHARACTER_SET] : null; - if (encodingName != null) - { - var eci = CharacterSetECI.getCharacterSetECIByName(encodingName); - if (eci == null) - throw new WriterException(string.Format("Encoding {0} isn't supported", encodingName)); - encoding = CharacterSetECI.getEncoding(eci); - if (encoding == null) - throw new WriterException(string.Format("Encoding {0} isn't supported", encodingName)); - } - var generateECI = hasEncodingHint || !DEFAULT_BYTE_MODE_ENCODING.Equals(encoding); -#else - // Silverlight supports only UTF-8 and UTF-16 out-of-the-box - var encoding = StringUtils.PLATFORM_DEFAULT_ENCODING_T; - // caller of the method can only control if the ECI segment should be written - // character set is fixed to UTF-8; but some scanners doesn't like the ECI segment - var generateECI = hasEncodingHint; -#endif - - if (hasCompactionHint) - { - mode = Mode.BYTE; - - var priorityEncoding = encoding.Equals(DEFAULT_BYTE_MODE_ENCODING) ? null : encoding; - var rn = MinimalEncoder.encode(content, null, priorityEncoding, hasGS1FormatHint, ecLevel); - - headerAndDataBits = new BitArray(); - rn.getBits(headerAndDataBits); - version = rn.getVersion(); - } - else - { - // Pick an encoding mode appropriate for the content. Note that this will not attempt to use - // multiple modes / segments even if that were more efficient. - mode = chooseMode(content, encoding); - - // This will store the header information, like mode and - // length, as well as "header" segments like an ECI segment. - var headerBits = new BitArray(); - - // Append ECI segment if applicable - if (mode == Mode.BYTE && generateECI) - { - var eci = CharacterSetECI.getCharacterSetECI(encoding); - if (eci != null) - { - var eciIsExplicitDisabled = (hints != null && hints.ContainsKey(EncodeHintType.DISABLE_ECI) && hints[EncodeHintType.DISABLE_ECI] != null && Convert.ToBoolean(hints[EncodeHintType.DISABLE_ECI].ToString())); - if (!eciIsExplicitDisabled) - { - appendECI(eci, headerBits); - } - } - } - - // Append the FNC1 mode header for GS1 formatted data if applicable - if (hasGS1FormatHint) - { - // GS1 formatted codes are prefixed with a FNC1 in first position mode header - appendModeInfo(Mode.FNC1_FIRST_POSITION, headerBits); - } - - // (With ECI in place,) Write the mode marker - appendModeInfo(mode, headerBits); - - // Collect data within the main segment, separately, to count its size if needed. Don't add it to - // main payload yet. - var dataBits = new BitArray(); - appendBytes(content, mode, dataBits, encoding); - - if (hints != null && hints.ContainsKey(EncodeHintType.QR_VERSION)) - { - int versionNumber = Int32.Parse(hints[EncodeHintType.QR_VERSION].ToString()); - version = Version.getVersionForNumber(versionNumber); - int bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, version); - if (!willFit(bitsNeeded, version, ecLevel)) - { - throw new WriterException("Data too big for requested version"); - } - } - else - { - version = recommendVersion(ecLevel, mode, headerBits, dataBits); - } - - headerAndDataBits = new BitArray(); - headerAndDataBits.appendBitArray(headerBits); - // Find "length" of main segment and write it - var numLetters = mode == Mode.BYTE ? dataBits.SizeInBytes : content.Length; - appendLengthInfo(numLetters, version, mode, headerAndDataBits); - // Put data together into the overall payload - headerAndDataBits.appendBitArray(dataBits); - } - - var ecBlocks = version.getECBlocksForLevel(ecLevel); - var numDataBytes = version.TotalCodewords - ecBlocks.TotalECCodewords; - - // Terminate the bits properly. - terminateBits(numDataBytes, headerAndDataBits); - - // Interleave data bits with error correction code. - var finalBits = interleaveWithECBytes(headerAndDataBits, - version.TotalCodewords, - numDataBytes, - ecBlocks.NumBlocks); - - var qrCode = new QRCode - { - ECLevel = ecLevel, - Mode = mode, - Version = version - }; - - // Choose the mask pattern and set to "qrCode". - var dimension = version.DimensionForVersion; - var matrix = new ByteMatrix(dimension, dimension); - - // Enable manual selection of the pattern to be used via hint - var maskPattern = -1; - if (hints != null && hints.ContainsKey(EncodeHintType.QR_MASK_PATTERN)) - { - var hintMaskPattern = Int32.Parse(hints[EncodeHintType.QR_MASK_PATTERN].ToString()); - maskPattern = QRCode.isValidMaskPattern(hintMaskPattern) ? hintMaskPattern : -1; - } - - if (maskPattern == -1) - { - maskPattern = chooseMaskPattern(finalBits, ecLevel, version, matrix); - } - qrCode.MaskPattern = maskPattern; - - // Build the matrix and set it to "qrCode". - MatrixUtil.buildMatrix(finalBits, ecLevel, version, maskPattern, matrix); - qrCode.Matrix = matrix; - - return qrCode; - } - - /// - /// Decides the smallest version of QR code that will contain all of the provided data. - /// - /// if the data cannot fit in any version - private static Version recommendVersion(ErrorCorrectionLevel ecLevel, Mode mode, BitArray headerBits, BitArray dataBits) - { - // Hard part: need to know version to know how many bits length takes. But need to know how many - // bits it takes to know version. First we take a guess at version by assuming version will be - // the minimum, 1: - var provisionalBitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, Version.getVersionForNumber(1)); - var provisionalVersion = chooseVersion(provisionalBitsNeeded, ecLevel); - - // Use that guess to calculate the right version. I am still not sure this works in 100% of cases. - var bitsNeeded = calculateBitsNeeded(mode, headerBits, dataBits, provisionalVersion); - return chooseVersion(bitsNeeded, ecLevel); - } - - private static int calculateBitsNeeded(Mode mode, BitArray headerBits, BitArray dataBits, Version version) - { - return headerBits.Size + mode.getCharacterCountBits(version) + dataBits.Size; - } - - /// - /// Gets the alphanumeric code. - /// - /// The code. - /// the code point of the table used in alphanumeric mode or - /// -1 if there is no corresponding code in the table. - internal static int getAlphanumericCode(int code) - { - if (code < ALPHANUMERIC_TABLE.Length) - { - return ALPHANUMERIC_TABLE[code]; - } - return -1; - } - - /// - /// Chooses the mode. - /// - /// The content. - /// - public static Mode chooseMode(String content) - { - return chooseMode(content, null); - } - - /// - /// Choose the best mode by examining the content. Note that 'encoding' is used as a hint; - /// if it is Shift_JIS, and the input is only double-byte Kanji, then we return {@link Mode#KANJI}. - /// - /// The content. - /// The encoding. - /// - private static Mode chooseMode(String content, Encoding encoding) - { - if (StringUtils.SHIFT_JIS_ENCODING != null && StringUtils.SHIFT_JIS_ENCODING.Equals(encoding) && isOnlyDoubleByteKanji(content)) - { - // Choose Kanji mode if all input are double-byte characters - return Mode.KANJI; - } - bool hasNumeric = false; - bool hasAlphanumeric = false; - for (int i = 0; i < content.Length; ++i) - { - char c = content[i]; - if (c >= '0' && c <= '9') - { - hasNumeric = true; - } - else if (getAlphanumericCode(c) != -1) - { - hasAlphanumeric = true; - } - else - { - return Mode.BYTE; - } - } - if (hasAlphanumeric) - { - - return Mode.ALPHANUMERIC; - } - if (hasNumeric) - { - - return Mode.NUMERIC; - } - return Mode.BYTE; - } - - internal static bool isOnlyDoubleByteKanji(String content) - { - byte[] bytes; - try - { - if (StringUtils.SHIFT_JIS_ENCODING == null) - return false; - bytes = StringUtils.SHIFT_JIS_ENCODING.GetBytes(content); - } - catch (Exception) - { - return false; - } - int length = bytes.Length; - if (length % 2 != 0) - { - return false; - } - for (int i = 0; i < length; i += 2) - { - - - int byte1 = bytes[i] & 0xFF; - if ((byte1 < 0x81 || byte1 > 0x9F) && (byte1 < 0xE0 || byte1 > 0xEB)) - { - - return false; - } - } - return true; - } - - private static int chooseMaskPattern(BitArray bits, - ErrorCorrectionLevel ecLevel, - Version version, - ByteMatrix matrix) - { - int minPenalty = Int32.MaxValue; // Lower penalty is better. - int bestMaskPattern = -1; - // We try all mask patterns to choose the best one. - for (int maskPattern = 0; maskPattern < QRCode.NUM_MASK_PATTERNS; maskPattern++) - { - - MatrixUtil.buildMatrix(bits, ecLevel, version, maskPattern, matrix); - int penalty = calculateMaskPenalty(matrix); - if (penalty < minPenalty) - { - - minPenalty = penalty; - bestMaskPattern = maskPattern; - } - } - return bestMaskPattern; - } - - private static Version chooseVersion(int numInputBits, ErrorCorrectionLevel ecLevel) - { - for (int versionNum = 1; versionNum <= 40; versionNum++) - { - var version = Version.getVersionForNumber(versionNum); - if (willFit(numInputBits, version, ecLevel)) - { - return version; - } - } - throw new WriterException("Data too big"); - } - - /// - /// true if the number of input bits will fit in a code with the specified version and error correction level. - internal static bool willFit(int numInputBits, Version version, ErrorCorrectionLevel ecLevel) - { - // In the following comments, we use numbers of Version 7-H. - // numBytes = 196 - var numBytes = version.TotalCodewords; - // getNumECBytes = 130 - var ecBlocks = version.getECBlocksForLevel(ecLevel); - var numEcBytes = ecBlocks.TotalECCodewords; - // getNumDataBytes = 196 - 130 = 66 - var numDataBytes = numBytes - numEcBytes; - var totalInputBytes = (numInputBits + 7) / 8; - return numDataBytes >= totalInputBytes; - } - - /// - /// Terminate bits as described in 8.4.8 and 8.4.9 of JISX0510:2004 (p.24). - /// - /// The num data bytes. - /// The bits. - internal static void terminateBits(int numDataBytes, BitArray bits) - { - int capacity = numDataBytes << 3; - if (bits.Size > capacity) - { - throw new WriterException("data bits cannot fit in the QR Code" + bits.Size + " > " + - capacity); - } - // Append Mode.TERMINATE if there is enough space (value is 0000) - for (int i = 0; i < 4 && bits.Size < capacity; ++i) - { - bits.appendBit(false); - } - // Append termination bits. See 8.4.8 of JISX0510:2004 (p.24) for details. - // If the last byte isn't 8-bit aligned, we'll add padding bits. - int numBitsInLastByte = bits.Size & 0x07; - if (numBitsInLastByte > 0) - { - for (int i = numBitsInLastByte; i < 8; i++) - { - bits.appendBit(false); - } - } - // If we have more space, we'll fill the space with padding patterns defined in 8.4.9 (p.24). - int numPaddingBytes = numDataBytes - bits.SizeInBytes; - for (int i = 0; i < numPaddingBytes; ++i) - { - bits.appendBits((i & 0x01) == 0 ? 0xEC : 0x11, 8); - } - if (bits.Size != capacity) - { - throw new WriterException("Bits size does not equal capacity"); - } - } - - /// - /// Get number of data bytes and number of error correction bytes for block id "blockID". Store - /// the result in "numDataBytesInBlock", and "numECBytesInBlock". See table 12 in 8.5.1 of - /// JISX0510:2004 (p.30) - /// - /// The num total bytes. - /// The num data bytes. - /// The num RS blocks. - /// The block ID. - /// The num data bytes in block. - /// The num EC bytes in block. - internal static void getNumDataBytesAndNumECBytesForBlockID(int numTotalBytes, - int numDataBytes, - int numRSBlocks, - int blockID, - int[] numDataBytesInBlock, - int[] numECBytesInBlock) - { - if (blockID >= numRSBlocks) - { - throw new WriterException("Block ID too large"); - } - // numRsBlocksInGroup2 = 196 % 5 = 1 - int numRsBlocksInGroup2 = numTotalBytes % numRSBlocks; - // numRsBlocksInGroup1 = 5 - 1 = 4 - int numRsBlocksInGroup1 = numRSBlocks - numRsBlocksInGroup2; - // numTotalBytesInGroup1 = 196 / 5 = 39 - int numTotalBytesInGroup1 = numTotalBytes / numRSBlocks; - // numTotalBytesInGroup2 = 39 + 1 = 40 - int numTotalBytesInGroup2 = numTotalBytesInGroup1 + 1; - // numDataBytesInGroup1 = 66 / 5 = 13 - int numDataBytesInGroup1 = numDataBytes / numRSBlocks; - // numDataBytesInGroup2 = 13 + 1 = 14 - int numDataBytesInGroup2 = numDataBytesInGroup1 + 1; - // numEcBytesInGroup1 = 39 - 13 = 26 - int numEcBytesInGroup1 = numTotalBytesInGroup1 - numDataBytesInGroup1; - // numEcBytesInGroup2 = 40 - 14 = 26 - int numEcBytesInGroup2 = numTotalBytesInGroup2 - numDataBytesInGroup2; - // Sanity checks. - // 26 = 26 - if (numEcBytesInGroup1 != numEcBytesInGroup2) - { - - throw new WriterException("EC bytes mismatch"); - } - // 5 = 4 + 1. - if (numRSBlocks != numRsBlocksInGroup1 + numRsBlocksInGroup2) - { - - throw new WriterException("RS blocks mismatch"); - } - // 196 = (13 + 26) * 4 + (14 + 26) * 1 - if (numTotalBytes != - ((numDataBytesInGroup1 + numEcBytesInGroup1) * - numRsBlocksInGroup1) + - ((numDataBytesInGroup2 + numEcBytesInGroup2) * - numRsBlocksInGroup2)) - { - throw new WriterException("Total bytes mismatch"); - } - - if (blockID < numRsBlocksInGroup1) - { - - numDataBytesInBlock[0] = numDataBytesInGroup1; - numECBytesInBlock[0] = numEcBytesInGroup1; - } - else - { - - - numDataBytesInBlock[0] = numDataBytesInGroup2; - numECBytesInBlock[0] = numEcBytesInGroup2; - } - } - - /// - /// Interleave "bits" with corresponding error correction bytes. On success, store the result in - /// "result". The interleave rule is complicated. See 8.6 of JISX0510:2004 (p.37) for details. - /// - /// The bits. - /// The num total bytes. - /// The num data bytes. - /// The num RS blocks. - /// - internal static BitArray interleaveWithECBytes(BitArray bits, - int numTotalBytes, - int numDataBytes, - int numRSBlocks) - { - // "bits" must have "getNumDataBytes" bytes of data. - if (bits.SizeInBytes != numDataBytes) - { - - throw new WriterException("Number of bits and data bytes does not match"); - } - - // Step 1. Divide data bytes into blocks and generate error correction bytes for them. We'll - // store the divided data bytes blocks and error correction bytes blocks into "blocks". - int dataBytesOffset = 0; - int maxNumDataBytes = 0; - int maxNumEcBytes = 0; - - // Since, we know the number of reedsolmon blocks, we can initialize the vector with the number. - var blocks = new List(numRSBlocks); - - for (int i = 0; i < numRSBlocks; ++i) - { - - int[] numDataBytesInBlock = new int[1]; - int[] numEcBytesInBlock = new int[1]; - getNumDataBytesAndNumECBytesForBlockID( - numTotalBytes, numDataBytes, numRSBlocks, i, - numDataBytesInBlock, numEcBytesInBlock); - - int size = numDataBytesInBlock[0]; - byte[] dataBytes = new byte[size]; - bits.toBytes(8 * dataBytesOffset, dataBytes, 0, size); - byte[] ecBytes = generateECBytes(dataBytes, numEcBytesInBlock[0]); - blocks.Add(new BlockPair(dataBytes, ecBytes)); - - maxNumDataBytes = Math.Max(maxNumDataBytes, size); - maxNumEcBytes = Math.Max(maxNumEcBytes, ecBytes.Length); - dataBytesOffset += numDataBytesInBlock[0]; - } - if (numDataBytes != dataBytesOffset) - { - - throw new WriterException("Data bytes does not match offset"); - } - - BitArray result = new BitArray(); - - // First, place data blocks. - for (int i = 0; i < maxNumDataBytes; ++i) - { - foreach (BlockPair block in blocks) - { - byte[] dataBytes = block.DataBytes; - if (i < dataBytes.Length) - { - result.appendBits(dataBytes[i], 8); - } - } - } - // Then, place error correction blocks. - for (int i = 0; i < maxNumEcBytes; ++i) - { - foreach (BlockPair block in blocks) - { - byte[] ecBytes = block.ErrorCorrectionBytes; - if (i < ecBytes.Length) - { - result.appendBits(ecBytes[i], 8); - } - } - } - if (numTotalBytes != result.SizeInBytes) - { // Should be same. - throw new WriterException("Interleaving error: " + numTotalBytes + " and " + - result.SizeInBytes + " differ."); - } - - return result; - } - - internal static byte[] generateECBytes(byte[] dataBytes, int numEcBytesInBlock) - { - int numDataBytes = dataBytes.Length; - int[] toEncode = new int[numDataBytes + numEcBytesInBlock]; - for (int i = 0; i < numDataBytes; i++) - { - toEncode[i] = dataBytes[i] & 0xFF; - - } - new ReedSolomonEncoder(GenericGF.QR_CODE_FIELD_256).encode(toEncode, numEcBytesInBlock); - - byte[] ecBytes = new byte[numEcBytesInBlock]; - for (int i = 0; i < numEcBytesInBlock; i++) - { - ecBytes[i] = (byte)toEncode[numDataBytes + i]; - - } - return ecBytes; - } - - /// - /// Append mode info. On success, store the result in "bits". - /// - /// The mode. - /// The bits. - internal static void appendModeInfo(Mode mode, BitArray bits) - { - bits.appendBits(mode.Bits, 4); - } - - - /// - /// Append length info. On success, store the result in "bits". - /// - /// The num letters. - /// The version. - /// The mode. - /// The bits. - internal static void appendLengthInfo(int numLetters, Version version, Mode mode, BitArray bits) - { - int numBits = mode.getCharacterCountBits(version); - if (numLetters >= (1 << numBits)) - { - throw new WriterException(numLetters + " is bigger than " + ((1 << numBits) - 1)); - } - bits.appendBits(numLetters, numBits); - } - - /// - /// Append "bytes" in "mode" mode (encoding) into "bits". On success, store the result in "bits". - /// - /// The content. - /// The mode. - /// The bits. - /// The encoding. - internal static void appendBytes(String content, - Mode mode, - BitArray bits, - Encoding encoding) - { - if (mode.Equals(Mode.NUMERIC)) - appendNumericBytes(content, bits); - else - if (mode.Equals(Mode.ALPHANUMERIC)) - appendAlphanumericBytes(content, bits); - else - if (mode.Equals(Mode.BYTE)) - append8BitBytes(content, bits, encoding); - else - if (mode.Equals(Mode.KANJI)) - appendKanjiBytes(content, bits); - else - throw new WriterException("Invalid mode: " + mode); - } - - internal static void appendNumericBytes(String content, BitArray bits) - { - int length = content.Length; - - int i = 0; - while (i < length) - { - int num1 = content[i] - '0'; - if (i + 2 < length) - { - // Encode three numeric letters in ten bits. - int num2 = content[i + 1] - '0'; - int num3 = content[i + 2] - '0'; - bits.appendBits(num1 * 100 + num2 * 10 + num3, 10); - i += 3; - } - else if (i + 1 < length) - { - // Encode two numeric letters in seven bits. - int num2 = content[i + 1] - '0'; - bits.appendBits(num1 * 10 + num2, 7); - i += 2; - } - else - { - // Encode one numeric letter in four bits. - bits.appendBits(num1, 4); - i++; - } - } - } - - internal static void appendAlphanumericBytes(String content, BitArray bits) - { - int length = content.Length; - - int i = 0; - while (i < length) - { - int code1 = getAlphanumericCode(content[i]); - if (code1 == -1) - { - throw new WriterException(); - } - if (i + 1 < length) - { - int code2 = getAlphanumericCode(content[i + 1]); - if (code2 == -1) - { - throw new WriterException(); - } - // Encode two alphanumeric letters in 11 bits. - bits.appendBits(code1 * 45 + code2, 11); - i += 2; - } - else - { - // Encode one alphanumeric letter in six bits. - bits.appendBits(code1, 6); - i++; - } - } - } - - internal static void append8BitBytes(String content, BitArray bits, Encoding encoding) - { - var bytes = encoding.GetBytes(content); - foreach (byte b in bytes) - { - bits.appendBits(b, 8); - } - } - - internal static void appendKanjiBytes(String content, BitArray bits) - { - if (StringUtils.SHIFT_JIS_ENCODING == null) - throw new WriterException("Encoding SHIFT_JIS isn't supported at this platform"); - var bytes = Encoding.GetEncoding("Shift_JIS").GetBytes(content); - if (bytes.Length % 2 != 0) - { - throw new WriterException("Kanji byte size not even"); - } - int maxI = bytes.Length - 1; // bytes.length must be even - for (int i = 0; i < maxI; i += 2) - { - int byte1 = bytes[i] & 0xFF; - int byte2 = bytes[i + 1] & 0xFF; - int code = (byte1 << 8) | byte2; - int subtracted = -1; - if (code >= 0x8140 && code <= 0x9ffc) - { - - subtracted = code - 0x8140; - } - else if (code >= 0xe040 && code <= 0xebbf) - { - subtracted = code - 0xc140; - } - if (subtracted == -1) - { - - throw new WriterException("Invalid byte sequence"); - } - int encoded = ((subtracted >> 8) * 0xc0) + (subtracted & 0xff); - bits.appendBits(encoded, 13); - } - } - - private static void appendECI(CharacterSetECI eci, BitArray bits) - { - bits.appendBits(Mode.ECI.Bits, 4); - - // This is correct for values up to 127, which is all we need now. - bits.appendBits(eci.Value, 8); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder/Encoder.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/encoder/Encoder.cs.meta deleted file mode 100644 index b1dabe9b1..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder/Encoder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c3f61abcf27f74ccfb117e0b9b935d82 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder/MaskUtil.cs b/Runtime/zxing.unity/Source/lib/qrcode/encoder/MaskUtil.cs deleted file mode 100644 index e0c60e1ce..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder/MaskUtil.cs +++ /dev/null @@ -1,285 +0,0 @@ -/* -* Copyright 2008 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; - -namespace ZXing.QrCode.Internal -{ - /// - /// - /// - /// Satoru Takabayashi - /// Daniel Switkin - /// Sean Owen - public static class MaskUtil - { - // Penalty weights from section 6.8.2.1 - private const int N1 = 3; - private const int N2 = 3; - private const int N3 = 40; - private const int N4 = 10; - - /// - /// Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and - /// give penalty to them. Example: 00000 or 11111. - /// - /// The matrix. - /// - public static int applyMaskPenaltyRule1(ByteMatrix matrix) - { - return applyMaskPenaltyRule1Internal(matrix, true) + applyMaskPenaltyRule1Internal(matrix, false); - } - - /// - /// Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give - /// penalty to them. This is actually equivalent to the spec's rule, which is to find MxN blocks and give a - /// penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block. - /// - /// The matrix. - /// - public static int applyMaskPenaltyRule2(ByteMatrix matrix) - { - int penalty = 0; - var array = matrix.Array; - int width = matrix.Width; - int height = matrix.Height; - for (int y = 0; y < height - 1; y++) - { - var arrayY = array[y]; - var arrayY1 = array[y + 1]; - for (int x = 0; x < width - 1; x++) - { - int value = arrayY[x]; - if (value == arrayY[x + 1] && value == arrayY1[x] && value == arrayY1[x + 1]) - { - penalty++; - } - } - } - return N2 * penalty; - } - - /// - /// Apply mask penalty rule 3 and return the penalty. Find consecutive cells of 00001011101 or - /// 10111010000, and give penalty to them. If we find patterns like 000010111010000, we give - /// penalties twice (i.e. 40 * 2). - /// - /// The matrix. - /// - public static int applyMaskPenaltyRule3(ByteMatrix matrix) - { - int numPenalties = 0; - byte[][] array = matrix.Array; - int width = matrix.Width; - int height = matrix.Height; - for (int y = 0; y < height; y++) - { - for (int x = 0; x < width; x++) - { - byte[] arrayY = array[y]; // We can at least optimize this access - if (x + 6 < width && - arrayY[x] == 1 && - arrayY[x + 1] == 0 && - arrayY[x + 2] == 1 && - arrayY[x + 3] == 1 && - arrayY[x + 4] == 1 && - arrayY[x + 5] == 0 && - arrayY[x + 6] == 1 && - (isWhiteHorizontal(arrayY, x - 4, x) || isWhiteHorizontal(arrayY, x + 7, x + 11))) - { - numPenalties++; - } - if (y + 6 < height && - array[y][x] == 1 && - array[y + 1][x] == 0 && - array[y + 2][x] == 1 && - array[y + 3][x] == 1 && - array[y + 4][x] == 1 && - array[y + 5][x] == 0 && - array[y + 6][x] == 1 && - (isWhiteVertical(array, x, y - 4, y) || isWhiteVertical(array, x, y + 7, y + 11))) - { - numPenalties++; - } - } - } - return numPenalties * N3; - } - - private static bool isWhiteHorizontal(byte[] rowArray, int from, int to) - { - if (from < 0 || rowArray.Length < to) - { - return false; - } - from = Math.Max(from, 0); - to = Math.Min(to, rowArray.Length); - for (int i = from; i < to; i++) - { - if (rowArray[i] == 1) - { - return false; - } - } - return true; - } - - private static bool isWhiteVertical(byte[][] array, int col, int from, int to) - { - if (from < 0 || array.Length < to) - { - return false; - } - from = Math.Max(from, 0); - to = Math.Min(to, array.Length); - for (int i = from; i < to; i++) - { - if (array[i][col] == 1) - { - return false; - } - } - return true; - } - - /// - /// Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give - /// penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance. - /// - /// The matrix. - /// - public static int applyMaskPenaltyRule4(ByteMatrix matrix) - { - int numDarkCells = 0; - var array = matrix.Array; - int width = matrix.Width; - int height = matrix.Height; - for (int y = 0; y < height; y++) - { - var arrayY = array[y]; - for (int x = 0; x < width; x++) - { - if (arrayY[x] == 1) - { - numDarkCells++; - } - } - } - var numTotalCells = matrix.Height * matrix.Width; - var darkRatio = (double)numDarkCells / numTotalCells; - var fivePercentVariances = (int)(Math.Abs(darkRatio - 0.5) * 20.0); // * 100.0 / 5.0 - return fivePercentVariances * N4; - } - - /// - /// Return the mask bit for "getMaskPattern" at "x" and "y". See 8.8 of JISX0510:2004 for mask - /// pattern conditions. - /// - /// The mask pattern. - /// The x. - /// The y. - /// - public static bool getDataMaskBit(int maskPattern, int x, int y) - { - int intermediate, temp; - switch (maskPattern) - { - - case 0: - intermediate = (y + x) & 0x1; - break; - - case 1: - intermediate = y & 0x1; - break; - - case 2: - intermediate = x % 3; - break; - - case 3: - intermediate = (y + x) % 3; - break; - - case 4: - intermediate = (((int)((uint)y >> 1)) + (x / 3)) & 0x1; - break; - - case 5: - temp = y * x; - intermediate = (temp & 0x1) + (temp % 3); - break; - - case 6: - temp = y * x; - intermediate = (((temp & 0x1) + (temp % 3)) & 0x1); - break; - - case 7: - temp = y * x; - intermediate = (((temp % 3) + ((y + x) & 0x1)) & 0x1); - break; - - default: - throw new ArgumentException("Invalid mask pattern: " + maskPattern); - - } - return intermediate == 0; - } - - /// - /// Helper function for applyMaskPenaltyRule1. We need this for doing this calculation in both - /// vertical and horizontal orders respectively. - /// - /// The matrix. - /// if set to true [is horizontal]. - /// - private static int applyMaskPenaltyRule1Internal(ByteMatrix matrix, bool isHorizontal) - { - int penalty = 0; - int iLimit = isHorizontal ? matrix.Height : matrix.Width; - int jLimit = isHorizontal ? matrix.Width : matrix.Height; - var array = matrix.Array; - for (int i = 0; i < iLimit; i++) - { - int numSameBitCells = 0; - int prevBit = -1; - for (int j = 0; j < jLimit; j++) - { - int bit = isHorizontal ? array[i][j] : array[j][i]; - if (bit == prevBit) - { - numSameBitCells++; - } - else - { - if (numSameBitCells >= 5) - { - penalty += N1 + (numSameBitCells - 5); - } - numSameBitCells = 1; // Include the cell itself. - prevBit = bit; - } - } - if (numSameBitCells >= 5) - { - penalty += N1 + (numSameBitCells - 5); - } - } - return penalty; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder/MaskUtil.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/encoder/MaskUtil.cs.meta deleted file mode 100644 index 845e984bd..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder/MaskUtil.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a29919e4de68e44a7b8da1ecd977eecc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder/MatrixUtil.cs b/Runtime/zxing.unity/Source/lib/qrcode/encoder/MatrixUtil.cs deleted file mode 100644 index 86ec393d3..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder/MatrixUtil.cs +++ /dev/null @@ -1,603 +0,0 @@ -/* -* Copyright 2008 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using ZXing.Common; - -namespace ZXing.QrCode.Internal -{ - /// - /// - /// - /// - /// satorux@google.com (Satoru Takabayashi) - creator - /// - public static class MatrixUtil - { - private static readonly int[][] POSITION_DETECTION_PATTERN = new int[][] - { - new int[] {1, 1, 1, 1, 1, 1, 1}, - new int[] {1, 0, 0, 0, 0, 0, 1}, - new int[] {1, 0, 1, 1, 1, 0, 1}, - new int[] {1, 0, 1, 1, 1, 0, 1}, - new int[] {1, 0, 1, 1, 1, 0, 1}, - new int[] {1, 0, 0, 0, 0, 0, 1}, - new int[] {1, 1, 1, 1, 1, 1, 1} - }; - - private static readonly int[][] POSITION_ADJUSTMENT_PATTERN = new int[][] - { - new int[] {1, 1, 1, 1, 1}, - new int[] {1, 0, 0, 0, 1}, - new int[] {1, 0, 1, 0, 1}, - new int[] {1, 0, 0, 0, 1}, - new int[] {1, 1, 1, 1, 1} - }; - - // From Appendix E. Table 1, JIS0510X:2004 (p 71). The table was double-checked by komatsu. - private static readonly int[][] POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE = new int[][] - { - new int[] {-1, -1, -1, -1, -1, -1, -1}, - new int[] {6, 18, -1, -1, -1, -1, -1}, - new int[] {6, 22, -1, -1, -1, -1, -1}, - new int[] {6, 26, -1, -1, -1, -1, -1}, - new int[] {6, 30, -1, -1, -1, -1, -1}, - new int[] {6, 34, -1, -1, -1, -1, -1}, - new int[] {6, 22, 38, -1, -1, -1, -1}, - new int[] {6, 24, 42, -1, -1, -1, -1}, - new int[] {6, 26, 46, -1, -1, -1, -1}, - new int[] {6, 28, 50, -1, -1, -1, -1}, - new int[] {6, 30, 54, -1, -1, -1, -1}, - new int[] {6, 32, 58, -1, -1, -1, -1}, - new int[] {6, 34, 62, -1, -1, -1, -1}, - new int[] {6, 26, 46, 66, -1, -1, -1}, - new int[] {6, 26, 48, 70, -1, -1, -1}, - new int[] {6, 26, 50, 74, -1, -1, -1}, - new int[] {6, 30, 54, 78, -1, -1, -1}, - new int[] {6, 30, 56, 82, -1, -1, -1}, - new int[] {6, 30, 58, 86, -1, -1, -1}, - new int[] {6, 34, 62, 90, -1, -1, -1}, - new int[] {6, 28, 50, 72, 94, -1, -1}, - new int[] {6, 26, 50, 74, 98, -1, -1}, - new int[] {6, 30, 54, 78, 102, -1, -1}, - new int[] {6, 28, 54, 80, 106, -1, -1}, - new int[] {6, 32, 58, 84, 110, -1, -1}, - new int[] {6, 30, 58, 86, 114, -1, -1}, - new int[] {6, 34, 62, 90, 118, -1, -1}, - new int[] {6, 26, 50, 74, 98, 122, -1}, - new int[] {6, 30, 54, 78, 102, 126, -1}, - new int[] {6, 26, 52, 78, 104, 130, -1}, - new int[] {6, 30, 56, 82, 108, 134, -1}, - new int[] {6, 34, 60, 86, 112, 138, -1}, - new int[] {6, 30, 58, 86, 114, 142, -1}, - new int[] {6, 34, 62, 90, 118, 146, -1}, - new int[] {6, 30, 54, 78, 102, 126, 150}, - new int[] {6, 24, 50, 76, 102, 128, 154}, - new int[] {6, 28, 54, 80, 106, 132, 158}, - new int[] {6, 32, 58, 84, 110, 136, 162}, - new int[] {6, 26, 54, 82, 110, 138, 166}, - new int[] {6, 30, 58, 86, 114, 142, 170} - }; - - // Type info cells at the left top corner. - private static readonly int[][] TYPE_INFO_COORDINATES = new int[][] - { - new int[] {8, 0}, - new int[] {8, 1}, - new int[] {8, 2}, - new int[] {8, 3}, - new int[] {8, 4}, - new int[] {8, 5}, - new int[] {8, 7}, - new int[] {8, 8}, - new int[] {7, 8}, - new int[] {5, 8}, - new int[] {4, 8}, - new int[] {3, 8}, - new int[] {2, 8}, - new int[] {1, 8}, - new int[] {0, 8} - }; - - // From Appendix D in JISX0510:2004 (p. 67) - private const int VERSION_INFO_POLY = 0x1f25; // 1 1111 0010 0101 - - // From Appendix C in JISX0510:2004 (p.65). - private const int TYPE_INFO_POLY = 0x537; - private const int TYPE_INFO_MASK_PATTERN = 0x5412; - - /// - /// Set all cells to 2. 2 means that the cell is empty (not set yet). - /// - /// JAVAPORT: We shouldn't need to do this at all. The code should be rewritten to begin encoding - /// with the ByteMatrix initialized all to zero. - /// - /// The matrix. - public static void clearMatrix(ByteMatrix matrix) - { - matrix.clear(2); - } - - /// - /// Build 2D matrix of QR Code from "dataBits" with "ecLevel", "version" and "getMaskPattern". On - /// success, store the result in "matrix" and return true. - /// - /// The data bits. - /// The ec level. - /// The version. - /// The mask pattern. - /// The matrix. - public static void buildMatrix(BitArray dataBits, ErrorCorrectionLevel ecLevel, Version version, int maskPattern, - ByteMatrix matrix) - { - clearMatrix(matrix); - embedBasicPatterns(version, matrix); - // Type information appear with any version. - embedTypeInfo(ecLevel, maskPattern, matrix); - // Version info appear if version >= 7. - maybeEmbedVersionInfo(version, matrix); - // Data should be embedded at end. - embedDataBits(dataBits, maskPattern, matrix); - } - - /// - /// Embed basic patterns. On success, modify the matrix and return true. - /// The basic patterns are: - /// - Position detection patterns - /// - Timing patterns - /// - Dark dot at the left bottom corner - /// - Position adjustment patterns, if need be - /// - /// The version. - /// The matrix. - public static void embedBasicPatterns(Version version, ByteMatrix matrix) - { - // Let's get started with embedding big squares at corners. - embedPositionDetectionPatternsAndSeparators(matrix); - // Then, embed the dark dot at the left bottom corner. - embedDarkDotAtLeftBottomCorner(matrix); - - // Position adjustment patterns appear if version >= 2. - maybeEmbedPositionAdjustmentPatterns(version, matrix); - // Timing patterns should be embedded after position adj. patterns. - embedTimingPatterns(matrix); - } - - /// - /// Embed type information. On success, modify the matrix. - /// - /// The ec level. - /// The mask pattern. - /// The matrix. - public static void embedTypeInfo(ErrorCorrectionLevel ecLevel, int maskPattern, ByteMatrix matrix) - { - BitArray typeInfoBits = new BitArray(); - makeTypeInfoBits(ecLevel, maskPattern, typeInfoBits); - - for (int i = 0; i < typeInfoBits.Size; ++i) - { - // Place bits in LSB to MSB order. LSB (least significant bit) is the last value in - // "typeInfoBits". - int bit = typeInfoBits[typeInfoBits.Size - 1 - i] ? 1 : 0; - - // Type info bits at the left top corner. See 8.9 of JISX0510:2004 (p.46). - int[] coordinates = TYPE_INFO_COORDINATES[i]; - int x1 = coordinates[0]; - int y1 = coordinates[1]; - matrix[x1, y1] = bit; - - int x2; - int y2; - if (i < 8) - { - // Right top corner. - x2 = matrix.Width - i - 1; - y2 = 8; - } - else - { - // Left bottom corner. - x2 = 8; - y2 = matrix.Height - 7 + (i - 8); - } - matrix[x2, y2] = bit; - } - } - - /// - /// Embed version information if need be. On success, modify the matrix and return true. - /// See 8.10 of JISX0510:2004 (p.47) for how to embed version information. - /// - /// The version. - /// The matrix. - public static void maybeEmbedVersionInfo(Version version, ByteMatrix matrix) - { - if (version.VersionNumber < 7) - { - // Version info is necessary if version >= 7. - return; // Don't need version info. - } - BitArray versionInfoBits = new BitArray(); - makeVersionInfoBits(version, versionInfoBits); - - int bitIndex = 6 * 3 - 1; // It will decrease from 17 to 0. - for (int i = 0; i < 6; ++i) - { - for (int j = 0; j < 3; ++j) - { - // Place bits in LSB (least significant bit) to MSB order. - var bit = versionInfoBits[bitIndex] ? 1 : 0; - bitIndex--; - // Left bottom corner. - matrix[i, matrix.Height - 11 + j] = bit; - // Right bottom corner. - matrix[matrix.Height - 11 + j, i] = bit; - } - } - } - - /// - /// Embed "dataBits" using "getMaskPattern". On success, modify the matrix and return true. - /// For debugging purposes, it skips masking process if "getMaskPattern" is -1. - /// See 8.7 of JISX0510:2004 (p.38) for how to embed data bits. - /// - /// The data bits. - /// The mask pattern. - /// The matrix. - public static void embedDataBits(BitArray dataBits, int maskPattern, ByteMatrix matrix) - { - int bitIndex = 0; - int direction = -1; - // Start from the right bottom cell. - int x = matrix.Width - 1; - int y = matrix.Height - 1; - while (x > 0) - { - // Skip the vertical timing pattern. - if (x == 6) - { - x -= 1; - } - while (y >= 0 && y < matrix.Height) - { - for (int i = 0; i < 2; ++i) - { - int xx = x - i; - // Skip the cell if it's not empty. - if (!isEmpty(matrix[xx, y])) - { - continue; - } - int bit; - if (bitIndex < dataBits.Size) - { - bit = dataBits[bitIndex] ? 1 : 0; - ++bitIndex; - } - else - { - // Padding bit. If there is no bit left, we'll fill the left cells with 0, as described - // in 8.4.9 of JISX0510:2004 (p. 24). - bit = 0; - } - - // Skip masking if mask_pattern is -1. - if (maskPattern != -1) - { - if (MaskUtil.getDataMaskBit(maskPattern, xx, y)) - { - bit ^= 0x1; - } - } - matrix[xx, y] = bit; - } - y += direction; - } - direction = -direction; // Reverse the direction. - y += direction; - x -= 2; // Move to the left. - } - // All bits should be consumed. - if (bitIndex != dataBits.Size) - { - throw new WriterException("Not all bits consumed: " + bitIndex + '/' + dataBits.Size); - } - } - - /// - /// Return the position of the most significant bit set (to one) in the "value". The most - /// significant bit is position 32. If there is no bit set, return 0. Examples: - /// - findMSBSet(0) => 0 - /// - findMSBSet(1) => 1 - /// - findMSBSet(255) => 8 - /// - /// The value_ renamed. - /// - public static int findMSBSet(int value_Renamed) - { - int numDigits = 0; - while (value_Renamed != 0) - { - value_Renamed = (int)((uint)value_Renamed >> 1); - ++numDigits; - } - return numDigits; - } - - /// - /// Calculate BCH (Bose-Chaudhuri-Hocquenghem) code for "value" using polynomial "poly". The BCH - /// code is used for encoding type information and version information. - /// Example: Calculation of version information of 7. - /// f(x) is created from 7. - /// - 7 = 000111 in 6 bits - /// - f(x) = x^2 + x^2 + x^1 - /// g(x) is given by the standard (p. 67) - /// - g(x) = x^12 + x^11 + x^10 + x^9 + x^8 + x^5 + x^2 + 1 - /// Multiply f(x) by x^(18 - 6) - /// - f'(x) = f(x) * x^(18 - 6) - /// - f'(x) = x^14 + x^13 + x^12 - /// Calculate the remainder of f'(x) / g(x) - /// x^2 - /// __________________________________________________ - /// g(x) )x^14 + x^13 + x^12 - /// x^14 + x^13 + x^12 + x^11 + x^10 + x^7 + x^4 + x^2 - /// -------------------------------------------------- - /// x^11 + x^10 + x^7 + x^4 + x^2 - /// - /// The remainder is x^11 + x^10 + x^7 + x^4 + x^2 - /// Encode it in binary: 110010010100 - /// The return value is 0xc94 (1100 1001 0100) - /// - /// Since all coefficients in the polynomials are 1 or 0, we can do the calculation by bit - /// operations. We don't care if coefficients are positive or negative. - /// - /// The value. - /// The poly. - /// - public static int calculateBCHCode(int value, int poly) - { - if (poly == 0) - throw new ArgumentException("0 polynominal", "poly"); - - // If poly is "1 1111 0010 0101" (version info poly), msbSetInPoly is 13. We'll subtract 1 - // from 13 to make it 12. - int msbSetInPoly = findMSBSet(poly); - value <<= msbSetInPoly - 1; - // Do the division business using exclusive-or operations. - while (findMSBSet(value) >= msbSetInPoly) - { - value ^= poly << (findMSBSet(value) - msbSetInPoly); - } - // Now the "value" is the remainder (i.e. the BCH code) - return value; - } - - /// - /// Make bit vector of type information. On success, store the result in "bits" and return true. - /// Encode error correction level and mask pattern. See 8.9 of - /// JISX0510:2004 (p.45) for details. - /// - /// The ec level. - /// The mask pattern. - /// The bits. - public static void makeTypeInfoBits(ErrorCorrectionLevel ecLevel, int maskPattern, BitArray bits) - { - if (!QRCode.isValidMaskPattern(maskPattern)) - { - throw new WriterException("Invalid mask pattern"); - } - int typeInfo = (ecLevel.Bits << 3) | maskPattern; - bits.appendBits(typeInfo, 5); - - int bchCode = calculateBCHCode(typeInfo, TYPE_INFO_POLY); - bits.appendBits(bchCode, 10); - - BitArray maskBits = new BitArray(); - maskBits.appendBits(TYPE_INFO_MASK_PATTERN, 15); - bits.xor(maskBits); - - if (bits.Size != 15) - { - // Just in case. - throw new WriterException("should not happen but we got: " + bits.Size); - } - } - - /// - /// Make bit vector of version information. On success, store the result in "bits" and return true. - /// See 8.10 of JISX0510:2004 (p.45) for details. - /// - /// The version. - /// The bits. - public static void makeVersionInfoBits(Version version, BitArray bits) - { - bits.appendBits(version.VersionNumber, 6); - int bchCode = calculateBCHCode(version.VersionNumber, VERSION_INFO_POLY); - bits.appendBits(bchCode, 12); - - if (bits.Size != 18) - { - // Just in case. - throw new WriterException("should not happen but we got: " + bits.Size); - } - } - - /// - /// Check if "value" is empty. - /// - /// The value. - /// - /// true if the specified value is empty; otherwise, false. - /// - private static bool isEmpty(int value) - { - return value == 2; - } - - private static void embedTimingPatterns(ByteMatrix matrix) - { - // -8 is for skipping position detection patterns (size 7), and two horizontal/vertical - // separation patterns (size 1). Thus, 8 = 7 + 1. - for (int i = 8; i < matrix.Width - 8; ++i) - { - int bit = (i + 1) % 2; - // Horizontal line. - if (isEmpty(matrix[i, 6])) - { - matrix[i, 6] = bit; - } - // Vertical line. - if (isEmpty(matrix[6, i])) - { - matrix[6, i] = bit; - } - } - } - - /// - /// Embed the lonely dark dot at left bottom corner. JISX0510:2004 (p.46) - /// - /// The matrix. - private static void embedDarkDotAtLeftBottomCorner(ByteMatrix matrix) - { - if (matrix[8, matrix.Height - 8] == 0) - { - throw new WriterException(); - } - matrix[8, matrix.Height - 8] = 1; - } - - private static void embedHorizontalSeparationPattern(int xStart, int yStart, ByteMatrix matrix) - { - for (int x = 0; x < 8; ++x) - { - if (!isEmpty(matrix[xStart + x, yStart])) - { - throw new WriterException(); - } - matrix[xStart + x, yStart] = 0; - } - } - - private static void embedVerticalSeparationPattern(int xStart, int yStart, ByteMatrix matrix) - { - for (int y = 0; y < 7; ++y) - { - if (!isEmpty(matrix[xStart, yStart + y])) - { - throw new WriterException(); - } - matrix[xStart, yStart + y] = 0; - } - } - - /// - /// - /// - /// The x start. - /// The y start. - /// The matrix. - private static void embedPositionAdjustmentPattern(int xStart, int yStart, ByteMatrix matrix) - { - for (int y = 0; y < 5; ++y) - { - var patternY = POSITION_ADJUSTMENT_PATTERN[y]; - for (int x = 0; x < 5; ++x) - { - matrix[xStart + x, yStart + y] = patternY[x]; - } - } - } - - private static void embedPositionDetectionPattern(int xStart, int yStart, ByteMatrix matrix) - { - for (int y = 0; y < 7; ++y) - { - var patternY = POSITION_DETECTION_PATTERN[y]; - for (int x = 0; x < 7; ++x) - { - matrix[xStart + x, yStart + y] = patternY[x]; - } - } - } - - /// - /// Embed position detection patterns and surrounding vertical/horizontal separators. - /// - /// The matrix. - private static void embedPositionDetectionPatternsAndSeparators(ByteMatrix matrix) - { - // Embed three big squares at corners. - int pdpWidth = POSITION_DETECTION_PATTERN[0].Length; - // Left top corner. - embedPositionDetectionPattern(0, 0, matrix); - // Right top corner. - embedPositionDetectionPattern(matrix.Width - pdpWidth, 0, matrix); - // Left bottom corner. - embedPositionDetectionPattern(0, matrix.Width - pdpWidth, matrix); - - // Embed horizontal separation patterns around the squares. - const int hspWidth = 8; - // Left top corner. - embedHorizontalSeparationPattern(0, hspWidth - 1, matrix); - // Right top corner. - embedHorizontalSeparationPattern(matrix.Width - hspWidth, hspWidth - 1, matrix); - // Left bottom corner. - embedHorizontalSeparationPattern(0, matrix.Width - hspWidth, matrix); - - // Embed vertical separation patterns around the squares. - const int vspSize = 7; - // Left top corner. - embedVerticalSeparationPattern(vspSize, 0, matrix); - // Right top corner. - embedVerticalSeparationPattern(matrix.Height - vspSize - 1, 0, matrix); - // Left bottom corner. - embedVerticalSeparationPattern(vspSize, matrix.Height - vspSize, matrix); - } - - /// - /// Embed position adjustment patterns if need be. - /// - /// The version. - /// The matrix. - private static void maybeEmbedPositionAdjustmentPatterns(Version version, ByteMatrix matrix) - { - if (version.VersionNumber < 2) - { - // The patterns appear if version >= 2 - return; - } - int index = version.VersionNumber - 1; - int[] coordinates = POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[index]; - foreach (int y in coordinates) - { - if (y >= 0) - { - foreach (int x in coordinates) - { - if (x >= 0 && isEmpty(matrix[x, y])) - { - // If the cell is unset, we embed the position adjustment pattern here. - // -2 is necessary since the x/y coordinates point to the center of the pattern, not the - // left top corner. - embedPositionAdjustmentPattern(x - 2, y - 2, matrix); - } - } - } - } - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder/MatrixUtil.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/encoder/MatrixUtil.cs.meta deleted file mode 100644 index dcad600d2..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder/MatrixUtil.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7054b6ad7c9304daebf1290045499f29 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder/MinimalEncoder.cs b/Runtime/zxing.unity/Source/lib/qrcode/encoder/MinimalEncoder.cs deleted file mode 100644 index 60d2b0b0f..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder/MinimalEncoder.cs +++ /dev/null @@ -1,932 +0,0 @@ -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace ZXing.QrCode.Internal -{ - using System; - using System.Collections.Generic; - using System.Text; - - using ZXing.Common; - - /// - /// * Encoder that encodes minimally - /// * - /// * Algorithm: - /// * - /// * The eleventh commandment was "Thou Shalt Compute" or "Thou Shalt Not Compute" - I forget which(Alan Perilis). - /// * - /// * This implementation computes.As an alternative, the QR-Code specification suggests heuristics like this one: - /// * - /// * If initial input data is in the exclusive subset of the Alphanumeric character set AND if there are less than - /// * [6,7,8] characters followed by data from the remainder of the 8-bit byte character set, THEN select the 8- - /// * bit byte mode ELSE select Alphanumeric mode; - /// * - /// * This is probably right for 99.99% of cases but there is at least this one counter example: The string "AAAAAAa" - /// * encodes 2 bits smaller as ALPHANUMERIC(AAAAAA), BYTE(a) than by encoding it as BYTE(AAAAAAa). - /// * Perhaps that is the only counter example but without having proof, it remains unclear. - /// * - /// * ECI switching: - /// * - /// * In multi language content the algorithm selects the most compact representation using ECI modes. - /// * For example the most compact representation of the string "\u0150\u015C" (O-double-acute, S-circumflex) is - /// * ECI(UTF-8), BYTE(\u0150\u015C) while prepending one or more times the same leading character as in - /// * "\u0150\u0150\u015C", the most compact representation uses two ECIs so that the string is encoded as - /// * ECI(ISO-8859-2), BYTE(\u0150\u0150), ECI(ISO-8859-3), BYTE(\u015C). - /// * - /// * @author Alex Geller - /// - internal class MinimalEncoder - { - internal enum VersionSize - { - SMALL, - MEDIUM, - LARGE - } - - // List of encoders that potentially encode characters not in ISO-8859-1 in one byte. - private static List ENCODERS = new List(); - static MinimalEncoder() - { - var names = new[] - { - "ISO-8859-2", - "ISO-8859-3", - "ISO-8859-4", - "ISO-8859-5", - "ISO-8859-6", - "ISO-8859-7", - "ISO-8859-8", - "ISO-8859-9", - "ISO-8859-10", - "ISO-8859-11", - "ISO-8859-13", - "ISO-8859-14", - "ISO-8859-15", - "ISO-8859-16", - "windows-1250", - "windows-1251", - "windows-1252", - "windows-1253", - "windows-1254", - "windows-1255", - "windows-1256", - "windows-1257", - "windows-1258", - "Shift_JIS" - }; - foreach (String name in names) - { - if (CharacterSetECI.getCharacterSetECIByName(name) != null) - { - try - { - ENCODERS.Add(Clone(Encoding.GetEncoding(name))); - } - catch (Exception) - { - // continue - } - } - } - } - - private String stringToEncode; - private bool isGS1; - private Encoding[] encoders; - private int priorityEncoderIndex; - private ErrorCorrectionLevel ecLevel; - -#if NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_3 || WINDOWS_UWP || PORTABLE || WINDOWS_PHONE || NETFX_CORE || WindowsCE || SILVERLIGHT - private static bool canEncode(Encoding encoding, char c) - { - // very limited support on old platforms; not sure, if it would work; and not sure, if somebody need the old platform support - try - { - var result = encoding.GetByteCount(new char[] { c }); - return result > 0; - } - catch - { - return false; - } - } -#else - private static bool canEncode(Encoding encoding, char c) - { - try - { - var prevFallback = encoding.EncoderFallback; - try - { - encoding.EncoderFallback = EncoderFallback.ExceptionFallback; - var result = encoding.GetByteCount(new char[] { c }); - return result > 0; - } - catch - { - return false; - } - finally - { - encoding.EncoderFallback = prevFallback; - } - } - catch - { - return false; - } - } -#endif - - private static Encoding Clone(Encoding encoding) - { - // encodings have to be cloned to change the EncoderFallback property later - -#if !NETSTANDARD1_0 && !NETSTANDARD1_1 && !PORTABLE && !WINDOWS_PHONE && !NETFX_CORE - // Clone isn't supported by .net standard 1.0, 1.1 and portable - return (Encoding)encoding.Clone(); -#else - return encoding; -#endif - } - - /// - /// Creates a MinimalEncoder - /// - /// The string to encode - /// The preferred . When the value of the argument is null, the algorithm - /// * chooses charsets that leads to a minimal representation.Otherwise the algorithm will use the priority - /// * charset to encode any character in the input that can be encoded by it if the charset is among the - /// * supported charsets. - /// {@code true} if a FNC1 is to be prepended; {@code false} otherwise - /// The error correction level. - public MinimalEncoder(String stringToEncode, Encoding priorityCharset, bool isGS1, ErrorCorrectionLevel ecLevel) - { - this.stringToEncode = stringToEncode; - this.isGS1 = isGS1; - this.ecLevel = ecLevel; - - var neededEncoders = new List(); - neededEncoders.Add(Clone(StringUtils.ISO88591_ENCODING)); - var needUnicodeEncoder = priorityCharset != null && priorityCharset.WebName.StartsWith("UTF", StringComparison.OrdinalIgnoreCase); - - for (int i = 0; i < stringToEncode.Length; i++) - { - bool canEnc = false; - foreach (var encoder in neededEncoders) - { - if (canEncode(encoder, stringToEncode[i])) - { - canEnc = true; - break; - } - } - - if (!canEnc) - { - foreach (var encoder in ENCODERS) - { - if (canEncode(encoder, stringToEncode[i])) - { - neededEncoders.Add(encoder); - canEnc = true; - break; - } - } - } - - if (!canEnc) - { - needUnicodeEncoder = true; - } - } - - if (neededEncoders.Count == 1 && !needUnicodeEncoder) - { - encoders = new Encoding[] { neededEncoders[0] }; - } - else - { - encoders = new Encoding[neededEncoders.Count + 2]; - int index = 0; - foreach (var encoder in neededEncoders) - { - encoders[index++] = encoder; - } - - encoders[index] = Clone(Encoding.UTF8); - encoders[index + 1] = Clone(Encoding.BigEndianUnicode); - } - - int priorityEncoderIndexValue = -1; - if (priorityCharset != null) - { - for (int i = 0; i < encoders.Length; i++) - { - if (encoders[i] != null && priorityCharset.WebName.Equals(encoders[i].WebName)) - { - priorityEncoderIndexValue = i; - break; - } - } - } - priorityEncoderIndex = priorityEncoderIndexValue; - } - - /// - /// Encodes the string minimally - /// - /// The string to encode - /// The preferred . A minimal version is computed(see - /// {@link ResultList#getVersion method} when the value of the argument is null - /// The preferred { @link Charset}. When the value of the argument is null, the algorithm - /// chooses charsets that leads to a minimal representation.Otherwise the algorithm will use the priority - /// charset to encode any character in the input that can be encoded by it if the charset is among the - /// supported charsets. - /// { @code true} if a FNC1 is to be prepended;{ @code false}otherwise - /// The error correction level. - /// An instance of { @code ResultList} - /// representing the minimal solution. - /// @see ResultList#getBits - /// @see ResultList#getVersion - /// @see ResultList#getSize - public static ResultList encode(String stringToEncode, Version version, Encoding priorityCharset, bool isGS1, ErrorCorrectionLevel ecLevel) - { - return new MinimalEncoder(stringToEncode, priorityCharset, isGS1, ecLevel).encode(version); - } - public ResultList encode(Version version) - { - if (version == null) - { - // compute minimal encoding trying the three version sizes. - Version[] versions = - { - getVersion(VersionSize.SMALL), - getVersion(VersionSize.MEDIUM), - getVersion(VersionSize.LARGE) - }; - ResultList[] results = - { - encodeSpecificVersion(versions[0]), - encodeSpecificVersion(versions[1]), - encodeSpecificVersion(versions[2]) - }; - int smallestSize = Int32.MaxValue; - int smallestResult = -1; - for (int i = 0; i < 3; i++) - { - int size = results[i].Size; - if (Encoder.willFit(size, versions[i], ecLevel) && size < smallestSize) - { - smallestSize = size; - smallestResult = i; - } - } - if (smallestResult < 0) - { - throw new WriterException("Data too big for any version"); - } - return results[smallestResult]; - } - else - { - // compute minimal encoding for a given version - ResultList result = encodeSpecificVersion(version); - if (!Encoder.willFit(result.Size, getVersion(getVersionSize(result.getVersion())), ecLevel)) - { - throw new WriterException("Data too big for version" + version); - } - return result; - } - } - - public static VersionSize getVersionSize(Version version) - { - return version.VersionNumber <= 9 ? VersionSize.SMALL : version.VersionNumber <= 26 ? - VersionSize.MEDIUM : VersionSize.LARGE; - } - - public static Version getVersion(VersionSize versionSize) - { - switch (versionSize) - { - case VersionSize.SMALL: - return Version.getVersionForNumber(9); - case VersionSize.MEDIUM: - return Version.getVersionForNumber(26); - case VersionSize.LARGE: - default: - return Version.getVersionForNumber(40); - } - } - - private static bool isNumeric(char c) - { - return c >= '0' && c <= '9'; - } - - private static bool isDoubleByteKanji(char c) - { - return Encoder.isOnlyDoubleByteKanji(new String(new[] { c })); - } - - private static bool isAlphanumeric(char c) - { - return Encoder.getAlphanumericCode(c) != -1; - } - - public bool canEncode(Mode mode, char c) - { - switch (mode.Name) - { - case Mode.Names.KANJI: - return isDoubleByteKanji(c); - case Mode.Names.ALPHANUMERIC: - return isAlphanumeric(c); - case Mode.Names.NUMERIC: - return isNumeric(c); - case Mode.Names.BYTE: - return true; // any character can be encoded as byte(s). Up to the caller to manage splitting into - // multiple bytes when String.getBytes(Charset) return more than one byte. - default: - return false; - } - } - - private static int getCompactedOrdinal(Mode mode) - { - if (mode == null) - { - return 0; - } - switch (mode.Name) - { - case Mode.Names.KANJI: - return 0; - case Mode.Names.ALPHANUMERIC: - return 1; - case Mode.Names.NUMERIC: - return 2; - case Mode.Names.BYTE: - return 3; - default: - throw new InvalidOperationException("Illegal mode " + mode); - } - } - - private void addEdge(Edge[][][] edges, int position, Edge edge) - { - int vertexIndex = position + edge.characterLength; - Edge[] modeEdges = edges[vertexIndex][edge.charsetEncoderIndex]; - int modeOrdinal = getCompactedOrdinal(edge.mode); - if (modeEdges[modeOrdinal] == null || modeEdges[modeOrdinal].cachedTotalSize > edge.cachedTotalSize) - { - modeEdges[modeOrdinal] = edge; - } - } - - private void addEdges(Version version, Edge[][][] edges, int from, Edge previous) - { - int start = 0; - int end = encoders.Length; - if (priorityEncoderIndex >= 0 && canEncode(encoders[priorityEncoderIndex], stringToEncode[from])) - { - start = priorityEncoderIndex; - end = priorityEncoderIndex + 1; - } - - for (int i = start; i < end; i++) - { - if (canEncode(encoders[i], stringToEncode[from])) - { - addEdge(edges, from, new Edge(Mode.BYTE, from, i, 1, previous, version, this)); - } - } - - if (canEncode(Mode.KANJI, stringToEncode[from])) - { - addEdge(edges, from, new Edge(Mode.KANJI, from, 0, 1, previous, version, this)); - } - - int inputLength = stringToEncode.Length; - if (canEncode(Mode.ALPHANUMERIC, stringToEncode[from])) - { - addEdge(edges, from, new Edge(Mode.ALPHANUMERIC, from, 0, from + 1 >= inputLength || - !canEncode(Mode.ALPHANUMERIC, stringToEncode[from + 1]) ? 1 : 2, previous, version, this)); - } - - if (canEncode(Mode.NUMERIC, stringToEncode[from])) - { - addEdge(edges, from, new Edge(Mode.NUMERIC, from, 0, from + 1 >= inputLength || - !canEncode(Mode.NUMERIC, stringToEncode[from + 1]) ? 1 : from + 2 >= inputLength || - !canEncode(Mode.NUMERIC, stringToEncode[from + 2]) ? 2 : 3, previous, version, this)); - } - } - - public ResultList encodeSpecificVersion(Version version) - { - /* A vertex represents a tuple of a position in the input, a mode and a character encoding where position 0 - * denotes the position left of the first character, 1 the position left of the second character and so on. - * Likewise the end vertices are located after the last character at position stringToEncode.length(). - * - * An edge leading to such a vertex encodes one or more of the characters left of the position that the vertex - * represents and encodes it in the same encoding and mode as the vertex on which the edge ends. In other words, - * all edges leading to a particular vertex encode the same characters in the same mode with the same character - * encoding. They differ only by their source vertices who are all located at i+1 minus the number of encoded - * characters. - * - * The edges leading to a vertex are stored in such a way that there is a fast way to enumerate the edges ending - * on a particular vertex. - * - * The algorithm processes the vertices in order of their position thereby performing the following: - * - * For every vertex at position i the algorithm enumerates the edges ending on the vertex and removes all but the - * shortest from that list. - * Then it processes the vertices for the position i+1. If i+1 == stringToEncode.length() then the algorithm ends - * and chooses the the edge with the smallest size from any of the edges leading to vertices at this position. - * Otherwise the algorithm computes all possible outgoing edges for the vertices at the position i+1 - * - * Examples: - * The process is illustrated by showing the graph (edges) after each iteration from left to right over the input: - * An edge is drawn as follows "(" + fromVertex + ") -- " + encodingMode + "(" + encodedInput + ") (" + - * accumulatedSize + ") --> (" + toVertex + ")" - * - * Example 1 encoding the string "ABCDE": - * Note: This example assumes that alphanumeric encoding is only possible in multiples of two characters so that - * the example is both short and showing the principle. In reality this restriction does not exist. - * - * Initial situation - * (initial) -- BYTE(A) (20) --> (1_BYTE) - * (initial) -- ALPHANUMERIC(AB) (24) --> (2_ALPHANUMERIC) - * - * Situation after adding edges to vertices at position 1 - * (initial) -- BYTE(A) (20) --> (1_BYTE) -- BYTE(B) (28) --> (2_BYTE) - * (1_BYTE) -- ALPHANUMERIC(BC) (44) --> (3_ALPHANUMERIC) - * (initial) -- ALPHANUMERIC(AB) (24) --> (2_ALPHANUMERIC) - * - * Situation after adding edges to vertices at position 2 - * (initial) -- BYTE(A) (20) --> (1_BYTE) - * (initial) -- ALPHANUMERIC(AB) (24) --> (2_ALPHANUMERIC) - * (initial) -- BYTE(A) (20) --> (1_BYTE) -- BYTE(B) (28) --> (2_BYTE) - * (1_BYTE) -- ALPHANUMERIC(BC) (44) --> (3_ALPHANUMERIC) - * (initial) -- ALPHANUMERIC(AB) (24) --> (2_ALPHANUMERIC) -- BYTE(C) (44) --> (3_BYTE) - * (2_ALPHANUMERIC) -- ALPHANUMERIC(CD) (35) --> (4_ALPHANUMERIC) - * - * Situation after adding edges to vertices at position 3 - * (initial) -- BYTE(A) (20) --> (1_BYTE) -- BYTE(B) (28) --> (2_BYTE) -- BYTE(C) (36) --> (3_BYTE) - * (1_BYTE) -- ALPHANUMERIC(BC) (44) --> (3_ALPHANUMERIC) -- BYTE(D) (64) --> (4_BYTE) - * (3_ALPHANUMERIC) -- ALPHANUMERIC(DE) (55) --> (5_ALPHANUMERIC) - * (initial) -- ALPHANUMERIC(AB) (24) --> (2_ALPHANUMERIC) -- ALPHANUMERIC(CD) (35) --> (4_ALPHANUMERIC) - * (2_ALPHANUMERIC) -- ALPHANUMERIC(CD) (35) --> (4_ALPHANUMERIC) - * - * Situation after adding edges to vertices at position 4 - * (initial) -- BYTE(A) (20) --> (1_BYTE) -- BYTE(B) (28) --> (2_BYTE) -- BYTE(C) (36) --> (3_BYTE) -- BYTE(D) (44) --> (4_BYTE) - * (1_BYTE) -- ALPHANUMERIC(BC) (44) --> (3_ALPHANUMERIC) -- ALPHANUMERIC(DE) (55) --> (5_ALPHANUMERIC) - * (initial) -- ALPHANUMERIC(AB) (24) --> (2_ALPHANUMERIC) -- ALPHANUMERIC(CD) (35) --> (4_ALPHANUMERIC) -- BYTE(E) (55) --> (5_BYTE) - * - * Situation after adding edges to vertices at position 5 - * (initial) -- BYTE(A) (20) --> (1_BYTE) -- BYTE(B) (28) --> (2_BYTE) -- BYTE(C) (36) --> (3_BYTE) -- BYTE(D) (44) --> (4_BYTE) -- BYTE(E) (52) --> (5_BYTE) - * (1_BYTE) -- ALPHANUMERIC(BC) (44) --> (3_ALPHANUMERIC) -- ALPHANUMERIC(DE) (55) --> (5_ALPHANUMERIC) - * (initial) -- ALPHANUMERIC(AB) (24) --> (2_ALPHANUMERIC) -- ALPHANUMERIC(CD) (35) --> (4_ALPHANUMERIC) - * - * Encoding as BYTE(ABCDE) has the smallest size of 52 and is hence chosen. The encodation ALPHANUMERIC(ABCD), - * BYTE(E) is longer with a size of 55. - * - * Example 2 encoding the string "XXYY" where X denotes a character unique to character set ISO-8859-2 and Y a - * character unique to ISO-8859-3. Both characters encode as double byte in UTF-8: - * - * Initial situation - * (initial) -- BYTE(X) (32) --> (1_BYTE_ISO-8859-2) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-8) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-16BE) - * - * Situation after adding edges to vertices at position 1 - * (initial) -- BYTE(X) (32) --> (1_BYTE_ISO-8859-2) -- BYTE(X) (40) --> (2_BYTE_ISO-8859-2) - * (1_BYTE_ISO-8859-2) -- BYTE(X) (72) --> (2_BYTE_UTF-8) - * (1_BYTE_ISO-8859-2) -- BYTE(X) (72) --> (2_BYTE_UTF-16BE) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-8) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-16BE) - * - * Situation after adding edges to vertices at position 2 - * (initial) -- BYTE(X) (32) --> (1_BYTE_ISO-8859-2) -- BYTE(X) (40) --> (2_BYTE_ISO-8859-2) - * (2_BYTE_ISO-8859-2) -- BYTE(Y) (72) --> (3_BYTE_ISO-8859-3) - * (2_BYTE_ISO-8859-2) -- BYTE(Y) (80) --> (3_BYTE_UTF-8) - * (2_BYTE_ISO-8859-2) -- BYTE(Y) (80) --> (3_BYTE_UTF-16BE) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-8) -- BYTE(X) (56) --> (2_BYTE_UTF-8) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-16BE) -- BYTE(X) (56) --> (2_BYTE_UTF-16BE) - * - * Situation after adding edges to vertices at position 3 - * (initial) -- BYTE(X) (32) --> (1_BYTE_ISO-8859-2) -- BYTE(X) (40) --> (2_BYTE_ISO-8859-2) -- BYTE(Y) (72) --> (3_BYTE_ISO-8859-3) - * (3_BYTE_ISO-8859-3) -- BYTE(Y) (80) --> (4_BYTE_ISO-8859-3) - * (3_BYTE_ISO-8859-3) -- BYTE(Y) (112) --> (4_BYTE_UTF-8) - * (3_BYTE_ISO-8859-3) -- BYTE(Y) (112) --> (4_BYTE_UTF-16BE) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-8) -- BYTE(X) (56) --> (2_BYTE_UTF-8) -- BYTE(Y) (72) --> (3_BYTE_UTF-8) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-16BE) -- BYTE(X) (56) --> (2_BYTE_UTF-16BE) -- BYTE(Y) (72) --> (3_BYTE_UTF-16BE) - * - * Situation after adding edges to vertices at position 4 - * (initial) -- BYTE(X) (32) --> (1_BYTE_ISO-8859-2) -- BYTE(X) (40) --> (2_BYTE_ISO-8859-2) -- BYTE(Y) (72) --> (3_BYTE_ISO-8859-3) -- BYTE(Y) (80) --> (4_BYTE_ISO-8859-3) - * (3_BYTE_UTF-8) -- BYTE(Y) (88) --> (4_BYTE_UTF-8) - * (3_BYTE_UTF-16BE) -- BYTE(Y) (88) --> (4_BYTE_UTF-16BE) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-8) -- BYTE(X) (56) --> (2_BYTE_UTF-8) -- BYTE(Y) (72) --> (3_BYTE_UTF-8) - * (initial) -- BYTE(X) (40) --> (1_BYTE_UTF-16BE) -- BYTE(X) (56) --> (2_BYTE_UTF-16BE) -- BYTE(Y) (72) --> (3_BYTE_UTF-16BE) - * - * Encoding as ECI(ISO-8859-2),BYTE(XX),ECI(ISO-8859-3),BYTE(YY) has the smallest size of 80 and is hence chosen. - * The encodation ECI(UTF-8),BYTE(XXYY) is longer with a size of 88. - */ - int inputLength = stringToEncode.Length; - - //Array that represents vertices. There is a vertex for every character, encoding and mode. The vertex contains a list - //of all edges that lead to it that have the same encoding and mode. - //The lists are created lazily - - //The last dimension in the array below encodes the 4 modes KANJI, ALPHANUMERIC, NUMERIC and BYTE via the - //function getCompactedOrdinal(Mode) - var edges = new Edge[inputLength + 1][][]; - for (var indexDim1 = 0; indexDim1 < inputLength + 1; indexDim1++) - { - edges[indexDim1] = new Edge[encoders.Length][]; - for (var indexDim2 = 0; indexDim2 < encoders.Length; indexDim2++) - { - edges[indexDim1][indexDim2] = new Edge[4]; - } - } - addEdges(version, edges, 0, null); - - for (int i = 1; i <= inputLength; i++) - { - for (int j = 0; j < encoders.Length; j++) - { - for (int k = 0; k < 4; k++) - { - if (edges[i][j][k] != null && i < inputLength) - { - addEdges(version, edges, i, edges[i][j][k]); - } - } - } - } - { - var minimalJ = -1; - var minimalK = -1; - var minimalSize = Int32.MaxValue; - for (int j = 0; j < encoders.Length; j++) - { - for (int k = 0; k < 4; k++) - { - if (edges[inputLength][j][k] != null) - { - var edge = edges[inputLength][j][k]; - if (edge.cachedTotalSize < minimalSize) - { - minimalSize = edge.cachedTotalSize; - minimalJ = j; - minimalK = k; - } - } - } - } - - if (minimalJ < 0) - { - throw new WriterException("Internal error: failed to encode \"" + stringToEncode + "\""); - } - return new ResultList(version, edges[inputLength][minimalJ][minimalK], this); - } - } - - internal sealed class Edge - { - public Mode mode; - public int fromPosition; - public int charsetEncoderIndex; - public int characterLength; - public Edge previous; - public int cachedTotalSize; - - public Edge(Mode mode, int fromPosition, int charsetEncoderIndex, int characterLength, Edge previous, Version version, MinimalEncoder encoder) - { - this.mode = mode; - this.fromPosition = fromPosition; - this.charsetEncoderIndex = mode == Mode.BYTE || previous == null ? charsetEncoderIndex : - previous.charsetEncoderIndex; // inherit the encoding if not of type BYTE - this.characterLength = characterLength; - this.previous = previous; - - int size = previous != null ? previous.cachedTotalSize : 0; - - bool needECI = mode == Mode.BYTE && - (previous == null && this.charsetEncoderIndex != 0) || // at the beginning and charset is not ISO-8859-1 - (previous != null && this.charsetEncoderIndex != previous.charsetEncoderIndex); - - if (previous == null || mode != previous.mode || needECI) - { - size += 4 + mode.getCharacterCountBits(version); - } - switch (mode.Name) - { - case Mode.Names.KANJI: - size += 13; - break; - case Mode.Names.ALPHANUMERIC: - size += characterLength == 1 ? 6 : 11; - break; - case Mode.Names.NUMERIC: - size += characterLength == 1 ? 4 : characterLength == 2 ? 7 : 10; - break; - case Mode.Names.BYTE: - size += 8 * encoder.encoders[charsetEncoderIndex].GetBytes(encoder.stringToEncode.Substring(fromPosition, characterLength)).Length; - if (needECI) - { - size += 4 + 8; // the ECI assignment numbers for ISO-8859-x, UTF-8 and UTF-16 are all 8 bit long - } - break; - } - cachedTotalSize = size; - } - } - - internal class ResultList - { - private List list = new List(); - private Version version; - private MinimalEncoder encoder; - - public ResultList(Version version, Edge solution, MinimalEncoder encoder) - { - this.encoder = encoder; - this.version = version; - var length = 0; - var current = solution; - var containsECI = false; - while (current != null) - { - length += current.characterLength; - Edge previous = current.previous; - - bool needECI = current.mode == Mode.BYTE && - (previous == null && current.charsetEncoderIndex != 0) || // at the beginning and charset is not ISO-8859-1 - (previous != null && current.charsetEncoderIndex != previous.charsetEncoderIndex); - - if (needECI) - { - containsECI = true; - } - - if (previous == null || previous.mode != current.mode || needECI) - { - list.Insert(0, new ResultNode(current.mode, current.fromPosition, current.charsetEncoderIndex, length, encoder, this)); - length = 0; - } - - if (needECI) - { - list.Insert(0, new ResultNode(Mode.ECI, current.fromPosition, current.charsetEncoderIndex, 0, encoder, this)); - } - current = previous; - } - - // prepend FNC1 if needed. If the bits contain an ECI then the FNC1 must be preceeded by an ECI. - // If there is no ECI at the beginning then we put an ECI to the default charset (ISO-8859-1) - if (encoder.isGS1) - { - var first = list[0]; - if (first != null && first.mode != Mode.ECI && containsECI) - { - // prepend a default character set ECI - list.Insert(0, new ResultNode(Mode.ECI, 0, 0, 0, encoder, this)); - } - first = list[0]; - // prepend or insert a FNC1_FIRST_POSITION after the ECI (if any) - var node = new ResultNode(Mode.FNC1_FIRST_POSITION, 0, 0, 0, encoder, this); - if (first == null || first.mode != Mode.ECI) - list.Insert(0, node); - else - list.Insert(1, node); - } - - // set version to smallest version into which the bits fit. - int versionNumber = version.VersionNumber; - int lowerLimit; - int upperLimit; - switch (getVersionSize(version)) - { - case VersionSize.SMALL: - lowerLimit = 1; - upperLimit = 9; - break; - case VersionSize.MEDIUM: - lowerLimit = 10; - upperLimit = 26; - break; - case VersionSize.LARGE: - default: - lowerLimit = 27; - upperLimit = 40; - break; - } - int size = getSize(version); - // increase version if needed - while (versionNumber < upperLimit && !Encoder.willFit(size, Version.getVersionForNumber(versionNumber), encoder.ecLevel)) - { - versionNumber++; - } - // shrink version if possible - while (versionNumber > lowerLimit && Encoder.willFit(size, Version.getVersionForNumber(versionNumber - 1), encoder.ecLevel)) - { - versionNumber--; - } - this.version = Version.getVersionForNumber(versionNumber); - } - - /// - /// returns the size in bits - /// - public int Size - { - get - { - return getSize(version); - } - } - - private int getSize(Version version) - { - int result = 0; - foreach (var resultNode in list) - { - result += resultNode.getSize(version); - } - return result; - } - - /// - /// appends the bits - /// - /// - public void getBits(BitArray bits) - { - foreach (ResultNode resultNode in list) - { - resultNode.getBits(bits); - } - } - - public Version getVersion() - { - return version; - } - - public override String ToString() - { - var result = new StringBuilder(); - ResultNode previous = null; - foreach (var current in list) - { - if (previous != null) - { - result.Append(","); - } - result.Append(current.ToString()); - previous = current; - } - return result.ToString(); - } - - internal class ResultNode - { - public Mode mode; - public int fromPosition; - public int charsetEncoderIndex; - public int characterLength; - public ResultList resultList; - public MinimalEncoder encoder; - - public ResultNode(Mode mode, int fromPosition, int charsetEncoderIndex, int characterLength, MinimalEncoder encoder, ResultList resultList) - { - this.mode = mode; - this.fromPosition = fromPosition; - this.charsetEncoderIndex = charsetEncoderIndex; - this.characterLength = characterLength; - this.encoder = encoder; - this.resultList = resultList; - } - - /// - /// returns the size in bits - /// - /// - public int getSize(Version version) - { - int size = 4 + mode.getCharacterCountBits(resultList.version); - switch (mode.Name) - { - case Mode.Names.KANJI: - size += 13 * characterLength; - break; - case Mode.Names.ALPHANUMERIC: - size += (characterLength / 2) * 11; - size += (characterLength % 2) == 1 ? 6 : 0; - break; - case Mode.Names.NUMERIC: - size += (characterLength / 3) * 10; - int rest = characterLength % 3; - size += rest == 1 ? 4 : rest == 2 ? 7 : 0; - break; - case Mode.Names.BYTE: - size += 8 * CharacterCountIndicator; - break; - case Mode.Names.ECI: - size += 8; // the ECI assignment numbers for ISO-8859-x, UTF-8 and UTF-16 are all 8 bit long - break; - } - return size; - } - - /// - /// returns the length in characters according to the specification (differs from getCharacterLength() in BYTE mode - /// for multi byte encoded characters) - /// - /// - public int CharacterCountIndicator - { - get - { - return mode == Mode.BYTE ? encoder.encoders[charsetEncoderIndex].GetBytes(encoder.stringToEncode.Substring(fromPosition, characterLength)).Length : characterLength; - } - } - - /// - /// appends the bits - /// - /// - public void getBits(BitArray bits) - { - bits.appendBits(mode.Bits, 4); - if (characterLength > 0) - { - int length = CharacterCountIndicator; - bits.appendBits(length, mode.getCharacterCountBits(resultList.version)); - } - if (mode == Mode.ECI) - { - bits.appendBits(CharacterSetECI.getCharacterSetECI(encoder.encoders[charsetEncoderIndex]).Value, 8); - } - else if (characterLength > 0) - { - // append data - Encoder.appendBytes(encoder.stringToEncode.Substring(fromPosition, characterLength), mode, bits, - encoder.encoders[charsetEncoderIndex]); - } - } - - public override String ToString() - { - var result = new StringBuilder(); - result.Append(mode).Append('('); - if (mode == Mode.ECI) - { - result.Append(encoder.encoders[charsetEncoderIndex].WebName.ToUpper()); - } - else - { - result.Append(makePrintable(encoder.stringToEncode.Substring(fromPosition, characterLength))); - } - result.Append(')'); - return result.ToString(); - } - - private String makePrintable(String s) - { - var result = new StringBuilder(); - for (int i = 0; i < s.Length; i++) - { - if (s[i] < 32 || s[i] > 126) - { - result.Append('.'); - } - else - { - result.Append(s[i]); - } - } - return result.ToString(); - } - } - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder/MinimalEncoder.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/encoder/MinimalEncoder.cs.meta deleted file mode 100644 index 4cbd47fb8..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder/MinimalEncoder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 14cd94d311ba34485bfac1a77810e75c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder/QRCode.cs b/Runtime/zxing.unity/Source/lib/qrcode/encoder/QRCode.cs deleted file mode 100644 index 3fb4db2c8..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder/QRCode.cs +++ /dev/null @@ -1,125 +0,0 @@ -/* -* Copyright 2008 ZXing authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using System; -using System.Text; - -namespace ZXing.QrCode.Internal -{ - /// satorux@google.com (Satoru Takabayashi) - creator - /// dswitkin@google.com (Daniel Switkin) - ported from C++ - public sealed class QRCode - { - /// - /// - /// - public static int NUM_MASK_PATTERNS = 8; - - /// - /// Initializes a new instance of the class. - /// - public QRCode() - { - MaskPattern = -1; - } - - /// - /// Gets or sets the mode, not relevant if is selected. - /// - /// - /// The mode. - /// - public Mode Mode { get; set; } - - /// - /// Gets or sets the EC level. - /// - /// - /// The EC level. - /// - public ErrorCorrectionLevel ECLevel { get; set; } - - /// - /// Gets or sets the version. - /// - /// - /// The version. - /// - public Version Version { get; set; } - - /// - /// Gets or sets the mask pattern. - /// - /// - /// The mask pattern. - /// - public int MaskPattern { get; set; } - - /// - /// Gets or sets the matrix. - /// - /// - /// The matrix. - /// - public ByteMatrix Matrix { get; set; } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override String ToString() - { - var result = new StringBuilder(200); - result.Append("<<\n"); - result.Append(" mode: "); - result.Append(Mode); - result.Append("\n ecLevel: "); - result.Append(ECLevel); - result.Append("\n version: "); - if (Version == null) - result.Append("null"); - else - result.Append(Version); - result.Append("\n maskPattern: "); - result.Append(MaskPattern); - if (Matrix == null) - { - result.Append("\n matrix: null\n"); - } - else - { - result.Append("\n matrix:\n"); - result.Append(Matrix.ToString()); - } - result.Append(">>\n"); - return result.ToString(); - } - - /// - /// Check if "mask_pattern" is valid. - /// - /// The mask pattern. - /// - /// true if [is valid mask pattern] [the specified mask pattern]; otherwise, false. - /// - public static bool isValidMaskPattern(int maskPattern) - { - return maskPattern >= 0 && maskPattern < NUM_MASK_PATTERNS; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder/QRCode.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/encoder/QRCode.cs.meta deleted file mode 100644 index d7db0779f..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder/QRCode.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 921dbf46d12f94a6a85672864e13e538 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder/QrCodeEncodingOptions.cs b/Runtime/zxing.unity/Source/lib/qrcode/encoder/QrCodeEncodingOptions.cs deleted file mode 100644 index 2feaa452c..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder/QrCodeEncodingOptions.cs +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.ComponentModel; -using System.Globalization; -using ZXing.Common; -using ZXing.QrCode.Internal; - -namespace ZXing.QrCode -{ - /// - /// The class holds the available options for the QrCodeWriter - /// - [Serializable] - public class QrCodeEncodingOptions : EncodingOptions - { - /// - /// Specifies what degree of error correction to use, for example in QR Codes. - /// Type depends on the encoder. For example for QR codes it's type - /// . - /// - public ErrorCorrectionLevel ErrorCorrection - { - get - { - if (Hints.ContainsKey(EncodeHintType.ERROR_CORRECTION)) - { - return (ErrorCorrectionLevel)Hints[EncodeHintType.ERROR_CORRECTION]; - } - return null; - } - set - { - if (value == null) - { - if (Hints.ContainsKey(EncodeHintType.ERROR_CORRECTION)) - Hints.Remove(EncodeHintType.ERROR_CORRECTION); - } - else - { - Hints[EncodeHintType.ERROR_CORRECTION] = value; - } - } - } - - /// - /// Specifies what character encoding to use where applicable (type ) - /// - public string CharacterSet - { - get - { - if (Hints.ContainsKey(EncodeHintType.CHARACTER_SET)) - { - return (string)Hints[EncodeHintType.CHARACTER_SET]; - } - return null; - } - set - { - if (value == null) - { - if (Hints.ContainsKey(EncodeHintType.CHARACTER_SET)) - Hints.Remove(EncodeHintType.CHARACTER_SET); - } - else - { - Hints[EncodeHintType.CHARACTER_SET] = value; - } - } - } - - /// - /// Explicitly disables ECI segment when generating QR Code - /// That is against the specification of QR Code but some - /// readers have problems if the charset is switched from - /// ISO-8859-1 (default) to UTF-8 with the necessary ECI segment. - /// If you set the property to true you can use UTF-8 encoding - /// and the ECI segment is omitted. - /// - public bool DisableECI - { - get - { - if (Hints.ContainsKey(EncodeHintType.DISABLE_ECI)) - { - return (bool)Hints[EncodeHintType.DISABLE_ECI]; - } - return false; - } - set - { - Hints[EncodeHintType.DISABLE_ECI] = value; - } - } - - /// - /// Specifies the exact version of QR code to be encoded. An integer, range 1 to 40. If the data specified - /// cannot fit within the required version, a WriterException will be thrown. - /// - public int? QrVersion - { - get - { - if (Hints.ContainsKey(EncodeHintType.QR_VERSION)) - { - return (int)Hints[EncodeHintType.QR_VERSION]; - } - return null; - } - set - { - if (value == null) - { - if (Hints.ContainsKey(EncodeHintType.QR_VERSION)) - Hints.Remove(EncodeHintType.QR_VERSION); - } - else - { - Hints[EncodeHintType.QR_VERSION] = value.Value; - } - } - } - - - /// - /// Specifies whether to use compact mode for QR code (type , or "true" or "false" - /// Please note that when compaction is performed, the most compact character encoding is chosen - /// for characters in the input that are not in the ISO-8859-1 character set. Based on experience, - /// some scanners do not support encodings like cp-1256 (Arabic). In such cases the encoding can - /// be forced to UTF-8 by means of the encoding hint. - /// - public bool QrCompact - { - get - { - if (Hints.ContainsKey(EncodeHintType.QR_COMPACT)) - { - return (bool)Hints[EncodeHintType.QR_COMPACT]; - } - return false; - } - set - { - Hints[EncodeHintType.QR_COMPACT] = value; - } - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/qrcode/encoder/QrCodeEncodingOptions.cs.meta b/Runtime/zxing.unity/Source/lib/qrcode/encoder/QrCodeEncodingOptions.cs.meta deleted file mode 100644 index da9e472f0..000000000 --- a/Runtime/zxing.unity/Source/lib/qrcode/encoder/QrCodeEncodingOptions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f4e49e0eff7b94c749d40541f9e299d5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/renderer.meta b/Runtime/zxing.unity/Source/lib/renderer.meta deleted file mode 100644 index 291e2c9d6..000000000 --- a/Runtime/zxing.unity/Source/lib/renderer.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 22ee4e4c962994042b1f81cbf1616dee -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/renderer/IBarcodeRenderer.cs b/Runtime/zxing.unity/Source/lib/renderer/IBarcodeRenderer.cs deleted file mode 100644 index 1b3c4904c..000000000 --- a/Runtime/zxing.unity/Source/lib/renderer/IBarcodeRenderer.cs +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using ZXing.Common; - -namespace ZXing.Rendering -{ -#if !(WINDOWS_PHONE || WindowsCE) - /// - /// Interface for a class to convert a BitMatrix to an output image format - /// - public interface IBarcodeRenderer -#else - /// - /// Interface for a class to convert a BitMatrix to an output image format - /// - public interface IBarcodeRenderer -#endif - { - /// - /// Renders the specified matrix to its graphically representation - /// - /// The matrix. - /// The format. - /// The encoded content of the barcode which should be included in the image. - /// That can be the numbers below a 1D barcode or something other. - /// - TOutput Render(BitMatrix matrix, BarcodeFormat format, string content); - - /// - /// Renders the specified matrix to its graphically representation - /// - /// The matrix. - /// The format. - /// The encoded content of the barcode which should be included in the image. - /// That can be the numbers below a 1D barcode or something other. - /// The options. - /// - TOutput Render(BitMatrix matrix, BarcodeFormat format, string content, EncodingOptions options); - } -} diff --git a/Runtime/zxing.unity/Source/lib/renderer/IBarcodeRenderer.cs.meta b/Runtime/zxing.unity/Source/lib/renderer/IBarcodeRenderer.cs.meta deleted file mode 100644 index de6143404..000000000 --- a/Runtime/zxing.unity/Source/lib/renderer/IBarcodeRenderer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2140474a926b044a1ad4439d210770ce -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/renderer/PixelData.Color32.cs b/Runtime/zxing.unity/Source/lib/renderer/PixelData.Color32.cs deleted file mode 100644 index 3eb899b53..000000000 --- a/Runtime/zxing.unity/Source/lib/renderer/PixelData.Color32.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using UnityEngine; - -namespace ZXing.Rendering -{ - /// - /// represents the generated code as a byte array with pixel data (4 byte per pixel, BGRA) - /// - public sealed partial class PixelData - { - /// - /// converts the pixel data to a bitmap object - /// - /// - public Color32[] ToColor32() - { - var result = new Color32[Width * Height]; - var resultIndex = 0; - - for (int y = Height - 1; y >= 0; y--) - { - var row = y * Width * 4; - for (int x = 0; x < Width; x++) - { - var pixelIndex = row + 4 * x; - result[resultIndex] = new Color32(Pixels[pixelIndex + 2], Pixels[pixelIndex + 1], Pixels[pixelIndex], Pixels[pixelIndex + 3]); - resultIndex++; - } - } - - return result; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/renderer/PixelData.Color32.cs.meta b/Runtime/zxing.unity/Source/lib/renderer/PixelData.Color32.cs.meta deleted file mode 100644 index a23cb6209..000000000 --- a/Runtime/zxing.unity/Source/lib/renderer/PixelData.Color32.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 13280c506da8646ab82f3b6fcbb7cf3e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/renderer/PixelData.cs b/Runtime/zxing.unity/Source/lib/renderer/PixelData.cs deleted file mode 100644 index edcd6a4c8..000000000 --- a/Runtime/zxing.unity/Source/lib/renderer/PixelData.cs +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -namespace ZXing.Rendering -{ - /// - /// represents the generated code as a byte array with pixel data (4 byte per pixel, BGRA) - /// - public sealed partial class PixelData - { - internal PixelData(int width, int height, byte[] pixels) - { - Height = height; - Width = width; - Pixels = pixels; - } - - /// - /// the generated code as byte array of BGRA pixels - /// - public byte[] Pixels { get; private set; } - /// - /// the width of the image - /// - public int Width { get; private set; } - /// - /// the height of the image - /// - public int Height { get; private set; } - } -} diff --git a/Runtime/zxing.unity/Source/lib/renderer/PixelData.cs.meta b/Runtime/zxing.unity/Source/lib/renderer/PixelData.cs.meta deleted file mode 100644 index 70388ac2c..000000000 --- a/Runtime/zxing.unity/Source/lib/renderer/PixelData.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4e9b63dd653654838977a0adbba5e0c5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/renderer/PixelDataRenderer.cs b/Runtime/zxing.unity/Source/lib/renderer/PixelDataRenderer.cs deleted file mode 100644 index 8808193d1..000000000 --- a/Runtime/zxing.unity/Source/lib/renderer/PixelDataRenderer.cs +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -using System; -using ZXing.Common; -using Color = UnityEngine.Color32; - -namespace ZXing.Rendering -{ - /// - /// Renders a to an byte array with pixel data (4 byte per pixel, BGRA) - /// - public sealed class PixelDataRenderer : IBarcodeRenderer - { - /// - /// Gets or sets the foreground color. - /// - /// - /// The foreground color. - /// - public Color Foreground { get; set; } - /// - /// Gets or sets the background color. - /// - /// - /// The background color. - /// - public Color Background { get; set; } - - /// - /// Initializes a new instance of the class. - /// - public PixelDataRenderer() - { - Foreground = UnityEngine.Color.black; - Background = UnityEngine.Color.white; - } - - /// - /// Renders the specified matrix. - /// - /// The matrix. - /// The format. - /// The content. - /// - public PixelData Render(BitMatrix matrix, BarcodeFormat format, string content) - { - return Render(matrix, format, content, null); - } - - /// - /// Renders the specified matrix. - /// - /// The matrix. - /// The format. - /// The content. - /// The options. - /// - public PixelData Render(BitMatrix matrix, BarcodeFormat format, string content, EncodingOptions options) - { - int width = matrix.Width; - int heigth = matrix.Height; - bool outputContent = (options == null || !options.PureBarcode) && - !String.IsNullOrEmpty(content) && (format == BarcodeFormat.CODE_39 || - format == BarcodeFormat.CODE_128 || - format == BarcodeFormat.EAN_13 || - format == BarcodeFormat.EAN_8 || - format == BarcodeFormat.CODABAR || - format == BarcodeFormat.ITF || - format == BarcodeFormat.UPC_A || - format == BarcodeFormat.MSI || - format == BarcodeFormat.PLESSEY); - int emptyArea = outputContent ? 16 : 0; - int pixelsize = 1; - - if (options != null) - { - if (options.Width > width) - { - width = options.Width; - } - if (options.Height > heigth) - { - heigth = options.Height; - } - // calculating the scaling factor - pixelsize = width / matrix.Width; - if (pixelsize > heigth / matrix.Height) - { - pixelsize = heigth / matrix.Height; - } - } - - if (emptyArea < heigth) - emptyArea = 0; - - var pixels = new byte[width * heigth * 4]; - var index = 0; - - for (int y = 0; y < matrix.Height - emptyArea; y++) - { - for (var pixelsizeHeight = 0; pixelsizeHeight < pixelsize; pixelsizeHeight++) - { - for (var x = 0; x < matrix.Width; x++) - { - var color = matrix[x, y] ? Foreground : Background; - for (var pixelsizeWidth = 0; pixelsizeWidth < pixelsize; pixelsizeWidth++) - { - pixels[index++] = color.b; - pixels[index++] = color.g; - pixels[index++] = color.r; - pixels[index++] = color.a; - } - } - for (var x = pixelsize * matrix.Width; x < width; x++) - { - pixels[index++] = Background.b; - pixels[index++] = Background.g; - pixels[index++] = Background.r; - pixels[index++] = Background.a; - } - } - } - for (int y = matrix.Height * pixelsize - emptyArea; y < heigth; y++) - { - for (var x = 0; x < width; x++) - { - pixels[index++] = Background.b; - pixels[index++] = Background.g; - pixels[index++] = Background.r; - pixels[index++] = Background.a; - } - } - - return new PixelData(width, heigth, pixels); - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/renderer/PixelDataRenderer.cs.meta b/Runtime/zxing.unity/Source/lib/renderer/PixelDataRenderer.cs.meta deleted file mode 100644 index 40a7f834e..000000000 --- a/Runtime/zxing.unity/Source/lib/renderer/PixelDataRenderer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 33f4720843bf64fa3b4ead4323eb60af -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/renderer/SVGRenderer.cs b/Runtime/zxing.unity/Source/lib/renderer/SVGRenderer.cs deleted file mode 100644 index 9afe72ebe..000000000 --- a/Runtime/zxing.unity/Source/lib/renderer/SVGRenderer.cs +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Copyright 2012 ZXing.Net authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System; -using System.Text; -using UnityEngine; -using ZXing.Common; - -namespace ZXing.Rendering -{ - /// - /// Renders a barcode into a Svg image - /// - public class SvgRenderer : IBarcodeRenderer - { - /// - /// the default font name if nothing else is set (Arial) - /// - public const string DefaultFontName = "Arial"; - /// - /// the default font size if nothing else is set (10) - /// - public const int DefaultFontSize = 10; - - /// - /// Gets or sets the foreground color. - /// - /// The foreground color. - public Color32 Foreground { get; set; } - - /// - /// Gets or sets the background color. - /// - /// The background color. - public Color32 Background { get; set; } - - /// - /// Gets or sets the font family name - /// - /// The font family name. - public string FontName { get; set; } - - /// - /// Gets or sets the font size in pixel - /// - /// The font size in pixel. - public int FontSize { get; set; } - - /// - /// Initializes a new instance of the class. - /// - public SvgRenderer() - { - Foreground = new Color32(0, 0, 0, 255); - Background = new Color32(255, 255, 255, 255); - } - - /// - /// Renders the specified matrix. - /// - /// The matrix. - /// The format. - /// The content. - /// - public SvgImage Render(BitMatrix matrix, BarcodeFormat format, string content) - { - return Render(matrix, format, content, null); - } - - /// - /// Renders the specified matrix. - /// - /// The matrix. - /// The format. - /// The content. - /// The options. - /// - public SvgImage Render(BitMatrix matrix, BarcodeFormat format, string content, EncodingOptions options) - { - var result = new SvgImage(matrix.Width, matrix.Height); - - Create(result, matrix, format, content, options); - - return result; - } - - private void Create(SvgImage image, BitMatrix matrix, BarcodeFormat format, string content, EncodingOptions options) - { - if (matrix == null) - return; - - const int spaceBetweenMatrixAndText = 3; - int width = matrix.Width; - int height = matrix.Height; - var outputContent = (options == null || !options.PureBarcode) && - !String.IsNullOrEmpty(content) && - (format == BarcodeFormat.CODE_39 || - format == BarcodeFormat.CODE_93 || - format == BarcodeFormat.CODE_128 || - format == BarcodeFormat.EAN_13 || - format == BarcodeFormat.EAN_8 || - format == BarcodeFormat.CODABAR || - format == BarcodeFormat.ITF || - format == BarcodeFormat.UPC_A || - format == BarcodeFormat.UPC_E || - format == BarcodeFormat.MSI || - format == BarcodeFormat.PLESSEY); - - if (outputContent) - { - var fontSize = FontSize < 1 ? DefaultFontSize : FontSize; - height += fontSize + spaceBetweenMatrixAndText; - } - - image.AddHeader(); - image.AddTag(0, 0, width, height, Background, Foreground); - AppendDarkCell(image, matrix, 0, 0); - - if (outputContent) - { - var fontName = String.IsNullOrEmpty(FontName) ? DefaultFontName : FontName; - var fontSize = FontSize < 1 ? DefaultFontSize : FontSize; - - image.AddText(content, fontName, fontSize); - } - - image.AddEnd(); - } - - private static void AppendDarkCell(SvgImage image, BitMatrix matrix, int offsetX, int offSetY) - { - if (matrix == null) - return; - - int width = matrix.Width; - int height = matrix.Height; - var processed = new BitMatrix(width, height); - bool currentIsBlack = false; - int startPosX = 0; - int startPosY = 0; - for (int x = 0; x < width; x++) - { - int endPosX; - for (int y = 0; y < height; y++) - { - if (processed[x, y]) - continue; - - processed[x, y] = true; - - if (matrix[x, y]) - { - if (!currentIsBlack) - { - startPosX = x; - startPosY = y; - currentIsBlack = true; - } - } - else - { - if (currentIsBlack) - { - FindMaximumRectangle(matrix, processed, startPosX, startPosY, y, out endPosX); - image.AddRec(startPosX + offsetX, startPosY + offSetY, endPosX - startPosX + 1, y - startPosY); - currentIsBlack = false; - } - } - } - if (currentIsBlack) - { - FindMaximumRectangle(matrix, processed, startPosX, startPosY, height, out endPosX); - image.AddRec(startPosX + offsetX, startPosY + offSetY, endPosX - startPosX + 1, height - startPosY); - currentIsBlack = false; - } - } - } - - private static void FindMaximumRectangle(BitMatrix matrix, BitMatrix processed, int startPosX, int startPosY, int endPosY, out int endPosX) - { - endPosX = startPosX; - - for (int x = startPosX + 1; x < matrix.Width; x++) - { - for (int y = startPosY; y < endPosY; y++) - { - if (!matrix[x, y]) - { - return; - } - } - endPosX = x; - for (int y = startPosY; y < endPosY; y++) - { - processed[x, y] = true; - } - } - } - - /// - /// Represents a barcode as a Svg image - /// - public class SvgImage - { - private readonly StringBuilder content; - - /// - /// Gets or sets the content. - /// - /// - /// The content. - /// - public String Content - { - get { return content.ToString(); } - set { content.Length = 0; if (value != null) content.Append(value); } - } - - /// - /// The original height of the bitmatrix for the barcode - /// - public int Height { get; set; } - - /// - /// The original width of the bitmatrix for the barcode - /// - public int Width { get; set; } - - /// - /// Initializes a new instance of the class. - /// - public SvgImage() - { - content = new StringBuilder(); - } - - /// - /// Initializes a new instance of the class. - /// - public SvgImage(int width, int height) - { - content = new StringBuilder(); - Width = width; - Height = height; - } - - /// - /// Initializes a new instance of the class. - /// - /// The content. - public SvgImage(string content) - { - this.content = new StringBuilder(content); - } - - /// - /// Gives the XML representation of the SVG image - /// - public override string ToString() - { - return content.ToString(); - } - - internal void AddHeader() - { - content.Append(""); - content.Append(@""); - content.Append(""); - } - - internal void AddEnd() - { - content.Append(""); - } - - internal void AddTag(int displaysizeX, int displaysizeY, int viewboxSizeX, int viewboxSizeY, Color background, Color fill) - { - - if (displaysizeX <= 0 || displaysizeY <= 0) - content.Append(string.Format("", - viewboxSizeX, - viewboxSizeY, - GetColorRgb(background), - ConvertAlpha(background), - GetColorRgb(fill), - ConvertAlpha(fill), - GetBackgroundStyle(background) - )); - else - content.Append(string.Format("", - viewboxSizeX, - viewboxSizeY, - GetColorRgb(background), - ConvertAlpha(background), - GetColorRgb(fill), - ConvertAlpha(fill), - GetBackgroundStyle(background), - displaysizeX, - displaysizeY)); - } - - internal void AddText(string text, string fontName, int fontSize) - { - content.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, - "{2}", - fontName, fontSize, text); - } - - internal void AddRec(int posX, int posY, int width, int height) - { - content.AppendFormat(System.Globalization.CultureInfo.InvariantCulture, "", posX, posY, width, height); - } - - internal static double ConvertAlpha(Color32 alpha) - { - return Math.Round((((double)alpha.a) / (double)255), 2); - } - - internal static string GetBackgroundStyle(Color32 color) - { - double alpha = ConvertAlpha(color); - return string.Format("style=\"background-color:rgb({0},{1},{2});background-color:rgba({0},{1},{2},{3});\"", - color.r, color.g, color.b, alpha); - } - - internal static string GetColorRgb(Color32 color) - { - return color.r + "," + color.g + "," + color.b; - } - - internal static string GetColorRgba(Color32 color) - { - double alpha = ConvertAlpha(color); - return color.r + "," + color.g + "," + color.b + "," + alpha; - } - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/renderer/SVGRenderer.cs.meta b/Runtime/zxing.unity/Source/lib/renderer/SVGRenderer.cs.meta deleted file mode 100644 index 780f83a03..000000000 --- a/Runtime/zxing.unity/Source/lib/renderer/SVGRenderer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 22099c441ea994072a57d7cb0c8d545c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/unity.meta b/Runtime/zxing.unity/Source/lib/unity.meta deleted file mode 100644 index e1c071357..000000000 --- a/Runtime/zxing.unity/Source/lib/unity.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e886384136e3344e8942ca2777bad80f -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/unity/Color32LuminanceSource.cs b/Runtime/zxing.unity/Source/lib/unity/Color32LuminanceSource.cs deleted file mode 100644 index 89d612073..000000000 --- a/Runtime/zxing.unity/Source/lib/unity/Color32LuminanceSource.cs +++ /dev/null @@ -1,85 +0,0 @@ -/* -* Copyright 2012 ZXing.Net authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using UnityEngine; - -namespace ZXing -{ - /// - /// Calculates the luminance values based upon the Color32 structure - /// - public class Color32LuminanceSource : BaseLuminanceSource - { - /// - /// Initializes a new instance of the class. - /// - /// The width. - /// The height. - public Color32LuminanceSource(int width, int height) - : base(width, height) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The color32s. - /// The width. - /// The height. - public Color32LuminanceSource(Color32[] color32s, int width, int height) - : base(width, height) - { - SetPixels(color32s); - } - - /// - /// Sets the pixels. - /// - /// The color32s. - public void SetPixels(Color32[] color32s) - { - var z = 0; - - for (var y = Height - 1; y >= 0; y--) - { - // This is flipped vertically because the Color32 array from Unity is reversed vertically, - // it means that the top most row of the image would be the bottom most in the array. - for (var x = 0; x < Width; x++) - { - var color32 = color32s[y * Width + x]; - // Calculate luminance cheaply, favoring green. - luminances[z++] = (byte)(( - color32.r + - color32.g + color32.g + - color32.b) >> 2); - } - } - } - - /// - /// Should create a new luminance source with the right class type. - /// The method is used in methods crop and rotate. - /// - /// The new luminances. - /// The width. - /// The height. - /// - protected override LuminanceSource CreateLuminanceSource(byte[] newLuminances, int width, int height) - { - return new Color32LuminanceSource(width, height) { luminances = newLuminances }; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/unity/Color32LuminanceSource.cs.meta b/Runtime/zxing.unity/Source/lib/unity/Color32LuminanceSource.cs.meta deleted file mode 100644 index 447e90155..000000000 --- a/Runtime/zxing.unity/Source/lib/unity/Color32LuminanceSource.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b7e08a62d5b6644a68c7227784c1f18e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/Source/lib/unity/Color32Renderer.cs b/Runtime/zxing.unity/Source/lib/unity/Color32Renderer.cs deleted file mode 100644 index bff5f551d..000000000 --- a/Runtime/zxing.unity/Source/lib/unity/Color32Renderer.cs +++ /dev/null @@ -1,115 +0,0 @@ -/* -* Copyright 2012 ZXing.Net authors -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -using UnityEngine; - -using ZXing.Common; -using ZXing.Rendering; - -namespace ZXing -{ - /// - /// a barcode renderer which returns a Color32 array - /// - public class Color32Renderer : IBarcodeRenderer - { - /// - /// Gets or sets the foreground color. - /// - /// - /// The foreground color. - /// - public Color32 Foreground { get; set; } - /// - /// Gets or sets the background color. - /// - /// - /// The background color. - /// - public Color32 Background { get; set; } - - /// - /// Initializes a new instance of the class. - /// - public Color32Renderer() - { - Foreground = Color.black; - Background = Color.white; - } - - /// - /// Renders the specified matrix. - /// - /// The matrix. - /// The format. - /// The content. - /// - public Color32[] Render(BitMatrix matrix, BarcodeFormat format, string content) - { - return Render(matrix, format, content, null); - } - - /// - /// Renders the specified matrix. - /// - /// The matrix. - /// The format. - /// The content. - /// The options. - /// - public Color32[] Render(BitMatrix matrix, BarcodeFormat format, string content, EncodingOptions options) - { - var result = new Color32[matrix.Width * matrix.Height]; - var offset = matrix.Height - 1; - var foreground = Foreground; - var background = Background; - var divisionLeftover = matrix.Width % 32; - var bitRowRemainder = divisionLeftover > 0 ? divisionLeftover : 32; - - for (int y = 0; y < matrix.Height; y++) - { - var ba = matrix.getRow(offset - y, null); - int[] bits = ba.Array; - - for (int x = 0; x < bits.Length; x++) - { - int finalIndex = 32; - - if (x == bits.Length - 1) - { - finalIndex = bitRowRemainder; - } - - for (int i = 0; i < finalIndex; i++) - { - int bit = (bits[x] >> i) & 1; - - if (bit == 1) - { - result[matrix.Width * y + x * 32 + i] = new Color32(foreground.r, foreground.g, foreground.b, foreground.a); - } - else - { - result[matrix.Width * y + x * 32 + i] = new Color32(background.r, background.g, background.b, background.a); - } - } - } - } - - return result; - } - } -} diff --git a/Runtime/zxing.unity/Source/lib/unity/Color32Renderer.cs.meta b/Runtime/zxing.unity/Source/lib/unity/Color32Renderer.cs.meta deleted file mode 100644 index 56f55c45a..000000000 --- a/Runtime/zxing.unity/Source/lib/unity/Color32Renderer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 86042fb6389e4450095e880e267373b7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/zxing.unity/zxing.unity.asmdef b/Runtime/zxing.unity/zxing.unity.asmdef deleted file mode 100644 index 41630c056..000000000 --- a/Runtime/zxing.unity/zxing.unity.asmdef +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "zxing.unity", - "rootNamespace": "", - "references": [], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": false, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Runtime/zxing.unity/zxing.unity.asmdef.meta b/Runtime/zxing.unity/zxing.unity.asmdef.meta deleted file mode 100644 index b4edf9f48..000000000 --- a/Runtime/zxing.unity/zxing.unity.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 153e18e942e4f45e68257b49629df380 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Samples~/EditorWallets.meta b/Samples~/EditorWallets.meta deleted file mode 100644 index 0e59e2508..000000000 --- a/Samples~/EditorWallets.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6566d2636901e443081421dc9473a93b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Samples~/EditorWallets/Editor.meta b/Samples~/EditorWallets/Editor.meta deleted file mode 100644 index 713ef10b2..000000000 --- a/Samples~/EditorWallets/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2ab04a15c291a4350844e61cb7247fc3 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Samples~/EditorWallets/Editor/Algorand.Unity.Samples.EditorWallets.Editor.asmdef b/Samples~/EditorWallets/Editor/Algorand.Unity.Samples.EditorWallets.Editor.asmdef deleted file mode 100644 index 88c1eed44..000000000 --- a/Samples~/EditorWallets/Editor/Algorand.Unity.Samples.EditorWallets.Editor.asmdef +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "Algorand.Unity.Samples.EditorWallets.Editor", - "rootNamespace": "", - "references": [ - "GUID:0ed527c4e62544933a97fbaff8ea5d5a", - "GUID:45ab5c0c2cb4a0e4ba897b731349c490", - "GUID:7d7102a6f2a084a30ad9e7734dd7ec17", - "GUID:f51ebe6a0ceec4240a699833d6309b23", - "GUID:e0cd26848372d4e5c891c569017e11f1" - ], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": false, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Samples~/EditorWallets/Editor/Algorand.Unity.Samples.EditorWallets.Editor.asmdef.meta b/Samples~/EditorWallets/Editor/Algorand.Unity.Samples.EditorWallets.Editor.asmdef.meta deleted file mode 100644 index b8f3c06d4..000000000 --- a/Samples~/EditorWallets/Editor/Algorand.Unity.Samples.EditorWallets.Editor.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: a3a2f144d72b54d4faf0a1d0eecab21f -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Samples~/EditorWallets/Editor/UI.meta b/Samples~/EditorWallets/Editor/UI.meta deleted file mode 100644 index 1da568742..000000000 --- a/Samples~/EditorWallets/Editor/UI.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 262274d36214344218e7df47b1c26809 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Samples~/EditorWallets/Editor/UI/WalletConnectAccountEditorWindow.uxml b/Samples~/EditorWallets/Editor/UI/WalletConnectAccountEditorWindow.uxml deleted file mode 100644 index 25e297911..000000000 --- a/Samples~/EditorWallets/Editor/UI/WalletConnectAccountEditorWindow.uxml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Samples~/EditorWallets/Editor/UI/WalletConnectAccountEditorWindow.uxml.meta b/Samples~/EditorWallets/Editor/UI/WalletConnectAccountEditorWindow.uxml.meta deleted file mode 100644 index fa3396bc6..000000000 --- a/Samples~/EditorWallets/Editor/UI/WalletConnectAccountEditorWindow.uxml.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 73f35da47f1fe4af792dc2d393579a74 -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} diff --git a/Samples~/EditorWallets/Editor/VisualElementExtensions.cs b/Samples~/EditorWallets/Editor/VisualElementExtensions.cs deleted file mode 100644 index d043a91d2..000000000 --- a/Samples~/EditorWallets/Editor/VisualElementExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -using UnityEngine.UIElements; - -namespace Algorand.Unity.Editor -{ - public static class VisualElementExtensions - { - public static void SetDisplayed(this VisualElement visualElement, bool isDisplayed) - { - if (visualElement == null) - return; - visualElement.style.display = isDisplayed ? DisplayStyle.Flex : DisplayStyle.None; - } - } -} diff --git a/Samples~/EditorWallets/Editor/VisualElementExtensions.cs.meta b/Samples~/EditorWallets/Editor/VisualElementExtensions.cs.meta deleted file mode 100644 index e611ad62b..000000000 --- a/Samples~/EditorWallets/Editor/VisualElementExtensions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 28a65422cc00f48a4b099e2674772e0d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Samples~/EditorWallets/Editor/WalletConnectAccountEditorWindow.cs b/Samples~/EditorWallets/Editor/WalletConnectAccountEditorWindow.cs deleted file mode 100644 index 6990bf237..000000000 --- a/Samples~/EditorWallets/Editor/WalletConnectAccountEditorWindow.cs +++ /dev/null @@ -1,211 +0,0 @@ -using System; -using Cysharp.Threading.Tasks; -using UnityEditor; -using UnityEditor.UIElements; -using UnityEngine; -using UnityEngine.UIElements; - -namespace Algorand.Unity.WalletConnect.Editor -{ - public class WalletConnectAccountEditorWindow : EditorWindow - { - private static readonly ClientMeta defaultDappMeta = new ClientMeta - { - Description = "This is a connection to the Unity Editor, used to interact with the Algorand Blockchain during development time.", - IconUrls = new[] - { - "https://unity3d.com/profiles/unity3d/themes/unity/images/pages/branding_trademarks/unity-tab.png", - "https://unity3d.com/profiles/unity3d/themes/unity/images/pages/branding_trademarks/unity-tab.png", - "https://unity3d.com/profiles/unity3d/themes/unity/images/pages/branding_trademarks/unity-tab.png" - }, - Url = "https://unity.com", - Name = "Unity Editor" - }; - - [SerializeField] private VisualTreeAsset visualTree; - - [SerializeField] private WalletConnectAccountObject asset; - - [SerializeField] private string statusText; - - private WalletConnectAccountObject unsavedAsset; - - private VisualElement configureSessionContent; - private VisualElement connectedContent; - private VisualElement requestingHandshakeContent; - - private Image qrCodeImage; - private Button startSessionButton; - - - [MenuItem("Algorand.Unity/Connect Account/WalletConnect")] - public static void ShowMenu() - { - var window = GetWindow("Connect Account via WalletConnect"); - var asset = ScriptableObject.CreateInstance(); - asset.SessionData = SessionData.InitSession(defaultDappMeta, DefaultBridge.MainBridge); - window.asset = asset; - } - - public static void ShowMenu(string assetGuid) - { - var window = GetWindow("Connect Account via WalletConnect"); - var assetPath = AssetDatabase.GUIDToAssetPath(assetGuid); - var asset = AssetDatabase.LoadAssetAtPath(assetPath); - asset.SessionData = asset.SessionData.Reinitialize(); - window.asset = asset; - } - - private void CreateGUI() - { - var gui = visualTree.CloneTree(); - - connectedContent = gui.Query("ConnectedContent").First(); - configureSessionContent = gui.Query("ConfigureSessionContent").First(); - requestingHandshakeContent = gui.Query("RequestingHandshakeContent").First(); - - var statusTextField = gui.Query("StatusField").First(); - - startSessionButton = configureSessionContent.Query