From ca03ea2627b24e81038a7f9b8fc66f25a70ac898 Mon Sep 17 00:00:00 2001 From: Fernando Arellano Date: Fri, 29 Apr 2016 12:14:15 -0700 Subject: [PATCH 1/2] Added more description for using cardio via use_framworks! in swift --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index ee91b28..824fa9c 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,11 @@ The card.io iOS SDK includes header files and a single static library. We'll wal pod 'CardIO' ``` +*Note:* If you want to use `use_frameworks!` in swift you have to add a +bridge file and import the project from there, visit +[#126](https://github.com/card-io/card.io-iOS-SDK/pull/126) + for more details + ##### If you don't use CocoaPods, then: 1. Download the latest version of the SDK. From 6aa21e2d589366fb8ab589b7a3f91707cbfe11dc Mon Sep 17 00:00:00 2001 From: Fernando Arellano Date: Tue, 31 May 2016 19:39:13 -0700 Subject: [PATCH 2/2] Exposed all the headers for this library --- CardIO/CardIO.h | 45 ++++ CardIO/CardIOAnalytics.h | 26 ++ CardIO/CardIOAnimation.h | 14 + CardIO/CardIOBundle.h | 31 +++ CardIO/CardIOCGGeometry.h | 246 ++++++++++++++++++ CardIO/CardIOCVVTextFieldDelegate.h | 13 + CardIO/CardIOCameraView.h | 43 +++ CardIO/CardIOCardOverlay.h | 18 ++ CardIO/CardIOCardScanner.h | 44 ++++ CardIO/CardIOConfig.h | 24 ++ CardIO/CardIOConfigurableTextFieldDelegate.h | 31 +++ CardIO/CardIOContext.h | 53 ++++ CardIO/CardIOCreditCardExpiryFormatter.h | 16 ++ CardIO/CardIOCreditCardNumber.h | 20 ++ CardIO/CardIOCreditCardNumberFormatter.h | 18 ++ CardIO/CardIODataEntryViewController.h | 42 +++ CardIO/CardIODevice.h | 15 ++ CardIO/CardIODmzBridge.h | 34 +++ CardIO/CardIOExpiryTextFieldDelegate.h | 16 ++ CardIO/CardIOGPUFilter.h | 36 +++ CardIO/CardIOGPURenderer.h | 37 +++ CardIO/CardIOGPUShaders.h | 14 + CardIO/CardIOGPUTransformFilter.h | 20 ++ CardIO/CardIOGuideLayer.h | 43 +++ CardIO/CardIOIccVersion.h | 12 + CardIO/CardIOIplImage.h | 37 +++ CardIO/CardIOLocalizer.h | 33 +++ CardIO/CardIOMacros.h | 28 ++ CardIO/CardIOMultipleFieldTableViewCell.h | 29 +++ CardIO/CardIONumbersTextFieldDelegate.h | 17 ++ CardIO/CardIOOrientation.h | 163 ++++++++++++ .../CardIOPaymentViewControllerContinuation.h | 32 +++ CardIO/CardIOPostalCodeTextFieldDelegate.h | 15 ++ CardIO/CardIOReadCardInfo.h | 34 +++ CardIO/CardIOResource.h | 15 ++ CardIO/CardIORowBasedTableViewSection.h | 34 +++ CardIO/CardIOSectionBasedTableViewDelegate.h | 25 ++ CardIO/CardIOShutterView.h | 15 ++ CardIO/CardIOStyles.h | 11 + CardIO/CardIOTableViewCell.h | 26 ++ CardIO/CardIOTransitionView.h | 20 ++ CardIO/CardIOVideoFrame.h | 70 +++++ CardIO/CardIOVideoStream.h | 56 ++++ CardIO/CardIOVideoStreamDelegate.h | 20 ++ CardIO/CardIOViewContinuation.h | 16 ++ CardIO/CardIOViewController.h | 22 ++ CardIO/NSObject+CardioCategoryTest.h | 15 ++ CardIO/RootViewController.h | 19 ++ CardIO/UIImage+ImageEffects.h | 107 ++++++++ CardIO/iccAppDelegate.h | 13 + CardIO/iccChoicesSelectViewController.h | 13 + 51 files changed, 1796 insertions(+) create mode 100644 CardIO/CardIOAnalytics.h create mode 100644 CardIO/CardIOAnimation.h create mode 100644 CardIO/CardIOBundle.h create mode 100644 CardIO/CardIOCGGeometry.h create mode 100644 CardIO/CardIOCVVTextFieldDelegate.h create mode 100644 CardIO/CardIOCameraView.h create mode 100644 CardIO/CardIOCardOverlay.h create mode 100644 CardIO/CardIOCardScanner.h create mode 100644 CardIO/CardIOConfig.h create mode 100644 CardIO/CardIOConfigurableTextFieldDelegate.h create mode 100644 CardIO/CardIOContext.h create mode 100644 CardIO/CardIOCreditCardExpiryFormatter.h create mode 100644 CardIO/CardIOCreditCardNumber.h create mode 100644 CardIO/CardIOCreditCardNumberFormatter.h create mode 100644 CardIO/CardIODataEntryViewController.h create mode 100644 CardIO/CardIODevice.h create mode 100644 CardIO/CardIODmzBridge.h create mode 100644 CardIO/CardIOExpiryTextFieldDelegate.h create mode 100644 CardIO/CardIOGPUFilter.h create mode 100644 CardIO/CardIOGPURenderer.h create mode 100644 CardIO/CardIOGPUShaders.h create mode 100644 CardIO/CardIOGPUTransformFilter.h create mode 100644 CardIO/CardIOGuideLayer.h create mode 100644 CardIO/CardIOIccVersion.h create mode 100644 CardIO/CardIOIplImage.h create mode 100644 CardIO/CardIOLocalizer.h create mode 100644 CardIO/CardIOMacros.h create mode 100644 CardIO/CardIOMultipleFieldTableViewCell.h create mode 100644 CardIO/CardIONumbersTextFieldDelegate.h create mode 100644 CardIO/CardIOOrientation.h create mode 100644 CardIO/CardIOPaymentViewControllerContinuation.h create mode 100644 CardIO/CardIOPostalCodeTextFieldDelegate.h create mode 100644 CardIO/CardIOReadCardInfo.h create mode 100644 CardIO/CardIOResource.h create mode 100644 CardIO/CardIORowBasedTableViewSection.h create mode 100644 CardIO/CardIOSectionBasedTableViewDelegate.h create mode 100644 CardIO/CardIOShutterView.h create mode 100644 CardIO/CardIOStyles.h create mode 100644 CardIO/CardIOTableViewCell.h create mode 100644 CardIO/CardIOTransitionView.h create mode 100644 CardIO/CardIOVideoFrame.h create mode 100644 CardIO/CardIOVideoStream.h create mode 100644 CardIO/CardIOVideoStreamDelegate.h create mode 100644 CardIO/CardIOViewContinuation.h create mode 100644 CardIO/CardIOViewController.h create mode 100644 CardIO/NSObject+CardioCategoryTest.h create mode 100644 CardIO/RootViewController.h create mode 100644 CardIO/UIImage+ImageEffects.h create mode 100644 CardIO/iccAppDelegate.h create mode 100644 CardIO/iccChoicesSelectViewController.h diff --git a/CardIO/CardIO.h b/CardIO/CardIO.h index 815a3b1..ec28179 100644 --- a/CardIO/CardIO.h +++ b/CardIO/CardIO.h @@ -13,3 +13,48 @@ #import "CardIOPaymentViewController.h" #import "CardIOPaymentViewControllerDelegate.h" #import "CardIOUtilities.h" +#import "CardIOCVVTextFieldDelegate.h" +#import "CardIONumbersTextFieldDelegate.h" +#import "CardIOAnalytics.h" +#import "CardIOAnimation.h" +#import "CardIOBundle.h" +#import "CardIOCGGeometry.h" +#import "CardIOCameraView.h" +#import "CardIOCardOverlay.h" +#import "CardIOCardScanner.h" +#import "CardIOConfig.h" +#import "CardIOConfigurableTextFieldDelegate.h" +#import "CardIOContext.h" +#import "CardIOCreditCardExpiryFormatter.h" +#import "CardIOCreditCardNumber.h" +#import "CardIOCreditCardNumberFormatter.h" +#import "CardIODataEntryViewController.h" +#import "CardIODevice.h" +#import "CardIOExpiryTextFieldDelegate.h" +#import "CardIOGPUFilter.h" +#import "CardIOGPURenderer.h" +#import "CardIOGPUShaders.h" +#import "CardIOGPUTransformFilter.h" +#import "CardIOGuideLayer.h" +#import "CardIOIccVersion.h" +#import "CardIOLocalizer.h" +#import "CardIOMacros.h" +#import "CardIOMultipleFieldTableViewCell.h" +#import "CardIOOrientation.h" +#import "CardIOPaymentViewControllerContinuation.h" +#import "CardIOPostalCodeTextFieldDelegate.h" +#import "CardIOReadCardInfo.h" +#import "CardIOResource.h" +#import "CardIORowBasedTableViewSection.h" +#import "CardIOSectionBasedTableViewDelegate.h" +#import "CardIOShutterView.h" +#import "CardIOStyles.h" +#import "CardIOTableViewCell.h" +#import "CardIOTransitionView.h" +#import "CardIOVideoFrame.h" +#import "CardIOVideoStream.h" +#import "CardIOVideoStreamDelegate.h" +#import "CardIOViewContinuation.h" +#import "CardIOViewController.h" +#import "RootViewController.h" +#import "UIImage+ImageEffects.h" diff --git a/CardIO/CardIOAnalytics.h b/CardIO/CardIOAnalytics.h new file mode 100644 index 0000000..6445c61 --- /dev/null +++ b/CardIO/CardIOAnalytics.h @@ -0,0 +1,26 @@ +// +// CardIOAnalytics.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import + +@class CardIOContext; +@class CardIOCardScanner; + +@interface CardIOAnalytics : NSObject + +- (id)initWithContext:(CardIOContext *)aContext; + +#if USE_CAMERA || SIMULATE_CAMERA + +// Trigger the reporting of current scan analytics +- (void)reportEventWithLabel:(NSString *)reportLabel withScanner:(CardIOCardScanner *)cardScanner; + +#endif // USE_CAMERA || SIMULATE_CAMERA + +@property(nonatomic, weak, readwrite) CardIOContext *context; // danger of retain cycles here, since context has a ref to us +@property(nonatomic, strong, readwrite) NSString *sessionID; + +@end + diff --git a/CardIO/CardIOAnimation.h b/CardIO/CardIOAnimation.h new file mode 100644 index 0000000..69ab953 --- /dev/null +++ b/CardIO/CardIOAnimation.h @@ -0,0 +1,14 @@ +// +// CardIOAnimation.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import + +typedef void (^BareBlock)(void); + +void SuppressCAAnimation(BareBlock block); + +//@interface CardIOAnimation : NSObject +// +//@end diff --git a/CardIO/CardIOBundle.h b/CardIO/CardIOBundle.h new file mode 100644 index 0000000..5b52d4d --- /dev/null +++ b/CardIO/CardIOBundle.h @@ -0,0 +1,31 @@ +// +// CardIOBundle.h +// +// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT DIRECTLY. +// +// To make changes, please either regenerate the file +// or update the generator (and submit a pull request +// with your fix!), as appropriate. +// +// Generated by command: `python baler.py assets/ Classes/ --overwrite-delay 0 -z -c CardIOBundle` +// + +#import + +@interface CardIOBundle : NSObject + +/// Get the CardIOBundle instance. +/// Expands and saves the bundle to the filesystem on first invocation. ++ (CardIOBundle *)sharedInstance; + +/// Analogous to UIImage's +imageNamed: +- (UIImage *)imageNamed:(NSString *)name; + +/// Use as you would any NSBundle +- (NSBundle *)NSBundle; + +#if BALER_DEBUG +- (BOOL)passesSelfTest:(NSError **)error; +#endif + +@end \ No newline at end of file diff --git a/CardIO/CardIOCGGeometry.h b/CardIO/CardIOCGGeometry.h new file mode 100644 index 0000000..d1deb91 --- /dev/null +++ b/CardIO/CardIOCGGeometry.h @@ -0,0 +1,246 @@ +// +// CardIOCGGeometry.h +// See the file "LICENSE.md" for the full license governing this code. +// + +// Note: These don't really need namespacing, since they are inlined. + +// Note: need to use `#ifdef __LP64__` logic, rather than depending on , +// because this header is sometimes included in .mm files (where doesn't apply). + +#import + +static inline CGRect CGRectZeroWithSize(CGSize size) { + return CGRectMake(0.0f, 0.0f, size.width, size.height); +} + +static inline CGRect CGRectZeroWithSquareSize(CGFloat size) { + return CGRectMake(0.0f, 0.0f, size, size); +} + +static inline CGRect CGRectZeroWithWidthAndHeight(CGFloat width, CGFloat height) { + return CGRectMake(0.0f, 0.0f, width, height); +} + +static inline CGRect CGRectWithOriginAndSize(CGPoint origin, CGSize size) { + return CGRectMake(origin.x, origin.y, size.width, size.height); +} + +static inline CGRect CGRectWithOriginWidthAndHeight(CGPoint origin, CGFloat width, CGFloat height) { + return CGRectMake(origin.x, origin.y, width, height); +} + +static inline CGRect CGRectWithOriginAndSquareSize(CGPoint origin, CGFloat size) { + return CGRectMake(origin.x, origin.y, size, size); +} + +static inline CGRect CGRectWithXYAndSize(CGFloat xOrigin, CGFloat yOrigin, CGSize size) { + return CGRectMake(xOrigin, yOrigin, size.width, size.height); +} + +static inline CGRect CGRectWithXYAndSquareSize(CGFloat xOrigin, CGFloat yOrigin, CGFloat size) { + return CGRectMake(xOrigin, yOrigin, size, size); +} + +static inline CGRect CGRectWithCenterAndSize(CGPoint center, CGSize size) { + return CGRectMake(center.x - size.width / 2.0f, center.y - size.height / 2.0f, size.width, size.height); +} + +static inline CGRect CGRectWithCenterAndSquareSize(CGPoint center, CGFloat size) { + return CGRectMake(center.x - size / 2.0f, center.y - size / 2.0f, size, size); +} + +static inline CGRect CGRectWithRotatedRect(CGRect rect) { + return CGRectMake(rect.origin.y, rect.origin.x, rect.size.height, rect.size.width); +} + +static inline CGSize CGSizeMakeSquare(CGFloat widthAndHeight) { + return CGSizeMake(widthAndHeight, widthAndHeight); +} + +static inline CGRect CGRectByAddingXOffset(CGRect originalRect, CGFloat xOffset) { + return CGRectWithXYAndSize(originalRect.origin.x + xOffset, originalRect.origin.y, originalRect.size); +} + +static inline CGRect CGRectByAddingYOffset(CGRect originalRect, CGFloat yOffset) { + return CGRectWithXYAndSize(originalRect.origin.x, originalRect.origin.y + yOffset, originalRect.size); +} + +static inline CGRect CGRectByAddingXAndYOffset(CGRect originalRect, CGFloat xOffset, CGFloat yOffset) { + return CGRectWithXYAndSize(originalRect.origin.x + xOffset, originalRect.origin.y + yOffset, originalRect.size); +} + +static inline CGRect CGRectByAddingWidth(CGRect originalRect, CGFloat additionalWidth) { + return CGRectMake(originalRect.origin.x, originalRect.origin.y, originalRect.size.width + additionalWidth, originalRect.size.height); +} + +static inline CGRect CGRectByAddingHeight(CGRect originalRect, CGFloat additionalHeight) { + return CGRectMake(originalRect.origin.x, originalRect.origin.y, originalRect.size.width, originalRect.size.height + additionalHeight); +} + +static inline CGRect CGRectBySettingWidth(CGRect originalRect, CGFloat newWidth) { + return CGRectMake(originalRect.origin.x, originalRect.origin.y, newWidth, originalRect.size.height); +} + +static inline CGRect CGRectBySettingHeight(CGRect originalRect, CGFloat newHeight) { + return CGRectMake(originalRect.origin.x, originalRect.origin.y, originalRect.size.width, newHeight); +} + +static inline CGRect CGRectByAddingWidthAndHeight(CGRect originalRect, CGFloat additionalWidth, CGFloat additionalHeight) { + return CGRectMake(originalRect.origin.x, originalRect.origin.y, originalRect.size.width + additionalWidth, originalRect.size.height + additionalHeight); +} + +static inline CGSize CGSizeByAddingHeight(CGSize originalSize, CGFloat extraHeight) { + return CGSizeMake(originalSize.width, originalSize.height + extraHeight); +} + +static inline CGSize CGSizeByAddingWidth(CGSize originalSize, CGFloat extraWidth) { + return CGSizeMake(originalSize.width + extraWidth, originalSize.height); +} + +static inline CGSize CGSizeByAddingWidthAndHeight(CGSize originalSize, CGFloat extraWidth, CGFloat extraHeight) { + return CGSizeMake(originalSize.width + extraWidth, originalSize.height + extraHeight); +} + +static inline CGSize CGSizeByScaling(CGSize originalSize, CGFloat scale) { + return CGSizeMake(originalSize.width * scale, originalSize.height * scale); +} + +static inline CGPoint CGPointByAddingXOffset(CGPoint originalPoint, CGFloat xOffset) { + return CGPointMake(originalPoint.x + xOffset, originalPoint.y); +} + +static inline CGPoint CGPointByAddingYOffset(CGPoint originalPoint, CGFloat yOffset) { + return CGPointMake(originalPoint.x, originalPoint.y + yOffset); +} + +static inline CGFloat SquaredDistanceBetweenPoints(CGPoint p1, CGPoint p2) { + CGFloat deltaX = p1.x - p2.x; + CGFloat deltaY = p1.y - p2.y; + return (deltaX * deltaX) + (deltaY * deltaY); +} + +static inline CGFloat DistanceBetweenPoints(CGPoint p1, CGPoint p2) { +#ifdef __LP64__ + return sqrt(SquaredDistanceBetweenPoints(p1, p2)); +#else + return sqrtf(SquaredDistanceBetweenPoints(p1, p2)); +#endif +} + +static inline CGPoint CenterOfRect(CGRect rect) { + return CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect)); +} + +static inline double AngleBetweenPoints(CGPoint p, CGPoint q) { + CGPoint deltaVector = CGPointMake(p.x - q.x, p.y - q.y); + double angle = atan(deltaVector.y / deltaVector.x) + (deltaVector.x < 0 ? M_PI : 0); + return angle; +} + +static inline CGPoint MidpointBetweenPoints(CGPoint p, CGPoint q) { + return CGPointMake((p.x + q.x) / 2.0f, (p.y + q.y) / 2.0f); +} + +static inline CGPoint PointMinusPoint(CGPoint p, CGPoint q) { + return CGPointMake(p.x - q.x, p.y - q.y); +} + +static inline CGPoint PointPlusPoint(CGPoint p, CGPoint q) { + return CGPointMake(p.x + q.x, p.y + q.y); +} + +static inline CGFloat OffsetToCenterFloatInFloat(CGFloat smallerValue, CGFloat largerValue) { + return (largerValue - smallerValue) / 2.0f; +} + +static inline CGRect CenteredRectInRectWithSize(CGRect rectToCenterIn, CGSize sizeOfCenteredRect) { + return CGRectWithXYAndSize(rectToCenterIn.origin.x + OffsetToCenterFloatInFloat(sizeOfCenteredRect.width, rectToCenterIn.size.width), + rectToCenterIn.origin.y + OffsetToCenterFloatInFloat(sizeOfCenteredRect.height, rectToCenterIn.size.height), + sizeOfCenteredRect); +} + +static inline CGSize ScaledSize(CGSize originalSize, CGFloat scalingFactor) { + return CGSizeMake(originalSize.width * scalingFactor, originalSize.height * scalingFactor); +} + +static inline CGRect CGRectRoundedToNearestPixel(CGRect rect) { +#ifdef __LP64__ + return CGRectMake(round(rect.origin.x), + round(rect.origin.y), + round(rect.size.width), + round(rect.size.height)); +#else + return CGRectMake(roundf(rect.origin.x), + roundf(rect.origin.y), + roundf(rect.size.width), + roundf(rect.size.height)); +#endif +} + +static inline CGRect CGRectFlooredToNearestPixel(CGRect rect) { +#ifdef __LP64__ + return CGRectMake(floor(rect.origin.x), + floor(rect.origin.y), + floor(rect.size.width), + floor(rect.size.height)); +#else + return CGRectMake(floorf(rect.origin.x), + floorf(rect.origin.y), + floorf(rect.size.width), + floorf(rect.size.height)); +#endif +} + +static inline CGFloat CGFloatMean(CGFloat a, CGFloat b) { + return (a + b) / 2.0f; +} + +static inline CGFloat orientationToRotation(UIInterfaceOrientation orientation) { + CGFloat rotation = 0.0f; + switch(orientation) { + case UIInterfaceOrientationPortrait: { + rotation = 0.0f; + break; + } + case UIInterfaceOrientationLandscapeRight: { + rotation = (CGFloat)M_PI_2; + break; + } + case UIInterfaceOrientationPortraitUpsideDown: { + rotation = (CGFloat)M_PI; + break; + } + case UIInterfaceOrientationLandscapeLeft: { + rotation = (CGFloat)(3.0 * M_PI_2); + break; + } + default: + break; + } + return rotation; +} + +static inline CGRect aspectFit(CGSize contents, CGSize container) { + // Aspect fit is not well defined when contents or container is degenerate. Rather than crashing, + // return a zero-ish value. + if(contents.height == 0 || contents.width == 0 || container.width == 0 || container.height == 0) { + return CGRectZero; + } + + CGFloat contentsAspectRatio = contents.width / contents.height; + + CGSize contained; + if (contentsAspectRatio * container.height < container.width) { + contained = CGSizeMake(contentsAspectRatio * container.height, container.height); + } else if (contentsAspectRatio * container.height > container.width) { + contained = CGSizeMake(container.width, container.width / contentsAspectRatio); + } else { + contained = container; + } + + CGPoint origin = CGPointMake((container.width - contained.width) / 2.0f, (container.height - contained.height) / 2.0f); + + return CGRectWithOriginAndSize(origin, contained); +} + diff --git a/CardIO/CardIOCVVTextFieldDelegate.h b/CardIO/CardIOCVVTextFieldDelegate.h new file mode 100644 index 0000000..5bbab56 --- /dev/null +++ b/CardIO/CardIOCVVTextFieldDelegate.h @@ -0,0 +1,13 @@ +// +// CardIOCVVTextFieldDelegate.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import +#import "CardIOConfigurableTextFieldDelegate.h" + +@interface CardIOCVVTextFieldDelegate : CardIOConfigurableTextFieldDelegate + ++ (BOOL)isValidCVV:(NSString *)cvv forNumber:(NSString *)number; + +@end diff --git a/CardIO/CardIOCameraView.h b/CardIO/CardIOCameraView.h new file mode 100644 index 0000000..84c3ee9 --- /dev/null +++ b/CardIO/CardIOCameraView.h @@ -0,0 +1,43 @@ +// +// CardIOCameraView.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#if USE_CAMERA || SIMULATE_CAMERA + +#import +#import "CardIOGuideLayer.h" +#import "CardIOVideoStreamDelegate.h" + +#define kRotationAnimationDuration 0.2f + +@class CardIOConfig; +@class CardIOVideoFrame; +@class CardIOVideoStream; +@class CardIOCardScanner; + +@interface CardIOCameraView : UIView + +- (id)initWithFrame:(CGRect)frame delegate:(id)delegate config:(CardIOConfig *)config; + +- (void)updateLightButtonState; + +- (void)willAppear; +- (void)willDisappear; + +- (void)startVideoStreamSession; +- (void)stopVideoStreamSession; + +- (CGRect)guideFrame; + +// CGRect for the actual camera preview area within the cameraView +- (CGRect)cameraPreviewFrame; + +@property(nonatomic, strong, readonly) CardIOCardScanner *scanner; +@property(nonatomic, weak, readwrite) id delegate; +@property(nonatomic, strong, readwrite) UIFont *instructionsFont; +@property(nonatomic, assign, readwrite) BOOL suppressFauxCardLayer; + +@end + +#endif \ No newline at end of file diff --git a/CardIO/CardIOCardOverlay.h b/CardIO/CardIOCardOverlay.h new file mode 100644 index 0000000..607df1c --- /dev/null +++ b/CardIO/CardIOCardOverlay.h @@ -0,0 +1,18 @@ +// +// CardIOCardOverlay.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#if USE_CAMERA || SIMULATE_CAMERA + +#import + +@class CardIOReadCardInfo; + +@interface CardIOCardOverlay : NSObject + ++ (UIImage *)cardImage:(UIImage *)cardImage withDisplayInfo:(CardIOReadCardInfo *)cardInfo annotated:(BOOL)shouldAnnotate; + +@end + +#endif diff --git a/CardIO/CardIOCardScanner.h b/CardIO/CardIOCardScanner.h new file mode 100644 index 0000000..c348457 --- /dev/null +++ b/CardIO/CardIOCardScanner.h @@ -0,0 +1,44 @@ +// +// CardIOCardScanner.h +// See the file "LICENSE.md" for the full license governing this code. +// + +// A thin, objective-c wrapper about dmz's ScannerState object, for convenience. + +#if USE_CAMERA || SIMULATE_CAMERA + +#import "scan.h" + +@class CardIOIplImage; +@class CardIOReadCardInfo; + +@interface CardIOCardScanner : NSObject + +- (void)reset; +- (void)addFrame:(CardIOIplImage *)y + focusScore:(float)focusScore + brightnessScore:(float)brightnessScore + isoSpeed:(NSInteger)isoSpeed + shutterSpeed:(float)shutterSpeed + torchIsOn:(BOOL)torchIsOn + markFlipped:(BOOL)flipped + scanExpiry:(BOOL)scanExpiry; +- (BOOL)complete; + +// these properties are intentionally (superstitiously, anyhow) atomic -- card scanners get passed around between threads + +// will return garbage unless -complete returns YES +// the xOffsets and yOffset populated in cardInfo will be +// from the most recent frame added via addFrame! +@property(strong, readonly) CardIOReadCardInfo *cardInfo; + +@property(assign, readonly) ScanSessionAnalytics *scanSessionAnalytics; +@property(assign, readonly) BOOL lastFrameWasUpsideDown; + +#if SIMULATE_CAMERA +@property(assign, readwrite) BOOL considerItScanned; +#endif + +@end + +#endif diff --git a/CardIO/CardIOConfig.h b/CardIO/CardIOConfig.h new file mode 100644 index 0000000..2076f8c --- /dev/null +++ b/CardIO/CardIOConfig.h @@ -0,0 +1,24 @@ +// +// CardIOConfig.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import +#import "CardIOAnalytics.h" +#import "CardIODetectionMode.h" + +@interface CardIOConfig : NSObject +@property(nonatomic, strong, readwrite) CardIOAnalytics *scanReport; + +@property(nonatomic, copy, readwrite) NSString *languageOrLocale; +@property(nonatomic, assign, readwrite) BOOL useCardIOLogo; +@property(nonatomic, retain, readwrite) UIColor *guideColor; +@property(nonatomic, assign, readwrite) CGFloat scannedImageDuration; +@property(nonatomic, assign, readwrite) BOOL allowFreelyRotatingCardGuide; +@property(nonatomic, assign, readwrite) BOOL scanExpiry; +@property(nonatomic, copy, readwrite) NSString *scanInstructions; +@property(nonatomic, assign, readwrite) BOOL hideCardIOLogo; +@property(nonatomic, retain, readwrite) UIView *scanOverlayView; + +@property(nonatomic, assign, readwrite) CardIODetectionMode detectionMode; +@end diff --git a/CardIO/CardIOConfigurableTextFieldDelegate.h b/CardIO/CardIOConfigurableTextFieldDelegate.h new file mode 100644 index 0000000..a40d4eb --- /dev/null +++ b/CardIO/CardIOConfigurableTextFieldDelegate.h @@ -0,0 +1,31 @@ +// +// CardIOConfigurableTextFieldDelegate.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import + + +@interface CardIOConfigurableTextFieldDelegate : NSObject { +@private + BOOL numbersOnly; + NSInteger maxLength; // set to zero for no max length +} + +@property(nonatomic, assign, readwrite) BOOL numbersOnly; +@property(nonatomic, assign, readwrite) NSInteger maxLength; + ++ (BOOL)containsNumbersOnly:(NSString *)newText; ++ (NSInteger)lengthOfString:(NSString *)originalText afterChangingCharactersInRange:(NSRange)range replacementString:(NSString *)string; + ++ (NSInteger)nonDigitsInTextField:(UITextField *)textField beforeOffset:(NSInteger)offset; ++ (UITextPosition *)positionInTextField:(UITextField *)textField after:(NSInteger)numberOfDigits; + ++ (void)getSelectionInTextField:(UITextField *)textField + withSelectedTextRange:(UITextRange *)selectedTextRange + forStart:(NSInteger *)startSelectionOffset + forEnd:(NSInteger *)endSelectionOffset; + ++ (void)vibrate; + +@end diff --git a/CardIO/CardIOContext.h b/CardIO/CardIOContext.h new file mode 100644 index 0000000..4d0c19f --- /dev/null +++ b/CardIO/CardIOContext.h @@ -0,0 +1,53 @@ +// +// CardIOContext.h +// See the file "LICENSE.md" for the full license governing this code. +// + +// This object is a container for information about a particular card.io instantiation. Most of this information +// is either set by the developer or initialized on first use. + +#import +#import "CardIODetectionMode.h" + +@class CardIOAnalytics; +@class CardIOConfig; + +@interface CardIOContext : NSObject + +@property(nonatomic, strong, readwrite) CardIOConfig *config; + +@property(nonatomic, assign, readwrite) BOOL collectCVV; +@property(nonatomic, assign, readwrite) BOOL collectExpiry; +@property(nonatomic, assign, readwrite) BOOL collectPostalCode; +@property(nonatomic, assign, readwrite) BOOL restrictPostalCodeToNumericOnly; +@property(nonatomic, assign, readwrite) BOOL collectCardholderName; +@property(nonatomic, assign, readwrite) BOOL disableManualEntryButtons; +@property(nonatomic, assign, readwrite) BOOL keepStatusBarStyle; +@property(nonatomic, assign, readwrite) UIBarStyle navigationBarStyle; +@property(nonatomic, retain, readwrite) UIColor *navigationBarTintColor; +@property(nonatomic, assign, readwrite) BOOL disableBlurWhenBackgrounding; +@property(nonatomic, assign, readwrite) BOOL suppressScanConfirmation; +@property(nonatomic, assign, readwrite) BOOL suppressScannedCardImage; +@property(nonatomic, assign, readwrite) BOOL maskManualEntryDigits; + +#if CARDIO_DEBUG +@property(nonatomic, assign, readwrite) BOOL doABTesting; +#endif + +// All of the following are passthroughs to self.config +@property(nonatomic, strong, readwrite) CardIOAnalytics *scanReport; +@property(nonatomic, copy, readwrite) NSString *languageOrLocale; +@property(nonatomic, assign, readwrite) BOOL useCardIOLogo; +@property(nonatomic, retain, readwrite) UIColor *guideColor; +@property(nonatomic, assign, readwrite) CGFloat scannedImageDuration; +@property(nonatomic, assign, readwrite) BOOL allowFreelyRotatingCardGuide; + +@property(nonatomic, copy, readwrite) NSString *scanInstructions; +@property(nonatomic, assign, readwrite) BOOL hideCardIOLogo; +@property(nonatomic, retain, readwrite) UIView *scanOverlayView; + +@property(nonatomic, assign, readwrite) CardIODetectionMode detectionMode; + +@property(nonatomic, assign, readwrite) BOOL scanExpiry; + +@end diff --git a/CardIO/CardIOCreditCardExpiryFormatter.h b/CardIO/CardIOCreditCardExpiryFormatter.h new file mode 100644 index 0000000..c4d3c9c --- /dev/null +++ b/CardIO/CardIOCreditCardExpiryFormatter.h @@ -0,0 +1,16 @@ +// +// CardIOCreditCardExpiryFormatter.h +// See the file "LICENSE.md" for the full license governing this code. +// + + +#import + +@interface CardIOCreditCardExpiryFormatter : NSObject + +// expects an initialized object in obj -- handles both NSString and CardIOCreditCardInfo +- (BOOL)getObjectValue:(id __autoreleasing *)obj forString:(NSString *)string errorDescription:(NSString **)error; + +- (NSString *)stringForObjectValue:(id)obj; + +@end diff --git a/CardIO/CardIOCreditCardNumber.h b/CardIO/CardIOCreditCardNumber.h new file mode 100644 index 0000000..a18b200 --- /dev/null +++ b/CardIO/CardIOCreditCardNumber.h @@ -0,0 +1,20 @@ +// +// CardIOCreditCardNumber.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import + +#import "CardIOCreditCardInfo.h" + +@interface CardIOCreditCardNumber : NSObject + ++ (CardIOCreditCardType)cardTypeForCardNumber:(NSString *)cardNumber; ++ (NSInteger)numberLengthForCardNumber:(NSString *)cardNumber; // returns -1 for unknown ++ (NSInteger)cvvLengthForCardType:(CardIOCreditCardType)cardType; // returns -1 for unknown ++ (BOOL)passesLuhnChecksum:(NSString *)cardNumber; ++ (NSString *)stringByRemovingNonNumbers:(NSString *)stringWithSpaces; ++ (NSString *)stringbyRemovingSpaces:(NSString *)stringWithSpaces; ++ (BOOL)isValidNumber:(NSString *)number; + +@end diff --git a/CardIO/CardIOCreditCardNumberFormatter.h b/CardIO/CardIOCreditCardNumberFormatter.h new file mode 100644 index 0000000..4041715 --- /dev/null +++ b/CardIO/CardIOCreditCardNumberFormatter.h @@ -0,0 +1,18 @@ +// +// CardIOCreditCardNumberFormatter.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import + + +@interface CardIOCreditCardNumberFormatter : NSObject + +// expects an initialized object in obj -- handles both NSString and CardIOCreditCardInfo +- (BOOL)getObjectValue:(id __autoreleasing *)obj forString:(NSString *)string errorDescription:(NSString **)error; + +// returns a string with proper spaces added +- (NSString *)stringForObjectValue:(id)obj; + + +@end diff --git a/CardIO/CardIODataEntryViewController.h b/CardIO/CardIODataEntryViewController.h new file mode 100644 index 0000000..c9d3154 --- /dev/null +++ b/CardIO/CardIODataEntryViewController.h @@ -0,0 +1,42 @@ +// +// CardIODataEntryViewController.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import + +@class CardIOContext; +@class CardIOCreditCardInfo; + +#define kCardPadding 10.0f + +#define kPortraitZoomedInCardImageSizePercent ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ? 0.935f : 0.885f) // this is selected such that the resulting card width matches the width of a grouped UITableViewCell +#define kLandscapeZoomedInCardImageSizePercent ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone ? 0.484f : 0.493f) // this is selected such that the resulting card width is half of (screenwidth - kCardPadding). + +@interface CardIODataEntryViewController : UIViewController + +@property(nonatomic, strong, readwrite) CardIOCreditCardInfo *cardInfo; +@property(nonatomic, strong, readwrite) UIImage *cardImage; +@property(nonatomic, strong, readwrite) UIImageView *cardView; +@property(nonatomic, assign, readwrite) CGPoint cardImageCenter; +@property(nonatomic, assign, readwrite) CGSize cardImageSize; +@property(nonatomic, strong, readwrite) UIView *floatingCardView; +@property(nonatomic, strong, readwrite) UIWindow *floatingCardWindow; +@property(nonatomic, strong, readwrite) UIWindow *priorKeyWindow; +@property(nonatomic, assign, readwrite) BOOL manualEntry; +@property(nonatomic, assign, readwrite) BOOL collectExpiry; +@property(nonatomic, assign, readwrite) BOOL collectCVV; +@property(nonatomic, assign, readwrite) BOOL collectPostalCode; +@property(nonatomic, assign, readwrite) BOOL restrictPostalCodeToNumericOnly; +@property(nonatomic, assign, readwrite) BOOL collectCardholderName; +@property(nonatomic, strong, readwrite) UITextField *expiryTextField; +@property(nonatomic, strong, readwrite) UITextField *numberTextField; +@property(nonatomic, strong, readwrite) UITextField *cvvTextField; +@property(nonatomic, strong, readwrite) UITextField *postalCodeTextField; +@property(nonatomic, strong, readwrite) UITextField *cardholderNameTextField; + ++ (BOOL)cardExpiryIsValid:(CardIOCreditCardInfo *)info; + +- (id)initWithContext:(CardIOContext *)aContext withStatusBarHidden:(BOOL)statusBarHidden; + +@end diff --git a/CardIO/CardIODevice.h b/CardIO/CardIODevice.h new file mode 100644 index 0000000..e830aec --- /dev/null +++ b/CardIO/CardIODevice.h @@ -0,0 +1,15 @@ +// +// CardIODevice.h +// See the file "LICENSE.md" for the full license governing this code. +// + +// Repository for device-specific settings. Device includes both hardware and OS version. + +#import + +@interface CardIODevice : NSObject + ++ (BOOL)hasVideoCamera; ++ (BOOL)shouldSetPixelFormat; + +@end diff --git a/CardIO/CardIODmzBridge.h b/CardIO/CardIODmzBridge.h new file mode 100644 index 0000000..bccbe74 --- /dev/null +++ b/CardIO/CardIODmzBridge.h @@ -0,0 +1,34 @@ +// +// CardIODmzBridge.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import "dmz.h" +#import + +static inline FrameOrientation frameOrientationWithInterfaceOrientation(UIInterfaceOrientation interfaceOrientation) { + FrameOrientation frameOrientation = FrameOrientationPortrait; // provide a default to keep static analyzer happy + switch(interfaceOrientation) { + case UIInterfaceOrientationPortrait: + frameOrientation = FrameOrientationPortrait; + break; + case UIInterfaceOrientationPortraitUpsideDown: + frameOrientation = FrameOrientationPortraitUpsideDown; + break; + case UIInterfaceOrientationLandscapeLeft: + frameOrientation = FrameOrientationLandscapeLeft; + break; + case UIInterfaceOrientationLandscapeRight: + frameOrientation = FrameOrientationLandscapeRight; + break; + } + return frameOrientation; +} + +static inline CGRect CGRectWithDmzRect(dmz_rect rect) { + return CGRectMake(rect.x, rect.y, rect.w, rect.h); +} + +static inline CGRect CGRectWithRotatedDmzRect(dmz_rect rect) { + return CGRectMake(rect.y, rect.x, rect.h, rect.w); +} diff --git a/CardIO/CardIOExpiryTextFieldDelegate.h b/CardIO/CardIOExpiryTextFieldDelegate.h new file mode 100644 index 0000000..e7abe2f --- /dev/null +++ b/CardIO/CardIOExpiryTextFieldDelegate.h @@ -0,0 +1,16 @@ +// +// CardIOExpiryTextFieldDelegate.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import +#import "CardIOConfigurableTextFieldDelegate.h" +#import "CardIOCreditCardExpiryFormatter.h" + +@interface CardIOExpiryTextFieldDelegate : CardIOConfigurableTextFieldDelegate + +@property(nonatomic, strong, readonly) CardIOCreditCardExpiryFormatter *formatter; + +- (BOOL)cleanupTextField:(UITextField *)textField; + +@end diff --git a/CardIO/CardIOGPUFilter.h b/CardIO/CardIOGPUFilter.h new file mode 100644 index 0000000..7ec22bd --- /dev/null +++ b/CardIO/CardIOGPUFilter.h @@ -0,0 +1,36 @@ +// +// CardIOGPUFilter.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import +#import "CardIOGPURenderer.h" +#import + +@interface CardIOGPUFilter : NSObject { + CardIOGPURenderer *_gpuRenderer; +} + +@property (nonatomic, assign, readonly) CGSize size; + +- (id)initWithSize:(CGSize)size vertexShaderSrc:(NSString *)vertexShaderSrc fragmentShaderSrc:(NSString *)fragmentShaderSrc; + +// Called upon app backgrounding, to call glFinish() +- (void)finish; + +// Returns a new UIImage of the given size +- (UIImage *)processUIImage:(UIImage *)srcUIImage toSize:(const CGSize)size; + +#if USE_CAMERA +- (UIImage *)processIplToUIImage:(IplImage *)srcImg toSize:(const CGSize)size; + +// Sets the imageData of the given dstImg IplImage. +- (void)processIplImage:(IplImage *)srcImg dstIplImg:(IplImage *)dstImg; +#endif // USE_CAMERA + +// Helper class methods ++ (void)loadIdentityMatrix:(GLfloat *)matrix size:(GLuint)size; ++ (void)loadOrthoMatrix:(GLfloat *)matrix left:(GLfloat)left right:(GLfloat)right bottom:(GLfloat)bottom top:(GLfloat)top near:(GLfloat)near far:(GLfloat)far; ++ (NSString *)matrixAsString:(GLfloat *)matrix size:(GLuint)size rowMajor:(BOOL)rowMajor; + +@end diff --git a/CardIO/CardIOGPURenderer.h b/CardIO/CardIOGPURenderer.h new file mode 100644 index 0000000..5e61ccb --- /dev/null +++ b/CardIO/CardIOGPURenderer.h @@ -0,0 +1,37 @@ +// +// CardIOGPURenderer.h +// See the file "LICENSE.md" for the full license governing this code. +// + +@interface CardIOGPURenderer : NSObject { + // Handles + GLuint _programHandle; + + // Inputs + GLuint _inputTexture, _positionSlot, _texCoordSlot, _textureUniform; +} +- (id)initWithSize:(CGSize)size vertexShaderSrc:(NSString *)vertexShaderSrc fragmentShaderSrc:(NSString *)vertexShaderSrc; +- (void)finish; + +- (void)prepareForUse; +- (GLuint) uniformIndex:(NSString *)uniformName; + +- (void)withContextDo:(void (^)(void))successBlock; + +- (void)renderUIImage:(UIImage *)inputImage toSize:(const CGSize)targetSize; + +// Creates a UIImage from the currently rendered framebuffer. +// Resulting image is 32bit RGBA +- (UIImage *)captureUIImageOfSize:(const CGSize)size; + +#if USE_CAMERA +- (void)renderIplImage:(IplImage *)inputImage toSize:(const CGSize)targetSize; + +// Creates an IplImage from the currently rendered framebuffer. +// Resulting image is 8bit grayscale +- (void) captureIplImage:(IplImage *)dstImg; +#endif // USE_CAMERA + +@property (nonatomic, assign, readonly) CGSize size; + +@end diff --git a/CardIO/CardIOGPUShaders.h b/CardIO/CardIOGPUShaders.h new file mode 100644 index 0000000..fd5ab99 --- /dev/null +++ b/CardIO/CardIOGPUShaders.h @@ -0,0 +1,14 @@ +// +// CardIOGPUShaders.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#ifndef icc_CardIOGPUShaders_h +#define icc_CardIOGPUShaders_h + +// via GPUImage's GPUImageFilter.h +#define STRINGIZE(x) #x +#define STRINGIZE2(x) STRINGIZE(x) +#define SHADER_STRING(text) @ STRINGIZE2(text) + +#endif diff --git a/CardIO/CardIOGPUTransformFilter.h b/CardIO/CardIOGPUTransformFilter.h new file mode 100644 index 0000000..b8eac4e --- /dev/null +++ b/CardIO/CardIOGPUTransformFilter.h @@ -0,0 +1,20 @@ +// +// CardIOGPUTransformFilter.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import "CardIOGPUFilter.h" + +@interface CardIOGPUTransformFilter : CardIOGPUFilter { + GLfloat orthographicMatrix[16]; + GLuint _transformMatrixUniform, _orthographicMatrixUniform; +} + +// Initialize with the size of the input texture +- (id)initWithSize:(CGSize)size; + +// Set the perspective matrix for this filter. +// Array of floats in column-major format. +- (void)setPerspectiveMat:(float *)matrix; + +@end diff --git a/CardIO/CardIOGuideLayer.h b/CardIO/CardIOGuideLayer.h new file mode 100644 index 0000000..f639413 --- /dev/null +++ b/CardIO/CardIOGuideLayer.h @@ -0,0 +1,43 @@ +// +// CardGuideOverlayView.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#if USE_CAMERA || SIMULATE_CAMERA + +#import + +#define kDefaultGuideColor [UIColor colorWithRed:0.0f green:1.0f blue:0.0f alpha:1.0f] + +@protocol CardIOGuideLayerDelegate +- (void)guideLayerDidLayout:(CGRect)internalGuideFrame; +@end + +/** + * This layer is meant to be layered atop a camera preview; it provides guidance about where to hold + * the card, and what edges are currently recognized. + * + * It should be a sublayer of the camera preview, with the same size. + */ + +@class CardIOVideoFrame; + +@interface CardIOGuideLayer : CALayer + +- (id)initWithDelegate:(id)guideLayerDelegate; + +- (CGRect)guideFrame; + +- (void)showCardFound:(BOOL)found; + +- (void)didRotateToDeviceOrientation:(UIDeviceOrientation)deviceOrientation; + +@property(nonatomic, strong, readwrite) UIColor *guideColor; +@property(nonatomic, strong, readwrite) CardIOVideoFrame *videoFrame; +@property(nonatomic, assign, readwrite) CFTimeInterval animationDuration; +@property(nonatomic, assign, readwrite) UIDeviceOrientation deviceOrientation; +@property(nonatomic, strong, readwrite) CAGradientLayer *fauxCardLayer; + +@end + +#endif diff --git a/CardIO/CardIOIccVersion.h b/CardIO/CardIOIccVersion.h new file mode 100644 index 0000000..0a2d07f --- /dev/null +++ b/CardIO/CardIOIccVersion.h @@ -0,0 +1,12 @@ +// +// CardIOIccVersion.h +// See the file "LICENSE.md" for the full license governing this code. +// + + +#ifndef icc_CardIOIccVersion_h +#define icc_CardIOIccVersion_h + +#define CardIOIccVersion() @"5.3.2" + +#endif diff --git a/CardIO/CardIOIplImage.h b/CardIO/CardIOIplImage.h new file mode 100644 index 0000000..904d1c2 --- /dev/null +++ b/CardIO/CardIOIplImage.h @@ -0,0 +1,37 @@ +// +// CardIOIplImage.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import +#import + +#define Y_PLANE 0 +#define CBCR_PLANE 1 + +@interface CardIOIplImage : NSObject { +@private + IplImage *image; +} + ++ (CardIOIplImage *)imageWithSize:(CvSize)size depth:(int)depth channels:(int)channels; ++ (CardIOIplImage *)imageWithIplImage:(IplImage *)anImage; +- (id)initWithIplImage:(IplImage *)anImage; + ++ (CardIOIplImage *)imageFromYCbCrBuffer:(CVImageBufferRef)imageBuffer plane:(size_t)plane; + +- (CardIOIplImage *)copyCropped:(CvRect)roi; +- (CardIOIplImage *)copyCropped:(CvRect)roi destSize:(CvSize)destSize; + +- (NSArray *)split; + ++ (CardIOIplImage *)rgbImageWithY:(CardIOIplImage *)y cb:(CardIOIplImage *)cb cr:(CardIOIplImage *)cr; + +- (UIImage *)UIImage; + +@property(nonatomic, assign, readonly) IplImage *image; +@property(nonatomic, assign, readonly) CvSize cvSize; +@property(nonatomic, assign, readonly) CGSize cgSize; +@property(nonatomic, assign, readonly) CvRect cvRect; + +@end diff --git a/CardIO/CardIOLocalizer.h b/CardIO/CardIOLocalizer.h new file mode 100644 index 0000000..579c886 --- /dev/null +++ b/CardIO/CardIOLocalizer.h @@ -0,0 +1,33 @@ +// +// CardIOLocalizer.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import +#import + +@interface CardIOLocalizer : NSObject + +#if CARDIO_DEBUG ++ (NSArray *)allLanguages; ++ (BOOL)passesSelfTest:(NSError **)error; +#endif + ++ (NSTextAlignment)textAlignmentForLanguageOrLocale:(NSString *)languageOrLocale; + ++ (void)preload; + +@end + +// This ugly stuff is to prevent name-mangling, so that this function +// can be called from either Objective-C or Objective-C++ files. +#ifdef __cplusplus +extern "C" { +#endif + + NSString *CardIOLocalizedString(NSString *key, + NSString *languageOrLocale); + +#ifdef __cplusplus +} +#endif diff --git a/CardIO/CardIOMacros.h b/CardIO/CardIOMacros.h new file mode 100644 index 0000000..ed973ce --- /dev/null +++ b/CardIO/CardIOMacros.h @@ -0,0 +1,28 @@ +// +// CardIOMacros.h +// See the file "LICENSE.md" for the full license governing this code. +// + +// CardIOLog is a replacement for NSLog that logs iff CARDIO_DEBUG is set. + +#if CARDIO_DEBUG +#define CardIOLog(format, args...) NSLog(format, ## args) +#else +#define CardIOLog(format, args...) +#endif + +@interface CardIOMacros : NSObject + ++ (id)localSettingForKey:(NSString *)key defaultValue:(NSString *)defaultValue productionValue:(NSString *)productionValue; + ++ (NSUInteger)deviceSystemMajorVersion; + ++ (BOOL)appHasViewControllerBasedStatusBar; + +@end + +#define iOS_MAJOR_VERSION [CardIOMacros deviceSystemMajorVersion] +#define iOS_8_PLUS (iOS_MAJOR_VERSION >= 8) +#define iOS_7_PLUS (iOS_MAJOR_VERSION >= 7) +#define iOS_6 (iOS_MAJOR_VERSION == 6) +#define iOS_5 (iOS_MAJOR_VERSION == 5) diff --git a/CardIO/CardIOMultipleFieldTableViewCell.h b/CardIO/CardIOMultipleFieldTableViewCell.h new file mode 100644 index 0000000..02e26f2 --- /dev/null +++ b/CardIO/CardIOMultipleFieldTableViewCell.h @@ -0,0 +1,29 @@ +// +// CardIOMultipleFieldTableViewCell.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import + +@class CardIOMultipleFieldContentView; + +@interface CardIOMultipleFieldTableViewCell : UITableViewCell { +@private + CardIOMultipleFieldContentView *content; + Class textFieldClass; +} + +//@property(nonatomic, retain, readwrite) NSArray *textFieldDelegates; +@property(nonatomic, assign, readwrite) NSUInteger numberOfFields; // should be a reasonable number ... 1-3 range. +@property(nonatomic, strong, readonly) NSArray *textFields; +@property(nonatomic, strong, readonly) NSMutableArray *labels; +@property(nonatomic, assign, readwrite) CGFloat labelWidth; +@property(nonatomic, assign, readwrite) Class textFieldClass; +@property(nonatomic, assign, readwrite) BOOL hiddenLabels; +@property(nonatomic, assign, readwrite) NSTextAlignment textAlignment; + +- (BOOL)textFitsInMultiFieldForLabel:(NSString *)labelText + forPlaceholder:(NSString *)placeholderText + forFieldWidth:(CGFloat)fieldWidth; + +@end diff --git a/CardIO/CardIONumbersTextFieldDelegate.h b/CardIO/CardIONumbersTextFieldDelegate.h new file mode 100644 index 0000000..d313af1 --- /dev/null +++ b/CardIO/CardIONumbersTextFieldDelegate.h @@ -0,0 +1,17 @@ +// +// CardIONumbersTextFieldDelegate.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import +#import "CardIOConfigurableTextFieldDelegate.h" + +@class CardIOCreditCardNumberFormatter; + +@interface CardIONumbersTextFieldDelegate : CardIOConfigurableTextFieldDelegate + +@property(nonatomic, strong, readonly) CardIOCreditCardNumberFormatter *formatter; + +- (BOOL)cleanupTextField:(UITextField *)textField; + +@end \ No newline at end of file diff --git a/CardIO/CardIOOrientation.h b/CardIO/CardIOOrientation.h new file mode 100644 index 0000000..d023f30 --- /dev/null +++ b/CardIO/CardIOOrientation.h @@ -0,0 +1,163 @@ +// +// CardIOOrientation.h +// See the file "LICENSE.md" for the full license governing this code. +// + +// Orientation helpers + +#import + +#define INTERFACE_LANDSCAPE_OR_PORTRAIT(interfaceOrientation) UIInterfaceOrientationIsPortrait(interfaceOrientation) ? @"PORTRAIT" : @"LANDSCAPE" +#define DEVICE_LANDSCAPE_OR_PORTRAIT(deviceOrientation) UIDeviceOrientationIsPortrait(deviceOrientation) ? @"PORTRAIT" : @"LANDSCAPE" + +#define kNavigationBarHeightPortrait 44 +#define kNavigationBarHeightLandscape 32 + +typedef uint8_t InterfaceToDeviceOrientationDelta; // the amount that the interfaceOrientation is rotated relative to the deviceOrientation + +enum { + InterfaceToDeviceOrientationSame = 1, + InterfaceToDeviceOrientationUpsideDown = 2, + InterfaceToDeviceOrientationRotatedClockwise = 3, + InterfaceToDeviceOrientationRotatedCounterclockwise = 4 +}; + +static inline InterfaceToDeviceOrientationDelta orientationDelta(UIInterfaceOrientation interfaceOrientation, UIDeviceOrientation deviceOrientation) { + uint16_t absoluteInterfaceOrientation = 0; + switch (interfaceOrientation) { + case UIInterfaceOrientationPortrait: + absoluteInterfaceOrientation = 0; + break; + case UIInterfaceOrientationLandscapeLeft: + absoluteInterfaceOrientation = 270; + break; + case UIInterfaceOrientationLandscapeRight: + absoluteInterfaceOrientation = 90; + break; + case UIInterfaceOrientationPortraitUpsideDown: + absoluteInterfaceOrientation = 180; + break; + default: + break; + } + + uint16_t absoluteDeviceOrientation = 0; + switch (deviceOrientation) { + case UIDeviceOrientationPortrait: + absoluteDeviceOrientation = 0; + break; + case UIDeviceOrientationLandscapeRight: + absoluteDeviceOrientation = 270; + break; + case UIDeviceOrientationLandscapeLeft: + absoluteDeviceOrientation = 90; + break; + case UIDeviceOrientationPortraitUpsideDown: + absoluteDeviceOrientation = 180; + break; + default: + // Note that we are explicitly not dealing with device flat / upside down here, since they do not impact + // the camera orientation. We assume that someone upstream of us hands this. + break; + } + + uint16_t orientationDelta = (360 + absoluteInterfaceOrientation - absoluteDeviceOrientation) % 360; + + InterfaceToDeviceOrientationDelta delta = InterfaceToDeviceOrientationSame; + switch (orientationDelta) { + case 0: + delta = InterfaceToDeviceOrientationSame; + break; + case 90: + delta = InterfaceToDeviceOrientationRotatedCounterclockwise; + break; + case 180: + delta = InterfaceToDeviceOrientationUpsideDown; + break; + case 270: + delta = InterfaceToDeviceOrientationRotatedClockwise; + break; + default: + break; + } + + return delta; +} + +static inline CGFloat rotationForOrientationDelta(InterfaceToDeviceOrientationDelta delta) { + CGFloat rotation = 0.0f; + switch (delta) { + case InterfaceToDeviceOrientationSame: + rotation = 0.0f; + break; + case InterfaceToDeviceOrientationRotatedClockwise: + rotation = (CGFloat)(3 * M_PI_2); + break; + case InterfaceToDeviceOrientationUpsideDown: + rotation = (CGFloat)M_PI; + break; + case InterfaceToDeviceOrientationRotatedCounterclockwise: + rotation = (CGFloat)M_PI_2; + break; + default: + break; + } + + return rotation; +} + +static inline CGFloat NavigationBarHeightForOrientation(UIInterfaceOrientation interfaceOrientation) { + return ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone + && UIInterfaceOrientationIsLandscape(interfaceOrientation) + ? kNavigationBarHeightLandscape + : kNavigationBarHeightPortrait); +} + +static inline CGFloat NavigationBarHeightForCurrentOrientation(UINavigationController *navigationController) { + return NavigationBarHeightForOrientation((navigationController && navigationController.modalPresentationStyle == UIModalPresentationFullScreen) + ? [[UIApplication sharedApplication] statusBarOrientation] + : UIInterfaceOrientationPortrait); +} + +static inline NSString *StringForInterfaceOrientation(UIInterfaceOrientation interfaceOrientation) { + NSString *string = nil; + switch (interfaceOrientation) { + case UIInterfaceOrientationPortrait: + string = @"UIInterfaceOrientationPortrait"; + break; + case UIInterfaceOrientationPortraitUpsideDown: + string = @"UIInterfaceOrientationPortraitUpsideDown"; + break; + case UIInterfaceOrientationLandscapeLeft: + string = @"UIInterfaceOrientationLandscapeLeft"; + break; + case UIInterfaceOrientationLandscapeRight: + string = @"UIInterfaceOrientationLandscapeRight"; + break; + default: + break; + } + + return string; +} + +static inline UIInterfaceOrientation InterfaceOrientationForString(NSString *string) { + UIInterfaceOrientation interfaceOrientation; + if ([string isEqualToString:@"UIInterfaceOrientationPortrait"]) { + interfaceOrientation = UIInterfaceOrientationPortrait; + } + else if ([string isEqualToString:@"UIInterfaceOrientationPortraitUpsideDown"]) { + interfaceOrientation = UIInterfaceOrientationPortraitUpsideDown; + } + else if ([string isEqualToString:@"UIInterfaceOrientationLandscapeLeft"]) { + interfaceOrientation = UIInterfaceOrientationLandscapeLeft; + } + else if ([string isEqualToString:@"UIInterfaceOrientationLandscapeRight"]) { + interfaceOrientation = UIInterfaceOrientationLandscapeRight; + } + else { + interfaceOrientation = UIInterfaceOrientationPortrait; + } + + return interfaceOrientation; +} diff --git a/CardIO/CardIOPaymentViewControllerContinuation.h b/CardIO/CardIOPaymentViewControllerContinuation.h new file mode 100644 index 0000000..8c60796 --- /dev/null +++ b/CardIO/CardIOPaymentViewControllerContinuation.h @@ -0,0 +1,32 @@ +// +// CardIOPaymentViewControllerContinuation.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import "CardIOPaymentViewController.h" + +@class CardIOAnalytics; +@class CardIOContext; + +@interface CardIOPaymentViewController () + ++ (CardIOPaymentViewController *)cardIOPaymentViewControllerForResponder:(UIResponder *)responder; +- (UIInterfaceOrientationMask)supportedOverlayOrientationsMask; + +@property(nonatomic, assign, readwrite) BOOL currentViewControllerIsDataEntry; +@property(nonatomic, assign, readwrite) UIInterfaceOrientation initialInterfaceOrientationForViewcontroller; + +@property(nonatomic, strong, readwrite) UIAlertView *unauthorizedForScanAlert; +@property(nonatomic, assign, readwrite) BOOL shouldStoreStatusBarStyle; +@property(nonatomic, assign, readwrite) UIStatusBarStyle originalStatusBarStyle; +@property(nonatomic, assign, readwrite) BOOL statusBarWasOriginallyHidden; + +@property(nonatomic, strong, readwrite) CardIOContext *context; + +@property(nonatomic, strong, readwrite) UIImageView *obfuscatingView; + +#if CARDIO_DEBUG +@property(nonatomic, assign, readwrite) BOOL doABTesting; +#endif + +@end diff --git a/CardIO/CardIOPostalCodeTextFieldDelegate.h b/CardIO/CardIOPostalCodeTextFieldDelegate.h new file mode 100644 index 0000000..b7155be --- /dev/null +++ b/CardIO/CardIOPostalCodeTextFieldDelegate.h @@ -0,0 +1,15 @@ +// +// CardIOPostalCodeTextFieldDelegate.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import +#import "CardIOConfigurableTextFieldDelegate.h" + +@interface CardIOPostalCodeTextFieldDelegate : CardIOConfigurableTextFieldDelegate { + +} + ++(BOOL)isValidPostalCode:(NSString*)postalCode; + +@end diff --git a/CardIO/CardIOReadCardInfo.h b/CardIO/CardIOReadCardInfo.h new file mode 100644 index 0000000..20a5606 --- /dev/null +++ b/CardIO/CardIOReadCardInfo.h @@ -0,0 +1,34 @@ +// +// CardIOReadCardInfo.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import + + +@interface CardIOReadCardInfo : NSObject + ++ (CardIOReadCardInfo *)cardInfoWithNumber:(NSString *)cardNumber + xOffsets:(NSArray *)xOffsets + yOffset:(NSUInteger)yOffset + expiryMonth:(NSUInteger)expiryMonth + expiryYear:(NSUInteger)expiryYear +#if CARDIO_DEBUG + expiryGroupedRects:(NSArray *)expiryGroupedRects + nameGroupedRects:(NSArray *)nameGroupedRects +#endif + ; + +@property(nonatomic, strong, readonly) NSString *numbers; +@property(nonatomic, strong, readonly) NSArray *xOffsets; +@property(nonatomic, assign, readonly) NSUInteger yOffset; +@property(nonatomic, assign, readonly) NSUInteger expiryYear; +@property(nonatomic, assign, readonly) NSUInteger expiryMonth; +@property(nonatomic, assign, readonly) BOOL isFlipped; + +#if CARDIO_DEBUG +@property(nonatomic, strong, readonly) NSArray *expiryGroupedRects; +@property(nonatomic, strong, readonly) NSArray *nameGroupedRects; +#endif + +@end diff --git a/CardIO/CardIOResource.h b/CardIO/CardIOResource.h new file mode 100644 index 0000000..da870f7 --- /dev/null +++ b/CardIO/CardIOResource.h @@ -0,0 +1,15 @@ +// +// CardIOResource.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import +#import "CardIOCreditCardInfo.h" + +@interface CardIOResource : NSObject + +// These are drawn using Quartz ++ (UIButton *)lightButton; ++ (UIImage *)boltImageForTorchOn:(BOOL)torchIsOn; + +@end diff --git a/CardIO/CardIORowBasedTableViewSection.h b/CardIO/CardIORowBasedTableViewSection.h new file mode 100644 index 0000000..2ffb34c --- /dev/null +++ b/CardIO/CardIORowBasedTableViewSection.h @@ -0,0 +1,34 @@ +// +// CardIORowBasedTableViewSection.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import + +@interface CardIORowBasedTableViewSection : NSObject < + UITableViewDataSource, + UITableViewDelegate +> { +@private + NSArray *rows; + NSString *headerTitle; + UIView *headerView; + NSString *footerTitle; + UIView *footerView; +} + +- (NSUInteger)indexOfRow:(id)row; + +// Each row should be an object that conforms to UITableViewDelegate and UITableViewDataSource, +// but which handles only requests for a single row. It should generally ignore the section and row info +// passed in (except where needed such as to deselect a cell at a particular index path). +// Rows unfortunately must implement tableView:numberOfRowsInSection:, but the value it (as well as other irrelevant +// methods such as tableView:numberOfSections:) returns will be ignored. :) + +@property(nonatomic, strong, readwrite) NSArray *rows; +@property(nonatomic, strong, readwrite) NSString *headerTitle; +@property(nonatomic, strong, readwrite) UIView *headerView; +@property(nonatomic, strong, readwrite) NSString *footerTitle; +@property(nonatomic, strong, readwrite) UIView *footerView; + +@end diff --git a/CardIO/CardIOSectionBasedTableViewDelegate.h b/CardIO/CardIOSectionBasedTableViewDelegate.h new file mode 100644 index 0000000..68aaea8 --- /dev/null +++ b/CardIO/CardIOSectionBasedTableViewDelegate.h @@ -0,0 +1,25 @@ +// +// CardIOSectionBasedTableViewDelegate.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import + +@interface CardIOSectionBasedTableViewDelegate : NSObject < + UITableViewDelegate, + UITableViewDataSource +> { +@private + NSArray *sections; +} + +- (NSUInteger)indexOfSection:(id)section; + +// Each section should be an object that conforms to UITableViewDelegate and UITableViewDataSource, +// but which handles only requests for a single section. It should generally ignore the section +// passed in (except where needed such as to deselect a cell at a particular index path). +// Sections may implement tableView:numberOfSections: if they really want, but it will be ignored. :) + +@property(nonatomic, strong, readwrite) NSArray *sections; + +@end diff --git a/CardIO/CardIOShutterView.h b/CardIO/CardIOShutterView.h new file mode 100644 index 0000000..de88684 --- /dev/null +++ b/CardIO/CardIOShutterView.h @@ -0,0 +1,15 @@ +// +// ShutterView.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import + + +@interface CardIOShutterView : UIView + +- (void)setOpen:(BOOL)shouldBeOpen animated:(BOOL)animated duration:(CFTimeInterval)duration; + +@property(nonatomic, assign, readwrite) BOOL open; + +@end diff --git a/CardIO/CardIOStyles.h b/CardIO/CardIOStyles.h new file mode 100644 index 0000000..f01659b --- /dev/null +++ b/CardIO/CardIOStyles.h @@ -0,0 +1,11 @@ +// +// CardIOStyles.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import + +#define kColorViewBackground [UIColor colorWithWhite:0.92f alpha:1.0f] + +// Compositing views with alpha < 1.0 is expensive. For older devices (esp. those running 3.0) it is better to precompute. +#define kColorDefaultCell [UIColor colorWithWhite:249.0f/255 alpha:1.0f] diff --git a/CardIO/CardIOTableViewCell.h b/CardIO/CardIOTableViewCell.h new file mode 100644 index 0000000..a5ba7fb --- /dev/null +++ b/CardIO/CardIOTableViewCell.h @@ -0,0 +1,26 @@ +// +// CardIOTableViewCell.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import + +// This should really be a category on UITableViewCell, but +// categories don't play nicely with static libraries (requires +// extra linker flags). + +@interface CardIOTableViewCell : NSObject + ++ (UIFont *)defaultTextLabelFontForCellStyle:(UITableViewCellStyle)cellStyle; ++ (UIFont *)defaultTextLabelFontForCellStyle:(UITableViewCellStyle)cellStyle fontSize:(CGFloat)fontSize; ++ (CGFloat)defaultTextLabelFontSizeForCellStyle:(UITableViewCellStyle)cellStyle; ++ (UIColor *)defaultTextLabelColorForCellStyle:(UITableViewCellStyle)cellStyle; + ++ (UIFont *)defaultDetailTextLabelFontForCellStyle:(UITableViewCellStyle)cellStyle; ++ (UIFont *)defaultDetailTextLabelFontForCellStyle:(UITableViewCellStyle)cellStyle fontSize:(CGFloat)fontSize; ++ (CGFloat)defaultDetailTextLabelFontSizeForCellStyle:(UITableViewCellStyle)cellStyle; ++ (UIColor *)defaultDetailTextLabelColorForCellStyle:(UITableViewCellStyle)cellStyle; + ++ (UITableViewCellStyle) defaultCellStyle; + +@end diff --git a/CardIO/CardIOTransitionView.h b/CardIO/CardIOTransitionView.h new file mode 100644 index 0000000..be293b8 --- /dev/null +++ b/CardIO/CardIOTransitionView.h @@ -0,0 +1,20 @@ +// +// CardIOTransitionView.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#if USE_CAMERA || SIMULATE_CAMERA + +#import +#import "CardIOAnimation.h" + +@interface CardIOTransitionView : UIView + +- (id)initWithFrame:(CGRect)frame cardImage:(UIImage *)cardImage transform:(CGAffineTransform)transform; +- (void)animateWithCompletion:(BareBlock)completionBlock; + +@property(nonatomic, strong, readonly) UIImageView *cardView; + +@end + +#endif diff --git a/CardIO/CardIOVideoFrame.h b/CardIO/CardIOVideoFrame.h new file mode 100644 index 0000000..4533609 --- /dev/null +++ b/CardIO/CardIOVideoFrame.h @@ -0,0 +1,70 @@ +// +// CardIOVideoFrame.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#if USE_CAMERA || SIMULATE_CAMERA + +#import +#import +#import "dmz.h" +#import "CardIODetectionMode.h" + +// Processor and container for a single frame captured from the camera. + +typedef enum { + FrameEncodingColorPNG = 1, + FrameEncodingGrayPNG = 2 +} FrameEncoding; + +@class CardIOIplImage; +@class CardIOCardScanner; +@class CardIOReadCardInfo; + +@interface CardIOVideoFrame : NSObject + +- (id)initWithSampleBuffer:(CMSampleBufferRef)sampleBuffer interfaceOrientation:(UIInterfaceOrientation)currentOrientation; + +- (void)process; +- (BOOL)foundAllEdges; +- (uint)numEdgesFound; +- (NSData *)encodedImageUsingEncoding:(FrameEncoding)encoding; +- (UIImage *)imageWithGrayscale:(BOOL)grayscale; ++ (NSString *)filenameForImageEncodedUsingEncoding:(FrameEncoding)encoding; + +@property(nonatomic, assign, readwrite) float focusScore; +@property(nonatomic, assign, readwrite) BOOL focusOk; +@property(nonatomic, assign, readwrite) BOOL focusSucks; +@property(nonatomic, assign, readwrite) float brightnessScore; +@property(nonatomic, assign, readwrite) BOOL brightnessLow; +@property(nonatomic, assign, readwrite) BOOL brightnessHigh; +@property(nonatomic, assign, readwrite) BOOL foundTopEdge; +@property(nonatomic, assign, readwrite) BOOL foundBottomEdge; +@property(nonatomic, assign, readwrite) BOOL foundLeftEdge; +@property(nonatomic, assign, readwrite) BOOL foundRightEdge; +@property(nonatomic, assign, readwrite) BOOL flipped; +@property(nonatomic, assign, readwrite) BOOL scanExpiry; +@property(nonatomic, assign, readwrite) NSInteger isoSpeed; +@property(nonatomic, assign, readwrite) float shutterSpeed; +@property(nonatomic, strong, readwrite) CardIOIplImage *ySample; +@property(nonatomic, strong, readwrite) CardIOIplImage *cbSample; +@property(nonatomic, strong, readwrite) CardIOIplImage *crSample; +@property(nonatomic, strong, readwrite) CardIOIplImage *cardY; +@property(nonatomic, strong, readwrite) CardIOIplImage *cardCb; +@property(nonatomic, strong, readwrite) CardIOIplImage *cardCr; +@property(nonatomic, strong, readwrite) CardIOCardScanner *scanner; +@property(nonatomic, strong, readwrite) CardIOReadCardInfo *cardInfo; // Will be nil unless frame processing completes with a successful scan +@property(assign) dmz_context *dmz; +@property(nonatomic, assign, readwrite) BOOL calculateBrightness; +@property(nonatomic, assign, readwrite) BOOL torchIsOn; + +@property(nonatomic, assign, readwrite) CardIODetectionMode detectionMode; + +#if CARDIO_DEBUG +@property(nonatomic, strong, readwrite) NSString *debugString; +@property(nonatomic, strong, readwrite) UIImage *debugCardImage; +#endif + +@end + +#endif diff --git a/CardIO/CardIOVideoStream.h b/CardIO/CardIOVideoStream.h new file mode 100644 index 0000000..7a51c74 --- /dev/null +++ b/CardIO/CardIOVideoStream.h @@ -0,0 +1,56 @@ +// +// CardIOVideoStream.h +// See the file "LICENSE.md" for the full license governing this code. +// + +// Handles a video stream, including setup and teardown, and dispatching frames to be processed. + +#if USE_CAMERA || SIMULATE_CAMERA + +#import +#import "CardIOVideoStreamDelegate.h" +#import +#import "dmz.h" + +#define LOG_FPS 1 // for performance tuning/testing + +@class CardIOCardScanner; +@class CardIOConfig; + +@interface CardIOVideoStream : NSObject { +@private +#if USE_CAMERA + dmz_context *dmz; +#endif +} +- (void)willAppear; +- (void)willDisappear; + +- (BOOL)hasTorch; +- (BOOL)canSetTorchLevel; +- (BOOL)torchIsOn; +- (BOOL)setTorchOn:(BOOL)torchShouldBeOn; // returns success value +- (BOOL)hasAutofocus; + +- (void)refocus; + +- (void)startSession; +- (void)stopSession; + +#if SIMULATE_CAMERA +- (void)considerItScanned; +#endif + +@property(nonatomic, strong, readwrite) CardIOConfig *config; +@property(nonatomic, assign, readonly) BOOL running; +@property(nonatomic, weak, readwrite) id delegate; +#if SIMULATE_CAMERA +@property(nonatomic, strong, readonly) CALayer *previewLayer; +#else +@property(nonatomic, strong, readonly) AVCaptureVideoPreviewLayer *previewLayer; +#endif +@property(nonatomic, strong, readwrite) CardIOCardScanner *scanner; + +@end + +#endif //USE_CAMERA || SIMULATE_CAMERA diff --git a/CardIO/CardIOVideoStreamDelegate.h b/CardIO/CardIOVideoStreamDelegate.h new file mode 100644 index 0000000..6d03285 --- /dev/null +++ b/CardIO/CardIOVideoStreamDelegate.h @@ -0,0 +1,20 @@ +// +// CardIOVideoStreamDelegate.h +// See the file "LICENSE.md" for the full license governing this code. +// + +@class CardIOVideoFrame; +@class CardIOVideoStream; + +@protocol CardIOVideoStreamDelegate + +@required + +- (void)videoStream:(CardIOVideoStream *)stream didProcessFrame:(CardIOVideoFrame *)processedFrame; + +@optional + +- (BOOL)isSupportedOverlayOrientation:(UIInterfaceOrientation)orientation; +- (UIInterfaceOrientation)defaultSupportedOverlayOrientation; + +@end diff --git a/CardIO/CardIOViewContinuation.h b/CardIO/CardIOViewContinuation.h new file mode 100644 index 0000000..91ecbed --- /dev/null +++ b/CardIO/CardIOViewContinuation.h @@ -0,0 +1,16 @@ +// +// CardIOViewContinuation.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import + +@class CardIOCardScanner; +@class CardIOTransitionView; + +@interface CardIOView (continued) + +@property(nonatomic, strong, readonly) CardIOCardScanner *scanner; +@property(nonatomic, strong, readonly) CardIOTransitionView *transitionView; + +@end diff --git a/CardIO/CardIOViewController.h b/CardIO/CardIOViewController.h new file mode 100644 index 0000000..a6d8444 --- /dev/null +++ b/CardIO/CardIOViewController.h @@ -0,0 +1,22 @@ +// +// CardIOViewController.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#if USE_CAMERA || SIMULATE_CAMERA + +#import + +#import + +@class CardIOContext; + +@interface CardIOViewController : UIViewController + +- (id)init; + +@property(nonatomic, strong, readwrite) CardIOContext *context; + +@end + +#endif //USE_CAMERA || SIMULATE_CAMERA diff --git a/CardIO/NSObject+CardioCategoryTest.h b/CardIO/NSObject+CardioCategoryTest.h new file mode 100644 index 0000000..5ae3840 --- /dev/null +++ b/CardIO/NSObject+CardioCategoryTest.h @@ -0,0 +1,15 @@ +// +// NSObject+CardioCategoryTest.h +// See the file "LICENSE.md" for the full license governing this code. +// + +// This is a dummy category used to test whether developers have +// added -ObjC to their linker flags. + +#import + +@interface NSObject (PPZebraCategoryTest) + ++ (BOOL)testForObjCLinkerFlag; + +@end diff --git a/CardIO/RootViewController.h b/CardIO/RootViewController.h new file mode 100644 index 0000000..6925d20 --- /dev/null +++ b/CardIO/RootViewController.h @@ -0,0 +1,19 @@ +// +// RootViewController.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import +#import "CardIOPaymentViewControllerDelegate.h" +#import "CardIOViewDelegate.h" + +@interface RootViewController : UIViewController + +- (IBAction)scan; +- (IBAction)scanPicoPika; + +#if CARDIO_DEBUG +- (IBAction)doI18n; +#endif + +@end diff --git a/CardIO/UIImage+ImageEffects.h b/CardIO/UIImage+ImageEffects.h new file mode 100644 index 0000000..5e1b108 --- /dev/null +++ b/CardIO/UIImage+ImageEffects.h @@ -0,0 +1,107 @@ +/* + File: UIImage+ImageEffects.h + Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur. + Version: 1.0 + + Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple + Inc. ("Apple") in consideration of your agreement to the following + terms, and your use, installation, modification or redistribution of + this Apple software constitutes acceptance of these terms. If you do + not agree with these terms, please do not use, install, modify or + redistribute this Apple software. + + In consideration of your agreement to abide by the following terms, and + subject to these terms, Apple grants you a personal, non-exclusive + license, under Apple's copyrights in this original Apple software (the + "Apple Software"), to use, reproduce, modify and redistribute the Apple + Software, with or without modifications, in source and/or binary forms; + provided that if you redistribute the Apple Software in its entirety and + without modifications, you must retain this notice and the following + text and disclaimers in all such redistributions of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. may + be used to endorse or promote products derived from the Apple Software + without specific prior written permission from Apple. Except as + expressly stated in this notice, no other rights or licenses, express or + implied, are granted by Apple herein, including but not limited to any + patent rights that may be infringed by your derivative works or by other + works in which the Apple Software may be incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE + MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION + THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND + OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, + MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED + AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), + STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + Copyright (C) 2013 Apple Inc. All Rights Reserved. + + + Copyright © 2013 Apple Inc. All rights reserved. + WWDC 2013 License + + NOTE: This Apple Software was supplied by Apple as part of a WWDC 2013 + Session. Please refer to the applicable WWDC 2013 Session for further + information. + + IMPORTANT: This Apple software is supplied to you by Apple Inc. + ("Apple") in consideration of your agreement to the following terms, and + your use, installation, modification or redistribution of this Apple + software constitutes acceptance of these terms. If you do not agree with + these terms, please do not use, install, modify or redistribute this + Apple software. + + In consideration of your agreement to abide by the following terms, and + subject to these terms, Apple grants you a non-exclusive license, under + Apple's copyrights in this original Apple software (the "Apple + Software"), to use, reproduce, modify and redistribute the Apple + Software, with or without modifications, in source and/or binary forms; + provided that if you redistribute the Apple Software in its entirety and + without modifications, you must retain this notice and the following + text and disclaimers in all such redistributions of the Apple Software. + Neither the name, trademarks, service marks or logos of Apple Inc. may + be used to endorse or promote products derived from the Apple Software + without specific prior written permission from Apple. Except as + expressly stated in this notice, no other rights or licenses, express or + implied, are granted by Apple herein, including but not limited to any + patent rights that may be infringed by your derivative works or by other + works in which the Apple Software may be incorporated. + + The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES + NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE + IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND + OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. + + IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, + MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED + AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), + STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + + EA1002 + 5/3/2013 + */ + +#import + +@interface UIImage (ImageEffects) + +- (UIImage *)applyLightEffect; +- (UIImage *)applyExtraLightEffect; +- (UIImage *)applyDarkEffect; +- (UIImage *)applyTintEffectWithColor:(UIColor *)tintColor; + +- (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage; + +@end diff --git a/CardIO/iccAppDelegate.h b/CardIO/iccAppDelegate.h new file mode 100644 index 0000000..82f9220 --- /dev/null +++ b/CardIO/iccAppDelegate.h @@ -0,0 +1,13 @@ +// +// iccAppDelegate.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import + +@interface iccAppDelegate : NSObject + +@property (nonatomic, strong) IBOutlet UIWindow *window; + +@end + diff --git a/CardIO/iccChoicesSelectViewController.h b/CardIO/iccChoicesSelectViewController.h new file mode 100644 index 0000000..29038c0 --- /dev/null +++ b/CardIO/iccChoicesSelectViewController.h @@ -0,0 +1,13 @@ +// +// iccChoicesSelectViewController.h +// See the file "LICENSE.md" for the full license governing this code. +// + +#import + +typedef void(^PPChoiceSelected)(NSString* selection); + +@interface iccChoicesSelectViewController : UITableViewController + +- (instancetype)initWithTitle:(NSString *)title choices:(NSArray *)choices currentSelection:(NSString *)currentSelection completion:(PPChoiceSelected)completed; +@end