From 982b3d6eb0398108f52bbd9aadb01ae849ec97dc Mon Sep 17 00:00:00 2001 From: chrislaganiere Date: Fri, 4 Sep 2015 14:27:14 -0400 Subject: [PATCH 01/26] set up cocoapods --- Ryff.xcodeproj/project.pbxproj | 385 ++--- Ryff/Data/SSKeychain/SSKeychain.h | 161 --- Ryff/Data/SSKeychain/SSKeychain.m | 94 -- Ryff/Data/SSKeychain/SSKeychainQuery.h | 133 -- Ryff/Data/SSKeychain/SSKeychainQuery.m | 282 ---- .../SSKeychain/en.lproj/SSKeychain.strings | Bin 1576 -> 0 bytes .../AFNetworking/AFHTTPRequestOperation.h | 67 - .../AFNetworking/AFHTTPRequestOperation.m | 206 --- .../AFHTTPRequestOperationManager.h | 308 ---- .../AFHTTPRequestOperationManager.m | 253 ---- .../AFNetworking/AFHTTPSessionManager.h | 238 --- .../AFNetworking/AFHTTPSessionManager.m | 339 ----- .../AFNetworkReachabilityManager.h | 199 --- .../AFNetworkReachabilityManager.m | 253 ---- Ryff/Frameworks/AFNetworking/AFNetworking.h | 44 - .../AFNetworking/AFSecurityPolicy.h | 143 -- .../AFNetworking/AFSecurityPolicy.m | 320 ---- .../AFNetworking/AFURLConnectionOperation.h | 328 ----- .../AFNetworking/AFURLConnectionOperation.m | 789 ---------- .../AFNetworking/AFURLRequestSerialization.h | 444 ------ .../AFNetworking/AFURLRequestSerialization.m | 1281 ----------------- .../AFNetworking/AFURLResponseSerialization.h | 294 ---- .../AFNetworking/AFURLResponseSerialization.m | 779 ---------- .../AFNetworking/AFURLSessionManager.h | 529 ------- .../AFNetworking/AFURLSessionManager.m | 1005 ------------- .../CHTCollectionViewWaterfallLayout.h | 282 ---- .../CHTCollectionViewWaterfallLayout.m | 487 ------- .../SDWebImage/MKAnnotationView+WebCache.h | 124 -- .../SDWebImage/MKAnnotationView+WebCache.m | 126 -- .../SDWebImage/NSData+ImageContentType.h | 26 - .../SDWebImage/NSData+ImageContentType.m | 49 - Ryff/Frameworks/SDWebImage/SDImageCache.h | 241 ---- Ryff/Frameworks/SDWebImage/SDImageCache.m | 534 ------- Ryff/Frameworks/SDWebImage/SDWebImageCompat.h | 70 - Ryff/Frameworks/SDWebImage/SDWebImageCompat.m | 45 - .../Frameworks/SDWebImage/SDWebImageDecoder.h | 18 - .../Frameworks/SDWebImage/SDWebImageDecoder.m | 72 - .../SDWebImage/SDWebImageDownloader.h | 173 --- .../SDWebImage/SDWebImageDownloader.m | 225 --- .../SDWebImageDownloaderOperation.h | 60 - .../SDWebImageDownloaderOperation.m | 414 ------ .../Frameworks/SDWebImage/SDWebImageManager.h | 292 ---- .../Frameworks/SDWebImage/SDWebImageManager.m | 346 ----- .../SDWebImage/SDWebImageOperation.h | 15 - .../SDWebImage/SDWebImagePrefetcher.h | 98 -- .../SDWebImage/SDWebImagePrefetcher.m | 138 -- .../Frameworks/SDWebImage/UIButton+WebCache.h | 229 --- .../Frameworks/SDWebImage/UIButton+WebCache.m | 260 ---- Ryff/Frameworks/SDWebImage/UIImage+GIF.h | 19 - Ryff/Frameworks/SDWebImage/UIImage+GIF.m | 158 -- .../SDWebImage/UIImage+MultiFormat.h | 15 - .../SDWebImage/UIImage+MultiFormat.m | 114 -- Ryff/Frameworks/SDWebImage/UIImage+WebP.h | 26 - Ryff/Frameworks/SDWebImage/UIImage+WebP.m | 68 - .../UIImageView+HighlightedWebCache.h | 100 -- .../UIImageView+HighlightedWebCache.m | 107 -- .../SDWebImage/UIImageView+WebCache.h | 201 --- .../SDWebImage/UIImageView+WebCache.m | 195 --- .../SDWebImage/UIView+WebCacheOperation.h | 36 - .../SDWebImage/UIView+WebCacheOperation.m | 55 - .../AFNetworkActivityIndicatorManager.h | 76 - .../AFNetworkActivityIndicatorManager.m | 171 --- .../UIActivityIndicatorView+AFNetworking.h | 64 - .../UIActivityIndicatorView+AFNetworking.m | 97 -- .../UIAlertView+AFNetworking.h | 96 -- .../UIAlertView+AFNetworking.m | 111 -- .../UIButton+AFNetworking.h | 146 -- .../UIButton+AFNetworking.m | 185 --- .../UIImageView+AFNetworking.h | 147 -- .../UIImageView+AFNetworking.m | 231 --- .../UIKit+AFNetworking/UIKit+AFNetworking.h | 38 - .../UIProgressView+AFNetworking.h | 88 -- .../UIProgressView+AFNetworking.m | 183 --- .../UIRefreshControl+AFNetworking.h | 64 - .../UIRefreshControl+AFNetworking.m | 95 -- .../UIWebView+AFNetworking.h | 83 -- .../UIWebView+AFNetworking.m | 151 -- Ryff/Ryff-Prefix.pch | 4 +- .../MBProgressHUD/MBProgressHUD-Prefix.pch | 15 - Ryff/UI/Custom/MBProgressHUD/MBProgressHUD.h | 515 ------- Ryff/UI/Custom/MBProgressHUD/MBProgressHUD.m | 1024 ------------- 81 files changed, 94 insertions(+), 17782 deletions(-) delete mode 100755 Ryff/Data/SSKeychain/SSKeychain.h delete mode 100755 Ryff/Data/SSKeychain/SSKeychain.m delete mode 100755 Ryff/Data/SSKeychain/SSKeychainQuery.h delete mode 100755 Ryff/Data/SSKeychain/SSKeychainQuery.m delete mode 100755 Ryff/Data/SSKeychain/en.lproj/SSKeychain.strings delete mode 100755 Ryff/Frameworks/AFNetworking/AFHTTPRequestOperation.h delete mode 100755 Ryff/Frameworks/AFNetworking/AFHTTPRequestOperation.m delete mode 100755 Ryff/Frameworks/AFNetworking/AFHTTPRequestOperationManager.h delete mode 100755 Ryff/Frameworks/AFNetworking/AFHTTPRequestOperationManager.m delete mode 100755 Ryff/Frameworks/AFNetworking/AFHTTPSessionManager.h delete mode 100755 Ryff/Frameworks/AFNetworking/AFHTTPSessionManager.m delete mode 100755 Ryff/Frameworks/AFNetworking/AFNetworkReachabilityManager.h delete mode 100755 Ryff/Frameworks/AFNetworking/AFNetworkReachabilityManager.m delete mode 100755 Ryff/Frameworks/AFNetworking/AFNetworking.h delete mode 100755 Ryff/Frameworks/AFNetworking/AFSecurityPolicy.h delete mode 100755 Ryff/Frameworks/AFNetworking/AFSecurityPolicy.m delete mode 100755 Ryff/Frameworks/AFNetworking/AFURLConnectionOperation.h delete mode 100755 Ryff/Frameworks/AFNetworking/AFURLConnectionOperation.m delete mode 100755 Ryff/Frameworks/AFNetworking/AFURLRequestSerialization.h delete mode 100755 Ryff/Frameworks/AFNetworking/AFURLRequestSerialization.m delete mode 100755 Ryff/Frameworks/AFNetworking/AFURLResponseSerialization.h delete mode 100755 Ryff/Frameworks/AFNetworking/AFURLResponseSerialization.m delete mode 100755 Ryff/Frameworks/AFNetworking/AFURLSessionManager.h delete mode 100755 Ryff/Frameworks/AFNetworking/AFURLSessionManager.m delete mode 100755 Ryff/Frameworks/CHTCollectionViewWaterfallLayout/CHTCollectionViewWaterfallLayout.h delete mode 100755 Ryff/Frameworks/CHTCollectionViewWaterfallLayout/CHTCollectionViewWaterfallLayout.m delete mode 100755 Ryff/Frameworks/SDWebImage/MKAnnotationView+WebCache.h delete mode 100755 Ryff/Frameworks/SDWebImage/MKAnnotationView+WebCache.m delete mode 100755 Ryff/Frameworks/SDWebImage/NSData+ImageContentType.h delete mode 100755 Ryff/Frameworks/SDWebImage/NSData+ImageContentType.m delete mode 100755 Ryff/Frameworks/SDWebImage/SDImageCache.h delete mode 100755 Ryff/Frameworks/SDWebImage/SDImageCache.m delete mode 100755 Ryff/Frameworks/SDWebImage/SDWebImageCompat.h delete mode 100755 Ryff/Frameworks/SDWebImage/SDWebImageCompat.m delete mode 100755 Ryff/Frameworks/SDWebImage/SDWebImageDecoder.h delete mode 100755 Ryff/Frameworks/SDWebImage/SDWebImageDecoder.m delete mode 100755 Ryff/Frameworks/SDWebImage/SDWebImageDownloader.h delete mode 100755 Ryff/Frameworks/SDWebImage/SDWebImageDownloader.m delete mode 100755 Ryff/Frameworks/SDWebImage/SDWebImageDownloaderOperation.h delete mode 100755 Ryff/Frameworks/SDWebImage/SDWebImageDownloaderOperation.m delete mode 100755 Ryff/Frameworks/SDWebImage/SDWebImageManager.h delete mode 100755 Ryff/Frameworks/SDWebImage/SDWebImageManager.m delete mode 100755 Ryff/Frameworks/SDWebImage/SDWebImageOperation.h delete mode 100755 Ryff/Frameworks/SDWebImage/SDWebImagePrefetcher.h delete mode 100755 Ryff/Frameworks/SDWebImage/SDWebImagePrefetcher.m delete mode 100755 Ryff/Frameworks/SDWebImage/UIButton+WebCache.h delete mode 100755 Ryff/Frameworks/SDWebImage/UIButton+WebCache.m delete mode 100755 Ryff/Frameworks/SDWebImage/UIImage+GIF.h delete mode 100755 Ryff/Frameworks/SDWebImage/UIImage+GIF.m delete mode 100755 Ryff/Frameworks/SDWebImage/UIImage+MultiFormat.h delete mode 100755 Ryff/Frameworks/SDWebImage/UIImage+MultiFormat.m delete mode 100755 Ryff/Frameworks/SDWebImage/UIImage+WebP.h delete mode 100755 Ryff/Frameworks/SDWebImage/UIImage+WebP.m delete mode 100755 Ryff/Frameworks/SDWebImage/UIImageView+HighlightedWebCache.h delete mode 100755 Ryff/Frameworks/SDWebImage/UIImageView+HighlightedWebCache.m delete mode 100755 Ryff/Frameworks/SDWebImage/UIImageView+WebCache.h delete mode 100755 Ryff/Frameworks/SDWebImage/UIImageView+WebCache.m delete mode 100755 Ryff/Frameworks/SDWebImage/UIView+WebCacheOperation.h delete mode 100755 Ryff/Frameworks/SDWebImage/UIView+WebCacheOperation.m delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/UIAlertView+AFNetworking.h delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/UIAlertView+AFNetworking.m delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/UIButton+AFNetworking.h delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/UIButton+AFNetworking.m delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/UIImageView+AFNetworking.h delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/UIImageView+AFNetworking.m delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/UIKit+AFNetworking.h delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/UIProgressView+AFNetworking.h delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/UIProgressView+AFNetworking.m delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/UIWebView+AFNetworking.h delete mode 100755 Ryff/Frameworks/UIKit+AFNetworking/UIWebView+AFNetworking.m delete mode 100755 Ryff/UI/Custom/MBProgressHUD/MBProgressHUD-Prefix.pch delete mode 100755 Ryff/UI/Custom/MBProgressHUD/MBProgressHUD.h delete mode 100755 Ryff/UI/Custom/MBProgressHUD/MBProgressHUD.m diff --git a/Ryff.xcodeproj/project.pbxproj b/Ryff.xcodeproj/project.pbxproj index 4994b84..ea1c91a 100644 --- a/Ryff.xcodeproj/project.pbxproj +++ b/Ryff.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 61B262729FECCE862CBC2CDE /* libPods-Ryff.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 610389EFACE91AC8266D46F6 /* libPods-Ryff.a */; }; 830029B91B7FB2B300666D93 /* RYRiffAudioNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 830029B81B7FB2B300666D93 /* RYRiffAudioNode.m */; }; 830029BB1B7FD17C00666D93 /* RYRiffCreateCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 830029BA1B7FD17C00666D93 /* RYRiffCreateCollectionViewController.swift */; }; 830029BD1B7FD3F900666D93 /* RYRiffCreateNodeCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 830029BC1B7FD3F900666D93 /* RYRiffCreateNodeCollectionViewCell.swift */; }; @@ -21,10 +22,6 @@ 83082FE819B55DF4000AFACB /* RYTagFeedViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83082FE719B55DF4000AFACB /* RYTagFeedViewController.m */; }; 83082FEB19B5652D000AFACB /* RYSearchTypeTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 83082FEA19B5652D000AFACB /* RYSearchTypeTableViewCell.m */; }; 8309553819CA5EAC000A41B3 /* RYRiffDetailsCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8309553719CA5EAC000A41B3 /* RYRiffDetailsCell.xib */; }; - 830BBCB318F9F54900A9C53F /* SSKeychain.strings in Resources */ = {isa = PBXBuildFile; fileRef = 830BBCAD18F9F54900A9C53F /* SSKeychain.strings */; }; - 830BBCB418F9F54900A9C53F /* SSKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 830BBCB018F9F54900A9C53F /* SSKeychain.m */; }; - 830BBCB518F9F54900A9C53F /* SSKeychainQuery.m in Sources */ = {isa = PBXBuildFile; fileRef = 830BBCB218F9F54900A9C53F /* SSKeychainQuery.m */; }; - 830BBCBA18FA055900A9C53F /* MBProgressHUD.m in Sources */ = {isa = PBXBuildFile; fileRef = 830BBCB918FA055900A9C53F /* MBProgressHUD.m */; }; 830BBCC318FA081600A9C53F /* checkmark.png in Resources */ = {isa = PBXBuildFile; fileRef = 830BBCC118FA081600A9C53F /* checkmark.png */; }; 830BBCC418FA081600A9C53F /* checkmark@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 830BBCC218FA081600A9C53F /* checkmark@2x.png */; }; 830BBCC818FA0A5800A9C53F /* RYLocationServices.m in Sources */ = {isa = PBXBuildFile; fileRef = 830BBCC718FA0A5800A9C53F /* RYLocationServices.m */; }; @@ -115,7 +112,6 @@ 837BA0E319CCAED8002AA13E /* RYUserListCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 837BA0E219CCAED8002AA13E /* RYUserListCollectionViewCell.m */; }; 837BA0F719CCC619002AA13E /* BNRDynamicTypeManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 837BA0F219CCC619002AA13E /* BNRDynamicTypeManager.m */; }; 837BA0FA19CCC7C2002AA13E /* UIFontDescriptor+RYCustomFont.m in Sources */ = {isa = PBXBuildFile; fileRef = 837BA0F919CCC7C2002AA13E /* UIFontDescriptor+RYCustomFont.m */; }; - 837BA10219CCFA69002AA13E /* CHTCollectionViewWaterfallLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 837BA10119CCFA69002AA13E /* CHTCollectionViewWaterfallLayout.m */; }; 837BA10A19CD12A8002AA13E /* UIViewController+RYSocialTransitions.m in Sources */ = {isa = PBXBuildFile; fileRef = 837BA10919CD12A8002AA13E /* UIViewController+RYSocialTransitions.m */; }; 837C98D819A82411002A9B34 /* RYUserListViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 837C98D719A82411002A9B34 /* RYUserListViewController.m */; }; 837CCD1719A3E12D00F95FCA /* RYTag.m in Sources */ = {isa = PBXBuildFile; fileRef = 837CCD1619A3E12D00F95FCA /* RYTag.m */; }; @@ -126,22 +122,6 @@ 838E5F4419E220510005CB34 /* RiffCreate.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 83B73E5419E0F87E001C746E /* RiffCreate.storyboard */; }; 8397133F1936DD1100913996 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8397133E1936DD1100913996 /* Main.storyboard */; }; 8398EC8419A012D800130EFC /* RYNewsfeedContainerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8398EC8319A012D800130EFC /* RYNewsfeedContainerViewController.m */; }; - 83BF315919C9FFC200F5BE48 /* MKAnnotationView+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BF313919C9FFC200F5BE48 /* MKAnnotationView+WebCache.m */; }; - 83BF315A19C9FFC200F5BE48 /* NSData+ImageContentType.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BF313B19C9FFC200F5BE48 /* NSData+ImageContentType.m */; }; - 83BF315B19C9FFC200F5BE48 /* SDImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BF313D19C9FFC200F5BE48 /* SDImageCache.m */; }; - 83BF315C19C9FFC200F5BE48 /* SDWebImageCompat.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BF313F19C9FFC200F5BE48 /* SDWebImageCompat.m */; }; - 83BF315D19C9FFC200F5BE48 /* SDWebImageDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BF314119C9FFC200F5BE48 /* SDWebImageDecoder.m */; }; - 83BF315E19C9FFC200F5BE48 /* SDWebImageDownloader.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BF314319C9FFC200F5BE48 /* SDWebImageDownloader.m */; }; - 83BF315F19C9FFC200F5BE48 /* SDWebImageDownloaderOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BF314519C9FFC200F5BE48 /* SDWebImageDownloaderOperation.m */; }; - 83BF316019C9FFC200F5BE48 /* SDWebImageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BF314719C9FFC200F5BE48 /* SDWebImageManager.m */; }; - 83BF316119C9FFC200F5BE48 /* SDWebImagePrefetcher.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BF314A19C9FFC200F5BE48 /* SDWebImagePrefetcher.m */; }; - 83BF316219C9FFC200F5BE48 /* UIButton+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BF314C19C9FFC200F5BE48 /* UIButton+WebCache.m */; }; - 83BF316319C9FFC200F5BE48 /* UIImage+GIF.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BF314E19C9FFC200F5BE48 /* UIImage+GIF.m */; }; - 83BF316419C9FFC200F5BE48 /* UIImage+MultiFormat.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BF315019C9FFC200F5BE48 /* UIImage+MultiFormat.m */; }; - 83BF316519C9FFC200F5BE48 /* UIImage+WebP.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BF315219C9FFC200F5BE48 /* UIImage+WebP.m */; }; - 83BF316619C9FFC200F5BE48 /* UIImageView+HighlightedWebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BF315419C9FFC200F5BE48 /* UIImageView+HighlightedWebCache.m */; }; - 83BF316719C9FFC200F5BE48 /* UIImageView+WebCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BF315619C9FFC200F5BE48 /* UIImageView+WebCache.m */; }; - 83BF316819C9FFC200F5BE48 /* UIView+WebCacheOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 83BF315819C9FFC200F5BE48 /* UIView+WebCacheOperation.m */; }; 83C354B319BBAD41000A5BD4 /* RYRiffStreamViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83C354B219BBAD41000A5BD4 /* RYRiffStreamViewController.m */; }; 83C354B919BC2AB3000A5BD4 /* availableStream.png in Resources */ = {isa = PBXBuildFile; fileRef = 83C354B719BC2AB3000A5BD4 /* availableStream.png */; }; 83C354BA19BC2AB3000A5BD4 /* availableStream@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 83C354B819BC2AB3000A5BD4 /* availableStream@2x.png */; }; @@ -210,23 +190,6 @@ 83CA122D19981070002610E8 /* RYAudioDeckViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CA122C19981070002610E8 /* RYAudioDeckViewController.m */; }; 83CA123019981087002610E8 /* RYAudioDeckManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CA122F19981087002610E8 /* RYAudioDeckManager.m */; }; 83CA123319981702002610E8 /* RYAudioDeckTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CA123219981702002610E8 /* RYAudioDeckTableViewCell.m */; }; - 83CCC90E197EFCBF00FD1B4B /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC8EA197EFCBF00FD1B4B /* AFHTTPRequestOperation.m */; }; - 83CCC90F197EFCBF00FD1B4B /* AFHTTPRequestOperationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC8EC197EFCBF00FD1B4B /* AFHTTPRequestOperationManager.m */; }; - 83CCC910197EFCBF00FD1B4B /* AFHTTPSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC8EE197EFCBF00FD1B4B /* AFHTTPSessionManager.m */; }; - 83CCC911197EFCBF00FD1B4B /* AFNetworkReachabilityManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC8F1197EFCBF00FD1B4B /* AFNetworkReachabilityManager.m */; }; - 83CCC912197EFCBF00FD1B4B /* AFSecurityPolicy.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC8F3197EFCBF00FD1B4B /* AFSecurityPolicy.m */; }; - 83CCC913197EFCBF00FD1B4B /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC8F5197EFCBF00FD1B4B /* AFURLConnectionOperation.m */; }; - 83CCC914197EFCBF00FD1B4B /* AFURLRequestSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC8F7197EFCBF00FD1B4B /* AFURLRequestSerialization.m */; }; - 83CCC915197EFCBF00FD1B4B /* AFURLResponseSerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC8F9197EFCBF00FD1B4B /* AFURLResponseSerialization.m */; }; - 83CCC916197EFCBF00FD1B4B /* AFURLSessionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC8FB197EFCBF00FD1B4B /* AFURLSessionManager.m */; }; - 83CCC917197EFCBF00FD1B4B /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC8FE197EFCBF00FD1B4B /* AFNetworkActivityIndicatorManager.m */; }; - 83CCC918197EFCBF00FD1B4B /* UIActivityIndicatorView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC900197EFCBF00FD1B4B /* UIActivityIndicatorView+AFNetworking.m */; }; - 83CCC919197EFCBF00FD1B4B /* UIAlertView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC902197EFCBF00FD1B4B /* UIAlertView+AFNetworking.m */; }; - 83CCC91A197EFCBF00FD1B4B /* UIButton+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC904197EFCBF00FD1B4B /* UIButton+AFNetworking.m */; }; - 83CCC91B197EFCBF00FD1B4B /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC906197EFCBF00FD1B4B /* UIImageView+AFNetworking.m */; }; - 83CCC91C197EFCBF00FD1B4B /* UIProgressView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC909197EFCBF00FD1B4B /* UIProgressView+AFNetworking.m */; }; - 83CCC91D197EFCBF00FD1B4B /* UIRefreshControl+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC90B197EFCBF00FD1B4B /* UIRefreshControl+AFNetworking.m */; }; - 83CCC91E197EFCBF00FD1B4B /* UIWebView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 83CCC90D197EFCBF00FD1B4B /* UIWebView+AFNetworking.m */; }; 83DBCA7B18F99E3F00262496 /* RYRiffStreamingCoreViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83DBCA7A18F99E3F00262496 /* RYRiffStreamingCoreViewController.m */; }; 83DC3B7819BD0EC00036AD2A /* RYRefreshControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 83DC3B7719BD0EC00036AD2A /* RYRefreshControl.m */; }; 83E3017219C7BAEE0085F17F /* RYTagCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 83E3017119C7BAEE0085F17F /* RYTagCollectionViewCell.m */; }; @@ -279,6 +242,7 @@ 83FCD1B118F93F5500A493F0 /* user@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 83FCD1AE18F93F5500A493F0 /* user@2x.png */; }; 83FCD1B818F9405F00A493F0 /* RYCoreTabBarViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83FCD1B718F9405F00A493F0 /* RYCoreTabBarViewController.m */; }; 83FCD1BB18F9413400A493F0 /* RYPost.m in Sources */ = {isa = PBXBuildFile; fileRef = 83FCD1BA18F9413400A493F0 /* RYPost.m */; }; + 89AC917E84DC12FB55E0A66D /* libPods-RyffTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B8BF0F30F13E8E20F6D2D2C /* libPods-RyffTests.a */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -292,6 +256,11 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 0F068F340A8DD53B769F8B4B /* Pods-Ryff.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Ryff.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Ryff/Pods-Ryff.debug.xcconfig"; sourceTree = ""; }; + 5D10781F97C58C1D8BE87763 /* Pods-Ryff.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Ryff.release.xcconfig"; path = "Pods/Target Support Files/Pods-Ryff/Pods-Ryff.release.xcconfig"; sourceTree = ""; }; + 610389EFACE91AC8266D46F6 /* libPods-Ryff.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Ryff.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 6616A16D4F2C65AA11F6581D /* Pods-RyffTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RyffTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RyffTests/Pods-RyffTests.release.xcconfig"; sourceTree = ""; }; + 7FFE42F2F5730A2D8E9FEB19 /* Pods-RyffTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RyffTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RyffTests/Pods-RyffTests.debug.xcconfig"; sourceTree = ""; }; 830029B71B7FB2B300666D93 /* RYRiffAudioNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RYRiffAudioNode.h; sourceTree = ""; }; 830029B81B7FB2B300666D93 /* RYRiffAudioNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RYRiffAudioNode.m; sourceTree = ""; }; 830029BA1B7FD17C00666D93 /* RYRiffCreateCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RYRiffCreateCollectionViewController.swift; sourceTree = ""; }; @@ -311,14 +280,6 @@ 83082FE919B5652D000AFACB /* RYSearchTypeTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RYSearchTypeTableViewCell.h; sourceTree = ""; }; 83082FEA19B5652D000AFACB /* RYSearchTypeTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RYSearchTypeTableViewCell.m; sourceTree = ""; }; 8309553719CA5EAC000A41B3 /* RYRiffDetailsCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RYRiffDetailsCell.xib; sourceTree = ""; }; - 830BBCAE18F9F54900A9C53F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/SSKeychain.strings; sourceTree = ""; }; - 830BBCAF18F9F54900A9C53F /* SSKeychain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSKeychain.h; sourceTree = ""; }; - 830BBCB018F9F54900A9C53F /* SSKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSKeychain.m; sourceTree = ""; }; - 830BBCB118F9F54900A9C53F /* SSKeychainQuery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSKeychainQuery.h; sourceTree = ""; }; - 830BBCB218F9F54900A9C53F /* SSKeychainQuery.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSKeychainQuery.m; sourceTree = ""; }; - 830BBCB718FA055900A9C53F /* MBProgressHUD-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MBProgressHUD-Prefix.pch"; sourceTree = ""; }; - 830BBCB818FA055900A9C53F /* MBProgressHUD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBProgressHUD.h; sourceTree = ""; }; - 830BBCB918FA055900A9C53F /* MBProgressHUD.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MBProgressHUD.m; sourceTree = ""; }; 830BBCC118FA081600A9C53F /* checkmark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = checkmark.png; sourceTree = ""; }; 830BBCC218FA081600A9C53F /* checkmark@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "checkmark@2x.png"; sourceTree = ""; }; 830BBCC618FA0A5800A9C53F /* RYLocationServices.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RYLocationServices.h; sourceTree = ""; }; @@ -447,8 +408,6 @@ 837BA0F219CCC619002AA13E /* BNRDynamicTypeManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BNRDynamicTypeManager.m; sourceTree = ""; }; 837BA0F819CCC7C2002AA13E /* UIFontDescriptor+RYCustomFont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIFontDescriptor+RYCustomFont.h"; sourceTree = ""; }; 837BA0F919CCC7C2002AA13E /* UIFontDescriptor+RYCustomFont.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIFontDescriptor+RYCustomFont.m"; sourceTree = ""; }; - 837BA10019CCFA69002AA13E /* CHTCollectionViewWaterfallLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHTCollectionViewWaterfallLayout.h; sourceTree = ""; }; - 837BA10119CCFA69002AA13E /* CHTCollectionViewWaterfallLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CHTCollectionViewWaterfallLayout.m; sourceTree = ""; }; 837BA10819CD12A8002AA13E /* UIViewController+RYSocialTransitions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+RYSocialTransitions.h"; sourceTree = ""; }; 837BA10919CD12A8002AA13E /* UIViewController+RYSocialTransitions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+RYSocialTransitions.m"; sourceTree = ""; }; 837C98D619A82411002A9B34 /* RYUserListViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RYUserListViewController.h; sourceTree = ""; }; @@ -466,39 +425,6 @@ 8398EC8319A012D800130EFC /* RYNewsfeedContainerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RYNewsfeedContainerViewController.m; sourceTree = ""; }; 83B73E4D19DF526E001C746E /* Ryff-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "Ryff-Bridging-Header.h"; path = "UI/Profile/RiffEdit/RiffCreate/Ryff-Bridging-Header.h"; sourceTree = ""; }; 83B73E5419E0F87E001C746E /* RiffCreate.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = RiffCreate.storyboard; sourceTree = ""; }; - 83BF313819C9FFC200F5BE48 /* MKAnnotationView+WebCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MKAnnotationView+WebCache.h"; sourceTree = ""; }; - 83BF313919C9FFC200F5BE48 /* MKAnnotationView+WebCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MKAnnotationView+WebCache.m"; sourceTree = ""; }; - 83BF313A19C9FFC200F5BE48 /* NSData+ImageContentType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+ImageContentType.h"; sourceTree = ""; }; - 83BF313B19C9FFC200F5BE48 /* NSData+ImageContentType.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+ImageContentType.m"; sourceTree = ""; }; - 83BF313C19C9FFC200F5BE48 /* SDImageCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDImageCache.h; sourceTree = ""; }; - 83BF313D19C9FFC200F5BE48 /* SDImageCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDImageCache.m; sourceTree = ""; }; - 83BF313E19C9FFC200F5BE48 /* SDWebImageCompat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDWebImageCompat.h; sourceTree = ""; }; - 83BF313F19C9FFC200F5BE48 /* SDWebImageCompat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageCompat.m; sourceTree = ""; }; - 83BF314019C9FFC200F5BE48 /* SDWebImageDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDWebImageDecoder.h; sourceTree = ""; }; - 83BF314119C9FFC200F5BE48 /* SDWebImageDecoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageDecoder.m; sourceTree = ""; }; - 83BF314219C9FFC200F5BE48 /* SDWebImageDownloader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDWebImageDownloader.h; sourceTree = ""; }; - 83BF314319C9FFC200F5BE48 /* SDWebImageDownloader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageDownloader.m; sourceTree = ""; }; - 83BF314419C9FFC200F5BE48 /* SDWebImageDownloaderOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDWebImageDownloaderOperation.h; sourceTree = ""; }; - 83BF314519C9FFC200F5BE48 /* SDWebImageDownloaderOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageDownloaderOperation.m; sourceTree = ""; }; - 83BF314619C9FFC200F5BE48 /* SDWebImageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDWebImageManager.h; sourceTree = ""; }; - 83BF314719C9FFC200F5BE48 /* SDWebImageManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImageManager.m; sourceTree = ""; }; - 83BF314819C9FFC200F5BE48 /* SDWebImageOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDWebImageOperation.h; sourceTree = ""; }; - 83BF314919C9FFC200F5BE48 /* SDWebImagePrefetcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDWebImagePrefetcher.h; sourceTree = ""; }; - 83BF314A19C9FFC200F5BE48 /* SDWebImagePrefetcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDWebImagePrefetcher.m; sourceTree = ""; }; - 83BF314B19C9FFC200F5BE48 /* UIButton+WebCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIButton+WebCache.h"; sourceTree = ""; }; - 83BF314C19C9FFC200F5BE48 /* UIButton+WebCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIButton+WebCache.m"; sourceTree = ""; }; - 83BF314D19C9FFC200F5BE48 /* UIImage+GIF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+GIF.h"; sourceTree = ""; }; - 83BF314E19C9FFC200F5BE48 /* UIImage+GIF.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+GIF.m"; sourceTree = ""; }; - 83BF314F19C9FFC200F5BE48 /* UIImage+MultiFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+MultiFormat.h"; sourceTree = ""; }; - 83BF315019C9FFC200F5BE48 /* UIImage+MultiFormat.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+MultiFormat.m"; sourceTree = ""; }; - 83BF315119C9FFC200F5BE48 /* UIImage+WebP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+WebP.h"; sourceTree = ""; }; - 83BF315219C9FFC200F5BE48 /* UIImage+WebP.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+WebP.m"; sourceTree = ""; }; - 83BF315319C9FFC200F5BE48 /* UIImageView+HighlightedWebCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+HighlightedWebCache.h"; sourceTree = ""; }; - 83BF315419C9FFC200F5BE48 /* UIImageView+HighlightedWebCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+HighlightedWebCache.m"; sourceTree = ""; }; - 83BF315519C9FFC200F5BE48 /* UIImageView+WebCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+WebCache.h"; sourceTree = ""; }; - 83BF315619C9FFC200F5BE48 /* UIImageView+WebCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+WebCache.m"; sourceTree = ""; }; - 83BF315719C9FFC200F5BE48 /* UIView+WebCacheOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+WebCacheOperation.h"; sourceTree = ""; }; - 83BF315819C9FFC200F5BE48 /* UIView+WebCacheOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+WebCacheOperation.m"; sourceTree = ""; }; 83C354B119BBAD41000A5BD4 /* RYRiffStreamViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RYRiffStreamViewController.h; sourceTree = ""; }; 83C354B219BBAD41000A5BD4 /* RYRiffStreamViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RYRiffStreamViewController.m; sourceTree = ""; }; 83C354B719BC2AB3000A5BD4 /* availableStream.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = availableStream.png; sourceTree = ""; }; @@ -624,42 +550,6 @@ 83CA122F19981087002610E8 /* RYAudioDeckManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RYAudioDeckManager.m; sourceTree = ""; }; 83CA123119981702002610E8 /* RYAudioDeckTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RYAudioDeckTableViewCell.h; sourceTree = ""; }; 83CA123219981702002610E8 /* RYAudioDeckTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RYAudioDeckTableViewCell.m; sourceTree = ""; }; - 83CCC8E9197EFCBF00FD1B4B /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperation.h; sourceTree = ""; }; - 83CCC8EA197EFCBF00FD1B4B /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperation.m; sourceTree = ""; }; - 83CCC8EB197EFCBF00FD1B4B /* AFHTTPRequestOperationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperationManager.h; sourceTree = ""; }; - 83CCC8EC197EFCBF00FD1B4B /* AFHTTPRequestOperationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperationManager.m; sourceTree = ""; }; - 83CCC8ED197EFCBF00FD1B4B /* AFHTTPSessionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPSessionManager.h; sourceTree = ""; }; - 83CCC8EE197EFCBF00FD1B4B /* AFHTTPSessionManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPSessionManager.m; sourceTree = ""; }; - 83CCC8EF197EFCBF00FD1B4B /* AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworking.h; sourceTree = ""; }; - 83CCC8F0197EFCBF00FD1B4B /* AFNetworkReachabilityManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworkReachabilityManager.h; sourceTree = ""; }; - 83CCC8F1197EFCBF00FD1B4B /* AFNetworkReachabilityManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkReachabilityManager.m; sourceTree = ""; }; - 83CCC8F2197EFCBF00FD1B4B /* AFSecurityPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFSecurityPolicy.h; sourceTree = ""; }; - 83CCC8F3197EFCBF00FD1B4B /* AFSecurityPolicy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFSecurityPolicy.m; sourceTree = ""; }; - 83CCC8F4197EFCBF00FD1B4B /* AFURLConnectionOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLConnectionOperation.h; sourceTree = ""; }; - 83CCC8F5197EFCBF00FD1B4B /* AFURLConnectionOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLConnectionOperation.m; sourceTree = ""; }; - 83CCC8F6197EFCBF00FD1B4B /* AFURLRequestSerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLRequestSerialization.h; sourceTree = ""; }; - 83CCC8F7197EFCBF00FD1B4B /* AFURLRequestSerialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLRequestSerialization.m; sourceTree = ""; }; - 83CCC8F8197EFCBF00FD1B4B /* AFURLResponseSerialization.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLResponseSerialization.h; sourceTree = ""; }; - 83CCC8F9197EFCBF00FD1B4B /* AFURLResponseSerialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLResponseSerialization.m; sourceTree = ""; }; - 83CCC8FA197EFCBF00FD1B4B /* AFURLSessionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLSessionManager.h; sourceTree = ""; }; - 83CCC8FB197EFCBF00FD1B4B /* AFURLSessionManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLSessionManager.m; sourceTree = ""; }; - 83CCC8FD197EFCBF00FD1B4B /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworkActivityIndicatorManager.h; sourceTree = ""; }; - 83CCC8FE197EFCBF00FD1B4B /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkActivityIndicatorManager.m; sourceTree = ""; }; - 83CCC8FF197EFCBF00FD1B4B /* UIActivityIndicatorView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIActivityIndicatorView+AFNetworking.h"; sourceTree = ""; }; - 83CCC900197EFCBF00FD1B4B /* UIActivityIndicatorView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIActivityIndicatorView+AFNetworking.m"; sourceTree = ""; }; - 83CCC901197EFCBF00FD1B4B /* UIAlertView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIAlertView+AFNetworking.h"; sourceTree = ""; }; - 83CCC902197EFCBF00FD1B4B /* UIAlertView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIAlertView+AFNetworking.m"; sourceTree = ""; }; - 83CCC903197EFCBF00FD1B4B /* UIButton+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIButton+AFNetworking.h"; sourceTree = ""; }; - 83CCC904197EFCBF00FD1B4B /* UIButton+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIButton+AFNetworking.m"; sourceTree = ""; }; - 83CCC905197EFCBF00FD1B4B /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+AFNetworking.h"; sourceTree = ""; }; - 83CCC906197EFCBF00FD1B4B /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+AFNetworking.m"; sourceTree = ""; }; - 83CCC907197EFCBF00FD1B4B /* UIKit+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIKit+AFNetworking.h"; sourceTree = ""; }; - 83CCC908197EFCBF00FD1B4B /* UIProgressView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIProgressView+AFNetworking.h"; sourceTree = ""; }; - 83CCC909197EFCBF00FD1B4B /* UIProgressView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIProgressView+AFNetworking.m"; sourceTree = ""; }; - 83CCC90A197EFCBF00FD1B4B /* UIRefreshControl+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIRefreshControl+AFNetworking.h"; sourceTree = ""; }; - 83CCC90B197EFCBF00FD1B4B /* UIRefreshControl+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIRefreshControl+AFNetworking.m"; sourceTree = ""; }; - 83CCC90C197EFCBF00FD1B4B /* UIWebView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIWebView+AFNetworking.h"; sourceTree = ""; }; - 83CCC90D197EFCBF00FD1B4B /* UIWebView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIWebView+AFNetworking.m"; sourceTree = ""; }; 83DBCA7918F99E3F00262496 /* RYRiffStreamingCoreViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RYRiffStreamingCoreViewController.h; sourceTree = ""; }; 83DBCA7A18F99E3F00262496 /* RYRiffStreamingCoreViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RYRiffStreamingCoreViewController.m; sourceTree = ""; }; 83DC3B7619BD0EC00036AD2A /* RYRefreshControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RYRefreshControl.h; sourceTree = ""; }; @@ -728,6 +618,7 @@ 83FCD1B718F9405F00A493F0 /* RYCoreTabBarViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RYCoreTabBarViewController.m; sourceTree = ""; }; 83FCD1B918F9413400A493F0 /* RYPost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RYPost.h; path = ../../Newsfeed/RYPost.h; sourceTree = ""; }; 83FCD1BA18F9413400A493F0 /* RYPost.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RYPost.m; path = ../../Newsfeed/RYPost.m; sourceTree = ""; }; + 8B8BF0F30F13E8E20F6D2D2C /* libPods-RyffTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RyffTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -741,6 +632,7 @@ 835E1E0619D21A50007EBD74 /* libCrittercism_v4_3_7.a in Frameworks */, 83FCD14018F907C400A493F0 /* UIKit.framework in Frameworks */, 83FCD13C18F907C400A493F0 /* Foundation.framework in Frameworks */, + 61B262729FECCE862CBC2CDE /* libPods-Ryff.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -751,12 +643,24 @@ 83FCD15E18F907C400A493F0 /* XCTest.framework in Frameworks */, 83FCD16018F907C400A493F0 /* UIKit.framework in Frameworks */, 83FCD15F18F907C400A493F0 /* Foundation.framework in Frameworks */, + 89AC917E84DC12FB55E0A66D /* libPods-RyffTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 5BD8AE6B5B14CE56E937FC6A /* Pods */ = { + isa = PBXGroup; + children = ( + 0F068F340A8DD53B769F8B4B /* Pods-Ryff.debug.xcconfig */, + 5D10781F97C58C1D8BE87763 /* Pods-Ryff.release.xcconfig */, + 7FFE42F2F5730A2D8E9FEB19 /* Pods-RyffTests.debug.xcconfig */, + 6616A16D4F2C65AA11F6581D /* Pods-RyffTests.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; 830185F119009C2B00093EFA /* Login */ = { isa = PBXGroup; children = ( @@ -780,30 +684,6 @@ path = TagFeed; sourceTree = ""; }; - 830BBCAC18F9F54900A9C53F /* SSKeychain */ = { - isa = PBXGroup; - children = ( - 830BBCAD18F9F54900A9C53F /* SSKeychain.strings */, - 830BBCAF18F9F54900A9C53F /* SSKeychain.h */, - 830BBCB018F9F54900A9C53F /* SSKeychain.m */, - 830BBCB118F9F54900A9C53F /* SSKeychainQuery.h */, - 830BBCB218F9F54900A9C53F /* SSKeychainQuery.m */, - ); - name = SSKeychain; - path = ../Data/SSKeychain; - sourceTree = ""; - }; - 830BBCB618FA055900A9C53F /* MBProgressHUD */ = { - isa = PBXGroup; - children = ( - 830BBCB718FA055900A9C53F /* MBProgressHUD-Prefix.pch */, - 830BBCB818FA055900A9C53F /* MBProgressHUD.h */, - 830BBCB918FA055900A9C53F /* MBProgressHUD.m */, - ); - name = MBProgressHUD; - path = ../UI/Custom/MBProgressHUD; - sourceTree = ""; - }; 830BBCC518FA0A4500A9C53F /* Location */ = { isa = PBXGroup; children = ( @@ -960,16 +840,10 @@ 832B89F61B32367700881AD8 /* FDWaveformView */, 835E1DFF19D21A50007EBD74 /* CrittercismSDK */, 837BA0E619CCC619002AA13E /* BNRDynamicTypeManager */, - 83BF313719C9FFC200F5BE48 /* SDWebImage */, 8322309719B00D0200C60033 /* PXAlertView */, - 830BBCB618FA055900A9C53F /* MBProgressHUD */, 83CA118B1995CD23002610E8 /* FLEX */, 83EB8BA319959F5C0007837D /* DWTagList */, - 83CCC8E8197EFCBF00FD1B4B /* AFNetworking */, - 83CCC8FC197EFCBF00FD1B4B /* UIKit+AFNetworking */, 830BBCCF18FA142000A9C53F /* BlockAlert */, - 830BBCAC18F9F54900A9C53F /* SSKeychain */, - 837BA0FF19CCFA69002AA13E /* CHTCollectionViewWaterfallLayout */, ); name = Extras; path = Frameworks; @@ -1057,15 +931,6 @@ path = Core; sourceTree = ""; }; - 837BA0FF19CCFA69002AA13E /* CHTCollectionViewWaterfallLayout */ = { - isa = PBXGroup; - children = ( - 837BA10019CCFA69002AA13E /* CHTCollectionViewWaterfallLayout.h */, - 837BA10119CCFA69002AA13E /* CHTCollectionViewWaterfallLayout.m */, - ); - path = CHTCollectionViewWaterfallLayout; - sourceTree = ""; - }; 837C98D519A82403002A9B34 /* UserList */ = { isa = PBXGroup; children = ( @@ -1077,46 +942,6 @@ path = UserList; sourceTree = ""; }; - 83BF313719C9FFC200F5BE48 /* SDWebImage */ = { - isa = PBXGroup; - children = ( - 83BF313819C9FFC200F5BE48 /* MKAnnotationView+WebCache.h */, - 83BF313919C9FFC200F5BE48 /* MKAnnotationView+WebCache.m */, - 83BF313A19C9FFC200F5BE48 /* NSData+ImageContentType.h */, - 83BF313B19C9FFC200F5BE48 /* NSData+ImageContentType.m */, - 83BF313C19C9FFC200F5BE48 /* SDImageCache.h */, - 83BF313D19C9FFC200F5BE48 /* SDImageCache.m */, - 83BF313E19C9FFC200F5BE48 /* SDWebImageCompat.h */, - 83BF313F19C9FFC200F5BE48 /* SDWebImageCompat.m */, - 83BF314019C9FFC200F5BE48 /* SDWebImageDecoder.h */, - 83BF314119C9FFC200F5BE48 /* SDWebImageDecoder.m */, - 83BF314219C9FFC200F5BE48 /* SDWebImageDownloader.h */, - 83BF314319C9FFC200F5BE48 /* SDWebImageDownloader.m */, - 83BF314419C9FFC200F5BE48 /* SDWebImageDownloaderOperation.h */, - 83BF314519C9FFC200F5BE48 /* SDWebImageDownloaderOperation.m */, - 83BF314619C9FFC200F5BE48 /* SDWebImageManager.h */, - 83BF314719C9FFC200F5BE48 /* SDWebImageManager.m */, - 83BF314819C9FFC200F5BE48 /* SDWebImageOperation.h */, - 83BF314919C9FFC200F5BE48 /* SDWebImagePrefetcher.h */, - 83BF314A19C9FFC200F5BE48 /* SDWebImagePrefetcher.m */, - 83BF314B19C9FFC200F5BE48 /* UIButton+WebCache.h */, - 83BF314C19C9FFC200F5BE48 /* UIButton+WebCache.m */, - 83BF314D19C9FFC200F5BE48 /* UIImage+GIF.h */, - 83BF314E19C9FFC200F5BE48 /* UIImage+GIF.m */, - 83BF314F19C9FFC200F5BE48 /* UIImage+MultiFormat.h */, - 83BF315019C9FFC200F5BE48 /* UIImage+MultiFormat.m */, - 83BF315119C9FFC200F5BE48 /* UIImage+WebP.h */, - 83BF315219C9FFC200F5BE48 /* UIImage+WebP.m */, - 83BF315319C9FFC200F5BE48 /* UIImageView+HighlightedWebCache.h */, - 83BF315419C9FFC200F5BE48 /* UIImageView+HighlightedWebCache.m */, - 83BF315519C9FFC200F5BE48 /* UIImageView+WebCache.h */, - 83BF315619C9FFC200F5BE48 /* UIImageView+WebCache.m */, - 83BF315719C9FFC200F5BE48 /* UIView+WebCacheOperation.h */, - 83BF315819C9FFC200F5BE48 /* UIView+WebCacheOperation.m */, - ); - path = SDWebImage; - sourceTree = ""; - }; 83C354B019BBAD28000A5BD4 /* RiffStream */ = { isa = PBXGroup; children = ( @@ -1314,56 +1139,6 @@ path = AudioDeck; sourceTree = ""; }; - 83CCC8E8197EFCBF00FD1B4B /* AFNetworking */ = { - isa = PBXGroup; - children = ( - 83CCC8E9197EFCBF00FD1B4B /* AFHTTPRequestOperation.h */, - 83CCC8EA197EFCBF00FD1B4B /* AFHTTPRequestOperation.m */, - 83CCC8EB197EFCBF00FD1B4B /* AFHTTPRequestOperationManager.h */, - 83CCC8EC197EFCBF00FD1B4B /* AFHTTPRequestOperationManager.m */, - 83CCC8ED197EFCBF00FD1B4B /* AFHTTPSessionManager.h */, - 83CCC8EE197EFCBF00FD1B4B /* AFHTTPSessionManager.m */, - 83CCC8EF197EFCBF00FD1B4B /* AFNetworking.h */, - 83CCC8F0197EFCBF00FD1B4B /* AFNetworkReachabilityManager.h */, - 83CCC8F1197EFCBF00FD1B4B /* AFNetworkReachabilityManager.m */, - 83CCC8F2197EFCBF00FD1B4B /* AFSecurityPolicy.h */, - 83CCC8F3197EFCBF00FD1B4B /* AFSecurityPolicy.m */, - 83CCC8F4197EFCBF00FD1B4B /* AFURLConnectionOperation.h */, - 83CCC8F5197EFCBF00FD1B4B /* AFURLConnectionOperation.m */, - 83CCC8F6197EFCBF00FD1B4B /* AFURLRequestSerialization.h */, - 83CCC8F7197EFCBF00FD1B4B /* AFURLRequestSerialization.m */, - 83CCC8F8197EFCBF00FD1B4B /* AFURLResponseSerialization.h */, - 83CCC8F9197EFCBF00FD1B4B /* AFURLResponseSerialization.m */, - 83CCC8FA197EFCBF00FD1B4B /* AFURLSessionManager.h */, - 83CCC8FB197EFCBF00FD1B4B /* AFURLSessionManager.m */, - ); - path = AFNetworking; - sourceTree = ""; - }; - 83CCC8FC197EFCBF00FD1B4B /* UIKit+AFNetworking */ = { - isa = PBXGroup; - children = ( - 83CCC8FD197EFCBF00FD1B4B /* AFNetworkActivityIndicatorManager.h */, - 83CCC8FE197EFCBF00FD1B4B /* AFNetworkActivityIndicatorManager.m */, - 83CCC8FF197EFCBF00FD1B4B /* UIActivityIndicatorView+AFNetworking.h */, - 83CCC900197EFCBF00FD1B4B /* UIActivityIndicatorView+AFNetworking.m */, - 83CCC901197EFCBF00FD1B4B /* UIAlertView+AFNetworking.h */, - 83CCC902197EFCBF00FD1B4B /* UIAlertView+AFNetworking.m */, - 83CCC903197EFCBF00FD1B4B /* UIButton+AFNetworking.h */, - 83CCC904197EFCBF00FD1B4B /* UIButton+AFNetworking.m */, - 83CCC905197EFCBF00FD1B4B /* UIImageView+AFNetworking.h */, - 83CCC906197EFCBF00FD1B4B /* UIImageView+AFNetworking.m */, - 83CCC907197EFCBF00FD1B4B /* UIKit+AFNetworking.h */, - 83CCC908197EFCBF00FD1B4B /* UIProgressView+AFNetworking.h */, - 83CCC909197EFCBF00FD1B4B /* UIProgressView+AFNetworking.m */, - 83CCC90A197EFCBF00FD1B4B /* UIRefreshControl+AFNetworking.h */, - 83CCC90B197EFCBF00FD1B4B /* UIRefreshControl+AFNetworking.m */, - 83CCC90C197EFCBF00FD1B4B /* UIWebView+AFNetworking.h */, - 83CCC90D197EFCBF00FD1B4B /* UIWebView+AFNetworking.m */, - ); - path = "UIKit+AFNetworking"; - sourceTree = ""; - }; 83DBCA7818F99E2000262496 /* Base Classes */ = { isa = PBXGroup; children = ( @@ -1439,6 +1214,7 @@ 83FCD16318F907C400A493F0 /* RyffTests */, 83FCD13A18F907C400A493F0 /* Frameworks */, 83FCD13918F907C400A493F0 /* Products */, + 5BD8AE6B5B14CE56E937FC6A /* Pods */, ); sourceTree = ""; }; @@ -1460,6 +1236,8 @@ 83FCD13D18F907C400A493F0 /* CoreGraphics.framework */, 83FCD13F18F907C400A493F0 /* UIKit.framework */, 83FCD15D18F907C400A493F0 /* XCTest.framework */, + 610389EFACE91AC8266D46F6 /* libPods-Ryff.a */, + 8B8BF0F30F13E8E20F6D2D2C /* libPods-RyffTests.a */, ); name = Frameworks; sourceTree = ""; @@ -1641,10 +1419,12 @@ isa = PBXNativeTarget; buildConfigurationList = 83FCD16D18F907C400A493F0 /* Build configuration list for PBXNativeTarget "Ryff" */; buildPhases = ( + 14EE549E532443BF66C382E8 /* Check Pods Manifest.lock */, 83FCD13418F907C400A493F0 /* Sources */, 83FCD13518F907C400A493F0 /* Frameworks */, 83FCD13618F907C400A493F0 /* Resources */, 835E1E0719D21BFB007EBD74 /* Run Script */, + 7F9865D3E129952ED8C70A59 /* Copy Pods Resources */, ); buildRules = ( ); @@ -1659,9 +1439,11 @@ isa = PBXNativeTarget; buildConfigurationList = 83FCD17018F907C400A493F0 /* Build configuration list for PBXNativeTarget "RyffTests" */; buildPhases = ( + 02E5AC0A959165E21C0D7ADC /* Check Pods Manifest.lock */, 83FCD15818F907C400A493F0 /* Sources */, 83FCD15918F907C400A493F0 /* Frameworks */, 83FCD15A18F907C400A493F0 /* Resources */, + 3548D77566CAD9E664FC3FA6 /* Copy Pods Resources */, ); buildRules = ( ); @@ -1680,6 +1462,7 @@ isa = PBXProject; attributes = { CLASSPREFIX = RY; + LastSwiftUpdateCheck = 0700; LastUpgradeCheck = 0510; ORGANIZATIONNAME = "Chris Laganiere"; TargetAttributes = { @@ -1741,7 +1524,6 @@ 837367FC19A8344600D9559D /* globe.png in Resources */, 8373680919A8344600D9559D /* userIcon@2x.png in Resources */, 83C6A5F31960EC5200BB3D1A /* plus@2x.png in Resources */, - 830BBCB318F9F54900A9C53F /* SSKeychain.strings in Resources */, 831A88B9199EEEDD00C44CED /* stream.png in Resources */, 831A88B6199EEEDD00C44CED /* rss@2x.png in Resources */, 83ED34F21931851600FEB018 /* AppIcon72x72.png in Resources */, @@ -1832,6 +1614,66 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 02E5AC0A959165E21C0D7ADC /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + 14EE549E532443BF66C382E8 /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + 3548D77566CAD9E664FC3FA6 /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RyffTests/Pods-RyffTests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 7F9865D3E129952ED8C70A59 /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Ryff/Pods-Ryff-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; 835E1E0719D21BFB007EBD74 /* Run Script */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1854,36 +1696,24 @@ buildActionMask = 2147483647; files = ( 83CA12231995CD23002610E8 /* FLEXHeapEnumerator.m in Sources */, - 83BF315919C9FFC200F5BE48 /* MKAnnotationView+WebCache.m in Sources */, 83814BCD19D0DCBF00F60FBF /* RYTagListHeaderView.m in Sources */, - 83BF315D19C9FFC200F5BE48 /* SDWebImageDecoder.m in Sources */, 83082FEB19B5652D000AFACB /* RYSearchTypeTableViewCell.m in Sources */, - 83CCC919197EFCBF00FD1B4B /* UIAlertView+AFNetworking.m in Sources */, 83FCD18F18F9144100A493F0 /* RYNewsfeedTableViewController.m in Sources */, 836F484519A04BAB00E948BE /* UIView+Styling.m in Sources */, 830185F419009C3A00093EFA /* RYLoginViewController.m in Sources */, 830029BB1B7FD17C00666D93 /* RYRiffCreateCollectionViewController.swift in Sources */, - 830BBCBA18FA055900A9C53F /* MBProgressHUD.m in Sources */, 83CA12251995CD23002610E8 /* FLEXRuntimeUtility.m in Sources */, - 83CCC918197EFCBF00FD1B4B /* UIActivityIndicatorView+AFNetworking.m in Sources */, 83C354B319BBAD41000A5BD4 /* RYRiffStreamViewController.m in Sources */, 83C8940B19C809E100127F68 /* RYTagList.m in Sources */, - 83BF316719C9FFC200F5BE48 /* UIImageView+WebCache.m in Sources */, 83CA12261995CD23002610E8 /* FLEXUtility.m in Sources */, 83CA12271995CD23002610E8 /* FLEXHierarchyTableViewCell.m in Sources */, - 830BBCB418F9F54900A9C53F /* SSKeychain.m in Sources */, - 83CCC90F197EFCBF00FD1B4B /* AFHTTPRequestOperationManager.m in Sources */, 83CA11F91995CD23002610E8 /* FLEXArgumentInputFontsPickerView.m in Sources */, 83CA12041995CD23002610E8 /* FLEXDefaultEditorViewController.m in Sources */, - 83CCC91A197EFCBF00FD1B4B /* UIButton+AFNetworking.m in Sources */, 83CA12191995CD23002610E8 /* FLEXDefaultsExplorerViewController.m in Sources */, 83CA12241995CD23002610E8 /* FLEXResources.m in Sources */, - 83BF315C19C9FFC200F5BE48 /* SDWebImageCompat.m in Sources */, 830029B91B7FB2B300666D93 /* RYRiffAudioNode.m in Sources */, 83302D9519C7A972008C5A54 /* RYDiscoverServices.m in Sources */, - 83BF316419C9FFC200F5BE48 /* UIImage+MultiFormat.m in Sources */, 83CA120F1995CD23002610E8 /* FLEXClassesTableViewController.m in Sources */, - 83BF316619C9FFC200F5BE48 /* UIImageView+HighlightedWebCache.m in Sources */, 834A0B4F19BED5A700E4D7E9 /* RYRegistrationServices.m in Sources */, 8322309C19B00D0200C60033 /* PXAlertView+Customization.m in Sources */, 83CA120E1995CD23002610E8 /* FLEXWindow.m in Sources */, @@ -1914,8 +1744,6 @@ 83E3017219C7BAEE0085F17F /* RYTagCollectionViewCell.m in Sources */, 836F484619A04BAB00E948BE /* UIViewController+Extras.m in Sources */, 83082FE819B55DF4000AFACB /* RYTagFeedViewController.m in Sources */, - 83BF316819C9FFC200F5BE48 /* UIView+WebCacheOperation.m in Sources */, - 83BF315B19C9FFC200F5BE48 /* SDImageCache.m in Sources */, 83FCD17618F909DB00A493F0 /* RYProfileViewController.m in Sources */, 83FCD14C18F907C400A493F0 /* RYAppDelegate.m in Sources */, 83CA121C1995CD23002610E8 /* FLEXGlobalsTableViewControllerEntry.m in Sources */, @@ -1932,37 +1760,25 @@ 83360CD119B6A7EB00136FCB /* RYNotificationsTableViewController.m in Sources */, 83E56B681953A0DA00EF054C /* RYMediaEditor.m in Sources */, 83CA121F1995CD23002610E8 /* FLEXObjectExplorerViewController.m in Sources */, - 83CCC910197EFCBF00FD1B4B /* AFHTTPSessionManager.m in Sources */, - 83BF315F19C9FFC200F5BE48 /* SDWebImageDownloaderOperation.m in Sources */, - 83CCC91B197EFCBF00FD1B4B /* UIImageView+AFNetworking.m in Sources */, 83DBCA7B18F99E3F00262496 /* RYRiffStreamingCoreViewController.m in Sources */, 83CA12181995CD23002610E8 /* FLEXClassExplorerViewController.m in Sources */, - 830BBCB518F9F54900A9C53F /* SSKeychainQuery.m in Sources */, 83CA11FB1995CD23002610E8 /* FLEXArgumentInputJSONObjectView.m in Sources */, - 83CCC91C197EFCBF00FD1B4B /* UIProgressView+AFNetworking.m in Sources */, 83CA123319981702002610E8 /* RYAudioDeckTableViewCell.m in Sources */, 83CA120A1995CD23002610E8 /* FLEXExplorerToolbar.m in Sources */, 83CA121B1995CD23002610E8 /* FLEXDictionaryExplorerViewController.m in Sources */, - 83CCC914197EFCBF00FD1B4B /* AFURLRequestSerialization.m in Sources */, 83CA11FD1995CD23002610E8 /* FLEXArgumentInputNumberView.m in Sources */, 831E5FFA19A03269007F3C31 /* RYNewsfeedNavigationController.m in Sources */, - 83CCC915197EFCBF00FD1B4B /* AFURLResponseSerialization.m in Sources */, 835516761951315F00CF2C23 /* RYRiffCreateTableViewCell.m in Sources */, 832B89F91B32367700881AD8 /* FDWaveformView.m in Sources */, 83CA12101995CD23002610E8 /* FLEXFileBrowserSearchOperation.m in Sources */, - 83BF316019C9FFC200F5BE48 /* SDWebImageManager.m in Sources */, 837BA0FA19CCC7C2002AA13E /* UIFontDescriptor+RYCustomFont.m in Sources */, - 83CCC913197EFCBF00FD1B4B /* AFURLConnectionOperation.m in Sources */, 83CA123019981087002610E8 /* RYAudioDeckManager.m in Sources */, 83CA12151995CD23002610E8 /* FLEXLiveObjectsTableViewController.m in Sources */, 833FC1B21989E4B0002491C8 /* RYRiffDetailsTableViewCell.m in Sources */, 8355167219512CF100CF2C23 /* RYRiffCreateOldViewController.m in Sources */, 831B96081964DEC6003A8616 /* RYDataManager.m in Sources */, - 83CCC911197EFCBF00FD1B4B /* AFNetworkReachabilityManager.m in Sources */, 837E9AC61981E3360052E006 /* RYProfileInfoTableViewCell.m in Sources */, 83CA12011995CD23002610E8 /* FLEXArgumentInputTextView.m in Sources */, - 83CCC917197EFCBF00FD1B4B /* AFNetworkActivityIndicatorManager.m in Sources */, - 83BF316519C9FFC200F5BE48 /* UIImage+WebP.m in Sources */, 830029BD1B7FD3F900666D93 /* RYRiffCreateNodeCollectionViewCell.swift in Sources */, 83CA12221995CD23002610E8 /* FLEXViewExplorerViewController.m in Sources */, 83360CDD19B6B84E00136FCB /* RYNotification.m in Sources */, @@ -1975,38 +1791,27 @@ 83CA12111995CD23002610E8 /* FLEXFileBrowserTableViewController.m in Sources */, 83DC3B7819BD0EC00036AD2A /* RYRefreshControl.m in Sources */, 83CA12071995CD23002610E8 /* FLEXIvarEditorViewController.m in Sources */, - 83CCC90E197EFCBF00FD1B4B /* AFHTTPRequestOperation.m in Sources */, 834FEC1019897E6600C3D9B9 /* RYRiffCell.m in Sources */, 83CA11FC1995CD23002610E8 /* FLEXArgumentInputNotSupportedView.m in Sources */, 837C98D819A82411002A9B34 /* RYUserListViewController.m in Sources */, 837BA0F719CCC619002AA13E /* BNRDynamicTypeManager.m in Sources */, - 83BF315A19C9FFC200F5BE48 /* NSData+ImageContentType.m in Sources */, 83302D8F19C7A20B008C5A54 /* RYTagListViewController.m in Sources */, 837BA0E319CCAED8002AA13E /* RYUserListCollectionViewCell.m in Sources */, - 83CCC912197EFCBF00FD1B4B /* AFSecurityPolicy.m in Sources */, 83CA122D19981070002610E8 /* RYAudioDeckViewController.m in Sources */, 83CA12021995CD23002610E8 /* FLEXArgumentInputView.m in Sources */, - 83BF316319C9FFC200F5BE48 /* UIImage+GIF.m in Sources */, 83CA12291995CD23002610E8 /* FLEXImagePreviewViewController.m in Sources */, 836F484419A04BAB00E948BE /* UIImage+Thumbnail.m in Sources */, 830BBCC818FA0A5800A9C53F /* RYLocationServices.m in Sources */, 83CA12081995CD23002610E8 /* FLEXMethodCallingViewController.m in Sources */, - 83CCC91D197EFCBF00FD1B4B /* UIRefreshControl+AFNetworking.m in Sources */, 83FCD1BB18F9413400A493F0 /* RYPost.m in Sources */, - 83CCC916197EFCBF00FD1B4B /* AFURLSessionManager.m in Sources */, - 83CCC91E197EFCBF00FD1B4B /* UIWebView+AFNetworking.m in Sources */, - 837BA10219CCFA69002AA13E /* CHTCollectionViewWaterfallLayout.m in Sources */, 83CA121E1995CD23002610E8 /* FLEXObjectExplorerFactory.m in Sources */, 83CA12171995CD23002610E8 /* FLEXArrayExplorerViewController.m in Sources */, 83CA121D1995CD23002610E8 /* FLEXImageExplorerViewController.m in Sources */, - 83BF316119C9FFC200F5BE48 /* SDWebImagePrefetcher.m in Sources */, 830BBCD218FA142000A9C53F /* BlockAlertView.m in Sources */, 833FC1AE1989E406002491C8 /* RYRiffDetailsViewController.m in Sources */, 83CA12091995CD23002610E8 /* FLEXPropertyEditorViewController.m in Sources */, 83CA12031995CD23002610E8 /* FLEXArgumentInputViewFactory.m in Sources */, 830185FE1900AEB300093EFA /* UIColor+Hex.m in Sources */, - 83BF316219C9FFC200F5BE48 /* UIButton+WebCache.m in Sources */, - 83BF315E19C9FFC200F5BE48 /* SDWebImageDownloader.m in Sources */, 83FCD1A318F921EA00A493F0 /* RYServices.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -2030,14 +1835,6 @@ /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ - 830BBCAD18F9F54900A9C53F /* SSKeychain.strings */ = { - isa = PBXVariantGroup; - children = ( - 830BBCAE18F9F54900A9C53F /* en */, - ); - name = SSKeychain.strings; - sourceTree = ""; - }; 83FCD14418F907C400A493F0 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( @@ -2143,6 +1940,7 @@ }; 83FCD16E18F907C400A493F0 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 0F068F340A8DD53B769F8B4B /* Pods-Ryff.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = "Ryff Icon"; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; @@ -2168,6 +1966,7 @@ }; 83FCD16F18F907C400A493F0 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 5D10781F97C58C1D8BE87763 /* Pods-Ryff.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = "Ryff Icon"; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; @@ -2192,6 +1991,7 @@ }; 83FCD17118F907C400A493F0 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 7FFE42F2F5730A2D8E9FEB19 /* Pods-RyffTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/Ryff.app/Ryff"; FRAMEWORK_SEARCH_PATHS = ( @@ -2214,6 +2014,7 @@ }; 83FCD17218F907C400A493F0 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 6616A16D4F2C65AA11F6581D /* Pods-RyffTests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/Ryff.app/Ryff"; FRAMEWORK_SEARCH_PATHS = ( diff --git a/Ryff/Data/SSKeychain/SSKeychain.h b/Ryff/Data/SSKeychain/SSKeychain.h deleted file mode 100755 index eb6c61f..0000000 --- a/Ryff/Data/SSKeychain/SSKeychain.h +++ /dev/null @@ -1,161 +0,0 @@ -// -// SSKeychain.h -// SSKeychain -// -// Created by Sam Soffes on 5/19/10. -// Copyright (c) 2010-2014 Sam Soffes. All rights reserved. -// - -#import "SSKeychainQuery.h" - -/** - Error code specific to SSKeychain that can be returned in NSError objects. - For codes returned by the operating system, refer to SecBase.h for your - platform. - */ -typedef NS_ENUM(OSStatus, SSKeychainErrorCode) { - /** Some of the arguments were invalid. */ - SSKeychainErrorBadArguments = -1001, -}; - -/** SSKeychain error domain */ -extern NSString *const kSSKeychainErrorDomain; - -/** Account name. */ -extern NSString *const kSSKeychainAccountKey; - -/** - Time the item was created. - - The value will be a string. - */ -extern NSString *const kSSKeychainCreatedAtKey; - -/** Item class. */ -extern NSString *const kSSKeychainClassKey; - -/** Item description. */ -extern NSString *const kSSKeychainDescriptionKey; - -/** Item label. */ -extern NSString *const kSSKeychainLabelKey; - -/** Time the item was last modified. - - The value will be a string. - */ -extern NSString *const kSSKeychainLastModifiedKey; - -/** Where the item was created. */ -extern NSString *const kSSKeychainWhereKey; - -/** - Simple wrapper for accessing accounts, getting passwords, setting passwords, and deleting passwords using the system - Keychain on Mac OS X and iOS. - - This was originally inspired by EMKeychain and SDKeychain (both of which are now gone). Thanks to the authors. - SSKeychain has since switched to a simpler implementation that was abstracted from [SSToolkit](http://sstoolk.it). - */ -@interface SSKeychain : NSObject - -#pragma mark - Classic methods - -/** - Returns a string containing the password for a given account and service, or `nil` if the Keychain doesn't have a - password for the given parameters. - - @param serviceName The service for which to return the corresponding password. - - @param account The account for which to return the corresponding password. - - @return Returns a string containing the password for a given account and service, or `nil` if the Keychain doesn't - have a password for the given parameters. - */ -+ (NSString *)passwordForService:(NSString *)serviceName account:(NSString *)account; -+ (NSString *)passwordForService:(NSString *)serviceName account:(NSString *)account error:(NSError **)error; - - -/** - Deletes a password from the Keychain. - - @param serviceName The service for which to delete the corresponding password. - - @param account The account for which to delete the corresponding password. - - @return Returns `YES` on success, or `NO` on failure. - */ -+ (BOOL)deletePasswordForService:(NSString *)serviceName account:(NSString *)account; -+ (BOOL)deletePasswordForService:(NSString *)serviceName account:(NSString *)account error:(NSError **)error; - - -/** - Sets a password in the Keychain. - - @param password The password to store in the Keychain. - - @param serviceName The service for which to set the corresponding password. - - @param account The account for which to set the corresponding password. - - @return Returns `YES` on success, or `NO` on failure. - */ -+ (BOOL)setPassword:(NSString *)password forService:(NSString *)serviceName account:(NSString *)account; -+ (BOOL)setPassword:(NSString *)password forService:(NSString *)serviceName account:(NSString *)account error:(NSError **)error; - - -/** - Returns an array containing the Keychain's accounts, or `nil` if the Keychain has no accounts. - - See the `NSString` constants declared in SSKeychain.h for a list of keys that can be used when accessing the - dictionaries returned by this method. - - @return An array of dictionaries containing the Keychain's accounts, or `nil` if the Keychain doesn't have any - accounts. The order of the objects in the array isn't defined. - */ -+ (NSArray *)allAccounts; - - -/** - Returns an array containing the Keychain's accounts for a given service, or `nil` if the Keychain doesn't have any - accounts for the given service. - - See the `NSString` constants declared in SSKeychain.h for a list of keys that can be used when accessing the - dictionaries returned by this method. - - @param serviceName The service for which to return the corresponding accounts. - - @return An array of dictionaries containing the Keychain's accountsfor a given `serviceName`, or `nil` if the Keychain - doesn't have any accounts for the given `serviceName`. The order of the objects in the array isn't defined. - */ -+ (NSArray *)accountsForService:(NSString *)serviceName; - - -#pragma mark - Configuration - -#if __IPHONE_4_0 && TARGET_OS_IPHONE -/** - Returns the accessibility type for all future passwords saved to the Keychain. - - @return Returns the accessibility type. - - The return value will be `NULL` or one of the "Keychain Item Accessibility - Constants" used for determining when a keychain item should be readable. - - @see setAccessibilityType - */ -+ (CFTypeRef)accessibilityType; - -/** - Sets the accessibility type for all future passwords saved to the Keychain. - - @param accessibilityType One of the "Keychain Item Accessibility Constants" - used for determining when a keychain item should be readable. - - If the value is `NULL` (the default), the Keychain default will be used. - - @see accessibilityType - */ -+ (void)setAccessibilityType:(CFTypeRef)accessibilityType; -#endif - -@end diff --git a/Ryff/Data/SSKeychain/SSKeychain.m b/Ryff/Data/SSKeychain/SSKeychain.m deleted file mode 100755 index 9893fb0..0000000 --- a/Ryff/Data/SSKeychain/SSKeychain.m +++ /dev/null @@ -1,94 +0,0 @@ -// -// SSKeychain.m -// SSKeychain -// -// Created by Sam Soffes on 5/19/10. -// Copyright (c) 2010-2014 Sam Soffes. All rights reserved. -// - -#import "SSKeychain.h" - -NSString *const kSSKeychainErrorDomain = @"com.samsoffes.sskeychain"; -NSString *const kSSKeychainAccountKey = @"acct"; -NSString *const kSSKeychainCreatedAtKey = @"cdat"; -NSString *const kSSKeychainClassKey = @"labl"; -NSString *const kSSKeychainDescriptionKey = @"desc"; -NSString *const kSSKeychainLabelKey = @"labl"; -NSString *const kSSKeychainLastModifiedKey = @"mdat"; -NSString *const kSSKeychainWhereKey = @"svce"; - -#if __IPHONE_4_0 && TARGET_OS_IPHONE -static CFTypeRef SSKeychainAccessibilityType = NULL; -#endif - -@implementation SSKeychain - -+ (NSString *)passwordForService:(NSString *)serviceName account:(NSString *)account { - return [self passwordForService:serviceName account:account error:nil]; -} - - -+ (NSString *)passwordForService:(NSString *)serviceName account:(NSString *)account error:(NSError *__autoreleasing *)error { - SSKeychainQuery *query = [[SSKeychainQuery alloc] init]; - query.service = serviceName; - query.account = account; - [query fetch:error]; - return query.password; -} - - -+ (BOOL)deletePasswordForService:(NSString *)serviceName account:(NSString *)account { - return [self deletePasswordForService:serviceName account:account error:nil]; -} - - -+ (BOOL)deletePasswordForService:(NSString *)serviceName account:(NSString *)account error:(NSError *__autoreleasing *)error { - SSKeychainQuery *query = [[SSKeychainQuery alloc] init]; - query.service = serviceName; - query.account = account; - return [query deleteItem:error]; -} - - -+ (BOOL)setPassword:(NSString *)password forService:(NSString *)serviceName account:(NSString *)account { - return [self setPassword:password forService:serviceName account:account error:nil]; -} - - -+ (BOOL)setPassword:(NSString *)password forService:(NSString *)serviceName account:(NSString *)account error:(NSError *__autoreleasing *)error { - SSKeychainQuery *query = [[SSKeychainQuery alloc] init]; - query.service = serviceName; - query.account = account; - query.password = password; - return [query save:error]; -} - - -+ (NSArray *)allAccounts { - return [self accountsForService:nil]; -} - - -+ (NSArray *)accountsForService:(NSString *)serviceName { - SSKeychainQuery *query = [[SSKeychainQuery alloc] init]; - query.service = serviceName; - return [query fetchAll:nil]; -} - - -#if __IPHONE_4_0 && TARGET_OS_IPHONE -+ (CFTypeRef)accessibilityType { - return SSKeychainAccessibilityType; -} - - -+ (void)setAccessibilityType:(CFTypeRef)accessibilityType { - CFRetain(accessibilityType); - if (SSKeychainAccessibilityType) { - CFRelease(SSKeychainAccessibilityType); - } - SSKeychainAccessibilityType = accessibilityType; -} -#endif - -@end diff --git a/Ryff/Data/SSKeychain/SSKeychainQuery.h b/Ryff/Data/SSKeychain/SSKeychainQuery.h deleted file mode 100755 index ef4079a..0000000 --- a/Ryff/Data/SSKeychain/SSKeychainQuery.h +++ /dev/null @@ -1,133 +0,0 @@ -// -// SSKeychainQuery.h -// SSKeychain -// -// Created by Caleb Davenport on 3/19/13. -// Copyright (c) 2013-2014 Sam Soffes. All rights reserved. -// - -#import -#import - -#if __IPHONE_7_0 || __MAC_10_9 -// Keychain synchronization available at compile time -#define SSKEYCHAIN_SYNCHRONIZATION_AVAILABLE 1 -#endif - -#ifdef SSKEYCHAIN_SYNCHRONIZATION_AVAILABLE -typedef NS_ENUM(NSUInteger, SSKeychainQuerySynchronizationMode) { - SSKeychainQuerySynchronizationModeAny, - SSKeychainQuerySynchronizationModeNo, - SSKeychainQuerySynchronizationModeYes -}; -#endif - -/** - Simple interface for querying or modifying keychain items. - */ -@interface SSKeychainQuery : NSObject - -/** kSecAttrAccount */ -@property (nonatomic, copy) NSString *account; - -/** kSecAttrService */ -@property (nonatomic, copy) NSString *service; - -/** kSecAttrLabel */ -@property (nonatomic, copy) NSString *label; - -#if __IPHONE_3_0 && TARGET_OS_IPHONE -/** kSecAttrAccessGroup (only used on iOS) */ -@property (nonatomic, copy) NSString *accessGroup; -#endif - -#ifdef SSKEYCHAIN_SYNCHRONIZATION_AVAILABLE -/** kSecAttrSynchronizable */ -@property (nonatomic) SSKeychainQuerySynchronizationMode synchronizationMode; -#endif - -/** Root storage for password information */ -@property (nonatomic, copy) NSData *passwordData; - -/** - This property automatically transitions between an object and the value of - `passwordData` using NSKeyedArchiver and NSKeyedUnarchiver. - */ -@property (nonatomic, copy) id passwordObject; - -/** - Convenience accessor for setting and getting a password string. Passes through - to `passwordData` using UTF-8 string encoding. - */ -@property (nonatomic, copy) NSString *password; - - -///------------------------ -/// @name Saving & Deleting -///------------------------ - -/** - Save the receiver's attributes as a keychain item. Existing items with the - given account, service, and access group will first be deleted. - - @param error Populated should an error occur. - - @return `YES` if saving was successful, `NO` otherwise. - */ -- (BOOL)save:(NSError **)error; - -/** - Dete keychain items that match the given account, service, and access group. - - @param error Populated should an error occur. - - @return `YES` if saving was successful, `NO` otherwise. - */ -- (BOOL)deleteItem:(NSError **)error; - - -///--------------- -/// @name Fetching -///--------------- - -/** - Fetch all keychain items that match the given account, service, and access - group. The values of `password` and `passwordData` are ignored when fetching. - - @param error Populated should an error occur. - - @return An array of dictionaries that represent all matching keychain items or - `nil` should an error occur. - The order of the items is not determined. - */ -- (NSArray *)fetchAll:(NSError **)error; - -/** - Fetch the keychain item that matches the given account, service, and access - group. The `password` and `passwordData` properties will be populated unless - an error occurs. The values of `password` and `passwordData` are ignored when - fetching. - - @param error Populated should an error occur. - - @return `YES` if fetching was successful, `NO` otherwise. - */ -- (BOOL)fetch:(NSError **)error; - - -///----------------------------- -/// @name Synchronization Status -///----------------------------- - -#ifdef SSKEYCHAIN_SYNCHRONIZATION_AVAILABLE -/** - Returns a boolean indicating if keychain synchronization is available on the device at runtime. The #define - SSKEYCHAIN_SYNCHRONIZATION_AVAILABLE is only for compile time. If you are checking for the presence of synchronization, - you should use this method. - - @return A value indicating if keychain synchronization is available - */ -+ (BOOL)isSynchronizationAvailable; -#endif - -@end diff --git a/Ryff/Data/SSKeychain/SSKeychainQuery.m b/Ryff/Data/SSKeychain/SSKeychainQuery.m deleted file mode 100755 index a493767..0000000 --- a/Ryff/Data/SSKeychain/SSKeychainQuery.m +++ /dev/null @@ -1,282 +0,0 @@ -// -// SSKeychainQuery.m -// SSKeychain -// -// Created by Caleb Davenport on 3/19/13. -// Copyright (c) 2013-2014 Sam Soffes. All rights reserved. -// - -#import "SSKeychainQuery.h" -#import "SSKeychain.h" - -@implementation SSKeychainQuery - -@synthesize account = _account; -@synthesize service = _service; -@synthesize label = _label; -@synthesize passwordData = _passwordData; - -#if __IPHONE_3_0 && TARGET_OS_IPHONE -@synthesize accessGroup = _accessGroup; -#endif - -#ifdef SSKEYCHAIN_SYNCHRONIZATION_AVAILABLE -@synthesize synchronizationMode = _synchronizationMode; -#endif - -#pragma mark - Public - -- (BOOL)save:(NSError *__autoreleasing *)error { - OSStatus status = SSKeychainErrorBadArguments; - if (!self.service || !self.account || !self.passwordData) { - if (error) { - *error = [[self class] errorWithCode:status]; - } - return NO; - } - - [self deleteItem:nil]; - - NSMutableDictionary *query = [self query]; - [query setObject:self.passwordData forKey:(__bridge id)kSecValueData]; - if (self.label) { - [query setObject:self.label forKey:(__bridge id)kSecAttrLabel]; - } -#if __IPHONE_4_0 && TARGET_OS_IPHONE - CFTypeRef accessibilityType = [SSKeychain accessibilityType]; - if (accessibilityType) { - [query setObject:(__bridge id)accessibilityType forKey:(__bridge id)kSecAttrAccessible]; - } -#endif - status = SecItemAdd((__bridge CFDictionaryRef)query, NULL); - - if (status != errSecSuccess && error != NULL) { - *error = [[self class] errorWithCode:status]; - } - - return (status == errSecSuccess); -} - - -- (BOOL)deleteItem:(NSError *__autoreleasing *)error { - OSStatus status = SSKeychainErrorBadArguments; - if (!self.service || !self.account) { - if (error) { - *error = [[self class] errorWithCode:status]; - } - return NO; - } - - NSMutableDictionary *query = [self query]; -#if TARGET_OS_IPHONE - status = SecItemDelete((__bridge CFDictionaryRef)query); -#else - CFTypeRef result = NULL; - [query setObject:@YES forKey:(__bridge id)kSecReturnRef]; - status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &result); - if (status == errSecSuccess) { - status = SecKeychainItemDelete((SecKeychainItemRef)result); - CFRelease(result); - } -#endif - - if (status != errSecSuccess && error != NULL) { - *error = [[self class] errorWithCode:status]; - } - - return (status == errSecSuccess); -} - - -- (NSArray *)fetchAll:(NSError *__autoreleasing *)error { - OSStatus status = SSKeychainErrorBadArguments; - NSMutableDictionary *query = [self query]; - [query setObject:@YES forKey:(__bridge id)kSecReturnAttributes]; - [query setObject:(__bridge id)kSecMatchLimitAll forKey:(__bridge id)kSecMatchLimit]; - - CFTypeRef result = NULL; - status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &result); - if (status != errSecSuccess && error != NULL) { - *error = [[self class] errorWithCode:status]; - return nil; - } - - return (__bridge_transfer NSArray *)result; -} - - -- (BOOL)fetch:(NSError *__autoreleasing *)error { - OSStatus status = SSKeychainErrorBadArguments; - if (!self.service || !self.account) { - if (error) { - *error = [[self class] errorWithCode:status]; - } - return NO; - } - - CFTypeRef result = NULL; - NSMutableDictionary *query = [self query]; - [query setObject:@YES forKey:(__bridge id)kSecReturnData]; - [query setObject:(__bridge id)kSecMatchLimitOne forKey:(__bridge id)kSecMatchLimit]; - status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &result); - - if (status != errSecSuccess && error != NULL) { - *error = [[self class] errorWithCode:status]; - return NO; - } - - self.passwordData = (__bridge_transfer NSData *)result; - return YES; -} - - -#pragma mark - Accessors - -- (void)setPasswordObject:(id)object { - self.passwordData = [NSKeyedArchiver archivedDataWithRootObject:object]; -} - - -- (id)passwordObject { - if ([self.passwordData length]) { - return [NSKeyedUnarchiver unarchiveObjectWithData:self.passwordData]; - } - return nil; -} - - -- (void)setPassword:(NSString *)password { - self.passwordData = [password dataUsingEncoding:NSUTF8StringEncoding]; -} - - -- (NSString *)password { - if ([self.passwordData length]) { - return [[NSString alloc] initWithData:self.passwordData encoding:NSUTF8StringEncoding]; - } - return nil; -} - - -#pragma mark - Synchronization Status - -#ifdef SSKEYCHAIN_SYNCHRONIZATION_AVAILABLE -+ (BOOL)isSynchronizationAvailable { -#if TARGET_OS_IPHONE - // Apple suggested way to check for 7.0 at runtime - // https://developer.apple.com/library/ios/documentation/userexperience/conceptual/transitionguide/SupportingEarlieriOS.html - return floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1; -#else - return floor(NSFoundationVersionNumber) > NSFoundationVersionNumber10_8_4; -#endif -} -#endif - - -#pragma mark - Private - -- (NSMutableDictionary *)query { - NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithCapacity:3]; - [dictionary setObject:(__bridge id)kSecClassGenericPassword forKey:(__bridge id)kSecClass]; - - if (self.service) { - [dictionary setObject:self.service forKey:(__bridge id)kSecAttrService]; - } - - if (self.account) { - [dictionary setObject:self.account forKey:(__bridge id)kSecAttrAccount]; - } - -#if __IPHONE_3_0 && TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR - if (self.accessGroup) { - [dictionary setObject:self.accessGroup forKey:(__bridge id)kSecAttrAccessGroup]; - } -#endif - -#ifdef SSKEYCHAIN_SYNCHRONIZATION_AVAILABLE - if ([[self class] isSynchronizationAvailable]) { - id value; - - switch (self.synchronizationMode) { - case SSKeychainQuerySynchronizationModeNo: { - value = @NO; - break; - } - case SSKeychainQuerySynchronizationModeYes: { - value = @YES; - break; - } - case SSKeychainQuerySynchronizationModeAny: { - value = (__bridge id)(kSecAttrSynchronizableAny); - break; - } - } - - [dictionary setObject:value forKey:(__bridge id)(kSecAttrSynchronizable)]; - } -#endif - - return dictionary; -} - - -+ (NSError *)errorWithCode:(OSStatus) code { - NSString *message = nil; - switch (code) { - case errSecSuccess: return nil; - case SSKeychainErrorBadArguments: message = NSLocalizedStringFromTable(@"SSKeychainErrorBadArguments", @"SSKeychain", nil); break; - -#if TARGET_OS_IPHONE - case errSecUnimplemented: { - message = NSLocalizedStringFromTable(@"errSecUnimplemented", @"SSKeychain", nil); - break; - } - case errSecParam: { - message = NSLocalizedStringFromTable(@"errSecParam", @"SSKeychain", nil); - break; - } - case errSecAllocate: { - message = NSLocalizedStringFromTable(@"errSecAllocate", @"SSKeychain", nil); - break; - } - case errSecNotAvailable: { - message = NSLocalizedStringFromTable(@"errSecNotAvailable", @"SSKeychain", nil); - break; - } - case errSecDuplicateItem: { - message = NSLocalizedStringFromTable(@"errSecDuplicateItem", @"SSKeychain", nil); - break; - } - case errSecItemNotFound: { - message = NSLocalizedStringFromTable(@"errSecItemNotFound", @"SSKeychain", nil); - break; - } - case errSecInteractionNotAllowed: { - message = NSLocalizedStringFromTable(@"errSecInteractionNotAllowed", @"SSKeychain", nil); - break; - } - case errSecDecode: { - message = NSLocalizedStringFromTable(@"errSecDecode", @"SSKeychain", nil); - break; - } - case errSecAuthFailed: { - message = NSLocalizedStringFromTable(@"errSecAuthFailed", @"SSKeychain", nil); - break; - } - default: { - message = NSLocalizedStringFromTable(@"errSecDefault", @"SSKeychain", nil); - } -#else - default: - message = (__bridge_transfer NSString *)SecCopyErrorMessageString(code, NULL); -#endif - } - - NSDictionary *userInfo = nil; - if (message) { - userInfo = @{ NSLocalizedDescriptionKey : message }; - } - return [NSError errorWithDomain:kSSKeychainErrorDomain code:code userInfo:userInfo]; -} - -@end diff --git a/Ryff/Data/SSKeychain/en.lproj/SSKeychain.strings b/Ryff/Data/SSKeychain/en.lproj/SSKeychain.strings deleted file mode 100755 index faeb205b3926664ede624315656b118fe59c4cab..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1576 zcmbW1%Z}4P5JhXvS6D1r%zOZ15i~?XNW5pk(i1x~7Kv^70p#a_bE{La2U`fCDCtgj zJ#O8))xUmT+cV4T6Q4I$+R1kIV7XOR+Xovt={U=<=VTyT$(k>GGW+h?bt^RAusN_Ri1OUA2wO+Q63n+)R77sE zDKD8zw~pLfFxA)&ST^j0q4VF?Gv%|Jn!CX>ug6>>c<(jjZ4Rt6Q(Cex&4o!zC6*u&J}5lRI!qQMysg|HG%LmTGf2iD?QAB<)C{n$(!R zTi3OEqgh^hhY|v(IF(`}&T`&v$e;=f)_I;9R7rg?L$V0VsS_>u8+4}^C8?^wQ)*i4 z$;P$xVDovIvPM6~OO-;Q_b+B&6R+8BQIvSol!sz7_Q6R)lBOcK5O%$Es$y70Coc9x oRkvjktbg=#btuch8;A-DofQiCkSLr;zlPFmumS2D5j8|+6DfdBvi diff --git a/Ryff/Frameworks/AFNetworking/AFHTTPRequestOperation.h b/Ryff/Frameworks/AFNetworking/AFHTTPRequestOperation.h deleted file mode 100755 index dfa82f6..0000000 --- a/Ryff/Frameworks/AFNetworking/AFHTTPRequestOperation.h +++ /dev/null @@ -1,67 +0,0 @@ -// AFHTTPRequestOperation.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import -#import "AFURLConnectionOperation.h" - -/** - `AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request. - */ -@interface AFHTTPRequestOperation : AFURLConnectionOperation - -///------------------------------------------------ -/// @name Getting HTTP URL Connection Information -///------------------------------------------------ - -/** - The last HTTP response received by the operation's connection. - */ -@property (readonly, nonatomic, strong) NSHTTPURLResponse *response; - -/** - Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an AFHTTPResponse serializer, which uses the raw data as its response object. The serializer validates the status code to be in the `2XX` range, denoting success. If the response serializer generates an error in `-responseObjectForResponse:data:error:`, the `failure` callback of the session task or request operation will be executed; otherwise, the `success` callback will be executed. - - @warning `responseSerializer` must not be `nil`. Setting a response serializer will clear out any cached value - */ -@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; - -/** - An object constructed by the `responseSerializer` from the response and response data. Returns `nil` unless the operation `isFinished`, has a `response`, and has `responseData` with non-zero content length. If an error occurs during serialization, `nil` will be returned, and the `error` property will be populated with the serialization error. - */ -@property (readonly, nonatomic, strong) id responseObject; - -///----------------------------------------------------------- -/// @name Setting Completion Block Success / Failure Callbacks -///----------------------------------------------------------- - -/** - Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed. - - This method should be overridden in subclasses in order to specify the response object passed into the success block. - - @param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request. - @param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occurred during the request. - */ -- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; - -@end diff --git a/Ryff/Frameworks/AFNetworking/AFHTTPRequestOperation.m b/Ryff/Frameworks/AFNetworking/AFHTTPRequestOperation.m deleted file mode 100755 index 723a3b3..0000000 --- a/Ryff/Frameworks/AFNetworking/AFHTTPRequestOperation.m +++ /dev/null @@ -1,206 +0,0 @@ -// AFHTTPRequestOperation.m -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import "AFHTTPRequestOperation.h" - -static dispatch_queue_t http_request_operation_processing_queue() { - static dispatch_queue_t af_http_request_operation_processing_queue; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - af_http_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.http-request.processing", DISPATCH_QUEUE_CONCURRENT); - }); - - return af_http_request_operation_processing_queue; -} - -static dispatch_group_t http_request_operation_completion_group() { - static dispatch_group_t af_http_request_operation_completion_group; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - af_http_request_operation_completion_group = dispatch_group_create(); - }); - - return af_http_request_operation_completion_group; -} - -#pragma mark - - -@interface AFURLConnectionOperation () -@property (readwrite, nonatomic, strong) NSURLRequest *request; -@property (readwrite, nonatomic, strong) NSURLResponse *response; -@end - -@interface AFHTTPRequestOperation () -@property (readwrite, nonatomic, strong) NSHTTPURLResponse *response; -@property (readwrite, nonatomic, strong) id responseObject; -@property (readwrite, nonatomic, strong) NSError *responseSerializationError; -@property (readwrite, nonatomic, strong) NSRecursiveLock *lock; -@end - -@implementation AFHTTPRequestOperation -@dynamic lock; - -- (instancetype)initWithRequest:(NSURLRequest *)urlRequest { - self = [super initWithRequest:urlRequest]; - if (!self) { - return nil; - } - - self.responseSerializer = [AFHTTPResponseSerializer serializer]; - - return self; -} - -- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { - NSParameterAssert(responseSerializer); - - [self.lock lock]; - _responseSerializer = responseSerializer; - self.responseObject = nil; - self.responseSerializationError = nil; - [self.lock unlock]; -} - -- (id)responseObject { - [self.lock lock]; - if (!_responseObject && [self isFinished] && !self.error) { - NSError *error = nil; - self.responseObject = [self.responseSerializer responseObjectForResponse:self.response data:self.responseData error:&error]; - if (error) { - self.responseSerializationError = error; - } - } - [self.lock unlock]; - - return _responseObject; -} - -- (NSError *)error { - if (_responseSerializationError) { - return _responseSerializationError; - } else { - return [super error]; - } -} - -#pragma mark - AFHTTPRequestOperation - -- (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure -{ - // completionBlock is manually nilled out in AFURLConnectionOperation to break the retain cycle. -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Warc-retain-cycles" -#pragma clang diagnostic ignored "-Wgnu" - self.completionBlock = ^{ - if (self.completionGroup) { - dispatch_group_enter(self.completionGroup); - } - - dispatch_async(http_request_operation_processing_queue(), ^{ - if (self.error) { - if (failure) { - dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ - failure(self, self.error); - }); - } - } else { - id responseObject = self.responseObject; - if (self.error) { - if (failure) { - dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ - failure(self, self.error); - }); - } - } else { - if (success) { - dispatch_group_async(self.completionGroup ?: http_request_operation_completion_group(), self.completionQueue ?: dispatch_get_main_queue(), ^{ - success(self, responseObject); - }); - } - } - } - - if (self.completionGroup) { - dispatch_group_leave(self.completionGroup); - } - }); - }; -#pragma clang diagnostic pop -} - -#pragma mark - AFURLRequestOperation - -- (void)pause { - [super pause]; - - u_int64_t offset = 0; - if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) { - offset = [(NSNumber *)[self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedLongLongValue]; - } else { - offset = [(NSData *)[self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey] length]; - } - - NSMutableURLRequest *mutableURLRequest = [self.request mutableCopy]; - if ([self.response respondsToSelector:@selector(allHeaderFields)] && [[self.response allHeaderFields] valueForKey:@"ETag"]) { - [mutableURLRequest setValue:[[self.response allHeaderFields] valueForKey:@"ETag"] forHTTPHeaderField:@"If-Range"]; - } - [mutableURLRequest setValue:[NSString stringWithFormat:@"bytes=%llu-", offset] forHTTPHeaderField:@"Range"]; - self.request = mutableURLRequest; -} - -#pragma mark - NSecureCoding - -+ (BOOL)supportsSecureCoding { - return YES; -} - -- (id)initWithCoder:(NSCoder *)decoder { - self = [super initWithCoder:decoder]; - if (!self) { - return nil; - } - - self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [super encodeWithCoder:coder]; - - [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; -} - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone { - AFHTTPRequestOperation *operation = [[[self class] allocWithZone:zone] initWithRequest:self.request]; - - operation.responseSerializer = [self.responseSerializer copyWithZone:zone]; - operation.completionQueue = self.completionQueue; - operation.completionGroup = self.completionGroup; - - return operation; -} - -@end diff --git a/Ryff/Frameworks/AFNetworking/AFHTTPRequestOperationManager.h b/Ryff/Frameworks/AFNetworking/AFHTTPRequestOperationManager.h deleted file mode 100755 index d7f6d42..0000000 --- a/Ryff/Frameworks/AFNetworking/AFHTTPRequestOperationManager.h +++ /dev/null @@ -1,308 +0,0 @@ -// AFHTTPRequestOperationManager.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import -#import -#import - -#if __IPHONE_OS_VERSION_MIN_REQUIRED -#import -#else -#import -#endif - -#import "AFHTTPRequestOperation.h" -#import "AFURLResponseSerialization.h" -#import "AFURLRequestSerialization.h" -#import "AFSecurityPolicy.h" -#import "AFNetworkReachabilityManager.h" - -/** - `AFHTTPRequestOperationManager` encapsulates the common patterns of communicating with a web application over HTTP, including request creation, response serialization, network reachability monitoring, and security, as well as request operation management. - - ## Subclassing Notes - - Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application. - - For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect. - - ## Methods to Override - - To change the behavior of all request operation construction for an `AFHTTPRequestOperationManager` subclass, override `HTTPRequestOperationWithRequest:success:failure`. - - ## Serialization - - Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to ``. - - Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `` - - ## URL Construction Using Relative Paths - - For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`. - - Below are a few examples of how `baseURL` and relative paths interact: - - NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; - [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo - [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz - [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo - [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo - [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/ - [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/ - - Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash. - - ## Network Reachability Monitoring - - Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `AFNetworkReachabilityManager` for more details. - - ## NSecureCoding & NSCopying Caveats - - `AFHTTPRequestOperationManager` conforms to the `NSecureCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. There are a few minor caveats to keep in mind, however: - - - Archives and copies of HTTP clients will be initialized with an empty operation queue. - - NSecureCoding cannot serialize / deserialize block properties, so an archive of an HTTP client will not include any reachability callback block that may be set. - */ -@interface AFHTTPRequestOperationManager : NSObject - -/** - The URL used to monitor reachability, and construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods. - */ -@property (readonly, nonatomic, strong) NSURL *baseURL; - -/** - Requests created with `requestWithMethod:URLString:parameters:` & `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:` are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of `AFHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies. - - @warning `requestSerializer` must not be `nil`. - */ -@property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; - -/** - Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to a JSON serializer, which serializes data from responses with a `application/json` MIME type, and falls back to the raw data object. The serializer validates the status code to be in the `2XX` range, denoting success. If the response serializer generates an error in `-responseObjectForResponse:data:error:`, the `failure` callback of the session task or request operation will be executed; otherwise, the `success` callback will be executed. - - @warning `responseSerializer` must not be `nil`. - */ -@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; - -/** - The operation queue on which request operations are scheduled and run. - */ -@property (nonatomic, strong) NSOperationQueue *operationQueue; - -///------------------------------- -/// @name Managing URL Credentials -///------------------------------- - -/** - Whether request operations should consult the credential storage for authenticating the connection. `YES` by default. - - @see AFURLConnectionOperation -shouldUseCredentialStorage - */ -@property (nonatomic, assign) BOOL shouldUseCredentialStorage; - -/** - The credential used by request operations for authentication challenges. - - @see AFURLConnectionOperation -credential - */ -@property (nonatomic, strong) NSURLCredential *credential; - -///------------------------------- -/// @name Managing Security Policy -///------------------------------- - -/** - The security policy used by created request operations to evaluate server trust for secure connections. `AFHTTPRequestOperationManager` uses the `defaultPolicy` unless otherwise specified. - */ -@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; - -///------------------------------------ -/// @name Managing Network Reachability -///------------------------------------ - -/** - The network reachability manager. `AFHTTPRequestOperationManager` uses the `sharedManager` by default. - */ -@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager; - -///------------------------------- -/// @name Managing Callback Queues -///------------------------------- - -/** - The dispatch queue for the `completionBlock` of request operations. If `NULL` (default), the main queue is used. - */ -@property (nonatomic, strong) dispatch_queue_t completionQueue; - -/** - The dispatch group for the `completionBlock` of request operations. If `NULL` (default), a private dispatch group is used. - */ -@property (nonatomic, strong) dispatch_group_t completionGroup; - -///--------------------------------------------- -/// @name Creating and Initializing HTTP Clients -///--------------------------------------------- - -/** - Creates and returns an `AFHTTPRequestOperationManager` object. - */ -+ (instancetype)manager; - -/** - Initializes an `AFHTTPRequestOperationManager` object with the specified base URL. - - This is the designated initializer. - - @param url The base URL for the HTTP client. - - @return The newly-initialized HTTP client - */ -- (instancetype)initWithBaseURL:(NSURL *)url; - -///--------------------------------------- -/// @name Managing HTTP Request Operations -///--------------------------------------- - -/** - Creates an `AFHTTPRequestOperation`, and sets the response serializers to that of the HTTP client. - - @param request The request object to be loaded asynchronously during execution of the operation. - @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the created request operation and the object created from the response data of request. - @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes two arguments:, the created request operation and the `NSError` object describing the network or parsing error that occurred. - */ -- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)request - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; - -///--------------------------- -/// @name Making HTTP Requests -///--------------------------- - -/** - Creates and runs an `AFHTTPRequestOperation` with a `GET` request. - - @param URLString The URL string used to create the request URL. - @param parameters The parameters to be encoded according to the client request serializer. - @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. - @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. - - @see -HTTPRequestOperationWithRequest:success:failure: - */ -- (AFHTTPRequestOperation *)GET:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; - -/** - Creates and runs an `AFHTTPRequestOperation` with a `HEAD` request. - - @param URLString The URL string used to create the request URL. - @param parameters The parameters to be encoded according to the client request serializer. - @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes a single arguments: the request operation. - @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. - - @see -HTTPRequestOperationWithRequest:success:failure: - */ -- (AFHTTPRequestOperation *)HEAD:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(AFHTTPRequestOperation *operation))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; - -/** - Creates and runs an `AFHTTPRequestOperation` with a `POST` request. - - @param URLString The URL string used to create the request URL. - @param parameters The parameters to be encoded according to the client request serializer. - @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. - @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. - - @see -HTTPRequestOperationWithRequest:success:failure: - */ -- (AFHTTPRequestOperation *)POST:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; - -/** - Creates and runs an `AFHTTPRequestOperation` with a multipart `POST` request. - - @param URLString The URL string used to create the request URL. - @param parameters The parameters to be encoded according to the client request serializer. - @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. - @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. - @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. - - @see -HTTPRequestOperationWithRequest:success:failure: - */ -- (AFHTTPRequestOperation *)POST:(NSString *)URLString - parameters:(id)parameters - constructingBodyWithBlock:(void (^)(id formData))block - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; - -/** - Creates and runs an `AFHTTPRequestOperation` with a `PUT` request. - - @param URLString The URL string used to create the request URL. - @param parameters The parameters to be encoded according to the client request serializer. - @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. - @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. - - @see -HTTPRequestOperationWithRequest:success:failure: - */ -- (AFHTTPRequestOperation *)PUT:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; - -/** - Creates and runs an `AFHTTPRequestOperation` with a `PATCH` request. - - @param URLString The URL string used to create the request URL. - @param parameters The parameters to be encoded according to the client request serializer. - @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. - @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. - - @see -HTTPRequestOperationWithRequest:success:failure: - */ -- (AFHTTPRequestOperation *)PATCH:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; - -/** - Creates and runs an `AFHTTPRequestOperation` with a `DELETE` request. - - @param URLString The URL string used to create the request URL. - @param parameters The parameters to be encoded according to the client request serializer. - @param success A block object to be executed when the request operation finishes successfully. This block has no return value and takes two arguments: the request operation, and the response object created by the client response serializer. - @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. - - @see -HTTPRequestOperationWithRequest:success:failure: - */ -- (AFHTTPRequestOperation *)DELETE:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; - -@end - diff --git a/Ryff/Frameworks/AFNetworking/AFHTTPRequestOperationManager.m b/Ryff/Frameworks/AFNetworking/AFHTTPRequestOperationManager.m deleted file mode 100755 index 03116cc..0000000 --- a/Ryff/Frameworks/AFNetworking/AFHTTPRequestOperationManager.m +++ /dev/null @@ -1,253 +0,0 @@ -// AFHTTPRequestOperationManager.m -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import - -#import "AFHTTPRequestOperationManager.h" -#import "AFHTTPRequestOperation.h" - -#import -#import - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -#import -#endif - -@interface AFHTTPRequestOperationManager () -@property (readwrite, nonatomic, strong) NSURL *baseURL; -@end - -@implementation AFHTTPRequestOperationManager - -+ (instancetype)manager { - return [[self alloc] initWithBaseURL:nil]; -} - -- (instancetype)init { - return [self initWithBaseURL:nil]; -} - -- (instancetype)initWithBaseURL:(NSURL *)url { - self = [super init]; - if (!self) { - return nil; - } - - // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected - if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { - url = [url URLByAppendingPathComponent:@""]; - } - - self.baseURL = url; - - self.requestSerializer = [AFHTTPRequestSerializer serializer]; - self.responseSerializer = [AFJSONResponseSerializer serializer]; - - self.securityPolicy = [AFSecurityPolicy defaultPolicy]; - - self.reachabilityManager = [AFNetworkReachabilityManager sharedManager]; - - self.operationQueue = [[NSOperationQueue alloc] init]; - - self.shouldUseCredentialStorage = YES; - - return self; -} - -#pragma mark - - -#ifdef _SYSTEMCONFIGURATION_H -#endif - -- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { - NSParameterAssert(requestSerializer); - - _requestSerializer = requestSerializer; -} - -- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { - NSParameterAssert(responseSerializer); - - _responseSerializer = responseSerializer; -} - -#pragma mark - - -- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)request - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure -{ - AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; - operation.responseSerializer = self.responseSerializer; - operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage; - operation.credential = self.credential; - operation.securityPolicy = self.securityPolicy; - - [operation setCompletionBlockWithSuccess:success failure:failure]; - operation.completionQueue = self.completionQueue; - operation.completionGroup = self.completionGroup; - - return operation; -} - -#pragma mark - - -- (AFHTTPRequestOperation *)GET:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure -{ - NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"GET" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; - AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; - - [self.operationQueue addOperation:operation]; - - return operation; -} - -- (AFHTTPRequestOperation *)HEAD:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(AFHTTPRequestOperation *operation))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure -{ - NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"HEAD" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; - AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *requestOperation, __unused id responseObject) { - if (success) { - success(requestOperation); - } - } failure:failure]; - - [self.operationQueue addOperation:operation]; - - return operation; -} - -- (AFHTTPRequestOperation *)POST:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure -{ - NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; - AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; - - [self.operationQueue addOperation:operation]; - - return operation; -} - -- (AFHTTPRequestOperation *)POST:(NSString *)URLString - parameters:(id)parameters - constructingBodyWithBlock:(void (^)(id formData))block - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure -{ - NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:nil]; - AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; - - [self.operationQueue addOperation:operation]; - - return operation; -} - -- (AFHTTPRequestOperation *)PUT:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure -{ - NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"PUT" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; - AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; - - [self.operationQueue addOperation:operation]; - - return operation; -} - -- (AFHTTPRequestOperation *)PATCH:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure -{ - NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"PATCH" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; - AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; - - [self.operationQueue addOperation:operation]; - - return operation; -} - -- (AFHTTPRequestOperation *)DELETE:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure -{ - NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"DELETE" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; - AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; - - [self.operationQueue addOperation:operation]; - - return operation; -} - -#pragma mark - NSObject - -- (NSString *)description { - return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.operationQueue]; -} - -#pragma mark - NSecureCoding - -+ (BOOL)supportsSecureCoding { - return YES; -} - -- (id)initWithCoder:(NSCoder *)decoder { - NSURL *baseURL = [decoder decodeObjectForKey:NSStringFromSelector(@selector(baseURL))]; - - self = [self initWithBaseURL:baseURL]; - if (!self) { - return nil; - } - - self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))]; - self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))]; - [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))]; - [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; -} - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone { - AFHTTPRequestOperationManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL]; - - HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone]; - HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone]; - - return HTTPClient; -} - -@end diff --git a/Ryff/Frameworks/AFNetworking/AFHTTPSessionManager.h b/Ryff/Frameworks/AFNetworking/AFHTTPSessionManager.h deleted file mode 100755 index a84fcc5..0000000 --- a/Ryff/Frameworks/AFNetworking/AFHTTPSessionManager.h +++ /dev/null @@ -1,238 +0,0 @@ -// AFHTTPSessionManager.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import -#import -#import - -#if __IPHONE_OS_VERSION_MIN_REQUIRED -#import -#else -#import -#endif - -#import "AFURLSessionManager.h" - -/** - `AFHTTPSessionManager` is a subclass of `AFURLSessionManager` with convenience methods for making HTTP requests. When a `baseURL` is provided, requests made with the `GET` / `POST` / et al. convenience methods can be made with relative paths. - - ## Subclassing Notes - - Developers targeting iOS 7 or Mac OS X 10.9 or later that deal extensively with a web service are encouraged to subclass `AFHTTPSessionManager`, providing a class method that returns a shared singleton object on which authentication and other configuration can be shared across the application. - - For developers targeting iOS 6 or Mac OS X 10.8 or earlier, `AFHTTPRequestOperationManager` may be used to similar effect. - - ## Methods to Override - - To change the behavior of all data task operation construction, which is also used in the `GET` / `POST` / et al. convenience methods, override `dataTaskWithRequest:completionHandler:`. - - ## Serialization - - Requests created by an HTTP client will contain default headers and encode parameters according to the `requestSerializer` property, which is an object conforming to ``. - - Responses received from the server are automatically validated and serialized by the `responseSerializers` property, which is an object conforming to `` - - ## URL Construction Using Relative Paths - - For HTTP convenience methods, the request serializer constructs URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`, when provided. If `baseURL` is `nil`, `path` needs to resolve to a valid `NSURL` object using `NSURL +URLWithString:`. - - Below are a few examples of how `baseURL` and relative paths interact: - - NSURL *baseURL = [NSURL URLWithString:@"http://example.com/v1/"]; - [NSURL URLWithString:@"foo" relativeToURL:baseURL]; // http://example.com/v1/foo - [NSURL URLWithString:@"foo?bar=baz" relativeToURL:baseURL]; // http://example.com/v1/foo?bar=baz - [NSURL URLWithString:@"/foo" relativeToURL:baseURL]; // http://example.com/foo - [NSURL URLWithString:@"foo/" relativeToURL:baseURL]; // http://example.com/v1/foo - [NSURL URLWithString:@"/foo/" relativeToURL:baseURL]; // http://example.com/foo/ - [NSURL URLWithString:@"http://example2.com/" relativeToURL:baseURL]; // http://example2.com/ - - Also important to note is that a trailing slash will be added to any `baseURL` without one. This would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash. - */ - -#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) - -@interface AFHTTPSessionManager : AFURLSessionManager - -/** - The URL used to monitor reachability, and construct requests from relative paths in methods like `requestWithMethod:URLString:parameters:`, and the `GET` / `POST` / et al. convenience methods. - */ -@property (readonly, nonatomic, strong) NSURL *baseURL; - -/** - Requests created with `requestWithMethod:URLString:parameters:` & `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:` are constructed with a set of default headers using a parameter serialization specified by this property. By default, this is set to an instance of `AFHTTPRequestSerializer`, which serializes query string parameters for `GET`, `HEAD`, and `DELETE` requests, or otherwise URL-form-encodes HTTP message bodies. - - @warning `requestSerializer` must not be `nil`. - */ -@property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; - -/** - Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`. - - @warning `responseSerializer` must not be `nil`. - */ -@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; - -///--------------------- -/// @name Initialization -///--------------------- - -/** - Creates and returns an `AFHTTPSessionManager` object. - */ -+ (instancetype)manager; - -/** - Initializes an `AFHTTPSessionManager` object with the specified base URL. - - @param url The base URL for the HTTP client. - - @return The newly-initialized HTTP client - */ -- (instancetype)initWithBaseURL:(NSURL *)url; - -/** - Initializes an `AFHTTPSessionManager` object with the specified base URL. - - This is the designated initializer. - - @param url The base URL for the HTTP client. - @param configuration The configuration used to create the managed session. - - @return The newly-initialized HTTP client - */ -- (instancetype)initWithBaseURL:(NSURL *)url - sessionConfiguration:(NSURLSessionConfiguration *)configuration; - -///--------------------------- -/// @name Making HTTP Requests -///--------------------------- - -/** - Creates and runs an `NSURLSessionDataTask` with a `GET` request. - - @param URLString The URL string used to create the request URL. - @param parameters The parameters to be encoded according to the client request serializer. - @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. - @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. - - @see -dataTaskWithRequest:completionHandler: - */ -- (NSURLSessionDataTask *)GET:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(NSURLSessionDataTask *task, id responseObject))success - failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; - -/** - Creates and runs an `NSURLSessionDataTask` with a `HEAD` request. - - @param URLString The URL string used to create the request URL. - @param parameters The parameters to be encoded according to the client request serializer. - @param success A block object to be executed when the task finishes successfully. This block has no return value and takes a single arguments: the data task. - @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. - - @see -dataTaskWithRequest:completionHandler: - */ -- (NSURLSessionDataTask *)HEAD:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(NSURLSessionDataTask *task))success - failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; - -/** - Creates and runs an `NSURLSessionDataTask` with a `POST` request. - - @param URLString The URL string used to create the request URL. - @param parameters The parameters to be encoded according to the client request serializer. - @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. - @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. - - @see -dataTaskWithRequest:completionHandler: - */ -- (NSURLSessionDataTask *)POST:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(NSURLSessionDataTask *task, id responseObject))success - failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; - -/** - Creates and runs an `NSURLSessionDataTask` with a multipart `POST` request. - - @param URLString The URL string used to create the request URL. - @param parameters The parameters to be encoded according to the client request serializer. - @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. - @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. - @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. - - @see -dataTaskWithRequest:completionHandler: - */ -- (NSURLSessionDataTask *)POST:(NSString *)URLString - parameters:(id)parameters - constructingBodyWithBlock:(void (^)(id formData))block - success:(void (^)(NSURLSessionDataTask *task, id responseObject))success - failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; - -/** - Creates and runs an `NSURLSessionDataTask` with a `PUT` request. - - @param URLString The URL string used to create the request URL. - @param parameters The parameters to be encoded according to the client request serializer. - @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. - @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. - - @see -dataTaskWithRequest:completionHandler: - */ -- (NSURLSessionDataTask *)PUT:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(NSURLSessionDataTask *task, id responseObject))success - failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; - -/** - Creates and runs an `NSURLSessionDataTask` with a `PATCH` request. - - @param URLString The URL string used to create the request URL. - @param parameters The parameters to be encoded according to the client request serializer. - @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. - @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. - - @see -dataTaskWithRequest:completionHandler: - */ -- (NSURLSessionDataTask *)PATCH:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(NSURLSessionDataTask *task, id responseObject))success - failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; - -/** - Creates and runs an `NSURLSessionDataTask` with a `DELETE` request. - - @param URLString The URL string used to create the request URL. - @param parameters The parameters to be encoded according to the client request serializer. - @param success A block object to be executed when the task finishes successfully. This block has no return value and takes two arguments: the data task, and the response object created by the client response serializer. - @param failure A block object to be executed when the task finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the data task and the error describing the network or parsing error that occurred. - - @see -dataTaskWithRequest:completionHandler: - */ -- (NSURLSessionDataTask *)DELETE:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(NSURLSessionDataTask *task, id responseObject))success - failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; - -@end - -#endif diff --git a/Ryff/Frameworks/AFNetworking/AFHTTPSessionManager.m b/Ryff/Frameworks/AFNetworking/AFHTTPSessionManager.m deleted file mode 100755 index 5abfe7e..0000000 --- a/Ryff/Frameworks/AFNetworking/AFHTTPSessionManager.m +++ /dev/null @@ -1,339 +0,0 @@ -// AFHTTPSessionManager.m -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import "AFHTTPSessionManager.h" - -#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) - -#import "AFURLRequestSerialization.h" -#import "AFURLResponseSerialization.h" - -#import -#import - -#ifdef _SYSTEMCONFIGURATION_H -#import -#import -#import -#import -#import -#endif - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -#import -#endif - -@interface AFHTTPSessionManager () -@property (readwrite, nonatomic, strong) NSURL *baseURL; -@end - -@implementation AFHTTPSessionManager - -+ (instancetype)manager { - return [[[self class] alloc] initWithBaseURL:nil]; -} - -- (instancetype)init { - return [self initWithBaseURL:nil]; -} - -- (instancetype)initWithBaseURL:(NSURL *)url { - return [self initWithBaseURL:url sessionConfiguration:nil]; -} - -- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { - return [self initWithBaseURL:nil sessionConfiguration:configuration]; -} - -- (instancetype)initWithBaseURL:(NSURL *)url - sessionConfiguration:(NSURLSessionConfiguration *)configuration -{ - self = [super initWithSessionConfiguration:configuration]; - if (!self) { - return nil; - } - - // Ensure terminal slash for baseURL path, so that NSURL +URLWithString:relativeToURL: works as expected - if ([[url path] length] > 0 && ![[url absoluteString] hasSuffix:@"/"]) { - url = [url URLByAppendingPathComponent:@""]; - } - - self.baseURL = url; - - self.requestSerializer = [AFHTTPRequestSerializer serializer]; - self.responseSerializer = [AFJSONResponseSerializer serializer]; - - return self; -} - -#pragma mark - - -#ifdef _SYSTEMCONFIGURATION_H -#endif - -- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { - NSParameterAssert(requestSerializer); - - _requestSerializer = requestSerializer; -} - -- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { - NSParameterAssert(responseSerializer); - - [super setResponseSerializer:responseSerializer]; -} - -#pragma mark - - -- (NSURLSessionDataTask *)GET:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(NSURLSessionDataTask *task, id responseObject))success - failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure -{ - NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"GET" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; - - __block NSURLSessionDataTask *task = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { - if (error) { - if (failure) { - failure(task, error); - } - } else { - if (success) { - success(task, responseObject); - } - } - }]; - - [task resume]; - - return task; -} - -- (NSURLSessionDataTask *)HEAD:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(NSURLSessionDataTask *task))success - failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure -{ - NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"HEAD" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; - - __block NSURLSessionDataTask *task = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id __unused responseObject, NSError *error) { - if (error) { - if (failure) { - failure(task, error); - } - } else { - if (success) { - success(task); - } - } - }]; - - [task resume]; - - return task; -} - -- (NSURLSessionDataTask *)POST:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(NSURLSessionDataTask *task, id responseObject))success - failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure -{ - NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; - - __block NSURLSessionDataTask *task = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { - if (error) { - if (failure) { - failure(task, error); - } - } else { - if (success) { - success(task, responseObject); - } - } - }]; - - [task resume]; - - return task; -} - -- (NSURLSessionDataTask *)POST:(NSString *)URLString - parameters:(id)parameters - constructingBodyWithBlock:(void (^)(id formData))block - success:(void (^)(NSURLSessionDataTask *task, id responseObject))success - failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure -{ - NSMutableURLRequest *request = [self.requestSerializer multipartFormRequestWithMethod:@"POST" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters constructingBodyWithBlock:block error:nil]; - - __block NSURLSessionDataTask *task = [self uploadTaskWithStreamedRequest:request progress:nil completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { - if (error) { - if (failure) { - failure(task, error); - } - } else { - if (success) { - success(task, responseObject); - } - } - }]; - - [task resume]; - - return task; -} - -- (NSURLSessionDataTask *)PUT:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(NSURLSessionDataTask *task, id responseObject))success - failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure -{ - NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"PUT" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; - - __block NSURLSessionDataTask *task = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { - if (error) { - if (failure) { - failure(task, error); - } - } else { - if (success) { - success(task, responseObject); - } - } - }]; - - [task resume]; - - return task; -} - -- (NSURLSessionDataTask *)PATCH:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(NSURLSessionDataTask *task, id responseObject))success - failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure -{ - NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"PATCH" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; - - __block NSURLSessionDataTask *task = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { - if (error) { - if (failure) { - failure(task, error); - } - } else { - if (success) { - success(task, responseObject); - } - } - }]; - - [task resume]; - - return task; -} - -- (NSURLSessionDataTask *)DELETE:(NSString *)URLString - parameters:(id)parameters - success:(void (^)(NSURLSessionDataTask *task, id responseObject))success - failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure -{ - NSMutableURLRequest *request = [self.requestSerializer requestWithMethod:@"DELETE" URLString:[[NSURL URLWithString:URLString relativeToURL:self.baseURL] absoluteString] parameters:parameters error:nil]; - - __block NSURLSessionDataTask *task = [self dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) { - if (error) { - if (failure) { - failure(task, error); - } - } else { - if (success) { - success(task, responseObject); - } - } - }]; - - [task resume]; - - return task; -} - -#pragma mark - NSObject - -- (NSString *)description { - return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.session, self.operationQueue]; -} - -#pragma mark - NSecureCoding - -+ (BOOL)supportsSecureCoding { - return YES; -} - -- (id)initWithCoder:(NSCoder *)decoder { - NSURL *baseURL = [decoder decodeObjectOfClass:[NSURL class] forKey:NSStringFromSelector(@selector(baseURL))]; - NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; - if (!configuration) { - NSString *configurationIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"identifier"]; - if (configurationIdentifier) { -#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1100) - configuration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:configurationIdentifier]; -#else - configuration = [NSURLSessionConfiguration backgroundSessionConfiguration:configurationIdentifier]; -#endif - } - } - - self = [self initWithBaseURL:baseURL sessionConfiguration:configuration]; - if (!self) { - return nil; - } - - self.requestSerializer = [decoder decodeObjectOfClass:[AFHTTPRequestSerializer class] forKey:NSStringFromSelector(@selector(requestSerializer))]; - self.responseSerializer = [decoder decodeObjectOfClass:[AFHTTPResponseSerializer class] forKey:NSStringFromSelector(@selector(responseSerializer))]; - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [super encodeWithCoder:coder]; - - [coder encodeObject:self.baseURL forKey:NSStringFromSelector(@selector(baseURL))]; - if ([self.session.configuration conformsToProtocol:@protocol(NSCoding)]) { - [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"]; - } else { - [coder encodeObject:self.session.configuration.identifier forKey:@"identifier"]; - } - [coder encodeObject:self.requestSerializer forKey:NSStringFromSelector(@selector(requestSerializer))]; - [coder encodeObject:self.responseSerializer forKey:NSStringFromSelector(@selector(responseSerializer))]; -} - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone { - AFHTTPSessionManager *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL sessionConfiguration:self.session.configuration]; - - HTTPClient.requestSerializer = [self.requestSerializer copyWithZone:zone]; - HTTPClient.responseSerializer = [self.responseSerializer copyWithZone:zone]; - - return HTTPClient; -} - -@end - -#endif diff --git a/Ryff/Frameworks/AFNetworking/AFNetworkReachabilityManager.h b/Ryff/Frameworks/AFNetworking/AFNetworkReachabilityManager.h deleted file mode 100755 index 6320783..0000000 --- a/Ryff/Frameworks/AFNetworking/AFNetworkReachabilityManager.h +++ /dev/null @@ -1,199 +0,0 @@ -// AFNetworkReachabilityManager.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import -#import - -#import -#import -#import -#import -#import - -typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) { - AFNetworkReachabilityStatusUnknown = -1, - AFNetworkReachabilityStatusNotReachable = 0, - AFNetworkReachabilityStatusReachableViaWWAN = 1, - AFNetworkReachabilityStatusReachableViaWiFi = 2, -}; - -/** - `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. - - Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability. - - See Apple's Reachability Sample Code (https://developer.apple.com/library/ios/samplecode/reachability/) - - @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined. - */ -@interface AFNetworkReachabilityManager : NSObject - -/** - The current network reachability status. - */ -@property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; - -/** - Whether or not the network is currently reachable. - */ -@property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable; - -/** - Whether or not the network is currently reachable via WWAN. - */ -@property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN; - -/** - Whether or not the network is currently reachable via WiFi. - */ -@property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi; - -///--------------------- -/// @name Initialization -///--------------------- - -/** - Returns the shared network reachability manager. - */ -+ (instancetype)sharedManager; - -/** - Creates and returns a network reachability manager for the specified domain. - - @param domain The domain used to evaluate network reachability. - - @return An initialized network reachability manager, actively monitoring the specified domain. - */ -+ (instancetype)managerForDomain:(NSString *)domain; - -/** - Creates and returns a network reachability manager for the socket address. - - @param address The socket address used to evaluate network reachability. - - @return An initialized network reachability manager, actively monitoring the specified socket address. - */ -+ (instancetype)managerForAddress:(const struct sockaddr_in *)address; - -/** - Initializes an instance of a network reachability manager from the specified reachability object. - - @param reachability The reachability object to monitor. - - @return An initialized network reachability manager, actively monitoring the specified reachability. - */ -- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability; - -///-------------------------------------------------- -/// @name Starting & Stopping Reachability Monitoring -///-------------------------------------------------- - -/** - Starts monitoring for changes in network reachability status. - */ -- (void)startMonitoring; - -/** - Stops monitoring for changes in network reachability status. - */ -- (void)stopMonitoring; - -///------------------------------------------------- -/// @name Getting Localized Reachability Description -///------------------------------------------------- - -/** - Returns a localized string representation of the current network reachability status. - */ -- (NSString *)localizedNetworkReachabilityStatusString; - -///--------------------------------------------------- -/// @name Setting Network Reachability Change Callback -///--------------------------------------------------- - -/** - Sets a callback to be executed when the network availability of the `baseURL` host changes. - - @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`. - */ -- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block; - -@end - -///---------------- -/// @name Constants -///---------------- - -/** - ## Network Reachability - - The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses. - - enum { - AFNetworkReachabilityStatusUnknown, - AFNetworkReachabilityStatusNotReachable, - AFNetworkReachabilityStatusReachableViaWWAN, - AFNetworkReachabilityStatusReachableViaWiFi, - } - - `AFNetworkReachabilityStatusUnknown` - The `baseURL` host reachability is not known. - - `AFNetworkReachabilityStatusNotReachable` - The `baseURL` host cannot be reached. - - `AFNetworkReachabilityStatusReachableViaWWAN` - The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS. - - `AFNetworkReachabilityStatusReachableViaWiFi` - The `baseURL` host can be reached via a Wi-Fi connection. - - ### Keys for Notification UserInfo Dictionary - - Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification. - - `AFNetworkingReachabilityNotificationStatusItem` - A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification. - The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. - */ - -///-------------------- -/// @name Notifications -///-------------------- - -/** - Posted when network reachability changes. - This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability. - - @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). - */ -extern NSString * const AFNetworkingReachabilityDidChangeNotification; -extern NSString * const AFNetworkingReachabilityNotificationStatusItem; - -///-------------------- -/// @name Functions -///-------------------- - -/** - Returns a localized string representation of an `AFNetworkReachabilityStatus` value. - */ -extern NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status); diff --git a/Ryff/Frameworks/AFNetworking/AFNetworkReachabilityManager.m b/Ryff/Frameworks/AFNetworking/AFNetworkReachabilityManager.m deleted file mode 100755 index 71adaef..0000000 --- a/Ryff/Frameworks/AFNetworking/AFNetworkReachabilityManager.m +++ /dev/null @@ -1,253 +0,0 @@ -// AFNetworkReachabilityManager.m -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import "AFNetworkReachabilityManager.h" - -NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change"; -NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem"; - -typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status); - -typedef NS_ENUM(NSUInteger, AFNetworkReachabilityAssociation) { - AFNetworkReachabilityForAddress = 1, - AFNetworkReachabilityForAddressPair = 2, - AFNetworkReachabilityForName = 3, -}; - -NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) { - switch (status) { - case AFNetworkReachabilityStatusNotReachable: - return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil); - case AFNetworkReachabilityStatusReachableViaWWAN: - return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil); - case AFNetworkReachabilityStatusReachableViaWiFi: - return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil); - case AFNetworkReachabilityStatusUnknown: - default: - return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil); - } -} - -static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) { - BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); - BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); - BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)); - BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0); - BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction)); - - AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown; - if (isNetworkReachable == NO) { - status = AFNetworkReachabilityStatusNotReachable; - } -#if TARGET_OS_IPHONE - else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { - status = AFNetworkReachabilityStatusReachableViaWWAN; - } -#endif - else { - status = AFNetworkReachabilityStatusReachableViaWiFi; - } - - return status; -} - -static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) { - AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); - AFNetworkReachabilityStatusBlock block = (__bridge AFNetworkReachabilityStatusBlock)info; - if (block) { - block(status); - } - - - dispatch_async(dispatch_get_main_queue(), ^{ - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; - [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:@{ AFNetworkingReachabilityNotificationStatusItem: @(status) }]; - }); - -} - -static const void * AFNetworkReachabilityRetainCallback(const void *info) { - return Block_copy(info); -} - -static void AFNetworkReachabilityReleaseCallback(const void *info) { - if (info) { - Block_release(info); - } -} - -@interface AFNetworkReachabilityManager () -@property (readwrite, nonatomic, assign) SCNetworkReachabilityRef networkReachability; -@property (readwrite, nonatomic, assign) AFNetworkReachabilityAssociation networkReachabilityAssociation; -@property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; -@property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock; -@end - -@implementation AFNetworkReachabilityManager - -+ (instancetype)sharedManager { - static AFNetworkReachabilityManager *_sharedManager = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - struct sockaddr_in address; - bzero(&address, sizeof(address)); - address.sin_len = sizeof(address); - address.sin_family = AF_INET; - - _sharedManager = [self managerForAddress:&address]; - }); - - return _sharedManager; -} - -+ (instancetype)managerForDomain:(NSString *)domain { - SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]); - - AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; - manager.networkReachabilityAssociation = AFNetworkReachabilityForName; - - return manager; -} - -+ (instancetype)managerForAddress:(const struct sockaddr_in *)address { - SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address); - - AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; - manager.networkReachabilityAssociation = AFNetworkReachabilityForAddress; - - return manager; -} - -- (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability { - self = [super init]; - if (!self) { - return nil; - } - - self.networkReachability = reachability; - self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; - - return self; -} - -- (void)dealloc { - [self stopMonitoring]; - - if (_networkReachability) { - CFRelease(_networkReachability); - _networkReachability = NULL; - } -} - -#pragma mark - - -- (BOOL)isReachable { - return [self isReachableViaWWAN] || [self isReachableViaWiFi]; -} - -- (BOOL)isReachableViaWWAN { - return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN; -} - -- (BOOL)isReachableViaWiFi { - return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi; -} - -#pragma mark - - -- (void)startMonitoring { - [self stopMonitoring]; - - if (!self.networkReachability) { - return; - } - - __weak __typeof(self)weakSelf = self; - AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) { - __strong __typeof(weakSelf)strongSelf = weakSelf; - - strongSelf.networkReachabilityStatus = status; - if (strongSelf.networkReachabilityStatusBlock) { - strongSelf.networkReachabilityStatusBlock(status); - } - - }; - - SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; - SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context); - SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); - - switch (self.networkReachabilityAssociation) { - case AFNetworkReachabilityForName: - break; - case AFNetworkReachabilityForAddress: - case AFNetworkReachabilityForAddressPair: - default: { - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{ - SCNetworkReachabilityFlags flags; - SCNetworkReachabilityGetFlags(self.networkReachability, &flags); - AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); - dispatch_async(dispatch_get_main_queue(), ^{ - callback(status); - - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; - [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:@{ AFNetworkingReachabilityNotificationStatusItem: @(status) }]; - - - }); - }); - } - break; - } -} - -- (void)stopMonitoring { - if (!self.networkReachability) { - return; - } - - SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); -} - -#pragma mark - - -- (NSString *)localizedNetworkReachabilityStatusString { - return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus); -} - -#pragma mark - - -- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block { - self.networkReachabilityStatusBlock = block; -} - -#pragma mark - NSKeyValueObserving - -+ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { - if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) { - return [NSSet setWithObject:@"networkReachabilityStatus"]; - } - - return [super keyPathsForValuesAffectingValueForKey:key]; -} - -@end diff --git a/Ryff/Frameworks/AFNetworking/AFNetworking.h b/Ryff/Frameworks/AFNetworking/AFNetworking.h deleted file mode 100755 index 68273da..0000000 --- a/Ryff/Frameworks/AFNetworking/AFNetworking.h +++ /dev/null @@ -1,44 +0,0 @@ -// AFNetworking.h -// -// Copyright (c) 2013 AFNetworking (http://afnetworking.com/) -// -// 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. - -#import -#import - -#ifndef _AFNETWORKING_ - #define _AFNETWORKING_ - - #import "AFURLRequestSerialization.h" - #import "AFURLResponseSerialization.h" - #import "AFSecurityPolicy.h" - #import "AFNetworkReachabilityManager.h" - - #import "AFURLConnectionOperation.h" - #import "AFHTTPRequestOperation.h" - #import "AFHTTPRequestOperationManager.h" - -#if ( ( defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || \ - ( defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 ) ) - #import "AFURLSessionManager.h" - #import "AFHTTPSessionManager.h" -#endif - -#endif /* _AFNETWORKING_ */ diff --git a/Ryff/Frameworks/AFNetworking/AFSecurityPolicy.h b/Ryff/Frameworks/AFNetworking/AFSecurityPolicy.h deleted file mode 100755 index b86e76b..0000000 --- a/Ryff/Frameworks/AFNetworking/AFSecurityPolicy.h +++ /dev/null @@ -1,143 +0,0 @@ -// AFSecurity.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import -#import - -typedef NS_ENUM(NSUInteger, AFSSLPinningMode) { - AFSSLPinningModeNone, - AFSSLPinningModePublicKey, - AFSSLPinningModeCertificate, -}; - -/** - `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. - - Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. - */ -@interface AFSecurityPolicy : NSObject - -/** - The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`. - */ -@property (nonatomic, assign) AFSSLPinningMode SSLPinningMode; - -/** - Whether to evaluate an entire SSL certificate chain, or just the leaf certificate. Defaults to `YES`. - */ -@property (nonatomic, assign) BOOL validatesCertificateChain; - -/** - The certificates used to evaluate server trust according to the SSL pinning mode. By default, this property is set to any (`.cer`) certificates included in the app bundle. - */ -@property (nonatomic, strong) NSArray *pinnedCertificates; - -/** - Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. - */ -@property (nonatomic, assign) BOOL allowInvalidCertificates; - -/** - Whether or not to validate the domain name in the certificates CN field. Defaults to `YES` for `AFSSLPinningModePublicKey` or `AFSSLPinningModeCertificate`, otherwise `NO`. - */ -@property (nonatomic, assign) BOOL validatesDomainName; - -///----------------------------------------- -/// @name Getting Specific Security Policies -///----------------------------------------- - -/** - Returns the shared default security policy, which does not accept invalid certificates, and does not validate against pinned certificates or public keys. - - @return The default security policy. - */ -+ (instancetype)defaultPolicy; - -///--------------------- -/// @name Initialization -///--------------------- - -/** - Creates and returns a security policy with the specified pinning mode. - - @param pinningMode The SSL pinning mode. - - @return A new security policy. - */ -+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; - -///------------------------------ -/// @name Evaluating Server Trust -///------------------------------ - -/** - Whether or not the specified server trust should be accepted, based on the security policy. - - This method should be used when responding to an authentication challenge from a server. - - @param serverTrust The X.509 certificate trust of the server. - - @return Whether or not to trust the server. - - @warning This method has been deprecated in favor of `-evaluateServerTrust:forDomain:`. - */ -- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust DEPRECATED_ATTRIBUTE; - -/** - Whether or not the specified server trust should be accepted, based on the security policy. - - This method should be used when responding to an authentication challenge from a server. - - @param serverTrust The X.509 certificate trust of the server. - @param domain The domain of serverTrust. If `nil`, the domain will not be validated. - - @return Whether or not to trust the server. - */ -- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust - forDomain:(NSString *)domain; - -@end - -///---------------- -/// @name Constants -///---------------- - -/** - ## SSL Pinning Modes - - The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. - - enum { - AFSSLPinningModeNone, - AFSSLPinningModePublicKey, - AFSSLPinningModeCertificate, - } - - `AFSSLPinningModeNone` - Do not used pinned certificates to validate servers. - - `AFSSLPinningModePublicKey` - Validate host certificates against public keys of pinned certificates. - - `AFSSLPinningModeCertificate` - Validate host certificates against pinned certificates. -*/ diff --git a/Ryff/Frameworks/AFNetworking/AFSecurityPolicy.m b/Ryff/Frameworks/AFNetworking/AFSecurityPolicy.m deleted file mode 100755 index f11caaa..0000000 --- a/Ryff/Frameworks/AFNetworking/AFSecurityPolicy.m +++ /dev/null @@ -1,320 +0,0 @@ -// AFSecurity.m -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import "AFSecurityPolicy.h" - -// Equivalent of macro in , without causing compiler warning: -// "'DebugAssert' is deprecated: first deprecated in OS X 10.8" -#ifndef AF_Require - #define AF_Require(assertion, exceptionLabel) \ - do { \ - if (__builtin_expect(!(assertion), 0)) { \ - goto exceptionLabel; \ - } \ - } while (0) -#endif - -#ifndef AF_Require_noErr - #define AF_Require_noErr(errorCode, exceptionLabel) \ - do { \ - if (__builtin_expect(0 != (errorCode), 0)) { \ - goto exceptionLabel; \ - } \ - } while (0) -#endif - -#if !defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -static NSData * AFSecKeyGetData(SecKeyRef key) { - CFDataRef data = NULL; - - AF_Require_noErr(SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data), _out); - - return (__bridge_transfer NSData *)data; - -_out: - if (data) { - CFRelease(data); - } - - return nil; -} -#endif - -static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) { -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - return [(__bridge id)key1 isEqual:(__bridge id)key2]; -#else - return [AFSecKeyGetData(key1) isEqual:AFSecKeyGetData(key2)]; -#endif -} - -static id AFPublicKeyForCertificate(NSData *certificate) { - id allowedPublicKey = nil; - SecCertificateRef allowedCertificate; - SecCertificateRef allowedCertificates[1]; - CFArrayRef tempCertificates = nil; - SecPolicyRef policy = nil; - SecTrustRef allowedTrust = nil; - SecTrustResultType result; - - allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificate); - AF_Require(allowedCertificate != NULL, _out); - - allowedCertificates[0] = allowedCertificate; - tempCertificates = CFArrayCreate(NULL, (const void **)allowedCertificates, 1, NULL); - - policy = SecPolicyCreateBasicX509(); - AF_Require_noErr(SecTrustCreateWithCertificates(tempCertificates, policy, &allowedTrust), _out); - AF_Require_noErr(SecTrustEvaluate(allowedTrust, &result), _out); - - allowedPublicKey = (__bridge_transfer id)SecTrustCopyPublicKey(allowedTrust); - -_out: - if (allowedTrust) { - CFRelease(allowedTrust); - } - - if (policy) { - CFRelease(policy); - } - - if (tempCertificates) { - CFRelease(tempCertificates); - } - - if (allowedCertificate) { - CFRelease(allowedCertificate); - } - - return allowedPublicKey; -} - -static BOOL AFServerTrustIsValid(SecTrustRef serverTrust) { - BOOL isValid = NO; - SecTrustResultType result; - AF_Require_noErr(SecTrustEvaluate(serverTrust, &result), _out); - - isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed); - -_out: - return isValid; -} - -static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) { - CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); - NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; - - for (CFIndex i = 0; i < certificateCount; i++) { - SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); - [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)]; - } - - return [NSArray arrayWithArray:trustChain]; -} - -static NSArray * AFPublicKeyTrustChainForServerTrust(SecTrustRef serverTrust) { - SecPolicyRef policy = SecPolicyCreateBasicX509(); - CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); - NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount]; - for (CFIndex i = 0; i < certificateCount; i++) { - SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); - - SecCertificateRef someCertificates[] = {certificate}; - CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL); - - SecTrustRef trust; - AF_Require_noErr(SecTrustCreateWithCertificates(certificates, policy, &trust), _out); - - SecTrustResultType result; - AF_Require_noErr(SecTrustEvaluate(trust, &result), _out); - - [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)]; - - _out: - if (trust) { - CFRelease(trust); - } - - if (certificates) { - CFRelease(certificates); - } - - continue; - } - CFRelease(policy); - - return [NSArray arrayWithArray:trustChain]; -} - -#pragma mark - - -@interface AFSecurityPolicy() -@property (readwrite, nonatomic, strong) NSArray *pinnedPublicKeys; -@end - -@implementation AFSecurityPolicy - -+ (NSArray *)defaultPinnedCertificates { - static NSArray *_defaultPinnedCertificates = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - NSBundle *bundle = [NSBundle bundleForClass:[self class]]; - NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."]; - - NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[paths count]]; - for (NSString *path in paths) { - NSData *certificateData = [NSData dataWithContentsOfFile:path]; - [certificates addObject:certificateData]; - } - - _defaultPinnedCertificates = [[NSArray alloc] initWithArray:certificates]; - }); - - return _defaultPinnedCertificates; -} - -+ (instancetype)defaultPolicy { - AFSecurityPolicy *securityPolicy = [[self alloc] init]; - securityPolicy.SSLPinningMode = AFSSLPinningModeNone; - - return securityPolicy; -} - -+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode { - AFSecurityPolicy *securityPolicy = [[self alloc] init]; - securityPolicy.SSLPinningMode = pinningMode; - securityPolicy.validatesDomainName = YES; - [securityPolicy setPinnedCertificates:[self defaultPinnedCertificates]]; - - return securityPolicy; -} - -- (id)init { - self = [super init]; - if (!self) { - return nil; - } - - self.validatesCertificateChain = YES; - - return self; -} - -#pragma mark - - -- (void)setPinnedCertificates:(NSArray *)pinnedCertificates { - _pinnedCertificates = pinnedCertificates; - - if (self.pinnedCertificates) { - NSMutableArray *mutablePinnedPublicKeys = [NSMutableArray arrayWithCapacity:[self.pinnedCertificates count]]; - for (NSData *certificate in self.pinnedCertificates) { - id publicKey = AFPublicKeyForCertificate(certificate); - if (!publicKey) { - continue; - } - [mutablePinnedPublicKeys addObject:publicKey]; - } - self.pinnedPublicKeys = [NSArray arrayWithArray:mutablePinnedPublicKeys]; - } else { - self.pinnedPublicKeys = nil; - } -} - -#pragma mark - - -- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust { - return [self evaluateServerTrust:serverTrust forDomain:nil]; -} - -- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust - forDomain:(NSString *)domain -{ - NSMutableArray *policies = [NSMutableArray array]; - if (self.validatesDomainName) { - [policies addObject:(__bridge_transfer id)SecPolicyCreateSSL(true, (__bridge CFStringRef)domain)]; - } else { - [policies addObject:(__bridge_transfer id)SecPolicyCreateBasicX509()]; - } - - SecTrustSetPolicies(serverTrust, (__bridge CFArrayRef)policies); - - if (!AFServerTrustIsValid(serverTrust) && !self.allowInvalidCertificates) { - return NO; - } - - NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust); - switch (self.SSLPinningMode) { - case AFSSLPinningModeNone: - return YES; - case AFSSLPinningModeCertificate: { - NSMutableArray *pinnedCertificates = [NSMutableArray array]; - for (NSData *certificateData in self.pinnedCertificates) { - [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)]; - } - SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates); - - if (!AFServerTrustIsValid(serverTrust)) { - return NO; - } - - if (!self.validatesCertificateChain) { - return YES; - } - - NSUInteger trustedCertificateCount = 0; - for (NSData *trustChainCertificate in serverCertificates) { - if ([self.pinnedCertificates containsObject:trustChainCertificate]) { - trustedCertificateCount++; - } - } - - return trustedCertificateCount == [serverCertificates count]; - } - case AFSSLPinningModePublicKey: { - NSUInteger trustedPublicKeyCount = 0; - NSArray *publicKeys = AFPublicKeyTrustChainForServerTrust(serverTrust); - if (!self.validatesCertificateChain && [publicKeys count] > 0) { - publicKeys = @[[publicKeys firstObject]]; - } - - for (id trustChainPublicKey in publicKeys) { - for (id pinnedPublicKey in self.pinnedPublicKeys) { - if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)trustChainPublicKey, (__bridge SecKeyRef)pinnedPublicKey)) { - trustedPublicKeyCount += 1; - } - } - } - - return trustedPublicKeyCount > 0 && ((self.validatesCertificateChain && trustedPublicKeyCount == [serverCertificates count]) || (!self.validatesCertificateChain && trustedPublicKeyCount >= 1)); - } - } - - return NO; -} - -#pragma mark - NSKeyValueObserving - -+ (NSSet *)keyPathsForValuesAffectingPinnedPublicKeys { - return [NSSet setWithObject:@"pinnedCertificates"]; -} - -@end diff --git a/Ryff/Frameworks/AFNetworking/AFURLConnectionOperation.h b/Ryff/Frameworks/AFNetworking/AFURLConnectionOperation.h deleted file mode 100755 index 8543556..0000000 --- a/Ryff/Frameworks/AFNetworking/AFURLConnectionOperation.h +++ /dev/null @@ -1,328 +0,0 @@ -// AFURLConnectionOperation.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import - -#import -#import "AFURLRequestSerialization.h" -#import "AFURLResponseSerialization.h" -#import "AFSecurityPolicy.h" - -/** - `AFURLConnectionOperation` is a subclass of `NSOperation` that implements `NSURLConnection` delegate methods. - - ## Subclassing Notes - - This is the base class of all network request operations. You may wish to create your own subclass in order to implement additional `NSURLConnection` delegate methods (see "`NSURLConnection` Delegate Methods" below), or to provide additional properties and/or class constructors. - - If you are creating a subclass that communicates over the HTTP or HTTPS protocols, you may want to consider subclassing `AFHTTPRequestOperation` instead, as it supports specifying acceptable content types or status codes. - - ## NSURLConnection Delegate Methods - - `AFURLConnectionOperation` implements the following `NSURLConnection` delegate methods: - - - `connection:didReceiveResponse:` - - `connection:didReceiveData:` - - `connectionDidFinishLoading:` - - `connection:didFailWithError:` - - `connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:` - - `connection:willCacheResponse:` - - `connectionShouldUseCredentialStorage:` - - `connection:needNewBodyStream:` - - `connection:willSendRequestForAuthenticationChallenge:` - - If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. - - ## Callbacks and Completion Blocks - - The built-in `completionBlock` provided by `NSOperation` allows for custom behavior to be executed after the request finishes. It is a common pattern for class constructors in subclasses to take callback block parameters, and execute them conditionally in the body of its `completionBlock`. Make sure to handle cancelled operations appropriately when setting a `completionBlock` (i.e. returning early before parsing response data). See the implementation of any of the `AFHTTPRequestOperation` subclasses for an example of this. - - Subclasses are strongly discouraged from overriding `setCompletionBlock:`, as `AFURLConnectionOperation`'s implementation includes a workaround to mitigate retain cycles, and what Apple rather ominously refers to as ["The Deallocation Problem"](http://developer.apple.com/library/ios/#technotes/tn2109/). - - ## SSL Pinning - - Relying on the CA trust model to validate SSL certificates exposes your app to security vulnerabilities, such as man-in-the-middle attacks. For applications that connect to known servers, SSL certificate pinning provides an increased level of security, by checking server certificate validity against those specified in the app bundle. - - SSL with certificate pinning is strongly recommended for any application that transmits sensitive information to an external webservice. - - Connections will be validated on all matching certificates with a `.cer` extension in the bundle root. - - ## App Extensions - - When using AFNetworking in an App Extension, `#define AF_APP_EXTENSIONS` to avoid using unavailable APIs. - - ## NSCoding & NSCopying Conformance - - `AFURLConnectionOperation` conforms to the `NSCoding` and `NSCopying` protocols, allowing operations to be archived to disk, and copied in memory, respectively. However, because of the intrinsic limitations of capturing the exact state of an operation at a particular moment, there are some important caveats to keep in mind: - - ### NSCoding Caveats - - - Encoded operations do not include any block or stream properties. Be sure to set `completionBlock`, `outputStream`, and any callback blocks as necessary when using `-initWithCoder:` or `NSKeyedUnarchiver`. - - Operations are paused on `encodeWithCoder:`. If the operation was encoded while paused or still executing, its archived state will return `YES` for `isReady`. Otherwise, the state of an operation when encoding will remain unchanged. - - ### NSCopying Caveats - - - `-copy` and `-copyWithZone:` return a new operation with the `NSURLRequest` of the original. So rather than an exact copy of the operation at that particular instant, the copying mechanism returns a completely new instance, which can be useful for retrying operations. - - A copy of an operation will not include the `outputStream` of the original. - - Operation copies do not include `completionBlock`, as it often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ operation when copied. - */ - -@interface AFURLConnectionOperation : NSOperation - -///------------------------------- -/// @name Accessing Run Loop Modes -///------------------------------- - -/** - The run loop modes in which the operation will run on the network thread. By default, this is a single-member set containing `NSRunLoopCommonModes`. - */ -@property (nonatomic, strong) NSSet *runLoopModes; - -///----------------------------------------- -/// @name Getting URL Connection Information -///----------------------------------------- - -/** - The request used by the operation's connection. - */ -@property (readonly, nonatomic, strong) NSURLRequest *request; - -/** - The last response received by the operation's connection. - */ -@property (readonly, nonatomic, strong) NSURLResponse *response; - -/** - The error, if any, that occurred in the lifecycle of the request. - */ -@property (readonly, nonatomic, strong) NSError *error; - -///---------------------------- -/// @name Getting Response Data -///---------------------------- - -/** - The data received during the request. - */ -@property (readonly, nonatomic, strong) NSData *responseData; - -/** - The string representation of the response data. - */ -@property (readonly, nonatomic, copy) NSString *responseString; - -/** - The string encoding of the response. - - If the response does not specify a valid string encoding, `responseStringEncoding` will return `NSUTF8StringEncoding`. - */ -@property (readonly, nonatomic, assign) NSStringEncoding responseStringEncoding; - -///------------------------------- -/// @name Managing URL Credentials -///------------------------------- - -/** - Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. - - This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. - */ -@property (nonatomic, assign) BOOL shouldUseCredentialStorage; - -/** - The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. - - This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. - */ -@property (nonatomic, strong) NSURLCredential *credential; - -///------------------------------- -/// @name Managing Security Policy -///------------------------------- - -/** - The security policy used to evaluate server trust for secure connections. - */ -@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; - -///------------------------ -/// @name Accessing Streams -///------------------------ - -/** - The input stream used to read data to be sent during the request. - - This property acts as a proxy to the `HTTPBodyStream` property of `request`. - */ -@property (nonatomic, strong) NSInputStream *inputStream; - -/** - The output stream that is used to write data received until the request is finished. - - By default, data is accumulated into a buffer that is stored into `responseData` upon completion of the request, with the intermediary `outputStream` property set to `nil`. When `outputStream` is set, the data will not be accumulated into an internal buffer, and as a result, the `responseData` property of the completed request will be `nil`. The output stream will be scheduled in the network thread runloop upon being set. - */ -@property (nonatomic, strong) NSOutputStream *outputStream; - -///--------------------------------- -/// @name Managing Callback Queues -///--------------------------------- - -/** - The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used. - */ -@property (nonatomic, strong) dispatch_queue_t completionQueue; - -/** - The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used. - */ -@property (nonatomic, strong) dispatch_group_t completionGroup; - -///--------------------------------------------- -/// @name Managing Request Operation Information -///--------------------------------------------- - -/** - The user info dictionary for the receiver. - */ -@property (nonatomic, strong) NSDictionary *userInfo; - -///------------------------------------------------------ -/// @name Initializing an AFURLConnectionOperation Object -///------------------------------------------------------ - -/** - Initializes and returns a newly allocated operation object with a url connection configured with the specified url request. - - This is the designated initializer. - - @param urlRequest The request object to be used by the operation connection. - */ -- (instancetype)initWithRequest:(NSURLRequest *)urlRequest; - -///---------------------------------- -/// @name Pausing / Resuming Requests -///---------------------------------- - -/** - Pauses the execution of the request operation. - - A paused operation returns `NO` for `-isReady`, `-isExecuting`, and `-isFinished`. As such, it will remain in an `NSOperationQueue` until it is either cancelled or resumed. Pausing a finished, cancelled, or paused operation has no effect. - */ -- (void)pause; - -/** - Whether the request operation is currently paused. - - @return `YES` if the operation is currently paused, otherwise `NO`. - */ -- (BOOL)isPaused; - -/** - Resumes the execution of the paused request operation. - - Pause/Resume behavior varies depending on the underlying implementation for the operation class. In its base implementation, resuming a paused requests restarts the original request. However, since HTTP defines a specification for how to request a specific content range, `AFHTTPRequestOperation` will resume downloading the request from where it left off, instead of restarting the original request. - */ -- (void)resume; - -///---------------------------------------------- -/// @name Configuring Backgrounding Task Behavior -///---------------------------------------------- - -/** - Specifies that the operation should continue execution after the app has entered the background, and the expiration handler for that background task. - - @param handler A handler to be called shortly before the application’s remaining background time reaches 0. The handler is wrapped in a block that cancels the operation, and cleans up and marks the end of execution, unlike the `handler` parameter in `UIApplication -beginBackgroundTaskWithExpirationHandler:`, which expects this to be done in the handler itself. The handler is called synchronously on the main thread, thus blocking the application’s suspension momentarily while the application is notified. - */ -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS) -- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler; -#endif - -///--------------------------------- -/// @name Setting Progress Callbacks -///--------------------------------- - -/** - Sets a callback to be called when an undetermined number of bytes have been uploaded to the server. - - @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes three arguments: the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread. - */ -- (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block; - -/** - Sets a callback to be called when an undetermined number of bytes have been downloaded from the server. - - @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread. - */ -- (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block; - -///------------------------------------------------- -/// @name Setting NSURLConnection Delegate Callbacks -///------------------------------------------------- - -/** - Sets a block to be executed when the connection will authenticate a challenge in order to download its request, as handled by the `NSURLConnectionDelegate` method `connection:willSendRequestForAuthenticationChallenge:`. - - @param block A block object to be executed when the connection will authenticate a challenge in order to download its request. The block has no return type and takes two arguments: the URL connection object, and the challenge that must be authenticated. This block must invoke one of the challenge-responder methods (NSURLAuthenticationChallengeSender protocol). - - If `allowsInvalidSSLCertificate` is set to YES, `connection:willSendRequestForAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. - */ -- (void)setWillSendRequestForAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block; - -/** - Sets a block to be executed when the server redirects the request from one URL to another URL, or when the request URL changed by the `NSURLProtocol` subclass handling the request in order to standardize its format, as handled by the `NSURLConnectionDataDelegate` method `connection:willSendRequest:redirectResponse:`. - - @param block A block object to be executed when the request URL was changed. The block returns an `NSURLRequest` object, the URL request to redirect, and takes three arguments: the URL connection object, the the proposed redirected request, and the URL response that caused the redirect. - */ -- (void)setRedirectResponseBlock:(NSURLRequest * (^)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse))block; - - -/** - Sets a block to be executed to modify the response a connection will cache, if any, as handled by the `NSURLConnectionDelegate` method `connection:willCacheResponse:`. - - @param block A block object to be executed to determine what response a connection will cache, if any. The block returns an `NSCachedURLResponse` object, the cached response to store in memory or `nil` to prevent the response from being cached, and takes two arguments: the URL connection object, and the cached response provided for the request. - */ -- (void)setCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block; - -/// - -/** - - */ -+ (NSArray *)batchOfRequestOperations:(NSArray *)operations - progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock - completionBlock:(void (^)(NSArray *operations))completionBlock; - -@end - -///-------------------- -/// @name Notifications -///-------------------- - -/** - Posted when an operation begins executing. - */ -extern NSString * const AFNetworkingOperationDidStartNotification; - -/** - Posted when an operation finishes. - */ -extern NSString * const AFNetworkingOperationDidFinishNotification; diff --git a/Ryff/Frameworks/AFNetworking/AFURLConnectionOperation.m b/Ryff/Frameworks/AFNetworking/AFURLConnectionOperation.m deleted file mode 100755 index e5e6839..0000000 --- a/Ryff/Frameworks/AFNetworking/AFURLConnectionOperation.m +++ /dev/null @@ -1,789 +0,0 @@ -// AFURLConnectionOperation.m -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import "AFURLConnectionOperation.h" - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -#import -#endif - -#if !__has_feature(objc_arc) -#error AFNetworking must be built with ARC. -// You can turn on ARC for only AFNetworking files by adding -fobjc-arc to the build phase for each of its files. -#endif - -typedef NS_ENUM(NSInteger, AFOperationState) { - AFOperationPausedState = -1, - AFOperationReadyState = 1, - AFOperationExecutingState = 2, - AFOperationFinishedState = 3, -}; - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS) -typedef UIBackgroundTaskIdentifier AFBackgroundTaskIdentifier; -#else -typedef id AFBackgroundTaskIdentifier; -#endif - -static dispatch_group_t url_request_operation_completion_group() { - static dispatch_group_t af_url_request_operation_completion_group; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - af_url_request_operation_completion_group = dispatch_group_create(); - }); - - return af_url_request_operation_completion_group; -} - -static dispatch_queue_t url_request_operation_completion_queue() { - static dispatch_queue_t af_url_request_operation_completion_queue; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - af_url_request_operation_completion_queue = dispatch_queue_create("com.alamofire.networking.operation.queue", DISPATCH_QUEUE_CONCURRENT ); - }); - - return af_url_request_operation_completion_queue; -} - -static NSString * const kAFNetworkingLockName = @"com.alamofire.networking.operation.lock"; - -NSString * const AFNetworkingOperationDidStartNotification = @"com.alamofire.networking.operation.start"; -NSString * const AFNetworkingOperationDidFinishNotification = @"com.alamofire.networking.operation.finish"; - -typedef void (^AFURLConnectionOperationProgressBlock)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); -typedef void (^AFURLConnectionOperationAuthenticationChallengeBlock)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge); -typedef NSCachedURLResponse * (^AFURLConnectionOperationCacheResponseBlock)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse); -typedef NSURLRequest * (^AFURLConnectionOperationRedirectResponseBlock)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse); - -static inline NSString * AFKeyPathFromOperationState(AFOperationState state) { - switch (state) { - case AFOperationReadyState: - return @"isReady"; - case AFOperationExecutingState: - return @"isExecuting"; - case AFOperationFinishedState: - return @"isFinished"; - case AFOperationPausedState: - return @"isPaused"; - default: { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunreachable-code" - return @"state"; -#pragma clang diagnostic pop - } - } -} - -static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperationState toState, BOOL isCancelled) { - switch (fromState) { - case AFOperationReadyState: - switch (toState) { - case AFOperationPausedState: - case AFOperationExecutingState: - return YES; - case AFOperationFinishedState: - return isCancelled; - default: - return NO; - } - case AFOperationExecutingState: - switch (toState) { - case AFOperationPausedState: - case AFOperationFinishedState: - return YES; - default: - return NO; - } - case AFOperationFinishedState: - return NO; - case AFOperationPausedState: - return toState == AFOperationReadyState; - default: { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunreachable-code" - switch (toState) { - case AFOperationPausedState: - case AFOperationReadyState: - case AFOperationExecutingState: - case AFOperationFinishedState: - return YES; - default: - return NO; - } - } -#pragma clang diagnostic pop - } -} - -@interface AFURLConnectionOperation () -@property (readwrite, nonatomic, assign) AFOperationState state; -@property (readwrite, nonatomic, strong) NSRecursiveLock *lock; -@property (readwrite, nonatomic, strong) NSURLConnection *connection; -@property (readwrite, nonatomic, strong) NSURLRequest *request; -@property (readwrite, nonatomic, strong) NSURLResponse *response; -@property (readwrite, nonatomic, strong) NSError *error; -@property (readwrite, nonatomic, strong) NSData *responseData; -@property (readwrite, nonatomic, copy) NSString *responseString; -@property (readwrite, nonatomic, assign) NSStringEncoding responseStringEncoding; -@property (readwrite, nonatomic, assign) long long totalBytesRead; -@property (readwrite, nonatomic, assign) AFBackgroundTaskIdentifier backgroundTaskIdentifier; -@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock uploadProgress; -@property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock downloadProgress; -@property (readwrite, nonatomic, copy) AFURLConnectionOperationAuthenticationChallengeBlock authenticationChallenge; -@property (readwrite, nonatomic, copy) AFURLConnectionOperationCacheResponseBlock cacheResponse; -@property (readwrite, nonatomic, copy) AFURLConnectionOperationRedirectResponseBlock redirectResponse; - -- (void)operationDidStart; -- (void)finish; -- (void)cancelConnection; -@end - -@implementation AFURLConnectionOperation -@synthesize outputStream = _outputStream; - -+ (void)networkRequestThreadEntryPoint:(id)__unused object { - @autoreleasepool { - [[NSThread currentThread] setName:@"AFNetworking"]; - - NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; - [runLoop addPort:[NSMachPort port] forMode:NSDefaultRunLoopMode]; - [runLoop run]; - } -} - -+ (NSThread *)networkRequestThread { - static NSThread *_networkRequestThread = nil; - static dispatch_once_t oncePredicate; - dispatch_once(&oncePredicate, ^{ - _networkRequestThread = [[NSThread alloc] initWithTarget:self selector:@selector(networkRequestThreadEntryPoint:) object:nil]; - [_networkRequestThread start]; - }); - - return _networkRequestThread; -} - -- (instancetype)initWithRequest:(NSURLRequest *)urlRequest { - NSParameterAssert(urlRequest); - - self = [super init]; - if (!self) { - return nil; - } - - _state = AFOperationReadyState; - - self.lock = [[NSRecursiveLock alloc] init]; - self.lock.name = kAFNetworkingLockName; - - self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes]; - - self.request = urlRequest; - - self.shouldUseCredentialStorage = YES; - - self.securityPolicy = [AFSecurityPolicy defaultPolicy]; - - return self; -} - -- (void)dealloc { - if (_outputStream) { - [_outputStream close]; - _outputStream = nil; - } - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS) - if (_backgroundTaskIdentifier) { - [[UIApplication sharedApplication] endBackgroundTask:_backgroundTaskIdentifier]; - _backgroundTaskIdentifier = UIBackgroundTaskInvalid; - } -#endif -} - -#pragma mark - - -- (void)setResponseData:(NSData *)responseData { - [self.lock lock]; - if (!responseData) { - _responseData = nil; - } else { - _responseData = [NSData dataWithBytes:responseData.bytes length:responseData.length]; - } - [self.lock unlock]; -} - -- (NSString *)responseString { - [self.lock lock]; - if (!_responseString && self.response && self.responseData) { - self.responseString = [[NSString alloc] initWithData:self.responseData encoding:self.responseStringEncoding]; - } - [self.lock unlock]; - - return _responseString; -} - -- (NSStringEncoding)responseStringEncoding { - [self.lock lock]; - if (!_responseStringEncoding && self.response) { - NSStringEncoding stringEncoding = NSUTF8StringEncoding; - if (self.response.textEncodingName) { - CFStringEncoding IANAEncoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)self.response.textEncodingName); - if (IANAEncoding != kCFStringEncodingInvalidId) { - stringEncoding = CFStringConvertEncodingToNSStringEncoding(IANAEncoding); - } - } - - self.responseStringEncoding = stringEncoding; - } - [self.lock unlock]; - - return _responseStringEncoding; -} - -- (NSInputStream *)inputStream { - return self.request.HTTPBodyStream; -} - -- (void)setInputStream:(NSInputStream *)inputStream { - NSMutableURLRequest *mutableRequest = [self.request mutableCopy]; - mutableRequest.HTTPBodyStream = inputStream; - self.request = mutableRequest; -} - -- (NSOutputStream *)outputStream { - if (!_outputStream) { - self.outputStream = [NSOutputStream outputStreamToMemory]; - } - - return _outputStream; -} - -- (void)setOutputStream:(NSOutputStream *)outputStream { - [self.lock lock]; - if (outputStream != _outputStream) { - if (_outputStream) { - [_outputStream close]; - } - - _outputStream = outputStream; - } - [self.lock unlock]; -} - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS) -- (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler { - [self.lock lock]; - if (!self.backgroundTaskIdentifier) { - UIApplication *application = [UIApplication sharedApplication]; - __weak __typeof(self)weakSelf = self; - self.backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^{ - __strong __typeof(weakSelf)strongSelf = weakSelf; - - if (handler) { - handler(); - } - - if (strongSelf) { - [strongSelf cancel]; - - [application endBackgroundTask:strongSelf.backgroundTaskIdentifier]; - strongSelf.backgroundTaskIdentifier = UIBackgroundTaskInvalid; - } - }]; - } - [self.lock unlock]; -} -#endif - -#pragma mark - - -- (void)setState:(AFOperationState)state { - if (!AFStateTransitionIsValid(self.state, state, [self isCancelled])) { - return; - } - - [self.lock lock]; - NSString *oldStateKey = AFKeyPathFromOperationState(self.state); - NSString *newStateKey = AFKeyPathFromOperationState(state); - - [self willChangeValueForKey:newStateKey]; - [self willChangeValueForKey:oldStateKey]; - _state = state; - [self didChangeValueForKey:oldStateKey]; - [self didChangeValueForKey:newStateKey]; - [self.lock unlock]; -} - -- (void)pause { - if ([self isPaused] || [self isFinished] || [self isCancelled]) { - return; - } - - [self.lock lock]; - - if ([self isExecuting]) { - [self performSelector:@selector(operationDidPause) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; - - dispatch_async(dispatch_get_main_queue(), ^{ - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; - [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; - }); - } - - self.state = AFOperationPausedState; - - [self.lock unlock]; -} - -- (void)operationDidPause { - [self.lock lock]; - [self.connection cancel]; - [self.lock unlock]; -} - -- (BOOL)isPaused { - return self.state == AFOperationPausedState; -} - -- (void)resume { - if (![self isPaused]) { - return; - } - - [self.lock lock]; - self.state = AFOperationReadyState; - - [self start]; - [self.lock unlock]; -} - -#pragma mark - - -- (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block { - self.uploadProgress = block; -} - -- (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block { - self.downloadProgress = block; -} - -- (void)setWillSendRequestForAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block { - self.authenticationChallenge = block; -} - -- (void)setCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block { - self.cacheResponse = block; -} - -- (void)setRedirectResponseBlock:(NSURLRequest * (^)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse))block { - self.redirectResponse = block; -} - -#pragma mark - NSOperation - -- (void)setCompletionBlock:(void (^)(void))block { - [self.lock lock]; - if (!block) { - [super setCompletionBlock:nil]; - } else { - __weak __typeof(self)weakSelf = self; - [super setCompletionBlock:^ { - __strong __typeof(weakSelf)strongSelf = weakSelf; - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wgnu" - dispatch_group_t group = strongSelf.completionGroup ?: url_request_operation_completion_group(); - dispatch_queue_t queue = strongSelf.completionQueue ?: dispatch_get_main_queue(); -#pragma clang diagnostic pop - - dispatch_group_async(group, queue, ^{ - block(); - }); - - dispatch_group_notify(group, url_request_operation_completion_queue(), ^{ - [strongSelf setCompletionBlock:nil]; - }); - }]; - } - [self.lock unlock]; -} - -- (BOOL)isReady { - return self.state == AFOperationReadyState && [super isReady]; -} - -- (BOOL)isExecuting { - return self.state == AFOperationExecutingState; -} - -- (BOOL)isFinished { - return self.state == AFOperationFinishedState; -} - -- (BOOL)isConcurrent { - return YES; -} - -- (void)start { - [self.lock lock]; - if ([self isCancelled]) { - [self performSelector:@selector(cancelConnection) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; - } else if ([self isReady]) { - self.state = AFOperationExecutingState; - - [self performSelector:@selector(operationDidStart) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; - } - [self.lock unlock]; -} - -- (void)operationDidStart { - [self.lock lock]; - if (![self isCancelled]) { - self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO]; - - NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; - for (NSString *runLoopMode in self.runLoopModes) { - [self.connection scheduleInRunLoop:runLoop forMode:runLoopMode]; - [self.outputStream scheduleInRunLoop:runLoop forMode:runLoopMode]; - } - - [self.connection start]; - } - [self.lock unlock]; - - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self]; - }); -} - -- (void)finish { - [self.lock lock]; - self.state = AFOperationFinishedState; - [self.lock unlock]; - - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; - }); -} - -- (void)cancel { - [self.lock lock]; - if (![self isFinished] && ![self isCancelled]) { - [super cancel]; - - if ([self isExecuting]) { - [self performSelector:@selector(cancelConnection) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; - } - } - [self.lock unlock]; -} - -- (void)cancelConnection { - NSDictionary *userInfo = nil; - if ([self.request URL]) { - userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey]; - } - NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]; - - if (![self isFinished]) { - if (self.connection) { - [self.connection cancel]; - [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:error]; - } else { - // Accomodate race condition where `self.connection` has not yet been set before cancellation - self.error = error; - [self finish]; - } - } -} - -#pragma mark - - -+ (NSArray *)batchOfRequestOperations:(NSArray *)operations - progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock - completionBlock:(void (^)(NSArray *operations))completionBlock -{ - if (!operations || [operations count] == 0) { - return @[[NSBlockOperation blockOperationWithBlock:^{ - dispatch_async(dispatch_get_main_queue(), ^{ - if (completionBlock) { - completionBlock(@[]); - } - }); - }]]; - } - - __block dispatch_group_t group = dispatch_group_create(); - NSBlockOperation *batchedOperation = [NSBlockOperation blockOperationWithBlock:^{ - dispatch_group_notify(group, dispatch_get_main_queue(), ^{ - if (completionBlock) { - completionBlock(operations); - } - }); - }]; - - for (AFURLConnectionOperation *operation in operations) { - operation.completionGroup = group; - void (^originalCompletionBlock)(void) = [operation.completionBlock copy]; - __weak __typeof(operation)weakOperation = operation; - operation.completionBlock = ^{ - __strong __typeof(weakOperation)strongOperation = weakOperation; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wgnu" - dispatch_queue_t queue = strongOperation.completionQueue ?: dispatch_get_main_queue(); -#pragma clang diagnostic pop - dispatch_group_async(group, queue, ^{ - if (originalCompletionBlock) { - originalCompletionBlock(); - } - - NSUInteger numberOfFinishedOperations = [[operations indexesOfObjectsPassingTest:^BOOL(id op, NSUInteger __unused idx, BOOL __unused *stop) { - return [op isFinished]; - }] count]; - - if (progressBlock) { - progressBlock(numberOfFinishedOperations, [operations count]); - } - - dispatch_group_leave(group); - }); - }; - - dispatch_group_enter(group); - [batchedOperation addDependency:operation]; - } - - return [operations arrayByAddingObject:batchedOperation]; -} - -#pragma mark - NSObject - -- (NSString *)description { - return [NSString stringWithFormat:@"<%@: %p, state: %@, cancelled: %@ request: %@, response: %@>", NSStringFromClass([self class]), self, AFKeyPathFromOperationState(self.state), ([self isCancelled] ? @"YES" : @"NO"), self.request, self.response]; -} - -#pragma mark - NSURLConnectionDelegate - -- (void)connection:(NSURLConnection *)connection -willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge -{ - if (self.authenticationChallenge) { - self.authenticationChallenge(connection, challenge); - return; - } - - if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { - if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { - NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; - [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; - } else { - [[challenge sender] cancelAuthenticationChallenge:challenge]; - } - } else { - if ([challenge previousFailureCount] == 0) { - if (self.credential) { - [[challenge sender] useCredential:self.credential forAuthenticationChallenge:challenge]; - } else { - [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; - } - } else { - [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; - } - } -} - -- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection __unused *)connection { - return self.shouldUseCredentialStorage; -} - -- (NSURLRequest *)connection:(NSURLConnection *)connection - willSendRequest:(NSURLRequest *)request - redirectResponse:(NSURLResponse *)redirectResponse -{ - if (self.redirectResponse) { - return self.redirectResponse(connection, request, redirectResponse); - } else { - return request; - } -} - -- (void)connection:(NSURLConnection __unused *)connection - didSendBodyData:(NSInteger)bytesWritten - totalBytesWritten:(NSInteger)totalBytesWritten -totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite -{ - dispatch_async(dispatch_get_main_queue(), ^{ - if (self.uploadProgress) { - self.uploadProgress((NSUInteger)bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); - } - }); -} - -- (void)connection:(NSURLConnection __unused *)connection -didReceiveResponse:(NSURLResponse *)response -{ - self.response = response; - - [self.outputStream open]; -} - -- (void)connection:(NSURLConnection __unused *)connection - didReceiveData:(NSData *)data -{ - NSUInteger length = [data length]; - while (YES) { - NSInteger totalNumberOfBytesWritten = 0; - if ([self.outputStream hasSpaceAvailable]) { - const uint8_t *dataBuffer = (uint8_t *)[data bytes]; - - NSInteger numberOfBytesWritten = 0; - while (totalNumberOfBytesWritten < (NSInteger)length) { - numberOfBytesWritten = [self.outputStream write:&dataBuffer[(NSUInteger)totalNumberOfBytesWritten] maxLength:(length - (NSUInteger)totalNumberOfBytesWritten)]; - if (numberOfBytesWritten == -1) { - break; - } - - totalNumberOfBytesWritten += numberOfBytesWritten; - } - - break; - } - - if (self.outputStream.streamError) { - [self.connection cancel]; - [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:self.outputStream.streamError]; - return; - } - } - - dispatch_async(dispatch_get_main_queue(), ^{ - self.totalBytesRead += (long long)length; - - if (self.downloadProgress) { - self.downloadProgress(length, self.totalBytesRead, self.response.expectedContentLength); - } - }); -} - -- (void)connectionDidFinishLoading:(NSURLConnection __unused *)connection { - self.responseData = [self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey]; - - [self.outputStream close]; - if (self.responseData) { - self.outputStream = nil; - } - - self.connection = nil; - - [self finish]; -} - -- (void)connection:(NSURLConnection __unused *)connection - didFailWithError:(NSError *)error -{ - self.error = error; - - [self.outputStream close]; - if (self.responseData) { - self.outputStream = nil; - } - - self.connection = nil; - - [self finish]; -} - -- (NSCachedURLResponse *)connection:(NSURLConnection *)connection - willCacheResponse:(NSCachedURLResponse *)cachedResponse -{ - if (self.cacheResponse) { - return self.cacheResponse(connection, cachedResponse); - } else { - if ([self isCancelled]) { - return nil; - } - - return cachedResponse; - } -} - -#pragma mark - NSecureCoding - -+ (BOOL)supportsSecureCoding { - return YES; -} - -- (id)initWithCoder:(NSCoder *)decoder { - NSURLRequest *request = [decoder decodeObjectOfClass:[NSURLRequest class] forKey:NSStringFromSelector(@selector(request))]; - - self = [self initWithRequest:request]; - if (!self) { - return nil; - } - - self.state = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(state))] integerValue]; - self.response = [decoder decodeObjectOfClass:[NSHTTPURLResponse class] forKey:NSStringFromSelector(@selector(response))]; - self.error = [decoder decodeObjectOfClass:[NSError class] forKey:NSStringFromSelector(@selector(error))]; - self.responseData = [decoder decodeObjectOfClass:[NSData class] forKey:NSStringFromSelector(@selector(responseData))]; - self.totalBytesRead = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(totalBytesRead))] longLongValue]; - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [self pause]; - - [coder encodeObject:self.request forKey:NSStringFromSelector(@selector(request))]; - - switch (self.state) { - case AFOperationExecutingState: - case AFOperationPausedState: - [coder encodeInteger:AFOperationReadyState forKey:NSStringFromSelector(@selector(state))]; - break; - default: - [coder encodeInteger:self.state forKey:NSStringFromSelector(@selector(state))]; - break; - } - - [coder encodeObject:self.response forKey:NSStringFromSelector(@selector(response))]; - [coder encodeObject:self.error forKey:NSStringFromSelector(@selector(error))]; - [coder encodeObject:self.responseData forKey:NSStringFromSelector(@selector(responseData))]; - [coder encodeInt64:self.totalBytesRead forKey:NSStringFromSelector(@selector(totalBytesRead))]; -} - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone { - AFURLConnectionOperation *operation = [(AFURLConnectionOperation *)[[self class] allocWithZone:zone] initWithRequest:self.request]; - - operation.uploadProgress = self.uploadProgress; - operation.downloadProgress = self.downloadProgress; - operation.authenticationChallenge = self.authenticationChallenge; - operation.cacheResponse = self.cacheResponse; - operation.redirectResponse = self.redirectResponse; - operation.completionQueue = self.completionQueue; - operation.completionGroup = self.completionGroup; - - return operation; -} - -@end diff --git a/Ryff/Frameworks/AFNetworking/AFURLRequestSerialization.h b/Ryff/Frameworks/AFNetworking/AFURLRequestSerialization.h deleted file mode 100755 index 161b551..0000000 --- a/Ryff/Frameworks/AFNetworking/AFURLRequestSerialization.h +++ /dev/null @@ -1,444 +0,0 @@ -// AFSerialization.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -#import -#endif - -/** - The `AFURLRequestSerialization` protocol is adopted by an object that encodes parameters for a specified HTTP requests. Request serializers may encode parameters as query strings, HTTP bodies, setting the appropriate HTTP header fields as necessary. - - For example, a JSON request serializer may set the HTTP body of the request to a JSON representation, and set the `Content-Type` HTTP header field value to `application/json`. - */ -@protocol AFURLRequestSerialization - -/** - Returns a request with the specified parameters encoded into a copy of the original request. - - @param request The original request. - @param parameters The parameters to be encoded. - @param error The error that occurred while attempting to encode the request parameters. - - @return A serialized request. - */ -- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request - withParameters:(id)parameters - error:(NSError * __autoreleasing *)error; - -@end - -#pragma mark - - -/** - - */ -typedef NS_ENUM(NSUInteger, AFHTTPRequestQueryStringSerializationStyle) { - AFHTTPRequestQueryStringDefaultStyle = 0, -}; - -@protocol AFMultipartFormData; - -/** - `AFHTTPRequestSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation. - - Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPRequestSerializer` in order to ensure consistent default behavior. - */ -@interface AFHTTPRequestSerializer : NSObject - -/** - The string encoding used to serialize parameters. `NSUTF8StringEncoding` by default. - */ -@property (nonatomic, assign) NSStringEncoding stringEncoding; - -/** - Whether created requests can use the device’s cellular radio (if present). `YES` by default. - - @see NSMutableURLRequest -setAllowsCellularAccess: - */ -@property (nonatomic, assign) BOOL allowsCellularAccess; - -/** - The cache policy of created requests. `NSURLRequestUseProtocolCachePolicy` by default. - - @see NSMutableURLRequest -setCachePolicy: - */ -@property (nonatomic, assign) NSURLRequestCachePolicy cachePolicy; - -/** - Whether created requests should use the default cookie handling. `YES` by default. - - @see NSMutableURLRequest -setHTTPShouldHandleCookies: - */ -@property (nonatomic, assign) BOOL HTTPShouldHandleCookies; - -/** - Whether created requests can continue transmitting data before receiving a response from an earlier transmission. `NO` by default - - @see NSMutableURLRequest -setHTTPShouldUsePipelining: - */ -@property (nonatomic, assign) BOOL HTTPShouldUsePipelining; - -/** - The network service type for created requests. `NSURLNetworkServiceTypeDefault` by default. - - @see NSMutableURLRequest -setNetworkServiceType: - */ -@property (nonatomic, assign) NSURLRequestNetworkServiceType networkServiceType; - -/** - The timeout interval, in seconds, for created requests. The default timeout interval is 60 seconds. - - @see NSMutableURLRequest -setTimeoutInterval: - */ -@property (nonatomic, assign) NSTimeInterval timeoutInterval; - -///--------------------------------------- -/// @name Configuring HTTP Request Headers -///--------------------------------------- - -/** - Default HTTP header field values to be applied to serialized requests. - */ -@property (readonly, nonatomic, strong) NSDictionary *HTTPRequestHeaders; - -/** - Creates and returns a serializer with default configuration. - */ -+ (instancetype)serializer; - -/** - Sets the value for the HTTP headers set in request objects made by the HTTP client. If `nil`, removes the existing value for that header. - - @param field The HTTP header to set a default value for - @param value The value set as default for the specified header, or `nil` - */ -- (void)setValue:(NSString *)value -forHTTPHeaderField:(NSString *)field; - -/** - Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header. - - @param username The HTTP basic auth username - @param password The HTTP basic auth password - */ -- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username - password:(NSString *)password; - -/** - @deprecated This method has been deprecated. Use -setValue:forHTTPHeaderField: instead. - */ -- (void)setAuthorizationHeaderFieldWithToken:(NSString *)token DEPRECATED_ATTRIBUTE; - - -/** - Clears any existing value for the "Authorization" HTTP header. - */ -- (void)clearAuthorizationHeader; - -///------------------------------------------------------- -/// @name Configuring Query String Parameter Serialization -///------------------------------------------------------- - -/** - HTTP methods for which serialized requests will encode parameters as a query string. `GET`, `HEAD`, and `DELETE` by default. - */ -@property (nonatomic, strong) NSSet *HTTPMethodsEncodingParametersInURI; - -/** - Set the method of query string serialization according to one of the pre-defined styles. - - @param style The serialization style. - - @see AFHTTPRequestQueryStringSerializationStyle - */ -- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style; - -/** - Set the a custom method of query string serialization according to the specified block. - - @param block A block that defines a process of encoding parameters into a query string. This block returns the query string and takes three arguments: the request, the parameters to encode, and the error that occurred when attempting to encode parameters for the given request. - */ -- (void)setQueryStringSerializationWithBlock:(NSString * (^)(NSURLRequest *request, NSDictionary *parameters, NSError * __autoreleasing *error))block; - -///------------------------------- -/// @name Creating Request Objects -///------------------------------- - -/** - @deprecated This method has been deprecated. Use -requestWithMethod:URLString:parameters:error: instead. - */ -- (NSMutableURLRequest *)requestWithMethod:(NSString *)method - URLString:(NSString *)URLString - parameters:(id)parameters DEPRECATED_ATTRIBUTE; - -/** - Creates an `NSMutableURLRequest` object with the specified HTTP method and URL string. - - If the HTTP method is `GET`, `HEAD`, or `DELETE`, the parameters will be used to construct a url-encoded query string that is appended to the request's URL. Otherwise, the parameters will be encoded according to the value of the `parameterEncoding` property, and set as the request body. - - @param method The HTTP method for the request, such as `GET`, `POST`, `PUT`, or `DELETE`. This parameter must not be `nil`. - @param URLString The URL string used to create the request URL. - @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body. - @param error The error that occured while constructing the request. - - @return An `NSMutableURLRequest` object. - */ -- (NSMutableURLRequest *)requestWithMethod:(NSString *)method - URLString:(NSString *)URLString - parameters:(id)parameters - error:(NSError * __autoreleasing *)error; - -/** - @deprecated This method has been deprecated. Use -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error: instead. - */ -- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method - URLString:(NSString *)URLString - parameters:(NSDictionary *)parameters - constructingBodyWithBlock:(void (^)(id formData))block DEPRECATED_ATTRIBUTE; - -/** - Creates an `NSMutableURLRequest` object with the specified HTTP method and URLString, and constructs a `multipart/form-data` HTTP body, using the specified parameters and multipart form data block. See http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.2 - - Multipart form requests are automatically streamed, reading files directly from disk along with in-memory data in a single HTTP body. The resulting `NSMutableURLRequest` object has an `HTTPBodyStream` property, so refrain from setting `HTTPBodyStream` or `HTTPBody` on this request object, as it will clear out the multipart form body stream. - - @param method The HTTP method for the request. This parameter must not be `GET` or `HEAD`, or `nil`. - @param URLString The URL string used to create the request URL. - @param parameters The parameters to be encoded and set in the request HTTP body. - @param block A block that takes a single argument and appends data to the HTTP body. The block argument is an object adopting the `AFMultipartFormData` protocol. - @param error The error that occured while constructing the request. - - @return An `NSMutableURLRequest` object - */ -- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method - URLString:(NSString *)URLString - parameters:(NSDictionary *)parameters - constructingBodyWithBlock:(void (^)(id formData))block - error:(NSError * __autoreleasing *)error; - -/** - Creates an `NSMutableURLRequest` by removing the `HTTPBodyStream` from a request, and asynchronously writing its contents into the specified file, invoking the completion handler when finished. - - @param request The multipart form request. - @param fileURL The file URL to write multipart form contents to. - @param handler A handler block to execute. - - @discussion There is a bug in `NSURLSessionTask` that causes requests to not send a `Content-Length` header when streaming contents from an HTTP body, which is notably problematic when interacting with the Amazon S3 webservice. As a workaround, this method takes a request constructed with `multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:error:`, or any other request with an `HTTPBodyStream`, writes the contents to the specified file and returns a copy of the original request with the `HTTPBodyStream` property set to `nil`. From here, the file can either be passed to `AFURLSessionManager -uploadTaskWithRequest:fromFile:progress:completionHandler:`, or have its contents read into an `NSData` that's assigned to the `HTTPBody` property of the request. - - @see https://github.com/AFNetworking/AFNetworking/issues/1398 - */ -- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request - writingStreamContentsToFile:(NSURL *)fileURL - completionHandler:(void (^)(NSError *error))handler; - -@end - -#pragma mark - - -/** - The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPRequestSerializer -multipartFormRequestWithMethod:URLString:parameters:constructingBodyWithBlock:`. - */ -@protocol AFMultipartFormData - -/** - Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary. - - The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively. - - @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. - @param name The name to be associated with the specified data. This parameter must not be `nil`. - @param error If an error occurs, upon return contains an `NSError` object that describes the problem. - - @return `YES` if the file data was successfully appended, otherwise `NO`. - */ -- (BOOL)appendPartWithFileURL:(NSURL *)fileURL - name:(NSString *)name - error:(NSError * __autoreleasing *)error; - -/** - Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. - - @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. - @param name The name to be associated with the specified data. This parameter must not be `nil`. - @param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`. - @param mimeType The declared MIME type of the file data. This parameter must not be `nil`. - @param error If an error occurs, upon return contains an `NSError` object that describes the problem. - - @return `YES` if the file data was successfully appended otherwise `NO`. - */ -- (BOOL)appendPartWithFileURL:(NSURL *)fileURL - name:(NSString *)name - fileName:(NSString *)fileName - mimeType:(NSString *)mimeType - error:(NSError * __autoreleasing *)error; - -/** - Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the data from the input stream and the multipart form boundary. - - @param inputStream The input stream to be appended to the form data - @param name The name to be associated with the specified input stream. This parameter must not be `nil`. - @param fileName The filename to be associated with the specified input stream. This parameter must not be `nil`. - @param length The length of the specified input stream in bytes. - @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. - */ -- (void)appendPartWithInputStream:(NSInputStream *)inputStream - name:(NSString *)name - fileName:(NSString *)fileName - length:(int64_t)length - mimeType:(NSString *)mimeType; - -/** - Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. - - @param data The data to be encoded and appended to the form data. - @param name The name to be associated with the specified data. This parameter must not be `nil`. - @param fileName The filename to be associated with the specified data. This parameter must not be `nil`. - @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. - */ -- (void)appendPartWithFileData:(NSData *)data - name:(NSString *)name - fileName:(NSString *)fileName - mimeType:(NSString *)mimeType; - -/** - Appends the HTTP headers `Content-Disposition: form-data; name=#{name}"`, followed by the encoded data and the multipart form boundary. - - @param data The data to be encoded and appended to the form data. - @param name The name to be associated with the specified data. This parameter must not be `nil`. - */ - -- (void)appendPartWithFormData:(NSData *)data - name:(NSString *)name; - - -/** - Appends HTTP headers, followed by the encoded data and the multipart form boundary. - - @param headers The HTTP headers to be appended to the form data. - @param body The data to be encoded and appended to the form data. - */ -- (void)appendPartWithHeaders:(NSDictionary *)headers - body:(NSData *)body; - -/** - Throttles request bandwidth by limiting the packet size and adding a delay for each chunk read from the upload stream. - - When uploading over a 3G or EDGE connection, requests may fail with "request body stream exhausted". Setting a maximum packet size and delay according to the recommended values (`kAFUploadStream3GSuggestedPacketSize` and `kAFUploadStream3GSuggestedDelay`) lowers the risk of the input stream exceeding its allocated bandwidth. Unfortunately, there is no definite way to distinguish between a 3G, EDGE, or LTE connection over `NSURLConnection`. As such, it is not recommended that you throttle bandwidth based solely on network reachability. Instead, you should consider checking for the "request body stream exhausted" in a failure block, and then retrying the request with throttled bandwidth. - - @param numberOfBytes Maximum packet size, in number of bytes. The default packet size for an input stream is 16kb. - @param delay Duration of delay each time a packet is read. By default, no delay is set. - */ -- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes - delay:(NSTimeInterval)delay; - -@end - -#pragma mark - - -@interface AFJSONRequestSerializer : AFHTTPRequestSerializer - -/** - Options for writing the request JSON data from Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONWritingOptions". `0` by default. - */ -@property (nonatomic, assign) NSJSONWritingOptions writingOptions; - -/** - Creates and returns a JSON serializer with specified reading and writing options. - - @param writingOptions The specified JSON writing options. - */ -+ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions; - -@end - -@interface AFPropertyListRequestSerializer : AFHTTPRequestSerializer - -/** - The property list format. Possible values are described in "NSPropertyListFormat". - */ -@property (nonatomic, assign) NSPropertyListFormat format; - -/** - @warning The `writeOptions` property is currently unused. - */ -@property (nonatomic, assign) NSPropertyListWriteOptions writeOptions; - -/** - Creates and returns a property list serializer with a specified format, read options, and write options. - - @param format The property list format. - @param writeOptions The property list write options. - - @warning The `writeOptions` property is currently unused. - */ -+ (instancetype)serializerWithFormat:(NSPropertyListFormat)format - writeOptions:(NSPropertyListWriteOptions)writeOptions; - -@end - -///---------------- -/// @name Constants -///---------------- - -/** - ## Error Domains - - The following error domain is predefined. - - - `NSString * const AFURLRequestSerializationErrorDomain` - - ### Constants - - `AFURLRequestSerializationErrorDomain` - AFURLRequestSerializer errors. Error codes for `AFURLRequestSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. - */ -extern NSString * const AFURLRequestSerializationErrorDomain; - -/** - ## User info dictionary keys - - These keys may exist in the user info dictionary, in addition to those defined for NSError. - - - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey` - - ### Constants - - `AFNetworkingOperationFailingURLRequestErrorKey` - The corresponding value is an `NSURLRequest` containing the request of the operation associated with an error. This key is only present in the `AFURLRequestSerializationErrorDomain`. - */ -extern NSString * const AFNetworkingOperationFailingURLRequestErrorKey; - -/** - ## Throttling Bandwidth for HTTP Request Input Streams - - @see -throttleBandwidthWithPacketSize:delay: - - ### Constants - - `kAFUploadStream3GSuggestedPacketSize` - Maximum packet size, in number of bytes. Equal to 16kb. - - `kAFUploadStream3GSuggestedDelay` - Duration of delay each time a packet is read. Equal to 0.2 seconds. - */ -extern NSUInteger const kAFUploadStream3GSuggestedPacketSize; -extern NSTimeInterval const kAFUploadStream3GSuggestedDelay; diff --git a/Ryff/Frameworks/AFNetworking/AFURLRequestSerialization.m b/Ryff/Frameworks/AFNetworking/AFURLRequestSerialization.m deleted file mode 100755 index 45df7a0..0000000 --- a/Ryff/Frameworks/AFNetworking/AFURLRequestSerialization.m +++ /dev/null @@ -1,1281 +0,0 @@ -// AFSerialization.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import "AFURLRequestSerialization.h" - -#if __IPHONE_OS_VERSION_MIN_REQUIRED -#import -#else -#import -#endif - -NSString * const AFURLRequestSerializationErrorDomain = @"com.alamofire.error.serialization.request"; -NSString * const AFNetworkingOperationFailingURLRequestErrorKey = @"com.alamofire.serialization.request.error.response"; - -typedef NSString * (^AFQueryStringSerializationBlock)(NSURLRequest *request, NSDictionary *parameters, NSError *__autoreleasing *error); - -static NSString * AFBase64EncodedStringFromString(NSString *string) { - NSData *data = [NSData dataWithBytes:[string UTF8String] length:[string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]]; - NSUInteger length = [data length]; - NSMutableData *mutableData = [NSMutableData dataWithLength:((length + 2) / 3) * 4]; - - uint8_t *input = (uint8_t *)[data bytes]; - uint8_t *output = (uint8_t *)[mutableData mutableBytes]; - - for (NSUInteger i = 0; i < length; i += 3) { - NSUInteger value = 0; - for (NSUInteger j = i; j < (i + 3); j++) { - value <<= 8; - if (j < length) { - value |= (0xFF & input[j]); - } - } - - static uint8_t const kAFBase64EncodingTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - NSUInteger idx = (i / 3) * 4; - output[idx + 0] = kAFBase64EncodingTable[(value >> 18) & 0x3F]; - output[idx + 1] = kAFBase64EncodingTable[(value >> 12) & 0x3F]; - output[idx + 2] = (i + 1) < length ? kAFBase64EncodingTable[(value >> 6) & 0x3F] : '='; - output[idx + 3] = (i + 2) < length ? kAFBase64EncodingTable[(value >> 0) & 0x3F] : '='; - } - - return [[NSString alloc] initWithData:mutableData encoding:NSASCIIStringEncoding]; -} - -static NSString * const kAFCharactersToBeEscapedInQueryString = @":/?&=;+!@#$()',*"; - -static NSString * AFPercentEscapedQueryStringKeyFromStringWithEncoding(NSString *string, NSStringEncoding encoding) { - static NSString * const kAFCharactersToLeaveUnescapedInQueryStringPairKey = @"[]."; - - return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, (__bridge CFStringRef)kAFCharactersToLeaveUnescapedInQueryStringPairKey, (__bridge CFStringRef)kAFCharactersToBeEscapedInQueryString, CFStringConvertNSStringEncodingToEncoding(encoding)); -} - -static NSString * AFPercentEscapedQueryStringValueFromStringWithEncoding(NSString *string, NSStringEncoding encoding) { - return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, NULL, (__bridge CFStringRef)kAFCharactersToBeEscapedInQueryString, CFStringConvertNSStringEncodingToEncoding(encoding)); -} - -#pragma mark - - -@interface AFQueryStringPair : NSObject -@property (readwrite, nonatomic, strong) id field; -@property (readwrite, nonatomic, strong) id value; - -- (id)initWithField:(id)field value:(id)value; - -- (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding; -@end - -@implementation AFQueryStringPair - -- (id)initWithField:(id)field value:(id)value { - self = [super init]; - if (!self) { - return nil; - } - - self.field = field; - self.value = value; - - return self; -} - -- (NSString *)URLEncodedStringValueWithEncoding:(NSStringEncoding)stringEncoding { - if (!self.value || [self.value isEqual:[NSNull null]]) { - return AFPercentEscapedQueryStringKeyFromStringWithEncoding([self.field description], stringEncoding); - } else { - return [NSString stringWithFormat:@"%@=%@", AFPercentEscapedQueryStringKeyFromStringWithEncoding([self.field description], stringEncoding), AFPercentEscapedQueryStringValueFromStringWithEncoding([self.value description], stringEncoding)]; - } -} - -@end - -#pragma mark - - -extern NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary); -extern NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value); - -static NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding stringEncoding) { - NSMutableArray *mutablePairs = [NSMutableArray array]; - for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { - [mutablePairs addObject:[pair URLEncodedStringValueWithEncoding:stringEncoding]]; - } - - return [mutablePairs componentsJoinedByString:@"&"]; -} - -NSArray * AFQueryStringPairsFromDictionary(NSDictionary *dictionary) { - return AFQueryStringPairsFromKeyAndValue(nil, dictionary); -} - -NSArray * AFQueryStringPairsFromKeyAndValue(NSString *key, id value) { - NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; - - NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(compare:)]; - - if ([value isKindOfClass:[NSDictionary class]]) { - NSDictionary *dictionary = value; - // Sort dictionary keys to ensure consistent ordering in query string, which is important when deserializing potentially ambiguous sequences, such as an array of dictionaries - for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { - id nestedValue = [dictionary objectForKey:nestedKey]; - if (nestedValue) { - [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; - } - } - } else if ([value isKindOfClass:[NSArray class]]) { - NSArray *array = value; - for (id nestedValue in array) { - [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; - } - } else if ([value isKindOfClass:[NSSet class]]) { - NSSet *set = value; - for (id obj in [set sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { - [mutableQueryStringComponents addObjectsFromArray:AFQueryStringPairsFromKeyAndValue(key, obj)]; - } - } else { - [mutableQueryStringComponents addObject:[[AFQueryStringPair alloc] initWithField:key value:value]]; - } - - return mutableQueryStringComponents; -} - -#pragma mark - - -@interface AFStreamingMultipartFormData : NSObject -- (instancetype)initWithURLRequest:(NSMutableURLRequest *)urlRequest - stringEncoding:(NSStringEncoding)encoding; - -- (NSMutableURLRequest *)requestByFinalizingMultipartFormData; -@end - -#pragma mark - - -@interface AFHTTPRequestSerializer () -@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableHTTPRequestHeaders; -@property (readwrite, nonatomic, assign) AFHTTPRequestQueryStringSerializationStyle queryStringSerializationStyle; -@property (readwrite, nonatomic, copy) AFQueryStringSerializationBlock queryStringSerialization; -@end - -@implementation AFHTTPRequestSerializer - -+ (instancetype)serializer { - return [[self alloc] init]; -} - -- (instancetype)init { - self = [super init]; - if (!self) { - return nil; - } - - self.stringEncoding = NSUTF8StringEncoding; - self.allowsCellularAccess = YES; - self.cachePolicy = NSURLRequestUseProtocolCachePolicy; - self.HTTPShouldHandleCookies = YES; - self.HTTPShouldUsePipelining = NO; - self.networkServiceType = NSURLNetworkServiceTypeDefault; - self.timeoutInterval = 60; - - self.mutableHTTPRequestHeaders = [NSMutableDictionary dictionary]; - - // Accept-Language HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 - NSMutableArray *acceptLanguagesComponents = [NSMutableArray array]; - [[NSLocale preferredLanguages] enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - float q = 1.0f - (idx * 0.1f); - [acceptLanguagesComponents addObject:[NSString stringWithFormat:@"%@;q=%0.1g", obj, q]]; - *stop = q <= 0.5f; - }]; - [self setValue:[acceptLanguagesComponents componentsJoinedByString:@", "] forHTTPHeaderField:@"Accept-Language"]; - - NSString *userAgent = nil; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wgnu" -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - // User-Agent Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43 - userAgent = [NSString stringWithFormat:@"%@/%@ (%@; iOS %@; Scale/%0.2f)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleIdentifierKey], (__bridge id)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey) ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleVersionKey], [[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]]; -#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) - userAgent = [NSString stringWithFormat:@"%@/%@ (Mac OS X %@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleExecutableKey] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleIdentifierKey], [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"] ?: [[[NSBundle mainBundle] infoDictionary] objectForKey:(__bridge NSString *)kCFBundleVersionKey], [[NSProcessInfo processInfo] operatingSystemVersionString]]; -#endif -#pragma clang diagnostic pop - if (userAgent) { - if (![userAgent canBeConvertedToEncoding:NSASCIIStringEncoding]) { - NSMutableString *mutableUserAgent = [userAgent mutableCopy]; - if (CFStringTransform((__bridge CFMutableStringRef)(mutableUserAgent), NULL, (__bridge CFStringRef)@"Any-Latin; Latin-ASCII; [:^ASCII:] Remove", false)) { - userAgent = mutableUserAgent; - } - } - [self setValue:userAgent forHTTPHeaderField:@"User-Agent"]; - } - - // HTTP Method Definitions; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html - self.HTTPMethodsEncodingParametersInURI = [NSSet setWithObjects:@"GET", @"HEAD", @"DELETE", nil]; - - return self; -} - -#pragma mark - - -- (NSDictionary *)HTTPRequestHeaders { - return [NSDictionary dictionaryWithDictionary:self.mutableHTTPRequestHeaders]; -} - -- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field { - [self.mutableHTTPRequestHeaders setValue:value forKey:field]; -} - -- (void)setAuthorizationHeaderFieldWithUsername:(NSString *)username password:(NSString *)password { - NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", username, password]; - [self setValue:[NSString stringWithFormat:@"Basic %@", AFBase64EncodedStringFromString(basicAuthCredentials)] forHTTPHeaderField:@"Authorization"]; -} - -- (void)setAuthorizationHeaderFieldWithToken:(NSString *)token { - [self setValue:[NSString stringWithFormat:@"Token token=\"%@\"", token] forHTTPHeaderField:@"Authorization"]; -} - -- (void)clearAuthorizationHeader { - [self.mutableHTTPRequestHeaders removeObjectForKey:@"Authorization"]; -} - -#pragma mark - - -- (void)setQueryStringSerializationWithStyle:(AFHTTPRequestQueryStringSerializationStyle)style { - self.queryStringSerializationStyle = style; - self.queryStringSerialization = nil; -} - -- (void)setQueryStringSerializationWithBlock:(NSString *(^)(NSURLRequest *, NSDictionary *, NSError *__autoreleasing *))block { - self.queryStringSerialization = block; -} - -#pragma mark - - -- (NSMutableURLRequest *)requestWithMethod:(NSString *)method - URLString:(NSString *)URLString - parameters:(id)parameters -{ - return [self requestWithMethod:method URLString:URLString parameters:parameters error:nil]; -} - -- (NSMutableURLRequest *)requestWithMethod:(NSString *)method - URLString:(NSString *)URLString - parameters:(id)parameters - error:(NSError *__autoreleasing *)error -{ - NSParameterAssert(method); - NSParameterAssert(URLString); - - NSURL *url = [NSURL URLWithString:URLString]; - - NSParameterAssert(url); - - NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:url]; - mutableRequest.HTTPMethod = method; - mutableRequest.allowsCellularAccess = self.allowsCellularAccess; - mutableRequest.cachePolicy = self.cachePolicy; - mutableRequest.HTTPShouldHandleCookies = self.HTTPShouldHandleCookies; - mutableRequest.HTTPShouldUsePipelining = self.HTTPShouldUsePipelining; - mutableRequest.networkServiceType = self.networkServiceType; - mutableRequest.timeoutInterval = self.timeoutInterval; - - mutableRequest = [[self requestBySerializingRequest:mutableRequest withParameters:parameters error:error] mutableCopy]; - - return mutableRequest; -} - -- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method - URLString:(NSString *)URLString - parameters:(NSDictionary *)parameters - constructingBodyWithBlock:(void (^)(id formData))block -{ - return [self multipartFormRequestWithMethod:method URLString:URLString parameters:parameters constructingBodyWithBlock:block error:nil]; -} - -- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method - URLString:(NSString *)URLString - parameters:(NSDictionary *)parameters - constructingBodyWithBlock:(void (^)(id formData))block - error:(NSError *__autoreleasing *)error -{ - NSParameterAssert(method); - NSParameterAssert(![method isEqualToString:@"GET"] && ![method isEqualToString:@"HEAD"]); - - NSMutableURLRequest *mutableRequest = [self requestWithMethod:method URLString:URLString parameters:nil error:error]; - - __block AFStreamingMultipartFormData *formData = [[AFStreamingMultipartFormData alloc] initWithURLRequest:mutableRequest stringEncoding:NSUTF8StringEncoding]; - - if (parameters) { - for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { - NSData *data = nil; - if ([pair.value isKindOfClass:[NSData class]]) { - data = pair.value; - } else if ([pair.value isEqual:[NSNull null]]) { - data = [NSData data]; - } else { - data = [[pair.value description] dataUsingEncoding:self.stringEncoding]; - } - - if (data) { - [formData appendPartWithFormData:data name:[pair.field description]]; - } - } - } - - if (block) { - block(formData); - } - - return [formData requestByFinalizingMultipartFormData]; -} - -- (NSMutableURLRequest *)requestWithMultipartFormRequest:(NSURLRequest *)request - writingStreamContentsToFile:(NSURL *)fileURL - completionHandler:(void (^)(NSError *error))handler -{ - if (!request.HTTPBodyStream) { - return [request mutableCopy]; - } - - NSParameterAssert([fileURL isFileURL]); - - NSInputStream *inputStream = request.HTTPBodyStream; - NSOutputStream *outputStream = [[NSOutputStream alloc] initWithURL:fileURL append:NO]; - __block NSError *error = nil; - - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; - [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; - - [inputStream open]; - [outputStream open]; - - while ([inputStream hasBytesAvailable] && [outputStream hasSpaceAvailable]) { - uint8_t buffer[1024]; - - NSInteger bytesRead = [inputStream read:buffer maxLength:1024]; - if (inputStream.streamError || bytesRead < 0) { - error = inputStream.streamError; - break; - } - - NSInteger bytesWritten = [outputStream write:buffer maxLength:(NSUInteger)bytesRead]; - if (outputStream.streamError || bytesWritten < 0) { - error = outputStream.streamError; - break; - } - - if (bytesRead == 0 && bytesWritten == 0) { - break; - } - } - - [outputStream close]; - [inputStream close]; - - if (handler) { - dispatch_async(dispatch_get_main_queue(), ^{ - handler(error); - }); - } - }); - - NSMutableURLRequest *mutableRequest = [request mutableCopy]; - mutableRequest.HTTPBodyStream = nil; - - return mutableRequest; -} - -#pragma mark - AFURLRequestSerialization - -- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request - withParameters:(id)parameters - error:(NSError *__autoreleasing *)error -{ - NSParameterAssert(request); - - NSMutableURLRequest *mutableRequest = [request mutableCopy]; - - [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { - if (![request valueForHTTPHeaderField:field]) { - [mutableRequest setValue:value forHTTPHeaderField:field]; - } - }]; - - if (parameters) { - NSString *query = nil; - if (self.queryStringSerialization) { - query = self.queryStringSerialization(request, parameters, error); - } else { - switch (self.queryStringSerializationStyle) { - case AFHTTPRequestQueryStringDefaultStyle: - query = AFQueryStringFromParametersWithEncoding(parameters, self.stringEncoding); - break; - } - } - - if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { - mutableRequest.URL = [NSURL URLWithString:[[mutableRequest.URL absoluteString] stringByAppendingFormat:mutableRequest.URL.query ? @"&%@" : @"?%@", query]]; - } else { - if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { - NSString *charset = (__bridge NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(self.stringEncoding)); - [mutableRequest setValue:[NSString stringWithFormat:@"application/x-www-form-urlencoded; charset=%@", charset] forHTTPHeaderField:@"Content-Type"]; - } - [mutableRequest setHTTPBody:[query dataUsingEncoding:self.stringEncoding]]; - } - } - - return mutableRequest; -} - -#pragma mark - NSecureCoding - -+ (BOOL)supportsSecureCoding { - return YES; -} - -- (id)initWithCoder:(NSCoder *)decoder { - self = [self init]; - if (!self) { - return nil; - } - - self.mutableHTTPRequestHeaders = [[decoder decodeObjectOfClass:[NSDictionary class] forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))] mutableCopy]; - self.queryStringSerializationStyle = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))] unsignedIntegerValue]; - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [coder encodeObject:self.mutableHTTPRequestHeaders forKey:NSStringFromSelector(@selector(mutableHTTPRequestHeaders))]; - [coder encodeInteger:self.queryStringSerializationStyle forKey:NSStringFromSelector(@selector(queryStringSerializationStyle))]; -} - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone { - AFHTTPRequestSerializer *serializer = [[[self class] allocWithZone:zone] init]; - serializer.mutableHTTPRequestHeaders = [self.mutableHTTPRequestHeaders mutableCopyWithZone:zone]; - serializer.queryStringSerializationStyle = self.queryStringSerializationStyle; - serializer.queryStringSerialization = self.queryStringSerialization; - - return serializer; -} - -@end - -#pragma mark - - -static NSString * AFCreateMultipartFormBoundary() { - return [NSString stringWithFormat:@"Boundary+%08X%08X", arc4random(), arc4random()]; -} - -static NSString * const kAFMultipartFormCRLF = @"\r\n"; - -static inline NSString * AFMultipartFormInitialBoundary(NSString *boundary) { - return [NSString stringWithFormat:@"--%@%@", boundary, kAFMultipartFormCRLF]; -} - -static inline NSString * AFMultipartFormEncapsulationBoundary(NSString *boundary) { - return [NSString stringWithFormat:@"%@--%@%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF]; -} - -static inline NSString * AFMultipartFormFinalBoundary(NSString *boundary) { - return [NSString stringWithFormat:@"%@--%@--%@", kAFMultipartFormCRLF, boundary, kAFMultipartFormCRLF]; -} - -static inline NSString * AFContentTypeForPathExtension(NSString *extension) { -#ifdef __UTTYPE__ - NSString *UTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)extension, NULL); - NSString *contentType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)UTI, kUTTagClassMIMEType); - if (!contentType) { - return @"application/octet-stream"; - } else { - return contentType; - } -#else -#pragma unused (extension) - return @"application/octet-stream"; -#endif -} - -NSUInteger const kAFUploadStream3GSuggestedPacketSize = 1024 * 16; -NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2; - -@interface AFHTTPBodyPart : NSObject -@property (nonatomic, assign) NSStringEncoding stringEncoding; -@property (nonatomic, strong) NSDictionary *headers; -@property (nonatomic, copy) NSString *boundary; -@property (nonatomic, strong) id body; -@property (nonatomic, assign) unsigned long long bodyContentLength; -@property (nonatomic, strong) NSInputStream *inputStream; - -@property (nonatomic, assign) BOOL hasInitialBoundary; -@property (nonatomic, assign) BOOL hasFinalBoundary; - -@property (readonly, nonatomic, assign, getter = hasBytesAvailable) BOOL bytesAvailable; -@property (readonly, nonatomic, assign) unsigned long long contentLength; - -- (NSInteger)read:(uint8_t *)buffer - maxLength:(NSUInteger)length; -@end - -@interface AFMultipartBodyStream : NSInputStream -@property (nonatomic, assign) NSUInteger numberOfBytesInPacket; -@property (nonatomic, assign) NSTimeInterval delay; -@property (nonatomic, strong) NSInputStream *inputStream; -@property (readonly, nonatomic, assign) unsigned long long contentLength; -@property (readonly, nonatomic, assign, getter = isEmpty) BOOL empty; - -- (id)initWithStringEncoding:(NSStringEncoding)encoding; -- (void)setInitialAndFinalBoundaries; -- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart; -@end - -#pragma mark - - -@interface AFStreamingMultipartFormData () -@property (readwrite, nonatomic, copy) NSMutableURLRequest *request; -@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; -@property (readwrite, nonatomic, copy) NSString *boundary; -@property (readwrite, nonatomic, strong) AFMultipartBodyStream *bodyStream; -@end - -@implementation AFStreamingMultipartFormData - -- (id)initWithURLRequest:(NSMutableURLRequest *)urlRequest - stringEncoding:(NSStringEncoding)encoding -{ - self = [super init]; - if (!self) { - return nil; - } - - self.request = urlRequest; - self.stringEncoding = encoding; - self.boundary = AFCreateMultipartFormBoundary(); - self.bodyStream = [[AFMultipartBodyStream alloc] initWithStringEncoding:encoding]; - - return self; -} - -- (BOOL)appendPartWithFileURL:(NSURL *)fileURL - name:(NSString *)name - error:(NSError * __autoreleasing *)error -{ - NSParameterAssert(fileURL); - NSParameterAssert(name); - - NSString *fileName = [fileURL lastPathComponent]; - NSString *mimeType = AFContentTypeForPathExtension([fileURL pathExtension]); - - return [self appendPartWithFileURL:fileURL name:name fileName:fileName mimeType:mimeType error:error]; -} - -- (BOOL)appendPartWithFileURL:(NSURL *)fileURL - name:(NSString *)name - fileName:(NSString *)fileName - mimeType:(NSString *)mimeType - error:(NSError * __autoreleasing *)error -{ - NSParameterAssert(fileURL); - NSParameterAssert(name); - NSParameterAssert(fileName); - NSParameterAssert(mimeType); - - if (![fileURL isFileURL]) { - NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"Expected URL to be a file URL", @"AFNetworking", nil)}; - if (error) { - *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; - } - - return NO; - } else if ([fileURL checkResourceIsReachableAndReturnError:error] == NO) { - NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: NSLocalizedStringFromTable(@"File URL not reachable.", @"AFNetworking", nil)}; - if (error) { - *error = [[NSError alloc] initWithDomain:AFURLRequestSerializationErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; - } - - return NO; - } - - NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[fileURL path] error:error]; - if (!fileAttributes) { - return NO; - } - - NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; - [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; - [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; - - AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; - bodyPart.stringEncoding = self.stringEncoding; - bodyPart.headers = mutableHeaders; - bodyPart.boundary = self.boundary; - bodyPart.body = fileURL; - bodyPart.bodyContentLength = [[fileAttributes objectForKey:NSFileSize] unsignedLongLongValue]; - [self.bodyStream appendHTTPBodyPart:bodyPart]; - - return YES; -} - -- (void)appendPartWithInputStream:(NSInputStream *)inputStream - name:(NSString *)name - fileName:(NSString *)fileName - length:(int64_t)length - mimeType:(NSString *)mimeType -{ - NSParameterAssert(name); - NSParameterAssert(fileName); - NSParameterAssert(mimeType); - - NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; - [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; - [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; - - - AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; - bodyPart.stringEncoding = self.stringEncoding; - bodyPart.headers = mutableHeaders; - bodyPart.boundary = self.boundary; - bodyPart.body = inputStream; - - bodyPart.bodyContentLength = (unsigned long long)length; - - [self.bodyStream appendHTTPBodyPart:bodyPart]; -} - -- (void)appendPartWithFileData:(NSData *)data - name:(NSString *)name - fileName:(NSString *)fileName - mimeType:(NSString *)mimeType -{ - NSParameterAssert(name); - NSParameterAssert(fileName); - NSParameterAssert(mimeType); - - NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; - [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"; filename=\"%@\"", name, fileName] forKey:@"Content-Disposition"]; - [mutableHeaders setValue:mimeType forKey:@"Content-Type"]; - - [self appendPartWithHeaders:mutableHeaders body:data]; -} - -- (void)appendPartWithFormData:(NSData *)data - name:(NSString *)name -{ - NSParameterAssert(name); - - NSMutableDictionary *mutableHeaders = [NSMutableDictionary dictionary]; - [mutableHeaders setValue:[NSString stringWithFormat:@"form-data; name=\"%@\"", name] forKey:@"Content-Disposition"]; - - [self appendPartWithHeaders:mutableHeaders body:data]; -} - -- (void)appendPartWithHeaders:(NSDictionary *)headers - body:(NSData *)body -{ - NSParameterAssert(body); - - AFHTTPBodyPart *bodyPart = [[AFHTTPBodyPart alloc] init]; - bodyPart.stringEncoding = self.stringEncoding; - bodyPart.headers = headers; - bodyPart.boundary = self.boundary; - bodyPart.bodyContentLength = [body length]; - bodyPart.body = body; - - [self.bodyStream appendHTTPBodyPart:bodyPart]; -} - -- (void)throttleBandwidthWithPacketSize:(NSUInteger)numberOfBytes - delay:(NSTimeInterval)delay -{ - self.bodyStream.numberOfBytesInPacket = numberOfBytes; - self.bodyStream.delay = delay; -} - -- (NSMutableURLRequest *)requestByFinalizingMultipartFormData { - if ([self.bodyStream isEmpty]) { - return self.request; - } - - // Reset the initial and final boundaries to ensure correct Content-Length - [self.bodyStream setInitialAndFinalBoundaries]; - [self.request setHTTPBodyStream:self.bodyStream]; - - [self.request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", self.boundary] forHTTPHeaderField:@"Content-Type"]; - [self.request setValue:[NSString stringWithFormat:@"%llu", [self.bodyStream contentLength]] forHTTPHeaderField:@"Content-Length"]; - - return self.request; -} - -@end - -#pragma mark - - -@interface NSStream () -@property (readwrite) NSStreamStatus streamStatus; -@property (readwrite, copy) NSError *streamError; -@end - -@interface AFMultipartBodyStream () -@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; -@property (readwrite, nonatomic, strong) NSMutableArray *HTTPBodyParts; -@property (readwrite, nonatomic, strong) NSEnumerator *HTTPBodyPartEnumerator; -@property (readwrite, nonatomic, strong) AFHTTPBodyPart *currentHTTPBodyPart; -@property (readwrite, nonatomic, strong) NSOutputStream *outputStream; -@property (readwrite, nonatomic, strong) NSMutableData *buffer; -@end - -@implementation AFMultipartBodyStream -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wimplicit-atomic-properties" -@synthesize streamStatus; -@synthesize streamError; -#pragma clang diagnostic pop - -- (id)initWithStringEncoding:(NSStringEncoding)encoding { - self = [super init]; - if (!self) { - return nil; - } - - self.stringEncoding = encoding; - self.HTTPBodyParts = [NSMutableArray array]; - self.numberOfBytesInPacket = NSIntegerMax; - - return self; -} - -- (void)setInitialAndFinalBoundaries { - if ([self.HTTPBodyParts count] > 0) { - for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { - bodyPart.hasInitialBoundary = NO; - bodyPart.hasFinalBoundary = NO; - } - - [[self.HTTPBodyParts objectAtIndex:0] setHasInitialBoundary:YES]; - [[self.HTTPBodyParts lastObject] setHasFinalBoundary:YES]; - } -} - -- (void)appendHTTPBodyPart:(AFHTTPBodyPart *)bodyPart { - [self.HTTPBodyParts addObject:bodyPart]; -} - -- (BOOL)isEmpty { - return [self.HTTPBodyParts count] == 0; -} - -#pragma mark - NSInputStream - -- (NSInteger)read:(uint8_t *)buffer - maxLength:(NSUInteger)length -{ - if ([self streamStatus] == NSStreamStatusClosed) { - return 0; - } - - NSInteger totalNumberOfBytesRead = 0; - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wgnu" - while ((NSUInteger)totalNumberOfBytesRead < MIN(length, self.numberOfBytesInPacket)) { - if (!self.currentHTTPBodyPart || ![self.currentHTTPBodyPart hasBytesAvailable]) { - if (!(self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject])) { - break; - } - } else { - NSUInteger maxLength = length - (NSUInteger)totalNumberOfBytesRead; - NSInteger numberOfBytesRead = [self.currentHTTPBodyPart read:&buffer[totalNumberOfBytesRead] maxLength:maxLength]; - if (numberOfBytesRead == -1) { - self.streamError = self.currentHTTPBodyPart.inputStream.streamError; - break; - } else { - totalNumberOfBytesRead += numberOfBytesRead; - - if (self.delay > 0.0f) { - [NSThread sleepForTimeInterval:self.delay]; - } - } - } - } -#pragma clang diagnostic pop - - return totalNumberOfBytesRead; -} - -- (BOOL)getBuffer:(__unused uint8_t **)buffer - length:(__unused NSUInteger *)len -{ - return NO; -} - -- (BOOL)hasBytesAvailable { - return [self streamStatus] == NSStreamStatusOpen; -} - -#pragma mark - NSStream - -- (void)open { - if (self.streamStatus == NSStreamStatusOpen) { - return; - } - - self.streamStatus = NSStreamStatusOpen; - - [self setInitialAndFinalBoundaries]; - self.HTTPBodyPartEnumerator = [self.HTTPBodyParts objectEnumerator]; -} - -- (void)close { - self.streamStatus = NSStreamStatusClosed; -} - -- (id)propertyForKey:(__unused NSString *)key { - return nil; -} - -- (BOOL)setProperty:(__unused id)property - forKey:(__unused NSString *)key -{ - return NO; -} - -- (void)scheduleInRunLoop:(__unused NSRunLoop *)aRunLoop - forMode:(__unused NSString *)mode -{} - -- (void)removeFromRunLoop:(__unused NSRunLoop *)aRunLoop - forMode:(__unused NSString *)mode -{} - -- (unsigned long long)contentLength { - unsigned long long length = 0; - for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { - length += [bodyPart contentLength]; - } - - return length; -} - -#pragma mark - Undocumented CFReadStream Bridged Methods - -- (void)_scheduleInCFRunLoop:(__unused CFRunLoopRef)aRunLoop - forMode:(__unused CFStringRef)aMode -{} - -- (void)_unscheduleFromCFRunLoop:(__unused CFRunLoopRef)aRunLoop - forMode:(__unused CFStringRef)aMode -{} - -- (BOOL)_setCFClientFlags:(__unused CFOptionFlags)inFlags - callback:(__unused CFReadStreamClientCallBack)inCallback - context:(__unused CFStreamClientContext *)inContext { - return NO; -} - -#pragma mark - NSCopying - --(id)copyWithZone:(NSZone *)zone { - AFMultipartBodyStream *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding]; - - for (AFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { - [bodyStreamCopy appendHTTPBodyPart:[bodyPart copy]]; - } - - [bodyStreamCopy setInitialAndFinalBoundaries]; - - return bodyStreamCopy; -} - -@end - -#pragma mark - - -typedef enum { - AFEncapsulationBoundaryPhase = 1, - AFHeaderPhase = 2, - AFBodyPhase = 3, - AFFinalBoundaryPhase = 4, -} AFHTTPBodyPartReadPhase; - -@interface AFHTTPBodyPart () { - AFHTTPBodyPartReadPhase _phase; - NSInputStream *_inputStream; - unsigned long long _phaseReadOffset; -} - -- (BOOL)transitionToNextPhase; -- (NSInteger)readData:(NSData *)data - intoBuffer:(uint8_t *)buffer - maxLength:(NSUInteger)length; -@end - -@implementation AFHTTPBodyPart - -- (id)init { - self = [super init]; - if (!self) { - return nil; - } - - [self transitionToNextPhase]; - - return self; -} - -- (void)dealloc { - if (_inputStream) { - [_inputStream close]; - _inputStream = nil; - } -} - -- (NSInputStream *)inputStream { - if (!_inputStream) { - if ([self.body isKindOfClass:[NSData class]]) { - _inputStream = [NSInputStream inputStreamWithData:self.body]; - } else if ([self.body isKindOfClass:[NSURL class]]) { - _inputStream = [NSInputStream inputStreamWithURL:self.body]; - } else if ([self.body isKindOfClass:[NSInputStream class]]) { - _inputStream = self.body; - } - } - - return _inputStream; -} - -- (NSString *)stringForHeaders { - NSMutableString *headerString = [NSMutableString string]; - for (NSString *field in [self.headers allKeys]) { - [headerString appendString:[NSString stringWithFormat:@"%@: %@%@", field, [self.headers valueForKey:field], kAFMultipartFormCRLF]]; - } - [headerString appendString:kAFMultipartFormCRLF]; - - return [NSString stringWithString:headerString]; -} - -- (unsigned long long)contentLength { - unsigned long long length = 0; - - NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding]; - length += [encapsulationBoundaryData length]; - - NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; - length += [headersData length]; - - length += _bodyContentLength; - - NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]); - length += [closingBoundaryData length]; - - return length; -} - -- (BOOL)hasBytesAvailable { - // Allows `read:maxLength:` to be called again if `AFMultipartFormFinalBoundary` doesn't fit into the available buffer - if (_phase == AFFinalBoundaryPhase) { - return YES; - } - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wcovered-switch-default" - switch (self.inputStream.streamStatus) { - case NSStreamStatusNotOpen: - case NSStreamStatusOpening: - case NSStreamStatusOpen: - case NSStreamStatusReading: - case NSStreamStatusWriting: - return YES; - case NSStreamStatusAtEnd: - case NSStreamStatusClosed: - case NSStreamStatusError: - default: - return NO; - } -#pragma clang diagnostic pop -} - -- (NSInteger)read:(uint8_t *)buffer - maxLength:(NSUInteger)length -{ - NSInteger totalNumberOfBytesRead = 0; - - if (_phase == AFEncapsulationBoundaryPhase) { - NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary(self.boundary) : AFMultipartFormEncapsulationBoundary(self.boundary)) dataUsingEncoding:self.stringEncoding]; - totalNumberOfBytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; - } - - if (_phase == AFHeaderPhase) { - NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; - totalNumberOfBytesRead += [self readData:headersData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; - } - - if (_phase == AFBodyPhase) { - NSInteger numberOfBytesRead = 0; - - numberOfBytesRead = [self.inputStream read:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; - if (numberOfBytesRead == -1) { - return -1; - } else { - totalNumberOfBytesRead += numberOfBytesRead; - - if ([self.inputStream streamStatus] >= NSStreamStatusAtEnd) { - [self transitionToNextPhase]; - } - } - } - - if (_phase == AFFinalBoundaryPhase) { - NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary(self.boundary) dataUsingEncoding:self.stringEncoding] : [NSData data]); - totalNumberOfBytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[totalNumberOfBytesRead] maxLength:(length - (NSUInteger)totalNumberOfBytesRead)]; - } - - return totalNumberOfBytesRead; -} - -- (NSInteger)readData:(NSData *)data - intoBuffer:(uint8_t *)buffer - maxLength:(NSUInteger)length -{ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wgnu" - NSRange range = NSMakeRange((NSUInteger)_phaseReadOffset, MIN([data length] - ((NSUInteger)_phaseReadOffset), length)); - [data getBytes:buffer range:range]; -#pragma clang diagnostic pop - - _phaseReadOffset += range.length; - - if (((NSUInteger)_phaseReadOffset) >= [data length]) { - [self transitionToNextPhase]; - } - - return (NSInteger)range.length; -} - -- (BOOL)transitionToNextPhase { - if (![[NSThread currentThread] isMainThread]) { - [self performSelectorOnMainThread:@selector(transitionToNextPhase) withObject:nil waitUntilDone:YES]; - return YES; - } - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wcovered-switch-default" - switch (_phase) { - case AFEncapsulationBoundaryPhase: - _phase = AFHeaderPhase; - break; - case AFHeaderPhase: - [self.inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; - [self.inputStream open]; - _phase = AFBodyPhase; - break; - case AFBodyPhase: - [self.inputStream close]; - _phase = AFFinalBoundaryPhase; - break; - case AFFinalBoundaryPhase: - default: - _phase = AFEncapsulationBoundaryPhase; - break; - } - _phaseReadOffset = 0; -#pragma clang diagnostic pop - - return YES; -} - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone { - AFHTTPBodyPart *bodyPart = [[[self class] allocWithZone:zone] init]; - - bodyPart.stringEncoding = self.stringEncoding; - bodyPart.headers = self.headers; - bodyPart.bodyContentLength = self.bodyContentLength; - bodyPart.body = self.body; - bodyPart.boundary = self.boundary; - - return bodyPart; -} - -@end - -#pragma mark - - -@implementation AFJSONRequestSerializer - -+ (instancetype)serializer { - return [self serializerWithWritingOptions:0]; -} - -+ (instancetype)serializerWithWritingOptions:(NSJSONWritingOptions)writingOptions -{ - AFJSONRequestSerializer *serializer = [[self alloc] init]; - serializer.writingOptions = writingOptions; - - return serializer; -} - -#pragma mark - AFURLRequestSerialization - -- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request - withParameters:(id)parameters - error:(NSError *__autoreleasing *)error -{ - NSParameterAssert(request); - - if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { - return [super requestBySerializingRequest:request withParameters:parameters error:error]; - } - - NSMutableURLRequest *mutableRequest = [request mutableCopy]; - - [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { - if (![request valueForHTTPHeaderField:field]) { - [mutableRequest setValue:value forHTTPHeaderField:field]; - } - }]; - - if (parameters) { - if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { - NSString *charset = (__bridge NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)); - [mutableRequest setValue:[NSString stringWithFormat:@"application/json; charset=%@", charset] forHTTPHeaderField:@"Content-Type"]; - } - - [mutableRequest setHTTPBody:[NSJSONSerialization dataWithJSONObject:parameters options:self.writingOptions error:error]]; - } - - return mutableRequest; -} - -#pragma mark - NSecureCoding - -- (id)initWithCoder:(NSCoder *)decoder { - self = [super initWithCoder:decoder]; - if (!self) { - return nil; - } - - self.writingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writingOptions))] unsignedIntegerValue]; - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [super encodeWithCoder:coder]; - - [coder encodeInteger:self.writingOptions forKey:NSStringFromSelector(@selector(writingOptions))]; -} - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone { - AFJSONRequestSerializer *serializer = [super copyWithZone:zone]; - serializer.writingOptions = self.writingOptions; - - return serializer; -} - -@end - -#pragma mark - - -@implementation AFPropertyListRequestSerializer - -+ (instancetype)serializer { - return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 writeOptions:0]; -} - -+ (instancetype)serializerWithFormat:(NSPropertyListFormat)format - writeOptions:(NSPropertyListWriteOptions)writeOptions -{ - AFPropertyListRequestSerializer *serializer = [[self alloc] init]; - serializer.format = format; - serializer.writeOptions = writeOptions; - - return serializer; -} - -#pragma mark - AFURLRequestSerializer - -- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request - withParameters:(id)parameters - error:(NSError *__autoreleasing *)error -{ - NSParameterAssert(request); - - if ([self.HTTPMethodsEncodingParametersInURI containsObject:[[request HTTPMethod] uppercaseString]]) { - return [super requestBySerializingRequest:request withParameters:parameters error:error]; - } - - NSMutableURLRequest *mutableRequest = [request mutableCopy]; - - [self.HTTPRequestHeaders enumerateKeysAndObjectsUsingBlock:^(id field, id value, BOOL * __unused stop) { - if (![request valueForHTTPHeaderField:field]) { - [mutableRequest setValue:value forHTTPHeaderField:field]; - } - }]; - - if (parameters) { - if (![mutableRequest valueForHTTPHeaderField:@"Content-Type"]) { - NSString *charset = (__bridge NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)); - [mutableRequest setValue:[NSString stringWithFormat:@"application/x-plist; charset=%@", charset] forHTTPHeaderField:@"Content-Type"]; - } - - [mutableRequest setHTTPBody:[NSPropertyListSerialization dataWithPropertyList:parameters format:self.format options:self.writeOptions error:error]]; - } - - return mutableRequest; -} - -#pragma mark - NSecureCoding - -- (id)initWithCoder:(NSCoder *)decoder { - self = [super initWithCoder:decoder]; - if (!self) { - return nil; - } - - self.format = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue]; - self.writeOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writeOptions))] unsignedIntegerValue]; - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [super encodeWithCoder:coder]; - - [coder encodeInteger:self.format forKey:NSStringFromSelector(@selector(format))]; - [coder encodeObject:@(self.writeOptions) forKey:NSStringFromSelector(@selector(writeOptions))]; -} - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone { - AFPropertyListRequestSerializer *serializer = [super copyWithZone:zone]; - serializer.format = self.format; - serializer.writeOptions = self.writeOptions; - - return serializer; -} - -@end diff --git a/Ryff/Frameworks/AFNetworking/AFURLResponseSerialization.h b/Ryff/Frameworks/AFNetworking/AFURLResponseSerialization.h deleted file mode 100755 index 36ed33e..0000000 --- a/Ryff/Frameworks/AFNetworking/AFURLResponseSerialization.h +++ /dev/null @@ -1,294 +0,0 @@ -// AFSerialization.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import -#import - -/** - The `AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data. - - For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object. - */ -@protocol AFURLResponseSerialization - -/** - The response object decoded from the data associated with a specified response. - - @param response The response to be processed. - @param data The response data to be decoded. - @param error The error that occurred while attempting to decode the response data. - - @return The object decoded from the specified response data. - */ -- (id)responseObjectForResponse:(NSURLResponse *)response - data:(NSData *)data - error:(NSError *__autoreleasing *)error; - -@end - -#pragma mark - - -/** - `AFHTTPResponseSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation. - - Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior. - */ -@interface AFHTTPResponseSerializer : NSObject - -/** - The string encoding used to serialize parameters. - */ -@property (nonatomic, assign) NSStringEncoding stringEncoding; - -/** - Creates and returns a serializer with default configuration. - */ -+ (instancetype)serializer; - -///----------------------------------------- -/// @name Configuring Response Serialization -///----------------------------------------- - -/** - The acceptable HTTP status codes for responses. When non-`nil`, responses with status codes not contained by the set will result in an error during validation. - - See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html - */ -@property (nonatomic, copy) NSIndexSet *acceptableStatusCodes; - -/** - The acceptable MIME types for responses. When non-`nil`, responses with a `Content-Type` with MIME types that do not intersect with the set will result in an error during validation. - */ -@property (nonatomic, copy) NSSet *acceptableContentTypes; - -/** - Validates the specified response and data. - - In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks. - - @param response The response to be validated. - @param data The data associated with the response. - @param error The error that occurred while attempting to validate the response. - - @return `YES` if the response is valid, otherwise `NO`. - */ -- (BOOL)validateResponse:(NSHTTPURLResponse *)response - data:(NSData *)data - error:(NSError *__autoreleasing *)error; - -@end - -#pragma mark - - - -/** - `AFJSONResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes JSON responses. - - By default, `AFJSONResponseSerializer` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types: - - - `application/json` - - `text/json` - - `text/javascript` - */ -@interface AFJSONResponseSerializer : AFHTTPResponseSerializer - -/** - Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. - */ -@property (nonatomic, assign) NSJSONReadingOptions readingOptions; - -/** - Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`. - */ -@property (nonatomic, assign) BOOL removesKeysWithNullValues; - -/** - Creates and returns a JSON serializer with specified reading and writing options. - - @param readingOptions The specified JSON reading options. - */ -+ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions; - -@end - -#pragma mark - - -/** - `AFXMLParserSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLParser` objects. - - By default, `AFXMLParserSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: - - - `application/xml` - - `text/xml` - */ -@interface AFXMLParserResponseSerializer : AFHTTPResponseSerializer - -@end - -#pragma mark - - -#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED - -/** - `AFXMLDocumentSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. - - By default, `AFXMLDocumentSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: - - - `application/xml` - - `text/xml` - */ -@interface AFXMLDocumentResponseSerializer : AFHTTPResponseSerializer - -/** - Input and output options specifically intended for `NSXMLDocument` objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. - */ -@property (nonatomic, assign) NSUInteger options; - -/** - Creates and returns an XML document serializer with the specified options. - - @param mask The XML document options. - */ -+ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask; - -@end - -#endif - -#pragma mark - - -/** - `AFPropertyListSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. - - By default, `AFPropertyListSerializer` accepts the following MIME types: - - - `application/x-plist` - */ -@interface AFPropertyListResponseSerializer : AFHTTPResponseSerializer - -/** - The property list format. Possible values are described in "NSPropertyListFormat". - */ -@property (nonatomic, assign) NSPropertyListFormat format; - -/** - The property list reading options. Possible values are described in "NSPropertyListMutabilityOptions." - */ -@property (nonatomic, assign) NSPropertyListReadOptions readOptions; - -/** - Creates and returns a property list serializer with a specified format, read options, and write options. - - @param format The property list format. - @param readOptions The property list reading options. - */ -+ (instancetype)serializerWithFormat:(NSPropertyListFormat)format - readOptions:(NSPropertyListReadOptions)readOptions; - -@end - -#pragma mark - - -/** - `AFImageSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes image responses. - - By default, `AFImageSerializer` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage: - - - `image/tiff` - - `image/jpeg` - - `image/gif` - - `image/png` - - `image/ico` - - `image/x-icon` - - `image/bmp` - - `image/x-bmp` - - `image/x-xbitmap` - - `image/x-win-bitmap` - */ -@interface AFImageResponseSerializer : AFHTTPResponseSerializer - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -/** - The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance. - */ -@property (nonatomic, assign) CGFloat imageScale; - -/** - Whether to automatically inflate response image data for compressed formats (such as PNG or JPEG). Enabling this can significantly improve drawing performance on iOS when used with `setCompletionBlockWithSuccess:failure:`, as it allows a bitmap representation to be constructed in the background rather than on the main thread. `YES` by default. - */ -@property (nonatomic, assign) BOOL automaticallyInflatesResponseImage; -#endif - -@end - -#pragma mark - - -/** - `AFCompoundSerializer` is a subclass of `AFHTTPResponseSerializer` that delegates the response serialization to the first `AFHTTPResponseSerializer` object that returns an object for `responseObjectForResponse:data:error:`, falling back on the default behavior of `AFHTTPResponseSerializer`. This is useful for supporting multiple potential types and structures of server responses with a single serializer. - */ -@interface AFCompoundResponseSerializer : AFHTTPResponseSerializer - -/** - The component response serializers. - */ -@property (readonly, nonatomic, copy) NSArray *responseSerializers; - -/** - Creates and returns a compound serializer comprised of the specified response serializers. - - @warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`. - */ -+ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers; - -@end - -///---------------- -/// @name Constants -///---------------- - -/** - ## Error Domains - - The following error domain is predefined. - - - `NSString * const AFURLResponseSerializationErrorDomain` - - ### Constants - - `AFURLResponseSerializationErrorDomain` - AFURLResponseSerializer errors. Error codes for `AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. - */ -extern NSString * const AFURLResponseSerializationErrorDomain; - -/** - ## User info dictionary keys - - These keys may exist in the user info dictionary, in addition to those defined for NSError. - - - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey` - - ### Constants - - `AFNetworkingOperationFailingURLResponseErrorKey` - The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. - */ -extern NSString * const AFNetworkingOperationFailingURLResponseErrorKey; diff --git a/Ryff/Frameworks/AFNetworking/AFURLResponseSerialization.m b/Ryff/Frameworks/AFNetworking/AFURLResponseSerialization.m deleted file mode 100755 index cc1e00b..0000000 --- a/Ryff/Frameworks/AFNetworking/AFURLResponseSerialization.m +++ /dev/null @@ -1,779 +0,0 @@ -// AFSerialization.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import "AFURLResponseSerialization.h" - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -#import -#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) -#import -#endif - -NSString * const AFURLResponseSerializationErrorDomain = @"com.alamofire.error.serialization.response"; -NSString * const AFNetworkingOperationFailingURLResponseErrorKey = @"com.alamofire.serialization.response.error.response"; - -static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) { - if (!error) { - return underlyingError; - } - - if (!underlyingError || error.userInfo[NSUnderlyingErrorKey]) { - return error; - } - - NSMutableDictionary *mutableUserInfo = [error.userInfo mutableCopy]; - mutableUserInfo[NSUnderlyingErrorKey] = underlyingError; - - return [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:mutableUserInfo]; -} - -static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger code, NSString *domain) { - if ([error.domain isEqualToString:domain] && error.code == code) { - return YES; - } else if (error.userInfo[NSUnderlyingErrorKey]) { - return AFErrorOrUnderlyingErrorHasCodeInDomain(error.userInfo[NSUnderlyingErrorKey], code, domain); - } - - return NO; -} - -static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) { - if ([JSONObject isKindOfClass:[NSArray class]]) { - NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:[(NSArray *)JSONObject count]]; - for (id value in (NSArray *)JSONObject) { - [mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)]; - } - - return (readingOptions & NSJSONReadingMutableContainers) ? mutableArray : [NSArray arrayWithArray:mutableArray]; - } else if ([JSONObject isKindOfClass:[NSDictionary class]]) { - NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:JSONObject]; - for (id key in [(NSDictionary *)JSONObject allKeys]) { - id value = [(NSDictionary *)JSONObject objectForKey:key]; - if (!value || [value isEqual:[NSNull null]]) { - [mutableDictionary removeObjectForKey:key]; - } else if ([value isKindOfClass:[NSArray class]] || [value isKindOfClass:[NSDictionary class]]) { - [mutableDictionary setObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions) forKey:key]; - } - } - - return (readingOptions & NSJSONReadingMutableContainers) ? mutableDictionary : [NSDictionary dictionaryWithDictionary:mutableDictionary]; - } - - return JSONObject; -} - -@implementation AFHTTPResponseSerializer - -+ (instancetype)serializer { - return [[self alloc] init]; -} - -- (instancetype)init { - self = [super init]; - if (!self) { - return nil; - } - - self.stringEncoding = NSUTF8StringEncoding; - - self.acceptableStatusCodes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)]; - self.acceptableContentTypes = nil; - - return self; -} - -#pragma mark - - -- (BOOL)validateResponse:(NSHTTPURLResponse *)response - data:(NSData *)data - error:(NSError * __autoreleasing *)error -{ - BOOL responseIsValid = YES; - NSError *validationError = nil; - - if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) { - if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]]) { - if ([data length] > 0) { - NSDictionary *userInfo = @{ - NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: unacceptable content-type: %@", @"AFNetworking", nil), [response MIMEType]], - NSURLErrorFailingURLErrorKey:[response URL], - AFNetworkingOperationFailingURLResponseErrorKey: response - }; - - validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo], validationError); - } - - responseIsValid = NO; - } - - if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode]) { - NSDictionary *userInfo = @{ - NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode], - NSURLErrorFailingURLErrorKey:[response URL], - AFNetworkingOperationFailingURLResponseErrorKey: response - }; - - validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:userInfo], validationError); - - responseIsValid = NO; - } - } - - if (error && !responseIsValid) { - *error = validationError; - } - - return responseIsValid; -} - -#pragma mark - AFURLResponseSerialization - -- (id)responseObjectForResponse:(NSURLResponse *)response - data:(NSData *)data - error:(NSError *__autoreleasing *)error -{ - [self validateResponse:(NSHTTPURLResponse *)response data:data error:error]; - - return data; -} - -#pragma mark - NSecureCoding - -+ (BOOL)supportsSecureCoding { - return YES; -} - -- (id)initWithCoder:(NSCoder *)decoder { - self = [self init]; - if (!self) { - return nil; - } - - self.acceptableStatusCodes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; - self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [coder encodeObject:self.acceptableStatusCodes forKey:NSStringFromSelector(@selector(acceptableStatusCodes))]; - [coder encodeObject:self.acceptableContentTypes forKey:NSStringFromSelector(@selector(acceptableContentTypes))]; -} - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone { - AFHTTPResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; - serializer.acceptableStatusCodes = [self.acceptableStatusCodes copyWithZone:zone]; - serializer.acceptableContentTypes = [self.acceptableContentTypes copyWithZone:zone]; - - return serializer; -} - -@end - -#pragma mark - - -@implementation AFJSONResponseSerializer - -+ (instancetype)serializer { - return [self serializerWithReadingOptions:0]; -} - -+ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions { - AFJSONResponseSerializer *serializer = [[self alloc] init]; - serializer.readingOptions = readingOptions; - - return serializer; -} - -- (instancetype)init { - self = [super init]; - if (!self) { - return nil; - } - - self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil]; - - return self; -} - -#pragma mark - AFURLResponseSerialization - -- (id)responseObjectForResponse:(NSURLResponse *)response - data:(NSData *)data - error:(NSError *__autoreleasing *)error -{ - if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { - if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { - return nil; - } - } - - // Workaround for behavior of Rails to return a single space for `head :ok` (a workaround for a bug in Safari), which is not interpreted as valid input by NSJSONSerialization. - // See https://github.com/rails/rails/issues/1742 - NSStringEncoding stringEncoding = self.stringEncoding; - if (response.textEncodingName) { - CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); - if (encoding != kCFStringEncodingInvalidId) { - stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); - } - } - - id responseObject = nil; - NSError *serializationError = nil; - @autoreleasepool { - NSString *responseString = [[NSString alloc] initWithData:data encoding:stringEncoding]; - if (responseString && ![responseString isEqualToString:@" "]) { - // Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character - // See http://stackoverflow.com/a/12843465/157142 - data = [responseString dataUsingEncoding:NSUTF8StringEncoding]; - - if (data) { - if ([data length] > 0) { - responseObject = [NSJSONSerialization JSONObjectWithData:data options:self.readingOptions error:&serializationError]; - } else { - return nil; - } - } else { - NSDictionary *userInfo = @{ - NSLocalizedDescriptionKey: NSLocalizedStringFromTable(@"Data failed decoding as a UTF-8 string", nil, @"AFNetworking"), - NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Could not decode string: %@", nil, @"AFNetworking"), responseString] - }; - - serializationError = [NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo]; - } - } - } - - if (self.removesKeysWithNullValues && responseObject) { - responseObject = AFJSONObjectByRemovingKeysWithNullValues(responseObject, self.readingOptions); - } - - if (error) { - *error = AFErrorWithUnderlyingError(serializationError, *error);; - } - - return responseObject; -} - -#pragma mark - NSecureCoding - -- (id)initWithCoder:(NSCoder *)decoder { - self = [super initWithCoder:decoder]; - if (!self) { - return nil; - } - - self.readingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readingOptions))] unsignedIntegerValue]; - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [super encodeWithCoder:coder]; - - [coder encodeObject:@(self.readingOptions) forKey:NSStringFromSelector(@selector(readingOptions))]; -} - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone { - AFJSONResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; - serializer.readingOptions = self.readingOptions; - - return serializer; -} - -@end - -#pragma mark - - -@implementation AFXMLParserResponseSerializer - -+ (instancetype)serializer { - AFXMLParserResponseSerializer *serializer = [[self alloc] init]; - - return serializer; -} - -- (instancetype)init { - self = [super init]; - if (!self) { - return nil; - } - - self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil]; - - return self; -} - -#pragma mark - AFURLResponseSerialization - -- (id)responseObjectForResponse:(NSHTTPURLResponse *)response - data:(NSData *)data - error:(NSError *__autoreleasing *)error -{ - if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { - if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { - return nil; - } - } - - return [[NSXMLParser alloc] initWithData:data]; -} - -@end - -#pragma mark - - -#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED - -@implementation AFXMLDocumentResponseSerializer - -+ (instancetype)serializer { - return [self serializerWithXMLDocumentOptions:0]; -} - -+ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask { - AFXMLDocumentResponseSerializer *serializer = [[self alloc] init]; - serializer.options = mask; - - return serializer; -} - -- (instancetype)init { - self = [super init]; - if (!self) { - return nil; - } - - self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil]; - - return self; -} - -#pragma mark - AFURLResponseSerialization - -- (id)responseObjectForResponse:(NSURLResponse *)response - data:(NSData *)data - error:(NSError *__autoreleasing *)error -{ - if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { - if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { - return nil; - } - } - - NSError *serializationError = nil; - NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:data options:self.options error:&serializationError]; - - if (error) { - *error = AFErrorWithUnderlyingError(serializationError, *error); - } - - return document; -} - -#pragma mark - NSecureCoding - -- (id)initWithCoder:(NSCoder *)decoder { - self = [super initWithCoder:decoder]; - if (!self) { - return nil; - } - - self.options = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(options))] unsignedIntegerValue]; - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [super encodeWithCoder:coder]; - - [coder encodeObject:@(self.options) forKey:NSStringFromSelector(@selector(options))]; -} - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone { - AFXMLDocumentResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; - serializer.options = self.options; - - return serializer; -} - -@end - -#endif - -#pragma mark - - -@implementation AFPropertyListResponseSerializer - -+ (instancetype)serializer { - return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 readOptions:0]; -} - -+ (instancetype)serializerWithFormat:(NSPropertyListFormat)format - readOptions:(NSPropertyListReadOptions)readOptions -{ - AFPropertyListResponseSerializer *serializer = [[self alloc] init]; - serializer.format = format; - serializer.readOptions = readOptions; - - return serializer; -} - -- (instancetype)init { - self = [super init]; - if (!self) { - return nil; - } - - self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/x-plist", nil]; - - return self; -} - -#pragma mark - AFURLResponseSerialization - -- (id)responseObjectForResponse:(NSURLResponse *)response - data:(NSData *)data - error:(NSError *__autoreleasing *)error -{ - if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { - if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { - return nil; - } - } - - id responseObject; - NSError *serializationError = nil; - - if (data) { - responseObject = [NSPropertyListSerialization propertyListWithData:data options:self.readOptions format:NULL error:&serializationError]; - } - - if (error) { - *error = AFErrorWithUnderlyingError(serializationError, *error); - } - - return responseObject; -} - -#pragma mark - NSecureCoding - -- (id)initWithCoder:(NSCoder *)decoder { - self = [super initWithCoder:decoder]; - if (!self) { - return nil; - } - - self.format = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue]; - self.readOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readOptions))] unsignedIntegerValue]; - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [super encodeWithCoder:coder]; - - [coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))]; - [coder encodeObject:@(self.readOptions) forKey:NSStringFromSelector(@selector(readOptions))]; -} - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone { - AFPropertyListResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; - serializer.format = self.format; - serializer.readOptions = self.readOptions; - - return serializer; -} - -@end - -#pragma mark - - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -#import - -static UIImage * AFImageWithDataAtScale(NSData *data, CGFloat scale) { - UIImage *image = [[UIImage alloc] initWithData:data]; - - return [[UIImage alloc] initWithCGImage:[image CGImage] scale:scale orientation:image.imageOrientation]; -} - -static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *response, NSData *data, CGFloat scale) { - if (!data || [data length] == 0) { - return nil; - } - - CGImageRef imageRef = NULL; - CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data); - - if ([response.MIMEType isEqualToString:@"image/png"]) { - imageRef = CGImageCreateWithPNGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); - } else if ([response.MIMEType isEqualToString:@"image/jpeg"]) { - imageRef = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault); - - // CGImageCreateWithJPEGDataProvider does not properly handle CMKY, so if so, fall back to AFImageWithDataAtScale - if (imageRef) { - CGColorSpaceRef imageColorSpace = CGImageGetColorSpace(imageRef); - CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(imageColorSpace); - if (imageColorSpaceModel == kCGColorSpaceModelCMYK) { - CGImageRelease(imageRef); - imageRef = NULL; - } - } - } - - CGDataProviderRelease(dataProvider); - - UIImage *image = AFImageWithDataAtScale(data, scale); - if (!imageRef) { - if (image.images || !image) { - return image; - } - - imageRef = CGImageCreateCopy([image CGImage]); - if (!imageRef) { - return nil; - } - } - - size_t width = CGImageGetWidth(imageRef); - size_t height = CGImageGetHeight(imageRef); - size_t bitsPerComponent = CGImageGetBitsPerComponent(imageRef); - - if (width * height > 1024 * 1024 || bitsPerComponent > 8) { - CGImageRelease(imageRef); - - return image; - } - - size_t bytesPerRow = 0; // CGImageGetBytesPerRow() calculates incorrectly in iOS 5.0, so defer to CGBitmapContextCreate - CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace); - CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); - - if (colorSpaceModel == kCGColorSpaceModelRGB) { - uint32_t alpha = (bitmapInfo & kCGBitmapAlphaInfoMask); - if (alpha == kCGImageAlphaNone) { - bitmapInfo &= ~kCGBitmapAlphaInfoMask; - bitmapInfo |= kCGImageAlphaNoneSkipFirst; - } else if (!(alpha == kCGImageAlphaNoneSkipFirst || alpha == kCGImageAlphaNoneSkipLast)) { - bitmapInfo &= ~kCGBitmapAlphaInfoMask; - bitmapInfo |= kCGImageAlphaPremultipliedFirst; - } - } - - CGContextRef context = CGBitmapContextCreate(NULL, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo); - - CGColorSpaceRelease(colorSpace); - - if (!context) { - CGImageRelease(imageRef); - - return image; - } - - CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, width, height), imageRef); - CGImageRef inflatedImageRef = CGBitmapContextCreateImage(context); - - CGContextRelease(context); - - UIImage *inflatedImage = [[UIImage alloc] initWithCGImage:inflatedImageRef scale:scale orientation:image.imageOrientation]; - - CGImageRelease(inflatedImageRef); - CGImageRelease(imageRef); - - return inflatedImage; -} -#endif - - -@implementation AFImageResponseSerializer - -- (instancetype)init { - self = [super init]; - if (!self) { - return nil; - } - - self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"image/tiff", @"image/jpeg", @"image/gif", @"image/png", @"image/ico", @"image/x-icon", @"image/bmp", @"image/x-bmp", @"image/x-xbitmap", @"image/x-win-bitmap", nil]; - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - self.imageScale = [[UIScreen mainScreen] scale]; - self.automaticallyInflatesResponseImage = YES; -#endif - - return self; -} - -#pragma mark - AFURLResponseSerializer - -- (id)responseObjectForResponse:(NSURLResponse *)response - data:(NSData *)data - error:(NSError *__autoreleasing *)error -{ - if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) { - if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) { - return nil; - } - } - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - if (self.automaticallyInflatesResponseImage) { - return AFInflatedImageFromResponseWithDataAtScale((NSHTTPURLResponse *)response, data, self.imageScale); - } else { - return AFImageWithDataAtScale(data, self.imageScale); - } -#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) - // Ensure that the image is set to it's correct pixel width and height - NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:data]; - NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])]; - [image addRepresentation:bitimage]; - - return image; -#endif - - return nil; -} - -#pragma mark - NSecureCoding - -- (id)initWithCoder:(NSCoder *)decoder { - self = [super initWithCoder:decoder]; - if (!self) { - return nil; - } - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - NSNumber *imageScale = [decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(imageScale))]; -#if CGFLOAT_IS_DOUBLE - self.imageScale = [imageScale doubleValue]; -#else - self.imageScale = [imageScale floatValue]; -#endif - - self.automaticallyInflatesResponseImage = [decoder decodeBoolForKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))]; -#endif - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [super encodeWithCoder:coder]; - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - [coder encodeObject:@(self.imageScale) forKey:NSStringFromSelector(@selector(imageScale))]; - [coder encodeBool:self.automaticallyInflatesResponseImage forKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))]; -#endif -} - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone { - AFImageResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - serializer.imageScale = self.imageScale; - serializer.automaticallyInflatesResponseImage = self.automaticallyInflatesResponseImage; -#endif - - return serializer; -} - -@end - -#pragma mark - - -@interface AFCompoundResponseSerializer () -@property (readwrite, nonatomic, copy) NSArray *responseSerializers; -@end - -@implementation AFCompoundResponseSerializer - -+ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers { - AFCompoundResponseSerializer *serializer = [[self alloc] init]; - serializer.responseSerializers = responseSerializers; - - return serializer; -} - -#pragma mark - AFURLResponseSerialization - -- (id)responseObjectForResponse:(NSURLResponse *)response - data:(NSData *)data - error:(NSError *__autoreleasing *)error -{ - for (id serializer in self.responseSerializers) { - if (![serializer isKindOfClass:[AFHTTPResponseSerializer class]]) { - continue; - } - - NSError *serializerError = nil; - id responseObject = [serializer responseObjectForResponse:response data:data error:&serializerError]; - if (responseObject) { - if (error) { - *error = AFErrorWithUnderlyingError(serializerError, *error); - } - - return responseObject; - } - } - - return [super responseObjectForResponse:response data:data error:error]; -} - -#pragma mark - NSecureCoding - -- (id)initWithCoder:(NSCoder *)decoder { - self = [super initWithCoder:decoder]; - if (!self) { - return nil; - } - - self.responseSerializers = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(responseSerializers))]; - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [super encodeWithCoder:coder]; - - [coder encodeObject:self.responseSerializers forKey:NSStringFromSelector(@selector(responseSerializers))]; -} - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone { - AFCompoundResponseSerializer *serializer = [[[self class] allocWithZone:zone] init]; - serializer.responseSerializers = self.responseSerializers; - - return serializer; -} - -@end diff --git a/Ryff/Frameworks/AFNetworking/AFURLSessionManager.h b/Ryff/Frameworks/AFNetworking/AFURLSessionManager.h deleted file mode 100755 index 6432027..0000000 --- a/Ryff/Frameworks/AFNetworking/AFURLSessionManager.h +++ /dev/null @@ -1,529 +0,0 @@ -// AFURLSessionManager.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import - -#import "AFURLResponseSerialization.h" -#import "AFURLRequestSerialization.h" -#import "AFSecurityPolicy.h" -#import "AFNetworkReachabilityManager.h" - -/** - `AFURLSessionManager` creates and manages an `NSURLSession` object based on a specified `NSURLSessionConfiguration` object, which conforms to ``, ``, ``, and ``. - - ## Subclassing Notes - - This is the base class for `AFHTTPSessionManager`, which adds functionality specific to making HTTP requests. If you are looking to extend `AFURLSessionManager` specifically for HTTP, consider subclassing `AFHTTPSessionManager` instead. - - ## NSURLSession & NSURLSessionTask Delegate Methods - - `AFURLSessionManager` implements the following delegate methods: - - ### `NSURLSessionDelegate` - - - `URLSession:didBecomeInvalidWithError:` - - `URLSession:didReceiveChallenge:completionHandler:` - - ### `NSURLSessionTaskDelegate` - - - `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:` - - `URLSession:task:didReceiveChallenge:completionHandler:` - - `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:` - - `URLSession:task:didCompleteWithError:` - - ### `NSURLSessionDataDelegate` - - - `URLSession:dataTask:didReceiveResponse:completionHandler:` - - `URLSession:dataTask:didBecomeDownloadTask:` - - `URLSession:dataTask:didReceiveData:` - - `URLSession:dataTask:willCacheResponse:completionHandler:` - - `URLSessionDidFinishEventsForBackgroundURLSession:` - - ### `NSURLSessionDownloadDelegate` - - - `URLSession:downloadTask:didFinishDownloadingToURL:` - - `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:` - - `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:` - - If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. - - ## Network Reachability Monitoring - - Network reachability status and change monitoring is available through the `reachabilityManager` property. Applications may choose to monitor network reachability conditions in order to prevent or suspend any outbound requests. See `AFNetworkReachabilityManager` for more details. - - ## NSCoding Caveats - - - Encoded managers do not include any block properties. Be sure to set delegate callback blocks when using `-initWithCoder:` or `NSKeyedUnarchiver`. - - ## NSCopying Caveats - - - `-copy` and `-copyWithZone:` return a new manager with a new `NSURLSession` created from the configuration of the original. - - Operation copies do not include any delegate callback blocks, as they often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ session manager when copied. - */ - -#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) - -@interface AFURLSessionManager : NSObject - -/** - The managed session. - */ -@property (readonly, nonatomic, strong) NSURLSession *session; - -/** - The operation queue on which delegate callbacks are run. - */ -@property (readonly, nonatomic, strong) NSOperationQueue *operationQueue; - -/** - Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an instance of `AFJSONResponseSerializer`. - - @warning `responseSerializer` must not be `nil`. - */ -@property (nonatomic, strong) id responseSerializer; - -///------------------------------- -/// @name Managing Security Policy -///------------------------------- - -/** - The security policy used by created request operations to evaluate server trust for secure connections. `AFURLSessionManager` uses the `defaultPolicy` unless otherwise specified. - */ -@property (nonatomic, strong) AFSecurityPolicy *securityPolicy; - -///-------------------------------------- -/// @name Monitoring Network Reachability -///-------------------------------------- - -/** - The network reachability manager. `AFURLSessionManager` uses the `sharedManager` by default. - */ -@property (readwrite, nonatomic, strong) AFNetworkReachabilityManager *reachabilityManager; - -///---------------------------- -/// @name Getting Session Tasks -///---------------------------- - -/** - The data, upload, and download tasks currently run by the managed session. - */ -@property (readonly, nonatomic, strong) NSArray *tasks; - -/** - The data tasks currently run by the managed session. - */ -@property (readonly, nonatomic, strong) NSArray *dataTasks; - -/** - The upload tasks currently run by the managed session. - */ -@property (readonly, nonatomic, strong) NSArray *uploadTasks; - -/** - The download tasks currently run by the managed session. - */ -@property (readonly, nonatomic, strong) NSArray *downloadTasks; - -///------------------------------- -/// @name Managing Callback Queues -///------------------------------- - -/** - The dispatch queue for `completionBlock`. If `NULL` (default), the main queue is used. - */ -@property (nonatomic, strong) dispatch_queue_t completionQueue; - -/** - The dispatch group for `completionBlock`. If `NULL` (default), a private dispatch group is used. - */ -@property (nonatomic, strong) dispatch_group_t completionGroup; - -///--------------------------------- -/// @name Working Around System Bugs -///--------------------------------- - -/** - Whether to attempt to retry creation of upload tasks for background sessions when initial call returns `nil`. `NO` by default. - - @bug As of iOS 7.0, there is a bug where upload tasks created for background tasks are sometimes `nil`. As a workaround, if this property is `YES`, AFNetworking will follow Apple's recommendation to try creating the task again. - - @see https://github.com/AFNetworking/AFNetworking/issues/1675 - */ -@property (nonatomic, assign) BOOL attemptsToRecreateUploadTasksForBackgroundSessions; - -///--------------------- -/// @name Initialization -///--------------------- - -/** - Creates and returns a manager for a session created with the specified configuration. This is the designated initializer. - - @param configuration The configuration used to create the managed session. - - @return A manager for a newly-created session. - */ -- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration; - -/** - Invalidates the managed session, optionally canceling pending tasks. - - @param cancelPendingTasks Whether or not to cancel pending tasks. - */ -- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks; - -///------------------------- -/// @name Running Data Tasks -///------------------------- - -/** - Creates an `NSURLSessionDataTask` with the specified request. - - @param request The HTTP request for the request. - @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. - */ -- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request - completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler; - -///--------------------------- -/// @name Running Upload Tasks -///--------------------------- - -/** - Creates an `NSURLSessionUploadTask` with the specified request for a local file. - - @param request The HTTP request for the request. - @param fileURL A URL to the local file to be uploaded. - @param progress A progress object monitoring the current upload progress. - @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. - - @see `attemptsToRecreateUploadTasksForBackgroundSessions` - */ -- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request - fromFile:(NSURL *)fileURL - progress:(NSProgress * __autoreleasing *)progress - completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler; - -/** - Creates an `NSURLSessionUploadTask` with the specified request for an HTTP body. - - @param request The HTTP request for the request. - @param bodyData A data object containing the HTTP body to be uploaded. - @param progress A progress object monitoring the current upload progress. - @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. - */ -- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request - fromData:(NSData *)bodyData - progress:(NSProgress * __autoreleasing *)progress - completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler; - -/** - Creates an `NSURLSessionUploadTask` with the specified streaming request. - - @param request The HTTP request for the request. - @param progress A progress object monitoring the current upload progress. - @param completionHandler A block object to be executed when the task finishes. This block has no return value and takes three arguments: the server response, the response object created by that serializer, and the error that occurred, if any. - */ -- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request - progress:(NSProgress * __autoreleasing *)progress - completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler; - -///----------------------------- -/// @name Running Download Tasks -///----------------------------- - -/** - Creates an `NSURLSessionDownloadTask` with the specified request. - - @param request The HTTP request for the request. - @param progress A progress object monitoring the current download progress. - @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL. - @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any. - - @warning If using a background `NSURLSessionConfiguration` on iOS, these blocks will be lost when the app is terminated. Background sessions may prefer to use `-setDownloadTaskDidFinishDownloadingBlock:` to specify the URL for saving the downloaded file, rather than the destination block of this method. - */ -- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request - progress:(NSProgress * __autoreleasing *)progress - destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination - completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler; - -/** - Creates an `NSURLSessionDownloadTask` with the specified resume data. - - @param resumeData The data used to resume downloading. - @param progress A progress object monitoring the current download progress. - @param destination A block object to be executed in order to determine the destination of the downloaded file. This block takes two arguments, the target path & the server response, and returns the desired file URL of the resulting download. The temporary file used during the download will be automatically deleted after being moved to the returned URL. - @param completionHandler A block to be executed when a task finishes. This block has no return value and takes three arguments: the server response, the path of the downloaded file, and the error describing the network or parsing error that occurred, if any. - */ -- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData - progress:(NSProgress * __autoreleasing *)progress - destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination - completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler; - -///--------------------------------- -/// @name Getting Progress for Tasks -///--------------------------------- - -/** - Returns the upload progress of the specified task. - - @param uploadTask The session upload task. Must not be `nil`. - - @return An `NSProgress` object reporting the upload progress of a task, or `nil` if the progress is unavailable. - */ -- (NSProgress *)uploadProgressForTask:(NSURLSessionUploadTask *)uploadTask; - -/** - Returns the download progress of the specified task. - - @param downloadTask The session download task. Must not be `nil`. - - @return An `NSProgress` object reporting the download progress of a task, or `nil` if the progress is unavailable. - */ -- (NSProgress *)downloadProgressForTask:(NSURLSessionDownloadTask *)downloadTask; - -///----------------------------------------- -/// @name Setting Session Delegate Callbacks -///----------------------------------------- - -/** - Sets a block to be executed when the managed session becomes invalid, as handled by the `NSURLSessionDelegate` method `URLSession:didBecomeInvalidWithError:`. - - @param block A block object to be executed when the managed session becomes invalid. The block has no return value, and takes two arguments: the session, and the error related to the cause of invalidation. - */ -- (void)setSessionDidBecomeInvalidBlock:(void (^)(NSURLSession *session, NSError *error))block; - -/** - Sets a block to be executed when a connection level authentication challenge has occurred, as handled by the `NSURLSessionDelegate` method `URLSession:didReceiveChallenge:completionHandler:`. - - @param block A block object to be executed when a connection level authentication challenge has occurred. The block returns the disposition of the authentication challenge, and takes three arguments: the session, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge. - */ -- (void)setSessionDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block; - -///-------------------------------------- -/// @name Setting Task Delegate Callbacks -///-------------------------------------- - -/** - Sets a block to be executed when a task requires a new request body stream to send to the remote server, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:needNewBodyStream:`. - - @param block A block object to be executed when a task requires a new request body stream. - */ -- (void)setTaskNeedNewBodyStreamBlock:(NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block; - -/** - Sets a block to be executed when an HTTP request is attempting to perform a redirection to a different URL, as handled by the `NSURLSessionTaskDelegate` method `URLSession:willPerformHTTPRedirection:newRequest:completionHandler:`. - - @param block A block object to be executed when an HTTP request is attempting to perform a redirection to a different URL. The block returns the request to be made for the redirection, and takes four arguments: the session, the task, the redirection response, and the request corresponding to the redirection response. - */ -- (void)setTaskWillPerformHTTPRedirectionBlock:(NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block; - -/** - Sets a block to be executed when a session task has received a request specific authentication challenge, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didReceiveChallenge:completionHandler:`. - - @param block A block object to be executed when a session task has received a request specific authentication challenge. The block returns the disposition of the authentication challenge, and takes four arguments: the session, the task, the authentication challenge, and a pointer to the credential that should be used to resolve the challenge. - */ -- (void)setTaskDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block; - -/** - Sets a block to be executed periodically to track upload progress, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:`. - - @param block A block object to be called when an undetermined number of bytes have been uploaded to the server. This block has no return value and takes five arguments: the session, the task, the number of bytes written since the last time the upload progress block was called, the total bytes written, and the total bytes expected to be written during the request, as initially determined by the length of the HTTP body. This block may be called multiple times, and will execute on the main thread. - */ -- (void)setTaskDidSendBodyDataBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block; - -/** - Sets a block to be executed as the last message related to a specific task, as handled by the `NSURLSessionTaskDelegate` method `URLSession:task:didCompleteWithError:`. - - @param block A block object to be executed when a session task is completed. The block has no return value, and takes three arguments: the session, the task, and any error that occurred in the process of executing the task. - */ -- (void)setTaskDidCompleteBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, NSError *error))block; - -///------------------------------------------- -/// @name Setting Data Task Delegate Callbacks -///------------------------------------------- - -/** - Sets a block to be executed when a data task has received a response, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveResponse:completionHandler:`. - - @param block A block object to be executed when a data task has received a response. The block returns the disposition of the session response, and takes three arguments: the session, the data task, and the received response. - */ -- (void)setDataTaskDidReceiveResponseBlock:(NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block; - -/** - Sets a block to be executed when a data task has become a download task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didBecomeDownloadTask:`. - - @param block A block object to be executed when a data task has become a download task. The block has no return value, and takes three arguments: the session, the data task, and the download task it has become. - */ -- (void)setDataTaskDidBecomeDownloadTaskBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block; - -/** - Sets a block to be executed when a data task receives data, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:didReceiveData:`. - - @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the session, the data task, and the data received. This block may be called multiple times, and will execute on the session manager operation queue. - */ -- (void)setDataTaskDidReceiveDataBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block; - -/** - Sets a block to be executed to determine the caching behavior of a data task, as handled by the `NSURLSessionDataDelegate` method `URLSession:dataTask:willCacheResponse:completionHandler:`. - - @param block A block object to be executed to determine the caching behavior of a data task. The block returns the response to cache, and takes three arguments: the session, the data task, and the proposed cached URL response. - */ -- (void)setDataTaskWillCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block; - -/** - Sets a block to be executed once all messages enqueued for a session have been delivered, as handled by the `NSURLSessionDataDelegate` method `URLSessionDidFinishEventsForBackgroundURLSession:`. - - @param block A block object to be executed once all messages enqueued for a session have been delivered. The block has no return value and takes a single argument: the session. - */ -- (void)setDidFinishEventsForBackgroundURLSessionBlock:(void (^)(NSURLSession *session))block; - -///----------------------------------------------- -/// @name Setting Download Task Delegate Callbacks -///----------------------------------------------- - -/** - Sets a block to be executed when a download task has completed a download, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didFinishDownloadingToURL:`. - - @param block A block object to be executed when a download task has completed. The block returns the URL the download should be moved to, and takes three arguments: the session, the download task, and the temporary location of the downloaded file. If the file manager encounters an error while attempting to move the temporary file to the destination, an `AFURLSessionDownloadTaskDidFailToMoveFileNotification` will be posted, with the download task as its object, and the user info of the error. - */ -- (void)setDownloadTaskDidFinishDownloadingBlock:(NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block; - -/** - Sets a block to be executed periodically to track download progress, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didWriteData:totalBytesWritten:totalBytesWritten:totalBytesExpectedToWrite:`. - - @param block A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes five arguments: the session, the download task, the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the session manager operation queue. - */ -- (void)setDownloadTaskDidWriteDataBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block; - -/** - Sets a block to be executed when a download task has been resumed, as handled by the `NSURLSessionDownloadDelegate` method `URLSession:downloadTask:didResumeAtOffset:expectedTotalBytes:`. - - @param block A block object to be executed when a download task has been resumed. The block has no return value and takes four arguments: the session, the download task, the file offset of the resumed download, and the total number of bytes expected to be downloaded. - */ -- (void)setDownloadTaskDidResumeBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block; - -@end - -#endif - -///-------------------- -/// @name Notifications -///-------------------- - -/** - Posted when a task begins executing. - - @deprecated Use `AFNetworkingTaskDidResumeNotification` instead. - */ -extern NSString * const AFNetworkingTaskDidStartNotification DEPRECATED_ATTRIBUTE; - -/** - Posted when a task resumes. - */ -extern NSString * const AFNetworkingTaskDidResumeNotification; - -/** - Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task. - - @deprecated Use `AFNetworkingTaskDidCompleteNotification` instead. - */ -extern NSString * const AFNetworkingTaskDidFinishNotification DEPRECATED_ATTRIBUTE; - -/** - Posted when a task finishes executing. Includes a userInfo dictionary with additional information about the task. - */ -extern NSString * const AFNetworkingTaskDidCompleteNotification; - -/** - Posted when a task suspends its execution. - */ -extern NSString * const AFNetworkingTaskDidSuspendNotification; - -/** - Posted when a session is invalidated. - */ -extern NSString * const AFURLSessionDidInvalidateNotification; - -/** - Posted when a session download task encountered an error when moving the temporary download file to a specified destination. - */ -extern NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification; - -/** - The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if response data exists for the task. - - @deprecated Use `AFNetworkingTaskDidCompleteResponseDataKey` instead. - */ -extern NSString * const AFNetworkingTaskDidFinishResponseDataKey DEPRECATED_ATTRIBUTE; - -/** - The raw response data of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if response data exists for the task. - */ -extern NSString * const AFNetworkingTaskDidCompleteResponseDataKey; - -/** - The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the response was serialized. - - @deprecated Use `AFNetworkingTaskDidCompleteSerializedResponseKey` instead. - */ -extern NSString * const AFNetworkingTaskDidFinishSerializedResponseKey DEPRECATED_ATTRIBUTE; - -/** - The serialized response object of the task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the response was serialized. - */ -extern NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey; - -/** - The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the task has an associated response serializer. - - @deprecated Use `AFNetworkingTaskDidCompleteResponseSerializerKey` instead. - */ -extern NSString * const AFNetworkingTaskDidFinishResponseSerializerKey DEPRECATED_ATTRIBUTE; - -/** - The response serializer used to serialize the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if the task has an associated response serializer. - */ -extern NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey; - -/** - The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an the response data has been stored directly to disk. - - @deprecated Use `AFNetworkingTaskDidCompleteAssetPathKey` instead. - */ -extern NSString * const AFNetworkingTaskDidFinishAssetPathKey DEPRECATED_ATTRIBUTE; - -/** - The file path associated with the download task. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an the response data has been stored directly to disk. - */ -extern NSString * const AFNetworkingTaskDidCompleteAssetPathKey; - -/** - Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an error exists. - - @deprecated Use `AFNetworkingTaskDidCompleteErrorKey` instead. - */ -extern NSString * const AFNetworkingTaskDidFinishErrorKey DEPRECATED_ATTRIBUTE; - -/** - Any error associated with the task, or the serialization of the response. Included in the userInfo dictionary of the `AFNetworkingTaskDidFinishNotification` if an error exists. - */ -extern NSString * const AFNetworkingTaskDidCompleteErrorKey; diff --git a/Ryff/Frameworks/AFNetworking/AFURLSessionManager.m b/Ryff/Frameworks/AFNetworking/AFURLSessionManager.m deleted file mode 100755 index 194cdfa..0000000 --- a/Ryff/Frameworks/AFNetworking/AFURLSessionManager.m +++ /dev/null @@ -1,1005 +0,0 @@ -// AFURLSessionManager.m -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import "AFURLSessionManager.h" - -#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) - -static dispatch_queue_t url_session_manager_processing_queue() { - static dispatch_queue_t af_url_session_manager_processing_queue; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - af_url_session_manager_processing_queue = dispatch_queue_create("com.alamofire.networking.session.manager.processing", DISPATCH_QUEUE_CONCURRENT); - }); - - return af_url_session_manager_processing_queue; -} - -static dispatch_group_t url_session_manager_completion_group() { - static dispatch_group_t af_url_session_manager_completion_group; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - af_url_session_manager_completion_group = dispatch_group_create(); - }); - - return af_url_session_manager_completion_group; -} - -NSString * const AFNetworkingTaskDidResumeNotification = @"com.alamofire.networking.task.resume"; -NSString * const AFNetworkingTaskDidCompleteNotification = @"com.alamofire.networking.task.complete"; -NSString * const AFNetworkingTaskDidSuspendNotification = @"com.alamofire.networking.task.suspend"; -NSString * const AFURLSessionDidInvalidateNotification = @"com.alamofire.networking.session.invalidate"; -NSString * const AFURLSessionDownloadTaskDidFailToMoveFileNotification = @"com.alamofire.networking.session.download.file-manager-error"; - -NSString * const AFNetworkingTaskDidStartNotification = @"com.alamofire.networking.task.resume"; // Deprecated -NSString * const AFNetworkingTaskDidFinishNotification = @"com.alamofire.networking.task.complete"; // Deprecated - -NSString * const AFNetworkingTaskDidCompleteSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse"; -NSString * const AFNetworkingTaskDidCompleteResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer"; -NSString * const AFNetworkingTaskDidCompleteResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata"; -NSString * const AFNetworkingTaskDidCompleteErrorKey = @"com.alamofire.networking.task.complete.error"; -NSString * const AFNetworkingTaskDidCompleteAssetPathKey = @"com.alamofire.networking.task.complete.assetpath"; - -NSString * const AFNetworkingTaskDidFinishSerializedResponseKey = @"com.alamofire.networking.task.complete.serializedresponse"; // Deprecated -NSString * const AFNetworkingTaskDidFinishResponseSerializerKey = @"com.alamofire.networking.task.complete.responseserializer"; // Deprecated -NSString * const AFNetworkingTaskDidFinishResponseDataKey = @"com.alamofire.networking.complete.finish.responsedata"; // Deprecated -NSString * const AFNetworkingTaskDidFinishErrorKey = @"com.alamofire.networking.task.complete.error"; // Deprecated -NSString * const AFNetworkingTaskDidFinishAssetPathKey = @"com.alamofire.networking.task.complete.assetpath"; // Deprecated - -static NSString * const AFURLSessionManagerLockName = @"com.alamofire.networking.session.manager.lock"; - -static NSUInteger const AFMaximumNumberOfToRecreateBackgroundSessionUploadTask = 3; - -static void * AFTaskStateChangedContext = &AFTaskStateChangedContext; - -typedef void (^AFURLSessionDidBecomeInvalidBlock)(NSURLSession *session, NSError *error); -typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential); - -typedef NSURLRequest * (^AFURLSessionTaskWillPerformHTTPRedirectionBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request); -typedef NSURLSessionAuthChallengeDisposition (^AFURLSessionTaskDidReceiveAuthenticationChallengeBlock)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential); - -typedef NSInputStream * (^AFURLSessionTaskNeedNewBodyStreamBlock)(NSURLSession *session, NSURLSessionTask *task); -typedef void (^AFURLSessionTaskDidSendBodyDataBlock)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend); -typedef void (^AFURLSessionTaskDidCompleteBlock)(NSURLSession *session, NSURLSessionTask *task, NSError *error); - -typedef NSURLSessionResponseDisposition (^AFURLSessionDataTaskDidReceiveResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response); -typedef void (^AFURLSessionDataTaskDidBecomeDownloadTaskBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask); -typedef void (^AFURLSessionDataTaskDidReceiveDataBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data); -typedef NSCachedURLResponse * (^AFURLSessionDataTaskWillCacheResponseBlock)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse); -typedef void (^AFURLSessionDidFinishEventsForBackgroundURLSessionBlock)(NSURLSession *session); - -typedef NSURL * (^AFURLSessionDownloadTaskDidFinishDownloadingBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location); -typedef void (^AFURLSessionDownloadTaskDidWriteDataBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite); -typedef void (^AFURLSessionDownloadTaskDidResumeBlock)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes); - -typedef void (^AFURLSessionTaskCompletionHandler)(NSURLResponse *response, id responseObject, NSError *error); - -#pragma mark - - -@interface AFURLSessionManagerTaskDelegate : NSObject -@property (nonatomic, weak) AFURLSessionManager *manager; -@property (nonatomic, strong) NSMutableData *mutableData; -@property (nonatomic, strong) NSProgress *progress; -@property (nonatomic, copy) NSURL *downloadFileURL; -@property (nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading; -@property (nonatomic, copy) AFURLSessionTaskCompletionHandler completionHandler; -@end - -@implementation AFURLSessionManagerTaskDelegate - -- (instancetype)init { - self = [super init]; - if (!self) { - return nil; - } - - self.mutableData = [NSMutableData data]; - - self.progress = [NSProgress progressWithTotalUnitCount:0]; - - return self; -} - -#pragma mark - NSURLSessionTaskDelegate - -- (void)URLSession:(__unused NSURLSession *)session - task:(__unused NSURLSessionTask *)task - didSendBodyData:(__unused int64_t)bytesSent - totalBytesSent:(int64_t)totalBytesSent -totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend -{ - self.progress.totalUnitCount = totalBytesExpectedToSend; - self.progress.completedUnitCount = totalBytesSent; -} - -- (void)URLSession:(__unused NSURLSession *)session - task:(NSURLSessionTask *)task -didCompleteWithError:(NSError *)error -{ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wgnu" - __strong AFURLSessionManager *manager = self.manager; - - __block id responseObject = nil; - - __block NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; - userInfo[AFNetworkingTaskDidCompleteResponseSerializerKey] = manager.responseSerializer; - - if (self.downloadFileURL) { - userInfo[AFNetworkingTaskDidCompleteAssetPathKey] = self.downloadFileURL; - } else if (self.mutableData) { - userInfo[AFNetworkingTaskDidCompleteResponseDataKey] = [NSData dataWithData:self.mutableData]; - } - - if (error) { - userInfo[AFNetworkingTaskDidCompleteErrorKey] = error; - - dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{ - if (self.completionHandler) { - self.completionHandler(task.response, responseObject, error); - } - - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo]; - }); - }); - } else { - dispatch_async(url_session_manager_processing_queue(), ^{ - NSError *serializationError = nil; - responseObject = [manager.responseSerializer responseObjectForResponse:task.response data:[NSData dataWithData:self.mutableData] error:&serializationError]; - - if (self.downloadFileURL) { - responseObject = self.downloadFileURL; - } - - if (responseObject) { - userInfo[AFNetworkingTaskDidCompleteSerializedResponseKey] = responseObject; - } - - if (serializationError) { - userInfo[AFNetworkingTaskDidCompleteErrorKey] = serializationError; - } - - dispatch_group_async(manager.completionGroup ?: url_session_manager_completion_group(), manager.completionQueue ?: dispatch_get_main_queue(), ^{ - if (self.completionHandler) { - self.completionHandler(task.response, responseObject, serializationError); - } - - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo]; - }); - }); - }); - } -#pragma clang diagnostic pop -} - -#pragma mark - NSURLSessionDataTaskDelegate - -- (void)URLSession:(__unused NSURLSession *)session - dataTask:(__unused NSURLSessionDataTask *)dataTask - didReceiveData:(NSData *)data -{ - [self.mutableData appendData:data]; -} - -#pragma mark - NSURLSessionDownloadTaskDelegate - -- (void)URLSession:(NSURLSession *)session - downloadTask:(NSURLSessionDownloadTask *)downloadTask -didFinishDownloadingToURL:(NSURL *)location -{ - NSError *fileManagerError = nil; - self.downloadFileURL = nil; - - if (self.downloadTaskDidFinishDownloading) { - self.downloadFileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location); - if (self.downloadFileURL) { - [[NSFileManager defaultManager] moveItemAtURL:location toURL:self.downloadFileURL error:&fileManagerError]; - - if (fileManagerError) { - [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:fileManagerError.userInfo]; - } - } - } -} - -- (void)URLSession:(__unused NSURLSession *)session - downloadTask:(__unused NSURLSessionDownloadTask *)downloadTask - didWriteData:(__unused int64_t)bytesWritten - totalBytesWritten:(int64_t)totalBytesWritten -totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite -{ - self.progress.totalUnitCount = totalBytesExpectedToWrite; - self.progress.completedUnitCount = totalBytesWritten; -} - -- (void)URLSession:(__unused NSURLSession *)session - downloadTask:(__unused NSURLSessionDownloadTask *)downloadTask - didResumeAtOffset:(int64_t)fileOffset -expectedTotalBytes:(int64_t)expectedTotalBytes { - self.progress.totalUnitCount = expectedTotalBytes; - self.progress.completedUnitCount = fileOffset; -} - -@end - -#pragma mark - - -@interface AFURLSessionManager () -@property (readwrite, nonatomic, strong) NSURLSessionConfiguration *sessionConfiguration; -@property (readwrite, nonatomic, strong) NSOperationQueue *operationQueue; -@property (readwrite, nonatomic, strong) NSURLSession *session; -@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableTaskDelegatesKeyedByTaskIdentifier; -@property (readwrite, nonatomic, strong) NSLock *lock; -@property (readwrite, nonatomic, copy) AFURLSessionDidBecomeInvalidBlock sessionDidBecomeInvalid; -@property (readwrite, nonatomic, copy) AFURLSessionDidReceiveAuthenticationChallengeBlock sessionDidReceiveAuthenticationChallenge; -@property (readwrite, nonatomic, copy) AFURLSessionTaskWillPerformHTTPRedirectionBlock taskWillPerformHTTPRedirection; -@property (readwrite, nonatomic, copy) AFURLSessionTaskDidReceiveAuthenticationChallengeBlock taskDidReceiveAuthenticationChallenge; -@property (readwrite, nonatomic, copy) AFURLSessionTaskNeedNewBodyStreamBlock taskNeedNewBodyStream; -@property (readwrite, nonatomic, copy) AFURLSessionTaskDidSendBodyDataBlock taskDidSendBodyData; -@property (readwrite, nonatomic, copy) AFURLSessionTaskDidCompleteBlock taskDidComplete; -@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveResponseBlock dataTaskDidReceiveResponse; -@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidBecomeDownloadTaskBlock dataTaskDidBecomeDownloadTask; -@property (readwrite, nonatomic, copy) AFURLSessionDataTaskDidReceiveDataBlock dataTaskDidReceiveData; -@property (readwrite, nonatomic, copy) AFURLSessionDataTaskWillCacheResponseBlock dataTaskWillCacheResponse; -@property (readwrite, nonatomic, copy) AFURLSessionDidFinishEventsForBackgroundURLSessionBlock didFinishEventsForBackgroundURLSession; -@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidFinishDownloadingBlock downloadTaskDidFinishDownloading; -@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidWriteDataBlock downloadTaskDidWriteData; -@property (readwrite, nonatomic, copy) AFURLSessionDownloadTaskDidResumeBlock downloadTaskDidResume; -@end - -@implementation AFURLSessionManager - -- (instancetype)init { - return [self initWithSessionConfiguration:nil]; -} - -- (instancetype)initWithSessionConfiguration:(NSURLSessionConfiguration *)configuration { - self = [super init]; - if (!self) { - return nil; - } - - if (!configuration) { - configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; - } - - self.operationQueue = [[NSOperationQueue alloc] init]; - self.operationQueue.maxConcurrentOperationCount = NSOperationQueueDefaultMaxConcurrentOperationCount; - - self.responseSerializer = [AFJSONResponseSerializer serializer]; - - self.sessionConfiguration = configuration; - self.session = [NSURLSession sessionWithConfiguration:self.sessionConfiguration delegate:self delegateQueue:self.operationQueue]; - - self.mutableTaskDelegatesKeyedByTaskIdentifier = [[NSMutableDictionary alloc] init]; - - self.securityPolicy = [AFSecurityPolicy defaultPolicy]; - - self.reachabilityManager = [AFNetworkReachabilityManager sharedManager]; - - self.lock = [[NSLock alloc] init]; - self.lock.name = AFURLSessionManagerLockName; - - [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { - for (NSURLSessionDataTask *task in dataTasks) { - [self addDelegateForDataTask:task completionHandler:nil]; - } - - for (NSURLSessionUploadTask *uploadTask in uploadTasks) { - [self addDelegateForUploadTask:uploadTask progress:nil completionHandler:nil]; - } - - for (NSURLSessionDownloadTask *downloadTask in downloadTasks) { - [self addDelegateForDownloadTask:downloadTask progress:nil destination:nil completionHandler:nil]; - } - }]; - - return self; -} - -#pragma mark - - -- (AFURLSessionManagerTaskDelegate *)delegateForTask:(NSURLSessionTask *)task { - NSParameterAssert(task); - - AFURLSessionManagerTaskDelegate *delegate = nil; - [self.lock lock]; - delegate = self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)]; - [self.lock unlock]; - - return delegate; -} - -- (void)setDelegate:(AFURLSessionManagerTaskDelegate *)delegate - forTask:(NSURLSessionTask *)task -{ - NSParameterAssert(task); - NSParameterAssert(delegate); - - [self.lock lock]; - [task addObserver:self forKeyPath:NSStringFromSelector(@selector(state)) options:NSKeyValueObservingOptionOld |NSKeyValueObservingOptionNew context:AFTaskStateChangedContext]; - self.mutableTaskDelegatesKeyedByTaskIdentifier[@(task.taskIdentifier)] = delegate; - [self.lock unlock]; -} - -- (void)addDelegateForDataTask:(NSURLSessionDataTask *)dataTask - completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler -{ - AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; - delegate.manager = self; - delegate.completionHandler = completionHandler; - - [self setDelegate:delegate forTask:dataTask]; -} - -- (void)addDelegateForUploadTask:(NSURLSessionUploadTask *)uploadTask - progress:(NSProgress * __autoreleasing *)progress - completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler -{ - AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; - delegate.manager = self; - delegate.completionHandler = completionHandler; - - int64_t totalUnitCount = uploadTask.countOfBytesExpectedToSend; - if(totalUnitCount == NSURLSessionTransferSizeUnknown) { - NSString *contentLength = [uploadTask.originalRequest valueForHTTPHeaderField:@"Content-Length"]; - if(contentLength) { - totalUnitCount = (int64_t) [contentLength longLongValue]; - } - } - - delegate.progress = [NSProgress progressWithTotalUnitCount:totalUnitCount]; - delegate.progress.pausingHandler = ^{ - [uploadTask suspend]; - }; - delegate.progress.cancellationHandler = ^{ - [uploadTask cancel]; - }; - - if (progress) { - *progress = delegate.progress; - } - - [self setDelegate:delegate forTask:uploadTask]; -} - -- (void)addDelegateForDownloadTask:(NSURLSessionDownloadTask *)downloadTask - progress:(NSProgress * __autoreleasing *)progress - destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination - completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler -{ - AFURLSessionManagerTaskDelegate *delegate = [[AFURLSessionManagerTaskDelegate alloc] init]; - delegate.manager = self; - delegate.completionHandler = completionHandler; - - delegate.downloadTaskDidFinishDownloading = ^NSURL * (NSURLSession * __unused session, NSURLSessionDownloadTask *task, NSURL *location) { - if (destination) { - return destination(location, task.response); - } - - return location; - }; - - if (progress) { - *progress = delegate.progress; - } - - [self setDelegate:delegate forTask:downloadTask]; -} - -- (void)removeDelegateForTask:(NSURLSessionTask *)task { - NSParameterAssert(task); - - [self.lock lock]; - [task removeObserver:self forKeyPath:NSStringFromSelector(@selector(state)) context:AFTaskStateChangedContext]; - [self.mutableTaskDelegatesKeyedByTaskIdentifier removeObjectForKey:@(task.taskIdentifier)]; - [self.lock unlock]; -} - -- (void)removeAllDelegates { - [self.lock lock]; - [self.mutableTaskDelegatesKeyedByTaskIdentifier removeAllObjects]; - [self.lock unlock]; -} - -#pragma mark - - -- (NSArray *)tasksForKeyPath:(NSString *)keyPath { - __block NSArray *tasks = nil; - dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); - [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { - if ([keyPath isEqualToString:NSStringFromSelector(@selector(dataTasks))]) { - tasks = dataTasks; - } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(uploadTasks))]) { - tasks = uploadTasks; - } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(downloadTasks))]) { - tasks = downloadTasks; - } else if ([keyPath isEqualToString:NSStringFromSelector(@selector(tasks))]) { - tasks = [@[dataTasks, uploadTasks, downloadTasks] valueForKeyPath:@"@unionOfArrays.self"]; - } - - dispatch_semaphore_signal(semaphore); - }]; - - dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); - - return tasks; -} - -- (NSArray *)tasks { - return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; -} - -- (NSArray *)dataTasks { - return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; -} - -- (NSArray *)uploadTasks { - return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; -} - -- (NSArray *)downloadTasks { - return [self tasksForKeyPath:NSStringFromSelector(_cmd)]; -} - -#pragma mark - - -- (void)invalidateSessionCancelingTasks:(BOOL)cancelPendingTasks { - if (cancelPendingTasks) { - [self.session invalidateAndCancel]; - } else { - [self.session finishTasksAndInvalidate]; - } -} - -#pragma mark - - -- (void)setResponseSerializer:(id )responseSerializer { - NSParameterAssert(responseSerializer); - - _responseSerializer = responseSerializer; -} - -#pragma mark - - -- (NSURLSessionDataTask *)dataTaskWithRequest:(NSURLRequest *)request - completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler -{ - NSURLSessionDataTask *dataTask = [self.session dataTaskWithRequest:request]; - - [self addDelegateForDataTask:dataTask completionHandler:completionHandler]; - - return dataTask; -} - -#pragma mark - - -- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request - fromFile:(NSURL *)fileURL - progress:(NSProgress * __autoreleasing *)progress - completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler -{ - NSURLSessionUploadTask *uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL]; - if (!uploadTask && self.attemptsToRecreateUploadTasksForBackgroundSessions && self.session.configuration.identifier) { - for (NSUInteger attempts = 0; !uploadTask && attempts < AFMaximumNumberOfToRecreateBackgroundSessionUploadTask; attempts++) { - uploadTask = [self.session uploadTaskWithRequest:request fromFile:fileURL]; - } - } - - [self addDelegateForUploadTask:uploadTask progress:progress completionHandler:completionHandler]; - - return uploadTask; -} - -- (NSURLSessionUploadTask *)uploadTaskWithRequest:(NSURLRequest *)request - fromData:(NSData *)bodyData - progress:(NSProgress * __autoreleasing *)progress - completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler -{ - NSURLSessionUploadTask *uploadTask = [self.session uploadTaskWithRequest:request fromData:bodyData]; - - [self addDelegateForUploadTask:uploadTask progress:progress completionHandler:completionHandler]; - - return uploadTask; -} - -- (NSURLSessionUploadTask *)uploadTaskWithStreamedRequest:(NSURLRequest *)request - progress:(NSProgress * __autoreleasing *)progress - completionHandler:(void (^)(NSURLResponse *response, id responseObject, NSError *error))completionHandler -{ - NSURLSessionUploadTask *uploadTask = [self.session uploadTaskWithStreamedRequest:request]; - - [self addDelegateForUploadTask:uploadTask progress:progress completionHandler:completionHandler]; - - return uploadTask; -} - -#pragma mark - - -- (NSURLSessionDownloadTask *)downloadTaskWithRequest:(NSURLRequest *)request - progress:(NSProgress * __autoreleasing *)progress - destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination - completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler -{ - NSURLSessionDownloadTask *downloadTask = [self.session downloadTaskWithRequest:request]; - - [self addDelegateForDownloadTask:downloadTask progress:progress destination:destination completionHandler:completionHandler]; - - return downloadTask; -} - -- (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData - progress:(NSProgress * __autoreleasing *)progress - destination:(NSURL * (^)(NSURL *targetPath, NSURLResponse *response))destination - completionHandler:(void (^)(NSURLResponse *response, NSURL *filePath, NSError *error))completionHandler -{ - NSURLSessionDownloadTask *downloadTask = [self.session downloadTaskWithResumeData:resumeData]; - - [self addDelegateForDownloadTask:downloadTask progress:progress destination:destination completionHandler:completionHandler]; - - return downloadTask; -} - -#pragma mark - - -- (NSProgress *)uploadProgressForTask:(NSURLSessionUploadTask *)uploadTask { - return [[self delegateForTask:uploadTask] progress]; -} - -- (NSProgress *)downloadProgressForTask:(NSURLSessionDownloadTask *)downloadTask { - return [[self delegateForTask:downloadTask] progress]; -} - -#pragma mark - - -- (void)setSessionDidBecomeInvalidBlock:(void (^)(NSURLSession *session, NSError *error))block { - self.sessionDidBecomeInvalid = block; -} - -- (void)setSessionDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block { - self.sessionDidReceiveAuthenticationChallenge = block; -} - -#pragma mark - - -- (void)setTaskNeedNewBodyStreamBlock:(NSInputStream * (^)(NSURLSession *session, NSURLSessionTask *task))block { - self.taskNeedNewBodyStream = block; -} - -- (void)setTaskWillPerformHTTPRedirectionBlock:(NSURLRequest * (^)(NSURLSession *session, NSURLSessionTask *task, NSURLResponse *response, NSURLRequest *request))block { - self.taskWillPerformHTTPRedirection = block; -} - -- (void)setTaskDidReceiveAuthenticationChallengeBlock:(NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLSessionTask *task, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential))block { - self.taskDidReceiveAuthenticationChallenge = block; -} - -- (void)setTaskDidSendBodyDataBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, int64_t bytesSent, int64_t totalBytesSent, int64_t totalBytesExpectedToSend))block { - self.taskDidSendBodyData = block; -} - -- (void)setTaskDidCompleteBlock:(void (^)(NSURLSession *session, NSURLSessionTask *task, NSError *error))block { - self.taskDidComplete = block; -} - -#pragma mark - - -- (void)setDataTaskDidReceiveResponseBlock:(NSURLSessionResponseDisposition (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLResponse *response))block { - self.dataTaskDidReceiveResponse = block; -} - -- (void)setDataTaskDidBecomeDownloadTaskBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSURLSessionDownloadTask *downloadTask))block { - self.dataTaskDidBecomeDownloadTask = block; -} - -- (void)setDataTaskDidReceiveDataBlock:(void (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSData *data))block { - self.dataTaskDidReceiveData = block; -} - -- (void)setDataTaskWillCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLSession *session, NSURLSessionDataTask *dataTask, NSCachedURLResponse *proposedResponse))block { - self.dataTaskWillCacheResponse = block; -} - -- (void)setDidFinishEventsForBackgroundURLSessionBlock:(void (^)(NSURLSession *session))block { - self.didFinishEventsForBackgroundURLSession = block; -} - -#pragma mark - - -- (void)setDownloadTaskDidFinishDownloadingBlock:(NSURL * (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, NSURL *location))block { - self.downloadTaskDidFinishDownloading = block; -} - -- (void)setDownloadTaskDidWriteDataBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite))block { - self.downloadTaskDidWriteData = block; -} - -- (void)setDownloadTaskDidResumeBlock:(void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block { - self.downloadTaskDidResume = block; -} - -#pragma mark - NSObject - -- (NSString *)description { - return [NSString stringWithFormat:@"<%@: %p, session: %@, operationQueue: %@>", NSStringFromClass([self class]), self, self.session, self.operationQueue]; -} - -- (BOOL)respondsToSelector:(SEL)selector { - if (selector == @selector(URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:)) { - return self.taskWillPerformHTTPRedirection != nil; - } else if (selector == @selector(URLSession:dataTask:didReceiveResponse:completionHandler:)) { - return self.dataTaskDidReceiveResponse != nil; - } else if (selector == @selector(URLSession:dataTask:willCacheResponse:completionHandler:)) { - return self.dataTaskWillCacheResponse != nil; - } else if (selector == @selector(URLSessionDidFinishEventsForBackgroundURLSession:)) { - return self.didFinishEventsForBackgroundURLSession != nil; - } - - return [[self class] instancesRespondToSelector:selector]; -} - -#pragma mark - NSKeyValueObserving - -- (void)observeValueForKeyPath:(NSString *)keyPath - ofObject:(id)object - change:(NSDictionary *)change - context:(void *)context -{ - if (context == AFTaskStateChangedContext && [keyPath isEqualToString:@"state"]) { - if (change[NSKeyValueChangeOldKey] && change[NSKeyValueChangeNewKey] && [change[NSKeyValueChangeNewKey] isEqual:change[NSKeyValueChangeOldKey]]) { - return; - } - - NSString *notificationName = nil; - switch ([(NSURLSessionTask *)object state]) { - case NSURLSessionTaskStateRunning: - notificationName = AFNetworkingTaskDidResumeNotification; - break; - case NSURLSessionTaskStateSuspended: - notificationName = AFNetworkingTaskDidSuspendNotification; - break; - case NSURLSessionTaskStateCompleted: - // AFNetworkingTaskDidFinishNotification posted by task completion handlers - default: - break; - } - - if (notificationName) { - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:notificationName object:object]; - }); - } - } else { - [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; - } -} - -#pragma mark - NSURLSessionDelegate - -- (void)URLSession:(NSURLSession *)session -didBecomeInvalidWithError:(NSError *)error -{ - if (self.sessionDidBecomeInvalid) { - self.sessionDidBecomeInvalid(session, error); - } - - [self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks) { - NSArray *tasks = [@[dataTasks, uploadTasks, downloadTasks] valueForKeyPath:@"@unionOfArrays.self"]; - for (NSURLSessionTask *task in tasks) { - [task removeObserver:self forKeyPath:NSStringFromSelector(@selector(state)) context:AFTaskStateChangedContext]; - } - - [self removeAllDelegates]; - }]; - - [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDidInvalidateNotification object:session]; -} - -- (void)URLSession:(NSURLSession *)session -didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge - completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler -{ - NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; - __block NSURLCredential *credential = nil; - - if (self.sessionDidReceiveAuthenticationChallenge) { - disposition = self.sessionDidReceiveAuthenticationChallenge(session, challenge, &credential); - } else { - if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { - if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { - credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; - if (credential) { - disposition = NSURLSessionAuthChallengeUseCredential; - } else { - disposition = NSURLSessionAuthChallengePerformDefaultHandling; - } - } else { - disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge; - } - } else { - disposition = NSURLSessionAuthChallengePerformDefaultHandling; - } - } - - if (completionHandler) { - completionHandler(disposition, credential); - } -} - -#pragma mark - NSURLSessionTaskDelegate - -- (void)URLSession:(NSURLSession *)session - task:(NSURLSessionTask *)task -willPerformHTTPRedirection:(NSHTTPURLResponse *)response - newRequest:(NSURLRequest *)request - completionHandler:(void (^)(NSURLRequest *))completionHandler -{ - NSURLRequest *redirectRequest = request; - - if (self.taskWillPerformHTTPRedirection) { - redirectRequest = self.taskWillPerformHTTPRedirection(session, task, response, request); - } - - if (completionHandler) { - completionHandler(redirectRequest); - } -} - -- (void)URLSession:(NSURLSession *)session - task:(NSURLSessionTask *)task -didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge - completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler -{ - NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling; - __block NSURLCredential *credential = nil; - - if (self.taskDidReceiveAuthenticationChallenge) { - disposition = self.taskDidReceiveAuthenticationChallenge(session, task, challenge, &credential); - } else { - if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { - if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host]) { - disposition = NSURLSessionAuthChallengeUseCredential; - credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; - } else { - disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge; - } - } else { - disposition = NSURLSessionAuthChallengePerformDefaultHandling; - } - } - - if (completionHandler) { - completionHandler(disposition, credential); - } -} - -- (void)URLSession:(NSURLSession *)session - task:(NSURLSessionTask *)task - needNewBodyStream:(void (^)(NSInputStream *bodyStream))completionHandler -{ - NSInputStream *inputStream = nil; - - if (self.taskNeedNewBodyStream) { - inputStream = self.taskNeedNewBodyStream(session, task); - } else if (task.originalRequest.HTTPBodyStream && [task.originalRequest.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) { - inputStream = [task.originalRequest.HTTPBodyStream copy]; - } - - if (completionHandler) { - completionHandler(inputStream); - } -} - -- (void)URLSession:(NSURLSession *)session - task:(NSURLSessionTask *)task - didSendBodyData:(int64_t)bytesSent - totalBytesSent:(int64_t)totalBytesSent -totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend -{ - - int64_t totalUnitCount = totalBytesExpectedToSend; - if(totalUnitCount == NSURLSessionTransferSizeUnknown) { - NSString *contentLength = [task.originalRequest valueForHTTPHeaderField:@"Content-Length"]; - if(contentLength) { - totalUnitCount = (int64_t) [contentLength longLongValue]; - } - } - - AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; - [delegate URLSession:session task:task didSendBodyData:bytesSent totalBytesSent:totalBytesSent totalBytesExpectedToSend:totalUnitCount]; - - if (self.taskDidSendBodyData) { - self.taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalUnitCount); - } -} - -- (void)URLSession:(NSURLSession *)session - task:(NSURLSessionTask *)task -didCompleteWithError:(NSError *)error -{ - AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:task]; - - // delegate may be nil when completing a task in the background - if (delegate) { - [delegate URLSession:session task:task didCompleteWithError:error]; - - [self removeDelegateForTask:task]; - } - - if (self.taskDidComplete) { - self.taskDidComplete(session, task, error); - } - -} - -#pragma mark - NSURLSessionDataDelegate - -- (void)URLSession:(NSURLSession *)session - dataTask:(NSURLSessionDataTask *)dataTask -didReceiveResponse:(NSURLResponse *)response - completionHandler:(void (^)(NSURLSessionResponseDisposition disposition))completionHandler -{ - NSURLSessionResponseDisposition disposition = NSURLSessionResponseAllow; - - if (self.dataTaskDidReceiveResponse) { - disposition = self.dataTaskDidReceiveResponse(session, dataTask, response); - } - - if (completionHandler) { - completionHandler(disposition); - } -} - -- (void)URLSession:(NSURLSession *)session - dataTask:(NSURLSessionDataTask *)dataTask -didBecomeDownloadTask:(NSURLSessionDownloadTask *)downloadTask -{ - AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask]; - if (delegate) { - [self removeDelegateForTask:dataTask]; - [self setDelegate:delegate forTask:downloadTask]; - } - - if (self.dataTaskDidBecomeDownloadTask) { - self.dataTaskDidBecomeDownloadTask(session, dataTask, downloadTask); - } -} - -- (void)URLSession:(NSURLSession *)session - dataTask:(NSURLSessionDataTask *)dataTask - didReceiveData:(NSData *)data -{ - AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:dataTask]; - [delegate URLSession:session dataTask:dataTask didReceiveData:data]; - - if (self.dataTaskDidReceiveData) { - self.dataTaskDidReceiveData(session, dataTask, data); - } -} - -- (void)URLSession:(NSURLSession *)session - dataTask:(NSURLSessionDataTask *)dataTask - willCacheResponse:(NSCachedURLResponse *)proposedResponse - completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler -{ - NSCachedURLResponse *cachedResponse = proposedResponse; - - if (self.dataTaskWillCacheResponse) { - cachedResponse = self.dataTaskWillCacheResponse(session, dataTask, proposedResponse); - } - - if (completionHandler) { - completionHandler(cachedResponse); - } -} - -- (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)session { - if (self.didFinishEventsForBackgroundURLSession) { - dispatch_async(dispatch_get_main_queue(), ^{ - self.didFinishEventsForBackgroundURLSession(session); - }); - } -} - -#pragma mark - NSURLSessionDownloadDelegate - -- (void)URLSession:(NSURLSession *)session - downloadTask:(NSURLSessionDownloadTask *)downloadTask -didFinishDownloadingToURL:(NSURL *)location -{ - if (self.downloadTaskDidFinishDownloading) { - NSURL *fileURL = self.downloadTaskDidFinishDownloading(session, downloadTask, location); - if (fileURL) { - NSError *error = nil; - [[NSFileManager defaultManager] moveItemAtURL:location toURL:fileURL error:&error]; - if (error) { - [[NSNotificationCenter defaultCenter] postNotificationName:AFURLSessionDownloadTaskDidFailToMoveFileNotification object:downloadTask userInfo:error.userInfo]; - } - return; - } - } - - AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; - if (delegate) { - [delegate URLSession:session downloadTask:downloadTask didFinishDownloadingToURL:location]; - } -} - -- (void)URLSession:(NSURLSession *)session - downloadTask:(NSURLSessionDownloadTask *)downloadTask - didWriteData:(int64_t)bytesWritten - totalBytesWritten:(int64_t)totalBytesWritten -totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite -{ - AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; - [delegate URLSession:session downloadTask:downloadTask didWriteData:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite]; - - if (self.downloadTaskDidWriteData) { - self.downloadTaskDidWriteData(session, downloadTask, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); - } -} - -- (void)URLSession:(NSURLSession *)session - downloadTask:(NSURLSessionDownloadTask *)downloadTask - didResumeAtOffset:(int64_t)fileOffset -expectedTotalBytes:(int64_t)expectedTotalBytes -{ - AFURLSessionManagerTaskDelegate *delegate = [self delegateForTask:downloadTask]; - [delegate URLSession:session downloadTask:downloadTask didResumeAtOffset:fileOffset expectedTotalBytes:expectedTotalBytes]; - - if (self.downloadTaskDidResume) { - self.downloadTaskDidResume(session, downloadTask, fileOffset, expectedTotalBytes); - } -} - -#pragma mark - NSecureCoding - -+ (BOOL)supportsSecureCoding { - return YES; -} - -- (id)initWithCoder:(NSCoder *)decoder { - NSURLSessionConfiguration *configuration = [decoder decodeObjectOfClass:[NSURLSessionConfiguration class] forKey:@"sessionConfiguration"]; - - self = [self initWithSessionConfiguration:configuration]; - if (!self) { - return nil; - } - - return self; -} - -- (void)encodeWithCoder:(NSCoder *)coder { - [coder encodeObject:self.session.configuration forKey:@"sessionConfiguration"]; -} - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone { - return [[[self class] allocWithZone:zone] initWithSessionConfiguration:self.session.configuration]; -} - -@end - -#endif diff --git a/Ryff/Frameworks/CHTCollectionViewWaterfallLayout/CHTCollectionViewWaterfallLayout.h b/Ryff/Frameworks/CHTCollectionViewWaterfallLayout/CHTCollectionViewWaterfallLayout.h deleted file mode 100755 index 3380f97..0000000 --- a/Ryff/Frameworks/CHTCollectionViewWaterfallLayout/CHTCollectionViewWaterfallLayout.h +++ /dev/null @@ -1,282 +0,0 @@ -// -// UICollectionViewWaterfallLayout.h -// -// Created by Nelson on 12/11/19. -// Copyright (c) 2012 Nelson Tai. All rights reserved. -// - -#import - -/** - * Enumerated structure to define direction in which items can be rendered. - */ -typedef NS_ENUM (NSUInteger, CHTCollectionViewWaterfallLayoutItemRenderDirection) { - CHTCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst, - CHTCollectionViewWaterfallLayoutItemRenderDirectionLeftToRight, - CHTCollectionViewWaterfallLayoutItemRenderDirectionRightToLeft -}; - -/** - * Constants that specify the types of supplementary views that can be presented using a waterfall layout. - */ - -/// A supplementary view that identifies the header for a given section. -extern NSString *const CHTCollectionElementKindSectionHeader; -/// A supplementary view that identifies the footer for a given section. -extern NSString *const CHTCollectionElementKindSectionFooter; - -#pragma mark - CHTCollectionViewDelegateWaterfallLayout - -@class CHTCollectionViewWaterfallLayout; - -/** - * The CHTCollectionViewDelegateWaterfallLayout protocol defines methods that let you coordinate with a - * CHTCollectionViewWaterfallLayout object to implement a waterfall-based layout. - * The methods of this protocol define the size of items. - * - * The waterfall layout object expects the collection view’s delegate object to adopt this protocol. - * Therefore, implement this protocol on object assigned to your collection view’s delegate property. - */ -@protocol CHTCollectionViewDelegateWaterfallLayout -@required -/** - * Asks the delegate for the size of the specified item’s cell. - * - * @param collectionView - * The collection view object displaying the waterfall layout. - * @param collectionViewLayout - * The layout object requesting the information. - * @param indexPath - * The index path of the item. - * - * @return - * The original size of the specified item. Both width and height must be greater than 0. - */ -- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath; - -@optional -/** - * Asks the delegate for the height of the header view in the specified section. - * - * @param collectionView - * The collection view object displaying the waterfall layout. - * @param collectionViewLayout - * The layout object requesting the information. - * @param section - * The index of the section whose header size is being requested. - * - * @return - * The height of the header. If you return 0, no header is added. - * - * @discussion - * If you do not implement this method, the waterfall layout uses the value in its headerHeight property to set the size of the header. - * - * @see - * headerHeight - */ -- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout heightForHeaderInSection:(NSInteger)section; - -/** - * Asks the delegate for the height of the footer view in the specified section. - * - * @param collectionView - * The collection view object displaying the waterfall layout. - * @param collectionViewLayout - * The layout object requesting the information. - * @param section - * The index of the section whose header size is being requested. - * - * @return - * The height of the footer. If you return 0, no footer is added. - * - * @discussion - * If you do not implement this method, the waterfall layout uses the value in its footerHeight property to set the size of the footer. - * - * @see - * footerHeight - */ -- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout heightForFooterInSection:(NSInteger)section; - -/** - * Asks the delegate for the insets in the specified section. - * - * @param collectionView - * The collection view object displaying the waterfall layout. - * @param collectionViewLayout - * The layout object requesting the information. - * @param section - * The index of the section whose insets are being requested. - * - * @discussion - * If you do not implement this method, the waterfall layout uses the value in its sectionInset property. - * - * @return - * The insets for the section. - */ -- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section; - -/** - * Asks the delegate for the header insets in the specified section. - * - * @param collectionView - * The collection view object displaying the waterfall layout. - * @param collectionViewLayout - * The layout object requesting the information. - * @param section - * The index of the section whose header insets are being requested. - * - * @discussion - * If you do not implement this method, the waterfall layout uses the value in its headerInset property. - * - * @return - * The headerInsets for the section. - */ -- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForHeaderInSection:(NSInteger)section; - -/** - * Asks the delegate for the footer insets in the specified section. - * - * @param collectionView - * The collection view object displaying the waterfall layout. - * @param collectionViewLayout - * The layout object requesting the information. - * @param section - * The index of the section whose footer insets are being requested. - * - * @discussion - * If you do not implement this method, the waterfall layout uses the value in its footerInset property. - * - * @return - * The footerInsets for the section. - */ -- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForFooterInSection:(NSInteger)section; - -/** - * Asks the delegate for the minimum spacing between two items in the same column - * in the specified section. If this method is not implemented, the - * minimumInteritemSpacing property is used for all sections. - * - * @param collectionView - * The collection view object displaying the waterfall layout. - * @param collectionViewLayout - * The layout object requesting the information. - * @param section - * The index of the section whose minimum interitem spacing is being requested. - * - * @discussion - * If you do not implement this method, the waterfall layout uses the value in its minimumInteritemSpacing property to determine the amount of space between items in the same column. - * - * @return - * The minimum interitem spacing. - */ -- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section; - -@end - -#pragma mark - CHTCollectionViewWaterfallLayout - -/** - * The CHTCollectionViewWaterfallLayout class is a concrete layout object that organizes items into waterfall-based grids - * with optional header and footer views for each section. - * - * A waterfall layout works with the collection view’s delegate object to determine the size of items, headers, and footers - * in each section. That delegate object must conform to the `CHTCollectionViewDelegateWaterfallLayout` protocol. - * - * Each section in a waterfall layout can have its own custom header and footer. To configure the header or footer for a view, - * you must configure the height of the header or footer to be non zero. You can do this by implementing the appropriate delegate - * methods or by assigning appropriate values to the `headerHeight` and `footerHeight` properties. - * If the header or footer height is 0, the corresponding view is not added to the collection view. - * - * @note CHTCollectionViewWaterfallLayout doesn't support decoration view, and it supports vertical scrolling direction only. - */ -@interface CHTCollectionViewWaterfallLayout : UICollectionViewLayout - -/** - * @brief How many columns for this layout. - * @discussion Default: 2 - */ -@property (nonatomic, assign) NSInteger columnCount; - -/** - * @brief The minimum spacing to use between successive columns. - * @discussion Default: 10.0 - */ -@property (nonatomic, assign) CGFloat minimumColumnSpacing; - -/** - * @brief The minimum spacing to use between items in the same column. - * @discussion Default: 10.0 - * @note This spacing is not applied to the space between header and columns or between columns and footer. - */ -@property (nonatomic, assign) CGFloat minimumInteritemSpacing; - -/** - * @brief Height for section header - * @discussion - * If your collectionView's delegate doesn't implement `collectionView:layout:heightForHeaderInSection:`, - * then this value will be used. - * - * Default: 0 - */ -@property (nonatomic, assign) CGFloat headerHeight; - -/** - * @brief Height for section footer - * @discussion - * If your collectionView's delegate doesn't implement `collectionView:layout:heightForFooterInSection:`, - * then this value will be used. - * - * Default: 0 - */ -@property (nonatomic, assign) CGFloat footerHeight; - -/** - * @brief The margins that are used to lay out the header for each section. - * @discussion - * These insets are applied to the headers in each section. - * They represent the distance between the top of the collection view and the top of the content items - * They also indicate the spacing on either side of the header. They do not affect the size of the headers or footers themselves. - * - * Default: UIEdgeInsetsZero - */ -@property (nonatomic, assign) UIEdgeInsets headerInset; - -/** - * @brief The margins that are used to lay out the footer for each section. - * @discussion - * These insets are applied to the footers in each section. - * They represent the distance between the top of the collection view and the top of the content items - * They also indicate the spacing on either side of the footer. They do not affect the size of the headers or footers themselves. - * - * Default: UIEdgeInsetsZero - */ -@property (nonatomic, assign) UIEdgeInsets footerInset; - -/** - * @brief The margins that are used to lay out content in each section. - * @discussion - * Section insets are margins applied only to the items in the section. - * They represent the distance between the header view and the columns and between the columns and the footer view. - * They also indicate the spacing on either side of columns. They do not affect the size of the headers or footers themselves. - * - * Default: UIEdgeInsetsZero - */ -@property (nonatomic, assign) UIEdgeInsets sectionInset; - -/** - * @brief The direction in which items will be rendered in subsequent rows. - * @discussion - * The direction in which each item is rendered. This could be left to right (CHTCollectionViewWaterfallLayoutItemRenderDirectionLeftToRight), right to left (CHTCollectionViewWaterfallLayoutItemRenderDirectionRightToLeft), or shortest column fills first (CHTCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst). - * - * Default: CHTCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst - */ -@property (nonatomic, assign) CHTCollectionViewWaterfallLayoutItemRenderDirection itemRenderDirection; - -/** - * @brief The calculated width of an item in the specified section. - * @discussion - * The width of an item is calculated based on number of columns, the collection view width, and the horizontal insets for that section. - */ -- (CGFloat)itemWidthInSectionAtIndex:(NSInteger)section; - -@end diff --git a/Ryff/Frameworks/CHTCollectionViewWaterfallLayout/CHTCollectionViewWaterfallLayout.m b/Ryff/Frameworks/CHTCollectionViewWaterfallLayout/CHTCollectionViewWaterfallLayout.m deleted file mode 100755 index 9e4cb19..0000000 --- a/Ryff/Frameworks/CHTCollectionViewWaterfallLayout/CHTCollectionViewWaterfallLayout.m +++ /dev/null @@ -1,487 +0,0 @@ -// -// UICollectionViewWaterfallLayout.m -// -// Created by Nelson on 12/11/19. -// Copyright (c) 2012 Nelson Tai. All rights reserved. -// - -#import "CHTCollectionViewWaterfallLayout.h" - -NSString *const CHTCollectionElementKindSectionHeader = @"CHTCollectionElementKindSectionHeader"; -NSString *const CHTCollectionElementKindSectionFooter = @"CHTCollectionElementKindSectionFooter"; - -@interface CHTCollectionViewWaterfallLayout () -/// The delegate will point to collection view's delegate automatically. -@property (nonatomic, weak) id delegate; -/// Array to store height for each column -@property (nonatomic, strong) NSMutableArray *columnHeights; -/// Array of arrays. Each array stores item attributes for each section -@property (nonatomic, strong) NSMutableArray *sectionItemAttributes; -/// Array to store attributes for all items includes headers, cells, and footers -@property (nonatomic, strong) NSMutableArray *allItemAttributes; -/// Dictionary to store section headers' attribute -@property (nonatomic, strong) NSMutableDictionary *headersAttribute; -/// Dictionary to store section footers' attribute -@property (nonatomic, strong) NSMutableDictionary *footersAttribute; -/// Array to store union rectangles -@property (nonatomic, strong) NSMutableArray *unionRects; -@end - -@implementation CHTCollectionViewWaterfallLayout - -/// How many items to be union into a single rectangle -const NSInteger unionSize = 20; - -#pragma mark - Public Accessors -- (void)setColumnCount:(NSInteger)columnCount { - if (_columnCount != columnCount) { - _columnCount = columnCount; - [self invalidateLayout]; - } -} - -- (void)setMinimumColumnSpacing:(CGFloat)minimumColumnSpacing { - if (_minimumColumnSpacing != minimumColumnSpacing) { - _minimumColumnSpacing = minimumColumnSpacing; - [self invalidateLayout]; - } -} - -- (void)setMinimumInteritemSpacing:(CGFloat)minimumInteritemSpacing { - if (_minimumInteritemSpacing != minimumInteritemSpacing) { - _minimumInteritemSpacing = minimumInteritemSpacing; - [self invalidateLayout]; - } -} - -- (void)setHeaderHeight:(CGFloat)headerHeight { - if (_headerHeight != headerHeight) { - _headerHeight = headerHeight; - [self invalidateLayout]; - } -} - -- (void)setFooterHeight:(CGFloat)footerHeight { - if (_footerHeight != footerHeight) { - _footerHeight = footerHeight; - [self invalidateLayout]; - } -} - -- (void)setHeaderInset:(UIEdgeInsets)headerInset{ - if (!UIEdgeInsetsEqualToEdgeInsets(_headerInset, headerInset)) { - _headerInset = headerInset; - [self invalidateLayout]; - } -} - -- (void)setFooterInset:(UIEdgeInsets)footerInset { - if (!UIEdgeInsetsEqualToEdgeInsets(_footerInset, footerInset)) { - _footerInset = footerInset; - [self invalidateLayout]; - } -} - -- (void)setSectionInset:(UIEdgeInsets)sectionInset { - if (!UIEdgeInsetsEqualToEdgeInsets(_sectionInset, sectionInset)) { - _sectionInset = sectionInset; - [self invalidateLayout]; - } -} - -- (void)setItemRenderDirection:(CHTCollectionViewWaterfallLayoutItemRenderDirection)itemRenderDirection { - if (_itemRenderDirection != itemRenderDirection) { - _itemRenderDirection = itemRenderDirection; - [self invalidateLayout]; - } -} - -- (CGFloat)itemWidthInSectionAtIndex:(NSInteger)section { - UIEdgeInsets sectionInset; - if ([self.delegate respondsToSelector:@selector(collectionView:layout:insetForSectionAtIndex:)]) { - sectionInset = [self.delegate collectionView:self.collectionView layout:self insetForSectionAtIndex:section]; - } else { - sectionInset = self.sectionInset; - } - CGFloat width = self.collectionView.frame.size.width - sectionInset.left - sectionInset.right; - return floorf((width - (self.columnCount - 1) * self.minimumColumnSpacing) / self.columnCount); -} - -#pragma mark - Private Accessors -- (NSMutableDictionary *)headersAttribute { - if (!_headersAttribute) { - _headersAttribute = [NSMutableDictionary dictionary]; - } - return _headersAttribute; -} - -- (NSMutableDictionary *)footersAttribute { - if (!_footersAttribute) { - _footersAttribute = [NSMutableDictionary dictionary]; - } - return _footersAttribute; -} - -- (NSMutableArray *)unionRects { - if (!_unionRects) { - _unionRects = [NSMutableArray array]; - } - return _unionRects; -} - -- (NSMutableArray *)columnHeights { - if (!_columnHeights) { - _columnHeights = [NSMutableArray array]; - } - return _columnHeights; -} - -- (NSMutableArray *)allItemAttributes { - if (!_allItemAttributes) { - _allItemAttributes = [NSMutableArray array]; - } - return _allItemAttributes; -} - -- (NSMutableArray *)sectionItemAttributes { - if (!_sectionItemAttributes) { - _sectionItemAttributes = [NSMutableArray array]; - } - return _sectionItemAttributes; -} - -- (id)delegate { - return (id)self.collectionView.delegate; -} - -#pragma mark - Init -- (void)commonInit { - _columnCount = 2; - _minimumColumnSpacing = 10; - _minimumInteritemSpacing = 10; - _headerHeight = 0; - _footerHeight = 0; - _sectionInset = UIEdgeInsetsZero; - _headerInset = UIEdgeInsetsZero; - _footerInset = UIEdgeInsetsZero; - _itemRenderDirection = CHTCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst; -} - -- (id)init { - if (self = [super init]) { - [self commonInit]; - } - return self; -} - -- (id)initWithCoder:(NSCoder *)aDecoder { - if (self = [super initWithCoder:aDecoder]) { - [self commonInit]; - } - return self; -} - -#pragma mark - Methods to Override -- (void)prepareLayout { - [super prepareLayout]; - - NSInteger numberOfSections = [self.collectionView numberOfSections]; - if (numberOfSections == 0) { - return; - } - - NSAssert([self.delegate conformsToProtocol:@protocol(CHTCollectionViewDelegateWaterfallLayout)], @"UICollectionView's delegate should conform to CHTCollectionViewDelegateWaterfallLayout protocol"); - NSAssert(self.columnCount > 0, @"UICollectionViewWaterfallLayout's columnCount should be greater than 0"); - - // Initialize variables - NSInteger idx = 0; - - [self.headersAttribute removeAllObjects]; - [self.footersAttribute removeAllObjects]; - [self.unionRects removeAllObjects]; - [self.columnHeights removeAllObjects]; - [self.allItemAttributes removeAllObjects]; - [self.sectionItemAttributes removeAllObjects]; - - for (idx = 0; idx < self.columnCount; idx++) { - [self.columnHeights addObject:@(0)]; - } - - // Create attributes - CGFloat top = 0; - UICollectionViewLayoutAttributes *attributes; - - for (NSInteger section = 0; section < numberOfSections; ++section) { - /* - * 1. Get section-specific metrics (minimumInteritemSpacing, sectionInset) - */ - CGFloat minimumInteritemSpacing; - if ([self.delegate respondsToSelector:@selector(collectionView:layout:minimumInteritemSpacingForSectionAtIndex:)]) { - minimumInteritemSpacing = [self.delegate collectionView:self.collectionView layout:self minimumInteritemSpacingForSectionAtIndex:section]; - } else { - minimumInteritemSpacing = self.minimumInteritemSpacing; - } - - UIEdgeInsets sectionInset; - if ([self.delegate respondsToSelector:@selector(collectionView:layout:insetForSectionAtIndex:)]) { - sectionInset = [self.delegate collectionView:self.collectionView layout:self insetForSectionAtIndex:section]; - } else { - sectionInset = self.sectionInset; - } - - CGFloat width = self.collectionView.frame.size.width - sectionInset.left - sectionInset.right; - CGFloat itemWidth = floorf((width - (self.columnCount - 1) * self.minimumColumnSpacing) / self.columnCount); - - /* - * 2. Section header - */ - CGFloat headerHeight; - if ([self.delegate respondsToSelector:@selector(collectionView:layout:heightForHeaderInSection:)]) { - headerHeight = [self.delegate collectionView:self.collectionView layout:self heightForHeaderInSection:section]; - } else { - headerHeight = self.headerHeight; - } - - UIEdgeInsets headerInset; - if ([self.delegate respondsToSelector:@selector(collectionView:layout:insetForHeaderInSection:)]) { - headerInset = [self.delegate collectionView:self.collectionView layout:self insetForHeaderInSection:section]; - } else { - headerInset = self.headerInset; - } - - top += headerInset.top; - - if (headerHeight > 0) { - attributes = [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:CHTCollectionElementKindSectionHeader withIndexPath:[NSIndexPath indexPathForItem:0 inSection:section]]; - attributes.frame = CGRectMake(headerInset.left, - top, - self.collectionView.frame.size.width - (headerInset.left + headerInset.right), - headerHeight); - - self.headersAttribute[@(section)] = attributes; - [self.allItemAttributes addObject:attributes]; - - top = CGRectGetMaxY(attributes.frame) + headerInset.bottom; - } - - top += sectionInset.top; - for (idx = 0; idx < self.columnCount; idx++) { - self.columnHeights[idx] = @(top); - } - - /* - * 3. Section items - */ - NSInteger itemCount = [self.collectionView numberOfItemsInSection:section]; - NSMutableArray *itemAttributes = [NSMutableArray arrayWithCapacity:itemCount]; - - // Item will be put into shortest column. - for (idx = 0; idx < itemCount; idx++) { - NSIndexPath *indexPath = [NSIndexPath indexPathForItem:idx inSection:section]; - NSUInteger columnIndex = [self nextColumnIndexForItem:idx]; - CGFloat xOffset = sectionInset.left + (itemWidth + self.minimumColumnSpacing) * columnIndex; - CGFloat yOffset = [self.columnHeights[columnIndex] floatValue]; - CGSize itemSize = [self.delegate collectionView:self.collectionView layout:self sizeForItemAtIndexPath:indexPath]; - CGFloat itemHeight = 0; - if (itemSize.height > 0 && itemSize.width > 0) { - itemHeight = floorf(itemSize.height * itemWidth / itemSize.width); - } - - attributes = [UICollectionViewLayoutAttributes layoutAttributesForCellWithIndexPath:indexPath]; - attributes.frame = CGRectMake(xOffset, yOffset, itemWidth, itemHeight); - [itemAttributes addObject:attributes]; - [self.allItemAttributes addObject:attributes]; - self.columnHeights[columnIndex] = @(CGRectGetMaxY(attributes.frame) + minimumInteritemSpacing); - } - - [self.sectionItemAttributes addObject:itemAttributes]; - - /* - * 4. Section footer - */ - CGFloat footerHeight; - NSUInteger columnIndex = [self longestColumnIndex]; - top = [self.columnHeights[columnIndex] floatValue] - minimumInteritemSpacing + sectionInset.bottom; - - if ([self.delegate respondsToSelector:@selector(collectionView:layout:heightForFooterInSection:)]) { - footerHeight = [self.delegate collectionView:self.collectionView layout:self heightForFooterInSection:section]; - } else { - footerHeight = self.footerHeight; - } - - UIEdgeInsets footerInset; - if ([self.delegate respondsToSelector:@selector(collectionView:layout:insetForFooterInSection:)]) { - footerInset = [self.delegate collectionView:self.collectionView layout:self insetForFooterInSection:section]; - } else { - footerInset = self.footerInset; - } - - top += footerInset.top; - - if (footerHeight > 0) { - attributes = [UICollectionViewLayoutAttributes layoutAttributesForSupplementaryViewOfKind:CHTCollectionElementKindSectionFooter withIndexPath:[NSIndexPath indexPathForItem:0 inSection:section]]; - attributes.frame = CGRectMake(footerInset.left, - top, - self.collectionView.frame.size.width - (footerInset.left + footerInset.right), - footerHeight); - - self.footersAttribute[@(section)] = attributes; - [self.allItemAttributes addObject:attributes]; - - top = CGRectGetMaxY(attributes.frame) + footerInset.bottom; - } - - for (idx = 0; idx < self.columnCount; idx++) { - self.columnHeights[idx] = @(top); - } - } // end of for (NSInteger section = 0; section < numberOfSections; ++section) - - // Build union rects - idx = 0; - NSInteger itemCounts = [self.allItemAttributes count]; - while (idx < itemCounts) { - CGRect rect1 = ((UICollectionViewLayoutAttributes *)self.allItemAttributes[idx]).frame; - idx = MIN(idx + unionSize, itemCounts) - 1; - CGRect rect2 = ((UICollectionViewLayoutAttributes *)self.allItemAttributes[idx]).frame; - [self.unionRects addObject:[NSValue valueWithCGRect:CGRectUnion(rect1, rect2)]]; - idx++; - } -} - -- (CGSize)collectionViewContentSize { - NSInteger numberOfSections = [self.collectionView numberOfSections]; - if (numberOfSections == 0) { - return CGSizeZero; - } - - CGSize contentSize = self.collectionView.bounds.size; - contentSize.height = [self.columnHeights[0] floatValue]; - - return contentSize; -} - -- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)path { - if (path.section >= [self.sectionItemAttributes count]) { - return nil; - } - if (path.item >= [self.sectionItemAttributes[path.section] count]) { - return nil; - } - return (self.sectionItemAttributes[path.section])[path.item]; -} - -- (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { - UICollectionViewLayoutAttributes *attribute = nil; - if ([kind isEqualToString:CHTCollectionElementKindSectionHeader]) { - attribute = self.headersAttribute[@(indexPath.section)]; - } else if ([kind isEqualToString:CHTCollectionElementKindSectionFooter]) { - attribute = self.footersAttribute[@(indexPath.section)]; - } - return attribute; -} - -- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { - NSInteger i; - NSInteger begin = 0, end = self.unionRects.count; - NSMutableArray *attrs = [NSMutableArray array]; - - for (i = 0; i < self.unionRects.count; i++) { - if (CGRectIntersectsRect(rect, [self.unionRects[i] CGRectValue])) { - begin = i * unionSize; - break; - } - } - for (i = self.unionRects.count - 1; i >= 0; i--) { - if (CGRectIntersectsRect(rect, [self.unionRects[i] CGRectValue])) { - end = MIN((i + 1) * unionSize, self.allItemAttributes.count); - break; - } - } - for (i = begin; i < end; i++) { - UICollectionViewLayoutAttributes *attr = self.allItemAttributes[i]; - if (CGRectIntersectsRect(rect, attr.frame)) { - [attrs addObject:attr]; - } - } - - return [NSArray arrayWithArray:attrs]; -} - -- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds { - CGRect oldBounds = self.collectionView.bounds; - if (CGRectGetWidth(newBounds) != CGRectGetWidth(oldBounds)) { - return YES; - } - return NO; -} - -#pragma mark - Private Methods - -/** - * Find the shortest column. - * - * @return index for the shortest column - */ -- (NSUInteger)shortestColumnIndex { - __block NSUInteger index = 0; - __block CGFloat shortestHeight = MAXFLOAT; - - [self.columnHeights enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - CGFloat height = [obj floatValue]; - if (height < shortestHeight) { - shortestHeight = height; - index = idx; - } - }]; - - return index; -} - -/** - * Find the longest column. - * - * @return index for the longest column - */ -- (NSUInteger)longestColumnIndex { - __block NSUInteger index = 0; - __block CGFloat longestHeight = 0; - - [self.columnHeights enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - CGFloat height = [obj floatValue]; - if (height > longestHeight) { - longestHeight = height; - index = idx; - } - }]; - - return index; -} - -/** - * Find the index for the next column. - * - * @return index for the next column - */ -- (NSUInteger)nextColumnIndexForItem:(NSInteger)item { - NSUInteger index = 0; - switch (self.itemRenderDirection) { - case CHTCollectionViewWaterfallLayoutItemRenderDirectionShortestFirst: - index = [self shortestColumnIndex]; - break; - - case CHTCollectionViewWaterfallLayoutItemRenderDirectionLeftToRight: - index = (item % self.columnCount); - break; - - case CHTCollectionViewWaterfallLayoutItemRenderDirectionRightToLeft: - index = (self.columnCount - 1) - (item % self.columnCount); - break; - - default: - index = [self shortestColumnIndex]; - break; - } - return index; -} - -@end diff --git a/Ryff/Frameworks/SDWebImage/MKAnnotationView+WebCache.h b/Ryff/Frameworks/SDWebImage/MKAnnotationView+WebCache.h deleted file mode 100755 index e7f9903..0000000 --- a/Ryff/Frameworks/SDWebImage/MKAnnotationView+WebCache.h +++ /dev/null @@ -1,124 +0,0 @@ -// -// MKAnnotationView+WebCache.h -// SDWebImage -// -// Created by Olivier Poitrey on 14/03/12. -// Copyright (c) 2012 Dailymotion. All rights reserved. -// - -#import "MapKit/MapKit.h" -#import "SDWebImageManager.h" - -/** - * Integrates SDWebImage async downloading and caching of remote images with MKAnnotationView. - */ -@interface MKAnnotationView (WebCache) - -/** - * Get the current image URL. - * - * Note that because of the limitations of categories this property can get out of sync - * if you use sd_setImage: directly. - */ -- (NSURL *)sd_imageURL; - -/** - * Set the imageView `image` with an `url`. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - */ -- (void)sd_setImageWithURL:(NSURL *)url; - -/** - * Set the imageView `image` with an `url` and a placeholder. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param placeholder The image to be set initially, until the image request finishes. - * @see sd_setImageWithURL:placeholderImage:options: - */ -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder; - -/** - * Set the imageView `image` with an `url`, placeholder and custom options. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param placeholder The image to be set initially, until the image request finishes. - * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. - */ - -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; - -/** - * Set the imageView `image` with an `url`. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Set the imageView `image` with an `url`, placeholder. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param placeholder The image to be set initially, until the image request finishes. - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Set the imageView `image` with an `url`, placeholder and custom options. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param placeholder The image to be set initially, until the image request finishes. - * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Cancel the current download - */ -- (void)sd_cancelCurrentImageLoad; - -@end - - -@interface MKAnnotationView (WebCacheDeprecated) - -- (NSURL *)imageURL __deprecated_msg("Use `sd_imageURL`"); - -- (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`"); -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`"); -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:`"); - -- (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:completed:`"); -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:completed:`"); -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`"); - -- (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelCurrentImageLoad`"); - -@end diff --git a/Ryff/Frameworks/SDWebImage/MKAnnotationView+WebCache.m b/Ryff/Frameworks/SDWebImage/MKAnnotationView+WebCache.m deleted file mode 100755 index cc75da0..0000000 --- a/Ryff/Frameworks/SDWebImage/MKAnnotationView+WebCache.m +++ /dev/null @@ -1,126 +0,0 @@ -// -// MKAnnotationView+WebCache.m -// SDWebImage -// -// Created by Olivier Poitrey on 14/03/12. -// Copyright (c) 2012 Dailymotion. All rights reserved. -// - -#import "MKAnnotationView+WebCache.h" -#import "objc/runtime.h" -#import "UIView+WebCacheOperation.h" - -static char imageURLKey; - -@implementation MKAnnotationView (WebCache) - -- (NSURL *)sd_imageURL { - return objc_getAssociatedObject(self, &imageURLKey); -} - -- (void)sd_setImageWithURL:(NSURL *)url { - [self sd_setImageWithURL:url placeholderImage:nil options:0 completed:nil]; -} - -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder { - [self sd_setImageWithURL:url placeholderImage:placeholder options:0 completed:nil]; -} - -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { - [self sd_setImageWithURL:url placeholderImage:placeholder options:options completed:nil]; -} - -- (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock { - [self sd_setImageWithURL:url placeholderImage:nil options:0 completed:completedBlock]; -} - -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { - [self sd_setImageWithURL:url placeholderImage:placeholder options:0 completed:completedBlock]; -} - -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { - [self sd_cancelCurrentImageLoad]; - - objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC); - self.image = placeholder; - - if (url) { - __weak MKAnnotationView *wself = self; - id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { - if (!wself) return; - dispatch_main_sync_safe(^{ - __strong MKAnnotationView *sself = wself; - if (!sself) return; - if (image) { - sself.image = image; - } - if (completedBlock && finished) { - completedBlock(image, error, cacheType, url); - } - }); - }]; - [self sd_setImageLoadOperation:operation forKey:@"MKAnnotationViewImage"]; - } else { - dispatch_main_async_safe(^{ - NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; - if (completedBlock) { - completedBlock(nil, error, SDImageCacheTypeNone, url); - } - }); - } -} - -- (void)sd_cancelCurrentImageLoad { - [self sd_cancelImageLoadOperationWithKey:@"MKAnnotationViewImage"]; -} - -@end - - -@implementation MKAnnotationView (WebCacheDeprecated) - -- (NSURL *)imageURL { - return [self sd_imageURL]; -} - -- (void)setImageWithURL:(NSURL *)url { - [self sd_setImageWithURL:url placeholderImage:nil options:0 completed:nil]; -} - -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder { - [self sd_setImageWithURL:url placeholderImage:placeholder options:0 completed:nil]; -} - -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { - [self sd_setImageWithURL:url placeholderImage:placeholder options:options completed:nil]; -} - -- (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock { - [self sd_setImageWithURL:url placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType); - } - }]; -} - -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { - [self sd_setImageWithURL:url placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType); - } - }]; -} - -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { - [self sd_setImageWithURL:url placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType); - } - }]; -} - -- (void)cancelCurrentImageLoad { - [self sd_cancelCurrentImageLoad]; -} - -@end diff --git a/Ryff/Frameworks/SDWebImage/NSData+ImageContentType.h b/Ryff/Frameworks/SDWebImage/NSData+ImageContentType.h deleted file mode 100755 index 69c76dc..0000000 --- a/Ryff/Frameworks/SDWebImage/NSData+ImageContentType.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// Created by Fabrice Aneche on 06/01/14. -// Copyright (c) 2014 Dailymotion. All rights reserved. -// - -#import - -@interface NSData (ImageContentType) - -/** - * Compute the content type for an image data - * - * @param data the input data - * - * @return the content type as string (i.e. image/jpeg, image/gif) - */ -+ (NSString *)sd_contentTypeForImageData:(NSData *)data; - -@end - - -@interface NSData (ImageContentTypeDeprecated) - -+ (NSString *)contentTypeForImageData:(NSData *)data __deprecated_msg("Use `sd_contentTypeForImageData:`"); - -@end diff --git a/Ryff/Frameworks/SDWebImage/NSData+ImageContentType.m b/Ryff/Frameworks/SDWebImage/NSData+ImageContentType.m deleted file mode 100755 index 0941cfa..0000000 --- a/Ryff/Frameworks/SDWebImage/NSData+ImageContentType.m +++ /dev/null @@ -1,49 +0,0 @@ -// -// Created by Fabrice Aneche on 06/01/14. -// Copyright (c) 2014 Dailymotion. All rights reserved. -// - -#import "NSData+ImageContentType.h" - - -@implementation NSData (ImageContentType) - -+ (NSString *)sd_contentTypeForImageData:(NSData *)data { - uint8_t c; - [data getBytes:&c length:1]; - switch (c) { - case 0xFF: - return @"image/jpeg"; - case 0x89: - return @"image/png"; - case 0x47: - return @"image/gif"; - case 0x49: - case 0x4D: - return @"image/tiff"; - case 0x52: - // R as RIFF for WEBP - if ([data length] < 12) { - return nil; - } - - NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding]; - if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) { - return @"image/webp"; - } - - return nil; - } - return nil; -} - -@end - - -@implementation NSData (ImageContentTypeDeprecated) - -+ (NSString *)contentTypeForImageData:(NSData *)data { - return [self sd_contentTypeForImageData:data]; -} - -@end diff --git a/Ryff/Frameworks/SDWebImage/SDImageCache.h b/Ryff/Frameworks/SDWebImage/SDImageCache.h deleted file mode 100755 index 62894a1..0000000 --- a/Ryff/Frameworks/SDWebImage/SDImageCache.h +++ /dev/null @@ -1,241 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import -#import "SDWebImageCompat.h" - -typedef NS_ENUM(NSInteger, SDImageCacheType) { - /** - * The image wasn't available the SDWebImage caches, but was downloaded from the web. - */ - SDImageCacheTypeNone, - /** - * The image was obtained from the disk cache. - */ - SDImageCacheTypeDisk, - /** - * The image was obtained from the memory cache. - */ - SDImageCacheTypeMemory -}; - -typedef void(^SDWebImageQueryCompletedBlock)(UIImage *image, SDImageCacheType cacheType); - -typedef void(^SDWebImageCheckCacheCompletionBlock)(BOOL isInCache); - -typedef void(^SDWebImageCalculateSizeBlock)(NSUInteger fileCount, NSUInteger totalSize); - -/** - * SDImageCache maintains a memory cache and an optional disk cache. Disk cache write operations are performed - * asynchronous so it doesn’t add unnecessary latency to the UI. - */ -@interface SDImageCache : NSObject - -/** - * The maximum "total cost" of the in-memory image cache. The cost function is the number of pixels held in memory. - */ -@property (assign, nonatomic) NSUInteger maxMemoryCost; - -/** - * The maximum length of time to keep an image in the cache, in seconds - */ -@property (assign, nonatomic) NSInteger maxCacheAge; - -/** - * The maximum size of the cache, in bytes. - */ -@property (assign, nonatomic) NSUInteger maxCacheSize; - -/** - * Returns global shared cache instance - * - * @return SDImageCache global instance - */ -+ (SDImageCache *)sharedImageCache; - -/** - * Init a new cache store with a specific namespace - * - * @param ns The namespace to use for this cache store - */ -- (id)initWithNamespace:(NSString *)ns; - -/** - * Add a read-only cache path to search for images pre-cached by SDImageCache - * Useful if you want to bundle pre-loaded images with your app - * - * @param path The path to use for this read-only cache path - */ -- (void)addReadOnlyCachePath:(NSString *)path; - -/** - * Store an image into memory and disk cache at the given key. - * - * @param image The image to store - * @param key The unique image cache key, usually it's image absolute URL - */ -- (void)storeImage:(UIImage *)image forKey:(NSString *)key; - -/** - * Store an image into memory and optionally disk cache at the given key. - * - * @param image The image to store - * @param key The unique image cache key, usually it's image absolute URL - * @param toDisk Store the image to disk cache if YES - */ -- (void)storeImage:(UIImage *)image forKey:(NSString *)key toDisk:(BOOL)toDisk; - -/** - * Store an image into memory and optionally disk cache at the given key. - * - * @param image The image to store - * @param recalculate BOOL indicates if imageData can be used or a new data should be constructed from the UIImage - * @param imageData The image data as returned by the server, this representation will be used for disk storage - * instead of converting the given image object into a storable/compressed image format in order - * to save quality and CPU - * @param key The unique image cache key, usually it's image absolute URL - * @param toDisk Store the image to disk cache if YES - */ -- (void)storeImage:(UIImage *)image recalculateFromImage:(BOOL)recalculate imageData:(NSData *)imageData forKey:(NSString *)key toDisk:(BOOL)toDisk; - -/** - * Query the disk cache asynchronously. - * - * @param key The unique key used to store the wanted image - */ -- (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(SDWebImageQueryCompletedBlock)doneBlock; - -/** - * Query the memory cache synchronously. - * - * @param key The unique key used to store the wanted image - */ -- (UIImage *)imageFromMemoryCacheForKey:(NSString *)key; - -/** - * Query the disk cache synchronously after checking the memory cache. - * - * @param key The unique key used to store the wanted image - */ -- (UIImage *)imageFromDiskCacheForKey:(NSString *)key; - -/** - * Remove the image from memory and disk cache synchronously - * - * @param key The unique image cache key - */ -- (void)removeImageForKey:(NSString *)key; - - -/** - * Remove the image from memory and disk cache synchronously - * - * @param key The unique image cache key - * @param completion An block that should be executed after the image has been removed (optional) - */ -- (void)removeImageForKey:(NSString *)key withCompletion:(SDWebImageNoParamsBlock)completion; - -/** - * Remove the image from memory and optionally disk cache synchronously - * - * @param key The unique image cache key - * @param fromDisk Also remove cache entry from disk if YES - */ -- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk; - -/** - * Remove the image from memory and optionally disk cache synchronously - * - * @param key The unique image cache key - * @param fromDisk Also remove cache entry from disk if YES - * @param completion An block that should be executed after the image has been removed (optional) - */ -- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk withCompletion:(SDWebImageNoParamsBlock)completion; - -/** - * Clear all memory cached images - */ -- (void)clearMemory; - -/** - * Clear all disk cached images. Non-blocking method - returns immediately. - * @param completion An block that should be executed after cache expiration completes (optional) - */ -- (void)clearDiskOnCompletion:(SDWebImageNoParamsBlock)completion; - -/** - * Clear all disk cached images - * @see clearDiskOnCompletion: - */ -- (void)clearDisk; - -/** - * Remove all expired cached image from disk. Non-blocking method - returns immediately. - * @param completionBlock An block that should be executed after cache expiration completes (optional) - */ -- (void)cleanDiskWithCompletionBlock:(SDWebImageNoParamsBlock)completionBlock; - -/** - * Remove all expired cached image from disk - * @see cleanDiskWithCompletionBlock: - */ -- (void)cleanDisk; - -/** - * Get the size used by the disk cache - */ -- (NSUInteger)getSize; - -/** - * Get the number of images in the disk cache - */ -- (NSUInteger)getDiskCount; - -/** - * Asynchronously calculate the disk cache's size. - */ -- (void)calculateSizeWithCompletionBlock:(SDWebImageCalculateSizeBlock)completionBlock; - -/** - * Async check if image exists in disk cache already (does not load the image) - * - * @param key the key describing the url - * @param completionBlock the block to be executed when the check is done. - * @note the completion block will be always executed on the main queue - */ -- (void)diskImageExistsWithKey:(NSString *)key completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; - -/** - * Check if image exists in disk cache already (does not load the image) - * - * @param key the key describing the url - * - * @return YES if an image exists for the given key - */ -- (BOOL)diskImageExistsWithKey:(NSString *)key; - -/** - * Get the cache path for a certain key (needs the cache path root folder) - * - * @param key the key (can be obtained from url using cacheKeyForURL) - * @param path the cach path root folder - * - * @return the cache path - */ -- (NSString *)cachePathForKey:(NSString *)key inPath:(NSString *)path; - -/** - * Get the default cache path for a certain key - * - * @param key the key (can be obtained from url using cacheKeyForURL) - * - * @return the default cache path - */ -- (NSString *)defaultCachePathForKey:(NSString *)key; - -@end diff --git a/Ryff/Frameworks/SDWebImage/SDImageCache.m b/Ryff/Frameworks/SDWebImage/SDImageCache.m deleted file mode 100755 index 59c3471..0000000 --- a/Ryff/Frameworks/SDWebImage/SDImageCache.m +++ /dev/null @@ -1,534 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import "SDImageCache.h" -#import "SDWebImageDecoder.h" -#import "UIImage+MultiFormat.h" -#import - -static const NSInteger kDefaultCacheMaxCacheAge = 60 * 60 * 24 * 7; // 1 week -// PNG signature bytes and data (below) -static unsigned char kPNGSignatureBytes[8] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}; -static NSData *kPNGSignatureData = nil; - -BOOL ImageDataHasPNGPreffix(NSData *data); - -BOOL ImageDataHasPNGPreffix(NSData *data) { - NSUInteger pngSignatureLength = [kPNGSignatureData length]; - if ([data length] >= pngSignatureLength) { - if ([[data subdataWithRange:NSMakeRange(0, pngSignatureLength)] isEqualToData:kPNGSignatureData]) { - return YES; - } - } - - return NO; -} - -@interface SDImageCache () - -@property (strong, nonatomic) NSCache *memCache; -@property (strong, nonatomic) NSString *diskCachePath; -@property (strong, nonatomic) NSMutableArray *customPaths; -@property (SDDispatchQueueSetterSementics, nonatomic) dispatch_queue_t ioQueue; - -@end - - -@implementation SDImageCache { - NSFileManager *_fileManager; -} - -+ (SDImageCache *)sharedImageCache { - static dispatch_once_t once; - static id instance; - dispatch_once(&once, ^{ - instance = [self new]; - kPNGSignatureData = [NSData dataWithBytes:kPNGSignatureBytes length:8]; - }); - return instance; -} - -- (id)init { - return [self initWithNamespace:@"default"]; -} - -- (id)initWithNamespace:(NSString *)ns { - if ((self = [super init])) { - NSString *fullNamespace = [@"com.hackemist.SDWebImageCache." stringByAppendingString:ns]; - - // Create IO serial queue - _ioQueue = dispatch_queue_create("com.hackemist.SDWebImageCache", DISPATCH_QUEUE_SERIAL); - - // Init default values - _maxCacheAge = kDefaultCacheMaxCacheAge; - - // Init the memory cache - _memCache = [[NSCache alloc] init]; - _memCache.name = fullNamespace; - - // Init the disk cache - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); - _diskCachePath = [paths[0] stringByAppendingPathComponent:fullNamespace]; - - dispatch_sync(_ioQueue, ^{ - _fileManager = [NSFileManager new]; - }); - -#if TARGET_OS_IPHONE - // Subscribe to app events - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(clearMemory) - name:UIApplicationDidReceiveMemoryWarningNotification - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(cleanDisk) - name:UIApplicationWillTerminateNotification - object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(backgroundCleanDisk) - name:UIApplicationDidEnterBackgroundNotification - object:nil]; -#endif - } - - return self; -} - -- (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; - SDDispatchQueueRelease(_ioQueue); -} - -- (void)addReadOnlyCachePath:(NSString *)path { - if (!self.customPaths) { - self.customPaths = [NSMutableArray new]; - } - - if (![self.customPaths containsObject:path]) { - [self.customPaths addObject:path]; - } -} - -- (NSString *)cachePathForKey:(NSString *)key inPath:(NSString *)path { - NSString *filename = [self cachedFileNameForKey:key]; - return [path stringByAppendingPathComponent:filename]; -} - -- (NSString *)defaultCachePathForKey:(NSString *)key { - return [self cachePathForKey:key inPath:self.diskCachePath]; -} - -#pragma mark SDImageCache (private) - -- (NSString *)cachedFileNameForKey:(NSString *)key { - const char *str = [key UTF8String]; - if (str == NULL) { - str = ""; - } - unsigned char r[CC_MD5_DIGEST_LENGTH]; - CC_MD5(str, (CC_LONG)strlen(str), r); - NSString *filename = [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], r[9], r[10], r[11], r[12], r[13], r[14], r[15]]; - - return filename; -} - -#pragma mark ImageCache - -- (void)storeImage:(UIImage *)image recalculateFromImage:(BOOL)recalculate imageData:(NSData *)imageData forKey:(NSString *)key toDisk:(BOOL)toDisk { - if (!image || !key) { - return; - } - - [self.memCache setObject:image forKey:key cost:image.size.height * image.size.width * image.scale]; - - if (toDisk) { - dispatch_async(self.ioQueue, ^{ - NSData *data = imageData; - - if (image && (recalculate || !data)) { -#if TARGET_OS_IPHONE - // We need to determine if the image is a PNG or a JPEG - // PNGs are easier to detect because they have a unique signature (http://www.w3.org/TR/PNG-Structure.html) - // The first eight bytes of a PNG file always contain the following (decimal) values: - // 137 80 78 71 13 10 26 10 - - // We assume the image is PNG, in case the imageData is nil (i.e. if trying to save a UIImage directly), - // we will consider it PNG to avoid loosing the transparency - BOOL imageIsPng = YES; - - // But if we have an image data, we will look at the preffix - if ([imageData length] >= [kPNGSignatureData length]) { - imageIsPng = ImageDataHasPNGPreffix(imageData); - } - - if (imageIsPng) { - data = UIImagePNGRepresentation(image); - } - else { - data = UIImageJPEGRepresentation(image, (CGFloat)1.0); - } -#else - data = [NSBitmapImageRep representationOfImageRepsInArray:image.representations usingType: NSJPEGFileType properties:nil]; -#endif - } - - if (data) { - if (![_fileManager fileExistsAtPath:_diskCachePath]) { - [_fileManager createDirectoryAtPath:_diskCachePath withIntermediateDirectories:YES attributes:nil error:NULL]; - } - - [_fileManager createFileAtPath:[self defaultCachePathForKey:key] contents:data attributes:nil]; - } - }); - } -} - -- (void)storeImage:(UIImage *)image forKey:(NSString *)key { - [self storeImage:image recalculateFromImage:YES imageData:nil forKey:key toDisk:YES]; -} - -- (void)storeImage:(UIImage *)image forKey:(NSString *)key toDisk:(BOOL)toDisk { - [self storeImage:image recalculateFromImage:YES imageData:nil forKey:key toDisk:toDisk]; -} - -- (BOOL)diskImageExistsWithKey:(NSString *)key { - BOOL exists = NO; - - // this is an exception to access the filemanager on another queue than ioQueue, but we are using the shared instance - // from apple docs on NSFileManager: The methods of the shared NSFileManager object can be called from multiple threads safely. - exists = [[NSFileManager defaultManager] fileExistsAtPath:[self defaultCachePathForKey:key]]; - - return exists; -} - -- (void)diskImageExistsWithKey:(NSString *)key completion:(SDWebImageCheckCacheCompletionBlock)completionBlock { - dispatch_async(_ioQueue, ^{ - BOOL exists = [_fileManager fileExistsAtPath:[self defaultCachePathForKey:key]]; - if (completionBlock) { - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(exists); - }); - } - }); -} - -- (UIImage *)imageFromMemoryCacheForKey:(NSString *)key { - return [self.memCache objectForKey:key]; -} - -- (UIImage *)imageFromDiskCacheForKey:(NSString *)key { - // First check the in-memory cache... - UIImage *image = [self imageFromMemoryCacheForKey:key]; - if (image) { - return image; - } - - // Second check the disk cache... - UIImage *diskImage = [self diskImageForKey:key]; - if (diskImage) { - CGFloat cost = diskImage.size.height * diskImage.size.width * diskImage.scale; - [self.memCache setObject:diskImage forKey:key cost:cost]; - } - - return diskImage; -} - -- (NSData *)diskImageDataBySearchingAllPathsForKey:(NSString *)key { - NSString *defaultPath = [self defaultCachePathForKey:key]; - NSData *data = [NSData dataWithContentsOfFile:defaultPath]; - if (data) { - return data; - } - - for (NSString *path in self.customPaths) { - NSString *filePath = [self cachePathForKey:key inPath:path]; - NSData *imageData = [NSData dataWithContentsOfFile:filePath]; - if (imageData) { - return imageData; - } - } - - return nil; -} - -- (UIImage *)diskImageForKey:(NSString *)key { - NSData *data = [self diskImageDataBySearchingAllPathsForKey:key]; - if (data) { - UIImage *image = [UIImage sd_imageWithData:data]; - image = [self scaledImageForKey:key image:image]; - image = [UIImage decodedImageWithImage:image]; - return image; - } - else { - return nil; - } -} - -- (UIImage *)scaledImageForKey:(NSString *)key image:(UIImage *)image { - return SDScaledImageForKey(key, image); -} - -- (NSOperation *)queryDiskCacheForKey:(NSString *)key done:(SDWebImageQueryCompletedBlock)doneBlock { - if (!doneBlock) { - return nil; - } - - if (!key) { - doneBlock(nil, SDImageCacheTypeNone); - return nil; - } - - // First check the in-memory cache... - UIImage *image = [self imageFromMemoryCacheForKey:key]; - if (image) { - doneBlock(image, SDImageCacheTypeMemory); - return nil; - } - - NSOperation *operation = [NSOperation new]; - dispatch_async(self.ioQueue, ^{ - if (operation.isCancelled) { - return; - } - - @autoreleasepool { - UIImage *diskImage = [self diskImageForKey:key]; - if (diskImage) { - CGFloat cost = diskImage.size.height * diskImage.size.width * diskImage.scale; - [self.memCache setObject:diskImage forKey:key cost:cost]; - } - - dispatch_async(dispatch_get_main_queue(), ^{ - doneBlock(diskImage, SDImageCacheTypeDisk); - }); - } - }); - - return operation; -} - -- (void)removeImageForKey:(NSString *)key { - [self removeImageForKey:key withCompletion:nil]; -} - -- (void)removeImageForKey:(NSString *)key withCompletion:(SDWebImageNoParamsBlock)completion { - [self removeImageForKey:key fromDisk:YES withCompletion:completion]; -} - -- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk { - [self removeImageForKey:key fromDisk:fromDisk withCompletion:nil]; -} - -- (void)removeImageForKey:(NSString *)key fromDisk:(BOOL)fromDisk withCompletion:(SDWebImageNoParamsBlock)completion { - - if (key == nil) { - return; - } - - [self.memCache removeObjectForKey:key]; - - if (fromDisk) { - dispatch_async(self.ioQueue, ^{ - [_fileManager removeItemAtPath:[self defaultCachePathForKey:key] error:nil]; - - if (completion) { - dispatch_async(dispatch_get_main_queue(), ^{ - completion(); - }); - } - }); - } else if (completion){ - completion(); - } - -} - -- (void)setMaxMemoryCost:(NSUInteger)maxMemoryCost { - self.memCache.totalCostLimit = maxMemoryCost; -} - -- (NSUInteger)maxMemoryCost { - return self.memCache.totalCostLimit; -} - -- (void)clearMemory { - [self.memCache removeAllObjects]; -} - -- (void)clearDisk { - [self clearDiskOnCompletion:nil]; -} - -- (void)clearDiskOnCompletion:(SDWebImageNoParamsBlock)completion -{ - dispatch_async(self.ioQueue, ^{ - [_fileManager removeItemAtPath:self.diskCachePath error:nil]; - [_fileManager createDirectoryAtPath:self.diskCachePath - withIntermediateDirectories:YES - attributes:nil - error:NULL]; - - if (completion) { - dispatch_async(dispatch_get_main_queue(), ^{ - completion(); - }); - } - }); -} - -- (void)cleanDisk { - [self cleanDiskWithCompletionBlock:nil]; -} - -- (void)cleanDiskWithCompletionBlock:(SDWebImageNoParamsBlock)completionBlock { - dispatch_async(self.ioQueue, ^{ - NSURL *diskCacheURL = [NSURL fileURLWithPath:self.diskCachePath isDirectory:YES]; - NSArray *resourceKeys = @[NSURLIsDirectoryKey, NSURLContentModificationDateKey, NSURLTotalFileAllocatedSizeKey]; - - // This enumerator prefetches useful properties for our cache files. - NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtURL:diskCacheURL - includingPropertiesForKeys:resourceKeys - options:NSDirectoryEnumerationSkipsHiddenFiles - errorHandler:NULL]; - - NSDate *expirationDate = [NSDate dateWithTimeIntervalSinceNow:-self.maxCacheAge]; - NSMutableDictionary *cacheFiles = [NSMutableDictionary dictionary]; - NSUInteger currentCacheSize = 0; - - // Enumerate all of the files in the cache directory. This loop has two purposes: - // - // 1. Removing files that are older than the expiration date. - // 2. Storing file attributes for the size-based cleanup pass. - NSMutableArray *urlsToDelete = [[NSMutableArray alloc] init]; - for (NSURL *fileURL in fileEnumerator) { - NSDictionary *resourceValues = [fileURL resourceValuesForKeys:resourceKeys error:NULL]; - - // Skip directories. - if ([resourceValues[NSURLIsDirectoryKey] boolValue]) { - continue; - } - - // Remove files that are older than the expiration date; - NSDate *modificationDate = resourceValues[NSURLContentModificationDateKey]; - if ([[modificationDate laterDate:expirationDate] isEqualToDate:expirationDate]) { - [urlsToDelete addObject:fileURL]; - continue; - } - - // Store a reference to this file and account for its total size. - NSNumber *totalAllocatedSize = resourceValues[NSURLTotalFileAllocatedSizeKey]; - currentCacheSize += [totalAllocatedSize unsignedIntegerValue]; - [cacheFiles setObject:resourceValues forKey:fileURL]; - } - - for (NSURL *fileURL in urlsToDelete) { - [_fileManager removeItemAtURL:fileURL error:nil]; - } - - // If our remaining disk cache exceeds a configured maximum size, perform a second - // size-based cleanup pass. We delete the oldest files first. - if (self.maxCacheSize > 0 && currentCacheSize > self.maxCacheSize) { - // Target half of our maximum cache size for this cleanup pass. - const NSUInteger desiredCacheSize = self.maxCacheSize / 2; - - // Sort the remaining cache files by their last modification time (oldest first). - NSArray *sortedFiles = [cacheFiles keysSortedByValueWithOptions:NSSortConcurrent - usingComparator:^NSComparisonResult(id obj1, id obj2) { - return [obj1[NSURLContentModificationDateKey] compare:obj2[NSURLContentModificationDateKey]]; - }]; - - // Delete files until we fall below our desired cache size. - for (NSURL *fileURL in sortedFiles) { - if ([_fileManager removeItemAtURL:fileURL error:nil]) { - NSDictionary *resourceValues = cacheFiles[fileURL]; - NSNumber *totalAllocatedSize = resourceValues[NSURLTotalFileAllocatedSizeKey]; - currentCacheSize -= [totalAllocatedSize unsignedIntegerValue]; - - if (currentCacheSize < desiredCacheSize) { - break; - } - } - } - } - if (completionBlock) { - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(); - }); - } - }); -} - -- (void)backgroundCleanDisk { - UIApplication *application = [UIApplication sharedApplication]; - __block UIBackgroundTaskIdentifier bgTask = [application beginBackgroundTaskWithExpirationHandler:^{ - // Clean up any unfinished task business by marking where you - // stopped or ending the task outright. - [application endBackgroundTask:bgTask]; - bgTask = UIBackgroundTaskInvalid; - }]; - - // Start the long-running task and return immediately. - [self cleanDiskWithCompletionBlock:^{ - [application endBackgroundTask:bgTask]; - bgTask = UIBackgroundTaskInvalid; - }]; -} - -- (NSUInteger)getSize { - __block NSUInteger size = 0; - dispatch_sync(self.ioQueue, ^{ - NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtPath:self.diskCachePath]; - for (NSString *fileName in fileEnumerator) { - NSString *filePath = [self.diskCachePath stringByAppendingPathComponent:fileName]; - NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:filePath error:nil]; - size += [attrs fileSize]; - } - }); - return size; -} - -- (NSUInteger)getDiskCount { - __block NSUInteger count = 0; - dispatch_sync(self.ioQueue, ^{ - NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtPath:self.diskCachePath]; - count = [[fileEnumerator allObjects] count]; - }); - return count; -} - -- (void)calculateSizeWithCompletionBlock:(SDWebImageCalculateSizeBlock)completionBlock { - NSURL *diskCacheURL = [NSURL fileURLWithPath:self.diskCachePath isDirectory:YES]; - - dispatch_async(self.ioQueue, ^{ - NSUInteger fileCount = 0; - NSUInteger totalSize = 0; - - NSDirectoryEnumerator *fileEnumerator = [_fileManager enumeratorAtURL:diskCacheURL - includingPropertiesForKeys:@[NSFileSize] - options:NSDirectoryEnumerationSkipsHiddenFiles - errorHandler:NULL]; - - for (NSURL *fileURL in fileEnumerator) { - NSNumber *fileSize; - [fileURL getResourceValue:&fileSize forKey:NSURLFileSizeKey error:NULL]; - totalSize += [fileSize unsignedIntegerValue]; - fileCount += 1; - } - - if (completionBlock) { - dispatch_async(dispatch_get_main_queue(), ^{ - completionBlock(fileCount, totalSize); - }); - } - }); -} - -@end diff --git a/Ryff/Frameworks/SDWebImage/SDWebImageCompat.h b/Ryff/Frameworks/SDWebImage/SDWebImageCompat.h deleted file mode 100755 index a0555fd..0000000 --- a/Ryff/Frameworks/SDWebImage/SDWebImageCompat.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * (c) Jamie Pinkham - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import - -#ifdef __OBJC_GC__ -#error SDWebImage does not support Objective-C Garbage Collection -#endif - -#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 -#error SDWebImage doesn't support Deployement Target version < 5.0 -#endif - -#if !TARGET_OS_IPHONE -#import -#ifndef UIImage -#define UIImage NSImage -#endif -#ifndef UIImageView -#define UIImageView NSImageView -#endif -#else - -#import - -#endif - -#ifndef NS_ENUM -#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type -#endif - -#ifndef NS_OPTIONS -#define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type -#endif - -#if OS_OBJECT_USE_OBJC - #undef SDDispatchQueueRelease - #undef SDDispatchQueueSetterSementics - #define SDDispatchQueueRelease(q) - #define SDDispatchQueueSetterSementics strong -#else -#undef SDDispatchQueueRelease -#undef SDDispatchQueueSetterSementics -#define SDDispatchQueueRelease(q) (dispatch_release(q)) -#define SDDispatchQueueSetterSementics assign -#endif - -extern UIImage *SDScaledImageForKey(NSString *key, UIImage *image); - -typedef void(^SDWebImageNoParamsBlock)(); - -#define dispatch_main_sync_safe(block)\ - if ([NSThread isMainThread]) {\ - block();\ - } else {\ - dispatch_sync(dispatch_get_main_queue(), block);\ - } - -#define dispatch_main_async_safe(block)\ - if ([NSThread isMainThread]) {\ - block();\ - } else {\ - dispatch_async(dispatch_get_main_queue(), block);\ - } diff --git a/Ryff/Frameworks/SDWebImage/SDWebImageCompat.m b/Ryff/Frameworks/SDWebImage/SDWebImageCompat.m deleted file mode 100755 index 8c7d345..0000000 --- a/Ryff/Frameworks/SDWebImage/SDWebImageCompat.m +++ /dev/null @@ -1,45 +0,0 @@ -// -// SDWebImageCompat.m -// SDWebImage -// -// Created by Olivier Poitrey on 11/12/12. -// Copyright (c) 2012 Dailymotion. All rights reserved. -// - -#import "SDWebImageCompat.h" - -#if !__has_feature(objc_arc) -#error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag -#endif - -inline UIImage *SDScaledImageForKey(NSString *key, UIImage *image) { - if (!image) { - return nil; - } - - if ([image.images count] > 0) { - NSMutableArray *scaledImages = [NSMutableArray array]; - - for (UIImage *tempImage in image.images) { - [scaledImages addObject:SDScaledImageForKey(key, tempImage)]; - } - - return [UIImage animatedImageWithImages:scaledImages duration:image.duration]; - } - else { - if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { - CGFloat scale = 1.0; - if (key.length >= 8) { - // Search @2x. at the end of the string, before a 3 to 4 extension length (only if key len is 8 or more @2x. + 4 len ext) - NSRange range = [key rangeOfString:@"@2x." options:0 range:NSMakeRange(key.length - 8, 5)]; - if (range.location != NSNotFound) { - scale = 2.0; - } - } - - UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; - image = scaledImage; - } - return image; - } -} diff --git a/Ryff/Frameworks/SDWebImage/SDWebImageDecoder.h b/Ryff/Frameworks/SDWebImage/SDWebImageDecoder.h deleted file mode 100755 index 0176a7b..0000000 --- a/Ryff/Frameworks/SDWebImage/SDWebImageDecoder.h +++ /dev/null @@ -1,18 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * Created by james on 9/28/11. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import -#import "SDWebImageCompat.h" - -@interface UIImage (ForceDecode) - -+ (UIImage *)decodedImageWithImage:(UIImage *)image; - -@end diff --git a/Ryff/Frameworks/SDWebImage/SDWebImageDecoder.m b/Ryff/Frameworks/SDWebImage/SDWebImageDecoder.m deleted file mode 100755 index 79ddb30..0000000 --- a/Ryff/Frameworks/SDWebImage/SDWebImageDecoder.m +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * Created by james on 9/28/11. - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import "SDWebImageDecoder.h" - -@implementation UIImage (ForceDecode) - -+ (UIImage *)decodedImageWithImage:(UIImage *)image { - if (image.images) { - // Do not decode animated images - return image; - } - - CGImageRef imageRef = image.CGImage; - CGSize imageSize = CGSizeMake(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)); - CGRect imageRect = (CGRect){.origin = CGPointZero, .size = imageSize}; - - CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); - - int infoMask = (bitmapInfo & kCGBitmapAlphaInfoMask); - BOOL anyNonAlpha = (infoMask == kCGImageAlphaNone || - infoMask == kCGImageAlphaNoneSkipFirst || - infoMask == kCGImageAlphaNoneSkipLast); - - // CGBitmapContextCreate doesn't support kCGImageAlphaNone with RGB. - // https://developer.apple.com/library/mac/#qa/qa1037/_index.html - if (infoMask == kCGImageAlphaNone && CGColorSpaceGetNumberOfComponents(colorSpace) > 1) { - // Unset the old alpha info. - bitmapInfo &= ~kCGBitmapAlphaInfoMask; - - // Set noneSkipFirst. - bitmapInfo |= kCGImageAlphaNoneSkipFirst; - } - // Some PNGs tell us they have alpha but only 3 components. Odd. - else if (!anyNonAlpha && CGColorSpaceGetNumberOfComponents(colorSpace) == 3) { - // Unset the old alpha info. - bitmapInfo &= ~kCGBitmapAlphaInfoMask; - bitmapInfo |= kCGImageAlphaPremultipliedFirst; - } - - // It calculates the bytes-per-row based on the bitsPerComponent and width arguments. - CGContextRef context = CGBitmapContextCreate(NULL, - imageSize.width, - imageSize.height, - CGImageGetBitsPerComponent(imageRef), - 0, - colorSpace, - bitmapInfo); - CGColorSpaceRelease(colorSpace); - - // If failed, return undecompressed image - if (!context) return image; - - CGContextDrawImage(context, imageRect, imageRef); - CGImageRef decompressedImageRef = CGBitmapContextCreateImage(context); - - CGContextRelease(context); - - UIImage *decompressedImage = [UIImage imageWithCGImage:decompressedImageRef scale:image.scale orientation:image.imageOrientation]; - CGImageRelease(decompressedImageRef); - return decompressedImage; -} - -@end diff --git a/Ryff/Frameworks/SDWebImage/SDWebImageDownloader.h b/Ryff/Frameworks/SDWebImage/SDWebImageDownloader.h deleted file mode 100755 index 008231a..0000000 --- a/Ryff/Frameworks/SDWebImage/SDWebImageDownloader.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import -#import "SDWebImageCompat.h" -#import "SDWebImageOperation.h" - -typedef NS_OPTIONS(NSUInteger, SDWebImageDownloaderOptions) { - SDWebImageDownloaderLowPriority = 1 << 0, - SDWebImageDownloaderProgressiveDownload = 1 << 1, - - /** - * By default, request prevent the of NSURLCache. With this flag, NSURLCache - * is used with default policies. - */ - SDWebImageDownloaderUseNSURLCache = 1 << 2, - - /** - * Call completion block with nil image/imageData if the image was read from NSURLCache - * (to be combined with `SDWebImageDownloaderUseNSURLCache`). - */ - - SDWebImageDownloaderIgnoreCachedResponse = 1 << 3, - /** - * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for - * extra time in background to let the request finish. If the background task expires the operation will be cancelled. - */ - - SDWebImageDownloaderContinueInBackground = 1 << 4, - - /** - * Handles cookies stored in NSHTTPCookieStore by setting - * NSMutableURLRequest.HTTPShouldHandleCookies = YES; - */ - SDWebImageDownloaderHandleCookies = 1 << 5, - - /** - * Enable to allow untrusted SSL ceriticates. - * Useful for testing purposes. Use with caution in production. - */ - SDWebImageDownloaderAllowInvalidSSLCertificates = 1 << 6, - - /** - * Put the image in the high priority queue. - */ - SDWebImageDownloaderHighPriority = 1 << 7, - - -}; - -typedef NS_ENUM(NSInteger, SDWebImageDownloaderExecutionOrder) { - /** - * Default value. All download operations will execute in queue style (first-in-first-out). - */ - SDWebImageDownloaderFIFOExecutionOrder, - - /** - * All download operations will execute in stack style (last-in-first-out). - */ - SDWebImageDownloaderLIFOExecutionOrder -}; - -extern NSString *const SDWebImageDownloadStartNotification; -extern NSString *const SDWebImageDownloadStopNotification; - -typedef void(^SDWebImageDownloaderProgressBlock)(NSInteger receivedSize, NSInteger expectedSize); - -typedef void(^SDWebImageDownloaderCompletedBlock)(UIImage *image, NSData *data, NSError *error, BOOL finished); - -typedef NSDictionary *(^SDWebImageDownloaderHeadersFilterBlock)(NSURL *url, NSDictionary *headers); - -/** - * Asynchronous downloader dedicated and optimized for image loading. - */ -@interface SDWebImageDownloader : NSObject - -@property (assign, nonatomic) NSInteger maxConcurrentDownloads; - -/** - * Shows the current amount of downloads that still need to be downloaded - */ - -@property (readonly, nonatomic) NSUInteger currentDownloadCount; - - -/** - * The timeout value (in seconds) for the download operation. Default: 15.0. - */ -@property (assign, nonatomic) NSTimeInterval downloadTimeout; - - -/** - * Changes download operations execution order. Default value is `SDWebImageDownloaderFIFOExecutionOrder`. - */ -@property (assign, nonatomic) SDWebImageDownloaderExecutionOrder executionOrder; - -/** - * Singleton method, returns the shared instance - * - * @return global shared instance of downloader class - */ -+ (SDWebImageDownloader *)sharedDownloader; - -/** - * Set username - */ -@property (strong, nonatomic) NSString *username; - -/** - * Set password - */ -@property (strong, nonatomic) NSString *password; - -/** - * Set filter to pick headers for downloading image HTTP request. - * - * This block will be invoked for each downloading image request, returned - * NSDictionary will be used as headers in corresponding HTTP request. - */ -@property (nonatomic, copy) SDWebImageDownloaderHeadersFilterBlock headersFilter; - -/** - * Set a value for a HTTP header to be appended to each download HTTP request. - * - * @param value The value for the header field. Use `nil` value to remove the header. - * @param field The name of the header field to set. - */ -- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field; - -/** - * Returns the value of the specified HTTP header field. - * - * @return The value associated with the header field field, or `nil` if there is no corresponding header field. - */ -- (NSString *)valueForHTTPHeaderField:(NSString *)field; - -/** - * Creates a SDWebImageDownloader async downloader instance with a given URL - * - * The delegate will be informed when the image is finish downloaded or an error has happen. - * - * @see SDWebImageDownloaderDelegate - * - * @param url The URL to the image to download - * @param options The options to be used for this download - * @param progressBlock A block called repeatedly while the image is downloading - * @param completedBlock A block called once the download is completed. - * If the download succeeded, the image parameter is set, in case of error, - * error parameter is set with the error. The last parameter is always YES - * if SDWebImageDownloaderProgressiveDownload isn't use. With the - * SDWebImageDownloaderProgressiveDownload option, this block is called - * repeatedly with the partial image object and the finished argument set to NO - * before to be called a last time with the full image and finished argument - * set to YES. In case of error, the finished argument is always YES. - * - * @return A cancellable SDWebImageOperation - */ -- (id )downloadImageWithURL:(NSURL *)url - options:(SDWebImageDownloaderOptions)options - progress:(SDWebImageDownloaderProgressBlock)progressBlock - completed:(SDWebImageDownloaderCompletedBlock)completedBlock; - -/** - * Sets the download queue suspension state - */ -- (void)setSuspended:(BOOL)suspended; - -@end diff --git a/Ryff/Frameworks/SDWebImage/SDWebImageDownloader.m b/Ryff/Frameworks/SDWebImage/SDWebImageDownloader.m deleted file mode 100755 index 60914db..0000000 --- a/Ryff/Frameworks/SDWebImage/SDWebImageDownloader.m +++ /dev/null @@ -1,225 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import "SDWebImageDownloader.h" -#import "SDWebImageDownloaderOperation.h" -#import - -NSString *const SDWebImageDownloadStartNotification = @"SDWebImageDownloadStartNotification"; -NSString *const SDWebImageDownloadStopNotification = @"SDWebImageDownloadStopNotification"; - -static NSString *const kProgressCallbackKey = @"progress"; -static NSString *const kCompletedCallbackKey = @"completed"; - -@interface SDWebImageDownloader () - -@property (strong, nonatomic) NSOperationQueue *downloadQueue; -@property (weak, nonatomic) NSOperation *lastAddedOperation; -@property (strong, nonatomic) NSMutableDictionary *URLCallbacks; -@property (strong, nonatomic) NSMutableDictionary *HTTPHeaders; -// This queue is used to serialize the handling of the network responses of all the download operation in a single queue -@property (SDDispatchQueueSetterSementics, nonatomic) dispatch_queue_t barrierQueue; - -@end - -@implementation SDWebImageDownloader - -+ (void)initialize { - // Bind SDNetworkActivityIndicator if available (download it here: http://github.com/rs/SDNetworkActivityIndicator ) - // To use it, just add #import "SDNetworkActivityIndicator.h" in addition to the SDWebImage import - if (NSClassFromString(@"SDNetworkActivityIndicator")) { - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Warc-performSelector-leaks" - id activityIndicator = [NSClassFromString(@"SDNetworkActivityIndicator") performSelector:NSSelectorFromString(@"sharedActivityIndicator")]; -#pragma clang diagnostic pop - - // Remove observer in case it was previously added. - [[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStartNotification object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:activityIndicator name:SDWebImageDownloadStopNotification object:nil]; - - [[NSNotificationCenter defaultCenter] addObserver:activityIndicator - selector:NSSelectorFromString(@"startActivity") - name:SDWebImageDownloadStartNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:activityIndicator - selector:NSSelectorFromString(@"stopActivity") - name:SDWebImageDownloadStopNotification object:nil]; - } -} - -+ (SDWebImageDownloader *)sharedDownloader { - static dispatch_once_t once; - static id instance; - dispatch_once(&once, ^{ - instance = [self new]; - }); - return instance; -} - -- (id)init { - if ((self = [super init])) { - _executionOrder = SDWebImageDownloaderFIFOExecutionOrder; - _downloadQueue = [NSOperationQueue new]; - _downloadQueue.maxConcurrentOperationCount = 2; - _URLCallbacks = [NSMutableDictionary new]; - _HTTPHeaders = [NSMutableDictionary dictionaryWithObject:@"image/webp,image/*;q=0.8" forKey:@"Accept"]; - _barrierQueue = dispatch_queue_create("com.hackemist.SDWebImageDownloaderBarrierQueue", DISPATCH_QUEUE_CONCURRENT); - _downloadTimeout = 15.0; - } - return self; -} - -- (void)dealloc { - [self.downloadQueue cancelAllOperations]; - SDDispatchQueueRelease(_barrierQueue); -} - -- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field { - if (value) { - self.HTTPHeaders[field] = value; - } - else { - [self.HTTPHeaders removeObjectForKey:field]; - } -} - -- (NSString *)valueForHTTPHeaderField:(NSString *)field { - return self.HTTPHeaders[field]; -} - -- (void)setMaxConcurrentDownloads:(NSInteger)maxConcurrentDownloads { - _downloadQueue.maxConcurrentOperationCount = maxConcurrentDownloads; -} - -- (NSUInteger)currentDownloadCount { - return _downloadQueue.operationCount; -} - -- (NSInteger)maxConcurrentDownloads { - return _downloadQueue.maxConcurrentOperationCount; -} - -- (id )downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageDownloaderCompletedBlock)completedBlock { - __block SDWebImageDownloaderOperation *operation; - __weak SDWebImageDownloader *wself = self; - - [self addProgressCallback:progressBlock andCompletedBlock:completedBlock forURL:url createCallback:^{ - NSTimeInterval timeoutInterval = wself.downloadTimeout; - if (timeoutInterval == 0.0) { - timeoutInterval = 15.0; - } - - // In order to prevent from potential duplicate caching (NSURLCache + SDImageCache) we disable the cache for image requests if told otherwise - NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:(options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:timeoutInterval]; - request.HTTPShouldHandleCookies = (options & SDWebImageDownloaderHandleCookies); - request.HTTPShouldUsePipelining = YES; - if (wself.headersFilter) { - request.allHTTPHeaderFields = wself.headersFilter(url, [wself.HTTPHeaders copy]); - } - else { - request.allHTTPHeaderFields = wself.HTTPHeaders; - } - operation = [[SDWebImageDownloaderOperation alloc] initWithRequest:request - options:options - progress:^(NSInteger receivedSize, NSInteger expectedSize) { - SDWebImageDownloader *sself = wself; - if (!sself) return; - NSArray *callbacksForURL = [sself callbacksForURL:url]; - for (NSDictionary *callbacks in callbacksForURL) { - SDWebImageDownloaderProgressBlock callback = callbacks[kProgressCallbackKey]; - if (callback) callback(receivedSize, expectedSize); - } - } - completed:^(UIImage *image, NSData *data, NSError *error, BOOL finished) { - SDWebImageDownloader *sself = wself; - if (!sself) return; - NSArray *callbacksForURL = [sself callbacksForURL:url]; - if (finished) { - [sself removeCallbacksForURL:url]; - } - for (NSDictionary *callbacks in callbacksForURL) { - SDWebImageDownloaderCompletedBlock callback = callbacks[kCompletedCallbackKey]; - if (callback) callback(image, data, error, finished); - } - } - cancelled:^{ - SDWebImageDownloader *sself = wself; - if (!sself) return; - [sself removeCallbacksForURL:url]; - }]; - - if (wself.username && wself.password) { - operation.credential = [NSURLCredential credentialWithUser:wself.username password:wself.password persistence:NSURLCredentialPersistenceForSession]; - } - - if (options & SDWebImageDownloaderHighPriority) { - operation.queuePriority = NSOperationQueuePriorityHigh; - } else if (options & SDWebImageDownloaderLowPriority) { - operation.queuePriority = NSOperationQueuePriorityLow; - } - - [wself.downloadQueue addOperation:operation]; - if (wself.executionOrder == SDWebImageDownloaderLIFOExecutionOrder) { - // Emulate LIFO execution order by systematically adding new operations as last operation's dependency - [wself.lastAddedOperation addDependency:operation]; - wself.lastAddedOperation = operation; - } - }]; - - return operation; -} - -- (void)addProgressCallback:(SDWebImageDownloaderProgressBlock)progressBlock andCompletedBlock:(SDWebImageDownloaderCompletedBlock)completedBlock forURL:(NSURL *)url createCallback:(SDWebImageNoParamsBlock)createCallback { - // The URL will be used as the key to the callbacks dictionary so it cannot be nil. If it is nil immediately call the completed block with no image or data. - if (url == nil) { - if (completedBlock != nil) { - completedBlock(nil, nil, nil, NO); - } - return; - } - - dispatch_barrier_sync(self.barrierQueue, ^{ - BOOL first = NO; - if (!self.URLCallbacks[url]) { - self.URLCallbacks[url] = [NSMutableArray new]; - first = YES; - } - - // Handle single download of simultaneous download request for the same URL - NSMutableArray *callbacksForURL = self.URLCallbacks[url]; - NSMutableDictionary *callbacks = [NSMutableDictionary new]; - if (progressBlock) callbacks[kProgressCallbackKey] = [progressBlock copy]; - if (completedBlock) callbacks[kCompletedCallbackKey] = [completedBlock copy]; - [callbacksForURL addObject:callbacks]; - self.URLCallbacks[url] = callbacksForURL; - - if (first) { - createCallback(); - } - }); -} - -- (NSArray *)callbacksForURL:(NSURL *)url { - __block NSArray *callbacksForURL; - dispatch_sync(self.barrierQueue, ^{ - callbacksForURL = self.URLCallbacks[url]; - }); - return [callbacksForURL copy]; -} - -- (void)removeCallbacksForURL:(NSURL *)url { - dispatch_barrier_async(self.barrierQueue, ^{ - [self.URLCallbacks removeObjectForKey:url]; - }); -} - -- (void)setSuspended:(BOOL)suspended { - [self.downloadQueue setSuspended:suspended]; -} - -@end diff --git a/Ryff/Frameworks/SDWebImage/SDWebImageDownloaderOperation.h b/Ryff/Frameworks/SDWebImage/SDWebImageDownloaderOperation.h deleted file mode 100755 index 21a3106..0000000 --- a/Ryff/Frameworks/SDWebImage/SDWebImageDownloaderOperation.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import -#import "SDWebImageDownloader.h" -#import "SDWebImageOperation.h" - -@interface SDWebImageDownloaderOperation : NSOperation - -/** - * The request used by the operation's connection. - */ -@property (strong, nonatomic, readonly) NSURLRequest *request; - -/** - * Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. - * - * This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. - */ -@property (nonatomic, assign) BOOL shouldUseCredentialStorage; - -/** - * The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. - * - * This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. - */ -@property (nonatomic, strong) NSURLCredential *credential; - -/** - * The SDWebImageDownloaderOptions for the receiver. - */ -@property (assign, nonatomic, readonly) SDWebImageDownloaderOptions options; - -/** - * Initializes a `SDWebImageDownloaderOperation` object - * - * @see SDWebImageDownloaderOperation - * - * @param request the URL request - * @param options downloader options - * @param progressBlock the block executed when a new chunk of data arrives. - * @note the progress block is executed on a background queue - * @param completedBlock the block executed when the download is done. - * @note the completed block is executed on the main queue for success. If errors are found, there is a chance the block will be executed on a background queue - * @param cancelBlock the block executed if the download (operation) is cancelled - * - * @return the initialized instance - */ -- (id)initWithRequest:(NSURLRequest *)request - options:(SDWebImageDownloaderOptions)options - progress:(SDWebImageDownloaderProgressBlock)progressBlock - completed:(SDWebImageDownloaderCompletedBlock)completedBlock - cancelled:(SDWebImageNoParamsBlock)cancelBlock; - -@end diff --git a/Ryff/Frameworks/SDWebImage/SDWebImageDownloaderOperation.m b/Ryff/Frameworks/SDWebImage/SDWebImageDownloaderOperation.m deleted file mode 100755 index 333e316..0000000 --- a/Ryff/Frameworks/SDWebImage/SDWebImageDownloaderOperation.m +++ /dev/null @@ -1,414 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import "SDWebImageDownloaderOperation.h" -#import "SDWebImageDecoder.h" -#import "UIImage+MultiFormat.h" -#import -#import "SDWebImageManager.h" - -@interface SDWebImageDownloaderOperation () - -@property (copy, nonatomic) SDWebImageDownloaderProgressBlock progressBlock; -@property (copy, nonatomic) SDWebImageDownloaderCompletedBlock completedBlock; -@property (copy, nonatomic) SDWebImageNoParamsBlock cancelBlock; - -@property (assign, nonatomic, getter = isExecuting) BOOL executing; -@property (assign, nonatomic, getter = isFinished) BOOL finished; -@property (assign, nonatomic) NSInteger expectedSize; -@property (strong, nonatomic) NSMutableData *imageData; -@property (strong, nonatomic) NSURLConnection *connection; -@property (strong, atomic) NSThread *thread; - -#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 -@property (assign, nonatomic) UIBackgroundTaskIdentifier backgroundTaskId; -#endif - -@end - -@implementation SDWebImageDownloaderOperation { - size_t width, height; - UIImageOrientation orientation; - BOOL responseFromCached; -} - -@synthesize executing = _executing; -@synthesize finished = _finished; - -- (id)initWithRequest:(NSURLRequest *)request - options:(SDWebImageDownloaderOptions)options - progress:(SDWebImageDownloaderProgressBlock)progressBlock - completed:(SDWebImageDownloaderCompletedBlock)completedBlock - cancelled:(SDWebImageNoParamsBlock)cancelBlock { - if ((self = [super init])) { - _request = request; - _shouldUseCredentialStorage = YES; - _options = options; - _progressBlock = [progressBlock copy]; - _completedBlock = [completedBlock copy]; - _cancelBlock = [cancelBlock copy]; - _executing = NO; - _finished = NO; - _expectedSize = 0; - responseFromCached = YES; // Initially wrong until `connection:willCacheResponse:` is called or not called - } - return self; -} - -- (void)start { - @synchronized (self) { - if (self.isCancelled) { - self.finished = YES; - [self reset]; - return; - } - -#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 - if ([self shouldContinueWhenAppEntersBackground]) { - __weak __typeof__ (self) wself = self; - self.backgroundTaskId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ - __strong __typeof (wself) sself = wself; - - if (sself) { - [sself cancel]; - - [[UIApplication sharedApplication] endBackgroundTask:sself.backgroundTaskId]; - sself.backgroundTaskId = UIBackgroundTaskInvalid; - } - }]; - } -#endif - - self.executing = YES; - self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO]; - self.thread = [NSThread currentThread]; - } - - [self.connection start]; - - if (self.connection) { - if (self.progressBlock) { - self.progressBlock(0, NSURLResponseUnknownLength); - } - [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStartNotification object:self]; - - if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_5_1) { - // Make sure to run the runloop in our background thread so it can process downloaded data - // Note: we use a timeout to work around an issue with NSURLConnection cancel under iOS 5 - // not waking up the runloop, leading to dead threads (see https://github.com/rs/SDWebImage/issues/466) - CFRunLoopRunInMode(kCFRunLoopDefaultMode, 10, false); - } - else { - CFRunLoopRun(); - } - - if (!self.isFinished) { - [self.connection cancel]; - [self connection:self.connection didFailWithError:[NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorTimedOut userInfo:@{NSURLErrorFailingURLErrorKey : self.request.URL}]]; - } - } - else { - if (self.completedBlock) { - self.completedBlock(nil, nil, [NSError errorWithDomain:NSURLErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey : @"Connection can't be initialized"}], YES); - } - } - -#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 - if (self.backgroundTaskId != UIBackgroundTaskInvalid) { - [[UIApplication sharedApplication] endBackgroundTask:self.backgroundTaskId]; - self.backgroundTaskId = UIBackgroundTaskInvalid; - } -#endif -} - -- (void)cancel { - @synchronized (self) { - if (self.thread) { - [self performSelector:@selector(cancelInternalAndStop) onThread:self.thread withObject:nil waitUntilDone:NO]; - } - else { - [self cancelInternal]; - } - } -} - -- (void)cancelInternalAndStop { - if (self.isFinished) return; - [self cancelInternal]; - CFRunLoopStop(CFRunLoopGetCurrent()); -} - -- (void)cancelInternal { - if (self.isFinished) return; - [super cancel]; - if (self.cancelBlock) self.cancelBlock(); - - if (self.connection) { - [self.connection cancel]; - [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:self]; - - // As we cancelled the connection, its callback won't be called and thus won't - // maintain the isFinished and isExecuting flags. - if (self.isExecuting) self.executing = NO; - if (!self.isFinished) self.finished = YES; - } - - [self reset]; -} - -- (void)done { - self.finished = YES; - self.executing = NO; - [self reset]; -} - -- (void)reset { - self.cancelBlock = nil; - self.completedBlock = nil; - self.progressBlock = nil; - self.connection = nil; - self.imageData = nil; - self.thread = nil; -} - -- (void)setFinished:(BOOL)finished { - [self willChangeValueForKey:@"isFinished"]; - _finished = finished; - [self didChangeValueForKey:@"isFinished"]; -} - -- (void)setExecuting:(BOOL)executing { - [self willChangeValueForKey:@"isExecuting"]; - _executing = executing; - [self didChangeValueForKey:@"isExecuting"]; -} - -- (BOOL)isConcurrent { - return YES; -} - -#pragma mark NSURLConnection (delegate) - -- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { - if (![response respondsToSelector:@selector(statusCode)] || [((NSHTTPURLResponse *)response) statusCode] < 400) { - NSInteger expected = response.expectedContentLength > 0 ? (NSInteger)response.expectedContentLength : 0; - self.expectedSize = expected; - if (self.progressBlock) { - self.progressBlock(0, expected); - } - - self.imageData = [[NSMutableData alloc] initWithCapacity:expected]; - } - else { - [self.connection cancel]; - - [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:nil]; - - if (self.completedBlock) { - self.completedBlock(nil, nil, [NSError errorWithDomain:NSURLErrorDomain code:[((NSHTTPURLResponse *)response) statusCode] userInfo:nil], YES); - } - CFRunLoopStop(CFRunLoopGetCurrent()); - [self done]; - } -} - -- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { - [self.imageData appendData:data]; - - if ((self.options & SDWebImageDownloaderProgressiveDownload) && self.expectedSize > 0 && self.completedBlock) { - // The following code is from http://www.cocoaintheshell.com/2011/05/progressive-images-download-imageio/ - // Thanks to the author @Nyx0uf - - // Get the total bytes downloaded - const NSInteger totalSize = self.imageData.length; - - // Update the data source, we must pass ALL the data, not just the new bytes - CGImageSourceRef imageSource = CGImageSourceCreateIncremental(NULL); - CGImageSourceUpdateData(imageSource, (__bridge CFDataRef)self.imageData, totalSize == self.expectedSize); - - if (width + height == 0) { - CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); - if (properties) { - NSInteger orientationValue = -1; - CFTypeRef val = CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight); - if (val) CFNumberGetValue(val, kCFNumberLongType, &height); - val = CFDictionaryGetValue(properties, kCGImagePropertyPixelWidth); - if (val) CFNumberGetValue(val, kCFNumberLongType, &width); - val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation); - if (val) CFNumberGetValue(val, kCFNumberNSIntegerType, &orientationValue); - CFRelease(properties); - - // When we draw to Core Graphics, we lose orientation information, - // which means the image below born of initWithCGIImage will be - // oriented incorrectly sometimes. (Unlike the image born of initWithData - // in connectionDidFinishLoading.) So save it here and pass it on later. - orientation = [[self class] orientationFromPropertyValue:(orientationValue == -1 ? 1 : orientationValue)]; - } - - } - - if (width + height > 0 && totalSize < self.expectedSize) { - // Create the image - CGImageRef partialImageRef = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL); - -#ifdef TARGET_OS_IPHONE - // Workaround for iOS anamorphic image - if (partialImageRef) { - const size_t partialHeight = CGImageGetHeight(partialImageRef); - CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - CGContextRef bmContext = CGBitmapContextCreate(NULL, width, height, 8, width * 4, colorSpace, kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedFirst); - CGColorSpaceRelease(colorSpace); - if (bmContext) { - CGContextDrawImage(bmContext, (CGRect){.origin.x = 0.0f, .origin.y = 0.0f, .size.width = width, .size.height = partialHeight}, partialImageRef); - CGImageRelease(partialImageRef); - partialImageRef = CGBitmapContextCreateImage(bmContext); - CGContextRelease(bmContext); - } - else { - CGImageRelease(partialImageRef); - partialImageRef = nil; - } - } -#endif - - if (partialImageRef) { - UIImage *image = [UIImage imageWithCGImage:partialImageRef scale:1 orientation:orientation]; - NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL]; - UIImage *scaledImage = [self scaledImageForKey:key image:image]; - image = [UIImage decodedImageWithImage:scaledImage]; - CGImageRelease(partialImageRef); - dispatch_main_sync_safe(^{ - if (self.completedBlock) { - self.completedBlock(image, nil, nil, NO); - } - }); - } - } - - CFRelease(imageSource); - } - - if (self.progressBlock) { - self.progressBlock(self.imageData.length, self.expectedSize); - } -} - -+ (UIImageOrientation)orientationFromPropertyValue:(NSInteger)value { - switch (value) { - case 1: - return UIImageOrientationUp; - case 3: - return UIImageOrientationDown; - case 8: - return UIImageOrientationLeft; - case 6: - return UIImageOrientationRight; - case 2: - return UIImageOrientationUpMirrored; - case 4: - return UIImageOrientationDownMirrored; - case 5: - return UIImageOrientationLeftMirrored; - case 7: - return UIImageOrientationRightMirrored; - default: - return UIImageOrientationUp; - } -} - -- (UIImage *)scaledImageForKey:(NSString *)key image:(UIImage *)image { - return SDScaledImageForKey(key, image); -} - -- (void)connectionDidFinishLoading:(NSURLConnection *)aConnection { - SDWebImageDownloaderCompletedBlock completionBlock = self.completedBlock; - @synchronized(self) { - CFRunLoopStop(CFRunLoopGetCurrent()); - self.thread = nil; - self.connection = nil; - [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:nil]; - } - - if (![[NSURLCache sharedURLCache] cachedResponseForRequest:_request]) { - responseFromCached = NO; - } - - if (completionBlock) - { - if (self.options & SDWebImageDownloaderIgnoreCachedResponse && responseFromCached) { - completionBlock(nil, nil, nil, YES); - } - else { - UIImage *image = [UIImage sd_imageWithData:self.imageData]; - NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:self.request.URL]; - image = [self scaledImageForKey:key image:image]; - - // Do not force decoding animated GIFs - if (!image.images) { - image = [UIImage decodedImageWithImage:image]; - } - if (CGSizeEqualToSize(image.size, CGSizeZero)) { - completionBlock(nil, nil, [NSError errorWithDomain:@"SDWebImageErrorDomain" code:0 userInfo:@{NSLocalizedDescriptionKey : @"Downloaded image has 0 pixels"}], YES); - } - else { - completionBlock(image, self.imageData, nil, YES); - } - } - } - self.completionBlock = nil; - [self done]; -} - -- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { - CFRunLoopStop(CFRunLoopGetCurrent()); - [[NSNotificationCenter defaultCenter] postNotificationName:SDWebImageDownloadStopNotification object:nil]; - - if (self.completedBlock) { - self.completedBlock(nil, nil, error, YES); - } - - [self done]; -} - -- (NSCachedURLResponse *)connection:(NSURLConnection *)connection willCacheResponse:(NSCachedURLResponse *)cachedResponse { - responseFromCached = NO; // If this method is called, it means the response wasn't read from cache - if (self.request.cachePolicy == NSURLRequestReloadIgnoringLocalCacheData) { - // Prevents caching of responses - return nil; - } - else { - return cachedResponse; - } -} - -- (BOOL)shouldContinueWhenAppEntersBackground { - return self.options & SDWebImageDownloaderContinueInBackground; -} - -- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection __unused *)connection { - return self.shouldUseCredentialStorage; -} - -- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{ - if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { - NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; - [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; - } else { - if ([challenge previousFailureCount] == 0) { - if (self.credential) { - [[challenge sender] useCredential:self.credential forAuthenticationChallenge:challenge]; - } else { - [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; - } - } else { - [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge]; - } - } -} - -@end diff --git a/Ryff/Frameworks/SDWebImage/SDWebImageManager.h b/Ryff/Frameworks/SDWebImage/SDWebImageManager.h deleted file mode 100755 index cae25d3..0000000 --- a/Ryff/Frameworks/SDWebImage/SDWebImageManager.h +++ /dev/null @@ -1,292 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import "SDWebImageCompat.h" -#import "SDWebImageOperation.h" -#import "SDWebImageDownloader.h" -#import "SDImageCache.h" - -typedef NS_OPTIONS(NSUInteger, SDWebImageOptions) { - /** - * By default, when a URL fail to be downloaded, the URL is blacklisted so the library won't keep trying. - * This flag disable this blacklisting. - */ - SDWebImageRetryFailed = 1 << 0, - - /** - * By default, image downloads are started during UI interactions, this flags disable this feature, - * leading to delayed download on UIScrollView deceleration for instance. - */ - SDWebImageLowPriority = 1 << 1, - - /** - * This flag disables on-disk caching - */ - SDWebImageCacheMemoryOnly = 1 << 2, - - /** - * This flag enables progressive download, the image is displayed progressively during download as a browser would do. - * By default, the image is only displayed once completely downloaded. - */ - SDWebImageProgressiveDownload = 1 << 3, - - /** - * Even if the image is cached, respect the HTTP response cache control, and refresh the image from remote location if needed. - * The disk caching will be handled by NSURLCache instead of SDWebImage leading to slight performance degradation. - * This option helps deal with images changing behind the same request URL, e.g. Facebook graph api profile pics. - * If a cached image is refreshed, the completion block is called once with the cached image and again with the final image. - * - * Use this flag only if you can't make your URLs static with embeded cache busting parameter. - */ - SDWebImageRefreshCached = 1 << 4, - - /** - * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for - * extra time in background to let the request finish. If the background task expires the operation will be cancelled. - */ - SDWebImageContinueInBackground = 1 << 5, - - /** - * Handles cookies stored in NSHTTPCookieStore by setting - * NSMutableURLRequest.HTTPShouldHandleCookies = YES; - */ - SDWebImageHandleCookies = 1 << 6, - - /** - * Enable to allow untrusted SSL ceriticates. - * Useful for testing purposes. Use with caution in production. - */ - SDWebImageAllowInvalidSSLCertificates = 1 << 7, - - /** - * By default, image are loaded in the order they were queued. This flag move them to - * the front of the queue and is loaded immediately instead of waiting for the current queue to be loaded (which - * could take a while). - */ - SDWebImageHighPriority = 1 << 8, - - /** - * By default, placeholder images are loaded while the image is loading. This flag will delay the loading - * of the placeholder image until after the image has finished loading. - */ - SDWebImageDelayPlaceholder = 1 << 9, - - /** - * We usually don't call transformDownloadedImage delegate method on animated images, - * as most transformation code would mangle it. - * Use this flag to transform them anyway. - */ - SDWebImageTransformAnimatedImage = 1 << 10, -}; - -typedef void(^SDWebImageCompletionBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL); - -typedef void(^SDWebImageCompletionWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL); - -typedef NSString *(^SDWebImageCacheKeyFilterBlock)(NSURL *url); - - -@class SDWebImageManager; - -@protocol SDWebImageManagerDelegate - -@optional - -/** - * Controls which image should be downloaded when the image is not found in the cache. - * - * @param imageManager The current `SDWebImageManager` - * @param imageURL The url of the image to be downloaded - * - * @return Return NO to prevent the downloading of the image on cache misses. If not implemented, YES is implied. - */ -- (BOOL)imageManager:(SDWebImageManager *)imageManager shouldDownloadImageForURL:(NSURL *)imageURL; - -/** - * Allows to transform the image immediately after it has been downloaded and just before to cache it on disk and memory. - * NOTE: This method is called from a global queue in order to not to block the main thread. - * - * @param imageManager The current `SDWebImageManager` - * @param image The image to transform - * @param imageURL The url of the image to transform - * - * @return The transformed image object. - */ -- (UIImage *)imageManager:(SDWebImageManager *)imageManager transformDownloadedImage:(UIImage *)image withURL:(NSURL *)imageURL; - -@end - -/** - * The SDWebImageManager is the class behind the UIImageView+WebCache category and likes. - * It ties the asynchronous downloader (SDWebImageDownloader) with the image cache store (SDImageCache). - * You can use this class directly to benefit from web image downloading with caching in another context than - * a UIView. - * - * Here is a simple example of how to use SDWebImageManager: - * - * @code - -SDWebImageManager *manager = [SDWebImageManager sharedManager]; -[manager downloadWithURL:imageURL - options:0 - progress:nil - completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { - if (image) { - // do something with image - } - }]; - - * @endcode - */ -@interface SDWebImageManager : NSObject - -@property (weak, nonatomic) id delegate; - -@property (strong, nonatomic, readonly) SDImageCache *imageCache; -@property (strong, nonatomic, readonly) SDWebImageDownloader *imageDownloader; - -/** - * The cache filter is a block used each time SDWebImageManager need to convert an URL into a cache key. This can - * be used to remove dynamic part of an image URL. - * - * The following example sets a filter in the application delegate that will remove any query-string from the - * URL before to use it as a cache key: - * - * @code - -[[SDWebImageManager sharedManager] setCacheKeyFilter:^(NSURL *url) { - url = [[NSURL alloc] initWithScheme:url.scheme host:url.host path:url.path]; - return [url absoluteString]; -}]; - - * @endcode - */ -@property (copy) SDWebImageCacheKeyFilterBlock cacheKeyFilter; - -/** - * Returns global SDWebImageManager instance. - * - * @return SDWebImageManager shared instance - */ -+ (SDWebImageManager *)sharedManager; - -/** - * Downloads the image at the given URL if not present in cache or return the cached version otherwise. - * - * @param url The URL to the image - * @param options A mask to specify options to use for this request - * @param progressBlock A block called while image is downloading - * @param completedBlock A block called when operation has been completed. - * - * This parameter is required. - * - * This block has no return value and takes the requested UIImage as first parameter. - * In case of error the image parameter is nil and the second parameter may contain an NSError. - * - * The third parameter is an `SDImageCacheType` enum indicating if the image was retrived from the local cache - * or from the memory cache or from the network. - * - * The last parameter is set to NO when the SDWebImageProgressiveDownload option is used and the image is - * downloading. This block is thus called repetidly with a partial image. When image is fully downloaded, the - * block is called a last time with the full image and the last parameter set to YES. - * - * @return Returns an NSObject conforming to SDWebImageOperation. Should be an instance of SDWebImageDownloaderOperation - */ -- (id )downloadImageWithURL:(NSURL *)url - options:(SDWebImageOptions)options - progress:(SDWebImageDownloaderProgressBlock)progressBlock - completed:(SDWebImageCompletionWithFinishedBlock)completedBlock; - -/** - * Saves image to cache for given URL - * - * @param image The image to cache - * @param url The URL to the image - * - */ - -- (void)saveImageToCache:(UIImage *)image forURL:(NSURL *)url; - -/** - * Cancel all current opreations - */ -- (void)cancelAll; - -/** - * Check one or more operations running - */ -- (BOOL)isRunning; - -/** - * Check if image has already been cached - * - * @param url image url - * - * @return if the image was already cached - */ -- (BOOL)cachedImageExistsForURL:(NSURL *)url; - -/** - * Check if image has already been cached on disk only - * - * @param url image url - * - * @return if the image was already cached (disk only) - */ -- (BOOL)diskImageExistsForURL:(NSURL *)url; - -/** - * Async check if image has already been cached - * - * @param url image url - * @param completionBlock the block to be executed when the check is finished - * - * @note the completion block is always executed on the main queue - */ -- (void)cachedImageExistsForURL:(NSURL *)url - completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; - -/** - * Async check if image has already been cached on disk only - * - * @param url image url - * @param completionBlock the block to be executed when the check is finished - * - * @note the completion block is always executed on the main queue - */ -- (void)diskImageExistsForURL:(NSURL *)url - completion:(SDWebImageCheckCacheCompletionBlock)completionBlock; - - -/** - *Return the cache key for a given URL - */ -- (NSString *)cacheKeyForURL:(NSURL *)url; - -@end - - -#pragma mark - Deprecated - -typedef void(^SDWebImageCompletedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType) __deprecated_msg("Block type deprecated. Use `SDWebImageCompletionBlock`"); -typedef void(^SDWebImageCompletedWithFinishedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished) __deprecated_msg("Block type deprecated. Use `SDWebImageCompletionWithFinishedBlock`"); - - -@interface SDWebImageManager (Deprecated) - -/** - * Downloads the image at the given URL if not present in cache or return the cached version otherwise. - * - * @deprecated This method has been deprecated. Use `downloadImageWithURL:options:progress:completed:` - */ -- (id )downloadWithURL:(NSURL *)url - options:(SDWebImageOptions)options - progress:(SDWebImageDownloaderProgressBlock)progressBlock - completed:(SDWebImageCompletedWithFinishedBlock)completedBlock __deprecated_msg("Method deprecated. Use `downloadImageWithURL:options:progress:completed:`"); - -@end diff --git a/Ryff/Frameworks/SDWebImage/SDWebImageManager.m b/Ryff/Frameworks/SDWebImage/SDWebImageManager.m deleted file mode 100755 index 89718cb..0000000 --- a/Ryff/Frameworks/SDWebImage/SDWebImageManager.m +++ /dev/null @@ -1,346 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import "SDWebImageManager.h" -#import - -@interface SDWebImageCombinedOperation : NSObject - -@property (assign, nonatomic, getter = isCancelled) BOOL cancelled; -@property (copy, nonatomic) SDWebImageNoParamsBlock cancelBlock; -@property (strong, nonatomic) NSOperation *cacheOperation; - -@end - -@interface SDWebImageManager () - -@property (strong, nonatomic, readwrite) SDImageCache *imageCache; -@property (strong, nonatomic, readwrite) SDWebImageDownloader *imageDownloader; -@property (strong, nonatomic) NSMutableArray *failedURLs; -@property (strong, nonatomic) NSMutableArray *runningOperations; - -@end - -@implementation SDWebImageManager - -+ (id)sharedManager { - static dispatch_once_t once; - static id instance; - dispatch_once(&once, ^{ - instance = [self new]; - }); - return instance; -} - -- (id)init { - if ((self = [super init])) { - _imageCache = [self createCache]; - _imageDownloader = [SDWebImageDownloader sharedDownloader]; - _failedURLs = [NSMutableArray new]; - _runningOperations = [NSMutableArray new]; - } - return self; -} - -- (SDImageCache *)createCache { - return [SDImageCache sharedImageCache]; -} - -- (NSString *)cacheKeyForURL:(NSURL *)url { - if (self.cacheKeyFilter) { - return self.cacheKeyFilter(url); - } - else { - return [url absoluteString]; - } -} - -- (BOOL)cachedImageExistsForURL:(NSURL *)url { - NSString *key = [self cacheKeyForURL:url]; - if ([self.imageCache imageFromMemoryCacheForKey:key] != nil) return YES; - return [self.imageCache diskImageExistsWithKey:key]; -} - -- (BOOL)diskImageExistsForURL:(NSURL *)url { - NSString *key = [self cacheKeyForURL:url]; - return [self.imageCache diskImageExistsWithKey:key]; -} - -- (void)cachedImageExistsForURL:(NSURL *)url - completion:(SDWebImageCheckCacheCompletionBlock)completionBlock { - NSString *key = [self cacheKeyForURL:url]; - - BOOL isInMemoryCache = ([self.imageCache imageFromMemoryCacheForKey:key] != nil); - - if (isInMemoryCache) { - // making sure we call the completion block on the main queue - dispatch_async(dispatch_get_main_queue(), ^{ - if (completionBlock) { - completionBlock(YES); - } - }); - return; - } - - [self.imageCache diskImageExistsWithKey:key completion:^(BOOL isInDiskCache) { - // the completion block of checkDiskCacheForImageWithKey:completion: is always called on the main queue, no need to further dispatch - if (completionBlock) { - completionBlock(isInDiskCache); - } - }]; -} - -- (void)diskImageExistsForURL:(NSURL *)url - completion:(SDWebImageCheckCacheCompletionBlock)completionBlock { - NSString *key = [self cacheKeyForURL:url]; - - [self.imageCache diskImageExistsWithKey:key completion:^(BOOL isInDiskCache) { - // the completion block of checkDiskCacheForImageWithKey:completion: is always called on the main queue, no need to further dispatch - if (completionBlock) { - completionBlock(isInDiskCache); - } - }]; -} - -- (id )downloadImageWithURL:(NSURL *)url - options:(SDWebImageOptions)options - progress:(SDWebImageDownloaderProgressBlock)progressBlock - completed:(SDWebImageCompletionWithFinishedBlock)completedBlock { - // Invoking this method without a completedBlock is pointless - NSAssert(completedBlock != nil, @"If you mean to prefetch the image, use -[SDWebImagePrefetcher prefetchURLs] instead"); - - // Very common mistake is to send the URL using NSString object instead of NSURL. For some strange reason, XCode won't - // throw any warning for this type mismatch. Here we failsafe this error by allowing URLs to be passed as NSString. - if ([url isKindOfClass:NSString.class]) { - url = [NSURL URLWithString:(NSString *)url]; - } - - // Prevents app crashing on argument type error like sending NSNull instead of NSURL - if (![url isKindOfClass:NSURL.class]) { - url = nil; - } - - __block SDWebImageCombinedOperation *operation = [SDWebImageCombinedOperation new]; - __weak SDWebImageCombinedOperation *weakOperation = operation; - - BOOL isFailedUrl = NO; - @synchronized (self.failedURLs) { - isFailedUrl = [self.failedURLs containsObject:url]; - } - - if (!url || (!(options & SDWebImageRetryFailed) && isFailedUrl)) { - dispatch_main_sync_safe(^{ - NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist userInfo:nil]; - completedBlock(nil, error, SDImageCacheTypeNone, YES, url); - }); - return operation; - } - - @synchronized (self.runningOperations) { - [self.runningOperations addObject:operation]; - } - NSString *key = [self cacheKeyForURL:url]; - - operation.cacheOperation = [self.imageCache queryDiskCacheForKey:key done:^(UIImage *image, SDImageCacheType cacheType) { - if (operation.isCancelled) { - @synchronized (self.runningOperations) { - [self.runningOperations removeObject:operation]; - } - - return; - } - - if ((!image || options & SDWebImageRefreshCached) && (![self.delegate respondsToSelector:@selector(imageManager:shouldDownloadImageForURL:)] || [self.delegate imageManager:self shouldDownloadImageForURL:url])) { - if (image && options & SDWebImageRefreshCached) { - dispatch_main_sync_safe(^{ - // If image was found in the cache bug SDWebImageRefreshCached is provided, notify about the cached image - // AND try to re-download it in order to let a chance to NSURLCache to refresh it from server. - completedBlock(image, nil, cacheType, YES, url); - }); - } - - // download if no image or requested to refresh anyway, and download allowed by delegate - SDWebImageDownloaderOptions downloaderOptions = 0; - if (options & SDWebImageLowPriority) downloaderOptions |= SDWebImageDownloaderLowPriority; - if (options & SDWebImageProgressiveDownload) downloaderOptions |= SDWebImageDownloaderProgressiveDownload; - if (options & SDWebImageRefreshCached) downloaderOptions |= SDWebImageDownloaderUseNSURLCache; - if (options & SDWebImageContinueInBackground) downloaderOptions |= SDWebImageDownloaderContinueInBackground; - if (options & SDWebImageHandleCookies) downloaderOptions |= SDWebImageDownloaderHandleCookies; - if (options & SDWebImageAllowInvalidSSLCertificates) downloaderOptions |= SDWebImageDownloaderAllowInvalidSSLCertificates; - if (options & SDWebImageHighPriority) downloaderOptions |= SDWebImageDownloaderHighPriority; - if (image && options & SDWebImageRefreshCached) { - // force progressive off if image already cached but forced refreshing - downloaderOptions &= ~SDWebImageDownloaderProgressiveDownload; - // ignore image read from NSURLCache if image if cached but force refreshing - downloaderOptions |= SDWebImageDownloaderIgnoreCachedResponse; - } - id subOperation = [self.imageDownloader downloadImageWithURL:url options:downloaderOptions progress:progressBlock completed:^(UIImage *downloadedImage, NSData *data, NSError *error, BOOL finished) { - if (weakOperation.isCancelled) { - // Do nothing if the operation was cancelled - // See #699 for more details - // if we would call the completedBlock, there could be a race condition between this block and another completedBlock for the same object, so if this one is called second, we will overwrite the new data - } - else if (error) { - dispatch_main_sync_safe(^{ - if (!weakOperation.isCancelled) { - completedBlock(nil, error, SDImageCacheTypeNone, finished, url); - } - }); - - if (error.code != NSURLErrorNotConnectedToInternet && error.code != NSURLErrorCancelled && error.code != NSURLErrorTimedOut) { - @synchronized (self.failedURLs) { - [self.failedURLs addObject:url]; - } - } - } - else { - BOOL cacheOnDisk = !(options & SDWebImageCacheMemoryOnly); - - if (options & SDWebImageRefreshCached && image && !downloadedImage) { - // Image refresh hit the NSURLCache cache, do not call the completion block - } - else if (downloadedImage && (!downloadedImage.images || (options & SDWebImageTransformAnimatedImage)) && [self.delegate respondsToSelector:@selector(imageManager:transformDownloadedImage:withURL:)]) { - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ - UIImage *transformedImage = [self.delegate imageManager:self transformDownloadedImage:downloadedImage withURL:url]; - - if (transformedImage && finished) { - BOOL imageWasTransformed = ![transformedImage isEqual:downloadedImage]; - [self.imageCache storeImage:transformedImage recalculateFromImage:imageWasTransformed imageData:data forKey:key toDisk:cacheOnDisk]; - } - - dispatch_main_sync_safe(^{ - if (!weakOperation.isCancelled) { - completedBlock(transformedImage, nil, SDImageCacheTypeNone, finished, url); - } - }); - }); - } - else { - if (downloadedImage && finished) { - [self.imageCache storeImage:downloadedImage recalculateFromImage:NO imageData:data forKey:key toDisk:cacheOnDisk]; - } - - dispatch_main_sync_safe(^{ - if (!weakOperation.isCancelled) { - completedBlock(downloadedImage, nil, SDImageCacheTypeNone, finished, url); - } - }); - } - } - - if (finished) { - @synchronized (self.runningOperations) { - [self.runningOperations removeObject:operation]; - } - } - }]; - operation.cancelBlock = ^{ - [subOperation cancel]; - - @synchronized (self.runningOperations) { - [self.runningOperations removeObject:weakOperation]; - } - }; - } - else if (image) { - dispatch_main_sync_safe(^{ - if (!weakOperation.isCancelled) { - completedBlock(image, nil, cacheType, YES, url); - } - }); - @synchronized (self.runningOperations) { - [self.runningOperations removeObject:operation]; - } - } - else { - // Image not in cache and download disallowed by delegate - dispatch_main_sync_safe(^{ - if (!weakOperation.isCancelled) { - completedBlock(nil, nil, SDImageCacheTypeNone, YES, url); - } - }); - @synchronized (self.runningOperations) { - [self.runningOperations removeObject:operation]; - } - } - }]; - - return operation; -} - -- (void)saveImageToCache:(UIImage *)image forURL:(NSURL *)url { - if (image && url) { - NSString *key = [self cacheKeyForURL:url]; - [self.imageCache storeImage:image forKey:key toDisk:YES]; - } -} - -- (void)cancelAll { - @synchronized (self.runningOperations) { - NSArray *copiedOperations = [self.runningOperations copy]; - [copiedOperations makeObjectsPerformSelector:@selector(cancel)]; - [self.runningOperations removeObjectsInArray:copiedOperations]; - } -} - -- (BOOL)isRunning { - return self.runningOperations.count > 0; -} - -@end - - -@implementation SDWebImageCombinedOperation - -- (void)setCancelBlock:(SDWebImageNoParamsBlock)cancelBlock { - // check if the operation is already cancelled, then we just call the cancelBlock - if (self.isCancelled) { - if (cancelBlock) { - cancelBlock(); - } - _cancelBlock = nil; // don't forget to nil the cancelBlock, otherwise we will get crashes - } else { - _cancelBlock = [cancelBlock copy]; - } -} - -- (void)cancel { - self.cancelled = YES; - if (self.cacheOperation) { - [self.cacheOperation cancel]; - self.cacheOperation = nil; - } - if (self.cancelBlock) { - self.cancelBlock(); - - // TODO: this is a temporary fix to #809. - // Until we can figure the exact cause of the crash, going with the ivar instead of the setter -// self.cancelBlock = nil; - _cancelBlock = nil; - } -} - -@end - - -@implementation SDWebImageManager (Deprecated) - -// deprecated method, uses the non deprecated method -// adapter for the completion block -- (id )downloadWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedWithFinishedBlock)completedBlock { - return [self downloadImageWithURL:url - options:options - progress:progressBlock - completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType, finished); - } - }]; -} - -@end diff --git a/Ryff/Frameworks/SDWebImage/SDWebImageOperation.h b/Ryff/Frameworks/SDWebImage/SDWebImageOperation.h deleted file mode 100755 index 71094ee..0000000 --- a/Ryff/Frameworks/SDWebImage/SDWebImageOperation.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import - -@protocol SDWebImageOperation - -- (void)cancel; - -@end diff --git a/Ryff/Frameworks/SDWebImage/SDWebImagePrefetcher.h b/Ryff/Frameworks/SDWebImage/SDWebImagePrefetcher.h deleted file mode 100755 index 4f14fa2..0000000 --- a/Ryff/Frameworks/SDWebImage/SDWebImagePrefetcher.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import -#import "SDWebImageManager.h" - -@class SDWebImagePrefetcher; - -@protocol SDWebImagePrefetcherDelegate - -@optional - -/** - * Called when an image was prefetched. - * - * @param imagePrefetcher The current image prefetcher - * @param imageURL The image url that was prefetched - * @param finishedCount The total number of images that were prefetched (successful or not) - * @param totalCount The total number of images that were to be prefetched - */ -- (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didPrefetchURL:(NSURL *)imageURL finishedCount:(NSUInteger)finishedCount totalCount:(NSUInteger)totalCount; - -/** - * Called when all images are prefetched. - * @param imagePrefetcher The current image prefetcher - * @param totalCount The total number of images that were prefetched (whether successful or not) - * @param skippedCount The total number of images that were skipped - */ -- (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didFinishWithTotalCount:(NSUInteger)totalCount skippedCount:(NSUInteger)skippedCount; - -@end - -typedef void(^SDWebImagePrefetcherProgressBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfTotalUrls); -typedef void(^SDWebImagePrefetcherCompletionBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfSkippedUrls); - -/** - * Prefetch some URLs in the cache for future use. Images are downloaded in low priority. - */ -@interface SDWebImagePrefetcher : NSObject - -/** - * The web image manager - */ -@property (strong, nonatomic, readonly) SDWebImageManager *manager; - -/** - * Maximum number of URLs to prefetch at the same time. Defaults to 3. - */ -@property (nonatomic, assign) NSUInteger maxConcurrentDownloads; - -/** - * SDWebImageOptions for prefetcher. Defaults to SDWebImageLowPriority. - */ -@property (nonatomic, assign) SDWebImageOptions options; - -@property (weak, nonatomic) id delegate; - -/** - * Return the global image prefetcher instance. - */ -+ (SDWebImagePrefetcher *)sharedImagePrefetcher; - -/** - * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, - * currently one image is downloaded at a time, - * and skips images for failed downloads and proceed to the next image in the list - * - * @param urls list of URLs to prefetch - */ -- (void)prefetchURLs:(NSArray *)urls; - -/** - * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, - * currently one image is downloaded at a time, - * and skips images for failed downloads and proceed to the next image in the list - * - * @param urls list of URLs to prefetch - * @param progressBlock block to be called when progress updates; - * first parameter is the number of completed (successful or not) requests, - * second parameter is the total number of images originally requested to be prefetched - * @param completionBlock block to be called when prefetching is completed - * first param is the number of completed (successful or not) requests, - * second parameter is the number of skipped requests - */ -- (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock; - -/** - * Remove and cancel queued list - */ -- (void)cancelPrefetching; - - -@end diff --git a/Ryff/Frameworks/SDWebImage/SDWebImagePrefetcher.m b/Ryff/Frameworks/SDWebImage/SDWebImagePrefetcher.m deleted file mode 100755 index 4087e4a..0000000 --- a/Ryff/Frameworks/SDWebImage/SDWebImagePrefetcher.m +++ /dev/null @@ -1,138 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import "SDWebImagePrefetcher.h" - -#if !defined(DEBUG) && !defined (SD_VERBOSE) -#define NSLog(...) -#endif - -@interface SDWebImagePrefetcher () - -@property (strong, nonatomic) SDWebImageManager *manager; -@property (strong, nonatomic) NSArray *prefetchURLs; -@property (assign, nonatomic) NSUInteger requestedCount; -@property (assign, nonatomic) NSUInteger skippedCount; -@property (assign, nonatomic) NSUInteger finishedCount; -@property (assign, nonatomic) NSTimeInterval startedTime; -@property (copy, nonatomic) SDWebImagePrefetcherCompletionBlock completionBlock; -@property (copy, nonatomic) SDWebImagePrefetcherProgressBlock progressBlock; - -@end - -@implementation SDWebImagePrefetcher - -+ (SDWebImagePrefetcher *)sharedImagePrefetcher { - static dispatch_once_t once; - static id instance; - dispatch_once(&once, ^{ - instance = [self new]; - }); - return instance; -} - -- (id)init { - if ((self = [super init])) { - _manager = [SDWebImageManager new]; - _options = SDWebImageLowPriority; - self.maxConcurrentDownloads = 3; - } - return self; -} - -- (void)setMaxConcurrentDownloads:(NSUInteger)maxConcurrentDownloads { - self.manager.imageDownloader.maxConcurrentDownloads = maxConcurrentDownloads; -} - -- (NSUInteger)maxConcurrentDownloads { - return self.manager.imageDownloader.maxConcurrentDownloads; -} - -- (void)startPrefetchingAtIndex:(NSUInteger)index { - if (index >= self.prefetchURLs.count) return; - self.requestedCount++; - [self.manager downloadImageWithURL:self.prefetchURLs[index] options:self.options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { - if (!finished) return; - self.finishedCount++; - - if (image) { - if (self.progressBlock) { - self.progressBlock(self.finishedCount,[self.prefetchURLs count]); - } - NSLog(@"Prefetched %@ out of %@", @(self.finishedCount), @(self.prefetchURLs.count)); - } - else { - if (self.progressBlock) { - self.progressBlock(self.finishedCount,[self.prefetchURLs count]); - } - NSLog(@"Prefetched %@ out of %@ (Failed)", @(self.finishedCount), @(self.prefetchURLs.count)); - - // Add last failed - self.skippedCount++; - } - if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didPrefetchURL:finishedCount:totalCount:)]) { - [self.delegate imagePrefetcher:self - didPrefetchURL:self.prefetchURLs[index] - finishedCount:self.finishedCount - totalCount:self.prefetchURLs.count - ]; - } - - if (self.prefetchURLs.count > self.requestedCount) { - dispatch_async(dispatch_get_main_queue(), ^{ - [self startPrefetchingAtIndex:self.requestedCount]; - }); - } - else if (self.finishedCount == self.requestedCount) { - [self reportStatus]; - if (self.completionBlock) { - self.completionBlock(self.finishedCount, self.skippedCount); - self.completionBlock = nil; - } - } - }]; -} - -- (void)reportStatus { - NSUInteger total = [self.prefetchURLs count]; - NSLog(@"Finished prefetching (%@ successful, %@ skipped, timeElasped %.2f)", @(total - self.skippedCount), @(self.skippedCount), CFAbsoluteTimeGetCurrent() - self.startedTime); - if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didFinishWithTotalCount:skippedCount:)]) { - [self.delegate imagePrefetcher:self - didFinishWithTotalCount:(total - self.skippedCount) - skippedCount:self.skippedCount - ]; - } -} - -- (void)prefetchURLs:(NSArray *)urls { - [self prefetchURLs:urls progress:nil completed:nil]; -} - -- (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock { - [self cancelPrefetching]; // Prevent duplicate prefetch request - self.startedTime = CFAbsoluteTimeGetCurrent(); - self.prefetchURLs = urls; - self.completionBlock = completionBlock; - self.progressBlock = progressBlock; - - // Starts prefetching from the very first image on the list with the max allowed concurrency - NSUInteger listCount = self.prefetchURLs.count; - for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) { - [self startPrefetchingAtIndex:i]; - } -} - -- (void)cancelPrefetching { - self.prefetchURLs = nil; - self.skippedCount = 0; - self.requestedCount = 0; - self.finishedCount = 0; - [self.manager cancelAll]; -} - -@end diff --git a/Ryff/Frameworks/SDWebImage/UIButton+WebCache.h b/Ryff/Frameworks/SDWebImage/UIButton+WebCache.h deleted file mode 100755 index 48ad0d5..0000000 --- a/Ryff/Frameworks/SDWebImage/UIButton+WebCache.h +++ /dev/null @@ -1,229 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import "SDWebImageCompat.h" -#import "SDWebImageManager.h" - -/** - * Integrates SDWebImage async downloading and caching of remote images with UIButtonView. - */ -@interface UIButton (WebCache) - -/** - * Get the current image URL. - */ -- (NSURL *)sd_currentImageURL; - -/** - * Get the image URL for a control state. - * - * @param state Which state you want to know the URL for. The values are described in UIControlState. - */ -- (NSURL *)sd_imageURLForState:(UIControlState)state; - -/** - * Set the imageView `image` with an `url`. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param state The state that uses the specified title. The values are described in UIControlState. - */ -- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state; - -/** - * Set the imageView `image` with an `url` and a placeholder. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param state The state that uses the specified title. The values are described in UIControlState. - * @param placeholder The image to be set initially, until the image request finishes. - * @see sd_setImageWithURL:placeholderImage:options: - */ -- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder; - -/** - * Set the imageView `image` with an `url`, placeholder and custom options. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param state The state that uses the specified title. The values are described in UIControlState. - * @param placeholder The image to be set initially, until the image request finishes. - * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. - */ -- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; - -/** - * Set the imageView `image` with an `url`. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param state The state that uses the specified title. The values are described in UIControlState. - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Set the imageView `image` with an `url`, placeholder. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param state The state that uses the specified title. The values are described in UIControlState. - * @param placeholder The image to be set initially, until the image request finishes. - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Set the imageView `image` with an `url`, placeholder and custom options. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param state The state that uses the specified title. The values are described in UIControlState. - * @param placeholder The image to be set initially, until the image request finishes. - * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Set the backgroundImageView `image` with an `url`. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param state The state that uses the specified title. The values are described in UIControlState. - */ -- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state; - -/** - * Set the backgroundImageView `image` with an `url` and a placeholder. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param state The state that uses the specified title. The values are described in UIControlState. - * @param placeholder The image to be set initially, until the image request finishes. - * @see sd_setImageWithURL:placeholderImage:options: - */ -- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder; - -/** - * Set the backgroundImageView `image` with an `url`, placeholder and custom options. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param state The state that uses the specified title. The values are described in UIControlState. - * @param placeholder The image to be set initially, until the image request finishes. - * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. - */ -- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; - -/** - * Set the backgroundImageView `image` with an `url`. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param state The state that uses the specified title. The values are described in UIControlState. - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Set the backgroundImageView `image` with an `url`, placeholder. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param state The state that uses the specified title. The values are described in UIControlState. - * @param placeholder The image to be set initially, until the image request finishes. - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Set the backgroundImageView `image` with an `url`, placeholder and custom options. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param placeholder The image to be set initially, until the image request finishes. - * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Cancel the current image download - */ -- (void)sd_cancelImageLoadForState:(UIControlState)state; - -/** - * Cancel the current backgroundImage download - */ -- (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state; - -@end - - -@interface UIButton (WebCacheDeprecated) - -- (NSURL *)currentImageURL __deprecated_msg("Use `sd_currentImageURL`"); -- (NSURL *)imageURLForState:(UIControlState)state __deprecated_msg("Use `sd_imageURLForState:`"); - -- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:`"); -- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:`"); -- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:options:`"); - -- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:completed:`"); -- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:completed:`"); -- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:options:completed:`"); - -- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:`"); -- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:`"); -- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:options:`"); - -- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:completed:`"); -- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:completed:`"); -- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:options:completed:`"); - -- (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelImageLoadForState:`"); -- (void)cancelBackgroundImageLoadForState:(UIControlState)state __deprecated_msg("Use `sd_cancelBackgroundImageLoadForState:`"); - -@end diff --git a/Ryff/Frameworks/SDWebImage/UIButton+WebCache.m b/Ryff/Frameworks/SDWebImage/UIButton+WebCache.m deleted file mode 100755 index 8e076ae..0000000 --- a/Ryff/Frameworks/SDWebImage/UIButton+WebCache.m +++ /dev/null @@ -1,260 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import "UIButton+WebCache.h" -#import "objc/runtime.h" -#import "UIView+WebCacheOperation.h" - -static char imageURLStorageKey; - -@implementation UIButton (WebCache) - -- (NSURL *)sd_currentImageURL { - NSURL *url = self.imageURLStorage[@(self.state)]; - - if (!url) { - url = self.imageURLStorage[@(UIControlStateNormal)]; - } - - return url; -} - -- (NSURL *)sd_imageURLForState:(UIControlState)state { - return self.imageURLStorage[@(state)]; -} - -- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state { - [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; -} - -- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { - [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; -} - -- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { - [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; -} - -- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock { - [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:completedBlock]; -} - -- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { - [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock]; -} - -- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { - - [self setImage:placeholder forState:state]; - [self sd_cancelImageLoadForState:state]; - - if (!url) { - [self.imageURLStorage removeObjectForKey:@(state)]; - - dispatch_main_async_safe(^{ - NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; - if (completedBlock) { - completedBlock(nil, error, SDImageCacheTypeNone, url); - } - }); - - return; - } - - self.imageURLStorage[@(state)] = url; - - __weak UIButton *wself = self; - id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { - if (!wself) return; - dispatch_main_sync_safe(^{ - __strong UIButton *sself = wself; - if (!sself) return; - if (image) { - [sself setImage:image forState:state]; - } - if (completedBlock && finished) { - completedBlock(image, error, cacheType, url); - } - }); - }]; - [self sd_setImageLoadOperation:operation forState:state]; -} - -- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state { - [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; -} - -- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { - [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; -} - -- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { - [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; -} - -- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletionBlock)completedBlock { - [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:completedBlock]; -} - -- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { - [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:completedBlock]; -} - -- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { - [self sd_cancelImageLoadForState:state]; - - [self setBackgroundImage:placeholder forState:state]; - - if (url) { - __weak UIButton *wself = self; - id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { - if (!wself) return; - dispatch_main_sync_safe(^{ - __strong UIButton *sself = wself; - if (!sself) return; - if (image) { - [sself setBackgroundImage:image forState:state]; - } - if (completedBlock && finished) { - completedBlock(image, error, cacheType, url); - } - }); - }]; - [self sd_setBackgroundImageLoadOperation:operation forState:state]; - } else { - dispatch_main_async_safe(^{ - NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; - if (completedBlock) { - completedBlock(nil, error, SDImageCacheTypeNone, url); - } - }); - } -} - -- (void)sd_setImageLoadOperation:(id)operation forState:(UIControlState)state { - [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; -} - -- (void)sd_cancelImageLoadForState:(UIControlState)state { - [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; -} - -- (void)sd_setBackgroundImageLoadOperation:(id)operation forState:(UIControlState)state { - [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; -} - -- (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state { - [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; -} - -- (NSMutableDictionary *)imageURLStorage { - NSMutableDictionary *storage = objc_getAssociatedObject(self, &imageURLStorageKey); - if (!storage) - { - storage = [NSMutableDictionary dictionary]; - objc_setAssociatedObject(self, &imageURLStorageKey, storage, OBJC_ASSOCIATION_RETAIN_NONATOMIC); - } - - return storage; -} - -@end - - -@implementation UIButton (WebCacheDeprecated) - -- (NSURL *)currentImageURL { - return [self sd_currentImageURL]; -} - -- (NSURL *)imageURLForState:(UIControlState)state { - return [self sd_imageURLForState:state]; -} - -- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state { - [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; -} - -- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { - [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; -} - -- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { - [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; -} - -- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock { - [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType); - } - }]; -} - -- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { - [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType); - } - }]; -} - -- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { - [self sd_setImageWithURL:url forState:state placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType); - } - }]; -} - -- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state { - [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; -} - -- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder { - [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:nil]; -} - -- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { - [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:nil]; -} - -- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state completed:(SDWebImageCompletedBlock)completedBlock { - [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType); - } - }]; -} - -- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { - [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType); - } - }]; -} - -- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { - [self sd_setBackgroundImageWithURL:url forState:state placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType); - } - }]; -} - -- (void)cancelCurrentImageLoad { - // in a backwards compatible manner, cancel for current state - [self sd_cancelImageLoadForState:self.state]; -} - -- (void)cancelBackgroundImageLoadForState:(UIControlState)state { - [self sd_cancelBackgroundImageLoadForState:state]; -} - -@end diff --git a/Ryff/Frameworks/SDWebImage/UIImage+GIF.h b/Ryff/Frameworks/SDWebImage/UIImage+GIF.h deleted file mode 100755 index 084f424..0000000 --- a/Ryff/Frameworks/SDWebImage/UIImage+GIF.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// UIImage+GIF.h -// LBGIFImage -// -// Created by Laurin Brandner on 06.01.12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import - -@interface UIImage (GIF) - -+ (UIImage *)sd_animatedGIFNamed:(NSString *)name; - -+ (UIImage *)sd_animatedGIFWithData:(NSData *)data; - -- (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size; - -@end diff --git a/Ryff/Frameworks/SDWebImage/UIImage+GIF.m b/Ryff/Frameworks/SDWebImage/UIImage+GIF.m deleted file mode 100755 index a703637..0000000 --- a/Ryff/Frameworks/SDWebImage/UIImage+GIF.m +++ /dev/null @@ -1,158 +0,0 @@ -// -// UIImage+GIF.m -// LBGIFImage -// -// Created by Laurin Brandner on 06.01.12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "UIImage+GIF.h" -#import - -@implementation UIImage (GIF) - -+ (UIImage *)sd_animatedGIFWithData:(NSData *)data { - if (!data) { - return nil; - } - - CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL); - - size_t count = CGImageSourceGetCount(source); - - UIImage *animatedImage; - - if (count <= 1) { - animatedImage = [[UIImage alloc] initWithData:data]; - } - else { - NSMutableArray *images = [NSMutableArray array]; - - NSTimeInterval duration = 0.0f; - - for (size_t i = 0; i < count; i++) { - CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL); - - duration += [self sd_frameDurationAtIndex:i source:source]; - - [images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]]; - - CGImageRelease(image); - } - - if (!duration) { - duration = (1.0f / 10.0f) * count; - } - - animatedImage = [UIImage animatedImageWithImages:images duration:duration]; - } - - CFRelease(source); - - return animatedImage; -} - -+ (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source { - float frameDuration = 0.1f; - CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil); - NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties; - NSDictionary *gifProperties = frameProperties[(NSString *)kCGImagePropertyGIFDictionary]; - - NSNumber *delayTimeUnclampedProp = gifProperties[(NSString *)kCGImagePropertyGIFUnclampedDelayTime]; - if (delayTimeUnclampedProp) { - frameDuration = [delayTimeUnclampedProp floatValue]; - } - else { - - NSNumber *delayTimeProp = gifProperties[(NSString *)kCGImagePropertyGIFDelayTime]; - if (delayTimeProp) { - frameDuration = [delayTimeProp floatValue]; - } - } - - // Many annoying ads specify a 0 duration to make an image flash as quickly as possible. - // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify - // a duration of <= 10 ms. See and - // for more information. - - if (frameDuration < 0.011f) { - frameDuration = 0.100f; - } - - CFRelease(cfFrameProperties); - return frameDuration; -} - -+ (UIImage *)sd_animatedGIFNamed:(NSString *)name { - CGFloat scale = [UIScreen mainScreen].scale; - - if (scale > 1.0f) { - NSString *retinaPath = [[NSBundle mainBundle] pathForResource:[name stringByAppendingString:@"@2x"] ofType:@"gif"]; - - NSData *data = [NSData dataWithContentsOfFile:retinaPath]; - - if (data) { - return [UIImage sd_animatedGIFWithData:data]; - } - - NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; - - data = [NSData dataWithContentsOfFile:path]; - - if (data) { - return [UIImage sd_animatedGIFWithData:data]; - } - - return [UIImage imageNamed:name]; - } - else { - NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; - - NSData *data = [NSData dataWithContentsOfFile:path]; - - if (data) { - return [UIImage sd_animatedGIFWithData:data]; - } - - return [UIImage imageNamed:name]; - } -} - -- (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size { - if (CGSizeEqualToSize(self.size, size) || CGSizeEqualToSize(size, CGSizeZero)) { - return self; - } - - CGSize scaledSize = size; - CGPoint thumbnailPoint = CGPointZero; - - CGFloat widthFactor = size.width / self.size.width; - CGFloat heightFactor = size.height / self.size.height; - CGFloat scaleFactor = (widthFactor > heightFactor) ? widthFactor : heightFactor; - scaledSize.width = self.size.width * scaleFactor; - scaledSize.height = self.size.height * scaleFactor; - - if (widthFactor > heightFactor) { - thumbnailPoint.y = (size.height - scaledSize.height) * 0.5; - } - else if (widthFactor < heightFactor) { - thumbnailPoint.x = (size.width - scaledSize.width) * 0.5; - } - - NSMutableArray *scaledImages = [NSMutableArray array]; - - UIGraphicsBeginImageContextWithOptions(size, NO, 0.0); - - for (UIImage *image in self.images) { - [image drawInRect:CGRectMake(thumbnailPoint.x, thumbnailPoint.y, scaledSize.width, scaledSize.height)]; - UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); - - [scaledImages addObject:newImage]; - } - - UIGraphicsEndImageContext(); - - return [UIImage animatedImageWithImages:scaledImages duration:self.duration]; -} - -@end diff --git a/Ryff/Frameworks/SDWebImage/UIImage+MultiFormat.h b/Ryff/Frameworks/SDWebImage/UIImage+MultiFormat.h deleted file mode 100755 index 186ebc0..0000000 --- a/Ryff/Frameworks/SDWebImage/UIImage+MultiFormat.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// UIImage+MultiFormat.h -// SDWebImage -// -// Created by Olivier Poitrey on 07/06/13. -// Copyright (c) 2013 Dailymotion. All rights reserved. -// - -#import - -@interface UIImage (MultiFormat) - -+ (UIImage *)sd_imageWithData:(NSData *)data; - -@end diff --git a/Ryff/Frameworks/SDWebImage/UIImage+MultiFormat.m b/Ryff/Frameworks/SDWebImage/UIImage+MultiFormat.m deleted file mode 100755 index 5395280..0000000 --- a/Ryff/Frameworks/SDWebImage/UIImage+MultiFormat.m +++ /dev/null @@ -1,114 +0,0 @@ -// -// UIImage+MultiFormat.m -// SDWebImage -// -// Created by Olivier Poitrey on 07/06/13. -// Copyright (c) 2013 Dailymotion. All rights reserved. -// - -#import "UIImage+MultiFormat.h" -#import "UIImage+GIF.h" -#import "NSData+ImageContentType.h" -#import - -#ifdef SD_WEBP -#import "UIImage+WebP.h" -#endif - -@implementation UIImage (MultiFormat) - -+ (UIImage *)sd_imageWithData:(NSData *)data { - UIImage *image; - NSString *imageContentType = [NSData sd_contentTypeForImageData:data]; - if ([imageContentType isEqualToString:@"image/gif"]) { - image = [UIImage sd_animatedGIFWithData:data]; - } -#ifdef SD_WEBP - else if ([imageContentType isEqualToString:@"image/webp"]) - { - image = [UIImage sd_imageWithWebPData:data]; - } -#endif - else { - image = [[UIImage alloc] initWithData:data]; - UIImageOrientation orientation = [self sd_imageOrientationFromImageData:data]; - if (orientation != UIImageOrientationUp) { - image = [UIImage imageWithCGImage:image.CGImage - scale:image.scale - orientation:orientation]; - } - } - - - return image; -} - - -+(UIImageOrientation)sd_imageOrientationFromImageData:(NSData *)imageData { - UIImageOrientation result = UIImageOrientationUp; - CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL); - if (imageSource) { - CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); - if (properties) { - CFTypeRef val; - int exifOrientation; - val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation); - if (val) { - CFNumberGetValue(val, kCFNumberIntType, &exifOrientation); - result = [self sd_exifOrientationToiOSOrientation:exifOrientation]; - } // else - if it's not set it remains at up - CFRelease((CFTypeRef) properties); - } else { - //NSLog(@"NO PROPERTIES, FAIL"); - } - CFRelease(imageSource); - } - return result; -} - -#pragma mark EXIF orientation tag converter -// Convert an EXIF image orientation to an iOS one. -// reference see here: http://sylvana.net/jpegcrop/exif_orientation.html -+ (UIImageOrientation) sd_exifOrientationToiOSOrientation:(int)exifOrientation { - UIImageOrientation orientation = UIImageOrientationUp; - switch (exifOrientation) { - case 1: - orientation = UIImageOrientationUp; - break; - - case 3: - orientation = UIImageOrientationDown; - break; - - case 8: - orientation = UIImageOrientationLeft; - break; - - case 6: - orientation = UIImageOrientationRight; - break; - - case 2: - orientation = UIImageOrientationUpMirrored; - break; - - case 4: - orientation = UIImageOrientationDownMirrored; - break; - - case 5: - orientation = UIImageOrientationLeftMirrored; - break; - - case 7: - orientation = UIImageOrientationRightMirrored; - break; - default: - break; - } - return orientation; -} - - - -@end diff --git a/Ryff/Frameworks/SDWebImage/UIImage+WebP.h b/Ryff/Frameworks/SDWebImage/UIImage+WebP.h deleted file mode 100755 index b791e6f..0000000 --- a/Ryff/Frameworks/SDWebImage/UIImage+WebP.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// UIImage+WebP.h -// SDWebImage -// -// Created by Olivier Poitrey on 07/06/13. -// Copyright (c) 2013 Dailymotion. All rights reserved. -// - -#ifdef SD_WEBP - -#import - -// Fix for issue #416 Undefined symbols for architecture armv7 since WebP introduction when deploying to device -void WebPInitPremultiplyNEON(void); - -void WebPInitUpsamplersNEON(void); - -void VP8DspInitNEON(void); - -@interface UIImage (WebP) - -+ (UIImage *)sd_imageWithWebPData:(NSData *)data; - -@end - -#endif diff --git a/Ryff/Frameworks/SDWebImage/UIImage+WebP.m b/Ryff/Frameworks/SDWebImage/UIImage+WebP.m deleted file mode 100755 index e6e8464..0000000 --- a/Ryff/Frameworks/SDWebImage/UIImage+WebP.m +++ /dev/null @@ -1,68 +0,0 @@ -// -// UIImage+WebP.m -// SDWebImage -// -// Created by Olivier Poitrey on 07/06/13. -// Copyright (c) 2013 Dailymotion. All rights reserved. -// - -#ifdef SD_WEBP -#import "UIImage+WebP.h" -#import "webp/decode.h" - -// Callback for CGDataProviderRelease -static void FreeImageData(void *info, const void *data, size_t size) -{ - free((void *)data); -} - -@implementation UIImage (WebP) - -+ (UIImage *)sd_imageWithWebPData:(NSData *)data { - WebPDecoderConfig config; - if (!WebPInitDecoderConfig(&config)) { - return nil; - } - - config.output.colorspace = MODE_rgbA; - config.options.use_threads = 1; - - // Decode the WebP image data into a RGBA value array. - if (WebPDecode(data.bytes, data.length, &config) != VP8_STATUS_OK) { - return nil; - } - - int width = config.input.width; - int height = config.input.height; - if (config.options.use_scaling) { - width = config.options.scaled_width; - height = config.options.scaled_height; - } - - // Construct a UIImage from the decoded RGBA value array. - CGDataProviderRef provider = - CGDataProviderCreateWithData(NULL, config.output.u.RGBA.rgba, config.output.u.RGBA.size, FreeImageData); - CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); - CGBitmapInfo bitmapInfo = kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast; - CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault; - CGImageRef imageRef = CGImageCreate(width, height, 8, 32, 4 * width, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent); - - CGColorSpaceRelease(colorSpaceRef); - CGDataProviderRelease(provider); - - UIImage *image = [[UIImage alloc] initWithCGImage:imageRef]; - CGImageRelease(imageRef); - - return image; -} - -@end - -#if !COCOAPODS -// Functions to resolve some undefined symbols when using WebP and force_load flag -void WebPInitPremultiplyNEON(void) {} -void WebPInitUpsamplersNEON(void) {} -void VP8DspInitNEON(void) {} -#endif - -#endif diff --git a/Ryff/Frameworks/SDWebImage/UIImageView+HighlightedWebCache.h b/Ryff/Frameworks/SDWebImage/UIImageView+HighlightedWebCache.h deleted file mode 100755 index 57f708f..0000000 --- a/Ryff/Frameworks/SDWebImage/UIImageView+HighlightedWebCache.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import -#import "SDWebImageCompat.h" -#import "SDWebImageManager.h" - -/** - * Integrates SDWebImage async downloading and caching of remote images with UIImageView for highlighted state. - */ -@interface UIImageView (HighlightedWebCache) - -/** - * Set the imageView `highlightedImage` with an `url`. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - */ -- (void)sd_setHighlightedImageWithURL:(NSURL *)url; - -/** - * Set the imageView `highlightedImage` with an `url` and custom options. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. - */ -- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options; - -/** - * Set the imageView `highlightedImage` with an `url`. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Set the imageView `highlightedImage` with an `url` and custom options. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Set the imageView `highlightedImage` with an `url` and custom options. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. - * @param progressBlock A block called while image is downloading - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Cancel the current download - */ -- (void)sd_cancelCurrentHighlightedImageLoad; - -@end - - -@interface UIImageView (HighlightedWebCacheDeprecated) - -- (void)setHighlightedImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:`"); -- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:`"); -- (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:completed:`"); -- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:completed:`"); -- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:progress:completed:`"); - -- (void)cancelCurrentHighlightedImageLoad __deprecated_msg("Use `sd_cancelCurrentHighlightedImageLoad`"); - -@end diff --git a/Ryff/Frameworks/SDWebImage/UIImageView+HighlightedWebCache.m b/Ryff/Frameworks/SDWebImage/UIImageView+HighlightedWebCache.m deleted file mode 100755 index ae73610..0000000 --- a/Ryff/Frameworks/SDWebImage/UIImageView+HighlightedWebCache.m +++ /dev/null @@ -1,107 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import "UIImageView+HighlightedWebCache.h" -#import "UIView+WebCacheOperation.h" - -#define UIImageViewHighlightedWebCacheOperationKey @"highlightedImage" - -@implementation UIImageView (HighlightedWebCache) - -- (void)sd_setHighlightedImageWithURL:(NSURL *)url { - [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; -} - -- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options { - [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; -} - -- (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock { - [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:completedBlock]; -} - -- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { - [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock]; -} - -- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { - [self sd_cancelCurrentHighlightedImageLoad]; - - if (url) { - __weak UIImageView *wself = self; - id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { - if (!wself) return; - dispatch_main_sync_safe (^ - { - if (!wself) return; - if (image) { - wself.highlightedImage = image; - [wself setNeedsLayout]; - } - if (completedBlock && finished) { - completedBlock(image, error, cacheType, url); - } - }); - }]; - [self sd_setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey]; - } else { - dispatch_main_async_safe(^{ - NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; - if (completedBlock) { - completedBlock(nil, error, SDImageCacheTypeNone, url); - } - }); - } -} - -- (void)sd_cancelCurrentHighlightedImageLoad { - [self sd_cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey]; -} - -@end - - -@implementation UIImageView (HighlightedWebCacheDeprecated) - -- (void)setHighlightedImageWithURL:(NSURL *)url { - [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; -} - -- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options { - [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; -} - -- (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock { - [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType); - } - }]; -} - -- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { - [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType); - } - }]; -} - -- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { - [self sd_setHighlightedImageWithURL:url options:0 progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType); - } - }]; -} - -- (void)cancelCurrentHighlightedImageLoad { - [self sd_cancelCurrentHighlightedImageLoad]; -} - -@end diff --git a/Ryff/Frameworks/SDWebImage/UIImageView+WebCache.h b/Ryff/Frameworks/SDWebImage/UIImageView+WebCache.h deleted file mode 100755 index e7489f4..0000000 --- a/Ryff/Frameworks/SDWebImage/UIImageView+WebCache.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import "SDWebImageCompat.h" -#import "SDWebImageManager.h" - -/** - * Integrates SDWebImage async downloading and caching of remote images with UIImageView. - * - * Usage with a UITableViewCell sub-class: - * - * @code - -#import - -... - -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -{ - static NSString *MyIdentifier = @"MyIdentifier"; - - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; - - if (cell == nil) { - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] - autorelease]; - } - - // Here we use the provided sd_setImageWithURL: method to load the web image - // Ensure you use a placeholder image otherwise cells will be initialized with no image - [cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"http://example.com/image.jpg"] - placeholderImage:[UIImage imageNamed:@"placeholder"]]; - - cell.textLabel.text = @"My Text"; - return cell; -} - - * @endcode - */ -@interface UIImageView (WebCache) - -/** - * Get the current image URL. - * - * Note that because of the limitations of categories this property can get out of sync - * if you use sd_setImage: directly. - */ -- (NSURL *)sd_imageURL; - -/** - * Set the imageView `image` with an `url`. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - */ -- (void)sd_setImageWithURL:(NSURL *)url; - -/** - * Set the imageView `image` with an `url` and a placeholder. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param placeholder The image to be set initially, until the image request finishes. - * @see sd_setImageWithURL:placeholderImage:options: - */ -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder; - -/** - * Set the imageView `image` with an `url`, placeholder and custom options. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param placeholder The image to be set initially, until the image request finishes. - * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. - */ -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; - -/** - * Set the imageView `image` with an `url`. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Set the imageView `image` with an `url`, placeholder. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param placeholder The image to be set initially, until the image request finishes. - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Set the imageView `image` with an `url`, placeholder and custom options. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param placeholder The image to be set initially, until the image request finishes. - * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Set the imageView `image` with an `url`, placeholder and custom options. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param placeholder The image to be set initially, until the image request finishes. - * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. - * @param progressBlock A block called while image is downloading - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Set the imageView `image` with an `url` and a optionaly placeholder image. - * - * The download is asynchronous and cached. - * - * @param url The url for the image. - * @param placeholder The image to be set initially, until the image request finishes. - * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. - * @param progressBlock A block called while image is downloading - * @param completedBlock A block called when operation has been completed. This block has no return value - * and takes the requested UIImage as first parameter. In case of error the image parameter - * is nil and the second parameter may contain an NSError. The third parameter is a Boolean - * indicating if the image was retrived from the local cache or from the network. - * The fourth parameter is the original image url. - */ -- (void)sd_setImageWithPreviousCachedImageWithURL:(NSURL *)url andPlaceholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; - -/** - * Download an array of images and starts them in an animation loop - * - * @param arrayOfURLs An array of NSURL - */ -- (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs; - -/** - * Cancel the current download - */ -- (void)sd_cancelCurrentImageLoad; - -- (void)sd_cancelCurrentAnimationImagesLoad; - -@end - - -@interface UIImageView (WebCacheDeprecated) - -- (NSURL *)imageURL __deprecated_msg("Use `sd_imageURL`"); - -- (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`"); -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`"); -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options`"); - -- (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:completed:`"); -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:completed:`"); -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`"); -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:progress:completed:`"); - -- (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs __deprecated_msg("Use `sd_setAnimationImagesWithURLs:`"); - -- (void)cancelCurrentArrayLoad __deprecated_msg("Use `sd_cancelCurrentAnimationImagesLoad`"); - -- (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelCurrentImageLoad`"); - -@end diff --git a/Ryff/Frameworks/SDWebImage/UIImageView+WebCache.m b/Ryff/Frameworks/SDWebImage/UIImageView+WebCache.m deleted file mode 100755 index 51663dd..0000000 --- a/Ryff/Frameworks/SDWebImage/UIImageView+WebCache.m +++ /dev/null @@ -1,195 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import "UIImageView+WebCache.h" -#import "objc/runtime.h" -#import "UIView+WebCacheOperation.h" - -static char imageURLKey; - -@implementation UIImageView (WebCache) - -- (void)sd_setImageWithURL:(NSURL *)url { - [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; -} - -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder { - [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil]; -} - -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { - [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil]; -} - -- (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock { - [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:completedBlock]; -} - -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { - [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:completedBlock]; -} - -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { - [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:completedBlock]; -} - -- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { - [self sd_cancelCurrentImageLoad]; - objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC); - - if (!(options & SDWebImageDelayPlaceholder)) { - self.image = placeholder; - } - - if (url) { - __weak UIImageView *wself = self; - id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { - if (!wself) return; - dispatch_main_sync_safe(^{ - if (!wself) return; - if (image) { - wself.image = image; - [wself setNeedsLayout]; - } else { - if ((options & SDWebImageDelayPlaceholder)) { - wself.image = placeholder; - [wself setNeedsLayout]; - } - } - if (completedBlock && finished) { - completedBlock(image, error, cacheType, url); - } - }); - }]; - [self sd_setImageLoadOperation:operation forKey:@"UIImageViewImageLoad"]; - } else { - dispatch_main_async_safe(^{ - NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; - if (completedBlock) { - completedBlock(nil, error, SDImageCacheTypeNone, url); - } - }); - } -} - -- (void)sd_setImageWithPreviousCachedImageWithURL:(NSURL *)url andPlaceholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { - NSString *key = [[SDWebImageManager sharedManager] cacheKeyForURL:url]; - UIImage *lastPreviousCachedImage = [[SDImageCache sharedImageCache] imageFromDiskCacheForKey:key]; - - [self sd_setImageWithURL:url placeholderImage:lastPreviousCachedImage ?: placeholder options:options progress:progressBlock completed:completedBlock]; -} - -- (NSURL *)sd_imageURL { - return objc_getAssociatedObject(self, &imageURLKey); -} - -- (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs { - [self sd_cancelCurrentAnimationImagesLoad]; - __weak UIImageView *wself = self; - - NSMutableArray *operationsArray = [[NSMutableArray alloc] init]; - - for (NSURL *logoImageURL in arrayOfURLs) { - id operation = [SDWebImageManager.sharedManager downloadImageWithURL:logoImageURL options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { - if (!wself) return; - dispatch_main_sync_safe(^{ - __strong UIImageView *sself = wself; - [sself stopAnimating]; - if (sself && image) { - NSMutableArray *currentImages = [[sself animationImages] mutableCopy]; - if (!currentImages) { - currentImages = [[NSMutableArray alloc] init]; - } - [currentImages addObject:image]; - - sself.animationImages = currentImages; - [sself setNeedsLayout]; - } - [sself startAnimating]; - }); - }]; - [operationsArray addObject:operation]; - } - - [self sd_setImageLoadOperation:[NSArray arrayWithArray:operationsArray] forKey:@"UIImageViewAnimationImages"]; -} - -- (void)sd_cancelCurrentImageLoad { - [self sd_cancelImageLoadOperationWithKey:@"UIImageViewImageLoad"]; -} - -- (void)sd_cancelCurrentAnimationImagesLoad { - [self sd_cancelImageLoadOperationWithKey:@"UIImageViewAnimationImages"]; -} - -@end - - -@implementation UIImageView (WebCacheDeprecated) - -- (NSURL *)imageURL { - return [self sd_imageURL]; -} - -- (void)setImageWithURL:(NSURL *)url { - [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; -} - -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder { - [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:nil]; -} - -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { - [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:nil]; -} - -- (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock { - [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType); - } - }]; -} - -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { - [self sd_setImageWithURL:url placeholderImage:placeholder options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType); - } - }]; -} - -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { - [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType); - } - }]; -} - -- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { - [self sd_setImageWithURL:url placeholderImage:placeholder options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { - if (completedBlock) { - completedBlock(image, error, cacheType); - } - }]; -} - -- (void)cancelCurrentArrayLoad { - [self sd_cancelCurrentAnimationImagesLoad]; -} - -- (void)cancelCurrentImageLoad { - [self sd_cancelCurrentImageLoad]; -} - -- (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs { - [self sd_setAnimationImagesWithURLs:arrayOfURLs]; -} - -@end diff --git a/Ryff/Frameworks/SDWebImage/UIView+WebCacheOperation.h b/Ryff/Frameworks/SDWebImage/UIView+WebCacheOperation.h deleted file mode 100755 index 6719036..0000000 --- a/Ryff/Frameworks/SDWebImage/UIView+WebCacheOperation.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import -#import "SDWebImageManager.h" - -@interface UIView (WebCacheOperation) - -/** - * Set the image load operation (storage in a UIView based dictionary) - * - * @param operation the operation - * @param key key for storing the operation - */ -- (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key; - -/** - * Cancel all operations for the current UIView and key - * - * @param key key for identifying the operations - */ -- (void)sd_cancelImageLoadOperationWithKey:(NSString *)key; - -/** - * Just remove the operations corresponding to the current UIView and key without cancelling them - * - * @param key key for identifying the operations - */ -- (void)sd_removeImageLoadOperationWithKey:(NSString *)key; - -@end diff --git a/Ryff/Frameworks/SDWebImage/UIView+WebCacheOperation.m b/Ryff/Frameworks/SDWebImage/UIView+WebCacheOperation.m deleted file mode 100755 index 9219478..0000000 --- a/Ryff/Frameworks/SDWebImage/UIView+WebCacheOperation.m +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of the SDWebImage package. - * (c) Olivier Poitrey - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#import "UIView+WebCacheOperation.h" -#import "objc/runtime.h" - -static char loadOperationKey; - -@implementation UIView (WebCacheOperation) - -- (NSMutableDictionary *)operationDictionary { - NSMutableDictionary *operations = objc_getAssociatedObject(self, &loadOperationKey); - if (operations) { - return operations; - } - operations = [NSMutableDictionary dictionary]; - objc_setAssociatedObject(self, &loadOperationKey, operations, OBJC_ASSOCIATION_RETAIN_NONATOMIC); - return operations; -} - -- (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key { - [self sd_cancelImageLoadOperationWithKey:key]; - NSMutableDictionary *operationDictionary = [self operationDictionary]; - [operationDictionary setObject:operation forKey:key]; -} - -- (void)sd_cancelImageLoadOperationWithKey:(NSString *)key { - // Cancel in progress downloader from queue - NSMutableDictionary *operationDictionary = [self operationDictionary]; - id operations = [operationDictionary objectForKey:key]; - if (operations) { - if ([operations isKindOfClass:[NSArray class]]) { - for (id operation in operations) { - if (operation) { - [operation cancel]; - } - } - } else if ([operations conformsToProtocol:@protocol(SDWebImageOperation)]){ - [(id) operations cancel]; - } - [operationDictionary removeObjectForKey:key]; - } -} - -- (void)sd_removeImageLoadOperationWithKey:(NSString *)key { - NSMutableDictionary *operationDictionary = [self operationDictionary]; - [operationDictionary removeObjectForKey:key]; -} - -@end diff --git a/Ryff/Frameworks/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h b/Ryff/Frameworks/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h deleted file mode 100755 index 312d680..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h +++ /dev/null @@ -1,76 +0,0 @@ -// AFNetworkActivityIndicatorManager.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import - -#import - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - -#import - -/** - `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a network request operation has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero. - - You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code: - - [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; - - By setting `isNetworkActivityIndicatorVisible` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself. - - See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: - http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 - */ -@interface AFNetworkActivityIndicatorManager : NSObject - -/** - A Boolean value indicating whether the manager is enabled. - - If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. - */ -@property (nonatomic, assign, getter = isEnabled) BOOL enabled; - -/** - A Boolean value indicating whether the network activity indicator is currently displayed in the status bar. - */ -@property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible; - -/** - Returns the shared network activity indicator manager object for the system. - - @return The systemwide network activity indicator manager. - */ -+ (instancetype)sharedManager; - -/** - Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. - */ -- (void)incrementActivityCount; - -/** - Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator. - */ -- (void)decrementActivityCount; - -@end - -#endif diff --git a/Ryff/Frameworks/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m b/Ryff/Frameworks/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m deleted file mode 100755 index c2d855a..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m +++ /dev/null @@ -1,171 +0,0 @@ -// AFNetworkActivityIndicatorManager.m -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import "AFNetworkActivityIndicatorManager.h" - -#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) - -#import "AFHTTPRequestOperation.h" - -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 -#import "AFURLSessionManager.h" -#endif - -static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17; - -static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) { - if ([[notification object] isKindOfClass:[AFURLConnectionOperation class]]) { - return [(AFURLConnectionOperation *)[notification object] request]; - } - -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 - if ([[notification object] respondsToSelector:@selector(originalRequest)]) { - return [(NSURLSessionTask *)[notification object] originalRequest]; - } -#endif - - return nil; -} - -@interface AFNetworkActivityIndicatorManager () -@property (readwrite, nonatomic, assign) NSInteger activityCount; -@property (readwrite, nonatomic, strong) NSTimer *activityIndicatorVisibilityTimer; -@property (readonly, nonatomic, getter = isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; - -- (void)updateNetworkActivityIndicatorVisibility; -- (void)updateNetworkActivityIndicatorVisibilityDelayed; -@end - -@implementation AFNetworkActivityIndicatorManager -@dynamic networkActivityIndicatorVisible; - -+ (instancetype)sharedManager { - static AFNetworkActivityIndicatorManager *_sharedManager = nil; - static dispatch_once_t oncePredicate; - dispatch_once(&oncePredicate, ^{ - _sharedManager = [[self alloc] init]; - }); - - return _sharedManager; -} - -+ (NSSet *)keyPathsForValuesAffectingIsNetworkActivityIndicatorVisible { - return [NSSet setWithObject:@"activityCount"]; -} - -- (id)init { - self = [super init]; - if (!self) { - return nil; - } - - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingOperationDidStartNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingOperationDidFinishNotification object:nil]; - -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidResumeNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidCompleteNotification object:nil]; -#endif - - return self; -} - -- (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; - - [_activityIndicatorVisibilityTimer invalidate]; -} - -- (void)updateNetworkActivityIndicatorVisibilityDelayed { - if (self.enabled) { - // Delay hiding of activity indicator for a short interval, to avoid flickering - if (![self isNetworkActivityIndicatorVisible]) { - [self.activityIndicatorVisibilityTimer invalidate]; - self.activityIndicatorVisibilityTimer = [NSTimer timerWithTimeInterval:kAFNetworkActivityIndicatorInvisibilityDelay target:self selector:@selector(updateNetworkActivityIndicatorVisibility) userInfo:nil repeats:NO]; - [[NSRunLoop mainRunLoop] addTimer:self.activityIndicatorVisibilityTimer forMode:NSRunLoopCommonModes]; - } else { - [self performSelectorOnMainThread:@selector(updateNetworkActivityIndicatorVisibility) withObject:nil waitUntilDone:NO modes:@[NSRunLoopCommonModes]]; - } - } -} - -- (BOOL)isNetworkActivityIndicatorVisible { - return self.activityCount > 0; -} - -- (void)updateNetworkActivityIndicatorVisibility { - [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]]; -} - -- (void)setActivityCount:(NSInteger)activityCount { - @synchronized(self) { - _activityCount = activityCount; - } - - dispatch_async(dispatch_get_main_queue(), ^{ - [self updateNetworkActivityIndicatorVisibilityDelayed]; - }); -} - -- (void)incrementActivityCount { - [self willChangeValueForKey:@"activityCount"]; - @synchronized(self) { - _activityCount++; - } - [self didChangeValueForKey:@"activityCount"]; - - dispatch_async(dispatch_get_main_queue(), ^{ - [self updateNetworkActivityIndicatorVisibilityDelayed]; - }); -} - -- (void)decrementActivityCount { - [self willChangeValueForKey:@"activityCount"]; - @synchronized(self) { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wgnu" - _activityCount = MAX(_activityCount - 1, 0); -#pragma clang diagnostic pop - } - [self didChangeValueForKey:@"activityCount"]; - - dispatch_async(dispatch_get_main_queue(), ^{ - [self updateNetworkActivityIndicatorVisibilityDelayed]; - }); -} - -- (void)networkRequestDidStart:(NSNotification *)notification { - if ([AFNetworkRequestFromNotification(notification) URL]) { - [self incrementActivityCount]; - } -} - -- (void)networkRequestDidFinish:(NSNotification *)notification { - if ([AFNetworkRequestFromNotification(notification) URL]) { - [self decrementActivityCount]; - } -} - -@end - -#endif diff --git a/Ryff/Frameworks/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h b/Ryff/Frameworks/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h deleted file mode 100755 index 1c1f8dd..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h +++ /dev/null @@ -1,64 +0,0 @@ -// UIActivityIndicatorView+AFNetworking.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import - -#import - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - -#import - -@class AFURLConnectionOperation; - -/** - This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a request operation or session task. - */ -@interface UIActivityIndicatorView (AFNetworking) - -///---------------------------------- -/// @name Animating for Session Tasks -///---------------------------------- - -/** - Binds the animating state to the state of the specified task. - - @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. - */ -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 -- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task; -#endif - -///--------------------------------------- -/// @name Animating for Request Operations -///--------------------------------------- - -/** - Binds the animating state to the execution state of the specified operation. - - @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled. - */ -- (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation; - -@end - -#endif diff --git a/Ryff/Frameworks/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m b/Ryff/Frameworks/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m deleted file mode 100755 index 6627dbb..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m +++ /dev/null @@ -1,97 +0,0 @@ -// UIActivityIndicatorView+AFNetworking.m -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import "UIActivityIndicatorView+AFNetworking.h" - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - -#import "AFHTTPRequestOperation.h" - -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 -#import "AFURLSessionManager.h" -#endif - -@implementation UIActivityIndicatorView (AFNetworking) - -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 -- (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; - - [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; - [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; - [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; - - if (task) { - if (task.state != NSURLSessionTaskStateCompleted) { - if (task.state == NSURLSessionTaskStateRunning) { - [self startAnimating]; - } else { - [self stopAnimating]; - } - - [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task]; - [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task]; - [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task]; - } - } -} -#endif - -#pragma mark - - -- (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation { - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; - - [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; - [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; - - if (operation) { - if (![operation isFinished]) { - if ([operation isExecuting]) { - [self startAnimating]; - } else { - [self stopAnimating]; - } - - [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingOperationDidStartNotification object:operation]; - [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingOperationDidFinishNotification object:operation]; - } - } -} - -#pragma mark - - -- (void)af_startAnimating { - dispatch_async(dispatch_get_main_queue(), ^{ - [self startAnimating]; - }); -} - -- (void)af_stopAnimating { - dispatch_async(dispatch_get_main_queue(), ^{ - [self stopAnimating]; - }); -} - -@end - -#endif diff --git a/Ryff/Frameworks/UIKit+AFNetworking/UIAlertView+AFNetworking.h b/Ryff/Frameworks/UIKit+AFNetworking/UIAlertView+AFNetworking.h deleted file mode 100755 index b94f1cb..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/UIAlertView+AFNetworking.h +++ /dev/null @@ -1,96 +0,0 @@ -// UIAlertView+AFNetworking.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import - -#import - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - -#import - -@class AFURLConnectionOperation; - -/** - This category adds methods to the UIKit framework's `UIAlertView` class. The methods in this category provide support for automatically showing an alert if a session task or request operation finishes with an error. Alert title and message are filled from the corresponding `localizedDescription` & `localizedRecoverySuggestion` or `localizedFailureReason` of the error. - */ -@interface UIAlertView (AFNetworking) - -///------------------------------------- -/// @name Showing Alert for Session Task -///------------------------------------- - -/** - Shows an alert view with the error of the specified session task, if any. - - @param task The session task. - @param delegate The alert view delegate. - */ -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 -+ (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task - delegate:(id)delegate; -#endif - -/** - Shows an alert view with the error of the specified session task, if any, with a custom cancel button title and other button titles. - - @param task The session task. - @param delegate The alert view delegate. - @param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title. - @param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`. - */ -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 -+ (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task - delegate:(id)delegate - cancelButtonTitle:(NSString *)cancelButtonTitle - otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION; -#endif - -///------------------------------------------ -/// @name Showing Alert for Request Operation -///------------------------------------------ - -/** - Shows an alert view with the error of the specified request operation, if any. - - @param operation The request operation. - @param delegate The alert view delegate. - */ -+ (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation - delegate:(id)delegate; - -/** - Shows an alert view with the error of the specified request operation, if any, with a custom cancel button title and other button titles. - - @param operation The request operation. - @param delegate The alert view delegate. - @param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title. - @param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`. - */ -+ (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation - delegate:(id)delegate - cancelButtonTitle:(NSString *)cancelButtonTitle - otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION; - -@end - -#endif diff --git a/Ryff/Frameworks/UIKit+AFNetworking/UIAlertView+AFNetworking.m b/Ryff/Frameworks/UIKit+AFNetworking/UIAlertView+AFNetworking.m deleted file mode 100755 index b7e2a26..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/UIAlertView+AFNetworking.m +++ /dev/null @@ -1,111 +0,0 @@ -// UIAlertView+AFNetworking.m -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import "UIAlertView+AFNetworking.h" - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - -#import "AFURLConnectionOperation.h" - -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 -#import "AFURLSessionManager.h" -#endif - -static void AFGetAlertViewTitleAndMessageFromError(NSError *error, NSString * __autoreleasing *title, NSString * __autoreleasing *message) { - if (error.localizedDescription && (error.localizedRecoverySuggestion || error.localizedFailureReason)) { - *title = error.localizedDescription; - - if (error.localizedRecoverySuggestion) { - *message = error.localizedRecoverySuggestion; - } else { - *message = error.localizedFailureReason; - } - } else if (error.localizedDescription) { - *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description"); - *message = error.localizedDescription; - } else { - *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description"); - *message = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%@ Error: %ld", @"AFNetworking", @"Fallback Error Failure Reason Format"), error.domain, (long)error.code]; - } -} - -@implementation UIAlertView (AFNetworking) - -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 -+ (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task - delegate:(id)delegate -{ - [self showAlertViewForTaskWithErrorOnCompletion:task delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil]; -} - -+ (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task - delegate:(id)delegate - cancelButtonTitle:(NSString *)cancelButtonTitle - otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION -{ - __block id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingTaskDidCompleteNotification object:task queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { - - NSError *error = notification.userInfo[AFNetworkingTaskDidCompleteErrorKey]; - if (error) { - NSString *title, *message; - AFGetAlertViewTitleAndMessageFromError(error, &title, &message); - - [[[UIAlertView alloc] initWithTitle:title message:message delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:otherButtonTitles, nil] show]; - } - - [[NSNotificationCenter defaultCenter] removeObserver:observer name:AFNetworkingTaskDidCompleteNotification object:notification.object]; - }]; -} -#endif - -#pragma mark - - -+ (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation - delegate:(id)delegate -{ - [self showAlertViewForRequestOperationWithErrorOnCompletion:operation delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlert View Cancel Button Title") otherButtonTitles:nil, nil]; -} - -+ (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation - delegate:(id)delegate - cancelButtonTitle:(NSString *)cancelButtonTitle - otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION -{ - __block id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingOperationDidFinishNotification object:operation queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { - - if (notification.object && [notification.object isKindOfClass:[AFURLConnectionOperation class]]) { - NSError *error = [(AFURLConnectionOperation *)notification.object error]; - if (error) { - NSString *title, *message; - AFGetAlertViewTitleAndMessageFromError(error, &title, &message); - - [[[UIAlertView alloc] initWithTitle:title message:message delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:otherButtonTitles, nil] show]; - } - } - - [[NSNotificationCenter defaultCenter] removeObserver:observer name:AFNetworkingOperationDidFinishNotification object:notification.object]; - }]; -} - -@end - -#endif diff --git a/Ryff/Frameworks/UIKit+AFNetworking/UIButton+AFNetworking.h b/Ryff/Frameworks/UIKit+AFNetworking/UIButton+AFNetworking.h deleted file mode 100755 index fd89ecd..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/UIButton+AFNetworking.h +++ /dev/null @@ -1,146 +0,0 @@ -// UIButton+AFNetworking.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import - -#import - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - -#import - -/** - This category adds methods to the UIKit framework's `UIButton` class. The methods in this category provide support for loading remote images and background images asynchronously from a URL. - */ -@interface UIButton (AFNetworking) - -///-------------------- -/// @name Setting Image -///-------------------- - -/** - Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. - - If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. - - @param state The control state. - @param url The URL used for the image request. - */ -- (void)setImageForState:(UIControlState)state - withURL:(NSURL *)url; - -/** - Asynchronously downloads an image from the specified URL, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. - - If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. - - @param state The control state. - @param url The URL used for the image request. - @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes. - */ -- (void)setImageForState:(UIControlState)state - withURL:(NSURL *)url - placeholderImage:(UIImage *)placeholderImage; - -/** - Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. - - If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. - - If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setImage:forState:` is applied. - - @param state The control state. - @param urlRequest The URL request used for the image request. - @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the button will not change its image until the image request finishes. - @param success A block to be executed when the image request operation finishes successfully. This block has no return value and takes two arguments: the server response and the image. If the image was returned from cache, the request and response parameters will be `nil`. - @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes a single argument: the error that occurred. - */ -- (void)setImageForState:(UIControlState)state - withURLRequest:(NSURLRequest *)urlRequest - placeholderImage:(UIImage *)placeholderImage - success:(void (^)(NSHTTPURLResponse *response, UIImage *image))success - failure:(void (^)(NSError *error))failure; - - -///------------------------------- -/// @name Setting Background Image -///------------------------------- - -/** - Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous background image request for the receiver will be cancelled. - - If the background image is cached locally, the background image is set immediately, otherwise the specified placeholder background image will be set immediately, and then the remote background image will be set once the request is finished. - - @param state The control state. - @param url The URL used for the background image request. - */ -- (void)setBackgroundImageForState:(UIControlState)state - withURL:(NSURL *)url; - -/** - Asynchronously downloads an image from the specified URL, and sets it as the background image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. - - If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. - - @param state The control state. - @param url The URL used for the background image request. - @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes. - */ -- (void)setBackgroundImageForState:(UIControlState)state - withURL:(NSURL *)url - placeholderImage:(UIImage *)placeholderImage; - -/** - Asynchronously downloads an image from the specified URL request, and sets it as the image for the specified state once the request is finished. Any previous image request for the receiver will be cancelled. - - If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. - - If a success block is specified, it is the responsibility of the block to set the image of the button before returning. If no success block is specified, the default behavior of setting the image with `setBackgroundImage:forState:` is applied. - - @param state The control state. - @param urlRequest The URL request used for the image request. - @param placeholderImage The background image to be set initially, until the background image request finishes. If `nil`, the button will not change its background image until the background image request finishes. - */ -- (void)setBackgroundImageForState:(UIControlState)state - withURLRequest:(NSURLRequest *)urlRequest - placeholderImage:(UIImage *)placeholderImage - success:(void (^)(NSHTTPURLResponse *response, UIImage *image))success - failure:(void (^)(NSError *error))failure; - - -///------------------------------ -/// @name Canceling Image Loading -///------------------------------ - -/** - Cancels any executing image operation for the receiver, if one exists. - */ -- (void)cancelImageRequestOperation; - -/** - Cancels any executing background image operation for the receiver, if one exists. - */ -- (void)cancelBackgroundImageRequestOperation; - -@end - -#endif diff --git a/Ryff/Frameworks/UIKit+AFNetworking/UIButton+AFNetworking.m b/Ryff/Frameworks/UIKit+AFNetworking/UIButton+AFNetworking.m deleted file mode 100755 index 689ae9a..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/UIButton+AFNetworking.m +++ /dev/null @@ -1,185 +0,0 @@ -// UIButton+AFNetworking.m -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import "UIButton+AFNetworking.h" - -#import - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - -#import "AFHTTPRequestOperation.h" - -@interface UIButton (_AFNetworking) -@property (readwrite, nonatomic, strong, setter = af_setImageRequestOperation:) AFHTTPRequestOperation *af_imageRequestOperation; -@property (readwrite, nonatomic, strong, setter = af_setBackgroundImageRequestOperation:) AFHTTPRequestOperation *af_backgroundImageRequestOperation; -@end - -@implementation UIButton (_AFNetworking) - -+ (NSOperationQueue *)af_sharedImageRequestOperationQueue { - static NSOperationQueue *_af_sharedImageRequestOperationQueue = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - _af_sharedImageRequestOperationQueue = [[NSOperationQueue alloc] init]; - _af_sharedImageRequestOperationQueue.maxConcurrentOperationCount = NSOperationQueueDefaultMaxConcurrentOperationCount; - }); - - return _af_sharedImageRequestOperationQueue; -} - -- (AFHTTPRequestOperation *)af_imageRequestOperation { - return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_imageRequestOperation)); -} - -- (void)af_setImageRequestOperation:(AFHTTPRequestOperation *)imageRequestOperation { - objc_setAssociatedObject(self, @selector(af_imageRequestOperation), imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - -- (AFHTTPRequestOperation *)af_backgroundImageRequestOperation { - return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_backgroundImageRequestOperation)); -} - -- (void)af_setBackgroundImageRequestOperation:(AFHTTPRequestOperation *)imageRequestOperation { - objc_setAssociatedObject(self, @selector(af_backgroundImageRequestOperation), imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - -@end - -#pragma mark - - -@implementation UIButton (AFNetworking) - -- (void)setImageForState:(UIControlState)state - withURL:(NSURL *)url -{ - [self setImageForState:state withURL:url placeholderImage:nil]; -} - -- (void)setImageForState:(UIControlState)state - withURL:(NSURL *)url - placeholderImage:(UIImage *)placeholderImage -{ - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; - [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; - - [self setImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; -} - -- (void)setImageForState:(UIControlState)state - withURLRequest:(NSURLRequest *)urlRequest - placeholderImage:(UIImage *)placeholderImage - success:(void (^)(NSHTTPURLResponse *response, UIImage *image))success - failure:(void (^)(NSError *error))failure -{ - [self cancelImageRequestOperation]; - - [self setImage:placeholderImage forState:state]; - - __weak __typeof(self)weakSelf = self; - self.af_imageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; - self.af_imageRequestOperation.responseSerializer = [AFImageResponseSerializer serializer]; - [self.af_imageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { - __strong __typeof(weakSelf)strongSelf = weakSelf; - if ([[urlRequest URL] isEqual:[operation.request URL]]) { - if (success) { - success(operation.response, responseObject); - } else if (responseObject) { - [strongSelf setImage:responseObject forState:state]; - } - } - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { - if ([[urlRequest URL] isEqual:[operation.response URL]]) { - if (failure) { - failure(error); - } - } - }]; - - [[[self class] af_sharedImageRequestOperationQueue] addOperation:self.af_imageRequestOperation]; -} - -#pragma mark - - -- (void)setBackgroundImageForState:(UIControlState)state - withURL:(NSURL *)url -{ - [self setBackgroundImageForState:state withURL:url placeholderImage:nil]; -} - -- (void)setBackgroundImageForState:(UIControlState)state - withURL:(NSURL *)url - placeholderImage:(UIImage *)placeholderImage -{ - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; - [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; - - [self setBackgroundImageForState:state withURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; -} - -- (void)setBackgroundImageForState:(UIControlState)state - withURLRequest:(NSURLRequest *)urlRequest - placeholderImage:(UIImage *)placeholderImage - success:(void (^)(NSHTTPURLResponse *response, UIImage *image))success - failure:(void (^)(NSError *error))failure -{ - [self cancelBackgroundImageRequestOperation]; - - [self setBackgroundImage:placeholderImage forState:state]; - - __weak __typeof(self)weakSelf = self; - self.af_backgroundImageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; - self.af_backgroundImageRequestOperation.responseSerializer = [AFImageResponseSerializer serializer]; - [self.af_backgroundImageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { - __strong __typeof(weakSelf)strongSelf = weakSelf; - if ([[urlRequest URL] isEqual:[operation.request URL]]) { - if (success) { - success(operation.response, responseObject); - } else if (responseObject) { - [strongSelf setBackgroundImage:responseObject forState:state]; - } - } - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { - if ([[urlRequest URL] isEqual:[operation.response URL]]) { - if (failure) { - failure(error); - } - } - }]; - - [[[self class] af_sharedImageRequestOperationQueue] addOperation:self.af_backgroundImageRequestOperation]; -} - -#pragma mark - - -- (void)cancelImageRequestOperation { - [self.af_imageRequestOperation cancel]; - self.af_imageRequestOperation = nil; -} - -- (void)cancelBackgroundImageRequestOperation { - [self.af_backgroundImageRequestOperation cancel]; - self.af_backgroundImageRequestOperation = nil; -} - -@end - -#endif diff --git a/Ryff/Frameworks/UIKit+AFNetworking/UIImageView+AFNetworking.h b/Ryff/Frameworks/UIKit+AFNetworking/UIImageView+AFNetworking.h deleted file mode 100755 index 40188c3..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/UIImageView+AFNetworking.h +++ /dev/null @@ -1,147 +0,0 @@ -// UIImageView+AFNetworking.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import - -#import - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - -#import - -@protocol AFURLResponseSerialization, AFImageCache; - -/** - This category adds methods to the UIKit framework's `UIImageView` class. The methods in this category provide support for loading remote images asynchronously from a URL. - */ -@interface UIImageView (AFNetworking) - -+ (void)clearImageCacheForURL:(NSURL *)url; - -///---------------------------- -/// @name Accessing Image Cache -///---------------------------- - -/** - The image cache used to improve image loadiing performance on scroll views. By default, this is an `NSCache` subclass conforming to the `AFImageCache` protocol, which listens for notification warnings and evicts objects accordingly. -*/ -+ (id )sharedImageCache; - -/** - Set the cache used for image loading. - - @param imageCache The image cache. - */ -+ (void)setSharedImageCache:(id )imageCache; - -///------------------------------------ -/// @name Accessing Response Serializer -///------------------------------------ - -/** - The response serializer used to create an image representation from the server response and response data. By default, this is an instance of `AFImageResponseSerializer`. - - @discussion Subclasses of `AFImageResponseSerializer` could be used to perform post-processing, such as color correction, face detection, or other effects. See https://github.com/AFNetworking/AFCoreImageSerializer - */ -@property (nonatomic, strong) id imageResponseSerializer; - -///-------------------- -/// @name Setting Image -///-------------------- - -/** - Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. - - If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. - - By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` - - @param url The URL used for the image request. - */ -- (void)setImageWithURL:(NSURL *)url; - -/** - Asynchronously downloads an image from the specified URL, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. - - If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. - - By default, URL requests have a `Accept` header field value of "image / *", a cache policy of `NSURLCacheStorageAllowed` and a timeout interval of 30 seconds, and are set not handle cookies. To configure URL requests differently, use `setImageWithURLRequest:placeholderImage:success:failure:` - - @param url The URL used for the image request. - @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. - */ -- (void)setImageWithURL:(NSURL *)url - placeholderImage:(UIImage *)placeholderImage; - -/** - Asynchronously downloads an image from the specified URL request, and sets it once the request is finished. Any previous image request for the receiver will be cancelled. - - If the image is cached locally, the image is set immediately, otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the request is finished. - - If a success block is specified, it is the responsibility of the block to set the image of the image view before returning. If no success block is specified, the default behavior of setting the image with `self.image = image` is applied. - - @param urlRequest The URL request used for the image request. - @param placeholderImage The image to be set initially, until the image request finishes. If `nil`, the image view will not change its image until the image request finishes. - @param success A block to be executed when the image request operation finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the image created from the response data of request. If the image was returned from cache, the request and response parameters will be `nil`. - @param failure A block object to be executed when the image request operation finishes unsuccessfully, or that finishes successfully. This block has no return value and takes three arguments: the request sent from the client, the response received from the server, and the error object describing the network or parsing error that occurred. - */ -- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest - placeholderImage:(UIImage *)placeholderImage - success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success - failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; - -/** - Cancels any executing image operation for the receiver, if one exists. - */ -- (void)cancelImageRequestOperation; - -@end - -#pragma mark - - -/** - The `AFImageCache` protocol is adopted by an object used to cache images loaded by the AFNetworking category on `UIImageView`. - */ -@protocol AFImageCache - -- (void)clearCachedRequest:(NSURLRequest *)request; - -/** - Returns a cached image for the specififed request, if available. - - @param request The image request. - - @return The cached image. - */ -- (UIImage *)cachedImageForRequest:(NSURLRequest *)request; - -/** - Caches a particular image for the specified request. - - @param image The image to cache. - @param request The request to be used as a cache key. - */ -- (void)cacheImage:(UIImage *)image - forRequest:(NSURLRequest *)request; -@end - -#endif diff --git a/Ryff/Frameworks/UIKit+AFNetworking/UIImageView+AFNetworking.m b/Ryff/Frameworks/UIKit+AFNetworking/UIImageView+AFNetworking.m deleted file mode 100755 index f815e69..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/UIImageView+AFNetworking.m +++ /dev/null @@ -1,231 +0,0 @@ -// UIImageView+AFNetworking.m -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import "UIImageView+AFNetworking.h" - -#import - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - -#import "AFHTTPRequestOperation.h" - -@interface AFImageCache : NSCache -@end - -#pragma mark - - -@interface UIImageView (_AFNetworking) -@property (readwrite, nonatomic, strong, setter = af_setImageRequestOperation:) AFHTTPRequestOperation *af_imageRequestOperation; -@end - -@implementation UIImageView (_AFNetworking) - -+ (NSOperationQueue *)af_sharedImageRequestOperationQueue { - static NSOperationQueue *_af_sharedImageRequestOperationQueue = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - _af_sharedImageRequestOperationQueue = [[NSOperationQueue alloc] init]; - _af_sharedImageRequestOperationQueue.maxConcurrentOperationCount = NSOperationQueueDefaultMaxConcurrentOperationCount; - }); - - return _af_sharedImageRequestOperationQueue; -} - -- (AFHTTPRequestOperation *)af_imageRequestOperation { - return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_imageRequestOperation)); -} - -- (void)af_setImageRequestOperation:(AFHTTPRequestOperation *)imageRequestOperation { - objc_setAssociatedObject(self, @selector(af_imageRequestOperation), imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - -@end - -#pragma mark - - -@implementation UIImageView (AFNetworking) - -+ (void)clearImageCacheForURL:(NSURL *)url { - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; - [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; - - UIImage *cachedImage = [[self sharedImageCache] cachedImageForRequest:request]; - if (cachedImage) { - [[self sharedImageCache] clearCachedRequest:request]; - } -} - -@dynamic imageResponseSerializer; - -+ (id )sharedImageCache { - static AFImageCache *_af_defaultImageCache = nil; - static dispatch_once_t oncePredicate; - dispatch_once(&oncePredicate, ^{ - _af_defaultImageCache = [[AFImageCache alloc] init]; - - [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidReceiveMemoryWarningNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * __unused notification) { - [_af_defaultImageCache removeAllObjects]; - }]; - }); - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wgnu" - return objc_getAssociatedObject(self, @selector(sharedImageCache)) ?: _af_defaultImageCache; -#pragma clang diagnostic pop -} - -+ (void)setSharedImageCache:(id)imageCache { - objc_setAssociatedObject(self, @selector(sharedImageCache), imageCache, OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - -- (id )imageResponseSerializer { - static id _af_defaultImageResponseSerializer = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - _af_defaultImageResponseSerializer = [AFImageResponseSerializer serializer]; - }); - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wgnu" - return objc_getAssociatedObject(self, @selector(imageResponseSerializer)) ?: _af_defaultImageResponseSerializer; -#pragma clang diagnostic pop -} - -- (void)setImageResponseSerializer:(id )serializer { - objc_setAssociatedObject(self, @selector(imageResponseSerializer), serializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - -#pragma mark - - -- (void)setImageWithURL:(NSURL *)url { - [self setImageWithURL:url placeholderImage:nil]; -} - -- (void)setImageWithURL:(NSURL *)url - placeholderImage:(UIImage *)placeholderImage -{ - NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; - [request addValue:@"image/*" forHTTPHeaderField:@"Accept"]; - - [self setImageWithURLRequest:request placeholderImage:placeholderImage success:nil failure:nil]; -} - -- (void)setImageWithURLRequest:(NSURLRequest *)urlRequest - placeholderImage:(UIImage *)placeholderImage - success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success - failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure -{ - [self cancelImageRequestOperation]; - - UIImage *cachedImage = [[[self class] sharedImageCache] cachedImageForRequest:urlRequest]; - if (cachedImage) { - if (success) { - success(nil, nil, cachedImage); - } else { - self.image = cachedImage; - } - - self.af_imageRequestOperation = nil; - } else { - if (placeholderImage) { - self.image = placeholderImage; - } - - __weak __typeof(self)weakSelf = self; - self.af_imageRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; - self.af_imageRequestOperation.responseSerializer = self.imageResponseSerializer; - [self.af_imageRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { - __strong __typeof(weakSelf)strongSelf = weakSelf; - if ([[urlRequest URL] isEqual:[strongSelf.af_imageRequestOperation.request URL]]) { - if (success) { - success(urlRequest, operation.response, responseObject); - } else if (responseObject) { - strongSelf.image = responseObject; - } - - if (operation == strongSelf.af_imageRequestOperation){ - strongSelf.af_imageRequestOperation = nil; - } - } - - [[[strongSelf class] sharedImageCache] cacheImage:responseObject forRequest:urlRequest]; - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { - __strong __typeof(weakSelf)strongSelf = weakSelf; - if ([[urlRequest URL] isEqual:[strongSelf.af_imageRequestOperation.request URL]]) { - if (failure) { - failure(urlRequest, operation.response, error); - } - - if (operation == strongSelf.af_imageRequestOperation){ - strongSelf.af_imageRequestOperation = nil; - } - } - }]; - - [[[self class] af_sharedImageRequestOperationQueue] addOperation:self.af_imageRequestOperation]; - } -} - -- (void)cancelImageRequestOperation { - [self.af_imageRequestOperation cancel]; - self.af_imageRequestOperation = nil; -} - -@end - -#pragma mark - - -static inline NSString * AFImageCacheKeyFromURLRequest(NSURLRequest *request) { - return [[request URL] absoluteString]; -} - -@implementation AFImageCache - -- (void)clearCachedRequest:(NSURLRequest *)request { - if (request) { - [self removeObjectForKey:AFImageCacheKeyFromURLRequest(request)]; - } -} - -- (UIImage *)cachedImageForRequest:(NSURLRequest *)request { - switch ([request cachePolicy]) { - case NSURLRequestReloadIgnoringCacheData: - case NSURLRequestReloadIgnoringLocalAndRemoteCacheData: - return nil; - default: - break; - } - - return [self objectForKey:AFImageCacheKeyFromURLRequest(request)]; -} - -- (void)cacheImage:(UIImage *)image - forRequest:(NSURLRequest *)request -{ - if (image && request) { - [self setObject:image forKey:AFImageCacheKeyFromURLRequest(request)]; - } -} - -@end - -#endif diff --git a/Ryff/Frameworks/UIKit+AFNetworking/UIKit+AFNetworking.h b/Ryff/Frameworks/UIKit+AFNetworking/UIKit+AFNetworking.h deleted file mode 100755 index 94082f6..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/UIKit+AFNetworking.h +++ /dev/null @@ -1,38 +0,0 @@ -// UIKit+AFNetworking.h -// -// Copyright (c) 2013 AFNetworking (http://afnetworking.com/) -// -// 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. - -#import - -#ifndef _UIKIT_AFNETWORKING_ - #define _UIKIT_AFNETWORKING_ - - #import "AFNetworkActivityIndicatorManager.h" - - #import "UIActivityIndicatorView+AFNetworking.h" - #import "UIAlertView+AFNetworking.h" - #import "UIButton+AFNetworking.h" - #import "UIImageView+AFNetworking.h" - #import "UIKit+AFNetworking.h" - #import "UIProgressView+AFNetworking.h" - #import "UIRefreshControl+AFNetworking.h" - #import "UIWebView+AFNetworking.h" -#endif /* _UIKIT_AFNETWORKING_ */ diff --git a/Ryff/Frameworks/UIKit+AFNetworking/UIProgressView+AFNetworking.h b/Ryff/Frameworks/UIKit+AFNetworking/UIProgressView+AFNetworking.h deleted file mode 100755 index 3f1bc08..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/UIProgressView+AFNetworking.h +++ /dev/null @@ -1,88 +0,0 @@ -// UIProgressView+AFNetworking.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import - -#import - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - -#import - -@class AFURLConnectionOperation; - -/** - This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task or request operation. - */ -@interface UIProgressView (AFNetworking) - -///------------------------------------ -/// @name Setting Session Task Progress -///------------------------------------ - -/** - Binds the progress to the upload progress of the specified session task. - - @param task The session task. - @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. - */ -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 -- (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task - animated:(BOOL)animated; -#endif - -/** - Binds the progress to the download progress of the specified session task. - - @param task The session task. - @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. - */ -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 -- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task - animated:(BOOL)animated; -#endif - -///------------------------------------ -/// @name Setting Session Task Progress -///------------------------------------ - -/** - Binds the progress to the upload progress of the specified request operation. - - @param operation The request operation. - @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. - */ -- (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation - animated:(BOOL)animated; - -/** - Binds the progress to the download progress of the specified request operation. - - @param operation The request operation. - @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. - */ -- (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation - animated:(BOOL)animated; - -@end - -#endif diff --git a/Ryff/Frameworks/UIKit+AFNetworking/UIProgressView+AFNetworking.m b/Ryff/Frameworks/UIKit+AFNetworking/UIProgressView+AFNetworking.m deleted file mode 100755 index 7281149..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/UIProgressView+AFNetworking.m +++ /dev/null @@ -1,183 +0,0 @@ -// UIProgressView+AFNetworking.m -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import "UIProgressView+AFNetworking.h" - -#import - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - -#import "AFURLConnectionOperation.h" - -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 -#import "AFURLSessionManager.h" -#endif - -static void * AFTaskCountOfBytesSentContext = &AFTaskCountOfBytesSentContext; -static void * AFTaskCountOfBytesReceivedContext = &AFTaskCountOfBytesReceivedContext; - -@interface AFURLConnectionOperation (_UIProgressView) -@property (readwrite, nonatomic, copy) void (^uploadProgress)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); -@property (readwrite, nonatomic, assign, setter = af_setUploadProgressAnimated:) BOOL af_uploadProgressAnimated; - -@property (readwrite, nonatomic, copy) void (^downloadProgress)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); -@property (readwrite, nonatomic, assign, setter = af_setDownloadProgressAnimated:) BOOL af_downloadProgressAnimated; -@end - -@implementation AFURLConnectionOperation (_UIProgressView) -@dynamic uploadProgress; // Implemented in AFURLConnectionOperation -@dynamic af_uploadProgressAnimated; - -@dynamic downloadProgress; // Implemented in AFURLConnectionOperation -@dynamic af_downloadProgressAnimated; -@end - -#pragma mark - - -@implementation UIProgressView (AFNetworking) - -- (BOOL)af_uploadProgressAnimated { - return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_uploadProgressAnimated)) boolValue]; -} - -- (void)af_setUploadProgressAnimated:(BOOL)animated { - objc_setAssociatedObject(self, @selector(af_uploadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - -- (BOOL)af_downloadProgressAnimated { - return [(NSNumber *)objc_getAssociatedObject(self, @selector(af_downloadProgressAnimated)) boolValue]; -} - -- (void)af_setDownloadProgressAnimated:(BOOL)animated { - objc_setAssociatedObject(self, @selector(af_downloadProgressAnimated), @(animated), OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - -#pragma mark - - -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 -- (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task - animated:(BOOL)animated -{ - [task addObserver:self forKeyPath:@"state" options:0 context:AFTaskCountOfBytesSentContext]; - [task addObserver:self forKeyPath:@"countOfBytesSent" options:0 context:AFTaskCountOfBytesSentContext]; - - [self af_setUploadProgressAnimated:animated]; -} - -- (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task - animated:(BOOL)animated -{ - [task addObserver:self forKeyPath:@"state" options:0 context:AFTaskCountOfBytesReceivedContext]; - [task addObserver:self forKeyPath:@"countOfBytesReceived" options:0 context:AFTaskCountOfBytesReceivedContext]; - - [self af_setDownloadProgressAnimated:animated]; -} -#endif - -#pragma mark - - -- (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation - animated:(BOOL)animated -{ - __weak __typeof(self)weakSelf = self; - void (^original)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) = [operation.uploadProgress copy]; - [operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) { - if (original) { - original(bytesWritten, totalBytesWritten, totalBytesExpectedToWrite); - } - - dispatch_async(dispatch_get_main_queue(), ^{ - if (totalBytesExpectedToWrite > 0) { - __strong __typeof(weakSelf)strongSelf = weakSelf; - [strongSelf setProgress:(totalBytesWritten / (totalBytesExpectedToWrite * 1.0f)) animated:animated]; - } - }); - }]; -} - -- (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation - animated:(BOOL)animated -{ - __weak __typeof(self)weakSelf = self; - void (^original)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) = [operation.downloadProgress copy]; - [operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) { - if (original) { - original(bytesRead, totalBytesRead, totalBytesExpectedToRead); - } - - dispatch_async(dispatch_get_main_queue(), ^{ - if (totalBytesExpectedToRead > 0) { - __strong __typeof(weakSelf)strongSelf = weakSelf; - [strongSelf setProgress:(totalBytesRead / (totalBytesExpectedToRead * 1.0f)) animated:animated]; - } - }); - }]; -} - -#pragma mark - NSKeyValueObserving - -- (void)observeValueForKeyPath:(NSString *)keyPath - ofObject:(id)object - change:(__unused NSDictionary *)change - context:(void *)context -{ -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 - if (context == AFTaskCountOfBytesSentContext || context == AFTaskCountOfBytesReceivedContext) { - if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesSent))]) { - if ([object countOfBytesExpectedToSend] > 0) { - dispatch_async(dispatch_get_main_queue(), ^{ - [self setProgress:[object countOfBytesSent] / ([object countOfBytesExpectedToSend] * 1.0f) animated:self.af_uploadProgressAnimated]; - }); - } - } - - if ([keyPath isEqualToString:NSStringFromSelector(@selector(countOfBytesReceived))]) { - if ([object countOfBytesExpectedToReceive] > 0) { - dispatch_async(dispatch_get_main_queue(), ^{ - [self setProgress:[object countOfBytesReceived] / ([object countOfBytesExpectedToReceive] * 1.0f) animated:self.af_downloadProgressAnimated]; - }); - } - } - - if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) { - if ([(NSURLSessionTask *)object state] == NSURLSessionTaskStateCompleted) { - @try { - [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(state))]; - - if (context == AFTaskCountOfBytesSentContext) { - [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesSent))]; - } - - if (context == AFTaskCountOfBytesReceivedContext) { - [object removeObserver:self forKeyPath:NSStringFromSelector(@selector(countOfBytesReceived))]; - } - } - @catch (NSException * __unused exception) {} - } - } - } -#endif -} - -@end - -#endif diff --git a/Ryff/Frameworks/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h b/Ryff/Frameworks/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h deleted file mode 100755 index 37ce772..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h +++ /dev/null @@ -1,64 +0,0 @@ -// UIRefreshControl+AFNetworking.m -// -// Copyright (c) 2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import - -#import - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - -#import - -@class AFURLConnectionOperation; - -/** - This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically begining and ending refreshing depending on the loading state of a request operation or session task. - */ -@interface UIRefreshControl (AFNetworking) - -///----------------------------------- -/// @name Refreshing for Session Tasks -///----------------------------------- - -/** - Binds the refreshing state to the state of the specified task. - - @param task The task. If `nil`, automatic updating from any previously specified operation will be diabled. - */ -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 -- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; -#endif - -///---------------------------------------- -/// @name Refreshing for Request Operations -///---------------------------------------- - -/** - Binds the refreshing state to the execution state of the specified operation. - - @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled. - */ -- (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation; - -@end - -#endif diff --git a/Ryff/Frameworks/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m b/Ryff/Frameworks/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m deleted file mode 100755 index ba28157..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m +++ /dev/null @@ -1,95 +0,0 @@ -// UIRefreshControl+AFNetworking.m -// -// Copyright (c) 2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import "UIRefreshControl+AFNetworking.h" - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - -#import "AFHTTPRequestOperation.h" - -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 -#import "AFURLSessionManager.h" -#endif - -@implementation UIRefreshControl (AFNetworking) - -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 -- (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; - - [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; - [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; - [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; - - if (task) { - if (task.state != NSURLSessionTaskStateCompleted) { - if (task.state == NSURLSessionTaskStateRunning) { - [self beginRefreshing]; - } else { - [self endRefreshing]; - } - - [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task]; - [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task]; - [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task]; - } - } -} -#endif - -- (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation { - NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; - - [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; - [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; - - if (operation) { - if (![operation isFinished]) { - if ([operation isExecuting]) { - [self beginRefreshing]; - } else { - [self endRefreshing]; - } - - [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingOperationDidStartNotification object:operation]; - [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingOperationDidFinishNotification object:operation]; - } - } -} - -#pragma mark - - -- (void)af_beginRefreshing { - dispatch_async(dispatch_get_main_queue(), ^{ - [self beginRefreshing]; - }); -} - -- (void)af_endRefreshing { - dispatch_async(dispatch_get_main_queue(), ^{ - [self endRefreshing]; - }); -} - -@end - -#endif diff --git a/Ryff/Frameworks/UIKit+AFNetworking/UIWebView+AFNetworking.h b/Ryff/Frameworks/UIKit+AFNetworking/UIWebView+AFNetworking.h deleted file mode 100755 index 202e8f4..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/UIWebView+AFNetworking.h +++ /dev/null @@ -1,83 +0,0 @@ -// UIWebView+AFNetworking.h -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import - -#import - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - -#import - -@class AFHTTPRequestSerializer, AFHTTPResponseSerializer; -@protocol AFURLRequestSerialization, AFURLResponseSerialization; - -/** - This category adds methods to the UIKit framework's `UIWebView` class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling. - - @discussion When using these category methods, make sure to assign `delegate` for the web view, which implements `–webView:shouldStartLoadWithRequest:navigationType:` appropriately. This allows for tapped links to be loaded through AFNetworking, and can ensure that `canGoBack` & `canGoForward` update their values correctly. - */ -@interface UIWebView (AFNetworking) - -/** - The request serializer used to serialize requests made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPRequestSerializer`. - */ -@property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; - -/** - The response serializer used to serialize responses made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPResponseSerializer`. - */ -@property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; - -/** - Asynchronously loads the specified request. - - @param request A URL request identifying the location of the content to load. This must not be `nil`. - @param progress A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread. - @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string. - @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. - */ -- (void)loadRequest:(NSURLRequest *)request - progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress - success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success - failure:(void (^)(NSError *error))failure; - -/** - Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. - - @param request A URL request identifying the location of the content to load. This must not be `nil`. - @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. - @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. - @param progress A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread. - @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data. - @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. - */ -- (void)loadRequest:(NSURLRequest *)request - MIMEType:(NSString *)MIMEType - textEncodingName:(NSString *)textEncodingName - progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress - success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success - failure:(void (^)(NSError *error))failure; - -@end - -#endif diff --git a/Ryff/Frameworks/UIKit+AFNetworking/UIWebView+AFNetworking.m b/Ryff/Frameworks/UIKit+AFNetworking/UIWebView+AFNetworking.m deleted file mode 100755 index 525d02a..0000000 --- a/Ryff/Frameworks/UIKit+AFNetworking/UIWebView+AFNetworking.m +++ /dev/null @@ -1,151 +0,0 @@ -// UIWebView+AFNetworking.m -// -// Copyright (c) 2013-2014 AFNetworking (http://afnetworking.com) -// -// 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. - -#import "UIWebView+AFNetworking.h" - -#import - -#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) - -#import "AFHTTPRequestOperation.h" -#import "AFURLResponseSerialization.h" -#import "AFURLRequestSerialization.h" - -@interface UIWebView (_AFNetworking) -@property (readwrite, nonatomic, strong, setter = af_setHTTPRequestOperation:) AFHTTPRequestOperation *af_HTTPRequestOperation; -@end - -@implementation UIWebView (_AFNetworking) - -- (AFHTTPRequestOperation *)af_HTTPRequestOperation { - return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_HTTPRequestOperation)); -} - -- (void)af_setHTTPRequestOperation:(AFHTTPRequestOperation *)operation { - objc_setAssociatedObject(self, @selector(af_HTTPRequestOperation), operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - -@end - -#pragma mark - - -@implementation UIWebView (AFNetworking) - -- (AFHTTPRequestSerializer *)requestSerializer { - static AFHTTPRequestSerializer *_af_defaultRequestSerializer = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - _af_defaultRequestSerializer = [AFHTTPRequestSerializer serializer]; - }); - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wgnu" - return objc_getAssociatedObject(self, @selector(requestSerializer)) ?: _af_defaultRequestSerializer; -#pragma clang diagnostic pop -} - -- (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { - objc_setAssociatedObject(self, @selector(requestSerializer), requestSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - -- (AFHTTPResponseSerializer *)responseSerializer { - static AFHTTPResponseSerializer *_af_defaultResponseSerializer = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer]; - }); - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wgnu" - return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer; -#pragma clang diagnostic pop -} - -- (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { - objc_setAssociatedObject(self, @selector(responseSerializer), responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - -#pragma mark - - -- (void)loadRequest:(NSURLRequest *)request - progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress - success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success - failure:(void (^)(NSError *error))failure -{ - [self loadRequest:request MIMEType:nil textEncodingName:nil progress:progress success:^NSData *(NSHTTPURLResponse *response, NSData *data) { - NSStringEncoding stringEncoding = NSUTF8StringEncoding; - if (response.textEncodingName) { - CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); - if (encoding != kCFStringEncodingInvalidId) { - stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); - } - } - - NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding]; - if (success) { - string = success(response, string); - } - - return [string dataUsingEncoding:stringEncoding]; - } failure:failure]; -} - -- (void)loadRequest:(NSURLRequest *)request - MIMEType:(NSString *)MIMEType - textEncodingName:(NSString *)textEncodingName - progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress - success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success - failure:(void (^)(NSError *error))failure -{ - NSParameterAssert(request); - - if (self.af_HTTPRequestOperation) { - [self.af_HTTPRequestOperation cancel]; - } - - request = [self.requestSerializer requestBySerializingRequest:request withParameters:nil error:nil]; - - self.af_HTTPRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; - self.af_HTTPRequestOperation.responseSerializer = self.responseSerializer; - - __weak __typeof(self)weakSelf = self; - [self.af_HTTPRequestOperation setDownloadProgressBlock:progress]; - [self.af_HTTPRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id __unused responseObject) { - NSData *data = success ? success(operation.response, operation.responseData) : operation.responseData; - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wgnu" - __strong __typeof(weakSelf) strongSelf = weakSelf; - [strongSelf loadData:data MIMEType:(MIMEType ?: [operation.response MIMEType]) textEncodingName:(textEncodingName ?: [operation.response textEncodingName]) baseURL:[operation.response URL]]; -#pragma clang diagnostic pop - } failure:^(AFHTTPRequestOperation * __unused operation, NSError *error) { - if (failure) { - failure(error); - } - }]; - - [self.af_HTTPRequestOperation start]; -} - -@end - -#endif diff --git a/Ryff/Ryff-Prefix.pch b/Ryff/Ryff-Prefix.pch index 08d912b..ab5e135 100644 --- a/Ryff/Ryff-Prefix.pch +++ b/Ryff/Ryff-Prefix.pch @@ -23,6 +23,4 @@ #define kLightFont @"Lato-Light" #define kItalicFont @"Lato-Light" -#import "NSObject+block.h" - -#import "Ryff-Swift.h" \ No newline at end of file +#import "NSObject+block.h" \ No newline at end of file diff --git a/Ryff/UI/Custom/MBProgressHUD/MBProgressHUD-Prefix.pch b/Ryff/UI/Custom/MBProgressHUD/MBProgressHUD-Prefix.pch deleted file mode 100755 index e81c669..0000000 --- a/Ryff/UI/Custom/MBProgressHUD/MBProgressHUD-Prefix.pch +++ /dev/null @@ -1,15 +0,0 @@ -// -// Prefix header for all source files of the 'MBProgressHUD' target in the 'MBProgressHUD' project -// - -#import - -#ifndef __IPHONE_3_0 -#warning "This project uses features only available in iOS SDK 3.0 and later." -#endif - -#ifdef __OBJC__ - #import - #import - #import -#endif diff --git a/Ryff/UI/Custom/MBProgressHUD/MBProgressHUD.h b/Ryff/UI/Custom/MBProgressHUD/MBProgressHUD.h deleted file mode 100755 index 1caa3ca..0000000 --- a/Ryff/UI/Custom/MBProgressHUD/MBProgressHUD.h +++ /dev/null @@ -1,515 +0,0 @@ -// -// MBProgressHUD.h -// Version 0.9 -// Created by Matej Bukovinski on 2.4.09. -// - -// This code is distributed under the terms and conditions of the MIT license. - -// Copyright (c) 2013 Matej Bukovinski -// -// 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. - -#import -#import -#import - -@protocol MBProgressHUDDelegate; - - -typedef enum { - /** Progress is shown using an UIActivityIndicatorView. This is the default. */ - MBProgressHUDModeIndeterminate, - /** Progress is shown using a round, pie-chart like, progress view. */ - MBProgressHUDModeDeterminate, - /** Progress is shown using a horizontal progress bar */ - MBProgressHUDModeDeterminateHorizontalBar, - /** Progress is shown using a ring-shaped progress view. */ - MBProgressHUDModeAnnularDeterminate, - /** Shows a custom view */ - MBProgressHUDModeCustomView, - /** Shows only labels */ - MBProgressHUDModeText -} MBProgressHUDMode; - -typedef enum { - /** Opacity animation */ - MBProgressHUDAnimationFade, - /** Opacity + scale animation */ - MBProgressHUDAnimationZoom, - MBProgressHUDAnimationZoomOut = MBProgressHUDAnimationZoom, - MBProgressHUDAnimationZoomIn -} MBProgressHUDAnimation; - - -#ifndef MB_INSTANCETYPE -#if __has_feature(objc_instancetype) - #define MB_INSTANCETYPE instancetype -#else - #define MB_INSTANCETYPE id -#endif -#endif - -#ifndef MB_STRONG -#if __has_feature(objc_arc) - #define MB_STRONG strong -#else - #define MB_STRONG retain -#endif -#endif - -#ifndef MB_WEAK -#if __has_feature(objc_arc_weak) - #define MB_WEAK weak -#elif __has_feature(objc_arc) - #define MB_WEAK unsafe_unretained -#else - #define MB_WEAK assign -#endif -#endif - -#if NS_BLOCKS_AVAILABLE -typedef void (^MBProgressHUDCompletionBlock)(); -#endif - - -/** - * Displays a simple HUD window containing a progress indicator and two optional labels for short messages. - * - * This is a simple drop-in class for displaying a progress HUD view similar to Apple's private UIProgressHUD class. - * The MBProgressHUD window spans over the entire space given to it by the initWithFrame constructor and catches all - * user input on this region, thereby preventing the user operations on components below the view. The HUD itself is - * drawn centered as a rounded semi-transparent view which resizes depending on the user specified content. - * - * This view supports four modes of operation: - * - MBProgressHUDModeIndeterminate - shows a UIActivityIndicatorView - * - MBProgressHUDModeDeterminate - shows a custom round progress indicator - * - MBProgressHUDModeAnnularDeterminate - shows a custom annular progress indicator - * - MBProgressHUDModeCustomView - shows an arbitrary, user specified view (@see customView) - * - * All three modes can have optional labels assigned: - * - If the labelText property is set and non-empty then a label containing the provided content is placed below the - * indicator view. - * - If also the detailsLabelText property is set then another label is placed below the first label. - */ -@interface MBProgressHUD : UIView - -/** - * Creates a new HUD, adds it to provided view and shows it. The counterpart to this method is hideHUDForView:animated:. - * - * @param view The view that the HUD will be added to - * @param animated If set to YES the HUD will appear using the current animationType. If set to NO the HUD will not use - * animations while appearing. - * @return A reference to the created HUD. - * - * @see hideHUDForView:animated: - * @see animationType - */ -+ (MB_INSTANCETYPE)showHUDAddedTo:(UIView *)view animated:(BOOL)animated; - -/** - * Finds the top-most HUD subview and hides it. The counterpart to this method is showHUDAddedTo:animated:. - * - * @param view The view that is going to be searched for a HUD subview. - * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use - * animations while disappearing. - * @return YES if a HUD was found and removed, NO otherwise. - * - * @see showHUDAddedTo:animated: - * @see animationType - */ -+ (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated; - -/** - * Finds all the HUD subviews and hides them. - * - * @param view The view that is going to be searched for HUD subviews. - * @param animated If set to YES the HUDs will disappear using the current animationType. If set to NO the HUDs will not use - * animations while disappearing. - * @return the number of HUDs found and removed. - * - * @see hideHUDForView:animated: - * @see animationType - */ -+ (NSUInteger)hideAllHUDsForView:(UIView *)view animated:(BOOL)animated; - -/** - * Finds the top-most HUD subview and returns it. - * - * @param view The view that is going to be searched. - * @return A reference to the last HUD subview discovered. - */ -+ (MB_INSTANCETYPE)HUDForView:(UIView *)view; - -/** - * Finds all HUD subviews and returns them. - * - * @param view The view that is going to be searched. - * @return All found HUD views (array of MBProgressHUD objects). - */ -+ (NSArray *)allHUDsForView:(UIView *)view; - -/** - * A convenience constructor that initializes the HUD with the window's bounds. Calls the designated constructor with - * window.bounds as the parameter. - * - * @param window The window instance that will provide the bounds for the HUD. Should be the same instance as - * the HUD's superview (i.e., the window that the HUD will be added to). - */ -- (id)initWithWindow:(UIWindow *)window; - -/** - * A convenience constructor that initializes the HUD with the view's bounds. Calls the designated constructor with - * view.bounds as the parameter - * - * @param view The view instance that will provide the bounds for the HUD. Should be the same instance as - * the HUD's superview (i.e., the view that the HUD will be added to). - */ -- (id)initWithView:(UIView *)view; - -/** - * Display the HUD. You need to make sure that the main thread completes its run loop soon after this method call so - * the user interface can be updated. Call this method when your task is already set-up to be executed in a new thread - * (e.g., when using something like NSOperation or calling an asynchronous call like NSURLRequest). - * - * @param animated If set to YES the HUD will appear using the current animationType. If set to NO the HUD will not use - * animations while appearing. - * - * @see animationType - */ -- (void)show:(BOOL)animated; - -/** - * Hide the HUD. This still calls the hudWasHidden: delegate. This is the counterpart of the show: method. Use it to - * hide the HUD when your task completes. - * - * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use - * animations while disappearing. - * - * @see animationType - */ -- (void)hide:(BOOL)animated; - -/** - * Hide the HUD after a delay. This still calls the hudWasHidden: delegate. This is the counterpart of the show: method. Use it to - * hide the HUD when your task completes. - * - * @param animated If set to YES the HUD will disappear using the current animationType. If set to NO the HUD will not use - * animations while disappearing. - * @param delay Delay in seconds until the HUD is hidden. - * - * @see animationType - */ -- (void)hide:(BOOL)animated afterDelay:(NSTimeInterval)delay; - -/** - * Shows the HUD while a background task is executing in a new thread, then hides the HUD. - * - * This method also takes care of autorelease pools so your method does not have to be concerned with setting up a - * pool. - * - * @param method The method to be executed while the HUD is shown. This method will be executed in a new thread. - * @param target The object that the target method belongs to. - * @param object An optional object to be passed to the method. - * @param animated If set to YES the HUD will (dis)appear using the current animationType. If set to NO the HUD will not use - * animations while (dis)appearing. - */ -- (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated; - -#if NS_BLOCKS_AVAILABLE - -/** - * Shows the HUD while a block is executing on a background queue, then hides the HUD. - * - * @see showAnimated:whileExecutingBlock:onQueue:completionBlock: - */ -- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block; - -/** - * Shows the HUD while a block is executing on a background queue, then hides the HUD. - * - * @see showAnimated:whileExecutingBlock:onQueue:completionBlock: - */ -- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block completionBlock:(MBProgressHUDCompletionBlock)completion; - -/** - * Shows the HUD while a block is executing on the specified dispatch queue, then hides the HUD. - * - * @see showAnimated:whileExecutingBlock:onQueue:completionBlock: - */ -- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue; - -/** - * Shows the HUD while a block is executing on the specified dispatch queue, executes completion block on the main queue, and then hides the HUD. - * - * @param animated If set to YES the HUD will (dis)appear using the current animationType. If set to NO the HUD will - * not use animations while (dis)appearing. - * @param block The block to be executed while the HUD is shown. - * @param queue The dispatch queue on which the block should be executed. - * @param completion The block to be executed on completion. - * - * @see completionBlock - */ -- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue - completionBlock:(MBProgressHUDCompletionBlock)completion; - -/** - * A block that gets called after the HUD was completely hidden. - */ -@property (copy) MBProgressHUDCompletionBlock completionBlock; - -#endif - -/** - * MBProgressHUD operation mode. The default is MBProgressHUDModeIndeterminate. - * - * @see MBProgressHUDMode - */ -@property (assign) MBProgressHUDMode mode; - -/** - * The animation type that should be used when the HUD is shown and hidden. - * - * @see MBProgressHUDAnimation - */ -@property (assign) MBProgressHUDAnimation animationType; - -/** - * The UIView (e.g., a UIImageView) to be shown when the HUD is in MBProgressHUDModeCustomView. - * For best results use a 37 by 37 pixel view (so the bounds match the built in indicator bounds). - */ -@property (MB_STRONG) UIView *customView; - -/** - * The HUD delegate object. - * - * @see MBProgressHUDDelegate - */ -@property (MB_WEAK) id delegate; - -/** - * An optional short message to be displayed below the activity indicator. The HUD is automatically resized to fit - * the entire text. If the text is too long it will get clipped by displaying "..." at the end. If left unchanged or - * set to @"", then no message is displayed. - */ -@property (copy) NSString *labelText; - -/** - * An optional details message displayed below the labelText message. This message is displayed only if the labelText - * property is also set and is different from an empty string (@""). The details text can span multiple lines. - */ -@property (copy) NSString *detailsLabelText; - -/** - * The opacity of the HUD window. Defaults to 0.8 (80% opacity). - */ -@property (assign) float opacity; - -/** - * The color of the HUD window. Defaults to black. If this property is set, color is set using - * this UIColor and the opacity property is not used. using retain because performing copy on - * UIColor base colors (like [UIColor greenColor]) cause problems with the copyZone. - */ -@property (MB_STRONG) UIColor *color; - -/** - * The x-axis offset of the HUD relative to the centre of the superview. - */ -@property (assign) float xOffset; - -/** - * The y-axis offset of the HUD relative to the centre of the superview. - */ -@property (assign) float yOffset; - -/** - * The amount of space between the HUD edge and the HUD elements (labels, indicators or custom views). - * Defaults to 20.0 - */ -@property (assign) float margin; - -/** - * The corner radius for the HUD - * Defaults to 10.0 - */ -@property (assign) float cornerRadius; - -/** - * Cover the HUD background view with a radial gradient. - */ -@property (assign) BOOL dimBackground; - -/* - * Grace period is the time (in seconds) that the invoked method may be run without - * showing the HUD. If the task finishes before the grace time runs out, the HUD will - * not be shown at all. - * This may be used to prevent HUD display for very short tasks. - * Defaults to 0 (no grace time). - * Grace time functionality is only supported when the task status is known! - * @see taskInProgress - */ -@property (assign) float graceTime; - -/** - * The minimum time (in seconds) that the HUD is shown. - * This avoids the problem of the HUD being shown and than instantly hidden. - * Defaults to 0 (no minimum show time). - */ -@property (assign) float minShowTime; - -/** - * Indicates that the executed operation is in progress. Needed for correct graceTime operation. - * If you don't set a graceTime (different than 0.0) this does nothing. - * This property is automatically set when using showWhileExecuting:onTarget:withObject:animated:. - * When threading is done outside of the HUD (i.e., when the show: and hide: methods are used directly), - * you need to set this property when your task starts and completes in order to have normal graceTime - * functionality. - */ -@property (assign) BOOL taskInProgress; - -/** - * Removes the HUD from its parent view when hidden. - * Defaults to NO. - */ -@property (assign) BOOL removeFromSuperViewOnHide; - -/** - * Font to be used for the main label. Set this property if the default is not adequate. - */ -@property (MB_STRONG) UIFont* labelFont; - -/** - * Color to be used for the main label. Set this property if the default is not adequate. - */ -@property (MB_STRONG) UIColor* labelColor; - -/** - * Font to be used for the details label. Set this property if the default is not adequate. - */ -@property (MB_STRONG) UIFont* detailsLabelFont; - -/** - * Color to be used for the details label. Set this property if the default is not adequate. - */ -@property (MB_STRONG) UIColor* detailsLabelColor; - -/** - * The color of the activity indicator. Defaults to [UIColor whiteColor] - * Does nothing on pre iOS 5. - */ -@property (MB_STRONG) UIColor *activityIndicatorColor; - -/** - * The progress of the progress indicator, from 0.0 to 1.0. Defaults to 0.0. - */ -@property (assign) float progress; - -/** - * The minimum size of the HUD bezel. Defaults to CGSizeZero (no minimum size). - */ -@property (assign) CGSize minSize; - - -/** - * The actual size of the HUD bezel. - * You can use this to limit touch handling on the bezel aria only. - * @see https://github.com/jdg/MBProgressHUD/pull/200 - */ -@property (atomic, assign, readonly) CGSize size; - - -/** - * Force the HUD dimensions to be equal if possible. - */ -@property (assign, getter = isSquare) BOOL square; - -@end - - -@protocol MBProgressHUDDelegate - -@optional - -/** - * Called after the HUD was fully hidden from the screen. - */ -- (void)hudWasHidden:(MBProgressHUD *)hud; - -@end - - -/** - * A progress view for showing definite progress by filling up a circle (pie chart). - */ -@interface MBRoundProgressView : UIView - -/** - * Progress (0.0 to 1.0) - */ -@property (nonatomic, assign) float progress; - -/** - * Indicator progress color. - * Defaults to white [UIColor whiteColor] - */ -@property (nonatomic, MB_STRONG) UIColor *progressTintColor; - -/** - * Indicator background (non-progress) color. - * Defaults to translucent white (alpha 0.1) - */ -@property (nonatomic, MB_STRONG) UIColor *backgroundTintColor; - -/* - * Display mode - NO = round or YES = annular. Defaults to round. - */ -@property (nonatomic, assign, getter = isAnnular) BOOL annular; - -@end - - -/** - * A flat bar progress view. - */ -@interface MBBarProgressView : UIView - -/** - * Progress (0.0 to 1.0) - */ -@property (nonatomic, assign) float progress; - -/** - * Bar border line color. - * Defaults to white [UIColor whiteColor]. - */ -@property (nonatomic, MB_STRONG) UIColor *lineColor; - -/** - * Bar background color. - * Defaults to clear [UIColor clearColor]; - */ -@property (nonatomic, MB_STRONG) UIColor *progressRemainingColor; - -/** - * Bar progress color. - * Defaults to white [UIColor whiteColor]. - */ -@property (nonatomic, MB_STRONG) UIColor *progressColor; - -@end diff --git a/Ryff/UI/Custom/MBProgressHUD/MBProgressHUD.m b/Ryff/UI/Custom/MBProgressHUD/MBProgressHUD.m deleted file mode 100755 index e312c5e..0000000 --- a/Ryff/UI/Custom/MBProgressHUD/MBProgressHUD.m +++ /dev/null @@ -1,1024 +0,0 @@ -// -// MBProgressHUD.m -// Version 0.9 -// Created by Matej Bukovinski on 2.4.09. -// - -#import "MBProgressHUD.h" -#import - - -#if __has_feature(objc_arc) - #define MB_AUTORELEASE(exp) exp - #define MB_RELEASE(exp) exp - #define MB_RETAIN(exp) exp -#else - #define MB_AUTORELEASE(exp) [exp autorelease] - #define MB_RELEASE(exp) [exp release] - #define MB_RETAIN(exp) [exp retain] -#endif - -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 - #define MBLabelAlignmentCenter NSTextAlignmentCenter -#else - #define MBLabelAlignmentCenter UITextAlignmentCenter -#endif - -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 - #define MB_TEXTSIZE(text, font) [text length] > 0 ? [text \ - sizeWithAttributes:@{NSFontAttributeName:font}] : CGSizeZero; -#else - #define MB_TEXTSIZE(text, font) [text length] > 0 ? [text sizeWithFont:font] : CGSizeZero; -#endif - -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 - #define MB_MULTILINE_TEXTSIZE(text, font, maxSize, mode) [text length] > 0 ? [text \ - boundingRectWithSize:maxSize options:(NSStringDrawingUsesLineFragmentOrigin) \ - attributes:@{NSFontAttributeName:font} context:nil].size : CGSizeZero; -#else - #define MB_MULTILINE_TEXTSIZE(text, font, maxSize, mode) [text length] > 0 ? [text \ - sizeWithFont:font constrainedToSize:maxSize lineBreakMode:mode] : CGSizeZero; -#endif - -#ifndef kCFCoreFoundationVersionNumber_iOS_7_0 - #define kCFCoreFoundationVersionNumber_iOS_7_0 847.20 -#endif - -#ifndef kCFCoreFoundationVersionNumber_iOS_8_0 - #define kCFCoreFoundationVersionNumber_iOS_8_0 1129.15 -#endif - - -static const CGFloat kPadding = 4.f; -static const CGFloat kLabelFontSize = 16.f; -static const CGFloat kDetailsLabelFontSize = 12.f; - - -@interface MBProgressHUD () { - BOOL useAnimation; - SEL methodForExecution; - id targetForExecution; - id objectForExecution; - UILabel *label; - UILabel *detailsLabel; - BOOL isFinished; - CGAffineTransform rotationTransform; -} - -@property (atomic, MB_STRONG) UIView *indicator; -@property (atomic, MB_STRONG) NSTimer *graceTimer; -@property (atomic, MB_STRONG) NSTimer *minShowTimer; -@property (atomic, MB_STRONG) NSDate *showStarted; - - -@end - - -@implementation MBProgressHUD - -#pragma mark - Properties - -@synthesize animationType; -@synthesize delegate; -@synthesize opacity; -@synthesize color; -@synthesize labelFont; -@synthesize labelColor; -@synthesize detailsLabelFont; -@synthesize detailsLabelColor; -@synthesize indicator; -@synthesize xOffset; -@synthesize yOffset; -@synthesize minSize; -@synthesize square; -@synthesize margin; -@synthesize dimBackground; -@synthesize graceTime; -@synthesize minShowTime; -@synthesize graceTimer; -@synthesize minShowTimer; -@synthesize taskInProgress; -@synthesize removeFromSuperViewOnHide; -@synthesize customView; -@synthesize showStarted; -@synthesize mode; -@synthesize labelText; -@synthesize detailsLabelText; -@synthesize progress; -@synthesize size; -@synthesize activityIndicatorColor; -#if NS_BLOCKS_AVAILABLE -@synthesize completionBlock; -#endif - -#pragma mark - Class methods - -+ (MB_INSTANCETYPE)showHUDAddedTo:(UIView *)view animated:(BOOL)animated { - MBProgressHUD *hud = [[self alloc] initWithView:view]; - hud.removeFromSuperViewOnHide = YES; - [view addSubview:hud]; - [hud show:animated]; - return MB_AUTORELEASE(hud); -} - -+ (BOOL)hideHUDForView:(UIView *)view animated:(BOOL)animated { - MBProgressHUD *hud = [self HUDForView:view]; - if (hud != nil) { - hud.removeFromSuperViewOnHide = YES; - [hud hide:animated]; - return YES; - } - return NO; -} - -+ (NSUInteger)hideAllHUDsForView:(UIView *)view animated:(BOOL)animated { - NSArray *huds = [MBProgressHUD allHUDsForView:view]; - for (MBProgressHUD *hud in huds) { - hud.removeFromSuperViewOnHide = YES; - [hud hide:animated]; - } - return [huds count]; -} - -+ (MB_INSTANCETYPE)HUDForView:(UIView *)view { - NSEnumerator *subviewsEnum = [view.subviews reverseObjectEnumerator]; - for (UIView *subview in subviewsEnum) { - if ([subview isKindOfClass:self]) { - return (MBProgressHUD *)subview; - } - } - return nil; -} - -+ (NSArray *)allHUDsForView:(UIView *)view { - NSMutableArray *huds = [NSMutableArray array]; - NSArray *subviews = view.subviews; - for (UIView *aView in subviews) { - if ([aView isKindOfClass:self]) { - [huds addObject:aView]; - } - } - return [NSArray arrayWithArray:huds]; -} - -#pragma mark - Lifecycle - -- (id)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; - if (self) { - // Set default values for properties - self.animationType = MBProgressHUDAnimationFade; - self.mode = MBProgressHUDModeIndeterminate; - self.labelText = nil; - self.detailsLabelText = nil; - self.opacity = 0.8f; - self.color = [UIColor colorWithWhite:0.25 alpha:0.95f]; - self.labelFont = [UIFont fontWithName:kBoldFont size:kLabelFontSize]; - self.labelColor = [UIColor whiteColor]; - self.detailsLabelFont = [UIFont fontWithName:kRegularFont size:kDetailsLabelFontSize]; - self.detailsLabelColor = [UIColor whiteColor]; - self.activityIndicatorColor = [UIColor whiteColor]; - self.xOffset = 0.0f; - self.yOffset = 0.0f; - self.dimBackground = NO; - self.margin = 20.0f; - self.cornerRadius = 10.0f; - self.graceTime = 0.0f; - self.minShowTime = 0.0f; - self.removeFromSuperViewOnHide = NO; - self.minSize = CGSizeZero; - self.square = NO; - self.contentMode = UIViewContentModeCenter; - self.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin - | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin; - - // Transparent background - self.opaque = NO; - self.backgroundColor = [UIColor clearColor]; - // Make it invisible for now - self.alpha = 0.0f; - - taskInProgress = NO; - rotationTransform = CGAffineTransformIdentity; - - [self setupLabels]; - [self updateIndicators]; - [self registerForKVO]; - [self registerForNotifications]; - } - return self; -} - -- (id)initWithView:(UIView *)view { - NSAssert(view, @"View must not be nil."); - return [self initWithFrame:view.bounds]; -} - -- (id)initWithWindow:(UIWindow *)window { - return [self initWithView:window]; -} - -- (void)dealloc { - [self unregisterFromNotifications]; - [self unregisterFromKVO]; -#if !__has_feature(objc_arc) - [color release]; - [indicator release]; - [label release]; - [detailsLabel release]; - [labelText release]; - [detailsLabelText release]; - [graceTimer release]; - [minShowTimer release]; - [showStarted release]; - [customView release]; - [labelFont release]; - [labelColor release]; - [detailsLabelFont release]; - [detailsLabelColor release]; -#if NS_BLOCKS_AVAILABLE - [completionBlock release]; -#endif - [super dealloc]; -#endif -} - -#pragma mark - Show & hide - -- (void)show:(BOOL)animated { - useAnimation = animated; - // If the grace time is set postpone the HUD display - if (self.graceTime > 0.0) { - self.graceTimer = [NSTimer scheduledTimerWithTimeInterval:self.graceTime target:self - selector:@selector(handleGraceTimer:) userInfo:nil repeats:NO]; - } - // ... otherwise show the HUD imediately - else { - [self setNeedsDisplay]; - [self showUsingAnimation:useAnimation]; - } -} - -- (void)hide:(BOOL)animated { - useAnimation = animated; - // If the minShow time is set, calculate how long the hud was shown, - // and pospone the hiding operation if necessary - if (self.minShowTime > 0.0 && showStarted) { - NSTimeInterval interv = [[NSDate date] timeIntervalSinceDate:showStarted]; - if (interv < self.minShowTime) { - self.minShowTimer = [NSTimer scheduledTimerWithTimeInterval:(self.minShowTime - interv) target:self - selector:@selector(handleMinShowTimer:) userInfo:nil repeats:NO]; - return; - } - } - // ... otherwise hide the HUD immediately - [self hideUsingAnimation:useAnimation]; -} - -- (void)hide:(BOOL)animated afterDelay:(NSTimeInterval)delay { - [self performSelector:@selector(hideDelayed:) withObject:[NSNumber numberWithBool:animated] afterDelay:delay]; -} - -- (void)hideDelayed:(NSNumber *)animated { - [self hide:[animated boolValue]]; -} - -#pragma mark - Timer callbacks - -- (void)handleGraceTimer:(NSTimer *)theTimer { - // Show the HUD only if the task is still running - if (taskInProgress) { - [self setNeedsDisplay]; - [self showUsingAnimation:useAnimation]; - } -} - -- (void)handleMinShowTimer:(NSTimer *)theTimer { - [self hideUsingAnimation:useAnimation]; -} - -#pragma mark - View Hierrarchy - -- (BOOL)shouldPerformOrientationTransform { - BOOL isPreiOS8 = NSFoundationVersionNumber < kCFCoreFoundationVersionNumber_iOS_8_0; - // prior to iOS8 code needs to take care of rotation if it is being added to the window - return isPreiOS8 && [self.superview isKindOfClass:[UIWindow class]]; -} - -- (void)didMoveToSuperview { - if ([self shouldPerformOrientationTransform]) { - [self setTransformForCurrentOrientation:NO]; - } -} - -#pragma mark - Internal show & hide operations - -- (void)showUsingAnimation:(BOOL)animated { - if (animated && animationType == MBProgressHUDAnimationZoomIn) { - self.transform = CGAffineTransformConcat(rotationTransform, CGAffineTransformMakeScale(0.5f, 0.5f)); - } else if (animated && animationType == MBProgressHUDAnimationZoomOut) { - self.transform = CGAffineTransformConcat(rotationTransform, CGAffineTransformMakeScale(1.5f, 1.5f)); - } - self.showStarted = [NSDate date]; - // Fade in - if (animated) { - [UIView beginAnimations:nil context:NULL]; - [UIView setAnimationDuration:0.30]; - self.alpha = 1.0f; - if (animationType == MBProgressHUDAnimationZoomIn || animationType == MBProgressHUDAnimationZoomOut) { - self.transform = rotationTransform; - } - [UIView commitAnimations]; - } - else { - self.alpha = 1.0f; - } -} - -- (void)hideUsingAnimation:(BOOL)animated { - // Fade out - if (animated && showStarted) { - [UIView beginAnimations:nil context:NULL]; - [UIView setAnimationDuration:0.30]; - [UIView setAnimationDelegate:self]; - [UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)]; - // 0.02 prevents the hud from passing through touches during the animation the hud will get completely hidden - // in the done method - if (animationType == MBProgressHUDAnimationZoomIn) { - self.transform = CGAffineTransformConcat(rotationTransform, CGAffineTransformMakeScale(1.5f, 1.5f)); - } else if (animationType == MBProgressHUDAnimationZoomOut) { - self.transform = CGAffineTransformConcat(rotationTransform, CGAffineTransformMakeScale(0.5f, 0.5f)); - } - - self.alpha = 0.02f; - [UIView commitAnimations]; - } - else { - self.alpha = 0.0f; - [self done]; - } - self.showStarted = nil; -} - -- (void)animationFinished:(NSString *)animationID finished:(BOOL)finished context:(void*)context { - [self done]; -} - -- (void)done { - [NSObject cancelPreviousPerformRequestsWithTarget:self]; - isFinished = YES; - self.alpha = 0.0f; - if (removeFromSuperViewOnHide) { - [self removeFromSuperview]; - } -#if NS_BLOCKS_AVAILABLE - if (self.completionBlock) { - self.completionBlock(); - self.completionBlock = NULL; - } -#endif - if ([delegate respondsToSelector:@selector(hudWasHidden:)]) { - [delegate performSelector:@selector(hudWasHidden:) withObject:self]; - } -} - -#pragma mark - Threading - -- (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated { - methodForExecution = method; - targetForExecution = MB_RETAIN(target); - objectForExecution = MB_RETAIN(object); - // Launch execution in new thread - self.taskInProgress = YES; - [NSThread detachNewThreadSelector:@selector(launchExecution) toTarget:self withObject:nil]; - // Show HUD view - [self show:animated]; -} - -#if NS_BLOCKS_AVAILABLE - -- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block { - dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); - [self showAnimated:animated whileExecutingBlock:block onQueue:queue completionBlock:NULL]; -} - -- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block completionBlock:(void (^)())completion { - dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); - [self showAnimated:animated whileExecutingBlock:block onQueue:queue completionBlock:completion]; -} - -- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue { - [self showAnimated:animated whileExecutingBlock:block onQueue:queue completionBlock:NULL]; -} - -- (void)showAnimated:(BOOL)animated whileExecutingBlock:(dispatch_block_t)block onQueue:(dispatch_queue_t)queue - completionBlock:(MBProgressHUDCompletionBlock)completion { - self.taskInProgress = YES; - self.completionBlock = completion; - dispatch_async(queue, ^(void) { - block(); - dispatch_async(dispatch_get_main_queue(), ^(void) { - [self cleanUp]; - }); - }); - [self show:animated]; -} - -#endif - -- (void)launchExecution { - @autoreleasepool { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Warc-performSelector-leaks" - // Start executing the requested task - [targetForExecution performSelector:methodForExecution withObject:objectForExecution]; -#pragma clang diagnostic pop - // Task completed, update view in main thread (note: view operations should - // be done only in the main thread) - [self performSelectorOnMainThread:@selector(cleanUp) withObject:nil waitUntilDone:NO]; - } -} - -- (void)cleanUp { - taskInProgress = NO; -#if !__has_feature(objc_arc) - [targetForExecution release]; - [objectForExecution release]; -#else - targetForExecution = nil; - objectForExecution = nil; -#endif - [self hide:useAnimation]; -} - -#pragma mark - UI - -- (void)setupLabels { - label = [[UILabel alloc] initWithFrame:self.bounds]; - label.adjustsFontSizeToFitWidth = NO; - label.textAlignment = MBLabelAlignmentCenter; - label.opaque = NO; - label.backgroundColor = [UIColor clearColor]; - label.textColor = self.labelColor; - label.font = self.labelFont; - label.text = self.labelText; - [self addSubview:label]; - - detailsLabel = [[UILabel alloc] initWithFrame:self.bounds]; - detailsLabel.font = self.detailsLabelFont; - detailsLabel.adjustsFontSizeToFitWidth = NO; - detailsLabel.textAlignment = MBLabelAlignmentCenter; - detailsLabel.opaque = NO; - detailsLabel.backgroundColor = [UIColor clearColor]; - detailsLabel.textColor = self.detailsLabelColor; - detailsLabel.numberOfLines = 0; - detailsLabel.font = self.detailsLabelFont; - detailsLabel.text = self.detailsLabelText; - [self addSubview:detailsLabel]; -} - -- (void)updateIndicators { - - BOOL isActivityIndicator = [indicator isKindOfClass:[UIActivityIndicatorView class]]; - BOOL isRoundIndicator = [indicator isKindOfClass:[MBRoundProgressView class]]; - - if (mode == MBProgressHUDModeIndeterminate) { - if (!isActivityIndicator) { - // Update to indeterminate indicator - [indicator removeFromSuperview]; - self.indicator = MB_AUTORELEASE([[UIActivityIndicatorView alloc] - initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]); - [(UIActivityIndicatorView *)indicator startAnimating]; - [self addSubview:indicator]; - } -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 50000 - [(UIActivityIndicatorView *)indicator setColor:self.activityIndicatorColor]; -#endif - } - else if (mode == MBProgressHUDModeDeterminateHorizontalBar) { - // Update to bar determinate indicator - [indicator removeFromSuperview]; - self.indicator = MB_AUTORELEASE([[MBBarProgressView alloc] init]); - [self addSubview:indicator]; - } - else if (mode == MBProgressHUDModeDeterminate || mode == MBProgressHUDModeAnnularDeterminate) { - if (!isRoundIndicator) { - // Update to determinante indicator - [indicator removeFromSuperview]; - self.indicator = MB_AUTORELEASE([[MBRoundProgressView alloc] init]); - [self addSubview:indicator]; - } - if (mode == MBProgressHUDModeAnnularDeterminate) { - [(MBRoundProgressView *)indicator setAnnular:YES]; - } - } - else if (mode == MBProgressHUDModeCustomView && customView != indicator) { - // Update custom view indicator - [indicator removeFromSuperview]; - self.indicator = customView; - [self addSubview:indicator]; - } else if (mode == MBProgressHUDModeText) { - [indicator removeFromSuperview]; - self.indicator = nil; - } -} - -#pragma mark - Layout - -- (void)layoutSubviews { - [super layoutSubviews]; - - // Entirely cover the parent view - UIView *parent = self.superview; - if (parent) { - self.frame = parent.bounds; - } - CGRect bounds = self.bounds; - - // Determine the total widt and height needed - CGFloat maxWidth = bounds.size.width - 4 * margin; - CGSize totalSize = CGSizeZero; - - CGRect indicatorF = indicator.bounds; - indicatorF.size.width = MIN(indicatorF.size.width, maxWidth); - totalSize.width = MAX(totalSize.width, indicatorF.size.width); - totalSize.height += indicatorF.size.height; - - CGSize labelSize = MB_TEXTSIZE(label.text, label.font); - labelSize.width = MIN(labelSize.width, maxWidth); - totalSize.width = MAX(totalSize.width, labelSize.width); - totalSize.height += labelSize.height; - if (labelSize.height > 0.f && indicatorF.size.height > 0.f) { - totalSize.height += kPadding; - } - - CGFloat remainingHeight = bounds.size.height - totalSize.height - kPadding - 4 * margin; - CGSize maxSize = CGSizeMake(maxWidth, remainingHeight); - CGSize detailsLabelSize = MB_MULTILINE_TEXTSIZE(detailsLabel.text, detailsLabel.font, maxSize, detailsLabel.lineBreakMode); - totalSize.width = MAX(totalSize.width, detailsLabelSize.width); - totalSize.height += detailsLabelSize.height; - if (detailsLabelSize.height > 0.f && (indicatorF.size.height > 0.f || labelSize.height > 0.f)) { - totalSize.height += kPadding; - } - - totalSize.width += 2 * margin; - totalSize.height += 2 * margin; - - // Position elements - CGFloat yPos = round(((bounds.size.height - totalSize.height) / 2)) + margin + yOffset; - CGFloat xPos = xOffset; - indicatorF.origin.y = yPos; - indicatorF.origin.x = round((bounds.size.width - indicatorF.size.width) / 2) + xPos; - indicator.frame = indicatorF; - yPos += indicatorF.size.height; - - if (labelSize.height > 0.f && indicatorF.size.height > 0.f) { - yPos += kPadding; - } - CGRect labelF; - labelF.origin.y = yPos; - labelF.origin.x = round((bounds.size.width - labelSize.width) / 2) + xPos; - labelF.size = labelSize; - label.frame = labelF; - yPos += labelF.size.height; - - if (detailsLabelSize.height > 0.f && (indicatorF.size.height > 0.f || labelSize.height > 0.f)) { - yPos += kPadding; - } - CGRect detailsLabelF; - detailsLabelF.origin.y = yPos; - detailsLabelF.origin.x = round((bounds.size.width - detailsLabelSize.width) / 2) + xPos; - detailsLabelF.size = detailsLabelSize; - detailsLabel.frame = detailsLabelF; - - // Enforce minsize and quare rules - if (square) { - CGFloat max = MAX(totalSize.width, totalSize.height); - if (max <= bounds.size.width - 2 * margin) { - totalSize.width = max; - } - if (max <= bounds.size.height - 2 * margin) { - totalSize.height = max; - } - } - if (totalSize.width < minSize.width) { - totalSize.width = minSize.width; - } - if (totalSize.height < minSize.height) { - totalSize.height = minSize.height; - } - - size = totalSize; -} - -#pragma mark BG Drawing - -- (void)drawRect:(CGRect)rect { - - CGContextRef context = UIGraphicsGetCurrentContext(); - UIGraphicsPushContext(context); - - if (self.dimBackground) { - //Gradient colours - size_t gradLocationsNum = 2; - CGFloat gradLocations[2] = {0.0f, 1.0f}; - CGFloat gradColors[8] = {0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.75f}; - CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, gradColors, gradLocations, gradLocationsNum); - CGColorSpaceRelease(colorSpace); - //Gradient center - CGPoint gradCenter= CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2); - //Gradient radius - float gradRadius = MIN(self.bounds.size.width , self.bounds.size.height) ; - //Gradient draw - CGContextDrawRadialGradient (context, gradient, gradCenter, - 0, gradCenter, gradRadius, - kCGGradientDrawsAfterEndLocation); - CGGradientRelease(gradient); - } - - // Set background rect color - if (self.color) { - CGContextSetFillColorWithColor(context, self.color.CGColor); - } else { - CGContextSetGrayFillColor(context, 0.0f, self.opacity); - } - - - // Center HUD - CGRect allRect = self.bounds; - // Draw rounded HUD backgroud rect - CGRect boxRect = CGRectMake(round((allRect.size.width - size.width) / 2) + self.xOffset, - round((allRect.size.height - size.height) / 2) + self.yOffset, size.width, size.height); - float radius = self.cornerRadius; - CGContextBeginPath(context); - CGContextMoveToPoint(context, CGRectGetMinX(boxRect) + radius, CGRectGetMinY(boxRect)); - CGContextAddArc(context, CGRectGetMaxX(boxRect) - radius, CGRectGetMinY(boxRect) + radius, radius, 3 * (float)M_PI / 2, 0, 0); - CGContextAddArc(context, CGRectGetMaxX(boxRect) - radius, CGRectGetMaxY(boxRect) - radius, radius, 0, (float)M_PI / 2, 0); - CGContextAddArc(context, CGRectGetMinX(boxRect) + radius, CGRectGetMaxY(boxRect) - radius, radius, (float)M_PI / 2, (float)M_PI, 0); - CGContextAddArc(context, CGRectGetMinX(boxRect) + radius, CGRectGetMinY(boxRect) + radius, radius, (float)M_PI, 3 * (float)M_PI / 2, 0); - CGContextClosePath(context); - CGContextFillPath(context); - - UIGraphicsPopContext(); -} - -#pragma mark - KVO - -- (void)registerForKVO { - for (NSString *keyPath in [self observableKeypaths]) { - [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:NULL]; - } -} - -- (void)unregisterFromKVO { - for (NSString *keyPath in [self observableKeypaths]) { - [self removeObserver:self forKeyPath:keyPath]; - } -} - -- (NSArray *)observableKeypaths { - return [NSArray arrayWithObjects:@"mode", @"customView", @"labelText", @"labelFont", @"labelColor", - @"detailsLabelText", @"detailsLabelFont", @"detailsLabelColor", @"progress", @"activityIndicatorColor", nil]; -} - -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - if (![NSThread isMainThread]) { - [self performSelectorOnMainThread:@selector(updateUIForKeypath:) withObject:keyPath waitUntilDone:NO]; - } else { - [self updateUIForKeypath:keyPath]; - } -} - -- (void)updateUIForKeypath:(NSString *)keyPath { - if ([keyPath isEqualToString:@"mode"] || [keyPath isEqualToString:@"customView"] || - [keyPath isEqualToString:@"activityIndicatorColor"]) { - [self updateIndicators]; - } else if ([keyPath isEqualToString:@"labelText"]) { - label.text = self.labelText; - } else if ([keyPath isEqualToString:@"labelFont"]) { - label.font = self.labelFont; - } else if ([keyPath isEqualToString:@"labelColor"]) { - label.textColor = self.labelColor; - } else if ([keyPath isEqualToString:@"detailsLabelText"]) { - detailsLabel.text = self.detailsLabelText; - } else if ([keyPath isEqualToString:@"detailsLabelFont"]) { - detailsLabel.font = self.detailsLabelFont; - } else if ([keyPath isEqualToString:@"detailsLabelColor"]) { - detailsLabel.textColor = self.detailsLabelColor; - } else if ([keyPath isEqualToString:@"progress"]) { - if ([indicator respondsToSelector:@selector(setProgress:)]) { - [(id)indicator setValue:@(progress) forKey:@"progress"]; - } - return; - } - [self setNeedsLayout]; - [self setNeedsDisplay]; -} - -#pragma mark - Notifications - -- (void)registerForNotifications { - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - - [nc addObserver:self selector:@selector(statusBarOrientationDidChange:) - name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; -} - -- (void)unregisterFromNotifications { - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - [nc removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; -} - -- (void)statusBarOrientationDidChange:(NSNotification *)notification { - UIView *superview = self.superview; - if (!superview) { - return; - } else if ([self shouldPerformOrientationTransform]) { - [self setTransformForCurrentOrientation:YES]; - } else { - self.frame = self.superview.bounds; - [self setNeedsDisplay]; - } -} - -- (void)setTransformForCurrentOrientation:(BOOL)animated { - // Stay in sync with the superview - if (self.superview) { - self.bounds = self.superview.bounds; - [self setNeedsDisplay]; - } - - UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; - CGFloat radians = 0; - if (UIInterfaceOrientationIsLandscape(orientation)) { - if (orientation == UIInterfaceOrientationLandscapeLeft) { radians = -(CGFloat)M_PI_2; } - else { radians = (CGFloat)M_PI_2; } - // Window coordinates differ! - self.bounds = CGRectMake(0, 0, self.bounds.size.height, self.bounds.size.width); - } else { - if (orientation == UIInterfaceOrientationPortraitUpsideDown) { radians = (CGFloat)M_PI; } - else { radians = 0; } - } - rotationTransform = CGAffineTransformMakeRotation(radians); - - if (animated) { - [UIView beginAnimations:nil context:nil]; - [UIView setAnimationDuration:0.3]; - } - [self setTransform:rotationTransform]; - if (animated) { - [UIView commitAnimations]; - } -} - -@end - - -@implementation MBRoundProgressView - -#pragma mark - Lifecycle - -- (id)init { - return [self initWithFrame:CGRectMake(0.f, 0.f, 37.f, 37.f)]; -} - -- (id)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; - if (self) { - self.backgroundColor = [UIColor clearColor]; - self.opaque = NO; - _progress = 0.f; - _annular = NO; - _progressTintColor = [[UIColor alloc] initWithWhite:1.f alpha:1.f]; - _backgroundTintColor = [[UIColor alloc] initWithWhite:1.f alpha:.1f]; - [self registerForKVO]; - } - return self; -} - -- (void)dealloc { - [self unregisterFromKVO]; -#if !__has_feature(objc_arc) - [_progressTintColor release]; - [_backgroundTintColor release]; - [super dealloc]; -#endif -} - -#pragma mark - Drawing - -- (void)drawRect:(CGRect)rect { - - CGRect allRect = self.bounds; - CGRect circleRect = CGRectInset(allRect, 2.0f, 2.0f); - CGContextRef context = UIGraphicsGetCurrentContext(); - - if (_annular) { - // Draw background - BOOL isPreiOS7 = NSFoundationVersionNumber < kCFCoreFoundationVersionNumber_iOS_7_0; - CGFloat lineWidth = isPreiOS7 ? 5.f : 2.f; - UIBezierPath *processBackgroundPath = [UIBezierPath bezierPath]; - processBackgroundPath.lineWidth = lineWidth; - processBackgroundPath.lineCapStyle = kCGLineCapButt; - CGPoint center = CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2); - CGFloat radius = (self.bounds.size.width - lineWidth)/2; - CGFloat startAngle = - ((float)M_PI / 2); // 90 degrees - CGFloat endAngle = (2 * (float)M_PI) + startAngle; - [processBackgroundPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES]; - [_backgroundTintColor set]; - [processBackgroundPath stroke]; - // Draw progress - UIBezierPath *processPath = [UIBezierPath bezierPath]; - processPath.lineCapStyle = isPreiOS7 ? kCGLineCapRound : kCGLineCapSquare; - processPath.lineWidth = lineWidth; - endAngle = (self.progress * 2 * (float)M_PI) + startAngle; - [processPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES]; - [_progressTintColor set]; - [processPath stroke]; - } else { - // Draw background - [_progressTintColor setStroke]; - [_backgroundTintColor setFill]; - CGContextSetLineWidth(context, 2.0f); - CGContextFillEllipseInRect(context, circleRect); - CGContextStrokeEllipseInRect(context, circleRect); - // Draw progress - CGPoint center = CGPointMake(allRect.size.width / 2, allRect.size.height / 2); - CGFloat radius = (allRect.size.width - 4) / 2; - CGFloat startAngle = - ((float)M_PI / 2); // 90 degrees - CGFloat endAngle = (self.progress * 2 * (float)M_PI) + startAngle; - CGContextSetRGBFillColor(context, 1.0f, 1.0f, 1.0f, 1.0f); // white - CGContextMoveToPoint(context, center.x, center.y); - CGContextAddArc(context, center.x, center.y, radius, startAngle, endAngle, 0); - CGContextClosePath(context); - CGContextFillPath(context); - } -} - -#pragma mark - KVO - -- (void)registerForKVO { - for (NSString *keyPath in [self observableKeypaths]) { - [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:NULL]; - } -} - -- (void)unregisterFromKVO { - for (NSString *keyPath in [self observableKeypaths]) { - [self removeObserver:self forKeyPath:keyPath]; - } -} - -- (NSArray *)observableKeypaths { - return [NSArray arrayWithObjects:@"progressTintColor", @"backgroundTintColor", @"progress", @"annular", nil]; -} - -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - [self setNeedsDisplay]; -} - -@end - - -@implementation MBBarProgressView - -#pragma mark - Lifecycle - -- (id)init { - return [self initWithFrame:CGRectMake(.0f, .0f, 120.0f, 20.0f)]; -} - -- (id)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; - if (self) { - _progress = 0.f; - _lineColor = [UIColor whiteColor]; - _progressColor = [UIColor whiteColor]; - _progressRemainingColor = [UIColor clearColor]; - self.backgroundColor = [UIColor clearColor]; - self.opaque = NO; - [self registerForKVO]; - } - return self; -} - -- (void)dealloc { - [self unregisterFromKVO]; -#if !__has_feature(objc_arc) - [_lineColor release]; - [_progressColor release]; - [_progressRemainingColor release]; - [super dealloc]; -#endif -} - -#pragma mark - Drawing - -- (void)drawRect:(CGRect)rect { - CGContextRef context = UIGraphicsGetCurrentContext(); - - CGContextSetLineWidth(context, 2); - CGContextSetStrokeColorWithColor(context,[_lineColor CGColor]); - CGContextSetFillColorWithColor(context, [_progressRemainingColor CGColor]); - - // Draw background - float radius = (rect.size.height / 2) - 2; - CGContextMoveToPoint(context, 2, rect.size.height/2); - CGContextAddArcToPoint(context, 2, 2, radius + 2, 2, radius); - CGContextAddLineToPoint(context, rect.size.width - radius - 2, 2); - CGContextAddArcToPoint(context, rect.size.width - 2, 2, rect.size.width - 2, rect.size.height / 2, radius); - CGContextAddArcToPoint(context, rect.size.width - 2, rect.size.height - 2, rect.size.width - radius - 2, rect.size.height - 2, radius); - CGContextAddLineToPoint(context, radius + 2, rect.size.height - 2); - CGContextAddArcToPoint(context, 2, rect.size.height - 2, 2, rect.size.height/2, radius); - CGContextFillPath(context); - - // Draw border - CGContextMoveToPoint(context, 2, rect.size.height/2); - CGContextAddArcToPoint(context, 2, 2, radius + 2, 2, radius); - CGContextAddLineToPoint(context, rect.size.width - radius - 2, 2); - CGContextAddArcToPoint(context, rect.size.width - 2, 2, rect.size.width - 2, rect.size.height / 2, radius); - CGContextAddArcToPoint(context, rect.size.width - 2, rect.size.height - 2, rect.size.width - radius - 2, rect.size.height - 2, radius); - CGContextAddLineToPoint(context, radius + 2, rect.size.height - 2); - CGContextAddArcToPoint(context, 2, rect.size.height - 2, 2, rect.size.height/2, radius); - CGContextStrokePath(context); - - CGContextSetFillColorWithColor(context, [_progressColor CGColor]); - radius = radius - 2; - float amount = self.progress * rect.size.width; - - // Progress in the middle area - if (amount >= radius + 4 && amount <= (rect.size.width - radius - 4)) { - CGContextMoveToPoint(context, 4, rect.size.height/2); - CGContextAddArcToPoint(context, 4, 4, radius + 4, 4, radius); - CGContextAddLineToPoint(context, amount, 4); - CGContextAddLineToPoint(context, amount, radius + 4); - - CGContextMoveToPoint(context, 4, rect.size.height/2); - CGContextAddArcToPoint(context, 4, rect.size.height - 4, radius + 4, rect.size.height - 4, radius); - CGContextAddLineToPoint(context, amount, rect.size.height - 4); - CGContextAddLineToPoint(context, amount, radius + 4); - - CGContextFillPath(context); - } - - // Progress in the right arc - else if (amount > radius + 4) { - float x = amount - (rect.size.width - radius - 4); - - CGContextMoveToPoint(context, 4, rect.size.height/2); - CGContextAddArcToPoint(context, 4, 4, radius + 4, 4, radius); - CGContextAddLineToPoint(context, rect.size.width - radius - 4, 4); - float angle = -acos(x/radius); - if (isnan(angle)) angle = 0; - CGContextAddArc(context, rect.size.width - radius - 4, rect.size.height/2, radius, M_PI, angle, 0); - CGContextAddLineToPoint(context, amount, rect.size.height/2); - - CGContextMoveToPoint(context, 4, rect.size.height/2); - CGContextAddArcToPoint(context, 4, rect.size.height - 4, radius + 4, rect.size.height - 4, radius); - CGContextAddLineToPoint(context, rect.size.width - radius - 4, rect.size.height - 4); - angle = acos(x/radius); - if (isnan(angle)) angle = 0; - CGContextAddArc(context, rect.size.width - radius - 4, rect.size.height/2, radius, -M_PI, angle, 1); - CGContextAddLineToPoint(context, amount, rect.size.height/2); - - CGContextFillPath(context); - } - - // Progress is in the left arc - else if (amount < radius + 4 && amount > 0) { - CGContextMoveToPoint(context, 4, rect.size.height/2); - CGContextAddArcToPoint(context, 4, 4, radius + 4, 4, radius); - CGContextAddLineToPoint(context, radius + 4, rect.size.height/2); - - CGContextMoveToPoint(context, 4, rect.size.height/2); - CGContextAddArcToPoint(context, 4, rect.size.height - 4, radius + 4, rect.size.height - 4, radius); - CGContextAddLineToPoint(context, radius + 4, rect.size.height/2); - - CGContextFillPath(context); - } -} - -#pragma mark - KVO - -- (void)registerForKVO { - for (NSString *keyPath in [self observableKeypaths]) { - [self addObserver:self forKeyPath:keyPath options:NSKeyValueObservingOptionNew context:NULL]; - } -} - -- (void)unregisterFromKVO { - for (NSString *keyPath in [self observableKeypaths]) { - [self removeObserver:self forKeyPath:keyPath]; - } -} - -- (NSArray *)observableKeypaths { - return [NSArray arrayWithObjects:@"lineColor", @"progressRemainingColor", @"progressColor", @"progress", nil]; -} - -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - [self setNeedsDisplay]; -} - -@end From cfdbb748b6c9c2e66e73195fbd8265334e3c251b Mon Sep 17 00:00:00 2001 From: chrislaganiere Date: Fri, 4 Sep 2015 16:25:38 -0400 Subject: [PATCH 02/26] set up project --- ...ridging-Header.h => Ryff-Bridging-Header.h | 18 ++-- Ryff.xcodeproj/project.pbxproj | 80 ++++++++++++--- .../RYRiffStreamingCoreViewController.m | 2 +- Ryff/Classes/RYNewsfeedDataSource.h | 13 +++ Ryff/Classes/RYNewsfeedDataSource.m | 17 ++++ Ryff/Data/RYPostsDataSource.h | 33 +++++++ Ryff/Data/RYPostsDataSource.m | 54 ++++++++++ Ryff/Main.storyboard | 34 +++---- Ryff/Newsfeed/RYPostTableViewCell.swift | 41 ++++++++ Ryff/Newsfeed/RYPostsViewController.swift | 98 +++++++++++++++++++ Ryff/RYAppDelegate.m | 23 ++++- ...wController.h => RYTabBarViewController.h} | 4 +- ...wController.m => RYTabBarViewController.m} | 47 +++++++-- Ryff/Ryff-Prefix.pch | 3 +- Ryff/SwiftCompatability.h | 15 +++ 15 files changed, 426 insertions(+), 56 deletions(-) rename Ryff/UI/Profile/RiffEdit/RiffCreate/Ryff-Bridging-Header.h => Ryff-Bridging-Header.h (54%) create mode 100644 Ryff/Classes/RYNewsfeedDataSource.h create mode 100644 Ryff/Classes/RYNewsfeedDataSource.m create mode 100644 Ryff/Data/RYPostsDataSource.h create mode 100644 Ryff/Data/RYPostsDataSource.m create mode 100644 Ryff/Newsfeed/RYPostTableViewCell.swift create mode 100644 Ryff/Newsfeed/RYPostsViewController.swift rename Ryff/{RYCoreTabBarViewController.h => RYTabBarViewController.h} (63%) rename Ryff/{RYCoreTabBarViewController.m => RYTabBarViewController.m} (54%) create mode 100644 Ryff/SwiftCompatability.h diff --git a/Ryff/UI/Profile/RiffEdit/RiffCreate/Ryff-Bridging-Header.h b/Ryff-Bridging-Header.h similarity index 54% rename from Ryff/UI/Profile/RiffEdit/RiffCreate/Ryff-Bridging-Header.h rename to Ryff-Bridging-Header.h index bd692cf..01fd52b 100644 --- a/Ryff/UI/Profile/RiffEdit/RiffCreate/Ryff-Bridging-Header.h +++ b/Ryff-Bridging-Header.h @@ -1,22 +1,24 @@ // -// Use this file to import your target's public headers that you would like to expose to Swift. +// Ryff-Bridging-Header.h +// Ryff +// +// Created by Christopher Laganiere on 4/11/14. +// Copyright (c) 2014 Chris Laganiere. All rights reserved. // -// Data Managers +#import "FDWaveformView.h" #import "RYAudioDeckManager.h" #import "RYDataManager.h" #import "RYDiscoverServices.h" +#import "RYLoadMoreControl.h" #import "RYMediaEditor.h" +#import "RYPost.h" +#import "RYPostsDataSource.h" +#import "RYRefreshControl.h" #import "RYRegistrationServices.h" #import "RYRiffAudioEngine.h" #import "RYRiffAudioNode.h" #import "RYServices.h" #import "RYStyleSheet.h" - -// Data Objects -#import "RYPost.h" #import "RYTag.h" #import "RYUser.h" - -// Custom UI -#import "FDWaveformView.h" \ No newline at end of file diff --git a/Ryff.xcodeproj/project.pbxproj b/Ryff.xcodeproj/project.pbxproj index ea1c91a..2a3e902 100644 --- a/Ryff.xcodeproj/project.pbxproj +++ b/Ryff.xcodeproj/project.pbxproj @@ -7,6 +7,14 @@ objects = { /* Begin PBXBuildFile section */ + 3F15B3641B9A1C95009F3790 /* RYPostsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F15B3631B9A1C95009F3790 /* RYPostsViewController.swift */; }; + 3F15B3671B9A1CBF009F3790 /* RYPostsDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F15B3661B9A1CBF009F3790 /* RYPostsDataSource.m */; }; + 3F15B3691B9A2497009F3790 /* RYPostTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F15B3681B9A2497009F3790 /* RYPostTableViewCell.swift */; }; + 3F15B36D1B9A2BD0009F3790 /* RYNewsfeedDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F15B36C1B9A2BD0009F3790 /* RYNewsfeedDataSource.m */; }; + 3F15B36F1B9A2FE0009F3790 /* RYPostsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F15B3631B9A1C95009F3790 /* RYPostsViewController.swift */; }; + 3F15B3721B9A30AA009F3790 /* RYPostsDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F15B3661B9A1CBF009F3790 /* RYPostsDataSource.m */; }; + 3F15B3731B9A30AD009F3790 /* RYNewsfeedDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 3F15B36C1B9A2BD0009F3790 /* RYNewsfeedDataSource.m */; }; + 3F15B3741B9A314B009F3790 /* RYPostTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F15B3681B9A2497009F3790 /* RYPostTableViewCell.swift */; }; 61B262729FECCE862CBC2CDE /* libPods-Ryff.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 610389EFACE91AC8266D46F6 /* libPods-Ryff.a */; }; 830029B91B7FB2B300666D93 /* RYRiffAudioNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 830029B81B7FB2B300666D93 /* RYRiffAudioNode.m */; }; 830029BB1B7FD17C00666D93 /* RYRiffCreateCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 830029BA1B7FD17C00666D93 /* RYRiffCreateCollectionViewController.swift */; }; @@ -240,7 +248,7 @@ 83FCD1AF18F93F5500A493F0 /* artists.png in Resources */ = {isa = PBXBuildFile; fileRef = 83FCD1AC18F93F5500A493F0 /* artists.png */; }; 83FCD1B018F93F5500A493F0 /* artists@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 83FCD1AD18F93F5500A493F0 /* artists@2x.png */; }; 83FCD1B118F93F5500A493F0 /* user@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 83FCD1AE18F93F5500A493F0 /* user@2x.png */; }; - 83FCD1B818F9405F00A493F0 /* RYCoreTabBarViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83FCD1B718F9405F00A493F0 /* RYCoreTabBarViewController.m */; }; + 83FCD1B818F9405F00A493F0 /* RYTabBarViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83FCD1B718F9405F00A493F0 /* RYTabBarViewController.m */; }; 83FCD1BB18F9413400A493F0 /* RYPost.m in Sources */ = {isa = PBXBuildFile; fileRef = 83FCD1BA18F9413400A493F0 /* RYPost.m */; }; 89AC917E84DC12FB55E0A66D /* libPods-RyffTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B8BF0F30F13E8E20F6D2D2C /* libPods-RyffTests.a */; }; /* End PBXBuildFile section */ @@ -257,6 +265,14 @@ /* Begin PBXFileReference section */ 0F068F340A8DD53B769F8B4B /* Pods-Ryff.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Ryff.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Ryff/Pods-Ryff.debug.xcconfig"; sourceTree = ""; }; + 3F15B3631B9A1C95009F3790 /* RYPostsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RYPostsViewController.swift; sourceTree = ""; }; + 3F15B3651B9A1CBF009F3790 /* RYPostsDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RYPostsDataSource.h; sourceTree = ""; }; + 3F15B3661B9A1CBF009F3790 /* RYPostsDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RYPostsDataSource.m; sourceTree = ""; }; + 3F15B3681B9A2497009F3790 /* RYPostTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RYPostTableViewCell.swift; sourceTree = ""; }; + 3F15B36B1B9A2BD0009F3790 /* RYNewsfeedDataSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RYNewsfeedDataSource.h; path = Ryff/Classes/RYNewsfeedDataSource.h; sourceTree = SOURCE_ROOT; }; + 3F15B36C1B9A2BD0009F3790 /* RYNewsfeedDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RYNewsfeedDataSource.m; path = Ryff/Classes/RYNewsfeedDataSource.m; sourceTree = SOURCE_ROOT; }; + 3F15B36E1B9A2EA6009F3790 /* SwiftCompatability.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SwiftCompatability.h; sourceTree = ""; }; + 3F15B3711B9A3082009F3790 /* Ryff-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "Ryff-Bridging-Header.h"; path = "../Ryff-Bridging-Header.h"; sourceTree = ""; }; 5D10781F97C58C1D8BE87763 /* Pods-Ryff.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Ryff.release.xcconfig"; path = "Pods/Target Support Files/Pods-Ryff/Pods-Ryff.release.xcconfig"; sourceTree = ""; }; 610389EFACE91AC8266D46F6 /* libPods-Ryff.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Ryff.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 6616A16D4F2C65AA11F6581D /* Pods-RyffTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RyffTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RyffTests/Pods-RyffTests.release.xcconfig"; sourceTree = ""; }; @@ -423,7 +439,6 @@ 8397133E1936DD1100913996 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; 8398EC8219A012D800130EFC /* RYNewsfeedContainerViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RYNewsfeedContainerViewController.h; sourceTree = ""; }; 8398EC8319A012D800130EFC /* RYNewsfeedContainerViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RYNewsfeedContainerViewController.m; sourceTree = ""; }; - 83B73E4D19DF526E001C746E /* Ryff-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "Ryff-Bridging-Header.h"; path = "UI/Profile/RiffEdit/RiffCreate/Ryff-Bridging-Header.h"; sourceTree = ""; }; 83B73E5419E0F87E001C746E /* RiffCreate.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = RiffCreate.storyboard; sourceTree = ""; }; 83C354B119BBAD41000A5BD4 /* RYRiffStreamViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RYRiffStreamViewController.h; sourceTree = ""; }; 83C354B219BBAD41000A5BD4 /* RYRiffStreamViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RYRiffStreamViewController.m; sourceTree = ""; }; @@ -614,8 +629,8 @@ 83FCD1AC18F93F5500A493F0 /* artists.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = artists.png; sourceTree = ""; }; 83FCD1AD18F93F5500A493F0 /* artists@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "artists@2x.png"; sourceTree = ""; }; 83FCD1AE18F93F5500A493F0 /* user@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "user@2x.png"; sourceTree = ""; }; - 83FCD1B618F9405F00A493F0 /* RYCoreTabBarViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RYCoreTabBarViewController.h; sourceTree = ""; }; - 83FCD1B718F9405F00A493F0 /* RYCoreTabBarViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RYCoreTabBarViewController.m; sourceTree = ""; }; + 83FCD1B618F9405F00A493F0 /* RYTabBarViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RYTabBarViewController.h; sourceTree = ""; }; + 83FCD1B718F9405F00A493F0 /* RYTabBarViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RYTabBarViewController.m; sourceTree = ""; }; 83FCD1B918F9413400A493F0 /* RYPost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RYPost.h; path = ../../Newsfeed/RYPost.h; sourceTree = ""; }; 83FCD1BA18F9413400A493F0 /* RYPost.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RYPost.m; path = ../../Newsfeed/RYPost.m; sourceTree = ""; }; 8B8BF0F30F13E8E20F6D2D2C /* libPods-RyffTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RyffTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -650,6 +665,17 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 3F15B36A1B9A2B91009F3790 /* PostsDataSources */ = { + isa = PBXGroup; + children = ( + 3F15B3651B9A1CBF009F3790 /* RYPostsDataSource.h */, + 3F15B3661B9A1CBF009F3790 /* RYPostsDataSource.m */, + 3F15B36B1B9A2BD0009F3790 /* RYNewsfeedDataSource.h */, + 3F15B36C1B9A2BD0009F3790 /* RYNewsfeedDataSource.m */, + ); + name = PostsDataSources; + sourceTree = ""; + }; 5BD8AE6B5B14CE56E937FC6A /* Pods */ = { isa = PBXGroup; children = ( @@ -1253,7 +1279,7 @@ 83FCD1A018F921AB00A493F0 /* Data */, 83FCD14A18F907C400A493F0 /* RYAppDelegate.h */, 83FCD14B18F907C400A493F0 /* RYAppDelegate.m */, - 83B73E4D19DF526E001C746E /* Ryff-Bridging-Header.h */, + 3F15B3711B9A3082009F3790 /* Ryff-Bridging-Header.h */, 8397133E1936DD1100913996 /* Main.storyboard */, 83FCD14D18F907C400A493F0 /* MainIphone.storyboard */, 83FCD18C18F9142600A493F0 /* Newsfeed */, @@ -1264,8 +1290,8 @@ 830185F119009C2B00093EFA /* Login */, 83FCD15618F907C400A493F0 /* Images.xcassets */, 83FCD14218F907C400A493F0 /* Supporting Files */, - 83FCD1B618F9405F00A493F0 /* RYCoreTabBarViewController.h */, - 83FCD1B718F9405F00A493F0 /* RYCoreTabBarViewController.m */, + 83FCD1B618F9405F00A493F0 /* RYTabBarViewController.h */, + 83FCD1B718F9405F00A493F0 /* RYTabBarViewController.m */, ); path = Ryff; sourceTree = ""; @@ -1277,6 +1303,7 @@ 83FCD14418F907C400A493F0 /* InfoPlist.strings */, 83FCD14718F907C400A493F0 /* main.m */, 83FCD14918F907C400A493F0 /* Ryff-Prefix.pch */, + 3F15B36E1B9A2EA6009F3790 /* SwiftCompatability.h */, ); name = "Supporting Files"; sourceTree = ""; @@ -1339,6 +1366,8 @@ 831E5FF919A03269007F3C31 /* RYNewsfeedNavigationController.m */, 8398EC8219A012D800130EFC /* RYNewsfeedContainerViewController.h */, 8398EC8319A012D800130EFC /* RYNewsfeedContainerViewController.m */, + 3F15B3631B9A1C95009F3790 /* RYPostsViewController.swift */, + 3F15B3681B9A2497009F3790 /* RYPostTableViewCell.swift */, ); path = Newsfeed; sourceTree = ""; @@ -1353,6 +1382,7 @@ 83E56B671953A0DA00EF054C /* RYMediaEditor.m */, 831B96061964DEC6003A8616 /* RYDataManager.h */, 831B96071964DEC6003A8616 /* RYDataManager.m */, + 3F15B36A1B9A2B91009F3790 /* PostsDataSources */, ); path = Data; sourceTree = ""; @@ -1695,11 +1725,13 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 3F15B3691B9A2497009F3790 /* RYPostTableViewCell.swift in Sources */, 83CA12231995CD23002610E8 /* FLEXHeapEnumerator.m in Sources */, 83814BCD19D0DCBF00F60FBF /* RYTagListHeaderView.m in Sources */, 83082FEB19B5652D000AFACB /* RYSearchTypeTableViewCell.m in Sources */, 83FCD18F18F9144100A493F0 /* RYNewsfeedTableViewController.m in Sources */, 836F484519A04BAB00E948BE /* UIView+Styling.m in Sources */, + 3F15B3671B9A1CBF009F3790 /* RYPostsDataSource.m in Sources */, 830185F419009C3A00093EFA /* RYLoginViewController.m in Sources */, 830029BB1B7FD17C00666D93 /* RYRiffCreateCollectionViewController.swift in Sources */, 83CA12251995CD23002610E8 /* FLEXRuntimeUtility.m in Sources */, @@ -1731,7 +1763,7 @@ 83360CD419B6A7FF00136FCB /* RYNotificationsTableViewCell.m in Sources */, 8322309D19B00D0200C60033 /* PXAlertView.m in Sources */, 83CA121A1995CD23002610E8 /* FLEXDescriptionTableViewCell.m in Sources */, - 83FCD1B818F9405F00A493F0 /* RYCoreTabBarViewController.m in Sources */, + 83FCD1B818F9405F00A493F0 /* RYTabBarViewController.m in Sources */, 8310F5AA1981F92300250172 /* RYPlayControl.m in Sources */, 83CA12061995CD23002610E8 /* FLEXFieldEditorViewController.m in Sources */, 83FCD14818F907C400A493F0 /* main.m in Sources */, @@ -1791,6 +1823,7 @@ 83CA12111995CD23002610E8 /* FLEXFileBrowserTableViewController.m in Sources */, 83DC3B7819BD0EC00036AD2A /* RYRefreshControl.m in Sources */, 83CA12071995CD23002610E8 /* FLEXIvarEditorViewController.m in Sources */, + 3F15B36D1B9A2BD0009F3790 /* RYNewsfeedDataSource.m in Sources */, 834FEC1019897E6600C3D9B9 /* RYRiffCell.m in Sources */, 83CA11FC1995CD23002610E8 /* FLEXArgumentInputNotSupportedView.m in Sources */, 837C98D819A82411002A9B34 /* RYUserListViewController.m in Sources */, @@ -1812,6 +1845,7 @@ 83CA12091995CD23002610E8 /* FLEXPropertyEditorViewController.m in Sources */, 83CA12031995CD23002610E8 /* FLEXArgumentInputViewFactory.m in Sources */, 830185FE1900AEB300093EFA /* UIColor+Hex.m in Sources */, + 3F15B3641B9A1C95009F3790 /* RYPostsViewController.swift in Sources */, 83FCD1A318F921EA00A493F0 /* RYServices.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1820,7 +1854,11 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 3F15B3731B9A30AD009F3790 /* RYNewsfeedDataSource.m in Sources */, 83FCD16A18F907C400A493F0 /* RyffTests.m in Sources */, + 3F15B36F1B9A2FE0009F3790 /* RYPostsViewController.swift in Sources */, + 3F15B3741B9A314B009F3790 /* RYPostTableViewCell.swift in Sources */, + 3F15B3721B9A30AA009F3790 /* RYPostsDataSource.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1946,8 +1984,14 @@ ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_ENABLE_MODULES = YES; DEFINES_MODULE = YES; + FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/**"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Ryff/Ryff-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "COCOAPODS=1", + "RYFF=1", + ); INFOPLIST_FILE = "Ryff/Ryff-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1957,7 +2001,7 @@ ); MODULE_NAME = Ryff; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "Ryff/UI/Profile/RiffEdit/RiffCreate/Ryff-Bridging-Header.h"; + SWIFT_OBJC_BRIDGING_HEADER = "Ryff-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; TARGETED_DEVICE_FAMILY = "1,2"; WRAPPER_EXTENSION = app; @@ -1972,8 +2016,14 @@ ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_ENABLE_MODULES = YES; DEFINES_MODULE = YES; + FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/**"; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Ryff/Ryff-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "COCOAPODS=1", + "RYFF=1", + ); INFOPLIST_FILE = "Ryff/Ryff-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.3; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; @@ -1983,7 +2033,7 @@ ); MODULE_NAME = Ryff; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "Ryff/UI/Profile/RiffEdit/RiffCreate/Ryff-Bridging-Header.h"; + SWIFT_OBJC_BRIDGING_HEADER = "Ryff-Bridging-Header.h"; TARGETED_DEVICE_FAMILY = "1,2"; WRAPPER_EXTENSION = app; }; @@ -2001,12 +2051,11 @@ ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Ryff/Ryff-Prefix.pch"; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); + GCC_PREPROCESSOR_DEFINITIONS = "RYFFTESTS=1"; INFOPLIST_FILE = "RyffTests/RyffTests-Info.plist"; + MODULE_NAME = RyffTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Ryff-Bridging-Header.h"; TEST_HOST = "$(BUNDLE_LOADER)"; WRAPPER_EXTENSION = xctest; }; @@ -2024,8 +2073,11 @@ ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "Ryff/Ryff-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = "RYFFTESTS=1"; INFOPLIST_FILE = "RyffTests/RyffTests-Info.plist"; + MODULE_NAME = RyffTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Ryff-Bridging-Header.h"; TEST_HOST = "$(BUNDLE_LOADER)"; WRAPPER_EXTENSION = xctest; }; diff --git a/Ryff/Base Classes/RYRiffStreamingCoreViewController.m b/Ryff/Base Classes/RYRiffStreamingCoreViewController.m index 1a6ed23..7aedb7f 100644 --- a/Ryff/Base Classes/RYRiffStreamingCoreViewController.m +++ b/Ryff/Base Classes/RYRiffStreamingCoreViewController.m @@ -69,7 +69,7 @@ - (void) follow:(BOOL)following confirmedForUser:(RYUser *)user - (void) followFailed:(NSString *)reason { - + NSLog(@"Follow user failed: %@", reason); } #pragma mark - ProfilePost Delegate diff --git a/Ryff/Classes/RYNewsfeedDataSource.h b/Ryff/Classes/RYNewsfeedDataSource.h new file mode 100644 index 0000000..d9928a2 --- /dev/null +++ b/Ryff/Classes/RYNewsfeedDataSource.h @@ -0,0 +1,13 @@ +// +// RYNewsfeedDataSource.h +// Ryff +// +// Created by Chris Laganiere on 9/4/15. +// Copyright (c) 2015 Chris Laganiere. All rights reserved. +// + +#import "RYPostsDataSource.h" + +@interface RYNewsfeedDataSource : RYPostsDataSource + +@end diff --git a/Ryff/Classes/RYNewsfeedDataSource.m b/Ryff/Classes/RYNewsfeedDataSource.m new file mode 100644 index 0000000..73a1179 --- /dev/null +++ b/Ryff/Classes/RYNewsfeedDataSource.m @@ -0,0 +1,17 @@ +// +// RYNewsfeedDataSource.m +// Ryff +// +// Created by Chris Laganiere on 9/4/15. +// Copyright (c) 2015 Chris Laganiere. All rights reserved. +// + +#import "RYNewsfeedDataSource.h" + +@implementation RYNewsfeedDataSource + +- (void)fetchContent:(NSInteger)page { + [[RYServices sharedInstance] getNewsfeedPostsWithPage:@(page) delegate:self]; +} + +@end diff --git a/Ryff/Data/RYPostsDataSource.h b/Ryff/Data/RYPostsDataSource.h new file mode 100644 index 0000000..2c8a6c3 --- /dev/null +++ b/Ryff/Data/RYPostsDataSource.h @@ -0,0 +1,33 @@ +// +// RYPostsDataSource.h +// Ryff +// +// Created by Chris Laganiere on 9/4/15. +// Copyright (c) 2015 Chris Laganiere. All rights reserved. +// + +@import Foundation; + +// Data Managers +#import "RYServices.h" + +@protocol RYPostsDataSourceDelegate +- (void)postUpdatedAtIndex:(NSInteger)postIndex; +- (void)contentUpdated; +- (void)contentFailedToUpdate; +@end + +@protocol RYContentFeedDataSource +- (void)fetchContent:(NSInteger)page; +@end + +@interface RYPostsDataSource : NSObject + +@property (nonatomic, readonly) NSArray/**/ *feedItems; + +@property (nonatomic, weak) id delegate; + +- (void)loadMoreContent; +- (void)refreshContent; + +@end diff --git a/Ryff/Data/RYPostsDataSource.m b/Ryff/Data/RYPostsDataSource.m new file mode 100644 index 0000000..ea30480 --- /dev/null +++ b/Ryff/Data/RYPostsDataSource.m @@ -0,0 +1,54 @@ +// +// RYPostsDataSource.m +// Ryff +// +// Created by Chris Laganiere on 9/4/15. +// Copyright (c) 2015 Chris Laganiere. All rights reserved. +// + +#import "RYPostsDataSource.h" + +@interface RYPostsDataSource () + +@property (nonatomic) NSArray/**/ *feedItems; + +// Last page of content loaded. Should load next page if fetching more content. +@property (nonatomic, assign) NSInteger currentPage; + +@end + +@implementation RYPostsDataSource + +- (void)loadMoreContent { + [self fetchContent:(_currentPage + 1)]; +} + +- (void)refreshContent { + [self fetchContent:1]; +} + +#pragma mark - Private + +- (void)fetchContent:(NSInteger)page { + NSAssert(NO, @"Must subclass RYPostsDataSource to specify appropriate fetch action"); +} + +#pragma mark - +#pragma mark - Post Delegate + +- (void)postSucceeded:(NSArray *)posts page:(NSNumber *)page { + if (page && page.integerValue > 1) { + self.feedItems = [self.feedItems arrayByAddingObjectsFromArray:posts]; + } + else { + self.feedItems = posts; + } + _currentPage = page.integerValue; + [_delegate contentUpdated]; +} + +- (void)postFailed:(NSString *)reason page:(NSNumber *)page { + [_delegate contentFailedToUpdate]; +} + +@end diff --git a/Ryff/Main.storyboard b/Ryff/Main.storyboard index 7e8d9ae..7a9dbe5 100644 --- a/Ryff/Main.storyboard +++ b/Ryff/Main.storyboard @@ -1,5 +1,5 @@ - + @@ -43,7 +43,7 @@ - + @@ -64,7 +64,7 @@ - +