motion-yapper 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (296) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -2
  3. data/.travis.yml +2 -0
  4. data/Gemfile +1 -0
  5. data/README.md +1 -1
  6. data/Rakefile +1 -1
  7. data/lib/motion-yapper.rb +1 -0
  8. data/lib/yapper.rb +3 -5
  9. data/lib/yapper/config.rb +2 -0
  10. data/lib/yapper/db.rb +105 -40
  11. data/lib/yapper/document.rb +7 -4
  12. data/lib/yapper/document/callbacks.rb +0 -7
  13. data/lib/yapper/document/{persistance.rb → persistence.rb} +27 -21
  14. data/lib/yapper/document/relation.rb +29 -22
  15. data/lib/yapper/document/selection.rb +122 -54
  16. data/lib/yapper/extensions.rb +12 -24
  17. data/lib/yapper/settings.rb +43 -0
  18. data/lib/yapper/timestamps.rb +2 -0
  19. data/lib/yapper/version.rb +1 -1
  20. data/{yapper.gemspec → motion-yapper.gemspec} +0 -0
  21. data/spec/integration/{where_spec.rb → criteria_spec.rb} +78 -10
  22. data/spec/integration/db_spec.rb +70 -0
  23. data/spec/integration/defaults_spec.rb +37 -0
  24. data/spec/integration/extensions_spec.rb +14 -0
  25. data/spec/integration/{persistance_spec.rb → persistence_spec.rb} +0 -0
  26. data/spec/integration/relation_spec.rb +4 -4
  27. data/vendor/Podfile.lock +9 -11
  28. data/vendor/Pods/.build/libPods-CocoaLumberjack.a +0 -0
  29. data/vendor/Pods/.build/libPods-NSData+MD5Digest.a +0 -0
  30. data/vendor/Pods/.build/libPods-YapDatabase.a +0 -0
  31. data/vendor/Pods/.build/libPods.a +0 -0
  32. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDASLLogger.h +4 -4
  33. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDAbstractDatabaseLogger.h +14 -14
  34. data/vendor/Pods/{CocoaLumberjack/Lumberjack/Extensions/ContextFilterLogFormatter.h → BuildHeaders/CocoaLumberjack/DDContextFilterLogFormatter.h} +6 -8
  35. data/vendor/Pods/BuildHeaders/CocoaLumberjack/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
  36. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDFileLogger.h +67 -32
  37. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog+LOGV.h +99 -0
  38. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDLog.h +98 -65
  39. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDMultiFormatter.h +30 -0
  40. data/vendor/Pods/BuildHeaders/CocoaLumberjack/DDTTYLogger.h +39 -25
  41. data/vendor/Pods/BuildHeaders/YapDatabase/NSDictionary+YapDatabase.h +8 -0
  42. data/vendor/Pods/BuildHeaders/YapDatabase/YapCache.h +1 -0
  43. data/vendor/Pods/BuildHeaders/YapDatabase/YapCollectionKey.h +3 -0
  44. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabase.h +4 -4
  45. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseConnection.h +21 -19
  46. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseDefaults.h +1 -1
  47. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseExtensionPrivate.h +35 -31
  48. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredView.h +8 -35
  49. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -2
  50. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTransaction.h +17 -17
  51. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFilteredViewTypes.h +32 -0
  52. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseFullTextSearchPrivate.h +8 -0
  53. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabasePrivate.h +43 -21
  54. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationship.h +35 -0
  55. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipConnection.h +29 -0
  56. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdge.h +163 -0
  57. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipEdgePrivate.h +79 -0
  58. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipNode.h +99 -0
  59. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipOptions.h +59 -0
  60. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipPrivate.h +125 -0
  61. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseRelationshipTransaction.h +384 -0
  62. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndex.h +49 -0
  63. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +10 -0
  64. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseSecondaryIndexSetupPrivate.h +18 -0
  65. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseTransaction.h +131 -21
  66. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseView.h +48 -107
  67. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewChange.h +2 -2
  68. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewConnection.h +1 -0
  69. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewMappings.h +17 -0
  70. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewOptions.h +10 -3
  71. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewPrivate.h +18 -1
  72. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTransaction.h +75 -24
  73. data/vendor/Pods/BuildHeaders/YapDatabase/YapDatabaseViewTypes.h +99 -0
  74. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.h +4 -4
  75. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDASLLogger.m +51 -50
  76. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.h +14 -14
  77. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDAbstractDatabaseLogger.m +546 -546
  78. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.h +67 -32
  79. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDFileLogger.m +1093 -907
  80. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog+LOGV.h +99 -0
  81. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.h +98 -65
  82. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDLog.m +873 -748
  83. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.h +39 -25
  84. data/vendor/Pods/CocoaLumberjack/Lumberjack/DDTTYLogger.m +1284 -1243
  85. data/vendor/Pods/{BuildHeaders/CocoaLumberjack/ContextFilterLogFormatter.h → CocoaLumberjack/Lumberjack/Extensions/DDContextFilterLogFormatter.h} +6 -8
  86. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/{ContextFilterLogFormatter.m → DDContextFilterLogFormatter.m} +70 -70
  87. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
  88. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDDispatchQueueLogFormatter.m +253 -0
  89. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.h +30 -0
  90. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DDMultiFormatter.m +127 -0
  91. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/README.txt +1 -1
  92. data/vendor/Pods/CocoaLumberjack/README.markdown +52 -15
  93. data/vendor/Pods/Headers/CocoaLumberjack/DDASLLogger.h +4 -4
  94. data/vendor/Pods/Headers/CocoaLumberjack/DDAbstractDatabaseLogger.h +14 -14
  95. data/vendor/Pods/Headers/CocoaLumberjack/{ContextFilterLogFormatter.h → DDContextFilterLogFormatter.h} +6 -8
  96. data/vendor/Pods/Headers/CocoaLumberjack/{DispatchQueueLogFormatter.h → DDDispatchQueueLogFormatter.h} +18 -6
  97. data/vendor/Pods/Headers/CocoaLumberjack/DDFileLogger.h +67 -32
  98. data/vendor/Pods/Headers/CocoaLumberjack/DDLog+LOGV.h +99 -0
  99. data/vendor/Pods/Headers/CocoaLumberjack/DDLog.h +98 -65
  100. data/vendor/Pods/Headers/CocoaLumberjack/DDMultiFormatter.h +30 -0
  101. data/vendor/Pods/Headers/CocoaLumberjack/DDTTYLogger.h +39 -25
  102. data/vendor/Pods/Headers/YapDatabase/YapCollectionKey.h +3 -0
  103. data/vendor/Pods/Headers/YapDatabase/YapDatabase.h +4 -4
  104. data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnection.h +21 -19
  105. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredView.h +8 -35
  106. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTransaction.h +17 -17
  107. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewTypes.h +32 -0
  108. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationship.h +35 -0
  109. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipConnection.h +29 -0
  110. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipEdge.h +163 -0
  111. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipNode.h +99 -0
  112. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipOptions.h +59 -0
  113. data/vendor/Pods/Headers/YapDatabase/YapDatabaseRelationshipTransaction.h +384 -0
  114. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndex.h +49 -0
  115. data/vendor/Pods/Headers/YapDatabase/YapDatabaseTransaction.h +131 -21
  116. data/vendor/Pods/Headers/YapDatabase/YapDatabaseView.h +48 -107
  117. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChange.h +2 -2
  118. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewConnection.h +1 -0
  119. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappings.h +17 -0
  120. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewOptions.h +10 -3
  121. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTransaction.h +75 -24
  122. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewTypes.h +99 -0
  123. data/vendor/Pods/Headers/____Pods-CocoaLumberjack-prefix.h +2 -0
  124. data/vendor/Pods/Headers/____Pods-environment.h +15 -15
  125. data/vendor/Pods/Manifest.lock +9 -11
  126. data/vendor/Pods/Pods-CocoaLumberjack-Private.xcconfig +1 -1
  127. data/vendor/Pods/Pods-CocoaLumberjack-prefix.pch +2 -0
  128. data/vendor/Pods/Pods-NSData+MD5Digest-Private.xcconfig +1 -1
  129. data/vendor/Pods/Pods-YapDatabase-Private.xcconfig +1 -1
  130. data/vendor/Pods/{Pods-Acknowledgements.markdown → Pods-acknowledgements.markdown} +0 -37
  131. data/vendor/Pods/{Pods-Acknowledgements.plist → Pods-acknowledgements.plist} +0 -45
  132. data/vendor/Pods/Pods-environment.h +15 -15
  133. data/vendor/Pods/Pods.xcconfig +3 -3
  134. data/vendor/Pods/Pods.xcodeproj/project.pbxproj +2426 -3155
  135. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-CocoaLumberjack.xcscheme +59 -0
  136. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-NSData+MD5Digest.xcscheme +59 -0
  137. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods-YapDatabase.xcscheme +59 -0
  138. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/Pods.xcscheme +59 -0
  139. data/vendor/Pods/Pods.xcodeproj/xcuserdata/kareemk.xcuserdatad/xcschemes/xcschememanagement.plist +31 -0
  140. data/vendor/Pods/YapDatabase/README.md +3 -1
  141. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/Internal/YapDatabaseFilteredViewPrivate.h +0 -2
  142. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.h +8 -35
  143. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredView.m +25 -41
  144. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.h +17 -17
  145. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTransaction.m +403 -134
  146. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FilteredViews/YapDatabaseFilteredViewTypes.h +32 -0
  147. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/Internal/YapDatabaseFullTextSearchPrivate.h +8 -0
  148. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchConnection.m +8 -8
  149. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/FullTextSearch/YapDatabaseFullTextSearchTransaction.m +113 -62
  150. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/Internal/YapDatabaseExtensionPrivate.h +35 -31
  151. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtension.m +25 -0
  152. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionConnection.m +1 -1
  153. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Protocol/YapDatabaseExtensionTransaction.m +25 -1
  154. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipEdgePrivate.h +79 -0
  155. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/Internal/YapDatabaseRelationshipPrivate.h +125 -0
  156. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.h +35 -0
  157. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationship.m +129 -0
  158. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.h +29 -0
  159. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipConnection.m +802 -0
  160. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.h +163 -0
  161. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipEdge.m +408 -0
  162. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipNode.h +99 -0
  163. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.h +59 -0
  164. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipOptions.m +29 -0
  165. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.h +384 -0
  166. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Relationships/YapDatabaseRelationshipTransaction.m +5254 -0
  167. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexPrivate.h +10 -0
  168. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/Internal/YapDatabaseSecondaryIndexSetupPrivate.h +18 -0
  169. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.h +49 -0
  170. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndex.m +12 -0
  171. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexConnection.m +9 -8
  172. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexSetup.m +62 -1
  173. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/SecondaryIndex/YapDatabaseSecondaryIndexTransaction.m +148 -45
  174. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Internal/YapDatabaseViewPrivate.h +18 -1
  175. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.h +2 -2
  176. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewChange.m +15 -9
  177. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.h +17 -0
  178. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/Utilities/YapDatabaseViewMappings.m +211 -64
  179. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.h +48 -107
  180. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseView.m +10 -7
  181. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.h +1 -0
  182. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewConnection.m +13 -22
  183. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewOptions.h +10 -3
  184. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.h +75 -24
  185. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTransaction.m +725 -244
  186. data/vendor/Pods/YapDatabase/YapDatabase/Extensions/Views/YapDatabaseViewTypes.h +99 -0
  187. data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.h +8 -0
  188. data/vendor/Pods/YapDatabase/YapDatabase/Internal/NSDictionary+YapDatabase.m +19 -0
  189. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.h +1 -0
  190. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapCache.m +12 -0
  191. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.h +1 -1
  192. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabaseDefaults.m +3 -3
  193. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapDatabasePrivate.h +43 -21
  194. data/vendor/Pods/YapDatabase/YapDatabase/Internal/YapNull.m +4 -0
  195. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.h +3 -0
  196. data/vendor/Pods/YapDatabase/YapDatabase/Utilities/YapCollectionKey.m +5 -0
  197. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.h +4 -4
  198. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabase.m +84 -93
  199. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.h +21 -19
  200. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseConnection.m +381 -209
  201. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.h +131 -21
  202. data/vendor/Pods/YapDatabase/YapDatabase/YapDatabaseTransaction.m +587 -267
  203. data/vendor/Pods/{Pods.bridgesupport → build-iPhoneSimulator/Pods.bridgesupport} +633 -2557
  204. data/vendor/Pods/build-iPhoneSimulator/libPods.a +0 -0
  205. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.bridgesupport +2 -1
  206. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.h +2 -1
  207. data/vendor/YapDatabaseRubyMotion/YapDatabaseRubyMotion.m +4 -2
  208. metadata +80 -108
  209. data/Gemfile.lock +0 -63
  210. data/lib/yapper/attachment.rb +0 -48
  211. data/lib/yapper/document/attachment.rb +0 -26
  212. data/lib/yapper/sync.rb +0 -134
  213. data/lib/yapper/sync/data.rb +0 -12
  214. data/lib/yapper/sync/event.rb +0 -194
  215. data/lib/yapper/sync/queue.rb +0 -164
  216. data/spec/integration/all_spec.rb +0 -40
  217. data/spec/integration/sync_spec.rb +0 -42
  218. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.h +0 -641
  219. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPClient.m +0 -1396
  220. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.h +0 -133
  221. data/vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m +0 -327
  222. data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.h +0 -113
  223. data/vendor/Pods/AFNetworking/AFNetworking/AFImageRequestOperation.m +0 -321
  224. data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.h +0 -71
  225. data/vendor/Pods/AFNetworking/AFNetworking/AFJSONRequestOperation.m +0 -150
  226. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  227. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworkActivityIndicatorManager.m +0 -157
  228. data/vendor/Pods/AFNetworking/AFNetworking/AFNetworking.h +0 -43
  229. data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  230. data/vendor/Pods/AFNetworking/AFNetworking/AFPropertyListRequestOperation.m +0 -143
  231. data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.h +0 -370
  232. data/vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m +0 -848
  233. data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.h +0 -89
  234. data/vendor/Pods/AFNetworking/AFNetworking/AFXMLRequestOperation.m +0 -167
  235. data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.h +0 -78
  236. data/vendor/Pods/AFNetworking/AFNetworking/UIImageView+AFNetworking.m +0 -191
  237. data/vendor/Pods/AFNetworking/LICENSE +0 -19
  238. data/vendor/Pods/AFNetworking/README.md +0 -208
  239. data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPClient.h +0 -641
  240. data/vendor/Pods/BuildHeaders/AFNetworking/AFHTTPRequestOperation.h +0 -133
  241. data/vendor/Pods/BuildHeaders/AFNetworking/AFImageRequestOperation.h +0 -113
  242. data/vendor/Pods/BuildHeaders/AFNetworking/AFJSONRequestOperation.h +0 -71
  243. data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  244. data/vendor/Pods/BuildHeaders/AFNetworking/AFNetworking.h +0 -43
  245. data/vendor/Pods/BuildHeaders/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  246. data/vendor/Pods/BuildHeaders/AFNetworking/AFURLConnectionOperation.h +0 -370
  247. data/vendor/Pods/BuildHeaders/AFNetworking/AFXMLRequestOperation.h +0 -89
  248. data/vendor/Pods/BuildHeaders/AFNetworking/UIImageView+AFNetworking.h +0 -78
  249. data/vendor/Pods/BuildHeaders/Reachability/Reachability.h +0 -109
  250. data/vendor/Pods/CocoaLumberjack/Lumberjack/Extensions/DispatchQueueLogFormatter.m +0 -251
  251. data/vendor/Pods/Headers/AFNetworking/AFHTTPClient.h +0 -641
  252. data/vendor/Pods/Headers/AFNetworking/AFHTTPRequestOperation.h +0 -133
  253. data/vendor/Pods/Headers/AFNetworking/AFImageRequestOperation.h +0 -113
  254. data/vendor/Pods/Headers/AFNetworking/AFJSONRequestOperation.h +0 -71
  255. data/vendor/Pods/Headers/AFNetworking/AFNetworkActivityIndicatorManager.h +0 -75
  256. data/vendor/Pods/Headers/AFNetworking/AFNetworking.h +0 -43
  257. data/vendor/Pods/Headers/AFNetworking/AFPropertyListRequestOperation.h +0 -68
  258. data/vendor/Pods/Headers/AFNetworking/AFURLConnectionOperation.h +0 -370
  259. data/vendor/Pods/Headers/AFNetworking/AFXMLRequestOperation.h +0 -89
  260. data/vendor/Pods/Headers/AFNetworking/UIImageView+AFNetworking.h +0 -78
  261. data/vendor/Pods/Headers/Reachability/Reachability.h +0 -109
  262. data/vendor/Pods/Headers/YapDatabase/YapCache.h +0 -90
  263. data/vendor/Pods/Headers/YapDatabase/YapDatabaseConnectionState.h +0 -29
  264. data/vendor/Pods/Headers/YapDatabase/YapDatabaseDefaults.h +0 -37
  265. data/vendor/Pods/Headers/YapDatabase/YapDatabaseExtensionPrivate.h +0 -440
  266. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFilteredViewPrivate.h +0 -19
  267. data/vendor/Pods/Headers/YapDatabase/YapDatabaseFullTextSearchPrivate.h +0 -69
  268. data/vendor/Pods/Headers/YapDatabase/YapDatabaseLogging.h +0 -158
  269. data/vendor/Pods/Headers/YapDatabase/YapDatabaseManager.h +0 -17
  270. data/vendor/Pods/Headers/YapDatabase/YapDatabasePrivate.h +0 -424
  271. data/vendor/Pods/Headers/YapDatabase/YapDatabaseSecondaryIndexPrivate.h +0 -73
  272. data/vendor/Pods/Headers/YapDatabase/YapDatabaseStatement.h +0 -13
  273. data/vendor/Pods/Headers/YapDatabase/YapDatabaseString.h +0 -121
  274. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewChangePrivate.h +0 -94
  275. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewMappingsPrivate.h +0 -72
  276. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPage.h +0 -36
  277. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPageMetadata.h +0 -27
  278. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewPrivate.h +0 -153
  279. data/vendor/Pods/Headers/YapDatabase/YapDatabaseViewRangeOptionsPrivate.h +0 -17
  280. data/vendor/Pods/Headers/YapDatabase/YapMemoryTable.h +0 -74
  281. data/vendor/Pods/Headers/YapDatabase/YapNull.h +0 -17
  282. data/vendor/Pods/Headers/YapDatabase/YapTouch.h +0 -15
  283. data/vendor/Pods/Headers/____Pods-AFNetworking-prefix.h +0 -17
  284. data/vendor/Pods/Headers/____Pods-Reachability-prefix.h +0 -5
  285. data/vendor/Pods/Pods-AFNetworking-Private.xcconfig +0 -5
  286. data/vendor/Pods/Pods-AFNetworking-dummy.m +0 -5
  287. data/vendor/Pods/Pods-AFNetworking-prefix.pch +0 -17
  288. data/vendor/Pods/Pods-AFNetworking.xcconfig +0 -1
  289. data/vendor/Pods/Pods-Reachability-Private.xcconfig +0 -5
  290. data/vendor/Pods/Pods-Reachability-dummy.m +0 -5
  291. data/vendor/Pods/Pods-Reachability-prefix.pch +0 -5
  292. data/vendor/Pods/Pods-Reachability.xcconfig +0 -1
  293. data/vendor/Pods/Reachability/LICENCE.txt +0 -24
  294. data/vendor/Pods/Reachability/README.md +0 -65
  295. data/vendor/Pods/Reachability/Reachability.h +0 -109
  296. data/vendor/Pods/Reachability/Reachability.m +0 -527
@@ -1,848 +0,0 @@
1
- // AFURLConnectionOperation.m
2
- //
3
- // Copyright (c) 2011 Gowalla (http://gowalla.com/)
4
- //
5
- // Permission is hereby granted, free of charge, to any person obtaining a copy
6
- // of this software and associated documentation files (the "Software"), to deal
7
- // in the Software without restriction, including without limitation the rights
8
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- // copies of the Software, and to permit persons to whom the Software is
10
- // furnished to do so, subject to the following conditions:
11
- //
12
- // The above copyright notice and this permission notice shall be included in
13
- // all copies or substantial portions of the Software.
14
- //
15
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- // THE SOFTWARE.
22
-
23
- #import "AFURLConnectionOperation.h"
24
-
25
- #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
26
- #import <UIKit/UIKit.h>
27
- #endif
28
-
29
- #if !__has_feature(objc_arc)
30
- #error AFNetworking must be built with ARC.
31
- // You can turn on ARC for only AFNetworking files by adding -fobjc-arc to the build phase for each of its files.
32
- #endif
33
-
34
- typedef enum {
35
- AFOperationPausedState = -1,
36
- AFOperationReadyState = 1,
37
- AFOperationExecutingState = 2,
38
- AFOperationFinishedState = 3,
39
- } _AFOperationState;
40
-
41
- typedef signed short AFOperationState;
42
-
43
- #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
44
- typedef UIBackgroundTaskIdentifier AFBackgroundTaskIdentifier;
45
- #else
46
- typedef id AFBackgroundTaskIdentifier;
47
- #endif
48
-
49
- static NSString * const kAFNetworkingLockName = @"com.alamofire.networking.operation.lock";
50
-
51
- NSString * const AFNetworkingErrorDomain = @"AFNetworkingErrorDomain";
52
- NSString * const AFNetworkingOperationFailingURLRequestErrorKey = @"AFNetworkingOperationFailingURLRequestErrorKey";
53
- NSString * const AFNetworkingOperationFailingURLResponseErrorKey = @"AFNetworkingOperationFailingURLResponseErrorKey";
54
-
55
- NSString * const AFNetworkingOperationDidStartNotification = @"com.alamofire.networking.operation.start";
56
- NSString * const AFNetworkingOperationDidFinishNotification = @"com.alamofire.networking.operation.finish";
57
-
58
- typedef void (^AFURLConnectionOperationProgressBlock)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected);
59
- typedef void (^AFURLConnectionOperationAuthenticationChallengeBlock)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge);
60
- typedef NSCachedURLResponse * (^AFURLConnectionOperationCacheResponseBlock)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse);
61
- typedef NSURLRequest * (^AFURLConnectionOperationRedirectResponseBlock)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse);
62
-
63
- static inline NSString * AFKeyPathFromOperationState(AFOperationState state) {
64
- switch (state) {
65
- case AFOperationReadyState:
66
- return @"isReady";
67
- case AFOperationExecutingState:
68
- return @"isExecuting";
69
- case AFOperationFinishedState:
70
- return @"isFinished";
71
- case AFOperationPausedState:
72
- return @"isPaused";
73
- default:
74
- return @"state";
75
- }
76
- }
77
-
78
- static inline BOOL AFStateTransitionIsValid(AFOperationState fromState, AFOperationState toState, BOOL isCancelled) {
79
- switch (fromState) {
80
- case AFOperationReadyState:
81
- switch (toState) {
82
- case AFOperationPausedState:
83
- case AFOperationExecutingState:
84
- return YES;
85
- case AFOperationFinishedState:
86
- return isCancelled;
87
- default:
88
- return NO;
89
- }
90
- case AFOperationExecutingState:
91
- switch (toState) {
92
- case AFOperationPausedState:
93
- case AFOperationFinishedState:
94
- return YES;
95
- default:
96
- return NO;
97
- }
98
- case AFOperationFinishedState:
99
- return NO;
100
- case AFOperationPausedState:
101
- return toState == AFOperationReadyState;
102
- default:
103
- return YES;
104
- }
105
- }
106
-
107
- #if !defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
108
- static NSData *AFSecKeyGetData(SecKeyRef key) {
109
- CFDataRef data = NULL;
110
-
111
- OSStatus status = SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data);
112
- NSCAssert(status == errSecSuccess, @"SecItemExport error: %ld", (long int)status);
113
- NSCParameterAssert(data);
114
-
115
- return (__bridge_transfer NSData *)data;
116
- }
117
- #endif
118
-
119
- static BOOL AFSecKeyIsEqualToKey(SecKeyRef key1, SecKeyRef key2) {
120
- #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
121
- return [(__bridge id)key1 isEqual:(__bridge id)key2];
122
- #else
123
- return [AFSecKeyGetData(key1) isEqual:AFSecKeyGetData(key2)];
124
- #endif
125
- }
126
-
127
- @interface AFURLConnectionOperation ()
128
- @property (readwrite, nonatomic, assign) AFOperationState state;
129
- @property (readwrite, nonatomic, assign, getter = isCancelled) BOOL cancelled;
130
- @property (readwrite, nonatomic, strong) NSRecursiveLock *lock;
131
- @property (readwrite, nonatomic, strong) NSURLConnection *connection;
132
- @property (readwrite, nonatomic, strong) NSURLRequest *request;
133
- @property (readwrite, nonatomic, strong) NSURLResponse *response;
134
- @property (readwrite, nonatomic, strong) NSError *error;
135
- @property (readwrite, nonatomic, strong) NSData *responseData;
136
- @property (readwrite, nonatomic, copy) NSString *responseString;
137
- @property (readwrite, nonatomic, assign) NSStringEncoding responseStringEncoding;
138
- @property (readwrite, nonatomic, assign) long long totalBytesRead;
139
- @property (readwrite, nonatomic, assign) AFBackgroundTaskIdentifier backgroundTaskIdentifier;
140
- @property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock uploadProgress;
141
- @property (readwrite, nonatomic, copy) AFURLConnectionOperationProgressBlock downloadProgress;
142
- @property (readwrite, nonatomic, copy) AFURLConnectionOperationAuthenticationChallengeBlock authenticationChallenge;
143
- @property (readwrite, nonatomic, copy) AFURLConnectionOperationCacheResponseBlock cacheResponse;
144
- @property (readwrite, nonatomic, copy) AFURLConnectionOperationRedirectResponseBlock redirectResponse;
145
-
146
- - (void)operationDidStart;
147
- - (void)finish;
148
- - (void)cancelConnection;
149
- @end
150
-
151
- @implementation AFURLConnectionOperation
152
- @synthesize state = _state;
153
- @synthesize cancelled = _cancelled;
154
- @synthesize connection = _connection;
155
- @synthesize runLoopModes = _runLoopModes;
156
- @synthesize request = _request;
157
- @synthesize response = _response;
158
- @synthesize error = _error;
159
- @synthesize allowsInvalidSSLCertificate = _allowsInvalidSSLCertificate;
160
- @synthesize responseData = _responseData;
161
- @synthesize responseString = _responseString;
162
- @synthesize responseStringEncoding = _responseStringEncoding;
163
- @synthesize totalBytesRead = _totalBytesRead;
164
- @dynamic inputStream;
165
- @synthesize outputStream = _outputStream;
166
- @synthesize credential = _credential;
167
- @synthesize SSLPinningMode = _SSLPinningMode;
168
- @synthesize shouldUseCredentialStorage = _shouldUseCredentialStorage;
169
- @synthesize userInfo = _userInfo;
170
- @synthesize backgroundTaskIdentifier = _backgroundTaskIdentifier;
171
- @synthesize uploadProgress = _uploadProgress;
172
- @synthesize downloadProgress = _downloadProgress;
173
- @synthesize authenticationChallenge = _authenticationChallenge;
174
- @synthesize cacheResponse = _cacheResponse;
175
- @synthesize redirectResponse = _redirectResponse;
176
- @synthesize lock = _lock;
177
-
178
- + (void)networkRequestThreadEntryPoint:(id __unused)object {
179
- @autoreleasepool {
180
- [[NSThread currentThread] setName:@"AFNetworking"];
181
-
182
- NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
183
- [runLoop addPort:[NSMachPort port] forMode:NSDefaultRunLoopMode];
184
- [runLoop run];
185
- }
186
- }
187
-
188
- + (NSThread *)networkRequestThread {
189
- static NSThread *_networkRequestThread = nil;
190
- static dispatch_once_t oncePredicate;
191
- dispatch_once(&oncePredicate, ^{
192
- _networkRequestThread = [[NSThread alloc] initWithTarget:self selector:@selector(networkRequestThreadEntryPoint:) object:nil];
193
- [_networkRequestThread start];
194
- });
195
-
196
- return _networkRequestThread;
197
- }
198
-
199
- + (NSArray *)pinnedCertificates {
200
- static NSArray *_pinnedCertificates = nil;
201
- static dispatch_once_t onceToken;
202
- dispatch_once(&onceToken, ^{
203
- NSBundle *bundle = [NSBundle mainBundle];
204
- NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."];
205
-
206
- NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[paths count]];
207
- for (NSString *path in paths) {
208
- NSData *certificateData = [NSData dataWithContentsOfFile:path];
209
- [certificates addObject:certificateData];
210
- }
211
-
212
- _pinnedCertificates = [[NSArray alloc] initWithArray:certificates];
213
- });
214
-
215
- return _pinnedCertificates;
216
- }
217
-
218
- + (NSArray *)pinnedPublicKeys {
219
- static NSArray *_pinnedPublicKeys = nil;
220
- static dispatch_once_t onceToken;
221
- dispatch_once(&onceToken, ^{
222
- NSArray *pinnedCertificates = [self pinnedCertificates];
223
- NSMutableArray *publicKeys = [NSMutableArray arrayWithCapacity:[pinnedCertificates count]];
224
-
225
- for (NSData *data in pinnedCertificates) {
226
- SecCertificateRef allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)data);
227
- NSParameterAssert(allowedCertificate);
228
-
229
- SecCertificateRef allowedCertificates[] = {allowedCertificate};
230
- CFArrayRef certificates = CFArrayCreate(NULL, (const void **)allowedCertificates, 1, NULL);
231
-
232
- SecPolicyRef policy = SecPolicyCreateBasicX509();
233
- SecTrustRef allowedTrust = NULL;
234
- OSStatus status = SecTrustCreateWithCertificates(certificates, policy, &allowedTrust);
235
- NSAssert(status == errSecSuccess, @"SecTrustCreateWithCertificates error: %ld", (long int)status);
236
- if (status == errSecSuccess && allowedTrust) {
237
- SecTrustResultType result = 0;
238
- status = SecTrustEvaluate(allowedTrust, &result);
239
- NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status);
240
- if (status == errSecSuccess) {
241
- SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(allowedTrust);
242
- NSParameterAssert(allowedPublicKey);
243
- if (allowedPublicKey) {
244
- [publicKeys addObject:(__bridge_transfer id)allowedPublicKey];
245
- }
246
- }
247
-
248
- CFRelease(allowedTrust);
249
- }
250
-
251
- CFRelease(policy);
252
- CFRelease(certificates);
253
- CFRelease(allowedCertificate);
254
- }
255
-
256
- _pinnedPublicKeys = [[NSArray alloc] initWithArray:publicKeys];
257
- });
258
-
259
- return _pinnedPublicKeys;
260
- }
261
-
262
- - (id)initWithRequest:(NSURLRequest *)urlRequest {
263
- NSParameterAssert(urlRequest);
264
-
265
- self = [super init];
266
- if (!self) {
267
- return nil;
268
- }
269
-
270
- self.lock = [[NSRecursiveLock alloc] init];
271
- self.lock.name = kAFNetworkingLockName;
272
-
273
- self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes];
274
-
275
- self.request = urlRequest;
276
-
277
- self.shouldUseCredentialStorage = YES;
278
-
279
- // #ifdef included for backwards-compatibility
280
- #ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_
281
- self.allowsInvalidSSLCertificate = YES;
282
- #endif
283
-
284
- self.state = AFOperationReadyState;
285
-
286
- return self;
287
- }
288
-
289
- - (void)dealloc {
290
- if (_outputStream) {
291
- [_outputStream close];
292
- _outputStream = nil;
293
- }
294
-
295
- #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
296
- if (_backgroundTaskIdentifier) {
297
- [[UIApplication sharedApplication] endBackgroundTask:_backgroundTaskIdentifier];
298
- _backgroundTaskIdentifier = UIBackgroundTaskInvalid;
299
- }
300
- #endif
301
- }
302
-
303
- - (NSString *)description {
304
- return [NSString stringWithFormat:@"<%@: %p, state: %@, cancelled: %@ request: %@, response: %@>", NSStringFromClass([self class]), self, AFKeyPathFromOperationState(self.state), ([self isCancelled] ? @"YES" : @"NO"), self.request, self.response];
305
- }
306
-
307
- - (void)setCompletionBlock:(void (^)(void))block {
308
- [self.lock lock];
309
- if (!block) {
310
- [super setCompletionBlock:nil];
311
- } else {
312
- __weak __typeof(&*self)weakSelf = self;
313
- [super setCompletionBlock:^ {
314
- __strong __typeof(&*weakSelf)strongSelf = weakSelf;
315
-
316
- block();
317
- [strongSelf setCompletionBlock:nil];
318
- }];
319
- }
320
- [self.lock unlock];
321
- }
322
-
323
- - (NSInputStream *)inputStream {
324
- return self.request.HTTPBodyStream;
325
- }
326
-
327
- - (void)setInputStream:(NSInputStream *)inputStream {
328
- [self willChangeValueForKey:@"inputStream"];
329
- NSMutableURLRequest *mutableRequest = [self.request mutableCopy];
330
- mutableRequest.HTTPBodyStream = inputStream;
331
- self.request = mutableRequest;
332
- [self didChangeValueForKey:@"inputStream"];
333
- }
334
-
335
- - (NSOutputStream *)outputStream {
336
- if (!_outputStream) {
337
- self.outputStream = [NSOutputStream outputStreamToMemory];
338
- }
339
-
340
- return _outputStream;
341
- }
342
-
343
- - (void)setOutputStream:(NSOutputStream *)outputStream {
344
- [self.lock lock];
345
- if (outputStream != _outputStream) {
346
- [self willChangeValueForKey:@"outputStream"];
347
- if (_outputStream) {
348
- [_outputStream close];
349
- }
350
- _outputStream = outputStream;
351
- [self didChangeValueForKey:@"outputStream"];
352
- }
353
- [self.lock unlock];
354
- }
355
-
356
- #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
357
- - (void)setShouldExecuteAsBackgroundTaskWithExpirationHandler:(void (^)(void))handler {
358
- [self.lock lock];
359
- if (!self.backgroundTaskIdentifier) {
360
- UIApplication *application = [UIApplication sharedApplication];
361
- __weak __typeof(&*self)weakSelf = self;
362
- self.backgroundTaskIdentifier = [application beginBackgroundTaskWithExpirationHandler:^{
363
- __strong __typeof(&*weakSelf)strongSelf = weakSelf;
364
-
365
- if (handler) {
366
- handler();
367
- }
368
-
369
- if (strongSelf) {
370
- [strongSelf cancel];
371
-
372
- [application endBackgroundTask:strongSelf.backgroundTaskIdentifier];
373
- strongSelf.backgroundTaskIdentifier = UIBackgroundTaskInvalid;
374
- }
375
- }];
376
- }
377
- [self.lock unlock];
378
- }
379
- #endif
380
-
381
- - (void)setUploadProgressBlock:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))block {
382
- self.uploadProgress = block;
383
- }
384
-
385
- - (void)setDownloadProgressBlock:(void (^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))block {
386
- self.downloadProgress = block;
387
- }
388
-
389
- - (void)setWillSendRequestForAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block {
390
- self.authenticationChallenge = block;
391
- }
392
-
393
- - (void)setCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block {
394
- self.cacheResponse = block;
395
- }
396
-
397
- - (void)setRedirectResponseBlock:(NSURLRequest * (^)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse))block {
398
- self.redirectResponse = block;
399
- }
400
-
401
- - (void)setState:(AFOperationState)state {
402
- if (!AFStateTransitionIsValid(self.state, state, [self isCancelled])) {
403
- return;
404
- }
405
-
406
- [self.lock lock];
407
- NSString *oldStateKey = AFKeyPathFromOperationState(self.state);
408
- NSString *newStateKey = AFKeyPathFromOperationState(state);
409
-
410
- [self willChangeValueForKey:newStateKey];
411
- [self willChangeValueForKey:oldStateKey];
412
- _state = state;
413
- [self didChangeValueForKey:oldStateKey];
414
- [self didChangeValueForKey:newStateKey];
415
- [self.lock unlock];
416
- }
417
-
418
- - (NSString *)responseString {
419
- [self.lock lock];
420
- if (!_responseString && self.response && self.responseData) {
421
- self.responseString = [[NSString alloc] initWithData:self.responseData encoding:self.responseStringEncoding];
422
- }
423
- [self.lock unlock];
424
-
425
- return _responseString;
426
- }
427
-
428
- - (NSStringEncoding)responseStringEncoding {
429
- [self.lock lock];
430
- if (!_responseStringEncoding && self.response) {
431
- NSStringEncoding stringEncoding = NSUTF8StringEncoding;
432
- if (self.response.textEncodingName) {
433
- CFStringEncoding IANAEncoding = CFStringConvertIANACharSetNameToEncoding((__bridge CFStringRef)self.response.textEncodingName);
434
- if (IANAEncoding != kCFStringEncodingInvalidId) {
435
- stringEncoding = CFStringConvertEncodingToNSStringEncoding(IANAEncoding);
436
- }
437
- }
438
-
439
- self.responseStringEncoding = stringEncoding;
440
- }
441
- [self.lock unlock];
442
-
443
- return _responseStringEncoding;
444
- }
445
-
446
- - (void)pause {
447
- if ([self isPaused] || [self isFinished] || [self isCancelled]) {
448
- return;
449
- }
450
-
451
- [self.lock lock];
452
-
453
- if ([self isExecuting]) {
454
- [self.connection performSelector:@selector(cancel) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]];
455
-
456
- dispatch_async(dispatch_get_main_queue(), ^{
457
- NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
458
- [notificationCenter postNotificationName:AFNetworkingOperationDidFinishNotification object:self];
459
- });
460
- }
461
-
462
- self.state = AFOperationPausedState;
463
-
464
- [self.lock unlock];
465
- }
466
-
467
- - (BOOL)isPaused {
468
- return self.state == AFOperationPausedState;
469
- }
470
-
471
- - (void)resume {
472
- if (![self isPaused]) {
473
- return;
474
- }
475
-
476
- [self.lock lock];
477
- self.state = AFOperationReadyState;
478
-
479
- [self start];
480
- [self.lock unlock];
481
- }
482
-
483
- #pragma mark - NSOperation
484
-
485
- - (BOOL)isReady {
486
- return self.state == AFOperationReadyState && [super isReady];
487
- }
488
-
489
- - (BOOL)isExecuting {
490
- return self.state == AFOperationExecutingState;
491
- }
492
-
493
- - (BOOL)isFinished {
494
- return self.state == AFOperationFinishedState;
495
- }
496
-
497
- - (BOOL)isConcurrent {
498
- return YES;
499
- }
500
-
501
- - (void)start {
502
- [self.lock lock];
503
- if ([self isReady]) {
504
- self.state = AFOperationExecutingState;
505
-
506
- [self performSelector:@selector(operationDidStart) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]];
507
- }
508
- [self.lock unlock];
509
- }
510
-
511
- - (void)operationDidStart {
512
- [self.lock lock];
513
- if (![self isCancelled]) {
514
- self.connection = [[NSURLConnection alloc] initWithRequest:self.request delegate:self startImmediately:NO];
515
-
516
- NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
517
- for (NSString *runLoopMode in self.runLoopModes) {
518
- [self.connection scheduleInRunLoop:runLoop forMode:runLoopMode];
519
- [self.outputStream scheduleInRunLoop:runLoop forMode:runLoopMode];
520
- }
521
-
522
- [self.connection start];
523
- }
524
- [self.lock unlock];
525
-
526
- dispatch_async(dispatch_get_main_queue(), ^{
527
- [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidStartNotification object:self];
528
- });
529
-
530
- if ([self isCancelled]) {
531
- NSDictionary *userInfo = nil;
532
- if ([self.request URL]) {
533
- userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey];
534
- }
535
- self.error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo];
536
-
537
- [self finish];
538
- }
539
- }
540
-
541
- - (void)finish {
542
- self.state = AFOperationFinishedState;
543
-
544
- dispatch_async(dispatch_get_main_queue(), ^{
545
- [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self];
546
- });
547
- }
548
-
549
- - (void)cancel {
550
- [self.lock lock];
551
- if (![self isFinished] && ![self isCancelled]) {
552
- [self willChangeValueForKey:@"isCancelled"];
553
- _cancelled = YES;
554
- [super cancel];
555
- [self didChangeValueForKey:@"isCancelled"];
556
-
557
- // Cancel the connection on the thread it runs on to prevent race conditions
558
- [self performSelector:@selector(cancelConnection) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]];
559
- }
560
- [self.lock unlock];
561
- }
562
-
563
- - (void)cancelConnection {
564
- NSDictionary *userInfo = nil;
565
- if ([self.request URL]) {
566
- userInfo = [NSDictionary dictionaryWithObject:[self.request URL] forKey:NSURLErrorFailingURLErrorKey];
567
- }
568
- NSError *error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo];
569
-
570
- if (![self isFinished] && self.connection) {
571
- [self.connection cancel];
572
- [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:error];
573
- }
574
- }
575
-
576
- #pragma mark - NSURLConnectionDelegate
577
-
578
- - (void)connection:(NSURLConnection *)connection
579
- willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
580
- {
581
- if (self.authenticationChallenge) {
582
- self.authenticationChallenge(connection, challenge);
583
- return;
584
- }
585
-
586
- if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
587
- SecTrustRef serverTrust = challenge.protectionSpace.serverTrust;
588
-
589
- SecPolicyRef policy = SecPolicyCreateBasicX509();
590
- CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust);
591
- NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:certificateCount];
592
-
593
- for (CFIndex i = 0; i < certificateCount; i++) {
594
- SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i);
595
-
596
- if (self.SSLPinningMode == AFSSLPinningModeCertificate) {
597
- [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)];
598
- } else if (self.SSLPinningMode == AFSSLPinningModePublicKey) {
599
- SecCertificateRef someCertificates[] = {certificate};
600
- CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL);
601
-
602
- SecTrustRef trust = NULL;
603
-
604
- OSStatus status = SecTrustCreateWithCertificates(certificates, policy, &trust);
605
- NSAssert(status == errSecSuccess, @"SecTrustCreateWithCertificates error: %ld", (long int)status);
606
- if (status == errSecSuccess && trust) {
607
- SecTrustResultType result;
608
- status = SecTrustEvaluate(trust, &result);
609
- NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status);
610
- if (status == errSecSuccess) {
611
- [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)];
612
- }
613
-
614
- CFRelease(trust);
615
- }
616
-
617
- CFRelease(certificates);
618
- }
619
- }
620
-
621
- CFRelease(policy);
622
-
623
- switch (self.SSLPinningMode) {
624
- case AFSSLPinningModePublicKey: {
625
- NSArray *pinnedPublicKeys = [self.class pinnedPublicKeys];
626
-
627
- for (id publicKey in trustChain) {
628
- for (id pinnedPublicKey in pinnedPublicKeys) {
629
- if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)publicKey, (__bridge SecKeyRef)pinnedPublicKey)) {
630
- NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust];
631
- [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
632
- return;
633
- }
634
- }
635
- }
636
-
637
- [[challenge sender] cancelAuthenticationChallenge:challenge];
638
- break;
639
- }
640
- case AFSSLPinningModeCertificate: {
641
- for (id serverCertificateData in trustChain) {
642
- if ([[self.class pinnedCertificates] containsObject:serverCertificateData]) {
643
- NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust];
644
- [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
645
- return;
646
- }
647
- }
648
-
649
- [[challenge sender] cancelAuthenticationChallenge:challenge];
650
- break;
651
- }
652
- case AFSSLPinningModeNone: {
653
- if (self.allowsInvalidSSLCertificate){
654
- NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust];
655
- [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
656
- } else {
657
- SecTrustResultType result = 0;
658
- OSStatus status = SecTrustEvaluate(serverTrust, &result);
659
- NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status);
660
-
661
- if (status == errSecSuccess && (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed)) {
662
- NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust];
663
- [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
664
- } else {
665
- [[challenge sender] cancelAuthenticationChallenge:challenge];
666
- }
667
- }
668
- break;
669
- }
670
- }
671
- } else {
672
- if ([challenge previousFailureCount] == 0) {
673
- if (self.credential) {
674
- [[challenge sender] useCredential:self.credential forAuthenticationChallenge:challenge];
675
- } else {
676
- [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge];
677
- }
678
- } else {
679
- [[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge];
680
- }
681
- }
682
- }
683
-
684
- - (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection __unused *)connection {
685
- return self.shouldUseCredentialStorage;
686
- }
687
-
688
- - (NSURLRequest *)connection:(NSURLConnection *)connection
689
- willSendRequest:(NSURLRequest *)request
690
- redirectResponse:(NSURLResponse *)redirectResponse
691
- {
692
- if (self.redirectResponse) {
693
- return self.redirectResponse(connection, request, redirectResponse);
694
- } else {
695
- return request;
696
- }
697
- }
698
-
699
- - (void)connection:(NSURLConnection __unused *)connection
700
- didSendBodyData:(NSInteger)bytesWritten
701
- totalBytesWritten:(NSInteger)totalBytesWritten
702
- totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
703
- {
704
- if (self.uploadProgress) {
705
- dispatch_async(dispatch_get_main_queue(), ^{
706
- self.uploadProgress((NSUInteger)bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);
707
- });
708
- }
709
- }
710
-
711
- - (void)connection:(NSURLConnection __unused *)connection
712
- didReceiveResponse:(NSURLResponse *)response
713
- {
714
- self.response = response;
715
-
716
- [self.outputStream open];
717
- }
718
-
719
- - (void)connection:(NSURLConnection __unused *)connection
720
- didReceiveData:(NSData *)data
721
- {
722
- NSUInteger length = [data length];
723
- while (YES) {
724
- NSUInteger totalNumberOfBytesWritten = 0;
725
- if ([self.outputStream hasSpaceAvailable]) {
726
- const uint8_t *dataBuffer = (uint8_t *)[data bytes];
727
-
728
- NSInteger numberOfBytesWritten = 0;
729
- while (totalNumberOfBytesWritten < length) {
730
- numberOfBytesWritten = [self.outputStream write:&dataBuffer[0] maxLength:length];
731
- if (numberOfBytesWritten == -1) {
732
- [self.connection cancel];
733
- [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:self.outputStream.streamError];
734
- return;
735
- } else {
736
- totalNumberOfBytesWritten += numberOfBytesWritten;
737
- }
738
- }
739
-
740
- break;
741
- }
742
- }
743
-
744
- dispatch_async(dispatch_get_main_queue(), ^{
745
- self.totalBytesRead += length;
746
-
747
- if (self.downloadProgress) {
748
- self.downloadProgress(length, self.totalBytesRead, self.response.expectedContentLength);
749
- }
750
- });
751
- }
752
-
753
- - (void)connectionDidFinishLoading:(NSURLConnection __unused *)connection {
754
- self.responseData = [self.outputStream propertyForKey:NSStreamDataWrittenToMemoryStreamKey];
755
-
756
- [self.outputStream close];
757
-
758
- [self finish];
759
-
760
- self.connection = nil;
761
- }
762
-
763
- - (void)connection:(NSURLConnection __unused *)connection
764
- didFailWithError:(NSError *)error
765
- {
766
- self.error = error;
767
-
768
- [self.outputStream close];
769
-
770
- [self finish];
771
-
772
- self.connection = nil;
773
- }
774
-
775
- - (NSCachedURLResponse *)connection:(NSURLConnection *)connection
776
- willCacheResponse:(NSCachedURLResponse *)cachedResponse
777
- {
778
- if (self.cacheResponse) {
779
- return self.cacheResponse(connection, cachedResponse);
780
- } else {
781
- if ([self isCancelled]) {
782
- return nil;
783
- }
784
-
785
- return cachedResponse;
786
- }
787
- }
788
-
789
- #pragma mark - NSCoding
790
-
791
- - (id)initWithCoder:(NSCoder *)aDecoder {
792
- NSURLRequest *request = [aDecoder decodeObjectForKey:@"request"];
793
-
794
- self = [self initWithRequest:request];
795
- if (!self) {
796
- return nil;
797
- }
798
-
799
- self.state = (AFOperationState)[aDecoder decodeIntegerForKey:@"state"];
800
- self.cancelled = [aDecoder decodeBoolForKey:@"isCancelled"];
801
- self.response = [aDecoder decodeObjectForKey:@"response"];
802
- self.error = [aDecoder decodeObjectForKey:@"error"];
803
- self.responseData = [aDecoder decodeObjectForKey:@"responseData"];
804
- self.totalBytesRead = [[aDecoder decodeObjectForKey:@"totalBytesRead"] longLongValue];
805
- self.allowsInvalidSSLCertificate = [[aDecoder decodeObjectForKey:@"allowsInvalidSSLCertificate"] boolValue];
806
-
807
- return self;
808
- }
809
-
810
- - (void)encodeWithCoder:(NSCoder *)aCoder {
811
- [self pause];
812
-
813
- [aCoder encodeObject:self.request forKey:@"request"];
814
-
815
- switch (self.state) {
816
- case AFOperationExecutingState:
817
- case AFOperationPausedState:
818
- [aCoder encodeInteger:AFOperationReadyState forKey:@"state"];
819
- break;
820
- default:
821
- [aCoder encodeInteger:self.state forKey:@"state"];
822
- break;
823
- }
824
-
825
- [aCoder encodeBool:[self isCancelled] forKey:@"isCancelled"];
826
- [aCoder encodeObject:self.response forKey:@"response"];
827
- [aCoder encodeObject:self.error forKey:@"error"];
828
- [aCoder encodeObject:self.responseData forKey:@"responseData"];
829
- [aCoder encodeObject:[NSNumber numberWithLongLong:self.totalBytesRead] forKey:@"totalBytesRead"];
830
- [aCoder encodeObject:[NSNumber numberWithBool:self.allowsInvalidSSLCertificate] forKey:@"allowsInvalidSSLCertificate"];
831
- }
832
-
833
- #pragma mark - NSCopying
834
-
835
- - (id)copyWithZone:(NSZone *)zone {
836
- AFURLConnectionOperation *operation = [(AFURLConnectionOperation *)[[self class] allocWithZone:zone] initWithRequest:self.request];
837
-
838
- operation.uploadProgress = self.uploadProgress;
839
- operation.downloadProgress = self.downloadProgress;
840
- operation.authenticationChallenge = self.authenticationChallenge;
841
- operation.cacheResponse = self.cacheResponse;
842
- operation.redirectResponse = self.redirectResponse;
843
- operation.allowsInvalidSSLCertificate = self.allowsInvalidSSLCertificate;
844
-
845
- return operation;
846
- }
847
-
848
- @end