From 0cecccf1be555fee38a6e97845408a79fbb5ac04 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Mon, 30 Jun 2014 15:17:02 -0700 Subject: [PATCH] Merge strong-remoting-ios into loopback-ios --- .gitignore | 2 + .gitmodules | 3 - LoopBack.podspec | 15 + LoopBack.xcodeproj/project.pbxproj | 404 ++--- LoopBack.xcworkspace/contents.xcworkspacedata | 1 + Podfile | 2 + SLAFNetworking/SLAFHTTPClient.h | 643 ++++++++ SLAFNetworking/SLAFHTTPClient.m | 1372 +++++++++++++++++ SLAFNetworking/SLAFHTTPRequestOperation.h | 133 ++ SLAFNetworking/SLAFHTTPRequestOperation.m | 319 ++++ SLAFNetworking/SLAFImageRequestOperation.h | 108 ++ SLAFNetworking/SLAFImageRequestOperation.m | 238 +++ SLAFNetworking/SLAFJSONRequestOperation.h | 71 + SLAFNetworking/SLAFJSONRequestOperation.m | 150 ++ .../SLAFNetworkActivityIndicatorManager.h | 75 + .../SLAFNetworkActivityIndicatorManager.m | 157 ++ SLAFNetworking/SLAFNetworking.h | 43 + .../SLAFPropertyListRequestOperation.h | 68 + .../SLAFPropertyListRequestOperation.m | 143 ++ SLAFNetworking/SLAFURLConnectionOperation.h | 407 +++++ SLAFNetworking/SLAFURLConnectionOperation.m | 907 +++++++++++ SLAFNetworking/SLAFXMLRequestOperation.h | 89 ++ SLAFNetworking/SLAFXMLRequestOperation.m | 167 ++ SLAFNetworking/UIImageView+SLAFNetworking.h | 78 + SLAFNetworking/UIImageView+SLAFNetworking.m | 184 +++ SLRemotingTests/SLRESTAdapterNonRootTests.h | 13 + SLRemotingTests/SLRESTAdapterNonRootTests.m | 90 ++ SLRemotingTests/SLRESTAdapterSSLTests.m | 132 ++ SLRemotingTests/SLRESTAdapterTests.h | 13 + SLRemotingTests/SLRESTAdapterTests.m | 132 ++ SLRemotingTests/SLRESTContractTests.h | 13 + SLRemotingTests/SLRESTContractTests.m | 154 ++ SLRemotingTests/SLRemotingTests-Info.plist | 22 + SLRemotingTests/en.lproj/InfoPlist.strings | 2 + SLRemotingTests/server/.gitignore | 1 + SLRemotingTests/server/contract-class.js | 49 + SLRemotingTests/server/contract.js | 26 + SLRemotingTests/server/index.js | 29 + SLRemotingTests/server/nonroot.js | 26 + SLRemotingTests/server/package.json | 9 + .../server/private/certificate.pem | 13 + SLRemotingTests/server/private/privatekey.pem | 15 + SLRemotingTests/server/simple-class.js | 48 + SLRemotingTests/server/simple.js | 24 + SLRemotingTests/server/ssl-config.js | 6 + docs/html/_l_b_access_token_8h.html | 113 ++ docs/html/_l_b_access_token_8h_source.html | 117 ++ docs/html/_l_b_container_8h.html | 114 ++ docs/html/_l_b_container_8h_source.html | 143 ++ docs/html/_l_b_file_8h.html | 113 ++ docs/html/_l_b_file_8h_source.html | 139 ++ docs/html/_l_b_installation_8h.html | 4 +- docs/html/_l_b_installation_8h_source.html | 14 +- docs/html/_l_b_model_8h.html | 4 +- docs/html/_l_b_model_8h_source.html | 22 +- docs/html/_l_b_push_notification_8h.html | 4 +- .../_l_b_push_notification_8h_source.html | 8 +- docs/html/_l_b_r_e_s_t_adapter_8h.html | 6 +- docs/html/_l_b_r_e_s_t_adapter_8h_source.html | 7 +- docs/html/_l_b_user_8h.html | 113 ++ docs/html/_l_b_user_8h_source.html | 146 ++ docs/html/_loop_back_8h.html | 7 +- docs/html/_loop_back_8h_source.html | 11 +- docs/html/annotated.html | 27 +- docs/html/classes.html | 16 +- .../dir_34f523d15f3e31a8b8d1fd09f77896dc.html | 12 +- docs/html/files.html | 31 +- docs/html/functions.html | 131 +- docs/html/functions_func.html | 159 +- docs/html/functions_prop.html | 34 +- docs/html/functions_type.html | 13 +- docs/html/globals.html | 33 +- docs/html/globals_enum.html | 6 +- docs/html/globals_eval.html | 6 +- docs/html/globals_type.html | 12 +- docs/html/hierarchy.html | 34 +- docs/html/index.html | 4 +- docs/html/interface_l_b_access_token.html | 179 +++ docs/html/interface_l_b_access_token.png | Bin 0 -> 633 bytes docs/html/interface_l_b_container.html | 259 ++++ docs/html/interface_l_b_container.png | Bin 0 -> 584 bytes docs/html/interface_l_b_file.html | 256 +++ docs/html/interface_l_b_file.png | Bin 0 -> 470 bytes docs/html/interface_l_b_installation.html | 30 +- docs/html/interface_l_b_installation.png | Bin 710 -> 547 bytes ...interface_l_b_installation_repository.html | 33 +- .../interface_l_b_installation_repository.png | Bin 1132 -> 895 bytes docs/html/interface_l_b_model.html | 37 +- docs/html/interface_l_b_model.png | Bin 719 -> 1602 bytes docs/html/interface_l_b_model_repository.html | 46 +- docs/html/interface_l_b_model_repository.png | Bin 1139 -> 902 bytes .../html/interface_l_b_push_notification.html | 8 +- docs/html/interface_l_b_r_e_s_t_adapter.html | 41 +- docs/html/interface_l_b_r_e_s_t_adapter.png | Bin 933 -> 509 bytes docs/html/interface_l_b_user.html | 168 ++ docs/html/interface_l_b_user.png | Bin 0 -> 480 bytes docs/html/search/all_1.js | 10 +- docs/html/search/all_3.js | 6 +- docs/html/search/all_4.js | 3 +- docs/html/search/all_6.js | 3 +- docs/html/search/all_7.js | 37 +- docs/html/search/all_8.js | 18 +- docs/html/search/all_9.js | 3 +- docs/html/search/all_a.js | 8 +- docs/html/search/all_b.js | 6 +- docs/html/search/all_c.js | 10 +- docs/html/search/all_d.js | 25 +- docs/html/search/classes_0.js | 6 +- docs/html/search/files_0.js | 4 + docs/html/search/functions_0.js | 4 - docs/html/search/functions_1.js | 3 +- docs/html/search/functions_2.js | 4 +- docs/html/search/functions_4.js | 3 +- docs/html/search/functions_5.js | 11 +- docs/html/search/functions_6.js | 2 +- docs/html/search/functions_7.js | 8 +- docs/html/search/functions_8.js | 3 +- docs/html/search/functions_9.js | 7 +- docs/html/search/functions_a.js | 3 +- docs/html/search/properties_1.js | 1 - docs/html/search/properties_3.js | 6 +- docs/html/search/properties_4.js | 4 +- docs/html/search/properties_5.js | 3 +- docs/html/search/properties_6.js | 3 +- docs/html/search/properties_7.js | 3 +- docs/html/search/search.js | 28 +- docs/html/search/typedefs_0.js | 3 + 127 files changed, 8579 insertions(+), 915 deletions(-) create mode 100644 LoopBack.podspec create mode 100644 LoopBack.xcworkspace/contents.xcworkspacedata create mode 100644 Podfile create mode 100755 SLAFNetworking/SLAFHTTPClient.h create mode 100755 SLAFNetworking/SLAFHTTPClient.m create mode 100755 SLAFNetworking/SLAFHTTPRequestOperation.h create mode 100755 SLAFNetworking/SLAFHTTPRequestOperation.m create mode 100755 SLAFNetworking/SLAFImageRequestOperation.h create mode 100755 SLAFNetworking/SLAFImageRequestOperation.m create mode 100755 SLAFNetworking/SLAFJSONRequestOperation.h create mode 100755 SLAFNetworking/SLAFJSONRequestOperation.m create mode 100755 SLAFNetworking/SLAFNetworkActivityIndicatorManager.h create mode 100755 SLAFNetworking/SLAFNetworkActivityIndicatorManager.m create mode 100755 SLAFNetworking/SLAFNetworking.h create mode 100755 SLAFNetworking/SLAFPropertyListRequestOperation.h create mode 100755 SLAFNetworking/SLAFPropertyListRequestOperation.m create mode 100755 SLAFNetworking/SLAFURLConnectionOperation.h create mode 100755 SLAFNetworking/SLAFURLConnectionOperation.m create mode 100755 SLAFNetworking/SLAFXMLRequestOperation.h create mode 100755 SLAFNetworking/SLAFXMLRequestOperation.m create mode 100755 SLAFNetworking/UIImageView+SLAFNetworking.h create mode 100755 SLAFNetworking/UIImageView+SLAFNetworking.m create mode 100644 SLRemotingTests/SLRESTAdapterNonRootTests.h create mode 100644 SLRemotingTests/SLRESTAdapterNonRootTests.m create mode 100644 SLRemotingTests/SLRESTAdapterSSLTests.m create mode 100644 SLRemotingTests/SLRESTAdapterTests.h create mode 100644 SLRemotingTests/SLRESTAdapterTests.m create mode 100644 SLRemotingTests/SLRESTContractTests.h create mode 100644 SLRemotingTests/SLRESTContractTests.m create mode 100644 SLRemotingTests/SLRemotingTests-Info.plist create mode 100644 SLRemotingTests/en.lproj/InfoPlist.strings create mode 100644 SLRemotingTests/server/.gitignore create mode 100644 SLRemotingTests/server/contract-class.js create mode 100644 SLRemotingTests/server/contract.js create mode 100644 SLRemotingTests/server/index.js create mode 100644 SLRemotingTests/server/nonroot.js create mode 100644 SLRemotingTests/server/package.json create mode 100644 SLRemotingTests/server/private/certificate.pem create mode 100644 SLRemotingTests/server/private/privatekey.pem create mode 100644 SLRemotingTests/server/simple-class.js create mode 100644 SLRemotingTests/server/simple.js create mode 100644 SLRemotingTests/server/ssl-config.js create mode 100644 docs/html/_l_b_access_token_8h.html create mode 100644 docs/html/_l_b_access_token_8h_source.html create mode 100644 docs/html/_l_b_container_8h.html create mode 100644 docs/html/_l_b_container_8h_source.html create mode 100644 docs/html/_l_b_file_8h.html create mode 100644 docs/html/_l_b_file_8h_source.html create mode 100644 docs/html/_l_b_user_8h.html create mode 100644 docs/html/_l_b_user_8h_source.html create mode 100644 docs/html/interface_l_b_access_token.html create mode 100644 docs/html/interface_l_b_access_token.png create mode 100644 docs/html/interface_l_b_container.html create mode 100644 docs/html/interface_l_b_container.png create mode 100644 docs/html/interface_l_b_file.html create mode 100644 docs/html/interface_l_b_file.png create mode 100644 docs/html/interface_l_b_user.html create mode 100644 docs/html/interface_l_b_user.png diff --git a/.gitignore b/.gitignore index f12f0e5..712ac84 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ npm-debug.log node_modules *.xcuserdatad *.xccheckout +*.lock +Pods diff --git a/.gitmodules b/.gitmodules index 367e60d..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "SLRemoting"] - path = SLRemoting - url = git@github.com:strongloop/strong-remoting-ios.git diff --git a/LoopBack.podspec b/LoopBack.podspec new file mode 100644 index 0000000..1fe2d35 --- /dev/null +++ b/LoopBack.podspec @@ -0,0 +1,15 @@ +Pod::Spec.new do |s| + s.name = 'LoopBack' + s.version = '1.3.0' + s.license = { :type=> 'MIT & StrongLoop', :file=>'LICENSE' } + s.summary = 'iOS SDK for LoopBack.' + s.homepage = 'https://github.com/strongloop/loopback-ios' + s.authors = { 'StrongLoop' => 'callback@strongloop.com' } + s.source = { :git => 'https://github.com/strongloop/loopback-ios.git', :tag => '1.3.0' } + s.source_files = 'LoopBack/*.{h,m}', 'SLRemoting/*.{h,m}', 'SLAFNetworking/*.{h,m}' + s.requires_arc = true + + s.ios.deployment_target = '6.1' + s.ios.frameworks = 'UIKit', 'Foundation', 'SenTestingKit' + +end diff --git a/LoopBack.xcodeproj/project.pbxproj b/LoopBack.xcodeproj/project.pbxproj index 92e410b..8afa243 100644 --- a/LoopBack.xcodeproj/project.pbxproj +++ b/LoopBack.xcodeproj/project.pbxproj @@ -48,39 +48,56 @@ 0B8022DF18A2F1BA00AF845E /* LBContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B8022DE18A2F1BA00AF845E /* LBContainer.h */; settings = {ATTRIBUTES = (Public, ); }; }; 0B8022E518A2F27600AF845E /* LBContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 0B8022E418A2F27600AF845E /* LBContainer.m */; }; 4769FF09184D6F4F00E5152C /* LBInstallationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4769FF08184D6F4F00E5152C /* LBInstallationTests.m */; }; - 4792A72D18C7D8160077ED45 /* AFHTTPClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4792A66018C7D8150077ED45 /* AFHTTPClient.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4792A72E18C7D8160077ED45 /* AFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 4792A66118C7D8150077ED45 /* AFHTTPClient.m */; }; - 4792A72F18C7D8160077ED45 /* AFHTTPRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4792A66218C7D8150077ED45 /* AFHTTPRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4792A73018C7D8160077ED45 /* AFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 4792A66318C7D8150077ED45 /* AFHTTPRequestOperation.m */; }; - 4792A73118C7D8160077ED45 /* AFImageRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4792A66418C7D8150077ED45 /* AFImageRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4792A73218C7D8160077ED45 /* AFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 4792A66518C7D8150077ED45 /* AFImageRequestOperation.m */; }; - 4792A73318C7D8160077ED45 /* AFJSONRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4792A66618C7D8150077ED45 /* AFJSONRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4792A73418C7D8160077ED45 /* AFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 4792A66718C7D8150077ED45 /* AFJSONRequestOperation.m */; }; - 4792A73518C7D8160077ED45 /* AFNetworkActivityIndicatorManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4792A66818C7D8150077ED45 /* AFNetworkActivityIndicatorManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4792A73618C7D8160077ED45 /* AFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 4792A66918C7D8150077ED45 /* AFNetworkActivityIndicatorManager.m */; }; - 4792A73718C7D8160077ED45 /* AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 4792A66A18C7D8150077ED45 /* AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4792A73818C7D8160077ED45 /* AFPropertyListRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4792A66B18C7D8150077ED45 /* AFPropertyListRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4792A73918C7D8160077ED45 /* AFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 4792A66C18C7D8150077ED45 /* AFPropertyListRequestOperation.m */; }; - 4792A73A18C7D8160077ED45 /* AFURLConnectionOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4792A66D18C7D8150077ED45 /* AFURLConnectionOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4792A73B18C7D8160077ED45 /* AFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 4792A66E18C7D8150077ED45 /* AFURLConnectionOperation.m */; }; - 4792A73C18C7D8160077ED45 /* AFXMLRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 4792A66F18C7D8150077ED45 /* AFXMLRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4792A73D18C7D8160077ED45 /* AFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 4792A67018C7D8150077ED45 /* AFXMLRequestOperation.m */; }; - 4792A73E18C7D8160077ED45 /* UIImageView+AFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 4792A67118C7D8150077ED45 /* UIImageView+AFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4792A73F18C7D8160077ED45 /* UIImageView+AFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 4792A67218C7D8150077ED45 /* UIImageView+AFNetworking.m */; }; - 4792A76018C7D8160077ED45 /* SLAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = 4792A70518C7D8150077ED45 /* SLAdapter.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4792A76118C7D8160077ED45 /* SLAdapter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4792A70618C7D8150077ED45 /* SLAdapter.m */; }; - 4792A76218C7D8160077ED45 /* SLObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 4792A70718C7D8150077ED45 /* SLObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4792A76318C7D8160077ED45 /* SLObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 4792A70818C7D8150077ED45 /* SLObject.m */; }; - 4792A76418C7D8160077ED45 /* SLRemoting-Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 4792A70918C7D8150077ED45 /* SLRemoting-Prefix.pch */; }; - 4792A76518C7D8160077ED45 /* SLRemoting.h in Headers */ = {isa = PBXBuildFile; fileRef = 4792A70A18C7D8150077ED45 /* SLRemoting.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4792A76618C7D8160077ED45 /* SLRemotingUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 4792A70B18C7D8150077ED45 /* SLRemotingUtils.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4792A76718C7D8160077ED45 /* SLRemotingUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 4792A70C18C7D8150077ED45 /* SLRemotingUtils.m */; }; - 4792A76818C7D8160077ED45 /* SLRESTAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = 4792A70D18C7D8150077ED45 /* SLRESTAdapter.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4792A76918C7D8160077ED45 /* SLRESTAdapter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4792A70E18C7D8150077ED45 /* SLRESTAdapter.m */; }; - 4792A76A18C7D8160077ED45 /* SLRESTContract.h in Headers */ = {isa = PBXBuildFile; fileRef = 4792A70F18C7D8150077ED45 /* SLRESTContract.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4792A76B18C7D8160077ED45 /* SLRESTContract.m in Sources */ = {isa = PBXBuildFile; fileRef = 4792A71018C7D8150077ED45 /* SLRESTContract.m */; }; 47AD031318491DA700F724C8 /* LBInstallation.m in Sources */ = {isa = PBXBuildFile; fileRef = 47AD031118491DA700F724C8 /* LBInstallation.m */; }; 47AD031418491E2000F724C8 /* LBInstallation.h in Headers */ = {isa = PBXBuildFile; fileRef = 47AD031018491DA700F724C8 /* LBInstallation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48B951962120E00995044 /* SLAFHTTPClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B751962120E00995044 /* SLAFHTTPClient.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48B961962120E00995044 /* SLAFHTTPClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48B761962120E00995044 /* SLAFHTTPClient.m */; }; + 47C48B971962120E00995044 /* SLAFHTTPRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B771962120E00995044 /* SLAFHTTPRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48B981962120E00995044 /* SLAFHTTPRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48B781962120E00995044 /* SLAFHTTPRequestOperation.m */; }; + 47C48B991962120E00995044 /* SLAFImageRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B791962120E00995044 /* SLAFImageRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48B9A1962120E00995044 /* SLAFImageRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48B7A1962120E00995044 /* SLAFImageRequestOperation.m */; }; + 47C48B9B1962120E00995044 /* SLAFJSONRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B7B1962120E00995044 /* SLAFJSONRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48B9C1962120E00995044 /* SLAFJSONRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48B7C1962120E00995044 /* SLAFJSONRequestOperation.m */; }; + 47C48B9D1962120E00995044 /* SLAFNetworkActivityIndicatorManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B7D1962120E00995044 /* SLAFNetworkActivityIndicatorManager.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48B9E1962120E00995044 /* SLAFNetworkActivityIndicatorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48B7E1962120E00995044 /* SLAFNetworkActivityIndicatorManager.m */; }; + 47C48B9F1962120E00995044 /* SLAFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B7F1962120E00995044 /* SLAFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48BA01962120E00995044 /* SLAFPropertyListRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B801962120E00995044 /* SLAFPropertyListRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48BA11962120E00995044 /* SLAFPropertyListRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48B811962120E00995044 /* SLAFPropertyListRequestOperation.m */; }; + 47C48BA21962120E00995044 /* SLAFURLConnectionOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B821962120E00995044 /* SLAFURLConnectionOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48BA31962120E00995044 /* SLAFURLConnectionOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48B831962120E00995044 /* SLAFURLConnectionOperation.m */; }; + 47C48BA41962120E00995044 /* SLAFXMLRequestOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B841962120E00995044 /* SLAFXMLRequestOperation.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48BA51962120E00995044 /* SLAFXMLRequestOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48B851962120E00995044 /* SLAFXMLRequestOperation.m */; }; + 47C48BA61962120E00995044 /* UIImageView+SLAFNetworking.h in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B861962120E00995044 /* UIImageView+SLAFNetworking.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48BA71962120E00995044 /* UIImageView+SLAFNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48B871962120E00995044 /* UIImageView+SLAFNetworking.m */; }; + 47C48BA81962120E00995044 /* SLAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B891962120E00995044 /* SLAdapter.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48BA91962120E00995044 /* SLAdapter.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48B8A1962120E00995044 /* SLAdapter.m */; }; + 47C48BAA1962120E00995044 /* SLObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B8B1962120E00995044 /* SLObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48BAB1962120E00995044 /* SLObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48B8C1962120E00995044 /* SLObject.m */; }; + 47C48BAC1962120E00995044 /* SLRemoting-Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B8D1962120E00995044 /* SLRemoting-Prefix.pch */; }; + 47C48BAD1962120E00995044 /* SLRemoting.h in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B8E1962120E00995044 /* SLRemoting.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48BAE1962120E00995044 /* SLRemotingUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B8F1962120E00995044 /* SLRemotingUtils.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48BAF1962120E00995044 /* SLRemotingUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48B901962120E00995044 /* SLRemotingUtils.m */; }; + 47C48BB01962120E00995044 /* SLRESTAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B911962120E00995044 /* SLRESTAdapter.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48BB11962120E00995044 /* SLRESTAdapter.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48B921962120E00995044 /* SLRESTAdapter.m */; }; + 47C48BB21962120E00995044 /* SLRESTContract.h in Headers */ = {isa = PBXBuildFile; fileRef = 47C48B931962120E00995044 /* SLRESTContract.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 47C48BB31962120E00995044 /* SLRESTContract.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48B941962120E00995044 /* SLRESTContract.m */; }; + 47C48BCC1962123900995044 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 47C48BB51962123900995044 /* InfoPlist.strings */; }; + 47C48BCD1962123900995044 /* .gitignore in Resources */ = {isa = PBXBuildFile; fileRef = 47C48BB81962123900995044 /* .gitignore */; }; + 47C48BCE1962123900995044 /* contract-class.js in Sources */ = {isa = PBXBuildFile; fileRef = 47C48BB91962123900995044 /* contract-class.js */; }; + 47C48BCF1962123900995044 /* contract.js in Sources */ = {isa = PBXBuildFile; fileRef = 47C48BBA1962123900995044 /* contract.js */; }; + 47C48BD01962123900995044 /* index.js in Sources */ = {isa = PBXBuildFile; fileRef = 47C48BBB1962123900995044 /* index.js */; }; + 47C48BD11962123900995044 /* nonroot.js in Sources */ = {isa = PBXBuildFile; fileRef = 47C48BBC1962123900995044 /* nonroot.js */; }; + 47C48BD21962123900995044 /* package.json in Resources */ = {isa = PBXBuildFile; fileRef = 47C48BBD1962123900995044 /* package.json */; }; + 47C48BD31962123900995044 /* certificate.pem in Resources */ = {isa = PBXBuildFile; fileRef = 47C48BBF1962123900995044 /* certificate.pem */; }; + 47C48BD41962123900995044 /* privatekey.pem in Resources */ = {isa = PBXBuildFile; fileRef = 47C48BC01962123900995044 /* privatekey.pem */; }; + 47C48BD51962123900995044 /* simple-class.js in Sources */ = {isa = PBXBuildFile; fileRef = 47C48BC11962123900995044 /* simple-class.js */; }; + 47C48BD61962123900995044 /* simple.js in Sources */ = {isa = PBXBuildFile; fileRef = 47C48BC21962123900995044 /* simple.js */; }; + 47C48BD71962123900995044 /* ssl-config.js in Sources */ = {isa = PBXBuildFile; fileRef = 47C48BC31962123900995044 /* ssl-config.js */; }; + 47C48BD81962123900995044 /* SLRemotingTests-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 47C48BC41962123900995044 /* SLRemotingTests-Info.plist */; }; + 47C48BD91962123900995044 /* SLRESTAdapterNonRootTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48BC61962123900995044 /* SLRESTAdapterNonRootTests.m */; }; + 47C48BDA1962123900995044 /* SLRESTAdapterSSLTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48BC71962123900995044 /* SLRESTAdapterSSLTests.m */; }; + 47C48BDB1962123900995044 /* SLRESTAdapterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48BC91962123900995044 /* SLRESTAdapterTests.m */; }; + 47C48BDC1962123900995044 /* SLRESTContractTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 47C48BCB1962123900995044 /* SLRESTContractTests.m */; }; 47F8E813185B7A4E0088BB73 /* LBPushNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 47F8E811185B7A4E0088BB73 /* LBPushNotification.h */; settings = {ATTRIBUTES = (Public, ); }; }; 47F8E814185B7A4E0088BB73 /* LBPushNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 47F8E812185B7A4E0088BB73 /* LBPushNotification.m */; }; B3D220FB17722AE800B7CB63 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B3D220FA17722AE800B7CB63 /* Foundation.framework */; }; @@ -101,20 +118,6 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 4792A77E18C7D8160077ED45 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4792A71118C7D8150077ED45 /* SLRemoting.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = B34A481B175D4BC400574A43; - remoteInfo = SLRemoting; - }; - 4792A78018C7D8160077ED45 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 4792A71118C7D8150077ED45 /* SLRemoting.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = B34A482C175D4BC400574A43; - remoteInfo = SLRemotingTests; - }; B3D2210E17722AE800B7CB63 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = B3D220EF17722AE800B7CB63 /* Project object */; @@ -150,40 +153,59 @@ 0B8022E418A2F27600AF845E /* LBContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LBContainer.m; sourceTree = ""; }; 4769FF07184D6F4F00E5152C /* LBInstallationTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LBInstallationTests.h; sourceTree = ""; }; 4769FF08184D6F4F00E5152C /* LBInstallationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LBInstallationTests.m; sourceTree = ""; }; - 4792A66018C7D8150077ED45 /* AFHTTPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPClient.h; sourceTree = ""; }; - 4792A66118C7D8150077ED45 /* AFHTTPClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPClient.m; sourceTree = ""; }; - 4792A66218C7D8150077ED45 /* AFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFHTTPRequestOperation.h; sourceTree = ""; }; - 4792A66318C7D8150077ED45 /* AFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFHTTPRequestOperation.m; sourceTree = ""; }; - 4792A66418C7D8150077ED45 /* AFImageRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFImageRequestOperation.h; sourceTree = ""; }; - 4792A66518C7D8150077ED45 /* AFImageRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFImageRequestOperation.m; sourceTree = ""; }; - 4792A66618C7D8150077ED45 /* AFJSONRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFJSONRequestOperation.h; sourceTree = ""; }; - 4792A66718C7D8150077ED45 /* AFJSONRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFJSONRequestOperation.m; sourceTree = ""; }; - 4792A66818C7D8150077ED45 /* AFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworkActivityIndicatorManager.h; sourceTree = ""; }; - 4792A66918C7D8150077ED45 /* AFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFNetworkActivityIndicatorManager.m; sourceTree = ""; }; - 4792A66A18C7D8150077ED45 /* AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFNetworking.h; sourceTree = ""; }; - 4792A66B18C7D8150077ED45 /* AFPropertyListRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFPropertyListRequestOperation.h; sourceTree = ""; }; - 4792A66C18C7D8150077ED45 /* AFPropertyListRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFPropertyListRequestOperation.m; sourceTree = ""; }; - 4792A66D18C7D8150077ED45 /* AFURLConnectionOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFURLConnectionOperation.h; sourceTree = ""; }; - 4792A66E18C7D8150077ED45 /* AFURLConnectionOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFURLConnectionOperation.m; sourceTree = ""; }; - 4792A66F18C7D8150077ED45 /* AFXMLRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AFXMLRequestOperation.h; sourceTree = ""; }; - 4792A67018C7D8150077ED45 /* AFXMLRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AFXMLRequestOperation.m; sourceTree = ""; }; - 4792A67118C7D8150077ED45 /* UIImageView+AFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+AFNetworking.h"; sourceTree = ""; }; - 4792A67218C7D8150077ED45 /* UIImageView+AFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+AFNetworking.m"; sourceTree = ""; }; - 4792A70518C7D8150077ED45 /* SLAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLAdapter.h; sourceTree = ""; }; - 4792A70618C7D8150077ED45 /* SLAdapter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLAdapter.m; sourceTree = ""; }; - 4792A70718C7D8150077ED45 /* SLObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLObject.h; sourceTree = ""; }; - 4792A70818C7D8150077ED45 /* SLObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLObject.m; sourceTree = ""; }; - 4792A70918C7D8150077ED45 /* SLRemoting-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SLRemoting-Prefix.pch"; sourceTree = ""; }; - 4792A70A18C7D8150077ED45 /* SLRemoting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLRemoting.h; sourceTree = ""; }; - 4792A70B18C7D8150077ED45 /* SLRemotingUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLRemotingUtils.h; sourceTree = ""; }; - 4792A70C18C7D8150077ED45 /* SLRemotingUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLRemotingUtils.m; sourceTree = ""; }; - 4792A70D18C7D8150077ED45 /* SLRESTAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLRESTAdapter.h; sourceTree = ""; }; - 4792A70E18C7D8150077ED45 /* SLRESTAdapter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLRESTAdapter.m; sourceTree = ""; }; - 4792A70F18C7D8150077ED45 /* SLRESTContract.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLRESTContract.h; sourceTree = ""; }; - 4792A71018C7D8150077ED45 /* SLRESTContract.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLRESTContract.m; sourceTree = ""; }; - 4792A71118C7D8150077ED45 /* SLRemoting.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = SLRemoting.xcodeproj; sourceTree = ""; }; 47AD031018491DA700F724C8 /* LBInstallation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LBInstallation.h; sourceTree = ""; }; 47AD031118491DA700F724C8 /* LBInstallation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LBInstallation.m; sourceTree = ""; }; + 47C48B751962120E00995044 /* SLAFHTTPClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLAFHTTPClient.h; sourceTree = ""; }; + 47C48B761962120E00995044 /* SLAFHTTPClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLAFHTTPClient.m; sourceTree = ""; }; + 47C48B771962120E00995044 /* SLAFHTTPRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLAFHTTPRequestOperation.h; sourceTree = ""; }; + 47C48B781962120E00995044 /* SLAFHTTPRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLAFHTTPRequestOperation.m; sourceTree = ""; }; + 47C48B791962120E00995044 /* SLAFImageRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLAFImageRequestOperation.h; sourceTree = ""; }; + 47C48B7A1962120E00995044 /* SLAFImageRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLAFImageRequestOperation.m; sourceTree = ""; }; + 47C48B7B1962120E00995044 /* SLAFJSONRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLAFJSONRequestOperation.h; sourceTree = ""; }; + 47C48B7C1962120E00995044 /* SLAFJSONRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLAFJSONRequestOperation.m; sourceTree = ""; }; + 47C48B7D1962120E00995044 /* SLAFNetworkActivityIndicatorManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLAFNetworkActivityIndicatorManager.h; sourceTree = ""; }; + 47C48B7E1962120E00995044 /* SLAFNetworkActivityIndicatorManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLAFNetworkActivityIndicatorManager.m; sourceTree = ""; }; + 47C48B7F1962120E00995044 /* SLAFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLAFNetworking.h; sourceTree = ""; }; + 47C48B801962120E00995044 /* SLAFPropertyListRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLAFPropertyListRequestOperation.h; sourceTree = ""; }; + 47C48B811962120E00995044 /* SLAFPropertyListRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLAFPropertyListRequestOperation.m; sourceTree = ""; }; + 47C48B821962120E00995044 /* SLAFURLConnectionOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLAFURLConnectionOperation.h; sourceTree = ""; }; + 47C48B831962120E00995044 /* SLAFURLConnectionOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLAFURLConnectionOperation.m; sourceTree = ""; }; + 47C48B841962120E00995044 /* SLAFXMLRequestOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLAFXMLRequestOperation.h; sourceTree = ""; }; + 47C48B851962120E00995044 /* SLAFXMLRequestOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLAFXMLRequestOperation.m; sourceTree = ""; }; + 47C48B861962120E00995044 /* UIImageView+SLAFNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImageView+SLAFNetworking.h"; sourceTree = ""; }; + 47C48B871962120E00995044 /* UIImageView+SLAFNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+SLAFNetworking.m"; sourceTree = ""; }; + 47C48B891962120E00995044 /* SLAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLAdapter.h; sourceTree = ""; }; + 47C48B8A1962120E00995044 /* SLAdapter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLAdapter.m; sourceTree = ""; }; + 47C48B8B1962120E00995044 /* SLObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLObject.h; sourceTree = ""; }; + 47C48B8C1962120E00995044 /* SLObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLObject.m; sourceTree = ""; }; + 47C48B8D1962120E00995044 /* SLRemoting-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SLRemoting-Prefix.pch"; sourceTree = ""; }; + 47C48B8E1962120E00995044 /* SLRemoting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLRemoting.h; sourceTree = ""; }; + 47C48B8F1962120E00995044 /* SLRemotingUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLRemotingUtils.h; sourceTree = ""; }; + 47C48B901962120E00995044 /* SLRemotingUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLRemotingUtils.m; sourceTree = ""; }; + 47C48B911962120E00995044 /* SLRESTAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLRESTAdapter.h; sourceTree = ""; }; + 47C48B921962120E00995044 /* SLRESTAdapter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLRESTAdapter.m; sourceTree = ""; }; + 47C48B931962120E00995044 /* SLRESTContract.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLRESTContract.h; sourceTree = ""; }; + 47C48B941962120E00995044 /* SLRESTContract.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLRESTContract.m; sourceTree = ""; }; + 47C48BB61962123900995044 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; + 47C48BB81962123900995044 /* .gitignore */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = .gitignore; sourceTree = ""; }; + 47C48BB91962123900995044 /* contract-class.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "contract-class.js"; sourceTree = ""; }; + 47C48BBA1962123900995044 /* contract.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = contract.js; sourceTree = ""; }; + 47C48BBB1962123900995044 /* index.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = index.js; sourceTree = ""; }; + 47C48BBC1962123900995044 /* nonroot.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = nonroot.js; sourceTree = ""; }; + 47C48BBD1962123900995044 /* package.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = package.json; sourceTree = ""; }; + 47C48BBF1962123900995044 /* certificate.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = certificate.pem; sourceTree = ""; }; + 47C48BC01962123900995044 /* privatekey.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = privatekey.pem; sourceTree = ""; }; + 47C48BC11962123900995044 /* simple-class.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "simple-class.js"; sourceTree = ""; }; + 47C48BC21962123900995044 /* simple.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = simple.js; sourceTree = ""; }; + 47C48BC31962123900995044 /* ssl-config.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "ssl-config.js"; sourceTree = ""; }; + 47C48BC41962123900995044 /* SLRemotingTests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "SLRemotingTests-Info.plist"; sourceTree = ""; }; + 47C48BC51962123900995044 /* SLRESTAdapterNonRootTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLRESTAdapterNonRootTests.h; sourceTree = ""; }; + 47C48BC61962123900995044 /* SLRESTAdapterNonRootTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLRESTAdapterNonRootTests.m; sourceTree = ""; }; + 47C48BC71962123900995044 /* SLRESTAdapterSSLTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLRESTAdapterSSLTests.m; sourceTree = ""; }; + 47C48BC81962123900995044 /* SLRESTAdapterTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLRESTAdapterTests.h; sourceTree = ""; }; + 47C48BC91962123900995044 /* SLRESTAdapterTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLRESTAdapterTests.m; sourceTree = ""; }; + 47C48BCA1962123900995044 /* SLRESTContractTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SLRESTContractTests.h; sourceTree = ""; }; + 47C48BCB1962123900995044 /* SLRESTContractTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SLRESTContractTests.m; sourceTree = ""; }; 47F8E811185B7A4E0088BB73 /* LBPushNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LBPushNotification.h; sourceTree = ""; }; 47F8E812185B7A4E0088BB73 /* LBPushNotification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LBPushNotification.m; sourceTree = ""; }; B3D220F717722AE800B7CB63 /* libLoopBack.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libLoopBack.a; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -232,78 +254,104 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 4792A65D18C7D8150077ED45 /* SLRemoting */ = { + 47C48B741962120E00995044 /* SLAFNetworking */ = { + isa = PBXGroup; + children = ( + 47C48B751962120E00995044 /* SLAFHTTPClient.h */, + 47C48B761962120E00995044 /* SLAFHTTPClient.m */, + 47C48B771962120E00995044 /* SLAFHTTPRequestOperation.h */, + 47C48B781962120E00995044 /* SLAFHTTPRequestOperation.m */, + 47C48B791962120E00995044 /* SLAFImageRequestOperation.h */, + 47C48B7A1962120E00995044 /* SLAFImageRequestOperation.m */, + 47C48B7B1962120E00995044 /* SLAFJSONRequestOperation.h */, + 47C48B7C1962120E00995044 /* SLAFJSONRequestOperation.m */, + 47C48B7D1962120E00995044 /* SLAFNetworkActivityIndicatorManager.h */, + 47C48B7E1962120E00995044 /* SLAFNetworkActivityIndicatorManager.m */, + 47C48B7F1962120E00995044 /* SLAFNetworking.h */, + 47C48B801962120E00995044 /* SLAFPropertyListRequestOperation.h */, + 47C48B811962120E00995044 /* SLAFPropertyListRequestOperation.m */, + 47C48B821962120E00995044 /* SLAFURLConnectionOperation.h */, + 47C48B831962120E00995044 /* SLAFURLConnectionOperation.m */, + 47C48B841962120E00995044 /* SLAFXMLRequestOperation.h */, + 47C48B851962120E00995044 /* SLAFXMLRequestOperation.m */, + 47C48B861962120E00995044 /* UIImageView+SLAFNetworking.h */, + 47C48B871962120E00995044 /* UIImageView+SLAFNetworking.m */, + ); + path = SLAFNetworking; + sourceTree = ""; + }; + 47C48B881962120E00995044 /* SLRemoting */ = { isa = PBXGroup; children = ( - 4792A65F18C7D8150077ED45 /* AFNetworking */, - 4792A70418C7D8150077ED45 /* SLRemoting */, - 4792A71118C7D8150077ED45 /* SLRemoting.xcodeproj */, + 47C48B891962120E00995044 /* SLAdapter.h */, + 47C48B8A1962120E00995044 /* SLAdapter.m */, + 47C48B8B1962120E00995044 /* SLObject.h */, + 47C48B8C1962120E00995044 /* SLObject.m */, + 47C48B8D1962120E00995044 /* SLRemoting-Prefix.pch */, + 47C48B8E1962120E00995044 /* SLRemoting.h */, + 47C48B8F1962120E00995044 /* SLRemotingUtils.h */, + 47C48B901962120E00995044 /* SLRemotingUtils.m */, + 47C48B911962120E00995044 /* SLRESTAdapter.h */, + 47C48B921962120E00995044 /* SLRESTAdapter.m */, + 47C48B931962120E00995044 /* SLRESTContract.h */, + 47C48B941962120E00995044 /* SLRESTContract.m */, ); path = SLRemoting; sourceTree = ""; }; - 4792A65F18C7D8150077ED45 /* AFNetworking */ = { + 47C48BB41962123900995044 /* SLRemotingTests */ = { isa = PBXGroup; children = ( - 4792A66018C7D8150077ED45 /* AFHTTPClient.h */, - 4792A66118C7D8150077ED45 /* AFHTTPClient.m */, - 4792A66218C7D8150077ED45 /* AFHTTPRequestOperation.h */, - 4792A66318C7D8150077ED45 /* AFHTTPRequestOperation.m */, - 4792A66418C7D8150077ED45 /* AFImageRequestOperation.h */, - 4792A66518C7D8150077ED45 /* AFImageRequestOperation.m */, - 4792A66618C7D8150077ED45 /* AFJSONRequestOperation.h */, - 4792A66718C7D8150077ED45 /* AFJSONRequestOperation.m */, - 4792A66818C7D8150077ED45 /* AFNetworkActivityIndicatorManager.h */, - 4792A66918C7D8150077ED45 /* AFNetworkActivityIndicatorManager.m */, - 4792A66A18C7D8150077ED45 /* AFNetworking.h */, - 4792A66B18C7D8150077ED45 /* AFPropertyListRequestOperation.h */, - 4792A66C18C7D8150077ED45 /* AFPropertyListRequestOperation.m */, - 4792A66D18C7D8150077ED45 /* AFURLConnectionOperation.h */, - 4792A66E18C7D8150077ED45 /* AFURLConnectionOperation.m */, - 4792A66F18C7D8150077ED45 /* AFXMLRequestOperation.h */, - 4792A67018C7D8150077ED45 /* AFXMLRequestOperation.m */, - 4792A67118C7D8150077ED45 /* UIImageView+AFNetworking.h */, - 4792A67218C7D8150077ED45 /* UIImageView+AFNetworking.m */, - ); - path = AFNetworking; + 47C48BB51962123900995044 /* InfoPlist.strings */, + 47C48BB71962123900995044 /* server */, + 47C48BC41962123900995044 /* SLRemotingTests-Info.plist */, + 47C48BC51962123900995044 /* SLRESTAdapterNonRootTests.h */, + 47C48BC61962123900995044 /* SLRESTAdapterNonRootTests.m */, + 47C48BC71962123900995044 /* SLRESTAdapterSSLTests.m */, + 47C48BC81962123900995044 /* SLRESTAdapterTests.h */, + 47C48BC91962123900995044 /* SLRESTAdapterTests.m */, + 47C48BCA1962123900995044 /* SLRESTContractTests.h */, + 47C48BCB1962123900995044 /* SLRESTContractTests.m */, + ); + path = SLRemotingTests; sourceTree = ""; }; - 4792A70418C7D8150077ED45 /* SLRemoting */ = { + 47C48BB71962123900995044 /* server */ = { isa = PBXGroup; children = ( - 4792A70518C7D8150077ED45 /* SLAdapter.h */, - 4792A70618C7D8150077ED45 /* SLAdapter.m */, - 4792A70718C7D8150077ED45 /* SLObject.h */, - 4792A70818C7D8150077ED45 /* SLObject.m */, - 4792A70918C7D8150077ED45 /* SLRemoting-Prefix.pch */, - 4792A70A18C7D8150077ED45 /* SLRemoting.h */, - 4792A70B18C7D8150077ED45 /* SLRemotingUtils.h */, - 4792A70C18C7D8150077ED45 /* SLRemotingUtils.m */, - 4792A70D18C7D8150077ED45 /* SLRESTAdapter.h */, - 4792A70E18C7D8150077ED45 /* SLRESTAdapter.m */, - 4792A70F18C7D8150077ED45 /* SLRESTContract.h */, - 4792A71018C7D8150077ED45 /* SLRESTContract.m */, - ); - path = SLRemoting; + 47C48BB81962123900995044 /* .gitignore */, + 47C48BB91962123900995044 /* contract-class.js */, + 47C48BBA1962123900995044 /* contract.js */, + 47C48BBB1962123900995044 /* index.js */, + 47C48BBC1962123900995044 /* nonroot.js */, + 47C48BBD1962123900995044 /* package.json */, + 47C48BBE1962123900995044 /* private */, + 47C48BC11962123900995044 /* simple-class.js */, + 47C48BC21962123900995044 /* simple.js */, + 47C48BC31962123900995044 /* ssl-config.js */, + ); + path = server; sourceTree = ""; }; - 4792A71218C7D8150077ED45 /* Products */ = { + 47C48BBE1962123900995044 /* private */ = { isa = PBXGroup; children = ( - 4792A77F18C7D8160077ED45 /* libSLRemoting.a */, - 4792A78118C7D8160077ED45 /* SLRemotingTests.octest */, + 47C48BBF1962123900995044 /* certificate.pem */, + 47C48BC01962123900995044 /* privatekey.pem */, ); - name = Products; + path = private; sourceTree = ""; }; B3D220EE17722AE800B7CB63 = { isa = PBXGroup; children = ( + 47C48BB41962123900995044 /* SLRemotingTests */, + 47C48B741962120E00995044 /* SLAFNetworking */, + 47C48B881962120E00995044 /* SLRemoting */, B3D220FC17722AE800B7CB63 /* LoopBack */, B3D2211117722AE800B7CB63 /* LoopBackTests */, B3D220F917722AE800B7CB63 /* Frameworks */, B3D220F817722AE800B7CB63 /* Products */, - 4792A65D18C7D8150077ED45 /* SLRemoting */, ); sourceTree = ""; }; @@ -399,32 +447,32 @@ buildActionMask = 2147483647; files = ( B3DFA5AD17970AB700F656D7 /* LoopBack.h in Headers */, - 4792A76A18C7D8160077ED45 /* SLRESTContract.h in Headers */, - 4792A72D18C7D8160077ED45 /* AFHTTPClient.h in Headers */, + 47C48BB01962120E00995044 /* SLRESTAdapter.h in Headers */, + 47C48BAC1962120E00995044 /* SLRemoting-Prefix.pch in Headers */, + 47C48BA21962120E00995044 /* SLAFURLConnectionOperation.h in Headers */, B3DFA5AE17970ABD00F656D7 /* LBModel.h in Headers */, - 4792A73718C7D8160077ED45 /* AFNetworking.h in Headers */, - 4792A76218C7D8160077ED45 /* SLObject.h in Headers */, B3DFA5AF17970ABD00F656D7 /* LBRESTAdapter.h in Headers */, - 4792A76518C7D8160077ED45 /* SLRemoting.h in Headers */, + 47C48BA41962120E00995044 /* SLAFXMLRequestOperation.h in Headers */, 0B8022DF18A2F1BA00AF845E /* LBContainer.h in Headers */, - 4792A76018C7D8160077ED45 /* SLAdapter.h in Headers */, - 4792A73E18C7D8160077ED45 /* UIImageView+AFNetworking.h in Headers */, + 47C48BAD1962120E00995044 /* SLRemoting.h in Headers */, 0B786860189B1C0700AB6782 /* LBFile.h in Headers */, 0B6DCCA518806F2E00F7E57A /* LBUser.h in Headers */, - 4792A73318C7D8160077ED45 /* AFJSONRequestOperation.h in Headers */, - 4792A73118C7D8160077ED45 /* AFImageRequestOperation.h in Headers */, + 47C48B9D1962120E00995044 /* SLAFNetworkActivityIndicatorManager.h in Headers */, + 47C48BA81962120E00995044 /* SLAdapter.h in Headers */, 0B4F52AA18908089004F675A /* LBAccessToken.h in Headers */, - 4792A76418C7D8160077ED45 /* SLRemoting-Prefix.pch in Headers */, + 47C48BAA1962120E00995044 /* SLObject.h in Headers */, + 47C48BA61962120E00995044 /* UIImageView+SLAFNetworking.h in Headers */, + 47C48B9B1962120E00995044 /* SLAFJSONRequestOperation.h in Headers */, + 47C48B971962120E00995044 /* SLAFHTTPRequestOperation.h in Headers */, + 47C48BB21962120E00995044 /* SLRESTContract.h in Headers */, 47AD031418491E2000F724C8 /* LBInstallation.h in Headers */, 47F8E813185B7A4E0088BB73 /* LBPushNotification.h in Headers */, B3DFA5B017970AC700F656D7 /* LoopBack-Prefix.pch in Headers */, - 4792A73818C7D8160077ED45 /* AFPropertyListRequestOperation.h in Headers */, - 4792A73A18C7D8160077ED45 /* AFURLConnectionOperation.h in Headers */, - 4792A76618C7D8160077ED45 /* SLRemotingUtils.h in Headers */, - 4792A73C18C7D8160077ED45 /* AFXMLRequestOperation.h in Headers */, - 4792A72F18C7D8160077ED45 /* AFHTTPRequestOperation.h in Headers */, - 4792A73518C7D8160077ED45 /* AFNetworkActivityIndicatorManager.h in Headers */, - 4792A76818C7D8160077ED45 /* SLRESTAdapter.h in Headers */, + 47C48B991962120E00995044 /* SLAFImageRequestOperation.h in Headers */, + 47C48B9F1962120E00995044 /* SLAFNetworking.h in Headers */, + 47C48B951962120E00995044 /* SLAFHTTPClient.h in Headers */, + 47C48BAE1962120E00995044 /* SLRemotingUtils.h in Headers */, + 47C48BA01962120E00995044 /* SLAFPropertyListRequestOperation.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -487,12 +535,6 @@ mainGroup = B3D220EE17722AE800B7CB63; productRefGroup = B3D220F817722AE800B7CB63 /* Products */; projectDirPath = ""; - projectReferences = ( - { - ProductGroup = 4792A71218C7D8150077ED45 /* Products */; - ProjectRef = 4792A71118C7D8150077ED45 /* SLRemoting.xcodeproj */; - }, - ); projectRoot = ""; targets = ( B3D220F617722AE800B7CB63 /* LoopBack */, @@ -503,30 +545,19 @@ }; /* End PBXProject section */ -/* Begin PBXReferenceProxy section */ - 4792A77F18C7D8160077ED45 /* libSLRemoting.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libSLRemoting.a; - remoteRef = 4792A77E18C7D8160077ED45 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 4792A78118C7D8160077ED45 /* SLRemotingTests.octest */ = { - isa = PBXReferenceProxy; - fileType = wrapper.cfbundle; - path = SLRemotingTests.octest; - remoteRef = 4792A78018C7D8160077ED45 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXReferenceProxy section */ - /* Begin PBXResourcesBuildPhase section */ B3D2210517722AE800B7CB63 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 47C48BCD1962123900995044 /* .gitignore in Resources */, 0B3A200E18A55B5A006772C8 /* LBContainerTests.h in Resources */, + 47C48BCC1962123900995044 /* InfoPlist.strings in Resources */, B3D2211617722AE800B7CB63 /* InfoPlist.strings in Resources */, + 47C48BD81962123900995044 /* SLRemotingTests-Info.plist in Resources */, + 47C48BD31962123900995044 /* certificate.pem in Resources */, + 47C48BD21962123900995044 /* package.json in Resources */, + 47C48BD41962123900995044 /* privatekey.pem in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -593,25 +624,25 @@ buildActionMask = 2147483647; files = ( B3D2212417722B1700B7CB63 /* LBModel.m in Sources */, - 4792A73F18C7D8160077ED45 /* UIImageView+AFNetworking.m in Sources */, + 47C48B9C1962120E00995044 /* SLAFJSONRequestOperation.m in Sources */, B3D2214A1773766800B7CB63 /* LBRESTAdapter.m in Sources */, - 4792A73418C7D8160077ED45 /* AFJSONRequestOperation.m in Sources */, - 4792A76B18C7D8160077ED45 /* SLRESTContract.m in Sources */, - 4792A73018C7D8160077ED45 /* AFHTTPRequestOperation.m in Sources */, - 4792A76718C7D8160077ED45 /* SLRemotingUtils.m in Sources */, - 4792A73D18C7D8160077ED45 /* AFXMLRequestOperation.m in Sources */, - 4792A73B18C7D8160077ED45 /* AFURLConnectionOperation.m in Sources */, - 4792A73218C7D8160077ED45 /* AFImageRequestOperation.m in Sources */, - 4792A72E18C7D8160077ED45 /* AFHTTPClient.m in Sources */, + 47C48BA91962120E00995044 /* SLAdapter.m in Sources */, + 47C48B961962120E00995044 /* SLAFHTTPClient.m in Sources */, + 47C48BA51962120E00995044 /* SLAFXMLRequestOperation.m in Sources */, 47F8E814185B7A4E0088BB73 /* LBPushNotification.m in Sources */, - 4792A76118C7D8160077ED45 /* SLAdapter.m in Sources */, + 47C48B9E1962120E00995044 /* SLAFNetworkActivityIndicatorManager.m in Sources */, + 47C48BAF1962120E00995044 /* SLRemotingUtils.m in Sources */, 47AD031318491DA700F724C8 /* LBInstallation.m in Sources */, - 4792A73918C7D8160077ED45 /* AFPropertyListRequestOperation.m in Sources */, - 4792A76918C7D8160077ED45 /* SLRESTAdapter.m in Sources */, + 47C48BB31962120E00995044 /* SLRESTContract.m in Sources */, + 47C48BA71962120E00995044 /* UIImageView+SLAFNetworking.m in Sources */, + 47C48B9A1962120E00995044 /* SLAFImageRequestOperation.m in Sources */, + 47C48B981962120E00995044 /* SLAFHTTPRequestOperation.m in Sources */, + 47C48BA11962120E00995044 /* SLAFPropertyListRequestOperation.m in Sources */, + 47C48BB11962120E00995044 /* SLRESTAdapter.m in Sources */, 0B6DCCA618806F2E00F7E57A /* LBUser.m in Sources */, - 4792A76318C7D8160077ED45 /* SLObject.m in Sources */, - 4792A73618C7D8160077ED45 /* AFNetworkActivityIndicatorManager.m in Sources */, + 47C48BAB1962120E00995044 /* SLObject.m in Sources */, 0B8022E518A2F27600AF845E /* LBContainer.m in Sources */, + 47C48BA31962120E00995044 /* SLAFURLConnectionOperation.m in Sources */, 0B786866189B1C3300AB6782 /* LBFile.m in Sources */, 0B4F52AB18908089004F675A /* LBAccessToken.m in Sources */, ); @@ -621,12 +652,23 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 47C48BDB1962123900995044 /* SLRESTAdapterTests.m in Sources */, + 47C48BD01962123900995044 /* index.js in Sources */, B3D2213B17722BAB00B7CB63 /* LBModelTests.m in Sources */, + 47C48BDC1962123900995044 /* SLRESTContractTests.m in Sources */, 0B3A201618A56BA5006772C8 /* LBContainerTests.m in Sources */, 0B3A201818A57CCD006772C8 /* LBUserTests.m in Sources */, + 47C48BDA1962123900995044 /* SLRESTAdapterSSLTests.m in Sources */, + 47C48BD91962123900995044 /* SLRESTAdapterNonRootTests.m in Sources */, B3D2214217725A7F00B7CB63 /* LBModelSubclassingTests.m in Sources */, + 47C48BCF1962123900995044 /* contract.js in Sources */, + 47C48BD11962123900995044 /* nonroot.js in Sources */, 4769FF09184D6F4F00E5152C /* LBInstallationTests.m in Sources */, 0B3A201B18A5856F006772C8 /* LBFileTests.m in Sources */, + 47C48BD51962123900995044 /* simple-class.js in Sources */, + 47C48BD61962123900995044 /* simple.js in Sources */, + 47C48BD71962123900995044 /* ssl-config.js in Sources */, + 47C48BCE1962123900995044 /* contract-class.js in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -646,6 +688,14 @@ /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ + 47C48BB51962123900995044 /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 47C48BB61962123900995044 /* en */, + ); + name = InfoPlist.strings; + sourceTree = ""; + }; B3D2211417722AE800B7CB63 /* InfoPlist.strings */ = { isa = PBXVariantGroup; children = ( diff --git a/LoopBack.xcworkspace/contents.xcworkspacedata b/LoopBack.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..2a7bb72 --- /dev/null +++ b/LoopBack.xcworkspace/contents.xcworkspacedata @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Podfile b/Podfile new file mode 100644 index 0000000..b384929 --- /dev/null +++ b/Podfile @@ -0,0 +1,2 @@ +platform :ios, '6.1' +workspace 'LoopBack' diff --git a/SLAFNetworking/SLAFHTTPClient.h b/SLAFNetworking/SLAFHTTPClient.h new file mode 100755 index 0000000..81bd5ac --- /dev/null +++ b/SLAFNetworking/SLAFHTTPClient.h @@ -0,0 +1,643 @@ +// AFHTTPClient.h +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "SLAFURLConnectionOperation.h" + +#import + +/** + `AFHTTPClient` captures the common patterns of communicating with an web application over HTTP. It encapsulates information like base URL, authorization credentials, and HTTP headers, and uses them to construct and manage the execution of HTTP request operations. + + ## Automatic Content Parsing + + Instances of `AFHTTPClient` may specify which types of requests it expects and should handle by registering HTTP operation classes for automatic parsing. Registered classes will determine whether they can handle a particular request, and then construct a request operation accordingly in `enqueueHTTPRequestOperationWithRequest:success:failure`. + + ## Subclassing Notes + + In most cases, one should create an `AFHTTPClient` subclass for each website or web application that your application communicates with. It is often useful, also, to define a class method that returns a singleton shared HTTP client in each subclass, that persists authentication credentials and other configuration across the entire application. + + ## Methods to Override + + To change the behavior of all url request construction for an `AFHTTPClient` subclass, override `requestWithMethod:path:parameters`. + + To change the behavior of all request operation construction for an `AFHTTPClient` subclass, override `HTTPRequestOperationWithRequest:success:failure`. + + ## Default Headers + + By default, `AFHTTPClient` sets the following HTTP headers: + + - `Accept-Language: (comma-delimited preferred languages), en-us;q=0.8` + - `User-Agent: (generated user agent)` + + You can override these HTTP headers or define new ones using `setDefaultHeader:value:`. + + ## URL Construction Using Relative Paths + + Both `-requestWithMethod:path:parameters:` and `-multipartFormRequestWithMethod:path:parameters:constructingBodyWithBlock:` construct URLs from the path relative to the `-baseURL`, using `NSURL +URLWithString:relativeToURL:`. 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, which would otherwise cause unexpected behavior when constructing URLs using paths without a leading slash. + + ## NSCoding / NSCopying Conformance + + `AFHTTPClient` conforms to the `NSCoding` 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. + - NSCoding cannot serialize / deserialize block properties, so an archive of an HTTP client will not include any reachability callback block that may be set. + */ + +#ifdef _SYSTEMCONFIGURATION_H +typedef enum { + AFNetworkReachabilityStatusUnknown = -1, + AFNetworkReachabilityStatusNotReachable = 0, + AFNetworkReachabilityStatusReachableViaWWAN = 1, + AFNetworkReachabilityStatusReachableViaWiFi = 2, +} AFNetworkReachabilityStatus; +#else +#pragma message("SystemConfiguration framework not found in project, or not included in precompiled header. Network reachability functionality will not be available.") +#endif + +#ifndef __UTTYPE__ +#if __IPHONE_OS_VERSION_MIN_REQUIRED +#pragma message("MobileCoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available.") +#else +#pragma message("CoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available.") +#endif +#endif + +typedef enum { + AFFormURLParameterEncoding, + AFJSONParameterEncoding, + AFPropertyListParameterEncoding, +} AFHTTPClientParameterEncoding; + +@class SLAFHTTPRequestOperation; +@protocol AFMultipartFormData; + +@interface SLAFHTTPClient : NSObject + +///--------------------------------------- +/// @name Accessing HTTP Client Properties +///--------------------------------------- + +/** + The url used as the base for paths specified in methods such as `getPath:parameters:success:failure` + */ +@property (readonly, nonatomic, strong) NSURL *baseURL; + +/** + The string encoding used in constructing url requests. This is `NSUTF8StringEncoding` by default. + */ +@property (nonatomic, assign) NSStringEncoding stringEncoding; + +/** + The `AFHTTPClientParameterEncoding` value corresponding to how parameters are encoded into a request body. This is `AFFormURLParameterEncoding` by default. + + @warning Some nested parameter structures, such as a keyed array of hashes containing inconsistent keys (i.e. `@{@"": @[@{@"a" : @(1)}, @{@"b" : @(2)}]}`), cannot be unambiguously represented in query strings. It is strongly recommended that an unambiguous encoding, such as `AFJSONParameterEncoding`, is used when posting complicated or nondeterministic parameter structures. + */ +@property (nonatomic, assign) AFHTTPClientParameterEncoding parameterEncoding; + +/** + The operation queue which manages operations enqueued by the HTTP client. + */ +@property (readonly, nonatomic, strong) NSOperationQueue *operationQueue; + +/** + The reachability status from the device to the current `baseURL` of the `AFHTTPClient`. + + @warning This property requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). + */ +#ifdef _SYSTEMCONFIGURATION_H +@property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; +#endif + +/** + Default SSL pinning mode for each `AFHTTPRequestOperation` created by `HTTPRequestOperationWithRequest:success:failure:`. + */ +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ +@property (nonatomic, assign) AFURLConnectionOperationSSLPinningMode defaultSSLPinningMode; +#endif + +/** + Whether each `AFHTTPRequestOperation` created by `HTTPRequestOperationWithRequest:success:failure:` should accept an invalid SSL certificate. + + If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to `YES` for backwards compatibility. Otherwise, this property defaults to `NO`. + */ +@property (nonatomic, assign) BOOL allowsInvalidSSLCertificate; + +///--------------------------------------------- +/// @name Creating and Initializing HTTP Clients +///--------------------------------------------- + +/** + Creates and initializes an `AFHTTPClient` object with the specified base URL. + + @param url The base URL for the HTTP client. This argument must not be `nil`. + + @return The newly-initialized HTTP client + */ ++ (instancetype)clientWithBaseURL:(NSURL *)url; + +/** + Initializes an `AFHTTPClient` object with the specified base URL. + + This is the designated initializer. + + @param url The base URL for the HTTP client. This argument must not be `nil`. + + @return The newly-initialized HTTP client + */ +- (id)initWithBaseURL:(NSURL *)url; + +///----------------------------------- +/// @name Managing Reachability Status +///----------------------------------- + +/** + 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`. + + @warning This method requires the `SystemConfiguration` framework. Add it in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). + */ +#ifdef _SYSTEMCONFIGURATION_H +- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block; +#endif + +///------------------------------- +/// @name Managing HTTP Operations +///------------------------------- + +/** + Attempts to register a subclass of `AFHTTPRequestOperation`, adding it to a chain to automatically generate request operations from a URL request. + + When `enqueueHTTPRequestOperationWithRequest:success:failure` is invoked, each registered class is consulted in turn to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to create an operation using `initWithURLRequest:` and do `setCompletionBlockWithSuccess:failure:`. There is no guarantee that all registered classes will be consulted. Classes are consulted in the reverse order of their registration. Attempting to register an already-registered class will move it to the top of the list. + + @param operationClass The subclass of `AFHTTPRequestOperation` to register + + @return `YES` if the registration is successful, `NO` otherwise. The only failure condition is if `operationClass` is not a subclass of `AFHTTPRequestOperation`. + */ +- (BOOL)registerHTTPOperationClass:(Class)operationClass; + +/** + Unregisters the specified subclass of `AFHTTPRequestOperation` from the chain of classes consulted when `-requestWithMethod:path:parameters` is called. + + @param operationClass The subclass of `AFHTTPRequestOperation` to register + */ +- (void)unregisterHTTPOperationClass:(Class)operationClass; + +///---------------------------------- +/// @name Managing HTTP Header Values +///---------------------------------- + +/** + Returns the value for the HTTP headers set in request objects created by the HTTP client. + + @param header The HTTP header to return the default value for + + @return The default value for the HTTP header, or `nil` if unspecified + */ +- (NSString *)defaultValueForHeader:(NSString *)header; + +/** + 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 header The HTTP header to set a default value for + @param value The value set as default for the specified header, or `nil + */ +- (void)setDefaultHeader:(NSString *)header + value:(NSString *)value; + +/** + 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)setAuthorizationHeaderWithUsername:(NSString *)username + password:(NSString *)password; + +/** + Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a token-based authentication value, such as an OAuth access token. This overwrites any existing value for this header. + + @param token The authentication token + */ +- (void)setAuthorizationHeaderWithToken:(NSString *)token; + + +/** + Clears any existing value for the "Authorization" HTTP header. + */ +- (void)clearAuthorizationHeader; + +///------------------------------- +/// @name Managing URL Credentials +///------------------------------- + +/** + Set the default URL credential to be set for request operations. + + @param credential The URL credential + */ +- (void)setDefaultCredential:(NSURLCredential *)credential; + +///------------------------------- +/// @name Creating Request Objects +///------------------------------- + +/** + Creates an `NSMutableURLRequest` object with the specified HTTP method and path. + + 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 path The path to be appended to the HTTP client's base URL and used as the request URL. If `nil`, no path will be appended to the base URL. + @param parameters The parameters to be either set as a query string for `GET` requests, or the request HTTP body. + + @return An `NSMutableURLRequest` object + */ +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + path:(NSString *)path + parameters:(NSDictionary *)parameters; + +/** + Creates an `NSMutableURLRequest` object with the specified HTTP method and path, 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 path The path to be appended to the HTTP client's base URL and used as 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. This can be used to upload files, encode HTTP body as JSON or XML, or specify multiple values for the same parameter, as one might for array values. + + @return An `NSMutableURLRequest` object + */ +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + path:(NSString *)path + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block; + +///------------------------------- +/// @name Creating HTTP Operations +///------------------------------- + +/** + Creates an `AFHTTPRequestOperation`. + + In order to determine what kind of operation is created, each registered subclass conforming to the `AFHTTPClient` protocol is consulted (in reverse order of when they were specified) to see if it can handle the specific request. The first class to return `YES` when sent a `canProcessRequest:` message is used to generate an operation using `HTTPRequestOperationWithRequest:success:failure:`. + + @param urlRequest 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. + */ +- (SLAFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure; + +///---------------------------------------- +/// @name Managing Enqueued HTTP Operations +///---------------------------------------- + +/** + Enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue. + + @param operation The HTTP request operation to be enqueued. + */ +- (void)enqueueHTTPRequestOperation:(SLAFHTTPRequestOperation *)operation; + +/** + Cancels all operations in the HTTP client's operation queue whose URLs match the specified HTTP method and path. + + This method only cancels `AFHTTPRequestOperations` whose request URL matches the HTTP client base URL with the path appended. For complete control over the lifecycle of enqueued operations, you can access the `operationQueue` property directly, which allows you to, for instance, cancel operations filtered by a predicate, or simply use `-cancelAllRequests`. Note that the operation queue may include non-HTTP operations, so be sure to check the type before attempting to directly introspect an operation's `request` property. + + @param method The HTTP method to match for the cancelled requests, such as `GET`, `POST`, `PUT`, or `DELETE`. If `nil`, all request operations with URLs matching the path will be cancelled. + @param path The path appended to the HTTP client base URL to match against the cancelled requests. If `nil`, no path will be appended to the base URL. + */ +- (void)cancelAllHTTPOperationsWithMethod:(NSString *)method path:(NSString *)path; + +///--------------------------------------- +/// @name Batching HTTP Request Operations +///--------------------------------------- + +/** + Creates and enqueues an `AFHTTPRequestOperation` to the HTTP client's operation queue for each specified request object into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes. + + Operations are created by passing the specified `NSURLRequest` objects in `requests`, using `-HTTPRequestOperationWithRequest:success:failure:`, with `nil` for both the `success` and `failure` parameters. + + @param urlRequests The `NSURLRequest` objects used to create and enqueue operations. + @param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations. + @param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations. + */ +- (void)enqueueBatchOfHTTPRequestOperationsWithRequests:(NSArray *)urlRequests + progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock + completionBlock:(void (^)(NSArray *operations))completionBlock; + +/** + Enqueues the specified request operations into a batch. When each request operation finishes, the specified progress block is executed, until all of the request operations have finished, at which point the completion block also executes. + + @param operations The request operations used to be batched and enqueued. + @param progressBlock A block object to be executed upon the completion of each request operation in the batch. This block has no return value and takes two arguments: the number of operations that have already finished execution, and the total number of operations. + @param completionBlock A block object to be executed upon the completion of all of the request operations in the batch. This block has no return value and takes a single argument: the batched request operations. + */ +- (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations + progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock + completionBlock:(void (^)(NSArray *operations))completionBlock; + +///--------------------------- +/// @name Making HTTP Requests +///--------------------------- + +/** + Creates an `AFHTTPRequestOperation` with a `GET` request, and enqueues it to the HTTP client's operation queue. + + @param path The path to be appended to the HTTP client's base URL and used as the request URL. + @param parameters The parameters to be encoded and appended as the query string for the request URL. + @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. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (void)getPath:(NSString *)path + parameters:(NSDictionary *)parameters + success:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates an `AFHTTPRequestOperation` with a `POST` request, and enqueues it to the HTTP client's operation queue. + + @param path The path to be appended to the HTTP client's base URL and used as the request URL. + @param parameters The parameters to be encoded and set in the request HTTP body. + @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. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (void)postPath:(NSString *)path + parameters:(NSDictionary *)parameters + success:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates an `AFHTTPRequestOperation` with a `PUT` request, and enqueues it to the HTTP client's operation queue. + + @param path The path to be appended to the HTTP client's base URL and used as the request URL. + @param parameters The parameters to be encoded and set in the request HTTP body. + @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. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (void)putPath:(NSString *)path + parameters:(NSDictionary *)parameters + success:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates an `AFHTTPRequestOperation` with a `DELETE` request, and enqueues it to the HTTP client's operation queue. + + @param path The path to be appended to the HTTP client's base URL and used as the request URL. + @param parameters The parameters to be encoded and appended as the query string for the request URL. + @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. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (void)deletePath:(NSString *)path + parameters:(NSDictionary *)parameters + success:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure; + +/** + Creates an `AFHTTPRequestOperation` with a `PATCH` request, and enqueues it to the HTTP client's operation queue. + + @param path The path to be appended to the HTTP client's base URL and used as the request URL. + @param parameters The parameters to be encoded and set in the request HTTP body. + @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. + + @see -HTTPRequestOperationWithRequest:success:failure: + */ +- (void)patchPath:(NSString *)path + parameters:(NSDictionary *)parameters + success:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure; +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## Network Reachability + + The following constants are provided by `AFHTTPClient` 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. + + ## Parameter Encoding + + The following constants are provided by `AFHTTPClient` as possible methods for serializing parameters into query string or message body values. + + enum { + AFFormURLParameterEncoding, + AFJSONParameterEncoding, + AFPropertyListParameterEncoding, + } + + `AFFormURLParameterEncoding` + Parameters are encoded into field/key pairs in the URL query string for `GET` `HEAD` and `DELETE` requests, and in the message body otherwise. Dictionary keys are sorted with the `caseInsensitiveCompare:` selector of their description, in order to mitigate the possibility of ambiguous query strings being generated non-deterministically. See the warning for the `parameterEncoding` property for additional information. + + `AFJSONParameterEncoding` + Parameters are encoded into JSON in the message body. + + `AFPropertyListParameterEncoding` + Parameters are encoded into a property list in the message body. + */ + +///---------------- +/// @name Functions +///---------------- + +/** + Returns a query string constructed by a set of parameters, using the specified encoding. + + Query strings are constructed by collecting each key-value pair, percent escaping a string representation of the key-value pair, and then joining the pairs with "&". + + If a query string pair has a an `NSArray` for its value, each member of the array will be represented in the format `field[]=value1&field[]value2`. Otherwise, the pair will be formatted as "field=value". String representations of both keys and values are derived using the `-description` method. The constructed query string does not include the ? character used to delimit the query component. + + @param parameters The parameters used to construct the query string + @param encoding The encoding to use in constructing the query string. If you are uncertain of the correct encoding, you should use UTF-8 (`NSUTF8StringEncoding`), which is the encoding designated by RFC 3986 as the correct encoding for use in URLs. + + @return A percent-escaped query string + */ +extern NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding encoding); + +///-------------------- +/// @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`). + */ +#ifdef _SYSTEMCONFIGURATION_H +extern NSString * const AFNetworkingReachabilityDidChangeNotification; +extern NSString * const AFNetworkingReachabilityNotificationStatusItem; +#endif + +#pragma mark - + +extern NSUInteger const kSLAFUploadStream3GSuggestedPacketSize; +extern NSTimeInterval const kSLAFUploadStream3GSuggestedDelay; + +/** + The `AFMultipartFormData` protocol defines the methods supported by the parameter in the block argument of `AFHTTPClient -multipartFormRequestWithMethod:path: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:(unsigned long long)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, as of iOS 6, there is no definite way to distinguish between a 3G, EDGE, or LTE connection. 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 32kb. + @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 diff --git a/SLAFNetworking/SLAFHTTPClient.m b/SLAFNetworking/SLAFHTTPClient.m new file mode 100755 index 0000000..2b2d58b --- /dev/null +++ b/SLAFNetworking/SLAFHTTPClient.m @@ -0,0 +1,1372 @@ +// AFHTTPClient.m +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "SLAFHTTPClient.h" +#import "SLAFHTTPRequestOperation.h" + +#import + +#ifdef _SYSTEMCONFIGURATION_H +#import +#import +#import +#import +#import +#endif + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import +#endif + +#ifdef _SYSTEMCONFIGURATION_H +NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change"; +NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem"; + +typedef SCNetworkReachabilityRef AFNetworkReachabilityRef; +typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status); +#else +typedef id AFNetworkReachabilityRef; +#endif + +typedef void (^AFCompletionBlock)(void); + +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 * AFPercentEscapedQueryStringPairMemberFromStringWithEncoding(NSString *string, NSStringEncoding encoding) { + static NSString * const kAFCharactersToBeEscaped = @":/?&=;+!@#$()',*"; + static NSString * const kAFCharactersToLeaveUnescaped = @"[]."; + + return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef)string, (__bridge CFStringRef)kAFCharactersToLeaveUnescaped, (__bridge CFStringRef)kAFCharactersToBeEscaped, CFStringConvertNSStringEncodingToEncoding(encoding)); +} + +#pragma mark - + +@interface SLAFQueryStringPair : 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 SLAFQueryStringPair +@synthesize field = _field; +@synthesize value = _value; + +- (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 AFPercentEscapedQueryStringPairMemberFromStringWithEncoding([self.field description], stringEncoding); + } else { + return [NSString stringWithFormat:@"%@=%@", AFPercentEscapedQueryStringPairMemberFromStringWithEncoding([self.field description], stringEncoding), AFPercentEscapedQueryStringPairMemberFromStringWithEncoding([self.value description], stringEncoding)]; + } +} + +@end + +#pragma mark - + +extern NSArray * SLAFQueryStringPairsFromDictionary(NSDictionary *dictionary); +extern NSArray * SLAFQueryStringPairsFromKeyAndValue(NSString *key, id value); + +NSString * AFQueryStringFromParametersWithEncoding(NSDictionary *parameters, NSStringEncoding stringEncoding) { + NSMutableArray *mutablePairs = [NSMutableArray array]; + for (SLAFQueryStringPair *pair in SLAFQueryStringPairsFromDictionary(parameters)) { + [mutablePairs addObject:[pair URLEncodedStringValueWithEncoding:stringEncoding]]; + } + + return [mutablePairs componentsJoinedByString:@"&"]; +} + +NSArray * SLAFQueryStringPairsFromDictionary(NSDictionary *dictionary) { + return SLAFQueryStringPairsFromKeyAndValue(nil, dictionary); +} + +NSArray * SLAFQueryStringPairsFromKeyAndValue(NSString *key, id value) { + NSMutableArray *mutableQueryStringComponents = [NSMutableArray array]; + + 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 + NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"description" ascending:YES selector:@selector(caseInsensitiveCompare:)]; + for (id nestedKey in [dictionary.allKeys sortedArrayUsingDescriptors:@[ sortDescriptor ]]) { + id nestedValue = [dictionary objectForKey:nestedKey]; + if (nestedValue) { + [mutableQueryStringComponents addObjectsFromArray:SLAFQueryStringPairsFromKeyAndValue((key ? [NSString stringWithFormat:@"%@[%@]", key, nestedKey] : nestedKey), nestedValue)]; + } + } + } else if ([value isKindOfClass:[NSArray class]]) { + NSArray *array = value; + for (id nestedValue in array) { + [mutableQueryStringComponents addObjectsFromArray:SLAFQueryStringPairsFromKeyAndValue([NSString stringWithFormat:@"%@[]", key], nestedValue)]; + } + } else if ([value isKindOfClass:[NSSet class]]) { + NSSet *set = value; + for (id obj in set) { + [mutableQueryStringComponents addObjectsFromArray:SLAFQueryStringPairsFromKeyAndValue(key, obj)]; + } + } else { + [mutableQueryStringComponents addObject:[[SLAFQueryStringPair alloc] initWithField:key value:value]]; + } + + return mutableQueryStringComponents; +} + +@interface SLAFStreamingMultipartFormData : NSObject +- (id)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding; + +- (NSMutableURLRequest *)requestByFinalizingMultipartFormData; +@end + +#pragma mark - + +@interface SLAFHTTPClient () +@property (readwrite, nonatomic, strong) NSURL *baseURL; +@property (readwrite, nonatomic, strong) NSMutableArray *registeredHTTPOperationClassNames; +@property (readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders; +@property (readwrite, nonatomic, strong) NSURLCredential *defaultCredential; +@property (readwrite, nonatomic, strong) NSOperationQueue *operationQueue; +#ifdef _SYSTEMCONFIGURATION_H +@property (readwrite, nonatomic, assign) AFNetworkReachabilityRef networkReachability; +@property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; +@property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock; +#endif + +#ifdef _SYSTEMCONFIGURATION_H +- (void)startMonitoringNetworkReachability; +- (void)stopMonitoringNetworkReachability; +#endif +@end + +@implementation SLAFHTTPClient +@synthesize baseURL = _baseURL; +@synthesize stringEncoding = _stringEncoding; +@synthesize parameterEncoding = _parameterEncoding; +@synthesize registeredHTTPOperationClassNames = _registeredHTTPOperationClassNames; +@synthesize defaultHeaders = _defaultHeaders; +@synthesize defaultCredential = _defaultCredential; +@synthesize operationQueue = _operationQueue; +#ifdef _SYSTEMCONFIGURATION_H +@synthesize networkReachability = _networkReachability; +@synthesize networkReachabilityStatus = _networkReachabilityStatus; +@synthesize networkReachabilityStatusBlock = _networkReachabilityStatusBlock; +#endif +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ +@synthesize defaultSSLPinningMode = _defaultSSLPinningMode; +#endif +@synthesize allowsInvalidSSLCertificate = _allowsInvalidSSLCertificate; + ++ (instancetype)clientWithBaseURL:(NSURL *)url { + return [[self alloc] initWithBaseURL:url]; +} + +- (id)init { + @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:[NSString stringWithFormat:@"%@ Failed to call designated initializer. Invoke `initWithBaseURL:` instead.", NSStringFromClass([self class])] userInfo:nil]; +} + +- (id)initWithBaseURL:(NSURL *)url { + NSParameterAssert(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.stringEncoding = NSUTF8StringEncoding; + self.parameterEncoding = AFFormURLParameterEncoding; + + self.registeredHTTPOperationClassNames = [NSMutableArray array]; + + self.defaultHeaders = [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 setDefaultHeader:@"Accept-Language" value:[acceptLanguagesComponents componentsJoinedByString:@", "]]; + +#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 + [self setDefaultHeader:@"User-Agent" value:[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] respondsToSelector:@selector(scale)] ? [[UIScreen mainScreen] scale] : 1.0f)]]; +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + [self setDefaultHeader:@"User-Agent" value:[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 + +#ifdef _SYSTEMCONFIGURATION_H + self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; + [self startMonitoringNetworkReachability]; +#endif + + self.operationQueue = [[NSOperationQueue alloc] init]; + [self.operationQueue setMaxConcurrentOperationCount:NSOperationQueueDefaultMaxConcurrentOperationCount]; + + // #ifdef included for backwards-compatibility +#ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ + self.allowsInvalidSSLCertificate = YES; +#endif + + return self; +} + +- (void)dealloc { +#ifdef _SYSTEMCONFIGURATION_H + [self stopMonitoringNetworkReachability]; +#endif +} + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@: %p, baseURL: %@, defaultHeaders: %@, registeredOperationClasses: %@, operationQueue: %@>", NSStringFromClass([self class]), self, [self.baseURL absoluteString], self.defaultHeaders, self.registeredHTTPOperationClassNames, self.operationQueue]; +} + +#pragma mark - + +#ifdef _SYSTEMCONFIGURATION_H +static BOOL AFURLHostIsIPAddress(NSURL *url) { + struct sockaddr_in sa_in; + struct sockaddr_in6 sa_in6; + + return [url host] && (inet_pton(AF_INET, [[url host] UTF8String], &sa_in) == 1 || inet_pton(AF_INET6, [[url host] UTF8String], &sa_in6) == 1); +} + +static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) { + BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); + BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); + BOOL isNetworkReachable = (isReachable && !needsConnection); + + 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:[NSDictionary dictionaryWithObject:[NSNumber numberWithInteger:status] forKey:AFNetworkingReachabilityNotificationStatusItem]]; + }); +} + +static const void * AFNetworkReachabilityRetainCallback(const void *info) { + return Block_copy(info); +} + +static void AFNetworkReachabilityReleaseCallback(const void *info) { + if (info) { + Block_release(info); + } +} + +- (void)startMonitoringNetworkReachability { + [self stopMonitoringNetworkReachability]; + + if (!self.baseURL) { + return; + } + + self.networkReachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [[self.baseURL host] UTF8String]); + + if (!self.networkReachability) { + return; + } + + __weak __typeof(&*self)weakSelf = self; + AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) { + __strong __typeof(&*weakSelf)strongSelf = weakSelf; + if (!strongSelf) { + return; + } + + strongSelf.networkReachabilityStatus = status; + if (strongSelf.networkReachabilityStatusBlock) { + strongSelf.networkReachabilityStatusBlock(status); + } + }; + + SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; + SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context); + + /* Network reachability monitoring does not establish a baseline for IP addresses as it does for hostnames, so if the base URL host is an IP address, the initial reachability callback is manually triggered. + */ + if (AFURLHostIsIPAddress(self.baseURL)) { + SCNetworkReachabilityFlags flags; + SCNetworkReachabilityGetFlags(self.networkReachability, &flags); + dispatch_async(dispatch_get_main_queue(), ^{ + AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); + callback(status); + }); + } + + SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); +} + +- (void)stopMonitoringNetworkReachability { + if (self.networkReachability) { + SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); + + CFRelease(_networkReachability); + _networkReachability = NULL; + } +} + +- (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block { + self.networkReachabilityStatusBlock = block; +} +#endif + +#pragma mark - + +- (BOOL)registerHTTPOperationClass:(Class)operationClass { + if (![operationClass isSubclassOfClass:[SLAFHTTPRequestOperation class]]) { + return NO; + } + + NSString *className = NSStringFromClass(operationClass); + [self.registeredHTTPOperationClassNames removeObject:className]; + [self.registeredHTTPOperationClassNames insertObject:className atIndex:0]; + + return YES; +} + +- (void)unregisterHTTPOperationClass:(Class)operationClass { + NSString *className = NSStringFromClass(operationClass); + [self.registeredHTTPOperationClassNames removeObject:className]; +} + +#pragma mark - + +- (NSString *)defaultValueForHeader:(NSString *)header { + return [self.defaultHeaders valueForKey:header]; +} + +- (void)setDefaultHeader:(NSString *)header value:(NSString *)value { + [self.defaultHeaders setValue:value forKey:header]; +} + +- (void)setAuthorizationHeaderWithUsername:(NSString *)username password:(NSString *)password { + NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", username, password]; + [self setDefaultHeader:@"Authorization" value:[NSString stringWithFormat:@"Basic %@", AFBase64EncodedStringFromString(basicAuthCredentials)]]; +} + +- (void)setAuthorizationHeaderWithToken:(NSString *)token { + [self setDefaultHeader:@"Authorization" value:[NSString stringWithFormat:@"Token token=\"%@\"", token]]; +} + +- (void)clearAuthorizationHeader { + [self.defaultHeaders removeObjectForKey:@"Authorization"]; +} + +#pragma mark - + +- (NSMutableURLRequest *)requestWithMethod:(NSString *)method + path:(NSString *)path + parameters:(NSDictionary *)parameters +{ + NSParameterAssert(method); + + if (!path) { + path = @""; + } + + NSURL *url = [NSURL URLWithString:path relativeToURL:self.baseURL]; + NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; + [request setHTTPMethod:method]; + [request setAllHTTPHeaderFields:self.defaultHeaders]; + + if (parameters) { + if ([method isEqualToString:@"GET"] || [method isEqualToString:@"HEAD"] || [method isEqualToString:@"DELETE"]) { + url = [NSURL URLWithString:[[url absoluteString] stringByAppendingFormat:[path rangeOfString:@"?"].location == NSNotFound ? @"?%@" : @"&%@", AFQueryStringFromParametersWithEncoding(parameters, self.stringEncoding)]]; + [request setURL:url]; + } else { + NSString *charset = (__bridge NSString *)CFStringConvertEncodingToIANACharSetName(CFStringConvertNSStringEncodingToEncoding(self.stringEncoding)); + NSError *error = nil; + + switch (self.parameterEncoding) { + case AFFormURLParameterEncoding:; + [request setValue:[NSString stringWithFormat:@"application/x-www-form-urlencoded; charset=%@", charset] forHTTPHeaderField:@"Content-Type"]; + [request setHTTPBody:[AFQueryStringFromParametersWithEncoding(parameters, self.stringEncoding) dataUsingEncoding:self.stringEncoding]]; + break; + case AFJSONParameterEncoding:; + [request setValue:[NSString stringWithFormat:@"application/json; charset=%@", charset] forHTTPHeaderField:@"Content-Type"]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wassign-enum" + [request setHTTPBody:[NSJSONSerialization dataWithJSONObject:parameters options:0 error:&error]]; +#pragma clang diagnostic pop + break; + case AFPropertyListParameterEncoding:; + [request setValue:[NSString stringWithFormat:@"application/x-plist; charset=%@", charset] forHTTPHeaderField:@"Content-Type"]; + [request setHTTPBody:[NSPropertyListSerialization dataWithPropertyList:parameters format:NSPropertyListXMLFormat_v1_0 options:0 error:&error]]; + break; + } + + if (error) { + NSLog(@"%@ %@: %@", [self class], NSStringFromSelector(_cmd), error); + } + } + } + + return request; +} + +- (NSMutableURLRequest *)multipartFormRequestWithMethod:(NSString *)method + path:(NSString *)path + parameters:(NSDictionary *)parameters + constructingBodyWithBlock:(void (^)(id formData))block +{ + NSParameterAssert(method); + NSParameterAssert(![method isEqualToString:@"GET"] && ![method isEqualToString:@"HEAD"]); + + NSMutableURLRequest *request = [self requestWithMethod:method path:path parameters:nil]; + + __block SLAFStreamingMultipartFormData *formData = [[SLAFStreamingMultipartFormData alloc] initWithURLRequest:request stringEncoding:self.stringEncoding]; + + if (parameters) { + for (SLAFQueryStringPair *pair in SLAFQueryStringPairsFromDictionary(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]; +} + +- (SLAFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure +{ + SLAFHTTPRequestOperation *operation = nil; + + for (NSString *className in self.registeredHTTPOperationClassNames) { + Class operationClass = NSClassFromString(className); + if (operationClass && [operationClass canProcessRequest:urlRequest]) { + operation = [(SLAFHTTPRequestOperation *)[operationClass alloc] initWithRequest:urlRequest]; + break; + } + } + + if (!operation) { + operation = [[SLAFHTTPRequestOperation alloc] initWithRequest:urlRequest]; + } + + [operation setCompletionBlockWithSuccess:success failure:failure]; + + operation.credential = self.defaultCredential; +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ + operation.SSLPinningMode = self.defaultSSLPinningMode; +#endif + operation.allowsInvalidSSLCertificate = self.allowsInvalidSSLCertificate; + + return operation; +} + +#pragma mark - + +- (void)enqueueHTTPRequestOperation:(SLAFHTTPRequestOperation *)operation { + [self.operationQueue addOperation:operation]; +} + +- (void)cancelAllHTTPOperationsWithMethod:(NSString *)method + path:(NSString *)path +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + NSString *pathToBeMatched = [[[self requestWithMethod:(method ?: @"GET") path:path parameters:nil] URL] path]; +#pragma clang diagnostic pop + + for (NSOperation *operation in [self.operationQueue operations]) { + if (![operation isKindOfClass:[SLAFHTTPRequestOperation class]]) { + continue; + } + + BOOL hasMatchingMethod = !method || [method isEqualToString:[[(SLAFHTTPRequestOperation *)operation request] HTTPMethod]]; + BOOL hasMatchingPath = [[[[(SLAFHTTPRequestOperation *)operation request] URL] path] isEqual:pathToBeMatched]; + + if (hasMatchingMethod && hasMatchingPath) { + [operation cancel]; + } + } +} + +- (void)enqueueBatchOfHTTPRequestOperationsWithRequests:(NSArray *)urlRequests + progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock + completionBlock:(void (^)(NSArray *operations))completionBlock +{ + NSMutableArray *mutableOperations = [NSMutableArray array]; + for (NSURLRequest *request in urlRequests) { + SLAFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:nil failure:nil]; + [mutableOperations addObject:operation]; + } + + [self enqueueBatchOfHTTPRequestOperations:mutableOperations progressBlock:progressBlock completionBlock:completionBlock]; +} + +- (void)enqueueBatchOfHTTPRequestOperations:(NSArray *)operations + progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock + completionBlock:(void (^)(NSArray *operations))completionBlock +{ + __block dispatch_group_t dispatchGroup = dispatch_group_create(); + NSBlockOperation *batchedOperation = [NSBlockOperation blockOperationWithBlock:^{ + dispatch_group_notify(dispatchGroup, dispatch_get_main_queue(), ^{ + if (completionBlock) { + completionBlock(operations); + } + }); +#if !OS_OBJECT_USE_OBJC + dispatch_release(dispatchGroup); +#endif + }]; + + for (SLAFHTTPRequestOperation *operation in operations) { + AFCompletionBlock originalCompletionBlock = [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.successCallbackQueue ?: dispatch_get_main_queue(); +#pragma clang diagnostic pop + dispatch_group_async(dispatchGroup, 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(dispatchGroup); + }); + }; + + dispatch_group_enter(dispatchGroup); + [batchedOperation addDependency:operation]; + } + [self.operationQueue addOperations:operations waitUntilFinished:NO]; + [self.operationQueue addOperation:batchedOperation]; +} + +#pragma mark - + +- (void)getPath:(NSString *)path + parameters:(NSDictionary *)parameters + success:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure +{ + NSURLRequest *request = [self requestWithMethod:@"GET" path:path parameters:parameters]; + SLAFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + [self enqueueHTTPRequestOperation:operation]; +} + +- (void)postPath:(NSString *)path + parameters:(NSDictionary *)parameters + success:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure +{ + NSURLRequest *request = [self requestWithMethod:@"POST" path:path parameters:parameters]; + SLAFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + [self enqueueHTTPRequestOperation:operation]; +} + +- (void)putPath:(NSString *)path + parameters:(NSDictionary *)parameters + success:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure +{ + NSURLRequest *request = [self requestWithMethod:@"PUT" path:path parameters:parameters]; + SLAFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + [self enqueueHTTPRequestOperation:operation]; +} + +- (void)deletePath:(NSString *)path + parameters:(NSDictionary *)parameters + success:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure +{ + NSURLRequest *request = [self requestWithMethod:@"DELETE" path:path parameters:parameters]; + SLAFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + [self enqueueHTTPRequestOperation:operation]; +} + +- (void)patchPath:(NSString *)path + parameters:(NSDictionary *)parameters + success:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure +{ + NSURLRequest *request = [self requestWithMethod:@"PATCH" path:path parameters:parameters]; + SLAFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; + [self enqueueHTTPRequestOperation:operation]; +} + +#pragma mark - NSCoding + +- (id)initWithCoder:(NSCoder *)aDecoder { + NSURL *baseURL = [aDecoder decodeObjectForKey:@"baseURL"]; + + self = [self initWithBaseURL:baseURL]; + if (!self) { + return nil; + } + + self.stringEncoding = [aDecoder decodeIntegerForKey:@"stringEncoding"]; + self.parameterEncoding = (AFHTTPClientParameterEncoding) [aDecoder decodeIntegerForKey:@"parameterEncoding"]; + self.registeredHTTPOperationClassNames = [aDecoder decodeObjectForKey:@"registeredHTTPOperationClassNames"]; + self.defaultHeaders = [aDecoder decodeObjectForKey:@"defaultHeaders"]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)aCoder { + [aCoder encodeObject:self.baseURL forKey:@"baseURL"]; + [aCoder encodeInteger:(NSInteger)self.stringEncoding forKey:@"stringEncoding"]; + [aCoder encodeInteger:self.parameterEncoding forKey:@"parameterEncoding"]; + [aCoder encodeObject:self.registeredHTTPOperationClassNames forKey:@"registeredHTTPOperationClassNames"]; + [aCoder encodeObject:self.defaultHeaders forKey:@"defaultHeaders"]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + SLAFHTTPClient *HTTPClient = [[[self class] allocWithZone:zone] initWithBaseURL:self.baseURL]; + + HTTPClient.stringEncoding = self.stringEncoding; + HTTPClient.parameterEncoding = self.parameterEncoding; + HTTPClient.registeredHTTPOperationClassNames = [self.registeredHTTPOperationClassNames copyWithZone:zone]; + HTTPClient.defaultHeaders = [self.defaultHeaders copyWithZone:zone]; +#ifdef _SYSTEMCONFIGURATION_H + HTTPClient.networkReachabilityStatusBlock = self.networkReachabilityStatusBlock; +#endif + return HTTPClient; +} + +@end + +#pragma mark - + +static NSString * const kAFMultipartFormBoundary = @"Boundary+0xAbCdEfGbOuNdArY"; + +static NSString * const kAFMultipartFormCRLF = @"\r\n"; + +static NSInteger const kAFStreamToStreamBufferSize = 1024 * 1024; //1 meg default + +static inline NSString * AFMultipartFormInitialBoundary() { + return [NSString stringWithFormat:@"--%@%@", kAFMultipartFormBoundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFMultipartFormEncapsulationBoundary() { + return [NSString stringWithFormat:@"%@--%@%@", kAFMultipartFormCRLF, kAFMultipartFormBoundary, kAFMultipartFormCRLF]; +} + +static inline NSString * AFMultipartFormFinalBoundary() { + return [NSString stringWithFormat:@"%@--%@--%@", kAFMultipartFormCRLF, kAFMultipartFormBoundary, 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 + return @"application/octet-stream"; +#endif +} + +NSUInteger const kSLAFUploadStream3GSuggestedPacketSize = 1024 * 16; +NSTimeInterval const kSLAFUploadStream3GSuggestedDelay = 0.2; + +@interface SLAFHTTPBodyPart : NSObject +@property (nonatomic, assign) NSStringEncoding stringEncoding; +@property (nonatomic, strong) NSDictionary *headers; +@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 (nonatomic, readonly, getter = hasBytesAvailable) BOOL bytesAvailable; +@property (nonatomic, readonly) unsigned long long contentLength; + +- (NSInteger)read:(uint8_t *)buffer + maxLength:(NSUInteger)length; +@end + +@interface SLAFMultipartBodyStream : NSInputStream +@property (nonatomic, assign) NSUInteger numberOfBytesInPacket; +@property (nonatomic, assign) NSTimeInterval delay; +@property (nonatomic, strong) NSInputStream *inputStream; +@property (nonatomic, readonly) unsigned long long contentLength; +@property (nonatomic, readonly, getter = isEmpty) BOOL empty; + +- (id)initWithStringEncoding:(NSStringEncoding)encoding; +- (void)setInitialAndFinalBoundaries; +- (void)appendHTTPBodyPart:(SLAFHTTPBodyPart *)bodyPart; +@end + +#pragma mark - + +@interface SLAFStreamingMultipartFormData () +@property (readwrite, nonatomic, copy) NSMutableURLRequest *request; +@property (readwrite, nonatomic, strong) SLAFMultipartBodyStream *bodyStream; +@property (readwrite, nonatomic, assign) NSStringEncoding stringEncoding; +@end + +@implementation SLAFStreamingMultipartFormData +@synthesize request = _request; +@synthesize bodyStream = _bodyStream; +@synthesize stringEncoding = _stringEncoding; + +- (id)initWithURLRequest:(NSMutableURLRequest *)urlRequest + stringEncoding:(NSStringEncoding)encoding +{ + self = [super init]; + if (!self) { + return nil; + } + + self.request = urlRequest; + self.stringEncoding = encoding; + self.bodyStream = [[SLAFMultipartBodyStream 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 = [NSDictionary dictionaryWithObject:NSLocalizedStringFromTable(@"Expected URL to be a file URL", @"AFNetworking", nil) forKey:NSLocalizedFailureReasonErrorKey]; + if (error != NULL) { + *error = [[NSError alloc] initWithDomain:SLAFNetworkingErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; + } + + return NO; + } else if ([fileURL checkResourceIsReachableAndReturnError:error] == NO) { + NSDictionary *userInfo = [NSDictionary dictionaryWithObject:NSLocalizedStringFromTable(@"File URL not reachable.", @"AFNetworking", nil) forKey:NSLocalizedFailureReasonErrorKey]; + if (error != NULL) { + *error = [[NSError alloc] initWithDomain:SLAFNetworkingErrorDomain code:NSURLErrorBadURL userInfo:userInfo]; + } + + 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"]; + + SLAFHTTPBodyPart *bodyPart = [[SLAFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.body = fileURL; + + NSDictionary *fileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:[fileURL path] error:nil]; + bodyPart.bodyContentLength = [[fileAttributes objectForKey:NSFileSize] unsignedLongLongValue]; + + [self.bodyStream appendHTTPBodyPart:bodyPart]; + + return YES; +} + + +- (void)appendPartWithInputStream:(NSInputStream *)inputStream + name:(NSString *)name + fileName:(NSString *)fileName + length:(unsigned long long)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"]; + + + SLAFHTTPBodyPart *bodyPart = [[SLAFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = mutableHeaders; + bodyPart.body = inputStream; + + bodyPart.bodyContentLength = 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); + + SLAFHTTPBodyPart *bodyPart = [[SLAFHTTPBodyPart alloc] init]; + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = headers; + 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 setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", kAFMultipartFormBoundary] forHTTPHeaderField:@"Content-Type"]; + [self.request setValue:[NSString stringWithFormat:@"%llu", [self.bodyStream contentLength]] forHTTPHeaderField:@"Content-Length"]; + [self.request setHTTPBodyStream:self.bodyStream]; + + return self.request; +} + +@end + +#pragma mark - + +@interface SLAFMultipartBodyStream () +@property (nonatomic, assign) NSStreamStatus streamStatus; +@property (nonatomic, strong) NSError *streamError; +@property (nonatomic, assign) NSStringEncoding stringEncoding; +@property (nonatomic, strong) NSMutableArray *HTTPBodyParts; +@property (nonatomic, strong) NSEnumerator *HTTPBodyPartEnumerator; +@property (nonatomic, strong) SLAFHTTPBodyPart *currentHTTPBodyPart; +@property (nonatomic, strong) NSOutputStream *outputStream; +@property (nonatomic, strong) NSMutableData *buffer; +@end + +@implementation SLAFMultipartBodyStream +@synthesize streamStatus = _streamStatus; +@synthesize streamError = _streamError; +@synthesize stringEncoding = _stringEncoding; +@synthesize HTTPBodyParts = _HTTPBodyParts; +@synthesize HTTPBodyPartEnumerator = _HTTPBodyPartEnumerator; +@synthesize currentHTTPBodyPart = _currentHTTPBodyPart; +@synthesize inputStream = _inputStream; +@synthesize outputStream = _outputStream; +@synthesize buffer = _buffer; +@synthesize numberOfBytesInPacket = _numberOfBytesInPacket; +@synthesize delay = _delay; + +- (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 (SLAFHTTPBodyPart *bodyPart in self.HTTPBodyParts) { + bodyPart.hasInitialBoundary = NO; + bodyPart.hasFinalBoundary = NO; + } + + [[self.HTTPBodyParts objectAtIndex:0] setHasInitialBoundary:YES]; + [[self.HTTPBodyParts lastObject] setHasFinalBoundary:YES]; + } +} + +- (void)appendHTTPBodyPart:(SLAFHTTPBodyPart *)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 bytesRead = 0; + + while ((NSUInteger)bytesRead < MIN(length, self.numberOfBytesInPacket)) { + if (!self.currentHTTPBodyPart || ![self.currentHTTPBodyPart hasBytesAvailable]) { + if (!(self.currentHTTPBodyPart = [self.HTTPBodyPartEnumerator nextObject])) { + break; + } + } else { + bytesRead += [self.currentHTTPBodyPart read:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; + if (self.delay > 0.0f) { + [NSThread sleepForTimeInterval:self.delay]; + } + } + } + return bytesRead; +} + +- (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 (SLAFHTTPBodyPart *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 { + SLAFMultipartBodyStream *bodyStreamCopy = [[[self class] allocWithZone:zone] initWithStringEncoding:self.stringEncoding]; + + for (SLAFHTTPBodyPart *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 SLAFHTTPBodyPart () { + AFHTTPBodyPartReadPhase _phase; + NSInputStream *_inputStream; + unsigned long long _phaseReadOffset; +} + +- (BOOL)transitionToNextPhase; +- (NSInteger)readData:(NSData *)data + intoBuffer:(uint8_t *)buffer + maxLength:(NSUInteger)length; +@end + +@implementation SLAFHTTPBodyPart +@synthesize stringEncoding = _stringEncoding; +@synthesize headers = _headers; +@synthesize body = _body; +@synthesize bodyContentLength = _bodyContentLength; +@synthesize inputStream = _inputStream; +@synthesize hasInitialBoundary = _hasInitialBoundary; +@synthesize hasFinalBoundary = _hasFinalBoundary; + +- (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() : AFMultipartFormEncapsulationBoundary()) dataUsingEncoding:self.stringEncoding]; + length += [encapsulationBoundaryData length]; + + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; + length += [headersData length]; + + length += _bodyContentLength; + + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary() 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 bytesRead = 0; + + if (_phase == AFEncapsulationBoundaryPhase) { + NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary() : AFMultipartFormEncapsulationBoundary()) dataUsingEncoding:self.stringEncoding]; + bytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; + } + + if (_phase == AFHeaderPhase) { + NSData *headersData = [[self stringForHeaders] dataUsingEncoding:self.stringEncoding]; + bytesRead += [self readData:headersData intoBuffer:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; + } + + if (_phase == AFBodyPhase) { + if ([self.inputStream hasBytesAvailable]) { + bytesRead += [self.inputStream read:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; + } + + if (![self.inputStream hasBytesAvailable]) { + [self transitionToNextPhase]; + } + } + + if (_phase == AFFinalBoundaryPhase) { + NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary() dataUsingEncoding:self.stringEncoding] : [NSData data]); + bytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - (NSUInteger)bytesRead)]; + } + + return bytesRead; +} + +- (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 { + SLAFHTTPBodyPart *bodyPart = [[[self class] allocWithZone:zone] init]; + + bodyPart.stringEncoding = self.stringEncoding; + bodyPart.headers = self.headers; + bodyPart.bodyContentLength = self.bodyContentLength; + bodyPart.body = self.body; + + return bodyPart; +} + +@end diff --git a/SLAFNetworking/SLAFHTTPRequestOperation.h b/SLAFNetworking/SLAFHTTPRequestOperation.h new file mode 100755 index 0000000..ffcdfec --- /dev/null +++ b/SLAFNetworking/SLAFHTTPRequestOperation.h @@ -0,0 +1,133 @@ +// AFHTTPRequestOperation.h +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "SLAFURLConnectionOperation.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 SLAFHTTPRequestOperation : SLAFURLConnectionOperation + +///---------------------------------------------- +/// @name Getting HTTP URL Connection Information +///---------------------------------------------- + +/** + The last HTTP response received by the operation's connection. + */ +@property (readonly, nonatomic, strong) NSHTTPURLResponse *response; + +///---------------------------------------------------------- +/// @name Managing And Checking For Acceptable HTTP Responses +///---------------------------------------------------------- + +/** + A Boolean value that corresponds to whether the status code of the response is within the specified set of acceptable status codes. Returns `YES` if `acceptableStatusCodes` is `nil`. + */ +@property (nonatomic, readonly) BOOL hasAcceptableStatusCode; + +/** + A Boolean value that corresponds to whether the MIME type of the response is among the specified set of acceptable content types. Returns `YES` if `acceptableContentTypes` is `nil`. + */ +@property (nonatomic, readonly) BOOL hasAcceptableContentType; + +/** + The callback dispatch queue on success. If `NULL` (default), the main queue is used. + */ +@property (nonatomic, assign) dispatch_queue_t successCallbackQueue; + +/** + The callback dispatch queue on failure. If `NULL` (default), the main queue is used. + */ +@property (nonatomic, assign) dispatch_queue_t failureCallbackQueue; + +///------------------------------------------------------------ +/// @name Managing Acceptable HTTP Status Codes & Content Types +///------------------------------------------------------------ + +/** + Returns an `NSIndexSet` object containing the ranges of acceptable HTTP status codes. When non-`nil`, the operation will set the `error` property to an error in `AFErrorDomain`. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html + + By default, this is the range 200 to 299, inclusive. + */ ++ (NSIndexSet *)acceptableStatusCodes; + +/** + Adds status codes to the set of acceptable HTTP status codes returned by `+acceptableStatusCodes` in subsequent calls by this class and its descendants. + + @param statusCodes The status codes to be added to the set of acceptable HTTP status codes + */ ++ (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes; + +/** + Returns an `NSSet` object containing the acceptable MIME types. When non-`nil`, the operation will set the `error` property to an error in `AFErrorDomain`. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17 + + By default, this is `nil`. + */ ++ (NSSet *)acceptableContentTypes; + +/** + Adds content types to the set of acceptable MIME types returned by `+acceptableContentTypes` in subsequent calls by this class and its descendants. + + @param contentTypes The content types to be added to the set of acceptable MIME types + */ ++ (void)addAcceptableContentTypes:(NSSet *)contentTypes; + + +///----------------------------------------------------- +/// @name Determining Whether A Request Can Be Processed +///----------------------------------------------------- + +/** + A Boolean value determining whether or not the class can process the specified request. For example, `AFJSONRequestOperation` may check to make sure the content type was `application/json` or the URL path extension was `.json`. + + @param urlRequest The request that is determined to be supported or not supported for this class. + */ ++ (BOOL)canProcessRequest:(NSURLRequest *)urlRequest; + +///----------------------------------------------------------- +/// @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 (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure; + +@end + +///---------------- +/// @name Functions +///---------------- + +/** + Returns a set of MIME types detected in an HTTP `Accept` or `Content-Type` header. + */ +extern NSSet * AFContentTypesFromHTTPHeader(NSString *string); + diff --git a/SLAFNetworking/SLAFHTTPRequestOperation.m b/SLAFNetworking/SLAFHTTPRequestOperation.m new file mode 100755 index 0000000..61791ca --- /dev/null +++ b/SLAFNetworking/SLAFHTTPRequestOperation.m @@ -0,0 +1,319 @@ +// AFHTTPRequestOperation.m +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "SLAFHTTPRequestOperation.h" +#import + +// Workaround for change in imp_implementationWithBlock() with Xcode 4.5 +#if defined(__IPHONE_6_0) || defined(__MAC_10_8) +#define AF_CAST_TO_BLOCK id +#else +#define AF_CAST_TO_BLOCK __bridge void * +#endif + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wstrict-selector-match" + +NSSet * AFContentTypesFromHTTPHeader(NSString *string) { + if (!string) { + return nil; + } + + NSArray *mediaRanges = [string componentsSeparatedByString:@","]; + NSMutableSet *mutableContentTypes = [NSMutableSet setWithCapacity:mediaRanges.count]; + + [mediaRanges enumerateObjectsUsingBlock:^(NSString *mediaRange, __unused NSUInteger idx, __unused BOOL *stop) { + NSRange parametersRange = [mediaRange rangeOfString:@";"]; + if (parametersRange.location != NSNotFound) { + mediaRange = [mediaRange substringToIndex:parametersRange.location]; + } + + mediaRange = [mediaRange stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + + if (mediaRange.length > 0) { + [mutableContentTypes addObject:mediaRange]; + } + }]; + + return [NSSet setWithSet:mutableContentTypes]; +} + +static void AFGetMediaTypeAndSubtypeWithString(NSString *string, NSString **type, NSString **subtype) { + NSScanner *scanner = [NSScanner scannerWithString:string]; + [scanner setCharactersToBeSkipped:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + [scanner scanUpToString:@"/" intoString:type]; + [scanner scanString:@"/" intoString:nil]; + [scanner scanUpToString:@";" intoString:subtype]; +} + +static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) { + NSMutableString *string = [NSMutableString string]; + + NSRange range = NSMakeRange([indexSet firstIndex], 1); + while (range.location != NSNotFound) { + NSUInteger nextIndex = [indexSet indexGreaterThanIndex:range.location]; + while (nextIndex == range.location + range.length) { + range.length++; + nextIndex = [indexSet indexGreaterThanIndex:nextIndex]; + } + + if (string.length) { + [string appendString:@","]; + } + + if (range.length == 1) { + [string appendFormat:@"%lu", (long)range.location]; + } else { + NSUInteger firstIndex = range.location; + NSUInteger lastIndex = firstIndex + range.length - 1; + [string appendFormat:@"%lu-%lu", (long)firstIndex, (long)lastIndex]; + } + + range.location = nextIndex; + range.length = 1; + } + + return string; +} + +static void AFSwizzleClassMethodWithClassAndSelectorUsingBlock(Class klass, SEL selector, id block) { + Method originalMethod = class_getClassMethod(klass, selector); + IMP implementation = imp_implementationWithBlock((AF_CAST_TO_BLOCK)block); + class_replaceMethod(objc_getMetaClass([NSStringFromClass(klass) UTF8String]), selector, implementation, method_getTypeEncoding(originalMethod)); +} + +#pragma mark - + +@interface SLAFHTTPRequestOperation () +@property (readwrite, nonatomic, strong) NSURLRequest *request; +@property (readwrite, nonatomic, strong) NSHTTPURLResponse *response; +@property (readwrite, nonatomic, strong) NSError *HTTPError; +@end + +@implementation SLAFHTTPRequestOperation +@synthesize HTTPError = _HTTPError; +@synthesize successCallbackQueue = _successCallbackQueue; +@synthesize failureCallbackQueue = _failureCallbackQueue; +@dynamic request; +@dynamic response; + +- (void)dealloc { + if (_successCallbackQueue) { +#if !OS_OBJECT_USE_OBJC + dispatch_release(_successCallbackQueue); +#endif + _successCallbackQueue = NULL; + } + + if (_failureCallbackQueue) { +#if !OS_OBJECT_USE_OBJC + dispatch_release(_failureCallbackQueue); +#endif + _failureCallbackQueue = NULL; + } +} + +- (NSError *)error { + if (!self.HTTPError && self.response) { + if (![self hasAcceptableStatusCode] || ![self hasAcceptableContentType]) { + NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; + [userInfo setValue:self.responseString forKey:NSLocalizedRecoverySuggestionErrorKey]; + [userInfo setValue:[self.request URL] forKey:NSURLErrorFailingURLErrorKey]; + [userInfo setValue:self.request forKey:SLAFNetworkingOperationFailingURLRequestErrorKey]; + [userInfo setValue:self.response forKey:SLAFNetworkingOperationFailingURLResponseErrorKey]; + + if (![self hasAcceptableStatusCode]) { + NSUInteger statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? (NSUInteger)[self.response statusCode] : 200; + [userInfo setValue:[NSString stringWithFormat:NSLocalizedStringFromTable(@"Expected status code in (%@), got %d", @"AFNetworking", nil), AFStringFromIndexSet([[self class] acceptableStatusCodes]), statusCode] forKey:NSLocalizedDescriptionKey]; + self.HTTPError = [[NSError alloc] initWithDomain:SLAFNetworkingErrorDomain code:NSURLErrorBadServerResponse userInfo:userInfo]; + } else if (![self hasAcceptableContentType]) { + // Don't invalidate content type if there is no content + if ([self.responseData length] > 0) { + [userInfo setValue:[NSString stringWithFormat:NSLocalizedStringFromTable(@"Expected content type %@, got %@", @"AFNetworking", nil), [[self class] acceptableContentTypes], [self.response MIMEType]] forKey:NSLocalizedDescriptionKey]; + self.HTTPError = [[NSError alloc] initWithDomain:SLAFNetworkingErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo]; + } + } + } + } + + if (self.HTTPError) { + return self.HTTPError; + } else { + return [super error]; + } +} + +- (NSStringEncoding)responseStringEncoding { + // When no explicit charset parameter is provided by the sender, media subtypes of the "text" type are defined to have a default charset value of "ISO-8859-1" when received via HTTP. Data in character sets other than "ISO-8859-1" or its subsets MUST be labeled with an appropriate charset value. + // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.4.1 + if (self.response && !self.response.textEncodingName && self.responseData && [self.response respondsToSelector:@selector(allHeaderFields)]) { + NSString *type = nil; + AFGetMediaTypeAndSubtypeWithString([[self.response allHeaderFields] valueForKey:@"Content-Type"], &type, nil); + + if ([type isEqualToString:@"text"]) { + return NSISOLatin1StringEncoding; + } + } + + return [super responseStringEncoding]; +} + +- (void)pause { + unsigned long long offset = 0; + if ([self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey]) { + offset = [[self.outputStream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedLongLongValue]; + } else { + offset = [[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; + + [super pause]; +} + +- (BOOL)hasAcceptableStatusCode { + if (!self.response) { + return NO; + } + + NSUInteger statusCode = ([self.response isKindOfClass:[NSHTTPURLResponse class]]) ? (NSUInteger)[self.response statusCode] : 200; + return ![[self class] acceptableStatusCodes] || [[[self class] acceptableStatusCodes] containsIndex:statusCode]; +} + +- (BOOL)hasAcceptableContentType { + if (!self.response) { + return NO; + } + + // Any HTTP/1.1 message containing an entity-body SHOULD include a Content-Type header field defining the media type of that body. If and only if the media type is not given by a Content-Type field, the recipient MAY attempt to guess the media type via inspection of its content and/or the name extension(s) of the URI used to identify the resource. If the media type remains unknown, the recipient SHOULD treat it as type "application/octet-stream". + // See http://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html + NSString *contentType = [self.response MIMEType]; + if (!contentType) { + contentType = @"application/octet-stream"; + } + + return ![[self class] acceptableContentTypes] || [[[self class] acceptableContentTypes] containsObject:contentType]; +} + +- (void)setSuccessCallbackQueue:(dispatch_queue_t)successCallbackQueue { + if (successCallbackQueue != _successCallbackQueue) { + if (_successCallbackQueue) { +#if !OS_OBJECT_USE_OBJC + dispatch_release(_successCallbackQueue); +#endif + _successCallbackQueue = NULL; + } + + if (successCallbackQueue) { +#if !OS_OBJECT_USE_OBJC + dispatch_retain(successCallbackQueue); +#endif + _successCallbackQueue = successCallbackQueue; + } + } +} + +- (void)setFailureCallbackQueue:(dispatch_queue_t)failureCallbackQueue { + if (failureCallbackQueue != _failureCallbackQueue) { + if (_failureCallbackQueue) { +#if !OS_OBJECT_USE_OBJC + dispatch_release(_failureCallbackQueue); +#endif + _failureCallbackQueue = NULL; + } + + if (failureCallbackQueue) { +#if !OS_OBJECT_USE_OBJC + dispatch_retain(failureCallbackQueue); +#endif + _failureCallbackQueue = failureCallbackQueue; + } + } +} + +- (void)setCompletionBlockWithSuccess:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *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.error) { + if (failure) { + dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ + failure(self, self.error); + }); + } + } else { + if (success) { + dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{ + success(self, self.responseData); + }); + } + } + }; +#pragma clang diagnostic pop +} + +#pragma mark - AFHTTPRequestOperation + ++ (NSIndexSet *)acceptableStatusCodes { + return [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)]; +} + ++ (void)addAcceptableStatusCodes:(NSIndexSet *)statusCodes { + NSMutableIndexSet *mutableStatusCodes = [[NSMutableIndexSet alloc] initWithIndexSet:[self acceptableStatusCodes]]; + [mutableStatusCodes addIndexes:statusCodes]; + AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableStatusCodes), ^(__unused id _self) { + return mutableStatusCodes; + }); +} + ++ (NSSet *)acceptableContentTypes { + return nil; +} + ++ (void)addAcceptableContentTypes:(NSSet *)contentTypes { + NSMutableSet *mutableContentTypes = [[NSMutableSet alloc] initWithSet:[self acceptableContentTypes] copyItems:YES]; + [mutableContentTypes unionSet:contentTypes]; + AFSwizzleClassMethodWithClassAndSelectorUsingBlock([self class], @selector(acceptableContentTypes), ^(__unused id _self) { + return mutableContentTypes; + }); +} + ++ (BOOL)canProcessRequest:(NSURLRequest *)request { + if ([[self class] isEqual:[SLAFHTTPRequestOperation class]]) { + return YES; + } + + return [[self acceptableContentTypes] intersectsSet:AFContentTypesFromHTTPHeader([request valueForHTTPHeaderField:@"Accept"])]; +} + +@end + +#pragma clang diagnostic pop diff --git a/SLAFNetworking/SLAFImageRequestOperation.h b/SLAFNetworking/SLAFImageRequestOperation.h new file mode 100755 index 0000000..da63e91 --- /dev/null +++ b/SLAFNetworking/SLAFImageRequestOperation.h @@ -0,0 +1,108 @@ +// AFImageRequestOperation.h +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "SLAFHTTPRequestOperation.h" + +#import + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#import +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) +#import +#endif + +/** + `AFImageRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and processing images. + + ## Acceptable Content Types + + By default, `AFImageRequestOperation` 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 SLAFImageRequestOperation : SLAFHTTPRequestOperation + +/** + An image constructed from the response data. If an error occurs during the request, `nil` will be returned, and the `error` property will be set to the error. + */ +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +@property (readonly, nonatomic, strong) UIImage *responseImage; +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) +@property (readonly, nonatomic, strong) NSImage *responseImage; +#endif + +#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; +#endif + +/** + Creates and returns an `AFImageRequestOperation` object and sets the specified success callback. + + @param urlRequest The request object to be loaded asynchronously during execution of the operation. + @param success A block object to be executed when the request finishes successfully. This block has no return value and takes a single argument, the image created from the response data of the request. + + @return A new image request operation + */ +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(UIImage *image))success; +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSImage *image))success; +#endif + +/** + Creates and returns an `AFImageRequestOperation` object and sets the specified success callback. + + @param urlRequest The request object to be loaded asynchronously during execution of the operation. + @param imageProcessingBlock A block object to be executed after the image request finishes successfully, but before the image is returned in the `success` block. This block takes a single argument, the image loaded from the response body, and returns the processed image. + @param success A block object to be executed when the request finishes successfully, with a status code in the 2xx range, and with an acceptable content type (e.g. `image/png`). This block has no return value and takes three arguments: the request object of the operation, the response for the request, and the image created from the response data. + @param failure A block object to be executed when the request finishes unsuccessfully. This block has no return value and takes three arguments: the request object of the operation, the response for the request, and the error associated with the cause for the unsuccessful operation. + + @return A new image request operation + */ +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest + imageProcessingBlock:(UIImage *(^)(UIImage *image))imageProcessingBlock + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest + imageProcessingBlock:(NSImage *(^)(NSImage *image))imageProcessingBlock + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure; +#endif + +@end diff --git a/SLAFNetworking/SLAFImageRequestOperation.m b/SLAFNetworking/SLAFImageRequestOperation.m new file mode 100755 index 0000000..b66cba1 --- /dev/null +++ b/SLAFNetworking/SLAFImageRequestOperation.m @@ -0,0 +1,238 @@ +// AFImageRequestOperation.m +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "SLAFImageRequestOperation.h" + +static dispatch_queue_t image_request_operation_processing_queue() { + static dispatch_queue_t af_image_request_operation_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_image_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.image-request.processing", DISPATCH_QUEUE_CONCURRENT); + }); + + return af_image_request_operation_processing_queue; +} + +@interface SLAFImageRequestOperation () +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +@property (readwrite, nonatomic, strong) UIImage *responseImage; +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) +@property (readwrite, nonatomic, strong) NSImage *responseImage; +#endif +@end + +@implementation SLAFImageRequestOperation +@synthesize responseImage = _responseImage; +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +@synthesize imageScale = _imageScale; +#endif + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(UIImage *image))success +{ + return [self imageRequestOperationWithRequest:urlRequest imageProcessingBlock:nil success:^(NSURLRequest __unused *request, NSHTTPURLResponse __unused *response, UIImage *image) { + if (success) { + success(image); + } + } failure:nil]; +} +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSImage *image))success +{ + return [self imageRequestOperationWithRequest:urlRequest imageProcessingBlock:nil success:^(NSURLRequest __unused *request, NSHTTPURLResponse __unused *response, NSImage *image) { + if (success) { + success(image); + } + } failure:nil]; +} +#endif + + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest + imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure +{ + SLAFImageRequestOperation *requestOperation = [(SLAFImageRequestOperation *)[self alloc] initWithRequest:urlRequest]; + [requestOperation setCompletionBlockWithSuccess:^(SLAFHTTPRequestOperation *operation, id responseObject) { + if (success) { + UIImage *image = responseObject; + if (imageProcessingBlock) { + dispatch_async(image_request_operation_processing_queue(), ^(void) { + UIImage *processedImage = imageProcessingBlock(image); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wgnu" + dispatch_async(operation.successCallbackQueue ?: dispatch_get_main_queue(), ^(void) { + success(operation.request, operation.response, processedImage); + }); +#pragma clang diagnostic pop + }); + } else { + success(operation.request, operation.response, image); + } + } + } failure:^(SLAFHTTPRequestOperation *operation, NSError *error) { + if (failure) { + failure(operation.request, operation.response, error); + } + }]; + + + return requestOperation; +} +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) ++ (instancetype)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest + imageProcessingBlock:(NSImage *(^)(NSImage *))imageProcessingBlock + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSImage *image))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure +{ + AFImageRequestOperation *requestOperation = [(AFImageRequestOperation *)[self alloc] initWithRequest:urlRequest]; + [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { + if (success) { + NSImage *image = responseObject; + if (imageProcessingBlock) { + dispatch_async(image_request_operation_processing_queue(), ^(void) { + NSImage *processedImage = imageProcessingBlock(image); + + dispatch_async(operation.successCallbackQueue ?: dispatch_get_main_queue(), ^(void) { + success(operation.request, operation.response, processedImage); + }); + }); + } else { + success(operation.request, operation.response, image); + } + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + if (failure) { + failure(operation.request, operation.response, error); + } + }]; + + return requestOperation; +} +#endif + +- (id)initWithRequest:(NSURLRequest *)urlRequest { + self = [super initWithRequest:urlRequest]; + if (!self) { + return nil; + } + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + self.imageScale = [[UIScreen mainScreen] scale]; +#endif + + return self; +} + + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +- (UIImage *)responseImage { + if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) { + UIImage *image = [UIImage imageWithData:self.responseData]; + + self.responseImage = [UIImage imageWithCGImage:[image CGImage] scale:self.imageScale orientation:image.imageOrientation]; + } + + return _responseImage; +} + +- (void)setImageScale:(CGFloat)imageScale { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wfloat-equal" + if (imageScale == _imageScale) { + return; + } +#pragma clang diagnostic pop + + _imageScale = imageScale; + + self.responseImage = nil; +} +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) +- (NSImage *)responseImage { + if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) { + // Ensure that the image is set to it's correct pixel width and height + NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:self.responseData]; + self.responseImage = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])]; + [self.responseImage addRepresentation:bitimage]; + } + + return _responseImage; +} +#endif + +#pragma mark - AFHTTPRequestOperation + ++ (NSSet *)acceptableContentTypes { + return [NSSet setWithObjects:@"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]; +} + ++ (BOOL)canProcessRequest:(NSURLRequest *)request { + static NSSet * _acceptablePathExtension = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _acceptablePathExtension = [[NSSet alloc] initWithObjects:@"tif", @"tiff", @"jpg", @"jpeg", @"gif", @"png", @"ico", @"bmp", @"cur", nil]; + }); + + return [_acceptablePathExtension containsObject:[[request URL] pathExtension]] || [super canProcessRequest:request]; +} + +- (void)setCompletionBlockWithSuccess:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wgnu" + + self.completionBlock = ^ { + dispatch_async(image_request_operation_processing_queue(), ^(void) { + if (self.error) { + if (failure) { + dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ + failure(self, self.error); + }); + } + } else { + if (success) { +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + UIImage *image = nil; +#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) + NSImage *image = nil; +#endif + + image = self.responseImage; + + dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{ + success(self, image); + }); + } + } + }); + }; +#pragma clang diagnostic pop +} + +@end diff --git a/SLAFNetworking/SLAFJSONRequestOperation.h b/SLAFNetworking/SLAFJSONRequestOperation.h new file mode 100755 index 0000000..8dc4348 --- /dev/null +++ b/SLAFNetworking/SLAFJSONRequestOperation.h @@ -0,0 +1,71 @@ +// AFJSONRequestOperation.h +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "SLAFHTTPRequestOperation.h" + +/** + `AFJSONRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and working with JSON response data. + + ## Acceptable Content Types + + By default, `AFJSONRequestOperation` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types: + + - `application/json` + - `text/json` + + @warning JSON parsing will use the built-in `NSJSONSerialization` class. + */ +@interface SLAFJSONRequestOperation : SLAFHTTPRequestOperation + +///---------------------------- +/// @name Getting Response Data +///---------------------------- + +/** + A JSON object constructed from the response data. If an error occurs while parsing, `nil` will be returned, and the `error` property will be set to the error. + */ +@property (readonly, nonatomic, strong) id responseJSON; + +/** + Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". + */ +@property (nonatomic, assign) NSJSONReadingOptions JSONReadingOptions; + +///---------------------------------- +/// @name Creating Request Operations +///---------------------------------- + +/** + Creates and returns an `AFJSONRequestOperation` object and sets the specified success and failure callbacks. + + @param urlRequest The request object to be loaded asynchronously during execution of the operation + @param success A block object to be executed when the 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 JSON object created from the response data of request. + @param failure A block object to be executed when the operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data as JSON. 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 describing the network or parsing error that occurred. + + @return A new JSON request operation + */ ++ (instancetype)JSONRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON))failure; + +@end diff --git a/SLAFNetworking/SLAFJSONRequestOperation.m b/SLAFNetworking/SLAFJSONRequestOperation.m new file mode 100755 index 0000000..ddb0b93 --- /dev/null +++ b/SLAFNetworking/SLAFJSONRequestOperation.m @@ -0,0 +1,150 @@ +// AFJSONRequestOperation.m +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "SLAFJSONRequestOperation.h" + +static dispatch_queue_t json_request_operation_processing_queue() { + static dispatch_queue_t af_json_request_operation_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_json_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.json-request.processing", DISPATCH_QUEUE_CONCURRENT); + }); + + return af_json_request_operation_processing_queue; +} + +@interface SLAFJSONRequestOperation () +@property (readwrite, nonatomic, strong) id responseJSON; +@property (readwrite, nonatomic, strong) NSError *JSONError; +@property (readwrite, nonatomic, strong) NSRecursiveLock *lock; +@end + +@implementation SLAFJSONRequestOperation +@synthesize responseJSON = _responseJSON; +@synthesize JSONReadingOptions = _JSONReadingOptions; +@synthesize JSONError = _JSONError; +@dynamic lock; + ++ (instancetype)JSONRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id JSON))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON))failure +{ + SLAFJSONRequestOperation *requestOperation = [(SLAFJSONRequestOperation *)[self alloc] initWithRequest:urlRequest]; + [requestOperation setCompletionBlockWithSuccess:^(SLAFHTTPRequestOperation *operation, id responseObject) { + if (success) { + success(operation.request, operation.response, responseObject); + } + } failure:^(SLAFHTTPRequestOperation *operation, NSError *error) { + if (failure) { + failure(operation.request, operation.response, error, [(SLAFJSONRequestOperation *)operation responseJSON]); + } + }]; + + return requestOperation; +} + + +- (id)responseJSON { + [self.lock lock]; + if (!_responseJSON && [self.responseData length] > 0 && [self isFinished] && !self.JSONError) { + NSError *error = 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 + if (self.responseString && ![self.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 + NSData *data = [self.responseString dataUsingEncoding:NSUTF8StringEncoding]; + + if (data) { + self.responseJSON = [NSJSONSerialization JSONObjectWithData:data options:self.JSONReadingOptions error:&error]; + } else { + NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; + [userInfo setValue:@"Operation responseData failed decoding as a UTF-8 string" forKey:NSLocalizedDescriptionKey]; + [userInfo setValue:[NSString stringWithFormat:@"Could not decode string: %@", self.responseString] forKey:NSLocalizedFailureReasonErrorKey]; + error = [[NSError alloc] initWithDomain:SLAFNetworkingErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo]; + } + } + + self.JSONError = error; + } + [self.lock unlock]; + + return _responseJSON; +} + +- (NSError *)error { + if (_JSONError) { + return _JSONError; + } else { + return [super error]; + } +} + +#pragma mark - AFHTTPRequestOperation + ++ (NSSet *)acceptableContentTypes { + return [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil]; +} + ++ (BOOL)canProcessRequest:(NSURLRequest *)request { + return [[[request URL] pathExtension] isEqualToString:@"json"] || [super canProcessRequest:request]; +} + +- (void)setCompletionBlockWithSuccess:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wgnu" + + self.completionBlock = ^ { + if (self.error) { + if (failure) { + dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ + failure(self, self.error); + }); + } + } else { + dispatch_async(json_request_operation_processing_queue(), ^{ + id JSON = self.responseJSON; + + if (self.error) { + if (failure) { + dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ + failure(self, self.error); + }); + } + } else { + if (success) { + dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{ + success(self, JSON); + }); + } + } + }); + } + }; +#pragma clang diagnostic pop +} + +@end diff --git a/SLAFNetworking/SLAFNetworkActivityIndicatorManager.h b/SLAFNetworking/SLAFNetworkActivityIndicatorManager.h new file mode 100755 index 0000000..c77d1a2 --- /dev/null +++ b/SLAFNetworking/SLAFNetworkActivityIndicatorManager.h @@ -0,0 +1,75 @@ +// AFNetworkActivityIndicatorManager.h +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 SLAFNetworkActivityIndicatorManager : 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 before decrementing, this will stop animating the status bar network activity indicator. + */ +- (void)decrementActivityCount; + +@end + +#endif diff --git a/SLAFNetworking/SLAFNetworkActivityIndicatorManager.m b/SLAFNetworking/SLAFNetworkActivityIndicatorManager.m new file mode 100755 index 0000000..afd5acf --- /dev/null +++ b/SLAFNetworking/SLAFNetworkActivityIndicatorManager.m @@ -0,0 +1,157 @@ +// AFNetworkActivityIndicatorManager.m +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "SLAFNetworkActivityIndicatorManager.h" + +#import "SLAFHTTPRequestOperation.h" + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17; + +@interface SLAFNetworkActivityIndicatorManager () +@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 SLAFNetworkActivityIndicatorManager +@synthesize activityCount = _activityCount; +@synthesize activityIndicatorVisibilityTimer = _activityIndicatorVisibilityTimer; +@synthesize enabled = _enabled; +@dynamic networkActivityIndicatorVisible; + ++ (instancetype)sharedManager { + static SLAFNetworkActivityIndicatorManager *_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(networkingOperationDidStart:) name:SLAFNetworkingOperationDidStartNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkingOperationDidFinish:) name:SLAFNetworkingOperationDidFinishNotification object:nil]; + + 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:[NSArray arrayWithObject:NSRunLoopCommonModes]]; + } + } +} + +- (BOOL)isNetworkActivityIndicatorVisible { + return _activityCount > 0; +} + +- (void)updateNetworkActivityIndicatorVisibility { + [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]]; +} + +// Not exposed, but used if activityCount is set via KVC. +- (NSInteger)activityCount { + return _activityCount; +} + +- (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)networkingOperationDidStart:(NSNotification *)notification { + SLAFURLConnectionOperation *connectionOperation = [notification object]; + if (connectionOperation.request.URL) { + [self incrementActivityCount]; + } +} + +- (void)networkingOperationDidFinish:(NSNotification *)notification { + SLAFURLConnectionOperation *connectionOperation = [notification object]; + if (connectionOperation.request.URL) { + [self decrementActivityCount]; + } +} + +@end + +#endif diff --git a/SLAFNetworking/SLAFNetworking.h b/SLAFNetworking/SLAFNetworking.h new file mode 100755 index 0000000..634c210 --- /dev/null +++ b/SLAFNetworking/SLAFNetworking.h @@ -0,0 +1,43 @@ +// AFNetworking.h +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "SLAFURLConnectionOperation.h" + + #import "SLAFHTTPRequestOperation.h" + #import "SLAFJSONRequestOperation.h" + #import "SLAFXMLRequestOperation.h" + #import "SLAFPropertyListRequestOperation.h" + #import "SLAFHTTPClient.h" + + #import "SLAFImageRequestOperation.h" + + #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + #import "SLAFNetworkActivityIndicatorManager.h" + #import "UIImageView+SLAFNetworking.h" + #endif +#endif /* _AFNETWORKING_ */ diff --git a/SLAFNetworking/SLAFPropertyListRequestOperation.h b/SLAFNetworking/SLAFPropertyListRequestOperation.h new file mode 100755 index 0000000..2e22f95 --- /dev/null +++ b/SLAFNetworking/SLAFPropertyListRequestOperation.h @@ -0,0 +1,68 @@ +// AFPropertyListRequestOperation.h +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "SLAFHTTPRequestOperation.h" + +/** + `AFPropertyListRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and deserializing objects with property list (plist) response data. + + ## Acceptable Content Types + + By default, `AFPropertyListRequestOperation` accepts the following MIME types: + + - `application/x-plist` + */ +@interface SLAFPropertyListRequestOperation : SLAFHTTPRequestOperation + +///---------------------------- +/// @name Getting Response Data +///---------------------------- + +/** + An object deserialized from a plist constructed using the response data. + */ +@property (readonly, nonatomic) id responsePropertyList; + +///-------------------------------------- +/// @name Managing Property List Behavior +///-------------------------------------- + +/** + One of the `NSPropertyListMutabilityOptions` options, specifying the mutability of objects deserialized from the property list. By default, this is `NSPropertyListImmutable`. + */ +@property (nonatomic, assign) NSPropertyListReadOptions propertyListReadOptions; + +/** + Creates and returns an `AFPropertyListRequestOperation` object and sets the specified success and failure callbacks. + + @param urlRequest The request object to be loaded asynchronously during execution of the operation + @param success A block object to be executed when the 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 object deserialized from a plist constructed using the response data. + @param failure A block object to be executed when the operation finishes unsuccessfully, or that finishes successfully, but encountered an error while deserializing the object from a property list. 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 describing the network or parsing error that occurred. + + @return A new property list request operation + */ ++ (instancetype)propertyListRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure; + +@end diff --git a/SLAFNetworking/SLAFPropertyListRequestOperation.m b/SLAFNetworking/SLAFPropertyListRequestOperation.m new file mode 100755 index 0000000..3ba891f --- /dev/null +++ b/SLAFNetworking/SLAFPropertyListRequestOperation.m @@ -0,0 +1,143 @@ +// AFPropertyListRequestOperation.m +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "SLAFPropertyListRequestOperation.h" + +static dispatch_queue_t property_list_request_operation_processing_queue() { + static dispatch_queue_t af_property_list_request_operation_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_property_list_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.property-list-request.processing", DISPATCH_QUEUE_CONCURRENT); + }); + + return af_property_list_request_operation_processing_queue; +} + +@interface SLAFPropertyListRequestOperation () +@property (readwrite, nonatomic) id responsePropertyList; +@property (readwrite, nonatomic, assign) NSPropertyListFormat propertyListFormat; +@property (readwrite, nonatomic) NSError *propertyListError; +@end + +@implementation SLAFPropertyListRequestOperation +@synthesize responsePropertyList = _responsePropertyList; +@synthesize propertyListReadOptions = _propertyListReadOptions; +@synthesize propertyListFormat = _propertyListFormat; +@synthesize propertyListError = _propertyListError; + ++ (instancetype)propertyListRequestOperationWithRequest:(NSURLRequest *)request + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList))failure +{ + SLAFPropertyListRequestOperation *requestOperation = [(SLAFPropertyListRequestOperation *)[self alloc] initWithRequest:request]; + [requestOperation setCompletionBlockWithSuccess:^(SLAFHTTPRequestOperation *operation, id responseObject) { + if (success) { + success(operation.request, operation.response, responseObject); + } + } failure:^(SLAFHTTPRequestOperation *operation, NSError *error) { + if (failure) { + failure(operation.request, operation.response, error, [(SLAFPropertyListRequestOperation *)operation responsePropertyList]); + } + }]; + + return requestOperation; +} + +- (id)initWithRequest:(NSURLRequest *)urlRequest { + self = [super initWithRequest:urlRequest]; + if (!self) { + return nil; + } + + self.propertyListReadOptions = NSPropertyListImmutable; + + return self; +} + + +- (id)responsePropertyList { + if (!_responsePropertyList && [self.responseData length] > 0 && [self isFinished]) { + NSPropertyListFormat format; + NSError *error = nil; + self.responsePropertyList = [NSPropertyListSerialization propertyListWithData:self.responseData options:self.propertyListReadOptions format:&format error:&error]; + self.propertyListFormat = format; + self.propertyListError = error; + } + + return _responsePropertyList; +} + +- (NSError *)error { + if (_propertyListError) { + return _propertyListError; + } else { + return [super error]; + } +} + +#pragma mark - AFHTTPRequestOperation + ++ (NSSet *)acceptableContentTypes { + return [NSSet setWithObjects:@"application/x-plist", nil]; +} + ++ (BOOL)canProcessRequest:(NSURLRequest *)request { + return [[[request URL] pathExtension] isEqualToString:@"plist"] || [super canProcessRequest:request]; +} + +- (void)setCompletionBlockWithSuccess:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wgnu" + self.completionBlock = ^ { + if (self.error) { + if (failure) { + dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ + failure(self, self.error); + }); + } + } else { + dispatch_async(property_list_request_operation_processing_queue(), ^(void) { + id propertyList = self.responsePropertyList; + + if (self.propertyListError) { + if (failure) { + dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ + failure(self, self.error); + }); + } + } else { + if (success) { + dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{ + success(self, propertyList); + }); + } + } + }); + } + }; +#pragma clang diagnostic pop +} + +@end diff --git a/SLAFNetworking/SLAFURLConnectionOperation.h b/SLAFNetworking/SLAFURLConnectionOperation.h new file mode 100755 index 0000000..437a14e --- /dev/null +++ b/SLAFNetworking/SLAFURLConnectionOperation.h @@ -0,0 +1,407 @@ +// AFURLConnectionOperation.h +// +// Copyright (c) 2011 Gowalla (http://gowalla.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` 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:` + + When _AFNETWORKING_PIN_SSL_CERTIFICATES_ is defined, the following authentication delegate method is implemented: + + - `connection:willSendRequestForAuthenticationChallenge:` + + Otherwise, the following authentication delegate methods are implemented: + + - `connection:canAuthenticateAgainstProtectionSpace:` + - `connection:didReceiveAuthenticationChallenge:` + + If any of these methods are overridden in a subclass, they _must_ call the `super` implementation first. + + ## Class Constructors + + Class constructors, or methods that return an unowned instance, are the preferred way for subclasses to encapsulate any particular logic for handling the setup or parsing of response data. For instance, `AFJSONRequestOperation` provides `JSONRequestOperationWithRequest:success:failure:`, which takes block arguments, whose parameter on for a successful request is the JSON object initialized from the `response data`. + + ## 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. + + When `_AFNETWORKING_PIN_SSL_CERTIFICATES_` is defined and the Security framework is linked, connections will be validated on all matching certificates with a `.cer` extension in the bundle root. + + ## 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`. `completionBlock` often strongly captures a reference to `self`, which would otherwise have the unintuitive side-effect of pointing to the _original_ operation when copied. + */ + +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ +typedef enum { + AFSSLPinningModeNone, + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, +} AFURLConnectionOperationSSLPinningMode; +#endif + +@interface SLAFURLConnectionOperation : NSOperation = 50000) || \ + (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080) +NSURLConnectionDataDelegate, +#endif +NSCoding, NSCopying> + +///------------------------------- +/// @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; + +/** + Whether the connection should accept an invalid SSL certificate. + + If `_AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_` is set, this property defaults to `YES` for backwards compatibility. Otherwise, this property defaults to `NO`. + */ +@property (nonatomic, assign) BOOL allowsInvalidSSLCertificate; + +///---------------------------- +/// @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; + +/** + The pinning mode which will be used for SSL connections. `AFSSLPinningModePublicKey` by default. + + To enable SSL Pinning, `#define _AFNETWORKING_PIN_SSL_CERTIFICATES_` in `Prefix.pch`. Also, make sure that the Security framework is linked with the binary. See the "SSL Pinning" section in the `AFURLConnectionOperation`" header for more information. + */ +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ +@property (nonatomic, assign) AFURLConnectionOperationSSLPinningMode SSLPinningMode; +#endif + +///------------------------ +/// @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. 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 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. + */ +- (id)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) +- (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 +///------------------------------------------------- + +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ +/** + 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; + +#else + +/** + Sets a block to be executed to determine whether the connection should be able to respond to a protection space's form of authentication, as handled by the `NSURLConnectionDelegate` method `connection:canAuthenticateAgainstProtectionSpace:`. + + If `allowsInvalidSSLCertificate` is set to YES, `connection:canAuthenticateAgainstProtectionSpace:` will accept invalid SSL certificates, returning `YES` if the protection space authentication method is `NSURLAuthenticationMethodServerTrust`. + + @param block A block object to be executed to determine whether the connection should be able to respond to a protection space's form of authentication. The block has a `BOOL` return type and takes two arguments: the URL connection object, and the protection space to authenticate against. + */ +- (void)setAuthenticationAgainstProtectionSpaceBlock:(BOOL (^)(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace))block; + +/** + Sets a block to be executed when the connection must authenticate a challenge in order to download its request, as handled by the `NSURLConnectionDelegate` method `connection:didReceiveAuthenticationChallenge:`. + + @param block A block object to be executed when the connection must 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. + + If `allowsInvalidSSLCertificate` is set to YES, `connection:didReceiveAuthenticationChallenge:` will attempt to have the challenge sender use credentials with invalid SSL certificates. + */ +- (void)setAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block; + +#endif + +/** + 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 `NSURLConnectionDelegate` 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; + +@end + +///---------------- +/// @name Constants +///---------------- + +/** + ## SSL Pinning Options + + The following constants are provided by `AFURLConnectionOperation` as possible SSL Pinning options. + + enum { + AFSSLPinningModeNone, + AFSSLPinningModePublicKey, + AFSSLPinningModeCertificate, + } + + `AFSSLPinningModeNone` + Do not pin SSL connections + + `AFSSLPinningModePublicKey` + Pin SSL connections to certificate public key (SPKI). + + `AFSSLPinningModeCertificate` + Pin SSL connections to exact certificate. This may cause problems when your certificate expires and needs re-issuance. + + ## User info dictionary keys + + These keys may exist in the user info dictionary, in addition to those defined for NSError. + + - `NSString * const AFNetworkingOperationFailingURLRequestErrorKey` + - `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 `AFNetworkingErrorDomain`. + + `AFNetworkingOperationFailingURLResponseErrorKey` + The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFNetworkingErrorDomain`. + + ## Error Domains + + The following error domain is predefined. + + - `NSString * const AFNetworkingErrorDomain` + + ### Constants + + `AFNetworkingErrorDomain` + AFNetworking errors. Error codes for `AFNetworkingErrorDomain` correspond to codes in `NSURLErrorDomain`. + */ +extern NSString * const SLAFNetworkingErrorDomain; +extern NSString * const SLAFNetworkingOperationFailingURLRequestErrorKey; +extern NSString * const SLAFNetworkingOperationFailingURLResponseErrorKey; + +///-------------------- +/// @name Notifications +///-------------------- + +/** + Posted when an operation begins executing. + */ +extern NSString * const SLAFNetworkingOperationDidStartNotification; + +/** + Posted when an operation finishes. + */ +extern NSString * const SLAFNetworkingOperationDidFinishNotification; diff --git a/SLAFNetworking/SLAFURLConnectionOperation.m b/SLAFNetworking/SLAFURLConnectionOperation.m new file mode 100755 index 0000000..7d5b22f --- /dev/null +++ b/SLAFNetworking/SLAFURLConnectionOperation.m @@ -0,0 +1,907 @@ +// AFURLConnectionOperation.m +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "SLAFURLConnectionOperation.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 enum { + AFOperationPausedState = -1, + AFOperationReadyState = 1, + AFOperationExecutingState = 2, + AFOperationFinishedState = 3, +} _AFOperationState; + +typedef signed short AFOperationState; + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +typedef UIBackgroundTaskIdentifier AFBackgroundTaskIdentifier; +#else +typedef id AFBackgroundTaskIdentifier; +#endif + +static NSString * const kAFNetworkingLockName = @"com.alamofire.networking.operation.lock"; + +NSString * const SLAFNetworkingErrorDomain = @"AFNetworkingErrorDomain"; +NSString * const SLAFNetworkingOperationFailingURLRequestErrorKey = @"AFNetworkingOperationFailingURLRequestErrorKey"; +NSString * const SLAFNetworkingOperationFailingURLResponseErrorKey = @"AFNetworkingOperationFailingURLResponseErrorKey"; + +NSString * const SLAFNetworkingOperationDidStartNotification = @"com.alamofire.networking.operation.start"; +NSString * const SLAFNetworkingOperationDidFinishNotification = @"com.alamofire.networking.operation.finish"; + +typedef void (^AFURLConnectionOperationProgressBlock)(NSUInteger bytes, long long totalBytes, long long totalBytesExpected); +#ifndef _AFNETWORKING_PIN_SSL_CERTIFICATES_ +typedef BOOL (^AFURLConnectionOperationAuthenticationAgainstProtectionSpaceBlock)(NSURLConnection *connection, NSURLProtectionSpace *protectionSpace); +#endif +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: + return @"state"; + } +} + +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: + return YES; + } +} + +#if !defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +static NSData *AFSecKeyGetData(SecKeyRef key) { + CFDataRef data = NULL; + + OSStatus status = SecItemExport(key, kSecFormatUnknown, kSecItemPemArmour, NULL, &data); + NSCAssert(status == errSecSuccess, @"SecItemExport error: %ld", (long int)status); + NSCParameterAssert(data); + + return (__bridge_transfer NSData *)data; +} +#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 +} + +@interface SLAFURLConnectionOperation () +@property (readwrite, nonatomic, assign) AFOperationState state; +@property (readwrite, nonatomic, assign, getter = isCancelled) BOOL cancelled; +@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; +#ifndef _AFNETWORKING_PIN_SSL_CERTIFICATES_ +@property (readwrite, nonatomic, copy) AFURLConnectionOperationAuthenticationAgainstProtectionSpaceBlock authenticationAgainstProtectionSpace; +#endif +@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 SLAFURLConnectionOperation +@synthesize state = _state; +@synthesize cancelled = _cancelled; +@synthesize connection = _connection; +@synthesize runLoopModes = _runLoopModes; +@synthesize request = _request; +@synthesize response = _response; +@synthesize error = _error; +@synthesize allowsInvalidSSLCertificate = _allowsInvalidSSLCertificate; +@synthesize responseData = _responseData; +@synthesize responseString = _responseString; +@synthesize responseStringEncoding = _responseStringEncoding; +@synthesize totalBytesRead = _totalBytesRead; +@dynamic inputStream; +@synthesize outputStream = _outputStream; +@synthesize credential = _credential; +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ +@synthesize SSLPinningMode = _SSLPinningMode; +#endif +@synthesize shouldUseCredentialStorage = _shouldUseCredentialStorage; +@synthesize userInfo = _userInfo; +@synthesize backgroundTaskIdentifier = _backgroundTaskIdentifier; +@synthesize uploadProgress = _uploadProgress; +@synthesize downloadProgress = _downloadProgress; +@synthesize authenticationChallenge = _authenticationChallenge; +#ifndef _AFNETWORKING_PIN_SSL_CERTIFICATES_ +@synthesize authenticationAgainstProtectionSpace = _authenticationAgainstProtectionSpace; +#endif +@synthesize cacheResponse = _cacheResponse; +@synthesize redirectResponse = _redirectResponse; +@synthesize lock = _lock; + ++ (void) __attribute__((noreturn)) networkRequestThreadEntryPoint:(id)__unused object { + do { + @autoreleasepool { + [[NSThread currentThread] setName:@"AFNetworking"]; + [[NSRunLoop currentRunLoop] run]; + } + } while (YES); +} + ++ (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; +} + +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ ++ (NSArray *)pinnedCertificates { + static NSArray *_pinnedCertificates = 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]; + } + + _pinnedCertificates = [[NSArray alloc] initWithArray:certificates]; + }); + + return _pinnedCertificates; +} + ++ (NSArray *)pinnedPublicKeys { + static NSArray *_pinnedPublicKeys = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSArray *pinnedCertificates = [self pinnedCertificates]; + NSMutableArray *publicKeys = [NSMutableArray arrayWithCapacity:[pinnedCertificates count]]; + + for (NSData *data in pinnedCertificates) { + SecCertificateRef allowedCertificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)data); + NSParameterAssert(allowedCertificate); + + SecCertificateRef allowedCertificates[] = {allowedCertificate}; + CFArrayRef certificates = CFArrayCreate(NULL, (const void **)allowedCertificates, 1, NULL); + + SecPolicyRef policy = SecPolicyCreateBasicX509(); + SecTrustRef allowedTrust = NULL; + OSStatus status = SecTrustCreateWithCertificates(certificates, policy, &allowedTrust); + NSAssert(status == errSecSuccess, @"SecTrustCreateWithCertificates error: %ld", (long int)status); + + SecTrustResultType result = 0; + status = SecTrustEvaluate(allowedTrust, &result); + NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status); + + SecKeyRef allowedPublicKey = SecTrustCopyPublicKey(allowedTrust); + NSParameterAssert(allowedPublicKey); + [publicKeys addObject:(__bridge_transfer id)allowedPublicKey]; + + CFRelease(allowedTrust); + CFRelease(policy); + CFRelease(certificates); + CFRelease(allowedCertificate); + } + + _pinnedPublicKeys = [[NSArray alloc] initWithArray:publicKeys]; + }); + + return _pinnedPublicKeys; +} +#endif + +- (id)initWithRequest:(NSURLRequest *)urlRequest { + self = [super init]; + if (!self) { + return nil; + } + + self.lock = [[NSRecursiveLock alloc] init]; + self.lock.name = kAFNetworkingLockName; + + self.runLoopModes = [NSSet setWithObject:NSRunLoopCommonModes]; + + self.request = urlRequest; + + self.shouldUseCredentialStorage = YES; + + // #ifdef included for backwards-compatibility +#ifdef _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ + self.allowsInvalidSSLCertificate = YES; +#endif + + self.state = AFOperationReadyState; + + return self; +} + +- (void)dealloc { + if (_outputStream) { + [_outputStream close]; + _outputStream = nil; + } + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) + if (_backgroundTaskIdentifier) { + [[UIApplication sharedApplication] endBackgroundTask:_backgroundTaskIdentifier]; + _backgroundTaskIdentifier = UIBackgroundTaskInvalid; + } +#endif +} + +- (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]; +} + +- (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; + + block(); + [strongSelf setCompletionBlock:nil]; + }]; + } + [self.lock unlock]; +} + +- (NSInputStream *)inputStream { + return self.request.HTTPBodyStream; +} + +- (void)setInputStream:(NSInputStream *)inputStream { + [self willChangeValueForKey:@"inputStream"]; + NSMutableURLRequest *mutableRequest = [self.request mutableCopy]; + mutableRequest.HTTPBodyStream = inputStream; + self.request = mutableRequest; + [self didChangeValueForKey:@"inputStream"]; +} + +- (NSOutputStream *)outputStream { + if (!_outputStream) { + self.outputStream = [NSOutputStream outputStreamToMemory]; + } + + return _outputStream; +} + +- (void)setOutputStream:(NSOutputStream *)outputStream { + [self.lock lock]; + if (outputStream != _outputStream) { + [self willChangeValueForKey:@"outputStream"]; + if (_outputStream) { + [_outputStream close]; + } + _outputStream = outputStream; + [self didChangeValueForKey:@"outputStream"]; + } + [self.lock unlock]; +} + +#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +- (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 + +- (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; +} + +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ + +- (void)setWillSendRequestForAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block { + self.authenticationChallenge = block; +} + +#else + +- (void)setAuthenticationAgainstProtectionSpaceBlock:(BOOL (^)(NSURLConnection *, NSURLProtectionSpace *))block { + self.authenticationAgainstProtectionSpace = block; +} + +- (void)setAuthenticationChallengeBlock:(void (^)(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge))block { + self.authenticationChallenge = block; +} + +#endif + +- (void)setCacheResponseBlock:(NSCachedURLResponse * (^)(NSURLConnection *connection, NSCachedURLResponse *cachedResponse))block { + self.cacheResponse = block; +} + +- (void)setRedirectResponseBlock:(NSURLRequest * (^)(NSURLConnection *connection, NSURLRequest *request, NSURLResponse *redirectResponse))block { + self.redirectResponse = block; +} + +- (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]; +} + +- (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; +} + +- (void)pause { + if ([self isPaused] || [self isFinished] || [self isCancelled]) { + return; + } + + [self.lock lock]; + + if ([self isExecuting]) { + [self.connection performSelector:@selector(cancel) onThread:[[self class] networkRequestThread] withObject:nil waitUntilDone:NO modes:[self.runLoopModes allObjects]]; + + dispatch_async(dispatch_get_main_queue(), ^{ + NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; + [notificationCenter postNotificationName:SLAFNetworkingOperationDidFinishNotification object:self]; + }); + } + + self.state = AFOperationPausedState; + + [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 - NSOperation + +- (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 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:SLAFNetworkingOperationDidStartNotification object:self]; + }); + + if ([self isCancelled]) { + [self finish]; + } +} + +- (void)finish { + self.state = AFOperationFinishedState; + + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:SLAFNetworkingOperationDidFinishNotification object:self]; + }); +} + +- (void)cancel { + [self.lock lock]; + if (![self isFinished] && ![self isCancelled]) { + [self willChangeValueForKey:@"isCancelled"]; + _cancelled = YES; + [super cancel]; + [self didChangeValueForKey:@"isCancelled"]; + + // Cancel the connection on the thread it runs on to prevent race conditions + [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]; + } + self.error = [NSError errorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled userInfo:userInfo]; + + if (self.connection) { + [self.connection cancel]; + + // Manually send this delegate message since `[self.connection cancel]` causes the connection to never send another message to its delegate + [self performSelector:@selector(connection:didFailWithError:) withObject:self.connection withObject:self.error]; + } +} + +#pragma mark - NSURLConnectionDelegate + +#ifdef _AFNETWORKING_PIN_SSL_CERTIFICATES_ + +- (void)connection:(NSURLConnection *)connection +willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge +{ + if (self.authenticationChallenge) { + self.authenticationChallenge(connection, challenge); + return; + } + + if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + SecTrustRef serverTrust = challenge.protectionSpace.serverTrust; + + SecPolicyRef policy = SecPolicyCreateBasicX509(); + CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust); + NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:certificateCount]; + + for (CFIndex i = 0; i < certificateCount; i++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i); + + if (self.SSLPinningMode == AFSSLPinningModeCertificate) { + [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)]; + } else if (self.SSLPinningMode == AFSSLPinningModePublicKey) { + SecCertificateRef someCertificates[] = {certificate}; + CFArrayRef certificates = CFArrayCreate(NULL, (const void **)someCertificates, 1, NULL); + + SecTrustRef trust = NULL; + + OSStatus status = SecTrustCreateWithCertificates(certificates, policy, &trust); + NSAssert(status == errSecSuccess, @"SecTrustCreateWithCertificates error: %ld", (long int)status); + + SecTrustResultType result; + status = SecTrustEvaluate(trust, &result); + NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status); + + [trustChain addObject:(__bridge_transfer id)SecTrustCopyPublicKey(trust)]; + + CFRelease(trust); + CFRelease(certificates); + } + } + + CFRelease(policy); + + switch (self.SSLPinningMode) { + case AFSSLPinningModePublicKey: { + NSArray *pinnedPublicKeys = [self.class pinnedPublicKeys]; + + for (id publicKey in trustChain) { + for (id pinnedPublicKey in pinnedPublicKeys) { + if (AFSecKeyIsEqualToKey((__bridge SecKeyRef)publicKey, (__bridge SecKeyRef)pinnedPublicKey)) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + return; + } + } + } + + [[challenge sender] cancelAuthenticationChallenge:challenge]; + break; + } + case AFSSLPinningModeCertificate: { + for (id serverCertificateData in trustChain) { + if ([[self.class pinnedCertificates] containsObject:serverCertificateData]) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + return; + } + } + + [[challenge sender] cancelAuthenticationChallenge:challenge]; + break; + } + case AFSSLPinningModeNone: { + if (self.allowsInvalidSSLCertificate){ + NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + } else { + SecTrustResultType result = 0; + OSStatus status = SecTrustEvaluate(serverTrust, &result); + NSAssert(status == errSecSuccess, @"SecTrustEvaluate error: %ld", (long int)status); + + if (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed) { + NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrust]; + [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; + } else { + [[challenge sender] cancelAuthenticationChallenge:challenge]; + } + } + break; + } + } + } 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]; + } + } +} + +#else + +- (BOOL)connection:(NSURLConnection *)connection +canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace +{ + if (self.allowsInvalidSSLCertificate && + [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + return YES; + } + + if (self.authenticationAgainstProtectionSpace) { + return self.authenticationAgainstProtectionSpace(connection, protectionSpace); + } else if ([protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust] || [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodClientCertificate]) { + return NO; + } else { + return YES; + } +} + +- (void)connection:(NSURLConnection *)connection +didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge +{ + + if (self.allowsInvalidSSLCertificate + && [challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { + [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge]; + return; + } + + if (self.authenticationChallenge) { + self.authenticationChallenge(connection, 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]; + } + } +} + +#endif + +- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection __unused *)connection { + return self.shouldUseCredentialStorage; +} + +- (NSInputStream *)connection:(NSURLConnection __unused *)connection + needNewBodyStream:(NSURLRequest *)request +{ + if ([request.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) { + return [request.HTTPBodyStream copy]; + } else { + [self cancelConnection]; + + return nil; + } +} + +- (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 +{ + if (self.uploadProgress) { + dispatch_async(dispatch_get_main_queue(), ^{ + 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]; + if ([self.outputStream hasSpaceAvailable]) { + const uint8_t *dataBuffer = (uint8_t *) [data bytes]; + [self.outputStream write:&dataBuffer[0] maxLength:length]; + } + + dispatch_async(dispatch_get_main_queue(), ^{ + self.totalBytesRead += 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]; + + [self finish]; + + self.connection = nil; +} + +- (void)connection:(NSURLConnection __unused *)connection + didFailWithError:(NSError *)error +{ + self.error = error; + + [self.outputStream close]; + + [self finish]; + + self.connection = nil; +} + +- (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 - NSCoding + +- (id)initWithCoder:(NSCoder *)aDecoder { + NSURLRequest *request = [aDecoder decodeObjectForKey:@"request"]; + + self = [self initWithRequest:request]; + if (!self) { + return nil; + } + + self.state = (AFOperationState)[aDecoder decodeIntegerForKey:@"state"]; + self.cancelled = [aDecoder decodeBoolForKey:@"isCancelled"]; + self.response = [aDecoder decodeObjectForKey:@"response"]; + self.error = [aDecoder decodeObjectForKey:@"error"]; + self.responseData = [aDecoder decodeObjectForKey:@"responseData"]; + self.totalBytesRead = [[aDecoder decodeObjectForKey:@"totalBytesRead"] longLongValue]; + self.allowsInvalidSSLCertificate = [[aDecoder decodeObjectForKey:@"allowsInvalidSSLCertificate"] boolValue]; + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)aCoder { + [self pause]; + + [aCoder encodeObject:self.request forKey:@"request"]; + + switch (self.state) { + case AFOperationExecutingState: + case AFOperationPausedState: + [aCoder encodeInteger:AFOperationReadyState forKey:@"state"]; + break; + default: + [aCoder encodeInteger:self.state forKey:@"state"]; + break; + } + + [aCoder encodeBool:[self isCancelled] forKey:@"isCancelled"]; + [aCoder encodeObject:self.response forKey:@"response"]; + [aCoder encodeObject:self.error forKey:@"error"]; + [aCoder encodeObject:self.responseData forKey:@"responseData"]; + [aCoder encodeObject:[NSNumber numberWithLongLong:self.totalBytesRead] forKey:@"totalBytesRead"]; + [aCoder encodeObject:[NSNumber numberWithBool:self.allowsInvalidSSLCertificate] forKey:@"allowsInvalidSSLCertificate"]; +} + +#pragma mark - NSCopying + +- (id)copyWithZone:(NSZone *)zone { + SLAFURLConnectionOperation *operation = [(SLAFURLConnectionOperation *)[[self class] allocWithZone:zone] initWithRequest:self.request]; + + operation.uploadProgress = self.uploadProgress; + operation.downloadProgress = self.downloadProgress; +#ifndef _AFNETWORKING_PIN_SSL_CERTIFICATES_ + operation.authenticationAgainstProtectionSpace = self.authenticationAgainstProtectionSpace; +#endif + operation.authenticationChallenge = self.authenticationChallenge; + operation.cacheResponse = self.cacheResponse; + operation.redirectResponse = self.redirectResponse; + operation.allowsInvalidSSLCertificate = self.allowsInvalidSSLCertificate; + + return operation; +} + +@end diff --git a/SLAFNetworking/SLAFXMLRequestOperation.h b/SLAFNetworking/SLAFXMLRequestOperation.h new file mode 100755 index 0000000..6f393d7 --- /dev/null +++ b/SLAFNetworking/SLAFXMLRequestOperation.h @@ -0,0 +1,89 @@ +// AFXMLRequestOperation.h +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "SLAFHTTPRequestOperation.h" + +#import + +/** + `AFXMLRequestOperation` is a subclass of `AFHTTPRequestOperation` for downloading and working with XML response data. + + ## Acceptable Content Types + + By default, `AFXMLRequestOperation` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: + + - `application/xml` + - `text/xml` + + ## Use With AFHTTPClient + + When `AFXMLRequestOperation` is registered with `AFHTTPClient`, the response object in the success callback of `HTTPRequestOperationWithRequest:success:failure:` will be an instance of `NSXMLParser`. On platforms that support `NSXMLDocument`, you have the option to ignore the response object, and simply use the `responseXMLDocument` property of the operation argument of the callback. + */ +@interface SLAFXMLRequestOperation : SLAFHTTPRequestOperation + +///---------------------------- +/// @name Getting Response Data +///---------------------------- + +/** + An `NSXMLParser` object constructed from the response data. + */ +@property (readonly, nonatomic, strong) NSXMLParser *responseXMLParser; + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +/** + An `NSXMLDocument` object constructed from the response data. If an error occurs while parsing, `nil` will be returned, and the `error` property will be set to the error. + */ +@property (readonly, nonatomic, strong) NSXMLDocument *responseXMLDocument; +#endif + +/** + Creates and returns an `AFXMLRequestOperation` object and sets the specified success and failure callbacks. + + @param urlRequest The request object to be loaded asynchronously during execution of the operation + @param success A block object to be executed when the 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 XML parser constructed with the response data of request. + @param failure A block object to be executed when the operation finishes unsuccessfully. 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 describing the network error that occurred. + + @return A new XML request operation + */ ++ (instancetype)XMLParserRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParser))failure; + + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +/** + Creates and returns an `AFXMLRequestOperation` object and sets the specified success and failure callbacks. + + @param urlRequest The request object to be loaded asynchronously during execution of the operation + @param success A block object to be executed when the 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 XML document created from the response data of request. + @param failure A block object to be executed when the operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data as XML. 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 describing the network or parsing error that occurred. + + @return A new XML request operation + */ ++ (instancetype)XMLDocumentRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLDocument *document))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLDocument *document))failure; +#endif + +@end diff --git a/SLAFNetworking/SLAFXMLRequestOperation.m b/SLAFNetworking/SLAFXMLRequestOperation.m new file mode 100755 index 0000000..859892e --- /dev/null +++ b/SLAFNetworking/SLAFXMLRequestOperation.m @@ -0,0 +1,167 @@ +// AFXMLRequestOperation.m +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "SLAFXMLRequestOperation.h" + +#include + +static dispatch_queue_t xml_request_operation_processing_queue() { + static dispatch_queue_t af_xml_request_operation_processing_queue; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + af_xml_request_operation_processing_queue = dispatch_queue_create("com.alamofire.networking.xml-request.processing", DISPATCH_QUEUE_CONCURRENT); + }); + + return af_xml_request_operation_processing_queue; +} + +@interface SLAFXMLRequestOperation () +@property (readwrite, nonatomic, strong) NSXMLParser *responseXMLParser; +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +@property (readwrite, nonatomic, strong) NSXMLDocument *responseXMLDocument; +#endif +@property (readwrite, nonatomic, strong) NSError *XMLError; +@end + +@implementation SLAFXMLRequestOperation +@synthesize responseXMLParser = _responseXMLParser; +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +@synthesize responseXMLDocument = _responseXMLDocument; +#endif +@synthesize XMLError = _XMLError; + ++ (instancetype)XMLParserRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParser))failure +{ + SLAFXMLRequestOperation *requestOperation = [(SLAFXMLRequestOperation *)[self alloc] initWithRequest:urlRequest]; + [requestOperation setCompletionBlockWithSuccess:^(SLAFHTTPRequestOperation *operation, id responseObject) { + if (success) { + success(operation.request, operation.response, responseObject); + } + } failure:^(SLAFHTTPRequestOperation *operation, NSError *error) { + if (failure) { + failure(operation.request, operation.response, error, [(SLAFXMLRequestOperation *)operation responseXMLParser]); + } + }]; + + return requestOperation; +} + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED ++ (instancetype)XMLDocumentRequestOperationWithRequest:(NSURLRequest *)urlRequest + success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLDocument *document))success + failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLDocument *document))failure +{ + AFXMLRequestOperation *requestOperation = [[self alloc] initWithRequest:urlRequest]; + [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, __unused id responseObject) { + if (success) { + NSXMLDocument *XMLDocument = [(AFXMLRequestOperation *)operation responseXMLDocument]; + success(operation.request, operation.response, XMLDocument); + } + } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + if (failure) { + NSXMLDocument *XMLDocument = [(AFXMLRequestOperation *)operation responseXMLDocument]; + failure(operation.request, operation.response, error, XMLDocument); + } + }]; + + return requestOperation; +} +#endif + + +- (NSXMLParser *)responseXMLParser { + if (!_responseXMLParser && [self.responseData length] > 0 && [self isFinished]) { + self.responseXMLParser = [[NSXMLParser alloc] initWithData:self.responseData]; + } + + return _responseXMLParser; +} + +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +- (NSXMLDocument *)responseXMLDocument { + if (!_responseXMLDocument && [self.responseData length] > 0 && [self isFinished]) { + NSError *error = nil; + self.responseXMLDocument = [[NSXMLDocument alloc] initWithData:self.responseData options:0 error:&error]; + self.XMLError = error; + } + + return _responseXMLDocument; +} +#endif + +- (NSError *)error { + if (_XMLError) { + return _XMLError; + } else { + return [super error]; + } +} + +#pragma mark - NSOperation + +- (void)cancel { + [super cancel]; + + self.responseXMLParser.delegate = nil; +} + +#pragma mark - AFHTTPRequestOperation + ++ (NSSet *)acceptableContentTypes { + return [NSSet setWithObjects:@"application/xml", @"text/xml", nil]; +} + ++ (BOOL)canProcessRequest:(NSURLRequest *)request { + return [[[request URL] pathExtension] isEqualToString:@"xml"] || [super canProcessRequest:request]; +} + +- (void)setCompletionBlockWithSuccess:(void (^)(SLAFHTTPRequestOperation *operation, id responseObject))success + failure:(void (^)(SLAFHTTPRequestOperation *operation, NSError *error))failure +{ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-retain-cycles" +#pragma clang diagnostic ignored "-Wgnu" + self.completionBlock = ^ { + dispatch_async(xml_request_operation_processing_queue(), ^(void) { + NSXMLParser *XMLParser = self.responseXMLParser; + + if (self.error) { + if (failure) { + dispatch_async(self.failureCallbackQueue ?: dispatch_get_main_queue(), ^{ + failure(self, self.error); + }); + } + } else { + if (success) { + dispatch_async(self.successCallbackQueue ?: dispatch_get_main_queue(), ^{ + success(self, XMLParser); + }); + } + } + }); + }; +#pragma clang diagnostic pop +} + +@end diff --git a/SLAFNetworking/UIImageView+SLAFNetworking.h b/SLAFNetworking/UIImageView+SLAFNetworking.h new file mode 100755 index 0000000..1cbcccf --- /dev/null +++ b/SLAFNetworking/UIImageView+SLAFNetworking.h @@ -0,0 +1,78 @@ +// UIImageView+AFNetworking.h +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "SLAFImageRequestOperation.h" + +#import + +#if __IPHONE_OS_VERSION_MIN_REQUIRED +#import + +/** + 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 (SLAFNetworking) + +/** + Creates and enqueues an image request operation, which asynchronously downloads the image from the specified URL, and sets it 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 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; + +/** + Creates and enqueues an image request operation, which asynchronously downloads the image from the specified URL. 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 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; + +/** + Creates and enqueues an image request operation, which asynchronously downloads the image with the specified URL request object. 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 executed. + + @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, with a status code in the 2xx range, and with an acceptable content type (e.g. `image/png`). 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 request operation for the receiver, if one exists. + */ +- (void)cancelImageRequestOperation; + +@end + +#endif diff --git a/SLAFNetworking/UIImageView+SLAFNetworking.m b/SLAFNetworking/UIImageView+SLAFNetworking.m new file mode 100755 index 0000000..761b562 --- /dev/null +++ b/SLAFNetworking/UIImageView+SLAFNetworking.m @@ -0,0 +1,184 @@ +// UIImageView+AFNetworking.m +// +// Copyright (c) 2011 Gowalla (http://gowalla.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 "UIImageView+SLAFNetworking.h" + +@interface SLAFImageCache : NSCache +- (UIImage *)cachedImageForRequest:(NSURLRequest *)request; +- (void)cacheImage:(UIImage *)image + forRequest:(NSURLRequest *)request; +@end + +#pragma mark - + +static char kAFImageRequestOperationObjectKey; + +@interface UIImageView (_AFNetworking) +@property (readwrite, nonatomic, strong, setter = af_setImageRequestOperation:) SLAFImageRequestOperation *af_imageRequestOperation; +@end + +@implementation UIImageView (_AFNetworking) +@dynamic af_imageRequestOperation; +@end + +#pragma mark - + +@implementation UIImageView (AFNetworking) + +- (SLAFHTTPRequestOperation *)af_imageRequestOperation { + return (SLAFHTTPRequestOperation *)objc_getAssociatedObject(self, &kAFImageRequestOperationObjectKey); +} + +- (void)af_setImageRequestOperation:(SLAFImageRequestOperation *)imageRequestOperation { + objc_setAssociatedObject(self, &kAFImageRequestOperationObjectKey, imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} + ++ (NSOperationQueue *)af_sharedImageRequestOperationQueue { + static NSOperationQueue *_af_imageRequestOperationQueue = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + _af_imageRequestOperationQueue = [[NSOperationQueue alloc] init]; + [_af_imageRequestOperationQueue setMaxConcurrentOperationCount:NSOperationQueueDefaultMaxConcurrentOperationCount]; + }); + + return _af_imageRequestOperationQueue; +} + ++ (SLAFImageCache *)af_sharedImageCache { + static SLAFImageCache *_af_imageCache = nil; + static dispatch_once_t oncePredicate; + dispatch_once(&oncePredicate, ^{ + _af_imageCache = [[SLAFImageCache alloc] init]; + }); + + return _af_imageCache; +} + +#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] af_sharedImageCache] cachedImageForRequest:urlRequest]; + if (cachedImage) { + if (success) { + success(nil, nil, cachedImage); + } else { + self.image = cachedImage; + } + + self.af_imageRequestOperation = nil; + } else { + self.image = placeholderImage; + + SLAFImageRequestOperation *requestOperation = [[SLAFImageRequestOperation alloc] initWithRequest:urlRequest]; + [requestOperation setCompletionBlockWithSuccess:^(SLAFHTTPRequestOperation *operation, id responseObject) { + if ([urlRequest isEqual:[self.af_imageRequestOperation request]]) { + if (success) { + success(operation.request, operation.response, responseObject); + } else if (responseObject) { + self.image = responseObject; + } + + if (self.af_imageRequestOperation == operation) { + self.af_imageRequestOperation = nil; + } + } + + [[[self class] af_sharedImageCache] cacheImage:responseObject forRequest:urlRequest]; + } failure:^(SLAFHTTPRequestOperation *operation, NSError *error) { + if ([urlRequest isEqual:[self.af_imageRequestOperation request]]) { + if (failure) { + failure(operation.request, operation.response, error); + } + + if (self.af_imageRequestOperation == operation) { + self.af_imageRequestOperation = nil; + } + } + }]; + + self.af_imageRequestOperation = requestOperation; + + [[[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 SLAFImageCache + +- (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/SLRemotingTests/SLRESTAdapterNonRootTests.h b/SLRemotingTests/SLRESTAdapterNonRootTests.h new file mode 100644 index 0000000..c91fc5a --- /dev/null +++ b/SLRemotingTests/SLRESTAdapterNonRootTests.h @@ -0,0 +1,13 @@ +// +// SLRESTAdapterTests.h +// SLRemoting +// +// Created by Michael Schoonmaker on 6/3/13. +// Copyright (c) 2013 StrongLoop. All rights reserved. +// + +#import + +@interface SLRESTAdapterNonRootTests : SenTestCase + +@end diff --git a/SLRemotingTests/SLRESTAdapterNonRootTests.m b/SLRemotingTests/SLRESTAdapterNonRootTests.m new file mode 100644 index 0000000..b2f0fc8 --- /dev/null +++ b/SLRemotingTests/SLRESTAdapterNonRootTests.m @@ -0,0 +1,90 @@ +// +// SLRESTAdapterTests.m +// SLRemoting +// +// Created by Michael Schoonmaker on 6/3/13. +// Copyright (c) 2013 StrongLoop. All rights reserved. +// + +#import "SLRESTAdapterNonRootTests.h" + +#import "SLRESTAdapter.h" +#import "SLObject.h" + +@interface SLRESTAdapterNonRootTests() { + SLRESTAdapter *adapter; +} + +@end + +@implementation SLRESTAdapterNonRootTests + +- (void)setUp { + [super setUp]; +} + +- (void)tearDown { + [super tearDown]; +} + +- (void)testGetMsg { + ASYNC_TEST_START + + adapter = [SLRESTAdapter adapterWithURL:[NSURL URLWithString:@"http://localhost:3001/nonroot/api"]]; + [adapter invokeStaticMethod:@"getMsg" + parameters:nil + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"Hello" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testConvertMsg { + ASYNC_TEST_START + + adapter = [SLRESTAdapter adapterWithURL:[NSURL URLWithString:@"http://localhost:3001/nonroot/api"]]; + [adapter invokeStaticMethod:@"convertMsg" + parameters:@{ @"str": @"somevalue" } + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"CONVERTED: SOMEVALUE" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testGetMsgWithTrailingSlash { + ASYNC_TEST_START + + adapter = [SLRESTAdapter adapterWithURL:[NSURL URLWithString:@"http://localhost:3001/nonroot/api/"]]; + [adapter invokeStaticMethod:@"getMsg" + parameters:nil + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"Hello" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testConvertMsgWithTrailingSlash { + ASYNC_TEST_START + + adapter = [SLRESTAdapter adapterWithURL:[NSURL URLWithString:@"http://localhost:3001/nonroot/api/"]]; + [adapter invokeStaticMethod:@"convertMsg" + parameters:@{ @"str": @"somevalue" } + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"CONVERTED: SOMEVALUE" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +@end diff --git a/SLRemotingTests/SLRESTAdapterSSLTests.m b/SLRemotingTests/SLRESTAdapterSSLTests.m new file mode 100644 index 0000000..471573d --- /dev/null +++ b/SLRemotingTests/SLRESTAdapterSSLTests.m @@ -0,0 +1,132 @@ +// +// SLRESTAdapterSSLTests.m +// SLRemoting +// +// Created by Michael Schoonmaker on 6/3/13. +// Copyright (c) 2013 StrongLoop. All rights reserved. +// + +#import "SLRESTAdapterTests.h" + +#import "SLRESTAdapter.h" +#import "SLObject.h" + +@interface SLRESTAdapterSSLTests : SLRESTAdapterTests { + SLRESTAdapter *adapter; + SLRepository *TestClass; +} + +@end + +@implementation SLRESTAdapterSSLTests + +- (void)setUp { + [super setUp]; + + adapter = [SLRESTAdapter adapterWithURL:[NSURL URLWithString:@"https://localhost:3002"] allowsInvalidSSLCertificate:YES]; + TestClass = [SLRepository repositoryWithClassName:@"SimpleClass"]; + TestClass.adapter = adapter; +} + +- (void)tearDown { + [super tearDown]; +} + +- (void)testGet { + ASYNC_TEST_START + [adapter invokeStaticMethod:@"simple.getSecret" + parameters:nil + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"shhh!" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testTransform { + ASYNC_TEST_START + [adapter invokeStaticMethod:@"simple.transform" + parameters:@{ @"str": @"somevalue" } + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"transformed: somevalue" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testTestClassGet { + ASYNC_TEST_START + [adapter invokeInstanceMethod:@"SimpleClass.prototype.getName" + constructorParameters:@{ @"name": @"somename" } + parameters:nil + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"somename" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testTestClassTransform { + ASYNC_TEST_START + [adapter invokeInstanceMethod:@"SimpleClass.prototype.greet" + constructorParameters:@{ @"name": @"somename" } + parameters:@{ @"other": @"othername" } + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"Hi, othername!" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testRepositoryStatic { + ASYNC_TEST_START + [TestClass invokeStaticMethod:@"getFavoritePerson" + parameters:nil + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"You" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testRepositoryGet { + ASYNC_TEST_START + SLObject *test = [TestClass objectWithParameters:@{ @"name": @"somename" }]; + + [test invokeMethod:@"getName" + parameters:nil + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"somename" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testRepositoryTransform { + ASYNC_TEST_START + SLObject *test = [TestClass objectWithParameters:@{ @"name": @{ @"somekey": @"somevalue" }}]; + + [test invokeMethod:@"greet" + parameters:@{ @"other": @"othername" } + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"Hi, othername!" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +@end diff --git a/SLRemotingTests/SLRESTAdapterTests.h b/SLRemotingTests/SLRESTAdapterTests.h new file mode 100644 index 0000000..8f355e3 --- /dev/null +++ b/SLRemotingTests/SLRESTAdapterTests.h @@ -0,0 +1,13 @@ +// +// SLRESTAdapterTests.h +// SLRemoting +// +// Created by Michael Schoonmaker on 6/3/13. +// Copyright (c) 2013 StrongLoop. All rights reserved. +// + +#import + +@interface SLRESTAdapterTests : SenTestCase + +@end diff --git a/SLRemotingTests/SLRESTAdapterTests.m b/SLRemotingTests/SLRESTAdapterTests.m new file mode 100644 index 0000000..0dbaf6d --- /dev/null +++ b/SLRemotingTests/SLRESTAdapterTests.m @@ -0,0 +1,132 @@ +// +// SLRESTAdapterTests.m +// SLRemoting +// +// Created by Michael Schoonmaker on 6/3/13. +// Copyright (c) 2013 StrongLoop. All rights reserved. +// + +#import "SLRESTAdapterTests.h" + +#import "SLRESTAdapter.h" +#import "SLObject.h" + +@interface SLRESTAdapterTests() { + SLRESTAdapter *adapter; + SLRepository *TestClass; +} + +@end + +@implementation SLRESTAdapterTests + +- (void)setUp { + [super setUp]; + + adapter = [SLRESTAdapter adapterWithURL:[NSURL URLWithString:@"http://localhost:3001"]]; + TestClass = [SLRepository repositoryWithClassName:@"SimpleClass"]; + TestClass.adapter = adapter; +} + +- (void)tearDown { + [super tearDown]; +} + +- (void)testGet { + ASYNC_TEST_START + [adapter invokeStaticMethod:@"simple.getSecret" + parameters:nil + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"shhh!" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testTransform { + ASYNC_TEST_START + [adapter invokeStaticMethod:@"simple.transform" + parameters:@{ @"str": @"somevalue" } + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"transformed: somevalue" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testTestClassGet { + ASYNC_TEST_START + [adapter invokeInstanceMethod:@"SimpleClass.prototype.getName" + constructorParameters:@{ @"name": @"somename" } + parameters:nil + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"somename" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testTestClassTransform { + ASYNC_TEST_START + [adapter invokeInstanceMethod:@"SimpleClass.prototype.greet" + constructorParameters:@{ @"name": @"somename" } + parameters:@{ @"other": @"othername" } + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"Hi, othername!" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testRepositoryStatic { + ASYNC_TEST_START + [TestClass invokeStaticMethod:@"getFavoritePerson" + parameters:nil + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"You" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testRepositoryGet { + ASYNC_TEST_START + SLObject *test = [TestClass objectWithParameters:@{ @"name": @"somename" }]; + + [test invokeMethod:@"getName" + parameters:nil + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"somename" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testRepositoryTransform { + ASYNC_TEST_START + SLObject *test = [TestClass objectWithParameters:@{ @"name": @{ @"somekey": @"somevalue" }}]; + + [test invokeMethod:@"greet" + parameters:@{ @"other": @"othername" } + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"Hi, othername!" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +@end diff --git a/SLRemotingTests/SLRESTContractTests.h b/SLRemotingTests/SLRESTContractTests.h new file mode 100644 index 0000000..27bc477 --- /dev/null +++ b/SLRemotingTests/SLRESTContractTests.h @@ -0,0 +1,13 @@ +// +// SLRESTContractTests.h +// SLRemoting +// +// Created by Michael Schoonmaker on 6/6/13. +// Copyright (c) 2013 StrongLoop. All rights reserved. +// + +#import + +@interface SLRESTContractTests : SenTestCase + +@end diff --git a/SLRemotingTests/SLRESTContractTests.m b/SLRemotingTests/SLRESTContractTests.m new file mode 100644 index 0000000..8034f1d --- /dev/null +++ b/SLRemotingTests/SLRESTContractTests.m @@ -0,0 +1,154 @@ +// +// SLRESTContractTests.m +// SLRemoting +// +// Created by Michael Schoonmaker on 6/6/13. +// Copyright (c) 2013 StrongLoop. All rights reserved. +// + +#import "SLRESTContractTests.h" + +#import "SLRESTAdapter.h" +#import "SLObject.h" + +@interface SLRESTContractTests() { + SLRESTAdapter *adapter; + SLRESTContract *contract; + SLRepository *TestClass; +} + +@end + +@implementation SLRESTContractTests + +- (void)setUp { + [super setUp]; + + adapter = [SLRESTAdapter adapterWithURL:[NSURL URLWithString:@"http://localhost:3001"]]; + + [adapter.contract addItem:[SLRESTContractItem itemWithPattern:@"/contract/customizedGetSecret" verb:@"GET"] forMethod:@"contract.getSecret"]; + [adapter.contract addItem:[SLRESTContractItem itemWithPattern:@"/contract/customizedTransform" verb:@"GET"] forMethod:@"contract.transform"]; + [adapter.contract addItem:[SLRESTContractItem itemWithPattern:@"/ContractClass/:name/getName" verb:@"POST"] forMethod:@"ContractClass.prototype.getName"]; + [adapter.contract addItem:[SLRESTContractItem itemWithPattern:@"/ContractClass/:name/greet" verb:@"POST"] forMethod:@"ContractClass.prototype.greet"]; + + TestClass = [SLRepository repositoryWithClassName:@"ContractClass"]; + TestClass.adapter = adapter; +} + +- (void)tearDown { + [super tearDown]; +} + +- (void)testAddItemsFromContract { + SLRESTContract *parent = [SLRESTContract contract]; + SLRESTContract *child = [SLRESTContract contract]; + + [parent addItem:[SLRESTContractItem itemWithPattern:@"/wrong/route" verb:@"OOPS"] forMethod:@"test.route"]; + [child addItem:[SLRESTContractItem itemWithPattern:@"/test/route" verb:@"GET"] forMethod:@"test.route"]; + [child addItem:[SLRESTContractItem itemWithPattern:@"/new/route" verb:@"POST"] forMethod:@"new.route"]; + + [parent addItemsFromContract:child]; + STAssertTrue([[parent urlForMethod:@"test.route" parameters:@{}] isEqualToString:@"/test/route"], @"Wrong URL."); + STAssertTrue([[parent verbForMethod:@"test.route"] isEqualToString:@"GET"], @"Wrong verb."); + STAssertTrue([[parent urlForMethod:@"new.route" parameters:@{}] isEqualToString:@"/new/route"], @"Wrong URL."); + STAssertTrue([[parent verbForMethod:@"new.route"] isEqualToString:@"POST"], @"Wrong verb."); +} + +- (void)testGet { + ASYNC_TEST_START + [adapter invokeStaticMethod:@"contract.getSecret" + parameters:nil + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"shhh!" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testTransform { + ASYNC_TEST_START + [adapter invokeStaticMethod:@"contract.transform" + parameters:@{ @"str": @"somevalue" } + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"transformed: somevalue" isEqualToString:value[@"data"]], @"Incorrect value returned."); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testTestClassGet { + ASYNC_TEST_START + [adapter invokeInstanceMethod:@"ContractClass.prototype.getName" + constructorParameters:@{ @"name": @"somename" } + parameters:nil + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"somename" isEqualToString:value[@"data"]], [NSString stringWithFormat:@"Incorrect value returned: %@", value]); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testTestClassTransform { + ASYNC_TEST_START + [adapter invokeInstanceMethod:@"ContractClass.prototype.greet" + constructorParameters:@{ @"name": @"somename" } + parameters:@{ @"other": @"othername" } + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"Hi, othername!" isEqualToString:value[@"data"]], [NSString stringWithFormat:@"Incorrect value returned: %@", value]); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testRepositoryStatic { + ASYNC_TEST_START + [TestClass invokeStaticMethod:@"getFavoritePerson" + parameters:nil + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"You" isEqualToString:value[@"data"]], [NSString stringWithFormat:@"Incorrect value returned: %@", value]); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testRepositoryGet { + ASYNC_TEST_START + SLObject *test = [TestClass objectWithParameters:@{ @"name": @"somename" }]; + + [test invokeMethod:@"getName" + parameters:nil + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"somename" isEqualToString:value[@"data"]], [NSString stringWithFormat:@"Incorrect value returned: %@", value]); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +- (void)testRepositoryTransform { + ASYNC_TEST_START + SLObject *test = [TestClass objectWithParameters:@{ @"name": @"somename" }]; + + [test invokeMethod:@"greet" + parameters:@{ @"other": @"othername" } + success:^(id value) { + STAssertNotNil(value, @"No value returned."); + STAssertTrue([@"Hi, othername!" isEqualToString:value[@"data"]], [NSString stringWithFormat:@"Incorrect value returned: %@", value]); + ASYNC_TEST_SIGNAL + } + failure:ASYNC_TEST_FAILURE_BLOCK]; + ASYNC_TEST_END +} + +@end diff --git a/SLRemotingTests/SLRemotingTests-Info.plist b/SLRemotingTests/SLRemotingTests-Info.plist new file mode 100644 index 0000000..da694d7 --- /dev/null +++ b/SLRemotingTests/SLRemotingTests-Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.strongloop.${PRODUCT_NAME:rfc1034identifier} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.1 + CFBundleSignature + ???? + CFBundleVersion + 2 + + diff --git a/SLRemotingTests/en.lproj/InfoPlist.strings b/SLRemotingTests/en.lproj/InfoPlist.strings new file mode 100644 index 0000000..477b28f --- /dev/null +++ b/SLRemotingTests/en.lproj/InfoPlist.strings @@ -0,0 +1,2 @@ +/* Localized versions of Info.plist keys */ + diff --git a/SLRemotingTests/server/.gitignore b/SLRemotingTests/server/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/SLRemotingTests/server/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/SLRemotingTests/server/contract-class.js b/SLRemotingTests/server/contract-class.js new file mode 100644 index 0000000..d8931af --- /dev/null +++ b/SLRemotingTests/server/contract-class.js @@ -0,0 +1,49 @@ +/** + * A simple class that contains a name, this time with a custom HTTP contract. + */ +function ContractClass(name) { + this.name = name; +} + +/** + * In order to expose ContractClass, we need a "shared constructor". + */ +ContractClass.sharedCtor = function (name, callback) { + callback(null, new ContractClass(name)); +}; +ContractClass.shared = true; +ContractClass.sharedCtor.accepts = [{ arg: 'name', type: 'string' }]; +ContractClass.sharedCtor.http = { path: '/:name' }; +ContractClass.sharedCtor.returns = { type: 'object', root: true }; + +/** + * Returns the ContractClass instance's name. + */ +ContractClass.prototype.getName = function(callback) { + callback(null, this.name); +}; +ContractClass.prototype.getName.shared = true; +ContractClass.prototype.getName.accepts = []; +ContractClass.prototype.getName.returns = [{ arg: 'data', type: 'string' }]; + +/** + * Takes in a name, returning a greeting for that name. + */ +ContractClass.prototype.greet = function(other, callback) { + callback(null, 'Hi, ' + other + '!'); +}; +ContractClass.prototype.greet.shared = true; +ContractClass.prototype.greet.accepts = [{ arg: 'other', type: 'string' }]; +ContractClass.prototype.greet.returns = [{ arg: 'data', type: 'string' }]; + +/** + * Returns the ContractClass prototype's favorite person's name. + */ +ContractClass.getFavoritePerson = function(callback) { + callback(null, 'You'); +}; +ContractClass.getFavoritePerson.shared = true; +ContractClass.getFavoritePerson.accepts = []; +ContractClass.getFavoritePerson.returns = [{ arg: 'data', type: 'string' }]; + +module.exports = ContractClass; diff --git a/SLRemotingTests/server/contract.js b/SLRemotingTests/server/contract.js new file mode 100644 index 0000000..1e8eec7 --- /dev/null +++ b/SLRemotingTests/server/contract.js @@ -0,0 +1,26 @@ +/** + * Returns a secret message. + */ +function getSecret(callback) { + callback(null, 'shhh!'); +} +getSecret.shared = true; +getSecret.accepts = []; +getSecret.returns = [{ arg: 'data', type: 'string' }]; +getSecret.http = { path: '/customizedGetSecret', verb: 'GET' }; + +/** + * Takes a string and returns an updated string. + */ +function transform(str, callback) { + callback(null, 'transformed: ' + str); +} +transform.shared = true; +transform.accepts = [{ arg: 'str', type: 'string' }]; +transform.returns = [{ arg: 'data', type: 'string' }]; +transform.http = { path: '/customizedTransform', verb: 'GET' }; + +module.exports = { + getSecret: getSecret, + transform: transform +}; diff --git a/SLRemotingTests/server/index.js b/SLRemotingTests/server/index.js new file mode 100644 index 0000000..efbe5d5 --- /dev/null +++ b/SLRemotingTests/server/index.js @@ -0,0 +1,29 @@ +var remotes = require('strong-remoting').create(); + +remotes.exports = { + simple: require('./simple'), + contract: require('./contract'), + SimpleClass: require('./simple-class'), + ContractClass: require('./contract-class'), + nonroot: require('./nonroot') +}; + +var app = remotes.handler('rest'); + +var server = require('http') + .createServer(app) + .listen(3001, function() { + console.log('http server is ready at http://localhost:3001.'); + }); + +var sslConfig = require('./ssl-config'); +var options = { + key: sslConfig.privateKey, + cert: sslConfig.certificate + }; +var httpsServer = require('https') + .createServer(options, app) + .listen(3002, function() { + console.log('https server is ready at https://localhost:3002.'); + }); + diff --git a/SLRemotingTests/server/nonroot.js b/SLRemotingTests/server/nonroot.js new file mode 100644 index 0000000..bd3079f --- /dev/null +++ b/SLRemotingTests/server/nonroot.js @@ -0,0 +1,26 @@ +/** + * Returns a secret message. + */ +function getMsg(callback) { + callback(null, 'Hello'); +} +getMsg.shared = true; +getMsg.accepts = []; +getMsg.returns = [{ arg: 'data', type: 'string' }]; +getMsg.http = {path: '/api/getMsg'}; + +/** + * Takes a string and returns an updated string. + */ +function convertMsg(str, callback) { + callback(null, 'CONVERTED: ' + str.toUpperCase()); +} +convertMsg.shared = true; +convertMsg.accepts = [{ arg: 'str', type: 'string' }]; +convertMsg.returns = [{ arg: 'data', type: 'string' }]; +convertMsg.http = {path: '/api/convertMsg'}; + +module.exports = { + getMsg: getMsg, + convertMsg: convertMsg +}; diff --git a/SLRemotingTests/server/package.json b/SLRemotingTests/server/package.json new file mode 100644 index 0000000..d496e4b --- /dev/null +++ b/SLRemotingTests/server/package.json @@ -0,0 +1,9 @@ +{ + "name": "sl-remoting-client-test-server", + "version": "0.0.0", + "description": "A test server for running sl-remoting-clients integration testing.", + "main": "index.js", + "dependencies": { + "strong-remoting": "~1.1.4" + } +} diff --git a/SLRemotingTests/server/private/certificate.pem b/SLRemotingTests/server/private/certificate.pem new file mode 100644 index 0000000..f24c123 --- /dev/null +++ b/SLRemotingTests/server/private/certificate.pem @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIICCTCCAXICCQD8yCsomM2e/jANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJV +UzELMAkGA1UECBMCQ0ExEjAQBgNVBAcTCVNhbiBNYXRlbzEZMBcGA1UEChMQU3Ry +b25nTG9vcCwgSW5jLjAeFw0xNDAzMDMxODI0NThaFw0xNDA0MDIxODI0NThaMEkx +CzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTESMBAGA1UEBxMJU2FuIE1hdGVvMRkw +FwYDVQQKExBTdHJvbmdMb29wLCBJbmMuMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB +iQKBgQC2+jw+jJ6ZtzMFjAyXN5+F3I95adGKekizTQtDrHWyMYydP7kkbnWXH2G0 +SpaUyWNUWlWgt5XiEh3nc8qT+QBa1lR9xXCY0fveEQZPCMRqTSYoqD/O2zICerNi +ncUpItdSaFmoMRlZl9d/rw24OHr8H8+Wk2st01JAptzQMb1ofwIDAQABMA0GCSqG +SIb3DQEBBQUAA4GBALacXlZ8bHsPhsmY4O/TNeUgYbCsf2nvpajteVCMBE29XHHw +I2mCAw7PYueyO/A3ivneYyutVDTuak5wj4ob2rtePPuTl7CW9LcFShEMe2Y1F259 +I4j0cDkNwdoFQpdL4v91o+l+tgXqcZkMHAvaPise+9P/fKagT3Vtb7W2KIWo +-----END CERTIFICATE----- diff --git a/SLRemotingTests/server/private/privatekey.pem b/SLRemotingTests/server/private/privatekey.pem new file mode 100644 index 0000000..4fd14de --- /dev/null +++ b/SLRemotingTests/server/private/privatekey.pem @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXAIBAAKBgQC2+jw+jJ6ZtzMFjAyXN5+F3I95adGKekizTQtDrHWyMYydP7kk +bnWXH2G0SpaUyWNUWlWgt5XiEh3nc8qT+QBa1lR9xXCY0fveEQZPCMRqTSYoqD/O +2zICerNincUpItdSaFmoMRlZl9d/rw24OHr8H8+Wk2st01JAptzQMb1ofwIDAQAB +AoGAR83PEmSwYHYJ6aVZ04WabjdtfiHOft8Z5HLZdscYsMLNAXBeQTOvpYxFFTEo +Al89QX7pl1Yz1TFy1r8Twhm2z0RZgnlNWCnAcQW6hCHYopdRpBkpX7Ar9QLsoiw+ +t+CXErN0TzgrNhtrTvldsCVmxyOSTvdJXBKMfwBG8Vhb9tECQQDq3ZOcqei9rXEY +GfahnwG5ZCLEmvGbwQIkaEsO2es7Wee6LT7b0B2ioSC00w1HOe91UR9I91gmiFR4 +Ssfyus6NAkEAx3FaIpEKWi2hDPSbzv/v1Y1kNNrd6MjOBSu5wwehNqK2PyzNi+Pb +1anlA0z8+TAzpJEdWXXFq23pRIKHB1qGOwJAGwgrsDFiJ0qqJKMAXvPFKAhddBF9 +U3bwfy49zVTJnUgowqXogTY/4vL2p7lO4u7JH9CZcDV/wNeaGUpKHybfFQJABiZ7 +thcs74z6q3CboW2JEtfSYELjlvsiR0yK5PXGRe4MmrQh/o9fRx5/HnPwVSrkXM3Q +zuJv3xJ7oA46ZcKn4wJBAJSW83MuyQgc6aElvtXkzzMSTt1+W+2FBvI7aMi1lOdP +5XHL+BGBHBRlikmoPh4BPBx1zK/i+uacA7ihYcahO3s= +-----END RSA PRIVATE KEY----- diff --git a/SLRemotingTests/server/simple-class.js b/SLRemotingTests/server/simple-class.js new file mode 100644 index 0000000..ea4bd00 --- /dev/null +++ b/SLRemotingTests/server/simple-class.js @@ -0,0 +1,48 @@ +/** + * A simple class that contains a name. + */ +function SimpleClass(name) { + this.name = name; +} + +/** + * In order to expose SimpleClass, we need a "shared constructor". + */ +SimpleClass.sharedCtor = function (name, callback) { + callback(null, new SimpleClass(name)); +}; +SimpleClass.shared = true; +SimpleClass.sharedCtor.accepts = [{ arg: 'name', type: 'string' }]; +SimpleClass.sharedCtor.returns = { type: 'object', root: true }; + +/** + * Returns the SimpleClass instance's name. + */ +SimpleClass.prototype.getName = function(callback) { + callback(null, this.name); +}; +SimpleClass.prototype.getName.shared = true; +SimpleClass.prototype.getName.accepts = []; +SimpleClass.prototype.getName.returns = [{ arg: 'data', type: 'string' }]; + +/** + * Takes in a name, returning a greeting for that name. + */ +SimpleClass.prototype.greet = function(other, callback) { + callback(null, 'Hi, ' + other + '!'); +}; +SimpleClass.prototype.greet.shared = true; +SimpleClass.prototype.greet.accepts = [{ arg: 'other', type: 'string' }]; +SimpleClass.prototype.greet.returns = [{ arg: 'data', type: 'string' }]; + +/** + * Returns the SimpleClass prototype's favorite person's name. + */ +SimpleClass.getFavoritePerson = function(callback) { + callback(null, 'You'); +}; +SimpleClass.getFavoritePerson.shared = true; +SimpleClass.getFavoritePerson.accepts = []; +SimpleClass.getFavoritePerson.returns = [{ arg: 'data', type: 'string' }]; + +module.exports = SimpleClass; diff --git a/SLRemotingTests/server/simple.js b/SLRemotingTests/server/simple.js new file mode 100644 index 0000000..10d3f44 --- /dev/null +++ b/SLRemotingTests/server/simple.js @@ -0,0 +1,24 @@ +/** + * Returns a secret message. + */ +function getSecret(callback) { + callback(null, 'shhh!'); +} +getSecret.shared = true; +getSecret.accepts = []; +getSecret.returns = [{ arg: 'data', type: 'string' }]; + +/** + * Takes a string and returns an updated string. + */ +function transform(str, callback) { + callback(null, 'transformed: ' + str); +} +transform.shared = true; +transform.accepts = [{ arg: 'str', type: 'string' }]; +transform.returns = [{ arg: 'data', type: 'string' }]; + +module.exports = { + getSecret: getSecret, + transform: transform +}; diff --git a/SLRemotingTests/server/ssl-config.js b/SLRemotingTests/server/ssl-config.js new file mode 100644 index 0000000..d186a86 --- /dev/null +++ b/SLRemotingTests/server/ssl-config.js @@ -0,0 +1,6 @@ +var path = require('path'), + fs = require("fs"); + +exports.privateKey = fs.readFileSync(path.join(__dirname, './private/privatekey.pem')).toString(); +exports.certificate = fs.readFileSync(path.join(__dirname, './private/certificate.pem')).toString(); + diff --git a/docs/html/_l_b_access_token_8h.html b/docs/html/_l_b_access_token_8h.html new file mode 100644 index 0000000..e349c8b --- /dev/null +++ b/docs/html/_l_b_access_token_8h.html @@ -0,0 +1,113 @@ + + + + + + +LoopBack iOS SDK: LoopBack/LBAccessToken.h File Reference + + + + + + + + + +
+
+ + + + + + +
+
LoopBack iOS SDK +
+
+
+ + + + + + + + + +
+ +
+ + +
+
+ +
+
LBAccessToken.h File Reference
+
+
+
#import "LBModel.h"
+
+

Go to the source code of this file.

+ + + + + +

+Data Structures

class  LBAccessToken
 An access token returned from the server for access control. More...
 
+

Detailed Description

+
Author
Stephen Hess
+ +
+ + + + diff --git a/docs/html/_l_b_access_token_8h_source.html b/docs/html/_l_b_access_token_8h_source.html new file mode 100644 index 0000000..5f41304 --- /dev/null +++ b/docs/html/_l_b_access_token_8h_source.html @@ -0,0 +1,117 @@ + + + + + + +LoopBack iOS SDK: LoopBack/LBAccessToken.h Source File + + + + + + + + + +
+
+ + + + + + +
+
LoopBack iOS SDK +
+
+
+ + + + + + + + + +
+ +
+ + +
+
+
+
LBAccessToken.h
+
+
+Go to the documentation of this file.
1 
+
8 #import "LBModel.h"
+
9 
+
13 @interface LBAccessToken : LBModel
+
14 
+
16 @property (nonatomic, copy) NSString *userId;
+
17 
+
18 @end
+
19 
+
23 @interface LBAccessTokenRepository : LBModelRepository
+
24 
+
25 + (instancetype)repository;
+
26 
+
27 @end
+
NSString * userId
The user id associated with this access token.
Definition: LBAccessToken.h:16
+
An access token returned from the server for access control.
Definition: LBAccessToken.h:13
+ +
A local representative of a single model instance on the server.
Definition: LBModel.h:15
+
A local representative of a single model type on the server, encapsulating the name of the model type...
Definition: LBModel.h:98
+
+ + + + diff --git a/docs/html/_l_b_container_8h.html b/docs/html/_l_b_container_8h.html new file mode 100644 index 0000000..44a9d9a --- /dev/null +++ b/docs/html/_l_b_container_8h.html @@ -0,0 +1,114 @@ + + + + + + +LoopBack iOS SDK: LoopBack/LBContainer.h File Reference + + + + + + + + + +
+
+ + + + + + +
+
LoopBack iOS SDK +
+
+
+ + + + + + + + + +
+ +
+ + +
+
+ +
+
LBContainer.h File Reference
+
+
+
#import "LBModel.h"
+#import "LBFile.h"
+
+

Go to the source code of this file.

+ + + + + +

+Data Structures

class  LBContainer
 A local representative of a container instance on the server. More...
 
+

Detailed Description

+
Author
Stephen Hess
+ +
+ + + + diff --git a/docs/html/_l_b_container_8h_source.html b/docs/html/_l_b_container_8h_source.html new file mode 100644 index 0000000..8f5db2c --- /dev/null +++ b/docs/html/_l_b_container_8h_source.html @@ -0,0 +1,143 @@ + + + + + + +LoopBack iOS SDK: LoopBack/LBContainer.h Source File + + + + + + + + + +
+
+ + + + + + +
+
LoopBack iOS SDK +
+
+
+ + + + + + + + + +
+ +
+ + +
+
+
+
LBContainer.h
+
+
+Go to the documentation of this file.
1 
+
8 #import "LBModel.h"
+
9 #import "LBFile.h"
+
10 
+
11 @class LBFileRepository;
+
12 
+
16 @interface LBContainer : LBModel
+
17 
+
18 @property (nonatomic, copy) NSString *name;
+
19 
+ +
31 - (void)deleteWithSuccess:(LBContainerDeleteSuccessBlock)success
+
32  failure:(SLFailureBlock)failure;
+
33 
+
42 - (void)getFileWithName:(NSString*)name
+
43  localPath:(NSString*)localPath
+
44  success:(LBFileGetSuccessBlock)success
+
45  failure:(SLFailureBlock)failure;
+
46 
+
47 @end
+
48 
+
52 @interface LBContainerRepository : LBModelRepository
+
53 
+
55 @property (nonatomic, readonly, strong) LBFileRepository *fileRepository;
+
56 
+
57 + (instancetype)repository;
+
58 
+
64 - (LBContainer *)createContainerWithName:(NSString*)name;
+
65 
+
70 typedef void (^LBGetContainerSuccessBlock)(LBContainer* container);
+
78 - (void)getContainerWithName:(NSString*)name
+
79  success:(LBGetContainerSuccessBlock)success
+
80  failure:(SLFailureBlock)failure;
+
81 
+
86 typedef void (^LBGetAllContainersSuccessBlock)(NSArray* containers);
+
93 - (void)getAllContainersWithSuccess:(LBGetAllContainersSuccessBlock)success
+
94  failure:(SLFailureBlock)failure;
+
95 
+
96 @end
+
void(^ LBContainerDeleteSuccessBlock)()
Blocks of this type are executed when LBContainer:uploadWithSuccess:failure: is successful.
Definition: LBContainer.h:24
+
A local representative of a container instance on the server.
Definition: LBContainer.h:16
+ +
A local representative of a single model instance on the server.
Definition: LBModel.h:15
+
A local representative of a single model type on the server, encapsulating the name of the model type...
Definition: LBModel.h:98
+ +
+ + + + diff --git a/docs/html/_l_b_file_8h.html b/docs/html/_l_b_file_8h.html new file mode 100644 index 0000000..ce77ce3 --- /dev/null +++ b/docs/html/_l_b_file_8h.html @@ -0,0 +1,113 @@ + + + + + + +LoopBack iOS SDK: LoopBack/LBFile.h File Reference + + + + + + + + + +
+
+ + + + + + +
+
LoopBack iOS SDK +
+
+
+ + + + + + + + + +
+ +
+ + +
+
+ +
+
LBFile.h File Reference
+
+
+
#import "LBModel.h"
+
+

Go to the source code of this file.

+ + + + + +

+Data Structures

class  LBFile
 A local representative of a file instance on the server. More...
 
+

Detailed Description

+
Author
Stephen Hess
+ +
+ + + + diff --git a/docs/html/_l_b_file_8h_source.html b/docs/html/_l_b_file_8h_source.html new file mode 100644 index 0000000..4ad392e --- /dev/null +++ b/docs/html/_l_b_file_8h_source.html @@ -0,0 +1,139 @@ + + + + + + +LoopBack iOS SDK: LoopBack/LBFile.h Source File + + + + + + + + + +
+
+ + + + + + +
+
LoopBack iOS SDK +
+
+
+ + + + + + + + + +
+ +
+ + +
+
+
+
LBFile.h
+
+
+Go to the documentation of this file.
1 
+
8 #import "LBModel.h"
+
9 
+
13 @interface LBFile : LBModel
+
14 
+
15 @property (nonatomic, copy) NSString *name;
+
16 @property (nonatomic, copy) NSString *localPath;
+
17 
+
18 @property (nonatomic, copy) NSString *container;
+
19 
+
24 typedef void (^LBFileUploadSuccessBlock)();
+
31 - (void)uploadWithSuccess:(LBFileUploadSuccessBlock)success
+
32  failure:(SLFailureBlock)failure;
+
33 
+
38 typedef void (^LBFileDownloadSuccessBlock)();
+
45 - (void)downloadWithSuccess:(LBFileDownloadSuccessBlock)success
+
46  failure:(SLFailureBlock)failure;
+
47 
+
48 @end
+
49 
+
53 @interface LBFileRepository : LBModelRepository
+
54 
+
55 + (instancetype)repository;
+
56 
+
64 - (LBFile *)createFileWithName:(NSString*)name
+
65  localPath:(NSString*)localPath
+
66  container:(NSString*)container;
+
67 
+
72 typedef void (^LBFileGetSuccessBlock)(LBFile* file);
+
82 - (void)getFileWithName:(NSString*)name
+
83  localPath:(NSString*)localPath
+
84  container:(NSString*)container
+
85  success:(LBFileGetSuccessBlock)success
+
86  failure:(SLFailureBlock)failure;
+
87 @end
+
void(^ LBFileUploadSuccessBlock)()
Blocks of this type are executed when LBFile:uploadWithSuccess:failure: is successful.
Definition: LBFile.h:24
+
A local representative of a file instance on the server.
Definition: LBFile.h:13
+ +
A local representative of a single model instance on the server.
Definition: LBModel.h:15
+
A local representative of a single model type on the server, encapsulating the name of the model type...
Definition: LBModel.h:98
+
void(^ LBFileDownloadSuccessBlock)()
Blocks of this type are executed when LBFile:downloadWithSuccess:failure: is successful.
Definition: LBFile.h:38
+
+ + + + diff --git a/docs/html/_l_b_installation_8h.html b/docs/html/_l_b_installation_8h.html index d322207..b0683d6 100644 --- a/docs/html/_l_b_installation_8h.html +++ b/docs/html/_l_b_installation_8h.html @@ -68,7 +68,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
@@ -108,7 +108,7 @@
diff --git a/docs/html/_l_b_installation_8h_source.html b/docs/html/_l_b_installation_8h_source.html index 6ed7e8d..3d99a59 100644 --- a/docs/html/_l_b_installation_8h_source.html +++ b/docs/html/_l_b_installation_8h_source.html @@ -68,7 +68,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
@@ -126,14 +126,14 @@
93  userId: (NSString *) userId
94  badge: (NSNumber *) badge
95  subscriptions: (NSArray *) subscriptions
-
96  success: (SLSuccessBlock) success
-
97  failure: (SLFailureBlock) failure;
+
96  success: (SLSuccessBlock) success
+
97  failure: (SLFailureBlock) failure;
98 
99 @end
100 
105 
-
109 + (instancetype)repository;
+
109 + (instancetype)repository;
110 
111 @end
112 
@@ -142,24 +142,22 @@
An extension to the vanilla SLRESTAdapter to make working with LBModels easier.
Definition: LBRESTAdapter.h:16
NSString * appId
The app id received from LoopBack application signup.
Definition: LBInstallation.h:25
NSArray * subscriptions
An array of topic names that the device subscribes to.
Definition: LBInstallation.h:55
+
instancetype repository()
Get a singleton for LBInstallationRepository.
A local representative of a single model instance on the server.
Definition: LBModel.h:15
-
SLRepository * repository
The SLRepository defining the type of this object.
Definition: SLObject.h:28
NSString * timeZone
The time zone for the server side to decide a good time for push.
Definition: LBInstallation.h:60
NSString * userId
The id for the signed in user for the installation.
Definition: LBInstallation.h:35
NSNumber * badge
The current badge.
Definition: LBInstallation.h:50
A local representative of a single model type on the server, encapsulating the name of the model type...
Definition: LBModel.h:98
Custom ModelRepository subclass for LBInstallation.
Definition: LBInstallation.h:104
-
void(^ SLSuccessBlock)(id value)
Blocks of this type are executed for any successful method invocation, i.e.
Definition: SLAdapter.h:27
NSString * deviceToken
The device token in hex string format.
Definition: LBInstallation.h:45
NSString * status
Status of the installation.
Definition: LBInstallation.h:65
-
void(^ SLFailureBlock)(NSError *error)
Blocks of this type are executed for any failed method invocation, i.e.
Definition: SLAdapter.h:46
LBInstallation represents the installation of a given app on the device.
Definition: LBInstallation.h:19
NSString * appVersion
The application version, default to "1.0.0".
Definition: LBInstallation.h:30
diff --git a/docs/html/_l_b_model_8h.html b/docs/html/_l_b_model_8h.html index 56fd7bd..3b11907 100644 --- a/docs/html/_l_b_model_8h.html +++ b/docs/html/_l_b_model_8h.html @@ -68,7 +68,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
@@ -108,7 +108,7 @@
diff --git a/docs/html/_l_b_model_8h_source.html b/docs/html/_l_b_model_8h_source.html index 26eaf85..eaa333d 100644 --- a/docs/html/_l_b_model_8h_source.html +++ b/docs/html/_l_b_model_8h_source.html @@ -68,7 +68,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
@@ -90,7 +90,7 @@ Go to the documentation of this file.
1 
8 #import <LoopBack/SLRemoting.h>
9 
-
15 @interface LBModel : SLObject
+
15 @interface LBModel : SLObject
16 
18 @property (nonatomic, readonly, copy) id _id;
19 
@@ -102,19 +102,19 @@
60 
65 typedef void (^LBModelSaveSuccessBlock)();
74 - (void)saveWithSuccess:(LBModelSaveSuccessBlock)success
-
75  failure:(SLFailureBlock)failure;
+
75  failure:(SLFailureBlock)failure;
76 
81 typedef void (^LBModelDestroySuccessBlock)();
88 - (void)destroyWithSuccess:(LBModelDestroySuccessBlock)success
-
89  failure:(SLFailureBlock)failure;
+
89  failure:(SLFailureBlock)failure;
90 
91 @end
92 
- +
98 @interface LBModelRepository : SLRepository
99 
101 @property Class modelClass;
102 
-
109 - (SLRESTContract *)contract;
+
109 - (SLRESTContract *)contract;
110 
117 - (LBModel *)modelWithDictionary:(NSDictionary *)dictionary;
118 
@@ -126,11 +126,11 @@
128 typedef void (^LBModelFindSuccessBlock)(LBModel *model);
137 - (void)findById:(id)_id
138  success:(LBModelFindSuccessBlock)success
-
139  failure:(SLFailureBlock)failure;
+
139  failure:(SLFailureBlock)failure;
140 
145 typedef void (^LBModelAllSuccessBlock)(NSArray *models);
152 - (void)allWithSuccess:(LBModelAllSuccessBlock)success
-
153  failure:(SLFailureBlock)failure;
+
153  failure:(SLFailureBlock)failure;
154 
155 //typedef void (^LBModelFindOneSuccessBlock)(LBModel *model);
156 //- (void)findOneWithFilter:(NSDictionary *)filter
@@ -138,21 +138,17 @@
158 // failure:(SLFailureBlock)failure;
159 
160 @end
-
A local representative of a single virtual object.
Definition: SLObject.h:25
void(^ LBModelSaveSuccessBlock)()
Blocks of this type are executed when saveWithSuccess:failure: is successful.
Definition: LBModel.h:65
void(^ LBModelDestroySuccessBlock)()
Blocks of this type are executed when destroyWithSuccess:failure: is successful.
Definition: LBModel.h:81
id _id
All Models have a numerical id field.
Definition: LBModel.h:18
Class modelClass
The LBModel subclass used to wrap model instances.
Definition: LBModel.h:101
A local representative of a single model instance on the server.
Definition: LBModel.h:15
A local representative of a single model type on the server, encapsulating the name of the model type...
Definition: LBModel.h:98
-
A contract specifies how remote method names map to HTTP routes.
Definition: SLRESTContract.h:84
NSDictionary * toDictionary()
Converts the LBModel (and all of its @properties) into an NSDictionary.
-
A local representative of classes (&quot;prototypes&quot; in JavaScript) defined and made remotable on the serv...
Definition: SLObject.h:81
-
void(^ SLFailureBlock)(NSError *error)
Blocks of this type are executed for any failed method invocation, i.e.
Definition: SLAdapter.h:46
diff --git a/docs/html/_l_b_push_notification_8h.html b/docs/html/_l_b_push_notification_8h.html index 1a6b35b..c43f63c 100644 --- a/docs/html/_l_b_push_notification_8h.html +++ b/docs/html/_l_b_push_notification_8h.html @@ -68,7 +68,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
@@ -165,7 +165,7 @@

Enumeration Type Documentation

diff --git a/docs/html/_l_b_push_notification_8h_source.html b/docs/html/_l_b_push_notification_8h_source.html index faee4ee..a13f8d4 100644 --- a/docs/html/_l_b_push_notification_8h_source.html +++ b/docs/html/_l_b_push_notification_8h_source.html @@ -68,7 +68,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
@@ -114,7 +114,7 @@
61 
72 + (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
73  adapter:(LBRESTAdapter *)adapter userId:(NSString *)userId subscriptions:(NSArray *)subscriptions
-
74  success:(SLSuccessBlock)success failure:(SLFailureBlock)failure;
+
74  success:(SLSuccessBlock)success failure:(SLFailureBlock)failure;
75 
79 + (void)application:(UIApplication*)application didFailToRegisterForRemoteNotificationsWithError:(NSError*)error;
80 
@@ -131,16 +131,14 @@
Wrapper class to handle received push notifications (Provide helper methods for iOS clients to handle...
Definition: LBPushNotification.h:33
NSDictionary * userInfo
The notification payload.
Definition: LBPushNotification.h:43
App was on Background.
Definition: LBPushNotification.h:24
-
void(^ SLSuccessBlock)(id value)
Blocks of this type are executed for any successful method invocation, i.e.
Definition: SLAdapter.h:27
App was terminated and launched again through Push notification.
Definition: LBPushNotification.h:26
-
void(^ SLFailureBlock)(NSError *error)
Blocks of this type are executed for any failed method invocation, i.e.
Definition: SLAdapter.h:46
LBPushNotificationType type
The notification type.
Definition: LBPushNotification.h:38
LBPushNotificationType
Push Notification Type: Indicates in what state was app when received it (Foreground, Background, Terminated)
Definition: LBPushNotification.h:20
diff --git a/docs/html/_l_b_r_e_s_t_adapter_8h.html b/docs/html/_l_b_r_e_s_t_adapter_8h.html index 0038133..21917e2 100644 --- a/docs/html/_l_b_r_e_s_t_adapter_8h.html +++ b/docs/html/_l_b_r_e_s_t_adapter_8h.html @@ -68,7 +68,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
@@ -97,7 +97,7 @@

Data Structures

class  LBRESTAdapter - An extension to the vanilla SLRESTAdapter to make working with LBModels easier. More...
+ An extension to the vanilla SLRESTAdapter to make working with LBModels easier. More...
 

Detailed Description

@@ -106,7 +106,7 @@
diff --git a/docs/html/_l_b_r_e_s_t_adapter_8h_source.html b/docs/html/_l_b_r_e_s_t_adapter_8h_source.html index d35f739..a795543 100644 --- a/docs/html/_l_b_r_e_s_t_adapter_8h_source.html +++ b/docs/html/_l_b_r_e_s_t_adapter_8h_source.html @@ -68,7 +68,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
@@ -92,7 +92,7 @@
9 
10 #import "LBModel.h"
11 
- +
16 @interface LBRESTAdapter : SLRESTAdapter
17 
24 - (LBModelRepository *)repositoryWithModelName:(NSString *)name;
25 
@@ -100,13 +100,12 @@
33 
34 @end
An extension to the vanilla SLRESTAdapter to make working with LBModels easier.
Definition: LBRESTAdapter.h:16
-
A specific SLAdapter implementation for RESTful servers.
Definition: SLRESTAdapter.h:22
A local representative of a single model type on the server, encapsulating the name of the model type...
Definition: LBModel.h:98
diff --git a/docs/html/_l_b_user_8h.html b/docs/html/_l_b_user_8h.html new file mode 100644 index 0000000..058def3 --- /dev/null +++ b/docs/html/_l_b_user_8h.html @@ -0,0 +1,113 @@ + + + + + + +LoopBack iOS SDK: LoopBack/LBUser.h File Reference + + + + + + + + + +
+
+ + + + + + +
+
LoopBack iOS SDK +
+
+
+ + + + + + + + + +
+ +
+ + +
+
+ +
+
LBUser.h File Reference
+
+
+
#import "LBModel.h"
+
+

Go to the source code of this file.

+ + + + + +

+Data Structures

class  LBUser
 A local representative of a user instance on the server. More...
 
+

Detailed Description

+
Author
Stephen Hess
+ +
+ + + + diff --git a/docs/html/_l_b_user_8h_source.html b/docs/html/_l_b_user_8h_source.html new file mode 100644 index 0000000..06f86a8 --- /dev/null +++ b/docs/html/_l_b_user_8h_source.html @@ -0,0 +1,146 @@ + + + + + + +LoopBack iOS SDK: LoopBack/LBUser.h Source File + + + + + + + + + +
+
+ + + + + + +
+
LoopBack iOS SDK +
+
+
+ + + + + + + + + +
+ +
+ + +
+
+
+
LBUser.h
+
+
+Go to the documentation of this file.
1 
+
8 #import "LBModel.h"
+
9 
+
10 @class LBAccessToken;
+
11 
+
15 @interface LBUser : LBModel
+
16 
+
17 @property (nonatomic, copy) NSString *email;
+
18 @property (nonatomic, copy) NSString *password;
+
19 
+
20 @property (nonatomic, copy) NSString *realm;
+
21 @property (nonatomic, strong) NSNumber *emailVerified;
+
22 @property (nonatomic, copy) NSString *status;
+
23 
+
24 @end
+
25 
+
30 @interface LBUserRepository : LBModelRepository
+
31 
+
32 + (instancetype)repository;
+
33 
+
41 - (LBUser *)createUserWithEmail:(NSString*)email
+
42  password:(NSString*)password
+
43  dictionary:(NSDictionary *)dictionary;
+
44 
+
51 - (LBUser *)createUserWithEmail:(NSString*)email
+
52  password:(NSString*)password;
+
53 
+
58 typedef void (^LBUserLoginSuccessBlock)(LBAccessToken* token);
+
68 - (void)loginWithEmail:(NSString*)email
+
69  password:(NSString*)password
+
70  success:(LBUserLoginSuccessBlock)success
+
71  failure:(SLFailureBlock)failure;
+
72 
+
77 typedef void (^LBUserLoginFindUserSuccessBlock)(LBUser *user);
+
86 - (void)userByLoginWithEmail:(NSString*)email
+
87  password:(NSString*)password
+
88  success:(LBUserLoginFindUserSuccessBlock)success
+
89  failure:(SLFailureBlock)failure;
+
90 
+
95 typedef void (^LBUserLogoutSuccessBlock)();
+
102 - (void)logoutWithSuccess:(LBUserLogoutSuccessBlock)success
+
103  failure:(SLFailureBlock)failure;
+
104 @end
+
An access token returned from the server for access control.
Definition: LBAccessToken.h:13
+ +
A local representative of a single model instance on the server.
Definition: LBModel.h:15
+
A local representative of a single model type on the server, encapsulating the name of the model type...
Definition: LBModel.h:98
+
A local representative of a user instance on the server.
Definition: LBUser.h:15
+
+ + + + diff --git a/docs/html/_loop_back_8h.html b/docs/html/_loop_back_8h.html index 3d9dfd2..118ea95 100644 --- a/docs/html/_loop_back_8h.html +++ b/docs/html/_loop_back_8h.html @@ -68,7 +68,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
@@ -91,6 +91,9 @@ #import "LBRESTAdapter.h"
#import "LBInstallation.h"
#import "LBPushNotification.h"
+#import "LBUser.h"
+#import "LBFile.h"
+#import "LBContainer.h"

Go to the source code of this file.

Detailed Description

@@ -99,7 +102,7 @@ diff --git a/docs/html/_loop_back_8h_source.html b/docs/html/_loop_back_8h_source.html index f7784fd..640368c 100644 --- a/docs/html/_loop_back_8h_source.html +++ b/docs/html/_loop_back_8h_source.html @@ -68,7 +68,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
@@ -92,15 +92,20 @@
9 #import "LBRESTAdapter.h"
10 #import "LBInstallation.h"
11 #import "LBPushNotification.h"
-
12 
+
12 #import "LBUser.h"
+
13 #import "LBFile.h"
+
14 #import "LBContainer.h"
+ + +
diff --git a/docs/html/annotated.html b/docs/html/annotated.html index 2f24f14..70a27e0 100644 --- a/docs/html/annotated.html +++ b/docs/html/annotated.html @@ -71,7 +71,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
@@ -87,25 +87,22 @@
Here are the data structures with brief descriptions:
- - - - - - - - - - - - - + + + + + + + + + +
oCLBInstallationLBInstallation represents the installation of a given app on the device
oCLBInstallationRepositoryCustom ModelRepository subclass for LBInstallation
oCLBModelA local representative of a single model instance on the server
oCLBModelRepositoryA local representative of a single model type on the server, encapsulating the name of the model type for easy LBModel creation, discovery, and management
oCLBPushNotificationWrapper class to handle received push notifications (Provide helper methods for iOS clients to handle push notifications)
oCLBRESTAdapterAn extension to the vanilla SLRESTAdapter to make working with LBModels easier
oCSLAdapterThe entry point to all networking accomplished with LoopBack
oCSLObjectA local representative of a single virtual object
oCSLRemotingUtilsA container for helper methods
oCSLRepositoryA local representative of classes ("prototypes" in JavaScript) defined and made remotable on the server
oCSLRESTAdapterA specific SLAdapter implementation for RESTful servers
oCSLRESTContractA contract specifies how remote method names map to HTTP routes
\CSLRESTContractItemA single item within a larger SLRESTContract, encapsulation a single route's verb and pattern, e.g
oCLBAccessTokenAn access token returned from the server for access control
oCLBContainerA local representative of a container instance on the server
oCLBFileA local representative of a file instance on the server
oCLBInstallationLBInstallation represents the installation of a given app on the device
oCLBInstallationRepositoryCustom ModelRepository subclass for LBInstallation
oCLBModelA local representative of a single model instance on the server
oCLBModelRepositoryA local representative of a single model type on the server, encapsulating the name of the model type for easy LBModel creation, discovery, and management
oCLBPushNotificationWrapper class to handle received push notifications (Provide helper methods for iOS clients to handle push notifications)
oCLBRESTAdapterAn extension to the vanilla SLRESTAdapter to make working with LBModels easier
\CLBUserA local representative of a user instance on the server
diff --git a/docs/html/classes.html b/docs/html/classes.html index 3ec183c..b9ac0f7 100644 --- a/docs/html/classes.html +++ b/docs/html/classes.html @@ -71,7 +71,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
+ All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
@@ -85,21 +85,19 @@
Data Structure Index
diff --git a/docs/html/dir_34f523d15f3e31a8b8d1fd09f77896dc.html b/docs/html/dir_34f523d15f3e31a8b8d1fd09f77896dc.html index 16e0a2f..74c0f93 100644 --- a/docs/html/dir_34f523d15f3e31a8b8d1fd09f77896dc.html +++ b/docs/html/dir_34f523d15f3e31a8b8d1fd09f77896dc.html @@ -62,7 +62,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
@@ -84,6 +84,12 @@ + + + + + + @@ -92,13 +98,15 @@ + +

Files

file  LBAccessToken.h [code]
 
file  LBContainer.h [code]
 
file  LBFile.h [code]
 
file  LBInstallation.h [code]
 
file  LBModel.h [code]
 
file  LBRESTAdapter.h [code]
 
file  LBUser.h [code]
 
file  LoopBack.h [code]
 
diff --git a/docs/html/files.html b/docs/html/files.html index 83e8087..3378f04 100644 --- a/docs/html/files.html +++ b/docs/html/files.html @@ -69,7 +69,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
@@ -84,28 +84,23 @@
diff --git a/docs/html/functions.html b/docs/html/functions.html index 6240b58..a1c3417 100644 --- a/docs/html/functions.html +++ b/docs/html/functions.html @@ -82,16 +82,13 @@
  • d
  • f
  • g
  • -
  • i
  • l
  • m
  • o
  • -
  • p
  • r
  • s
  • t
  • -
  • u
  • -
  • v
  • +
  • u
  • @@ -100,7 +97,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
    @@ -120,19 +117,6 @@

    - _ -

    diff --git a/docs/html/functions_func.html b/docs/html/functions_func.html index 954332a..a40ca5a 100644 --- a/docs/html/functions_func.html +++ b/docs/html/functions_func.html @@ -73,31 +73,13 @@
  • Properties
  • - + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
    @@ -107,21 +89,7 @@
    -  - -

    - a -

    diff --git a/docs/html/functions_prop.html b/docs/html/functions_prop.html index b708236..351ebb7 100644 --- a/docs/html/functions_prop.html +++ b/docs/html/functions_prop.html @@ -79,7 +79,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
    @@ -93,9 +93,6 @@
  • _id : LBModel
  • -
  • adapter -: SLRepository -
  • appId : LBInstallation
  • @@ -105,36 +102,15 @@
  • badge : LBInstallation
  • -
  • className -: SLRepository -
  • -
  • connected -: SLAdapter -
  • -
  • contract -: SLRESTAdapter -
  • -
  • creationParameters -: SLObject -
  • deviceToken : LBInstallation
  • deviceType : LBInstallation
  • -
  • dict -: SLRESTContract -
  • modelClass : LBModelRepository
  • -
  • pattern -: SLRESTContractItem -
  • -
  • repository -: SLObject -
  • status : LBInstallation
  • @@ -148,19 +124,17 @@ : LBPushNotification
  • userId -: LBInstallation +: LBAccessToken +, LBInstallation
  • userInfo : LBPushNotification
  • -
  • verb -: SLRESTContractItem -
  • diff --git a/docs/html/functions_type.html b/docs/html/functions_type.html index 9a8ea58..93566ef 100644 --- a/docs/html/functions_type.html +++ b/docs/html/functions_type.html @@ -79,7 +79,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
    @@ -90,6 +90,15 @@
     
    diff --git a/docs/html/globals.html b/docs/html/globals.html index 6115eb9..c0be60e 100644 --- a/docs/html/globals.html +++ b/docs/html/globals.html @@ -66,11 +66,9 @@
    @@ -79,7 +77,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
    @@ -90,18 +88,6 @@
    Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation:
    diff --git a/docs/html/globals_enum.html b/docs/html/globals_enum.html index 39eaac4..4c7e9c8 100644 --- a/docs/html/globals_enum.html +++ b/docs/html/globals_enum.html @@ -66,11 +66,9 @@
    @@ -79,7 +77,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
    @@ -97,7 +95,7 @@
    diff --git a/docs/html/globals_eval.html b/docs/html/globals_eval.html index 5a3ed96..1b30bcc 100644 --- a/docs/html/globals_eval.html +++ b/docs/html/globals_eval.html @@ -66,11 +66,9 @@ @@ -79,7 +77,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
    @@ -103,7 +101,7 @@
    diff --git a/docs/html/globals_type.html b/docs/html/globals_type.html index 696d9ff..4050314 100644 --- a/docs/html/globals_type.html +++ b/docs/html/globals_type.html @@ -66,11 +66,9 @@ @@ -79,7 +77,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
    @@ -93,17 +91,11 @@
  • LBPushNotificationType : LBPushNotification.h
  • -
  • SLFailureBlock -: SLAdapter.h -
  • -
  • SLSuccessBlock -: SLAdapter.h -
  • diff --git a/docs/html/hierarchy.html b/docs/html/hierarchy.html index 8b2e285..0cffef4 100644 --- a/docs/html/hierarchy.html +++ b/docs/html/hierarchy.html @@ -71,7 +71,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
    @@ -86,27 +86,27 @@
    This inheritance list is sorted roughly, but not completely, alphabetically:
    -
    [detail level 1234]
    - - - - - - - - - - - - - - +
    [detail level 123]
    \CNSObject
     oCLBPushNotificationWrapper class to handle received push notifications (Provide helper methods for iOS clients to handle push notifications)
     oCSLAdapterThe entry point to all networking accomplished with LoopBack
     |\CSLRESTAdapterA specific SLAdapter implementation for RESTful servers
     | \CLBRESTAdapterAn extension to the vanilla SLRESTAdapter to make working with LBModels easier
     oCSLObjectA local representative of a single virtual object
     |\CLBModelA local representative of a single model instance on the server
     | \CLBInstallationLBInstallation represents the installation of a given app on the device
     oCSLRemotingUtilsA container for helper methods
     oCSLRepositoryA local representative of classes ("prototypes" in JavaScript) defined and made remotable on the server
     |\CLBModelRepositoryA local representative of a single model type on the server, encapsulating the name of the model type for easy LBModel creation, discovery, and management
     | \CLBInstallationRepositoryCustom ModelRepository subclass for LBInstallation
     oCSLRESTContractA contract specifies how remote method names map to HTTP routes
     \CSLRESTContractItemA single item within a larger SLRESTContract, encapsulation a single route's verb and pattern, e.g
    + + + + + + + + + + + + + +
    oCNSObject
    |\CLBPushNotificationWrapper class to handle received push notifications (Provide helper methods for iOS clients to handle push notifications)
    oCSLObject
    |\CLBModelA local representative of a single model instance on the server
    | oCLBAccessTokenAn access token returned from the server for access control
    | oCLBContainerA local representative of a container instance on the server
    | oCLBFileA local representative of a file instance on the server
    | oCLBInstallationLBInstallation represents the installation of a given app on the device
    | \CLBUserA local representative of a user instance on the server
    oCSLRepository
    |\CLBModelRepositoryA local representative of a single model type on the server, encapsulating the name of the model type for easy LBModel creation, discovery, and management
    | \CLBInstallationRepositoryCustom ModelRepository subclass for LBInstallation
    \CSLRESTAdapter
     \CLBRESTAdapterAn extension to the vanilla SLRESTAdapter to make working with LBModels easier
    diff --git a/docs/html/index.html b/docs/html/index.html index fabb450..2f46445 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -63,7 +63,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
    @@ -80,7 +80,7 @@
    diff --git a/docs/html/interface_l_b_access_token.html b/docs/html/interface_l_b_access_token.html new file mode 100644 index 0000000..214be30 --- /dev/null +++ b/docs/html/interface_l_b_access_token.html @@ -0,0 +1,179 @@ + + + + + + +LoopBack iOS SDK: LBAccessToken Class Reference + + + + + + + + + +
    +
    + + + + + + +
    +
    LoopBack iOS SDK +
    +
    +
    + + + + + + + + + +
    + +
    + +
    +
    + +
    +
    LBAccessToken Class Reference
    +
    +
    + +

    An access token returned from the server for access control. + More...

    + +

    #import <LBAccessToken.h>

    +
    +Inheritance diagram for LBAccessToken:
    +
    +
    + + +LBModel + +
    + + + + + + + + + +

    +Properties

    NSString * userId
     The user id associated with this access token. More...
     
    - Properties inherited from LBModel
    id _id
     All Models have a numerical id field. More...
     
    + + + + + + + + + + + + + + + + + + + + + + + + +

    +Additional Inherited Members

    - Public Types inherited from LBModel
    +typedef void(^ LBModelSaveSuccessBlock )()
     Blocks of this type are executed when saveWithSuccess:failure: is successful.
     
    +typedef void(^ LBModelDestroySuccessBlock )()
     Blocks of this type are executed when destroyWithSuccess:failure: is successful.
     
    - Instance Methods inherited from LBModel
    (id) - objectForKeyedSubscript:
     Returns the value associated with a given key. More...
     
    (void) - setObject:forKeyedSubscript:
     Adds a given key-value pair to the dictionary. More...
     
    (NSDictionary *) - toDictionary
     Converts the LBModel (and all of its @properties) into an NSDictionary. More...
     
    (void) - saveWithSuccess:failure:
     Saves the LBModel to the server. More...
     
    (void) - destroyWithSuccess:failure:
     Destroys the LBModel from the server. More...
     
    +

    Detailed Description

    +

    An access token returned from the server for access control.

    +

    Property Documentation

    + +
    +
    + + + + + +
    + + + + +
    - (NSString*) userId
    +
    +readwritenonatomiccopy
    +
    + +

    The user id associated with this access token.

    + +
    +
    +
    The documentation for this class was generated from the following file: +
    + + + + diff --git a/docs/html/interface_l_b_access_token.png b/docs/html/interface_l_b_access_token.png new file mode 100644 index 0000000000000000000000000000000000000000..f60a7d5a97e6f4f6c7397e8afa5b022b534dfa10 GIT binary patch literal 633 zcmeAS@N?(olHy`uVBq!ia0vp^=|J4U!3-qN_Oi|aQW60^A+G=b{|7Q(y!l$%e`o@b z1;z&s9ANFdBM;V(_Mj~xj&zMKVbC9{=*EmU;kM{L#^#! za4NPuXWU@KP_kfhy2P&zt4cRt@j(6a=daGLX0SV8%TRWQIpH`O^;rFwgtdc+V5Q9W zj*c5Yh38E;^d)k(>bA9Siv?Hi%dfnYI&JEODD1=`tH5B>SIzLI zu!Hp9yG=HrP?*vTKkt)nqS^^|M|QvH_X;t_uW6ya*3Pgmn)Yya6jEGyZOv? z>7B=q{=70TSEKp**1Y9;;iYr^h2->;_vc5Szx0;Zf9Asn=f5tT^FDgFe13(`^Ud$~ zeq9n`etYY*zJ>Ruy}dnm{r`Q85rzB>bLGFZ2pszShxwUMQ0V%+o1DOO!r + + + + + +LoopBack iOS SDK: LBContainer Class Reference + + + + + + + + + +
    +
    + + + + + + +
    +
    LoopBack iOS SDK +
    +
    +
    + + + + + + + + + +
    + +
    + +
    +
    + +
    +
    LBContainer Class Reference
    +
    +
    + +

    A local representative of a container instance on the server. + More...

    + +

    #import <LBContainer.h>

    +
    +Inheritance diagram for LBContainer:
    +
    +
    + + +LBModel + +
    + + + + + + + + + + + + + + + + + + + + + + + + +

    +Instance Methods

    (void) - deleteWithSuccess:failure:
     Deletes the container on the server. More...
     
    (void) - getFileWithName:localPath:success:failure:
     Gets the file with the given name. More...
     
    - Instance Methods inherited from LBModel
    (id) - objectForKeyedSubscript:
     Returns the value associated with a given key. More...
     
    (void) - setObject:forKeyedSubscript:
     Adds a given key-value pair to the dictionary. More...
     
    (NSDictionary *) - toDictionary
     Converts the LBModel (and all of its @properties) into an NSDictionary. More...
     
    (void) - saveWithSuccess:failure:
     Saves the LBModel to the server. More...
     
    (void) - destroyWithSuccess:failure:
     Destroys the LBModel from the server. More...
     
    + + + + +

    +Protected Types

    +typedef void(^ LBContainerDeleteSuccessBlock )()
     Blocks of this type are executed when LBContainer:uploadWithSuccess:failure: is successful.
     
    + + + + + + + +

    +Properties

    +NSString * name
     
    - Properties inherited from LBModel
    id _id
     All Models have a numerical id field. More...
     
    + + + + + + + + +

    +Additional Inherited Members

    - Public Types inherited from LBModel
    +typedef void(^ LBModelSaveSuccessBlock )()
     Blocks of this type are executed when saveWithSuccess:failure: is successful.
     
    +typedef void(^ LBModelDestroySuccessBlock )()
     Blocks of this type are executed when destroyWithSuccess:failure: is successful.
     
    +

    Detailed Description

    +

    A local representative of a container instance on the server.

    +

    Method Documentation

    + +
    +
    + + + + + + + + + + + + + + + + + + +
    - (void) deleteWithSuccess: (LBContainerDeleteSuccessBlocksuccess
    failure:(SLFailureBlock) failure 
    +
    + +

    Deletes the container on the server.

    +
    Parameters
    + + + +
    successThe block to be executed when the delete is successful.
    failureThe block to be executed when the delete fails.
    +
    +
    + +
    +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    - (void) getFileWithName: (NSString *) name
    localPath:(NSString *) localPath
    success:(LBFileGetSuccessBlock) success
    failure:(SLFailureBlock) failure 
    +
    + +

    Gets the file with the given name.

    +
    Parameters
    + + + + + +
    nameThe file name.
    localPathThe local path to the file, without file name.
    successThe block to be executed when the get is successful.
    failureThe block to be executed when the get fails.
    +
    +
    + +
    +
    +
    The documentation for this class was generated from the following file: +
    + + + + diff --git a/docs/html/interface_l_b_container.png b/docs/html/interface_l_b_container.png new file mode 100644 index 0000000000000000000000000000000000000000..bc1e5b89c8f97065c63a1e704b62f77f15e392cd GIT binary patch literal 584 zcmeAS@N?(olHy`uVBq!ia0vp^Al$*h3?!YyeI5WQi2$Dv*Z=?j1DP-0d@b!iGy%v0 z;{yi{uy)>&2XZ+|g8YIRfQmri>ZuST1_s9Ko-U3d6^w7^zV2IXz{7UjP3isrW6LLS zf1k81e(Bo2aGsqx5^pS?nx~~jZI}`iBy?&@(4~S!bGpn-cNfmJSm&>~cKzZ_c5%;V zztfuQ_f&DkPg&hxQs1vk`RDsc{FF?UXTt3})6(}&f34v^CAM=tZ}_R0jd@Sk*@Oqi z$v1{;{reYpt@!4-Wb5h6Mb|(5^Wb{%?tl6k@24L>uDf)KNsW7Eni}hZenE%sILp4G z<#9g^R?UqM_~&udnNvY&3WJmr=K@7IJ%`%l?@?C$i{>ZhLF-ucOT>8bCh zgMZ1tP4&zu)sxN-yL0!iu+z(T>mJsJ@f|ksV0@9xa$!+;-{Lzf!|i&qo{LYh5BeCu z)WMf38 + + + + + +LoopBack iOS SDK: LBFile Class Reference + + + + + + + + + +
    +
    + + + + + + +
    +
    LoopBack iOS SDK +
    +
    +
    + + + + + + + + + +
    + +
    + +
    +
    + +
    +
    LBFile Class Reference
    +
    +
    + +

    A local representative of a file instance on the server. + More...

    + +

    #import <LBFile.h>

    +
    +Inheritance diagram for LBFile:
    +
    +
    + + +LBModel + +
    + + + + + + + + + + + + +

    +Public Types

    +typedef void(^ LBFileDownloadSuccessBlock )()
     Blocks of this type are executed when LBFile:downloadWithSuccess:failure: is successful.
     
    - Public Types inherited from LBModel
    +typedef void(^ LBModelSaveSuccessBlock )()
     Blocks of this type are executed when saveWithSuccess:failure: is successful.
     
    +typedef void(^ LBModelDestroySuccessBlock )()
     Blocks of this type are executed when destroyWithSuccess:failure: is successful.
     
    + + + + + + + + + + + + + + + + + + + + + + + +

    +Instance Methods

    (void) - uploadWithSuccess:failure:
     Uploads the file to the server. More...
     
    (void) - downloadWithSuccess:failure:
     Downloads the file from the server. More...
     
    - Instance Methods inherited from LBModel
    (id) - objectForKeyedSubscript:
     Returns the value associated with a given key. More...
     
    (void) - setObject:forKeyedSubscript:
     Adds a given key-value pair to the dictionary. More...
     
    (NSDictionary *) - toDictionary
     Converts the LBModel (and all of its @properties) into an NSDictionary. More...
     
    (void) - saveWithSuccess:failure:
     Saves the LBModel to the server. More...
     
    (void) - destroyWithSuccess:failure:
     Destroys the LBModel from the server. More...
     
    + + + + +

    +Protected Types

    +typedef void(^ LBFileUploadSuccessBlock )()
     Blocks of this type are executed when LBFile:uploadWithSuccess:failure: is successful.
     
    + + + + + + + + + + + +

    +Properties

    +NSString * name
     
    +NSString * localPath
     
    +NSString * container
     
    - Properties inherited from LBModel
    id _id
     All Models have a numerical id field. More...
     
    +

    Detailed Description

    +

    A local representative of a file instance on the server.

    +

    Method Documentation

    + +
    +
    + + + + + + + + + + + + + + + + + + +
    - (void) downloadWithSuccess: (LBFileDownloadSuccessBlocksuccess
    failure:(SLFailureBlock) failure 
    +
    + +

    Downloads the file from the server.

    +
    Parameters
    + + + +
    successThe block to be executed when the download is successful.
    failureThe block to be executed when the download fails.
    +
    +
    + +
    +
    + +
    +
    + + + + + + + + + + + + + + + + + + +
    - (void) uploadWithSuccess: (LBFileUploadSuccessBlocksuccess
    failure:(SLFailureBlock) failure 
    +
    + +

    Uploads the file to the server.

    +
    Parameters
    + + + +
    successThe block to be executed when the upload is successful.
    failureThe block to be executed when the upload fails.
    +
    +
    + +
    +
    +
    The documentation for this class was generated from the following file: +
    + + + + diff --git a/docs/html/interface_l_b_file.png b/docs/html/interface_l_b_file.png new file mode 100644 index 0000000000000000000000000000000000000000..669a1ce98b8c1482d10cbc3fe2028de5f3cb2fcd GIT binary patch literal 470 zcmeAS@N?(olHy`uVBq!ia0vp^4nW+&!3-o5cw|k1lth3}i0l9V|AEXGZ@!lHADRGU zf$@O@2Ut7r$OE|?B|(0{3_wL7aP?G(5d#Bbs;7%%NCo5Dxeq5DQs8MZH*miHzt>-3 ziO0d9M|Vq2`ff9{_Nyj-(eLOmVamO|ZS83WQ-w4Ww#v!BQy*;bm(*`CimZ5QSagF` z#>~g1FwExYfw#+*c^Gbr&93J26?!dmh0m(toZzdU$`0pVGh9$9eDdJM$30w|Ej7M7 zywd-^AezLl7+gU2PfK8zN$IabBx8pKp8UJ{QaC$j>6S-aeUS@*&bG3ezJNK+l zJF;JB5oX`CD{^Le07Kg36K}aK6SA+`3iyT|w0tg>(%{cn@qVup!-t^%|E`NQO - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
    @@ -99,8 +99,7 @@
    -LBModel -SLObject +LBModel
    @@ -112,10 +111,6 @@ - - - -
    (void) + registerDeviceWithAdapter:deviceToken:registrationId:appId:appVersion:userId:badge:subscriptions:success:failure:
     Register the device against LoopBack server. More...
     
    - Class Methods inherited from SLObject
    (instancetype) + objectWithRepository:parameters:
     Returns a new object with the type defined by given repository. More...
     
    @@ -158,14 +153,6 @@ - - - - - - -

    Properties

    id _id
     All Models have a numerical id field. More...
     
    - Properties inherited from SLObject
    SLRepositoryrepository
     The SLRepository defining the type of this object. More...
     
    -NSDictionary * creationParameters
     The complete set of parameters to be used to identify/create this object on the server.
     
    @@ -194,13 +181,6 @@ - - - - - - -

    Additional Inherited Members

    (void) - destroyWithSuccess:failure:
     Destroys the LBModel from the server. More...
     
    - Instance Methods inherited from SLObject
    (instancetype) - initWithRepository:parameters:
     Initializes a new object with the type defined by the given repository. More...
     
    (void) - invokeMethod:parameters:success:failure:
     Invokes a remotable method exposed within instances of this class on the server. More...
     

    Detailed Description

    LBInstallation represents the installation of a given app on the device.

    @@ -286,13 +266,13 @@ success: - (SLSuccessBlock)  + (SLSuccessBlock)  success failure: - (SLFailureBlock)  + (SLFailureBlock)  failure  @@ -352,7 +332,7 @@

    Property Documentation

    diff --git a/docs/html/interface_l_b_installation.png b/docs/html/interface_l_b_installation.png index 5547900e3a6787a54887c6073df89139e1a060cc..a41f861010687c0b88d653567eeafa4598618b99 100644 GIT binary patch delta 480 zcmV<60U!Rx1)~Iz7Yc|70{{R3O1$ivks&&N0kTO%K~#7F?cLFC!ypU=&}$=w|NrAP z0gMwuOBz$HswX@kEhk{SJ%fnIK0qwHLy2VTE;mUfueNq}1E8$*$ zZcE)ty-MAlRzkVrn}1~kEB+5VvcUf_ej`gnWF7!88Vdl}#~gN9rnqz1hdRTZ#C};N zIP0vl&H|{-S!bR70XBpX>;r+B**cv4FiW{xf9h2F<81%@HJg8Jwsce2wEuNnXYaC! zNW=VOdr6%!^RA8M_Jloj%&gnkZpA!*cHJBj_WN^sU$XPpI5o3qY3`vWWyk$r#wz&f1$09(54 z8fB`!r$(L0Gq&^PJ_`U%JYgRnrP(@`Uxk$?GLZ!@SON|WgxWx;O)YqlTh-}Hx9YXc zJG$(CaXO(4>H&6>x7hI{TwyQd_KeM^YI2*CAos2+VY_-=2`vi%cHykEvsoe{^Y{bV WB1Cucj6y*G0000<#9 delta 644 zcmZ3?a*TC?IM)FVW(Ed^mD^KhPgJz3XA1RnaSW+oe0%rire*~mwg>i!Z1?{6_H(tk z2Clha>33O?HN-CRQe1OKMoq(<;=B@#-=WvyBlcfc{yO&p$9c21m<@pfD|0NK$B4$} zh&-BWa{Ou7mB)XsYw4}(=ly&x^8cm}r#2OxTUxYd`==#7>%zR&Pv$i~_kBm&U(LEh zV(#_j2Ddj~$xxZ$v-C_$diCvdw-5Vtr2qa9US|75ext1Nm;R5vI)WEJFf`oTz+hna zY{NCb!si>htq#vUvQI~NN@!SQD&vwxYc`$w$B^A)_?WqEW+l*tsne#Nj|%-;;kfQ} zZQ3)Xz8fA#mbc#F-+%U<+V;KfVS>;1hb_Fjk(2kDe!Zg3k~K3dwR@FMe>a=|mhtvp z&YhQ%{%YP!TCJRY_M3`nUfQ9}dwVOje`-}$&*1#nA^-1G)XU%cH~B*UOT?d)N7FMH0;deeovJ=+rtBky_HoM1_NmcDS!rp=MbJ(6+^7o^1)jvbe|c1!b}Oj%(1 zj>$Ksr#5XmrL|h8Ap{siH{}yLJC3n)Fu1jEicd)1D!aI3^Ycw%i;It$$>ry5X4udz zT(*d_fo zf5=yzoZo+A!>YUY+I%MzpEpXh{$(TlO^2a}J9X;ZvqFNr{q`cNq3bFHdA - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
    @@ -98,8 +98,7 @@
    -LBModelRepository -SLRepository +LBModelRepository
    @@ -109,10 +108,6 @@ (instancetype)  - - - -
    + repository
     Get a singleton for LBInstallationRepository.
     
    - Class Methods inherited from SLRepository
    (instancetype) + repositoryWithClassName:
     Returns a new Repository representing the named remote class. More...
     
    @@ -126,8 +121,8 @@ - - + + @@ -138,28 +133,10 @@ - - - - - - - - - - - - - - - - -

    Additional Inherited Members

     Blocks of this type are executed when allWithSuccess:failure: is successful.
     
    - Instance Methods inherited from LBModelRepository
    (SLRESTContract *) - contract
     The SLRESTContract representing this model type's custom routes. More...
    (SLRESTContract *) - contract
     The SLRESTContract representing this model type's custom routes. More...
     
    (LBModel *) - modelWithDictionary:
     Creates a new LBModel of this type with the parameters described. More...
    (void) - allWithSuccess:failure:
     Finds and downloads all models of this type on and from the server. More...
     
    - Instance Methods inherited from SLRepository
    (instancetype) - initWithClassName:
     Initializes a new Repository, associating it with the named remote class. More...
     
    (SLObject *) - objectWithParameters:
     Returns a new SLObject as a virtual instance of this remote class. More...
     
    (void) - invokeStaticMethod:parameters:success:failure:
     Invokes a remotable method exposed statically within this class on the server. More...
     
    - Properties inherited from LBModelRepository
    Class modelClass
     The LBModel subclass used to wrap model instances. More...
     
    - Properties inherited from SLRepository
    NSString * className
     The name given to this class on the server. More...
     
    -SLAdapteradapter
     The SLAdapter that should be used for invoking methods, both for static methods on this repository and all methods on all instances of this class.
     

    Detailed Description

    Custom ModelRepository subclass for LBInstallation.

    @@ -169,7 +146,7 @@
    diff --git a/docs/html/interface_l_b_installation_repository.png b/docs/html/interface_l_b_installation_repository.png index dd9ef8df3f2195888ac60877652e249f586923eb..0ba325d4f1c21fe314137312f3c34bca5a2c02c5 100644 GIT binary patch delta 830 zcmaFE@tT=Ah)pyT}68I<~^lSQ*piiuxp;v_$E?Jc&=(TE<*krHmPCMpio!;@b>gUz+xxu^o zSNd!EhF&#{56D^+V(0bd+Ki_ca%;DjpNReb-}Cg#R_owX{yXh=Zwm=7PWk#PHuS6F z<(Kuf)4W5I%B?g^SFEyo(%JR8SaW^!=YP2#=cYcB`x;jDz0H*8c&j$&(p6a>w_S?S ztBuRNJ^hu}OwsMLrgc>(h5tD6&epowere|C^_pkHzs>)9Gc@$C7|4wegEf~`8#87T*E2DGWMJoClQZp)@Y)U-r_}NU``09UT=)Q(Rnh zoIG8QJPOf#dim{ov+bYvmHrKD>+0ay(JLfqSh-@0t-f@Zhi%o;#hW@#^vw@Eb#O=B zwXoG8Ri`!>RlSXVytD7DaYx4&AI+z;KQF$1x%StstolWv`eoO5ulrUe__A+jj8)(* z?rU4DWy=Dx1SWo)(S7OJ=IU!&m-g1YyxIOF=B3W=d%;#q%8S#t8-W5vRq2xP%93p% z@1I`U>}C0-3rBf#9doax7 zP-W;2VA^nF%Bh$0K1FYqyj~-1a!ZI!qPXmKL}tP92+jqIeHaa%sV;rJbZhDFeYGM> z*QRGrkv3bp&U}0QsR?O^b~|r2>YpO?hEM3LLSX;DHpl#?yA!Xz{(gMtl{rz5cNM7D zt#g>SF&(n+zxUZ1(I``kTRWDqSrcbD`{FaIZ( z0yFidyLnljX^%Oz@ZPJ{D|b{IZryrS({{~{sN=hH{vHFSn*H`m%YJKqU3jJE)1S@U l51N5q_^@(Hkk`5&?DyD;pRY8#?gz{#44$rjF6*2Ung9y7lAQnm literal 1132 zcmeAS@N?(olHy`uVBq!ia0vp^lYsaD2Q!eo@%WSjkdg@S332`Z|38rV;?396{zDUh zEHFNB-~emq9eE&^qa?^Lm;tB=1g@S6F=Aj~{_W}F7*fIbcJ9Tp%~}F(=JT^#zt=yW z>>^+=OVM}sx%;K7EVcdiN;c!?bJBn83hE4Bzokp;?#C&` z=O)*vPTv-}ZNVE}x9R*EQ$4;~ZVitz{&(5Sd6vA(OHa;cb3R+f-)7k+&?EZ2dS}T# zec7;>was&i=RIUEdtc7}CthQ(?Y;OPH_uu=pRYQl=-kai%Y(c$cQQSw-ofzW(ELkJ zADufn|I*bHvnM+*U17m6JAi2ehblui0qVzPuhW}!_9aYI@o$-=5(&aST1#Kwe|shB zY0#v;9d>3_9+wo0y}n<(t+Q3r^LdTK%I=`QD>gHDRcJ2oKKbo<6@8$r>-aVF7YbCN3%A6*!vwfuH`cHZ;a*Hxjry)JQXkDHY8DI|0DdI_(r<14UN4^7^G+O?K(UEdKWAhu8iq^*n4i-J9L3 z`rx#(_PcUZtW>@pkC|dN|8C6c6Ca+wo?GkDH??omYulymU*6r5342!fFw4pF(upOP zE(YzL?!8`X>W6;LOQBb;Yk|U~e3$m0Gw*D-GggLJz56!XOMUOZsqDPSUB- z(mlOt2jz)DbLkUqp$2s)&I3wQ7<9~*R_$8;=h~ZJrQzzm`&t;!SysJ`dHJNbShb9VuXOpn9lCcK@4vcm>Ep+Tc{6OU9oniND88urk}041`YitP^HZ|Qd^OJM$C!T+ zI6e7d+lwuCPlQz|PM4edtmviB%9fvs)4f(~|Mg1iU7SyCF0Yrr_PVPd^`h-JR-f;C z@4xbXU9CpxUYq}Kn0_b#y-=gIbjl>{f6VKyPJ9=BX(J1;XkhSk^>bP0l+XkK=UyLb diff --git a/docs/html/interface_l_b_model.html b/docs/html/interface_l_b_model.html index d0260a6..2009782 100644 --- a/docs/html/interface_l_b_model.html +++ b/docs/html/interface_l_b_model.html @@ -70,7 +70,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
    @@ -100,8 +100,11 @@
    -SLObject -LBInstallation +LBAccessToken +LBContainer +LBFile +LBInstallation +LBUser
    @@ -133,34 +136,12 @@ - - - - - - -
    (void) - destroyWithSuccess:failure:
     Destroys the LBModel from the server. More...
     
    - Instance Methods inherited from SLObject
    (instancetype) - initWithRepository:parameters:
     Initializes a new object with the type defined by the given repository. More...
     
    (void) - invokeMethod:parameters:success:failure:
     Invokes a remotable method exposed within instances of this class on the server. More...
     
    - - - - - - - -

    Properties

    id _id
     All Models have a numerical id field. More...
     
    - Properties inherited from SLObject
    SLRepositoryrepository
     The SLRepository defining the type of this object. More...
     
    -NSDictionary * creationParameters
     The complete set of parameters to be used to identify/create this object on the server.
     
    - - - - -

    -Additional Inherited Members

    - Class Methods inherited from SLObject
    (instancetype) + objectWithRepository:parameters:
     Returns a new object with the type defined by given repository. More...
     

    Detailed Description

    A local representative of a single model instance on the server.

    @@ -179,7 +160,7 @@ failure: - (SLFailureBlock)  + (SLFailureBlock)  failure  @@ -241,7 +222,7 @@ failure: - (SLFailureBlock)  + (SLFailureBlock)  failure  @@ -348,7 +329,7 @@

    Property Documentation

    diff --git a/docs/html/interface_l_b_model.png b/docs/html/interface_l_b_model.png index 1d9fd0b43787a6dd0888bd34cec5016cf262c789..4528e43040bac32d8df83f1213603c4c92938419 100644 GIT binary patch literal 1602 zcmbtU3rv$&6fQV~Aqr{`K}FnDq8(ts0Y(bQV+h6K9RH6LXdP0qJVXm9w3UZ0Fy?r; zSqX?zM2h^iMX(b$DlDwmMqy#?z!i?`OZD(d^x!} zM=^eDjjfCk2*g_d!#>9l2z?~%|7^4hw(FzA65(U>(ZFC|olXb4iphoK{D%dw_hAc# zLW7*4?JzV-I)?cH0h5+jk2u&7fiQUP?{g?PMQ=*_f>g`1%6i@+`n5!7In!W{q;HtA zXv$uk{v)6!#wI*VFx$3Pv`>pLa=rg!G2``=#CU52HZ$WoM_kM#B4!nFNb^sX9DAsdz>e$R>=pGWRud3vJ%sn`D{Xb*|@nRp=d z*G)#VBjKLVD`kF4c9ZFR@`X@CWmeFn`R?d@9wHKvm z+E^*_P`O4=cHzpqjYbgw4W_JH;SSZo! zYsYO);9Ar??DrLS;4?U0SH0lCl$<(P>%`0 z?*afyTLxyO&Z{1f8Bk2?_!j$wR4t=>Yh4NtGexom$*7>~V}Qbub@vU8VfeFb?n?j?gxGtb2nQ4qAqlZY2)6N2JY z?b4#j{(#sG%otTlpZIadsTv=L5vNiaFY%^&hEx0g+Jb^t%td2SEX1z`1f(`AQjnP(is#M%sKFQ@lW3wSE?0{gh1+-=%nLVlV z$%C&Jt|!aq7OEifWF4jJC6h{tymFJz8frG23XBBotn;xNNOnFV^nG2TDYkc@f<{S? zU#C2xrbAHH3};S@QlMCz-8Imr{7P(NLumWxSbd_}1b>>4Y%&E73)pYChNv^6y1&Gy zt}>y4#CQTu1Fn(qd^&Xa_f=E84!I&R-q3bq`^;3`hwPjTh$HC|&>{ z!XRBr`FulZNndI-?skKdh6Or1QKk0PM4;zZH9Q!@iVAcHuz)8BA&4yr002{B1q5Y> zb3a1M`w+zB90Pj1u~pE-jzacF_-VdoZLyZE=cs~~oZL}YK7RGq)^n2+=`-KoYkR~< RtAam#gugGwhwXLZ(%;{t8khh8 delta 674 zcmV;T0$u&W49^82iBL{Q4GJ0x0000DNk~Le000110002M2m=5B0I9cRn~@T0pwz=vBv%YDBTN9_0^ zyu-e6wkU6g85cJ-QOn6*nR#9qYwT)PL}YsW0ZABDIp0I@M*si-07*qo IM6N<$f&+R^S^xk5 diff --git a/docs/html/interface_l_b_model_repository.html b/docs/html/interface_l_b_model_repository.html index 4e0c625..a277c2a 100644 --- a/docs/html/interface_l_b_model_repository.html +++ b/docs/html/interface_l_b_model_repository.html @@ -70,7 +70,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
    @@ -100,8 +100,7 @@
    -SLRepository -LBInstallationRepository +LBInstallationRepository
    @@ -118,8 +117,8 @@
    - - + + @@ -130,37 +129,12 @@ - - - - - - - - - -

    Instance Methods

    (SLRESTContract *) - contract
     The SLRESTContract representing this model type's custom routes. More...
    (SLRESTContract *) - contract
     The SLRESTContract representing this model type's custom routes. More...
     
    (LBModel *) - modelWithDictionary:
     Creates a new LBModel of this type with the parameters described. More...
    (void) - allWithSuccess:failure:
     Finds and downloads all models of this type on and from the server. More...
     
    - Instance Methods inherited from SLRepository
    (instancetype) - initWithClassName:
     Initializes a new Repository, associating it with the named remote class. More...
     
    (SLObject *) - objectWithParameters:
     Returns a new SLObject as a virtual instance of this remote class. More...
     
    (void) - invokeStaticMethod:parameters:success:failure:
     Invokes a remotable method exposed statically within this class on the server. More...
     
    - - - - - - - -

    Properties

    Class modelClass
     The LBModel subclass used to wrap model instances. More...
     
    - Properties inherited from SLRepository
    NSString * className
     The name given to this class on the server. More...
     
    -SLAdapteradapter
     The SLAdapter that should be used for invoking methods, both for static methods on this repository and all methods on all instances of this class.
     
    - - - - -

    -Additional Inherited Members

    - Class Methods inherited from SLRepository
    (instancetype) + repositoryWithClassName:
     Returns a new Repository representing the named remote class. More...
     

    Detailed Description

    A local representative of a single model type on the server, encapsulating the name of the model type for easy LBModel creation, discovery, and management.

    @@ -178,7 +152,7 @@ failure: - (SLFailureBlock)  + (SLFailureBlock)  failure  @@ -205,7 +179,7 @@
    - + @@ -213,9 +187,9 @@
    - (SLRESTContract *) contract - (SLRESTContract *) contract
    -

    The SLRESTContract representing this model type's custom routes.

    +

    The SLRESTContract representing this model type's custom routes.

    Used to extend an Adapter to support this model type.

    -
    Returns
    A shared SLRESTContract for this model type.
    +
    Returns
    A shared SLRESTContract for this model type.
    @@ -238,7 +212,7 @@ failure: - (SLFailureBlock)  + (SLFailureBlock)  failure  @@ -315,7 +289,7 @@

    Property Documentation

    diff --git a/docs/html/interface_l_b_model_repository.png b/docs/html/interface_l_b_model_repository.png index 29b5ef63d49488b9b8c95d0fa58ffb2fe0de0657..fce4598fbe2e10f5280370de52eb9c74e3814c1e 100644 GIT binary patch delta 838 zcmey&(Z)VOoU4O_nSp`9`h}C@L`AE5W>HTU$B+ufw{ve7y;k615U*7G_21sklZP!w zc%pak*Pft!S%c|Y1)fZu67-4HGxVzP!X>M+1ieuW3jo2fkaDh}Q|_1@k@-ou3ty_{CAirTZ* zWV-kK@LT7W?h1O=7wvnxuliBQk0UQ_t()wZW`16;dG`Gq``?>aull9y1a#=3!i2}gMW)q zgR2H(#2l@st4#lHf3z-DH+KKjWem)DYZ-jxv~oYEIxmRZdnr&d;rMxtrwLCECwD(u z7Lw()`BK%|=*N-Ia>E})F1=&vzxUp|!`Fj^*Z$g2eJ^xt{oTfQvraD+Ub;8IclYHq z_N8nK_C8y*<>#AcQLekD>zn?bFh_fC>h)@`_Ahx=W!l9tJ3exntSs3U^8V?i&0dy& zYMV@~Uu~7$K5Lq+xs7PuvoG^xFVDYJx%qyG)Rte`_PZJOy93?)Bg9KnHJqWQjk`hr zk7lgiyE#CzcaNoINPU+qdxEeRgV;ir1VIAS|E-rc>6~`op>uju4U?FlpnuDxjt*Ci z&W?y2FU|XT^P}$AZLRrhrZHugO-sj#hRu1&OC9?+PU`S*mvnMTIpgj1^4GrC(f9A$ z{MYu1J{zVXYqoSI$9G=26ZLpk zfqLC)XW!$G58pMYUemf-KTvE@pD94ojhHR99j|mllPCZH literal 1139 zcmeAS@N?(olHy`uVBq!ia0vp^lYsaD2Q!eo@%WSjkdg@S332`Z|38rV;?396{zDUh zEHFNB-~emq9eE&^qa?^Lm;tB=1g@S6F=Aj~Ve)iw45?szJNNapPg(-3-Djgd{mZYp z;?NM2Bcp%Ve7R{VlVU)o)E{pS#WSpmOQ)nAni}MF5==bGT)On<+wa>fraA39Vf)sq zrmSW8)Kf23yVg$(@{+b&7viRW{_2gGe9_H9+i$OAFuWsq*lM{oG|K4TZLio_@-8nA3i)U*Ew0-|6MkfBz2M&-2o(6$|&$RPDB$>co+##c=O1Yl7ah;9W7x zif8%1%rcpMxy5VWBZiz9&I5<0GUyPX9{Fn@m3SN@pqi-`<2gwOgxRJZ`dVy#HE7?I zCCclz_liv_IWgnX-tSgknqHSI;{&o5h17YynKt9;g|(&I%TI)Uf4|`Aha<9@PXpg2 zU!Np0OL_J6Y|p9_1y%A-gQnh?Q|84x>B|K5u$cMYmG@?S&v!0bV=^sPe`$Gs#NiF| zcT5VHl=5-Yr3k&f@tJq0zw()>ooA@4{jM|iq3rJOFW5}xUt00=`;<2G&-LH)!zb-) z)%KipbdHzdF$+Rq-xyS&77*4a!a)%ZdNvvn*954{+~2v8rFgMv?w zgTWZ8xNyak)ziMjch8=-wPdfBFQea%txN`$E4K7a=WVR|;#Hm6z&k(i)WH+8k4qg5 zU3q0n+S0E<+mCGSxqa@yX0M+QZN3!kDv$T}-SX<}ySnhJc6=qrBlKi7a#^!)$(r5P zG-Y^eD7N%!y74uoOM7cp-fVjk@ls=VT=1=><)2f`jemDq-*04_+PCc0)|jd=&G!BN z6VhD&<{Z^smU?vVJFfXR_qzX{VZ`+Zcvt zNp?$5r&=xlIc1&OW=r1{Pqg_C93ve6pd|8dOHhyDzE*D_!MsT2Yzr`q!Qs40{hL?v&XQ$Q z4(~a=ROVG_t*Q3AeKT%ty{c&&Q&=jSzv-*=?(I9Bb8q`D4w-#+(UmQ;egf0XvjbCA jPA2&+l}Mh`^`Alb#>C3RgVMFY5`w|g)z4*}Q$iB}2p$^v diff --git a/docs/html/interface_l_b_push_notification.html b/docs/html/interface_l_b_push_notification.html index abe5d27..78cda6b 100644 --- a/docs/html/interface_l_b_push_notification.html +++ b/docs/html/interface_l_b_push_notification.html @@ -70,7 +70,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
    @@ -250,13 +250,13 @@ success: - (SLSuccessBlock)  + (SLSuccessBlock)  success failure: - (SLFailureBlock)  + (SLFailureBlock)  failure  @@ -332,7 +332,7 @@
    diff --git a/docs/html/interface_l_b_r_e_s_t_adapter.html b/docs/html/interface_l_b_r_e_s_t_adapter.html index 5363133..70ae6c2 100644 --- a/docs/html/interface_l_b_r_e_s_t_adapter.html +++ b/docs/html/interface_l_b_r_e_s_t_adapter.html @@ -70,7 +70,7 @@ onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros + All Data Structures Files Functions Typedefs Enumerations Enumerator Properties
    @@ -88,7 +88,7 @@
    -

    An extension to the vanilla SLRESTAdapter to make working with LBModels easier. +

    An extension to the vanilla SLRESTAdapter to make working with LBModels easier. More...

    #import <LBRESTAdapter.h>

    @@ -98,8 +98,6 @@
    -SLRESTAdapter -SLAdapter
    @@ -111,40 +109,9 @@ - - - - - - - - - - - - - -
    (LBModelRepository *) - repositoryWithClass:
     Returns a new LBModelRepository from the given subclass. More...
     
    - Instance Methods inherited from SLAdapter
    (instancetype) - initWithURL:
     Initializes a new Adapter, connecting it to url. More...
     
    (void) - connectToURL:
     Connects the Adapter to url. More...
     
    (void) - invokeStaticMethod:parameters:success:failure:
     Invokes a remotable method exposed statically on the server. More...
     
    (void) - invokeInstanceMethod:constructorParameters:parameters:success:failure:
     Invokes a remotable method exposed within a prototype on the server. More...
     
    - - - - - - - - - - - - - - - -

    -Additional Inherited Members

    - Class Methods inherited from SLAdapter
    (instancetype) + adapter
     Returns a new, disconnected Adapter. More...
     
    (instancetype) + adapterWithURL:
     Returns a new Adapter connected to url. More...
     
    - Properties inherited from SLRESTAdapter
    SLRESTContractcontract
     A custom contract for fine-grained route configuration. More...
     
    - Properties inherited from SLAdapter
    BOOL connected
     YES if the SLAdapter is connected to a server, NO otherwise. More...
     

    Detailed Description

    -

    An extension to the vanilla SLRESTAdapter to make working with LBModels easier.

    +

    An extension to the vanilla SLRESTAdapter to make working with LBModels easier.

    Method Documentation

    @@ -202,7 +169,7 @@
    diff --git a/docs/html/interface_l_b_r_e_s_t_adapter.png b/docs/html/interface_l_b_r_e_s_t_adapter.png index a098263bc832ce8265ff77bb5988f9534090eb99..df9c6ca563769238c434f1124de94253b6817a7b 100644 GIT binary patch delta 442 zcmV;r0Y(0$2mJ$(7Ya}a0{{R3GvJ%vks&&N0gOpRK~#7F?Va7St1t*g7dPeo-*~si z5R#}0?hMRZoa5abaC(C>cqg}~TNX>wb)lKL_jbjp+jXVB;?3hYYzubG_rYa-hCm#D z$AwmL)85c;eSN&$P^1=z#qHDT_kZXEOR9OE^Xba|JLkGSr}wA50n5L=n2F>2ZTr>Y z54Y^z@4>mR-;x9H4@wR| zT*(25D>(phB?lm`GQqA+6kFV6V`F`HGWG z7SnAdrIZf3$H^x1jOxWalyTX^rO0lll+r=(aCXl$XQS_XXp59m>UABTvb1dfXto7^ z+~w>(={OxZTWWlT)8xYoe=ZX6?Yu6VZS(ER@j1UgFY_%YOiC#o^wImku=HQxSXTP~ zLP{yw^@E%cLU>*PR!sl{G>9`zV?cvAGiC^A6zAvi%{c%!6{OHn&s)Xq9YL|UD3)}`}LF%fiCMD+Jl zjy91wvzM!%ySGcR*0&D59TBPDi*xIEyH=}BwRYrXA|j10@}P;2;^aPs>&8Sx8eQg_ ziqDc34Qo5B%IWe(MAY}qJSc})E%*LhrNj-+b$mobUg$sXPd%U#=$vosCkMZOV}^i6aegk}oC9z}&H=E? zIRJJ!2f!}p0NCXm0K1$6V3%{|C&m~Dh$tfRxSS&*V%K<1n4hJnt+lBuxw+2SCpNXS z4#ml9GpB8qwwh3^**V(G3r;(KVXMr}?e1=!o71_YOw;Ff#mU3DCm-=@@mQ@LWtq-{ z%lI5NqBv@68P|;+@~w@Jo_7dR-ACECcB>u#APMKlKEP|Mg%x zj?TCBlY@V_W#4@tytp{d5fQm9=ZJ{dHINfyjL!?estI6#263io3}_I4XT}TxjpF=V zzBvcrhMWUnmvaE@at?r9&H=E?IRJJ!2f!}p%ufg*3=jd}aXAOTuHl?qthsS0bEPDw zTF}(aI$m)0pQcp(YGSeWbxu2RtL!&pcY0}V_2TtD?M=>VKuz4NZd3MYwOTvMvbW+ESOMmpdLy+oFKFYqeTkZGg`_plBzOA1e v{KGB#?)%`}mU95?at?r9134jt@Vx#2SdnIh14iOW00000NkvXXu0mjf@5rq} diff --git a/docs/html/interface_l_b_user.html b/docs/html/interface_l_b_user.html new file mode 100644 index 0000000..ba48e48 --- /dev/null +++ b/docs/html/interface_l_b_user.html @@ -0,0 +1,168 @@ + + + + + + +LoopBack iOS SDK: LBUser Class Reference + + + + + + + + + +
    +
    + + + + + + +
    +
    LoopBack iOS SDK +
    +
    +
    + + + + + + + + + +
    + +
    + +
    +
    + +
    +
    LBUser Class Reference
    +
    +
    + +

    A local representative of a user instance on the server. + More...

    + +

    #import <LBUser.h>

    +
    +Inheritance diagram for LBUser:
    +
    +
    + + +LBModel + +
    + + + + + + + + + + + + + + + + +

    +Properties

    +NSString * email
     
    +NSString * password
     
    +NSString * realm
     
    +NSNumber * emailVerified
     
    +NSString * status
     
    - Properties inherited from LBModel
    id _id
     All Models have a numerical id field. More...
     
    + + + + + + + + + + + + + + + + + + + + + + + + +

    +Additional Inherited Members

    - Public Types inherited from LBModel
    +typedef void(^ LBModelSaveSuccessBlock )()
     Blocks of this type are executed when saveWithSuccess:failure: is successful.
     
    +typedef void(^ LBModelDestroySuccessBlock )()
     Blocks of this type are executed when destroyWithSuccess:failure: is successful.
     
    - Instance Methods inherited from LBModel
    (id) - objectForKeyedSubscript:
     Returns the value associated with a given key. More...
     
    (void) - setObject:forKeyedSubscript:
     Adds a given key-value pair to the dictionary. More...
     
    (NSDictionary *) - toDictionary
     Converts the LBModel (and all of its @properties) into an NSDictionary. More...
     
    (void) - saveWithSuccess:failure:
     Saves the LBModel to the server. More...
     
    (void) - destroyWithSuccess:failure:
     Destroys the LBModel from the server. More...
     
    +

    Detailed Description

    +

    A local representative of a user instance on the server.

    +

    The documentation for this class was generated from the following file: +
    + + + + diff --git a/docs/html/interface_l_b_user.png b/docs/html/interface_l_b_user.png new file mode 100644 index 0000000000000000000000000000000000000000..d857e8d13850d662c0d9878251e7571c6576a32d GIT binary patch literal 480 zcmeAS@N?(olHy`uVBq!ia0vp^4nW+&!3-o5cw|k1lth3}i0l9V|AEXGZ@!lHADRGU zf$@O@2Ut7r$OE|?B|(0{3_wL7aP?G(5d#BbzNd?0NCo5DxexOWEAX_OS5STb{}{If zk79sFOzzcJT*nxsufi%humJ^04%W?ty}-e{C!H8#+7$89o@9FMwH(_D#wkHRrYw9?Hl;e;p~|I8MYX}SwNCOZ=T!U_x(a%>rlE6=}M_V7uAor3K>_KvEi4fm$8Hf-rC zJIy>#jG^ID-kw98)wf+Pe&o1N!LVQp+X1c3H*P$vS=ID+21CeM20;gxB^~n0{zm4m TdlbF_ql3ZI)z4*}Q$iB}|E16( literal 0 HcmV?d00001 diff --git a/docs/html/search/all_1.js b/docs/html/search/all_1.js index 57c08e6..66b49bc 100644 --- a/docs/html/search/all_1.js +++ b/docs/html/search/all_1.js @@ -1,18 +1,10 @@ var searchData= [ - ['adapter',['adapter',['../interface_s_l_repository.html#ab80405fac6612b5866f70201621ed377',1,'SLRepository::adapter()'],['../interface_s_l_adapter.html#a5a7195ff8d9ffa5a314a44e75791da97',1,'SLAdapter::adapter()']]], - ['adapterwithurl_3a',['adapterWithURL:',['../interface_s_l_adapter.html#abbdfbfe0048dd0cfa7976c0060d81232',1,'SLAdapter']]], - ['additem_3aformethod_3a',['addItem:forMethod:',['../interface_s_l_r_e_s_t_contract.html#a7452533bf3aa40778e1b84fdacd92da1',1,'SLRESTContract']]], - ['additemsfromcontract_3a',['addItemsFromContract:',['../interface_s_l_r_e_s_t_contract.html#a86c6af82b8ccebfe5fd9b779b6621d66',1,'SLRESTContract']]], ['allwithsuccess_3afailure_3a',['allWithSuccess:failure:',['../interface_l_b_model_repository.html#ac97a68ff8076ae8591b21e9692e94086',1,'LBModelRepository']]], ['appid',['appId',['../interface_l_b_installation.html#a021bab35bc71b7f715508c00992b170a',1,'LBInstallation']]], ['application_3adidfailtoregisterforremotenotificationswitherror_3a',['application:didFailToRegisterForRemoteNotificationsWithError:',['../interface_l_b_push_notification.html#a1f6fbd35aea75f014b67f70ad2775311',1,'LBPushNotification']]], ['application_3adidfinishlaunchingwithoptions_3a',['application:didFinishLaunchingWithOptions:',['../interface_l_b_push_notification.html#a253654a9f5424905c010c5a0e5e542d1',1,'LBPushNotification']]], ['application_3adidreceiveremotenotification_3a',['application:didReceiveRemoteNotification:',['../interface_l_b_push_notification.html#acab7c687cf025fa9cd7c4b22a407a7f4',1,'LBPushNotification']]], ['application_3adidregisterforremotenotificationswithdevicetoken_3aadapter_3auserid_3asubscriptions_3asuccess_3afailure_3a',['application:didRegisterForRemoteNotificationsWithDeviceToken:adapter:userId:subscriptions:success:failure:',['../interface_l_b_push_notification.html#a6f39e1aa0085d9d62d8b762754b90d6f',1,'LBPushNotification']]], - ['appversion',['appVersion',['../interface_l_b_installation.html#a5c58df6b4f19c0c4a3f5c969eb7b03c2',1,'LBInstallation']]], - ['async_5ftest_5fend',['ASYNC_TEST_END',['../_s_l_remoting_utils_8h.html#a805ec26082472cab40c94e353890df4c',1,'SLRemotingUtils.h']]], - ['async_5ftest_5ffailure_5fblock',['ASYNC_TEST_FAILURE_BLOCK',['../_s_l_remoting_utils_8h.html#a5d9bd533e4ae1f2aad11f153ddf2caa5',1,'SLRemotingUtils.h']]], - ['async_5ftest_5fsignal',['ASYNC_TEST_SIGNAL',['../_s_l_remoting_utils_8h.html#ac5ec60a2ffd2766563b3501d2a20c661',1,'SLRemotingUtils.h']]], - ['async_5ftest_5fstart',['ASYNC_TEST_START',['../_s_l_remoting_utils_8h.html#a75b4415b4ad58673e0993080e3064671',1,'SLRemotingUtils.h']]] + ['appversion',['appVersion',['../interface_l_b_installation.html#a5c58df6b4f19c0c4a3f5c969eb7b03c2',1,'LBInstallation']]] ]; diff --git a/docs/html/search/all_3.js b/docs/html/search/all_3.js index 89bf92a..725bb54 100644 --- a/docs/html/search/all_3.js +++ b/docs/html/search/all_3.js @@ -1,8 +1,4 @@ var searchData= [ - ['classname',['className',['../interface_s_l_repository.html#a20568756d6fb3c9dddc5e359f14488dd',1,'SLRepository']]], - ['connected',['connected',['../interface_s_l_adapter.html#aa59b74a90d17cae71c63da74d8431119',1,'SLAdapter']]], - ['connecttourl_3a',['connectToURL:',['../interface_s_l_adapter.html#ae89d78e1ed21a3c73b5343ef8778ae0c',1,'SLAdapter']]], - ['contract',['contract',['../interface_s_l_r_e_s_t_adapter.html#aefe945e1e8e062ce0c061598d999cccf',1,'SLRESTAdapter::contract()'],['../interface_l_b_model_repository.html#a1c1f7782220149be3fb7b2ff2bb53f73',1,'LBModelRepository::contract()'],['../interface_s_l_r_e_s_t_contract.html#aad097113d9a25a1d0fc09e5f70b4eea9',1,'SLRESTContract::contract()']]], - ['creationparameters',['creationParameters',['../interface_s_l_object.html#a4187295e29e1fc2859be401525a4ae87',1,'SLObject']]] + ['contract',['contract',['../interface_l_b_model_repository.html#a1c1f7782220149be3fb7b2ff2bb53f73',1,'LBModelRepository']]] ]; diff --git a/docs/html/search/all_4.js b/docs/html/search/all_4.js index 31b645b..701d7ed 100644 --- a/docs/html/search/all_4.js +++ b/docs/html/search/all_4.js @@ -1,8 +1,9 @@ var searchData= [ + ['deletewithsuccess_3afailure_3a',['deleteWithSuccess:failure:',['../interface_l_b_container.html#a5e30c11b50fccdf95f8539f717445d67',1,'LBContainer']]], ['destroywithsuccess_3afailure_3a',['destroyWithSuccess:failure:',['../interface_l_b_model.html#a85cb42b9c3094ea8363bf942ce95d7b8',1,'LBModel']]], ['devicetoken',['deviceToken',['../interface_l_b_installation.html#adb690dc224650d3d5f3c50d8154efbdb',1,'LBInstallation']]], ['devicetokenwithdata_3a',['deviceTokenWithData:',['../interface_l_b_installation.html#a39340936d48bfc17852b44fcc6e733cd',1,'LBInstallation']]], ['devicetype',['deviceType',['../interface_l_b_installation.html#a9fdec8099a814ad3cce4e89a6685ab0f',1,'LBInstallation']]], - ['dict',['dict',['../interface_s_l_r_e_s_t_contract.html#afa9fc6f1bfabfe7026ef9f0dddc6f592',1,'SLRESTContract']]] + ['downloadwithsuccess_3afailure_3a',['downloadWithSuccess:failure:',['../interface_l_b_file.html#a5109f2ba85b8d515a234af379b0dc562',1,'LBFile']]] ]; diff --git a/docs/html/search/all_6.js b/docs/html/search/all_6.js index b9b13b2..507ef92 100644 --- a/docs/html/search/all_6.js +++ b/docs/html/search/all_6.js @@ -1,4 +1,5 @@ var searchData= [ - ['getbadge',['getBadge',['../interface_l_b_push_notification.html#a49310f547e5618d61323720e7b3e03fc',1,'LBPushNotification']]] + ['getbadge',['getBadge',['../interface_l_b_push_notification.html#a49310f547e5618d61323720e7b3e03fc',1,'LBPushNotification']]], + ['getfilewithname_3alocalpath_3asuccess_3afailure_3a',['getFileWithName:localPath:success:failure:',['../interface_l_b_container.html#ad2149181e23df726b70dbb1dd3131052',1,'LBContainer']]] ]; diff --git a/docs/html/search/all_7.js b/docs/html/search/all_7.js index f7c49c7..283c335 100644 --- a/docs/html/search/all_7.js +++ b/docs/html/search/all_7.js @@ -1,13 +1,30 @@ var searchData= [ - ['initwithclassname_3a',['initWithClassName:',['../interface_s_l_repository.html#a3ba5a7eecaf4e42734b69c8efcc4a313',1,'SLRepository']]], - ['initwithpattern_3a',['initWithPattern:',['../interface_s_l_r_e_s_t_contract_item.html#a5867aae81da3b32604869134b2133783',1,'SLRESTContractItem']]], - ['initwithpattern_3averb_3a',['initWithPattern:verb:',['../interface_s_l_r_e_s_t_contract_item.html#a906e0d38d2d68fd70b77639004c1bcb8',1,'SLRESTContractItem']]], - ['initwithrepository_3aparameters_3a',['initWithRepository:parameters:',['../interface_s_l_object.html#a368b1c26aba0b047d29b20bf3d6ebd19',1,'SLObject']]], - ['initwithurl_3a',['initWithURL:',['../interface_s_l_adapter.html#a772aa56022d1c63052a3b86ae8f43064',1,'SLAdapter']]], - ['invokeinstancemethod_3aconstructorparameters_3aparameters_3asuccess_3afailure_3a',['invokeInstanceMethod:constructorParameters:parameters:success:failure:',['../interface_s_l_adapter.html#ad4813db06f471724e13b704520f021c1',1,'SLAdapter']]], - ['invokemethod_3aparameters_3asuccess_3afailure_3a',['invokeMethod:parameters:success:failure:',['../interface_s_l_object.html#a6f761bfca92d63028d46897baee6e542',1,'SLObject']]], - ['invokestaticmethod_3aparameters_3asuccess_3afailure_3a',['invokeStaticMethod:parameters:success:failure:',['../interface_s_l_adapter.html#a1f6b9753c341b13576cb5226fe9d8bb4',1,'SLAdapter::invokeStaticMethod:parameters:success:failure:()'],['../interface_s_l_repository.html#abb889a06c1392062fae3e4123ac3825f',1,'SLRepository::invokeStaticMethod:parameters:success:failure:()']]], - ['itemwithpattern_3a',['itemWithPattern:',['../interface_s_l_r_e_s_t_contract_item.html#a8a5f2e08d3369a1997ec166bb02a188d',1,'SLRESTContractItem']]], - ['itemwithpattern_3averb_3a',['itemWithPattern:verb:',['../interface_s_l_r_e_s_t_contract_item.html#a1b824e5c31215d5741f077fb970a4712',1,'SLRESTContractItem']]] + ['lbaccesstoken',['LBAccessToken',['../interface_l_b_access_token.html',1,'']]], + ['lbaccesstoken_2eh',['LBAccessToken.h',['../_l_b_access_token_8h.html',1,'']]], + ['lbcontainer',['LBContainer',['../interface_l_b_container.html',1,'']]], + ['lbcontainer_2eh',['LBContainer.h',['../_l_b_container_8h.html',1,'']]], + ['lbcontainerdeletesuccessblock',['LBContainerDeleteSuccessBlock',['../interface_l_b_container.html#a77d55b2d0ff38f75c7a63c91bd80f9ae',1,'LBContainer']]], + ['lbfile',['LBFile',['../interface_l_b_file.html',1,'']]], + ['lbfile_2eh',['LBFile.h',['../_l_b_file_8h.html',1,'']]], + ['lbfiledownloadsuccessblock',['LBFileDownloadSuccessBlock',['../interface_l_b_file.html#a3604f45f4d4cf7f505a790bf8b100a7f',1,'LBFile']]], + ['lbfileuploadsuccessblock',['LBFileUploadSuccessBlock',['../interface_l_b_file.html#a5f6acf35d972e73f93146c3bd483e2dc',1,'LBFile']]], + ['lbinstallation',['LBInstallation',['../interface_l_b_installation.html',1,'']]], + ['lbinstallation_2eh',['LBInstallation.h',['../_l_b_installation_8h.html',1,'']]], + ['lbinstallationrepository',['LBInstallationRepository',['../interface_l_b_installation_repository.html',1,'']]], + ['lbmodel',['LBModel',['../interface_l_b_model.html',1,'']]], + ['lbmodel_2eh',['LBModel.h',['../_l_b_model_8h.html',1,'']]], + ['lbmodelallsuccessblock',['LBModelAllSuccessBlock',['../interface_l_b_model_repository.html#a26943bb32e29ba89d9628833d644728c',1,'LBModelRepository']]], + ['lbmodeldestroysuccessblock',['LBModelDestroySuccessBlock',['../interface_l_b_model.html#aeabd473b6f68263102a5f0527dd16710',1,'LBModel']]], + ['lbmodelfindsuccessblock',['LBModelFindSuccessBlock',['../interface_l_b_model_repository.html#a250f76b6c76addafa770cc9953f348a5',1,'LBModelRepository']]], + ['lbmodelrepository',['LBModelRepository',['../interface_l_b_model_repository.html',1,'']]], + ['lbmodelsavesuccessblock',['LBModelSaveSuccessBlock',['../interface_l_b_model.html#a2919b2129c1d860915092aaac8653404',1,'LBModel']]], + ['lbpushnotification',['LBPushNotification',['../interface_l_b_push_notification.html',1,'']]], + ['lbpushnotification_2eh',['LBPushNotification.h',['../_l_b_push_notification_8h.html',1,'']]], + ['lbpushnotificationtype',['LBPushNotificationType',['../_l_b_push_notification_8h.html#abf24b9a6c849237f086139da3ff5bcaa',1,'LBPushNotificationType(): LBPushNotification.h'],['../_l_b_push_notification_8h.html#af8b88d90b884226b009c52cc23e550a3',1,'LBPushNotificationType(): LBPushNotification.h']]], + ['lbrestadapter',['LBRESTAdapter',['../interface_l_b_r_e_s_t_adapter.html',1,'']]], + ['lbrestadapter_2eh',['LBRESTAdapter.h',['../_l_b_r_e_s_t_adapter_8h.html',1,'']]], + ['lbuser',['LBUser',['../interface_l_b_user.html',1,'']]], + ['lbuser_2eh',['LBUser.h',['../_l_b_user_8h.html',1,'']]], + ['loopback_2eh',['LoopBack.h',['../_loop_back_8h.html',1,'']]] ]; diff --git a/docs/html/search/all_8.js b/docs/html/search/all_8.js index c01c11a..8f6e986 100644 --- a/docs/html/search/all_8.js +++ b/docs/html/search/all_8.js @@ -1,19 +1,5 @@ var searchData= [ - ['lbinstallation',['LBInstallation',['../interface_l_b_installation.html',1,'']]], - ['lbinstallation_2eh',['LBInstallation.h',['../_l_b_installation_8h.html',1,'']]], - ['lbinstallationrepository',['LBInstallationRepository',['../interface_l_b_installation_repository.html',1,'']]], - ['lbmodel',['LBModel',['../interface_l_b_model.html',1,'']]], - ['lbmodel_2eh',['LBModel.h',['../_l_b_model_8h.html',1,'']]], - ['lbmodelallsuccessblock',['LBModelAllSuccessBlock',['../interface_l_b_model_repository.html#a26943bb32e29ba89d9628833d644728c',1,'LBModelRepository']]], - ['lbmodeldestroysuccessblock',['LBModelDestroySuccessBlock',['../interface_l_b_model.html#aeabd473b6f68263102a5f0527dd16710',1,'LBModel']]], - ['lbmodelfindsuccessblock',['LBModelFindSuccessBlock',['../interface_l_b_model_repository.html#a250f76b6c76addafa770cc9953f348a5',1,'LBModelRepository']]], - ['lbmodelrepository',['LBModelRepository',['../interface_l_b_model_repository.html',1,'']]], - ['lbmodelsavesuccessblock',['LBModelSaveSuccessBlock',['../interface_l_b_model.html#a2919b2129c1d860915092aaac8653404',1,'LBModel']]], - ['lbpushnotification',['LBPushNotification',['../interface_l_b_push_notification.html',1,'']]], - ['lbpushnotification_2eh',['LBPushNotification.h',['../_l_b_push_notification_8h.html',1,'']]], - ['lbpushnotificationtype',['LBPushNotificationType',['../_l_b_push_notification_8h.html#abf24b9a6c849237f086139da3ff5bcaa',1,'LBPushNotificationType(): LBPushNotification.h'],['../_l_b_push_notification_8h.html#af8b88d90b884226b009c52cc23e550a3',1,'LBPushNotificationType(): LBPushNotification.h']]], - ['lbrestadapter',['LBRESTAdapter',['../interface_l_b_r_e_s_t_adapter.html',1,'']]], - ['lbrestadapter_2eh',['LBRESTAdapter.h',['../_l_b_r_e_s_t_adapter_8h.html',1,'']]], - ['loopback_2eh',['LoopBack.h',['../_loop_back_8h.html',1,'']]] + ['modelclass',['modelClass',['../interface_l_b_model_repository.html#a4e8ad29527c96121e151ac890994a344',1,'LBModelRepository']]], + ['modelwithdictionary_3a',['modelWithDictionary:',['../interface_l_b_model_repository.html#a1e7721e2f0c429f1e6e2a3c983fb3339',1,'LBModelRepository']]] ]; diff --git a/docs/html/search/all_9.js b/docs/html/search/all_9.js index 8f6e986..394ced7 100644 --- a/docs/html/search/all_9.js +++ b/docs/html/search/all_9.js @@ -1,5 +1,4 @@ var searchData= [ - ['modelclass',['modelClass',['../interface_l_b_model_repository.html#a4e8ad29527c96121e151ac890994a344',1,'LBModelRepository']]], - ['modelwithdictionary_3a',['modelWithDictionary:',['../interface_l_b_model_repository.html#a1e7721e2f0c429f1e6e2a3c983fb3339',1,'LBModelRepository']]] + ['objectforkeyedsubscript_3a',['objectForKeyedSubscript:',['../interface_l_b_model.html#ab50d3fa3329577575a19110aaadd1b86',1,'LBModel']]] ]; diff --git a/docs/html/search/all_a.js b/docs/html/search/all_a.js index f28b8f8..abeb8d6 100644 --- a/docs/html/search/all_a.js +++ b/docs/html/search/all_a.js @@ -1,6 +1,8 @@ var searchData= [ - ['objectforkeyedsubscript_3a',['objectForKeyedSubscript:',['../interface_l_b_model.html#ab50d3fa3329577575a19110aaadd1b86',1,'LBModel']]], - ['objectwithparameters_3a',['objectWithParameters:',['../interface_s_l_repository.html#a459bcb7f443b09f723699730bf986543',1,'SLRepository']]], - ['objectwithrepository_3aparameters_3a',['objectWithRepository:parameters:',['../interface_s_l_object.html#ab383fbe486ee4a348869ed041f5abed5',1,'SLObject']]] + ['registerdevicewithadapter_3adevicetoken_3aregistrationid_3aappid_3aappversion_3auserid_3abadge_3asubscriptions_3asuccess_3afailure_3a',['registerDeviceWithAdapter:deviceToken:registrationId:appId:appVersion:userId:badge:subscriptions:success:failure:',['../interface_l_b_installation.html#a2bc99bced92a9bfbd8877f84f84feebd',1,'LBInstallation']]], + ['repository',['repository',['../interface_l_b_installation_repository.html#ab760762328203f50e8f4e6831de07094',1,'LBInstallationRepository']]], + ['repositorywithclass_3a',['repositoryWithClass:',['../interface_l_b_r_e_s_t_adapter.html#aaa22707ed4b5bf211827ed9c64cc2282',1,'LBRESTAdapter']]], + ['repositorywithmodelname_3a',['repositoryWithModelName:',['../interface_l_b_r_e_s_t_adapter.html#a7a8f5da791f6b67c42b51958c4cf2979',1,'LBRESTAdapter']]], + ['resetbadge_3a',['resetBadge:',['../interface_l_b_push_notification.html#a769dca49181442507694494f7126c057',1,'LBPushNotification']]] ]; diff --git a/docs/html/search/all_b.js b/docs/html/search/all_b.js index 7b1a133..e08067c 100644 --- a/docs/html/search/all_b.js +++ b/docs/html/search/all_b.js @@ -1,5 +1,7 @@ var searchData= [ - ['pattern',['pattern',['../interface_s_l_r_e_s_t_contract_item.html#a27d498f65b5061f808670fe988426117',1,'SLRESTContractItem']]], - ['patternformethod_3a',['patternForMethod:',['../interface_s_l_r_e_s_t_contract.html#a612649b0a4dcca206c38b3caa2598569',1,'SLRESTContract']]] + ['savewithsuccess_3afailure_3a',['saveWithSuccess:failure:',['../interface_l_b_model.html#a8078bba4859631207bd479523abafab8',1,'LBModel']]], + ['setobject_3aforkeyedsubscript_3a',['setObject:forKeyedSubscript:',['../interface_l_b_model.html#a2814cc9dd27ded4ddaa850635beb62d3',1,'LBModel']]], + ['status',['status',['../interface_l_b_installation.html#ac3b264e7d53e11f8b1ef8c76b987bd9c',1,'LBInstallation']]], + ['subscriptions',['subscriptions',['../interface_l_b_installation.html#ae282f22550f632fb28d5176b41bda3de',1,'LBInstallation']]] ]; diff --git a/docs/html/search/all_c.js b/docs/html/search/all_c.js index 0d3321f..175d6fd 100644 --- a/docs/html/search/all_c.js +++ b/docs/html/search/all_c.js @@ -1,9 +1,7 @@ var searchData= [ - ['registerdevicewithadapter_3adevicetoken_3aregistrationid_3aappid_3aappversion_3auserid_3abadge_3asubscriptions_3asuccess_3afailure_3a',['registerDeviceWithAdapter:deviceToken:registrationId:appId:appVersion:userId:badge:subscriptions:success:failure:',['../interface_l_b_installation.html#a2bc99bced92a9bfbd8877f84f84feebd',1,'LBInstallation']]], - ['repository',['repository',['../interface_s_l_object.html#a3dbcb5c6229ba41568990d25f0c0b7b6',1,'SLObject::repository()'],['../interface_l_b_installation_repository.html#ab760762328203f50e8f4e6831de07094',1,'LBInstallationRepository::repository()']]], - ['repositorywithclass_3a',['repositoryWithClass:',['../interface_l_b_r_e_s_t_adapter.html#aaa22707ed4b5bf211827ed9c64cc2282',1,'LBRESTAdapter']]], - ['repositorywithclassname_3a',['repositoryWithClassName:',['../interface_s_l_repository.html#a45a90e030effe9dd8c54ed9c968e441d',1,'SLRepository']]], - ['repositorywithmodelname_3a',['repositoryWithModelName:',['../interface_l_b_r_e_s_t_adapter.html#a7a8f5da791f6b67c42b51958c4cf2979',1,'LBRESTAdapter']]], - ['resetbadge_3a',['resetBadge:',['../interface_l_b_push_notification.html#a769dca49181442507694494f7126c057',1,'LBPushNotification']]] + ['terminated',['Terminated',['../_l_b_push_notification_8h.html#abf24b9a6c849237f086139da3ff5bcaaa0bd9962868a464e4730ffcf8d3fa798d',1,'LBPushNotification.h']]], + ['timezone',['timeZone',['../interface_l_b_installation.html#a62152081d6d74b9fcb8477739b2ecc3a',1,'LBInstallation']]], + ['todictionary',['toDictionary',['../interface_l_b_model.html#a99e522f6b5c62ba2da250347586ea311',1,'LBModel']]], + ['type',['type',['../interface_l_b_push_notification.html#afc386fb3f552180335501ff587aec70b',1,'LBPushNotification']]] ]; diff --git a/docs/html/search/all_d.js b/docs/html/search/all_d.js index 3552228..9c0bbf2 100644 --- a/docs/html/search/all_d.js +++ b/docs/html/search/all_d.js @@ -1,25 +1,6 @@ var searchData= [ - ['savewithsuccess_3afailure_3a',['saveWithSuccess:failure:',['../interface_l_b_model.html#a8078bba4859631207bd479523abafab8',1,'LBModel']]], - ['setobject_3aforkeyedsubscript_3a',['setObject:forKeyedSubscript:',['../interface_l_b_model.html#a2814cc9dd27ded4ddaa850635beb62d3',1,'LBModel']]], - ['sladapter',['SLAdapter',['../interface_s_l_adapter.html',1,'']]], - ['sladapter_2eh',['SLAdapter.h',['../_s_l_adapter_8h.html',1,'']]], - ['sladapternotconnectederrordescription',['SLAdapterNotConnectedErrorDescription',['../_s_l_adapter_8h.html#a2c9fcfaf591c3c2dd8c8f6d84ab31208',1,'SLAdapter.h']]], - ['slfailureblock',['SLFailureBlock',['../_s_l_adapter_8h.html#a420607c4e242df077c5aadaf2ac9c523',1,'SLAdapter.h']]], - ['slobject',['SLObject',['../interface_s_l_object.html',1,'']]], - ['slobject_2eh',['SLObject.h',['../_s_l_object_8h.html',1,'']]], - ['slobjectinvalidrepositorydescription',['SLObjectInvalidRepositoryDescription',['../_s_l_object_8h.html#ae4fd8a38cd98b526acdc255095f3a578',1,'SLObject.h']]], - ['slremoting_2eh',['SLRemoting.h',['../_s_l_remoting_8h.html',1,'']]], - ['slremotingutils',['SLRemotingUtils',['../interface_s_l_remoting_utils.html',1,'']]], - ['slremotingutils_2eh',['SLRemotingUtils.h',['../_s_l_remoting_utils_8h.html',1,'']]], - ['slrepository',['SLRepository',['../interface_s_l_repository.html',1,'']]], - ['slrestadapter',['SLRESTAdapter',['../interface_s_l_r_e_s_t_adapter.html',1,'']]], - ['slrestadapter_2eh',['SLRESTAdapter.h',['../_s_l_r_e_s_t_adapter_8h.html',1,'']]], - ['slrestcontract',['SLRESTContract',['../interface_s_l_r_e_s_t_contract.html',1,'']]], - ['slrestcontract_2eh',['SLRESTContract.h',['../_s_l_r_e_s_t_contract_8h.html',1,'']]], - ['slrestcontractdefaultverb',['SLRESTContractDefaultVerb',['../_s_l_r_e_s_t_contract_8h.html#a125ea05f073d19cd2036d791aa3c3dcf',1,'SLRESTContract.h']]], - ['slrestcontractitem',['SLRESTContractItem',['../interface_s_l_r_e_s_t_contract_item.html',1,'']]], - ['slsuccessblock',['SLSuccessBlock',['../_s_l_adapter_8h.html#a58c5ad97ebd52e3365bf16c81e10a932',1,'SLAdapter.h']]], - ['status',['status',['../interface_l_b_installation.html#ac3b264e7d53e11f8b1ef8c76b987bd9c',1,'LBInstallation']]], - ['subscriptions',['subscriptions',['../interface_l_b_installation.html#ae282f22550f632fb28d5176b41bda3de',1,'LBInstallation']]] + ['uploadwithsuccess_3afailure_3a',['uploadWithSuccess:failure:',['../interface_l_b_file.html#a51b03712514bf28f9df7959f71c652d0',1,'LBFile']]], + ['userid',['userId',['../interface_l_b_access_token.html#a7751264828fc7366ebf669d8d690492e',1,'LBAccessToken::userId()'],['../interface_l_b_installation.html#adf48cbcd8df0eb9f51f555acde16090e',1,'LBInstallation::userId()']]], + ['userinfo',['userInfo',['../interface_l_b_push_notification.html#aeee830f8c8e526bcece046620a72099b',1,'LBPushNotification']]] ]; diff --git a/docs/html/search/classes_0.js b/docs/html/search/classes_0.js index 4ee832a..277bbb0 100644 --- a/docs/html/search/classes_0.js +++ b/docs/html/search/classes_0.js @@ -1,9 +1,13 @@ var searchData= [ + ['lbaccesstoken',['LBAccessToken',['../interface_l_b_access_token.html',1,'']]], + ['lbcontainer',['LBContainer',['../interface_l_b_container.html',1,'']]], + ['lbfile',['LBFile',['../interface_l_b_file.html',1,'']]], ['lbinstallation',['LBInstallation',['../interface_l_b_installation.html',1,'']]], ['lbinstallationrepository',['LBInstallationRepository',['../interface_l_b_installation_repository.html',1,'']]], ['lbmodel',['LBModel',['../interface_l_b_model.html',1,'']]], ['lbmodelrepository',['LBModelRepository',['../interface_l_b_model_repository.html',1,'']]], ['lbpushnotification',['LBPushNotification',['../interface_l_b_push_notification.html',1,'']]], - ['lbrestadapter',['LBRESTAdapter',['../interface_l_b_r_e_s_t_adapter.html',1,'']]] + ['lbrestadapter',['LBRESTAdapter',['../interface_l_b_r_e_s_t_adapter.html',1,'']]], + ['lbuser',['LBUser',['../interface_l_b_user.html',1,'']]] ]; diff --git a/docs/html/search/files_0.js b/docs/html/search/files_0.js index eedb26a..12ab819 100644 --- a/docs/html/search/files_0.js +++ b/docs/html/search/files_0.js @@ -1,8 +1,12 @@ var searchData= [ + ['lbaccesstoken_2eh',['LBAccessToken.h',['../_l_b_access_token_8h.html',1,'']]], + ['lbcontainer_2eh',['LBContainer.h',['../_l_b_container_8h.html',1,'']]], + ['lbfile_2eh',['LBFile.h',['../_l_b_file_8h.html',1,'']]], ['lbinstallation_2eh',['LBInstallation.h',['../_l_b_installation_8h.html',1,'']]], ['lbmodel_2eh',['LBModel.h',['../_l_b_model_8h.html',1,'']]], ['lbpushnotification_2eh',['LBPushNotification.h',['../_l_b_push_notification_8h.html',1,'']]], ['lbrestadapter_2eh',['LBRESTAdapter.h',['../_l_b_r_e_s_t_adapter_8h.html',1,'']]], + ['lbuser_2eh',['LBUser.h',['../_l_b_user_8h.html',1,'']]], ['loopback_2eh',['LoopBack.h',['../_loop_back_8h.html',1,'']]] ]; diff --git a/docs/html/search/functions_0.js b/docs/html/search/functions_0.js index 6f02adb..71f195e 100644 --- a/docs/html/search/functions_0.js +++ b/docs/html/search/functions_0.js @@ -1,9 +1,5 @@ var searchData= [ - ['adapter',['adapter',['../interface_s_l_adapter.html#a5a7195ff8d9ffa5a314a44e75791da97',1,'SLAdapter']]], - ['adapterwithurl_3a',['adapterWithURL:',['../interface_s_l_adapter.html#abbdfbfe0048dd0cfa7976c0060d81232',1,'SLAdapter']]], - ['additem_3aformethod_3a',['addItem:forMethod:',['../interface_s_l_r_e_s_t_contract.html#a7452533bf3aa40778e1b84fdacd92da1',1,'SLRESTContract']]], - ['additemsfromcontract_3a',['addItemsFromContract:',['../interface_s_l_r_e_s_t_contract.html#a86c6af82b8ccebfe5fd9b779b6621d66',1,'SLRESTContract']]], ['allwithsuccess_3afailure_3a',['allWithSuccess:failure:',['../interface_l_b_model_repository.html#ac97a68ff8076ae8591b21e9692e94086',1,'LBModelRepository']]], ['application_3adidfailtoregisterforremotenotificationswitherror_3a',['application:didFailToRegisterForRemoteNotificationsWithError:',['../interface_l_b_push_notification.html#a1f6fbd35aea75f014b67f70ad2775311',1,'LBPushNotification']]], ['application_3adidfinishlaunchingwithoptions_3a',['application:didFinishLaunchingWithOptions:',['../interface_l_b_push_notification.html#a253654a9f5424905c010c5a0e5e542d1',1,'LBPushNotification']]], diff --git a/docs/html/search/functions_1.js b/docs/html/search/functions_1.js index d01ea4d..725bb54 100644 --- a/docs/html/search/functions_1.js +++ b/docs/html/search/functions_1.js @@ -1,5 +1,4 @@ var searchData= [ - ['connecttourl_3a',['connectToURL:',['../interface_s_l_adapter.html#ae89d78e1ed21a3c73b5343ef8778ae0c',1,'SLAdapter']]], - ['contract',['contract',['../interface_l_b_model_repository.html#a1c1f7782220149be3fb7b2ff2bb53f73',1,'LBModelRepository::contract()'],['../interface_s_l_r_e_s_t_contract.html#aad097113d9a25a1d0fc09e5f70b4eea9',1,'SLRESTContract::contract()']]] + ['contract',['contract',['../interface_l_b_model_repository.html#a1c1f7782220149be3fb7b2ff2bb53f73',1,'LBModelRepository']]] ]; diff --git a/docs/html/search/functions_2.js b/docs/html/search/functions_2.js index 21894e1..9650adc 100644 --- a/docs/html/search/functions_2.js +++ b/docs/html/search/functions_2.js @@ -1,5 +1,7 @@ var searchData= [ + ['deletewithsuccess_3afailure_3a',['deleteWithSuccess:failure:',['../interface_l_b_container.html#a5e30c11b50fccdf95f8539f717445d67',1,'LBContainer']]], ['destroywithsuccess_3afailure_3a',['destroyWithSuccess:failure:',['../interface_l_b_model.html#a85cb42b9c3094ea8363bf942ce95d7b8',1,'LBModel']]], - ['devicetokenwithdata_3a',['deviceTokenWithData:',['../interface_l_b_installation.html#a39340936d48bfc17852b44fcc6e733cd',1,'LBInstallation']]] + ['devicetokenwithdata_3a',['deviceTokenWithData:',['../interface_l_b_installation.html#a39340936d48bfc17852b44fcc6e733cd',1,'LBInstallation']]], + ['downloadwithsuccess_3afailure_3a',['downloadWithSuccess:failure:',['../interface_l_b_file.html#a5109f2ba85b8d515a234af379b0dc562',1,'LBFile']]] ]; diff --git a/docs/html/search/functions_4.js b/docs/html/search/functions_4.js index b9b13b2..507ef92 100644 --- a/docs/html/search/functions_4.js +++ b/docs/html/search/functions_4.js @@ -1,4 +1,5 @@ var searchData= [ - ['getbadge',['getBadge',['../interface_l_b_push_notification.html#a49310f547e5618d61323720e7b3e03fc',1,'LBPushNotification']]] + ['getbadge',['getBadge',['../interface_l_b_push_notification.html#a49310f547e5618d61323720e7b3e03fc',1,'LBPushNotification']]], + ['getfilewithname_3alocalpath_3asuccess_3afailure_3a',['getFileWithName:localPath:success:failure:',['../interface_l_b_container.html#ad2149181e23df726b70dbb1dd3131052',1,'LBContainer']]] ]; diff --git a/docs/html/search/functions_5.js b/docs/html/search/functions_5.js index f7c49c7..91b0d1d 100644 --- a/docs/html/search/functions_5.js +++ b/docs/html/search/functions_5.js @@ -1,13 +1,4 @@ var searchData= [ - ['initwithclassname_3a',['initWithClassName:',['../interface_s_l_repository.html#a3ba5a7eecaf4e42734b69c8efcc4a313',1,'SLRepository']]], - ['initwithpattern_3a',['initWithPattern:',['../interface_s_l_r_e_s_t_contract_item.html#a5867aae81da3b32604869134b2133783',1,'SLRESTContractItem']]], - ['initwithpattern_3averb_3a',['initWithPattern:verb:',['../interface_s_l_r_e_s_t_contract_item.html#a906e0d38d2d68fd70b77639004c1bcb8',1,'SLRESTContractItem']]], - ['initwithrepository_3aparameters_3a',['initWithRepository:parameters:',['../interface_s_l_object.html#a368b1c26aba0b047d29b20bf3d6ebd19',1,'SLObject']]], - ['initwithurl_3a',['initWithURL:',['../interface_s_l_adapter.html#a772aa56022d1c63052a3b86ae8f43064',1,'SLAdapter']]], - ['invokeinstancemethod_3aconstructorparameters_3aparameters_3asuccess_3afailure_3a',['invokeInstanceMethod:constructorParameters:parameters:success:failure:',['../interface_s_l_adapter.html#ad4813db06f471724e13b704520f021c1',1,'SLAdapter']]], - ['invokemethod_3aparameters_3asuccess_3afailure_3a',['invokeMethod:parameters:success:failure:',['../interface_s_l_object.html#a6f761bfca92d63028d46897baee6e542',1,'SLObject']]], - ['invokestaticmethod_3aparameters_3asuccess_3afailure_3a',['invokeStaticMethod:parameters:success:failure:',['../interface_s_l_adapter.html#a1f6b9753c341b13576cb5226fe9d8bb4',1,'SLAdapter::invokeStaticMethod:parameters:success:failure:()'],['../interface_s_l_repository.html#abb889a06c1392062fae3e4123ac3825f',1,'SLRepository::invokeStaticMethod:parameters:success:failure:()']]], - ['itemwithpattern_3a',['itemWithPattern:',['../interface_s_l_r_e_s_t_contract_item.html#a8a5f2e08d3369a1997ec166bb02a188d',1,'SLRESTContractItem']]], - ['itemwithpattern_3averb_3a',['itemWithPattern:verb:',['../interface_s_l_r_e_s_t_contract_item.html#a1b824e5c31215d5741f077fb970a4712',1,'SLRESTContractItem']]] + ['modelwithdictionary_3a',['modelWithDictionary:',['../interface_l_b_model_repository.html#a1e7721e2f0c429f1e6e2a3c983fb3339',1,'LBModelRepository']]] ]; diff --git a/docs/html/search/functions_6.js b/docs/html/search/functions_6.js index 91b0d1d..394ced7 100644 --- a/docs/html/search/functions_6.js +++ b/docs/html/search/functions_6.js @@ -1,4 +1,4 @@ var searchData= [ - ['modelwithdictionary_3a',['modelWithDictionary:',['../interface_l_b_model_repository.html#a1e7721e2f0c429f1e6e2a3c983fb3339',1,'LBModelRepository']]] + ['objectforkeyedsubscript_3a',['objectForKeyedSubscript:',['../interface_l_b_model.html#ab50d3fa3329577575a19110aaadd1b86',1,'LBModel']]] ]; diff --git a/docs/html/search/functions_7.js b/docs/html/search/functions_7.js index f28b8f8..abeb8d6 100644 --- a/docs/html/search/functions_7.js +++ b/docs/html/search/functions_7.js @@ -1,6 +1,8 @@ var searchData= [ - ['objectforkeyedsubscript_3a',['objectForKeyedSubscript:',['../interface_l_b_model.html#ab50d3fa3329577575a19110aaadd1b86',1,'LBModel']]], - ['objectwithparameters_3a',['objectWithParameters:',['../interface_s_l_repository.html#a459bcb7f443b09f723699730bf986543',1,'SLRepository']]], - ['objectwithrepository_3aparameters_3a',['objectWithRepository:parameters:',['../interface_s_l_object.html#ab383fbe486ee4a348869ed041f5abed5',1,'SLObject']]] + ['registerdevicewithadapter_3adevicetoken_3aregistrationid_3aappid_3aappversion_3auserid_3abadge_3asubscriptions_3asuccess_3afailure_3a',['registerDeviceWithAdapter:deviceToken:registrationId:appId:appVersion:userId:badge:subscriptions:success:failure:',['../interface_l_b_installation.html#a2bc99bced92a9bfbd8877f84f84feebd',1,'LBInstallation']]], + ['repository',['repository',['../interface_l_b_installation_repository.html#ab760762328203f50e8f4e6831de07094',1,'LBInstallationRepository']]], + ['repositorywithclass_3a',['repositoryWithClass:',['../interface_l_b_r_e_s_t_adapter.html#aaa22707ed4b5bf211827ed9c64cc2282',1,'LBRESTAdapter']]], + ['repositorywithmodelname_3a',['repositoryWithModelName:',['../interface_l_b_r_e_s_t_adapter.html#a7a8f5da791f6b67c42b51958c4cf2979',1,'LBRESTAdapter']]], + ['resetbadge_3a',['resetBadge:',['../interface_l_b_push_notification.html#a769dca49181442507694494f7126c057',1,'LBPushNotification']]] ]; diff --git a/docs/html/search/functions_8.js b/docs/html/search/functions_8.js index 86a875e..2447e12 100644 --- a/docs/html/search/functions_8.js +++ b/docs/html/search/functions_8.js @@ -1,4 +1,5 @@ var searchData= [ - ['patternformethod_3a',['patternForMethod:',['../interface_s_l_r_e_s_t_contract.html#a612649b0a4dcca206c38b3caa2598569',1,'SLRESTContract']]] + ['savewithsuccess_3afailure_3a',['saveWithSuccess:failure:',['../interface_l_b_model.html#a8078bba4859631207bd479523abafab8',1,'LBModel']]], + ['setobject_3aforkeyedsubscript_3a',['setObject:forKeyedSubscript:',['../interface_l_b_model.html#a2814cc9dd27ded4ddaa850635beb62d3',1,'LBModel']]] ]; diff --git a/docs/html/search/functions_9.js b/docs/html/search/functions_9.js index ac0532f..4a1e6fd 100644 --- a/docs/html/search/functions_9.js +++ b/docs/html/search/functions_9.js @@ -1,9 +1,4 @@ var searchData= [ - ['registerdevicewithadapter_3adevicetoken_3aregistrationid_3aappid_3aappversion_3auserid_3abadge_3asubscriptions_3asuccess_3afailure_3a',['registerDeviceWithAdapter:deviceToken:registrationId:appId:appVersion:userId:badge:subscriptions:success:failure:',['../interface_l_b_installation.html#a2bc99bced92a9bfbd8877f84f84feebd',1,'LBInstallation']]], - ['repository',['repository',['../interface_l_b_installation_repository.html#ab760762328203f50e8f4e6831de07094',1,'LBInstallationRepository']]], - ['repositorywithclass_3a',['repositoryWithClass:',['../interface_l_b_r_e_s_t_adapter.html#aaa22707ed4b5bf211827ed9c64cc2282',1,'LBRESTAdapter']]], - ['repositorywithclassname_3a',['repositoryWithClassName:',['../interface_s_l_repository.html#a45a90e030effe9dd8c54ed9c968e441d',1,'SLRepository']]], - ['repositorywithmodelname_3a',['repositoryWithModelName:',['../interface_l_b_r_e_s_t_adapter.html#a7a8f5da791f6b67c42b51958c4cf2979',1,'LBRESTAdapter']]], - ['resetbadge_3a',['resetBadge:',['../interface_l_b_push_notification.html#a769dca49181442507694494f7126c057',1,'LBPushNotification']]] + ['todictionary',['toDictionary',['../interface_l_b_model.html#a99e522f6b5c62ba2da250347586ea311',1,'LBModel']]] ]; diff --git a/docs/html/search/functions_a.js b/docs/html/search/functions_a.js index 2447e12..99cf38a 100644 --- a/docs/html/search/functions_a.js +++ b/docs/html/search/functions_a.js @@ -1,5 +1,4 @@ var searchData= [ - ['savewithsuccess_3afailure_3a',['saveWithSuccess:failure:',['../interface_l_b_model.html#a8078bba4859631207bd479523abafab8',1,'LBModel']]], - ['setobject_3aforkeyedsubscript_3a',['setObject:forKeyedSubscript:',['../interface_l_b_model.html#a2814cc9dd27ded4ddaa850635beb62d3',1,'LBModel']]] + ['uploadwithsuccess_3afailure_3a',['uploadWithSuccess:failure:',['../interface_l_b_file.html#a51b03712514bf28f9df7959f71c652d0',1,'LBFile']]] ]; diff --git a/docs/html/search/properties_1.js b/docs/html/search/properties_1.js index 7124396..46003ba 100644 --- a/docs/html/search/properties_1.js +++ b/docs/html/search/properties_1.js @@ -1,6 +1,5 @@ var searchData= [ - ['adapter',['adapter',['../interface_s_l_repository.html#ab80405fac6612b5866f70201621ed377',1,'SLRepository']]], ['appid',['appId',['../interface_l_b_installation.html#a021bab35bc71b7f715508c00992b170a',1,'LBInstallation']]], ['appversion',['appVersion',['../interface_l_b_installation.html#a5c58df6b4f19c0c4a3f5c969eb7b03c2',1,'LBInstallation']]] ]; diff --git a/docs/html/search/properties_3.js b/docs/html/search/properties_3.js index 0bd42b4..e4bd5fa 100644 --- a/docs/html/search/properties_3.js +++ b/docs/html/search/properties_3.js @@ -1,7 +1,5 @@ var searchData= [ - ['classname',['className',['../interface_s_l_repository.html#a20568756d6fb3c9dddc5e359f14488dd',1,'SLRepository']]], - ['connected',['connected',['../interface_s_l_adapter.html#aa59b74a90d17cae71c63da74d8431119',1,'SLAdapter']]], - ['contract',['contract',['../interface_s_l_r_e_s_t_adapter.html#aefe945e1e8e062ce0c061598d999cccf',1,'SLRESTAdapter']]], - ['creationparameters',['creationParameters',['../interface_s_l_object.html#a4187295e29e1fc2859be401525a4ae87',1,'SLObject']]] + ['devicetoken',['deviceToken',['../interface_l_b_installation.html#adb690dc224650d3d5f3c50d8154efbdb',1,'LBInstallation']]], + ['devicetype',['deviceType',['../interface_l_b_installation.html#a9fdec8099a814ad3cce4e89a6685ab0f',1,'LBInstallation']]] ]; diff --git a/docs/html/search/properties_4.js b/docs/html/search/properties_4.js index 2098425..dcfd353 100644 --- a/docs/html/search/properties_4.js +++ b/docs/html/search/properties_4.js @@ -1,6 +1,4 @@ var searchData= [ - ['devicetoken',['deviceToken',['../interface_l_b_installation.html#adb690dc224650d3d5f3c50d8154efbdb',1,'LBInstallation']]], - ['devicetype',['deviceType',['../interface_l_b_installation.html#a9fdec8099a814ad3cce4e89a6685ab0f',1,'LBInstallation']]], - ['dict',['dict',['../interface_s_l_r_e_s_t_contract.html#afa9fc6f1bfabfe7026ef9f0dddc6f592',1,'SLRESTContract']]] + ['modelclass',['modelClass',['../interface_l_b_model_repository.html#a4e8ad29527c96121e151ac890994a344',1,'LBModelRepository']]] ]; diff --git a/docs/html/search/properties_5.js b/docs/html/search/properties_5.js index dcfd353..db59546 100644 --- a/docs/html/search/properties_5.js +++ b/docs/html/search/properties_5.js @@ -1,4 +1,5 @@ var searchData= [ - ['modelclass',['modelClass',['../interface_l_b_model_repository.html#a4e8ad29527c96121e151ac890994a344',1,'LBModelRepository']]] + ['status',['status',['../interface_l_b_installation.html#ac3b264e7d53e11f8b1ef8c76b987bd9c',1,'LBInstallation']]], + ['subscriptions',['subscriptions',['../interface_l_b_installation.html#ae282f22550f632fb28d5176b41bda3de',1,'LBInstallation']]] ]; diff --git a/docs/html/search/properties_6.js b/docs/html/search/properties_6.js index 6ba40fe..678168f 100644 --- a/docs/html/search/properties_6.js +++ b/docs/html/search/properties_6.js @@ -1,4 +1,5 @@ var searchData= [ - ['pattern',['pattern',['../interface_s_l_r_e_s_t_contract_item.html#a27d498f65b5061f808670fe988426117',1,'SLRESTContractItem']]] + ['timezone',['timeZone',['../interface_l_b_installation.html#a62152081d6d74b9fcb8477739b2ecc3a',1,'LBInstallation']]], + ['type',['type',['../interface_l_b_push_notification.html#afc386fb3f552180335501ff587aec70b',1,'LBPushNotification']]] ]; diff --git a/docs/html/search/properties_7.js b/docs/html/search/properties_7.js index 8426b74..77e3d46 100644 --- a/docs/html/search/properties_7.js +++ b/docs/html/search/properties_7.js @@ -1,4 +1,5 @@ var searchData= [ - ['repository',['repository',['../interface_s_l_object.html#a3dbcb5c6229ba41568990d25f0c0b7b6',1,'SLObject']]] + ['userid',['userId',['../interface_l_b_access_token.html#a7751264828fc7366ebf669d8d690492e',1,'LBAccessToken::userId()'],['../interface_l_b_installation.html#adf48cbcd8df0eb9f51f555acde16090e',1,'LBInstallation::userId()']]], + ['userinfo',['userInfo',['../interface_l_b_push_notification.html#aeee830f8c8e526bcece046620a72099b',1,'LBPushNotification']]] ]; diff --git a/docs/html/search/search.js b/docs/html/search/search.js index 7d26273..8063610 100644 --- a/docs/html/search/search.js +++ b/docs/html/search/search.js @@ -7,16 +7,14 @@ var indexSectionsWithContent = { - 0: "_abcdfgilmoprstuv", - 1: "ls", - 2: "ls", - 3: "acdfgimoprstuv", - 4: "s", - 5: "ls", - 6: "l", - 7: "bft", - 8: "_abcdmprstuv", - 9: "a" + 0: "_abcdfglmorstu", + 1: "l", + 2: "l", + 3: "acdfgmorstu", + 4: "l", + 5: "l", + 6: "bft", + 7: "_abdmstu" }; var indexSectionNames = @@ -25,12 +23,10 @@ var indexSectionNames = 1: "classes", 2: "files", 3: "functions", - 4: "variables", - 5: "typedefs", - 6: "enums", - 7: "enumvalues", - 8: "properties", - 9: "defines" + 4: "typedefs", + 5: "enums", + 6: "enumvalues", + 7: "properties" }; function convertToId(search) diff --git a/docs/html/search/typedefs_0.js b/docs/html/search/typedefs_0.js index 63bfdd2..c057707 100644 --- a/docs/html/search/typedefs_0.js +++ b/docs/html/search/typedefs_0.js @@ -1,5 +1,8 @@ var searchData= [ + ['lbcontainerdeletesuccessblock',['LBContainerDeleteSuccessBlock',['../interface_l_b_container.html#a77d55b2d0ff38f75c7a63c91bd80f9ae',1,'LBContainer']]], + ['lbfiledownloadsuccessblock',['LBFileDownloadSuccessBlock',['../interface_l_b_file.html#a3604f45f4d4cf7f505a790bf8b100a7f',1,'LBFile']]], + ['lbfileuploadsuccessblock',['LBFileUploadSuccessBlock',['../interface_l_b_file.html#a5f6acf35d972e73f93146c3bd483e2dc',1,'LBFile']]], ['lbmodelallsuccessblock',['LBModelAllSuccessBlock',['../interface_l_b_model_repository.html#a26943bb32e29ba89d9628833d644728c',1,'LBModelRepository']]], ['lbmodeldestroysuccessblock',['LBModelDestroySuccessBlock',['../interface_l_b_model.html#aeabd473b6f68263102a5f0527dd16710',1,'LBModel']]], ['lbmodelfindsuccessblock',['LBModelFindSuccessBlock',['../interface_l_b_model_repository.html#a250f76b6c76addafa770cc9953f348a5',1,'LBModelRepository']]],